├── js
└── threejs
│ ├── .gitignore
│ ├── examples
│ └── js
│ │ ├── loaders
│ │ ├── ctm
│ │ │ ├── CTMWorker.js
│ │ │ └── license
│ │ │ │ ├── OpenCTM.txt
│ │ │ │ ├── js-lzma.txt
│ │ │ │ └── js-openctm.txt
│ │ ├── VTKLoader.js
│ │ ├── PLYLoader.js
│ │ └── ObjectLoader.js
│ │ ├── PRNG.js
│ │ ├── shaders
│ │ ├── BasicShader.js
│ │ ├── CopyShader.js
│ │ ├── LuminosityShader.js
│ │ ├── ColorifyShader.js
│ │ ├── ColorCorrectionShader.js
│ │ ├── BlendShader.js
│ │ ├── SepiaShader.js
│ │ ├── UnpackDepthRGBAShader.js
│ │ ├── MirrorShader.js
│ │ ├── DOFMipMapShader.js
│ │ ├── NormalMapShader.js
│ │ ├── RGBShiftShader.js
│ │ ├── KaleidoShader.js
│ │ ├── BrightnessContrastShader.js
│ │ ├── VignetteShader.js
│ │ ├── BleachBypassShader.js
│ │ ├── DotScreenShader.js
│ │ ├── HueSaturationShader.js
│ │ ├── VerticalBlurShader.js
│ │ ├── HorizontalBlurShader.js
│ │ ├── TriangleBlurShader.js
│ │ ├── EdgeShader2.js
│ │ ├── VerticalTiltShiftShader.js
│ │ ├── HorizontalTiltShiftShader.js
│ │ ├── FresnelShader.js
│ │ ├── ConvolutionShader.js
│ │ ├── FocusShader.js
│ │ ├── FilmShader.js
│ │ ├── FXAAShader.js
│ │ ├── EdgeShader.js
│ │ └── BokehShader.js
│ │ ├── postprocessing
│ │ ├── TexturePass.js
│ │ ├── ShaderPass.js
│ │ ├── RenderPass.js
│ │ ├── SavePass.js
│ │ ├── DotScreenPass.js
│ │ ├── FilmPass.js
│ │ ├── MaskPass.js
│ │ ├── EffectComposer.js
│ │ └── BloomPass.js
│ │ ├── math
│ │ ├── ColorConverter.js
│ │ └── TypeArrayVector3.js
│ │ ├── libs
│ │ ├── system.min.js
│ │ ├── stats.min.js
│ │ └── tween.min.js
│ │ ├── modifiers
│ │ └── ExplodeModifier.js
│ │ ├── effects
│ │ ├── CrosseyedEffect.js
│ │ ├── ParallaxBarrierEffect.js
│ │ ├── AnaglyphEffect.js
│ │ ├── OculusRiftEffect.js
│ │ └── AsciiEffect.js
│ │ ├── Detector.js
│ │ ├── exporters
│ │ ├── MaterialExporter.js
│ │ ├── OBJExporter.js
│ │ └── GeometryExporter.js
│ │ ├── ImprovedNoise.js
│ │ ├── controls
│ │ ├── PointerLockControls.js
│ │ ├── EditorControls.js
│ │ └── FirstPersonControls.js
│ │ ├── AudioObject.js
│ │ ├── UVsUtils.js
│ │ ├── MD2Character.js
│ │ ├── renderers
│ │ └── CSS3DRenderer.js
│ │ ├── Cloth.js
│ │ ├── ParametricGeometries.js
│ │ └── CurveExtras.js
│ └── LICENSE
├── README.md
├── demo
└── path.json
└── index.html
/js/threejs/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | *.swp
3 | .project
4 | utils/npm/node_modules/*
--------------------------------------------------------------------------------
/js/threejs/examples/js/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/threejs/examples/js/PRNG.js:
--------------------------------------------------------------------------------
1 | // Park-Miller-Carta Pseudo-Random Number Generator
2 | // https://github.com/pnitsch/BitmapData.js/blob/master/js/BitmapData.js
3 |
4 | var PRNG = function () {
5 |
6 | this.seed = 1;
7 | this.next = function() { return (this.gen() / 2147483647); };
8 | this.nextRange = function(min, max) { return min + ((max - min) * this.next()) };
9 | this.gen = function() { return this.seed = (this.seed * 16807) % 2147483647; };
10 |
11 | };
12 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | three.js-camera-path-tool
2 | =========================
3 |
4 | Crude tool for building camera paths for three.js scenes.
5 |
6 |
7 | KEY CONTROLS
8 | ------------
9 |
10 | = Add Path
11 |
12 | \- Remove Path
13 |
14 | Click and drag to rotate camera
15 | Use Mouse Wheel to Zoom In/Out
16 |
17 | Click Nodes to Move
18 |
19 | Click off Node to Deselect
20 |
21 | UP/DOWN/LEFT/RIGHT Translate Node on Y or X Axis
22 |
23 | OPTION + UP/DOWN Translate Node on Z Axis
24 |
25 | W/A/S/D Rotate Node
26 |
27 | SHIFT Moves Faster
28 |
--------------------------------------------------------------------------------
/js/threejs/examples/js/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 |
--------------------------------------------------------------------------------
/demo/path.json:
--------------------------------------------------------------------------------
1 | {"vertices": [
2 | {"x": -37, "y": 80, "z": 370},
3 | {"x": 76, "y": 41, "z": 274},
4 | {"x": 195, "y": 35, "z": 164},
5 | {"x": 97, "y": 41, "z": 156},
6 | {"x": -3, "y": 55, "z": 245},
7 | {"x": -218, "y": 37, "z": 176},
8 | {"x": -228, "y": 33, "z": 58},
9 | {"x": 3, "y": 12, "z": -29},
10 | {"x": 81, "y": 46, "z": -220},
11 | {"x": 272, "y": 30, "z": -347},
12 | {"x": 349, "y": 33, "z": -270},
13 | {"x": 251, "y": 38, "z": -209},
14 | {"x": 76, "y": 31, "z": -274},
15 | {"x": -127, "y": 48, "z": -355},
16 | {"x": -320, "y": 100, "z": -359},
17 | {"x": -373, "y": 84, "z": -398}
18 | ]
19 | }
--------------------------------------------------------------------------------
/js/threejs/examples/js/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/threejs/examples/js/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/threejs/examples/js/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/threejs/examples/js/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/threejs/examples/js/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 |
15 | },
16 |
17 | vertexShader: [
18 |
19 | "varying vec2 vUv;",
20 |
21 | "void main() {",
22 |
23 | "vUv = uv;",
24 |
25 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
26 |
27 | "}"
28 |
29 | ].join("\n"),
30 |
31 | fragmentShader: [
32 |
33 | "uniform sampler2D tDiffuse;",
34 | "uniform vec3 powRGB;",
35 | "uniform vec3 mulRGB;",
36 |
37 | "varying vec2 vUv;",
38 |
39 | "void main() {",
40 |
41 | "gl_FragColor = texture2D( tDiffuse, vUv );",
42 | "gl_FragColor.rgb = mulRGB * pow( gl_FragColor.rgb, powRGB );",
43 |
44 | "}"
45 |
46 | ].join("\n")
47 |
48 | };
49 |
--------------------------------------------------------------------------------
/js/threejs/examples/js/postprocessing/TexturePass.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | */
4 |
5 | THREE.TexturePass = function ( texture, opacity ) {
6 |
7 | if ( THREE.CopyShader === undefined )
8 | console.error( "THREE.TexturePass relies on THREE.CopyShader" );
9 |
10 | var shader = THREE.CopyShader;
11 |
12 | this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
13 |
14 | this.uniforms[ "opacity" ].value = ( opacity !== undefined ) ? opacity : 1.0;
15 | this.uniforms[ "tDiffuse" ].value = texture;
16 |
17 | this.material = new THREE.ShaderMaterial( {
18 |
19 | uniforms: this.uniforms,
20 | vertexShader: shader.vertexShader,
21 | fragmentShader: shader.fragmentShader
22 |
23 | } );
24 |
25 | this.enabled = true;
26 | this.needsSwap = false;
27 |
28 | };
29 |
30 | THREE.TexturePass.prototype = {
31 |
32 | render: function ( renderer, writeBuffer, readBuffer, delta ) {
33 |
34 | THREE.EffectComposer.quad.material = this.material;
35 |
36 | renderer.render( THREE.EffectComposer.scene, THREE.EffectComposer.camera, readBuffer );
37 |
38 | }
39 |
40 | };
41 |
--------------------------------------------------------------------------------
/js/threejs/examples/js/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/threejs/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License
2 |
3 | Copyright (c) 2010-2013 three.js authors
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/js/threejs/examples/js/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/threejs/examples/js/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/threejs/examples/js/postprocessing/ShaderPass.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | */
4 |
5 | THREE.ShaderPass = function ( shader, textureID ) {
6 |
7 | this.textureID = ( textureID !== undefined ) ? textureID : "tDiffuse";
8 |
9 | this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
10 |
11 | this.material = new THREE.ShaderMaterial( {
12 |
13 | uniforms: this.uniforms,
14 | vertexShader: shader.vertexShader,
15 | fragmentShader: shader.fragmentShader
16 |
17 | } );
18 |
19 | this.renderToScreen = false;
20 |
21 | this.enabled = true;
22 | this.needsSwap = true;
23 | this.clear = false;
24 |
25 | };
26 |
27 | THREE.ShaderPass.prototype = {
28 |
29 | render: function ( renderer, writeBuffer, readBuffer, delta ) {
30 |
31 | if ( this.uniforms[ this.textureID ] ) {
32 |
33 | this.uniforms[ this.textureID ].value = readBuffer;
34 |
35 | }
36 |
37 | THREE.EffectComposer.quad.material = this.material;
38 |
39 | if ( this.renderToScreen ) {
40 |
41 | renderer.render( THREE.EffectComposer.scene, THREE.EffectComposer.camera );
42 |
43 | } else {
44 |
45 | renderer.render( THREE.EffectComposer.scene, THREE.EffectComposer.camera, writeBuffer, this.clear );
46 |
47 | }
48 |
49 | }
50 |
51 | };
52 |
--------------------------------------------------------------------------------
/js/threejs/examples/js/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/threejs/examples/js/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 | // RGBA depth
39 |
40 | "float unpackDepth( const in vec4 rgba_depth ) {",
41 |
42 | "const vec4 bit_shift = vec4( 1.0 / ( 256.0 * 256.0 * 256.0 ), 1.0 / ( 256.0 * 256.0 ), 1.0 / 256.0, 1.0 );",
43 | "float depth = dot( rgba_depth, bit_shift );",
44 | "return depth;",
45 |
46 | "}",
47 |
48 | "void main() {",
49 |
50 | "float depth = 1.0 - unpackDepth( texture2D( tDiffuse, vUv ) );",
51 | "gl_FragColor = opacity * vec4( vec3( depth ), 1.0 );",
52 |
53 | "}"
54 |
55 | ].join("\n")
56 |
57 | };
58 |
--------------------------------------------------------------------------------
/js/threejs/examples/js/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/threejs/examples/js/postprocessing/RenderPass.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | */
4 |
5 | THREE.RenderPass = function ( scene, camera, overrideMaterial, clearColor, clearAlpha ) {
6 |
7 | this.scene = scene;
8 | this.camera = camera;
9 |
10 | this.overrideMaterial = overrideMaterial;
11 |
12 | this.clearColor = clearColor;
13 | this.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 1;
14 |
15 | this.oldClearColor = new THREE.Color();
16 | this.oldClearAlpha = 1;
17 |
18 | this.enabled = true;
19 | this.clear = true;
20 | this.needsSwap = false;
21 |
22 | };
23 |
24 | THREE.RenderPass.prototype = {
25 |
26 | render: function ( renderer, writeBuffer, readBuffer, delta ) {
27 |
28 | this.scene.overrideMaterial = this.overrideMaterial;
29 |
30 | if ( this.clearColor ) {
31 |
32 | this.oldClearColor.copy( renderer.getClearColor() );
33 | this.oldClearAlpha = renderer.getClearAlpha();
34 |
35 | renderer.setClearColor( this.clearColor, this.clearAlpha );
36 |
37 | }
38 |
39 | renderer.render( this.scene, this.camera, readBuffer, this.clear );
40 |
41 | if ( this.clearColor ) {
42 |
43 | renderer.setClearColor( this.oldClearColor, this.oldClearAlpha );
44 |
45 | }
46 |
47 | this.scene.overrideMaterial = null;
48 |
49 | }
50 |
51 | };
52 |
--------------------------------------------------------------------------------
/js/threejs/examples/js/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/threejs/examples/js/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/threejs/examples/js/math/ColorConverter.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author bhouston / http://exocortex.com/
3 | * @author zz85 / http://github.com/zz85
4 | */
5 |
6 | THREE.ColorConverter = {
7 |
8 | setHSV: function ( color, h, s, v ) {
9 |
10 | // https://gist.github.com/xpansive/1337890#file-index-js
11 | return color.setHSL( h, ( s * v ) / ( ( h = ( 2 - s ) * v ) < 1 ? h : ( 2 - h ) ), h * 0.5 );
12 |
13 | },
14 |
15 | getHSV: function( color ) {
16 |
17 | var hsl = color.getHSL();
18 |
19 | // based on https://gist.github.com/xpansive/1337890#file-index-js
20 | hsl.s *= ( hsl.l < 0.5 ) ? hsl.l : ( 1 - hsl.l );
21 |
22 | return {
23 | h: hsl.h,
24 | s: 2 * hsl.s / ( hsl.l + hsl.s ),
25 | v: hsl.l + hsl.s
26 | };
27 | },
28 |
29 | // where c, m, y, k is between 0 and 1
30 |
31 | setCMYK: function ( color, c, m, y, k ) {
32 |
33 | var r = ( 1 - c ) * ( 1 - k );
34 | var g = ( 1 - m ) * ( 1 - k );
35 | var b = ( 1 - y ) * ( 1 - k );
36 |
37 | return color.setRGB( r, g, b );
38 |
39 | },
40 |
41 | getCMYK: function ( color ) {
42 |
43 | var r = color.r;
44 | var g = color.g;
45 | var b = color.b;
46 | var k = 1 - Math.max(r, g, b);
47 | var c = ( 1 - r - k ) / ( 1 - k );
48 | var m = ( 1 - g - k ) / ( 1 - k );
49 | var y = ( 1 - b - k ) / ( 1 - k );
50 |
51 | return {
52 | c: c, m: m, y: y, k: k
53 | };
54 |
55 | }
56 |
57 |
58 | };
--------------------------------------------------------------------------------
/js/threejs/examples/js/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/threejs/examples/js/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/threejs/examples/js/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/threejs/examples/js/libs/system.min.js:
--------------------------------------------------------------------------------
1 | // system.js - http://github.com/mrdoob/system.js
2 | 'use strict';var System={browser:function(){var a=navigator.userAgent;return/Arora/i.test(a)?"Arora":/Chrome/i.test(a)?"Chrome":/Epiphany/i.test(a)?"Epiphany":/Firefox/i.test(a)?"Firefox":/Mobile(\/.*)? Safari/i.test(a)?"Mobile Safari":/MSIE/i.test(a)?"Internet Explorer":/Midori/i.test(a)?"Midori":/Opera/.test(a)?"Opera":/Safari/i.test(a)?"Safari":!1}(),os:function(){var a=navigator.userAgent;return/Android/i.test(a)?"Android":/CrOS/i.test(a)?"Chrome OS":/iP[ao]d|iPhone/i.test(a)?"iOS":/Linux/i.test(a)?
3 | "Linux":/Mac OS/i.test(a)?"Mac OS":/windows/i.test(a)?"Windows":!1}(),support:{canvas:!!window.CanvasRenderingContext2D,localStorage:function(){try{return!!window.localStorage.getItem}catch(a){return!1}}(),file:!!window.File&&!!window.FileReader&&!!window.FileList&&!!window.Blob,fileSystem:!!window.requestFileSystem||!!window.webkitRequestFileSystem,getUserMedia:!!window.navigator.getUserMedia||!!window.navigator.webkitGetUserMedia||!!window.navigator.mozGetUserMedia||!!window.navigator.msGetUserMedia,
4 | requestAnimationFrame:!!window.mozRequestAnimationFrame||!!window.webkitRequestAnimationFrame||!!window.oRequestAnimationFrame||!!window.msRequestAnimationFrame,sessionStorage:function(){try{return!!window.sessionStorage.getItem}catch(a){return!1}}(),webgl:function(){try{return!!window.WebGLRenderingContext&&!!document.createElement("canvas").getContext("experimental-webgl")}catch(a){return!1}}(),worker:!!window.Worker}};
5 |
--------------------------------------------------------------------------------
/js/threejs/examples/js/postprocessing/SavePass.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | */
4 |
5 | THREE.SavePass = function ( renderTarget ) {
6 |
7 | if ( THREE.CopyShader === undefined )
8 | console.error( "THREE.SavePass relies on THREE.CopyShader" );
9 |
10 | var shader = THREE.CopyShader;
11 |
12 | this.textureID = "tDiffuse";
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 | this.renderTarget = renderTarget;
25 |
26 | if ( this.renderTarget === undefined ) {
27 |
28 | this.renderTargetParameters = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBFormat, stencilBuffer: false };
29 | this.renderTarget = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, this.renderTargetParameters );
30 |
31 | }
32 |
33 | this.enabled = true;
34 | this.needsSwap = false;
35 | this.clear = false;
36 |
37 | };
38 |
39 | THREE.SavePass.prototype = {
40 |
41 | render: function ( renderer, writeBuffer, readBuffer, delta ) {
42 |
43 | if ( this.uniforms[ this.textureID ] ) {
44 |
45 | this.uniforms[ this.textureID ].value = readBuffer;
46 |
47 | }
48 |
49 | THREE.EffectComposer.quad.material = this.material;
50 |
51 | renderer.render( THREE.EffectComposer.scene, THREE.EffectComposer.camera, this.renderTarget, this.clear );
52 |
53 | }
54 |
55 | };
56 |
--------------------------------------------------------------------------------
/js/threejs/examples/js/postprocessing/DotScreenPass.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | */
4 |
5 | THREE.DotScreenPass = function ( center, angle, scale ) {
6 |
7 | if ( THREE.DotScreenShader === undefined )
8 | console.error( "THREE.DotScreenPass relies on THREE.DotScreenShader" );
9 |
10 | var shader = THREE.DotScreenShader;
11 |
12 | this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
13 |
14 | if ( center !== undefined ) this.uniforms[ "center" ].value.copy( center );
15 | if ( angle !== undefined ) this.uniforms[ "angle"].value = angle;
16 | if ( scale !== undefined ) this.uniforms[ "scale"].value = scale;
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.enabled = true;
27 | this.renderToScreen = false;
28 | this.needsSwap = true;
29 |
30 | };
31 |
32 | THREE.DotScreenPass.prototype = {
33 |
34 | render: function ( renderer, writeBuffer, readBuffer, delta ) {
35 |
36 | this.uniforms[ "tDiffuse" ].value = readBuffer;
37 | this.uniforms[ "tSize" ].value.set( readBuffer.width, readBuffer.height );
38 |
39 | THREE.EffectComposer.quad.material = this.material;
40 |
41 | if ( this.renderToScreen ) {
42 |
43 | renderer.render( THREE.EffectComposer.scene, THREE.EffectComposer.camera );
44 |
45 | } else {
46 |
47 | renderer.render( THREE.EffectComposer.scene, THREE.EffectComposer.camera, writeBuffer, false );
48 |
49 | }
50 |
51 | }
52 |
53 | };
54 |
--------------------------------------------------------------------------------
/js/threejs/examples/js/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/threejs/examples/js/modifiers/ExplodeModifier.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Make all faces use unique vertices
3 | * so that each face can be separated from others
4 | *
5 | * @author alteredq / http://alteredqualia.com/
6 | */
7 |
8 | THREE.ExplodeModifier = function () {
9 |
10 | };
11 |
12 | THREE.ExplodeModifier.prototype.modify = function ( geometry ) {
13 |
14 | var vertices = [];
15 |
16 | for ( var i = 0, il = geometry.faces.length; i < il; i ++ ) {
17 |
18 | var n = vertices.length;
19 |
20 | var face = geometry.faces[ i ];
21 |
22 | if ( face instanceof THREE.Face4 ) {
23 |
24 | var a = face.a;
25 | var b = face.b;
26 | var c = face.c;
27 | var d = face.d;
28 |
29 | var va = geometry.vertices[ a ];
30 | var vb = geometry.vertices[ b ];
31 | var vc = geometry.vertices[ c ];
32 | var vd = geometry.vertices[ d ];
33 |
34 | vertices.push( va.clone() );
35 | vertices.push( vb.clone() );
36 | vertices.push( vc.clone() );
37 | vertices.push( vd.clone() );
38 |
39 | face.a = n;
40 | face.b = n + 1;
41 | face.c = n + 2;
42 | face.d = n + 3;
43 |
44 | } else {
45 |
46 | var a = face.a;
47 | var b = face.b;
48 | var c = face.c;
49 |
50 | var va = geometry.vertices[ a ];
51 | var vb = geometry.vertices[ b ];
52 | var vc = geometry.vertices[ c ];
53 |
54 | vertices.push( va.clone() );
55 | vertices.push( vb.clone() );
56 | vertices.push( vc.clone() );
57 |
58 | face.a = n;
59 | face.b = n + 1;
60 | face.c = n + 2;
61 |
62 | }
63 |
64 | }
65 |
66 | geometry.vertices = vertices;
67 | delete geometry.__tmpVertices;
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/js/threejs/examples/js/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/threejs/examples/js/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/threejs/examples/js/postprocessing/FilmPass.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | */
4 |
5 | THREE.FilmPass = function ( noiseIntensity, scanlinesIntensity, scanlinesCount, grayscale ) {
6 |
7 | if ( THREE.FilmShader === undefined )
8 | console.error( "THREE.FilmPass relies on THREE.FilmShader" );
9 |
10 | var shader = THREE.FilmShader;
11 |
12 | this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
13 |
14 | this.material = new THREE.ShaderMaterial( {
15 |
16 | uniforms: this.uniforms,
17 | vertexShader: shader.vertexShader,
18 | fragmentShader: shader.fragmentShader
19 |
20 | } );
21 |
22 | if ( grayscale !== undefined ) this.uniforms.grayscale.value = grayscale;
23 | if ( noiseIntensity !== undefined ) this.uniforms.nIntensity.value = noiseIntensity;
24 | if ( scanlinesIntensity !== undefined ) this.uniforms.sIntensity.value = scanlinesIntensity;
25 | if ( scanlinesCount !== undefined ) this.uniforms.sCount.value = scanlinesCount;
26 |
27 | this.enabled = true;
28 | this.renderToScreen = false;
29 | this.needsSwap = true;
30 |
31 | };
32 |
33 | THREE.FilmPass.prototype = {
34 |
35 | render: function ( renderer, writeBuffer, readBuffer, delta ) {
36 |
37 | this.uniforms[ "tDiffuse" ].value = readBuffer;
38 | this.uniforms[ "time" ].value += delta;
39 |
40 | THREE.EffectComposer.quad.material = this.material;
41 |
42 | if ( this.renderToScreen ) {
43 |
44 | renderer.render( THREE.EffectComposer.scene, THREE.EffectComposer.camera );
45 |
46 | } else {
47 |
48 | renderer.render( THREE.EffectComposer.scene, THREE.EffectComposer.camera, writeBuffer, false );
49 |
50 | }
51 |
52 | }
53 |
54 | };
55 |
--------------------------------------------------------------------------------
/js/threejs/examples/js/effects/CrosseyedEffect.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | */
4 |
5 | THREE.CrosseyedEffect = function ( renderer ) {
6 |
7 | // API
8 |
9 | this.separation = 10;
10 |
11 | // internals
12 |
13 | var _width, _height;
14 |
15 | var _cameraL = new THREE.PerspectiveCamera();
16 | _cameraL.target = new THREE.Vector3();
17 |
18 | var _cameraR = new THREE.PerspectiveCamera();
19 | _cameraR.target = new THREE.Vector3();
20 |
21 | // initialization
22 |
23 | renderer.autoClear = false;
24 |
25 | this.setSize = function ( width, height ) {
26 |
27 | _width = width / 2;
28 | _height = height;
29 |
30 | renderer.setSize( width, height );
31 |
32 | };
33 |
34 | this.render = function ( scene, camera ) {
35 |
36 | // left
37 |
38 | _cameraL.fov = camera.fov;
39 | _cameraL.aspect = 0.5 * camera.aspect;
40 | _cameraL.near = camera.near;
41 | _cameraL.far = camera.far;
42 | _cameraL.updateProjectionMatrix();
43 |
44 | _cameraL.position.copy( camera.position );
45 | _cameraL.target.copy( camera.target );
46 | _cameraL.translateX( this.separation );
47 | _cameraL.lookAt( _cameraL.target );
48 |
49 | // right
50 |
51 | _cameraR.near = camera.near;
52 | _cameraR.far = camera.far;
53 |
54 | _cameraR.projectionMatrix = _cameraL.projectionMatrix;
55 |
56 | _cameraR.position.copy( camera.position );
57 | _cameraR.target.copy( camera.target );
58 | _cameraR.translateX( - this.separation );
59 | _cameraR.lookAt( _cameraR.target );
60 |
61 | //
62 |
63 | renderer.clear();
64 |
65 | renderer.setViewport( 0, 0, _width, _height );
66 | renderer.render( scene, _cameraL );
67 |
68 | renderer.setViewport( _width, 0, _width, _height );
69 | renderer.render( scene, _cameraR, false );
70 |
71 | };
72 |
73 | };
74 |
--------------------------------------------------------------------------------
/js/threejs/examples/js/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/threejs/examples/js/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 | "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 |
40 | "varying vec2 vUv;",
41 |
42 | "void main() {",
43 |
44 | "vec4 sum = vec4( 0.0 );",
45 |
46 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 4.0 * v ) ) * 0.051;",
47 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 3.0 * v ) ) * 0.0918;",
48 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 2.0 * v ) ) * 0.12245;",
49 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 1.0 * v ) ) * 0.1531;",
50 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;",
51 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 1.0 * v ) ) * 0.1531;",
52 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 2.0 * v ) ) * 0.12245;",
53 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 3.0 * v ) ) * 0.0918;",
54 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 4.0 * v ) ) * 0.051;",
55 |
56 | "gl_FragColor = sum;",
57 |
58 | "}"
59 |
60 | ].join("\n")
61 |
62 | };
63 |
--------------------------------------------------------------------------------
/js/threejs/examples/js/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 | "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 |
40 | "varying vec2 vUv;",
41 |
42 | "void main() {",
43 |
44 | "vec4 sum = vec4( 0.0 );",
45 |
46 | "sum += texture2D( tDiffuse, vec2( vUv.x - 4.0 * h, vUv.y ) ) * 0.051;",
47 | "sum += texture2D( tDiffuse, vec2( vUv.x - 3.0 * h, vUv.y ) ) * 0.0918;",
48 | "sum += texture2D( tDiffuse, vec2( vUv.x - 2.0 * h, vUv.y ) ) * 0.12245;",
49 | "sum += texture2D( tDiffuse, vec2( vUv.x - 1.0 * h, vUv.y ) ) * 0.1531;",
50 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;",
51 | "sum += texture2D( tDiffuse, vec2( vUv.x + 1.0 * h, vUv.y ) ) * 0.1531;",
52 | "sum += texture2D( tDiffuse, vec2( vUv.x + 2.0 * h, vUv.y ) ) * 0.12245;",
53 | "sum += texture2D( tDiffuse, vec2( vUv.x + 3.0 * h, vUv.y ) ) * 0.0918;",
54 | "sum += texture2D( tDiffuse, vec2( vUv.x + 4.0 * h, vUv.y ) ) * 0.051;",
55 |
56 | "gl_FragColor = sum;",
57 |
58 | "}"
59 |
60 | ].join("\n")
61 |
62 | };
63 |
--------------------------------------------------------------------------------
/js/threejs/examples/js/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 | "#define ITERATIONS 10.0",
38 |
39 | "uniform sampler2D texture;",
40 | "uniform vec2 delta;",
41 |
42 | "varying vec2 vUv;",
43 |
44 | "float random( vec3 scale, float seed ) {",
45 |
46 | // use the fragment position for a different seed per-pixel
47 |
48 | "return fract( sin( dot( gl_FragCoord.xyz + seed, scale ) ) * 43758.5453 + seed );",
49 |
50 | "}",
51 |
52 | "void main() {",
53 |
54 | "vec4 color = vec4( 0.0 );",
55 |
56 | "float total = 0.0;",
57 |
58 | // randomize the lookup values to hide the fixed number of samples
59 |
60 | "float offset = random( vec3( 12.9898, 78.233, 151.7182 ), 0.0 );",
61 |
62 | "for ( float t = -ITERATIONS; t <= ITERATIONS; t ++ ) {",
63 |
64 | "float percent = ( t + offset - 0.5 ) / ITERATIONS;",
65 | "float weight = 1.0 - abs( percent );",
66 |
67 | "color += texture2D( texture, vUv + delta * percent ) * weight;",
68 | "total += weight;",
69 |
70 | "}",
71 |
72 | "gl_FragColor = color / total;",
73 |
74 | "}"
75 |
76 | ].join("\n")
77 |
78 | };
79 |
--------------------------------------------------------------------------------
/js/threejs/examples/js/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/threejs/examples/js/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/threejs/examples/js/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/threejs/examples/js/postprocessing/MaskPass.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | */
4 |
5 | THREE.MaskPass = function ( scene, camera ) {
6 |
7 | this.scene = scene;
8 | this.camera = camera;
9 |
10 | this.enabled = true;
11 | this.clear = true;
12 | this.needsSwap = false;
13 |
14 | this.inverse = false;
15 |
16 | };
17 |
18 | THREE.MaskPass.prototype = {
19 |
20 | render: function ( renderer, writeBuffer, readBuffer, delta ) {
21 |
22 | var context = renderer.context;
23 |
24 | // don't update color or depth
25 |
26 | context.colorMask( false, false, false, false );
27 | context.depthMask( false );
28 |
29 | // set up stencil
30 |
31 | var writeValue, clearValue;
32 |
33 | if ( this.inverse ) {
34 |
35 | writeValue = 0;
36 | clearValue = 1;
37 |
38 | } else {
39 |
40 | writeValue = 1;
41 | clearValue = 0;
42 |
43 | }
44 |
45 | context.enable( context.STENCIL_TEST );
46 | context.stencilOp( context.REPLACE, context.REPLACE, context.REPLACE );
47 | context.stencilFunc( context.ALWAYS, writeValue, 0xffffffff );
48 | context.clearStencil( clearValue );
49 |
50 | // draw into the stencil buffer
51 |
52 | renderer.render( this.scene, this.camera, readBuffer, this.clear );
53 | renderer.render( this.scene, this.camera, writeBuffer, this.clear );
54 |
55 | // re-enable update of color and depth
56 |
57 | context.colorMask( true, true, true, true );
58 | context.depthMask( true );
59 |
60 | // only render where stencil is set to 1
61 |
62 | context.stencilFunc( context.EQUAL, 1, 0xffffffff ); // draw if == 1
63 | context.stencilOp( context.KEEP, context.KEEP, context.KEEP );
64 |
65 | }
66 |
67 | };
68 |
69 |
70 | THREE.ClearMaskPass = function () {
71 |
72 | this.enabled = true;
73 |
74 | };
75 |
76 | THREE.ClearMaskPass.prototype = {
77 |
78 | render: function ( renderer, writeBuffer, readBuffer, delta ) {
79 |
80 | var context = renderer.context;
81 |
82 | context.disable( context.STENCIL_TEST );
83 |
84 | }
85 |
86 | };
87 |
--------------------------------------------------------------------------------
/js/threejs/examples/js/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/threejs/examples/js/libs/stats.min.js:
--------------------------------------------------------------------------------
1 | // stats.js - http://github.com/mrdoob/stats.js
2 | var Stats=function(){var l=Date.now(),m=l,g=0,n=Infinity,o=0,h=0,p=Infinity,q=0,r=0,s=0,f=document.createElement("div");f.id="stats";f.addEventListener("mousedown",function(b){b.preventDefault();t(++s%2)},!1);f.style.cssText="width:80px;opacity:0.9;cursor:pointer";var a=document.createElement("div");a.id="fps";a.style.cssText="padding:0 0 3px 3px;text-align:left;background-color:#002";f.appendChild(a);var i=document.createElement("div");i.id="fpsText";i.style.cssText="color:#0ff;font-family:Helvetica,Arial,sans-serif;font-size:9px;font-weight:bold;line-height:15px";
3 | i.innerHTML="FPS";a.appendChild(i);var c=document.createElement("div");c.id="fpsGraph";c.style.cssText="position:relative;width:74px;height:30px;background-color:#0ff";for(a.appendChild(c);74>c.children.length;){var j=document.createElement("span");j.style.cssText="width:1px;height:30px;float:left;background-color:#113";c.appendChild(j)}var d=document.createElement("div");d.id="ms";d.style.cssText="padding:0 0 3px 3px;text-align:left;background-color:#020;display:none";f.appendChild(d);var k=document.createElement("div");
4 | k.id="msText";k.style.cssText="color:#0f0;font-family:Helvetica,Arial,sans-serif;font-size:9px;font-weight:bold;line-height:15px";k.innerHTML="MS";d.appendChild(k);var e=document.createElement("div");e.id="msGraph";e.style.cssText="position:relative;width:74px;height:30px;background-color:#0f0";for(d.appendChild(e);74>e.children.length;)j=document.createElement("span"),j.style.cssText="width:1px;height:30px;float:left;background-color:#131",e.appendChild(j);var t=function(b){s=b;switch(s){case 0:a.style.display=
5 | "block";d.style.display="none";break;case 1:a.style.display="none",d.style.display="block"}};return{REVISION:11,domElement:f,setMode:t,begin:function(){l=Date.now()},end:function(){var b=Date.now();g=b-l;n=Math.min(n,g);o=Math.max(o,g);k.textContent=g+" MS ("+n+"-"+o+")";var a=Math.min(30,30-30*(g/200));e.appendChild(e.firstChild).style.height=a+"px";r++;b>m+1E3&&(h=Math.round(1E3*r/(b-m)),p=Math.min(p,h),q=Math.max(q,h),i.textContent=h+" FPS ("+p+"-"+q+")",a=Math.min(30,30-30*(h/100)),c.appendChild(c.firstChild).style.height=
6 | a+"px",m=b,r=0);return b},update:function(){l=this.end()}}};
7 |
--------------------------------------------------------------------------------
/js/threejs/examples/js/exporters/MaterialExporter.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author mrdoob / http://mrdoob.com/
3 | */
4 |
5 | THREE.MaterialExporter = function () {};
6 |
7 | THREE.MaterialExporter.prototype = {
8 |
9 | constructor: THREE.MaterialExporter,
10 |
11 | parse: function ( material ) {
12 |
13 | var output = {
14 | metadata: {
15 | version: 4.0,
16 | type: 'material',
17 | generator: 'MaterialExporter'
18 | }
19 | };
20 |
21 | if ( material.name !== "" ) output.name = material.name;
22 |
23 | if ( material instanceof THREE.MeshBasicMaterial ) {
24 |
25 | output.type = 'MeshBasicMaterial';
26 | output.color = material.color.getHex();
27 | output.opacity = material.opacity;
28 | output.transparent = material.transparent;
29 | output.wireframe = material.wireframe;
30 |
31 | } else if ( material instanceof THREE.MeshLambertMaterial ) {
32 |
33 | output.type = 'MeshLambertMaterial';
34 | output.color = material.color.getHex();
35 | output.ambient = material.ambient.getHex();
36 | output.emissive = material.emissive.getHex();
37 | output.opacity = material.opacity;
38 | output.transparent = material.transparent;
39 | output.wireframe = material.wireframe;
40 |
41 | } else if ( material instanceof THREE.MeshPhongMaterial ) {
42 |
43 | output.type = 'MeshPhongMaterial';
44 | output.color = material.color.getHex();
45 | output.ambient = material.ambient.getHex();
46 | output.emissive = material.emissive.getHex();
47 | output.specular = material.specular.getHex();
48 | output.shininess = material.shininess;
49 | output.opacity = material.opacity;
50 | output.transparent = material.transparent;
51 | output.wireframe = material.wireframe;
52 |
53 | } else if ( material instanceof THREE.MeshNormalMaterial ) {
54 |
55 | output.type = 'MeshNormalMaterial';
56 | output.opacity = material.opacity;
57 | output.transparent = material.transparent;
58 | output.wireframe = material.wireframe;
59 |
60 | } else if ( material instanceof THREE.MeshDepthMaterial ) {
61 |
62 | output.type = 'MeshDepthMaterial';
63 | output.opacity = material.opacity;
64 | output.transparent = material.transparent;
65 | output.wireframe = material.wireframe;
66 |
67 | }
68 |
69 | return output;
70 |
71 | }
72 |
73 | };
74 |
--------------------------------------------------------------------------------
/js/threejs/examples/js/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/threejs/examples/js/ImprovedNoise.js:
--------------------------------------------------------------------------------
1 | // http://mrl.nyu.edu/~perlin/noise/
2 |
3 | var ImprovedNoise = function () {
4 |
5 | var p = [151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,
6 | 23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,
7 | 174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,
8 | 133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,
9 | 89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,
10 | 202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,
11 | 248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,
12 | 178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,
13 | 14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,
14 | 93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180];
15 |
16 | for (var i=0; i < 256 ; i++) {
17 |
18 | p[256+i] = p[i];
19 |
20 | }
21 |
22 | function fade(t) {
23 |
24 | return t * t * t * (t * (t * 6 - 15) + 10);
25 |
26 | }
27 |
28 | function lerp(t, a, b) {
29 |
30 | return a + t * (b - a);
31 |
32 | }
33 |
34 | function grad(hash, x, y, z) {
35 |
36 | var h = hash & 15;
37 | var u = h < 8 ? x : y, v = h < 4 ? y : h == 12 || h == 14 ? x : z;
38 | return ((h&1) == 0 ? u : -u) + ((h&2) == 0 ? v : -v);
39 |
40 | }
41 |
42 | return {
43 |
44 | noise: function (x, y, z) {
45 |
46 | var floorX = ~~x, floorY = ~~y, floorZ = ~~z;
47 |
48 | var X = floorX & 255, Y = floorY & 255, Z = floorZ & 255;
49 |
50 | x -= floorX;
51 | y -= floorY;
52 | z -= floorZ;
53 |
54 | var xMinus1 = x -1, yMinus1 = y - 1, zMinus1 = z - 1;
55 |
56 | var u = fade(x), v = fade(y), w = fade(z);
57 |
58 | var A = p[X]+Y, AA = p[A]+Z, AB = p[A+1]+Z, B = p[X+1]+Y, BA = p[B]+Z, BB = p[B+1]+Z;
59 |
60 | return lerp(w, lerp(v, lerp(u, grad(p[AA], x, y, z),
61 | grad(p[BA], xMinus1, y, z)),
62 | lerp(u, grad(p[AB], x, yMinus1, z),
63 | grad(p[BB], xMinus1, yMinus1, z))),
64 | lerp(v, lerp(u, grad(p[AA+1], x, y, zMinus1),
65 | grad(p[BA+1], xMinus1, y, z-1)),
66 | lerp(u, grad(p[AB+1], x, yMinus1, zMinus1),
67 | grad(p[BB+1], xMinus1, yMinus1, zMinus1))));
68 |
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/js/threejs/examples/js/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/threejs/examples/js/math/TypeArrayVector3.js:
--------------------------------------------------------------------------------
1 | THREE.TypeArrayVector3 = function ( x, y, z ) {
2 |
3 | this.elements = new Float64Array( 3 );
4 | this.set( x, y, z );
5 |
6 | };
7 |
8 |
9 | THREE.TypeArrayVector3.prototype = {
10 |
11 | constructor: THREE.TypeArrayVector3,
12 |
13 | get x() {
14 |
15 | return this.elements[ 0 ];
16 |
17 | },
18 |
19 | set x( value ) {
20 |
21 | this.elements[ 0 ] = value;
22 |
23 | },
24 |
25 | get y() {
26 |
27 | return this.elements[ 1 ];
28 |
29 | },
30 |
31 | set y( value ) {
32 |
33 | this.elements[ 1 ] = value;
34 |
35 | },
36 |
37 | get z() {
38 |
39 | return this.elements[ 2 ];
40 |
41 | },
42 |
43 | set z( value ) {
44 |
45 | this.elements[ 2 ] = value;
46 |
47 | },
48 |
49 | set: function ( x, y, z ) {
50 |
51 | var elements = this.elements;
52 |
53 | elements[ 0 ] = x;
54 | elements[ 1 ] = y;
55 | elements[ 2 ] = z;
56 |
57 | return this;
58 |
59 | },
60 |
61 | copy: function ( v ) {
62 |
63 | var elements = this.elements;
64 | var velements = v.elements;
65 |
66 | elements[ 0 ] = velements[ 0 ];
67 | elements[ 1 ] = velements[ 1 ];
68 | elements[ 2 ] = velements[ 2 ];
69 |
70 | return this;
71 |
72 | },
73 |
74 | add: function ( v ) {
75 |
76 | var elements = this.elements;
77 | var velements = v.elements;
78 |
79 | elements[ 0 ] += velements[ 0 ];
80 | elements[ 1 ] += velements[ 1 ];
81 | elements[ 2 ] += velements[ 2 ];
82 |
83 | return this;
84 |
85 | },
86 |
87 | addVectors: function ( a, b ) {
88 |
89 | var elements = this.elements;
90 | var aelements = a.elements;
91 | var belements = b.elements;
92 |
93 | elements[ 0 ] = aelements[ 0 ] + belements[ 0 ];
94 | elements[ 1 ] = aelements[ 1 ] + belements[ 1 ];
95 | elements[ 2 ] = aelements[ 2 ] + belements[ 2 ];
96 |
97 | return this;
98 |
99 | },
100 |
101 | sub: function ( v, w ) {
102 |
103 | var elements = this.elements;
104 | var velements = v.elements;
105 |
106 | elements[ 0 ] -= velements[ 0 ];
107 | elements[ 1 ] -= velements[ 1 ];
108 | elements[ 2 ] -= velements[ 2 ];
109 |
110 | return this;
111 |
112 | },
113 |
114 | subVectors: function ( a, b ) {
115 |
116 | var elements = this.elements;
117 | var aelements = a.elements;
118 | var belements = b.elements;
119 |
120 | elements[ 0 ] = aelements[ 0 ] - belements[ 0 ];
121 | elements[ 1 ] = aelements[ 1 ] - belements[ 1 ];
122 | elements[ 2 ] = aelements[ 2 ] - belements[ 2 ];
123 |
124 | return this;
125 |
126 | }
127 |
128 | }
129 |
--------------------------------------------------------------------------------
/js/threejs/examples/js/exporters/OBJExporter.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author mrdoob / http://mrdoob.com/
3 | */
4 |
5 | THREE.OBJExporter = function () {};
6 |
7 | THREE.OBJExporter.prototype = {
8 |
9 | constructor: THREE.OBJExporter,
10 |
11 | parse: function ( geometry ) {
12 |
13 | console.log( geometry );
14 |
15 | var output = '';
16 |
17 | for ( var i = 0, l = geometry.vertices.length; i < l; i ++ ) {
18 |
19 | var vertex = geometry.vertices[ i ];
20 | output += 'v ' + vertex.x + ' ' + vertex.y + ' ' + vertex.z + '\n';
21 |
22 | }
23 |
24 | // uvs
25 |
26 | for ( var i = 0, l = geometry.faceVertexUvs[ 0 ].length; i < l; i ++ ) {
27 |
28 | var vertexUvs = geometry.faceVertexUvs[ 0 ][ i ];
29 |
30 | for ( var j = 0; j < vertexUvs.length; j ++ ) {
31 |
32 | var uv = vertexUvs[ j ];
33 | output += 'vt ' + uv.x + ' ' + uv.y + '\n';
34 |
35 | }
36 |
37 | }
38 |
39 | // normals
40 |
41 | for ( var i = 0, l = geometry.faces.length; i < l; i ++ ) {
42 |
43 | var normals = geometry.faces[ i ].vertexNormals;
44 |
45 | for ( var j = 0; j < normals.length; j ++ ) {
46 |
47 | var normal = normals[ j ];
48 | output += 'vn ' + normal.x + ' ' + normal.y + ' ' + normal.z + '\n';
49 |
50 | }
51 |
52 | }
53 |
54 | // map
55 |
56 | var count = 1; // OBJ values start by 1
57 | var map = [ count ];
58 |
59 | for ( var i = 0, l = geometry.faces.length; i < l; i ++ ) {
60 |
61 | var face = geometry.faces[ i ];
62 |
63 | if ( face instanceof THREE.Face3 ) {
64 |
65 | count += 3;
66 |
67 | } else if ( face instanceof THREE.Face4 ) {
68 |
69 | count += 4;
70 |
71 | }
72 |
73 | map.push( count );
74 |
75 | }
76 |
77 | // faces
78 |
79 | for ( var i = 0, l = geometry.faces.length; i < l; i ++ ) {
80 |
81 | var face = geometry.faces[ i ];
82 |
83 | output += 'f ';
84 |
85 | if ( face instanceof THREE.Face3 ) {
86 |
87 | output += ( face.a + 1 ) + '/' + ( map[ i ] ) + '/' + ( map[ i ] ) + ' ';
88 | output += ( face.b + 1 ) + '/' + ( map[ i ] + 1 ) + '/' + ( map[ i ] + 1 ) + ' ';
89 | output += ( face.c + 1 ) + '/' + ( map[ i ] + 2 ) + '/' + ( map[ i ] + 2 ) + '\n';
90 |
91 | } else if ( face instanceof THREE.Face4 ) {
92 |
93 | output += ( face.a + 1 ) + '/' + ( map[ i ] ) + '/' + ( map[ i ] ) + ' ';
94 | output += ( face.b + 1 ) + '/' + ( map[ i ] + 1 ) + '/' + ( map[ i ] + 1 ) + ' ';
95 | output += ( face.c + 1 ) + '/' + ( map[ i ] + 2 ) + '/' + ( map[ i ] + 2 ) + ' ';
96 | output += ( face.d + 1 ) + '/' + ( map[ i ] + 3 ) + '/' + ( map[ i ] + 3 ) + '\n';
97 |
98 | }
99 |
100 | }
101 |
102 | return output;
103 |
104 | }
105 |
106 | }
107 |
--------------------------------------------------------------------------------
/js/threejs/examples/js/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/threejs/examples/js/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 | // control parameter
52 | "uniform float time;",
53 |
54 | "uniform bool grayscale;",
55 |
56 | // noise effect intensity value (0 = no effect, 1 = full effect)
57 | "uniform float nIntensity;",
58 |
59 | // scanlines effect intensity value (0 = no effect, 1 = full effect)
60 | "uniform float sIntensity;",
61 |
62 | // scanlines effect count value (0 = no effect, 4096 = full effect)
63 | "uniform float sCount;",
64 |
65 | "uniform sampler2D tDiffuse;",
66 |
67 | "varying vec2 vUv;",
68 |
69 | "void main() {",
70 |
71 | // sample the source
72 | "vec4 cTextureScreen = texture2D( tDiffuse, vUv );",
73 |
74 | // make some noise
75 | "float x = vUv.x * vUv.y * time * 1000.0;",
76 | "x = mod( x, 13.0 ) * mod( x, 123.0 );",
77 | "float dx = mod( x, 0.01 );",
78 |
79 | // add noise
80 | "vec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx * 100.0, 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/threejs/examples/js/loaders/VTKLoader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author mrdoob / http://mrdoob.com/
3 | */
4 |
5 | THREE.VTKLoader = function () {};
6 |
7 | THREE.VTKLoader.prototype = {
8 |
9 | constructor: THREE.VTKLoader,
10 |
11 | addEventListener: THREE.EventDispatcher.prototype.addEventListener,
12 | hasEventListener: THREE.EventDispatcher.prototype.hasEventListener,
13 | removeEventListener: THREE.EventDispatcher.prototype.removeEventListener,
14 | dispatchEvent: THREE.EventDispatcher.prototype.dispatchEvent,
15 |
16 | load: function ( url, callback ) {
17 |
18 | var scope = this;
19 | var request = new XMLHttpRequest();
20 |
21 | request.addEventListener( 'load', function ( event ) {
22 |
23 | var geometry = scope.parse( event.target.responseText );
24 |
25 | scope.dispatchEvent( { type: 'load', content: geometry } );
26 |
27 | if ( callback ) callback( geometry );
28 |
29 | }, false );
30 |
31 | request.addEventListener( 'progress', function ( event ) {
32 |
33 | scope.dispatchEvent( { type: 'progress', loaded: event.loaded, total: event.total } );
34 |
35 | }, false );
36 |
37 | request.addEventListener( 'error', function () {
38 |
39 | scope.dispatchEvent( { type: 'error', message: 'Couldn\'t load URL [' + url + ']' } );
40 |
41 | }, false );
42 |
43 | request.open( 'GET', url, true );
44 | request.send( null );
45 |
46 | },
47 |
48 | parse: function ( data ) {
49 |
50 | var geometry = new THREE.Geometry();
51 |
52 | function vertex( x, y, z ) {
53 |
54 | geometry.vertices.push( new THREE.Vector3( x, y, z ) );
55 |
56 | }
57 |
58 | function face3( a, b, c ) {
59 |
60 | geometry.faces.push( new THREE.Face3( a, b, c ) );
61 |
62 | }
63 |
64 | function face4( a, b, c, d ) {
65 |
66 | geometry.faces.push( new THREE.Face4( a, b, c, d ) );
67 |
68 | }
69 |
70 | var pattern, result;
71 |
72 | // float float float
73 |
74 | pattern = /([\+|\-]?[\d]+[\.][\d|\-|e]+)[ ]+([\+|\-]?[\d]+[\.][\d|\-|e]+)[ ]+([\+|\-]?[\d]+[\.][\d|\-|e]+)/g;
75 |
76 | while ( ( result = pattern.exec( data ) ) != null ) {
77 |
78 | // ["1.0 2.0 3.0", "1.0", "2.0", "3.0"]
79 |
80 | vertex( parseFloat( result[ 1 ] ), parseFloat( result[ 2 ] ), parseFloat( result[ 3 ] ) );
81 |
82 | }
83 |
84 | // 3 int int int
85 |
86 | pattern = /3[ ]+([\d]+)[ ]+([\d]+)[ ]+([\d]+)/g;
87 |
88 | while ( ( result = pattern.exec( data ) ) != null ) {
89 |
90 | // ["3 1 2 3", "1", "2", "3"]
91 |
92 | face3( parseInt( result[ 1 ] ), parseInt( result[ 2 ] ), parseInt( result[ 3 ] ) );
93 |
94 | }
95 |
96 | // 4 int int int int
97 |
98 | pattern = /4[ ]+([\d]+)[ ]+([\d]+)[ ]+([\d]+)[ ]+([\d]+)/g;
99 |
100 | while ( ( result = pattern.exec( data ) ) != null ) {
101 |
102 | // ["4 1 2 3 4", "1", "2", "3", "4"]
103 |
104 | face4( parseInt( result[ 1 ] ), parseInt( result[ 2 ] ), parseInt( result[ 3 ] ), parseInt( result[ 4 ] ) );
105 |
106 | }
107 |
108 | geometry.computeCentroids();
109 | geometry.computeFaceNormals();
110 | geometry.computeVertexNormals();
111 | geometry.computeBoundingSphere();
112 |
113 | return geometry;
114 |
115 | }
116 |
117 | };
118 |
--------------------------------------------------------------------------------
/js/threejs/examples/js/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 | "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 sampler2D tDiffuse;",
36 | "uniform vec2 resolution;",
37 |
38 | "varying vec2 vUv;",
39 |
40 | "#define FXAA_REDUCE_MIN (1.0/128.0)",
41 | "#define FXAA_REDUCE_MUL (1.0/8.0)",
42 | "#define FXAA_SPAN_MAX 8.0",
43 |
44 | "void main() {",
45 |
46 | "vec3 rgbNW = texture2D( tDiffuse, ( gl_FragCoord.xy + vec2( -1.0, -1.0 ) ) * resolution ).xyz;",
47 | "vec3 rgbNE = texture2D( tDiffuse, ( gl_FragCoord.xy + vec2( 1.0, -1.0 ) ) * resolution ).xyz;",
48 | "vec3 rgbSW = texture2D( tDiffuse, ( gl_FragCoord.xy + vec2( -1.0, 1.0 ) ) * resolution ).xyz;",
49 | "vec3 rgbSE = texture2D( tDiffuse, ( gl_FragCoord.xy + vec2( 1.0, 1.0 ) ) * resolution ).xyz;",
50 | "vec4 rgbaM = texture2D( tDiffuse, gl_FragCoord.xy * resolution );",
51 | "vec3 rgbM = rgbaM.xyz;",
52 | "float opacity = rgbaM.w;",
53 |
54 | "vec3 luma = vec3( 0.299, 0.587, 0.114 );",
55 |
56 | "float lumaNW = dot( rgbNW, luma );",
57 | "float lumaNE = dot( rgbNE, luma );",
58 | "float lumaSW = dot( rgbSW, luma );",
59 | "float lumaSE = dot( rgbSE, luma );",
60 | "float lumaM = dot( rgbM, luma );",
61 | "float lumaMin = min( lumaM, min( min( lumaNW, lumaNE ), min( lumaSW, lumaSE ) ) );",
62 | "float lumaMax = max( lumaM, max( max( lumaNW, lumaNE) , max( lumaSW, lumaSE ) ) );",
63 |
64 | "vec2 dir;",
65 | "dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));",
66 | "dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));",
67 |
68 | "float dirReduce = max( ( lumaNW + lumaNE + lumaSW + lumaSE ) * ( 0.25 * FXAA_REDUCE_MUL ), FXAA_REDUCE_MIN );",
69 |
70 | "float rcpDirMin = 1.0 / ( min( abs( dir.x ), abs( dir.y ) ) + dirReduce );",
71 | "dir = min( vec2( FXAA_SPAN_MAX, FXAA_SPAN_MAX),",
72 | "max( vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),",
73 | "dir * rcpDirMin)) * resolution;",
74 |
75 | "vec3 rgbA = 0.5 * (",
76 | "texture2D( tDiffuse, gl_FragCoord.xy * resolution + dir * ( 1.0 / 3.0 - 0.5 ) ).xyz +",
77 | "texture2D( tDiffuse, gl_FragCoord.xy * resolution + dir * ( 2.0 / 3.0 - 0.5 ) ).xyz );",
78 |
79 | "vec3 rgbB = rgbA * 0.5 + 0.25 * (",
80 | "texture2D( tDiffuse, gl_FragCoord.xy * resolution + dir * -0.5 ).xyz +",
81 | "texture2D( tDiffuse, gl_FragCoord.xy * resolution + dir * 0.5 ).xyz );",
82 |
83 | "float lumaB = dot( rgbB, luma );",
84 |
85 | "if ( ( lumaB < lumaMin ) || ( lumaB > lumaMax ) ) {",
86 |
87 | "gl_FragColor = vec4( rgbA, opacity );",
88 |
89 | "} else {",
90 |
91 | "gl_FragColor = vec4( rgbB, opacity );",
92 |
93 | "}",
94 |
95 | "}"
96 |
97 | ].join("\n")
98 |
99 | };
100 |
--------------------------------------------------------------------------------
/js/threejs/examples/js/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/threejs/examples/js/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 width = window.innerWidth || 1;
12 | var height = window.innerHeight || 1;
13 | var parameters = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBFormat, stencilBuffer: false };
14 |
15 | renderTarget = new THREE.WebGLRenderTarget( width, height, parameters );
16 |
17 | }
18 |
19 | this.renderTarget1 = renderTarget;
20 | this.renderTarget2 = renderTarget.clone();
21 |
22 | this.writeBuffer = this.renderTarget1;
23 | this.readBuffer = this.renderTarget2;
24 |
25 | this.passes = [];
26 |
27 | if ( THREE.CopyShader === undefined )
28 | console.error( "THREE.EffectComposer relies on THREE.CopyShader" );
29 |
30 | this.copyPass = new THREE.ShaderPass( THREE.CopyShader );
31 |
32 | };
33 |
34 | THREE.EffectComposer.prototype = {
35 |
36 | swapBuffers: function() {
37 |
38 | var tmp = this.readBuffer;
39 | this.readBuffer = this.writeBuffer;
40 | this.writeBuffer = tmp;
41 |
42 | },
43 |
44 | addPass: function ( pass ) {
45 |
46 | this.passes.push( pass );
47 |
48 | },
49 |
50 | insertPass: function ( pass, index ) {
51 |
52 | this.passes.splice( index, 0, pass );
53 |
54 | },
55 |
56 | render: function ( delta ) {
57 |
58 | this.writeBuffer = this.renderTarget1;
59 | this.readBuffer = this.renderTarget2;
60 |
61 | var maskActive = false;
62 |
63 | var pass, i, il = this.passes.length;
64 |
65 | for ( i = 0; i < il; i ++ ) {
66 |
67 | pass = this.passes[ i ];
68 |
69 | if ( !pass.enabled ) continue;
70 |
71 | pass.render( this.renderer, this.writeBuffer, this.readBuffer, delta, maskActive );
72 |
73 | if ( pass.needsSwap ) {
74 |
75 | if ( maskActive ) {
76 |
77 | var context = this.renderer.context;
78 |
79 | context.stencilFunc( context.NOTEQUAL, 1, 0xffffffff );
80 |
81 | this.copyPass.render( this.renderer, this.writeBuffer, this.readBuffer, delta );
82 |
83 | context.stencilFunc( context.EQUAL, 1, 0xffffffff );
84 |
85 | }
86 |
87 | this.swapBuffers();
88 |
89 | }
90 |
91 | if ( pass instanceof THREE.MaskPass ) {
92 |
93 | maskActive = true;
94 |
95 | } else if ( pass instanceof THREE.ClearMaskPass ) {
96 |
97 | maskActive = false;
98 |
99 | }
100 |
101 | }
102 |
103 | },
104 |
105 | reset: function ( renderTarget ) {
106 |
107 | if ( renderTarget === undefined ) {
108 |
109 | renderTarget = this.renderTarget1.clone();
110 |
111 | renderTarget.width = window.innerWidth;
112 | renderTarget.height = window.innerHeight;
113 |
114 | }
115 |
116 | this.renderTarget1 = renderTarget;
117 | this.renderTarget2 = renderTarget.clone();
118 |
119 | this.writeBuffer = this.renderTarget1;
120 | this.readBuffer = this.renderTarget2;
121 |
122 | },
123 |
124 | setSize: function ( width, height ) {
125 |
126 | var renderTarget = this.renderTarget1.clone();
127 |
128 | renderTarget.width = width;
129 | renderTarget.height = height;
130 |
131 | this.reset( renderTarget );
132 |
133 | }
134 |
135 | };
136 |
137 | // shared ortho camera
138 |
139 | THREE.EffectComposer.camera = new THREE.OrthographicCamera( -1, 1, 1, -1, 0, 1 );
140 |
141 | THREE.EffectComposer.quad = new THREE.Mesh( new THREE.PlaneGeometry( 2, 2 ), null );
142 |
143 | THREE.EffectComposer.scene = new THREE.Scene();
144 | THREE.EffectComposer.scene.add( THREE.EffectComposer.quad );
145 |
--------------------------------------------------------------------------------
/js/threejs/examples/js/controls/PointerLockControls.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author mrdoob / http://mrdoob.com/
3 | */
4 |
5 | THREE.PointerLockControls = function ( camera ) {
6 |
7 | var scope = this;
8 |
9 | var pitchObject = new THREE.Object3D();
10 | pitchObject.add( camera );
11 |
12 | var yawObject = new THREE.Object3D();
13 | yawObject.position.y = 10;
14 | yawObject.add( pitchObject );
15 |
16 | var moveForward = false;
17 | var moveBackward = false;
18 | var moveLeft = false;
19 | var moveRight = false;
20 |
21 | var isOnObject = false;
22 | var canJump = false;
23 |
24 | var velocity = new THREE.Vector3();
25 |
26 | var PI_2 = Math.PI / 2;
27 |
28 | var onMouseMove = function ( event ) {
29 |
30 | if ( scope.enabled === false ) return;
31 |
32 | var movementX = event.movementX || event.mozMovementX || event.webkitMovementX || 0;
33 | var movementY = event.movementY || event.mozMovementY || event.webkitMovementY || 0;
34 |
35 | yawObject.rotation.y -= movementX * 0.002;
36 | pitchObject.rotation.x -= movementY * 0.002;
37 |
38 | pitchObject.rotation.x = Math.max( - PI_2, Math.min( PI_2, pitchObject.rotation.x ) );
39 |
40 | };
41 |
42 | var onKeyDown = function ( event ) {
43 |
44 | switch ( event.keyCode ) {
45 |
46 | case 38: // up
47 | case 87: // w
48 | moveForward = true;
49 | break;
50 |
51 | case 37: // left
52 | case 65: // a
53 | moveLeft = true; break;
54 |
55 | case 40: // down
56 | case 83: // s
57 | moveBackward = true;
58 | break;
59 |
60 | case 39: // right
61 | case 68: // d
62 | moveRight = true;
63 | break;
64 |
65 | case 32: // space
66 | if ( canJump === true ) velocity.y += 10;
67 | canJump = false;
68 | break;
69 |
70 | }
71 |
72 | };
73 |
74 | var onKeyUp = function ( event ) {
75 |
76 | switch( event.keyCode ) {
77 |
78 | case 38: // up
79 | case 87: // w
80 | moveForward = false;
81 | break;
82 |
83 | case 37: // left
84 | case 65: // a
85 | moveLeft = false;
86 | break;
87 |
88 | case 40: // down
89 | case 83: // a
90 | moveBackward = false;
91 | break;
92 |
93 | case 39: // right
94 | case 68: // d
95 | moveRight = false;
96 | break;
97 |
98 | }
99 |
100 | };
101 |
102 | document.addEventListener( 'mousemove', onMouseMove, false );
103 | document.addEventListener( 'keydown', onKeyDown, false );
104 | document.addEventListener( 'keyup', onKeyUp, false );
105 |
106 | this.enabled = false;
107 |
108 | this.getObject = function () {
109 |
110 | return yawObject;
111 |
112 | };
113 |
114 | this.isOnObject = function ( boolean ) {
115 |
116 | isOnObject = boolean;
117 | canJump = boolean;
118 |
119 | };
120 |
121 | this.update = function ( delta ) {
122 |
123 | if ( scope.enabled === false ) return;
124 |
125 | delta *= 0.1;
126 |
127 | velocity.x += ( - velocity.x ) * 0.08 * delta;
128 | velocity.z += ( - velocity.z ) * 0.08 * delta;
129 |
130 | velocity.y -= 0.25 * delta;
131 |
132 | if ( moveForward ) velocity.z -= 0.12 * delta;
133 | if ( moveBackward ) velocity.z += 0.12 * delta;
134 |
135 | if ( moveLeft ) velocity.x -= 0.12 * delta;
136 | if ( moveRight ) velocity.x += 0.12 * delta;
137 |
138 | if ( isOnObject === true ) {
139 |
140 | velocity.y = Math.max( 0, velocity.y );
141 |
142 | }
143 |
144 | yawObject.translateX( velocity.x );
145 | yawObject.translateY( velocity.y );
146 | yawObject.translateZ( velocity.z );
147 |
148 | if ( yawObject.position.y < 10 ) {
149 |
150 | velocity.y = 0;
151 | yawObject.position.y = 10;
152 |
153 | canJump = true;
154 |
155 | }
156 |
157 | };
158 |
159 | };
160 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
Click a Node to Move
114 || = | Add Spline |
| - | Remove Spline |
| H | Toggle Code View |
| UP/DOWN | Y Axis |
| LEFT/RIGHT | X Axis |
| OPTION + UP/DOWN | Z Axis |
| SHIFT | Speed Up |