├── README.md
├── css
├── font-awesome.css
└── style.css
├── fonts
├── FontAwesome.otf
├── droid
│ ├── NOTICE
│ ├── README.txt
│ ├── droid_sans_bold.typeface.js
│ ├── droid_sans_mono_regular.typeface.js
│ ├── droid_sans_regular.typeface.js
│ ├── droid_serif_bold.typeface.js
│ └── droid_serif_regular.typeface.js
├── fontawesome-webfont.eot
├── fontawesome-webfont.svg
├── fontawesome-webfont.ttf
├── fontawesome-webfont.woff
├── fontawesome-webfont.woff2
├── gentilis_bold.typeface.js
├── gentilis_regular.typeface.js
├── helvetiker_bold.typeface.js
├── helvetiker_regular.typeface.js
├── optimer_bold.typeface.js
└── optimer_regular.typeface.js
├── index.html
├── js
├── ControlsHandler.js
├── Explosion.js
├── FXHandler.js
├── Generator.js
├── Main.js
├── NavHandler.js
├── VizHandler.js
├── lib
│ ├── Detector.js
│ ├── FastBlur.js
│ ├── Helvetiker.js
│ ├── MarchingSquares.js
│ ├── Mirror.js
│ ├── OBJExporter.js
│ ├── OBJExporterAsync.js
│ ├── OBJLoader.js
│ ├── SimplexNoise.js
│ ├── Tween.js
│ ├── TweenMax.min.js
│ ├── VREffect.js
│ ├── VREffect_org.js
│ ├── ViveController.js
│ ├── WaterShader.js
│ ├── WebVR.js
│ ├── atutil.js
│ ├── bas.js
│ ├── controls
│ │ ├── DeviceOrientationControls.js
│ │ ├── DragControls.js
│ │ ├── EditorControls.js
│ │ ├── FirstPersonControls.js
│ │ ├── FlyControls.js
│ │ ├── MouseControls.js
│ │ ├── OrbitControls.js
│ │ ├── OrthographicTrackballControls.js
│ │ ├── PointerLockControls.js
│ │ ├── TrackballControls.js
│ │ ├── TransformControls.js
│ │ └── VRControls.js
│ ├── dat.gui.min.js
│ ├── gsap
│ │ ├── TimelineLite.min.js
│ │ ├── TimelineMax.min.js
│ │ ├── TweenLite.min.js
│ │ ├── TweenMax.min.js
│ │ ├── easing
│ │ │ └── EasePack.min.js
│ │ ├── jquery.gsap.min.js
│ │ ├── plugins
│ │ │ ├── AttrPlugin.min.js
│ │ │ ├── BezierPlugin.min.js
│ │ │ ├── CSSPlugin.min.js
│ │ │ ├── CSSRulePlugin.min.js
│ │ │ ├── ColorPropsPlugin.min.js
│ │ │ ├── DirectionalRotationPlugin.min.js
│ │ │ ├── EaselPlugin.min.js
│ │ │ ├── KineticPlugin.min.js
│ │ │ ├── RaphaelPlugin.min.js
│ │ │ ├── RoundPropsPlugin.min.js
│ │ │ ├── ScrollToPlugin.min.js
│ │ │ └── TextPlugin.min.js
│ │ └── utils
│ │ │ └── Draggable.min.js
│ ├── isMobile.js
│ ├── jquery-2.2.4.min.js
│ ├── loaders
│ │ ├── 3MFLoader.js
│ │ ├── AMFLoader.js
│ │ ├── AWDLoader.js
│ │ ├── AssimpJSONLoader.js
│ │ ├── BabylonLoader.js
│ │ ├── BinaryLoader.js
│ │ ├── ColladaLoader.js
│ │ ├── ColladaLoader2.js
│ │ ├── DDSLoader.js
│ │ ├── FBXLoader.js
│ │ ├── HDRCubeTextureLoader.js
│ │ ├── KMZLoader.js
│ │ ├── MD2Loader.js
│ │ ├── MMDLoader.js
│ │ ├── MTLLoader.js
│ │ ├── NRRDLoader.js
│ │ ├── OBJLoader.js
│ │ ├── PCDLoader.js
│ │ ├── PDBLoader.js
│ │ ├── PLYLoader.js
│ │ ├── PVRLoader.js
│ │ ├── PlayCanvasLoader.js
│ │ ├── RGBELoader.js
│ │ ├── STLLoader.js
│ │ ├── SVGLoader.js
│ │ ├── TGALoader.js
│ │ ├── UTF8Loader.js
│ │ ├── VRMLLoader.js
│ │ ├── VTKLoader.js
│ │ ├── collada
│ │ │ ├── Animation.js
│ │ │ ├── AnimationHandler.js
│ │ │ └── KeyFrameAnimation.js
│ │ ├── ctm
│ │ │ ├── CTMLoader.js
│ │ │ ├── CTMWorker.js
│ │ │ ├── ctm.js
│ │ │ ├── license
│ │ │ │ ├── OpenCTM.txt
│ │ │ │ ├── js-lzma.txt
│ │ │ │ └── js-openctm.txt
│ │ │ └── lzma.js
│ │ ├── deprecated
│ │ │ └── SceneLoader.js
│ │ ├── gltf
│ │ │ ├── glTF-parser.js
│ │ │ ├── glTFAnimation.js
│ │ │ ├── glTFLoader.js
│ │ │ ├── glTFLoaderUtils.js
│ │ │ ├── glTFShaders.js
│ │ │ └── gltfUtilities.js
│ │ └── sea3d
│ │ │ ├── SEA3D.js
│ │ │ ├── SEA3DDeflate.js
│ │ │ ├── SEA3DLZMA.js
│ │ │ ├── SEA3DLegacy.js
│ │ │ └── SEA3DLoader.js
│ ├── minivents.min.js
│ ├── modifiers
│ │ ├── BufferSubdivisionModifier.js
│ │ └── TessellateModifier.js
│ ├── pnltri.min.js
│ ├── postprocessing
│ │ ├── AdaptiveToneMappingPass.js
│ │ ├── BloomPass.js
│ │ ├── BokehPass.js
│ │ ├── ClearPass.js
│ │ ├── DotScreenPass.js
│ │ ├── EffectComposer.js
│ │ ├── FilmPass.js
│ │ ├── GlitchPass.js
│ │ ├── ManualMSAARenderPass.js
│ │ ├── MaskPass.js
│ │ ├── RenderPass.js
│ │ ├── SMAAPass.js
│ │ ├── SavePass.js
│ │ ├── ShaderPass.js
│ │ ├── TAARenderPass.js
│ │ └── TexturePass.js
│ ├── seedrandom.js
│ ├── shaders
│ │ ├── AdditiveBlendShader.js
│ │ ├── BadTVShader.js
│ │ ├── BasicShader.js
│ │ ├── BleachBypassShader.js
│ │ ├── BlendShader.js
│ │ ├── BokehShader.js
│ │ ├── BokehShader2.js
│ │ ├── BrightnessContrastShader.js
│ │ ├── ColorCorrectionShader.js
│ │ ├── ColorifyShader.js
│ │ ├── CompositeShader.js
│ │ ├── ConvolutionShader.js
│ │ ├── CopyShader.js
│ │ ├── DOFMipMapShader.js
│ │ ├── DigitalGlitch.js
│ │ ├── DotScreenShader.js
│ │ ├── EdgeShader.js
│ │ ├── EdgeShader2.js
│ │ ├── FXAAShader.js
│ │ ├── FilmShader.js
│ │ ├── FocusShader.js
│ │ ├── FresnelShader.js
│ │ ├── GammaCorrectionShader.js
│ │ ├── HorizontalBlurShader.js
│ │ ├── HorizontalTiltShiftShader.js
│ │ ├── HueSaturationShader.js
│ │ ├── KaleidoShader.js
│ │ ├── LuminosityShader.js
│ │ ├── MirrorShader.js
│ │ ├── NormalMapShader.js
│ │ ├── OceanShaders.js
│ │ ├── ParallaxShader.js
│ │ ├── RGBShiftShader.js
│ │ ├── RGBShiftShader2.js
│ │ ├── SMAAShader.js
│ │ ├── SSAOShader.js
│ │ ├── SepiaShader.js
│ │ ├── ShaderTerrain.js
│ │ ├── TechnicolorShader.js
│ │ ├── TiltShiftShader.js
│ │ ├── ToneMapShader.js
│ │ ├── TriangleBlurShader.js
│ │ ├── UnpackDepthRGBAShader.js
│ │ ├── VerticalBlurShader.js
│ │ ├── VerticalTiltShiftShader.js
│ │ └── VignetteShader.js
│ ├── stats.min.js
│ ├── three.js
│ ├── three.min.js
│ └── totro.js
└── viz
│ ├── Assets.js
│ ├── BG.js
│ ├── Create.js
│ ├── Crystals.js
│ ├── Gallery.js
│ ├── Heart.js
│ ├── Items.js
│ ├── LightPanels.js
│ ├── Mecha.js
│ ├── Mountain.js
│ ├── Mountains.js
│ ├── Ocean.js
│ ├── Person.js
│ ├── Rocks.js
│ └── Tools.js
├── nbproject
├── private
│ ├── private.properties
│ └── private.xml
├── project.properties
└── project.xml
└── textures
├── Above_The_Sea.jpg
├── cover.jpg
└── logo.svg
/README.md:
--------------------------------------------------------------------------------
1 | # Mass Migrations
2 | An experiment in living mecha world creation. Create, adopt and set them free.
3 |
4 | [](https://marpi.pl/work/mass-migrations/)
5 |
6 | More info: [marpi.pl/work/mass-migrations](https://marpi.pl/work/mass-migrations/)
7 |
8 | See live: [massmigrations.com](https://massmigrations.com/)
9 |
10 | Credits
11 | -------
12 |
13 | Mass Migrations was created by [Marpi](http://marpi.pl) with music by [An On Bast](http://www.anonbast.com/) and design by [Angelique Hering](http://ahering.com/).
14 |
15 | Libraries
16 | -------
17 |
18 | [three.js](https://github.com/mrdoob/three.js/), [three.bas](https://github.com/zadvorsky/three.bas), [TweenMax.js](https://greensock.com/tweenmax), [Airtight Interactive](https://www.airtightinteractive.com/2013/10/making-audio-reactive-visuals/), [totro.js](https://www.dwheeler.com/totro.html), [SimplexNoise.js](https://github.com/josephg/noisejs), [jQuery](https://github.com/jquery/jquery), [FontAwesome](http://fontawesome.io/), [minivents.js](https://github.com/allouis/minivents), [isMobile](https://github.com/kaimallea/isMobile), [seedrandom.js](https://github.com/davidbau/seedrandom)
19 |
20 |
21 | License
22 | -------
23 |
24 | Copyright © Marpi, [marpi.pl](https://marpi.pl/)
--------------------------------------------------------------------------------
/fonts/FontAwesome.otf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marpi/mass_migrations/7d799d60629077199459c9fd484893cce7d6f64d/fonts/FontAwesome.otf
--------------------------------------------------------------------------------
/fonts/droid/README.txt:
--------------------------------------------------------------------------------
1 | Copyright (C) 2008 The Android Open Source Project
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | ##########
16 |
17 | This directory contains the fonts for the platform. They are licensed
18 | under the Apache 2 license.
19 |
--------------------------------------------------------------------------------
/fonts/fontawesome-webfont.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marpi/mass_migrations/7d799d60629077199459c9fd484893cce7d6f64d/fonts/fontawesome-webfont.eot
--------------------------------------------------------------------------------
/fonts/fontawesome-webfont.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marpi/mass_migrations/7d799d60629077199459c9fd484893cce7d6f64d/fonts/fontawesome-webfont.ttf
--------------------------------------------------------------------------------
/fonts/fontawesome-webfont.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marpi/mass_migrations/7d799d60629077199459c9fd484893cce7d6f64d/fonts/fontawesome-webfont.woff
--------------------------------------------------------------------------------
/fonts/fontawesome-webfont.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marpi/mass_migrations/7d799d60629077199459c9fd484893cce7d6f64d/fonts/fontawesome-webfont.woff2
--------------------------------------------------------------------------------
/js/NavHandler.js:
--------------------------------------------------------------------------------
1 | var NavHandler = function () {
2 |
3 | var CREATE = "CREATE"
4 | var STORY = "STORY"
5 | var GALLERY = "GALLERY"
6 |
7 | var currentPage = null;
8 |
9 | var audio;
10 |
11 | function init() {
12 | document.getElementById('create').addEventListener('click', create, false);
13 | document.getElementById('gallery').addEventListener('click', gallery, false);
14 | if (document.getElementById('setfree'))
15 | document.getElementById('setfree').addEventListener('click', setfree, false);
16 | }
17 |
18 | function create() {
19 | NavHandler.goTo(NavHandler.CREATE);
20 | Create.generate();
21 | }
22 |
23 | function gallery() {
24 | NavHandler.goTo(NavHandler.GALLERY)
25 | }
26 |
27 | function setfree() {
28 | NavHandler.goTo(NavHandler.STORY)
29 | }
30 |
31 | function killDelayedCalls() {
32 | TweenMax.killDelayedCallsTo(Create.generate)
33 | TweenMax.killDelayedCallsTo(create)
34 | TweenMax.killDelayedCallsTo(setfree)
35 | }
36 |
37 | function goTo(page, param) {
38 | if (currentPage == page)
39 | return;
40 |
41 | currentPage = page;
42 | if (currentPage == STORY) {
43 | if (audio)
44 | audio.pause();
45 | //AudioHandler.decode(0,true)//
46 | AudioHandler.seekTo(0)
47 | Create.lock();
48 | Gallery.disable()
49 | //document.getElementById('leftnav').style.display = 'block';
50 | //Create.destroy()
51 | //Mecha.init();
52 | if (ControlsHandler.fxParams.screensaver) {
53 | killDelayedCalls();
54 | TweenMax.delayedCall(60 * 1, create);
55 | }
56 | if (ControlsHandler.fxParams.installation) {
57 | killDelayedCalls();
58 | TweenMax.delayedCall(60 * 1, create);
59 | }
60 | }
61 | if (currentPage == GALLERY) {
62 | Create.disable();
63 | Gallery.show()
64 | }
65 | if (currentPage == CREATE) {
66 | if (audio)
67 | audio.play()
68 | Create.unlock();
69 | Create.generate(0, 0, 0, false, param)
70 | Gallery.disable();
71 | $('#nav').fadeIn()
72 | $('#leftnav').fadeOut()
73 | Create.show();
74 | //document.getElementById('nav').style.display = 'block';
75 | //document.getElementById('leftnav').style.display = 'none';
76 | if (ControlsHandler.fxParams.screensaver) {
77 | killDelayedCalls()
78 | TweenMax.delayedCall(60 * .5, setfree)
79 | }
80 | if (ControlsHandler.fxParams.graffiti) {
81 | killDelayedCalls()
82 | for (var i = 0; i < 100; i++) {
83 | TweenMax.delayedCall(5 * i, Create.generate);
84 | }
85 | } else if (ControlsHandler.fxParams.installation) {
86 | killDelayedCalls()
87 | TweenMax.delayedCall(5 * 1, Create.generate);
88 | TweenMax.delayedCall(10 * 1, Create.generate);
89 | TweenMax.delayedCall(15 * 1, Create.generate);
90 | TweenMax.delayedCall(20 * 1, Create.generate);
91 | TweenMax.delayedCall(25 * 1, Create.generate);
92 | TweenMax.delayedCall(30 * 1, setfree)
93 | }
94 | }
95 | }
96 |
97 | return {
98 | init: init,
99 | currentPage: function () {
100 | return currentPage
101 | },
102 | goTo: goTo,
103 | CREATE: CREATE,
104 | STORY: STORY,
105 | GALLERY: GALLERY,
106 | setfree: setfree,
107 | killDelayedCalls: killDelayedCalls,
108 | audio: function () {
109 | return audio
110 | },
111 | setAudio: function (a) {
112 | audio = a
113 | }
114 | };
115 | }();
--------------------------------------------------------------------------------
/js/lib/Detector.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | * @author mr.doob / http://mrdoob.com/
4 | */
5 |
6 | var Detector = {
7 |
8 | canvas: !! window.CanvasRenderingContext2D,
9 | webgl: ( function () { try { return !! window.WebGLRenderingContext && !! document.createElement( 'canvas' ).getContext( 'experimental-webgl' ); } catch( e ) { return false; } } )(),
10 | workers: !! window.Worker,
11 | fileapi: window.File && window.FileReader && window.FileList && window.Blob,
12 |
13 | getWebGLErrorMessage: function () {
14 |
15 | var element = document.createElement( 'div' );
16 | element.id = 'webgl-error-message';
17 | element.style.fontFamily = 'monospace';
18 | element.style.fontSize = '13px';
19 | element.style.fontWeight = 'normal';
20 | element.style.textAlign = 'center';
21 | element.style.background = '#fff';
22 | element.style.color = '#000';
23 | element.style.padding = '1.5em';
24 | element.style.width = '400px';
25 | element.style.margin = '5em auto 0';
26 |
27 | if ( ! this.webgl ) {
28 |
29 | element.innerHTML = window.WebGLRenderingContext ? [
30 | 'Your graphics card does not seem to support WebGL.
',
31 | 'Find out how to get it here.'
32 | ].join( '\n' ) : [
33 | 'Your browser does not seem to support WebGL.
',
34 | 'Find out how to get it here.'
35 | ].join( '\n' );
36 |
37 | }
38 |
39 | return element;
40 |
41 | },
42 |
43 | addGetWebGLMessage: function ( parameters ) {
44 |
45 | var parent, id, element;
46 |
47 | parameters = parameters || {};
48 |
49 | parent = parameters.parent !== undefined ? parameters.parent : document.body;
50 | id = parameters.id !== undefined ? parameters.id : 'oldie';
51 |
52 | element = Detector.getWebGLErrorMessage();
53 | element.id = id;
54 |
55 | parent.appendChild( element );
56 |
57 | }
58 |
59 | };
60 |
--------------------------------------------------------------------------------
/js/lib/WebVR.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author mrdoob / http://mrdoob.com
3 | * Based on @tojiro's vr-samples-utils.js
4 | */
5 |
6 | var WEBVR = {
7 | isLatestAvailable: function () {
8 |
9 | return navigator.getVRDisplays !== undefined;
10 |
11 | },
12 | isAvailable: function () {
13 |
14 | return navigator.getVRDisplays !== undefined || navigator.getVRDevices !== undefined;
15 |
16 | },
17 | getMessage: function () {
18 |
19 | var message;
20 |
21 | if (navigator.getVRDisplays) {
22 |
23 | navigator.getVRDisplays().then(function (displays) {
24 |
25 | if (displays.length === 0)
26 | message = 'WebVR supported, but no VRDisplays found.';
27 |
28 | });
29 |
30 | } else if (navigator.getVRDevices) {
31 |
32 | message = 'Your browser supports WebVR but not the latest version. See webvr.info for more info.';
33 |
34 | } else {
35 |
36 | message = 'Your browser does not support WebVR. See webvr.info for assistance.';
37 |
38 | }
39 |
40 | if (message !== undefined) {
41 |
42 | var container = document.createElement('div');
43 | container.style.position = 'absolute';
44 | container.style.left = '0';
45 | container.style.top = '0';
46 | container.style.right = '0';
47 | container.style.zIndex = '999';
48 | container.align = 'center';
49 |
50 | var error = document.createElement('div');
51 | error.style.fontFamily = 'sans-serif';
52 | error.style.fontSize = '16px';
53 | error.style.fontStyle = 'normal';
54 | error.style.lineHeight = '26px';
55 | error.style.backgroundColor = '#fff';
56 | error.style.color = '#000';
57 | error.style.padding = '10px 20px';
58 | error.style.margin = '50px';
59 | error.style.display = 'inline-block';
60 | error.innerHTML = message;
61 | container.appendChild(error);
62 |
63 | return container;
64 |
65 | }
66 |
67 | },
68 | getButton: function (effect, switchControls) {
69 |
70 | var button = document.createElement('img');
71 | button.setAttribute('src', 'enter.png');
72 | button.style.position = 'absolute';
73 | button.style.left = 'calc(50% - 50px)';
74 | button.style.bottom = '20px';
75 | button.style.width = '100px';
76 | button.style.border = '0';
77 | button.style.cursor = 'pointer';
78 | button.style.color = '#fff';
79 | button.style.fontFamily = 'sans-serif';
80 | button.style.fontSize = '13px';
81 | button.style.fontStyle = 'normal';
82 | button.style.textAlign = 'center';
83 | button.style.zIndex = '999';
84 | button.onclick = function () {
85 | button.style.display='none'
86 | effect.requestPresent();
87 |
88 | switchControls()
89 |
90 | };
91 |
92 | window.addEventListener('vrdisplaypresentchange', function (event) {
93 |
94 | //button.textContent = false ? 'EXIT VR' : 'ENTER VR';
95 |
96 | }, false);
97 |
98 | return button;
99 |
100 | }
101 |
102 | };
103 |
--------------------------------------------------------------------------------
/js/lib/atutil.js:
--------------------------------------------------------------------------------
1 | ATUtil = {
2 | randomRange : function(min, max) {
3 | return min + Math.random() * (max - min);
4 | },
5 | randomInt : function(min,max){
6 | return Math.floor(min + Math.random() * (max - min + 1));
7 | },
8 | map : function(value, min1, max1, min2, max2) {
9 | return ATUtil.lerp(min2, max2, ATUtil.norm(value, min1, max1));
10 | },
11 | lerp : function(amt, min, max){
12 | return min + (max -min) * amt;
13 | },
14 | norm : function(value , min, max){
15 | return (value - min) / (max - min);
16 | },
17 | shuffle : function(o) {
18 | for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
19 | return o;
20 | }
21 | };
--------------------------------------------------------------------------------
/js/lib/controls/DeviceOrientationControls.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author richt / http://richt.me
3 | * @author WestLangley / http://github.com/WestLangley
4 | *
5 | * W3C Device Orientation control (http://w3c.github.io/deviceorientation/spec-source-orientation.html)
6 | */
7 |
8 | THREE.DeviceOrientationControls = function ( object ) {
9 |
10 | var scope = this;
11 |
12 | this.object = object;
13 | this.object.rotation.reorder( "YXZ" );
14 |
15 | this.enabled = true;
16 |
17 | this.deviceOrientation = {};
18 | this.screenOrientation = 0;
19 |
20 | var onDeviceOrientationChangeEvent = function ( event ) {
21 |
22 | scope.deviceOrientation = event;
23 |
24 | };
25 |
26 | var onScreenOrientationChangeEvent = function () {
27 |
28 | scope.screenOrientation = window.orientation || 0;
29 |
30 | };
31 |
32 | // The angles alpha, beta and gamma form a set of intrinsic Tait-Bryan angles of type Z-X'-Y''
33 |
34 | var setObjectQuaternion = function () {
35 |
36 | var zee = new THREE.Vector3( 0, 0, 1 );
37 |
38 | var euler = new THREE.Euler();
39 |
40 | var q0 = new THREE.Quaternion();
41 |
42 | var q1 = new THREE.Quaternion( - Math.sqrt( 0.5 ), 0, 0, Math.sqrt( 0.5 ) ); // - PI/2 around the x-axis
43 |
44 | return function ( quaternion, alpha, beta, gamma, orient ) {
45 |
46 | euler.set( beta, alpha, - gamma, 'YXZ' ); // 'ZXY' for the device, but 'YXZ' for us
47 |
48 | quaternion.setFromEuler( euler ); // orient the device
49 |
50 | quaternion.multiply( q1 ); // camera looks out the back of the device, not the top
51 |
52 | quaternion.multiply( q0.setFromAxisAngle( zee, - orient ) ); // adjust for screen orientation
53 |
54 | }
55 |
56 | }();
57 |
58 | this.connect = function() {
59 |
60 | onScreenOrientationChangeEvent(); // run once on load
61 |
62 | window.addEventListener( 'orientationchange', onScreenOrientationChangeEvent, false );
63 | window.addEventListener( 'deviceorientation', onDeviceOrientationChangeEvent, false );
64 |
65 | scope.enabled = true;
66 |
67 | };
68 |
69 | this.disconnect = function() {
70 |
71 | window.removeEventListener( 'orientationchange', onScreenOrientationChangeEvent, false );
72 | window.removeEventListener( 'deviceorientation', onDeviceOrientationChangeEvent, false );
73 |
74 | scope.enabled = false;
75 |
76 | };
77 |
78 | this.update = function () {
79 |
80 | if ( scope.enabled === false ) return;
81 |
82 | var alpha = scope.deviceOrientation.alpha ? THREE.Math.degToRad( scope.deviceOrientation.alpha ) : 0; // Z
83 | var beta = scope.deviceOrientation.beta ? THREE.Math.degToRad( scope.deviceOrientation.beta ) : 0; // X'
84 | var gamma = scope.deviceOrientation.gamma ? THREE.Math.degToRad( scope.deviceOrientation.gamma ) : 0; // Y''
85 | var orient = scope.screenOrientation ? THREE.Math.degToRad( scope.screenOrientation ) : 0; // O
86 |
87 | setObjectQuaternion( scope.object.quaternion, alpha, beta, gamma, orient );
88 |
89 | };
90 |
91 | this.dispose = function () {
92 |
93 | this.disconnect();
94 |
95 | };
96 |
97 | this.connect();
98 |
99 | };
100 |
--------------------------------------------------------------------------------
/js/lib/controls/MouseControls.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author dmarcos / http://github.com/dmarcos
3 | *
4 | * This controls allow to change the orientation of the camera using the mouse
5 | */
6 |
7 | THREE.MouseControls = function ( object ) {
8 |
9 | var scope = this;
10 | var PI_2 = Math.PI / 2;
11 | var mouseQuat = {
12 | x: new THREE.Quaternion(),
13 | y: new THREE.Quaternion()
14 | };
15 | var object = object;
16 | var xVector = new THREE.Vector3( 1, 0, 0 );
17 | var yVector = new THREE.Vector3( 0, 1, 0 );
18 |
19 | var onMouseMove = function ( event ) {
20 |
21 | if ( scope.enabled === false ) return;
22 |
23 | var orientation = scope.orientation;
24 |
25 | var movementX = event.movementX || event.mozMovementX || event.webkitMovementX || 0;
26 | var movementY = event.movementY || event.mozMovementY || event.webkitMovementY || 0;
27 |
28 | orientation.y += movementX * 0.0025;
29 | orientation.x += movementY * 0.0025;
30 |
31 | orientation.x = Math.max( - PI_2, Math.min( PI_2, orientation.x ) );
32 |
33 | };
34 |
35 | this.enabled = true;
36 |
37 | this.orientation = {
38 | x: 0,
39 | y: 0,
40 | };
41 |
42 | this.update = function() {
43 |
44 | if ( this.enabled === false ) return;
45 |
46 | mouseQuat.x.setFromAxisAngle( xVector, this.orientation.x );
47 | mouseQuat.y.setFromAxisAngle( yVector, this.orientation.y );
48 | object.quaternion.copy( mouseQuat.y ).multiply( mouseQuat.x );
49 | return;
50 |
51 | };
52 |
53 | this.dispose = function() {
54 |
55 | document.removeEventListener( 'mousemove', onMouseMove, false );
56 |
57 | }
58 |
59 | document.addEventListener( 'mousemove', onMouseMove, false );
60 |
61 | };
62 |
--------------------------------------------------------------------------------
/js/lib/controls/PointerLockControls.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author mrdoob / http://mrdoob.com/
3 | */
4 |
5 | THREE.PointerLockControls = function ( camera ) {
6 |
7 | var scope = this;
8 |
9 | camera.rotation.set( 0, 0, 0 );
10 |
11 | var pitchObject = new THREE.Object3D();
12 | pitchObject.add( camera );
13 |
14 | var yawObject = new THREE.Object3D();
15 | yawObject.position.y = 10;
16 | yawObject.add( pitchObject );
17 |
18 | var PI_2 = Math.PI / 2;
19 |
20 | var onMouseMove = function ( event ) {
21 |
22 | if ( scope.enabled === false ) return;
23 |
24 | var movementX = event.movementX || event.mozMovementX || event.webkitMovementX || 0;
25 | var movementY = event.movementY || event.mozMovementY || event.webkitMovementY || 0;
26 |
27 | yawObject.rotation.y -= movementX * 0.002;
28 | pitchObject.rotation.x -= movementY * 0.002;
29 |
30 | pitchObject.rotation.x = Math.max( - PI_2, Math.min( PI_2, pitchObject.rotation.x ) );
31 |
32 | };
33 |
34 | this.dispose = function() {
35 |
36 | document.removeEventListener( 'mousemove', onMouseMove, false );
37 |
38 | };
39 |
40 | document.addEventListener( 'mousemove', onMouseMove, false );
41 |
42 | this.enabled = false;
43 |
44 | this.getObject = function () {
45 |
46 | return yawObject;
47 |
48 | };
49 |
50 | this.getDirection = function() {
51 |
52 | // assumes the camera itself is not rotated
53 |
54 | var direction = new THREE.Vector3( 0, 0, - 1 );
55 | var rotation = new THREE.Euler( 0, 0, 0, "YXZ" );
56 |
57 | return function( v ) {
58 |
59 | rotation.set( pitchObject.rotation.x, yawObject.rotation.y, 0 );
60 |
61 | v.copy( direction ).applyEuler( rotation );
62 |
63 | return v;
64 |
65 | };
66 |
67 | }();
68 |
69 | };
70 |
--------------------------------------------------------------------------------
/js/lib/controls/VRControls.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author dmarcos / https://github.com/dmarcos
3 | * @author mrdoob / http://mrdoob.com
4 | */
5 |
6 | THREE.VRControls = function ( object, onError ) {
7 |
8 | var scope = this;
9 |
10 | var vrDisplay, vrDisplays;
11 |
12 | var standingMatrix = new THREE.Matrix4();
13 |
14 | var frameData = null;
15 | if ( 'VRFrameData' in window ) {
16 | frameData = new VRFrameData();
17 | }
18 |
19 | function gotVRDisplays( displays ) {
20 |
21 | vrDisplays = displays;
22 |
23 | if ( displays.length > 0 ) {
24 |
25 | vrDisplay = displays[ 0 ];
26 |
27 | } else {
28 |
29 | if ( onError ) onError( 'VR input not available.' );
30 |
31 | }
32 |
33 | }
34 |
35 | if ( navigator.getVRDisplays ) {
36 |
37 | navigator.getVRDisplays().then( gotVRDisplays );
38 |
39 | }
40 |
41 | // the Rift SDK returns the position in meters
42 | // this scale factor allows the user to define how meters
43 | // are converted to scene units.
44 |
45 | this.scale = 1;
46 |
47 | // If true will use "standing space" coordinate system where y=0 is the
48 | // floor and x=0, z=0 is the center of the room.
49 | this.standing = false;
50 |
51 | // Distance from the users eyes to the floor in meters. Used when
52 | // standing=true but the VRDisplay doesn't provide stageParameters.
53 | this.userHeight = 1.6;
54 |
55 | this.getVRDisplay = function () {
56 |
57 | return vrDisplay;
58 |
59 | };
60 |
61 | this.getVRDisplays = function () {
62 |
63 | return vrDisplays;
64 |
65 | };
66 |
67 | this.getStandingMatrix = function () {
68 |
69 | return standingMatrix;
70 |
71 | };
72 |
73 | this.update = function () {
74 |
75 | if ( vrDisplay ) {
76 |
77 | var pose;
78 |
79 | if ( vrDisplay.getFrameData ) {
80 |
81 | vrDisplay.getFrameData( frameData );
82 | pose = frameData.pose;
83 |
84 | } else if ( vrDisplay.getPose ) {
85 |
86 | pose = vrDisplay.getPose();
87 |
88 | }
89 |
90 | if ( pose.orientation !== null ) {
91 |
92 | object.quaternion.fromArray( pose.orientation );
93 |
94 | }
95 |
96 | if ( pose.position !== null ) {
97 |
98 | object.position.fromArray( pose.position );
99 |
100 | } else {
101 |
102 | object.position.set( 0, 0, 0 );
103 |
104 | }
105 |
106 | if ( this.standing ) {
107 |
108 | if ( vrDisplay.stageParameters ) {
109 |
110 | object.updateMatrix();
111 |
112 | standingMatrix.fromArray( vrDisplay.stageParameters.sittingToStandingTransform );
113 | object.applyMatrix( standingMatrix );
114 |
115 | } else {
116 |
117 | object.position.setY( object.position.y + this.userHeight );
118 |
119 | }
120 |
121 | }
122 |
123 | object.position.multiplyScalar( scope.scale );
124 |
125 | }
126 |
127 | };
128 |
129 | this.resetPose = function () {
130 |
131 | if ( vrDisplay ) {
132 |
133 | vrDisplay.resetPose();
134 |
135 | }
136 |
137 | };
138 |
139 | this.resetSensor = function () {
140 |
141 | console.warn( 'THREE.VRControls: .resetSensor() is now .resetPose().' );
142 | this.resetPose();
143 |
144 | };
145 |
146 | this.zeroSensor = function () {
147 |
148 | console.warn( 'THREE.VRControls: .zeroSensor() is now .resetPose().' );
149 | this.resetPose();
150 |
151 | };
152 |
153 | this.dispose = function () {
154 |
155 | vrDisplay = null;
156 |
157 | };
158 |
159 | };
160 |
--------------------------------------------------------------------------------
/js/lib/gsap/easing/EasePack.min.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * VERSION: beta 1.9.3
3 | * DATE: 2013-04-02
4 | * UPDATES AND DOCS AT: http://www.greensock.com
5 | *
6 | * @license Copyright (c) 2008-2014, GreenSock. All rights reserved.
7 | * This work is subject to the terms at http://www.greensock.com/terms_of_use.html or for
8 | * Club GreenSock members, the software agreement that was issued with your membership.
9 | *
10 | * @author: Jack Doyle, jack@greensock.com
11 | **/
12 | (window._gsQueue||(window._gsQueue=[])).push(function(){"use strict";window._gsDefine("easing.Back",["easing.Ease"],function(t){var e,i,s,r=window.GreenSockGlobals||window,n=r.com.greensock,a=2*Math.PI,o=Math.PI/2,h=n._class,l=function(e,i){var s=h("easing."+e,function(){},!0),r=s.prototype=new t;return r.constructor=s,r.getRatio=i,s},_=t.register||function(){},u=function(t,e,i,s){var r=h("easing."+t,{easeOut:new e,easeIn:new i,easeInOut:new s},!0);return _(r,t),r},c=function(t,e,i){this.t=t,this.v=e,i&&(this.next=i,i.prev=this,this.c=i.v-e,this.gap=i.t-t)},p=function(e,i){var s=h("easing."+e,function(t){this._p1=t||0===t?t:1.70158,this._p2=1.525*this._p1},!0),r=s.prototype=new t;return r.constructor=s,r.getRatio=i,r.config=function(t){return new s(t)},s},f=u("Back",p("BackOut",function(t){return(t-=1)*t*((this._p1+1)*t+this._p1)+1}),p("BackIn",function(t){return t*t*((this._p1+1)*t-this._p1)}),p("BackInOut",function(t){return 1>(t*=2)?.5*t*t*((this._p2+1)*t-this._p2):.5*((t-=2)*t*((this._p2+1)*t+this._p2)+2)})),m=h("easing.SlowMo",function(t,e,i){e=e||0===e?e:.7,null==t?t=.7:t>1&&(t=1),this._p=1!==t?e:0,this._p1=(1-t)/2,this._p2=t,this._p3=this._p1+this._p2,this._calcEnd=i===!0},!0),d=m.prototype=new t;return d.constructor=m,d.getRatio=function(t){var e=t+(.5-t)*this._p;return this._p1>t?this._calcEnd?1-(t=1-t/this._p1)*t:e-(t=1-t/this._p1)*t*t*t*e:t>this._p3?this._calcEnd?1-(t=(t-this._p3)/this._p1)*t:e+(t-e)*(t=(t-this._p3)/this._p1)*t*t*t:this._calcEnd?1:e},m.ease=new m(.7,.7),d.config=m.config=function(t,e,i){return new m(t,e,i)},e=h("easing.SteppedEase",function(t){t=t||1,this._p1=1/t,this._p2=t+1},!0),d=e.prototype=new t,d.constructor=e,d.getRatio=function(t){return 0>t?t=0:t>=1&&(t=.999999999),(this._p2*t>>0)*this._p1},d.config=e.config=function(t){return new e(t)},i=h("easing.RoughEase",function(e){e=e||{};for(var i,s,r,n,a,o,h=e.taper||"none",l=[],_=0,u=0|(e.points||20),p=u,f=e.randomize!==!1,m=e.clamp===!0,d=e.template instanceof t?e.template:null,g="number"==typeof e.strength?.4*e.strength:.4;--p>-1;)i=f?Math.random():1/u*p,s=d?d.getRatio(i):i,"none"===h?r=g:"out"===h?(n=1-i,r=n*n*g):"in"===h?r=i*i*g:.5>i?(n=2*i,r=.5*n*n*g):(n=2*(1-i),r=.5*n*n*g),f?s+=Math.random()*r-.5*r:p%2?s+=.5*r:s-=.5*r,m&&(s>1?s=1:0>s&&(s=0)),l[_++]={x:i,y:s};for(l.sort(function(t,e){return t.x-e.x}),o=new c(1,1,null),p=u;--p>-1;)a=l[p],o=new c(a.x,a.y,o);this._prev=new c(0,0,0!==o.t?o:o.next)},!0),d=i.prototype=new t,d.constructor=i,d.getRatio=function(t){var e=this._prev;if(t>e.t){for(;e.next&&t>=e.t;)e=e.next;e=e.prev}else for(;e.prev&&e.t>=t;)e=e.prev;return this._prev=e,e.v+(t-e.t)/e.gap*e.c},d.config=function(t){return new i(t)},i.ease=new i,u("Bounce",l("BounceOut",function(t){return 1/2.75>t?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}),l("BounceIn",function(t){return 1/2.75>(t=1-t)?1-7.5625*t*t:2/2.75>t?1-(7.5625*(t-=1.5/2.75)*t+.75):2.5/2.75>t?1-(7.5625*(t-=2.25/2.75)*t+.9375):1-(7.5625*(t-=2.625/2.75)*t+.984375)}),l("BounceInOut",function(t){var e=.5>t;return t=e?1-2*t:2*t-1,t=1/2.75>t?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375,e?.5*(1-t):.5*t+.5})),u("Circ",l("CircOut",function(t){return Math.sqrt(1-(t-=1)*t)}),l("CircIn",function(t){return-(Math.sqrt(1-t*t)-1)}),l("CircInOut",function(t){return 1>(t*=2)?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)})),s=function(e,i,s){var r=h("easing."+e,function(t,e){this._p1=t||1,this._p2=e||s,this._p3=this._p2/a*(Math.asin(1/this._p1)||0)},!0),n=r.prototype=new t;return n.constructor=r,n.getRatio=i,n.config=function(t,e){return new r(t,e)},r},u("Elastic",s("ElasticOut",function(t){return this._p1*Math.pow(2,-10*t)*Math.sin((t-this._p3)*a/this._p2)+1},.3),s("ElasticIn",function(t){return-(this._p1*Math.pow(2,10*(t-=1))*Math.sin((t-this._p3)*a/this._p2))},.3),s("ElasticInOut",function(t){return 1>(t*=2)?-.5*this._p1*Math.pow(2,10*(t-=1))*Math.sin((t-this._p3)*a/this._p2):.5*this._p1*Math.pow(2,-10*(t-=1))*Math.sin((t-this._p3)*a/this._p2)+1},.45)),u("Expo",l("ExpoOut",function(t){return 1-Math.pow(2,-10*t)}),l("ExpoIn",function(t){return Math.pow(2,10*(t-1))-.001}),l("ExpoInOut",function(t){return 1>(t*=2)?.5*Math.pow(2,10*(t-1)):.5*(2-Math.pow(2,-10*(t-1)))})),u("Sine",l("SineOut",function(t){return Math.sin(t*o)}),l("SineIn",function(t){return-Math.cos(t*o)+1}),l("SineInOut",function(t){return-.5*(Math.cos(Math.PI*t)-1)})),h("easing.EaseLookup",{find:function(e){return t.map[e]}},!0),_(r.SlowMo,"SlowMo","ease,"),_(i,"RoughEase","ease,"),_(e,"SteppedEase","ease,"),f},!0)}),window._gsDefine&&window._gsQueue.pop()();
--------------------------------------------------------------------------------
/js/lib/gsap/jquery.gsap.min.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * VERSION: 0.1.6
3 | * DATE: 2013-02-13
4 | * UPDATES AND DOCS AT: http://www.greensock.com/jquery-gsap-plugin/
5 | *
6 | * Requires TweenLite version 1.8.0 or higher and CSSPlugin.
7 | *
8 | * @license Copyright (c) 2014, GreenSock. All rights reserved.
9 | * This work is subject to the terms at http://www.greensock.com/terms_of_use.html or for
10 | * Club GreenSock members, the software agreement that was issued with your membership.
11 | *
12 | * @author: Jack Doyle, jack@greensock.com
13 | */
14 | (function(t){"use strict";var e,i,s,r=t.fn.animate,n=t.fn.stop,a=!0,o=function(t,e){"function"==typeof t&&this.each(t),e()},h=function(t,e,i,s,r){r="function"==typeof r?r:null,e="function"==typeof e?e:null,(e||r)&&(s[t]=r?o:i.each,s[t+"Scope"]=i,s[t+"Params"]=r?[e,r]:[e])},l={overwrite:1,delay:1,useFrames:1,runBackwards:1,easeParams:1,yoyo:1,immediateRender:1,repeat:1,repeatDelay:1,autoCSS:1},_=function(t,e){for(var i in l)l[i]&&void 0!==t[i]&&(e[i]=t[i])},u=function(t){return function(e){return t.getRatio(e)}},c={},f=function(){var r,n,a,o=window.GreenSockGlobals||window;if(e=o.TweenMax||o.TweenLite,e&&(r=(e.version+".0.0").split("."),n=!(Number(r[0])>0&&Number(r[1])>7),o=o.com.greensock,i=o.plugins.CSSPlugin,c=o.easing.Ease.map||{}),!e||!i||n)return e=null,!s&&window.console&&(window.console.log("The jquery.gsap.js plugin requires the TweenMax (or at least TweenLite and CSSPlugin) JavaScript file(s)."+(n?" Version "+r.join(".")+" is too old.":"")),s=!0),void 0;if(t.easing){for(a in c)t.easing[a]=u(c[a]);f=!1}};t.fn.animate=function(s,n,o,l){if(s=s||{},f&&(f(),!e||!i))return r.call(this,s,n,o,l);if(!a||s.skipGSAP===!0||"object"==typeof n&&"function"==typeof n.step||null!=s.scrollTop||null!=s.scrollLeft)return r.call(this,s,n,o,l);var u,p,m,d,g=t.speed(n,o,l),v={ease:c[g.easing]||(g.easing===!1?c.linear:c.swing)},T=this,y="object"==typeof n?n.specialEasing:null;for(p in s){if(u=s[p],u instanceof Array&&c[u[1]]&&(y=y||{},y[p]=u[1],u=u[0]),"toggle"===u||"hide"===u||"show"===u)return r.call(this,s,n,o,l);v[-1===p.indexOf("-")?p:t.camelCase(p)]=u}if(y){d=[];for(p in y)u=d[d.length]={},_(v,u),u.ease=c[y[p]]||v.ease,-1!==p.indexOf("-")&&(p=t.camelCase(p)),u[p]=v[p];0===d.length&&(d=null)}return m=function(i){if(d)for(var s=d.length;--s>-1;)e.to(T,t.fx.off?0:g.duration/1e3,d[s]);h("onComplete",g.old,T,v,i),e.to(T,t.fx.off?0:g.duration/1e3,v)},g.queue!==!1?T.queue(g.queue,m):m(),T},t.fn.stop=function(t,i){if(n.call(this,t,i),e){if(i)for(var s,r=e.getTweensOf(this),a=r.length;--a>-1;)s=r[a].totalTime()/r[a].totalDuration(),s>0&&1>s&&r[a].seek(r[a].totalDuration());e.killTweensOf(this)}return this},t.gsap={enabled:function(t){a=t},version:"0.1.6"}})(jQuery);
--------------------------------------------------------------------------------
/js/lib/gsap/plugins/AttrPlugin.min.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * VERSION: 0.2.0
3 | * DATE: 2013-07-10
4 | * UPDATES AND DOCS AT: http://www.greensock.com
5 | *
6 | * @license Copyright (c) 2008-2014, GreenSock. All rights reserved.
7 | * This work is subject to the terms at http://www.greensock.com/terms_of_use.html or for
8 | * Club GreenSock members, the software agreement that was issued with your membership.
9 | *
10 | * @author: Jack Doyle, jack@greensock.com
11 | */
12 | (window._gsQueue||(window._gsQueue=[])).push(function(){"use strict";window._gsDefine.plugin({propName:"attr",API:2,version:"0.2.0",init:function(t,e){var i;if("function"!=typeof t.setAttribute)return!1;this._target=t,this._proxy={};for(i in e)this._addTween(this._proxy,i,parseFloat(t.getAttribute(i)),e[i],i)&&this._overwriteProps.push(i);return!0},set:function(t){this._super.setRatio.call(this,t);for(var e,i=this._overwriteProps,s=i.length;--s>-1;)e=i[s],this._target.setAttribute(e,this._proxy[e]+"")}})}),window._gsDefine&&window._gsQueue.pop()();
--------------------------------------------------------------------------------
/js/lib/gsap/plugins/CSSRulePlugin.min.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * VERSION: beta 0.6.0
3 | * DATE: 2013-07-03
4 | * UPDATES AND DOCS AT: http://www.greensock.com
5 | *
6 | * @license Copyright (c) 2008-2014, GreenSock. All rights reserved.
7 | * This work is subject to the terms at http://www.greensock.com/terms_of_use.html or for
8 | * Club GreenSock members, the software agreement that was issued with your membership.
9 | *
10 | * @author: Jack Doyle, jack@greensock.com
11 | */
12 | (window._gsQueue||(window._gsQueue=[])).push(function(){"use strict";window._gsDefine("plugins.CSSRulePlugin",["plugins.TweenPlugin","TweenLite","plugins.CSSPlugin"],function(t,e,i){var s=function(){t.call(this,"cssRule"),this._overwriteProps.length=0},r=window.document,n=i.prototype.setRatio,a=s.prototype=new i;return a._propName="cssRule",a.constructor=s,s.API=2,s.getRule=function(t){var e,i,s,n,a=r.all?"rules":"cssRules",o=r.styleSheets,l=o.length,h=":"===t.charAt(0);for(t=(h?"":",")+t.toLowerCase()+",",h&&(n=[]);--l>-1;){try{i=o[l][a]}catch(u){console.log(u);continue}for(e=i.length;--e>-1;)if(s=i[e],s.selectorText&&-1!==(","+s.selectorText.split("::").join(":").toLowerCase()+",").indexOf(t)){if(!h)return s.style;n.push(s.style)}}return n},a._onInitTween=function(t,e,s){if(void 0===t.cssText)return!1;var n=r.createElement("div");return this._ss=t,this._proxy=n.style,n.style.cssText=t.cssText,i.prototype._onInitTween.call(this,n,e,s),!0},a.setRatio=function(t){n.call(this,t),this._ss.cssText=this._proxy.cssText},t.activate([s]),s},!0)}),window._gsDefine&&window._gsQueue.pop()();
--------------------------------------------------------------------------------
/js/lib/gsap/plugins/ColorPropsPlugin.min.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * VERSION: beta 1.2.0
3 | * DATE: 2013-03-01
4 | * UPDATES AND DOCS AT: http://www.greensock.com
5 | *
6 | * @license Copyright (c) 2008-2014, GreenSock. All rights reserved.
7 | * This work is subject to the terms at http://www.greensock.com/terms_of_use.html or for
8 | * Club GreenSock members, the software agreement that was issued with your membership.
9 | *
10 | * @author: Jack Doyle, jack@greensock.com
11 | **/
12 | (window._gsQueue||(window._gsQueue=[])).push(function(){"use strict";var t=/(\d|\.)+/g,e={aqua:[0,255,255],lime:[0,255,0],silver:[192,192,192],black:[0,0,0],maroon:[128,0,0],teal:[0,128,128],blue:[0,0,255],navy:[0,0,128],white:[255,255,255],fuchsia:[255,0,255],olive:[128,128,0],yellow:[255,255,0],orange:[255,165,0],gray:[128,128,128],purple:[128,0,128],green:[0,128,0],red:[255,0,0],pink:[255,192,203],cyan:[0,255,255],transparent:[255,255,255,0]},i=function(t,e,i){return t=0>t?t+1:t>1?t-1:t,0|255*(1>6*t?e+6*(i-e)*t:.5>t?i:2>3*t?e+6*(i-e)*(2/3-t):e)+.5},s=function(s){if(""===s||null==s||"none"===s)return e.transparent;if(e[s])return e[s];if("number"==typeof s)return[s>>16,255&s>>8,255&s];if("#"===s.charAt(0))return 4===s.length&&(s="#"+s.charAt(1)+s.charAt(1)+s.charAt(2)+s.charAt(2)+s.charAt(3)+s.charAt(3)),s=parseInt(s.substr(1),16),[s>>16,255&s>>8,255&s];if("hsl"===s.substr(0,3)){s=s.match(t);var r=Number(s[0])%360/360,n=Number(s[1])/100,a=Number(s[2])/100,o=.5>=a?a*(n+1):a+n-a*n,h=2*a-o;return s.length>3&&(s[3]=Number(s[3])),s[0]=i(r+1/3,h,o),s[1]=i(r,h,o),s[2]=i(r-1/3,h,o),s}return s.match(t)||e.transparent};window._gsDefine.plugin({propName:"colorProps",priority:-1,API:2,init:function(t,e){this._target=t;var i,r,n,a;for(i in e)n=s(e[i]),this._firstPT=a={_next:this._firstPT,p:i,f:"function"==typeof t[i],n:i,r:!1},r=s(a.f?t[i.indexOf("set")||"function"!=typeof t["get"+i.substr(3)]?i:"get"+i.substr(3)]():t[i]),a.s=Number(r[0]),a.c=Number(n[0])-a.s,a.gs=Number(r[1]),a.gc=Number(n[1])-a.gs,a.bs=Number(r[2]),a.bc=Number(n[2])-a.bs,(a.rgba=r.length>3||n.length>3)&&(a.as=4>r.length?1:Number(r[3]),a.ac=(4>n.length?1:Number(n[3]))-a.as),a._next&&(a._next._prev=a);return!0},set:function(t){for(var e,i=this._firstPT;i;)e=(i.rgba?"rgba(":"rgb(")+(i.s+t*i.c>>0)+", "+(i.gs+t*i.gc>>0)+", "+(i.bs+t*i.bc>>0)+(i.rgba?", "+(i.as+t*i.ac):"")+")",i.f?this._target[i.p](e):this._target[i.p]=e,i=i._next}})}),window._gsDefine&&window._gsQueue.pop()();
--------------------------------------------------------------------------------
/js/lib/gsap/plugins/DirectionalRotationPlugin.min.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * VERSION: beta 0.2.0
3 | * DATE: 2013-05-07
4 | * UPDATES AND DOCS AT: http://www.greensock.com
5 | *
6 | * @license Copyright (c) 2008-2014, GreenSock. All rights reserved.
7 | * This work is subject to the terms at http://www.greensock.com/terms_of_use.html or for
8 | * Club GreenSock members, the software agreement that was issued with your membership.
9 | *
10 | * @author: Jack Doyle, jack@greensock.com
11 | **/
12 | (window._gsQueue||(window._gsQueue=[])).push(function(){"use strict";window._gsDefine.plugin({propName:"directionalRotation",API:2,version:"0.2.0",init:function(t,e){"object"!=typeof e&&(e={rotation:e}),this.finals={};var i,s,r,n,a,o,l=e.useRadians===!0?2*Math.PI:360,h=1e-6;for(i in e)"useRadians"!==i&&(o=(e[i]+"").split("_"),s=o[0],r=parseFloat("function"!=typeof t[i]?t[i]:t[i.indexOf("set")||"function"!=typeof t["get"+i.substr(3)]?i:"get"+i.substr(3)]()),n=this.finals[i]="string"==typeof s&&"="===s.charAt(1)?r+parseInt(s.charAt(0)+"1",10)*Number(s.substr(2)):Number(s)||0,a=n-r,o.length&&(s=o.join("_"),-1!==s.indexOf("short")&&(a%=l,a!==a%(l/2)&&(a=0>a?a+l:a-l)),-1!==s.indexOf("_cw")&&0>a?a=(a+9999999999*l)%l-(0|a/l)*l:-1!==s.indexOf("ccw")&&a>0&&(a=(a-9999999999*l)%l-(0|a/l)*l)),(a>h||-h>a)&&(this._addTween(t,i,r,r+a,i),this._overwriteProps.push(i)));return!0},set:function(t){var e;if(1!==t)this._super.setRatio.call(this,t);else for(e=this._firstPT;e;)e.f?e.t[e.p](this.finals[e.p]):e.t[e.p]=this.finals[e.p],e=e._next}})._autoCSS=!0}),window._gsDefine&&window._gsQueue.pop()();
--------------------------------------------------------------------------------
/js/lib/gsap/plugins/EaselPlugin.min.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * VERSION: beta 0.1.5
3 | * DATE: 2013-08-29
4 | * UPDATES AND DOCS AT: http://www.greensock.com
5 | *
6 | * @license Copyright (c) 2008-2014, GreenSock. All rights reserved.
7 | * This work is subject to the terms at http://www.greensock.com/terms_of_use.html or for
8 | * Club GreenSock members, the software agreement that was issued with your membership.
9 | *
10 | * @author: Jack Doyle, jack@greensock.com
11 | **/
12 | (window._gsQueue||(window._gsQueue=[])).push(function(){"use strict";var t,e,i=/(\d|\.)+/g,r=["redMultiplier","greenMultiplier","blueMultiplier","alphaMultiplier","redOffset","greenOffset","blueOffset","alphaOffset"],s={aqua:[0,255,255],lime:[0,255,0],silver:[192,192,192],black:[0,0,0],maroon:[128,0,0],teal:[0,128,128],blue:[0,0,255],navy:[0,0,128],white:[255,255,255],fuchsia:[255,0,255],olive:[128,128,0],yellow:[255,255,0],orange:[255,165,0],gray:[128,128,128],purple:[128,0,128],green:[0,128,0],red:[255,0,0],pink:[255,192,203],cyan:[0,255,255],transparent:[255,255,255,0]},n=function(t){return""===t||null==t||"none"===t?s.transparent:s[t]?s[t]:"number"==typeof t?[t>>16,255&t>>8,255&t]:"#"===t.charAt(0)?(4===t.length&&(t="#"+t.charAt(1)+t.charAt(1)+t.charAt(2)+t.charAt(2)+t.charAt(3)+t.charAt(3)),t=parseInt(t.substr(1),16),[t>>16,255&t>>8,255&t]):t.match(i)||s.transparent},a=function(e,i,s){if(!t&&(t=window.ColorFilter||window.createjs.ColorFilter,!t))throw"EaselPlugin error: The EaselJS ColorFilter JavaScript file wasn't loaded.";for(var a,o,l,h,u,_=e.filters||[],p=_.length;--p>-1;)if(_[p]instanceof t){o=_[p];break}if(o||(o=new t,_.push(o),e.filters=_),l=o.clone(),null!=i.tint)a=n(i.tint),h=null!=i.tintAmount?Number(i.tintAmount):1,l.redOffset=Number(a[0])*h,l.greenOffset=Number(a[1])*h,l.blueOffset=Number(a[2])*h,l.redMultiplier=l.greenMultiplier=l.blueMultiplier=1-h;else for(u in i)"exposure"!==u&&"brightness"!==u&&(l[u]=Number(i[u]));for(null!=i.exposure?(l.redOffset=l.greenOffset=l.blueOffset=255*(Number(i.exposure)-1),l.redMultiplier=l.greenMultiplier=l.blueMultiplier=1):null!=i.brightness&&(h=Number(i.brightness)-1,l.redOffset=l.greenOffset=l.blueOffset=h>0?255*h:0,l.redMultiplier=l.greenMultiplier=l.blueMultiplier=1-Math.abs(h)),p=8;--p>-1;)u=r[p],o[u]!==l[u]&&s._addTween(o,u,o[u],l[u],"easel_colorFilter");if(s._overwriteProps.push("easel_colorFilter"),!e.cacheID)throw"EaselPlugin warning: for filters to display in EaselJS, you must call the object's cache() method first. "+e},o=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],l=.212671,h=.71516,u=.072169,_=function(t,e){if(!(t instanceof Array&&e instanceof Array))return e;var i,r,s=[],n=0,a=0;for(i=0;4>i;i++){for(r=0;5>r;r++)a=4===r?t[n+4]:0,s[n+r]=t[n]*e[r]+t[n+1]*e[r+5]+t[n+2]*e[r+10]+t[n+3]*e[r+15]+a;n+=5}return s},p=function(t,e){if(isNaN(e))return t;var i=1-e,r=i*l,s=i*h,n=i*u;return _([r+e,s,n,0,0,r,s+e,n,0,0,r,s,n+e,0,0,0,0,0,1,0],t)},f=function(t,e,i){isNaN(i)&&(i=1);var r=n(e),s=r[0]/255,a=r[1]/255,o=r[2]/255,p=1-i;return _([p+i*s*l,i*s*h,i*s*u,0,0,i*a*l,p+i*a*h,i*a*u,0,0,i*o*l,i*o*h,p+i*o*u,0,0,0,0,0,1,0],t)},c=function(t,e){if(isNaN(e))return t;e*=Math.PI/180;var i=Math.cos(e),r=Math.sin(e);return _([l+i*(1-l)+r*-l,h+i*-h+r*-h,u+i*-u+r*(1-u),0,0,l+i*-l+.143*r,h+i*(1-h)+.14*r,u+i*-u+r*-.283,0,0,l+i*-l+r*-(1-l),h+i*-h+r*h,u+i*(1-u)+r*u,0,0,0,0,0,1,0,0,0,0,0,1],t)},d=function(t,e){return isNaN(e)?t:(e+=.01,_([e,0,0,0,128*(1-e),0,e,0,0,128*(1-e),0,0,e,0,128*(1-e),0,0,0,1,0],t))},m=function(t,i,r){if(!e&&(e=window.ColorMatrixFilter||window.createjs.ColorMatrixFilter,!e))throw"EaselPlugin error: The EaselJS ColorMatrixFilter JavaScript file wasn't loaded.";for(var s,n,a,l=t.filters||[],h=l.length;--h>-1;)if(l[h]instanceof e){a=l[h];break}for(a||(a=new e(o.slice()),l.push(a),t.filters=l),n=a.matrix,s=o.slice(),null!=i.colorize&&(s=f(s,i.colorize,Number(i.colorizeAmount))),null!=i.contrast&&(s=d(s,Number(i.contrast))),null!=i.hue&&(s=c(s,Number(i.hue))),null!=i.saturation&&(s=p(s,Number(i.saturation))),h=s.length;--h>-1;)s[h]!==n[h]&&r._addTween(n,h,n[h],s[h],"easel_colorMatrixFilter");if(r._overwriteProps.push("easel_colorMatrixFilter"),!t.cacheID)throw"EaselPlugin warning: for filters to display in EaselJS, you must call the object's cache() method first. "+t;r._matrix=n};window._gsDefine.plugin({propName:"easel",priority:-1,API:2,init:function(t,e){this._target=t;var i,r,s,n;for(i in e)"colorFilter"===i||"tint"===i||"tintAmount"===i||"exposure"===i||"brightness"===i?s||(a(t,e.colorFilter||e,this),s=!0):"saturation"===i||"contrast"===i||"hue"===i||"colorize"===i||"colorizeAmount"===i?n||(m(t,e.colorMatrixFilter||e,this),n=!0):"frame"===i?(this._firstPT=r={_next:this._firstPT,t:t,p:"gotoAndStop",s:t.currentFrame,f:!0,n:"frame",pr:0,type:0,r:!0},r.c="number"==typeof e[i]?e[i]-r.s:"string"==typeof e[i]?parseFloat(e[i].split("=").join("")):0,r._next&&(r._next._prev=r)):null!=t[i]&&(this._firstPT=r={_next:this._firstPT,t:t,p:i,f:"function"==typeof t[i],n:i,pr:0,type:0},r.s=r.f?t[i.indexOf("set")||"function"!=typeof t["get"+i.substr(3)]?i:"get"+i.substr(3)]():parseFloat(t[i]),r.c="number"==typeof e[i]?e[i]-r.s:"string"==typeof e[i]?parseFloat(e[i].split("=").join("")):0,r._next&&(r._next._prev=r));return!0},set:function(t){for(var e,i=this._firstPT,r=1e-6;i;)e=i.c*t+i.s,i.r?e=e+(e>0?.5:-.5)>>0:r>e&&e>-r&&(e=0),i.f?i.t[i.p](e):i.t[i.p]=e,i=i._next;this._target.cacheID&&this._target.updateCache()}})}),window._gsDefine&&window._gsQueue.pop()();
--------------------------------------------------------------------------------
/js/lib/gsap/plugins/KineticPlugin.min.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * VERSION: 0.5.0
3 | * DATE: 2014-01-18
4 | * UPDATES AND DOCS AT: http://www.greensock.com
5 | *
6 | * @license Copyright (c) 2008-2014, GreenSock. All rights reserved.
7 | * This work is subject to the terms at http://www.greensock.com/terms_of_use.html or for
8 | * Club GreenSock members, the software agreement that was issued with your membership.
9 | *
10 | * @author: Jack Doyle, jack@greensock.com
11 | */
12 | (window._gsQueue||(window._gsQueue=[])).push(function(){"use strict";var t,e,i,r,s={scale:1,shadowOffset:1,fillPatternOffset:1,offset:1,fill:2,stroke:2,shadowColor:2},n={},a={},o=/(\d|\.)+/g,l=/(?:_cw|_ccw|_short)/,h=window._gsDefine.globals.com.greensock.plugins,u={aqua:[0,255,255],lime:[0,255,0],silver:[192,192,192],black:[0,0,0],maroon:[128,0,0],teal:[0,128,128],blue:[0,0,255],navy:[0,0,128],white:[255,255,255],fuchsia:[255,0,255],olive:[128,128,0],yellow:[255,255,0],orange:[255,165,0],gray:[128,128,128],purple:[128,0,128],green:[0,128,0],red:[255,0,0],pink:[255,192,203],cyan:[0,255,255],transparent:[255,255,255,0]},_=function(t,e,i){return t=0>t?t+1:t>1?t-1:t,0|255*(1>6*t?e+6*(i-e)*t:.5>t?i:2>3*t?e+6*(i-e)*(2/3-t):e)+.5},p=function(t){if(""===t||null==t||"none"===t)return u.transparent;if(u[t])return u[t];if("number"==typeof t)return[t>>16,255&t>>8,255&t];if("#"===t.charAt(0))return 4===t.length&&(t="#"+t.charAt(1)+t.charAt(1)+t.charAt(2)+t.charAt(2)+t.charAt(3)+t.charAt(3)),t=parseInt(t.substr(1),16),[t>>16,255&t>>8,255&t];if("hsl"===t.substr(0,3)){t=t.match(o);var e=Number(t[0])%360/360,i=Number(t[1])/100,r=Number(t[2])/100,s=.5>=r?r*(i+1):r+i-r*i,n=2*r-s;return t.length>3&&(t[3]=Number(t[3])),t[0]=_(e+1/3,n,s),t[1]=_(e,n,s),t[2]=_(e-1/3,n,s),t}for(var a=t.match(o)||u.transparent,l=a.length;--l>-1;)a[l]=Number(a[l]);return a},f=function(t,e,i,r){this.getter=e,this.setter=i;var s=p(t[e]());this.proxy={r:s[0],g:s[1],b:s[2],a:s.length>3?s[3]:1},r&&(this._next=r,r._prev=this)},c=[],d=function(){var i=c.length;if(0!==i){for(;--i>-1;)c[i].draw(),c[i]._gsDraw=!1;c.length=0}else t.removeEventListener("tick",d),e=!1},m=function(t,e){var i="x"===e?"y":"x",r="_gs_"+t;n[t]=function(){return this["get"+t]()[e]},a[t]=function(s){var n=this["get"+t](),a=this[r];return a||(a=this[r]={}),a[e]=s,a[i]=n[i],this[t](a),this}},g=function(t,e){return function(i){return arguments.length?e(i):t()}},v=function(t,e){var i,r,o,l,h=[];for(i in e)if(r=e[i],"bezier"!==i&&"autoDraw"!==i&&"set"!==i.substr(0,3)&&void 0===t[i]&&(h.push(i),delete e[i],i="set"+i.charAt(0).toUpperCase()+i.substr(1),e[i]=r),s[i]){if(1===s[i])return e[i+"X"]=e[i+"Y"]=e[i],delete e[i],v(t,e);!t[i]&&a[i]&&(l=t.prototype||t,l[i]=g(n[i],a[i]))}else if("bezier"===i)for(r=r instanceof Array?r:r.values||[],o=r.length;--o>-1;)0===o?h=h.concat(v(t,r[o])):v(t,r[o]);return h},y=function(t){var e,i={};for(e in t)i[e]=t[e];return i};for(r in s)1===s[r]&&(m(r,"x"),m(r,"y"));window._gsDefine.plugin({propName:"kinetic",API:2,version:"0.5.0",init:function(e,r,n){var a,o,u,_,c,d;if(!i&&(i=5>parseInt(Kinetic.version.split(".")[0],10)))throw"The GSAP KineticPlugin that's loaded requires KineticJS version 5.0.0 or later. For earlier versions, use KineticPlugin from GSAP 1.11.3 or earlier.";this._overwriteProps=v(e,r),this._target=e,this._layer=r.autoDraw!==!1?e.getLayer():null,!t&&this._layer&&(t=n.constructor.ticker);for(a in r){if(o=r[a],2===s[a])_=this._firstSP=new f(e,a,a,this._firstSP),o=p(o),_.proxy.r!==o[0]&&this._addTween(_.proxy,"r",_.proxy.r,o[0],a),_.proxy.g!==o[1]&&this._addTween(_.proxy,"g",_.proxy.g,o[1],a),_.proxy.b!==o[2]&&this._addTween(_.proxy,"b",_.proxy.b,o[2],a),(o.length>3||1!==_.proxy.a)&&_.proxy.a!==o[3]&&this._addTween(_.proxy,"a",_.proxy.a,o.length>3?o[3]:1,a);else if("bezier"===a){if(c=h.BezierPlugin,!c)throw"BezierPlugin not loaded";c=this._bezier=new c,"object"==typeof o&&o.autoRotate===!0&&(o.autoRotate=["x","y","rotation",0,!1]),c._onInitTween(e,o,n),this._overwriteProps=this._overwriteProps.concat(c._overwriteProps),this._addTween(c,"setRatio",0,1,a)}else if("rotation"!==a&&"rotationDeg"!==a||"string"!=typeof o||!l.test(o))"autoDraw"!==a&&(u="get"+a.substr(3),this._addTween(e,a,("function"==typeof e[a]?e["function"==typeof e[u]?u:a]():e[a])||0,o,a));else{if(d=h.DirectionalRotationPlugin,!d)throw"DirectionalRotationPlugin not loaded";d=this._directionalRotation=new d,u={useRadians:!1},u[a]=o,d._onInitTween(e,u,n),this._addTween(d,"setRatio",0,1,a)}this._overwriteProps.push(a)}return!0},kill:function(t){return t=y(t),v(this._target,t),this._bezier&&this._bezier._kill(t),this._directionalRotation&&this._directionalRotation._kill(t),this._super._kill.call(this,t)},round:function(t,e){return t=y(t),v(this._target,t),this._bezier&&this._bezier._roundProps(t,e),this._super._roundProps.call(this,t,e)},set:function(i){this._super.setRatio.call(this,i);var r,s,n=this._firstSP,a=this._layer;if(n)for(r=this._target;n;)s=n.proxy,r[n.setter]((1!==s.a?"rgba(":"rgb(")+(0|s.r)+", "+(0|s.g)+", "+(0|s.b)+(1!==s.a?", "+s.a:"")+")"),n=n._next;a&&!a._gsDraw&&(c.push(a),a._gsDraw=!0,e||(t.addEventListener("tick",d),e=!0))}})}),window._gsDefine&&window._gsQueue.pop()();
--------------------------------------------------------------------------------
/js/lib/gsap/plugins/RaphaelPlugin.min.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * VERSION: beta 0.2.0
3 | * DATE: 2013-02-27
4 | * UPDATES AND DOCS AT: http://www.greensock.com
5 | *
6 | * @license Copyright (c) 2008-2014, GreenSock. All rights reserved.
7 | * This work is subject to the terms at http://www.greensock.com/terms_of_use.html or for
8 | * Club GreenSock members, the software agreement that was issued with your membership.
9 | *
10 | * @author: Jack Doyle, jack@greensock.com
11 | */
12 | (window._gsQueue||(window._gsQueue=[])).push(function(){"use strict";var t=/[^\d\-\.]/g,e=Math.PI/180,i=/(\d|\.)+/g,r={aqua:[0,255,255],lime:[0,255,0],silver:[192,192,192],black:[0,0,0],maroon:[128,0,0],teal:[0,128,128],blue:[0,0,255],navy:[0,0,128],white:[255,255,255],fuchsia:[255,0,255],olive:[128,128,0],yellow:[255,255,0],orange:[255,165,0],gray:[128,128,128],purple:[128,0,128],green:[0,128,0],red:[255,0,0],pink:[255,192,203],cyan:[0,255,255],transparent:[255,255,255,0]},s=function(t){return"number"==typeof t?[t>>16,255&t>>8,255&t]:""===t||null==t||"none"===t||"string"!=typeof t?r.transparent:r[t]?r[t]:"#"===t.charAt(0)?(4===t.length&&(t="#"+t.charAt(1)+t.charAt(1)+t.charAt(2)+t.charAt(2)+t.charAt(3)+t.charAt(3)),t=parseInt(t.substr(1),16),[t>>16,255&t>>8,255&t]):t.match(i)||r.transparent},n={scaleX:1,scaleY:1,tx:1,ty:1,rotation:1,shortRotation:1,skewX:1,skewY:1,scale:1},a=function(t,e){var i=t.matrix,r=1e-6,s=i.a,n=i.b,a=i.c,o=i.d,l=e?t._gsTransform||{skewY:0}:{skewY:0},h=0>l.scaleX;return l.tx=i.e-(l.ox||0),l.ty=i.f-(l.oy||0),l.scaleX=Math.sqrt(s*s+n*n),l.scaleY=Math.sqrt(o*o+a*a),l.rotation=s||n?Math.atan2(n,s):l.rotation||0,l.skewX=a||o?Math.atan2(a,o)+l.rotation:l.skewX||0,Math.abs(l.skewX)>Math.PI/2&&(h?(l.scaleX*=-1,l.skewX+=0>=l.rotation?Math.PI:-Math.PI,l.rotation+=0>=l.rotation?Math.PI:-Math.PI):(l.scaleY*=-1,l.skewX+=0>=l.skewX?Math.PI:-Math.PI)),r>l.rotation&&l.rotation>-r&&(s||n)&&(l.rotation=0),r>l.skewX&&l.skewX>-r&&(n||a)&&(l.skewX=0),e&&(t._gsTransform=l),l},o=function(t,e){return null==t?e:"string"==typeof t&&1===t.indexOf("=")?parseInt(t.charAt(0)+"1",10)*Number(t.substr(2))+e:Number(t)},l=function(i,r){var s=-1===i.indexOf("rad")?e:1,n=1===i.indexOf("=");return i=Number(i.replace(t,""))*s,n?i+r:i},h=window._gsDefine.plugin({propName:"raphael",API:2,init:function(e,i,r){if(!e.attr)return!1;this._target=e,this._tween=r,this._props=e._gsProps=e._gsProps||{};var a,o,l,h,u,_,p;for(a in i)l=i[a],"transform"!==a?n[a]||"pivot"===a?this._parseTransform(e,i):(o=e.attr(a),this._firstPT=h={_next:this._firstPT,t:this._props,p:a,b:o,f:!1,n:"raphael_"+a,r:!1,type:0},"fill"===a||"stroke"===a?(u=s(o),_=s(l),h.e=l,h.s=Number(u[0]),h.c=Number(_[0])-h.s,h.gs=Number(u[1]),h.gc=Number(_[1])-h.gs,h.bs=Number(u[2]),h.bc=Number(_[2])-h.bs,u.length>3||_.length>3?(h.as=4>u.length?1:Number(u[3]),h.ac=(4>_.length?1:Number(_[3]))-h.as,h.type=2):h.type=1):(o="string"==typeof o?parseFloat(o.replace(t,"")):Number(o),"string"==typeof l?(p="="===l.charAt(1),l=parseFloat(l.replace(t,""))):p=!1,h.e=l||0===l?p?l+o:l:i[a],!o&&0!==o||!l&&0!==l||!(h.c=p?l:l-o)?(h.type=-1,h.i=i[a],h.s=h.c=0):h.s=o),this._overwriteProps.push("raphael_"+a),h._next&&(h._next._prev=h)):this._parseTransform(e,l);return!0},set:function(t){for(var e,i=this._firstPT;i;)e=i.c*t+i.s,i.r&&(e=e>0?e+.5>>0:e-.5>>0),i.type?1===i.type?i.t[i.p]="rgb("+(e>>0)+", "+(i.gs+t*i.gc>>0)+", "+(i.bs+t*i.bc>>0)+")":2===i.type?i.t[i.p]="rgba("+(e>>0)+", "+(i.gs+t*i.gc>>0)+", "+(i.bs+t*i.bc>>0)+", "+(i.as+t*i.ac)+")":-1===i.type&&(i.t[i.p]=i.i):i.t[i.p]=e,i=i._next;if(this._target.attr(this._props),this._transform){i=this._transform;var r=i.rotation,s=r-i.skewX,n=Math.cos(r)*i.scaleX,a=Math.sin(r)*i.scaleX,o=Math.sin(s)*-i.scaleY,l=Math.cos(s)*i.scaleY,h=1e-6,u=this._pxl,_=this._pyl;h>a&&a>-h&&(a=0),h>o&&o>-h&&(o=0),i.ox=this._pxg-(u*n+_*o),i.oy=this._pyg-(u*a+_*l),this._target.transform("m"+n+","+a+","+o+","+l+","+(i.tx+i.ox)+","+(i.ty+i.oy))}}}),u=h.prototype;u._parseTransform=function(t,i){if(!this._transform){var r,s,h,u,_,p,f,c,d,m=this._transform=a(t,!0),g=1e-6;if("object"==typeof i){if(r={scaleX:o(null!=i.scaleX?i.scaleX:i.scale,m.scaleX),scaleY:o(null!=i.scaleY?i.scaleY:i.scale,m.scaleY),tx:o(i.tx,m.tx),ty:o(i.ty,m.ty)},null!=i.shortRotation){r.rotation="number"==typeof i.shortRotation?i.shortRotation*e:l(i.shortRotation,m.rotation);var v=(r.rotation-m.rotation)%(2*Math.PI);v!==v%Math.PI&&(v+=Math.PI*(0>v?2:-2)),r.rotation=m.rotation+v}else r.rotation=null==i.rotation?m.rotation:"number"==typeof i.rotation?i.rotation*e:l(i.rotation,m.rotation);r.skewX=null==i.skewX?m.skewX:"number"==typeof i.skewX?i.skewX*e:l(i.skewX,m.skewX),r.skewY=null==i.skewY?m.skewY:"number"==typeof i.skewY?i.skewY*e:l(i.skewY,m.skewY),(s=r.skewY-m.skewY)&&(r.skewX+=s,r.rotation+=s),g>r.skewY&&r.skewY>-g&&(r.skewY=0),g>r.skewX&&r.skewX>-g&&(r.skewX=0),g>r.rotation&&r.rotation>-g&&(r.rotation=0),d=i.localPivot||i.globalPivot,"string"==typeof d?(_=d.split(","),p=Number(_[0]),f=Number(_[1])):"object"==typeof d?(p=Number(d.x),f=Number(d.y)):i.localPivot?(_=t.getBBox(!0),p=_.width/2,f=_.height/2):(_=t.getBBox(),p=_.x+_.width/2,f=_.y+_.height/2),i.localPivot?(c=t.matrix,p+=t.attr("x"),f+=t.attr("y"),this._pxl=p,this._pyl=f,this._pxg=p*c.a+f*c.c+c.e-m.tx,this._pyg=p*c.b+f*c.d+c.f-m.ty):(c=t.matrix.invert(),this._pxl=p*c.a+f*c.c+c.e,this._pyl=p*c.b+f*c.d+c.f,this._pxg=p-m.tx,this._pyg=f-m.ty)}else{if("string"!=typeof i)return;_=this._target.transform(),t.transform(i),r=a(t,!1),t.transform(_)}for(h in n)m[h]!==r[h]&&"shortRotation"!==h&&"scale"!==h&&(this._firstPT=u={_next:this._firstPT,t:m,p:h,s:m[h],c:r[h]-m[h],n:h,f:!1,r:!1,b:m[h],e:r[h],type:0},u._next&&(u._next._prev=u),this._overwriteProps.push("raphael_"+h))}}}),window._gsDefine&&window._gsQueue.pop()();
--------------------------------------------------------------------------------
/js/lib/gsap/plugins/RoundPropsPlugin.min.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * VERSION: beta 1.4.0
3 | * DATE: 2013-02-27
4 | * UPDATES AND DOCS AT: http://www.greensock.com
5 | *
6 | * @license Copyright (c) 2008-2014, GreenSock. All rights reserved.
7 | * This work is subject to the terms at http://www.greensock.com/terms_of_use.html or for
8 | * Club GreenSock members, the software agreement that was issued with your membership.
9 | *
10 | * @author: Jack Doyle, jack@greensock.com
11 | **/
12 | (window._gsQueue||(window._gsQueue=[])).push(function(){"use strict";var t=window._gsDefine.plugin({propName:"roundProps",priority:-1,API:2,init:function(t,e,i){return this._tween=i,!0}}),e=t.prototype;e._onInitAllProps=function(){for(var t,e,i,r=this._tween,s=r.vars.roundProps instanceof Array?r.vars.roundProps:r.vars.roundProps.split(","),n=s.length,a={},o=r._propLookup.roundProps;--n>-1;)a[s[n]]=1;for(n=s.length;--n>-1;)for(t=s[n],e=r._firstPT;e;)i=e._next,e.pg?e.t._roundProps(a,!0):e.n===t&&(this._add(e.t,t,e.s,e.c),i&&(i._prev=e._prev),e._prev?e._prev._next=i:r._firstPT===e&&(r._firstPT=i),e._next=e._prev=null,r._propLookup[t]=o),e=i;return!1},e._add=function(t,e,i,r){this._addTween(t,e,i,i+r,e,!0),this._overwriteProps.push(e)}}),window._gsDefine&&window._gsQueue.pop()();
--------------------------------------------------------------------------------
/js/lib/gsap/plugins/ScrollToPlugin.min.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * VERSION: 1.7.3
3 | * DATE: 2014-01-14
4 | * UPDATES AND DOCS AT: http://www.greensock.com
5 | *
6 | * @license Copyright (c) 2008-2014, GreenSock. All rights reserved.
7 | * This work is subject to the terms at http://www.greensock.com/terms_of_use.html or for
8 | * Club GreenSock members, the software agreement that was issued with your membership.
9 | *
10 | * @author: Jack Doyle, jack@greensock.com
11 | **/
12 | (window._gsQueue||(window._gsQueue=[])).push(function(){"use strict";var t=document.documentElement,e=window,i=function(i,s){var r="x"===s?"Width":"Height",n="scroll"+r,a="client"+r,o=document.body;return i===e||i===t||i===o?Math.max(t[n],o[n])-(e["inner"+r]||Math.max(t[a],o[a])):i[n]-i["offset"+r]},s=window._gsDefine.plugin({propName:"scrollTo",API:2,version:"1.7.3",init:function(t,s,r){return this._wdw=t===e,this._target=t,this._tween=r,"object"!=typeof s&&(s={y:s}),this._autoKill=s.autoKill!==!1,this.x=this.xPrev=this.getX(),this.y=this.yPrev=this.getY(),null!=s.x?(this._addTween(this,"x",this.x,"max"===s.x?i(t,"x"):s.x,"scrollTo_x",!0),this._overwriteProps.push("scrollTo_x")):this.skipX=!0,null!=s.y?(this._addTween(this,"y",this.y,"max"===s.y?i(t,"y"):s.y,"scrollTo_y",!0),this._overwriteProps.push("scrollTo_y")):this.skipY=!0,!0},set:function(t){this._super.setRatio.call(this,t);var s=this._wdw||!this.skipX?this.getX():this.xPrev,r=this._wdw||!this.skipY?this.getY():this.yPrev,n=r-this.yPrev,a=s-this.xPrev;this._autoKill&&(!this.skipX&&(a>7||-7>a)&&i(this._target,"x")>s&&(this.skipX=!0),!this.skipY&&(n>7||-7>n)&&i(this._target,"y")>r&&(this.skipY=!0),this.skipX&&this.skipY&&this._tween.kill()),this._wdw?e.scrollTo(this.skipX?s:this.x,this.skipY?r:this.y):(this.skipY||(this._target.scrollTop=this.y),this.skipX||(this._target.scrollLeft=this.x)),this.xPrev=this.x,this.yPrev=this.y}}),r=s.prototype;s.max=i,r.getX=function(){return this._wdw?null!=e.pageXOffset?e.pageXOffset:null!=t.scrollLeft?t.scrollLeft:document.body.scrollLeft:this._target.scrollLeft},r.getY=function(){return this._wdw?null!=e.pageYOffset?e.pageYOffset:null!=t.scrollTop?t.scrollTop:document.body.scrollTop:this._target.scrollTop},r._kill=function(t){return t.scrollTo_x&&(this.skipX=!0),t.scrollTo_y&&(this.skipY=!0),this._super._kill.call(this,t)}}),window._gsDefine&&window._gsQueue.pop()();
--------------------------------------------------------------------------------
/js/lib/gsap/plugins/TextPlugin.min.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * VERSION: 0.5.0
3 | * DATE: 2013-07-10
4 | * UPDATES AND DOCS AT: http://www.greensock.com
5 | *
6 | * @license Copyright (c) 2008-2014, GreenSock. All rights reserved.
7 | * This work is subject to the terms at http://www.greensock.com/terms_of_use.html or for
8 | * Club GreenSock members, the software agreement that was issued with your membership.
9 | *
10 | * @author: Jack Doyle, jack@greensock.com
11 | */
12 | (window._gsQueue||(window._gsQueue=[])).push(function(){"use strict";var t=function(e){var i=e.nodeType,s="";if(1===i||9===i||11===i){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)s+=t(e)}else if(3===i||4===i)return e.nodeValue;return s},e=window._gsDefine.plugin({propName:"text",API:2,version:"0.5.0",init:function(e,i,s){var r,n;if(!("innerHTML"in e))return!1;if(this._target=e,"object"!=typeof i&&(i={value:i}),void 0===i.value)return this._text=this._original=[""],!0;for(this._delimiter=i.delimiter||"",this._original=t(e).replace(/\s+/g," ").split(this._delimiter),this._text=i.value.replace(/\s+/g," ").split(this._delimiter),this._runBackwards=s.vars.runBackwards===!0,this._runBackwards&&(r=this._original,this._original=this._text,this._text=r),"string"==typeof i.newClass&&(this._newClass=i.newClass,this._hasClass=!0),"string"==typeof i.oldClass&&(this._oldClass=i.oldClass,this._hasClass=!0),r=this._original.length-this._text.length,n=0>r?this._original:this._text,this._fillChar=i.fillChar||(i.padSpace?" ":""),0>r&&(r=-r);--r>-1;)n.push(this._fillChar);return!0},set:function(t){t>1?t=1:0>t&&(t=0),this._runBackwards&&(t=1-t);var e,i,s,r=this._text.length,n=0|t*r+.5;this._hasClass?(e=this._newClass&&0!==n,i=this._oldClass&&n!==r,s=(e?"":"")+this._text.slice(0,n).join(this._delimiter)+(e?"":"")+(i?"":"")+this._delimiter+this._original.slice(n).join(this._delimiter)+(i?"":"")):s=this._text.slice(0,n).join(this._delimiter)+this._delimiter+this._original.slice(n).join(this._delimiter),this._target.innerHTML=" "===this._fillChar&&-1!==s.indexOf(" ")?s.split(" ").join(" "):s}}),i=e.prototype;i._newClass=i._oldClass=i._delimiter=""}),window._gsDefine&&window._gsQueue.pop()();
--------------------------------------------------------------------------------
/js/lib/loaders/HDRCubeTextureLoader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Prashant Sharma / spidersharma03
3 | * @author Ben Houston / http://clara.io / bhouston
4 | */
5 |
6 | THREE.HDRCubeTextureLoader = function (manager) {
7 | this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;
8 | // override in sub classes
9 | this.hdrLoader = new THREE.RGBELoader();
10 |
11 | if( THREE.Encodings === undefined ) throw new Error( "HDRCubeMapLoader requires THREE.Encodings" );
12 | }
13 |
14 | THREE.HDRCubeTextureLoader.prototype.load = function(type, urls, onLoad, onProgress, onError) {
15 | var texture = new THREE.CubeTexture();
16 |
17 | texture.type = type;
18 | texture.encoding = (type === THREE.UnsignedByteType) ? THREE.RGBEEncoding : THREE.LinearEncoding;
19 | texture.format = (type === THREE.UnsignedByteType ) ? THREE.RGBAFormat : THREE.RGBFormat;
20 | texture.minFilter = (texture.encoding === THREE.RGBEEncoding ) ? THREE.NearestFilter : THREE.LinearFilter;
21 | texture.magFilter = (texture.encoding === THREE.RGBEEncoding ) ? THREE.NearestFilter : THREE.LinearFilter;
22 | texture.generateMipmaps = (texture.encoding !== THREE.RGBEEncoding );
23 | texture.anisotropy = 0;
24 |
25 | var scope = this.hdrLoader;
26 |
27 | var loaded = 0;
28 |
29 | function loadHDRData(i, onLoad, onProgress, onError) {
30 | var loader = new THREE.XHRLoader( this.manager );
31 | loader.setResponseType( 'arraybuffer' );
32 |
33 | loader.load( urls[i], function ( buffer ) {
34 | loaded++;
35 |
36 | var texData = scope._parser( buffer );
37 |
38 | if ( ! texData ) return;
39 |
40 | if(type === THREE.FloatType) {
41 | var numElements = ( texData.data.length / 4 )*3;
42 | var floatdata = new Float32Array( numElements );
43 | for( var j=0; j 1 ) {
88 |
89 | node.animationCache.prevKey = keys[ 0 ];
90 | node.animationCache.nextKey = keys[ 1 ];
91 |
92 | this.startTime = Math.min( keys[ 0 ].time, this.startTime );
93 | this.endTime = Math.max( keys[ keys.length - 1 ].time, this.endTime );
94 |
95 | }
96 |
97 | }
98 |
99 | this.update( 0 );
100 |
101 | }
102 |
103 | this.isPaused = false;
104 | },
105 |
106 | stop: function () {
107 |
108 | this.isPlaying = false;
109 | this.isPaused = false;
110 |
111 | // reset JIT matrix and remove cache
112 |
113 | for ( var h = 0; h < this.data.hierarchy.length; h ++ ) {
114 |
115 | var obj = this.hierarchy[ h ];
116 | var node = this.data.hierarchy[ h ];
117 |
118 | if ( node.animationCache !== undefined ) {
119 |
120 | var original = node.animationCache.originalMatrix;
121 |
122 | original.copy( obj.matrix );
123 | obj.matrix = original;
124 |
125 | delete node.animationCache;
126 |
127 | }
128 |
129 | }
130 |
131 | },
132 |
133 | update: function ( delta ) {
134 |
135 | if ( this.isPlaying === false ) return;
136 |
137 | this.currentTime += delta * this.timeScale;
138 |
139 | //
140 |
141 | var duration = this.data.length;
142 |
143 | if ( this.loop === true && this.currentTime > duration ) {
144 |
145 | this.currentTime %= duration;
146 |
147 | }
148 |
149 | this.currentTime = Math.min( this.currentTime, duration );
150 |
151 | for ( var h = 0, hl = this.hierarchy.length; h < hl; h ++ ) {
152 |
153 | var object = this.hierarchy[ h ];
154 | var node = this.data.hierarchy[ h ];
155 |
156 | var keys = node.keys,
157 | animationCache = node.animationCache;
158 |
159 |
160 | if ( keys.length ) {
161 |
162 | var prevKey = animationCache.prevKey;
163 | var nextKey = animationCache.nextKey;
164 |
165 | if ( nextKey.time <= this.currentTime ) {
166 |
167 | while ( nextKey.time < this.currentTime && nextKey.index > prevKey.index ) {
168 |
169 | prevKey = nextKey;
170 | nextKey = keys[ prevKey.index + 1 ];
171 |
172 | }
173 |
174 | animationCache.prevKey = prevKey;
175 | animationCache.nextKey = nextKey;
176 |
177 | }
178 |
179 | if ( nextKey.time >= this.currentTime ) {
180 |
181 | prevKey.interpolate( nextKey, this.currentTime );
182 |
183 | } else {
184 |
185 | prevKey.interpolate( nextKey, nextKey.time );
186 |
187 | }
188 |
189 | this.data.hierarchy[ h ].node.updateMatrix();
190 | object.matrixWorldNeedsUpdate = true;
191 |
192 | }
193 |
194 | }
195 |
196 | },
197 |
198 | getNextKeyWith: function ( sid, h, key ) {
199 |
200 | var keys = this.data.hierarchy[ h ].keys;
201 | key = key % keys.length;
202 |
203 | for ( ; key < keys.length; key ++ ) {
204 |
205 | if ( keys[ key ].hasTarget( sid ) ) {
206 |
207 | return keys[ key ];
208 |
209 | }
210 |
211 | }
212 |
213 | return keys[ 0 ];
214 |
215 | },
216 |
217 | getPrevKeyWith: function ( sid, h, key ) {
218 |
219 | var keys = this.data.hierarchy[ h ].keys;
220 | key = key >= 0 ? key : key + keys.length;
221 |
222 | for ( ; key >= 0; key -- ) {
223 |
224 | if ( keys[ key ].hasTarget( sid ) ) {
225 |
226 | return keys[ key ];
227 |
228 | }
229 |
230 | }
231 |
232 | return keys[ keys.length - 1 ];
233 |
234 | }
235 |
236 | };
237 |
--------------------------------------------------------------------------------
/js/lib/loaders/ctm/CTMWorker.js:
--------------------------------------------------------------------------------
1 | importScripts( "lzma.js", "ctm.js" );
2 |
3 | self.onmessage = function( event ) {
4 |
5 | var files = [];
6 |
7 | for ( var i = 0; i < event.data.offsets.length; i ++ ) {
8 |
9 | var stream = new CTM.Stream( event.data.data );
10 | stream.offset = event.data.offsets[ i ];
11 |
12 | files[ i ] = new CTM.File( stream );
13 |
14 | }
15 |
16 | self.postMessage( files );
17 | self.close();
18 |
19 | };
20 |
--------------------------------------------------------------------------------
/js/lib/loaders/ctm/license/OpenCTM.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2009-2010 Marcus Geelnard
2 |
3 | This software is provided 'as-is', without any express or implied
4 | warranty. In no event will the authors be held liable for any damages
5 | arising from the use of this software.
6 |
7 | Permission is granted to anyone to use this software for any purpose,
8 | including commercial applications, and to alter it and redistribute it
9 | freely, subject to the following restrictions:
10 |
11 | 1. The origin of this software must not be misrepresented; you must not
12 | claim that you wrote the original software. If you use this software
13 | in a product, an acknowledgment in the product documentation would be
14 | appreciated but is not required.
15 |
16 | 2. Altered source versions must be plainly marked as such, and must not
17 | be misrepresented as being the original software.
18 |
19 | 3. This notice may not be removed or altered from any source
20 | distribution.
21 |
--------------------------------------------------------------------------------
/js/lib/loaders/ctm/license/js-lzma.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2011 Juan Mellado
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
20 |
--------------------------------------------------------------------------------
/js/lib/loaders/ctm/license/js-openctm.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2011 Juan Mellado
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
20 |
--------------------------------------------------------------------------------
/js/lib/loaders/gltf/glTFShaders.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Tony Parisi / http://www.tonyparisi.com/
3 | */
4 |
5 | THREE.glTFShaders = ( function () {
6 |
7 | var shaders = [];
8 |
9 | return {
10 | add : function(shader) {
11 | shaders.push(shader);
12 | },
13 |
14 | remove: function(shader) {
15 |
16 | var i = shaders.indexOf(shader);
17 |
18 | if ( i !== -1 ) {
19 | shaders.splice( i, 1 );
20 | }
21 | },
22 |
23 | removeAll: function(shader) {
24 |
25 | // probably want to clean up the shaders, too, but not for now
26 | shaders = [];
27 | },
28 |
29 | bindShaderParameters: function(scene) {
30 | for (i = 0; i < shaders.length; i++)
31 | {
32 | shaders[i].bindParameters(scene);
33 | }
34 | },
35 |
36 | update : function(scene, camera) {
37 | for (i = 0; i < shaders.length; i++)
38 | {
39 | shaders[i].update(scene, camera);
40 | }
41 | },
42 | };
43 | })();
44 |
45 | // Construction/initialization
46 | THREE.glTFShader = function(material, params, object, scene) {
47 | this.material = material;
48 | this.parameters = params.technique.parameters;
49 | this.uniforms = params.technique.uniforms;
50 | this.joints = params.joints;
51 | this.object = object;
52 | this.semantics = {};
53 | this.m4 = new THREE.Matrix4;
54 | }
55 |
56 |
57 | // bindParameters - connect the uniform values to their source parameters
58 | THREE.glTFShader.prototype.bindParameters = function(scene) {
59 |
60 | function findObject(o, p) {
61 | if (o.glTFID == param.node) {
62 | p.sourceObject = o;
63 | }
64 | }
65 |
66 | for (var uniform in this.uniforms) {
67 | var pname = this.uniforms[uniform];
68 | var param = this.parameters[pname];
69 | if (param.semantic) {
70 |
71 | var p = {
72 | semantic : param.semantic,
73 | uniform: this.material.uniforms[uniform]
74 | };
75 |
76 | if (param.node) {
77 | scene.traverse(function(o) { findObject(o, p)});
78 | }
79 | else {
80 | p.sourceObject = this.object;
81 | }
82 |
83 | this.semantics[pname] = p;
84 |
85 | }
86 | }
87 |
88 | }
89 |
90 | // Update - update all the uniform values
91 | THREE.glTFShader.prototype.update = function(scene, camera) {
92 |
93 | // update scene graph
94 |
95 | scene.updateMatrixWorld();
96 |
97 | // update camera matrices and frustum
98 | camera.updateMatrixWorld();
99 | camera.matrixWorldInverse.getInverse( camera.matrixWorld );
100 |
101 | for (var sname in this.semantics) {
102 | var semantic = this.semantics[sname];
103 | if (semantic) {
104 | switch (semantic.semantic) {
105 | case "MODELVIEW" :
106 | var m4 = semantic.uniform.value;
107 | m4.multiplyMatrices(camera.matrixWorldInverse,
108 | semantic.sourceObject.matrixWorld);
109 | break;
110 |
111 | case "MODELVIEWINVERSETRANSPOSE" :
112 | var m3 = semantic.uniform.value;
113 | this.m4.multiplyMatrices(camera.matrixWorldInverse,
114 | semantic.sourceObject.matrixWorld);
115 | m3.getNormalMatrix(this.m4);
116 | break;
117 |
118 | case "PROJECTION" :
119 | var m4 = semantic.uniform.value;
120 | m4.copy(camera.projectionMatrix);
121 | break;
122 |
123 | case "JOINTMATRIX" :
124 |
125 | var m4v = semantic.uniform.value;
126 | for (var mi = 0; mi < m4v.length; mi++) {
127 | // So it goes like this:
128 | // SkinnedMesh world matrix is already baked into MODELVIEW;
129 | // ransform joints to local space,
130 | // then transform using joint's inverse
131 | m4v[mi].getInverse(semantic.sourceObject.matrixWorld).
132 | multiply(this.joints[mi].matrixWorld).
133 | multiply(this.object.skeleton.boneInverses[mi]);
134 | }
135 |
136 | //console.log("Joint:", semantic)
137 | break;
138 |
139 | default :
140 | throw new Error("Unhandled shader semantic" + semantic);
141 | break;
142 | }
143 | }
144 | }
145 | }
146 |
--------------------------------------------------------------------------------
/js/lib/minivents.min.js:
--------------------------------------------------------------------------------
1 | function Events(e){var t={},n,r,i,s=Array;e=e||this;e.on=function(e,n,r){t[e]||(t[e]=[]);t[e].push({f:n,c:r})};e.off=function(e,i){r=t[e]||[];n=r.length=i?r.length:0;while(~--n<0)i==r[n].f&&r.splice(n,1)};e.emit=function(){i=s.apply([],arguments);r=t[i.shift()]||[];i=i[0]instanceof s&&i[0]||i;n=r.length;while(~--n<0)r[n].f.apply(r[n].c,i)}}
2 |
--------------------------------------------------------------------------------
/js/lib/postprocessing/BloomPass.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | */
4 |
5 | THREE.BloomPass = function ( strength, kernelSize, sigma, resolution ) {
6 |
7 | THREE.Pass.call( this );
8 |
9 | strength = ( strength !== undefined ) ? strength : 1;
10 | kernelSize = ( kernelSize !== undefined ) ? kernelSize : 25;
11 | sigma = ( sigma !== undefined ) ? sigma : 4.0;
12 | resolution = ( resolution !== undefined ) ? resolution : 256;
13 |
14 | // render targets
15 |
16 | var pars = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBAFormat };
17 |
18 | this.renderTargetX = new THREE.WebGLRenderTarget( resolution, resolution, pars );
19 | this.renderTargetY = new THREE.WebGLRenderTarget( resolution, resolution, pars );
20 |
21 | // copy material
22 |
23 | if ( THREE.CopyShader === undefined )
24 | console.error( "THREE.BloomPass relies on THREE.CopyShader" );
25 |
26 | var copyShader = THREE.CopyShader;
27 |
28 | this.copyUniforms = THREE.UniformsUtils.clone( copyShader.uniforms );
29 |
30 | this.copyUniforms[ "opacity" ].value = strength;
31 |
32 | this.materialCopy = new THREE.ShaderMaterial( {
33 |
34 | uniforms: this.copyUniforms,
35 | vertexShader: copyShader.vertexShader,
36 | fragmentShader: copyShader.fragmentShader,
37 | blending: THREE.AdditiveBlending,
38 | transparent: true
39 |
40 | } );
41 |
42 | // convolution material
43 |
44 | if ( THREE.ConvolutionShader === undefined )
45 | console.error( "THREE.BloomPass relies on THREE.ConvolutionShader" );
46 |
47 | var convolutionShader = THREE.ConvolutionShader;
48 |
49 | this.convolutionUniforms = THREE.UniformsUtils.clone( convolutionShader.uniforms );
50 |
51 | this.convolutionUniforms[ "uImageIncrement" ].value = THREE.BloomPass.blurX;
52 | this.convolutionUniforms[ "cKernel" ].value = THREE.ConvolutionShader.buildKernel( sigma );
53 |
54 | this.materialConvolution = new THREE.ShaderMaterial( {
55 |
56 | uniforms: this.convolutionUniforms,
57 | vertexShader: convolutionShader.vertexShader,
58 | fragmentShader: convolutionShader.fragmentShader,
59 | defines: {
60 | "KERNEL_SIZE_FLOAT": kernelSize.toFixed( 1 ),
61 | "KERNEL_SIZE_INT": kernelSize.toFixed( 0 )
62 | }
63 |
64 | } );
65 |
66 | this.needsSwap = false;
67 |
68 | this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
69 | this.scene = new THREE.Scene();
70 |
71 | this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null );
72 | this.scene.add( this.quad );
73 |
74 | };
75 |
76 | THREE.BloomPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
77 |
78 | constructor: THREE.BloomPass,
79 |
80 | render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) {
81 |
82 | if ( maskActive ) renderer.context.disable( renderer.context.STENCIL_TEST );
83 |
84 | // Render quad with blured scene into texture (convolution pass 1)
85 |
86 | this.quad.material = this.materialConvolution;
87 |
88 | this.convolutionUniforms[ "tDiffuse" ].value = readBuffer.texture;
89 | this.convolutionUniforms[ "uImageIncrement" ].value = THREE.BloomPass.blurX;
90 |
91 | renderer.render( this.scene, this.camera, this.renderTargetX, true );
92 |
93 |
94 | // Render quad with blured scene into texture (convolution pass 2)
95 |
96 | this.convolutionUniforms[ "tDiffuse" ].value = this.renderTargetX.texture;
97 | this.convolutionUniforms[ "uImageIncrement" ].value = THREE.BloomPass.blurY;
98 |
99 | renderer.render( this.scene, this.camera, this.renderTargetY, true );
100 |
101 | // Render original scene with superimposed blur to texture
102 |
103 | this.quad.material = this.materialCopy;
104 |
105 | this.copyUniforms[ "tDiffuse" ].value = this.renderTargetY.texture;
106 |
107 | if ( maskActive ) renderer.context.enable( renderer.context.STENCIL_TEST );
108 |
109 | renderer.render( this.scene, this.camera, readBuffer, this.clear );
110 |
111 | }
112 |
113 | } );
114 |
115 | THREE.BloomPass.blurX = new THREE.Vector2( 0.001953125, 0.0 );
116 | THREE.BloomPass.blurY = new THREE.Vector2( 0.0, 0.001953125 );
117 |
--------------------------------------------------------------------------------
/js/lib/postprocessing/BokehPass.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Depth-of-field post-process with bokeh shader
3 | */
4 |
5 |
6 | THREE.BokehPass = function ( scene, camera, params ) {
7 |
8 | THREE.Pass.call( this );
9 |
10 | this.scene = scene;
11 | this.camera = camera;
12 |
13 | var focus = ( params.focus !== undefined ) ? params.focus : 1.0;
14 | var aspect = ( params.aspect !== undefined ) ? params.aspect : camera.aspect;
15 | var aperture = ( params.aperture !== undefined ) ? params.aperture : 0.025;
16 | var maxblur = ( params.maxblur !== undefined ) ? params.maxblur : 1.0;
17 |
18 | // render targets
19 |
20 | var width = params.width || window.innerWidth || 1;
21 | var height = params.height || window.innerHeight || 1;
22 |
23 | this.renderTargetColor = new THREE.WebGLRenderTarget( width, height, {
24 | minFilter: THREE.LinearFilter,
25 | magFilter: THREE.LinearFilter,
26 | format: THREE.RGBFormat
27 | } );
28 |
29 | this.renderTargetDepth = this.renderTargetColor.clone();
30 |
31 | // depth material
32 |
33 | this.materialDepth = new THREE.MeshDepthMaterial();
34 |
35 | // bokeh material
36 |
37 | if ( THREE.BokehShader === undefined ) {
38 |
39 | console.error( "THREE.BokehPass relies on THREE.BokehShader" );
40 |
41 | }
42 |
43 | var bokehShader = THREE.BokehShader;
44 | var bokehUniforms = THREE.UniformsUtils.clone( bokehShader.uniforms );
45 |
46 | bokehUniforms[ "tDepth" ].value = this.renderTargetDepth.texture;
47 |
48 | bokehUniforms[ "focus" ].value = focus;
49 | bokehUniforms[ "aspect" ].value = aspect;
50 | bokehUniforms[ "aperture" ].value = aperture;
51 | bokehUniforms[ "maxblur" ].value = maxblur;
52 |
53 | this.materialBokeh = new THREE.ShaderMaterial( {
54 | uniforms: bokehUniforms,
55 | vertexShader: bokehShader.vertexShader,
56 | fragmentShader: bokehShader.fragmentShader
57 | } );
58 |
59 | this.uniforms = bokehUniforms;
60 | this.needsSwap = false;
61 |
62 | this.camera2 = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
63 | this.scene2 = new THREE.Scene();
64 |
65 | this.quad2 = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null );
66 | this.scene2.add( this.quad2 );
67 |
68 | };
69 |
70 | THREE.BokehPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
71 |
72 | constructor: THREE.BokehPass,
73 |
74 | render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) {
75 |
76 | this.quad2.material = this.materialBokeh;
77 |
78 | // Render depth into texture
79 |
80 | this.scene.overrideMaterial = this.materialDepth;
81 |
82 | renderer.render( this.scene, this.camera, this.renderTargetDepth, true );
83 |
84 | // Render bokeh composite
85 |
86 | this.uniforms[ "tColor" ].value = readBuffer.texture;
87 |
88 | if ( this.renderToScreen ) {
89 |
90 | renderer.render( this.scene2, this.camera2 );
91 |
92 | } else {
93 |
94 | renderer.render( this.scene2, this.camera2, writeBuffer, this.clear );
95 |
96 | }
97 |
98 | this.scene.overrideMaterial = null;
99 |
100 | }
101 |
102 | } );
103 |
--------------------------------------------------------------------------------
/js/lib/postprocessing/ClearPass.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author mrdoob / http://mrdoob.com/
3 | */
4 |
5 | THREE.ClearPass = function () {
6 |
7 | THREE.Pass.call( this );
8 |
9 | this.needsSwap = false;
10 |
11 | };
12 |
13 | THREE.ClearPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
14 |
15 | constructor: THREE.ClearPass,
16 |
17 | render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) {
18 |
19 | renderer.setRenderTarget( readBuffer );
20 | renderer.clear();
21 |
22 | }
23 |
24 | } );
25 |
--------------------------------------------------------------------------------
/js/lib/postprocessing/DotScreenPass.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | */
4 |
5 | THREE.DotScreenPass = function ( center, angle, scale ) {
6 |
7 | THREE.Pass.call( this );
8 |
9 | if ( THREE.DotScreenShader === undefined )
10 | console.error( "THREE.DotScreenPass relies on THREE.DotScreenShader" );
11 |
12 | var shader = THREE.DotScreenShader;
13 |
14 | this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
15 |
16 | if ( center !== undefined ) this.uniforms[ "center" ].value.copy( center );
17 | if ( angle !== undefined ) this.uniforms[ "angle" ].value = angle;
18 | if ( scale !== undefined ) this.uniforms[ "scale" ].value = scale;
19 |
20 | this.material = new THREE.ShaderMaterial( {
21 |
22 | uniforms: this.uniforms,
23 | vertexShader: shader.vertexShader,
24 | fragmentShader: shader.fragmentShader
25 |
26 | } );
27 |
28 | this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
29 | this.scene = new THREE.Scene();
30 |
31 | this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null );
32 | this.scene.add( this.quad );
33 |
34 | };
35 |
36 | THREE.DotScreenPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
37 |
38 | constructor: THREE.DotScreenPass,
39 |
40 | render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) {
41 |
42 | this.uniforms[ "tDiffuse" ].value = readBuffer.texture;
43 | this.uniforms[ "tSize" ].value.set( readBuffer.width, readBuffer.height );
44 |
45 | this.quad.material = this.material;
46 |
47 | if ( this.renderToScreen ) {
48 |
49 | renderer.render( this.scene, this.camera );
50 |
51 | } else {
52 |
53 | renderer.render( this.scene, this.camera, writeBuffer, this.clear );
54 |
55 | }
56 |
57 | }
58 |
59 | } );
60 |
--------------------------------------------------------------------------------
/js/lib/postprocessing/EffectComposer.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | */
4 |
5 | THREE.EffectComposer = function ( renderer, renderTarget ) {
6 |
7 | this.renderer = renderer;
8 |
9 | if ( renderTarget === undefined ) {
10 |
11 | var parameters = {
12 | minFilter: THREE.LinearFilter,
13 | magFilter: THREE.LinearFilter,
14 | format: THREE.RGBAFormat,
15 | stencilBuffer: false
16 | };
17 | var size = renderer.getSize();
18 | renderTarget = new THREE.WebGLRenderTarget( size.width, size.height, parameters );
19 |
20 | }
21 |
22 | this.renderTarget1 = renderTarget;
23 | this.renderTarget2 = renderTarget.clone();
24 |
25 | this.writeBuffer = this.renderTarget1;
26 | this.readBuffer = this.renderTarget2;
27 |
28 | this.passes = [];
29 |
30 | if ( THREE.CopyShader === undefined )
31 | console.error( "THREE.EffectComposer relies on THREE.CopyShader" );
32 |
33 | this.copyPass = new THREE.ShaderPass( THREE.CopyShader );
34 |
35 | };
36 |
37 | Object.assign( THREE.EffectComposer.prototype, {
38 |
39 | swapBuffers: function() {
40 |
41 | var tmp = this.readBuffer;
42 | this.readBuffer = this.writeBuffer;
43 | this.writeBuffer = tmp;
44 |
45 | },
46 |
47 | addPass: function ( pass ) {
48 |
49 | this.passes.push( pass );
50 |
51 | var size = this.renderer.getSize();
52 | pass.setSize( size.width, size.height );
53 |
54 | },
55 |
56 | insertPass: function ( pass, index ) {
57 |
58 | this.passes.splice( index, 0, pass );
59 |
60 | },
61 |
62 | render: function ( delta ) {
63 |
64 | var maskActive = false;
65 |
66 | var pass, i, il = this.passes.length;
67 |
68 | for ( i = 0; i < il; i ++ ) {
69 |
70 | pass = this.passes[ i ];
71 |
72 | if ( pass.enabled === false ) continue;
73 |
74 | pass.render( this.renderer, this.writeBuffer, this.readBuffer, delta, maskActive );
75 |
76 | if ( pass.needsSwap ) {
77 |
78 | if ( maskActive ) {
79 |
80 | var context = this.renderer.context;
81 |
82 | context.stencilFunc( context.NOTEQUAL, 1, 0xffffffff );
83 |
84 | this.copyPass.render( this.renderer, this.writeBuffer, this.readBuffer, delta );
85 |
86 | context.stencilFunc( context.EQUAL, 1, 0xffffffff );
87 |
88 | }
89 |
90 | this.swapBuffers();
91 |
92 | }
93 |
94 | if ( pass instanceof THREE.MaskPass ) {
95 |
96 | maskActive = true;
97 |
98 | } else if ( pass instanceof THREE.ClearMaskPass ) {
99 |
100 | maskActive = false;
101 |
102 | }
103 |
104 | }
105 |
106 | },
107 |
108 | reset: function ( renderTarget ) {
109 |
110 | if ( renderTarget === undefined ) {
111 |
112 | var size = this.renderer.getSize();
113 |
114 | renderTarget = this.renderTarget1.clone();
115 | renderTarget.setSize( size.width, size.height );
116 |
117 | }
118 |
119 | this.renderTarget1.dispose();
120 | this.renderTarget2.dispose();
121 | this.renderTarget1 = renderTarget;
122 | this.renderTarget2 = renderTarget.clone();
123 |
124 | this.writeBuffer = this.renderTarget1;
125 | this.readBuffer = this.renderTarget2;
126 |
127 | },
128 |
129 | setSize: function ( width, height ) {
130 |
131 | this.renderTarget1.setSize( width, height );
132 | this.renderTarget2.setSize( width, height );
133 |
134 | for ( var i = 0; i < this.passes.length; i ++ ) {
135 |
136 | this.passes[i].setSize( width, height );
137 |
138 | }
139 |
140 | }
141 |
142 | } );
143 |
144 |
145 | THREE.Pass = function () {
146 |
147 | // if set to true, the pass is processed by the composer
148 | this.enabled = true;
149 |
150 | // if set to true, the pass indicates to swap read and write buffer after rendering
151 | this.needsSwap = true;
152 |
153 | // if set to true, the pass clears its buffer before rendering
154 | this.clear = false;
155 |
156 | // if set to true, the result of the pass is rendered to screen
157 | this.renderToScreen = false;
158 |
159 | };
160 |
161 | Object.assign( THREE.Pass.prototype, {
162 |
163 | setSize: function( width, height ) {},
164 |
165 | render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) {
166 |
167 | console.error( "THREE.Pass: .render() must be implemented in derived pass." );
168 |
169 | }
170 |
171 | } );
172 |
--------------------------------------------------------------------------------
/js/lib/postprocessing/FilmPass.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | */
4 |
5 | THREE.FilmPass = function ( noiseIntensity, scanlinesIntensity, scanlinesCount, grayscale ) {
6 |
7 | THREE.Pass.call( this );
8 |
9 | if ( THREE.FilmShader === undefined )
10 | console.error( "THREE.FilmPass relies on THREE.FilmShader" );
11 |
12 | var shader = THREE.FilmShader;
13 |
14 | this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
15 |
16 | this.material = new THREE.ShaderMaterial( {
17 |
18 | uniforms: this.uniforms,
19 | vertexShader: shader.vertexShader,
20 | fragmentShader: shader.fragmentShader
21 |
22 | } );
23 |
24 | if ( grayscale !== undefined ) this.uniforms.grayscale.value = grayscale;
25 | if ( noiseIntensity !== undefined ) this.uniforms.nIntensity.value = noiseIntensity;
26 | if ( scanlinesIntensity !== undefined ) this.uniforms.sIntensity.value = scanlinesIntensity;
27 | if ( scanlinesCount !== undefined ) this.uniforms.sCount.value = scanlinesCount;
28 |
29 | this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
30 | this.scene = new THREE.Scene();
31 |
32 | this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null );
33 | this.scene.add( this.quad );
34 |
35 | };
36 |
37 | THREE.FilmPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
38 |
39 | constructor: THREE.FilmPass,
40 |
41 | render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) {
42 |
43 | this.uniforms[ "tDiffuse" ].value = readBuffer.texture;
44 | this.uniforms[ "time" ].value += delta;
45 |
46 | this.quad.material = this.material;
47 |
48 | if ( this.renderToScreen ) {
49 |
50 | renderer.render( this.scene, this.camera );
51 |
52 | } else {
53 |
54 | renderer.render( this.scene, this.camera, writeBuffer, this.clear );
55 |
56 | }
57 |
58 | }
59 |
60 | } );
61 |
--------------------------------------------------------------------------------
/js/lib/postprocessing/GlitchPass.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | */
4 |
5 | THREE.GlitchPass = function ( dt_size ) {
6 |
7 | THREE.Pass.call( this );
8 |
9 | if ( THREE.DigitalGlitch === undefined ) console.error( "THREE.GlitchPass relies on THREE.DigitalGlitch" );
10 |
11 | var shader = THREE.DigitalGlitch;
12 | this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
13 |
14 | if ( dt_size == undefined ) dt_size = 64;
15 |
16 |
17 | this.uniforms[ "tDisp" ].value = this.generateHeightmap( dt_size );
18 |
19 |
20 | this.material = new THREE.ShaderMaterial( {
21 | uniforms: this.uniforms,
22 | vertexShader: shader.vertexShader,
23 | fragmentShader: shader.fragmentShader
24 | } );
25 |
26 | this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
27 | this.scene = new THREE.Scene();
28 |
29 | this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null );
30 | this.scene.add( this.quad );
31 |
32 | this.goWild = false;
33 | this.curF = 0;
34 | this.generateTrigger();
35 |
36 | };
37 |
38 | THREE.GlitchPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
39 |
40 | constructor: THREE.GlitchPass,
41 |
42 | render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) {
43 |
44 | this.uniforms[ "tDiffuse" ].value = readBuffer.texture;
45 | this.uniforms[ 'seed' ].value = Math.random();//default seeding
46 | this.uniforms[ 'byp' ].value = 0;
47 |
48 | if ( this.curF % this.randX == 0 || this.goWild == true ) {
49 |
50 | this.uniforms[ 'amount' ].value = Math.random() / 30;
51 | this.uniforms[ 'angle' ].value = THREE.Math.randFloat( - Math.PI, Math.PI );
52 | this.uniforms[ 'seed_x' ].value = THREE.Math.randFloat( - 1, 1 );
53 | this.uniforms[ 'seed_y' ].value = THREE.Math.randFloat( - 1, 1 );
54 | this.uniforms[ 'distortion_x' ].value = THREE.Math.randFloat( 0, 1 );
55 | this.uniforms[ 'distortion_y' ].value = THREE.Math.randFloat( 0, 1 );
56 | this.curF = 0;
57 | this.generateTrigger();
58 |
59 | } else if ( this.curF % this.randX < this.randX / 5 ) {
60 |
61 | this.uniforms[ 'amount' ].value = Math.random() / 90;
62 | this.uniforms[ 'angle' ].value = THREE.Math.randFloat( - Math.PI, Math.PI );
63 | this.uniforms[ 'distortion_x' ].value = THREE.Math.randFloat( 0, 1 );
64 | this.uniforms[ 'distortion_y' ].value = THREE.Math.randFloat( 0, 1 );
65 | this.uniforms[ 'seed_x' ].value = THREE.Math.randFloat( - 0.3, 0.3 );
66 | this.uniforms[ 'seed_y' ].value = THREE.Math.randFloat( - 0.3, 0.3 );
67 |
68 | } else if ( this.goWild == false ) {
69 |
70 | this.uniforms[ 'byp' ].value = 1;
71 |
72 | }
73 |
74 | this.curF ++;
75 | this.quad.material = this.material;
76 |
77 | if ( this.renderToScreen ) {
78 |
79 | renderer.render( this.scene, this.camera );
80 |
81 | } else {
82 |
83 | renderer.render( this.scene, this.camera, writeBuffer, this.clear );
84 |
85 | }
86 |
87 | },
88 |
89 | generateTrigger: function() {
90 |
91 | this.randX = THREE.Math.randInt( 120, 240 );
92 |
93 | },
94 |
95 | generateHeightmap: function( dt_size ) {
96 |
97 | var data_arr = new Float32Array( dt_size * dt_size * 3 );
98 | var length = dt_size * dt_size;
99 |
100 | for ( var i = 0; i < length; i ++ ) {
101 |
102 | var val = THREE.Math.randFloat( 0, 1 );
103 | data_arr[ i * 3 + 0 ] = val;
104 | data_arr[ i * 3 + 1 ] = val;
105 | data_arr[ i * 3 + 2 ] = val;
106 |
107 | }
108 |
109 | var texture = new THREE.DataTexture( data_arr, dt_size, dt_size, THREE.RGBFormat, THREE.FloatType );
110 | texture.needsUpdate = true;
111 | return texture;
112 |
113 | }
114 |
115 | } );
116 |
--------------------------------------------------------------------------------
/js/lib/postprocessing/MaskPass.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | */
4 |
5 | THREE.MaskPass = function ( scene, camera ) {
6 |
7 | THREE.Pass.call( this );
8 |
9 | this.scene = scene;
10 | this.camera = camera;
11 |
12 | this.clear = true;
13 | this.needsSwap = false;
14 |
15 | this.inverse = false;
16 |
17 | };
18 |
19 | THREE.MaskPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
20 |
21 | constructor: THREE.MaskPass,
22 |
23 | render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) {
24 |
25 | var context = renderer.context;
26 | var state = renderer.state;
27 |
28 | // don't update color or depth
29 |
30 | state.buffers.color.setMask( false );
31 | state.buffers.depth.setMask( false );
32 |
33 | // lock buffers
34 |
35 | state.buffers.color.setLocked( true );
36 | state.buffers.depth.setLocked( true );
37 |
38 | // set up stencil
39 |
40 | var writeValue, clearValue;
41 |
42 | if ( this.inverse ) {
43 |
44 | writeValue = 0;
45 | clearValue = 1;
46 |
47 | } else {
48 |
49 | writeValue = 1;
50 | clearValue = 0;
51 |
52 | }
53 |
54 | state.buffers.stencil.setTest( true );
55 | state.buffers.stencil.setOp( context.REPLACE, context.REPLACE, context.REPLACE );
56 | state.buffers.stencil.setFunc( context.ALWAYS, writeValue, 0xffffffff );
57 | state.buffers.stencil.setClear( clearValue );
58 |
59 | // draw into the stencil buffer
60 |
61 | renderer.render( this.scene, this.camera, readBuffer, this.clear );
62 | renderer.render( this.scene, this.camera, writeBuffer, this.clear );
63 |
64 | // unlock color and depth buffer for subsequent rendering
65 |
66 | state.buffers.color.setLocked( false );
67 | state.buffers.depth.setLocked( false );
68 |
69 | // only render where stencil is set to 1
70 |
71 | state.buffers.stencil.setFunc( context.EQUAL, 1, 0xffffffff ); // draw if == 1
72 | state.buffers.stencil.setOp( context.KEEP, context.KEEP, context.KEEP );
73 |
74 | }
75 |
76 | } );
77 |
78 |
79 | THREE.ClearMaskPass = function () {
80 |
81 | THREE.Pass.call( this );
82 |
83 | this.needsSwap = false;
84 |
85 | };
86 |
87 | THREE.ClearMaskPass.prototype = Object.create( THREE.Pass.prototype );
88 |
89 | Object.assign( THREE.ClearMaskPass.prototype, {
90 |
91 | render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) {
92 |
93 | renderer.state.buffers.stencil.setTest( false );
94 |
95 | }
96 |
97 | } );
98 |
--------------------------------------------------------------------------------
/js/lib/postprocessing/RenderPass.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | */
4 |
5 | THREE.RenderPass = function ( scene, camera, overrideMaterial, clearColor, clearAlpha ) {
6 |
7 | THREE.Pass.call( this );
8 |
9 | this.scene = scene;
10 | this.camera = camera;
11 |
12 | this.overrideMaterial = overrideMaterial;
13 |
14 | this.clearColor = clearColor;
15 | this.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 1;
16 |
17 | this.oldClearColor = new THREE.Color();
18 | this.oldClearAlpha = 1;
19 |
20 | this.clear = true;
21 | this.needsSwap = false;
22 |
23 | };
24 |
25 | THREE.RenderPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
26 |
27 | constructor: THREE.RenderPass,
28 |
29 | render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) {
30 |
31 | this.scene.overrideMaterial = this.overrideMaterial;
32 |
33 | if ( this.clearColor ) {
34 |
35 | this.oldClearColor.copy( renderer.getClearColor() );
36 | this.oldClearAlpha = renderer.getClearAlpha();
37 |
38 | renderer.setClearColor( this.clearColor, this.clearAlpha );
39 |
40 | }
41 |
42 | renderer.render( this.scene, this.camera, readBuffer, this.clear );
43 |
44 | if ( this.clearColor ) {
45 |
46 | renderer.setClearColor( this.oldClearColor, this.oldClearAlpha );
47 |
48 | }
49 |
50 | this.scene.overrideMaterial = null;
51 |
52 | }
53 |
54 | } );
55 |
--------------------------------------------------------------------------------
/js/lib/postprocessing/SavePass.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | */
4 |
5 | THREE.SavePass = function ( renderTarget ) {
6 |
7 | THREE.Pass.call( this );
8 |
9 | if ( THREE.CopyShader === undefined )
10 | console.error( "THREE.SavePass relies on THREE.CopyShader" );
11 |
12 | var shader = THREE.CopyShader;
13 |
14 | this.textureID = "tDiffuse";
15 |
16 | this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
17 |
18 | this.material = new THREE.ShaderMaterial( {
19 |
20 | uniforms: this.uniforms,
21 | vertexShader: shader.vertexShader,
22 | fragmentShader: shader.fragmentShader
23 |
24 | } );
25 |
26 | this.renderTarget = renderTarget;
27 |
28 | if ( this.renderTarget === undefined ) {
29 |
30 | this.renderTargetParameters = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBFormat, stencilBuffer: false };
31 | this.renderTarget = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, this.renderTargetParameters );
32 |
33 | }
34 |
35 | this.needsSwap = false;
36 |
37 | this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
38 | this.scene = new THREE.Scene();
39 |
40 | this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null );
41 | this.scene.add( this.quad );
42 |
43 | };
44 |
45 | THREE.SavePass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
46 |
47 | constructor: THREE.SavePass,
48 |
49 | render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) {
50 |
51 | if ( this.uniforms[ this.textureID ] ) {
52 |
53 | this.uniforms[ this.textureID ].value = readBuffer.texture;
54 |
55 | }
56 |
57 | this.quad.material = this.material;
58 |
59 | renderer.render( this.scene, this.camera, this.renderTarget, this.clear );
60 |
61 | }
62 |
63 | } );
64 |
--------------------------------------------------------------------------------
/js/lib/postprocessing/ShaderPass.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | */
4 |
5 | THREE.ShaderPass = function ( shader, textureID ) {
6 |
7 | THREE.Pass.call( this );
8 |
9 | this.textureID = ( textureID !== undefined ) ? textureID : "tDiffuse";
10 |
11 | if ( shader instanceof THREE.ShaderMaterial ) {
12 |
13 | this.uniforms = shader.uniforms;
14 |
15 | this.material = shader;
16 |
17 | } else if ( shader ) {
18 |
19 | this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
20 |
21 | this.material = new THREE.ShaderMaterial( {
22 |
23 | defines: shader.defines || {},
24 | uniforms: this.uniforms,
25 | vertexShader: shader.vertexShader,
26 | fragmentShader: shader.fragmentShader
27 |
28 | } );
29 |
30 | }
31 |
32 | this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
33 | this.scene = new THREE.Scene();
34 |
35 | this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null );
36 | this.scene.add( this.quad );
37 |
38 | };
39 |
40 | THREE.ShaderPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
41 |
42 | constructor: THREE.ShaderPass,
43 |
44 | render: function( renderer, writeBuffer, readBuffer, delta, maskActive ) {
45 |
46 | if ( this.uniforms[ this.textureID ] ) {
47 |
48 | this.uniforms[ this.textureID ].value = readBuffer.texture;
49 |
50 | }
51 |
52 | this.quad.material = this.material;
53 |
54 | if ( this.renderToScreen ) {
55 |
56 | renderer.render( this.scene, this.camera );
57 |
58 | } else {
59 |
60 | renderer.render( this.scene, this.camera, writeBuffer, this.clear );
61 |
62 | }
63 |
64 | }
65 |
66 | } );
67 |
--------------------------------------------------------------------------------
/js/lib/postprocessing/TAARenderPass.js:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Temporal Anti-Aliasing Render Pass
4 | *
5 | * @author bhouston / http://clara.io/
6 | *
7 | * When there is no motion in the scene, the TAA render pass accumulates jittered camera samples across frames to create a high quality anti-aliased result.
8 | *
9 | * References:
10 | *
11 | * TODO: Add support for motion vector pas so that accumulation of samples across frames can occur on dynamics scenes.
12 | *
13 | */
14 |
15 | THREE.TAARenderPass = function ( scene, camera, params ) {
16 |
17 | if ( THREE.ManualMSAARenderPass === undefined ) {
18 |
19 | console.error( "THREE.TAARenderPass relies on THREE.ManualMSAARenderPass" );
20 |
21 | }
22 | THREE.ManualMSAARenderPass.call( this, scene, camera, params );
23 |
24 | this.sampleLevel = 0;
25 | this.accumulate = false;
26 |
27 | };
28 |
29 | THREE.TAARenderPass.JitterVectors = THREE.ManualMSAARenderPass.JitterVectors;
30 |
31 | THREE.TAARenderPass.prototype = Object.assign( Object.create( THREE.ManualMSAARenderPass.prototype ), {
32 |
33 | constructor: THREE.TAARenderPass,
34 |
35 | render: function ( renderer, writeBuffer, readBuffer, delta ) {
36 |
37 | if( ! this.accumulate ) {
38 |
39 | THREE.ManualMSAARenderPass.prototype.render.call( this, renderer, writeBuffer, readBuffer, delta );
40 |
41 | this.accumulateIndex = -1;
42 | return;
43 |
44 | }
45 |
46 | var jitterOffsets = THREE.TAARenderPass.JitterVectors[ 5 ];
47 |
48 | if ( ! this.sampleRenderTarget ) {
49 |
50 | this.sampleRenderTarget = new THREE.WebGLRenderTarget( readBuffer.width, readBuffer.height, this.params );
51 |
52 | }
53 |
54 | if ( ! this.holdRenderTarget ) {
55 |
56 | this.holdRenderTarget = new THREE.WebGLRenderTarget( readBuffer.width, readBuffer.height, this.params );
57 |
58 | }
59 |
60 | if( this.accumulate && this.accumulateIndex === -1 ) {
61 |
62 | THREE.ManualMSAARenderPass.prototype.render.call( this, renderer, this.holdRenderTarget, readBuffer, delta );
63 |
64 | this.accumulateIndex = 0;
65 |
66 | }
67 |
68 | var autoClear = renderer.autoClear;
69 | renderer.autoClear = false;
70 |
71 | var sampleWeight = 1.0 / ( jitterOffsets.length );
72 |
73 | if( this.accumulateIndex >= 0 && this.accumulateIndex < jitterOffsets.length ) {
74 |
75 | this.copyUniforms[ "opacity" ].value = sampleWeight;
76 | this.copyUniforms[ "tDiffuse" ].value = writeBuffer.texture;
77 |
78 | // render the scene multiple times, each slightly jitter offset from the last and accumulate the results.
79 | var numSamplesPerFrame = Math.pow( 2, this.sampleLevel );
80 | for ( var i = 0; i < numSamplesPerFrame; i ++ ) {
81 |
82 | var j = this.accumulateIndex;
83 | var jitterOffset = jitterOffsets[j];
84 | if ( this.camera.setViewOffset ) {
85 | this.camera.setViewOffset( readBuffer.width, readBuffer.height,
86 | jitterOffset[ 0 ] * 0.0625, jitterOffset[ 1 ] * 0.0625, // 0.0625 = 1 / 16
87 | readBuffer.width, readBuffer.height );
88 | }
89 |
90 | renderer.render( this.scene, this.camera, writeBuffer, true );
91 | renderer.render( this.scene2, this.camera2, this.sampleRenderTarget, ( this.accumulateIndex === 0 ) );
92 |
93 | this.accumulateIndex ++;
94 | if( this.accumulateIndex >= jitterOffsets.length ) break;
95 | }
96 |
97 | if ( this.camera.clearViewOffset ) this.camera.clearViewOffset();
98 |
99 | }
100 |
101 | var accumulationWeight = this.accumulateIndex * sampleWeight;
102 |
103 | if( accumulationWeight > 0 ) {
104 | this.copyUniforms[ "opacity" ].value = 1.0;
105 | this.copyUniforms[ "tDiffuse" ].value = this.sampleRenderTarget.texture;
106 | renderer.render( this.scene2, this.camera2, writeBuffer, true );
107 | }
108 | if( accumulationWeight < 1.0 ) {
109 | this.copyUniforms[ "opacity" ].value = 1.0 - accumulationWeight;
110 | this.copyUniforms[ "tDiffuse" ].value = this.holdRenderTarget.texture;
111 | renderer.render( this.scene2, this.camera2, writeBuffer, ( accumulationWeight === 0 ) );
112 | }
113 |
114 | renderer.autoClear = autoClear;
115 |
116 | }
117 |
118 | });
119 |
--------------------------------------------------------------------------------
/js/lib/postprocessing/TexturePass.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | */
4 |
5 | THREE.TexturePass = function ( texture, opacity ) {
6 |
7 | THREE.Pass.call( this );
8 |
9 | if ( THREE.CopyShader === undefined )
10 | console.error( "THREE.TexturePass relies on THREE.CopyShader" );
11 |
12 | var shader = THREE.CopyShader;
13 |
14 | this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
15 |
16 | this.uniforms[ "opacity" ].value = ( opacity !== undefined ) ? opacity : 1.0;
17 | this.uniforms[ "tDiffuse" ].value = texture;
18 |
19 | this.material = new THREE.ShaderMaterial( {
20 |
21 | uniforms: this.uniforms,
22 | vertexShader: shader.vertexShader,
23 | fragmentShader: shader.fragmentShader
24 |
25 | } );
26 |
27 | this.needsSwap = false;
28 |
29 | this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
30 | this.scene = new THREE.Scene();
31 |
32 | this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null );
33 | this.scene.add( this.quad );
34 |
35 | };
36 |
37 | THREE.TexturePass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
38 |
39 | constructor: THREE.TexturePass,
40 |
41 | render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) {
42 |
43 | this.quad.material = this.material;
44 |
45 | renderer.render( this.scene, this.camera, readBuffer, this.clear );
46 |
47 | }
48 |
49 | } );
50 |
--------------------------------------------------------------------------------
/js/lib/shaders/AdditiveBlendShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author felixturner / http://airtight.cc/
3 | *
4 | * Simple additive buffer blending - makes things glowy
5 | *
6 | * based on @author Thibaut 'BKcore' Despoulain
7 | * from http://www.clicktorelease.com/code/perlin/lights.html
8 | *
9 | * tBase: base texture
10 | * tAdd: texture to add
11 | * amount: amount to add 2nd texture
12 | */
13 |
14 | THREE.AdditiveBlendShader = {
15 |
16 | uniforms: {
17 |
18 | "tBase": { type: "t", value: null },
19 | "tAdd": { type: "t", value: null },
20 | "amount": { type: "f", value: 1.0 }
21 |
22 | },
23 |
24 | vertexShader: [
25 |
26 | "varying vec2 vUv;",
27 |
28 | "void main() {",
29 |
30 | "vUv = uv;",
31 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
32 |
33 | "}"
34 |
35 | ].join("\n"),
36 |
37 | fragmentShader: [
38 |
39 |
40 | "uniform sampler2D tBase;",
41 | "uniform sampler2D tAdd;",
42 | "uniform float amount;",
43 |
44 | "varying vec2 vUv;",
45 |
46 | "void main() {",
47 |
48 | "vec4 texel1 = texture2D( tBase, vUv );",
49 | "vec4 texel2 = texture2D( tAdd, vUv );",
50 | "gl_FragColor = texel1 + texel2 * amount;",
51 |
52 | "}"
53 |
54 | ].join("\n")
55 |
56 | };
--------------------------------------------------------------------------------
/js/lib/shaders/BadTVShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author felixturner / http://airtight.cc/
3 | *
4 | * Bad TV Shader
5 | * Simulates a bad TV via horizontal distortion and vertical roll
6 | * Uses Ashima WebGl Noise: https://github.com/ashima/webgl-noise
7 | *
8 | * time: steadily increasing float passed in
9 | * distortion: amount of thick distortion
10 | * distortion2: amount of fine grain distortion
11 | * speed: distortion vertical travel speed
12 | * rollSpeed: vertical roll speed
13 | */
14 |
15 | THREE.BadTVShader = {
16 | uniforms: {
17 | "tDiffuse": { type: "t", value: null },
18 | "time": { type: "f", value: 0.0 },
19 | "distortion": { type: "f", value: 3.0 },
20 | "distortion2": { type: "f", value: 5.0 },
21 | "speed": { type: "f", value: 0.2 },
22 | "rollSpeed": { type: "f", value: 0.1 },
23 | },
24 |
25 | vertexShader: [
26 | "varying vec2 vUv;",
27 | "void main() {",
28 | "vUv = uv;",
29 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
30 | "}"
31 |
32 | ].join("\n"),
33 |
34 | fragmentShader: [
35 |
36 | "uniform sampler2D tDiffuse;",
37 | "uniform float time;",
38 | "uniform float distortion;",
39 | "uniform float distortion2;",
40 | "uniform float speed;",
41 | "uniform float rollSpeed;",
42 | "varying vec2 vUv;",
43 |
44 | // Start Ashima 2D Simplex Noise
45 |
46 | "vec3 mod289(vec3 x) {",
47 | " return x - floor(x * (1.0 / 289.0)) * 289.0;",
48 | "}",
49 |
50 | "vec2 mod289(vec2 x) {",
51 | " return x - floor(x * (1.0 / 289.0)) * 289.0;",
52 | "}",
53 |
54 | "vec3 permute(vec3 x) {",
55 | " return mod289(((x*34.0)+1.0)*x);",
56 | "}",
57 |
58 | "float snoise(vec2 v)",
59 | " {",
60 | " const vec4 C = vec4(0.211324865405187, // (3.0-sqrt(3.0))/6.0",
61 | " 0.366025403784439, // 0.5*(sqrt(3.0)-1.0)",
62 | " -0.577350269189626, // -1.0 + 2.0 * C.x",
63 | " 0.024390243902439); // 1.0 / 41.0",
64 | " vec2 i = floor(v + dot(v, C.yy) );",
65 | " vec2 x0 = v - i + dot(i, C.xx);",
66 |
67 | " vec2 i1;",
68 | " i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);",
69 | " vec4 x12 = x0.xyxy + C.xxzz;",
70 | " x12.xy -= i1;",
71 |
72 | " i = mod289(i); // Avoid truncation effects in permutation",
73 | " vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 ))",
74 | " + i.x + vec3(0.0, i1.x, 1.0 ));",
75 |
76 | " vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0);",
77 | " m = m*m ;",
78 | " m = m*m ;",
79 |
80 | " vec3 x = 2.0 * fract(p * C.www) - 1.0;",
81 | " vec3 h = abs(x) - 0.5;",
82 | " vec3 ox = floor(x + 0.5);",
83 | " vec3 a0 = x - ox;",
84 |
85 | " m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h );",
86 |
87 | " vec3 g;",
88 | " g.x = a0.x * x0.x + h.x * x0.y;",
89 | " g.yz = a0.yz * x12.xz + h.yz * x12.yw;",
90 | " return 130.0 * dot(m, g);",
91 | "}",
92 |
93 | // End Ashima 2D Simplex Noise
94 |
95 | "void main() {",
96 |
97 | "vec2 p = vUv;",
98 | "float ty = time*speed;",
99 | "float yt = p.y - ty;",
100 |
101 | //smooth distortion
102 | "float offset = snoise(vec2(yt*3.0,0.0))*0.2;",
103 | // boost distortion
104 | "offset = pow( offset*distortion,3.0)/distortion;",
105 | //add fine grain distortion
106 | "offset += snoise(vec2(yt*50.0,0.0))*distortion2*0.001;",
107 | //combine distortion on X with roll on Y
108 | "gl_FragColor = texture2D(tDiffuse, vec2(fract(p.x + offset),fract(p.y-time*rollSpeed) ));",
109 |
110 | "}"
111 |
112 | ].join("\n")
113 |
114 | };
115 |
--------------------------------------------------------------------------------
/js/lib/shaders/BasicShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author mrdoob / http://www.mrdoob.com
3 | *
4 | * Simple test shader
5 | */
6 |
7 | THREE.BasicShader = {
8 |
9 | uniforms: {},
10 |
11 | vertexShader: [
12 |
13 | "void main() {",
14 |
15 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
16 |
17 | "}"
18 |
19 | ].join( "\n" ),
20 |
21 | fragmentShader: [
22 |
23 | "void main() {",
24 |
25 | "gl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );",
26 |
27 | "}"
28 |
29 | ].join( "\n" )
30 |
31 | };
32 |
--------------------------------------------------------------------------------
/js/lib/shaders/BleachBypassShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | *
4 | * Bleach bypass shader [http://en.wikipedia.org/wiki/Bleach_bypass]
5 | * - based on Nvidia example
6 | * http://developer.download.nvidia.com/shaderlibrary/webpages/shader_library.html#post_bleach_bypass
7 | */
8 |
9 | THREE.BleachBypassShader = {
10 |
11 | uniforms: {
12 |
13 | "tDiffuse": { type: "t", value: null },
14 | "opacity": { type: "f", value: 1.0 }
15 |
16 | },
17 |
18 | vertexShader: [
19 |
20 | "varying vec2 vUv;",
21 |
22 | "void main() {",
23 |
24 | "vUv = uv;",
25 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
26 |
27 | "}"
28 |
29 | ].join( "\n" ),
30 |
31 | fragmentShader: [
32 |
33 | "uniform float opacity;",
34 |
35 | "uniform sampler2D tDiffuse;",
36 |
37 | "varying vec2 vUv;",
38 |
39 | "void main() {",
40 |
41 | "vec4 base = texture2D( tDiffuse, vUv );",
42 |
43 | "vec3 lumCoeff = vec3( 0.25, 0.65, 0.1 );",
44 | "float lum = dot( lumCoeff, base.rgb );",
45 | "vec3 blend = vec3( lum );",
46 |
47 | "float L = min( 1.0, max( 0.0, 10.0 * ( lum - 0.45 ) ) );",
48 |
49 | "vec3 result1 = 2.0 * base.rgb * blend;",
50 | "vec3 result2 = 1.0 - 2.0 * ( 1.0 - blend ) * ( 1.0 - base.rgb );",
51 |
52 | "vec3 newColor = mix( result1, result2, L );",
53 |
54 | "float A2 = opacity * base.a;",
55 | "vec3 mixRGB = A2 * newColor.rgb;",
56 | "mixRGB += ( ( 1.0 - A2 ) * base.rgb );",
57 |
58 | "gl_FragColor = vec4( mixRGB, base.a );",
59 |
60 | "}"
61 |
62 | ].join( "\n" )
63 |
64 | };
65 |
--------------------------------------------------------------------------------
/js/lib/shaders/BlendShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | *
4 | * Blend two textures
5 | */
6 |
7 | THREE.BlendShader = {
8 |
9 | uniforms: {
10 |
11 | "tDiffuse1": { type: "t", value: null },
12 | "tDiffuse2": { type: "t", value: null },
13 | "mixRatio": { type: "f", value: 0.5 },
14 | "opacity": { type: "f", value: 1.0 }
15 |
16 | },
17 |
18 | vertexShader: [
19 |
20 | "varying vec2 vUv;",
21 |
22 | "void main() {",
23 |
24 | "vUv = uv;",
25 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
26 |
27 | "}"
28 |
29 | ].join( "\n" ),
30 |
31 | fragmentShader: [
32 |
33 | "uniform float opacity;",
34 | "uniform float mixRatio;",
35 |
36 | "uniform sampler2D tDiffuse1;",
37 | "uniform sampler2D tDiffuse2;",
38 |
39 | "varying vec2 vUv;",
40 |
41 | "void main() {",
42 |
43 | "vec4 texel1 = texture2D( tDiffuse1, vUv );",
44 | "vec4 texel2 = texture2D( tDiffuse2, vUv );",
45 | "gl_FragColor = opacity * mix( texel1, texel2, mixRatio );",
46 |
47 | "}"
48 |
49 | ].join( "\n" )
50 |
51 | };
52 |
--------------------------------------------------------------------------------
/js/lib/shaders/BrightnessContrastShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author tapio / http://tapio.github.com/
3 | *
4 | * Brightness and contrast adjustment
5 | * https://github.com/evanw/glfx.js
6 | * brightness: -1 to 1 (-1 is solid black, 0 is no change, and 1 is solid white)
7 | * contrast: -1 to 1 (-1 is solid gray, 0 is no change, and 1 is maximum contrast)
8 | */
9 |
10 | THREE.BrightnessContrastShader = {
11 |
12 | uniforms: {
13 |
14 | "tDiffuse": { type: "t", value: null },
15 | "brightness": { type: "f", value: 0 },
16 | "contrast": { type: "f", value: 0 }
17 |
18 | },
19 |
20 | vertexShader: [
21 |
22 | "varying vec2 vUv;",
23 |
24 | "void main() {",
25 |
26 | "vUv = uv;",
27 |
28 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
29 |
30 | "}"
31 |
32 | ].join( "\n" ),
33 |
34 | fragmentShader: [
35 |
36 | "uniform sampler2D tDiffuse;",
37 | "uniform float brightness;",
38 | "uniform float contrast;",
39 |
40 | "varying vec2 vUv;",
41 |
42 | "void main() {",
43 |
44 | "gl_FragColor = texture2D( tDiffuse, vUv );",
45 |
46 | "gl_FragColor.rgb += brightness;",
47 |
48 | "if (contrast > 0.0) {",
49 | "gl_FragColor.rgb = (gl_FragColor.rgb - 0.5) / (1.0 - contrast) + 0.5;",
50 | "} else {",
51 | "gl_FragColor.rgb = (gl_FragColor.rgb - 0.5) * (1.0 + contrast) + 0.5;",
52 | "}",
53 |
54 | "}"
55 |
56 | ].join( "\n" )
57 |
58 | };
59 |
--------------------------------------------------------------------------------
/js/lib/shaders/ColorCorrectionShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | *
4 | * Color correction
5 | */
6 |
7 | THREE.ColorCorrectionShader = {
8 |
9 | uniforms: {
10 |
11 | "tDiffuse": { type: "t", value: null },
12 | "powRGB": { type: "v3", value: new THREE.Vector3( 2, 2, 2 ) },
13 | "mulRGB": { type: "v3", value: new THREE.Vector3( 1, 1, 1 ) },
14 | "addRGB": { type: "v3", value: new THREE.Vector3( 0, 0, 0 ) }
15 |
16 | },
17 |
18 | vertexShader: [
19 |
20 | "varying vec2 vUv;",
21 |
22 | "void main() {",
23 |
24 | "vUv = uv;",
25 |
26 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
27 |
28 | "}"
29 |
30 | ].join( "\n" ),
31 |
32 | fragmentShader: [
33 |
34 | "uniform sampler2D tDiffuse;",
35 | "uniform vec3 powRGB;",
36 | "uniform vec3 mulRGB;",
37 | "uniform vec3 addRGB;",
38 |
39 | "varying vec2 vUv;",
40 |
41 | "void main() {",
42 |
43 | "gl_FragColor = texture2D( tDiffuse, vUv );",
44 | "gl_FragColor.rgb = mulRGB * pow( ( gl_FragColor.rgb + addRGB ), powRGB );",
45 |
46 | "}"
47 |
48 | ].join( "\n" )
49 |
50 | };
51 |
--------------------------------------------------------------------------------
/js/lib/shaders/ColorifyShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | *
4 | * Colorify shader
5 | */
6 |
7 | THREE.ColorifyShader = {
8 |
9 | uniforms: {
10 |
11 | "tDiffuse": { type: "t", value: null },
12 | "color": { type: "c", value: new THREE.Color( 0xffffff ) }
13 |
14 | },
15 |
16 | vertexShader: [
17 |
18 | "varying vec2 vUv;",
19 |
20 | "void main() {",
21 |
22 | "vUv = uv;",
23 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
24 |
25 | "}"
26 |
27 | ].join( "\n" ),
28 |
29 | fragmentShader: [
30 |
31 | "uniform vec3 color;",
32 | "uniform sampler2D tDiffuse;",
33 |
34 | "varying vec2 vUv;",
35 |
36 | "void main() {",
37 |
38 | "vec4 texel = texture2D( tDiffuse, vUv );",
39 |
40 | "vec3 luma = vec3( 0.299, 0.587, 0.114 );",
41 | "float v = dot( texel.xyz, luma );",
42 |
43 | "gl_FragColor = vec4( v * color, texel.w );",
44 |
45 | "}"
46 |
47 | ].join( "\n" )
48 |
49 | };
50 |
--------------------------------------------------------------------------------
/js/lib/shaders/CompositeShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author bhouston / http://clara.io/
3 | *
4 | * Multi-Sample Anti-aliasing shader - for blending together sample buffers
5 | */
6 |
7 | THREE.CompositeShader = {
8 |
9 | shaderID: "composite",
10 |
11 | uniforms: {
12 |
13 | "tForeground": { type: "t", value: null },
14 | "scale": { type: "f", value: 1.0 }
15 |
16 | },
17 |
18 | vertexShader: [
19 |
20 | "varying vec2 vUv;",
21 |
22 | "void main() {",
23 |
24 | "vUv = uv;",
25 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
26 |
27 | "}"
28 |
29 | ].join( '\n' ),
30 |
31 | fragmentShader: [
32 |
33 | "varying vec2 vUv;",
34 |
35 | "uniform sampler2D tForeground;",
36 | "uniform float scale;",
37 |
38 | "void main() {",
39 |
40 | "vec4 foreground = texture2D( tForeground, vUv );",
41 |
42 | "gl_FragColor = foreground * scale;",
43 |
44 | "}"
45 |
46 | ].join( '\n' )
47 |
48 | };
49 |
--------------------------------------------------------------------------------
/js/lib/shaders/ConvolutionShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | *
4 | * Convolution shader
5 | * ported from o3d sample to WebGL / GLSL
6 | * http://o3d.googlecode.com/svn/trunk/samples/convolution.html
7 | */
8 |
9 | THREE.ConvolutionShader = {
10 |
11 | defines: {
12 |
13 | "KERNEL_SIZE_FLOAT": "25.0",
14 | "KERNEL_SIZE_INT": "25",
15 |
16 | },
17 |
18 | uniforms: {
19 |
20 | "tDiffuse": { type: "t", value: null },
21 | "uImageIncrement": { type: "v2", value: new THREE.Vector2( 0.001953125, 0.0 ) },
22 | "cKernel": { type: "fv1", value: [] }
23 |
24 | },
25 |
26 | vertexShader: [
27 |
28 | "uniform vec2 uImageIncrement;",
29 |
30 | "varying vec2 vUv;",
31 |
32 | "void main() {",
33 |
34 | "vUv = uv - ( ( KERNEL_SIZE_FLOAT - 1.0 ) / 2.0 ) * uImageIncrement;",
35 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
36 |
37 | "}"
38 |
39 | ].join( "\n" ),
40 |
41 | fragmentShader: [
42 |
43 | "uniform float cKernel[ KERNEL_SIZE_INT ];",
44 |
45 | "uniform sampler2D tDiffuse;",
46 | "uniform vec2 uImageIncrement;",
47 |
48 | "varying vec2 vUv;",
49 |
50 | "void main() {",
51 |
52 | "vec2 imageCoord = vUv;",
53 | "vec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );",
54 |
55 | "for( int i = 0; i < KERNEL_SIZE_INT; i ++ ) {",
56 |
57 | "sum += texture2D( tDiffuse, imageCoord ) * cKernel[ i ];",
58 | "imageCoord += uImageIncrement;",
59 |
60 | "}",
61 |
62 | "gl_FragColor = sum;",
63 |
64 | "}"
65 |
66 |
67 | ].join( "\n" ),
68 |
69 | buildKernel: function ( sigma ) {
70 |
71 | // We lop off the sqrt(2 * pi) * sigma term, since we're going to normalize anyway.
72 |
73 | function gauss( x, sigma ) {
74 |
75 | return Math.exp( - ( x * x ) / ( 2.0 * sigma * sigma ) );
76 |
77 | }
78 |
79 | var i, values, sum, halfWidth, kMaxKernelSize = 25, kernelSize = 2 * Math.ceil( sigma * 3.0 ) + 1;
80 |
81 | if ( kernelSize > kMaxKernelSize ) kernelSize = kMaxKernelSize;
82 | halfWidth = ( kernelSize - 1 ) * 0.5;
83 |
84 | values = new Array( kernelSize );
85 | sum = 0.0;
86 | for ( i = 0; i < kernelSize; ++ i ) {
87 |
88 | values[ i ] = gauss( i - halfWidth, sigma );
89 | sum += values[ i ];
90 |
91 | }
92 |
93 | // normalize the kernel
94 |
95 | for ( i = 0; i < kernelSize; ++ i ) values[ i ] /= sum;
96 |
97 | return values;
98 |
99 | }
100 |
101 | };
102 |
--------------------------------------------------------------------------------
/js/lib/shaders/CopyShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | *
4 | * Full-screen textured quad shader
5 | */
6 |
7 | THREE.CopyShader = {
8 |
9 | uniforms: {
10 |
11 | "tDiffuse": { type: "t", value: null },
12 | "opacity": { type: "f", value: 1.0 }
13 |
14 | },
15 |
16 | vertexShader: [
17 |
18 | "varying vec2 vUv;",
19 |
20 | "void main() {",
21 |
22 | "vUv = uv;",
23 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
24 |
25 | "}"
26 |
27 | ].join( "\n" ),
28 |
29 | fragmentShader: [
30 |
31 | "uniform float opacity;",
32 |
33 | "uniform sampler2D tDiffuse;",
34 |
35 | "varying vec2 vUv;",
36 |
37 | "void main() {",
38 |
39 | "vec4 texel = texture2D( tDiffuse, vUv );",
40 | "gl_FragColor = opacity * texel;",
41 |
42 | "}"
43 |
44 | ].join( "\n" )
45 |
46 | };
47 |
--------------------------------------------------------------------------------
/js/lib/shaders/DOFMipMapShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | *
4 | * Depth-of-field shader using mipmaps
5 | * - from Matt Handley @applmak
6 | * - requires power-of-2 sized render target with enabled mipmaps
7 | */
8 |
9 | THREE.DOFMipMapShader = {
10 |
11 | uniforms: {
12 |
13 | "tColor": { type: "t", value: null },
14 | "tDepth": { type: "t", value: null },
15 | "focus": { type: "f", value: 1.0 },
16 | "maxblur": { type: "f", value: 1.0 }
17 |
18 | },
19 |
20 | vertexShader: [
21 |
22 | "varying vec2 vUv;",
23 |
24 | "void main() {",
25 |
26 | "vUv = uv;",
27 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
28 |
29 | "}"
30 |
31 | ].join( "\n" ),
32 |
33 | fragmentShader: [
34 |
35 | "uniform float focus;",
36 | "uniform float maxblur;",
37 |
38 | "uniform sampler2D tColor;",
39 | "uniform sampler2D tDepth;",
40 |
41 | "varying vec2 vUv;",
42 |
43 | "void main() {",
44 |
45 | "vec4 depth = texture2D( tDepth, vUv );",
46 |
47 | "float factor = depth.x - focus;",
48 |
49 | "vec4 col = texture2D( tColor, vUv, 2.0 * maxblur * abs( focus - depth.x ) );",
50 |
51 | "gl_FragColor = col;",
52 | "gl_FragColor.a = 1.0;",
53 |
54 | "}"
55 |
56 | ].join( "\n" )
57 |
58 | };
59 |
--------------------------------------------------------------------------------
/js/lib/shaders/DigitalGlitch.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author felixturner / http://airtight.cc/
3 | *
4 | * RGB Shift Shader
5 | * Shifts red and blue channels from center in opposite directions
6 | * Ported from http://kriss.cx/tom/2009/05/rgb-shift/
7 | * by Tom Butterworth / http://kriss.cx/tom/
8 | *
9 | * amount: shift distance (1 is width of input)
10 | * angle: shift angle in radians
11 | */
12 |
13 | THREE.DigitalGlitch = {
14 |
15 | uniforms: {
16 |
17 | "tDiffuse": { type: "t", value: null },//diffuse texture
18 | "tDisp": { type: "t", value: null },//displacement texture for digital glitch squares
19 | "byp": { type: "i", value: 0 },//apply the glitch ?
20 | "amount": { type: "f", value: 0.08 },
21 | "angle": { type: "f", value: 0.02 },
22 | "seed": { type: "f", value: 0.02 },
23 | "seed_x": { type: "f", value: 0.02 },//-1,1
24 | "seed_y": { type: "f", value: 0.02 },//-1,1
25 | "distortion_x": { type: "f", value: 0.5 },
26 | "distortion_y": { type: "f", value: 0.6 },
27 | "col_s": { type: "f", value: 0.05 }
28 | },
29 |
30 | vertexShader: [
31 |
32 | "varying vec2 vUv;",
33 | "void main() {",
34 | "vUv = uv;",
35 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
36 | "}"
37 | ].join( "\n" ),
38 |
39 | fragmentShader: [
40 | "uniform int byp;",//should we apply the glitch ?
41 |
42 | "uniform sampler2D tDiffuse;",
43 | "uniform sampler2D tDisp;",
44 |
45 | "uniform float amount;",
46 | "uniform float angle;",
47 | "uniform float seed;",
48 | "uniform float seed_x;",
49 | "uniform float seed_y;",
50 | "uniform float distortion_x;",
51 | "uniform float distortion_y;",
52 | "uniform float col_s;",
53 |
54 | "varying vec2 vUv;",
55 |
56 |
57 | "float rand(vec2 co){",
58 | "return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);",
59 | "}",
60 |
61 | "void main() {",
62 | "if(byp<1) {",
63 | "vec2 p = vUv;",
64 | "float xs = floor(gl_FragCoord.x / 0.5);",
65 | "float ys = floor(gl_FragCoord.y / 0.5);",
66 | //based on staffantans glitch shader for unity https://github.com/staffantan/unityglitch
67 | "vec4 normal = texture2D (tDisp, p*seed*seed);",
68 | "if(p.ydistortion_x-col_s*seed) {",
69 | "if(seed_x>0.){",
70 | "p.y = 1. - (p.y + distortion_y);",
71 | "}",
72 | "else {",
73 | "p.y = distortion_y;",
74 | "}",
75 | "}",
76 | "if(p.xdistortion_y-col_s*seed) {",
77 | "if(seed_y>0.){",
78 | "p.x=distortion_x;",
79 | "}",
80 | "else {",
81 | "p.x = 1. - (p.x + distortion_x);",
82 | "}",
83 | "}",
84 | "p.x+=normal.x*seed_x*(seed/5.);",
85 | "p.y+=normal.y*seed_y*(seed/5.);",
86 | //base from RGB shift shader
87 | "vec2 offset = amount * vec2( cos(angle), sin(angle));",
88 | "vec4 cr = texture2D(tDiffuse, p + offset);",
89 | "vec4 cga = texture2D(tDiffuse, p);",
90 | "vec4 cb = texture2D(tDiffuse, p - offset);",
91 | "gl_FragColor = vec4(cr.r, cga.g, cb.b, cga.a);",
92 | //add noise
93 | "vec4 snow = 200.*amount*vec4(rand(vec2(xs * seed,ys * seed*50.))*0.2);",
94 | "gl_FragColor = gl_FragColor+ snow;",
95 | "}",
96 | "else {",
97 | "gl_FragColor=texture2D (tDiffuse, vUv);",
98 | "}",
99 | "}"
100 |
101 | ].join( "\n" )
102 |
103 | };
104 |
--------------------------------------------------------------------------------
/js/lib/shaders/DotScreenShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | *
4 | * Dot screen shader
5 | * based on glfx.js sepia shader
6 | * https://github.com/evanw/glfx.js
7 | */
8 |
9 | THREE.DotScreenShader = {
10 |
11 | uniforms: {
12 |
13 | "tDiffuse": { type: "t", value: null },
14 | "tSize": { type: "v2", value: new THREE.Vector2( 256, 256 ) },
15 | "center": { type: "v2", value: new THREE.Vector2( 0.5, 0.5 ) },
16 | "angle": { type: "f", value: 1.57 },
17 | "scale": { type: "f", value: 1.0 }
18 |
19 | },
20 |
21 | vertexShader: [
22 |
23 | "varying vec2 vUv;",
24 |
25 | "void main() {",
26 |
27 | "vUv = uv;",
28 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
29 |
30 | "}"
31 |
32 | ].join( "\n" ),
33 |
34 | fragmentShader: [
35 |
36 | "uniform vec2 center;",
37 | "uniform float angle;",
38 | "uniform float scale;",
39 | "uniform vec2 tSize;",
40 |
41 | "uniform sampler2D tDiffuse;",
42 |
43 | "varying vec2 vUv;",
44 |
45 | "float pattern() {",
46 |
47 | "float s = sin( angle ), c = cos( angle );",
48 |
49 | "vec2 tex = vUv * tSize - center;",
50 | "vec2 point = vec2( c * tex.x - s * tex.y, s * tex.x + c * tex.y ) * scale;",
51 |
52 | "return ( sin( point.x ) * sin( point.y ) ) * 4.0;",
53 |
54 | "}",
55 |
56 | "void main() {",
57 |
58 | "vec4 color = texture2D( tDiffuse, vUv );",
59 |
60 | "float average = ( color.r + color.g + color.b ) / 3.0;",
61 |
62 | "gl_FragColor = vec4( vec3( average * 10.0 - 5.0 + pattern() ), color.a );",
63 |
64 | "}"
65 |
66 | ].join( "\n" )
67 |
68 | };
69 |
--------------------------------------------------------------------------------
/js/lib/shaders/EdgeShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author zz85 / https://github.com/zz85 | https://www.lab4games.net/zz85/blog
3 | *
4 | * Edge Detection Shader using Frei-Chen filter
5 | * Based on http://rastergrid.com/blog/2011/01/frei-chen-edge-detector
6 | *
7 | * aspect: vec2 of (1/width, 1/height)
8 | */
9 |
10 | THREE.EdgeShader = {
11 |
12 | uniforms: {
13 |
14 | "tDiffuse": { type: "t", value: null },
15 | "aspect": { type: "v2", value: new THREE.Vector2( 512, 512 ) },
16 | },
17 |
18 | vertexShader: [
19 |
20 | "varying vec2 vUv;",
21 |
22 | "void main() {",
23 |
24 | "vUv = uv;",
25 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
26 |
27 | "}"
28 |
29 | ].join( "\n" ),
30 |
31 | fragmentShader: [
32 |
33 | "uniform sampler2D tDiffuse;",
34 | "varying vec2 vUv;",
35 |
36 | "uniform vec2 aspect;",
37 |
38 | "vec2 texel = vec2(1.0 / aspect.x, 1.0 / aspect.y);",
39 |
40 |
41 | "mat3 G[9];",
42 |
43 | // hard coded matrix values!!!! as suggested in https://github.com/neilmendoza/ofxPostProcessing/blob/master/src/EdgePass.cpp#L45
44 |
45 | "const mat3 g0 = mat3( 0.3535533845424652, 0, -0.3535533845424652, 0.5, 0, -0.5, 0.3535533845424652, 0, -0.3535533845424652 );",
46 | "const mat3 g1 = mat3( 0.3535533845424652, 0.5, 0.3535533845424652, 0, 0, 0, -0.3535533845424652, -0.5, -0.3535533845424652 );",
47 | "const mat3 g2 = mat3( 0, 0.3535533845424652, -0.5, -0.3535533845424652, 0, 0.3535533845424652, 0.5, -0.3535533845424652, 0 );",
48 | "const mat3 g3 = mat3( 0.5, -0.3535533845424652, 0, -0.3535533845424652, 0, 0.3535533845424652, 0, 0.3535533845424652, -0.5 );",
49 | "const mat3 g4 = mat3( 0, -0.5, 0, 0.5, 0, 0.5, 0, -0.5, 0 );",
50 | "const mat3 g5 = mat3( -0.5, 0, 0.5, 0, 0, 0, 0.5, 0, -0.5 );",
51 | "const mat3 g6 = mat3( 0.1666666716337204, -0.3333333432674408, 0.1666666716337204, -0.3333333432674408, 0.6666666865348816, -0.3333333432674408, 0.1666666716337204, -0.3333333432674408, 0.1666666716337204 );",
52 | "const mat3 g7 = mat3( -0.3333333432674408, 0.1666666716337204, -0.3333333432674408, 0.1666666716337204, 0.6666666865348816, 0.1666666716337204, -0.3333333432674408, 0.1666666716337204, -0.3333333432674408 );",
53 | "const mat3 g8 = mat3( 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408 );",
54 |
55 | "void main(void)",
56 | "{",
57 |
58 | "G[0] = g0,",
59 | "G[1] = g1,",
60 | "G[2] = g2,",
61 | "G[3] = g3,",
62 | "G[4] = g4,",
63 | "G[5] = g5,",
64 | "G[6] = g6,",
65 | "G[7] = g7,",
66 | "G[8] = g8;",
67 |
68 | "mat3 I;",
69 | "float cnv[9];",
70 | "vec3 sample;",
71 |
72 | /* fetch the 3x3 neighbourhood and use the RGB vector's length as intensity value */
73 | "for (float i=0.0; i<3.0; i++) {",
74 | "for (float j=0.0; j<3.0; j++) {",
75 | "sample = texture2D(tDiffuse, vUv + texel * vec2(i-1.0,j-1.0) ).rgb;",
76 | "I[int(i)][int(j)] = length(sample);",
77 | "}",
78 | "}",
79 |
80 | /* calculate the convolution values for all the masks */
81 | "for (int i=0; i<9; i++) {",
82 | "float dp3 = dot(G[i][0], I[0]) + dot(G[i][1], I[1]) + dot(G[i][2], I[2]);",
83 | "cnv[i] = dp3 * dp3;",
84 | "}",
85 |
86 | "float M = (cnv[0] + cnv[1]) + (cnv[2] + cnv[3]);",
87 | "float S = (cnv[4] + cnv[5]) + (cnv[6] + cnv[7]) + (cnv[8] + M);",
88 |
89 | "gl_FragColor = vec4(vec3(sqrt(M/S)), 1.0);",
90 | "}",
91 |
92 | ].join( "\n" )
93 | };
94 |
--------------------------------------------------------------------------------
/js/lib/shaders/EdgeShader2.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author zz85 / https://github.com/zz85 | https://www.lab4games.net/zz85/blog
3 | *
4 | * Edge Detection Shader using Sobel filter
5 | * Based on http://rastergrid.com/blog/2011/01/frei-chen-edge-detector
6 | *
7 | * aspect: vec2 of (1/width, 1/height)
8 | */
9 |
10 | THREE.EdgeShader2 = {
11 |
12 | uniforms: {
13 |
14 | "tDiffuse": { type: "t", value: null },
15 | "aspect": { type: "v2", value: new THREE.Vector2( 512, 512 ) },
16 | },
17 |
18 | vertexShader: [
19 |
20 | "varying vec2 vUv;",
21 |
22 | "void main() {",
23 |
24 | "vUv = uv;",
25 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
26 |
27 | "}"
28 |
29 | ].join( "\n" ),
30 |
31 | fragmentShader: [
32 |
33 | "uniform sampler2D tDiffuse;",
34 | "varying vec2 vUv;",
35 | "uniform vec2 aspect;",
36 |
37 |
38 | "vec2 texel = vec2(1.0 / aspect.x, 1.0 / aspect.y);",
39 |
40 | "mat3 G[2];",
41 |
42 | "const mat3 g0 = mat3( 1.0, 2.0, 1.0, 0.0, 0.0, 0.0, -1.0, -2.0, -1.0 );",
43 | "const mat3 g1 = mat3( 1.0, 0.0, -1.0, 2.0, 0.0, -2.0, 1.0, 0.0, -1.0 );",
44 |
45 |
46 | "void main(void)",
47 | "{",
48 | "mat3 I;",
49 | "float cnv[2];",
50 | "vec3 sample;",
51 |
52 | "G[0] = g0;",
53 | "G[1] = g1;",
54 |
55 | /* fetch the 3x3 neighbourhood and use the RGB vector's length as intensity value */
56 | "for (float i=0.0; i<3.0; i++)",
57 | "for (float j=0.0; j<3.0; j++) {",
58 | "sample = texture2D( tDiffuse, vUv + texel * vec2(i-1.0,j-1.0) ).rgb;",
59 | "I[int(i)][int(j)] = length(sample);",
60 | "}",
61 |
62 | /* calculate the convolution values for all the masks */
63 | "for (int i=0; i<2; i++) {",
64 | "float dp3 = dot(G[i][0], I[0]) + dot(G[i][1], I[1]) + dot(G[i][2], I[2]);",
65 | "cnv[i] = dp3 * dp3; ",
66 | "}",
67 |
68 | "gl_FragColor = vec4(0.5 * sqrt(cnv[0]*cnv[0]+cnv[1]*cnv[1]));",
69 | "} ",
70 |
71 | ].join( "\n" )
72 |
73 | };
74 |
--------------------------------------------------------------------------------
/js/lib/shaders/FXAAShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | * @author davidedc / http://www.sketchpatch.net/
4 | *
5 | * NVIDIA FXAA by Timothy Lottes
6 | * http://timothylottes.blogspot.com/2011/06/fxaa3-source-released.html
7 | * - WebGL port by @supereggbert
8 | * http://www.glge.org/demos/fxaa/
9 | */
10 |
11 | THREE.FXAAShader = {
12 |
13 | uniforms: {
14 |
15 | "tDiffuse": { type: "t", value: null },
16 | "resolution": { type: "v2", value: new THREE.Vector2( 1 / 1024, 1 / 512 ) }
17 |
18 | },
19 |
20 | vertexShader: [
21 |
22 | "void main() {",
23 |
24 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
25 |
26 | "}"
27 |
28 | ].join( "\n" ),
29 |
30 | fragmentShader: [
31 |
32 | "uniform sampler2D tDiffuse;",
33 | "uniform vec2 resolution;",
34 |
35 | "#define FXAA_REDUCE_MIN (1.0/128.0)",
36 | "#define FXAA_REDUCE_MUL (1.0/8.0)",
37 | "#define FXAA_SPAN_MAX 8.0",
38 |
39 | "void main() {",
40 |
41 | "vec3 rgbNW = texture2D( tDiffuse, ( gl_FragCoord.xy + vec2( -1.0, -1.0 ) ) * resolution ).xyz;",
42 | "vec3 rgbNE = texture2D( tDiffuse, ( gl_FragCoord.xy + vec2( 1.0, -1.0 ) ) * resolution ).xyz;",
43 | "vec3 rgbSW = texture2D( tDiffuse, ( gl_FragCoord.xy + vec2( -1.0, 1.0 ) ) * resolution ).xyz;",
44 | "vec3 rgbSE = texture2D( tDiffuse, ( gl_FragCoord.xy + vec2( 1.0, 1.0 ) ) * resolution ).xyz;",
45 | "vec4 rgbaM = texture2D( tDiffuse, gl_FragCoord.xy * resolution );",
46 | "vec3 rgbM = rgbaM.xyz;",
47 | "vec3 luma = vec3( 0.299, 0.587, 0.114 );",
48 |
49 | "float lumaNW = dot( rgbNW, luma );",
50 | "float lumaNE = dot( rgbNE, luma );",
51 | "float lumaSW = dot( rgbSW, luma );",
52 | "float lumaSE = dot( rgbSE, luma );",
53 | "float lumaM = dot( rgbM, luma );",
54 | "float lumaMin = min( lumaM, min( min( lumaNW, lumaNE ), min( lumaSW, lumaSE ) ) );",
55 | "float lumaMax = max( lumaM, max( max( lumaNW, lumaNE) , max( lumaSW, lumaSE ) ) );",
56 |
57 | "vec2 dir;",
58 | "dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));",
59 | "dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));",
60 |
61 | "float dirReduce = max( ( lumaNW + lumaNE + lumaSW + lumaSE ) * ( 0.25 * FXAA_REDUCE_MUL ), FXAA_REDUCE_MIN );",
62 |
63 | "float rcpDirMin = 1.0 / ( min( abs( dir.x ), abs( dir.y ) ) + dirReduce );",
64 | "dir = min( vec2( FXAA_SPAN_MAX, FXAA_SPAN_MAX),",
65 | "max( vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),",
66 | "dir * rcpDirMin)) * resolution;",
67 | "vec4 rgbA = (1.0/2.0) * (",
68 | "texture2D(tDiffuse, gl_FragCoord.xy * resolution + dir * (1.0/3.0 - 0.5)) +",
69 | "texture2D(tDiffuse, gl_FragCoord.xy * resolution + dir * (2.0/3.0 - 0.5)));",
70 | "vec4 rgbB = rgbA * (1.0/2.0) + (1.0/4.0) * (",
71 | "texture2D(tDiffuse, gl_FragCoord.xy * resolution + dir * (0.0/3.0 - 0.5)) +",
72 | "texture2D(tDiffuse, gl_FragCoord.xy * resolution + dir * (3.0/3.0 - 0.5)));",
73 | "float lumaB = dot(rgbB, vec4(luma, 0.0));",
74 |
75 | "if ( ( lumaB < lumaMin ) || ( lumaB > lumaMax ) ) {",
76 |
77 | "gl_FragColor = rgbA;",
78 |
79 | "} else {",
80 | "gl_FragColor = rgbB;",
81 |
82 | "}",
83 |
84 | "}"
85 |
86 | ].join( "\n" )
87 |
88 | };
89 |
--------------------------------------------------------------------------------
/js/lib/shaders/FilmShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | *
4 | * Film grain & scanlines shader
5 | *
6 | * - ported from HLSL to WebGL / GLSL
7 | * http://www.truevision3d.com/forums/showcase/staticnoise_colorblackwhite_scanline_shaders-t18698.0.html
8 | *
9 | * Screen Space Static Postprocessor
10 | *
11 | * Produces an analogue noise overlay similar to a film grain / TV static
12 | *
13 | * Original implementation and noise algorithm
14 | * Pat 'Hawthorne' Shearon
15 | *
16 | * Optimized scanlines + noise version with intensity scaling
17 | * Georg 'Leviathan' Steinrohder
18 | *
19 | * This version is provided under a Creative Commons Attribution 3.0 License
20 | * http://creativecommons.org/licenses/by/3.0/
21 | */
22 |
23 | THREE.FilmShader = {
24 |
25 | uniforms: {
26 |
27 | "tDiffuse": { type: "t", value: null },
28 | "time": { type: "f", value: 0.0 },
29 | "nIntensity": { type: "f", value: 0.5 },
30 | "sIntensity": { type: "f", value: 0.05 },
31 | "sCount": { type: "f", value: 4096 },
32 | "grayscale": { type: "i", value: 1 }
33 |
34 | },
35 |
36 | vertexShader: [
37 |
38 | "varying vec2 vUv;",
39 |
40 | "void main() {",
41 |
42 | "vUv = uv;",
43 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
44 |
45 | "}"
46 |
47 | ].join( "\n" ),
48 |
49 | fragmentShader: [
50 |
51 | "#include ",
52 |
53 | // control parameter
54 | "uniform float time;",
55 |
56 | "uniform bool grayscale;",
57 |
58 | // noise effect intensity value (0 = no effect, 1 = full effect)
59 | "uniform float nIntensity;",
60 |
61 | // scanlines effect intensity value (0 = no effect, 1 = full effect)
62 | "uniform float sIntensity;",
63 |
64 | // scanlines effect count value (0 = no effect, 4096 = full effect)
65 | "uniform float sCount;",
66 |
67 | "uniform sampler2D tDiffuse;",
68 |
69 | "varying vec2 vUv;",
70 |
71 | "void main() {",
72 |
73 | // sample the source
74 | "vec4 cTextureScreen = texture2D( tDiffuse, vUv );",
75 |
76 | // make some noise
77 | "float dx = rand( vUv + time );",
78 |
79 | // add noise
80 | "vec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx, 0.0, 1.0 );",
81 |
82 | // get us a sine and cosine
83 | "vec2 sc = vec2( sin( vUv.y * sCount ), cos( vUv.y * sCount ) );",
84 |
85 | // add scanlines
86 | "cResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * sIntensity;",
87 |
88 | // interpolate between source and result by intensity
89 | "cResult = cTextureScreen.rgb + clamp( nIntensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );",
90 |
91 | // convert to grayscale if desired
92 | "if( grayscale ) {",
93 |
94 | "cResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );",
95 |
96 | "}",
97 |
98 | "gl_FragColor = vec4( cResult, cTextureScreen.a );",
99 |
100 | "}"
101 |
102 | ].join( "\n" )
103 |
104 | };
105 |
--------------------------------------------------------------------------------
/js/lib/shaders/FocusShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | *
4 | * Focus shader
5 | * based on PaintEffect postprocess from ro.me
6 | * http://code.google.com/p/3-dreams-of-black/source/browse/deploy/js/effects/PaintEffect.js
7 | */
8 |
9 | THREE.FocusShader = {
10 |
11 | uniforms : {
12 |
13 | "tDiffuse": { type: "t", value: null },
14 | "screenWidth": { type: "f", value: 1024 },
15 | "screenHeight": { type: "f", value: 1024 },
16 | "sampleDistance": { type: "f", value: 0.94 },
17 | "waveFactor": { type: "f", value: 0.00125 }
18 |
19 | },
20 |
21 | vertexShader: [
22 |
23 | "varying vec2 vUv;",
24 |
25 | "void main() {",
26 |
27 | "vUv = uv;",
28 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
29 |
30 | "}"
31 |
32 | ].join( "\n" ),
33 |
34 | fragmentShader: [
35 |
36 | "uniform float screenWidth;",
37 | "uniform float screenHeight;",
38 | "uniform float sampleDistance;",
39 | "uniform float waveFactor;",
40 |
41 | "uniform sampler2D tDiffuse;",
42 |
43 | "varying vec2 vUv;",
44 |
45 | "void main() {",
46 |
47 | "vec4 color, org, tmp, add;",
48 | "float sample_dist, f;",
49 | "vec2 vin;",
50 | "vec2 uv = vUv;",
51 |
52 | "add = color = org = texture2D( tDiffuse, uv );",
53 |
54 | "vin = ( uv - vec2( 0.5 ) ) * vec2( 1.4 );",
55 | "sample_dist = dot( vin, vin ) * 2.0;",
56 |
57 | "f = ( waveFactor * 100.0 + sample_dist ) * sampleDistance * 4.0;",
58 |
59 | "vec2 sampleSize = vec2( 1.0 / screenWidth, 1.0 / screenHeight ) * vec2( f );",
60 |
61 | "add += tmp = texture2D( tDiffuse, uv + vec2( 0.111964, 0.993712 ) * sampleSize );",
62 | "if( tmp.b < color.b ) color = tmp;",
63 |
64 | "add += tmp = texture2D( tDiffuse, uv + vec2( 0.846724, 0.532032 ) * sampleSize );",
65 | "if( tmp.b < color.b ) color = tmp;",
66 |
67 | "add += tmp = texture2D( tDiffuse, uv + vec2( 0.943883, -0.330279 ) * sampleSize );",
68 | "if( tmp.b < color.b ) color = tmp;",
69 |
70 | "add += tmp = texture2D( tDiffuse, uv + vec2( 0.330279, -0.943883 ) * sampleSize );",
71 | "if( tmp.b < color.b ) color = tmp;",
72 |
73 | "add += tmp = texture2D( tDiffuse, uv + vec2( -0.532032, -0.846724 ) * sampleSize );",
74 | "if( tmp.b < color.b ) color = tmp;",
75 |
76 | "add += tmp = texture2D( tDiffuse, uv + vec2( -0.993712, -0.111964 ) * sampleSize );",
77 | "if( tmp.b < color.b ) color = tmp;",
78 |
79 | "add += tmp = texture2D( tDiffuse, uv + vec2( -0.707107, 0.707107 ) * sampleSize );",
80 | "if( tmp.b < color.b ) color = tmp;",
81 |
82 | "color = color * vec4( 2.0 ) - ( add / vec4( 8.0 ) );",
83 | "color = color + ( add / vec4( 8.0 ) - color ) * ( vec4( 1.0 ) - vec4( sample_dist * 0.5 ) );",
84 |
85 | "gl_FragColor = vec4( color.rgb * color.rgb * vec3( 0.95 ) + color.rgb, 1.0 );",
86 |
87 | "}"
88 |
89 |
90 | ].join( "\n" )
91 | };
92 |
--------------------------------------------------------------------------------
/js/lib/shaders/FresnelShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | *
4 | * Based on Nvidia Cg tutorial
5 | */
6 |
7 | THREE.FresnelShader = {
8 |
9 | uniforms: {
10 |
11 | "mRefractionRatio": { type: "f", value: 1.02 },
12 | "mFresnelBias": { type: "f", value: 0.1 },
13 | "mFresnelPower": { type: "f", value: 2.0 },
14 | "mFresnelScale": { type: "f", value: 1.0 },
15 | "tCube": { type: "t", value: null }
16 |
17 | },
18 |
19 | vertexShader: [
20 |
21 | "uniform float mRefractionRatio;",
22 | "uniform float mFresnelBias;",
23 | "uniform float mFresnelScale;",
24 | "uniform float mFresnelPower;",
25 |
26 | "varying vec3 vReflect;",
27 | "varying vec3 vRefract[3];",
28 | "varying float vReflectionFactor;",
29 |
30 | "void main() {",
31 |
32 | "vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",
33 | "vec4 worldPosition = modelMatrix * vec4( position, 1.0 );",
34 |
35 | "vec3 worldNormal = normalize( mat3( modelMatrix[0].xyz, modelMatrix[1].xyz, modelMatrix[2].xyz ) * normal );",
36 |
37 | "vec3 I = worldPosition.xyz - cameraPosition;",
38 |
39 | "vReflect = reflect( I, worldNormal );",
40 | "vRefract[0] = refract( normalize( I ), worldNormal, mRefractionRatio );",
41 | "vRefract[1] = refract( normalize( I ), worldNormal, mRefractionRatio * 0.99 );",
42 | "vRefract[2] = refract( normalize( I ), worldNormal, mRefractionRatio * 0.98 );",
43 | "vReflectionFactor = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( I ), worldNormal ), mFresnelPower );",
44 |
45 | "gl_Position = projectionMatrix * mvPosition;",
46 |
47 | "}"
48 |
49 | ].join( "\n" ),
50 |
51 | fragmentShader: [
52 |
53 | "uniform samplerCube tCube;",
54 |
55 | "varying vec3 vReflect;",
56 | "varying vec3 vRefract[3];",
57 | "varying float vReflectionFactor;",
58 |
59 | "void main() {",
60 |
61 | "vec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );",
62 | "vec4 refractedColor = vec4( 1.0 );",
63 |
64 | "refractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;",
65 | "refractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;",
66 | "refractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;",
67 |
68 | "gl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );",
69 |
70 | "}"
71 |
72 | ].join( "\n" )
73 |
74 | };
75 |
--------------------------------------------------------------------------------
/js/lib/shaders/GammaCorrectionShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author WestLangley / http://github.com/WestLangley
3 | *
4 | * Gamma Correction Shader
5 | * http://en.wikipedia.org/wiki/gamma_correction
6 | */
7 |
8 | THREE.GammaCorrectionShader = {
9 |
10 | uniforms: {
11 |
12 | "tDiffuse": { type: "t", value: null },
13 |
14 | },
15 |
16 | vertexShader: [
17 |
18 | "varying vec2 vUv;",
19 |
20 | "void main() {",
21 |
22 | "vUv = uv;",
23 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
24 |
25 | "}"
26 |
27 | ].join( "\n" ),
28 |
29 | fragmentShader: [
30 |
31 | "uniform sampler2D tDiffuse;",
32 |
33 | "varying vec2 vUv;",
34 |
35 | "void main() {",
36 |
37 | "vec4 tex = texture2D( tDiffuse, vec2( vUv.x, vUv.y ) );",
38 |
39 | "gl_FragColor = LinearToGamma( tex, float( GAMMA_FACTOR ) );",
40 |
41 | "}"
42 |
43 | ].join( "\n" )
44 |
45 | };
46 |
--------------------------------------------------------------------------------
/js/lib/shaders/HorizontalBlurShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author zz85 / http://www.lab4games.net/zz85/blog
3 | *
4 | * Two pass Gaussian blur filter (horizontal and vertical blur shaders)
5 | * - described in http://www.gamerendering.com/2008/10/11/gaussian-blur-filter-shader/
6 | * and used in http://www.cake23.de/traveling-wavefronts-lit-up.html
7 | *
8 | * - 9 samples per pass
9 | * - standard deviation 2.7
10 | * - "h" and "v" parameters should be set to "1 / width" and "1 / height"
11 | */
12 |
13 | THREE.HorizontalBlurShader = {
14 |
15 | uniforms: {
16 |
17 | "tDiffuse": { type: "t", value: null },
18 | "h": { type: "f", value: 1.0 / 512.0 }
19 |
20 | },
21 |
22 | vertexShader: [
23 |
24 | "uniform float h;",
25 | "varying vec2 vUv;",
26 |
27 | "varying vec2 v0;",
28 | "varying vec2 v1;",
29 | "varying vec2 v2;",
30 | "varying vec2 v3;",
31 | "varying vec2 v4;",
32 | "varying vec2 v5;",
33 | "varying vec2 v6;",
34 | "varying vec2 v7;",
35 | "varying vec2 v8;",
36 |
37 | "void main() {",
38 |
39 | "vUv = uv;",
40 | "v0 = vec2(uv.x - 4.0 * h, uv.y);",
41 | "v1 = vec2(uv.x - 3.0 * h, uv.y);",
42 | "v2 = vec2(uv.x - 2.0 * h, uv.y);",
43 | "v3 = vec2(uv.x - 1.0 * h, uv.y);",
44 | "v4 = vec2(uv.x, uv.y);",
45 | "v5 = vec2(uv.x + 1.0 * h, uv.y);",
46 | "v6 = vec2(uv.x + 2.0 * h, uv.y);",
47 | "v7 = vec2(uv.x + 3.0 * h, uv.y);",
48 | "v8 = vec2(uv.x + 4.0 * h, uv.y);",
49 |
50 |
51 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
52 |
53 | "}"
54 |
55 | ].join( "\n" ),
56 |
57 | fragmentShader: [
58 |
59 | "uniform sampler2D tDiffuse;",
60 | "uniform float h;",
61 |
62 |
63 | "varying vec2 v0;",
64 | "varying vec2 v1;",
65 | "varying vec2 v2;",
66 | "varying vec2 v3;",
67 | "varying vec2 v4;",
68 | "varying vec2 v5;",
69 | "varying vec2 v6;",
70 | "varying vec2 v7;",
71 | "varying vec2 v8;",
72 |
73 | "varying vec2 vUv;",
74 |
75 | "void main() {",
76 |
77 | "vec4 sum = vec4( 0.0 );",
78 |
79 | "sum += texture2D( tDiffuse, v0 ) * 0.051;",
80 | "sum += texture2D( tDiffuse, v1 ) * 0.0918;",
81 | "sum += texture2D( tDiffuse, v2 ) * 0.12245;",
82 | "sum += texture2D( tDiffuse, v3 ) * 0.1531;",
83 | "sum += texture2D( tDiffuse, v4 ) * 0.1633;",
84 | "sum += texture2D( tDiffuse, v5 ) * 0.1531;",
85 | "sum += texture2D( tDiffuse, v6 ) * 0.12245;",
86 | "sum += texture2D( tDiffuse, v7 ) * 0.0918;",
87 | "sum += texture2D( tDiffuse, v8 ) * 0.051;",
88 |
89 | "gl_FragColor = sum;",
90 |
91 | "}"
92 |
93 | ].join( "\n" )
94 |
95 | };
--------------------------------------------------------------------------------
/js/lib/shaders/HorizontalTiltShiftShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | *
4 | * Simple fake tilt-shift effect, modulating two pass Gaussian blur (see above) by vertical position
5 | *
6 | * - 9 samples per pass
7 | * - standard deviation 2.7
8 | * - "h" and "v" parameters should be set to "1 / width" and "1 / height"
9 | * - "r" parameter control where "focused" horizontal line lies
10 | */
11 |
12 | THREE.HorizontalTiltShiftShader = {
13 |
14 | uniforms: {
15 |
16 | "tDiffuse": { type: "t", value: null },
17 | "h": { type: "f", value: 1.0 / 512.0 },
18 | "r": { type: "f", value: 0.35 }
19 |
20 | },
21 |
22 | vertexShader: [
23 |
24 | "varying vec2 vUv;",
25 |
26 | "void main() {",
27 |
28 | "vUv = uv;",
29 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
30 |
31 | "}"
32 |
33 | ].join( "\n" ),
34 |
35 | fragmentShader: [
36 |
37 | "uniform sampler2D tDiffuse;",
38 | "uniform float h;",
39 | "uniform float r;",
40 |
41 | "varying vec2 vUv;",
42 |
43 | "void main() {",
44 |
45 | "vec4 sum = vec4( 0.0 );",
46 |
47 | "float hh = h * abs( r - vUv.y );",
48 |
49 | "sum += texture2D( tDiffuse, vec2( vUv.x - 4.0 * hh, vUv.y ) ) * 0.051;",
50 | "sum += texture2D( tDiffuse, vec2( vUv.x - 3.0 * hh, vUv.y ) ) * 0.0918;",
51 | "sum += texture2D( tDiffuse, vec2( vUv.x - 2.0 * hh, vUv.y ) ) * 0.12245;",
52 | "sum += texture2D( tDiffuse, vec2( vUv.x - 1.0 * hh, vUv.y ) ) * 0.1531;",
53 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;",
54 | "sum += texture2D( tDiffuse, vec2( vUv.x + 1.0 * hh, vUv.y ) ) * 0.1531;",
55 | "sum += texture2D( tDiffuse, vec2( vUv.x + 2.0 * hh, vUv.y ) ) * 0.12245;",
56 | "sum += texture2D( tDiffuse, vec2( vUv.x + 3.0 * hh, vUv.y ) ) * 0.0918;",
57 | "sum += texture2D( tDiffuse, vec2( vUv.x + 4.0 * hh, vUv.y ) ) * 0.051;",
58 |
59 | "gl_FragColor = sum;",
60 |
61 | "}"
62 |
63 | ].join( "\n" )
64 |
65 | };
66 |
--------------------------------------------------------------------------------
/js/lib/shaders/HueSaturationShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author tapio / http://tapio.github.com/
3 | *
4 | * Hue and saturation adjustment
5 | * https://github.com/evanw/glfx.js
6 | * hue: -1 to 1 (-1 is 180 degrees in the negative direction, 0 is no change, etc.
7 | * saturation: -1 to 1 (-1 is solid gray, 0 is no change, and 1 is maximum contrast)
8 | */
9 |
10 | THREE.HueSaturationShader = {
11 |
12 | uniforms: {
13 |
14 | "tDiffuse": { type: "t", value: null },
15 | "hue": { type: "f", value: 0 },
16 | "saturation": { type: "f", value: 0 }
17 |
18 | },
19 |
20 | vertexShader: [
21 |
22 | "varying vec2 vUv;",
23 |
24 | "void main() {",
25 |
26 | "vUv = uv;",
27 |
28 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
29 |
30 | "}"
31 |
32 | ].join( "\n" ),
33 |
34 | fragmentShader: [
35 |
36 | "uniform sampler2D tDiffuse;",
37 | "uniform float hue;",
38 | "uniform float saturation;",
39 |
40 | "varying vec2 vUv;",
41 |
42 | "void main() {",
43 |
44 | "gl_FragColor = texture2D( tDiffuse, vUv );",
45 |
46 | // hue
47 | "float angle = hue * 3.14159265;",
48 | "float s = sin(angle), c = cos(angle);",
49 | "vec3 weights = (vec3(2.0 * c, -sqrt(3.0) * s - c, sqrt(3.0) * s - c) + 1.0) / 3.0;",
50 | "float len = length(gl_FragColor.rgb);",
51 | "gl_FragColor.rgb = vec3(",
52 | "dot(gl_FragColor.rgb, weights.xyz),",
53 | "dot(gl_FragColor.rgb, weights.zxy),",
54 | "dot(gl_FragColor.rgb, weights.yzx)",
55 | ");",
56 |
57 | // saturation
58 | "float average = (gl_FragColor.r + gl_FragColor.g + gl_FragColor.b) / 3.0;",
59 | "if (saturation > 0.0) {",
60 | "gl_FragColor.rgb += (average - gl_FragColor.rgb) * (1.0 - 1.0 / (1.001 - saturation));",
61 | "} else {",
62 | "gl_FragColor.rgb += (average - gl_FragColor.rgb) * (-saturation);",
63 | "}",
64 |
65 | "}"
66 |
67 | ].join( "\n" )
68 |
69 | };
70 |
--------------------------------------------------------------------------------
/js/lib/shaders/KaleidoShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author felixturner / http://airtight.cc/
3 | *
4 | * Kaleidoscope Shader
5 | * Radial reflection around center point
6 | * Ported from: http://pixelshaders.com/editor/
7 | * by Toby Schachman / http://tobyschachman.com/
8 | *
9 | * sides: number of reflections
10 | * angle: initial angle in radians
11 | */
12 |
13 | THREE.KaleidoShader = {
14 |
15 | uniforms: {
16 |
17 | "tDiffuse": { type: "t", value: null },
18 | "sides": { type: "f", value: 6.0 },
19 | "angle": { type: "f", value: 0.0 }
20 |
21 | },
22 |
23 | vertexShader: [
24 |
25 | "varying vec2 vUv;",
26 |
27 | "void main() {",
28 |
29 | "vUv = uv;",
30 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
31 |
32 | "}"
33 |
34 | ].join( "\n" ),
35 |
36 | fragmentShader: [
37 |
38 | "uniform sampler2D tDiffuse;",
39 | "uniform float sides;",
40 | "uniform float angle;",
41 |
42 | "varying vec2 vUv;",
43 |
44 | "void main() {",
45 |
46 | "vec2 p = vUv - 0.5;",
47 | "float r = length(p);",
48 | "float a = atan(p.y, p.x) + angle;",
49 | "float tau = 2. * 3.1416 ;",
50 | "a = mod(a, tau/sides);",
51 | "a = abs(a - tau/sides/2.) ;",
52 | "p = r * vec2(cos(a), sin(a));",
53 | "vec4 color = texture2D(tDiffuse, p + 0.5);",
54 | "gl_FragColor = color;",
55 |
56 | "}"
57 |
58 | ].join( "\n" )
59 |
60 | };
61 |
--------------------------------------------------------------------------------
/js/lib/shaders/LuminosityShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | *
4 | * Luminosity
5 | * http://en.wikipedia.org/wiki/Luminosity
6 | */
7 |
8 | THREE.LuminosityShader = {
9 |
10 | uniforms: {
11 |
12 | "tDiffuse": { type: "t", value: null }
13 |
14 | },
15 |
16 | vertexShader: [
17 |
18 | "varying vec2 vUv;",
19 |
20 | "void main() {",
21 |
22 | "vUv = uv;",
23 |
24 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
25 |
26 | "}"
27 |
28 | ].join( "\n" ),
29 |
30 | fragmentShader: [
31 |
32 | "uniform sampler2D tDiffuse;",
33 |
34 | "varying vec2 vUv;",
35 |
36 | "void main() {",
37 |
38 | "vec4 texel = texture2D( tDiffuse, vUv );",
39 |
40 | "vec3 luma = vec3( 0.299, 0.587, 0.114 );",
41 |
42 | "float v = dot( texel.xyz, luma );",
43 |
44 | "gl_FragColor = vec4( v, v, v, texel.w );",
45 |
46 | "}"
47 |
48 | ].join( "\n" )
49 |
50 | };
51 |
--------------------------------------------------------------------------------
/js/lib/shaders/MirrorShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author felixturner / http://airtight.cc/
3 | *
4 | * Mirror Shader
5 | * Copies half the input to the other half
6 | *
7 | * side: side of input to mirror (0 = left, 1 = right, 2 = top, 3 = bottom)
8 | */
9 |
10 | THREE.MirrorShader = {
11 |
12 | uniforms: {
13 |
14 | "tDiffuse": { type: "t", value: null },
15 | "side": { type: "i", value: 1 }
16 |
17 | },
18 |
19 | vertexShader: [
20 |
21 | "varying vec2 vUv;",
22 |
23 | "void main() {",
24 |
25 | "vUv = uv;",
26 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
27 |
28 | "}"
29 |
30 | ].join( "\n" ),
31 |
32 | fragmentShader: [
33 |
34 | "uniform sampler2D tDiffuse;",
35 | "uniform int side;",
36 |
37 | "varying vec2 vUv;",
38 |
39 | "void main() {",
40 |
41 | "vec2 p = vUv;",
42 | "if (side == 0){",
43 | "if (p.x > 0.5) p.x = 1.0 - p.x;",
44 | "}else if (side == 1){",
45 | "if (p.x < 0.5) p.x = 1.0 - p.x;",
46 | "}else if (side == 2){",
47 | "if (p.y < 0.5) p.y = 1.0 - p.y;",
48 | "}else if (side == 3){",
49 | "if (p.y > 0.5) p.y = 1.0 - p.y;",
50 | "} ",
51 | "vec4 color = texture2D(tDiffuse, p);",
52 | "gl_FragColor = color;",
53 |
54 | "}"
55 |
56 | ].join( "\n" )
57 |
58 | };
59 |
--------------------------------------------------------------------------------
/js/lib/shaders/NormalMapShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | *
4 | * Normal map shader
5 | * - compute normals from heightmap
6 | */
7 |
8 | THREE.NormalMapShader = {
9 |
10 | uniforms: {
11 |
12 | "heightMap": { type: "t", value: null },
13 | "resolution": { type: "v2", value: new THREE.Vector2( 512, 512 ) },
14 | "scale": { type: "v2", value: new THREE.Vector2( 1, 1 ) },
15 | "height": { type: "f", value: 0.05 }
16 |
17 | },
18 |
19 | vertexShader: [
20 |
21 | "varying vec2 vUv;",
22 |
23 | "void main() {",
24 |
25 | "vUv = uv;",
26 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
27 |
28 | "}"
29 |
30 | ].join( "\n" ),
31 |
32 | fragmentShader: [
33 |
34 | "uniform float height;",
35 | "uniform vec2 resolution;",
36 | "uniform sampler2D heightMap;",
37 |
38 | "varying vec2 vUv;",
39 |
40 | "void main() {",
41 |
42 | "float val = texture2D( heightMap, vUv ).x;",
43 |
44 | "float valU = texture2D( heightMap, vUv + vec2( 1.0 / resolution.x, 0.0 ) ).x;",
45 | "float valV = texture2D( heightMap, vUv + vec2( 0.0, 1.0 / resolution.y ) ).x;",
46 |
47 | "gl_FragColor = vec4( ( 0.5 * normalize( vec3( val - valU, val - valV, height ) ) + 0.5 ), 1.0 );",
48 |
49 | "}"
50 |
51 | ].join( "\n" )
52 |
53 | };
54 |
--------------------------------------------------------------------------------
/js/lib/shaders/RGBShiftShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author felixturner / http://airtight.cc/
3 | *
4 | * RGB Shift Shader
5 | * Shifts red and blue channels from center in opposite directions
6 | * Ported from http://kriss.cx/tom/2009/05/rgb-shift/
7 | * by Tom Butterworth / http://kriss.cx/tom/
8 | *
9 | * amount: shift distance (1 is width of input)
10 | * angle: shift angle in radians
11 | */
12 |
13 | THREE.RGBShiftShader = {
14 |
15 | uniforms: {
16 |
17 | "tDiffuse": { type: "t", value: null },
18 | "amount": { type: "f", value: 0.005 },
19 | "angle": { type: "f", value: 0.0 }
20 |
21 | },
22 |
23 | vertexShader: [
24 |
25 | "varying vec2 vUv;",
26 |
27 | "void main() {",
28 |
29 | "vUv = uv;",
30 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
31 |
32 | "}"
33 |
34 | ].join( "\n" ),
35 |
36 | fragmentShader: [
37 |
38 | "uniform sampler2D tDiffuse;",
39 | "uniform float amount;",
40 | "uniform float angle;",
41 |
42 | "varying vec2 vUv;",
43 |
44 | "void main() {",
45 |
46 | "vec2 offset = amount * vec2( cos(angle), sin(angle));",
47 | "vec4 cr = texture2D(tDiffuse, vUv + offset);",
48 | "vec4 cga = texture2D(tDiffuse, vUv);",
49 | "vec4 cb = texture2D(tDiffuse, vUv - offset);",
50 | "gl_FragColor = vec4(cr.r, cga.g, cb.b, cga.a);",
51 |
52 | "}"
53 |
54 | ].join( "\n" )
55 |
56 | };
57 |
--------------------------------------------------------------------------------
/js/lib/shaders/RGBShiftShader2.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author felixturner / http://airtight.cc/
3 | * @author marpi / http://marpi.pl/
4 | *
5 | * RGB Shift Shader
6 | * Shifts red and blue channels from center in opposite directions
7 | * Ported from http://kriss.cx/tom/2009/05/rgb-shift/
8 | * by Tom Butterworth / http://kriss.cx/tom/
9 | *
10 | * Customized to appear only on peripheral vision
11 | *
12 | * amount: shift distance (1 is width of input)
13 | * angle: shift angle in radians
14 | */
15 |
16 | THREE.RGBShiftShader = {
17 |
18 | uniforms: {
19 |
20 | "tDiffuse": { type: "t", value: null },
21 | "amount": { type: "f", value: 0.005 },
22 | "angle": { type: "f", value: 0.0 }
23 |
24 | },
25 |
26 | vertexShader: [
27 |
28 | "varying vec2 vUv;",
29 |
30 | "void main() {",
31 |
32 | "vUv = uv;",
33 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
34 |
35 | "}"
36 |
37 | ].join("\n"),
38 |
39 | fragmentShader: [
40 |
41 | "uniform sampler2D tDiffuse;",
42 | "uniform float amount;",
43 | "uniform float angle;",
44 |
45 | "varying vec2 vUv;",
46 |
47 | "void main() {",
48 |
49 | "vec2 offset = abs(vUv.x - 0.5) * amount * vec2( cos(angle), sin(angle));",
50 | "vec4 cr = texture2D(tDiffuse, vUv + offset);",
51 | "vec4 cga = texture2D(tDiffuse, vUv);",
52 | "vec4 cb = texture2D(tDiffuse, vUv - offset);",
53 | "gl_FragColor = vec4(cr.r, cga.g, cb.b, cga.a);",
54 |
55 | "}"
56 |
57 | ].join("\n")
58 |
59 | };
60 |
--------------------------------------------------------------------------------
/js/lib/shaders/SepiaShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | *
4 | * Sepia tone shader
5 | * based on glfx.js sepia shader
6 | * https://github.com/evanw/glfx.js
7 | */
8 |
9 | THREE.SepiaShader = {
10 |
11 | uniforms: {
12 |
13 | "tDiffuse": { type: "t", value: null },
14 | "amount": { type: "f", value: 1.0 }
15 |
16 | },
17 |
18 | vertexShader: [
19 |
20 | "varying vec2 vUv;",
21 |
22 | "void main() {",
23 |
24 | "vUv = uv;",
25 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
26 |
27 | "}"
28 |
29 | ].join( "\n" ),
30 |
31 | fragmentShader: [
32 |
33 | "uniform float amount;",
34 |
35 | "uniform sampler2D tDiffuse;",
36 |
37 | "varying vec2 vUv;",
38 |
39 | "void main() {",
40 |
41 | "vec4 color = texture2D( tDiffuse, vUv );",
42 | "vec3 c = color.rgb;",
43 |
44 | "color.r = dot( c, vec3( 1.0 - 0.607 * amount, 0.769 * amount, 0.189 * amount ) );",
45 | "color.g = dot( c, vec3( 0.349 * amount, 1.0 - 0.314 * amount, 0.168 * amount ) );",
46 | "color.b = dot( c, vec3( 0.272 * amount, 0.534 * amount, 1.0 - 0.869 * amount ) );",
47 |
48 | "gl_FragColor = vec4( min( vec3( 1.0 ), color.rgb ), color.a );",
49 |
50 | "}"
51 |
52 | ].join( "\n" )
53 |
54 | };
55 |
--------------------------------------------------------------------------------
/js/lib/shaders/TechnicolorShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author flimshaw / http://charliehoey.com
3 | *
4 | * Technicolor Shader
5 | * Simulates the look of the two-strip technicolor process popular in early 20th century films.
6 | * More historical info here: http://www.widescreenmuseum.com/oldcolor/technicolor1.htm
7 | * Demo here: http://charliehoey.com/technicolor_shader/shader_test.html
8 | */
9 |
10 | THREE.TechnicolorShader = {
11 |
12 | uniforms: {
13 |
14 | "tDiffuse": { type: "t", value: null },
15 |
16 | },
17 |
18 | vertexShader: [
19 |
20 | "varying vec2 vUv;",
21 |
22 | "void main() {",
23 |
24 | "vUv = uv;",
25 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
26 |
27 | "}"
28 |
29 | ].join( "\n" ),
30 |
31 | fragmentShader: [
32 |
33 | "uniform sampler2D tDiffuse;",
34 | "varying vec2 vUv;",
35 |
36 | "void main() {",
37 |
38 | "vec4 tex = texture2D( tDiffuse, vec2( vUv.x, vUv.y ) );",
39 | "vec4 newTex = vec4(tex.r, (tex.g + tex.b) * .5, (tex.g + tex.b) * .5, 1.0);",
40 |
41 | "gl_FragColor = newTex;",
42 |
43 | "}"
44 |
45 | ].join( "\n" )
46 |
47 | };
48 |
--------------------------------------------------------------------------------
/js/lib/shaders/TiltShiftShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Customized Vertical TiltShift
4 | *
5 | * Added H blur
6 | * Added amount + brightness uniforms
7 | *
8 | * @author alteredq / http://alteredqualia.com/
9 | * @author felixturner / airtight.cc
10 | *
11 | */
12 |
13 | THREE.VerticalTiltShiftShader = {
14 |
15 | uniforms: {
16 |
17 | "tDiffuse": { type: "t", value: null },
18 | "focusPos": { type: "f", value: 0.35 }, // focus Y position 0 = bottom, 1 = top
19 | "amount": { type: "f", value: 1 }, // amount of blur
20 | "brightness": { type: "f", value: 0.5 } // 0.5 = no brightness change
21 |
22 | },
23 |
24 | vertexShader: [
25 |
26 | "varying vec2 vUv;",
27 |
28 | "void main() {",
29 |
30 | "vUv = uv;",
31 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
32 |
33 | "}"
34 |
35 | ].join( "\n" ),
36 |
37 | fragmentShader: [
38 |
39 | "uniform sampler2D tDiffuse;",
40 | "uniform float focusPos;",
41 | "uniform float amount;",
42 | "uniform float brightness;",
43 |
44 | "varying vec2 vUv;",
45 |
46 | "void main() {",
47 |
48 | "vec4 sum = vec4( 0.0 );",
49 | "float vv = abs( focusPos - vUv.y ) * amount;",//0.0006+
50 |
51 | //V blur
52 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 4.0 * vv ) ) * 0.051 * brightness;",
53 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 3.0 * vv ) ) * 0.0918 * brightness;",
54 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 2.0 * vv ) ) * 0.12245 * brightness;",
55 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 1.0 * vv ) ) * 0.1531 * brightness;",
56 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633 * brightness;",
57 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 1.0 * vv ) ) * 0.1531 * brightness;",
58 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 2.0 * vv ) ) * 0.12245 * brightness;",
59 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 3.0 * vv ) ) * 0.0918 * brightness;",
60 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 4.0 * vv ) ) * 0.051 * brightness;",
61 |
62 | //H blur
63 | "sum += texture2D( tDiffuse, vec2( vUv.x - 4.0 * vv , vUv.y ) ) * 0.051 * brightness;",
64 | "sum += texture2D( tDiffuse, vec2( vUv.x - 3.0 * vv, vUv.y ) ) * 0.0918 * brightness;",
65 | "sum += texture2D( tDiffuse, vec2( vUv.x - 2.0 * vv, vUv.y ) ) * 0.12245 * brightness;",
66 | "sum += texture2D( tDiffuse, vec2( vUv.x - 1.0 * vv, vUv.y ) ) * 0.1531 * brightness;",
67 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633 * brightness;",
68 | "sum += texture2D( tDiffuse, vec2( vUv.x + 1.0 * vv, vUv.y ) ) * 0.1531 * brightness;",
69 | "sum += texture2D( tDiffuse, vec2( vUv.x + 2.0 * vv, vUv.y ) ) * 0.12245 * brightness;",
70 | "sum += texture2D( tDiffuse, vec2( vUv.x + 3.0 * vv, vUv.y ) ) * 0.0918 * brightness;",
71 | "sum += texture2D( tDiffuse, vec2( vUv.x + 4.0 * vv, vUv.y ) ) * 0.051 * brightness;",
72 |
73 | "gl_FragColor = sum;",
74 |
75 | "}"
76 |
77 | ].join( "\n" )
78 |
79 | };
80 |
--------------------------------------------------------------------------------
/js/lib/shaders/ToneMapShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author miibond
3 | *
4 | * Full-screen tone-mapping shader based on http://www.graphics.cornell.edu/~jaf/publications/sig02_paper.pdf
5 | */
6 |
7 | THREE.ToneMapShader = {
8 |
9 | uniforms: {
10 |
11 | "tDiffuse": { type: "t", value: null },
12 | "averageLuminance": { type: "f", value: 1.0 },
13 | "luminanceMap": { type: "t", value: null },
14 | "maxLuminance": { type: "f", value: 16.0 },
15 | "middleGrey": { type: "f", value: 0.6 }
16 | },
17 |
18 | vertexShader: [
19 |
20 | "varying vec2 vUv;",
21 |
22 | "void main() {",
23 |
24 | "vUv = uv;",
25 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
26 |
27 | "}"
28 |
29 | ].join( "\n" ),
30 |
31 | fragmentShader: [
32 |
33 | "uniform sampler2D tDiffuse;",
34 |
35 | "varying vec2 vUv;",
36 |
37 | "uniform float middleGrey;",
38 | "uniform float maxLuminance;",
39 | "#ifdef ADAPTED_LUMINANCE",
40 | "uniform sampler2D luminanceMap;",
41 | "#else",
42 | "uniform float averageLuminance;",
43 | "#endif",
44 |
45 | "const vec3 LUM_CONVERT = vec3(0.299, 0.587, 0.114);",
46 |
47 | "vec3 ToneMap( vec3 vColor ) {",
48 | "#ifdef ADAPTED_LUMINANCE",
49 | // Get the calculated average luminance
50 | "float fLumAvg = texture2D(luminanceMap, vec2(0.5, 0.5)).r;",
51 | "#else",
52 | "float fLumAvg = averageLuminance;",
53 | "#endif",
54 |
55 | // Calculate the luminance of the current pixel
56 | "float fLumPixel = dot(vColor, LUM_CONVERT);",
57 |
58 | // Apply the modified operator (Eq. 4)
59 | "float fLumScaled = (fLumPixel * middleGrey) / fLumAvg;",
60 |
61 | "float fLumCompressed = (fLumScaled * (1.0 + (fLumScaled / (maxLuminance * maxLuminance)))) / (1.0 + fLumScaled);",
62 | "return fLumCompressed * vColor;",
63 | "}",
64 |
65 | "void main() {",
66 |
67 | "vec4 texel = texture2D( tDiffuse, vUv );",
68 |
69 | "gl_FragColor = vec4( ToneMap( texel.xyz ), texel.w );",
70 |
71 | "}"
72 |
73 | ].join( "\n" )
74 |
75 | };
76 |
--------------------------------------------------------------------------------
/js/lib/shaders/TriangleBlurShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author zz85 / http://www.lab4games.net/zz85/blog
3 | *
4 | * Triangle blur shader
5 | * based on glfx.js triangle blur shader
6 | * https://github.com/evanw/glfx.js
7 | *
8 | * A basic blur filter, which convolves the image with a
9 | * pyramid filter. The pyramid filter is separable and is applied as two
10 | * perpendicular triangle filters.
11 | */
12 |
13 | THREE.TriangleBlurShader = {
14 |
15 | uniforms : {
16 |
17 | "texture": { type: "t", value: null },
18 | "delta": { type: "v2", value: new THREE.Vector2( 1, 1 ) }
19 |
20 | },
21 |
22 | vertexShader: [
23 |
24 | "varying vec2 vUv;",
25 |
26 | "void main() {",
27 |
28 | "vUv = uv;",
29 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
30 |
31 | "}"
32 |
33 | ].join( "\n" ),
34 |
35 | fragmentShader: [
36 |
37 | "#include ",
38 |
39 | "#define ITERATIONS 10.0",
40 |
41 | "uniform sampler2D texture;",
42 | "uniform vec2 delta;",
43 |
44 | "varying vec2 vUv;",
45 |
46 | "void main() {",
47 |
48 | "vec4 color = vec4( 0.0 );",
49 |
50 | "float total = 0.0;",
51 |
52 | // randomize the lookup values to hide the fixed number of samples
53 |
54 | "float offset = rand( vUv );",
55 |
56 | "for ( float t = -ITERATIONS; t <= ITERATIONS; t ++ ) {",
57 |
58 | "float percent = ( t + offset - 0.5 ) / ITERATIONS;",
59 | "float weight = 1.0 - abs( percent );",
60 |
61 | "color += texture2D( texture, vUv + delta * percent ) * weight;",
62 | "total += weight;",
63 |
64 | "}",
65 |
66 | "gl_FragColor = color / total;",
67 |
68 | "}"
69 |
70 | ].join( "\n" )
71 |
72 | };
73 |
--------------------------------------------------------------------------------
/js/lib/shaders/UnpackDepthRGBAShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | *
4 | * Unpack RGBA depth shader
5 | * - show RGBA encoded depth as monochrome color
6 | */
7 |
8 | THREE.UnpackDepthRGBAShader = {
9 |
10 | uniforms: {
11 |
12 | "tDiffuse": { type: "t", value: null },
13 | "opacity": { type: "f", value: 1.0 }
14 |
15 | },
16 |
17 | vertexShader: [
18 |
19 | "varying vec2 vUv;",
20 |
21 | "void main() {",
22 |
23 | "vUv = uv;",
24 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
25 |
26 | "}"
27 |
28 | ].join( "\n" ),
29 |
30 | fragmentShader: [
31 |
32 | "uniform float opacity;",
33 |
34 | "uniform sampler2D tDiffuse;",
35 |
36 | "varying vec2 vUv;",
37 |
38 | "#include ",
39 |
40 | "void main() {",
41 |
42 | "float depth = 1.0 - unpackRGBAToDepth( texture2D( tDiffuse, vUv ) );",
43 | "gl_FragColor = opacity * vec4( vec3( depth ), 1.0 );",
44 |
45 | "}"
46 |
47 | ].join( "\n" )
48 |
49 | };
50 |
--------------------------------------------------------------------------------
/js/lib/shaders/VerticalBlurShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author zz85 / http://www.lab4games.net/zz85/blog
3 | *
4 | * Two pass Gaussian blur filter (horizontal and vertical blur shaders)
5 | * - described in http://www.gamerendering.com/2008/10/11/gaussian-blur-filter-shader/
6 | * and used in http://www.cake23.de/traveling-wavefronts-lit-up.html
7 | *
8 | * - 9 samples per pass
9 | * - standard deviation 2.7
10 | * - "h" and "v" parameters should be set to "1 / width" and "1 / height"
11 | */
12 |
13 | THREE.VerticalBlurShader = {
14 |
15 | uniforms: {
16 |
17 | "tDiffuse": { type: "t", value: null },
18 | "v": { type: "f", value: 1.0 / 512.0 }
19 |
20 | },
21 |
22 | vertexShader: [
23 |
24 | "varying vec2 vUv;",
25 |
26 | "uniform float v;",
27 |
28 | "varying vec2 v0;",
29 | "varying vec2 v1;",
30 | "varying vec2 v2;",
31 | "varying vec2 v3;",
32 | "varying vec2 v4;",
33 | "varying vec2 v5;",
34 | "varying vec2 v6;",
35 | "varying vec2 v7;",
36 | "varying vec2 v8;",
37 | "void main() {",
38 |
39 | "vUv = uv;",
40 | "v0 = vec2(uv.x, uv.y - 4.0 * v);",
41 | "v1 = vec2(uv.x, uv.y - 3.0 * v);",
42 | "v2 = vec2(uv.x, uv.y - 2.0 * v);",
43 | "v3 = vec2(uv.x, uv.y - 1.0 * v);",
44 | "v4 = vec2(uv.x, uv.y);",
45 | "v5 = vec2(uv.x, uv.y + 1.0 * v);",
46 | "v6 = vec2(uv.x, uv.y + 2.0 * v);",
47 | "v7 = vec2(uv.x, uv.y + 3.0 * v);",
48 | "v8 = vec2(uv.x, uv.y + 4.0 * v);",
49 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
50 |
51 | "}"
52 |
53 | ].join( "\n" ),
54 |
55 | fragmentShader: [
56 |
57 | "uniform sampler2D tDiffuse;",
58 | "uniform float v;",
59 |
60 |
61 | "varying vec2 v0;",
62 | "varying vec2 v1;",
63 | "varying vec2 v2;",
64 | "varying vec2 v3;",
65 | "varying vec2 v4;",
66 | "varying vec2 v5;",
67 | "varying vec2 v6;",
68 | "varying vec2 v7;",
69 | "varying vec2 v8;",
70 |
71 | "varying vec2 vUv;",
72 |
73 | "void main() {",
74 |
75 | "vec4 sum = vec4( 0.0 );",
76 |
77 | "sum += texture2D( tDiffuse, v0 ) * 0.051;",
78 | "sum += texture2D( tDiffuse, v1 ) * 0.0918;",
79 | "sum += texture2D( tDiffuse, v2 ) * 0.12245;",
80 | "sum += texture2D( tDiffuse, v3 ) * 0.1531;",
81 | "sum += texture2D( tDiffuse, v4 ) * 0.1633;",
82 | "sum += texture2D( tDiffuse, v5 ) * 0.1531;",
83 | "sum += texture2D( tDiffuse, v6 ) * 0.12245;",
84 | "sum += texture2D( tDiffuse, v7 ) * 0.0918;",
85 | "sum += texture2D( tDiffuse, v8 ) * 0.051;",
86 |
87 | "gl_FragColor = sum;",
88 |
89 | "}"
90 |
91 | ].join( "\n" )
92 |
93 | };
94 |
--------------------------------------------------------------------------------
/js/lib/shaders/VerticalTiltShiftShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | *
4 | * Simple fake tilt-shift effect, modulating two pass Gaussian blur (see above) by vertical position
5 | *
6 | * - 9 samples per pass
7 | * - standard deviation 2.7
8 | * - "h" and "v" parameters should be set to "1 / width" and "1 / height"
9 | * - "r" parameter control where "focused" horizontal line lies
10 | */
11 |
12 | THREE.VerticalTiltShiftShader = {
13 |
14 | uniforms: {
15 |
16 | "tDiffuse": { type: "t", value: null },
17 | "v": { type: "f", value: 1.0 / 512.0 },
18 | "r": { type: "f", value: 0.35 }
19 |
20 | },
21 |
22 | vertexShader: [
23 |
24 | "varying vec2 vUv;",
25 |
26 | "void main() {",
27 |
28 | "vUv = uv;",
29 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
30 |
31 | "}"
32 |
33 | ].join( "\n" ),
34 |
35 | fragmentShader: [
36 |
37 | "uniform sampler2D tDiffuse;",
38 | "uniform float v;",
39 | "uniform float r;",
40 |
41 | "varying vec2 vUv;",
42 |
43 | "void main() {",
44 |
45 | "vec4 sum = vec4( 0.0 );",
46 |
47 | "float vv = v * abs( r - vUv.y );",
48 |
49 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 4.0 * vv ) ) * 0.051;",
50 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 3.0 * vv ) ) * 0.0918;",
51 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 2.0 * vv ) ) * 0.12245;",
52 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 1.0 * vv ) ) * 0.1531;",
53 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;",
54 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 1.0 * vv ) ) * 0.1531;",
55 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 2.0 * vv ) ) * 0.12245;",
56 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 3.0 * vv ) ) * 0.0918;",
57 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 4.0 * vv ) ) * 0.051;",
58 |
59 | "gl_FragColor = sum;",
60 |
61 | "}"
62 |
63 | ].join( "\n" )
64 |
65 | };
66 |
--------------------------------------------------------------------------------
/js/lib/shaders/VignetteShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | *
4 | * Vignette shader
5 | * based on PaintEffect postprocess from ro.me
6 | * http://code.google.com/p/3-dreams-of-black/source/browse/deploy/js/effects/PaintEffect.js
7 | */
8 |
9 | THREE.VignetteShader = {
10 |
11 | uniforms: {
12 |
13 | "tDiffuse": { type: "t", value: null },
14 | "offset": { type: "f", value: 1.0 },
15 | "darkness": { type: "f", value: 1.0 }
16 |
17 | },
18 |
19 | vertexShader: [
20 |
21 | "varying vec2 vUv;",
22 |
23 | "void main() {",
24 |
25 | "vUv = uv;",
26 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
27 |
28 | "}"
29 |
30 | ].join( "\n" ),
31 |
32 | fragmentShader: [
33 |
34 | "uniform float offset;",
35 | "uniform float darkness;",
36 |
37 | "uniform sampler2D tDiffuse;",
38 |
39 | "varying vec2 vUv;",
40 |
41 | "void main() {",
42 |
43 | // Eskil's vignette
44 |
45 | "vec4 texel = texture2D( tDiffuse, vUv );",
46 | "vec2 uv = ( vUv - vec2( 0.5 ) ) * vec2( offset );",
47 | "gl_FragColor = vec4( mix( texel.rgb, vec3( 1.0 - darkness ), dot( uv, uv ) ), texel.a );",
48 |
49 | /*
50 | // alternative version from glfx.js
51 | // this one makes more "dusty" look (as opposed to "burned")
52 |
53 | "vec4 color = texture2D( tDiffuse, vUv );",
54 | "float dist = distance( vUv, vec2( 0.5 ) );",
55 | "color.rgb *= smoothstep( 0.8, offset * 0.799, dist *( darkness + offset ) );",
56 | "gl_FragColor = color;",
57 | */
58 |
59 | "}"
60 |
61 | ].join( "\n" )
62 |
63 | };
64 |
--------------------------------------------------------------------------------
/js/lib/stats.min.js:
--------------------------------------------------------------------------------
1 | // stats.js - http://github.com/mrdoob/stats.js
2 | var Stats=function(){function f(a,e,b){a=document.createElement(a);a.id=e;a.style.cssText=b;return a}function l(a,e,b){var c=f("div",a,"padding:0 0 3px 3px;text-align:left;background:"+b),d=f("div",a+"Text","font-family:Helvetica,Arial,sans-serif;font-size:9px;font-weight:bold;line-height:15px;color:"+e);d.innerHTML=a.toUpperCase();c.appendChild(d);a=f("div",a+"Graph","width:74px;height:30px;background:"+e);c.appendChild(a);for(e=0;74>e;e++)a.appendChild(f("span","","width:1px;height:30px;float:left;opacity:0.9;background:"+
3 | b));return c}function m(a){for(var b=c.children,d=0;dr+1E3&&(d=Math.round(1E3*
5 | t/(a-r)),u=Math.min(u,d),v=Math.max(v,d),A.textContent=d+" FPS ("+u+"-"+v+")",p(B,d/100),r=a,t=0,void 0!==h)){var b=performance.memory.usedJSHeapSize,c=performance.memory.jsHeapSizeLimit;h=Math.round(9.54E-7*b);y=Math.min(y,h);z=Math.max(z,h);E.textContent=h+" MB ("+y+"-"+z+")";p(F,b/c)}return a},update:function(){k=this.end()}}};"object"===typeof module&&(module.exports=Stats);
--------------------------------------------------------------------------------
/js/viz/BG.js:
--------------------------------------------------------------------------------
1 | var BG = function () {
2 |
3 | var groupHolder;
4 | var material;
5 | var planeMaterial
6 | var spd = 0;
7 |
8 | var shapes = [];
9 |
10 | var cubeMesh, cubeShader, skyBox
11 |
12 | function init() {
13 |
14 | //console.log("BG")
15 |
16 | //init event listeners
17 |
18 |
19 | groupHolder = new THREE.Object3D();
20 | VizHandler.getVizHolder().add(groupHolder);
21 |
22 | var cubeMapId = 23//4//28//23//20//16//7;//9
23 | //4,,23,16,9,,28,20
24 | cubeMap = Assets.getMainCubeMap();
25 |
26 | /*cubeShader = THREE.ShaderLib['cube'];
27 | cubeShader.uniforms['tCube'].value = cubeMap;
28 |
29 | var skyBoxMaterial = new THREE.ShaderMaterial({
30 | fragmentShader: cubeShader.fragmentShader,
31 | vertexShader: cubeShader.vertexShader,
32 | uniforms: cubeShader.uniforms,
33 | depthWrite: false,
34 | side: THREE.DoubleSide
35 | });*/
36 |
37 |
38 | var materialArray = [];
39 | for (var i = 0; i < 6; i++)
40 | materialArray.push(new THREE.MeshBasicMaterial({
41 | map: cubeMap.image[ i ],
42 | side: THREE.BackSide, fog: false
43 | }));
44 |
45 | var skyMaterial = new THREE.MeshFaceMaterial(materialArray);
46 | skyBox = new THREE.Mesh(
47 | new THREE.CubeGeometry(1500, 1500, 1500),
48 | skyMaterial
49 | );
50 | skyBox.noOBJ = true;
51 |
52 | /*skyBox = new THREE.Mesh(
53 | new THREE.SphereGeometry(1500),
54 | new THREE.MeshBasicMaterial({
55 | map: new THREE.TextureLoader().load("textures/sky2_09.jpg"),
56 | side: THREE.BackSide, fog: false, depthWrite:false
57 | })
58 | );*/
59 |
60 | if (ControlsHandler.fxParams.smoothBg) {
61 | var geometry = new THREE.OctahedronGeometry(1500, 1)
62 |
63 | for (var i = 0; i < geometry.faces.length; i++) {
64 |
65 | var face = geometry.faces[ i ];
66 | var temp = face.a;
67 | face.a = face.c;
68 | face.c = temp;
69 |
70 | }
71 |
72 | geometry.computeFaceNormals();
73 | geometry.computeVertexNormals();
74 |
75 | var faceVertexUvs = geometry.faceVertexUvs[ 0 ];
76 | for (var i = 0; i < faceVertexUvs.length; i++) {
77 |
78 | var temp = faceVertexUvs[ i ][ 0 ];
79 | faceVertexUvs[ i ][ 0 ] = faceVertexUvs[ i ][ 2 ];
80 | faceVertexUvs[ i ][ 2 ] = temp;
81 |
82 | }
83 |
84 | var material = new THREE.MeshStandardMaterial({
85 | roughness: 0,
86 | metalness: 0.5,
87 | side: THREE.DoubleSide,
88 | depthWrite: false,
89 | fog: false,
90 | emissive: 0x666666,
91 | color: 0xFFFFFF * Math.random(),
92 | side: THREE.DoubleSide
93 | })
94 |
95 | skyBox = new THREE.Mesh(
96 | geometry,
97 | //skyBoxMaterial
98 | material
99 | );
100 | skyBox.scale.y = -1;
101 | }
102 |
103 | groupHolder.add(skyBox);
104 | }
105 |
106 | function updateSkyboxTextures() {
107 | if (!skyBox.material.materials)
108 | return;
109 | var materialArray = [];
110 | for (var i = 0; i < 6; i++) {
111 | skyBox.material.materials[i].map = new THREE.Texture(cubeMap.image[ i ])
112 | skyBox.material.materials[i].map.needsUpdate = true;
113 | }
114 | }
115 |
116 | function setEnvMap(cubeMap) {
117 | if (cubeShader)
118 | cubeShader.uniforms['tCube'].value = cubeMap;
119 | }
120 | function setColor(color) {
121 | return;
122 | if (skyBox.material.color)
123 | skyBox.material.color.setHex(color)
124 | }
125 |
126 | function changeVisibility() {
127 | groupHolder.visible = ControlsHandler.fxParams.bg;
128 | }
129 |
130 | function generate() {
131 | skyBox.rotation.y = Math.randomX() * Math.PI * 2;
132 |
133 | /*if (skyBox.material.color) {
134 | var palette = Generator.getPalette()
135 | var color = palette[Math.floor(Math.randomX() * palette.length)]
136 | skyBox.material.color.setRGB(color[0] / 255, color[1] / 255, color[2] / 255)
137 | }*/
138 | }
139 |
140 | return {
141 | init: init,
142 | setEnvMap: setEnvMap,
143 | setColor: setColor,
144 | changeVisibility: changeVisibility,
145 | generate: generate,
146 | updateSkyboxTextures: updateSkyboxTextures
147 | };
148 |
149 | }();
--------------------------------------------------------------------------------
/js/viz/LightPanels.js:
--------------------------------------------------------------------------------
1 | var LightPanels = function () {
2 |
3 | var groupHolder;
4 | var material;
5 |
6 | var drewNewShape = false;
7 |
8 | var scl = 0;
9 | var dae;
10 | var spd = 0;
11 | var mod = 0;
12 | var objects = [];
13 |
14 | function init() {
15 |
16 | //init event listeners
17 | events.on("update", update);
18 | events.on("onBeat", onBeat);
19 |
20 |
21 | var radius = 1000;
22 | groupHolder = new THREE.Object3D();
23 | VizHandler.getVizHolder().add(groupHolder);
24 |
25 |
26 | //material = new THREE.MeshBasicMaterial( { envMap: VizHandler.getCubeCameras()[1].renderTarget,reflectivity:.5, blending: THREE.AdditiveBlending,shading: THREE.FlatShading } );//,shading: THREE.FlatShading
27 | material = new THREE.MeshBasicMaterial({
28 | envMap: Assets.textureCube(),
29 | reflectivity: 1,
30 | blending: THREE.AdditiveBlending,
31 | shading: THREE.FlatShading
32 | });//,shading: THREE.FlatShading
33 |
34 | reload()
35 | }
36 |
37 | function reload() {
38 |
39 | var imgTexture = new THREE.TextureLoader().load("textures/white.jpg");
40 | imgTexture.wrapS = imgTexture.wrapT = THREE.RepeatWrapping;
41 | //imgTexture = null;
42 |
43 | var shininess = 50, specular = 0xffffff, bumpScale = 1, shading = THREE.SmoothShading;
44 |
45 | var reflectionCube = Assets.getCubeMap(10)
46 | reflectionCube.format = THREE.RGBFormat;
47 |
48 | var cubeWidth = 15000;
49 | var numberOfSphersPerSide = 40;
50 | var sphereRadius = (cubeWidth / numberOfSphersPerSide) * 0.8 * 0.5;
51 | var stepSize = 1.0 / numberOfSphersPerSide;
52 |
53 | //var geometry = new THREE.SphereBufferGeometry(sphereRadius, 3, 2);
54 | //var geometry = new THREE.TetrahedronGeometry(500)
55 | var geometry = new THREE.BoxGeometry(sphereRadius, sphereRadius, sphereRadius, 1, 1, 1);
56 |
57 | var roughness = .5;
58 | var diffuseColor = new THREE.Color(.1, .1, .1);
59 | var metalness = 1;
60 | var material = new THREE.MeshStandardMaterial({
61 | //map: imgTexture,
62 | bumpMap: imgTexture,
63 | bumpScale: bumpScale,
64 | color: diffuseColor,
65 | metalness: metalness,
66 | roughness: roughness,
67 | shading: THREE.SmoothShading,
68 | envMap: reflectionCube,
69 | blending: THREE.AdditiveBlending,
70 | shading: THREE.FlatShading,
71 | transparent: true
72 | })
73 |
74 | for (var alpha = 0, alphaIndex = 0; alpha <= 1.0; alpha += stepSize, alphaIndex++) {
75 | for (var gamma = 0; gamma <= 1.0; gamma += stepSize) {
76 |
77 | // basic monochromatic energy preservation
78 | var mesh = new THREE.Mesh(geometry, material);
79 |
80 | mesh.scale.y = 1 + Math.random() * 3 * 2
81 | mesh.scale.x = mesh.scale.z = 1 + Math.random() * 1
82 |
83 | mesh.position.x = alpha * cubeWidth - cubeWidth / 2 - stepSize * cubeWidth * Math.random();
84 | mesh.position.y = 0//-800 + sphereRadius// * mesh.scale.y / 2
85 | mesh.position.z = gamma * cubeWidth - cubeWidth / 2 - 4000 + Math.random() * 2000;
86 | //mesh.rotation.x = Math.random() * 3;
87 | //mesh.rotation.y = Math.random() * 3;
88 |
89 | objects.push(mesh);
90 |
91 | groupHolder.add(mesh);
92 | }
93 | }
94 | }
95 |
96 | function update() {
97 | for (var i = 0; i < objects.length; i++) {
98 | var o = objects[i]
99 |
100 | o.position.z += 10
101 | if (o.position.z > 1000) {
102 | o.position.z -= 15000;
103 | }
104 | }
105 | }
106 |
107 | function onBeat() {
108 | }
109 |
110 | return {
111 | init: init,
112 | update: update,
113 | onBeat: onBeat,
114 | };
115 |
116 | }();
--------------------------------------------------------------------------------
/js/viz/Mountain.js:
--------------------------------------------------------------------------------
1 | var Mountain = function () {
2 |
3 | var groupHolder;
4 | var material;
5 |
6 | var drewNewShape = false;
7 |
8 | var scl = 0;
9 | var dae;
10 | var spd = 0;
11 | var mod = 0;
12 | var objects = [];
13 |
14 | function init() {
15 |
16 | //init event listeners
17 | events.on("update", update);
18 | events.on("onBeat", onBeat);
19 |
20 |
21 | var radius = 1000;
22 | groupHolder = new THREE.Object3D();
23 | VizHandler.getVizHolder().add(groupHolder);
24 |
25 |
26 | //material = new THREE.MeshBasicMaterial( { envMap: VizHandler.getCubeCameras()[1].renderTarget,reflectivity:.5, blending: THREE.AdditiveBlending,shading: THREE.FlatShading } );//,shading: THREE.FlatShading
27 | material = new THREE.MeshBasicMaterial({
28 | envMap: Assets.textureCube(),
29 | reflectivity: 1,
30 | blending: THREE.AdditiveBlending,
31 | shading: THREE.FlatShading
32 | });//,shading: THREE.FlatShading
33 |
34 | reload()
35 | }
36 |
37 | function reload() {
38 |
39 | var imgTexture = new THREE.TextureLoader().load("textures/white.jpg");
40 | imgTexture.wrapS = imgTexture.wrapT = THREE.RepeatWrapping;
41 | //imgTexture = null;
42 |
43 | var shininess = 50, specular = 0xffffff, bumpScale = 1, shading = THREE.SmoothShading;
44 |
45 | var reflectionCube = Assets.getCubeMap(2)
46 | reflectionCube.format = THREE.RGBFormat;
47 |
48 | var cubeWidth = 15000;
49 |
50 | //var geometry = new THREE.SphereBufferGeometry(sphereRadius, 3, 2);
51 | var geometry = new THREE.CylinderGeometry(0,500,1000,3)
52 | //var geometry = new THREE.BoxGeometry(sphereRadius, sphereRadius, sphereRadius, 1, 1, 1);
53 |
54 | var roughness = .9;
55 | var diffuseColor = new THREE.Color(.9,.9,.9);
56 | var metalness = 1;
57 | var material = new THREE.MeshStandardMaterial({
58 | map: imgTexture,
59 | bumpMap: imgTexture,
60 | bumpScale: bumpScale,
61 | color: diffuseColor,
62 | metalness: metalness,
63 | roughness: roughness,
64 | shading: THREE.SmoothShading,
65 | envMap: reflectionCube,
66 | //shading: THREE.FlatShading
67 | })
68 |
69 | // basic monochromatic energy preservation
70 | var mesh = new THREE.Mesh(geometry, material);
71 |
72 | objects.push(mesh);
73 |
74 | groupHolder.add(mesh);
75 | }
76 |
77 | function update() {
78 | for (var i = 0; i < objects.length; i++) {
79 | var o = objects[i]
80 | o.rotation.y += .01
81 | }
82 | }
83 |
84 | function onBeat() {
85 | }
86 |
87 | return {
88 | init: init,
89 | update: update,
90 | onBeat: onBeat,
91 | };
92 |
93 | }();
--------------------------------------------------------------------------------
/js/viz/Ocean.js:
--------------------------------------------------------------------------------
1 | var Ocean = function () {
2 | var groupHolder;
3 |
4 |
5 | var parameters = {
6 | width: 2000,
7 | height: 2000,
8 | widthSegments: 250,
9 | heightSegments: 250,
10 | depth: 1500,
11 | param: 4,
12 | filterparam: 1
13 | };
14 |
15 | function init() {
16 |
17 | //init event listeners
18 | events.on("postupdate", update);
19 | events.on("onBeat", onBeat);
20 |
21 | groupHolder = new THREE.Object3D();
22 | groupHolder.visible = true;
23 | VizHandler.getVizHolder().add(groupHolder);
24 |
25 | build()
26 |
27 | changeVisibility()
28 | }
29 |
30 | function build() {
31 |
32 | waterNormals = new THREE.TextureLoader().load('textures/waternormals.jpg');
33 | waterNormals.wrapS = waterNormals.wrapT = THREE.RepeatWrapping;
34 | waterNormals.repeat.set(100, 100);
35 |
36 | water = new THREE.Water(VizHandler.getRenderer(), VizHandler.getCamera(), VizHandler.getScene(), {
37 | textureWidth: 512,
38 | textureHeight: 512,
39 | waterNormals: waterNormals,
40 | alpha: 1,//.7, //1, //.7, //1,//.71,
41 | sunDirection: VizHandler.getLight().position.clone().normalize(),
42 | sunColor: 0xffffff,
43 | waterColor: 0x7194c3,//0x333333,//0x7194c3,
44 | distortionScale: .3,//0,//50.0 / 20,
45 | side: THREE.DoubleSide,
46 | fog: true
47 | });
48 |
49 |
50 | mirrorMesh = new THREE.Mesh(
51 | //new THREE.CircleGeometry(parameters.width * .5),
52 | new THREE.PlaneBufferGeometry(parameters.width * 1, parameters.height * 1),
53 | water.material
54 | //new THREE.MeshPhongMaterial({map:waterNormals})
55 | );
56 |
57 | mirrorMesh.add(water);
58 | mirrorMesh.rotation.x = -Math.PI * 0.5;
59 | mirrorMesh.position.y = -20;
60 | //mirrorMesh.visible = ControlsHandler.fxParams.ocean;
61 | //mirrorMesh.scale.set(.015, .015, .015)
62 | //mirrorMesh.receiveShadow=true;
63 | groupHolder.add(mirrorMesh);
64 | }
65 |
66 | function onBeat() {
67 | }
68 |
69 | function changeVisibility() {
70 | groupHolder.visible = ControlsHandler.fxParams.ocean;
71 | }
72 |
73 | function hide() {
74 | groupHolder.visible = false;
75 | }
76 |
77 | function update() {
78 | if (mirrorMesh.visible) {
79 | water.material.uniforms.time.value += 1.0 / 60.0 / 5;
80 | water.render();
81 | }
82 | }
83 | function postupdate() {
84 | //mirrorMesh.visible = ControlsHandler.fxParams.ocean;
85 | }
86 |
87 | return {
88 | init: init,
89 | update: update,
90 | onBeat: onBeat,
91 | hide: hide,
92 | changeVisibility: changeVisibility
93 | }
94 |
95 | }
96 | ();
--------------------------------------------------------------------------------
/js/viz/Rocks.js:
--------------------------------------------------------------------------------
1 | var Rocks = function () {
2 |
3 | var groupHolder;
4 | var material;
5 |
6 | var drewNewShape = false;
7 |
8 | var scl = 0;
9 | var dae;
10 | var spd = 0;
11 | var mod = 0;
12 | var objects = [];
13 |
14 | function init() {
15 |
16 | //init event listeners
17 | events.on("update", update);
18 | events.on("onBeat", onBeat);
19 |
20 |
21 | var radius = 1000;
22 | groupHolder = new THREE.Object3D();
23 | VizHandler.getVizHolder().add(groupHolder);
24 |
25 |
26 | //material = new THREE.MeshBasicMaterial( { envMap: VizHandler.getCubeCameras()[1].renderTarget,reflectivity:.5, blending: THREE.AdditiveBlending,shading: THREE.FlatShading } );//,shading: THREE.FlatShading
27 | material = new THREE.MeshBasicMaterial({
28 | envMap: Assets.textureCube(),
29 | reflectivity: 1,
30 | blending: THREE.AdditiveBlending,
31 | shading: THREE.FlatShading
32 | });//,shading: THREE.FlatShading
33 |
34 | reload()
35 | }
36 |
37 | function reload() {
38 |
39 | var imgTexture = new THREE.TextureLoader().load("textures/white.jpg");
40 | imgTexture.wrapS = imgTexture.wrapT = THREE.RepeatWrapping;
41 | //imgTexture = null;
42 |
43 | var shininess = 50, specular = 0xffffff, bumpScale = 1, shading = THREE.SmoothShading;
44 |
45 | var reflectionCube = Assets.getCubeMap(8)
46 | reflectionCube.format = THREE.RGBFormat;
47 |
48 | var cubeWidth = 15000;
49 | var numberOfSphersPerSide = 10;
50 | var sphereRadius = (cubeWidth / numberOfSphersPerSide) * 0.8 * 0.5;
51 | var stepSize = 1.0 / numberOfSphersPerSide;
52 |
53 | //var geometry = new THREE.SphereBufferGeometry(sphereRadius, 3, 2);
54 | var geometry = new THREE.TetrahedronGeometry(500)
55 | //var geometry = new THREE.BoxGeometry(sphereRadius, sphereRadius, sphereRadius, 1, 1, 1);
56 |
57 | var roughness = .5;
58 | var diffuseColor = new THREE.Color(1, 1, 1);
59 | var metalness = 1;
60 | var material = new THREE.MeshStandardMaterial({
61 | //map: imgTexture,
62 | bumpMap: imgTexture,
63 | bumpScale: bumpScale,
64 | color: diffuseColor,
65 | metalness: metalness,
66 | roughness: roughness,
67 | shading: THREE.SmoothShading,
68 | envMap: reflectionCube,
69 | shading: THREE.FlatShading
70 | })
71 |
72 | for (var alpha = 0, alphaIndex = 0; alpha <= 1.0; alpha += stepSize, alphaIndex++) {
73 |
74 | for (var beta = 0; beta <= 1.0; beta += stepSize) {
75 | for (var gamma = 0; gamma <= 1.0; gamma += stepSize) {
76 |
77 | // basic monochromatic energy preservation
78 | var mesh = new THREE.Mesh(geometry, material);
79 |
80 | mesh.position.x = alpha * cubeWidth - cubeWidth / 2 - stepSize * cubeWidth;
81 | mesh.position.y = beta * cubeWidth - cubeWidth / 2 - stepSize * cubeWidth;
82 | mesh.position.z = gamma * cubeWidth - cubeWidth / 2 - 4000 + Math.random() * 2000;
83 | mesh.rotation.x = Math.random() * 3;
84 | mesh.rotation.y = Math.random() * 3;
85 |
86 | objects.push(mesh);
87 |
88 | groupHolder.add(mesh);
89 | }
90 | }
91 | }
92 | }
93 |
94 | function update() {
95 | for (var i = 0; i < objects.length; i++) {
96 | var o = objects[i]
97 | o.rotation.x += .01
98 | o.rotation.y += .01
99 |
100 | o.position.z += 10
101 | if (o.position.z > 0) {
102 | o.position.z -= 10000;
103 | }
104 | }
105 | }
106 |
107 | function onBeat() {
108 | }
109 |
110 | return {
111 | init: init,
112 | update: update,
113 | onBeat: onBeat,
114 | };
115 |
116 | }();
--------------------------------------------------------------------------------
/js/viz/Tools.js:
--------------------------------------------------------------------------------
1 | var Tools = function () {
2 |
3 | var renderer;
4 | var scene;
5 | var camera;
6 | var composer
7 |
8 | var preSize = {width: 0, height: 0}
9 | var savingName;
10 |
11 | var musicEnabled = true;
12 |
13 | function init() {
14 | renderer = VizHandler.getRenderer();
15 | scene = VizHandler.getScene();
16 | camera = VizHandler.getCamera();
17 |
18 | document.getElementById('fullscreen').addEventListener('click', fullscreen, false);
19 | document.getElementById('about').addEventListener('click', about, false);
20 | document.getElementById('overlay').addEventListener('click', aboutClose, false);
21 | document.getElementById('overlayVR').addEventListener('click', aboutVRClose, false);
22 | if (WEBVR.isAvailable() === true) {
23 | document.getElementById('vr').addEventListener('click', FXHandler.enableVR, false);
24 | } else {
25 | document.getElementById('vr').addEventListener('click', vrinfo, false);
26 | }
27 | }
28 | function about() {
29 | $('#overlay').fadeIn()
30 | $('#overlay .popup').css('margin-top', -$('#overlay .popup').height() / 2 + 10 + 'px');
31 | }
32 |
33 | function aboutClose(e) {
34 | if (e.toElement.className == "overlay" || e.toElement.className == "fa fa-times fa-2x")
35 | $('#overlay').fadeOut()
36 | }
37 |
38 | function vrinfo() {
39 | $('#overlayVR').fadeIn()
40 | $('#overlayVR .popup').css('margin-top', -$('#overlayVR .popup').height() / 2 + 'px');
41 |
42 | }
43 |
44 | function aboutVRClose(e) {
45 | if (e.toElement.className == "overlay" || e.toElement.className == "fa fa-times fa-2x")
46 | $('#overlayVR').fadeOut()
47 | }
48 |
49 | function fullscreen() {
50 | var elem = document.body;
51 | //elem.webkitRequestFullScreen()
52 | if ((document.fullScreenElement !== undefined && document.fullScreenElement === null) || (document.msFullscreenElement !== undefined && document.msFullscreenElement === null) || (document.mozFullScreen !== undefined && !document.mozFullScreen) || (document.webkitIsFullScreen !== undefined && !document.webkitIsFullScreen)) {
53 | if (elem.requestFullScreen) {
54 | elem.requestFullScreen();
55 | } else if (elem.mozRequestFullScreen) {
56 | elem.mozRequestFullScreen();
57 | } else if (elem.webkitRequestFullScreen) {
58 | elem.webkitRequestFullScreen();
59 | } else if (elem.msRequestFullscreen) {
60 | elem.msRequestFullscreen();
61 | }
62 | } else {
63 | if (document.cancelFullScreen) {
64 | document.cancelFullScreen();
65 | } else if (document.mozCancelFullScreen) {
66 | document.mozCancelFullScreen();
67 | } else if (document.webkitCancelFullScreen) {
68 | document.webkitCancelFullScreen();
69 | } else if (document.msExitFullscreen) {
70 | document.msExitFullscreen();
71 | }
72 | }
73 | }
74 |
75 | return {
76 | init: init,
77 | fullscreen: fullscreen,
78 | musicEnabled: function () {
79 | return musicEnabled
80 | },
81 | };
82 |
83 | }();
--------------------------------------------------------------------------------
/nbproject/private/private.properties:
--------------------------------------------------------------------------------
1 | browser=Chrome.INTEGRATED
2 | external.project.url=http://localhost/mass_migrations/
3 | server=EXTERNAL
4 |
--------------------------------------------------------------------------------
/nbproject/private/private.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/nbproject/project.properties:
--------------------------------------------------------------------------------
1 | auxiliary.org-netbeans-modules-javascript-nodejs.enabled=false
2 | auxiliary.org-netbeans-modules-javascript-nodejs.node_2e_default=true
3 | auxiliary.org-netbeans-modules-javascript-nodejs.run_2e_enabled=false
4 | auxiliary.org-netbeans-modules-javascript-nodejs.sync_2e_enabled=true
5 | browser.autorefresh.Chrome=true
6 | browser.autorefresh.Chrome.INTEGRATED=true
7 | browser.autorefresh.SL[/Browsers/webviewBrowser=true
8 | browser.highlightselection.Chrome=true
9 | browser.highlightselection.Chrome.INTEGRATED=true
10 | browser.highlightselection.SL[/Browsers/webviewBrowser=true
11 | browser.run=true
12 | file.reference.kinect-christmas_party_2014_vj_nokinect=.
13 | file.reference.maratropa-new=.
14 | file.reference.vj-system=.
15 | file.reference.VR-mass_migrations=.
16 | file.reference.Workspace-mass_migrations=.
17 | files.encoding=UTF-8
18 | site.root.folder=${file.reference.Workspace-mass_migrations}
19 | start.file=
20 | web.context.root=/http://localhost/mass_migrations/
21 |
--------------------------------------------------------------------------------
/nbproject/project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.netbeans.modules.web.clientproject
4 |
5 |
6 | mass_migrations_github
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/textures/Above_The_Sea.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marpi/mass_migrations/7d799d60629077199459c9fd484893cce7d6f64d/textures/Above_The_Sea.jpg
--------------------------------------------------------------------------------
/textures/cover.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marpi/mass_migrations/7d799d60629077199459c9fd484893cce7d6f64d/textures/cover.jpg
--------------------------------------------------------------------------------
/textures/logo.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------