├── LICENSE
├── README.md
├── docs
├── API.hbs
├── API.md
└── screenshots
│ ├── apollonian_firsthit.png
│ ├── apollonian_firsthit_thumb.png
│ ├── apollonian_pt.png
│ ├── apollonian_pt_thumb.png
│ ├── armadillo_thumb.png
│ ├── basicAnimation.png
│ ├── basicAnimation_thumb.png
│ ├── bounce_thumb.png
│ ├── bunny_thumb.png
│ ├── city_thumb.png
│ ├── distanceViz_thumb.png
│ ├── font_sdf_thumb.png
│ ├── gem.png
│ ├── gem_thumb.png
│ ├── glassPolyhedron_thumb.png
│ ├── hand_thumb.png
│ ├── helloWorld.png
│ ├── helloWorld_thumb.png
│ ├── helloWorld_thumb2.png
│ ├── lattice_dielectric.png
│ ├── lattice_dielectric_thumb.png
│ ├── lattice_metallic.png
│ ├── lattice_metallic_thumb.png
│ ├── lattice_mixed.png
│ ├── lattice_mixed_thumb.png
│ ├── mandelbox.png
│ ├── mandelbox_thumb.png
│ ├── math_dielectric_thumb.png
│ ├── math_sdf_thumb.png
│ ├── menger.png
│ ├── mengerBunny_thumb.png
│ ├── mengerHead_thumb.png
│ ├── menger_thumb.png
│ ├── meteorite.png
│ ├── meteorite_thumb.png
│ ├── pyroclastic_thumb.png
│ ├── rock.png
│ ├── rock_thumb.png
│ ├── volumeBunny_thumb.png
│ ├── volumeCheckerboard_thumb.png
│ └── volumetricMath_thumb.png
├── exampleScenes
├── animation
│ ├── basicAnimation.html
│ └── bounce.html
├── dielectrics
│ ├── gem.html
│ ├── glassPolyhedron.html
│ ├── lattice_dielectric.html
│ ├── lattice_mixed.html
│ └── sphereOnCheckerboard.html
├── fonts
│ ├── font_sdf.html
│ ├── font_sdf2.html
│ ├── math_dielectric.html
│ └── math_sdf.html
├── fractals
│ ├── IFS
│ │ ├── cube.html
│ │ ├── damaged2.html
│ │ ├── damageddavid.html
│ │ ├── dodecahedron.html
│ │ ├── icosahedron.html
│ │ ├── mandalay.html
│ │ ├── mandalay_mod.html
│ │ ├── mandalay_sphere.html
│ │ ├── meshkifs.html
│ │ ├── meshmenger.html
│ │ ├── octahedron.html
│ │ ├── pseudo_kleinian.html
│ │ └── tetrahedron.html
│ ├── apollonian_firsthit.html
│ ├── apollonian_pt.html
│ ├── doyleSpirals.html
│ ├── female-mandel.html
│ ├── female-menger.html
│ ├── mandelbox.html
│ ├── mandelbrot.html
│ ├── menger.html
│ ├── mengerBunny.html
│ └── mengerHead.html
├── math
│ ├── knot.html
│ └── polyhedra.html
├── meshes
│ ├── PBR_setup.html
│ ├── armadillo.html
│ ├── bunny.html
│ ├── female.html
│ ├── hand.html
│ ├── pieta.html
│ └── pieta_sss.html
├── metals
│ ├── lattice_metallic.html
│ └── meteorite.html
├── misc
│ ├── castle.html
│ ├── city.html
│ ├── distanceViz.html
│ ├── helloWorld.html
│ ├── rock.html
│ └── wood.html
├── physics
│ └── orbitals.html
├── textures
│ ├── texture_flesh.html
│ └── texture_rocks.html
└── volumes
│ ├── pyroclastic.html
│ ├── volumeBunny.html
│ ├── volumeCheckerboard.html
│ └── volumetricMath.html
├── js
├── color.js
├── compiled
│ └── snelly.min.js
├── debugger.html
├── gl.js
├── gui.js
├── materials.js
├── renderer.js
├── sceneAPI.js
├── shaders.js
├── snelly.js
├── spectra.js
└── thirdparty
│ ├── jquery-1.11.3.min.js
│ ├── math-sdf.js
│ ├── three
│ ├── AudioObject.js
│ ├── BlendCharacter.js
│ ├── BlendCharacterGui.js
│ ├── Car.js
│ ├── Cloth.js
│ ├── CurveExtras.js
│ ├── Detector.js
│ ├── ImprovedNoise.js
│ ├── MD2Character.js
│ ├── MD2CharacterComplex.js
│ ├── MarchingCubes.js
│ ├── Mirror.js
│ ├── Ocean.js
│ ├── Octree.js
│ ├── PRNG.js
│ ├── ParametricGeometries.js
│ ├── ShaderDeferred.js
│ ├── ShaderGodRays.js
│ ├── ShaderSkin.js
│ ├── ShaderTerrain.js
│ ├── ShaderToon.js
│ ├── SimplexNoise.js
│ ├── SimulationRenderer.js
│ ├── SkyShader.js
│ ├── Sparks.js
│ ├── TypedArrayUtils.js
│ ├── UCSCharacter.js
│ ├── WaterShader.js
│ ├── cameras
│ │ └── CombinedCamera.js
│ ├── controls
│ │ ├── DeviceOrientationControls.js
│ │ ├── EditorControls.js
│ │ ├── FirstPersonControls.js
│ │ ├── FlyControls.js
│ │ ├── MouseControls.js
│ │ ├── OrbitControls.js
│ │ ├── OrthographicTrackballControls.js
│ │ ├── PointerLockControls.js
│ │ ├── TrackballControls.js
│ │ ├── TransformControls.js
│ │ └── VRControls.js
│ ├── crossfade
│ │ ├── gui.js
│ │ ├── scenes.js
│ │ └── transition.js
│ ├── curves
│ │ ├── NURBSCurve.js
│ │ ├── NURBSSurface.js
│ │ └── NURBSUtils.js
│ ├── effects
│ │ ├── AnaglyphEffect.js
│ │ ├── AsciiEffect.js
│ │ ├── ParallaxBarrierEffect.js
│ │ ├── StereoEffect.js
│ │ └── VREffect.js
│ ├── exporters
│ │ ├── OBJExporter.js
│ │ ├── STLBinaryExporter.js
│ │ ├── STLExporter.js
│ │ ├── SceneExporter.js
│ │ └── TypedGeometryExporter.js
│ ├── geometries
│ │ ├── ConvexGeometry.js
│ │ ├── DecalGeometry.js
│ │ ├── hilbert2D.js
│ │ └── hilbert3D.js
│ ├── libs
│ │ ├── dat.gui.min.js
│ │ ├── msgpack-js.js
│ │ ├── pnltri.min.js
│ │ ├── require.js
│ │ ├── stats.min.js
│ │ ├── system.min.js
│ │ └── tween.min.js
│ ├── loaders
│ │ ├── AWDLoader.js
│ │ ├── AssimpJSONLoader.js
│ │ ├── BabylonLoader.js
│ │ ├── BinaryLoader.js
│ │ ├── ColladaLoader.js
│ │ ├── DDSLoader.js
│ │ ├── MTLLoader.js
│ │ ├── OBJLoader.js
│ │ ├── OBJMTLLoader.js
│ │ ├── PDBLoader.js
│ │ ├── PLYLoader.js
│ │ ├── PVRLoader.js
│ │ ├── RGBELoader.js
│ │ ├── STLLoader.js
│ │ ├── SVGLoader.js
│ │ ├── TGALoader.js
│ │ ├── UTF8Loader.js
│ │ ├── VRMLLoader.js
│ │ ├── VTKLoader.js
│ │ ├── ctm
│ │ │ ├── CTMLoader.js
│ │ │ ├── CTMWorker.js
│ │ │ ├── ctm.js
│ │ │ ├── license
│ │ │ │ ├── OpenCTM.txt
│ │ │ │ ├── js-lzma.txt
│ │ │ │ └── js-openctm.txt
│ │ │ └── lzma.js
│ │ ├── deprecated
│ │ │ └── SceneLoader.js
│ │ └── gltf
│ │ │ ├── glTF-parser.js
│ │ │ ├── glTFAnimation.js
│ │ │ ├── glTFLoader.js
│ │ │ └── glTFLoaderUtils.js
│ ├── math
│ │ ├── ColorConverter.js
│ │ └── Lut.js
│ ├── modifiers
│ │ ├── ExplodeModifier.js
│ │ ├── SubdivisionModifier.js
│ │ └── TessellateModifier.js
│ ├── objects
│ │ └── ShadowMesh.js
│ ├── postprocessing
│ │ ├── AdaptiveToneMappingPass.js
│ │ ├── BloomPass.js
│ │ ├── BokehPass.js
│ │ ├── DotScreenPass.js
│ │ ├── EffectComposer.js
│ │ ├── FilmPass.js
│ │ ├── GlitchPass.js
│ │ ├── MaskPass.js
│ │ ├── RenderPass.js
│ │ ├── SavePass.js
│ │ ├── ShaderPass.js
│ │ └── TexturePass.js
│ ├── renderers
│ │ ├── CSS2DRenderer.js
│ │ ├── CSS3DRenderer.js
│ │ ├── CSS3DStereoRenderer.js
│ │ ├── CanvasRenderer.js
│ │ ├── Projector.js
│ │ ├── RaytracingRenderer.js
│ │ ├── SVGRenderer.js
│ │ ├── SoftwareRenderer.js
│ │ ├── WebGLDeferredRenderer.js
│ │ └── plugins
│ │ │ └── DepthPassPlugin.js
│ ├── shaders
│ │ ├── BasicShader.js
│ │ ├── BleachBypassShader.js
│ │ ├── BlendShader.js
│ │ ├── BokehShader.js
│ │ ├── BokehShader2.js
│ │ ├── BrightnessContrastShader.js
│ │ ├── ColorCorrectionShader.js
│ │ ├── ColorifyShader.js
│ │ ├── ConvolutionShader.js
│ │ ├── CopyShader.js
│ │ ├── DOFMipMapShader.js
│ │ ├── DigitalGlitch.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
│ │ ├── NormalDisplacementShader.js
│ │ ├── NormalMapShader.js
│ │ ├── OceanShaders.js
│ │ ├── ParallaxShader.js
│ │ ├── RGBShiftShader.js
│ │ ├── SSAOShader.js
│ │ ├── SepiaShader.js
│ │ ├── TechnicolorShader.js
│ │ ├── ToneMapShader.js
│ │ ├── TriangleBlurShader.js
│ │ ├── UnpackDepthRGBAShader.js
│ │ ├── VerticalBlurShader.js
│ │ ├── VerticalTiltShiftShader.js
│ │ └── VignetteShader.js
│ ├── three.js
│ ├── three.min.js
│ ├── utils
│ │ ├── GeometryUtils.js
│ │ ├── ShadowMapViewer.js
│ │ └── UVsDebug.js
│ └── wip
│ │ ├── CircleTypedGeometry.js
│ │ ├── GeometryEditor.js
│ │ ├── IndexedTypedGeometry.js
│ │ ├── PlaneTypedGeometry.js
│ │ ├── ProxyGeometry.js
│ │ ├── TypedGeometry.js
│ │ ├── benchmark
│ │ ├── BoxGeometry2.js
│ │ ├── Geometry2.js
│ │ ├── Geometry2Loader.js
│ │ ├── Geometry3.js
│ │ ├── Geometry4.js
│ │ ├── Geometry5.js
│ │ ├── Geometry5b.js
│ │ ├── IndexedGeometry3.js
│ │ ├── IndexedGeometry5.js
│ │ ├── IndexedPlaneGeometry5.js
│ │ ├── PlaneGeometry.js
│ │ ├── PlaneGeometry2.js
│ │ ├── PlaneGeometry2b.js
│ │ ├── PlaneGeometry3.js
│ │ ├── PlaneGeometry5.js
│ │ ├── PlaneGeometry6.js
│ │ ├── PlaneGeometry99.js
│ │ └── TypedGeometry.js
│ │ └── proxies
│ │ ├── MultiColor.js
│ │ ├── MultiVector3.js
│ │ ├── ProxyColor.js
│ │ ├── ProxyFace3.js
│ │ ├── ProxyVector2.js
│ │ ├── ProxyVector3.js
│ │ └── ProxyVector4.js
│ └── tiny-sdf.js
├── scripts
├── build
├── closure-compiler
│ └── compiler.jar
├── color
│ ├── cie.py
│ └── lin2012xyz2e_fine_7sf.csv
├── frameserver.js
├── metalParser.py
└── pngPacker.html
└── shaders
├── ao-fragment-shader.glsl
├── ao-vertex-shader.glsl
├── normals-fragment-shader.glsl
├── normals-vertex-shader.glsl
├── pathtracer-fragment-shader.glsl
├── pathtracer-vertex-shader.glsl
├── pick-fragment-shader.glsl
├── pick-vertex-shader.glsl
├── simplepathtracer-fragment-shader.glsl
├── simplepathtracer-vertex-shader.glsl
├── tonemapper-fragment-shader.glsl
└── tonemapper-vertex-shader.glsl
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License
2 |
3 | Copyright (c) 2017 Jamie Portsmouth
4 |
5 | Permission is hereby granted, free of charge,
6 | to any person obtaining a copy of this software and
7 | associated documentation files (the "Software"), to
8 | deal in the Software without restriction, including
9 | without limitation the rights to use, copy, modify,
10 | merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom
12 | the Software is furnished to do so,
13 | subject to the following conditions:
14 |
15 | The above copyright notice and this permission notice
16 | shall be included in all copies or substantial portions of the Software.
17 |
18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
22 | ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/docs/API.hbs:
--------------------------------------------------------------------------------
1 |
2 | {{>main}}
3 |
4 |
--------------------------------------------------------------------------------
/docs/screenshots/apollonian_firsthit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portsmouth/snelly/570ed2abbc4217b21aa56e7da72a020397626f53/docs/screenshots/apollonian_firsthit.png
--------------------------------------------------------------------------------
/docs/screenshots/apollonian_firsthit_thumb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portsmouth/snelly/570ed2abbc4217b21aa56e7da72a020397626f53/docs/screenshots/apollonian_firsthit_thumb.png
--------------------------------------------------------------------------------
/docs/screenshots/apollonian_pt.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portsmouth/snelly/570ed2abbc4217b21aa56e7da72a020397626f53/docs/screenshots/apollonian_pt.png
--------------------------------------------------------------------------------
/docs/screenshots/apollonian_pt_thumb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portsmouth/snelly/570ed2abbc4217b21aa56e7da72a020397626f53/docs/screenshots/apollonian_pt_thumb.png
--------------------------------------------------------------------------------
/docs/screenshots/armadillo_thumb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portsmouth/snelly/570ed2abbc4217b21aa56e7da72a020397626f53/docs/screenshots/armadillo_thumb.png
--------------------------------------------------------------------------------
/docs/screenshots/basicAnimation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portsmouth/snelly/570ed2abbc4217b21aa56e7da72a020397626f53/docs/screenshots/basicAnimation.png
--------------------------------------------------------------------------------
/docs/screenshots/basicAnimation_thumb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portsmouth/snelly/570ed2abbc4217b21aa56e7da72a020397626f53/docs/screenshots/basicAnimation_thumb.png
--------------------------------------------------------------------------------
/docs/screenshots/bounce_thumb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portsmouth/snelly/570ed2abbc4217b21aa56e7da72a020397626f53/docs/screenshots/bounce_thumb.png
--------------------------------------------------------------------------------
/docs/screenshots/bunny_thumb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portsmouth/snelly/570ed2abbc4217b21aa56e7da72a020397626f53/docs/screenshots/bunny_thumb.png
--------------------------------------------------------------------------------
/docs/screenshots/city_thumb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portsmouth/snelly/570ed2abbc4217b21aa56e7da72a020397626f53/docs/screenshots/city_thumb.png
--------------------------------------------------------------------------------
/docs/screenshots/distanceViz_thumb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portsmouth/snelly/570ed2abbc4217b21aa56e7da72a020397626f53/docs/screenshots/distanceViz_thumb.png
--------------------------------------------------------------------------------
/docs/screenshots/font_sdf_thumb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portsmouth/snelly/570ed2abbc4217b21aa56e7da72a020397626f53/docs/screenshots/font_sdf_thumb.png
--------------------------------------------------------------------------------
/docs/screenshots/gem.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portsmouth/snelly/570ed2abbc4217b21aa56e7da72a020397626f53/docs/screenshots/gem.png
--------------------------------------------------------------------------------
/docs/screenshots/gem_thumb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portsmouth/snelly/570ed2abbc4217b21aa56e7da72a020397626f53/docs/screenshots/gem_thumb.png
--------------------------------------------------------------------------------
/docs/screenshots/glassPolyhedron_thumb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portsmouth/snelly/570ed2abbc4217b21aa56e7da72a020397626f53/docs/screenshots/glassPolyhedron_thumb.png
--------------------------------------------------------------------------------
/docs/screenshots/hand_thumb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portsmouth/snelly/570ed2abbc4217b21aa56e7da72a020397626f53/docs/screenshots/hand_thumb.png
--------------------------------------------------------------------------------
/docs/screenshots/helloWorld.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portsmouth/snelly/570ed2abbc4217b21aa56e7da72a020397626f53/docs/screenshots/helloWorld.png
--------------------------------------------------------------------------------
/docs/screenshots/helloWorld_thumb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portsmouth/snelly/570ed2abbc4217b21aa56e7da72a020397626f53/docs/screenshots/helloWorld_thumb.png
--------------------------------------------------------------------------------
/docs/screenshots/helloWorld_thumb2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portsmouth/snelly/570ed2abbc4217b21aa56e7da72a020397626f53/docs/screenshots/helloWorld_thumb2.png
--------------------------------------------------------------------------------
/docs/screenshots/lattice_dielectric.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portsmouth/snelly/570ed2abbc4217b21aa56e7da72a020397626f53/docs/screenshots/lattice_dielectric.png
--------------------------------------------------------------------------------
/docs/screenshots/lattice_dielectric_thumb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portsmouth/snelly/570ed2abbc4217b21aa56e7da72a020397626f53/docs/screenshots/lattice_dielectric_thumb.png
--------------------------------------------------------------------------------
/docs/screenshots/lattice_metallic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portsmouth/snelly/570ed2abbc4217b21aa56e7da72a020397626f53/docs/screenshots/lattice_metallic.png
--------------------------------------------------------------------------------
/docs/screenshots/lattice_metallic_thumb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portsmouth/snelly/570ed2abbc4217b21aa56e7da72a020397626f53/docs/screenshots/lattice_metallic_thumb.png
--------------------------------------------------------------------------------
/docs/screenshots/lattice_mixed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portsmouth/snelly/570ed2abbc4217b21aa56e7da72a020397626f53/docs/screenshots/lattice_mixed.png
--------------------------------------------------------------------------------
/docs/screenshots/lattice_mixed_thumb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portsmouth/snelly/570ed2abbc4217b21aa56e7da72a020397626f53/docs/screenshots/lattice_mixed_thumb.png
--------------------------------------------------------------------------------
/docs/screenshots/mandelbox.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portsmouth/snelly/570ed2abbc4217b21aa56e7da72a020397626f53/docs/screenshots/mandelbox.png
--------------------------------------------------------------------------------
/docs/screenshots/mandelbox_thumb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portsmouth/snelly/570ed2abbc4217b21aa56e7da72a020397626f53/docs/screenshots/mandelbox_thumb.png
--------------------------------------------------------------------------------
/docs/screenshots/math_dielectric_thumb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portsmouth/snelly/570ed2abbc4217b21aa56e7da72a020397626f53/docs/screenshots/math_dielectric_thumb.png
--------------------------------------------------------------------------------
/docs/screenshots/math_sdf_thumb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portsmouth/snelly/570ed2abbc4217b21aa56e7da72a020397626f53/docs/screenshots/math_sdf_thumb.png
--------------------------------------------------------------------------------
/docs/screenshots/menger.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portsmouth/snelly/570ed2abbc4217b21aa56e7da72a020397626f53/docs/screenshots/menger.png
--------------------------------------------------------------------------------
/docs/screenshots/mengerBunny_thumb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portsmouth/snelly/570ed2abbc4217b21aa56e7da72a020397626f53/docs/screenshots/mengerBunny_thumb.png
--------------------------------------------------------------------------------
/docs/screenshots/mengerHead_thumb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portsmouth/snelly/570ed2abbc4217b21aa56e7da72a020397626f53/docs/screenshots/mengerHead_thumb.png
--------------------------------------------------------------------------------
/docs/screenshots/menger_thumb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portsmouth/snelly/570ed2abbc4217b21aa56e7da72a020397626f53/docs/screenshots/menger_thumb.png
--------------------------------------------------------------------------------
/docs/screenshots/meteorite.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portsmouth/snelly/570ed2abbc4217b21aa56e7da72a020397626f53/docs/screenshots/meteorite.png
--------------------------------------------------------------------------------
/docs/screenshots/meteorite_thumb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portsmouth/snelly/570ed2abbc4217b21aa56e7da72a020397626f53/docs/screenshots/meteorite_thumb.png
--------------------------------------------------------------------------------
/docs/screenshots/pyroclastic_thumb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portsmouth/snelly/570ed2abbc4217b21aa56e7da72a020397626f53/docs/screenshots/pyroclastic_thumb.png
--------------------------------------------------------------------------------
/docs/screenshots/rock.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portsmouth/snelly/570ed2abbc4217b21aa56e7da72a020397626f53/docs/screenshots/rock.png
--------------------------------------------------------------------------------
/docs/screenshots/rock_thumb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portsmouth/snelly/570ed2abbc4217b21aa56e7da72a020397626f53/docs/screenshots/rock_thumb.png
--------------------------------------------------------------------------------
/docs/screenshots/volumeBunny_thumb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portsmouth/snelly/570ed2abbc4217b21aa56e7da72a020397626f53/docs/screenshots/volumeBunny_thumb.png
--------------------------------------------------------------------------------
/docs/screenshots/volumeCheckerboard_thumb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portsmouth/snelly/570ed2abbc4217b21aa56e7da72a020397626f53/docs/screenshots/volumeCheckerboard_thumb.png
--------------------------------------------------------------------------------
/docs/screenshots/volumetricMath_thumb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portsmouth/snelly/570ed2abbc4217b21aa56e7da72a020397626f53/docs/screenshots/volumetricMath_thumb.png
--------------------------------------------------------------------------------
/js/thirdparty/three/Detector.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | * @author mr.doob / http://mrdoob.com/
4 | */
5 |
6 | var Detector = {
7 |
8 | canvas: !! window.CanvasRenderingContext2D,
9 | webgl: ( function () { try { var canvas = document.createElement( 'canvas' ); return !! ( window.WebGLRenderingContext && ( canvas.getContext( 'webgl' ) || canvas.getContext( 'experimental-webgl' ) ) ); } catch ( e ) { return false; } } )(),
10 | workers: !! window.Worker,
11 | fileapi: window.File && window.FileReader && window.FileList && window.Blob,
12 |
13 | getWebGLErrorMessage: function () {
14 |
15 | var element = document.createElement( 'div' );
16 | element.id = 'webgl-error-message';
17 | element.style.fontFamily = 'monospace';
18 | element.style.fontSize = '13px';
19 | element.style.fontWeight = 'normal';
20 | element.style.textAlign = 'center';
21 | element.style.background = '#fff';
22 | element.style.color = '#000';
23 | element.style.padding = '1.5em';
24 | element.style.width = '400px';
25 | element.style.margin = '5em auto 0';
26 |
27 | if ( ! this.webgl ) {
28 |
29 | element.innerHTML = window.WebGLRenderingContext ? [
30 | 'Your graphics card does not seem to support WebGL.
',
31 | 'Find out how to get it here.'
32 | ].join( '\n' ) : [
33 | 'Your browser does not seem to support WebGL.
',
34 | 'Find out how to get it here.'
35 | ].join( '\n' );
36 |
37 | }
38 |
39 | return element;
40 |
41 | },
42 |
43 | addGetWebGLMessage: function ( parameters ) {
44 |
45 | var parent, id, element;
46 |
47 | parameters = parameters || {};
48 |
49 | parent = parameters.parent !== undefined ? parameters.parent : document.body;
50 | id = parameters.id !== undefined ? parameters.id : 'oldie';
51 |
52 | element = Detector.getWebGLErrorMessage();
53 | element.id = id;
54 |
55 | parent.appendChild( element );
56 |
57 | }
58 |
59 | };
60 |
61 | // browserify support
62 | if ( typeof module === 'object' ) {
63 |
64 | module.exports = Detector;
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/js/thirdparty/three/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/thirdparty/three/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/thirdparty/three/UCSCharacter.js:
--------------------------------------------------------------------------------
1 | THREE.UCSCharacter = function() {
2 |
3 | var scope = this;
4 |
5 | var mesh;
6 |
7 | this.scale = 1;
8 |
9 | this.root = new THREE.Object3D();
10 |
11 | this.numSkins;
12 | this.numMorphs;
13 |
14 | this.skins = [];
15 | this.materials = [];
16 | this.morphs = [];
17 |
18 | this.onLoadComplete = function () {};
19 |
20 | this.loadCounter = 0;
21 |
22 | this.loadParts = function ( config ) {
23 |
24 | this.numSkins = config.skins.length;
25 | this.numMorphs = config.morphs.length;
26 |
27 | // Character geometry + number of skins
28 | this.loadCounter = 1 + config.skins.length;
29 |
30 | // SKINS
31 | this.skins = loadTextures( config.baseUrl + "skins/", config.skins );
32 | this.materials = createMaterials( this.skins );
33 |
34 | // MORPHS
35 | this.morphs = config.morphs;
36 |
37 | // CHARACTER
38 | var loader = new THREE.JSONLoader();
39 | console.log( config.baseUrl + config.character );
40 | loader.load( config.baseUrl + config.character, function( geometry ) {
41 | geometry.computeBoundingBox();
42 | geometry.computeVertexNormals();
43 |
44 | //THREE.AnimationHandler.add( geometry.animation );
45 |
46 | mesh = new THREE.SkinnedMesh( geometry, new THREE.MeshFaceMaterial() );
47 | scope.root.add( mesh );
48 |
49 | var bb = geometry.boundingBox;
50 | scope.root.scale.set( config.s, config.s, config.s );
51 | scope.root.position.set( config.x, config.y - bb.min.y * config.s, config.z );
52 |
53 | mesh.castShadow = true;
54 | mesh.receiveShadow = true;
55 |
56 | animation = new THREE.Animation( mesh, geometry.animation );
57 | animation.play();
58 |
59 | scope.setSkin(0);
60 |
61 | scope.checkLoadComplete();
62 | } );
63 |
64 | };
65 |
66 | this.setSkin = function( index ) {
67 | if ( mesh && scope.materials ) {
68 | mesh.material = scope.materials[ index ];
69 | }
70 | };
71 |
72 | this.updateMorphs = function( influences ) {
73 | if ( mesh ) {
74 | for ( var i = 0; i < scope.numMorphs; i ++ ) {
75 | mesh.morphTargetInfluences[ i ] = influences[ scope.morphs[ i ] ] / 100;
76 | }
77 | }
78 | }
79 |
80 | function loadTextures( baseUrl, textureUrls ) {
81 | var mapping = THREE.UVMapping;
82 | var textures = [];
83 |
84 | for ( var i = 0; i < textureUrls.length; i ++ ) {
85 |
86 | textures[ i ] = THREE.ImageUtils.loadTexture( baseUrl + textureUrls[ i ], mapping, scope.checkLoadComplete );
87 | textures[ i ].name = textureUrls[ i ];
88 |
89 | }
90 |
91 | return textures;
92 | };
93 |
94 | function createMaterials( skins ) {
95 | var materials = [];
96 |
97 | for ( var i = 0; i < skins.length; i ++ ) {
98 |
99 | materials[ i ] = new THREE.MeshLambertMaterial( {
100 | color: 0xeeeeee,
101 | specular: 10.0,
102 | map: skins[ i ],
103 | skinning: true,
104 | morphTargets: true,
105 | wrapAround: true
106 | } );
107 |
108 | }
109 |
110 | return materials;
111 | }
112 |
113 | this.checkLoadComplete = function () {
114 |
115 | scope.loadCounter -= 1;
116 |
117 | if ( scope.loadCounter === 0 ) {
118 |
119 | scope.onLoadComplete();
120 |
121 | }
122 |
123 | }
124 |
125 | }
126 |
--------------------------------------------------------------------------------
/js/thirdparty/three/controls/DeviceOrientationControls.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author richt / http://richt.me
3 | * @author WestLangley / http://github.com/WestLangley
4 | *
5 | * W3C Device Orientation control (http://w3c.github.io/deviceorientation/spec-source-orientation.html)
6 | */
7 |
8 | THREE.DeviceOrientationControls = function ( object ) {
9 |
10 | var scope = this;
11 |
12 | this.object = object;
13 | this.object.rotation.reorder( "YXZ" );
14 |
15 | this.enabled = true;
16 |
17 | this.deviceOrientation = {};
18 | this.screenOrientation = 0;
19 |
20 | var onDeviceOrientationChangeEvent = function ( event ) {
21 |
22 | scope.deviceOrientation = event;
23 |
24 | };
25 |
26 | var onScreenOrientationChangeEvent = function () {
27 |
28 | scope.screenOrientation = window.orientation || 0;
29 |
30 | };
31 |
32 | // The angles alpha, beta and gamma form a set of intrinsic Tait-Bryan angles of type Z-X'-Y''
33 |
34 | var setObjectQuaternion = function () {
35 |
36 | var zee = new THREE.Vector3( 0, 0, 1 );
37 |
38 | var euler = new THREE.Euler();
39 |
40 | var q0 = new THREE.Quaternion();
41 |
42 | var q1 = new THREE.Quaternion( - Math.sqrt( 0.5 ), 0, 0, Math.sqrt( 0.5 ) ); // - PI/2 around the x-axis
43 |
44 | return function ( quaternion, alpha, beta, gamma, orient ) {
45 |
46 | euler.set( beta, alpha, - gamma, 'YXZ' ); // 'ZXY' for the device, but 'YXZ' for us
47 |
48 | quaternion.setFromEuler( euler ); // orient the device
49 |
50 | quaternion.multiply( q1 ); // camera looks out the back of the device, not the top
51 |
52 | quaternion.multiply( q0.setFromAxisAngle( zee, - orient ) ); // adjust for screen orientation
53 |
54 | }
55 |
56 | }();
57 |
58 | this.connect = function() {
59 |
60 | onScreenOrientationChangeEvent(); // run once on load
61 |
62 | window.addEventListener( 'orientationchange', onScreenOrientationChangeEvent, false );
63 | window.addEventListener( 'deviceorientation', onDeviceOrientationChangeEvent, false );
64 |
65 | scope.enabled = true;
66 |
67 | };
68 |
69 | this.disconnect = function() {
70 |
71 | window.removeEventListener( 'orientationchange', onScreenOrientationChangeEvent, false );
72 | window.removeEventListener( 'deviceorientation', onDeviceOrientationChangeEvent, false );
73 |
74 | scope.enabled = false;
75 |
76 | };
77 |
78 | this.update = function () {
79 |
80 | if ( scope.enabled === false ) return;
81 |
82 | var alpha = scope.deviceOrientation.alpha ? THREE.Math.degToRad( scope.deviceOrientation.alpha ) : 0; // Z
83 | var beta = scope.deviceOrientation.beta ? THREE.Math.degToRad( scope.deviceOrientation.beta ) : 0; // X'
84 | var gamma = scope.deviceOrientation.gamma ? THREE.Math.degToRad( scope.deviceOrientation.gamma ) : 0; // Y''
85 | var orient = scope.screenOrientation ? THREE.Math.degToRad( scope.screenOrientation ) : 0; // O
86 |
87 | setObjectQuaternion( scope.object.quaternion, alpha, beta, gamma, orient );
88 |
89 | };
90 |
91 | this.connect();
92 |
93 | };
94 |
--------------------------------------------------------------------------------
/js/thirdparty/three/controls/MouseControls.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author dmarcos / http://github.com/dmarcos
3 | *
4 | * This controls allow to change the orientation of the camera using the mouse
5 | */
6 |
7 | THREE.MouseControls = function ( object ) {
8 |
9 | var scope = this;
10 | var PI_2 = Math.PI / 2;
11 | var mouseQuat = {
12 | x: new THREE.Quaternion(),
13 | y: new THREE.Quaternion()
14 | };
15 | var object = object;
16 | var xVector = new THREE.Vector3( 1, 0, 0 );
17 | var yVector = new THREE.Vector3( 0, 1, 0 );
18 |
19 | var onMouseMove = function ( event ) {
20 |
21 | if ( scope.enabled === false ) return;
22 |
23 | var orientation = scope.orientation;
24 |
25 | var movementX = event.movementX || event.mozMovementX || event.webkitMovementX || 0;
26 | var movementY = event.movementY || event.mozMovementY || event.webkitMovementY || 0;
27 |
28 | orientation.y += movementX * 0.0025;
29 | orientation.x += movementY * 0.0025;
30 |
31 | orientation.x = Math.max( - PI_2, Math.min( PI_2, orientation.x ) );
32 |
33 | };
34 |
35 | this.enabled = true;
36 |
37 | this.orientation = {
38 | x: 0,
39 | y: 0,
40 | };
41 |
42 | this.update = function() {
43 |
44 | if ( this.enabled === false ) return;
45 |
46 | mouseQuat.x.setFromAxisAngle( xVector, this.orientation.x );
47 | mouseQuat.y.setFromAxisAngle( yVector, this.orientation.y );
48 | object.quaternion.copy(mouseQuat.y).multiply(mouseQuat.x)
49 | return;
50 |
51 | };
52 |
53 | document.addEventListener( 'mousemove', onMouseMove, false );
54 |
55 | };
56 |
--------------------------------------------------------------------------------
/js/thirdparty/three/controls/PointerLockControls.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author mrdoob / http://mrdoob.com/
3 | */
4 |
5 | THREE.PointerLockControls = function ( camera ) {
6 |
7 | var scope = this;
8 |
9 | camera.rotation.set( 0, 0, 0 );
10 |
11 | var pitchObject = new THREE.Object3D();
12 | pitchObject.add( camera );
13 |
14 | var yawObject = new THREE.Object3D();
15 | yawObject.position.y = 10;
16 | yawObject.add( pitchObject );
17 |
18 | var PI_2 = Math.PI / 2;
19 |
20 | var onMouseMove = function ( event ) {
21 |
22 | if ( scope.enabled === false ) return;
23 |
24 | var movementX = event.movementX || event.mozMovementX || event.webkitMovementX || 0;
25 | var movementY = event.movementY || event.mozMovementY || event.webkitMovementY || 0;
26 |
27 | yawObject.rotation.y -= movementX * 0.002;
28 | pitchObject.rotation.x -= movementY * 0.002;
29 |
30 | pitchObject.rotation.x = Math.max( - PI_2, Math.min( PI_2, pitchObject.rotation.x ) );
31 |
32 | };
33 |
34 | document.addEventListener( 'mousemove', onMouseMove, false );
35 |
36 | this.enabled = false;
37 |
38 | this.getObject = function () {
39 |
40 | return yawObject;
41 |
42 | };
43 |
44 | this.getDirection = function() {
45 |
46 | // assumes the camera itself is not rotated
47 |
48 | var direction = new THREE.Vector3( 0, 0, -1 );
49 | var rotation = new THREE.Euler( 0, 0, 0, "YXZ" );
50 |
51 | return function( v ) {
52 |
53 | rotation.set( pitchObject.rotation.x, yawObject.rotation.y, 0 );
54 |
55 | v.copy( direction ).applyEuler( rotation );
56 |
57 | return v;
58 |
59 | }
60 |
61 | }();
62 |
63 | };
64 |
--------------------------------------------------------------------------------
/js/thirdparty/three/controls/VRControls.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author dmarcos / https://github.com/dmarcos
3 | * @author mrdoob / http://mrdoob.com
4 | */
5 |
6 | THREE.VRControls = function ( object, callback ) {
7 |
8 | var scope = this;
9 |
10 | var vrInput;
11 |
12 | var onVRDevices = function ( devices ) {
13 |
14 | for ( var i = 0; i < devices.length; i ++ ) {
15 |
16 | var device = devices[ i ];
17 |
18 | if ( device instanceof PositionSensorVRDevice ) {
19 |
20 | vrInput = devices[ i ];
21 | return; // We keep the first we encounter
22 |
23 | }
24 |
25 | }
26 |
27 | if ( callback !== undefined ) {
28 |
29 | callback( 'HMD not available' );
30 |
31 | }
32 |
33 | };
34 |
35 | if ( navigator.getVRDevices !== undefined ) {
36 |
37 | navigator.getVRDevices().then( onVRDevices );
38 |
39 | } else if ( callback !== undefined ) {
40 |
41 | callback( 'Your browser is not VR Ready' );
42 |
43 | }
44 |
45 | // the Rift SDK returns the position in meters
46 | // this scale factor allows the user to define how meters
47 | // are converted to scene units.
48 | this.scale = 1;
49 |
50 | this.update = function () {
51 |
52 | if ( vrInput === undefined ) return;
53 |
54 | var state = vrInput.getState();
55 |
56 | if ( state.orientation !== null ) {
57 |
58 | object.quaternion.copy( state.orientation );
59 |
60 | }
61 |
62 | if ( state.position !== null ) {
63 |
64 | object.position.copy( state.position ).multiplyScalar( scope.scale );
65 |
66 | }
67 |
68 | };
69 |
70 | this.zeroSensor = function () {
71 |
72 | if ( vrInput === undefined ) return;
73 |
74 | vrInput.zeroSensor();
75 |
76 | };
77 |
78 | };
79 |
--------------------------------------------------------------------------------
/js/thirdparty/three/crossfade/gui.js:
--------------------------------------------------------------------------------
1 | var transitionParams = {
2 | "useTexture": true,
3 | "transition": 0.5,
4 | "transitionSpeed": 2.0,
5 | "texture": 5,
6 | "loopTexture": true,
7 | "animateTransition": true,
8 | "textureThreshold": 0.3
9 | };
10 |
11 | function initGUI() {
12 |
13 | var gui = new dat.GUI();
14 |
15 | gui.add(transitionParams, "useTexture").onChange(function(value) {
16 |
17 | transition.useTexture(value);
18 |
19 | });
20 |
21 | gui.add(transitionParams, 'loopTexture');
22 |
23 | gui.add(transitionParams, 'texture', { Perlin: 0, Squares: 1, Cells: 2, Distort: 3, Gradient: 4, Radial: 5 } ).onChange(function(value) {
24 |
25 | transition.setTexture(value);
26 |
27 | }).listen();
28 |
29 | gui.add(transitionParams, "textureThreshold", 0, 1, 0.01).onChange(function(value) {
30 |
31 | transition.setTextureThreshold(value);
32 |
33 | });
34 |
35 | gui.add(transitionParams, "animateTransition");
36 | gui.add(transitionParams, "transition", 0, 1, 0.01).listen();
37 | gui.add(transitionParams, "transitionSpeed", 0.5, 5, 0.01);
38 |
39 | }
--------------------------------------------------------------------------------
/js/thirdparty/three/crossfade/scenes.js:
--------------------------------------------------------------------------------
1 | function generateGeometry(objectType, numObjects) {
2 |
3 | var geometry = new THREE.Geometry();
4 |
5 | function applyVertexColors( g, c ) {
6 |
7 | g.faces.forEach( function( f ) {
8 |
9 | var n = ( f instanceof THREE.Face3 ) ? 3 : 4;
10 |
11 | for ( var j = 0; j < n; j ++ ) {
12 |
13 | f.vertexColors[ j ] = c;
14 |
15 | }
16 |
17 | } );
18 |
19 | }
20 |
21 | for ( var i = 0; i < numObjects; i ++ ) {
22 |
23 | var position = new THREE.Vector3();
24 |
25 | position.x = Math.random() * 10000 - 5000;
26 | position.y = Math.random() * 6000 - 3000;
27 | position.z = Math.random() * 8000 - 4000;
28 |
29 | var rotation = new THREE.Euler();
30 |
31 | rotation.x = Math.random() * 2 * Math.PI;
32 | rotation.y = Math.random() * 2 * Math.PI;
33 | rotation.z = Math.random() * 2 * Math.PI;
34 |
35 | var scale = new THREE.Vector3();
36 |
37 | var geom, color = new THREE.Color();
38 |
39 | scale.x = Math.random() * 200 + 100;
40 |
41 | if ( objectType == "cube" )
42 | {
43 | geom = new THREE.BoxGeometry( 1, 1, 1 );
44 | scale.y = Math.random() * 200 + 100;
45 | scale.z = Math.random() * 200 + 100;
46 | color.setRGB( 0, 0, Math.random() + 0.1 );
47 | }
48 | else if ( objectType == "sphere" )
49 | {
50 | geom = new THREE.IcosahedronGeometry( 1, 1 )
51 | scale.y = scale.z = scale.x;
52 | color.setRGB( Math.random() + 0.1, 0, 0 );
53 | }
54 |
55 | // give the geom's vertices a random color, to be displayed
56 | applyVertexColors( geom, color );
57 |
58 | var mesh = new THREE.Mesh( geom );
59 | mesh.position.copy( position );
60 | mesh.rotation.copy( rotation );
61 | mesh.scale.copy( scale );
62 | mesh.updateMatrix();
63 |
64 | geometry.merge( mesh.geometry, mesh.matrix );
65 |
66 | }
67 |
68 | return geometry;
69 |
70 | }
71 |
72 | function Scene ( type, numObjects, cameraZ, fov, rotationSpeed, clearColor ) {
73 |
74 | this.clearColor = clearColor;
75 |
76 | this.camera = new THREE.PerspectiveCamera( fov, window.innerWidth / window.innerHeight, 1, 10000 );
77 | this.camera.position.z = cameraZ;
78 |
79 | // Setup scene
80 | this.scene = new THREE.Scene();
81 | this.scene.add( new THREE.AmbientLight( 0x555555 ) );
82 |
83 | var light = new THREE.SpotLight( 0xffffff, 1.5 );
84 | light.position.set( 0, 500, 2000 );
85 | this.scene.add( light );
86 |
87 | this.rotationSpeed = rotationSpeed;
88 | defaultMaterial = new THREE.MeshLambertMaterial({ color: 0xffffff, shading: THREE.FlatShading, vertexColors: THREE.VertexColors } );
89 | this.mesh = new THREE.Mesh( generateGeometry( type, numObjects ), defaultMaterial );
90 | this.scene.add( this.mesh );
91 |
92 | renderTargetParameters = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBFormat, stencilBuffer: false };
93 | this.fbo = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, renderTargetParameters );
94 |
95 | this.render = function( delta, rtt ) {
96 |
97 | this.mesh.rotation.x += delta * this.rotationSpeed.x;
98 | this.mesh.rotation.y += delta * this.rotationSpeed.y;
99 | this.mesh.rotation.z += delta * this.rotationSpeed.z;
100 |
101 | renderer.setClearColor( this.clearColor );
102 |
103 | if (rtt)
104 | renderer.render( this.scene, this.camera, this.fbo, true );
105 | else
106 | renderer.render( this.scene, this.camera );
107 |
108 | };
109 | }
110 |
--------------------------------------------------------------------------------
/js/thirdparty/three/curves/NURBSCurve.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author renej
3 | * NURBS curve object
4 | *
5 | * Derives from Curve, overriding getPoint and getTangent.
6 | *
7 | * Implementation is based on (x, y [, z=0 [, w=1]]) control points with w=weight.
8 | *
9 | **/
10 |
11 |
12 | /**************************************************************
13 | * NURBS curve
14 | **************************************************************/
15 |
16 | THREE.NURBSCurve = function ( degree, knots /* array of reals */, controlPoints /* array of Vector(2|3|4) */) {
17 |
18 | this.degree = degree;
19 | this.knots = knots;
20 | this.controlPoints = [];
21 | for (var i = 0; i < controlPoints.length; ++ i) { // ensure Vector4 for control points
22 | var point = controlPoints[i];
23 | this.controlPoints[i] = new THREE.Vector4(point.x, point.y, point.z, point.w);
24 | }
25 |
26 | };
27 |
28 |
29 | THREE.NURBSCurve.prototype = Object.create( THREE.Curve.prototype );
30 | THREE.NURBSCurve.prototype.constructor = THREE.NURBSCurve;
31 |
32 |
33 | THREE.NURBSCurve.prototype.getPoint = function ( t ) {
34 |
35 | var u = this.knots[0] + t * (this.knots[this.knots.length - 1] - this.knots[0]); // linear mapping t->u
36 |
37 | // following results in (wx, wy, wz, w) homogeneous point
38 | var hpoint = THREE.NURBSUtils.calcBSplinePoint(this.degree, this.knots, this.controlPoints, u);
39 |
40 | if (hpoint.w != 1.0) { // project to 3D space: (wx, wy, wz, w) -> (x, y, z, 1)
41 | hpoint.divideScalar(hpoint.w);
42 | }
43 |
44 | return new THREE.Vector3(hpoint.x, hpoint.y, hpoint.z);
45 | };
46 |
47 |
48 | THREE.NURBSCurve.prototype.getTangent = function ( t ) {
49 |
50 | var u = this.knots[0] + t * (this.knots[this.knots.length - 1] - this.knots[0]);
51 | var ders = THREE.NURBSUtils.calcNURBSDerivatives(this.degree, this.knots, this.controlPoints, u, 1);
52 | var tangent = ders[1].clone();
53 | tangent.normalize();
54 |
55 | return tangent;
56 | };
57 |
58 |
--------------------------------------------------------------------------------
/js/thirdparty/three/curves/NURBSSurface.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author renej
3 | * NURBS surface object
4 | *
5 | * Implementation is based on (x, y [, z=0 [, w=1]]) control points with w=weight.
6 | *
7 | **/
8 |
9 |
10 | /**************************************************************
11 | * NURBS surface
12 | **************************************************************/
13 |
14 | THREE.NURBSSurface = function ( degree1, degree2, knots1, knots2 /* arrays of reals */, controlPoints /* array^2 of Vector(2|3|4) */) {
15 |
16 | this.degree1 = degree1;
17 | this.degree2 = degree2;
18 | this.knots1 = knots1;
19 | this.knots2 = knots2;
20 | this.controlPoints = [];
21 |
22 | var len1 = knots1.length - degree1 - 1;
23 | var len2 = knots2.length - degree2 - 1;
24 |
25 | // ensure Vector4 for control points
26 | for (var i = 0; i < len1; ++ i) {
27 | this.controlPoints[i] = []
28 | for (var j = 0; j < len2; ++ j) {
29 | var point = controlPoints[i][j];
30 | this.controlPoints[i][j] = new THREE.Vector4(point.x, point.y, point.z, point.w);
31 | }
32 | }
33 | };
34 |
35 |
36 | THREE.NURBSSurface.prototype = {
37 |
38 | constructor: THREE.NURBSSurface,
39 |
40 | getPoint: function ( t1, t2 ) {
41 |
42 | var u = this.knots1[0] + t1 * (this.knots1[this.knots1.length - 1] - this.knots1[0]); // linear mapping t1->u
43 | var v = this.knots2[0] + t2 * (this.knots2[this.knots2.length - 1] - this.knots2[0]); // linear mapping t2->u
44 |
45 | return THREE.NURBSUtils.calcSurfacePoint(this.degree1, this.degree2, this.knots1, this.knots2, this.controlPoints, u, v);
46 | }
47 | };
48 |
49 |
50 |
--------------------------------------------------------------------------------
/js/thirdparty/three/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 ( object ) {
12 |
13 | var output = '';
14 |
15 | var indexVertex = 0;
16 | var indexVertexUvs = 0
17 | var indexNormals = 0;
18 |
19 | var parseObject = function ( child ) {
20 |
21 | var nbVertex = 0;
22 | var nbVertexUvs = 0;
23 | var nbNormals = 0;
24 |
25 | var geometry = child.geometry;
26 |
27 | if ( geometry instanceof THREE.Geometry ) {
28 |
29 | output += 'o ' + child.name + '\n';
30 |
31 | for ( var i = 0, l = geometry.vertices.length; i < l; i ++ ) {
32 |
33 | var vertex = geometry.vertices[ i ].clone();
34 | vertex.applyMatrix4( child.matrixWorld );
35 |
36 | output += 'v ' + vertex.x + ' ' + vertex.y + ' ' + vertex.z + '\n';
37 |
38 | nbVertex ++;
39 |
40 | }
41 |
42 | // uvs
43 |
44 | for ( var i = 0, l = geometry.faceVertexUvs[ 0 ].length; i < l; i ++ ) {
45 |
46 | var vertexUvs = geometry.faceVertexUvs[ 0 ][ i ];
47 |
48 | for ( var j = 0; j < vertexUvs.length; j ++ ) {
49 |
50 | var uv = vertexUvs[ j ];
51 | vertex.applyMatrix4( child.matrixWorld );
52 |
53 | output += 'vt ' + uv.x + ' ' + uv.y + '\n';
54 |
55 | nbVertexUvs ++;
56 |
57 | }
58 |
59 | }
60 |
61 | // normals
62 |
63 | for ( var i = 0, l = geometry.faces.length; i < l; i ++ ) {
64 |
65 | var normals = geometry.faces[ i ].vertexNormals;
66 |
67 | for ( var j = 0; j < normals.length; j ++ ) {
68 |
69 | var normal = normals[ j ];
70 | output += 'vn ' + normal.x + ' ' + normal.y + ' ' + normal.z + '\n';
71 |
72 | nbNormals ++;
73 |
74 | }
75 |
76 | }
77 |
78 | // faces
79 |
80 | for ( var i = 0, j = 1, l = geometry.faces.length; i < l; i ++, j += 3 ) {
81 |
82 | var face = geometry.faces[ i ];
83 |
84 | output += 'f ';
85 | output += ( indexVertex + face.a + 1 ) + '/' + ( indexVertexUvs + j ) + '/' + ( indexNormals + j ) + ' ';
86 | output += ( indexVertex + face.b + 1 ) + '/' + ( indexVertexUvs + j + 1 ) + '/' + ( indexNormals + j + 1 ) + ' ';
87 | output += ( indexVertex + face.c + 1 ) + '/' + ( indexVertexUvs + j + 2 ) + '/' + ( indexNormals + j + 2 ) + '\n';
88 |
89 | }
90 |
91 | }
92 |
93 | // update index
94 | indexVertex += nbVertex;
95 | indexVertexUvs += nbVertexUvs;
96 | indexNormals += nbNormals;
97 |
98 | };
99 |
100 | object.traverse( parseObject );
101 |
102 | return output;
103 |
104 | }
105 |
106 | };
107 |
--------------------------------------------------------------------------------
/js/thirdparty/three/exporters/STLBinaryExporter.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author kovacsv / http://kovacsv.hu/
3 | * @author mrdoob / http://mrdoob.com/
4 | * @author mudcube / http://mudcu.be/
5 | */
6 |
7 | THREE.STLBinaryExporter = function () {};
8 |
9 | THREE.STLBinaryExporter.prototype = {
10 |
11 | constructor: THREE.STLBinaryExporter,
12 |
13 | parse: ( function () {
14 |
15 | var vector = new THREE.Vector3();
16 | var normalMatrixWorld = new THREE.Matrix3();
17 |
18 | return function ( scene ) {
19 |
20 | var triangles = 0;
21 | scene.traverse( function ( object ) {
22 | if ( !(object instanceof THREE.Mesh) ) return;
23 | triangles += object.geometry.faces.length;
24 | });
25 |
26 | var offset = 80; // skip header
27 | var bufferLength = triangles * 2 + triangles * 3 * 4 * 4 + 80 + 4;
28 | var arrayBuffer = new ArrayBuffer(bufferLength);
29 | var output = new DataView(arrayBuffer);
30 | output.setUint32(offset, triangles, true); offset += 4;
31 |
32 | scene.traverse( function ( object ) {
33 |
34 | if ( !(object instanceof THREE.Mesh) ) return;
35 | if ( !(object.geometry instanceof THREE.Geometry )) return;
36 |
37 | var geometry = object.geometry;
38 | var matrixWorld = object.matrixWorld;
39 |
40 | var vertices = geometry.vertices;
41 | var faces = geometry.faces;
42 |
43 | normalMatrixWorld.getNormalMatrix( matrixWorld );
44 |
45 | for ( var i = 0, l = faces.length; i < l; i ++ ) {
46 |
47 | var face = faces[ i ];
48 |
49 | vector.copy( face.normal ).applyMatrix3( normalMatrixWorld ).normalize();
50 |
51 | output.setFloat32(offset, vector.x, true); offset += 4; // normal
52 | output.setFloat32(offset, vector.y, true); offset += 4;
53 | output.setFloat32(offset, vector.z, true); offset += 4;
54 |
55 | var indices = [ face.a, face.b, face.c ];
56 |
57 | for ( var j = 0; j < 3; j ++ ) {
58 |
59 | vector.copy( vertices[ indices[ j ] ] ).applyMatrix4( matrixWorld );
60 |
61 | output.setFloat32(offset, vector.x, true); offset += 4; // vertices
62 | output.setFloat32(offset, vector.y, true); offset += 4;
63 | output.setFloat32(offset, vector.z, true); offset += 4;
64 |
65 | }
66 |
67 | output.setUint16(offset, 0, true); offset += 2; // attribute byte count
68 |
69 | }
70 |
71 | } );
72 |
73 | return output;
74 |
75 | };
76 |
77 | }() )
78 |
79 | };
--------------------------------------------------------------------------------
/js/thirdparty/three/exporters/STLExporter.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author kovacsv / http://kovacsv.hu/
3 | * @author mrdoob / http://mrdoob.com/
4 | */
5 |
6 | THREE.STLExporter = function () {};
7 |
8 | THREE.STLExporter.prototype = {
9 |
10 | constructor: THREE.STLExporter,
11 |
12 | parse: ( function () {
13 |
14 | var vector = new THREE.Vector3();
15 | var normalMatrixWorld = new THREE.Matrix3();
16 |
17 | return function ( scene ) {
18 |
19 | var output = '';
20 |
21 | output += 'solid exported\n';
22 |
23 | scene.traverse( function ( object ) {
24 |
25 | if ( object instanceof THREE.Mesh ) {
26 |
27 | var geometry = object.geometry;
28 | var matrixWorld = object.matrixWorld;
29 |
30 | if ( geometry instanceof THREE.Geometry ) {
31 |
32 | var vertices = geometry.vertices;
33 | var faces = geometry.faces;
34 |
35 | normalMatrixWorld.getNormalMatrix( matrixWorld );
36 |
37 | for ( var i = 0, l = faces.length; i < l; i ++ ) {
38 |
39 | var face = faces[ i ];
40 |
41 | vector.copy( face.normal ).applyMatrix3( normalMatrixWorld ).normalize();
42 |
43 | output += '\tfacet normal ' + vector.x + ' ' + vector.y + ' ' + vector.z + '\n';
44 | output += '\t\touter loop\n';
45 |
46 | var indices = [ face.a, face.b, face.c ];
47 |
48 | for ( var j = 0; j < 3; j ++ ) {
49 |
50 | vector.copy( vertices[ indices[ j ] ] ).applyMatrix4( matrixWorld );
51 |
52 | output += '\t\t\tvertex ' + vector.x + ' ' + vector.y + ' ' + vector.z + '\n';
53 |
54 | }
55 |
56 | output += '\t\tendloop\n';
57 | output += '\tendfacet\n';
58 |
59 | }
60 |
61 | }
62 |
63 | }
64 |
65 | } );
66 |
67 | output += 'endsolid exported\n';
68 |
69 | return output;
70 |
71 | };
72 |
73 | }() )
74 |
75 | };
--------------------------------------------------------------------------------
/js/thirdparty/three/exporters/TypedGeometryExporter.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author mrdoob / http://mrdoob.com/
3 | */
4 |
5 | THREE.TypedGeometryExporter = function () {};
6 |
7 | THREE.TypedGeometryExporter.prototype = {
8 |
9 | constructor: THREE.TypedGeometryExporter,
10 |
11 | parse: function ( geometry ) {
12 |
13 | var output = {
14 | metadata: {
15 | version: 4.0,
16 | type: 'TypedGeometry',
17 | generator: 'TypedGeometryExporter'
18 | }
19 | };
20 |
21 | var attributes = [ 'vertices', 'normals', 'uvs' ];
22 |
23 | for ( var key in attributes ) {
24 |
25 | var attribute = attributes[ key ];
26 |
27 | var typedArray = geometry[ attribute ];
28 | var array = [];
29 |
30 | for ( var i = 0, l = typedArray.length; i < l; i ++ ) {
31 |
32 | array[ i ] = typedArray[ i ];
33 |
34 | }
35 |
36 | output[ attribute ] = array;
37 |
38 | }
39 |
40 | var boundingSphere = geometry.boundingSphere;
41 |
42 | if ( boundingSphere !== null ) {
43 |
44 | output.boundingSphere = {
45 | center: boundingSphere.center.toArray(),
46 | radius: boundingSphere.radius
47 | }
48 |
49 | }
50 |
51 | return output;
52 |
53 | }
54 |
55 | };
56 |
--------------------------------------------------------------------------------
/js/thirdparty/three/geometries/hilbert2D.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Hilbert Curve: Generates 2D-Coordinates in a very fast way.
3 | *
4 | * @author Dylan Grafmyre
5 | *
6 | * Based on work by:
7 | * @author Thomas Diewald
8 | * @link http://www.openprocessing.org/sketch/15493
9 | *
10 | * @param center Center of Hilbert curve.
11 | * @param size Total width of Hilbert curve.
12 | * @param iterations Number of subdivisions.
13 | * @param v0 Corner index -X, -Z.
14 | * @param v1 Corner index -X, +Z.
15 | * @param v2 Corner index +X, +Z.
16 | * @param v3 Corner index +X, -Z.
17 | */
18 | function hilbert2D (center, size, iterations, v0, v1, v2, v3) {
19 | // Default Vars
20 | var center = undefined !== center ? center : new THREE.Vector3(0, 0, 0),
21 | size = undefined !== size ? size : 10,
22 | half = size / 2,
23 | iterations = undefined !== iterations ? iterations : 1,
24 | v0 = undefined !== v0 ? v0 : 0,
25 | v1 = undefined !== v1 ? v1 : 1,
26 | v2 = undefined !== v2 ? v2 : 2,
27 | v3 = undefined !== v3 ? v3 : 3
28 | ;
29 |
30 | var vec_s = [
31 | new THREE.Vector3( center.x - half, center.y, center.z - half ),
32 | new THREE.Vector3( center.x - half, center.y, center.z + half ),
33 | new THREE.Vector3( center.x + half, center.y, center.z + half ),
34 | new THREE.Vector3( center.x + half, center.y, center.z - half )
35 | ];
36 |
37 | var vec = [
38 | vec_s[ v0 ],
39 | vec_s[ v1 ],
40 | vec_s[ v2 ],
41 | vec_s[ v3 ]
42 | ];
43 |
44 | // Recurse iterations
45 | if (0 <= -- iterations) {
46 | var tmp = [];
47 |
48 | Array.prototype.push.apply( tmp, hilbert2D ( vec[ 0 ], half, iterations, v0, v3, v2, v1 ) );
49 | Array.prototype.push.apply( tmp, hilbert2D ( vec[ 1 ], half, iterations, v0, v1, v2, v3 ) );
50 | Array.prototype.push.apply( tmp, hilbert2D ( vec[ 2 ], half, iterations, v0, v1, v2, v3 ) );
51 | Array.prototype.push.apply( tmp, hilbert2D ( vec[ 3 ], half, iterations, v2, v1, v0, v3 ) );
52 |
53 | // Return recursive call
54 | return tmp;
55 | }
56 |
57 | // Return complete Hilbert Curve.
58 | return vec;
59 | }
60 |
--------------------------------------------------------------------------------
/js/thirdparty/three/geometries/hilbert3D.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Hilbert Curve: Generates 2D-Coordinates in a very fast way.
3 | *
4 | * @author Dylan Grafmyre
5 | *
6 | * Based on work by:
7 | * @author Thomas Diewald
8 | * @link http://www.openprocessing.org/visuals/?visualID=15599
9 | *
10 | * Based on `examples/canvas_lines_colors.html`:
11 | * @author OpenShift guest
12 | * @link https://github.com/mrdoob/three.js/blob/8413a860aa95ed29c79cbb7f857c97d7880d260f/examples/canvas_lines_colors.html
13 | * @see Line 149 - 186
14 | *
15 | * @param center Center of Hilbert curve.
16 | * @param size Total width of Hilbert curve.
17 | * @param iterations Number of subdivisions.
18 | * @param v0 Corner index -X, +Y, -Z.
19 | * @param v1 Corner index -X, +Y, +Z.
20 | * @param v2 Corner index -X, -Y, +Z.
21 | * @param v3 Corner index -X, -Y, -Z.
22 | * @param v4 Corner index +X, -Y, -Z.
23 | * @param v5 Corner index +X, -Y, +Z.
24 | * @param v6 Corner index +X, +Y, +Z.
25 | * @param v7 Corner index +X, +Y, -Z.
26 | */
27 | function hilbert3D(center, size, iterations, v0, v1, v2, v3, v4, v5, v6, v7) {
28 | // Default Vars
29 | var center = undefined !== center ? center : new THREE.Vector3(0, 0, 0),
30 | size = undefined !== size ? size : 10,
31 | half = size / 2,
32 | iterations = undefined !== iterations ? iterations : 1,
33 | v0 = undefined !== v0 ? v0 : 0,
34 | v1 = undefined !== v1 ? v1 : 1,
35 | v2 = undefined !== v2 ? v2 : 2,
36 | v3 = undefined !== v3 ? v3 : 3,
37 | v4 = undefined !== v4 ? v4 : 4,
38 | v5 = undefined !== v5 ? v5 : 5,
39 | v6 = undefined !== v6 ? v6 : 6,
40 | v7 = undefined !== v7 ? v7 : 7
41 | ;
42 |
43 | var vec_s = [
44 | new THREE.Vector3( center.x - half, center.y + half, center.z - half ),
45 | new THREE.Vector3( center.x - half, center.y + half, center.z + half ),
46 | new THREE.Vector3( center.x - half, center.y - half, center.z + half ),
47 | new THREE.Vector3( center.x - half, center.y - half, center.z - half ),
48 | new THREE.Vector3( center.x + half, center.y - half, center.z - half ),
49 | new THREE.Vector3( center.x + half, center.y - half, center.z + half ),
50 | new THREE.Vector3( center.x + half, center.y + half, center.z + half ),
51 | new THREE.Vector3( center.x + half, center.y + half, center.z - half )
52 | ];
53 |
54 | var vec = [
55 | vec_s[ v0 ],
56 | vec_s[ v1 ],
57 | vec_s[ v2 ],
58 | vec_s[ v3 ],
59 | vec_s[ v4 ],
60 | vec_s[ v5 ],
61 | vec_s[ v6 ],
62 | vec_s[ v7 ]
63 | ];
64 |
65 | // Recurse iterations
66 | if ( -- iterations >= 0 ) {
67 | var tmp = [];
68 |
69 | Array.prototype.push.apply( tmp, hilbert3D ( vec[ 0 ], half, iterations, v0, v3, v4, v7, v6, v5, v2, v1 ) );
70 | Array.prototype.push.apply( tmp, hilbert3D ( vec[ 1 ], half, iterations, v0, v7, v6, v1, v2, v5, v4, v3 ) );
71 | Array.prototype.push.apply( tmp, hilbert3D ( vec[ 2 ], half, iterations, v0, v7, v6, v1, v2, v5, v4, v3 ) );
72 | Array.prototype.push.apply( tmp, hilbert3D ( vec[ 3 ], half, iterations, v2, v3, v0, v1, v6, v7, v4, v5 ) );
73 | Array.prototype.push.apply( tmp, hilbert3D ( vec[ 4 ], half, iterations, v2, v3, v0, v1, v6, v7, v4, v5 ) );
74 | Array.prototype.push.apply( tmp, hilbert3D ( vec[ 5 ], half, iterations, v4, v3, v2, v5, v6, v1, v0, v7 ) );
75 | Array.prototype.push.apply( tmp, hilbert3D ( vec[ 6 ], half, iterations, v4, v3, v2, v5, v6, v1, v0, v7 ) );
76 | Array.prototype.push.apply( tmp, hilbert3D ( vec[ 7 ], half, iterations, v6, v5, v2, v1, v0, v3, v4, v7 ) );
77 |
78 | // Return recursive call
79 | return tmp;
80 | }
81 |
82 | // Return complete Hilbert Curve.
83 | return vec;
84 | }
85 |
--------------------------------------------------------------------------------
/js/thirdparty/three/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/thirdparty/three/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/thirdparty/three/loaders/SVGLoader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author mrdoob / http://mrdoob.com/
3 | * @author zz85 / http://joshuakoo.com/
4 | */
5 |
6 | THREE.SVGLoader = function ( manager ) {
7 |
8 | this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;
9 |
10 | };
11 |
12 | THREE.SVGLoader.prototype = {
13 |
14 | constructor: THREE.MaterialLoader,
15 |
16 | load: function ( url, onLoad, onProgress, onError ) {
17 |
18 | var scope = this;
19 |
20 | var parser = new DOMParser();
21 |
22 | var loader = new THREE.XHRLoader( scope.manager );
23 | loader.setCrossOrigin( this.crossOrigin );
24 | loader.load( url, function ( svgString ) {
25 |
26 | var doc = parser.parseFromString( svgString, 'image/svg+xml' ); // application/xml
27 |
28 | onLoad( doc.firstChild );
29 |
30 | }, onProgress, onError );
31 |
32 | }
33 | };
34 |
--------------------------------------------------------------------------------
/js/thirdparty/three/loaders/VTKLoader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author mrdoob / http://mrdoob.com/
3 | */
4 |
5 | THREE.VTKLoader = function ( manager ) {
6 |
7 | this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;
8 |
9 | };
10 |
11 | THREE.VTKLoader.prototype = {
12 |
13 | constructor: THREE.VTKLoader,
14 |
15 | load: function ( url, onLoad, onProgress, onError ) {
16 |
17 | var scope = this;
18 |
19 | var loader = new THREE.XHRLoader( scope.manager );
20 | loader.setCrossOrigin( this.crossOrigin );
21 | loader.load( url, function ( text ) {
22 |
23 | onLoad( scope.parse( text ) );
24 |
25 | }, onProgress, onError );
26 |
27 | },
28 |
29 | parse: function ( data ) {
30 |
31 | var indices = [];
32 | var positions = [];
33 |
34 | var pattern, result;
35 |
36 | // float float float
37 |
38 | pattern = /([\+|\-]?[\d]+[\.][\d|\-|e]+)[ ]+([\+|\-]?[\d]+[\.][\d|\-|e]+)[ ]+([\+|\-]?[\d]+[\.][\d|\-|e]+)/g;
39 |
40 | while ( ( result = pattern.exec( data ) ) !== null ) {
41 |
42 | // ["1.0 2.0 3.0", "1.0", "2.0", "3.0"]
43 |
44 | positions.push( parseFloat( result[ 1 ] ), parseFloat( result[ 2 ] ), parseFloat( result[ 3 ] ) );
45 |
46 | }
47 |
48 | // 3 int int int
49 |
50 | pattern = /3[ ]+([\d]+)[ ]+([\d]+)[ ]+([\d]+)/g;
51 |
52 | while ( ( result = pattern.exec( data ) ) !== null ) {
53 |
54 | // ["3 1 2 3", "1", "2", "3"]
55 |
56 | indices.push( parseInt( result[ 1 ] ), parseInt( result[ 2 ] ), parseInt( result[ 3 ] ) );
57 |
58 | }
59 |
60 | // 4 int int int int
61 |
62 | pattern = /4[ ]+([\d]+)[ ]+([\d]+)[ ]+([\d]+)[ ]+([\d]+)/g;
63 |
64 | while ( ( result = pattern.exec( data ) ) !== null ) {
65 |
66 | // ["4 1 2 3 4", "1", "2", "3", "4"]
67 |
68 | indices.push( parseInt( result[ 1 ] ), parseInt( result[ 2 ] ), parseInt( result[ 4 ] ) );
69 | indices.push( parseInt( result[ 2 ] ), parseInt( result[ 3 ] ), parseInt( result[ 4 ] ) );
70 |
71 | }
72 |
73 | var geometry = new THREE.BufferGeometry();
74 | geometry.addAttribute( 'index', new THREE.BufferAttribute( new ( indices.length > 65535 ? Uint32Array : Uint16Array )( indices ), 1 ) );
75 | geometry.addAttribute( 'position', new THREE.BufferAttribute( new Float32Array( positions ), 3 ) );
76 |
77 | return geometry;
78 |
79 | }
80 |
81 | };
82 |
83 | THREE.EventDispatcher.prototype.apply( THREE.VTKLoader.prototype );
84 |
--------------------------------------------------------------------------------
/js/thirdparty/three/loaders/ctm/CTMWorker.js:
--------------------------------------------------------------------------------
1 | importScripts( "lzma.js", "ctm.js" );
2 |
3 | self.onmessage = function( event ) {
4 |
5 | var files = [];
6 |
7 | for ( var i = 0; i < event.data.offsets.length; i ++ ) {
8 |
9 | var stream = new CTM.Stream( event.data.data );
10 | stream.offset = event.data.offsets[ i ];
11 |
12 | files[ i ] = new CTM.File( stream );
13 |
14 | }
15 |
16 | self.postMessage( files );
17 | self.close();
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/js/thirdparty/three/loaders/ctm/license/OpenCTM.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2009-2010 Marcus Geelnard
2 |
3 | This software is provided 'as-is', without any express or implied
4 | warranty. In no event will the authors be held liable for any damages
5 | arising from the use of this software.
6 |
7 | Permission is granted to anyone to use this software for any purpose,
8 | including commercial applications, and to alter it and redistribute it
9 | freely, subject to the following restrictions:
10 |
11 | 1. The origin of this software must not be misrepresented; you must not
12 | claim that you wrote the original software. If you use this software
13 | in a product, an acknowledgment in the product documentation would be
14 | appreciated but is not required.
15 |
16 | 2. Altered source versions must be plainly marked as such, and must not
17 | be misrepresented as being the original software.
18 |
19 | 3. This notice may not be removed or altered from any source
20 | distribution.
21 |
--------------------------------------------------------------------------------
/js/thirdparty/three/loaders/ctm/license/js-lzma.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2011 Juan Mellado
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
20 |
--------------------------------------------------------------------------------
/js/thirdparty/three/loaders/ctm/license/js-openctm.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2011 Juan Mellado
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
20 |
--------------------------------------------------------------------------------
/js/thirdparty/three/math/ColorConverter.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author bhouston / http://exocortex.com/
3 | * @author zz85 / http://github.com/zz85
4 | */
5 |
6 | THREE.ColorConverter = {
7 |
8 | setHSV: function ( color, h, s, v ) {
9 |
10 | // https://gist.github.com/xpansive/1337890#file-index-js
11 | return color.setHSL( h, ( s * v ) / ( ( h = ( 2 - s ) * v ) < 1 ? h : ( 2 - h ) ), h * 0.5 );
12 |
13 | },
14 |
15 | getHSV: function( color ) {
16 |
17 | var hsl = color.getHSL();
18 |
19 | // based on https://gist.github.com/xpansive/1337890#file-index-js
20 | hsl.s *= ( hsl.l < 0.5 ) ? hsl.l : ( 1 - hsl.l );
21 |
22 | return {
23 | h: hsl.h,
24 | s: 2 * hsl.s / ( hsl.l + hsl.s ),
25 | v: hsl.l + hsl.s
26 | };
27 | },
28 |
29 | // where c, m, y, k is between 0 and 1
30 |
31 | setCMYK: function ( color, c, m, y, k ) {
32 |
33 | var r = ( 1 - c ) * ( 1 - k );
34 | var g = ( 1 - m ) * ( 1 - k );
35 | var b = ( 1 - y ) * ( 1 - k );
36 |
37 | return color.setRGB( r, g, b );
38 |
39 | },
40 |
41 | getCMYK: function ( color ) {
42 |
43 | var r = color.r;
44 | var g = color.g;
45 | var b = color.b;
46 | var k = 1 - Math.max(r, g, b);
47 | var c = ( 1 - r - k ) / ( 1 - k );
48 | var m = ( 1 - g - k ) / ( 1 - k );
49 | var y = ( 1 - b - k ) / ( 1 - k );
50 |
51 | return {
52 | c: c, m: m, y: y, k: k
53 | };
54 |
55 | }
56 |
57 |
58 | };
--------------------------------------------------------------------------------
/js/thirdparty/three/modifiers/ExplodeModifier.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Make all faces use unique vertices
3 | * so that each face can be separated from others
4 | *
5 | * @author alteredq / http://alteredqualia.com/
6 | */
7 |
8 | THREE.ExplodeModifier = function () {
9 |
10 | };
11 |
12 | THREE.ExplodeModifier.prototype.modify = function ( geometry ) {
13 |
14 | var vertices = [];
15 |
16 | for ( var i = 0, il = geometry.faces.length; i < il; i ++ ) {
17 |
18 | var n = vertices.length;
19 |
20 | var face = geometry.faces[ i ];
21 |
22 | var a = face.a;
23 | var b = face.b;
24 | var c = face.c;
25 |
26 | var va = geometry.vertices[ a ];
27 | var vb = geometry.vertices[ b ];
28 | var vc = geometry.vertices[ c ];
29 |
30 | vertices.push( va.clone() );
31 | vertices.push( vb.clone() );
32 | vertices.push( vc.clone() );
33 |
34 | face.a = n;
35 | face.b = n + 1;
36 | face.c = n + 2;
37 |
38 | }
39 |
40 | geometry.vertices = vertices;
41 | delete geometry.__tmpVertices;
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/js/thirdparty/three/objects/ShadowMesh.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author erichlof / http://github.com/erichlof
3 | *
4 | * A shadow Mesh that follows a shadow-casting Mesh in the scene, but is confined to a single plane.
5 | */
6 |
7 | THREE.ShadowMesh = function ( mesh ) {
8 |
9 | var shadowMaterial = new THREE.MeshBasicMaterial( {
10 |
11 | color: 0x000000,
12 | transparent: true,
13 | opacity: 0.6,
14 | depthWrite: false
15 |
16 | } );
17 |
18 | THREE.Mesh.call( this, mesh.geometry, shadowMaterial );
19 |
20 | this.meshMatrix = mesh.matrixWorld;
21 |
22 | this.frustumCulled = false;
23 | this.matrixAutoUpdate = false;
24 |
25 | };
26 |
27 | THREE.ShadowMesh.prototype = Object.create( THREE.Mesh.prototype );
28 | THREE.ShadowMesh.prototype.constructor = THREE.ShadowMesh;
29 |
30 | THREE.ShadowMesh.prototype.update = function () {
31 |
32 | var shadowMatrix = new THREE.Matrix4();
33 |
34 | return function ( plane, lightPosition4D ) {
35 |
36 | // based on https://www.opengl.org/archives/resources/features/StencilTalk/tsld021.htm
37 |
38 | var dot = plane.normal.x * lightPosition4D.x +
39 | plane.normal.y * lightPosition4D.y +
40 | plane.normal.z * lightPosition4D.z +
41 | -plane.constant * lightPosition4D.w;
42 |
43 | var sme = shadowMatrix.elements;
44 |
45 | sme[ 0 ] = dot - lightPosition4D.x * plane.normal.x;
46 | sme[ 4 ] = - lightPosition4D.x * plane.normal.y;
47 | sme[ 8 ] = - lightPosition4D.x * plane.normal.z;
48 | sme[ 12 ] = - lightPosition4D.x * -plane.constant;
49 |
50 | sme[ 1 ] = - lightPosition4D.y * plane.normal.x;
51 | sme[ 5 ] = dot - lightPosition4D.y * plane.normal.y;
52 | sme[ 9 ] = - lightPosition4D.y * plane.normal.z;
53 | sme[ 13 ] = - lightPosition4D.y * -plane.constant;
54 |
55 | sme[ 2 ] = - lightPosition4D.z * plane.normal.x;
56 | sme[ 6 ] = - lightPosition4D.z * plane.normal.y;
57 | sme[ 10 ] = dot - lightPosition4D.z * plane.normal.z;
58 | sme[ 14 ] = - lightPosition4D.z * -plane.constant;
59 |
60 | sme[ 3 ] = - lightPosition4D.w * plane.normal.x;
61 | sme[ 7 ] = - lightPosition4D.w * plane.normal.y;
62 | sme[ 11 ] = - lightPosition4D.w * plane.normal.z;
63 | sme[ 15 ] = dot - lightPosition4D.w * -plane.constant;
64 |
65 | this.matrix.multiplyMatrices( shadowMatrix, this.meshMatrix );
66 |
67 | };
68 |
69 | }();
70 |
--------------------------------------------------------------------------------
/js/thirdparty/three/postprocessing/BokehPass.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Depth-of-field post-process with bokeh shader
3 | */
4 |
5 |
6 | THREE.BokehPass = function ( scene, camera, params ) {
7 |
8 | this.scene = scene;
9 | this.camera = camera;
10 |
11 | var focus = ( params.focus !== undefined ) ? params.focus : 1.0;
12 | var aspect = ( params.aspect !== undefined ) ? params.aspect : camera.aspect;
13 | var aperture = ( params.aperture !== undefined ) ? params.aperture : 0.025;
14 | var maxblur = ( params.maxblur !== undefined ) ? params.maxblur : 1.0;
15 |
16 | // render targets
17 |
18 | var width = params.width || window.innerWidth || 1;
19 | var height = params.height || window.innerHeight || 1;
20 |
21 | this.renderTargetColor = new THREE.WebGLRenderTarget( width, height, {
22 | minFilter: THREE.LinearFilter,
23 | magFilter: THREE.LinearFilter,
24 | format: THREE.RGBFormat
25 | } );
26 |
27 | this.renderTargetDepth = this.renderTargetColor.clone();
28 |
29 | // depth material
30 |
31 | this.materialDepth = new THREE.MeshDepthMaterial();
32 |
33 | // bokeh material
34 |
35 | if ( THREE.BokehShader === undefined ) {
36 | console.error( "THREE.BokehPass relies on THREE.BokehShader" );
37 | }
38 |
39 | var bokehShader = THREE.BokehShader;
40 | var bokehUniforms = THREE.UniformsUtils.clone( bokehShader.uniforms );
41 |
42 | bokehUniforms[ "tDepth" ].value = this.renderTargetDepth;
43 |
44 | bokehUniforms[ "focus" ].value = focus;
45 | bokehUniforms[ "aspect" ].value = aspect;
46 | bokehUniforms[ "aperture" ].value = aperture;
47 | bokehUniforms[ "maxblur" ].value = maxblur;
48 |
49 | this.materialBokeh = new THREE.ShaderMaterial({
50 | uniforms: bokehUniforms,
51 | vertexShader: bokehShader.vertexShader,
52 | fragmentShader: bokehShader.fragmentShader
53 | });
54 |
55 | this.uniforms = bokehUniforms;
56 | this.enabled = true;
57 | this.needsSwap = false;
58 | this.renderToScreen = false;
59 | this.clear = false;
60 |
61 | this.camera2 = new THREE.OrthographicCamera( -1, 1, 1, -1, 0, 1 );
62 | this.scene2 = new THREE.Scene();
63 |
64 | this.quad2 = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null );
65 | this.scene2.add( this.quad2 );
66 |
67 | };
68 |
69 | THREE.BokehPass.prototype = {
70 |
71 | render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) {
72 |
73 | this.quad2.material = this.materialBokeh;
74 |
75 | // Render depth into texture
76 |
77 | this.scene.overrideMaterial = this.materialDepth;
78 |
79 | renderer.render( this.scene, this.camera, this.renderTargetDepth, true );
80 |
81 | // Render bokeh composite
82 |
83 | this.uniforms[ "tColor" ].value = readBuffer;
84 |
85 | if ( this.renderToScreen ) {
86 |
87 | renderer.render( this.scene2, this.camera2 );
88 |
89 | } else {
90 |
91 | renderer.render( this.scene2, this.camera2, writeBuffer, this.clear );
92 |
93 | }
94 |
95 | this.scene.overrideMaterial = null;
96 |
97 | }
98 |
99 | };
100 |
101 |
--------------------------------------------------------------------------------
/js/thirdparty/three/postprocessing/DotScreenPass.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | */
4 |
5 | THREE.DotScreenPass = function ( center, angle, scale ) {
6 |
7 | if ( THREE.DotScreenShader === undefined )
8 | console.error( "THREE.DotScreenPass relies on THREE.DotScreenShader" );
9 |
10 | var shader = THREE.DotScreenShader;
11 |
12 | this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
13 |
14 | if ( center !== undefined ) this.uniforms[ "center" ].value.copy( center );
15 | if ( angle !== undefined ) this.uniforms[ "angle"].value = angle;
16 | if ( scale !== undefined ) this.uniforms[ "scale"].value = scale;
17 |
18 | this.material = new THREE.ShaderMaterial( {
19 |
20 | uniforms: this.uniforms,
21 | vertexShader: shader.vertexShader,
22 | fragmentShader: shader.fragmentShader
23 |
24 | } );
25 |
26 | this.enabled = true;
27 | this.renderToScreen = false;
28 | this.needsSwap = true;
29 |
30 |
31 | this.camera = new THREE.OrthographicCamera( -1, 1, 1, -1, 0, 1 );
32 | this.scene = new THREE.Scene();
33 |
34 | this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null );
35 | this.scene.add( this.quad );
36 |
37 | };
38 |
39 | THREE.DotScreenPass.prototype = {
40 |
41 | render: function ( renderer, writeBuffer, readBuffer, delta ) {
42 |
43 | this.uniforms[ "tDiffuse" ].value = readBuffer;
44 | this.uniforms[ "tSize" ].value.set( readBuffer.width, readBuffer.height );
45 |
46 | this.quad.material = this.material;
47 |
48 | if ( this.renderToScreen ) {
49 |
50 | renderer.render( this.scene, this.camera );
51 |
52 | } else {
53 |
54 | renderer.render( this.scene, this.camera, writeBuffer, false );
55 |
56 | }
57 |
58 | }
59 |
60 | };
61 |
--------------------------------------------------------------------------------
/js/thirdparty/three/postprocessing/EffectComposer.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | */
4 |
5 | THREE.EffectComposer = function ( renderer, renderTarget ) {
6 |
7 | this.renderer = renderer;
8 |
9 | if ( renderTarget === undefined ) {
10 |
11 | var pixelRatio = renderer.getPixelRatio();
12 |
13 | var width = Math.floor( renderer.context.canvas.width / pixelRatio ) || 1;
14 | var height = Math.floor( renderer.context.canvas.height / pixelRatio ) || 1;
15 | var parameters = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBFormat, stencilBuffer: false };
16 |
17 | renderTarget = new THREE.WebGLRenderTarget( width, height, parameters );
18 |
19 | }
20 |
21 | this.renderTarget1 = renderTarget;
22 | this.renderTarget2 = renderTarget.clone();
23 |
24 | this.writeBuffer = this.renderTarget1;
25 | this.readBuffer = this.renderTarget2;
26 |
27 | this.passes = [];
28 |
29 | if ( THREE.CopyShader === undefined )
30 | console.error( "THREE.EffectComposer relies on THREE.CopyShader" );
31 |
32 | this.copyPass = new THREE.ShaderPass( THREE.CopyShader );
33 |
34 | };
35 |
36 | THREE.EffectComposer.prototype = {
37 |
38 | swapBuffers: function() {
39 |
40 | var tmp = this.readBuffer;
41 | this.readBuffer = this.writeBuffer;
42 | this.writeBuffer = tmp;
43 |
44 | },
45 |
46 | addPass: function ( pass ) {
47 |
48 | this.passes.push( pass );
49 |
50 | },
51 |
52 | insertPass: function ( pass, index ) {
53 |
54 | this.passes.splice( index, 0, pass );
55 |
56 | },
57 |
58 | render: function ( delta ) {
59 |
60 | this.writeBuffer = this.renderTarget1;
61 | this.readBuffer = this.renderTarget2;
62 |
63 | var maskActive = false;
64 |
65 | var pass, i, il = this.passes.length;
66 |
67 | for ( i = 0; i < il; i ++ ) {
68 |
69 | pass = this.passes[ i ];
70 |
71 | if ( !pass.enabled ) continue;
72 |
73 | pass.render( this.renderer, this.writeBuffer, this.readBuffer, delta, maskActive );
74 |
75 | if ( pass.needsSwap ) {
76 |
77 | if ( maskActive ) {
78 |
79 | var context = this.renderer.context;
80 |
81 | context.stencilFunc( context.NOTEQUAL, 1, 0xffffffff );
82 |
83 | this.copyPass.render( this.renderer, this.writeBuffer, this.readBuffer, delta );
84 |
85 | context.stencilFunc( context.EQUAL, 1, 0xffffffff );
86 |
87 | }
88 |
89 | this.swapBuffers();
90 |
91 | }
92 |
93 | if ( pass instanceof THREE.MaskPass ) {
94 |
95 | maskActive = true;
96 |
97 | } else if ( pass instanceof THREE.ClearMaskPass ) {
98 |
99 | maskActive = false;
100 |
101 | }
102 |
103 | }
104 |
105 | },
106 |
107 | reset: function ( renderTarget ) {
108 |
109 | if ( renderTarget === undefined ) {
110 |
111 | renderTarget = this.renderTarget1.clone();
112 |
113 | var pixelRatio = this.renderer.getPixelRatio();
114 |
115 | renderTarget.width = Math.floor( this.renderer.context.canvas.width / pixelRatio );
116 | renderTarget.height = Math.floor( this.renderer.context.canvas.height / pixelRatio );
117 |
118 | }
119 |
120 | this.renderTarget1 = renderTarget;
121 | this.renderTarget2 = renderTarget.clone();
122 |
123 | this.writeBuffer = this.renderTarget1;
124 | this.readBuffer = this.renderTarget2;
125 |
126 | },
127 |
128 | setSize: function ( width, height ) {
129 |
130 | var renderTarget = this.renderTarget1.clone();
131 |
132 | renderTarget.width = width;
133 | renderTarget.height = height;
134 |
135 | this.reset( renderTarget );
136 |
137 | }
138 |
139 | };
140 |
--------------------------------------------------------------------------------
/js/thirdparty/three/postprocessing/FilmPass.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | */
4 |
5 | THREE.FilmPass = function ( noiseIntensity, scanlinesIntensity, scanlinesCount, grayscale ) {
6 |
7 | if ( THREE.FilmShader === undefined )
8 | console.error( "THREE.FilmPass relies on THREE.FilmShader" );
9 |
10 | var shader = THREE.FilmShader;
11 |
12 | this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
13 |
14 | this.material = new THREE.ShaderMaterial( {
15 |
16 | uniforms: this.uniforms,
17 | vertexShader: shader.vertexShader,
18 | fragmentShader: shader.fragmentShader
19 |
20 | } );
21 |
22 | if ( grayscale !== undefined ) this.uniforms.grayscale.value = grayscale;
23 | if ( noiseIntensity !== undefined ) this.uniforms.nIntensity.value = noiseIntensity;
24 | if ( scanlinesIntensity !== undefined ) this.uniforms.sIntensity.value = scanlinesIntensity;
25 | if ( scanlinesCount !== undefined ) this.uniforms.sCount.value = scanlinesCount;
26 |
27 | this.enabled = true;
28 | this.renderToScreen = false;
29 | this.needsSwap = true;
30 |
31 |
32 | this.camera = new THREE.OrthographicCamera( -1, 1, 1, -1, 0, 1 );
33 | this.scene = new THREE.Scene();
34 |
35 | this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null );
36 | this.scene.add( this.quad );
37 |
38 | };
39 |
40 | THREE.FilmPass.prototype = {
41 |
42 | render: function ( renderer, writeBuffer, readBuffer, delta ) {
43 |
44 | this.uniforms[ "tDiffuse" ].value = readBuffer;
45 | this.uniforms[ "time" ].value += delta;
46 |
47 | this.quad.material = this.material;
48 |
49 | if ( this.renderToScreen ) {
50 |
51 | renderer.render( this.scene, this.camera );
52 |
53 | } else {
54 |
55 | renderer.render( this.scene, this.camera, writeBuffer, false );
56 |
57 | }
58 |
59 | }
60 |
61 | };
62 |
--------------------------------------------------------------------------------
/js/thirdparty/three/postprocessing/GlitchPass.js:
--------------------------------------------------------------------------------
1 | /**
2 |
3 | */
4 |
5 | THREE.GlitchPass = function ( dt_size ) {
6 |
7 | if ( THREE.DigitalGlitch === undefined ) console.error( "THREE.GlitchPass relies on THREE.DigitalGlitch" );
8 |
9 | var shader = THREE.DigitalGlitch;
10 | this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
11 |
12 | if (dt_size == undefined) dt_size = 64;
13 |
14 |
15 | this.uniforms[ "tDisp"].value = this.generateHeightmap(dt_size);
16 |
17 |
18 | this.material = new THREE.ShaderMaterial({
19 | uniforms: this.uniforms,
20 | vertexShader: shader.vertexShader,
21 | fragmentShader: shader.fragmentShader
22 | });
23 |
24 | console.log(this.material);
25 |
26 | this.enabled = true;
27 | this.renderToScreen = false;
28 | this.needsSwap = true;
29 |
30 |
31 | this.camera = new THREE.OrthographicCamera( -1, 1, 1, -1, 0, 1 );
32 | this.scene = new THREE.Scene();
33 |
34 | this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null );
35 | this.scene.add( this.quad );
36 |
37 | this.goWild = false;
38 | this.curF = 0;
39 | this.generateTrigger();
40 |
41 | };
42 |
43 | THREE.GlitchPass.prototype = {
44 |
45 | render: function ( renderer, writeBuffer, readBuffer, delta )
46 | {
47 | this.uniforms[ "tDiffuse" ].value = readBuffer;
48 | this.uniforms[ 'seed' ].value = Math.random();//default seeding
49 | this.uniforms[ 'byp' ].value = 0;
50 |
51 | if (this.curF % this.randX == 0 || this.goWild == true)
52 | {
53 | this.uniforms[ 'amount' ].value = Math.random() / 30;
54 | this.uniforms[ 'angle' ].value = THREE.Math.randFloat(-Math.PI, Math.PI);
55 | this.uniforms[ 'seed_x' ].value = THREE.Math.randFloat(-1, 1);
56 | this.uniforms[ 'seed_y' ].value = THREE.Math.randFloat(-1, 1);
57 | this.uniforms[ 'distortion_x' ].value = THREE.Math.randFloat(0, 1);
58 | this.uniforms[ 'distortion_y' ].value = THREE.Math.randFloat(0, 1);
59 | this.curF = 0;
60 | this.generateTrigger();
61 | }
62 | else if (this.curF % this.randX < this.randX / 5)
63 | {
64 | this.uniforms[ 'amount' ].value = Math.random() / 90;
65 | this.uniforms[ 'angle' ].value = THREE.Math.randFloat(-Math.PI, Math.PI);
66 | this.uniforms[ 'distortion_x' ].value = THREE.Math.randFloat(0, 1);
67 | this.uniforms[ 'distortion_y' ].value = THREE.Math.randFloat(0, 1);
68 | this.uniforms[ 'seed_x' ].value = THREE.Math.randFloat(-0.3, 0.3);
69 | this.uniforms[ 'seed_y' ].value = THREE.Math.randFloat(-0.3, 0.3);
70 | }
71 | else if (this.goWild == false)
72 | {
73 | this.uniforms[ 'byp' ].value = 1;
74 | }
75 | this.curF ++;
76 |
77 | this.quad.material = this.material;
78 | if ( this.renderToScreen )
79 | {
80 | renderer.render( this.scene, this.camera );
81 | }
82 | else
83 | {
84 | renderer.render( this.scene, this.camera, writeBuffer, false );
85 | }
86 | },
87 | generateTrigger:function()
88 | {
89 | this.randX = THREE.Math.randInt(120, 240);
90 | },
91 | generateHeightmap:function(dt_size)
92 | {
93 | var data_arr = new Float32Array( dt_size * dt_size * 3 );
94 | console.log(dt_size);
95 | var length = dt_size * dt_size;
96 |
97 | for ( var i = 0; i < length; i ++)
98 | {
99 | var val = THREE.Math.randFloat(0, 1);
100 | data_arr[ i * 3 + 0 ] = val;
101 | data_arr[ i * 3 + 1 ] = val;
102 | data_arr[ i * 3 + 2 ] = val;
103 | }
104 |
105 | var texture = new THREE.DataTexture( data_arr, dt_size, dt_size, THREE.RGBFormat, THREE.FloatType );
106 | console.log(texture);
107 | console.log(dt_size);
108 | texture.minFilter = THREE.NearestFilter;
109 | texture.magFilter = THREE.NearestFilter;
110 | texture.needsUpdate = true;
111 | texture.flipY = false;
112 | return texture;
113 | }
114 | };
--------------------------------------------------------------------------------
/js/thirdparty/three/postprocessing/MaskPass.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | */
4 |
5 | THREE.MaskPass = function ( scene, camera ) {
6 |
7 | this.scene = scene;
8 | this.camera = camera;
9 |
10 | this.enabled = true;
11 | this.clear = true;
12 | this.needsSwap = false;
13 |
14 | this.inverse = false;
15 |
16 | };
17 |
18 | THREE.MaskPass.prototype = {
19 |
20 | render: function ( renderer, writeBuffer, readBuffer, delta ) {
21 |
22 | var context = renderer.context;
23 |
24 | // don't update color or depth
25 |
26 | context.colorMask( false, false, false, false );
27 | context.depthMask( false );
28 |
29 | // set up stencil
30 |
31 | var writeValue, clearValue;
32 |
33 | if ( this.inverse ) {
34 |
35 | writeValue = 0;
36 | clearValue = 1;
37 |
38 | } else {
39 |
40 | writeValue = 1;
41 | clearValue = 0;
42 |
43 | }
44 |
45 | context.enable( context.STENCIL_TEST );
46 | context.stencilOp( context.REPLACE, context.REPLACE, context.REPLACE );
47 | context.stencilFunc( context.ALWAYS, writeValue, 0xffffffff );
48 | context.clearStencil( clearValue );
49 |
50 | // draw into the stencil buffer
51 |
52 | renderer.render( this.scene, this.camera, readBuffer, this.clear );
53 | renderer.render( this.scene, this.camera, writeBuffer, this.clear );
54 |
55 | // re-enable update of color and depth
56 |
57 | context.colorMask( true, true, true, true );
58 | context.depthMask( true );
59 |
60 | // only render where stencil is set to 1
61 |
62 | context.stencilFunc( context.EQUAL, 1, 0xffffffff ); // draw if == 1
63 | context.stencilOp( context.KEEP, context.KEEP, context.KEEP );
64 |
65 | }
66 |
67 | };
68 |
69 |
70 | THREE.ClearMaskPass = function () {
71 |
72 | this.enabled = true;
73 |
74 | };
75 |
76 | THREE.ClearMaskPass.prototype = {
77 |
78 | render: function ( renderer, writeBuffer, readBuffer, delta ) {
79 |
80 | var context = renderer.context;
81 |
82 | context.disable( context.STENCIL_TEST );
83 |
84 | }
85 |
86 | };
87 |
--------------------------------------------------------------------------------
/js/thirdparty/three/postprocessing/RenderPass.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | */
4 |
5 | THREE.RenderPass = function ( scene, camera, overrideMaterial, clearColor, clearAlpha ) {
6 |
7 | this.scene = scene;
8 | this.camera = camera;
9 |
10 | this.overrideMaterial = overrideMaterial;
11 |
12 | this.clearColor = clearColor;
13 | this.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 1;
14 |
15 | this.oldClearColor = new THREE.Color();
16 | this.oldClearAlpha = 1;
17 |
18 | this.enabled = true;
19 | this.clear = true;
20 | this.needsSwap = false;
21 |
22 | };
23 |
24 | THREE.RenderPass.prototype = {
25 |
26 | render: function ( renderer, writeBuffer, readBuffer, delta ) {
27 |
28 | this.scene.overrideMaterial = this.overrideMaterial;
29 |
30 | if ( this.clearColor ) {
31 |
32 | this.oldClearColor.copy( renderer.getClearColor() );
33 | this.oldClearAlpha = renderer.getClearAlpha();
34 |
35 | renderer.setClearColor( this.clearColor, this.clearAlpha );
36 |
37 | }
38 |
39 | renderer.render( this.scene, this.camera, readBuffer, this.clear );
40 |
41 | if ( this.clearColor ) {
42 |
43 | renderer.setClearColor( this.oldClearColor, this.oldClearAlpha );
44 |
45 | }
46 |
47 | this.scene.overrideMaterial = null;
48 |
49 | }
50 |
51 | };
52 |
--------------------------------------------------------------------------------
/js/thirdparty/three/postprocessing/SavePass.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | */
4 |
5 | THREE.SavePass = function ( renderTarget ) {
6 |
7 | if ( THREE.CopyShader === undefined )
8 | console.error( "THREE.SavePass relies on THREE.CopyShader" );
9 |
10 | var shader = THREE.CopyShader;
11 |
12 | this.textureID = "tDiffuse";
13 |
14 | this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
15 |
16 | this.material = new THREE.ShaderMaterial( {
17 |
18 | uniforms: this.uniforms,
19 | vertexShader: shader.vertexShader,
20 | fragmentShader: shader.fragmentShader
21 |
22 | } );
23 |
24 | this.renderTarget = renderTarget;
25 |
26 | if ( this.renderTarget === undefined ) {
27 |
28 | this.renderTargetParameters = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBFormat, stencilBuffer: false };
29 | this.renderTarget = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, this.renderTargetParameters );
30 |
31 | }
32 |
33 | this.enabled = true;
34 | this.needsSwap = false;
35 | this.clear = false;
36 |
37 |
38 | this.camera = new THREE.OrthographicCamera( -1, 1, 1, -1, 0, 1 );
39 | this.scene = new THREE.Scene();
40 |
41 | this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null );
42 | this.scene.add( this.quad );
43 |
44 | };
45 |
46 | THREE.SavePass.prototype = {
47 |
48 | render: function ( renderer, writeBuffer, readBuffer, delta ) {
49 |
50 | if ( this.uniforms[ this.textureID ] ) {
51 |
52 | this.uniforms[ this.textureID ].value = readBuffer;
53 |
54 | }
55 |
56 | this.quad.material = this.material;
57 |
58 | renderer.render( this.scene, this.camera, this.renderTarget, this.clear );
59 |
60 | }
61 |
62 | };
63 |
--------------------------------------------------------------------------------
/js/thirdparty/three/postprocessing/ShaderPass.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | */
4 |
5 | THREE.ShaderPass = function ( shader, textureID ) {
6 |
7 | this.textureID = ( textureID !== undefined ) ? textureID : "tDiffuse";
8 |
9 | this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
10 |
11 | this.material = new THREE.ShaderMaterial( {
12 |
13 | defines: shader.defines || {},
14 | uniforms: this.uniforms,
15 | vertexShader: shader.vertexShader,
16 | fragmentShader: shader.fragmentShader
17 |
18 | } );
19 |
20 | this.renderToScreen = false;
21 |
22 | this.enabled = true;
23 | this.needsSwap = true;
24 | this.clear = false;
25 |
26 |
27 | this.camera = new THREE.OrthographicCamera( -1, 1, 1, -1, 0, 1 );
28 | this.scene = new THREE.Scene();
29 |
30 | this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null );
31 | this.scene.add( this.quad );
32 |
33 | };
34 |
35 | THREE.ShaderPass.prototype = {
36 |
37 | render: function ( renderer, writeBuffer, readBuffer, delta ) {
38 |
39 | if ( this.uniforms[ this.textureID ] ) {
40 |
41 | this.uniforms[ this.textureID ].value = readBuffer;
42 |
43 | }
44 |
45 | this.quad.material = this.material;
46 |
47 | if ( this.renderToScreen ) {
48 |
49 | renderer.render( this.scene, this.camera );
50 |
51 | } else {
52 |
53 | renderer.render( this.scene, this.camera, writeBuffer, this.clear );
54 |
55 | }
56 |
57 | }
58 |
59 | };
60 |
--------------------------------------------------------------------------------
/js/thirdparty/three/postprocessing/TexturePass.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | */
4 |
5 | THREE.TexturePass = function ( texture, opacity ) {
6 |
7 | if ( THREE.CopyShader === undefined )
8 | console.error( "THREE.TexturePass relies on THREE.CopyShader" );
9 |
10 | var shader = THREE.CopyShader;
11 |
12 | this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
13 |
14 | this.uniforms[ "opacity" ].value = ( opacity !== undefined ) ? opacity : 1.0;
15 | this.uniforms[ "tDiffuse" ].value = texture;
16 |
17 | this.material = new THREE.ShaderMaterial( {
18 |
19 | uniforms: this.uniforms,
20 | vertexShader: shader.vertexShader,
21 | fragmentShader: shader.fragmentShader
22 |
23 | } );
24 |
25 | this.enabled = true;
26 | this.needsSwap = false;
27 |
28 |
29 | this.camera = new THREE.OrthographicCamera( -1, 1, 1, -1, 0, 1 );
30 | this.scene = new THREE.Scene();
31 |
32 | this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null );
33 | this.scene.add( this.quad );
34 |
35 | };
36 |
37 | THREE.TexturePass.prototype = {
38 |
39 | render: function ( renderer, writeBuffer, readBuffer, delta ) {
40 |
41 | this.quad.material = this.material;
42 |
43 | renderer.render( this.scene, this.camera, readBuffer );
44 |
45 | }
46 |
47 | };
48 |
--------------------------------------------------------------------------------
/js/thirdparty/three/renderers/CSS2DRenderer.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author mrdoob / http://mrdoob.com/
3 | */
4 |
5 | THREE.CSS2DObject = function ( element ) {
6 |
7 | THREE.Object3D.call( this );
8 |
9 | this.element = element;
10 | this.element.style.position = 'absolute';
11 |
12 | this.addEventListener( 'removed', function ( event ) {
13 |
14 | if ( this.element.parentNode !== null ) {
15 |
16 | this.element.parentNode.removeChild( this.element );
17 |
18 | }
19 |
20 | } );
21 |
22 | };
23 |
24 | THREE.CSS2DObject.prototype = Object.create( THREE.Object3D.prototype );
25 | THREE.CSS2DObject.prototype.constructor = THREE.CSS2DObject;
26 |
27 | //
28 |
29 | THREE.CSS2DRenderer = function () {
30 |
31 | console.log( 'THREE.CSS2DRenderer', THREE.REVISION );
32 |
33 | var _width, _height;
34 | var _widthHalf, _heightHalf;
35 |
36 | var vector = new THREE.Vector3();
37 | var viewMatrix = new THREE.Matrix4();
38 | var viewProjectionMatrix = new THREE.Matrix4();
39 |
40 | var domElement = document.createElement( 'div' );
41 | domElement.style.overflow = 'hidden';
42 |
43 | this.domElement = domElement;
44 |
45 | this.setSize = function ( width, height ) {
46 |
47 | _width = width;
48 | _height = height;
49 |
50 | _widthHalf = _width / 2;
51 | _heightHalf = _height / 2;
52 |
53 | domElement.style.width = width + 'px';
54 | domElement.style.height = height + 'px';
55 |
56 | };
57 |
58 | var renderObject = function ( object, camera ) {
59 |
60 | if ( object instanceof THREE.CSS2DObject ) {
61 |
62 | vector.setFromMatrixPosition( object.matrixWorld );
63 | vector.applyProjection( viewProjectionMatrix );
64 |
65 | var element = object.element;
66 | var style = 'translate(-50%,-50%) translate(' + ( vector.x * _widthHalf + _widthHalf ) + 'px,' + ( - vector.y * _heightHalf + _heightHalf ) + 'px)';
67 |
68 | element.style.WebkitTransform = style;
69 | element.style.MozTransform = style;
70 | element.style.oTransform = style;
71 | element.style.transform = style;
72 |
73 | if ( element.parentNode !== domElement ) {
74 |
75 | domElement.appendChild( element );
76 |
77 | }
78 |
79 | }
80 |
81 | for ( var i = 0, l = object.children.length; i < l; i ++ ) {
82 |
83 | renderObject( object.children[ i ], camera );
84 |
85 | }
86 |
87 | };
88 |
89 | this.render = function ( scene, camera ) {
90 |
91 | scene.updateMatrixWorld();
92 |
93 | if ( camera.parent === undefined ) camera.updateMatrixWorld();
94 |
95 | camera.matrixWorldInverse.getInverse( camera.matrixWorld );
96 |
97 | viewMatrix.copy( camera.matrixWorldInverse.getInverse( camera.matrixWorld ) );
98 | viewProjectionMatrix.multiplyMatrices( camera.projectionMatrix, viewMatrix );
99 |
100 | renderObject( scene, camera );
101 |
102 | };
103 |
104 | };
105 |
--------------------------------------------------------------------------------
/js/thirdparty/three/shaders/BasicShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author mrdoob / http://www.mrdoob.com
3 | *
4 | * Simple test shader
5 | */
6 |
7 | THREE.BasicShader = {
8 |
9 | uniforms: {},
10 |
11 | vertexShader: [
12 |
13 | "void main() {",
14 |
15 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
16 |
17 | "}"
18 |
19 | ].join("\n"),
20 |
21 | fragmentShader: [
22 |
23 | "void main() {",
24 |
25 | "gl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );",
26 |
27 | "}"
28 |
29 | ].join("\n")
30 |
31 | };
32 |
--------------------------------------------------------------------------------
/js/thirdparty/three/shaders/BleachBypassShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | *
4 | * Bleach bypass shader [http://en.wikipedia.org/wiki/Bleach_bypass]
5 | * - based on Nvidia example
6 | * http://developer.download.nvidia.com/shaderlibrary/webpages/shader_library.html#post_bleach_bypass
7 | */
8 |
9 | THREE.BleachBypassShader = {
10 |
11 | uniforms: {
12 |
13 | "tDiffuse": { type: "t", value: null },
14 | "opacity": { type: "f", value: 1.0 }
15 |
16 | },
17 |
18 | vertexShader: [
19 |
20 | "varying vec2 vUv;",
21 |
22 | "void main() {",
23 |
24 | "vUv = uv;",
25 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
26 |
27 | "}"
28 |
29 | ].join("\n"),
30 |
31 | fragmentShader: [
32 |
33 | "uniform float opacity;",
34 |
35 | "uniform sampler2D tDiffuse;",
36 |
37 | "varying vec2 vUv;",
38 |
39 | "void main() {",
40 |
41 | "vec4 base = texture2D( tDiffuse, vUv );",
42 |
43 | "vec3 lumCoeff = vec3( 0.25, 0.65, 0.1 );",
44 | "float lum = dot( lumCoeff, base.rgb );",
45 | "vec3 blend = vec3( lum );",
46 |
47 | "float L = min( 1.0, max( 0.0, 10.0 * ( lum - 0.45 ) ) );",
48 |
49 | "vec3 result1 = 2.0 * base.rgb * blend;",
50 | "vec3 result2 = 1.0 - 2.0 * ( 1.0 - blend ) * ( 1.0 - base.rgb );",
51 |
52 | "vec3 newColor = mix( result1, result2, L );",
53 |
54 | "float A2 = opacity * base.a;",
55 | "vec3 mixRGB = A2 * newColor.rgb;",
56 | "mixRGB += ( ( 1.0 - A2 ) * base.rgb );",
57 |
58 | "gl_FragColor = vec4( mixRGB, base.a );",
59 |
60 | "}"
61 |
62 | ].join("\n")
63 |
64 | };
65 |
--------------------------------------------------------------------------------
/js/thirdparty/three/shaders/BlendShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | *
4 | * Blend two textures
5 | */
6 |
7 | THREE.BlendShader = {
8 |
9 | uniforms: {
10 |
11 | "tDiffuse1": { type: "t", value: null },
12 | "tDiffuse2": { type: "t", value: null },
13 | "mixRatio": { type: "f", value: 0.5 },
14 | "opacity": { type: "f", value: 1.0 }
15 |
16 | },
17 |
18 | vertexShader: [
19 |
20 | "varying vec2 vUv;",
21 |
22 | "void main() {",
23 |
24 | "vUv = uv;",
25 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
26 |
27 | "}"
28 |
29 | ].join("\n"),
30 |
31 | fragmentShader: [
32 |
33 | "uniform float opacity;",
34 | "uniform float mixRatio;",
35 |
36 | "uniform sampler2D tDiffuse1;",
37 | "uniform sampler2D tDiffuse2;",
38 |
39 | "varying vec2 vUv;",
40 |
41 | "void main() {",
42 |
43 | "vec4 texel1 = texture2D( tDiffuse1, vUv );",
44 | "vec4 texel2 = texture2D( tDiffuse2, vUv );",
45 | "gl_FragColor = opacity * mix( texel1, texel2, mixRatio );",
46 |
47 | "}"
48 |
49 | ].join("\n")
50 |
51 | };
52 |
--------------------------------------------------------------------------------
/js/thirdparty/three/shaders/BrightnessContrastShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author tapio / http://tapio.github.com/
3 | *
4 | * Brightness and contrast adjustment
5 | * https://github.com/evanw/glfx.js
6 | * brightness: -1 to 1 (-1 is solid black, 0 is no change, and 1 is solid white)
7 | * contrast: -1 to 1 (-1 is solid gray, 0 is no change, and 1 is maximum contrast)
8 | */
9 |
10 | THREE.BrightnessContrastShader = {
11 |
12 | uniforms: {
13 |
14 | "tDiffuse": { type: "t", value: null },
15 | "brightness": { type: "f", value: 0 },
16 | "contrast": { type: "f", value: 0 }
17 |
18 | },
19 |
20 | vertexShader: [
21 |
22 | "varying vec2 vUv;",
23 |
24 | "void main() {",
25 |
26 | "vUv = uv;",
27 |
28 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
29 |
30 | "}"
31 |
32 | ].join("\n"),
33 |
34 | fragmentShader: [
35 |
36 | "uniform sampler2D tDiffuse;",
37 | "uniform float brightness;",
38 | "uniform float contrast;",
39 |
40 | "varying vec2 vUv;",
41 |
42 | "void main() {",
43 |
44 | "gl_FragColor = texture2D( tDiffuse, vUv );",
45 |
46 | "gl_FragColor.rgb += brightness;",
47 |
48 | "if (contrast > 0.0) {",
49 | "gl_FragColor.rgb = (gl_FragColor.rgb - 0.5) / (1.0 - contrast) + 0.5;",
50 | "} else {",
51 | "gl_FragColor.rgb = (gl_FragColor.rgb - 0.5) * (1.0 + contrast) + 0.5;",
52 | "}",
53 |
54 | "}"
55 |
56 | ].join("\n")
57 |
58 | };
59 |
--------------------------------------------------------------------------------
/js/thirdparty/three/shaders/ColorCorrectionShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | *
4 | * Color correction
5 | */
6 |
7 | THREE.ColorCorrectionShader = {
8 |
9 | uniforms: {
10 |
11 | "tDiffuse": { type: "t", value: null },
12 | "powRGB": { type: "v3", value: new THREE.Vector3( 2, 2, 2 ) },
13 | "mulRGB": { type: "v3", value: new THREE.Vector3( 1, 1, 1 ) },
14 | "addRGB": { type: "v3", value: new THREE.Vector3( 0, 0, 0 ) }
15 |
16 | },
17 |
18 | vertexShader: [
19 |
20 | "varying vec2 vUv;",
21 |
22 | "void main() {",
23 |
24 | "vUv = uv;",
25 |
26 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
27 |
28 | "}"
29 |
30 | ].join("\n"),
31 |
32 | fragmentShader: [
33 |
34 | "uniform sampler2D tDiffuse;",
35 | "uniform vec3 powRGB;",
36 | "uniform vec3 mulRGB;",
37 | "uniform vec3 addRGB;",
38 |
39 | "varying vec2 vUv;",
40 |
41 | "void main() {",
42 |
43 | "gl_FragColor = texture2D( tDiffuse, vUv );",
44 | "gl_FragColor.rgb = mulRGB * pow( ( gl_FragColor.rgb + addRGB ), powRGB );",
45 |
46 | "}"
47 |
48 | ].join("\n")
49 |
50 | };
51 |
--------------------------------------------------------------------------------
/js/thirdparty/three/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/thirdparty/three/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/thirdparty/three/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/thirdparty/three/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/thirdparty/three/shaders/DigitalGlitch.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author felixturner / http://airtight.cc/
3 | *
4 | * RGB Shift Shader
5 | * Shifts red and blue channels from center in opposite directions
6 | * Ported from http://kriss.cx/tom/2009/05/rgb-shift/
7 | * by Tom Butterworth / http://kriss.cx/tom/
8 | *
9 | * amount: shift distance (1 is width of input)
10 | * angle: shift angle in radians
11 | */
12 |
13 | THREE.DigitalGlitch = {
14 |
15 | uniforms: {
16 |
17 | "tDiffuse": { type: "t", value: null },//diffuse texture
18 | "tDisp": { type: "t", value: null },//displacement texture for digital glitch squares
19 | "byp": { type: "i", value: 0 },//apply the glitch ?
20 | "amount": { type: "f", value: 0.08 },
21 | "angle": { type: "f", value: 0.02 },
22 | "seed": { type: "f", value: 0.02 },
23 | "seed_x": { type: "f", value: 0.02 },//-1,1
24 | "seed_y": { type: "f", value: 0.02 },//-1,1
25 | "distortion_x": { type: "f", value: 0.5 },
26 | "distortion_y": { type: "f", value: 0.6 },
27 | "col_s": { type: "f", value: 0.05 }
28 | },
29 |
30 | vertexShader: [
31 |
32 | "varying vec2 vUv;",
33 | "void main() {",
34 | "vUv = uv;",
35 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
36 | "}"
37 | ].join("\n"),
38 |
39 | fragmentShader: [
40 | "uniform int byp;",//should we apply the glitch ?
41 |
42 | "uniform sampler2D tDiffuse;",
43 | "uniform sampler2D tDisp;",
44 |
45 | "uniform float amount;",
46 | "uniform float angle;",
47 | "uniform float seed;",
48 | "uniform float seed_x;",
49 | "uniform float seed_y;",
50 | "uniform float distortion_x;",
51 | "uniform float distortion_y;",
52 | "uniform float col_s;",
53 |
54 | "varying vec2 vUv;",
55 |
56 |
57 | "float rand(vec2 co){",
58 | "return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);",
59 | "}",
60 |
61 | "void main() {",
62 | "if(byp<1) {",
63 | "vec2 p = vUv;",
64 | "float xs = floor(gl_FragCoord.x / 0.5);",
65 | "float ys = floor(gl_FragCoord.y / 0.5);",
66 | //based on staffantans glitch shader for unity https://github.com/staffantan/unityglitch
67 | "vec4 normal = texture2D (tDisp, p*seed*seed);",
68 | "if(p.ydistortion_x-col_s*seed) {",
69 | "if(seed_x>0.){",
70 | "p.y = 1. - (p.y + distortion_y);",
71 | "}",
72 | "else {",
73 | "p.y = distortion_y;",
74 | "}",
75 | "}",
76 | "if(p.xdistortion_y-col_s*seed) {",
77 | "if(seed_y>0.){",
78 | "p.x=distortion_x;",
79 | "}",
80 | "else {",
81 | "p.x = 1. - (p.x + distortion_x);",
82 | "}",
83 | "}",
84 | "p.x+=normal.x*seed_x*(seed/5.);",
85 | "p.y+=normal.y*seed_y*(seed/5.);",
86 | //base from RGB shift shader
87 | "vec2 offset = amount * vec2( cos(angle), sin(angle));",
88 | "vec4 cr = texture2D(tDiffuse, p + offset);",
89 | "vec4 cga = texture2D(tDiffuse, p);",
90 | "vec4 cb = texture2D(tDiffuse, p - offset);",
91 | "gl_FragColor = vec4(cr.r, cga.g, cb.b, cga.a);",
92 | //add noise
93 | "vec4 snow = 200.*amount*vec4(rand(vec2(xs * seed,ys * seed*50.))*0.2);",
94 | "gl_FragColor = gl_FragColor+ snow;",
95 | "}",
96 | "else {",
97 | "gl_FragColor=texture2D (tDiffuse, vUv);",
98 | "}",
99 | "}"
100 |
101 | ].join("\n")
102 |
103 | };
104 |
--------------------------------------------------------------------------------
/js/thirdparty/three/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/thirdparty/three/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/thirdparty/three/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/thirdparty/three/shaders/FXAAShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | * @author davidedc / http://www.sketchpatch.net/
4 | *
5 | * NVIDIA FXAA by Timothy Lottes
6 | * http://timothylottes.blogspot.com/2011/06/fxaa3-source-released.html
7 | * - WebGL port by @supereggbert
8 | * http://www.glge.org/demos/fxaa/
9 | */
10 |
11 | THREE.FXAAShader = {
12 |
13 | uniforms: {
14 |
15 | "tDiffuse": { type: "t", value: null },
16 | "resolution": { type: "v2", value: new THREE.Vector2( 1 / 1024, 1 / 512 ) }
17 |
18 | },
19 |
20 | vertexShader: [
21 |
22 | "void main() {",
23 |
24 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
25 |
26 | "}"
27 |
28 | ].join("\n"),
29 |
30 | fragmentShader: [
31 |
32 | "uniform sampler2D tDiffuse;",
33 | "uniform vec2 resolution;",
34 |
35 | "#define FXAA_REDUCE_MIN (1.0/128.0)",
36 | "#define FXAA_REDUCE_MUL (1.0/8.0)",
37 | "#define FXAA_SPAN_MAX 8.0",
38 |
39 | "void main() {",
40 |
41 | "vec3 rgbNW = texture2D( tDiffuse, ( gl_FragCoord.xy + vec2( -1.0, -1.0 ) ) * resolution ).xyz;",
42 | "vec3 rgbNE = texture2D( tDiffuse, ( gl_FragCoord.xy + vec2( 1.0, -1.0 ) ) * resolution ).xyz;",
43 | "vec3 rgbSW = texture2D( tDiffuse, ( gl_FragCoord.xy + vec2( -1.0, 1.0 ) ) * resolution ).xyz;",
44 | "vec3 rgbSE = texture2D( tDiffuse, ( gl_FragCoord.xy + vec2( 1.0, 1.0 ) ) * resolution ).xyz;",
45 | "vec4 rgbaM = texture2D( tDiffuse, gl_FragCoord.xy * resolution );",
46 | "vec3 rgbM = rgbaM.xyz;",
47 | "vec3 luma = vec3( 0.299, 0.587, 0.114 );",
48 |
49 | "float lumaNW = dot( rgbNW, luma );",
50 | "float lumaNE = dot( rgbNE, luma );",
51 | "float lumaSW = dot( rgbSW, luma );",
52 | "float lumaSE = dot( rgbSE, luma );",
53 | "float lumaM = dot( rgbM, luma );",
54 | "float lumaMin = min( lumaM, min( min( lumaNW, lumaNE ), min( lumaSW, lumaSE ) ) );",
55 | "float lumaMax = max( lumaM, max( max( lumaNW, lumaNE) , max( lumaSW, lumaSE ) ) );",
56 |
57 | "vec2 dir;",
58 | "dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));",
59 | "dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));",
60 |
61 | "float dirReduce = max( ( lumaNW + lumaNE + lumaSW + lumaSE ) * ( 0.25 * FXAA_REDUCE_MUL ), FXAA_REDUCE_MIN );",
62 |
63 | "float rcpDirMin = 1.0 / ( min( abs( dir.x ), abs( dir.y ) ) + dirReduce );",
64 | "dir = min( vec2( FXAA_SPAN_MAX, FXAA_SPAN_MAX),",
65 | "max( vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),",
66 | "dir * rcpDirMin)) * resolution;",
67 | "vec4 rgbA = (1.0/2.0) * (",
68 | "texture2D(tDiffuse, gl_FragCoord.xy * resolution + dir * (1.0/3.0 - 0.5)) +",
69 | "texture2D(tDiffuse, gl_FragCoord.xy * resolution + dir * (2.0/3.0 - 0.5)));",
70 | "vec4 rgbB = rgbA * (1.0/2.0) + (1.0/4.0) * (",
71 | "texture2D(tDiffuse, gl_FragCoord.xy * resolution + dir * (0.0/3.0 - 0.5)) +",
72 | "texture2D(tDiffuse, gl_FragCoord.xy * resolution + dir * (3.0/3.0 - 0.5)));",
73 | "float lumaB = dot(rgbB, vec4(luma, 0.0));",
74 |
75 | "if ( ( lumaB < lumaMin ) || ( lumaB > lumaMax ) ) {",
76 |
77 | "gl_FragColor = rgbA;",
78 |
79 | "} else {",
80 | "gl_FragColor = rgbB;",
81 |
82 | "}",
83 |
84 | "}"
85 |
86 | ].join("\n")
87 |
88 | };
89 |
--------------------------------------------------------------------------------
/js/thirdparty/three/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/thirdparty/three/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/thirdparty/three/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/thirdparty/three/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/thirdparty/three/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/thirdparty/three/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/thirdparty/three/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/thirdparty/three/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/thirdparty/three/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/thirdparty/three/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/thirdparty/three/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/thirdparty/three/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/thirdparty/three/shaders/TechnicolorShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author flimshaw / http://charliehoey.com
3 | *
4 | * Technicolor Shader
5 | * Simulates the look of the two-strip technicolor process popular in early 20th century films.
6 | * More historical info here: http://www.widescreenmuseum.com/oldcolor/technicolor1.htm
7 | * Demo here: http://charliehoey.com/technicolor_shader/shader_test.html
8 | */
9 |
10 | THREE.TechnicolorShader = {
11 |
12 | uniforms: {
13 |
14 | "tDiffuse": { type: "t", value: null },
15 |
16 | },
17 |
18 | vertexShader: [
19 |
20 | "varying vec2 vUv;",
21 |
22 | "void main() {",
23 |
24 | "vUv = uv;",
25 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
26 |
27 | "}"
28 |
29 | ].join("\n"),
30 |
31 | fragmentShader: [
32 |
33 | "uniform sampler2D tDiffuse;",
34 | "varying vec2 vUv;",
35 |
36 | "void main() {",
37 |
38 | "vec4 tex = texture2D( tDiffuse, vec2( vUv.x, vUv.y ) );",
39 | "vec4 newTex = vec4(tex.r, (tex.g + tex.b) * .5, (tex.g + tex.b) * .5, 1.0);",
40 |
41 | "gl_FragColor = newTex;",
42 |
43 | "}"
44 |
45 | ].join("\n")
46 |
47 | };
48 |
--------------------------------------------------------------------------------
/js/thirdparty/three/shaders/ToneMapShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author miibond
3 | *
4 | * Full-screen tone-mapping shader based on http://www.graphics.cornell.edu/~jaf/publications/sig02_paper.pdf
5 | */
6 |
7 | THREE.ToneMapShader = {
8 |
9 | uniforms: {
10 |
11 | "tDiffuse": { type: "t", value: null },
12 | "averageLuminance": { type: "f", value: 1.0 },
13 | "luminanceMap": { type: "t", value: null },
14 | "maxLuminance": { type: "f", value: 16.0 },
15 | "middleGrey": { type: "f", value: 0.6 }
16 | },
17 |
18 | vertexShader: [
19 |
20 | "varying vec2 vUv;",
21 |
22 | "void main() {",
23 |
24 | "vUv = uv;",
25 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
26 |
27 | "}"
28 |
29 | ].join("\n"),
30 |
31 | fragmentShader: [
32 |
33 | "uniform sampler2D tDiffuse;",
34 |
35 | "varying vec2 vUv;",
36 |
37 | "uniform float middleGrey;",
38 | "uniform float maxLuminance;",
39 | "#ifdef ADAPTED_LUMINANCE",
40 | "uniform sampler2D luminanceMap;",
41 | "#else",
42 | "uniform float averageLuminance;",
43 | "#endif",
44 |
45 | "const vec3 LUM_CONVERT = vec3(0.299, 0.587, 0.114);",
46 |
47 | "vec3 ToneMap( vec3 vColor ) {",
48 | "#ifdef ADAPTED_LUMINANCE",
49 | // Get the calculated average luminance
50 | "float fLumAvg = texture2D(luminanceMap, vec2(0.5, 0.5)).r;",
51 | "#else",
52 | "float fLumAvg = averageLuminance;",
53 | "#endif",
54 |
55 | // Calculate the luminance of the current pixel
56 | "float fLumPixel = dot(vColor, LUM_CONVERT);",
57 |
58 | // Apply the modified operator (Eq. 4)
59 | "float fLumScaled = (fLumPixel * middleGrey) / fLumAvg;",
60 |
61 | "float fLumCompressed = (fLumScaled * (1.0 + (fLumScaled / (maxLuminance * maxLuminance)))) / (1.0 + fLumScaled);",
62 | "return fLumCompressed * vColor;",
63 | "}",
64 |
65 | "void main() {",
66 |
67 | "vec4 texel = texture2D( tDiffuse, vUv );",
68 |
69 | "gl_FragColor = vec4( ToneMap( texel.xyz ), texel.w );",
70 | //Gamma 2.0
71 | "gl_FragColor.xyz = sqrt( gl_FragColor.xyz );",
72 |
73 | "}"
74 |
75 | ].join("\n")
76 |
77 | };
78 |
--------------------------------------------------------------------------------
/js/thirdparty/three/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/thirdparty/three/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/thirdparty/three/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/thirdparty/three/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/thirdparty/three/shaders/VignetteShader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | *
4 | * Vignette shader
5 | * based on PaintEffect postprocess from ro.me
6 | * http://code.google.com/p/3-dreams-of-black/source/browse/deploy/js/effects/PaintEffect.js
7 | */
8 |
9 | THREE.VignetteShader = {
10 |
11 | uniforms: {
12 |
13 | "tDiffuse": { type: "t", value: null },
14 | "offset": { type: "f", value: 1.0 },
15 | "darkness": { type: "f", value: 1.0 }
16 |
17 | },
18 |
19 | vertexShader: [
20 |
21 | "varying vec2 vUv;",
22 |
23 | "void main() {",
24 |
25 | "vUv = uv;",
26 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
27 |
28 | "}"
29 |
30 | ].join("\n"),
31 |
32 | fragmentShader: [
33 |
34 | "uniform float offset;",
35 | "uniform float darkness;",
36 |
37 | "uniform sampler2D tDiffuse;",
38 |
39 | "varying vec2 vUv;",
40 |
41 | "void main() {",
42 |
43 | // Eskil's vignette
44 |
45 | "vec4 texel = texture2D( tDiffuse, vUv );",
46 | "vec2 uv = ( vUv - vec2( 0.5 ) ) * vec2( offset );",
47 | "gl_FragColor = vec4( mix( texel.rgb, vec3( 1.0 - darkness ), dot( uv, uv ) ), texel.a );",
48 |
49 | /*
50 | // alternative version from glfx.js
51 | // this one makes more "dusty" look (as opposed to "burned")
52 |
53 | "vec4 color = texture2D( tDiffuse, vUv );",
54 | "float dist = distance( vUv, vec2( 0.5 ) );",
55 | "color.rgb *= smoothstep( 0.8, offset * 0.799, dist *( darkness + offset ) );",
56 | "gl_FragColor = color;",
57 | */
58 |
59 | "}"
60 |
61 | ].join("\n")
62 |
63 | };
64 |
--------------------------------------------------------------------------------
/js/thirdparty/three/utils/UVsDebug.js:
--------------------------------------------------------------------------------
1 | /*
2 | * @author zz85 / http://github.com/zz85
3 | * @author WestLangley / http://github.com/WestLangley
4 | *
5 | * tool for "unwrapping" and debugging three.js
6 | * geometries UV mapping
7 | *
8 | * Sample usage:
9 | * document.body.appendChild(
10 | * THREE.UVsDebug(
11 | * new THREE.SphereGeometry(10,10,10,10));
12 | *
13 | */
14 |
15 | THREE.UVsDebug = function( geometry, size ) {
16 |
17 | // handles wrapping of uv.x > 1 only
18 |
19 | var abc = 'abcd';
20 |
21 | var uv, u, ax, ay;
22 | var i, il, j, jl;
23 | var vnum;
24 |
25 | var a = new THREE.Vector2();
26 | var b = new THREE.Vector2();
27 |
28 | var faces = geometry.faces;
29 | var uvs = geometry.faceVertexUvs[ 0 ];
30 |
31 | var canvas = document.createElement( 'canvas' );
32 | var width = size || 1024; // power of 2 required for wrapping
33 | var height = size || 1024;
34 | canvas.width = width;
35 | canvas.height = height;
36 |
37 | var ctx = canvas.getContext( '2d' );
38 | ctx.lineWidth = 2;
39 | ctx.strokeStyle = 'rgba( 0, 0, 0, 1.0 )';
40 | ctx.textAlign = 'center';
41 |
42 | // paint background white
43 |
44 | ctx.fillStyle = 'rgba( 255, 255, 255, 1.0 )';
45 | ctx.fillRect( 0, 0, width, height );
46 |
47 | for ( i = 0, il = uvs.length; i < il; i ++ ) {
48 |
49 | uv = uvs[ i ];
50 |
51 | // draw lines
52 |
53 | ctx.beginPath();
54 |
55 | a.set( 0, 0 );
56 |
57 | for ( j = 0, jl = uv.length; j < jl; j ++ ) {
58 |
59 | u = uv[ j ];
60 |
61 | a.x += u.x;
62 | a.y += u.y;
63 |
64 | if ( j == 0 ) {
65 |
66 | ctx.moveTo( u.x * width, ( 1 - u.y ) * height );
67 |
68 | } else {
69 |
70 | ctx.lineTo( u.x * width, ( 1 - u.y ) * height );
71 |
72 | }
73 |
74 | }
75 |
76 | ctx.closePath();
77 | ctx.stroke();
78 |
79 | a.divideScalar( jl );
80 |
81 | // label the face number
82 |
83 | ctx.font = "12pt Arial bold";
84 | ctx.fillStyle = 'rgba( 0, 0, 0, 1.0 )';
85 | ctx.fillText( i, a.x * width, ( 1 - a.y ) * height );
86 |
87 | if ( a.x > 0.95 ) { // wrap x // 0.95 is arbitrary
88 |
89 | ctx.fillText( i, ( a.x % 1 ) * width, ( 1 - a.y ) * height );
90 |
91 | }
92 |
93 | ctx.font = "8pt Arial bold";
94 | ctx.fillStyle = 'rgba( 0, 0, 0, 1.0 )';
95 |
96 | // label uv edge orders
97 |
98 | for ( j = 0, jl = uv.length; j < jl; j ++ ) {
99 |
100 | u = uv[ j ];
101 | b.addVectors( a, u ).divideScalar( 2 );
102 |
103 | vnum = faces[ i ][ abc[ j ] ];
104 | ctx.fillText( abc[ j ] + vnum, b.x * width, ( 1 - b.y ) * height );
105 |
106 | if ( b.x > 0.95 ) { // wrap x
107 |
108 | ctx.fillText( abc[ j ] + vnum, ( b.x % 1 ) * width, ( 1 - b.y ) * height );
109 |
110 | }
111 |
112 | }
113 |
114 | }
115 |
116 | return canvas;
117 |
118 | }
119 |
120 |
--------------------------------------------------------------------------------
/js/thirdparty/three/wip/CircleTypedGeometry.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author hughes
3 | * @author mrdoob / http://mrdoob.com/
4 | */
5 |
6 | THREE.CircleTypedGeometry = function ( radius, segments, thetaStart, thetaLength ) {
7 |
8 | this.parameters = {
9 | radius: radius,
10 | segments: segments,
11 | thetaStart: thetaStart,
12 | thetaLength: thetaLength
13 | };
14 |
15 | radius = radius || 50;
16 | segments = segments !== undefined ? Math.max( 3, segments ) : 8;
17 |
18 | thetaStart = thetaStart !== undefined ? thetaStart : 0;
19 | thetaLength = thetaLength !== undefined ? thetaLength : Math.PI * 2;
20 |
21 | //
22 |
23 | var elements = segments + 2;
24 |
25 | var indices = new Uint16Array( segments * 3 );
26 | var vertices = new Float32Array( elements * 3 );
27 | var normals = new Float32Array( elements * 3 );
28 | var uvs = new Float32Array( elements * 2 );
29 |
30 | // center
31 |
32 | normals[ 2 ] = 1;
33 |
34 | uvs[ 0 ] = 0.5;
35 | uvs[ 1 ] = 0.5;
36 |
37 | var offset = 0, offset2 = 2, offset3 = 3;
38 |
39 | for ( var i = 0; i <= segments; i ++ ) {
40 |
41 | var segment = thetaStart + i / segments * thetaLength;
42 |
43 | var x = radius * Math.cos( segment );
44 | var y = radius * Math.sin( segment );
45 |
46 | vertices[ offset3 ] = x;
47 | vertices[ offset3 + 1 ] = y;
48 |
49 | normals[ offset3 + 2 ] = 1;
50 |
51 | uvs[ offset2 ] = ( x / radius + 1 ) / 2;
52 | uvs[ offset2 + 1 ] = ( y / radius + 1 ) / 2;
53 |
54 | offset2 += 2;
55 | offset3 += 3;
56 |
57 | //
58 |
59 | indices[ offset ] = 0;
60 | indices[ offset + 1 ] = i + 1;
61 | indices[ offset + 2 ] = i + 2;
62 |
63 | offset += 3;
64 |
65 | }
66 |
67 | THREE.IndexedTypedGeometry.call( this );
68 |
69 | this.setArrays( indices, vertices, normals, uvs );
70 |
71 | this.boundingSphere = new THREE.Sphere( new THREE.Vector3(), radius );
72 |
73 | };
74 |
75 | THREE.CircleTypedGeometry.prototype = Object.create( THREE.IndexedTypedGeometry.prototype );
76 | THREE.CircleTypedGeometry.prototype.constructor = THREE.CircleTypedGeometry;
77 |
--------------------------------------------------------------------------------
/js/thirdparty/three/wip/GeometryEditor.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author mrdoob / http://mrdoob.com/
3 | */
4 |
5 | THREE.GeometryEditor = function ( geometry ) {
6 |
7 | this.geometry = geometry;
8 |
9 | };
10 |
11 | Object.defineProperties( THREE.GeometryEditor.prototype, {
12 | vertices: {
13 | enumerable: true,
14 | get: function() { return this.createVertexProxies(); }
15 | },
16 | normals: {
17 | enumerable: true,
18 | get: function() { return this.createNormalProxies(); }
19 | },
20 | uvs: {
21 | enumerable: true,
22 | get: function() { return this.createUVProxies(); }
23 | }
24 | } );
25 |
26 | THREE.GeometryEditor.prototype.createVertexProxies = function () {
27 |
28 | Object.defineProperty( this, 'vertices', { value: [], writable: true } );
29 |
30 | var attributes = this.geometry.attributes;
31 | var length = attributes.position.array.length / 3;
32 |
33 | for ( var i = 0; i < length; i ++ ) {
34 |
35 | this.vertices.push( new THREE.ProxyVector3( attributes.position.array, i * 3 ) );
36 |
37 | }
38 |
39 | return this.vertices;
40 |
41 | };
42 |
43 | THREE.GeometryEditor.prototype.createNormalProxies = function () {
44 |
45 | Object.defineProperty( this, 'normals', { value: [], writable: true } );
46 |
47 | var attributes = this.geometry.attributes;
48 | var length = attributes.position.array.length / 3;
49 |
50 | for ( var i = 0; i < length; i ++ ) {
51 |
52 | this.normals.push( new THREE.ProxyVector3( attributes.normal.array, i * 3 ) );
53 |
54 | }
55 |
56 | return this.normals;
57 |
58 | };
59 |
60 | THREE.GeometryEditor.prototype.createUVProxies = function () {
61 |
62 | Object.defineProperty( this, 'uvs', { value: [], writable: true } );
63 |
64 | var attributes = this.geometry.attributes;
65 | var length = attributes.position.array.length / 3;
66 |
67 | for ( var i = 0; i < length; i ++ ) {
68 |
69 | this.uvs.push( new THREE.ProxyVector2( attributes.uv.array, i * 2 ) );
70 |
71 | }
72 |
73 | return this.uvs;
74 |
75 | };
--------------------------------------------------------------------------------
/js/thirdparty/three/wip/IndexedTypedGeometry.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author mrdoob / http://mrdoob.com/
3 | */
4 |
5 | THREE.IndexedTypedGeometry = function () {
6 |
7 | THREE.BufferGeometry.call( this );
8 |
9 | };
10 |
11 | THREE.IndexedTypedGeometry.prototype = Object.create( THREE.BufferGeometry.prototype );
12 | THREE.IndexedTypedGeometry.prototype.constructor = THREE.IndexedTypedGeometry;
13 |
14 | THREE.IndexedTypedGeometry.prototype.setArrays = function ( indices, vertices, normals, uvs ) {
15 |
16 | this.indices = indices;
17 | this.vertices = vertices;
18 | this.normals = normals;
19 | this.uvs = uvs;
20 |
21 | this.attributes[ 'index' ] = { array: indices, itemSize: 1 };
22 | this.attributes[ 'position' ] = { array: vertices, itemSize: 3 };
23 | this.attributes[ 'normal' ] = { array: normals, itemSize: 3 };
24 | this.attributes[ 'uv' ] = { array: uvs, itemSize: 2 };
25 |
26 | return this;
27 |
28 | };
29 |
--------------------------------------------------------------------------------
/js/thirdparty/three/wip/PlaneTypedGeometry.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author mrdoob / http://mrdoob.com/
3 | * based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Plane.as
4 | */
5 |
6 | THREE.PlaneTypedGeometry = function ( width, height, widthSegments, heightSegments ) {
7 |
8 | this.parameters = {
9 | width: width,
10 | height: height,
11 | widthSegments: widthSegments,
12 | heightSegments: heightSegments
13 | };
14 |
15 | var width_half = width / 2;
16 | var height_half = height / 2;
17 |
18 | var gridX = widthSegments || 1;
19 | var gridY = heightSegments || 1;
20 |
21 | var gridX1 = gridX + 1;
22 | var gridY1 = gridY + 1;
23 |
24 | var segment_width = width / gridX;
25 | var segment_height = height / gridY;
26 |
27 | var vertices = new Float32Array( gridX1 * gridY1 * 3 );
28 | var normals = new Float32Array( gridX1 * gridY1 * 3 );
29 | var uvs = new Float32Array( gridX1 * gridY1 * 2 );
30 |
31 | var offset = 0;
32 | var offset2 = 0;
33 |
34 | for ( var iy = 0; iy < gridY1; iy ++ ) {
35 |
36 | var y = iy * segment_height - height_half;
37 |
38 | for ( var ix = 0; ix < gridX1; ix ++ ) {
39 |
40 | var x = ix * segment_width - width_half;
41 |
42 | vertices[ offset ] = x;
43 | vertices[ offset + 1 ] = - y;
44 |
45 | normals[ offset + 2 ] = 1;
46 |
47 | uvs[ offset2 ] = ix / gridX;
48 | uvs[ offset2 + 1 ] = 1 - ( iy / gridY );
49 |
50 | offset += 3;
51 | offset2 += 2;
52 |
53 | }
54 |
55 | }
56 |
57 | offset = 0;
58 |
59 | var indices = new ( ( vertices.length / 3 ) > 65535 ? Uint32Array : Uint16Array )( gridX * gridY * 6 );
60 |
61 | for ( var iy = 0; iy < gridY; iy ++ ) {
62 |
63 | for ( var ix = 0; ix < gridX; ix ++ ) {
64 |
65 | var a = ix + gridX1 * iy;
66 | var b = ix + gridX1 * ( iy + 1 );
67 | var c = ( ix + 1 ) + gridX1 * ( iy + 1 );
68 | var d = ( ix + 1 ) + gridX1 * iy;
69 |
70 | indices[ offset ] = a;
71 | indices[ offset + 1 ] = b;
72 | indices[ offset + 2 ] = d;
73 |
74 | indices[ offset + 3 ] = b;
75 | indices[ offset + 4 ] = c;
76 | indices[ offset + 5 ] = d;
77 |
78 | offset += 6;
79 |
80 | }
81 |
82 | }
83 |
84 | THREE.IndexedTypedGeometry.call( this );
85 |
86 | this.setArrays( indices, vertices, normals, uvs );
87 | this.computeBoundingSphere();
88 |
89 | };
90 |
91 | THREE.PlaneTypedGeometry.prototype = Object.create( THREE.IndexedTypedGeometry.prototype );
92 | THREE.PlaneTypedGeometry.prototype.constructor = THREE.PlaneTypedGeometry;
93 |
--------------------------------------------------------------------------------
/js/thirdparty/three/wip/TypedGeometry.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author mrdoob / http://mrdoob.com/
3 | */
4 |
5 | THREE.TypedGeometry = function ( size ) {
6 |
7 | THREE.BufferGeometry.call( this );
8 |
9 | if ( size !== undefined ) {
10 |
11 | this.setArrays(
12 | new Float32Array( size * 3 * 3 ),
13 | new Float32Array( size * 3 * 3 ),
14 | new Float32Array( size * 3 * 2 )
15 | );
16 |
17 | }
18 |
19 | };
20 |
21 | THREE.TypedGeometry.prototype = Object.create( THREE.BufferGeometry.prototype );
22 | THREE.TypedGeometry.prototype.constructor = THREE.TypedGeometry;
23 |
24 | THREE.TypedGeometry.prototype.setArrays = function ( vertices, normals, uvs ) {
25 |
26 | this.vertices = vertices;
27 | this.normals = normals;
28 | this.uvs = uvs;
29 |
30 | this.addAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
31 | this.addAttribute( 'normal', new THREE.BufferAttribute( normals, 3 ) );
32 | this.addAttribute( 'uv', new THREE.BufferAttribute( uvs, 2 ) );
33 |
34 | return this;
35 |
36 | };
37 |
38 | THREE.TypedGeometry.prototype.merge = ( function () {
39 |
40 | var offset = 0;
41 | var normalMatrix = new THREE.Matrix3();
42 |
43 | return function ( geometry, matrix, startOffset ) {
44 |
45 | if ( startOffset !== undefined ) offset = startOffset;
46 |
47 | var offset2 = offset * 2;
48 | var offset3 = offset * 3;
49 |
50 | var vertices = this.attributes.position.array;
51 | var normals = this.attributes.normal.array;
52 | var uvs = this.attributes.uv.array;
53 |
54 | if ( geometry instanceof THREE.TypedGeometry ) {
55 |
56 | var vertices2 = geometry.attributes.position.array;
57 | var normals2 = geometry.attributes.normal.array;
58 | var uvs2 = geometry.attributes.uv.array;
59 |
60 | for ( var i = 0, l = vertices2.length; i < l; i += 3 ) {
61 |
62 | vertices[ i + offset3 ] = vertices2[ i ];
63 | vertices[ i + offset3 + 1 ] = vertices2[ i + 1 ];
64 | vertices[ i + offset3 + 2 ] = vertices2[ i + 2 ];
65 |
66 | normals[ i + offset3 ] = normals2[ i ];
67 | normals[ i + offset3 + 1 ] = normals2[ i + 1 ];
68 | normals[ i + offset3 + 2 ] = normals2[ i + 2 ];
69 |
70 | uvs[ i + offset2 ] = uvs2[ i ];
71 | uvs[ i + offset2 + 1 ] = uvs2[ i + 1 ];
72 |
73 | }
74 |
75 | } else if ( geometry instanceof THREE.IndexedTypedGeometry ) {
76 |
77 | var indices2 = geometry.attributes.index.array;
78 | var vertices2 = geometry.attributes.position.array;
79 | var normals2 = geometry.attributes.normal.array;
80 | var uvs2 = geometry.attributes.uv.array;
81 |
82 | for ( var i = 0, l = indices2.length; i < l; i ++ ) {
83 |
84 | var index = indices2[ i ];
85 |
86 | var index3 = index * 3;
87 | var i3 = i * 3;
88 |
89 | vertices[ i3 + offset3 ] = vertices2[ index3 ];
90 | vertices[ i3 + offset3 + 1 ] = vertices2[ index3 + 1 ];
91 | vertices[ i3 + offset3 + 2 ] = vertices2[ index3 + 2 ];
92 |
93 | normals[ i3 + offset3 ] = normals2[ index3 ];
94 | normals[ i3 + offset3 + 1 ] = normals2[ index3 + 1 ];
95 | normals[ i3 + offset3 + 2 ] = normals2[ index3 + 2 ];
96 |
97 | var index2 = index * 2;
98 | var i2 = i * 2;
99 |
100 | uvs[ i2 + offset2 ] = uvs2[ index2 ];
101 | uvs[ i2 + offset2 + 1 ] = uvs2[ index2 + 1 ];
102 |
103 | }
104 |
105 | if ( matrix !== undefined ) {
106 |
107 | matrix.applyToVector3Array( vertices, offset3, indices2.length * 3 );
108 |
109 | normalMatrix.getNormalMatrix( matrix );
110 | normalMatrix.applyToVector3Array( normals, offset3, indices2.length * 3 );
111 |
112 | }
113 |
114 | offset += indices2.length;
115 |
116 | }
117 |
118 | };
119 |
120 | } )();
--------------------------------------------------------------------------------
/js/thirdparty/three/wip/benchmark/BoxGeometry2.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author mrdoob / http://mrdoob.com/
3 | * based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Cube.as
4 | */
5 |
6 | THREE.BoxGeometry2 = function ( width, height, depth, widthSegments, heightSegments, depthSegments ) {
7 |
8 | var scope = this;
9 |
10 | this.width = width;
11 | this.height = height;
12 | this.depth = depth;
13 |
14 | this.widthSegments = widthSegments || 1;
15 | this.heightSegments = heightSegments || 1;
16 | this.depthSegments = depthSegments || 1;
17 |
18 | var width_half = this.width / 2;
19 | var height_half = this.height / 2;
20 | var depth_half = this.depth / 2;
21 |
22 | var vector = new THREE.Vector3();
23 |
24 | var vectors = [];
25 | var vertices = [];
26 |
27 | var addVertex = function ( a, b, c ) {
28 |
29 | vertices.push( vectors[ a ], vectors[ a + 1 ], vectors[ a + 2 ] );
30 | vertices.push( vectors[ b ], vectors[ b + 1 ], vectors[ b + 2 ] );
31 | vertices.push( vectors[ c ], vectors[ c + 1 ], vectors[ c + 2 ] );
32 |
33 | };
34 |
35 | buildPlane( 'z', 'y', - 1, - 1, this.depth, this.height, width_half, 0 ); // px
36 | buildPlane( 'z', 'y', 1, - 1, this.depth, this.height, - width_half, 1 ); // nx
37 | buildPlane( 'x', 'z', 1, 1, this.width, this.depth, height_half, 2 ); // py
38 | buildPlane( 'x', 'z', 1, - 1, this.width, this.depth, - height_half, 3 ); // ny
39 | buildPlane( 'x', 'y', 1, - 1, this.width, this.height, depth_half, 4 ); // pz
40 | buildPlane( 'x', 'y', - 1, - 1, this.width, this.height, - depth_half, 5 ); // nz
41 |
42 | function buildPlane( u, v, udir, vdir, width, height, depth, materialIndex ) {
43 |
44 | var w, ix, iy,
45 | gridX = scope.widthSegments,
46 | gridY = scope.heightSegments,
47 | width_half = width / 2,
48 | height_half = height / 2,
49 | offset = vectors.length;
50 |
51 | if ( ( u === 'x' && v === 'y' ) || ( u === 'y' && v === 'x' ) ) {
52 |
53 | w = 'z';
54 |
55 | } else if ( ( u === 'x' && v === 'z' ) || ( u === 'z' && v === 'x' ) ) {
56 |
57 | w = 'y';
58 | gridY = scope.depthSegments;
59 |
60 | } else if ( ( u === 'z' && v === 'y' ) || ( u === 'y' && v === 'z' ) ) {
61 |
62 | w = 'x';
63 | gridX = scope.depthSegments;
64 |
65 | }
66 |
67 | var gridX1 = gridX + 1,
68 | gridY1 = gridY + 1,
69 | segment_width = width / gridX,
70 | segment_height = height / gridY,
71 | normal = new THREE.Vector3();
72 |
73 | normal[ w ] = depth > 0 ? 1 : - 1;
74 |
75 | for ( iy = 0; iy < gridY1; iy ++ ) {
76 |
77 | for ( ix = 0; ix < gridX1; ix ++ ) {
78 |
79 | vector[ u ] = ( ix * segment_width - width_half ) * udir;
80 | vector[ v ] = ( iy * segment_height - height_half ) * vdir;
81 | vector[ w ] = depth;
82 |
83 | vectors.push( vector.x, vector.y, vector.z );
84 |
85 | }
86 |
87 | }
88 |
89 | for ( iy = 0; iy < gridY; iy ++ ) {
90 |
91 | for ( ix = 0; ix < gridX; ix ++ ) {
92 |
93 | var a = ix + gridX1 * iy;
94 | var b = ix + gridX1 * ( iy + 1 );
95 | var c = ( ix + 1 ) + gridX1 * ( iy + 1 );
96 | var d = ( ix + 1 ) + gridX1 * iy;
97 |
98 | addVertex( a * 3 + offset, b * 3 + offset, d * 3 + offset );
99 | addVertex( b * 3 + offset, c * 3 + offset, d * 3 + offset );
100 |
101 | }
102 |
103 | }
104 |
105 | }
106 |
107 | THREE.Geometry2.call( this, vertices.length / 3 );
108 |
109 | this.vertices.set( vertices );
110 |
111 | };
112 |
113 | THREE.BoxGeometry2.prototype = Object.create( THREE.Geometry2.prototype );
114 | THREE.BoxGeometry2.prototype.constructor = THREE.BoxGeometry2;
115 |
--------------------------------------------------------------------------------
/js/thirdparty/three/wip/benchmark/Geometry2.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author mrdoob / http://mrdoob.com/
3 | */
4 |
5 | THREE.Geometry2 = function ( size ) {
6 |
7 | THREE.BufferGeometry.call( this );
8 |
9 | this.vertices = new THREE.Float32Attribute( size, 3 );
10 | this.normals = new THREE.Float32Attribute( size, 3 );
11 | this.uvs = new THREE.Float32Attribute( size, 2 );
12 |
13 | this.addAttribute( 'position', this.vertices );
14 | this.addAttribute( 'normal', this.normals );
15 | this.addAttribute( 'uv', this.uvs );
16 |
17 | };
18 |
19 | THREE.Geometry2.prototype = Object.create( THREE.BufferGeometry.prototype );
20 | THREE.Geometry2.prototype.constructor = THREE.Geometry2;
--------------------------------------------------------------------------------
/js/thirdparty/three/wip/benchmark/Geometry2Loader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author mrdoob / http://mrdoob.com/
3 | */
4 |
5 | THREE.Geometry2Loader = function ( manager ) {
6 |
7 | this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;
8 |
9 | };
10 |
11 | THREE.Geometry2Loader.prototype = {
12 |
13 | constructor: THREE.Geometry2Loader,
14 |
15 | load: function ( url, onLoad, onProgress, onError ) {
16 |
17 | var scope = this;
18 |
19 | var loader = new THREE.XHRLoader();
20 | loader.setCrossOrigin( this.crossOrigin );
21 | loader.load( url, function ( text ) {
22 |
23 | onLoad( scope.parse( JSON.parse( text ) ) );
24 |
25 | } );
26 |
27 | },
28 |
29 | setCrossOrigin: function ( value ) {
30 |
31 | this.crossOrigin = value;
32 |
33 | },
34 |
35 | parse: function ( json ) {
36 |
37 | var geometry = new THREE.Geometry2( json.vertices.length / 3 );
38 |
39 | var attributes = [ 'vertices', 'normals', 'uvs' ];
40 | var boundingSphere = json.boundingSphere;
41 |
42 | for ( var key in attributes ) {
43 |
44 | var attribute = attributes[ key ];
45 | geometry[ attribute ].set( json[ attribute ] );
46 |
47 | }
48 |
49 | if ( boundingSphere !== undefined ) {
50 |
51 | var center = new THREE.Vector3();
52 |
53 | if ( boundingSphere.center !== undefined ) {
54 |
55 | center.fromArray( boundingSphere.center );
56 |
57 | }
58 |
59 | geometry.boundingSphere = new THREE.Sphere( center, boundingSphere.radius );
60 |
61 | }
62 |
63 | return geometry;
64 |
65 | }
66 |
67 | };
68 |
--------------------------------------------------------------------------------
/js/thirdparty/three/wip/benchmark/Geometry3.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author mrdoob / http://mrdoob.com/
3 | */
4 |
5 | THREE.Geometry3 = function ( size ) {
6 |
7 | THREE.BufferGeometry.call( this );
8 |
9 | var verticesBuffer = new ArrayBuffer( size * 3 * 4 );
10 | var normalsBuffer = new ArrayBuffer( size * 3 * 4 );
11 | var uvsBuffer = new ArrayBuffer( size * 2 * 4 );
12 |
13 | this.vertices = [];
14 | this.normals = [];
15 | this.uvs = [];
16 |
17 | for ( var i = 0; i < size; i ++ ) {
18 |
19 | this.vertices.push( new Float32Array( verticesBuffer, i * 3 * 4, 3 ) );
20 | this.normals.push( new Float32Array( normalsBuffer, i * 3 * 4, 3 ) );
21 | this.uvs.push( new Float32Array( uvsBuffer, i * 2 * 4, 2 ) );
22 |
23 | }
24 |
25 | this.attributes[ 'position' ] = { array: new Float32Array( verticesBuffer, 0, size * 3 ), itemSize: 3 };
26 | this.attributes[ 'normal' ] = { array: new Float32Array( normalsBuffer, 0, size * 3 ), itemSize: 3 };
27 | this.attributes[ 'uv' ] = { array: new Float32Array( uvsBuffer, 0, size * 2 ), itemSize: 2 };
28 |
29 | };
30 |
31 | THREE.Geometry3.prototype = Object.create( THREE.BufferGeometry.prototype );
32 | THREE.Geometry3.prototype.constructor = THREE.Geometry3;
--------------------------------------------------------------------------------
/js/thirdparty/three/wip/benchmark/Geometry4.js:
--------------------------------------------------------------------------------
1 | THREE.Geometry4 = function ( size ) {
2 |
3 | THREE.BufferGeometry.call( this );
4 |
5 | var verticesBuffer = new ArrayBuffer( size * 3 * 4 );
6 | var normalsBuffer = new ArrayBuffer( size * 3 * 4 );
7 | var uvsBuffer = new ArrayBuffer( size * 2 * 4 );
8 |
9 | this.attributes[ 'position' ] = { array: new Float32Array( verticesBuffer, 0, size * 3 ), itemSize: 3 };
10 | this.attributes[ 'normal' ] = { array: new Float32Array( normalsBuffer, 0, size * 3 ), itemSize: 3 };
11 | this.attributes[ 'uv' ] = { array: new Float32Array( uvsBuffer, 0, size * 2 ), itemSize: 2 };
12 |
13 | this.vertices = new THREE.VectorArrayProxy( this.attributes[ 'position' ] );
14 | this.normals = new THREE.VectorArrayProxy( this.attributes[ 'normal' ] );
15 | this.uvs = new THREE.VectorArrayProxy( this.attributes[ 'uv' ] );
16 |
17 | };
18 | THREE.Geometry4.prototype = Object.create( THREE.BufferGeometry.prototype );
19 | THREE.Geometry4.prototype.constructor = THREE.Geometry4;
20 |
21 | THREE.VectorArrayProxy = function(attribute) {
22 |
23 | // Acts as a proxy for an array of vectors, by setting up accessors which return THREE.Vector*Proxy objects
24 |
25 | this.attribute = attribute;
26 |
27 | for (var i = 0, l = this.attribute.array.length / this.attribute.itemSize; i < l; i ++) {
28 |
29 | Object.defineProperty(this, i, {
30 | get: (function(i) { return function() { return this.getValue(i); }})(i),
31 | set: (function(i) { return function(v) { return this.setValue(i, v); }})(i),
32 | });
33 |
34 | }
35 |
36 | }
37 |
38 | THREE.VectorArrayProxy.prototype.getValue = function(i) {
39 |
40 | // Allocates a new THREE.Vector2Proxy or THREE.Vector3Proxy depending on the itemSize of our attribute
41 |
42 | var subarray = this.attribute.array.subarray(i * this.attribute.itemSize, (i + 1) * this.attribute.itemSize);
43 |
44 | switch (this.attribute.itemSize) {
45 |
46 | case 2:
47 | return new THREE.Vector2Proxy(subarray);
48 |
49 | case 3:
50 | return new THREE.Vector3Proxy(subarray);
51 |
52 | }
53 |
54 | }
55 | THREE.VectorArrayProxy.prototype.setValue = function(i, v) {
56 |
57 | var vec = this[i];
58 | vec.copy(v);
59 |
60 | }
61 |
62 | // Vector Proxy Objects
63 |
64 | THREE.Vector2Proxy = function(subarray) {
65 |
66 | this.subarray = subarray;
67 |
68 | }
69 | THREE.Vector2Proxy.prototype = Object.create( THREE.Vector2.prototype );
70 | THREE.Vector2Proxy.prototype.constructor = THREE.Vector2Proxy;
71 | Object.defineProperty(THREE.Vector2Proxy.prototype, 'x', { get: function() { return this.subarray[0]; }, set: function(v) { this.subarray[0] = v; } });
72 | Object.defineProperty(THREE.Vector2Proxy.prototype, 'y', { get: function() { return this.subarray[1]; }, set: function(v) { this.subarray[1] = v; } });
73 |
74 |
75 | THREE.Vector3Proxy = function(subarray) {
76 |
77 | this.subarray = subarray;
78 |
79 | }
80 | THREE.Vector3Proxy.prototype = Object.create( THREE.Vector3.prototype );
81 | THREE.Vector3Proxy.prototype.constructor = THREE.Vector3Proxy;
82 |
83 | Object.defineProperty(THREE.Vector3Proxy.prototype, 'x', { get: function() { return this.subarray[0]; }, set: function(v) { this.subarray[0] = v; } });
84 | Object.defineProperty(THREE.Vector3Proxy.prototype, 'y', { get: function() { return this.subarray[1]; }, set: function(v) { this.subarray[1] = v; } });
85 | Object.defineProperty(THREE.Vector3Proxy.prototype, 'z', { get: function() { return this.subarray[2]; }, set: function(v) { this.subarray[2] = v; } });
--------------------------------------------------------------------------------
/js/thirdparty/three/wip/benchmark/Geometry5.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author mrdoob / http://mrdoob.com/
3 | */
4 |
5 | THREE.Geometry5 = function ( size ) {
6 |
7 | THREE.BufferGeometry.call( this );
8 |
9 | var verticesBuffer = new Float32Array( size * 3 );
10 | var normalsBuffer = new Float32Array( size * 3 );
11 | var uvsBuffer = new Float32Array( size * 2 );
12 |
13 | this.vertices = [];
14 | this.normals = [];
15 | this.uvs = [];
16 |
17 | for ( var i = 0; i < size; i ++ ) {
18 |
19 | this.vertices.push( new THREE.TypedVector3( verticesBuffer, i * 3 ) );
20 | this.normals.push( new THREE.TypedVector3( normalsBuffer, i * 3 ) );
21 | this.uvs.push( new THREE.TypedVector2( uvsBuffer, i * 2 ) );
22 |
23 | }
24 |
25 | this.attributes[ 'position' ] = { array: verticesBuffer, itemSize: 3 };
26 | this.attributes[ 'normal' ] = { array: normalsBuffer, itemSize: 3 };
27 | this.attributes[ 'uv' ] = { array: uvsBuffer, itemSize: 2 };
28 |
29 | };
30 |
31 | THREE.Geometry5.prototype = Object.create( THREE.BufferGeometry.prototype );
32 | THREE.Geometry5.prototype.constructor = THREE.Geometry5;
33 |
34 | THREE.TypedVector2 = function ( array, offset ) {
35 |
36 | this.array = array;
37 | this.offset = offset;
38 |
39 | };
40 |
41 | THREE.TypedVector2.prototype = Object.create( THREE.Vector2.prototype );
42 | THREE.TypedVector2.prototype.constructor = THREE.TypedVector2;
43 |
44 | Object.defineProperties( THREE.TypedVector2.prototype, {
45 | 'x': {
46 | get: function () { return this.array[ this.offset ]; },
47 | set: function ( v ) { this.array[ this.offset ] = v; }
48 | },
49 | 'y': {
50 | get: function () { return this.array[ this.offset + 1 ]; },
51 | set: function ( v ) { this.array[ this.offset + 1 ] = v; }
52 | }
53 | } );
54 |
55 | THREE.TypedVector3 = function ( array, offset ) {
56 |
57 | this.array = array;
58 | this.offset = offset;
59 |
60 | };
61 |
62 | THREE.TypedVector3.prototype = Object.create( THREE.Vector3.prototype );
63 | THREE.TypedVector3.prototype.constructor = THREE.TypedVector3;
64 |
65 | Object.defineProperties( THREE.TypedVector3.prototype, {
66 | 'x': {
67 | get: function () { return this.array[ this.offset ]; },
68 | set: function ( v ) { this.array[ this.offset ] = v; }
69 | },
70 | 'y': {
71 | get: function () { return this.array[ this.offset + 1 ]; },
72 | set: function ( v ) { this.array[ this.offset + 1 ] = v; }
73 | },
74 | 'z': {
75 | get: function () { return this.array[ this.offset + 2 ]; },
76 | set: function ( v ) { this.array[ this.offset + 2 ] = v; }
77 | }
78 | } );
--------------------------------------------------------------------------------
/js/thirdparty/three/wip/benchmark/Geometry5b.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author mrdoob / http://mrdoob.com/
3 | */
4 |
5 | THREE.Geometry5b = function ( bufferGeometry ) {
6 |
7 | THREE.BufferGeometry.call( this );
8 |
9 | this.attributes = bufferGeometry.attributes;
10 |
11 | var verticesBuffer = this.attributes.position.array;
12 | var normalsBuffer = this.attributes.normal.array;
13 | var uvsBuffer = this.attributes.uv.array;
14 |
15 | this.vertices = [];
16 | this.normals = [];
17 | this.uvs = [];
18 |
19 | for ( var i = 0, l = verticesBuffer.length / 3; i < l; i ++ ) {
20 |
21 | this.vertices.push( new THREE.TypedVector3( verticesBuffer, i * 3 ) );
22 | this.normals.push( new THREE.TypedVector3( normalsBuffer, i * 3 ) );
23 | this.uvs.push( new THREE.TypedVector2( uvsBuffer, i * 2 ) );
24 |
25 | }
26 |
27 | };
28 |
29 | THREE.Geometry5b.prototype = Object.create( THREE.BufferGeometry.prototype );
30 | THREE.Geometry5b.prototype.constructor = THREE.Geometry5b;
31 |
32 | THREE.TypedVector2 = function ( array, offset ) {
33 |
34 | this.array = array;
35 | this.offset = offset;
36 |
37 | };
38 |
39 | THREE.TypedVector2.prototype = Object.create( THREE.Vector2.prototype );
40 | THREE.TypedVector2.prototype.constructor = THREE.TypedVector2;
41 |
42 | Object.defineProperties( THREE.TypedVector2.prototype, {
43 | 'x': {
44 | get: function () { return this.array[ this.offset ]; },
45 | set: function ( v ) { this.array[ this.offset ] = v; }
46 | },
47 | 'y': {
48 | get: function () { return this.array[ this.offset + 1 ]; },
49 | set: function ( v ) { this.array[ this.offset + 1 ] = v; }
50 | }
51 | } );
52 |
53 | THREE.TypedVector3 = function ( array, offset ) {
54 |
55 | this.array = array;
56 | this.offset = offset;
57 |
58 | };
59 |
60 | THREE.TypedVector3.prototype = Object.create( THREE.Vector3.prototype );
61 | THREE.TypedVector3.prototype.constructor = THREE.TypedVector3;
62 |
63 | Object.defineProperties( THREE.TypedVector3.prototype, {
64 | 'x': {
65 | get: function () { return this.array[ this.offset ]; },
66 | set: function ( v ) { this.array[ this.offset ] = v; }
67 | },
68 | 'y': {
69 | get: function () { return this.array[ this.offset + 1 ]; },
70 | set: function ( v ) { this.array[ this.offset + 1 ] = v; }
71 | },
72 | 'z': {
73 | get: function () { return this.array[ this.offset + 2 ]; },
74 | set: function ( v ) { this.array[ this.offset + 2 ] = v; }
75 | }
76 | } );
--------------------------------------------------------------------------------
/js/thirdparty/three/wip/benchmark/IndexedGeometry3.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author mrdoob / http://mrdoob.com/
3 | */
4 |
5 | THREE.IndexedGeometry3 = function ( indices, size ) {
6 |
7 | THREE.BufferGeometry.call( this );
8 |
9 | var verticesBuffer = new ArrayBuffer( size * 3 * 4 );
10 | var normalsBuffer = new ArrayBuffer( size * 3 * 4 );
11 | var uvsBuffer = new ArrayBuffer( size * 2 * 4 );
12 |
13 | this.indices = new Uint16Array( indices );
14 | this.vertices = [];
15 | this.normals = [];
16 | this.uvs = [];
17 |
18 | for ( var i = 0; i < size; i ++ ) {
19 |
20 | this.vertices.push( new Float32Array( verticesBuffer, i * 3 * 4, 3 ) );
21 | this.normals.push( new Float32Array( normalsBuffer, i * 3 * 4, 3 ) );
22 | this.uvs.push( new Float32Array( uvsBuffer, i * 2 * 4, 2 ) );
23 |
24 | }
25 |
26 | this.attributes[ 'index' ] = { array: this.indices, itemSize: 1 };
27 | this.attributes[ 'position' ] = { array: new Float32Array( verticesBuffer, 0, size * 3 ), itemSize: 3 };
28 | this.attributes[ 'normal' ] = { array: new Float32Array( normalsBuffer, 0, size * 3 ), itemSize: 3 };
29 | this.attributes[ 'uv' ] = { array: new Float32Array( uvsBuffer, 0, size * 2 ), itemSize: 2 };
30 |
31 | };
32 |
33 | THREE.Geometry3.prototype = Object.create( THREE.BufferGeometry.prototype );
34 | THREE.Geometry3.prototype.constructor = THREE.Geometry3;
--------------------------------------------------------------------------------
/js/thirdparty/three/wip/benchmark/IndexedGeometry5.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author mrdoob / http://mrdoob.com/
3 | */
4 |
5 | THREE.IndexedGeometry5 = function ( indices, size ) {
6 |
7 | THREE.BufferGeometry.call( this );
8 |
9 | var verticesBuffer = new Float32Array( size * 3 );
10 | var normalsBuffer = new Float32Array( size * 3 );
11 | var uvsBuffer = new Float32Array( size * 2 );
12 |
13 | this.indices = new Uint16Array( indices );
14 | this.vertices = [];
15 | this.normals = [];
16 | this.uvs = [];
17 |
18 | for ( var i = 0; i < size; i ++ ) {
19 |
20 | this.vertices.push( new THREE.TypedVector3( verticesBuffer, i * 3 ) );
21 | this.normals.push( new THREE.TypedVector3( normalsBuffer, i * 3 ) );
22 | this.uvs.push( new THREE.TypedVector2( uvsBuffer, i * 2 ) );
23 |
24 | }
25 |
26 | this.attributes[ 'index' ] = { array: this.indices, itemSize: 1 };
27 | this.attributes[ 'position' ] = { array: verticesBuffer, itemSize: 3 };
28 | this.attributes[ 'normal' ] = { array: normalsBuffer, itemSize: 3 };
29 | this.attributes[ 'uv' ] = { array: uvsBuffer, itemSize: 2 };
30 |
31 | };
32 |
33 | THREE.IndexedGeometry5.prototype = Object.create( THREE.BufferGeometry.prototype );
34 | THREE.IndexedGeometry5.prototype.constructor = THREE.IndexedGeometry5;
35 |
36 | THREE.TypedVector2 = function ( array, offset ) {
37 |
38 | this.array = array;
39 | this.offset = offset;
40 |
41 | };
42 |
43 | THREE.TypedVector2.prototype = Object.create( THREE.Vector2.prototype );
44 | THREE.TypedVector2.prototype.constructor = THREE.TypedVector2;
45 |
46 | Object.defineProperties( THREE.TypedVector2.prototype, {
47 | 'x': {
48 | get: function () { return this.array[ this.offset ]; },
49 | set: function ( v ) { this.array[ this.offset ] = v; }
50 | },
51 | 'y': {
52 | get: function () { return this.array[ this.offset + 1 ]; },
53 | set: function ( v ) { this.array[ this.offset + 1 ] = v; }
54 | }
55 | } );
56 |
57 | THREE.TypedVector3 = function ( array, offset ) {
58 |
59 | this.array = array;
60 | this.offset = offset;
61 |
62 | };
63 |
64 | THREE.TypedVector3.prototype = Object.create( THREE.Vector3.prototype );
65 | THREE.TypedVector3.prototype.constructor = THREE.TypedVector3;
66 |
67 | Object.defineProperties( THREE.TypedVector3.prototype, {
68 | 'x': {
69 | get: function () { return this.array[ this.offset ]; },
70 | set: function ( v ) { this.array[ this.offset ] = v; }
71 | },
72 | 'y': {
73 | get: function () { return this.array[ this.offset + 1 ]; },
74 | set: function ( v ) { this.array[ this.offset + 1 ] = v; }
75 | },
76 | 'z': {
77 | get: function () { return this.array[ this.offset + 2 ]; },
78 | set: function ( v ) { this.array[ this.offset + 2 ] = v; }
79 | }
80 | } );
--------------------------------------------------------------------------------
/js/thirdparty/three/wip/benchmark/IndexedPlaneGeometry5.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author mrdoob / http://mrdoob.com/
3 | * based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Plane.as
4 | */
5 |
6 | THREE.IndexedPlaneGeometry5 = function ( width, height, widthSegments, heightSegments ) {
7 |
8 | this.width = width;
9 | this.height = height;
10 |
11 | this.widthSegments = widthSegments || 1;
12 | this.heightSegments = heightSegments || 1;
13 |
14 | var width_half = width / 2;
15 | var height_half = height / 2;
16 |
17 | var gridX = this.widthSegments;
18 | var gridY = this.heightSegments;
19 |
20 | var gridX1 = gridX + 1;
21 | var gridY1 = gridY + 1;
22 |
23 | var segment_width = this.width / gridX;
24 | var segment_height = this.height / gridY;
25 |
26 | var indices = gridX * gridY * 6;
27 | var vertices = gridX1 * gridY1;
28 |
29 | THREE.IndexedGeometry5.call( this, indices, vertices );
30 |
31 | var offset = 0;
32 |
33 | for ( var iy = 0; iy < gridY1; iy ++ ) {
34 |
35 | var y = iy * segment_height - height_half;
36 |
37 | for ( var ix = 0; ix < gridX1; ix ++ ) {
38 |
39 | var x = ix * segment_width - width_half;
40 |
41 | this.vertices[ offset ].x = x;
42 | this.vertices[ offset ].y = - y;
43 |
44 | this.normals[ offset ].z = 1;
45 |
46 | this.uvs[ offset ].x = ix / gridX;
47 | this.uvs[ offset ].y = iy / gridY;
48 |
49 | offset ++;
50 |
51 | }
52 |
53 | }
54 |
55 | var offset = 0;
56 |
57 | for ( var iy = 0; iy < gridY; iy ++ ) {
58 |
59 | for ( var ix = 0; ix < gridX; ix ++ ) {
60 |
61 | var a = ix + gridX1 * iy;
62 | var b = ix + gridX1 * ( iy + 1 );
63 | var c = ( ix + 1 ) + gridX1 * ( iy + 1 );
64 | var d = ( ix + 1 ) + gridX1 * iy;
65 |
66 | this.indices[ offset ] = a;
67 | this.indices[ offset + 1 ] = b;
68 | this.indices[ offset + 2 ] = d;
69 |
70 | this.indices[ offset + 3 ] = b;
71 | this.indices[ offset + 4 ] = c;
72 | this.indices[ offset + 5 ] = d;
73 |
74 | offset += 6;
75 |
76 | }
77 |
78 | }
79 |
80 | };
81 |
82 | THREE.IndexedPlaneGeometry5.prototype = Object.create( THREE.IndexedGeometry5.prototype );
83 | THREE.IndexedPlaneGeometry5.prototype.constructor = THREE.IndexedPlaneGeometry5;
84 |
--------------------------------------------------------------------------------
/js/thirdparty/three/wip/benchmark/PlaneGeometry.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author mrdoob / http://mrdoob.com/
3 | * based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Plane.as
4 | */
5 |
6 | THREE.PlaneGeometry = function ( width, height, widthSegments, heightSegments ) {
7 |
8 | THREE.Geometry.call( this );
9 |
10 | this.width = width;
11 | this.height = height;
12 |
13 | this.widthSegments = widthSegments || 1;
14 | this.heightSegments = heightSegments || 1;
15 |
16 | var ix, iz;
17 | var width_half = width / 2;
18 | var height_half = height / 2;
19 |
20 | var gridX = this.widthSegments;
21 | var gridZ = this.heightSegments;
22 |
23 | var gridX1 = gridX + 1;
24 | var gridZ1 = gridZ + 1;
25 |
26 | var segment_width = this.width / gridX;
27 | var segment_height = this.height / gridZ;
28 |
29 | var normal = new THREE.Vector3( 0, 0, 1 );
30 |
31 | for ( iz = 0; iz < gridZ1; iz ++ ) {
32 |
33 | for ( ix = 0; ix < gridX1; ix ++ ) {
34 |
35 | var x = ix * segment_width - width_half;
36 | var y = iz * segment_height - height_half;
37 |
38 | this.vertices.push( new THREE.Vector3( x, - y, 0 ) );
39 |
40 | }
41 |
42 | }
43 |
44 | for ( iz = 0; iz < gridZ; iz ++ ) {
45 |
46 | for ( ix = 0; ix < gridX; ix ++ ) {
47 |
48 | var a = ix + gridX1 * iz;
49 | var b = ix + gridX1 * ( iz + 1 );
50 | var c = ( ix + 1 ) + gridX1 * ( iz + 1 );
51 | var d = ( ix + 1 ) + gridX1 * iz;
52 |
53 | var uva = new THREE.Vector2( ix / gridX, 1 - iz / gridZ );
54 | var uvb = new THREE.Vector2( ix / gridX, 1 - ( iz + 1 ) / gridZ );
55 | var uvc = new THREE.Vector2( ( ix + 1 ) / gridX, 1 - ( iz + 1 ) / gridZ );
56 | var uvd = new THREE.Vector2( ( ix + 1 ) / gridX, 1 - iz / gridZ );
57 |
58 | var face = new THREE.Face3( a, b, d );
59 | face.normal.copy( normal );
60 | face.vertexNormals.push( normal.clone(), normal.clone(), normal.clone() );
61 |
62 | this.faces.push( face );
63 | this.faceVertexUvs[ 0 ].push( [ uva, uvb, uvd ] );
64 |
65 | face = new THREE.Face3( b, c, d );
66 | face.normal.copy( normal );
67 | face.vertexNormals.push( normal.clone(), normal.clone(), normal.clone() );
68 |
69 | this.faces.push( face );
70 | this.faceVertexUvs[ 0 ].push( [ uvb.clone(), uvc, uvd.clone() ] );
71 |
72 | }
73 |
74 | }
75 |
76 | };
77 |
78 | THREE.PlaneGeometry.prototype = Object.create( THREE.Geometry.prototype );
79 | THREE.PlaneGeometry.prototype.constructor = THREE.PlaneGeometry;
80 |
--------------------------------------------------------------------------------
/js/thirdparty/three/wip/benchmark/PlaneGeometry2.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author mrdoob / http://mrdoob.com/
3 | * based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Plane.as
4 | */
5 |
6 | THREE.PlaneGeometry2 = function ( width, height, widthSegments, heightSegments ) {
7 |
8 | THREE.Geometry2.call( this, ( widthSegments * heightSegments ) * 2 * 3 );
9 |
10 | var vertices = this.vertices.array;
11 | var normals = this.normals.array;
12 | var uvs = this.uvs.array;
13 |
14 | this.width = width;
15 | this.height = height;
16 |
17 | this.widthSegments = widthSegments || 1;
18 | this.heightSegments = heightSegments || 1;
19 |
20 | var widthHalf = width / 2;
21 | var heightHalf = height / 2;
22 |
23 | var gridX = this.widthSegments;
24 | var gridY = this.heightSegments;
25 |
26 | var segmentWidth = this.width / gridX;
27 | var segmentHeight = this.height / gridY;
28 |
29 | var offset = 0;
30 |
31 | for ( var iy = 0; iy < gridY; iy ++ ) {
32 |
33 | var y1 = iy * segmentHeight - heightHalf;
34 | var y2 = ( iy + 1 ) * segmentHeight - heightHalf;
35 |
36 | for ( var ix = 0; ix < gridX; ix ++ ) {
37 |
38 | var x1 = ix * segmentWidth - widthHalf;
39 | var x2 = ( ix + 1 ) * segmentWidth - widthHalf;
40 |
41 | vertices[ offset + 0 ] = x1;
42 | vertices[ offset + 1 ] = y1;
43 |
44 | vertices[ offset + 3 ] = x2;
45 | vertices[ offset + 4 ] = y1;
46 |
47 | vertices[ offset + 6 ] = x1;
48 | vertices[ offset + 7 ] = y2;
49 |
50 | normals[ offset + 2 ] = 1;
51 | normals[ offset + 5 ] = 1;
52 | normals[ offset + 8 ] = 1;
53 |
54 | vertices[ offset + 9 ] = x2;
55 | vertices[ offset + 10 ] = y1;
56 |
57 | vertices[ offset + 12 ] = x2;
58 | vertices[ offset + 13 ] = y2;
59 |
60 | vertices[ offset + 15 ] = x1;
61 | vertices[ offset + 16 ] = y2;
62 |
63 | normals[ offset + 11 ] = 1;
64 | normals[ offset + 13 ] = 1;
65 | normals[ offset + 17 ] = 1;
66 |
67 | offset += 18;
68 |
69 | }
70 |
71 | }
72 |
73 | };
74 |
75 | THREE.PlaneGeometry2.prototype = Object.create( THREE.Geometry2.prototype );
76 | THREE.PlaneGeometry2.prototype.constructor = THREE.PlaneGeometry2;
77 |
--------------------------------------------------------------------------------
/js/thirdparty/three/wip/benchmark/PlaneGeometry2b.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author mrdoob / http://mrdoob.com/
3 | * based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Plane.as
4 | */
5 |
6 | THREE.PlaneGeometry2b = function ( width, height, widthSegments, heightSegments ) {
7 |
8 | THREE.Geometry2.call( this, ( widthSegments * heightSegments ) * 2 * 3 );
9 |
10 | var vertices = this.vertices;
11 | var normals = this.normals;
12 | var uvs = this.uvs;
13 |
14 | this.width = width;
15 | this.height = height;
16 |
17 | this.widthSegments = widthSegments || 1;
18 | this.heightSegments = heightSegments || 1;
19 |
20 | var widthHalf = width / 2;
21 | var heightHalf = height / 2;
22 |
23 | var gridX = this.widthSegments;
24 | var gridY = this.heightSegments;
25 |
26 | var segmentWidth = this.width / gridX;
27 | var segmentHeight = this.height / gridY;
28 |
29 | var index = 0;
30 |
31 | for ( var iy = 0; iy < gridY; iy ++ ) {
32 |
33 | var y1 = iy * segmentHeight - heightHalf;
34 | var y2 = ( iy + 1 ) * segmentHeight - heightHalf;
35 |
36 | for ( var ix = 0; ix < gridX; ix ++ ) {
37 |
38 | var x1 = ix * segmentWidth - widthHalf;
39 | var x2 = ( ix + 1 ) * segmentWidth - widthHalf;
40 |
41 | this.vertices.setXY( index + 0, x1, y1 );
42 | this.vertices.setXY( index + 1, x2, y1 );
43 | this.vertices.setXY( index + 2, x1, y2 );
44 |
45 | this.vertices.setXY( index + 3, x2, y1 );
46 | this.vertices.setXY( index + 4, x2, y2 );
47 | this.vertices.setXY( index + 5, x1, y2 );
48 |
49 | this.normals.setZ( index + 0, 1 );
50 | this.normals.setZ( index + 1, 1 );
51 | this.normals.setZ( index + 2, 1 );
52 |
53 | this.normals.setZ( index + 3, 1 );
54 | this.normals.setZ( index + 4, 1 );
55 | this.normals.setZ( index + 5, 1 );
56 |
57 | index += 6;
58 |
59 | }
60 |
61 | }
62 |
63 | };
64 |
65 | THREE.PlaneGeometry2b.prototype = Object.create( THREE.Geometry2.prototype );
66 | THREE.PlaneGeometry2b.prototype.constructor = THREE.PlaneGeometry2b;
67 |
--------------------------------------------------------------------------------
/js/thirdparty/three/wip/benchmark/PlaneGeometry3.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author mrdoob / http://mrdoob.com/
3 | * based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Plane.as
4 | */
5 |
6 | THREE.PlaneGeometry3 = function ( width, height, widthSegments, heightSegments ) {
7 |
8 | THREE.Geometry3.call( this, ( widthSegments * heightSegments ) * 2 * 3 );
9 |
10 | var vertices = this.vertices;
11 | var normals = this.normals;
12 | var uvs = this.uvs;
13 |
14 | this.width = width;
15 | this.height = height;
16 |
17 | this.widthSegments = widthSegments || 1;
18 | this.heightSegments = heightSegments || 1;
19 |
20 | var widthHalf = width / 2;
21 | var heightHalf = height / 2;
22 |
23 | var gridX = this.widthSegments;
24 | var gridY = this.heightSegments;
25 |
26 | var segmentWidth = this.width / gridX;
27 | var segmentHeight = this.height / gridY;
28 |
29 | var offset = 0;
30 |
31 | for ( var iy = 0; iy < gridY; iy ++ ) {
32 |
33 | var y1 = iy * segmentHeight - heightHalf;
34 | var y2 = ( iy + 1 ) * segmentHeight - heightHalf;
35 |
36 | for ( var ix = 0; ix < gridX; ix ++ ) {
37 |
38 | var x1 = ix * segmentWidth - widthHalf;
39 | var x2 = ( ix + 1 ) * segmentWidth - widthHalf;
40 |
41 | vertices[ offset + 0 ][ 0 ] = x1;
42 | vertices[ offset + 0 ][ 1 ] = y1;
43 |
44 | vertices[ offset + 1 ][ 0 ] = x2;
45 | vertices[ offset + 1 ][ 1 ] = y1;
46 |
47 | vertices[ offset + 2 ][ 0 ] = x1;
48 | vertices[ offset + 2 ][ 1 ] = y2;
49 |
50 | normals[ offset + 0 ][ 2 ] = 1;
51 | normals[ offset + 1 ][ 2 ] = 1;
52 | normals[ offset + 2 ][ 2 ] = 1;
53 |
54 | vertices[ offset + 3 ][ 0 ] = x2;
55 | vertices[ offset + 3 ][ 1 ] = y1;
56 |
57 | vertices[ offset + 4 ][ 0 ] = x2;
58 | vertices[ offset + 4 ][ 1 ] = y2;
59 |
60 | vertices[ offset + 5 ][ 0 ] = x1;
61 | vertices[ offset + 5 ][ 1 ] = y2;
62 |
63 | normals[ offset + 3 ][ 2 ] = 1;
64 | normals[ offset + 4 ][ 2 ] = 1;
65 | normals[ offset + 5 ][ 2 ] = 1;
66 |
67 | offset += 6;
68 |
69 | }
70 |
71 | }
72 |
73 | };
74 |
75 | THREE.PlaneGeometry3.prototype = Object.create( THREE.Geometry3.prototype );
76 | THREE.PlaneGeometry3.prototype.constructor = THREE.PlaneGeometry3;
77 |
--------------------------------------------------------------------------------
/js/thirdparty/three/wip/benchmark/PlaneGeometry5.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author mrdoob / http://mrdoob.com/
3 | * based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Plane.as
4 | */
5 |
6 | THREE.PlaneGeometry5 = function ( width, height, widthSegments, heightSegments ) {
7 |
8 | THREE.Geometry5.call( this, ( widthSegments * heightSegments ) * 2 * 3 );
9 |
10 | var vertices = this.vertices;
11 | var normals = this.normals;
12 | var uvs = this.uvs;
13 |
14 | this.width = width;
15 | this.height = height;
16 |
17 | this.widthSegments = widthSegments || 1;
18 | this.heightSegments = heightSegments || 1;
19 |
20 | var widthHalf = width / 2;
21 | var heightHalf = height / 2;
22 |
23 | var gridX = this.widthSegments;
24 | var gridY = this.heightSegments;
25 |
26 | var segmentWidth = this.width / gridX;
27 | var segmentHeight = this.height / gridY;
28 |
29 | var offset = 0;
30 |
31 | for ( var iy = 0; iy < gridY; iy ++ ) {
32 |
33 | var y1 = iy * segmentHeight - heightHalf;
34 | var y2 = ( iy + 1 ) * segmentHeight - heightHalf;
35 |
36 | for ( var ix = 0; ix < gridX; ix ++ ) {
37 |
38 | var x1 = ix * segmentWidth - widthHalf;
39 | var x2 = ( ix + 1 ) * segmentWidth - widthHalf;
40 |
41 | vertices[ offset + 0 ].set( x1, y1, 0 );
42 | vertices[ offset + 1 ].set( x2, y1, 0 );
43 | vertices[ offset + 2 ].set( x1, y2, 0 );
44 |
45 | normals[ offset + 0 ].z = 1;
46 | normals[ offset + 1 ].z = 1;
47 | normals[ offset + 2 ].z = 1;
48 |
49 | vertices[ offset + 3 ].set( x2, y1, 0 );
50 | vertices[ offset + 4 ].set( x2, y2, 0 );
51 | vertices[ offset + 5 ].set( x1, y2, 0 );
52 |
53 | normals[ offset + 3 ].z = 1;
54 | normals[ offset + 4 ].z = 1;
55 | normals[ offset + 5 ].z = 1;
56 |
57 | offset += 6;
58 |
59 | }
60 |
61 | }
62 |
63 | };
64 |
65 | THREE.PlaneGeometry5.prototype = Object.create( THREE.Geometry5.prototype );
66 | THREE.PlaneGeometry5.prototype.constructor = THREE.PlaneGeometry5;
67 |
--------------------------------------------------------------------------------
/js/thirdparty/three/wip/benchmark/PlaneGeometry6.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author mrdoob / http://mrdoob.com/
3 | */
4 |
5 | THREE.PlaneGeometry6 = function ( width, height, widthSegments, heightSegments ) {
6 |
7 | THREE.PlaneBufferGeometry.call( this, width, height, widthSegments, heightSegments );
8 |
9 | var indices = this.attributes.index.array;
10 | var vertices = this.attributes.position.array;
11 | var normals = this.attributes.normal.array;
12 | var uvs = this.attributes.uv.array;
13 |
14 | this.indices = indices;
15 | this.vertices = [];
16 | this.normals = [];
17 | this.uvs = [];
18 |
19 | for ( var i = 0, l = vertices.length / 3; i < l; i ++ ) {
20 |
21 | this.vertices.push( new THREE.TypedVector3( vertices, i * 3 ) );
22 | this.normals.push( new THREE.TypedVector3( normals, i * 3 ) );
23 | this.uvs.push( new THREE.TypedVector2( uvs, i * 2 ) );
24 |
25 | }
26 |
27 | };
28 |
29 | THREE.PlaneGeometry6.prototype = Object.create( THREE.PlaneBufferGeometry.prototype );
30 | THREE.PlaneGeometry6.prototype.constructor = THREE.PlaneGeometry6;
--------------------------------------------------------------------------------
/js/thirdparty/three/wip/benchmark/PlaneGeometry99.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author mrdoob / http://mrdoob.com/
3 | */
4 |
5 | THREE.PlaneGeometry99 = function ( width, height, widthSegments, heightSegments ) {
6 |
7 | THREE.Geometry99.call( this );
8 |
9 | this.parameters = {
10 | width: width,
11 | height: height,
12 | widthSegments: widthSegments,
13 | heightSegments: heightSegments
14 | };
15 |
16 | var width_half = width / 2;
17 | var height_half = height / 2;
18 |
19 | var gridX = widthSegments || 1;
20 | var gridY = heightSegments || 1;
21 |
22 | var gridX1 = gridX + 1;
23 | var gridY1 = gridY + 1;
24 |
25 | var segment_width = width / gridX;
26 | var segment_height = height / gridY;
27 |
28 | var vertices = new Float32Array( gridX1 * gridY1 * 3 );
29 | var normals = new Float32Array( gridX1 * gridY1 * 3 );
30 | var uvs = new Float32Array( gridX1 * gridY1 * 2 );
31 |
32 | var offset = 0;
33 | var offset2 = 0;
34 |
35 | for ( var iy = 0; iy < gridY1; iy ++ ) {
36 |
37 | var y = iy * segment_height - height_half;
38 |
39 | for ( var ix = 0; ix < gridX1; ix ++ ) {
40 |
41 | var x = ix * segment_width - width_half;
42 |
43 | vertices[ offset ] = x;
44 | vertices[ offset + 1 ] = - y;
45 |
46 | normals[ offset + 2 ] = 1;
47 |
48 | uvs[ offset2 ] = ix / gridX;
49 | uvs[ offset2 + 1 ] = 1 - ( iy / gridY );
50 |
51 | offset += 3;
52 | offset2 += 2;
53 |
54 | }
55 |
56 | }
57 |
58 | offset = 0;
59 |
60 | var indices = new Uint16Array( gridX * gridY * 6 );
61 |
62 | for ( var iy = 0; iy < gridY; iy ++ ) {
63 |
64 | for ( var ix = 0; ix < gridX; ix ++ ) {
65 |
66 | var a = ix + gridX1 * iy;
67 | var b = ix + gridX1 * ( iy + 1 );
68 | var c = ( ix + 1 ) + gridX1 * ( iy + 1 );
69 | var d = ( ix + 1 ) + gridX1 * iy;
70 |
71 | indices[ offset ] = a;
72 | indices[ offset + 1 ] = b;
73 | indices[ offset + 2 ] = d;
74 |
75 | indices[ offset + 3 ] = b;
76 | indices[ offset + 4 ] = c;
77 | indices[ offset + 5 ] = d;
78 |
79 | offset += 6;
80 |
81 | }
82 |
83 | }
84 |
85 | this.attributes[ 'index' ] = { array: indices, itemSize: 1 };
86 | this.attributes[ 'position' ] = { array: vertices, itemSize: 3 };
87 | this.attributes[ 'normal' ] = { array: normals, itemSize: 3 };
88 | this.attributes[ 'uv' ] = { array: uvs, itemSize: 2 };
89 |
90 | };
91 |
92 | THREE.PlaneGeometry99.prototype = Object.create( THREE.Geometry99.prototype );
93 | THREE.PlaneGeometry99.prototype.constructor = THREE.PlaneGeometry99;
--------------------------------------------------------------------------------
/js/thirdparty/three/wip/benchmark/TypedGeometry.js:
--------------------------------------------------------------------------------
1 | THREE.TypedVector2 = function ( array, offset ) {
2 |
3 | this.array = array;
4 | this.offset = offset * 2;
5 |
6 | };
7 |
8 | THREE.TypedVector2.prototype = {
9 |
10 | constructor: THREE.TypedVector2,
11 |
12 | get x () {
13 |
14 | return this.array[ this.offset ];
15 |
16 | },
17 |
18 | set x ( value ) {
19 |
20 | this.array[ this.offset ] = value;
21 |
22 | },
23 |
24 | get y () {
25 |
26 | return this.array[ this.offset + 1 ];
27 |
28 | },
29 |
30 | set y ( value ) {
31 |
32 | this.array[ this.offset + 1 ] = value;
33 |
34 | },
35 |
36 | set: function ( x, y ) {
37 |
38 | this.array[ this.offset ] = x;
39 | this.array[ this.offset + 1 ] = y;
40 | return this;
41 |
42 | }
43 |
44 | };
45 |
46 | THREE.TypedVector3 = function ( array, offset ) {
47 |
48 | this.array = array;
49 | this.offset = offset * 3;
50 |
51 | };
52 |
53 | THREE.TypedVector3.prototype = {
54 |
55 | constructor: THREE.TypedVector3,
56 |
57 | get x () {
58 |
59 | return this.array[ this.offset ];
60 |
61 | },
62 |
63 | set x ( value ) {
64 |
65 | this.array[ this.offset ] = value;
66 |
67 | },
68 |
69 | get y () {
70 |
71 | return this.array[ this.offset + 1 ];
72 |
73 | },
74 |
75 | set y ( value ) {
76 |
77 | this.array[ this.offset + 1 ] = value;
78 |
79 | },
80 |
81 | get z () {
82 |
83 | return this.array[ this.offset + 2 ];
84 |
85 | },
86 |
87 | set z ( value ) {
88 |
89 | this.array[ this.offset + 2 ] = value;
90 |
91 | },
92 |
93 | set: function ( x, y, z ) {
94 |
95 | this.array[ this.offset ] = x;
96 | this.array[ this.offset + 1 ] = y;
97 | this.array[ this.offset + 2 ] = z;
98 | return this;
99 |
100 | },
101 |
102 | toString: function () {
103 |
104 | return '[' + this.array[ this.offset ] + ',' + this.array[ this.offset + 1 ] + ',' + this.array[ this.offset + 2 ] + ']';
105 |
106 | }
107 |
108 | };
109 |
110 | THREE.TypedFace = function ( positions, normals, uvs, offset ) {
111 |
112 | this.positions = positions;
113 | this.normals = normals;
114 | this.uvs = uvs;
115 | this.offset = offset * 3;
116 |
117 | };
118 |
119 | THREE.TypedFace.prototype = {
120 |
121 | constructor: THREE.TypedFace,
122 |
123 | vertex: function ( index ) {
124 |
125 | return new THREE.TypedVector3( this.positions, this.offset + index );
126 |
127 | },
128 |
129 | normal: function ( index ) {
130 |
131 | return new THREE.TypedVector3( this.normals, this.offset + index );
132 |
133 | },
134 |
135 | uv: function ( index ) {
136 |
137 | return new THREE.TypedVector2( this.uvs, this.offset + index );
138 |
139 | }
140 |
141 | }
142 |
143 |
144 | THREE.TypedGeometry = function ( size ) {
145 |
146 | this.id = THREE.GeometryIdCount ++;
147 | this.uuid = THREE.Math.generateUUID();
148 |
149 | this.name = '';
150 |
151 | this.positions = new Float32Array( size * 3 * 3 );
152 | this.normals = new Float32Array( size * 3 * 3 );
153 | this.uvs = new Float32Array( size * 3 * 2 );
154 |
155 | this.boundingBox = null;
156 | this.boundingSphere = null;
157 |
158 | };
159 |
160 | THREE.TypedGeometry.prototype = {
161 |
162 | constructor: THREE.TypedGeometry,
163 |
164 | face: function ( index ) {
165 |
166 | return new THREE.TypedFace( this.positions, this.normals, this.uvs, index );
167 |
168 | },
169 |
170 | dispose: function () {
171 |
172 | this.dispatchEvent( { type: 'dispose' } );
173 |
174 | }
175 |
176 | };
177 |
178 | THREE.EventDispatcher.prototype.apply( THREE.TypedGeometry.prototype );
179 |
--------------------------------------------------------------------------------
/js/thirdparty/three/wip/proxies/MultiColor.js:
--------------------------------------------------------------------------------
1 | // Allows updating of multiple THREE.Color objects with the same value
2 | // Used for face.color -> face.vertexColor[] compatibility layer for non-indexed geometry
3 |
4 | THREE.MultiColor = function(links) {
5 |
6 | this.links = links;
7 |
8 | }
9 |
10 | THREE.MultiColor.prototype = Object.create( THREE.Color.prototype );
11 | THREE.MultiColor.prototype.constructor = THREE.MultiColor;
12 |
13 | THREE.MultiColor.prototype.setAll = function(axis, value) {
14 |
15 | for (var i = 0, l = this.links.length; i < l; i ++) {
16 |
17 | this.links[i][axis] = value;
18 |
19 | }
20 |
21 | }
22 |
23 | // Getters return value from the first linked color
24 | // Setters set the same value for all linked colors
25 | Object.defineProperties( THREE.MultiColor.prototype, {
26 | 'r': {
27 | get: function () { return (this.links[0] ? this.links[0].r : 0); },
28 | set: function ( v ) { this.setAll('r', v); }
29 | },
30 | 'g': {
31 | get: function () { return (this.links[0] ? this.links[0].g : 0); },
32 | set: function ( v ) { this.setAll('g', v); }
33 | },
34 | 'b': {
35 | get: function () { return (this.links[0] ? this.links[0].b : 0); },
36 | set: function ( v ) { this.setAll('b', v); }
37 | }
38 | } );
39 |
40 |
--------------------------------------------------------------------------------
/js/thirdparty/three/wip/proxies/MultiVector3.js:
--------------------------------------------------------------------------------
1 | // Allows updating of multiple THREE.Vector3 objects with the same value
2 | // Used for face.normal -> face.vertexNormal[] compatibility layer for FlatShading
3 |
4 | THREE.MultiVector3 = function(links) {
5 |
6 | this.links = links;
7 |
8 | }
9 |
10 | THREE.MultiVector3.prototype = Object.create( THREE.Vector3.prototype );
11 | THREE.MultiVector3.prototype.constructor = THREE.MultiVector3;
12 |
13 | THREE.MultiVector3.prototype.setAll = function(axis, value) {
14 |
15 | for (var i = 0, l = this.links.length; i < l; i ++) {
16 |
17 | this.links[i][axis] = value;
18 |
19 | }
20 |
21 | }
22 |
23 | // Getters return value from the first linked vector
24 | // Setters set the same value for all linked vectors
25 | Object.defineProperties( THREE.MultiVector3.prototype, {
26 | 'x': {
27 | get: function () { return (this.links[0] ? this.links[0].x : 0); },
28 | set: function ( v ) { this.setAll('x', v); }
29 | },
30 | 'y': {
31 | get: function () { return (this.links[0] ? this.links[0].y : 0); },
32 | set: function ( v ) { this.setAll('y', v); }
33 | },
34 | 'z': {
35 | get: function () { return (this.links[0] ? this.links[0].z : 0); },
36 | set: function ( v ) { this.setAll('z', v); }
37 | }
38 | } );
39 |
40 |
41 |
--------------------------------------------------------------------------------
/js/thirdparty/three/wip/proxies/ProxyColor.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author mrdoob / http://mrdoob.com/
3 | * @author jbaicoianu / http://baicoianu.com/
4 | */
5 |
6 | THREE.ProxyColor = function ( array, offset ) {
7 |
8 | this.array = array;
9 | this.offset = offset;
10 |
11 | }
12 |
13 | THREE.ProxyColor.prototype = Object.create( THREE.Color.prototype );
14 | THREE.ProxyColor.prototype.constructor = THREE.ProxyColor;
15 |
16 | Object.defineProperties( THREE.ProxyColor.prototype, {
17 | 'r': {
18 | enumerable: true,
19 | get: function () { return this.array[ this.offset ]; },
20 | set: function ( v ) { this.array[ this.offset ] = v; }
21 | },
22 | 'g': {
23 | enumerable: true,
24 | get: function () { return this.array[ this.offset + 1 ]; },
25 | set: function ( v ) { this.array[ this.offset + 1 ] = v; }
26 | },
27 | 'b': {
28 | enumerable: true,
29 | get: function () { return this.array[ this.offset + 2 ]; },
30 | set: function ( v ) { this.array[ this.offset + 2 ] = v; }
31 | }
32 | } );
33 |
34 |
--------------------------------------------------------------------------------
/js/thirdparty/three/wip/proxies/ProxyFace3.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author jbaicoianu / http://baicoianu.com/
3 | */
4 |
5 | THREE.ProxyFace3 = function ( array, offset, vertexNormals, vertexColors, vertexTangents ) {
6 |
7 | this.array = array;
8 | this.offset = offset;
9 | this.vertexNormals = vertexNormals || [];
10 | this.vertexColors = vertexColors || [];
11 | this.vertexTangents = vertexTangents || [];
12 |
13 | this.normal = new THREE.MultiVector3( this.vertexNormals );
14 | this.color = new THREE.MultiColor( this.vertexColors );
15 |
16 | //THREE.Face3.call( this, array[offset], array[offset+1], array[offset+2] /*, normal, color, materialIndex */);
17 |
18 | }
19 |
20 | THREE.ProxyFace3.prototype = Object.create( THREE.Face3.prototype );
21 | THREE.ProxyFace3.prototype.constructor = THREE.ProxyFace3;
22 |
23 | Object.defineProperties( THREE.ProxyFace3.prototype, {
24 | 'a': {
25 | enumerable: true,
26 | get: function () { return this.array[ this.offset ]; },
27 | set: function ( v ) { this.array[ this.offset ] = v; }
28 | },
29 | 'b': {
30 | enumerable: true,
31 | get: function () { return this.array[ this.offset + 1 ]; },
32 | set: function ( v ) { this.array[ this.offset + 1 ] = v; }
33 | },
34 | 'c': {
35 | enumerable: true,
36 | get: function () { return this.array[ this.offset + 2 ]; },
37 | set: function ( v ) { this.array[ this.offset + 2 ] = v; }
38 | },
39 | } );
40 |
41 |
--------------------------------------------------------------------------------
/js/thirdparty/three/wip/proxies/ProxyVector2.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author mrdoob / http://mrdoob.com/
3 | * @author jbaicoianu / http://baicoianu.com/
4 | */
5 |
6 | THREE.ProxyVector2 = function ( array, offset ) {
7 |
8 | this.array = array;
9 | this.offset = offset;
10 |
11 | };
12 |
13 | THREE.ProxyVector2.prototype = Object.create( THREE.Vector2.prototype );
14 | THREE.ProxyVector2.prototype.constructor = THREE.ProxyVector2;
15 |
16 | Object.defineProperties( THREE.ProxyVector2.prototype, {
17 | 'x': {
18 | get: function () { return this.array[ this.offset ]; },
19 | set: function ( v ) { this.array[ this.offset ] = v; }
20 | },
21 | 'y': {
22 | get: function () { return this.array[ this.offset + 1 ]; },
23 | set: function ( v ) { this.array[ this.offset + 1 ] = v; }
24 | }
25 | } );
26 |
27 |
--------------------------------------------------------------------------------
/js/thirdparty/three/wip/proxies/ProxyVector3.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author mrdoob / http://mrdoob.com/
3 | * @author jbaicoianu / http://baicoianu.com/
4 | */
5 |
6 | THREE.ProxyVector3 = function ( array, offset ) {
7 |
8 | this.array = array;
9 | this.offset = offset;
10 |
11 | };
12 |
13 | THREE.ProxyVector3.prototype = Object.create( THREE.Vector3.prototype );
14 | THREE.ProxyVector3.prototype.constructor = THREE.ProxyVector3;
15 |
16 | Object.defineProperties( THREE.ProxyVector3.prototype, {
17 | 'x': {
18 | get: function () { return this.array[ this.offset ]; },
19 | set: function ( v ) { this.array[ this.offset ] = v; }
20 | },
21 | 'y': {
22 | get: function () { return this.array[ this.offset + 1 ]; },
23 | set: function ( v ) { this.array[ this.offset + 1 ] = v; }
24 | },
25 | 'z': {
26 | get: function () { return this.array[ this.offset + 2 ]; },
27 | set: function ( v ) { this.array[ this.offset + 2 ] = v; }
28 | }
29 | } );
30 |
31 |
--------------------------------------------------------------------------------
/js/thirdparty/three/wip/proxies/ProxyVector4.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author mrdoob / http://mrdoob.com/
3 | * @author jbaicoianu / http://baicoianu.com/
4 | */
5 |
6 | THREE.ProxyVector4 = function ( array, offset ) {
7 |
8 | this.array = array;
9 | this.offset = offset;
10 |
11 | };
12 |
13 | THREE.ProxyVector4.prototype = Object.create( THREE.Vector4.prototype );
14 | THREE.ProxyVector4.prototype.constructor = THREE.ProxyVector4;
15 |
16 | Object.defineProperties( THREE.ProxyVector4.prototype, {
17 | 'x': {
18 | get: function () { return this.array[ this.offset ]; },
19 | set: function ( v ) { this.array[ this.offset ] = v; }
20 | },
21 | 'y': {
22 | get: function () { return this.array[ this.offset + 1 ]; },
23 | set: function ( v ) { this.array[ this.offset + 1 ] = v; }
24 | },
25 | 'z': {
26 | get: function () { return this.array[ this.offset + 2 ]; },
27 | set: function ( v ) { this.array[ this.offset + 2 ] = v; }
28 | },
29 | 'w': {
30 | get: function () { return this.array[ this.offset + 3 ]; },
31 | set: function ( v ) { this.array[ this.offset + 3 ] = v; }
32 | }
33 | } );
34 |
35 |
--------------------------------------------------------------------------------
/scripts/build:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 |
3 | import os, imp
4 |
5 | abspath = os.path.abspath(__file__)
6 | dname = os.path.dirname(abspath)
7 | os.chdir(dname)
8 |
9 | print('******************\ncompile shaders into JS source ...')
10 | ShaderDir = '../shaders'
11 | src = "var Shaders = {\n\n"
12 | for f in os.listdir(ShaderDir):
13 |
14 | if f.find('.glsl') == -1: continue
15 | name = f.replace('.glsl', '')
16 | src += "'%s': `#version 300 es" % name
17 | path = os.path.join(ShaderDir, f)
18 | lines = open(path).read().strip().split('\n')
19 | code = []
20 | code.append('')
21 | code.extend(lines)
22 |
23 | for i, line in enumerate(code):
24 | src += line.lstrip('\n') + '\n'
25 | if i==len(code)-1:
26 | src += "`,\n\n"
27 |
28 | src += "}"
29 | open("../js/shaders.js", 'w').write(src)
30 |
31 | print('\n******************\nminify code into snelly.min.js ...')
32 | # Construct the command for Google Closure Compiler, to generate minified code
33 | jsDestPath = "../js/compiled/snelly.min.js"
34 | jsSources = [
35 | '../js/thirdparty/jquery-1.11.3.min.js',
36 | '../js/thirdparty/three/three.min.js',
37 | '../js/thirdparty/tiny-sdf.js',
38 | '../js/thirdparty/math-sdf.js',
39 | '../js/thirdparty/three/libs/stats.min.js',
40 | '../js/thirdparty/three/libs/dat.gui.min.js',
41 | '../js/thirdparty/three/controls/OrbitControls.js',
42 | '../js/gl.js',
43 | '../js/gui.js',
44 | '../js/shaders.js',
45 | '../js/color.js',
46 | '../js/materials.js',
47 | '../js/spectra.js',
48 | '../js/renderer.js',
49 | '../js/snelly.js'
50 | ]
51 |
52 | lib_files = ' '.join(jsSources)
53 | cmd = '''
54 | java -jar closure-compiler/compiler.jar --js %s -O WHITESPACE_ONLY --js_output_file %s
55 | ''' % (lib_files, jsDestPath)
56 |
57 | os.system(cmd)
58 |
59 |
60 | print('\n******************\nbuild documentation via jsdoc2md ...')
61 | jsSources = [
62 | '../js/snelly.js',
63 | '../js/sceneAPI.js',
64 | '../js/renderer.js',
65 | '../js/materials.js',
66 | '../js/gui.js',
67 | '../js/gl.js',
68 | '../js/gui.js'
69 | ]
70 | api_files = ' '.join(jsSources)
71 | cmd = '''
72 | jsdoc2md --template ../docs/API.hbs --files %s > ../docs/API.md''' % api_files
73 | os.system(cmd)
74 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/scripts/closure-compiler/compiler.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portsmouth/snelly/570ed2abbc4217b21aa56e7da72a020397626f53/scripts/closure-compiler/compiler.jar
--------------------------------------------------------------------------------
/shaders/ao-vertex-shader.glsl:
--------------------------------------------------------------------------------
1 | precision highp float;
2 |
3 | in vec3 Position;
4 | in vec2 TexCoord;
5 |
6 | out vec2 vTexCoord;
7 |
8 | void main()
9 | {
10 | gl_Position = vec4(Position, 1.0);
11 | vTexCoord = TexCoord;
12 | }
13 |
--------------------------------------------------------------------------------
/shaders/normals-vertex-shader.glsl:
--------------------------------------------------------------------------------
1 | precision highp float;
2 |
3 | in vec3 Position;
4 | in vec2 TexCoord;
5 |
6 | out vec2 vTexCoord;
7 |
8 | void main()
9 | {
10 | gl_Position = vec4(Position, 1.0);
11 | vTexCoord = TexCoord;
12 | }
13 |
--------------------------------------------------------------------------------
/shaders/pathtracer-vertex-shader.glsl:
--------------------------------------------------------------------------------
1 | precision highp float;
2 |
3 | in vec3 Position;
4 | in vec2 TexCoord;
5 |
6 | out vec2 vTexCoord;
7 |
8 | void main()
9 | {
10 | gl_Position = vec4(Position, 1.0);
11 | vTexCoord = TexCoord;
12 | }
13 |
--------------------------------------------------------------------------------
/shaders/pick-vertex-shader.glsl:
--------------------------------------------------------------------------------
1 | precision highp float;
2 |
3 | in vec3 Position;
4 | in vec2 TexCoord;
5 |
6 | out vec2 vTexCoord;
7 |
8 | void main()
9 | {
10 | gl_Position = vec4(Position, 1.0);
11 | vTexCoord = TexCoord;
12 | }
13 |
--------------------------------------------------------------------------------
/shaders/simplepathtracer-vertex-shader.glsl:
--------------------------------------------------------------------------------
1 | precision highp float;
2 |
3 | in vec3 Position;
4 | in vec2 TexCoord;
5 |
6 | out vec2 vTexCoord;
7 |
8 | void main()
9 | {
10 | gl_Position = vec4(Position, 1.0);
11 | vTexCoord = TexCoord;
12 | }
13 |
--------------------------------------------------------------------------------
/shaders/tonemapper-fragment-shader.glsl:
--------------------------------------------------------------------------------
1 | precision highp float;
2 |
3 | uniform sampler2D Radiance;
4 | in vec2 vTexCoord;
5 |
6 | uniform float exposure;
7 | uniform float invGamma;
8 | uniform float contrast;
9 | uniform float saturation;
10 | uniform float hueShift;
11 |
12 | out vec4 g_outputColor;
13 |
14 | float toneMap(float L)
15 | {
16 | return L / (1.0 + L);
17 | }
18 |
19 | vec3 rgb2hsv(vec3 c)
20 | {
21 | vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
22 | vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
23 | vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
24 | float d = q.x - min(q.w, q.y);
25 | float e = 1.0e-10;
26 | return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
27 | }
28 |
29 | vec3 hsv2rgb(vec3 c)
30 | {
31 | vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
32 | vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
33 | return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
34 | }
35 |
36 | void main()
37 | {
38 | vec3 L = texture(Radiance, vTexCoord).rgb;
39 | float X = L.x;
40 | float Y = L.y;
41 | float Z = L.z;
42 |
43 | // convert XYZ tristimulus to linear RGB color space
44 | vec3 RGB;
45 | RGB.r = 3.2406*X - 1.5372*Y - 0.4986*Z;
46 | RGB.g = -0.9689*X + 1.8758*Y + 0.0415*Z;
47 | RGB.b = 0.0557*X - 0.2040*Y + 1.0570*Z;
48 |
49 | // deal with out-of-gamut RGB.
50 | float delta = -min(0.0, min(min(RGB.r, RGB.g), RGB.b));
51 | RGB.r += delta;
52 | RGB.g += delta;
53 | RGB.b += delta;
54 |
55 | // apply gamma correction to convert linear RGB to sRGB
56 | RGB = pow(RGB, vec3(invGamma));
57 |
58 | // apply tonemapping
59 | RGB *= pow(2.0, exposure);
60 | float R = RGB.r;
61 | float G = RGB.g;
62 | float B = RGB.b;
63 | R = toneMap(R);
64 | G = toneMap(G);
65 | B = toneMap(B);
66 |
67 |
68 |
69 | // apply saturation
70 | float mean = (R + G + B)/3.0;
71 | float dR = R - mean;
72 | float dG = G - mean;
73 | float dB = B - mean;
74 | R = mean + sign(dR)*pow(abs(dR), 1.0/saturation);
75 | G = mean + sign(dG)*pow(abs(dG), 1.0/saturation);
76 | B = mean + sign(dB)*pow(abs(dB), 1.0/saturation);
77 |
78 | // apply contrast
79 | dR = R - 0.5;
80 | dG = G - 0.5;
81 | dB = B - 0.5;
82 | R = 0.5 + sign(dR)*pow(abs(dR), 1.0/contrast);
83 | G = 0.5 + sign(dG)*pow(abs(dG), 1.0/contrast);
84 | B = 0.5 + sign(dB)*pow(abs(dB), 1.0/contrast);
85 |
86 | vec3 C =vec3(R,G,B);
87 |
88 | // apply hue-shift
89 | if (hueShift > 0.0)
90 | {
91 | vec3 hsv = rgb2hsv(C);
92 | hsv.r = mod(hsv.r + hueShift, 1.0);
93 | C = hsv2rgb(hsv);
94 | }
95 |
96 | g_outputColor = vec4(C, 1.0);
97 | }
98 |
--------------------------------------------------------------------------------
/shaders/tonemapper-vertex-shader.glsl:
--------------------------------------------------------------------------------
1 | precision highp float;
2 |
3 | in vec3 Position;
4 | in vec2 TexCoord;
5 | out vec2 vTexCoord;
6 |
7 | void main()
8 | {
9 | gl_Position = vec4(Position, 1.0);
10 | vTexCoord = TexCoord;
11 | }
12 |
--------------------------------------------------------------------------------