├── README.md ├── build ├── three.js └── three.min.js ├── favicon.ico ├── image └── dan │ ├── 1.jpg │ ├── 10.jpg │ ├── 100.jpg │ ├── 101.jpg │ ├── 102.jpg │ ├── 103.jpg │ ├── 104.jpg │ ├── 105.jpg │ ├── 106.jpg │ ├── 107.jpg │ ├── 108.jpg │ ├── 109.jpg │ ├── 11.jpg │ ├── 110.jpg │ ├── 111.jpg │ ├── 112.jpg │ ├── 113.jpg │ ├── 114.jpg │ ├── 115.jpg │ ├── 116.jpg │ ├── 117.jpg │ ├── 118.jpg │ ├── 119.jpg │ ├── 12.jpg │ ├── 120.jpg │ ├── 121.jpg │ ├── 122.jpg │ ├── 123.jpg │ ├── 124.jpg │ ├── 125.jpg │ ├── 126.jpg │ ├── 127.jpg │ ├── 128.jpg │ ├── 129.jpg │ ├── 13.jpg │ ├── 130.jpg │ ├── 131.jpg │ ├── 132.jpg │ ├── 133.jpg │ ├── 134.jpg │ ├── 135.jpg │ ├── 136.jpg │ ├── 137.jpg │ ├── 138.jpg │ ├── 139.jpg │ ├── 14.jpg │ ├── 140.jpg │ ├── 141.jpg │ ├── 142.jpg │ ├── 143.jpg │ ├── 144.jpg │ ├── 145.jpg │ ├── 146.jpg │ ├── 147.jpg │ ├── 148.jpg │ ├── 149.jpg │ ├── 15.jpg │ ├── 150.jpg │ ├── 151.jpg │ ├── 152.jpg │ ├── 16.jpg │ ├── 17.jpg │ ├── 18.jpg │ ├── 19.jpg │ ├── 2.jpg │ ├── 20.jpg │ ├── 21.jpg │ ├── 22.jpg │ ├── 23.jpg │ ├── 24.jpg │ ├── 25.jpg │ ├── 26.jpg │ ├── 27.jpg │ ├── 28.jpg │ ├── 29.jpg │ ├── 3.jpg │ ├── 30.jpg │ ├── 31.jpg │ ├── 32.jpg │ ├── 33.jpg │ ├── 34.jpg │ ├── 35.jpg │ ├── 36.jpg │ ├── 37.jpg │ ├── 38.jpg │ ├── 39.jpg │ ├── 4.jpg │ ├── 40.jpg │ ├── 41.jpg │ ├── 42.jpg │ ├── 43.jpg │ ├── 44.jpg │ ├── 45.jpg │ ├── 46.jpg │ ├── 47.jpg │ ├── 48.jpg │ ├── 49.jpg │ ├── 5.jpg │ ├── 50.jpg │ ├── 51.jpg │ ├── 52.jpg │ ├── 53.jpg │ ├── 54.jpg │ ├── 55.jpg │ ├── 56.jpg │ ├── 57.jpg │ ├── 58.jpg │ ├── 59.jpg │ ├── 6.jpg │ ├── 60.jpg │ ├── 61.jpg │ ├── 62.jpg │ ├── 63.jpg │ ├── 64.jpg │ ├── 65.jpg │ ├── 66.jpg │ ├── 67.jpg │ ├── 68.jpg │ ├── 69.jpg │ ├── 7.jpg │ ├── 70.jpg │ ├── 71.jpg │ ├── 72.jpg │ ├── 73.jpg │ ├── 74.jpg │ ├── 75.jpg │ ├── 76.jpg │ ├── 77.jpg │ ├── 78.jpg │ ├── 79.jpg │ ├── 8.jpg │ ├── 80.jpg │ ├── 81.jpg │ ├── 82.jpg │ ├── 83.jpg │ ├── 84.jpg │ ├── 85.jpg │ ├── 86.jpg │ ├── 87.jpg │ ├── 88.jpg │ ├── 89.jpg │ ├── 9.jpg │ ├── 90.jpg │ ├── 91.jpg │ ├── 92.jpg │ ├── 93.jpg │ ├── 94.jpg │ ├── 95.jpg │ ├── 96.jpg │ ├── 97.jpg │ ├── 98.jpg │ └── 99.jpg ├── index.html ├── index.php └── js ├── AudioObject.js ├── Car.js ├── Cloth.js ├── CurveExtras.js ├── Detector.js ├── ImprovedNoise.js ├── MD2Character.js ├── MD2CharacterComplex.js ├── MarchingCubes.js ├── PRNG.js ├── ParametricGeometries.js ├── ShaderDeferred.js ├── ShaderGodRays.js ├── ShaderSkin.js ├── ShaderTerrain.js ├── ShaderToon.js ├── SimplexNoise.js ├── Sparks.js ├── UVsUtils.js ├── controls ├── EditorControls.js ├── FirstPersonControls.js ├── FlyControls.js ├── OrbitControls.js ├── PathControls.js ├── PointerLockControls.js └── TrackballControls.js ├── effects ├── AnaglyphEffect.js ├── AsciiEffect.js ├── CrosseyedEffect.js ├── OculusRiftEffect.js └── ParallaxBarrierEffect.js ├── exporters ├── GeometryExporter.js ├── MaterialExporter.js ├── OBJExporter.js ├── ObjectExporter.js └── SceneExporter.js ├── libs ├── dat.gui.min.js ├── stats.min.js ├── system.min.js └── tween.min.js ├── loaders ├── BinaryLoader.js ├── ColladaLoader.js ├── MTLLoader.js ├── OBJLoader.js ├── OBJMTLLoader.js ├── ObjectLoader.js ├── PDBLoader.js ├── PLYLoader.js ├── STLLoader.js ├── UTF8Loader.js ├── VTKLoader.js └── ctm │ ├── CTMLoader.js │ ├── CTMWorker.js │ ├── ctm.js │ ├── license │ ├── OpenCTM.txt │ ├── js-lzma.txt │ └── js-openctm.txt │ └── lzma.js ├── math ├── ColorConverter.js └── TypeArrayVector3.js ├── modifiers ├── ExplodeModifier.js ├── SubdivisionModifier.js └── TessellateModifier.js ├── postprocessing ├── BloomPass.js ├── DotScreenPass.js ├── EffectComposer.js ├── FilmPass.js ├── MaskPass.js ├── RenderPass.js ├── SavePass.js ├── ShaderPass.js └── TexturePass.js ├── renderers ├── CSS3DRenderer.js ├── SVGRenderer.js ├── SoftwareRenderer.js ├── WebGLDeferredRenderer.js └── WebGLRenderer3.js └── shaders ├── BasicShader.js ├── BleachBypassShader.js ├── BlendShader.js ├── BokehShader.js ├── BokehShader2.js ├── BrightnessContrastShader.js ├── ColorCorrectionShader.js ├── ColorifyShader.js ├── ConvolutionShader.js ├── CopyShader.js ├── DOFMipMapShader.js ├── DotScreenShader.js ├── EdgeShader.js ├── EdgeShader2.js ├── FXAAShader.js ├── FilmShader.js ├── FocusShader.js ├── FresnelShader.js ├── HorizontalBlurShader.js ├── HorizontalTiltShiftShader.js ├── HueSaturationShader.js ├── KaleidoShader.js ├── LuminosityShader.js ├── MirrorShader.js ├── NormalMapShader.js ├── RGBShiftShader.js ├── SSAOShader.js ├── SepiaShader.js ├── TriangleBlurShader.js ├── UnpackDepthRGBAShader.js ├── VerticalBlurShader.js ├── VerticalTiltShiftShader.js └── VignetteShader.js /README.md: -------------------------------------------------------------------------------- 1 | meidan 2 | ====== 3 | 4 | Don't be so serious. 5 | 高端大气上档次,低调奢华有内涵。 6 | 7 | Some clones: 8 | * lulukeke1314.heroku.com Heart shaped src 9 | 10 | File me a pull request to add your example here. 11 | -------------------------------------------------------------------------------- /favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/favicon.ico -------------------------------------------------------------------------------- /image/dan/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/1.jpg -------------------------------------------------------------------------------- /image/dan/10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/10.jpg -------------------------------------------------------------------------------- /image/dan/100.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/100.jpg -------------------------------------------------------------------------------- /image/dan/101.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/101.jpg -------------------------------------------------------------------------------- /image/dan/102.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/102.jpg -------------------------------------------------------------------------------- /image/dan/103.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/103.jpg -------------------------------------------------------------------------------- /image/dan/104.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/104.jpg -------------------------------------------------------------------------------- /image/dan/105.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/105.jpg -------------------------------------------------------------------------------- /image/dan/106.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/106.jpg -------------------------------------------------------------------------------- /image/dan/107.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/107.jpg -------------------------------------------------------------------------------- /image/dan/108.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/108.jpg -------------------------------------------------------------------------------- /image/dan/109.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/109.jpg -------------------------------------------------------------------------------- /image/dan/11.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/11.jpg -------------------------------------------------------------------------------- /image/dan/110.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/110.jpg -------------------------------------------------------------------------------- /image/dan/111.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/111.jpg -------------------------------------------------------------------------------- /image/dan/112.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/112.jpg -------------------------------------------------------------------------------- /image/dan/113.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/113.jpg -------------------------------------------------------------------------------- /image/dan/114.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/114.jpg -------------------------------------------------------------------------------- /image/dan/115.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/115.jpg -------------------------------------------------------------------------------- /image/dan/116.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/116.jpg -------------------------------------------------------------------------------- /image/dan/117.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/117.jpg -------------------------------------------------------------------------------- /image/dan/118.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/118.jpg -------------------------------------------------------------------------------- /image/dan/119.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/119.jpg -------------------------------------------------------------------------------- /image/dan/12.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/12.jpg -------------------------------------------------------------------------------- /image/dan/120.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/120.jpg -------------------------------------------------------------------------------- /image/dan/121.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/121.jpg -------------------------------------------------------------------------------- /image/dan/122.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/122.jpg -------------------------------------------------------------------------------- /image/dan/123.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/123.jpg -------------------------------------------------------------------------------- /image/dan/124.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/124.jpg -------------------------------------------------------------------------------- /image/dan/125.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/125.jpg -------------------------------------------------------------------------------- /image/dan/126.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/126.jpg -------------------------------------------------------------------------------- /image/dan/127.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/127.jpg -------------------------------------------------------------------------------- /image/dan/128.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/128.jpg -------------------------------------------------------------------------------- /image/dan/129.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/129.jpg -------------------------------------------------------------------------------- /image/dan/13.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/13.jpg -------------------------------------------------------------------------------- /image/dan/130.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/130.jpg -------------------------------------------------------------------------------- /image/dan/131.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/131.jpg -------------------------------------------------------------------------------- /image/dan/132.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/132.jpg -------------------------------------------------------------------------------- /image/dan/133.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/133.jpg -------------------------------------------------------------------------------- /image/dan/134.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/134.jpg -------------------------------------------------------------------------------- /image/dan/135.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/135.jpg -------------------------------------------------------------------------------- /image/dan/136.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/136.jpg -------------------------------------------------------------------------------- /image/dan/137.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/137.jpg -------------------------------------------------------------------------------- /image/dan/138.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/138.jpg -------------------------------------------------------------------------------- /image/dan/139.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/139.jpg -------------------------------------------------------------------------------- /image/dan/14.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/14.jpg -------------------------------------------------------------------------------- /image/dan/140.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/140.jpg -------------------------------------------------------------------------------- /image/dan/141.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/141.jpg -------------------------------------------------------------------------------- /image/dan/142.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/142.jpg -------------------------------------------------------------------------------- /image/dan/143.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/143.jpg -------------------------------------------------------------------------------- /image/dan/144.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/144.jpg -------------------------------------------------------------------------------- /image/dan/145.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/145.jpg -------------------------------------------------------------------------------- /image/dan/146.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/146.jpg -------------------------------------------------------------------------------- /image/dan/147.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/147.jpg -------------------------------------------------------------------------------- /image/dan/148.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/148.jpg -------------------------------------------------------------------------------- /image/dan/149.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/149.jpg -------------------------------------------------------------------------------- /image/dan/15.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/15.jpg -------------------------------------------------------------------------------- /image/dan/150.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/150.jpg -------------------------------------------------------------------------------- /image/dan/151.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/151.jpg -------------------------------------------------------------------------------- /image/dan/152.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/152.jpg -------------------------------------------------------------------------------- /image/dan/16.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/16.jpg -------------------------------------------------------------------------------- /image/dan/17.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/17.jpg -------------------------------------------------------------------------------- /image/dan/18.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/18.jpg -------------------------------------------------------------------------------- /image/dan/19.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/19.jpg -------------------------------------------------------------------------------- /image/dan/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/2.jpg -------------------------------------------------------------------------------- /image/dan/20.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/20.jpg -------------------------------------------------------------------------------- /image/dan/21.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/21.jpg -------------------------------------------------------------------------------- /image/dan/22.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/22.jpg -------------------------------------------------------------------------------- /image/dan/23.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/23.jpg -------------------------------------------------------------------------------- /image/dan/24.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/24.jpg -------------------------------------------------------------------------------- /image/dan/25.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/25.jpg -------------------------------------------------------------------------------- /image/dan/26.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/26.jpg -------------------------------------------------------------------------------- /image/dan/27.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/27.jpg -------------------------------------------------------------------------------- /image/dan/28.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/28.jpg -------------------------------------------------------------------------------- /image/dan/29.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/29.jpg -------------------------------------------------------------------------------- /image/dan/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/3.jpg -------------------------------------------------------------------------------- /image/dan/30.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/30.jpg -------------------------------------------------------------------------------- /image/dan/31.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/31.jpg -------------------------------------------------------------------------------- /image/dan/32.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/32.jpg -------------------------------------------------------------------------------- /image/dan/33.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/33.jpg -------------------------------------------------------------------------------- /image/dan/34.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/34.jpg -------------------------------------------------------------------------------- /image/dan/35.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/35.jpg -------------------------------------------------------------------------------- /image/dan/36.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/36.jpg -------------------------------------------------------------------------------- /image/dan/37.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/37.jpg -------------------------------------------------------------------------------- /image/dan/38.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/38.jpg -------------------------------------------------------------------------------- /image/dan/39.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/39.jpg -------------------------------------------------------------------------------- /image/dan/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/4.jpg -------------------------------------------------------------------------------- /image/dan/40.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/40.jpg -------------------------------------------------------------------------------- /image/dan/41.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/41.jpg -------------------------------------------------------------------------------- /image/dan/42.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/42.jpg -------------------------------------------------------------------------------- /image/dan/43.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/43.jpg -------------------------------------------------------------------------------- /image/dan/44.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/44.jpg -------------------------------------------------------------------------------- /image/dan/45.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/45.jpg -------------------------------------------------------------------------------- /image/dan/46.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/46.jpg -------------------------------------------------------------------------------- /image/dan/47.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/47.jpg -------------------------------------------------------------------------------- /image/dan/48.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/48.jpg -------------------------------------------------------------------------------- /image/dan/49.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/49.jpg -------------------------------------------------------------------------------- /image/dan/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/5.jpg -------------------------------------------------------------------------------- /image/dan/50.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/50.jpg -------------------------------------------------------------------------------- /image/dan/51.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/51.jpg -------------------------------------------------------------------------------- /image/dan/52.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/52.jpg -------------------------------------------------------------------------------- /image/dan/53.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/53.jpg -------------------------------------------------------------------------------- /image/dan/54.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/54.jpg -------------------------------------------------------------------------------- /image/dan/55.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/55.jpg -------------------------------------------------------------------------------- /image/dan/56.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/56.jpg -------------------------------------------------------------------------------- /image/dan/57.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/57.jpg -------------------------------------------------------------------------------- /image/dan/58.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/58.jpg -------------------------------------------------------------------------------- /image/dan/59.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/59.jpg -------------------------------------------------------------------------------- /image/dan/6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/6.jpg -------------------------------------------------------------------------------- /image/dan/60.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/60.jpg -------------------------------------------------------------------------------- /image/dan/61.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/61.jpg -------------------------------------------------------------------------------- /image/dan/62.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/62.jpg -------------------------------------------------------------------------------- /image/dan/63.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/63.jpg -------------------------------------------------------------------------------- /image/dan/64.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/64.jpg -------------------------------------------------------------------------------- /image/dan/65.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/65.jpg -------------------------------------------------------------------------------- /image/dan/66.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/66.jpg -------------------------------------------------------------------------------- /image/dan/67.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/67.jpg -------------------------------------------------------------------------------- /image/dan/68.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/68.jpg -------------------------------------------------------------------------------- /image/dan/69.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/69.jpg -------------------------------------------------------------------------------- /image/dan/7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/7.jpg -------------------------------------------------------------------------------- /image/dan/70.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/70.jpg -------------------------------------------------------------------------------- /image/dan/71.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/71.jpg -------------------------------------------------------------------------------- /image/dan/72.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/72.jpg -------------------------------------------------------------------------------- /image/dan/73.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/73.jpg -------------------------------------------------------------------------------- /image/dan/74.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/74.jpg -------------------------------------------------------------------------------- /image/dan/75.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/75.jpg -------------------------------------------------------------------------------- /image/dan/76.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/76.jpg -------------------------------------------------------------------------------- /image/dan/77.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/77.jpg -------------------------------------------------------------------------------- /image/dan/78.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/78.jpg -------------------------------------------------------------------------------- /image/dan/79.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/79.jpg -------------------------------------------------------------------------------- /image/dan/8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/8.jpg -------------------------------------------------------------------------------- /image/dan/80.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/80.jpg -------------------------------------------------------------------------------- /image/dan/81.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/81.jpg -------------------------------------------------------------------------------- /image/dan/82.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/82.jpg -------------------------------------------------------------------------------- /image/dan/83.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/83.jpg -------------------------------------------------------------------------------- /image/dan/84.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/84.jpg -------------------------------------------------------------------------------- /image/dan/85.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/85.jpg -------------------------------------------------------------------------------- /image/dan/86.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/86.jpg -------------------------------------------------------------------------------- /image/dan/87.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/87.jpg -------------------------------------------------------------------------------- /image/dan/88.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/88.jpg -------------------------------------------------------------------------------- /image/dan/89.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/89.jpg -------------------------------------------------------------------------------- /image/dan/9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/9.jpg -------------------------------------------------------------------------------- /image/dan/90.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/90.jpg -------------------------------------------------------------------------------- /image/dan/91.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/91.jpg -------------------------------------------------------------------------------- /image/dan/92.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/92.jpg -------------------------------------------------------------------------------- /image/dan/93.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/93.jpg -------------------------------------------------------------------------------- /image/dan/94.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/94.jpg -------------------------------------------------------------------------------- /image/dan/95.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/95.jpg -------------------------------------------------------------------------------- /image/dan/96.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/96.jpg -------------------------------------------------------------------------------- /image/dan/97.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/97.jpg -------------------------------------------------------------------------------- /image/dan/98.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/98.jpg -------------------------------------------------------------------------------- /image/dan/99.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/programmer-has-no-girlfriend/meidan/08faede7d9b7572f8c99d265203c190f2daee2bb/image/dan/99.jpg -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Hello World! 8 | 9 | 10 | -------------------------------------------------------------------------------- /js/AudioObject.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * 4 | * AudioObject 5 | * 6 | * - 3d spatialized sound with Doppler-shift effect 7 | * 8 | * - uses Audio API (currently supported in WebKit-based browsers) 9 | * https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html 10 | * 11 | * - based on Doppler effect demo from Chromium 12 | * http://chromium.googlecode.com/svn/trunk/samples/audio/doppler.html 13 | * 14 | * - parameters 15 | * 16 | * - listener 17 | * dopplerFactor // A constant used to determine the amount of pitch shift to use when rendering a doppler effect. 18 | * speedOfSound // The speed of sound used for calculating doppler shift. The default value is 343.3 meters / second. 19 | * 20 | * - panner 21 | * refDistance // A reference distance for reducing volume as source move further from the listener. 22 | * maxDistance // The maximum distance between source and listener, after which the volume will not be reduced any further. 23 | * rolloffFactor // Describes how quickly the volume is reduced as source moves away from listener. 24 | * coneInnerAngle // An angle inside of which there will be no volume reduction. 25 | * coneOuterAngle // An angle outside of which the volume will be reduced to a constant value of coneOuterGain. 26 | * coneOuterGain // Amount of volume reduction outside of the coneOuterAngle. 27 | */ 28 | 29 | THREE.AudioObject = function ( url, volume, playbackRate, loop ) { 30 | 31 | THREE.Object3D.call( this ); 32 | 33 | if ( playbackRate === undefined ) playbackRate = 1; 34 | if ( volume === undefined ) volume = 1; 35 | if ( loop === undefined ) loop = true; 36 | 37 | if ( ! this.context ) { 38 | 39 | try { 40 | 41 | THREE.AudioObject.prototype.context = new webkitAudioContext(); 42 | 43 | } catch( error ) { 44 | 45 | console.warn( "THREE.AudioObject: webkitAudioContext not found" ); 46 | return this; 47 | 48 | } 49 | 50 | } 51 | 52 | this.directionalSource = false; 53 | 54 | this.listener = this.context.listener; 55 | this.panner = this.context.createPanner(); 56 | this.source = this.context.createBufferSource(); 57 | 58 | this.masterGainNode = this.context.createGainNode(); 59 | this.dryGainNode = this.context.createGainNode(); 60 | 61 | // Setup initial gains 62 | 63 | this.masterGainNode.gain.value = volume; 64 | this.dryGainNode.gain.value = 3.0; 65 | 66 | // Connect dry mix 67 | 68 | this.source.connect( this.panner ); 69 | this.panner.connect( this.dryGainNode ); 70 | this.dryGainNode.connect( this.masterGainNode ); 71 | 72 | // Connect master gain 73 | 74 | this.masterGainNode.connect( this.context.destination ); 75 | 76 | // Set source parameters and load sound 77 | 78 | this.source.playbackRate.value = playbackRate; 79 | this.source.loop = loop; 80 | 81 | loadBufferAndPlay( url ); 82 | 83 | // private properties 84 | 85 | var soundPosition = new THREE.Vector3(), 86 | cameraPosition = new THREE.Vector3(), 87 | oldSoundPosition = new THREE.Vector3(), 88 | oldCameraPosition = new THREE.Vector3(), 89 | 90 | soundDelta = new THREE.Vector3(), 91 | cameraDelta = new THREE.Vector3(), 92 | 93 | soundFront = new THREE.Vector3(), 94 | cameraFront = new THREE.Vector3(), 95 | soundUp = new THREE.Vector3(), 96 | cameraUp = new THREE.Vector3(); 97 | 98 | var _this = this; 99 | 100 | // API 101 | 102 | this.setVolume = function ( volume ) { 103 | 104 | this.masterGainNode.gain.value = volume; 105 | 106 | }; 107 | 108 | this.update = function ( camera ) { 109 | 110 | oldSoundPosition.copy( soundPosition ); 111 | oldCameraPosition.copy( cameraPosition ); 112 | 113 | soundPosition.getPositionFromMatrix( this.matrixWorld ); 114 | cameraPosition.getPositionFromMatrix( camera.matrixWorld ); 115 | 116 | soundDelta.subVectors( soundPosition, oldSoundPosition ); 117 | cameraDelta.subVectors( cameraPosition, oldCameraPosition ); 118 | 119 | cameraUp.copy( camera.up ); 120 | 121 | cameraFront.set( 0, 0, -1 ); 122 | cameraFront.transformDirection( camera.matrixWorld ); 123 | 124 | this.listener.setPosition( cameraPosition.x, cameraPosition.y, cameraPosition.z ); 125 | this.listener.setVelocity( cameraDelta.x, cameraDelta.y, cameraDelta.z ); 126 | this.listener.setOrientation( cameraFront.x, cameraFront.y, cameraFront.z, cameraUp.x, cameraUp.y, cameraUp.z ); 127 | 128 | this.panner.setPosition( soundPosition.x, soundPosition.y, soundPosition.z ); 129 | this.panner.setVelocity( soundDelta.x, soundDelta.y, soundDelta.z ); 130 | 131 | if ( this.directionalSource ) { 132 | 133 | soundFront.set( 0, 0, -1 ); 134 | soundFront.transformDirection( this.matrixWorld ); 135 | 136 | soundUp.copy( this.up ); 137 | this.panner.setOrientation( soundFront.x, soundFront.y, soundFront.z, soundUp.x, soundUp.y, soundUp.z ); 138 | 139 | } 140 | 141 | 142 | }; 143 | 144 | function loadBufferAndPlay( url ) { 145 | 146 | // Load asynchronously 147 | 148 | var request = new XMLHttpRequest(); 149 | request.open( "GET", url, true ); 150 | request.responseType = "arraybuffer"; 151 | 152 | request.onload = function() { 153 | 154 | _this.source.buffer = _this.context.createBuffer( request.response, true ); 155 | _this.source.noteOn( 0 ); 156 | 157 | } 158 | 159 | request.send(); 160 | 161 | } 162 | 163 | }; 164 | 165 | THREE.AudioObject.prototype = Object.create( THREE.Object3D.prototype ); 166 | 167 | THREE.AudioObject.prototype.context = null; 168 | THREE.AudioObject.prototype.type = null; 169 | 170 | -------------------------------------------------------------------------------- /js/Cloth.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Cloth Simulation using a relaxed constrains solver 3 | */ 4 | 5 | // Suggested Readings 6 | 7 | // Advanced Character Physics by Thomas Jakobsen Character 8 | // http://freespace.virgin.net/hugo.elias/models/m_cloth.htm 9 | // http://en.wikipedia.org/wiki/Cloth_modeling 10 | // http://cg.alexandra.dk/tag/spring-mass-system/ 11 | // Real-time Cloth Animation http://www.darwin3d.com/gamedev/articles/col0599.pdf 12 | 13 | var DAMPING = 0.03; 14 | var DRAG = 1 - DAMPING; 15 | var MASS = .1; 16 | var restDistance = 25; 17 | 18 | 19 | var xSegs = 10; // 20 | var ySegs = 10; // 21 | 22 | var clothFunction = plane(restDistance * xSegs, restDistance * ySegs); 23 | 24 | var cloth = new Cloth(xSegs, ySegs); 25 | 26 | var GRAVITY = 981 * 1.4; // 27 | var gravity = new THREE.Vector3( 0, -GRAVITY, 0 ).multiplyScalar(MASS); 28 | 29 | 30 | var TIMESTEP = 18 / 1000; 31 | var TIMESTEP_SQ = TIMESTEP * TIMESTEP; 32 | 33 | var pins = []; 34 | 35 | 36 | var wind = true; 37 | var windStrength = 2; 38 | var windForce = new THREE.Vector3(0,0,0); 39 | 40 | var ballPosition = new THREE.Vector3(0, -45, 0); 41 | var ballSize = 60; //40 42 | 43 | var tmpForce = new THREE.Vector3(); 44 | 45 | var lastTime; 46 | 47 | 48 | function plane(width, height) { 49 | 50 | return function(u, v) { 51 | var x = (u-0.5) * width; 52 | var y = (v+0.5) * height; 53 | var z = 0; 54 | 55 | return new THREE.Vector3(x, y, z); 56 | }; 57 | } 58 | 59 | function Particle(x, y, z, mass) { 60 | this.position = clothFunction(x, y); // position 61 | this.previous = clothFunction(x, y); // previous 62 | this.original = clothFunction(x, y); 63 | this.a = new THREE.Vector3(0, 0, 0); // acceleration 64 | this.mass = mass; 65 | this.invMass = 1 / mass; 66 | this.tmp = new THREE.Vector3(); 67 | this.tmp2 = new THREE.Vector3(); 68 | } 69 | 70 | // Force -> Acceleration 71 | Particle.prototype.addForce = function(force) { 72 | this.a.add( 73 | this.tmp2.copy(force).multiplyScalar(this.invMass) 74 | ); 75 | }; 76 | 77 | 78 | // Performs verlet integration 79 | Particle.prototype.integrate = function(timesq) { 80 | var newPos = this.tmp.subVectors(this.position, this.previous); 81 | newPos.multiplyScalar(DRAG).add(this.position); 82 | newPos.add(this.a.multiplyScalar(timesq)); 83 | 84 | this.tmp = this.previous; 85 | this.previous = this.position; 86 | this.position = newPos; 87 | 88 | this.a.set(0, 0, 0); 89 | } 90 | 91 | 92 | var diff = new THREE.Vector3(); 93 | 94 | function satisifyConstrains(p1, p2, distance) { 95 | diff.subVectors(p2.position, p1.position); 96 | var currentDist = diff.length(); 97 | if (currentDist==0) return; // prevents division by 0 98 | var correction = diff.multiplyScalar(1 - distance/currentDist); 99 | var correctionHalf = correction.multiplyScalar(0.5); 100 | p1.position.add(correctionHalf); 101 | p2.position.sub(correctionHalf); 102 | } 103 | 104 | 105 | function Cloth(w, h) { 106 | w = w || 10; 107 | h = h || 10; 108 | this.w = w; 109 | this.h = h; 110 | 111 | var particles = []; 112 | var constrains = []; 113 | 114 | var u, v; 115 | 116 | // Create particles 117 | for (v=0;v<=h;v++) { 118 | for (u=0;u<=w;u++) { 119 | particles.push( 120 | new Particle(u/w, v/h, 0, MASS) 121 | ); 122 | } 123 | } 124 | 125 | // Structural 126 | 127 | for (v=0;vWebGL.
', 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/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/MD2Character.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | */ 4 | 5 | THREE.MD2Character = function () { 6 | 7 | var scope = this; 8 | 9 | this.scale = 1; 10 | this.animationFPS = 6; 11 | 12 | this.root = new THREE.Object3D(); 13 | 14 | this.meshBody = null; 15 | this.meshWeapon = null; 16 | 17 | this.skinsBody = []; 18 | this.skinsWeapon = []; 19 | 20 | this.weapons = []; 21 | 22 | this.activeAnimation = null; 23 | 24 | this.onLoadComplete = function () {}; 25 | 26 | this.loadCounter = 0; 27 | 28 | this.loadParts = function ( config ) { 29 | 30 | this.loadCounter = config.weapons.length * 2 + config.skins.length + 1; 31 | 32 | var weaponsTextures = [] 33 | for ( var i = 0; i < config.weapons.length; i ++ ) weaponsTextures[ i ] = config.weapons[ i ][ 1 ]; 34 | 35 | // SKINS 36 | 37 | this.skinsBody = loadTextures( config.baseUrl + "skins/", config.skins ); 38 | this.skinsWeapon = loadTextures( config.baseUrl + "skins/", weaponsTextures ); 39 | 40 | // BODY 41 | 42 | var loader = new THREE.JSONLoader(); 43 | 44 | loader.load( config.baseUrl + config.body, function( geo ) { 45 | 46 | geo.computeBoundingBox(); 47 | scope.root.position.y = - scope.scale * geo.boundingBox.min.y; 48 | 49 | var mesh = createPart( geo, scope.skinsBody[ 0 ] ); 50 | mesh.scale.set( scope.scale, scope.scale, scope.scale ); 51 | 52 | scope.root.add( mesh ); 53 | 54 | scope.meshBody = mesh; 55 | scope.activeAnimation = geo.firstAnimation; 56 | 57 | checkLoadingComplete(); 58 | 59 | } ); 60 | 61 | // WEAPONS 62 | 63 | var generateCallback = function ( index, name ) { 64 | 65 | return function( geo ) { 66 | 67 | var mesh = createPart( geo, scope.skinsWeapon[ index ] ); 68 | mesh.scale.set( scope.scale, scope.scale, scope.scale ); 69 | mesh.visible = false; 70 | 71 | mesh.name = name; 72 | 73 | scope.root.add( mesh ); 74 | 75 | scope.weapons[ index ] = mesh; 76 | scope.meshWeapon = mesh; 77 | 78 | checkLoadingComplete(); 79 | 80 | } 81 | 82 | } 83 | 84 | for ( var i = 0; i < config.weapons.length; i ++ ) { 85 | 86 | loader.load( config.baseUrl + config.weapons[ i ][ 0 ], generateCallback( i, config.weapons[ i ][ 0 ] ) ); 87 | 88 | } 89 | 90 | }; 91 | 92 | this.setPlaybackRate = function ( rate ) { 93 | 94 | if ( this.meshBody ) this.meshBody.duration = this.meshBody.baseDuration / rate; 95 | if ( this.meshWeapon ) this.meshWeapon.duration = this.meshWeapon.baseDuration / rate; 96 | 97 | }; 98 | 99 | this.setWireframe = function ( wireframeEnabled ) { 100 | 101 | if ( wireframeEnabled ) { 102 | 103 | if ( this.meshBody ) this.meshBody.material = this.meshBody.materialWireframe; 104 | if ( this.meshWeapon ) this.meshWeapon.material = this.meshWeapon.materialWireframe; 105 | 106 | } else { 107 | 108 | if ( this.meshBody ) this.meshBody.material = this.meshBody.materialTexture; 109 | if ( this.meshWeapon ) this.meshWeapon.material = this.meshWeapon.materialTexture; 110 | 111 | } 112 | 113 | }; 114 | 115 | this.setSkin = function( index ) { 116 | 117 | if ( this.meshBody && this.meshBody.material.wireframe === false ) { 118 | 119 | this.meshBody.material.map = this.skinsBody[ index ]; 120 | 121 | } 122 | 123 | }; 124 | 125 | this.setWeapon = function ( index ) { 126 | 127 | for ( var i = 0; i < this.weapons.length; i ++ ) this.weapons[ i ].visible = false; 128 | 129 | var activeWeapon = this.weapons[ index ]; 130 | 131 | if ( activeWeapon ) { 132 | 133 | activeWeapon.visible = true; 134 | this.meshWeapon = activeWeapon; 135 | 136 | activeWeapon.playAnimation( this.activeAnimation, this.animationFPS ); 137 | 138 | this.meshWeapon.baseDuration = this.meshWeapon.duration; 139 | 140 | this.meshWeapon.time = this.meshBody.time; 141 | this.meshWeapon.duration = this.meshBody.duration; 142 | 143 | } 144 | 145 | }; 146 | 147 | this.setAnimation = function ( animationName ) { 148 | 149 | if ( this.meshBody ) { 150 | 151 | this.meshBody.playAnimation( animationName, this.animationFPS ); 152 | this.meshBody.baseDuration = this.meshBody.duration; 153 | 154 | } 155 | 156 | if ( this.meshWeapon ) { 157 | 158 | this.meshWeapon.playAnimation( animationName, this.animationFPS ); 159 | this.meshWeapon.baseDuration = this.meshWeapon.duration; 160 | this.meshWeapon.time = this.meshBody.time; 161 | 162 | } 163 | 164 | this.activeAnimation = animationName; 165 | 166 | }; 167 | 168 | this.update = function ( delta ) { 169 | 170 | if ( this.meshBody ) { 171 | 172 | this.meshBody.updateAnimation( 1000 * delta ); 173 | 174 | } 175 | 176 | if ( this.meshWeapon ) { 177 | 178 | this.meshWeapon.updateAnimation( 1000 * delta ); 179 | 180 | } 181 | 182 | }; 183 | 184 | function loadTextures( baseUrl, textureUrls ) { 185 | 186 | var mapping = new THREE.UVMapping(); 187 | var textures = []; 188 | 189 | for ( var i = 0; i < textureUrls.length; i ++ ) { 190 | 191 | textures[ i ] = THREE.ImageUtils.loadTexture( baseUrl + textureUrls[ i ], mapping, checkLoadingComplete ); 192 | textures[ i ].name = textureUrls[ i ]; 193 | 194 | } 195 | 196 | return textures; 197 | 198 | }; 199 | 200 | function createPart( geometry, skinMap ) { 201 | 202 | geometry.computeMorphNormals(); 203 | 204 | var whiteMap = THREE.ImageUtils.generateDataTexture( 1, 1, new THREE.Color( 0xffffff ) ); 205 | var materialWireframe = new THREE.MeshPhongMaterial( { color: 0xffaa00, specular: 0x111111, shininess: 50, wireframe: true, shading: THREE.SmoothShading, map: whiteMap, morphTargets: true, morphNormals: true, metal: false } ); 206 | 207 | var materialTexture = new THREE.MeshPhongMaterial( { color: 0xffffff, specular: 0x111111, shininess: 50, wireframe: false, shading: THREE.SmoothShading, map: skinMap, morphTargets: true, morphNormals: true, metal: false } ); 208 | materialTexture.wrapAround = true; 209 | 210 | // 211 | 212 | var mesh = new THREE.MorphAnimMesh( geometry, materialTexture ); 213 | mesh.rotation.y = -Math.PI/2; 214 | 215 | mesh.castShadow = true; 216 | mesh.receiveShadow = true; 217 | 218 | // 219 | 220 | mesh.materialTexture = materialTexture; 221 | mesh.materialWireframe = materialWireframe; 222 | 223 | // 224 | 225 | mesh.parseAnimations(); 226 | 227 | mesh.playAnimation( geometry.firstAnimation, scope.animationFPS ); 228 | mesh.baseDuration = mesh.duration; 229 | 230 | return mesh; 231 | 232 | }; 233 | 234 | function checkLoadingComplete() { 235 | 236 | scope.loadCounter -= 1; 237 | 238 | if ( scope.loadCounter === 0 ) scope.onLoadComplete(); 239 | 240 | }; 241 | 242 | }; 243 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /js/ParametricGeometries.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @author zz85 3 | * 4 | * Experimenting of primitive geometry creation using Surface Parametric equations 5 | * 6 | */ 7 | 8 | 9 | THREE.ParametricGeometries = { 10 | 11 | klein: function (v, u) { 12 | u *= Math.PI; 13 | v *= 2 * Math.PI; 14 | 15 | u = u * 2; 16 | var x, y, z; 17 | if (u < Math.PI) { 18 | x = 3 * Math.cos(u) * (1 + Math.sin(u)) + (2 * (1 - Math.cos(u) / 2)) * Math.cos(u) * Math.cos(v); 19 | z = -8 * Math.sin(u) - 2 * (1 - Math.cos(u) / 2) * Math.sin(u) * Math.cos(v); 20 | } else { 21 | x = 3 * Math.cos(u) * (1 + Math.sin(u)) + (2 * (1 - Math.cos(u) / 2)) * Math.cos(v + Math.PI); 22 | z = -8 * Math.sin(u); 23 | } 24 | 25 | y = -2 * (1 - Math.cos(u) / 2) * Math.sin(v); 26 | 27 | return new THREE.Vector3(x, y, z); 28 | }, 29 | 30 | plane: function (width, height) { 31 | 32 | return function(u, v) { 33 | var x = u * width; 34 | var y = 0; 35 | var z = v * height; 36 | 37 | return new THREE.Vector3(x, y, z); 38 | }; 39 | }, 40 | 41 | mobius: function(u, t) { 42 | 43 | // flat mobius strip 44 | // http://www.wolframalpha.com/input/?i=M%C3%B6bius+strip+parametric+equations&lk=1&a=ClashPrefs_*Surface.MoebiusStrip.SurfaceProperty.ParametricEquations- 45 | u = u - 0.5; 46 | var v = 2 * Math.PI * t; 47 | 48 | var x, y, z; 49 | 50 | var a = 2; 51 | x = Math.cos(v) * (a + u * Math.cos(v/2)); 52 | y = Math.sin(v) * (a + u * Math.cos(v/2)); 53 | z = u * Math.sin(v/2); 54 | return new THREE.Vector3(x, y, z); 55 | 56 | }, 57 | 58 | mobius3d: function(u, t) { 59 | 60 | // volumetric mobius strip 61 | u *= Math.PI; 62 | t *= 2 * Math.PI; 63 | 64 | u = u * 2; 65 | var phi = u / 2; 66 | var major = 2.25, a = 0.125, b = 0.65; 67 | var x, y, z; 68 | x = a * Math.cos(t) * Math.cos(phi) - b * Math.sin(t) * Math.sin(phi); 69 | z = a * Math.cos(t) * Math.sin(phi) + b * Math.sin(t) * Math.cos(phi); 70 | y = (major + x) * Math.sin(u); 71 | x = (major + x) * Math.cos(u); 72 | return new THREE.Vector3(x, y, z); 73 | } 74 | 75 | }; 76 | 77 | 78 | /********************************************* 79 | * 80 | * Parametric Replacement for TubeGeometry 81 | * 82 | *********************************************/ 83 | 84 | THREE.ParametricGeometries.TubeGeometry = function(path, segments, radius, segmentsRadius, closed, debug) { 85 | 86 | this.path = path; 87 | this.segments = segments || 64; 88 | this.radius = radius || 1; 89 | this.segmentsRadius = segmentsRadius || 8; 90 | this.closed = closed || false; 91 | if (debug) this.debug = new THREE.Object3D(); 92 | 93 | 94 | var scope = this, 95 | 96 | tangent, normal, binormal, 97 | 98 | numpoints = this.segments + 1, 99 | 100 | x, y, z, tx, ty, tz, u, v, 101 | 102 | cx, cy, pos, pos2 = new THREE.Vector3(), 103 | i, j, ip, jp, a, b, c, d, uva, uvb, uvc, uvd; 104 | 105 | var frames = new THREE.TubeGeometry.FrenetFrames(path, segments, closed), 106 | tangents = frames.tangents, 107 | normals = frames.normals, 108 | binormals = frames.binormals; 109 | 110 | // proxy internals 111 | this.tangents = tangents; 112 | this.normals = normals; 113 | this.binormals = binormals; 114 | 115 | 116 | 117 | var ParametricTube = function(u, v) { 118 | v *= 2 * Math.PI; 119 | 120 | i = u * (numpoints - 1); 121 | i = Math.floor(i); 122 | 123 | pos = path.getPointAt(u); 124 | 125 | tangent = tangents[i]; 126 | normal = normals[i]; 127 | binormal = binormals[i]; 128 | 129 | if (scope.debug) { 130 | 131 | scope.debug.add(new THREE.ArrowHelper(tangent, pos, radius, 0x0000ff)); 132 | scope.debug.add(new THREE.ArrowHelper(normal, pos, radius, 0xff0000)); 133 | scope.debug.add(new THREE.ArrowHelper(binormal, pos, radius, 0x00ff00)); 134 | 135 | } 136 | 137 | cx = -scope.radius * Math.cos(v); // TODO: Hack: Negating it so it faces outside. 138 | cy = scope.radius * Math.sin(v); 139 | 140 | pos2.copy(pos); 141 | pos2.x += cx * normal.x + cy * binormal.x; 142 | pos2.y += cx * normal.y + cy * binormal.y; 143 | pos2.z += cx * normal.z + cy * binormal.z; 144 | 145 | return pos2.clone(); 146 | }; 147 | 148 | THREE.ParametricGeometry.call(this, ParametricTube, segments, segmentsRadius); 149 | 150 | }; 151 | 152 | THREE.ParametricGeometries.TubeGeometry.prototype = Object.create( THREE.Geometry.prototype ); 153 | 154 | 155 | /********************************************* 156 | * 157 | * Parametric Replacement for TorusKnotGeometry 158 | * 159 | *********************************************/ 160 | THREE.ParametricGeometries.TorusKnotGeometry = function ( radius, tube, segmentsR, segmentsT, p, q, heightScale ) { 161 | 162 | var scope = this; 163 | 164 | this.radius = radius || 200; 165 | this.tube = tube || 40; 166 | this.segmentsR = segmentsR || 64; 167 | this.segmentsT = segmentsT || 8; 168 | this.p = p || 2; 169 | this.q = q || 3; 170 | this.heightScale = heightScale || 1; 171 | 172 | 173 | var TorusKnotCurve = THREE.Curve.create( 174 | 175 | function() { 176 | }, 177 | 178 | function(t) { 179 | 180 | t *= Math.PI * 2; 181 | 182 | var r = 0.5; 183 | 184 | var tx = (1 + r * Math.cos(q * t)) * Math.cos(p * t), 185 | ty = (1 + r * Math.cos(q * t)) * Math.sin(p * t), 186 | tz = r * Math.sin(q * t); 187 | 188 | return new THREE.Vector3(tx, ty * heightScale, tz).multiplyScalar(radius); 189 | 190 | } 191 | 192 | ); 193 | var segments = segmentsR; 194 | var radiusSegments = segmentsT; 195 | var extrudePath = new TorusKnotCurve(); 196 | 197 | THREE.ParametricGeometries.TubeGeometry.call( this, extrudePath, segments, tube, radiusSegments, true, false ); 198 | 199 | 200 | }; 201 | 202 | THREE.ParametricGeometries.TorusKnotGeometry.prototype = Object.create( THREE.Geometry.prototype ); 203 | 204 | 205 | /********************************************* 206 | * 207 | * Parametric Replacement for SphereGeometry 208 | * 209 | *********************************************/ 210 | THREE.ParametricGeometries.SphereGeometry = function(size, u, v) { 211 | 212 | function sphere(u, v) { 213 | u *= Math.PI; 214 | v *= 2 * Math.PI; 215 | 216 | var x = size * Math.sin(u) * Math.cos(v); 217 | var y = size * Math.sin(u) * Math.sin(v); 218 | var z = size * Math.cos(u); 219 | 220 | 221 | return new THREE.Vector3(x, y, z); 222 | } 223 | 224 | THREE.ParametricGeometry.call(this, sphere, u, v, !true); 225 | 226 | }; 227 | 228 | THREE.ParametricGeometries.SphereGeometry.prototype = Object.create( THREE.Geometry.prototype ); 229 | 230 | 231 | /********************************************* 232 | * 233 | * Parametric Replacement for PlaneGeometry 234 | * 235 | *********************************************/ 236 | 237 | THREE.ParametricGeometries.PlaneGeometry = function(width, depth, segmentsWidth, segmentsDepth) { 238 | 239 | function plane(u, v) { 240 | 241 | var x = u * width; 242 | var y = 0; 243 | var z = v * depth; 244 | 245 | return new THREE.Vector3(x, y, z); 246 | } 247 | 248 | THREE.ParametricGeometry.call(this, plane, segmentsWidth, segmentsDepth); 249 | 250 | }; 251 | 252 | THREE.ParametricGeometries.PlaneGeometry.prototype = Object.create( THREE.Geometry.prototype ); 253 | -------------------------------------------------------------------------------- /js/UVsUtils.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @author gyuque / http://github.com/gyuque 3 | * 4 | * Cylinder Mapping for ExtrudeGeometry 5 | * 6 | */ 7 | 8 | THREE.UVsUtils = { 9 | 10 | }; 11 | 12 | THREE.UVsUtils.CylinderUVGenerator = function() { 13 | this.uRepeat = 1; 14 | this.targetGeometry = null; 15 | this.lengthCache = null; 16 | }; 17 | 18 | THREE.UVsUtils.CylinderUVGenerator.prototype = { 19 | generateTopUV: THREE.ExtrudeGeometry.WorldUVGenerator.generateTopUV, 20 | generateBottomUV: THREE.ExtrudeGeometry.WorldUVGenerator.generateBottomUV, 21 | 22 | generateSideWallUV: function( geometry, extrudedShape, wallContour, extrudeOptions, 23 | indexA, indexB, indexC, indexD, stepIndex, stepsLength, 24 | contourIndex1, contourIndex2 ) { 25 | // first call 26 | if (this.targetGeometry !== geometry) { 27 | this.prepare(geometry, wallContour); 28 | } 29 | 30 | // generate uv 31 | var u_list = this.lengthCache; 32 | var v1 = stepIndex / stepsLength; 33 | var v2 = ( stepIndex + 1 ) / stepsLength; 34 | 35 | var u1 = u_list[contourIndex1]; 36 | var u2 = u_list[contourIndex2]; 37 | if (u1 < u2) {u1 += 1.0;} 38 | 39 | u1 *= this.uRepeat; 40 | u2 *= this.uRepeat; 41 | return [ 42 | new THREE.Vector2( u1, v1 ), 43 | new THREE.Vector2( u2, v1 ), 44 | new THREE.Vector2( u2, v2 ), 45 | new THREE.Vector2( u1, v2 ) 46 | ]; 47 | }, 48 | 49 | prepare: function(geometry, wallContour) { 50 | var p1, p2; 51 | var u_list = []; 52 | var lengthSum = 0; 53 | var len = wallContour.length; 54 | for (var i = 0;i < len;i++) { 55 | p1 = wallContour[ i ]; 56 | p2 = wallContour[ (i+1) % len ]; 57 | 58 | var dx = p1.x - p2.x; 59 | var dy = p1.y - p2.y; 60 | var segmentLength = Math.sqrt(dx*dx + dy*dy); 61 | 62 | u_list.push(lengthSum); 63 | lengthSum += segmentLength; 64 | } 65 | 66 | this.normalizeArray(u_list, lengthSum); 67 | this.targetGeometry = geometry; 68 | this.lengthCache = u_list; 69 | }, 70 | 71 | normalizeArray: function(ls, v) { 72 | var len = ls.length; 73 | for (var i = 0;i < len;i++) { 74 | ls[i] /= v; 75 | } 76 | 77 | return ls; 78 | } 79 | }; 80 | 81 | 82 | 83 | /* 84 | * @author zz85 / http://github.com/zz85 85 | * @author WestLangley / http://github.com/WestLangley 86 | * 87 | * tool for "unwrapping" and debugging three.js 88 | * geometries UV mapping 89 | * 90 | * Sample usage: 91 | * document.body.appendChild( 92 | * THREE.UVsDebug( 93 | * new THREE.SphereGeometry(10,10,10,10)); 94 | * 95 | */ 96 | 97 | THREE.UVsDebug = function( geometry, size ) { 98 | 99 | // handles wrapping of uv.x > 1 only 100 | 101 | var abc = 'abcd'; 102 | 103 | var uv, u, ax, ay; 104 | var i, il, j, jl; 105 | var vnum; 106 | 107 | var a = new THREE.Vector2(); 108 | var b = new THREE.Vector2(); 109 | 110 | var faces = geometry.faces; 111 | var uvs = geometry.faceVertexUvs[ 0 ]; 112 | 113 | var canvas = document.createElement( 'canvas' ); 114 | var width = size || 1024; // power of 2 required for wrapping 115 | var height = size || 1024; 116 | canvas.width = width; 117 | canvas.height = height; 118 | 119 | var ctx = canvas.getContext( '2d' ); 120 | ctx.lineWidth = 2; 121 | ctx.strokeStyle = 'rgba( 0, 0, 0, 1.0 )'; 122 | ctx.textAlign = 'center'; 123 | 124 | // paint background white 125 | 126 | ctx.fillStyle = 'rgba( 255, 255, 255, 1.0 )'; 127 | ctx.fillRect( 0, 0, width, height ); 128 | 129 | for ( i = 0, il = uvs.length; i < il; i++ ) { 130 | 131 | uv = uvs[ i ]; 132 | 133 | // draw lines 134 | 135 | ctx.beginPath(); 136 | 137 | a.set( 0, 0 ); 138 | 139 | for ( j = 0, jl = uv.length; j < jl; j++ ) { 140 | 141 | u = uv[ j ]; 142 | 143 | a.x += u.x; 144 | a.y += u.y; 145 | 146 | if ( j == 0 ) { 147 | 148 | ctx.moveTo( u.x * width, ( 1 - u.y ) * height ); 149 | 150 | } else { 151 | 152 | ctx.lineTo( u.x * width, ( 1 - u.y ) * height ); 153 | 154 | } 155 | 156 | } 157 | 158 | ctx.closePath(); 159 | ctx.stroke(); 160 | 161 | a.divideScalar( jl ); 162 | 163 | // label the face number 164 | 165 | ctx.font = "12pt Arial bold"; 166 | ctx.fillStyle = 'rgba( 0, 0, 0, 1.0 )'; 167 | ctx.fillText( i, a.x * width, ( 1 - a.y ) * height ); 168 | 169 | if ( a.x > 0.95 ) { // wrap x // 0.95 is arbitrary 170 | 171 | ctx.fillText( i, ( a.x % 1 ) * width, ( 1 - a.y ) * height ); 172 | 173 | } 174 | 175 | ctx.font = "8pt Arial bold"; 176 | ctx.fillStyle = 'rgba( 0, 0, 0, 1.0 )'; 177 | 178 | // label uv edge orders 179 | 180 | for ( j = 0, jl = uv.length; j < jl; j++ ) { 181 | 182 | u = uv[ j ]; 183 | b.addVectors( a, u ).divideScalar( 2 ); 184 | 185 | vnum = faces[ i ][ abc[ j ] ]; 186 | ctx.fillText( abc[ j ] + vnum, b.x * width, ( 1 - b.y ) * height ); 187 | 188 | if ( b.x > 0.95 ) { // wrap x 189 | 190 | ctx.fillText( abc[ j ] + vnum, ( b.x % 1 ) * width, ( 1 - b.y ) * height ); 191 | 192 | } 193 | 194 | } 195 | 196 | } 197 | 198 | return canvas; 199 | 200 | } 201 | 202 | -------------------------------------------------------------------------------- /js/controls/EditorControls.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author qiao / https://github.com/qiao 3 | * @author mrdoob / http://mrdoob.com 4 | * @author alteredq / http://alteredqualia.com/ 5 | * @author WestLangley / http://github.com/WestLangley 6 | */ 7 | 8 | THREE.EditorControls = function ( object, domElement ) { 9 | 10 | domElement = ( domElement !== undefined ) ? domElement : document; 11 | 12 | // API 13 | 14 | this.enabled = true; 15 | 16 | // internals 17 | 18 | var scope = this; 19 | var vector = new THREE.Vector3(); 20 | 21 | var STATE = { NONE: -1, ROTATE: 0, ZOOM: 1, PAN: 2 }; 22 | var state = STATE.NONE; 23 | 24 | var center = new THREE.Vector3(); 25 | var normalMatrix = new THREE.Matrix3(); 26 | 27 | // events 28 | 29 | var changeEvent = { type: 'change' }; 30 | 31 | this.focus = function ( target ) { 32 | 33 | center.getPositionFromMatrix( target.matrixWorld ); 34 | object.lookAt( center ); 35 | 36 | scope.dispatchEvent( changeEvent ); 37 | 38 | }; 39 | 40 | this.pan = function ( distance ) { 41 | 42 | normalMatrix.getNormalMatrix( object.matrix ); 43 | 44 | distance.applyMatrix3( normalMatrix ); 45 | distance.multiplyScalar( vector.copy( center ).sub( object.position ).length() * 0.001 ); 46 | 47 | object.position.add( distance ); 48 | center.add( distance ); 49 | 50 | scope.dispatchEvent( changeEvent ); 51 | 52 | }; 53 | 54 | this.zoom = function ( distance ) { 55 | 56 | normalMatrix.getNormalMatrix( object.matrix ); 57 | 58 | distance.applyMatrix3( normalMatrix ); 59 | distance.multiplyScalar( vector.copy( center ).sub( object.position ).length() * 0.001 ); 60 | 61 | object.position.add( distance ); 62 | 63 | scope.dispatchEvent( changeEvent ); 64 | 65 | }; 66 | 67 | this.rotate = function ( delta ) { 68 | 69 | vector.copy( object.position ).sub( center ); 70 | 71 | var theta = Math.atan2( vector.x, vector.z ); 72 | var phi = Math.atan2( Math.sqrt( vector.x * vector.x + vector.z * vector.z ), vector.y ); 73 | 74 | theta += delta.x; 75 | phi += delta.y; 76 | 77 | var EPS = 0.000001; 78 | 79 | phi = Math.max( EPS, Math.min( Math.PI - EPS, phi ) ); 80 | 81 | var radius = vector.length(); 82 | 83 | vector.x = radius * Math.sin( phi ) * Math.sin( theta ); 84 | vector.y = radius * Math.cos( phi ); 85 | vector.z = radius * Math.sin( phi ) * Math.cos( theta ); 86 | 87 | object.position.copy( center ).add( vector ); 88 | 89 | object.lookAt( center ); 90 | 91 | scope.dispatchEvent( changeEvent ); 92 | 93 | }; 94 | 95 | // mouse 96 | 97 | function onMouseDown( event ) { 98 | 99 | if ( scope.enabled === false ) return; 100 | 101 | event.preventDefault(); 102 | 103 | if ( event.button === 0 ) { 104 | 105 | state = STATE.ROTATE; 106 | 107 | } else if ( event.button === 1 ) { 108 | 109 | state = STATE.ZOOM; 110 | 111 | } else if ( event.button === 2 ) { 112 | 113 | state = STATE.PAN; 114 | 115 | } 116 | 117 | document.addEventListener( 'mousemove', onMouseMove, false ); 118 | document.addEventListener( 'mouseup', onMouseUp, false ); 119 | 120 | } 121 | 122 | function onMouseMove( event ) { 123 | 124 | if ( scope.enabled === false ) return; 125 | 126 | event.preventDefault(); 127 | 128 | var movementX = event.movementX || event.webkitMovementX || event.mozMovementX || event.oMovementX || 0; 129 | var movementY = event.movementY || event.webkitMovementY || event.mozMovementY || event.oMovementY || 0; 130 | 131 | if ( state === STATE.ROTATE ) { 132 | 133 | scope.rotate( new THREE.Vector3( - movementX * 0.005, - movementY * 0.005, 0 ) ); 134 | 135 | } else if ( state === STATE.ZOOM ) { 136 | 137 | scope.zoom( new THREE.Vector3( 0, 0, movementY ) ); 138 | 139 | } else if ( state === STATE.PAN ) { 140 | 141 | scope.pan( new THREE.Vector3( - movementX, movementY, 0 ) ); 142 | 143 | } 144 | 145 | } 146 | 147 | function onMouseUp( event ) { 148 | 149 | if ( scope.enabled === false ) return; 150 | 151 | document.removeEventListener( 'mousemove', onMouseMove, false ); 152 | document.removeEventListener( 'mouseup', onMouseUp, false ); 153 | 154 | state = STATE.NONE; 155 | 156 | } 157 | 158 | function onMouseWheel( event ) { 159 | 160 | if ( scope.enabled === false ) return; 161 | 162 | var delta = 0; 163 | 164 | if ( event.wheelDelta ) { // WebKit / Opera / Explorer 9 165 | 166 | delta = - event.wheelDelta; 167 | 168 | } else if ( event.detail ) { // Firefox 169 | 170 | delta = event.detail * 10; 171 | 172 | } 173 | 174 | scope.zoom( new THREE.Vector3( 0, 0, delta ) ); 175 | 176 | } 177 | 178 | domElement.addEventListener( 'contextmenu', function ( event ) { event.preventDefault(); }, false ); 179 | domElement.addEventListener( 'mousedown', onMouseDown, false ); 180 | domElement.addEventListener( 'mousewheel', onMouseWheel, false ); 181 | domElement.addEventListener( 'DOMMouseScroll', onMouseWheel, false ); // firefox 182 | 183 | // touch 184 | 185 | var touch = new THREE.Vector3(); 186 | var prevTouch = new THREE.Vector3(); 187 | var prevDistance = null; 188 | 189 | function touchStart( event ) { 190 | 191 | if ( scope.enabled === false ) return; 192 | 193 | var touches = event.touches; 194 | 195 | switch ( touches.length ) { 196 | 197 | case 2: 198 | var dx = touches[ 0 ].pageX - touches[ 1 ].pageX; 199 | var dy = touches[ 0 ].pageY - touches[ 1 ].pageY; 200 | prevDistance = Math.sqrt( dx * dx + dy * dy ); 201 | break; 202 | 203 | } 204 | 205 | prevTouch.set( touches[ 0 ].pageX, touches[ 0 ].pageY, 0 ); 206 | 207 | } 208 | 209 | function touchMove( event ) { 210 | 211 | if ( scope.enabled === false ) return; 212 | 213 | event.preventDefault(); 214 | event.stopPropagation(); 215 | 216 | var touches = event.touches; 217 | 218 | touch.set( touches[ 0 ].pageX, touches[ 0 ].pageY, 0 ); 219 | 220 | switch ( touches.length ) { 221 | 222 | case 1: 223 | scope.rotate( touch.sub( prevTouch ).multiplyScalar( - 0.005 ) ); 224 | break; 225 | 226 | case 2: 227 | var dx = touches[ 0 ].pageX - touches[ 1 ].pageX; 228 | var dy = touches[ 0 ].pageY - touches[ 1 ].pageY; 229 | var distance = Math.sqrt( dx * dx + dy * dy ); 230 | scope.zoom( new THREE.Vector3( 0, 0, prevDistance - distance ) ); 231 | prevDistance = distance; 232 | break; 233 | 234 | case 3: 235 | scope.pan( touch.sub( prevTouch ).setX( - touch.x ) ); 236 | break; 237 | 238 | } 239 | 240 | prevTouch.set( touches[ 0 ].pageX, touches[ 0 ].pageY, 0 ); 241 | 242 | } 243 | 244 | domElement.addEventListener( 'touchstart', touchStart, false ); 245 | domElement.addEventListener( 'touchmove', touchMove, false ); 246 | 247 | }; 248 | 249 | THREE.EditorControls.prototype = Object.create( THREE.EventDispatcher.prototype ); 250 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /js/effects/AnaglyphEffect.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author mrdoob / http://mrdoob.com/ 3 | * @author marklundin / http://mark-lundin.com/ 4 | * @author alteredq / http://alteredqualia.com/ 5 | */ 6 | 7 | THREE.AnaglyphEffect = function ( renderer, width, height ) { 8 | 9 | var eyeRight = new THREE.Matrix4(); 10 | var eyeLeft = new THREE.Matrix4(); 11 | var focalLength = 125; 12 | var _aspect, _near, _far, _fov; 13 | 14 | var _cameraL = new THREE.PerspectiveCamera(); 15 | _cameraL.matrixAutoUpdate = false; 16 | 17 | var _cameraR = new THREE.PerspectiveCamera(); 18 | _cameraR.matrixAutoUpdate = false; 19 | 20 | var _camera = new THREE.OrthographicCamera( -1, 1, 1, - 1, 0, 1 ); 21 | 22 | var _scene = new THREE.Scene(); 23 | 24 | var _params = { minFilter: THREE.LinearFilter, magFilter: THREE.NearestFilter, format: THREE.RGBAFormat }; 25 | 26 | if ( width === undefined ) width = 512; 27 | if ( height === undefined ) height = 512; 28 | 29 | var _renderTargetL = new THREE.WebGLRenderTarget( width, height, _params ); 30 | var _renderTargetR = new THREE.WebGLRenderTarget( width, height, _params ); 31 | 32 | var _material = new THREE.ShaderMaterial( { 33 | 34 | uniforms: { 35 | 36 | "mapLeft": { type: "t", value: _renderTargetL }, 37 | "mapRight": { type: "t", value: _renderTargetR } 38 | 39 | }, 40 | 41 | vertexShader: [ 42 | 43 | "varying vec2 vUv;", 44 | 45 | "void main() {", 46 | 47 | " vUv = vec2( uv.x, uv.y );", 48 | " gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 49 | 50 | "}" 51 | 52 | ].join("\n"), 53 | 54 | fragmentShader: [ 55 | 56 | "uniform sampler2D mapLeft;", 57 | "uniform sampler2D mapRight;", 58 | "varying vec2 vUv;", 59 | 60 | "void main() {", 61 | 62 | " vec4 colorL, colorR;", 63 | " vec2 uv = vUv;", 64 | 65 | " colorL = texture2D( mapLeft, uv );", 66 | " colorR = texture2D( mapRight, uv );", 67 | 68 | // http://3dtv.at/Knowhow/AnaglyphComparison_en.aspx 69 | 70 | " gl_FragColor = vec4( colorL.g * 0.7 + colorL.b * 0.3, colorR.g, colorR.b, colorL.a + colorR.a ) * 1.1;", 71 | 72 | "}" 73 | 74 | ].join("\n") 75 | 76 | } ); 77 | 78 | var mesh = new THREE.Mesh( new THREE.PlaneGeometry( 2, 2 ), _material ); 79 | _scene.add( mesh ); 80 | 81 | this.setSize = function ( width, height ) { 82 | 83 | _renderTargetL = new THREE.WebGLRenderTarget( width, height, _params ); 84 | _renderTargetR = new THREE.WebGLRenderTarget( width, height, _params ); 85 | 86 | _material.uniforms[ "mapLeft" ].value = _renderTargetL; 87 | _material.uniforms[ "mapRight" ].value = _renderTargetR; 88 | 89 | renderer.setSize( width, height ); 90 | 91 | }; 92 | 93 | /* 94 | * Renderer now uses an asymmetric perspective projection 95 | * (http://paulbourke.net/miscellaneous/stereographics/stereorender/). 96 | * 97 | * Each camera is offset by the eye seperation and its projection matrix is 98 | * also skewed asymetrically back to converge on the same projection plane. 99 | * Added a focal length parameter to, this is where the parallax is equal to 0. 100 | */ 101 | 102 | this.render = function ( scene, camera ) { 103 | 104 | scene.updateMatrixWorld(); 105 | 106 | if ( camera.parent === undefined ) camera.updateMatrixWorld(); 107 | 108 | var hasCameraChanged = ( _aspect !== camera.aspect ) || ( _near !== camera.near ) || ( _far !== camera.far ) || ( _fov !== camera.fov ); 109 | 110 | if ( hasCameraChanged ) { 111 | 112 | _aspect = camera.aspect; 113 | _near = camera.near; 114 | _far = camera.far; 115 | _fov = camera.fov; 116 | 117 | var projectionMatrix = camera.projectionMatrix.clone(); 118 | var eyeSep = focalLength / 30 * 0.5; 119 | var eyeSepOnProjection = eyeSep * _near / focalLength; 120 | var ymax = _near * Math.tan( THREE.Math.degToRad( _fov * 0.5 ) ); 121 | var xmin, xmax; 122 | 123 | // translate xOffset 124 | 125 | eyeRight.elements[12] = eyeSep; 126 | eyeLeft.elements[12] = -eyeSep; 127 | 128 | // for left eye 129 | 130 | xmin = -ymax * _aspect + eyeSepOnProjection; 131 | xmax = ymax * _aspect + eyeSepOnProjection; 132 | 133 | projectionMatrix.elements[0] = 2 * _near / ( xmax - xmin ); 134 | projectionMatrix.elements[8] = ( xmax + xmin ) / ( xmax - xmin ); 135 | 136 | _cameraL.projectionMatrix.copy( projectionMatrix ); 137 | 138 | // for right eye 139 | 140 | xmin = -ymax * _aspect - eyeSepOnProjection; 141 | xmax = ymax * _aspect - eyeSepOnProjection; 142 | 143 | projectionMatrix.elements[0] = 2 * _near / ( xmax - xmin ); 144 | projectionMatrix.elements[8] = ( xmax + xmin ) / ( xmax - xmin ); 145 | 146 | _cameraR.projectionMatrix.copy( projectionMatrix ); 147 | 148 | } 149 | 150 | _cameraL.matrixWorld.copy( camera.matrixWorld ).multiply( eyeLeft ); 151 | _cameraL.position.copy( camera.position ); 152 | _cameraL.near = camera.near; 153 | _cameraL.far = camera.far; 154 | 155 | renderer.render( scene, _cameraL, _renderTargetL, true ); 156 | 157 | _cameraR.matrixWorld.copy( camera.matrixWorld ).multiply( eyeRight ); 158 | _cameraR.position.copy( camera.position ); 159 | _cameraR.near = camera.near; 160 | _cameraR.far = camera.far; 161 | 162 | renderer.render( scene, _cameraR, _renderTargetR, true ); 163 | 164 | renderer.render( _scene, _camera ); 165 | 166 | }; 167 | 168 | }; 169 | -------------------------------------------------------------------------------- /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/effects/ParallaxBarrierEffect.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author mrdoob / http://mrdoob.com/ 3 | * @author marklundin / http://mark-lundin.com/ 4 | * @author alteredq / http://alteredqualia.com/ 5 | */ 6 | 7 | THREE.ParallaxBarrierEffect = function ( renderer ) { 8 | 9 | var eyeRight = new THREE.Matrix4(); 10 | var eyeLeft = new THREE.Matrix4(); 11 | var focalLength = 125; 12 | var _aspect, _near, _far, _fov; 13 | 14 | var _cameraL = new THREE.PerspectiveCamera(); 15 | _cameraL.matrixAutoUpdate = false; 16 | 17 | var _cameraR = new THREE.PerspectiveCamera(); 18 | _cameraR.matrixAutoUpdate = false; 19 | 20 | var _scene = new THREE.Scene(); 21 | 22 | var _camera = new THREE.PerspectiveCamera( 53, 1, 1, 10000 ); 23 | _camera.position.z = 2; 24 | _scene.add( _camera ); 25 | 26 | var _params = { minFilter: THREE.LinearFilter, magFilter: THREE.NearestFilter, format: THREE.RGBAFormat }; 27 | 28 | var _renderTargetL = new THREE.WebGLRenderTarget( 512, 512, _params ); 29 | var _renderTargetR = new THREE.WebGLRenderTarget( 512, 512, _params ); 30 | 31 | var _material = new THREE.ShaderMaterial( { 32 | 33 | uniforms: { 34 | 35 | "mapLeft": { type: "t", value: _renderTargetL }, 36 | "mapRight": { type: "t", value: _renderTargetR } 37 | 38 | }, 39 | 40 | vertexShader: [ 41 | 42 | "varying vec2 vUv;", 43 | 44 | "void main() {", 45 | 46 | " vUv = vec2( uv.x, uv.y );", 47 | " gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 48 | 49 | "}" 50 | 51 | ].join("\n"), 52 | 53 | fragmentShader: [ 54 | 55 | "uniform sampler2D mapLeft;", 56 | "uniform sampler2D mapRight;", 57 | "varying vec2 vUv;", 58 | 59 | "void main() {", 60 | 61 | " vec2 uv = vUv;", 62 | 63 | " if ( ( mod( gl_FragCoord.x, 2.0 ) ) > 1.00 ) {", 64 | 65 | " gl_FragColor = texture2D( mapLeft, uv );", 66 | 67 | " } else {", 68 | 69 | " gl_FragColor = texture2D( mapRight, uv );", 70 | 71 | " }", 72 | 73 | "}" 74 | 75 | ].join("\n") 76 | 77 | } ); 78 | 79 | var mesh = new THREE.Mesh( new THREE.PlaneGeometry( 2, 2 ), _material ); 80 | _scene.add( mesh ); 81 | 82 | this.setSize = function ( width, height ) { 83 | 84 | _renderTargetL = new THREE.WebGLRenderTarget( width, height, _params ); 85 | _renderTargetR = new THREE.WebGLRenderTarget( width, height, _params ); 86 | 87 | _material.uniforms[ "mapLeft" ].value = _renderTargetL; 88 | _material.uniforms[ "mapRight" ].value = _renderTargetR; 89 | 90 | renderer.setSize( width, height ); 91 | 92 | }; 93 | 94 | /* 95 | * Renderer now uses an asymmetric perspective projection 96 | * (http://paulbourke.net/miscellaneous/stereographics/stereorender/). 97 | * 98 | * Each camera is offset by the eye seperation and its projection matrix is 99 | * also skewed asymetrically back to converge on the same projection plane. 100 | * Added a focal length parameter to, this is where the parallax is equal to 0. 101 | */ 102 | 103 | this.render = function ( scene, camera ) { 104 | 105 | scene.updateMatrixWorld(); 106 | 107 | if ( camera.parent === undefined ) camera.updateMatrixWorld(); 108 | 109 | var hasCameraChanged = ( _aspect !== camera.aspect ) || ( _near !== camera.near ) || ( _far !== camera.far ) || ( _fov !== camera.fov ); 110 | 111 | if ( hasCameraChanged ) { 112 | 113 | _aspect = camera.aspect; 114 | _near = camera.near; 115 | _far = camera.far; 116 | _fov = camera.fov; 117 | 118 | var projectionMatrix = camera.projectionMatrix.clone(); 119 | var eyeSep = focalLength / 30 * 0.5; 120 | var eyeSepOnProjection = eyeSep * _near / focalLength; 121 | var ymax = _near * Math.tan( THREE.Math.degToRad( _fov * 0.5 ) ); 122 | var xmin, xmax; 123 | 124 | // translate xOffset 125 | 126 | eyeRight.elements[12] = eyeSep; 127 | eyeLeft.elements[12] = -eyeSep; 128 | 129 | // for left eye 130 | 131 | xmin = -ymax * _aspect + eyeSepOnProjection; 132 | xmax = ymax * _aspect + eyeSepOnProjection; 133 | 134 | projectionMatrix.elements[0] = 2 * _near / ( xmax - xmin ); 135 | projectionMatrix.elements[8] = ( xmax + xmin ) / ( xmax - xmin ); 136 | 137 | _cameraL.projectionMatrix.copy( projectionMatrix ); 138 | 139 | // for right eye 140 | 141 | xmin = -ymax * _aspect - eyeSepOnProjection; 142 | xmax = ymax * _aspect - eyeSepOnProjection; 143 | 144 | projectionMatrix.elements[0] = 2 * _near / ( xmax - xmin ); 145 | projectionMatrix.elements[8] = ( xmax + xmin ) / ( xmax - xmin ); 146 | 147 | _cameraR.projectionMatrix.copy( projectionMatrix ); 148 | 149 | } 150 | 151 | _cameraL.matrixWorld.copy( camera.matrixWorld ).multiply( eyeLeft ); 152 | _cameraL.position.copy( camera.position ); 153 | _cameraL.near = camera.near; 154 | _cameraL.far = camera.far; 155 | 156 | renderer.render( scene, _cameraL, _renderTargetL, true ); 157 | 158 | _cameraR.matrixWorld.copy( camera.matrixWorld ).multiply( eyeRight ); 159 | _cameraR.position.copy( camera.position ); 160 | _cameraR.near = camera.near; 161 | _cameraR.far = camera.far; 162 | 163 | renderer.render( scene, _cameraR, _renderTargetR, true ); 164 | 165 | _scene.updateMatrixWorld(); 166 | 167 | renderer.render( _scene, _camera ); 168 | 169 | }; 170 | 171 | }; 172 | -------------------------------------------------------------------------------- /js/exporters/GeometryExporter.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author mrdoob / http://mrdoob.com/ 3 | */ 4 | 5 | THREE.GeometryExporter = function () {}; 6 | 7 | THREE.GeometryExporter.prototype = { 8 | 9 | constructor: THREE.GeometryExporter, 10 | 11 | parse: function ( geometry ) { 12 | 13 | var output = { 14 | metadata: { 15 | version: 4.0, 16 | type: 'geometry', 17 | generator: 'GeometryExporter' 18 | } 19 | }; 20 | 21 | var vertices = []; 22 | 23 | for ( var i = 0; i < geometry.vertices.length; i ++ ) { 24 | 25 | var vertex = geometry.vertices[ i ]; 26 | vertices.push( vertex.x, vertex.y, vertex.z ); 27 | 28 | } 29 | 30 | var faces = []; 31 | var uvs = [[]]; 32 | var normals = []; 33 | var normalsHash = {}; 34 | 35 | for ( var i = 0; i < geometry.faces.length; i ++ ) { 36 | 37 | var face = geometry.faces[ i ]; 38 | 39 | var isTriangle = face instanceof THREE.Face3; 40 | var hasMaterial = false; // face.materialIndex !== undefined; 41 | var hasFaceUv = false; // geometry.faceUvs[ 0 ][ i ] !== undefined; 42 | var hasFaceVertexUv = false; // geometry.faceVertexUvs[ 0 ][ i ] !== undefined; 43 | var hasFaceNormal = face.normal.length() > 0; 44 | var hasFaceVertexNormal = face.vertexNormals[ 0 ] !== undefined; 45 | var hasFaceColor = false; // face.color; 46 | var hasFaceVertexColor = false; // face.vertexColors[ 0 ] !== undefined; 47 | 48 | var faceType = 0; 49 | 50 | faceType = setBit( faceType, 0, ! isTriangle ); 51 | faceType = setBit( faceType, 1, hasMaterial ); 52 | faceType = setBit( faceType, 2, hasFaceUv ); 53 | faceType = setBit( faceType, 3, hasFaceVertexUv ); 54 | faceType = setBit( faceType, 4, hasFaceNormal ); 55 | faceType = setBit( faceType, 5, hasFaceVertexNormal ); 56 | faceType = setBit( faceType, 6, hasFaceColor ); 57 | faceType = setBit( faceType, 7, hasFaceVertexColor ); 58 | 59 | faces.push( faceType ); 60 | 61 | if ( isTriangle ) { 62 | 63 | faces.push( face.a, face.b, face.c ); 64 | 65 | } else { 66 | 67 | faces.push( face.a, face.b, face.c, face.d ); 68 | 69 | } 70 | 71 | if ( hasMaterial ) { 72 | 73 | faces.push( face.materialIndex ); 74 | 75 | } 76 | 77 | /* 78 | if ( hasFaceUv ) { 79 | 80 | var uv = geometry.faceUvs[ 0 ][ i ]; 81 | uvs[ 0 ].push( uv.u, uv.v ); 82 | 83 | } 84 | */ 85 | 86 | /* 87 | if ( hasFaceVertexUv ) { 88 | 89 | var uvs = geometry.faceVertexUvs[ 0 ][ i ]; 90 | 91 | if ( isTriangle ) { 92 | 93 | faces.push( 94 | uvs[ 0 ].u, uvs[ 0 ].v, 95 | uvs[ 1 ].u, uvs[ 1 ].v, 96 | uvs[ 2 ].u, uvs[ 2 ].v 97 | ); 98 | 99 | } else { 100 | 101 | faces.push( 102 | uvs[ 0 ].u, uvs[ 0 ].v, 103 | uvs[ 1 ].u, uvs[ 1 ].v, 104 | uvs[ 2 ].u, uvs[ 2 ].v, 105 | uvs[ 3 ].u, uvs[ 3 ].v 106 | ); 107 | 108 | } 109 | 110 | } 111 | */ 112 | 113 | if ( hasFaceNormal ) { 114 | 115 | var faceNormal = face.normal; 116 | faces.push( getNormalIndex( faceNormal.x, faceNormal.y, faceNormal.z ) ); 117 | 118 | } 119 | 120 | if ( hasFaceVertexNormal ) { 121 | 122 | var vertexNormals = face.vertexNormals; 123 | 124 | if ( isTriangle ) { 125 | 126 | faces.push( 127 | getNormalIndex( vertexNormals[ 0 ].x, vertexNormals[ 0 ].y, vertexNormals[ 0 ].z ), 128 | getNormalIndex( vertexNormals[ 1 ].x, vertexNormals[ 1 ].y, vertexNormals[ 1 ].z ), 129 | getNormalIndex( vertexNormals[ 2 ].x, vertexNormals[ 2 ].y, vertexNormals[ 2 ].z ) 130 | ); 131 | 132 | } else { 133 | 134 | faces.push( 135 | getNormalIndex( vertexNormals[ 0 ].x, vertexNormals[ 0 ].y, vertexNormals[ 0 ].z ), 136 | getNormalIndex( vertexNormals[ 1 ].x, vertexNormals[ 1 ].y, vertexNormals[ 1 ].z ), 137 | getNormalIndex( vertexNormals[ 2 ].x, vertexNormals[ 2 ].y, vertexNormals[ 2 ].z ), 138 | getNormalIndex( vertexNormals[ 3 ].x, vertexNormals[ 3 ].y, vertexNormals[ 3 ].z ) 139 | ); 140 | 141 | } 142 | 143 | } 144 | 145 | } 146 | 147 | function setBit( value, position, enabled ) { 148 | 149 | return enabled ? value | ( 1 << position ) : value & ( ~ ( 1 << position) ); 150 | 151 | } 152 | 153 | function getNormalIndex( x, y, z ) { 154 | 155 | var hash = x.toString() + y.toString() + z.toString(); 156 | 157 | if ( normalsHash[ hash ] !== undefined ) { 158 | 159 | return normalsHash[ hash ]; 160 | 161 | } 162 | 163 | normalsHash[ hash ] = normals.length / 3; 164 | normals.push( x, y, z ); 165 | 166 | return normalsHash[ hash ]; 167 | 168 | } 169 | 170 | output.vertices = vertices; 171 | output.normals = normals; 172 | output.uvs = uvs; 173 | output.faces = faces; 174 | 175 | // 176 | 177 | return output; 178 | 179 | } 180 | 181 | }; 182 | -------------------------------------------------------------------------------- /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/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/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/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/libs/tween.min.js: -------------------------------------------------------------------------------- 1 | // tween.js - http://github.com/sole/tween.js 2 | 'use strict';var TWEEN=TWEEN||function(){var a=[];return{REVISION:"7",getAll:function(){return a},removeAll:function(){a=[]},add:function(c){a.push(c)},remove:function(c){c=a.indexOf(c);-1!==c&&a.splice(c,1)},update:function(c){if(0===a.length)return!1;for(var b=0,d=a.length,c=void 0!==c?c:Date.now();b(a*=2)?0.5*a*a:-0.5*(--a*(a-2)-1)}},Cubic:{In:function(a){return a*a*a},Out:function(a){return--a*a*a+1},InOut:function(a){return 1>(a*=2)?0.5*a*a*a:0.5*((a-=2)*a*a+2)}},Quartic:{In:function(a){return a*a*a*a},Out:function(a){return 1- --a*a*a*a},InOut:function(a){return 1>(a*=2)?0.5*a*a*a*a:-0.5*((a-=2)*a*a*a-2)}},Quintic:{In:function(a){return a*a*a* 7 | a*a},Out:function(a){return--a*a*a*a*a+1},InOut:function(a){return 1>(a*=2)?0.5*a*a*a*a*a:0.5*((a-=2)*a*a*a*a+2)}},Sinusoidal:{In:function(a){return 1-Math.cos(a*Math.PI/2)},Out:function(a){return Math.sin(a*Math.PI/2)},InOut:function(a){return 0.5*(1-Math.cos(Math.PI*a))}},Exponential:{In:function(a){return 0===a?0:Math.pow(1024,a-1)},Out:function(a){return 1===a?1:1-Math.pow(2,-10*a)},InOut:function(a){return 0===a?0:1===a?1:1>(a*=2)?0.5*Math.pow(1024,a-1):0.5*(-Math.pow(2,-10*(a-1))+2)}},Circular:{In:function(a){return 1- 8 | Math.sqrt(1-a*a)},Out:function(a){return Math.sqrt(1- --a*a)},InOut:function(a){return 1>(a*=2)?-0.5*(Math.sqrt(1-a*a)-1):0.5*(Math.sqrt(1-(a-=2)*a)+1)}},Elastic:{In:function(a){var c,b=0.1;if(0===a)return 0;if(1===a)return 1;!b||1>b?(b=1,c=0.1):c=0.4*Math.asin(1/b)/(2*Math.PI);return-(b*Math.pow(2,10*(a-=1))*Math.sin((a-c)*2*Math.PI/0.4))},Out:function(a){var c,b=0.1;if(0===a)return 0;if(1===a)return 1;!b||1>b?(b=1,c=0.1):c=0.4*Math.asin(1/b)/(2*Math.PI);return b*Math.pow(2,-10*a)*Math.sin((a-c)* 9 | 2*Math.PI/0.4)+1},InOut:function(a){var c,b=0.1;if(0===a)return 0;if(1===a)return 1;!b||1>b?(b=1,c=0.1):c=0.4*Math.asin(1/b)/(2*Math.PI);return 1>(a*=2)?-0.5*b*Math.pow(2,10*(a-=1))*Math.sin((a-c)*2*Math.PI/0.4):0.5*b*Math.pow(2,-10*(a-=1))*Math.sin((a-c)*2*Math.PI/0.4)+1}},Back:{In:function(a){return a*a*(2.70158*a-1.70158)},Out:function(a){return--a*a*(2.70158*a+1.70158)+1},InOut:function(a){return 1>(a*=2)?0.5*a*a*(3.5949095*a-2.5949095):0.5*((a-=2)*a*(3.5949095*a+2.5949095)+2)}},Bounce:{In:function(a){return 1- 10 | TWEEN.Easing.Bounce.Out(1-a)},Out:function(a){return a<1/2.75?7.5625*a*a:a<2/2.75?7.5625*(a-=1.5/2.75)*a+0.75:a<2.5/2.75?7.5625*(a-=2.25/2.75)*a+0.9375:7.5625*(a-=2.625/2.75)*a+0.984375},InOut:function(a){return 0.5>a?0.5*TWEEN.Easing.Bounce.In(2*a):0.5*TWEEN.Easing.Bounce.Out(2*a-1)+0.5}}}; 11 | TWEEN.Interpolation={Linear:function(a,c){var b=a.length-1,d=b*c,e=Math.floor(d),f=TWEEN.Interpolation.Utils.Linear;return 0>c?f(a[0],a[1],d):1b?b:e+1],d-e)},Bezier:function(a,c){var b=0,d=a.length-1,e=Math.pow,f=TWEEN.Interpolation.Utils.Bernstein,h;for(h=0;h<=d;h++)b+=e(1-c,d-h)*e(c,h)*a[h]*f(d,h);return b},CatmullRom:function(a,c){var b=a.length-1,d=b*c,e=Math.floor(d),f=TWEEN.Interpolation.Utils.CatmullRom;return a[0]===a[b]?(0>c&&(e=Math.floor(d=b*(1+c))),f(a[(e- 12 | 1+b)%b],a[e],a[(e+1)%b],a[(e+2)%b],d-e)):0>c?a[0]-(f(a[0],a[0],a[1],a[1],-d)-a[0]):1 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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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 | --------------------------------------------------------------------------------