├── .bowerrc ├── .gitignore ├── README.md ├── app ├── bower_components │ ├── jquery │ │ ├── .bower.json │ │ ├── MIT-LICENSE.txt │ │ ├── bower.json │ │ ├── dist │ │ │ ├── jquery.js │ │ │ ├── jquery.min.js │ │ │ └── jquery.min.map │ │ └── src │ │ │ ├── ajax.js │ │ │ ├── ajax │ │ │ ├── jsonp.js │ │ │ ├── load.js │ │ │ ├── parseJSON.js │ │ │ ├── parseXML.js │ │ │ ├── script.js │ │ │ ├── var │ │ │ │ ├── nonce.js │ │ │ │ └── rquery.js │ │ │ └── xhr.js │ │ │ ├── attributes.js │ │ │ ├── attributes │ │ │ ├── attr.js │ │ │ ├── classes.js │ │ │ ├── prop.js │ │ │ ├── support.js │ │ │ └── val.js │ │ │ ├── callbacks.js │ │ │ ├── core.js │ │ │ ├── core │ │ │ ├── access.js │ │ │ ├── init.js │ │ │ ├── parseHTML.js │ │ │ ├── ready.js │ │ │ └── var │ │ │ │ └── rsingleTag.js │ │ │ ├── css.js │ │ │ ├── css │ │ │ ├── addGetHookIf.js │ │ │ ├── curCSS.js │ │ │ ├── defaultDisplay.js │ │ │ ├── hiddenVisibleSelectors.js │ │ │ ├── support.js │ │ │ ├── swap.js │ │ │ └── var │ │ │ │ ├── cssExpand.js │ │ │ │ ├── getStyles.js │ │ │ │ ├── isHidden.js │ │ │ │ ├── rmargin.js │ │ │ │ └── rnumnonpx.js │ │ │ ├── data.js │ │ │ ├── data │ │ │ ├── Data.js │ │ │ ├── accepts.js │ │ │ └── var │ │ │ │ ├── data_priv.js │ │ │ │ └── data_user.js │ │ │ ├── deferred.js │ │ │ ├── deprecated.js │ │ │ ├── dimensions.js │ │ │ ├── effects.js │ │ │ ├── effects │ │ │ ├── Tween.js │ │ │ └── animatedSelector.js │ │ │ ├── event.js │ │ │ ├── event │ │ │ ├── ajax.js │ │ │ ├── alias.js │ │ │ └── support.js │ │ │ ├── exports │ │ │ ├── amd.js │ │ │ └── global.js │ │ │ ├── intro.js │ │ │ ├── jquery.js │ │ │ ├── manipulation.js │ │ │ ├── manipulation │ │ │ ├── _evalUrl.js │ │ │ ├── support.js │ │ │ └── var │ │ │ │ └── rcheckableType.js │ │ │ ├── offset.js │ │ │ ├── outro.js │ │ │ ├── queue.js │ │ │ ├── queue │ │ │ └── delay.js │ │ │ ├── selector-native.js │ │ │ ├── selector-sizzle.js │ │ │ ├── selector.js │ │ │ ├── serialize.js │ │ │ ├── sizzle │ │ │ └── dist │ │ │ │ ├── sizzle.js │ │ │ │ ├── sizzle.min.js │ │ │ │ └── sizzle.min.map │ │ │ ├── traversing.js │ │ │ ├── traversing │ │ │ ├── findFilter.js │ │ │ └── var │ │ │ │ └── rneedsContext.js │ │ │ ├── var │ │ │ ├── arr.js │ │ │ ├── class2type.js │ │ │ ├── concat.js │ │ │ ├── hasOwn.js │ │ │ ├── indexOf.js │ │ │ ├── pnum.js │ │ │ ├── push.js │ │ │ ├── rnotwhite.js │ │ │ ├── slice.js │ │ │ ├── strundefined.js │ │ │ ├── support.js │ │ │ └── toString.js │ │ │ └── wrap.js │ ├── requirejs │ │ ├── .bower.json │ │ ├── README.md │ │ ├── bower.json │ │ └── require.js │ └── threejs │ │ ├── .bower.json │ │ ├── bower.json │ │ ├── build │ │ ├── three.js │ │ └── three.min.js │ │ └── examples │ │ └── js │ │ ├── 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 │ │ └── 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 ├── css │ └── main.css ├── data │ └── scenedata.json ├── image │ ├── skybox │ │ ├── nx.jpg │ │ ├── ny.jpg │ │ ├── nz.jpg │ │ ├── px.jpg │ │ ├── py.jpg │ │ └── pz.jpg │ └── ui │ │ ├── press_space.png │ │ └── title.png ├── index.html └── js │ ├── app.js │ ├── config.js │ ├── lib │ ├── dat.gui.min.js │ ├── jquery-1.11.1.min.js │ └── tween.min.js │ └── three.js │ ├── Detector.js │ ├── OrbitControls.js │ ├── Stats.js │ ├── TrackballControls.js │ ├── postprocessing │ ├── BloomPass.js │ ├── BokehPass.js │ ├── DotScreenPass.js │ ├── EffectComposer.js │ ├── FilmPass.js │ ├── GlitchPass.js │ ├── MaskPass.js │ ├── RenderPass.js │ ├── SavePass.js │ ├── ShaderPass.js │ └── TexturePass.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 │ ├── DotMatrixShader.js │ ├── DotScreenShader.js │ ├── EdgeShader.js │ ├── EdgeShader2.js │ ├── FXAAShader.js │ ├── FilmShader.js │ ├── FocusShader.js │ ├── FresnelShader.js │ ├── HorizontalBlurShader.js │ ├── HorizontalTiltShiftShader.js │ ├── HueSaturationShader.js │ ├── KaleidoShader.js │ ├── LuminosityShader.js │ ├── MirrorShader.js │ ├── NormalMapShader.js │ ├── OceanShaders.js │ ├── RGBShiftShader.js │ ├── SSAOShader.js │ ├── SepiaShader.js │ ├── TechnicolorShader.js │ ├── TriangleBlurShader.js │ ├── UnpackDepthRGBAShader.js │ ├── VerticalBlurShader.js │ ├── VerticalTiltShiftShader.js │ └── VignetteShader.js │ ├── three.js │ └── three.min.js ├── bower.json ├── gulpfile.coffee ├── npm-debug.log ├── package.json ├── src ├── app.ts ├── framework │ ├── CEventDispatcher.ts │ ├── CMover.ts │ ├── CView.ts │ ├── ControlManager.ts │ ├── GameApp.ts │ └── IMover.ts ├── game │ ├── Bullet.ts │ ├── BulletEnemy.ts │ ├── Enemy.ts │ ├── EnemyBoss.ts │ ├── EnemyMid.ts │ ├── EnemySmall.ts │ ├── Explosion.ts │ ├── GameManager.ts │ ├── GameView.ts │ ├── HitArea.ts │ ├── Mover.ts │ ├── MyShip.ts │ ├── SceneData.ts │ ├── Score.ts │ ├── Shooter.ts │ ├── ShooterNway.ts │ ├── ShooterSingle.ts │ ├── Stage.ts │ └── TopView.ts ├── tsconfig.json ├── tsd.d.ts └── utils │ └── SimplexNoise.ts └── tsd.json /.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "app/bower_components" 3 | } 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .DS_Store 3 | *.iml 4 | node_modules 5 | DefinitelyTyped -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # three.js-game 2 | 3 | Shooting Game Development using three.js 4 | 5 | [http://verytired.github.io/three.js-game/app/index.html](http://verytired.github.io/three.js-game/app/index.html) 6 | 7 | ## build setting 8 | 9 | ``` 10 | npm install 11 | 12 | bower install 13 | 14 | tsd install 15 | 16 | ``` 17 | 18 | ## start 19 | 20 | ``` 21 | npm start 22 | ``` 23 | -------------------------------------------------------------------------------- /app/bower_components/jquery/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery", 3 | "version": "2.1.3", 4 | "main": "dist/jquery.js", 5 | "license": "MIT", 6 | "ignore": [ 7 | "**/.*", 8 | "build", 9 | "speed", 10 | "test", 11 | "*.md", 12 | "AUTHORS.txt", 13 | "Gruntfile.js", 14 | "package.json" 15 | ], 16 | "devDependencies": { 17 | "sizzle": "2.1.1-jquery.2.1.2", 18 | "requirejs": "2.1.10", 19 | "qunit": "1.14.0", 20 | "sinon": "1.8.1" 21 | }, 22 | "keywords": [ 23 | "jquery", 24 | "javascript", 25 | "library" 26 | ], 27 | "homepage": "https://github.com/jquery/jquery", 28 | "_release": "2.1.3", 29 | "_resolution": { 30 | "type": "version", 31 | "tag": "2.1.3", 32 | "commit": "8f2a9d9272d6ed7f32d3a484740ab342c02541e0" 33 | }, 34 | "_source": "git://github.com/jquery/jquery.git", 35 | "_target": "~2.1.3", 36 | "_originalSource": "jquery" 37 | } -------------------------------------------------------------------------------- /app/bower_components/jquery/MIT-LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2014 jQuery Foundation and other contributors 2 | http://jquery.com/ 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining 5 | a copy of this software and associated documentation files (the 6 | "Software"), to deal in the Software without restriction, including 7 | without limitation the rights to use, copy, modify, merge, publish, 8 | distribute, sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so, subject to 10 | the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /app/bower_components/jquery/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery", 3 | "version": "2.1.3", 4 | "main": "dist/jquery.js", 5 | "license": "MIT", 6 | "ignore": [ 7 | "**/.*", 8 | "build", 9 | "speed", 10 | "test", 11 | "*.md", 12 | "AUTHORS.txt", 13 | "Gruntfile.js", 14 | "package.json" 15 | ], 16 | "devDependencies": { 17 | "sizzle": "2.1.1-jquery.2.1.2", 18 | "requirejs": "2.1.10", 19 | "qunit": "1.14.0", 20 | "sinon": "1.8.1" 21 | }, 22 | "keywords": [ 23 | "jquery", 24 | "javascript", 25 | "library" 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /app/bower_components/jquery/src/ajax/load.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../core", 3 | "../core/parseHTML", 4 | "../ajax", 5 | "../traversing", 6 | "../manipulation", 7 | "../selector", 8 | // Optional event/alias dependency 9 | "../event/alias" 10 | ], function( jQuery ) { 11 | 12 | // Keep a copy of the old load method 13 | var _load = jQuery.fn.load; 14 | 15 | /** 16 | * Load a url into a page 17 | */ 18 | jQuery.fn.load = function( url, params, callback ) { 19 | if ( typeof url !== "string" && _load ) { 20 | return _load.apply( this, arguments ); 21 | } 22 | 23 | var selector, type, response, 24 | self = this, 25 | off = url.indexOf(" "); 26 | 27 | if ( off >= 0 ) { 28 | selector = jQuery.trim( url.slice( off ) ); 29 | url = url.slice( 0, off ); 30 | } 31 | 32 | // If it's a function 33 | if ( jQuery.isFunction( params ) ) { 34 | 35 | // We assume that it's the callback 36 | callback = params; 37 | params = undefined; 38 | 39 | // Otherwise, build a param string 40 | } else if ( params && typeof params === "object" ) { 41 | type = "POST"; 42 | } 43 | 44 | // If we have elements to modify, make the request 45 | if ( self.length > 0 ) { 46 | jQuery.ajax({ 47 | url: url, 48 | 49 | // if "type" variable is undefined, then "GET" method will be used 50 | type: type, 51 | dataType: "html", 52 | data: params 53 | }).done(function( responseText ) { 54 | 55 | // Save response for use in complete callback 56 | response = arguments; 57 | 58 | self.html( selector ? 59 | 60 | // If a selector was specified, locate the right elements in a dummy div 61 | // Exclude scripts to avoid IE 'Permission Denied' errors 62 | jQuery("
").append( jQuery.parseHTML( responseText ) ).find( selector ) : 63 | 64 | // Otherwise use the full result 65 | responseText ); 66 | 67 | }).complete( callback && function( jqXHR, status ) { 68 | self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] ); 69 | }); 70 | } 71 | 72 | return this; 73 | }; 74 | 75 | }); 76 | -------------------------------------------------------------------------------- /app/bower_components/jquery/src/ajax/parseJSON.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../core" 3 | ], function( jQuery ) { 4 | 5 | // Support: Android 2.3 6 | // Workaround failure to string-cast null input 7 | jQuery.parseJSON = function( data ) { 8 | return JSON.parse( data + "" ); 9 | }; 10 | 11 | return jQuery.parseJSON; 12 | 13 | }); 14 | -------------------------------------------------------------------------------- /app/bower_components/jquery/src/ajax/parseXML.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../core" 3 | ], function( jQuery ) { 4 | 5 | // Cross-browser xml parsing 6 | jQuery.parseXML = function( data ) { 7 | var xml, tmp; 8 | if ( !data || typeof data !== "string" ) { 9 | return null; 10 | } 11 | 12 | // Support: IE9 13 | try { 14 | tmp = new DOMParser(); 15 | xml = tmp.parseFromString( data, "text/xml" ); 16 | } catch ( e ) { 17 | xml = undefined; 18 | } 19 | 20 | if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) { 21 | jQuery.error( "Invalid XML: " + data ); 22 | } 23 | return xml; 24 | }; 25 | 26 | return jQuery.parseXML; 27 | 28 | }); 29 | -------------------------------------------------------------------------------- /app/bower_components/jquery/src/ajax/script.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../core", 3 | "../ajax" 4 | ], function( jQuery ) { 5 | 6 | // Install script dataType 7 | jQuery.ajaxSetup({ 8 | accepts: { 9 | script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript" 10 | }, 11 | contents: { 12 | script: /(?:java|ecma)script/ 13 | }, 14 | converters: { 15 | "text script": function( text ) { 16 | jQuery.globalEval( text ); 17 | return text; 18 | } 19 | } 20 | }); 21 | 22 | // Handle cache's special case and crossDomain 23 | jQuery.ajaxPrefilter( "script", function( s ) { 24 | if ( s.cache === undefined ) { 25 | s.cache = false; 26 | } 27 | if ( s.crossDomain ) { 28 | s.type = "GET"; 29 | } 30 | }); 31 | 32 | // Bind script tag hack transport 33 | jQuery.ajaxTransport( "script", function( s ) { 34 | // This transport only deals with cross domain requests 35 | if ( s.crossDomain ) { 36 | var script, callback; 37 | return { 38 | send: function( _, complete ) { 39 | script = jQuery(" 9 | 10 | 11 |
score
12 |
debug
13 |
14 |
15 | 22 | 26 | 30 |
31 | 32 | 33 | -------------------------------------------------------------------------------- /app/js/config.js: -------------------------------------------------------------------------------- 1 | // RequireJSの設定 2 | require.config({ 3 | paths : { 4 | jquery : [ 5 | '../bower_components/jquery/dist/jquery.min' 6 | ], 7 | threejs : [ 8 | '../bower_components/threejs/build/three.min' 9 | ], 10 | orbit_controls :[ 11 | '../bower_components/threejs/examples/js/controls/OrbitControls' 12 | ], 13 | trackball_controls :[ 14 | '../bower_components/threejs/examples/js/controls/TrackballControls' 15 | ], 16 | improved_noise :[ 17 | '../bower_components/threejs/examples/js/ImprovedNoise' 18 | ], 19 | stats :[ 20 | '../bower_components/threejs/examples/js/libs/stats.min' 21 | ], 22 | app_main :[ 23 | 'app' 24 | ] 25 | }, 26 | shim: { 27 | 'orbit_controls': { 28 | deps: ['threejs'], 29 | exports: 'THREE' 30 | }, 31 | 'trackball_controls': { 32 | deps: ['threejs'], 33 | exports: 'THREE' 34 | }, 35 | 'improved_noise': { 36 | deps: ['threejs'], 37 | exports: 'THREE' 38 | }, 39 | 'app_main': { 40 | deps: ['threejs','orbit_controls','trackball_controls','improved_noise'], 41 | } 42 | } 43 | }); 44 | 45 | // モジュール定義 46 | define(['jquery','threejs','orbit_controls','trackball_controls','stats','improved_noise','app_main'], function (THREE) { 47 | }); -------------------------------------------------------------------------------- /app/js/three.js/postprocessing/DotScreenPass.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | */ 4 | 5 | THREE.DotScreenPass = function ( center, angle, scale ) { 6 | 7 | if ( THREE.DotScreenShader === undefined ) 8 | console.error( "THREE.DotScreenPass relies on THREE.DotScreenShader" ); 9 | 10 | var shader = THREE.DotScreenShader; 11 | 12 | this.uniforms = THREE.UniformsUtils.clone( shader.uniforms ); 13 | 14 | if ( center !== undefined ) this.uniforms[ "center" ].value.copy( center ); 15 | if ( angle !== undefined ) this.uniforms[ "angle"].value = angle; 16 | if ( scale !== undefined ) this.uniforms[ "scale"].value = scale; 17 | 18 | this.material = new THREE.ShaderMaterial( { 19 | 20 | uniforms: this.uniforms, 21 | vertexShader: shader.vertexShader, 22 | fragmentShader: shader.fragmentShader 23 | 24 | } ); 25 | 26 | this.enabled = true; 27 | this.renderToScreen = false; 28 | this.needsSwap = true; 29 | 30 | 31 | 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.PlaneGeometry( 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 | -------------------------------------------------------------------------------- /app/js/three.js/postprocessing/FilmPass.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | */ 4 | 5 | THREE.FilmPass = function ( noiseIntensity, scanlinesIntensity, scanlinesCount, grayscale ) { 6 | 7 | if ( THREE.FilmShader === undefined ) 8 | console.error( "THREE.FilmPass relies on THREE.FilmShader" ); 9 | 10 | var shader = THREE.FilmShader; 11 | 12 | this.uniforms = THREE.UniformsUtils.clone( shader.uniforms ); 13 | 14 | this.material = new THREE.ShaderMaterial( { 15 | 16 | uniforms: this.uniforms, 17 | vertexShader: shader.vertexShader, 18 | fragmentShader: shader.fragmentShader 19 | 20 | } ); 21 | 22 | if ( grayscale !== undefined ) this.uniforms.grayscale.value = grayscale; 23 | if ( noiseIntensity !== undefined ) this.uniforms.nIntensity.value = noiseIntensity; 24 | if ( scanlinesIntensity !== undefined ) this.uniforms.sIntensity.value = scanlinesIntensity; 25 | if ( scanlinesCount !== undefined ) this.uniforms.sCount.value = scanlinesCount; 26 | 27 | this.enabled = true; 28 | this.renderToScreen = false; 29 | this.needsSwap = true; 30 | 31 | 32 | 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.PlaneGeometry( 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 | -------------------------------------------------------------------------------- /app/js/three.js/postprocessing/MaskPass.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | */ 4 | 5 | THREE.MaskPass = function ( scene, camera ) { 6 | 7 | this.scene = scene; 8 | this.camera = camera; 9 | 10 | this.enabled = true; 11 | this.clear = true; 12 | this.needsSwap = false; 13 | 14 | this.inverse = false; 15 | 16 | }; 17 | 18 | THREE.MaskPass.prototype = { 19 | 20 | render: function ( renderer, writeBuffer, readBuffer, delta ) { 21 | 22 | var context = renderer.context; 23 | 24 | // don't update color or depth 25 | 26 | context.colorMask( false, false, false, false ); 27 | context.depthMask( false ); 28 | 29 | // set up stencil 30 | 31 | var writeValue, clearValue; 32 | 33 | if ( this.inverse ) { 34 | 35 | writeValue = 0; 36 | clearValue = 1; 37 | 38 | } else { 39 | 40 | writeValue = 1; 41 | clearValue = 0; 42 | 43 | } 44 | 45 | context.enable( context.STENCIL_TEST ); 46 | context.stencilOp( context.REPLACE, context.REPLACE, context.REPLACE ); 47 | context.stencilFunc( context.ALWAYS, writeValue, 0xffffffff ); 48 | context.clearStencil( clearValue ); 49 | 50 | // draw into the stencil buffer 51 | 52 | renderer.render( this.scene, this.camera, readBuffer, this.clear ); 53 | renderer.render( this.scene, this.camera, writeBuffer, this.clear ); 54 | 55 | // re-enable update of color and depth 56 | 57 | context.colorMask( true, true, true, true ); 58 | context.depthMask( true ); 59 | 60 | // only render where stencil is set to 1 61 | 62 | context.stencilFunc( context.EQUAL, 1, 0xffffffff ); // draw if == 1 63 | context.stencilOp( context.KEEP, context.KEEP, context.KEEP ); 64 | 65 | } 66 | 67 | }; 68 | 69 | 70 | THREE.ClearMaskPass = function () { 71 | 72 | this.enabled = true; 73 | 74 | }; 75 | 76 | THREE.ClearMaskPass.prototype = { 77 | 78 | render: function ( renderer, writeBuffer, readBuffer, delta ) { 79 | 80 | var context = renderer.context; 81 | 82 | context.disable( context.STENCIL_TEST ); 83 | 84 | } 85 | 86 | }; 87 | -------------------------------------------------------------------------------- /app/js/three.js/postprocessing/RenderPass.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | */ 4 | 5 | THREE.RenderPass = function ( scene, camera, overrideMaterial, clearColor, clearAlpha ) { 6 | 7 | this.scene = scene; 8 | this.camera = camera; 9 | 10 | this.overrideMaterial = overrideMaterial; 11 | 12 | this.clearColor = clearColor; 13 | this.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 1; 14 | 15 | this.oldClearColor = new THREE.Color(); 16 | this.oldClearAlpha = 1; 17 | 18 | this.enabled = true; 19 | this.clear = true; 20 | this.needsSwap = false; 21 | 22 | }; 23 | 24 | THREE.RenderPass.prototype = { 25 | 26 | render: function ( renderer, writeBuffer, readBuffer, delta ) { 27 | 28 | this.scene.overrideMaterial = this.overrideMaterial; 29 | 30 | if ( this.clearColor ) { 31 | 32 | this.oldClearColor.copy( renderer.getClearColor() ); 33 | this.oldClearAlpha = renderer.getClearAlpha(); 34 | 35 | renderer.setClearColor( this.clearColor, this.clearAlpha ); 36 | 37 | } 38 | 39 | renderer.render( this.scene, this.camera, readBuffer, this.clear ); 40 | 41 | if ( this.clearColor ) { 42 | 43 | renderer.setClearColor( this.oldClearColor, this.oldClearAlpha ); 44 | 45 | } 46 | 47 | this.scene.overrideMaterial = null; 48 | 49 | } 50 | 51 | }; 52 | -------------------------------------------------------------------------------- /app/js/three.js/postprocessing/SavePass.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | */ 4 | 5 | THREE.SavePass = function ( renderTarget ) { 6 | 7 | if ( THREE.CopyShader === undefined ) 8 | console.error( "THREE.SavePass relies on THREE.CopyShader" ); 9 | 10 | var shader = THREE.CopyShader; 11 | 12 | this.textureID = "tDiffuse"; 13 | 14 | this.uniforms = THREE.UniformsUtils.clone( shader.uniforms ); 15 | 16 | this.material = new THREE.ShaderMaterial( { 17 | 18 | uniforms: this.uniforms, 19 | vertexShader: shader.vertexShader, 20 | fragmentShader: shader.fragmentShader 21 | 22 | } ); 23 | 24 | this.renderTarget = renderTarget; 25 | 26 | if ( this.renderTarget === undefined ) { 27 | 28 | this.renderTargetParameters = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBFormat, stencilBuffer: false }; 29 | this.renderTarget = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, this.renderTargetParameters ); 30 | 31 | } 32 | 33 | this.enabled = true; 34 | this.needsSwap = false; 35 | this.clear = false; 36 | 37 | 38 | 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.PlaneGeometry( 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 | -------------------------------------------------------------------------------- /app/js/three.js/postprocessing/ShaderPass.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | */ 4 | 5 | THREE.ShaderPass = function ( shader, textureID ) { 6 | 7 | this.textureID = ( textureID !== undefined ) ? textureID : "tDiffuse"; 8 | 9 | this.uniforms = THREE.UniformsUtils.clone( shader.uniforms ); 10 | 11 | this.material = new THREE.ShaderMaterial( { 12 | 13 | uniforms: this.uniforms, 14 | vertexShader: shader.vertexShader, 15 | fragmentShader: shader.fragmentShader 16 | 17 | } ); 18 | 19 | this.renderToScreen = false; 20 | 21 | this.enabled = true; 22 | this.needsSwap = true; 23 | this.clear = false; 24 | 25 | 26 | this.camera = new THREE.OrthographicCamera( -1, 1, 1, -1, 0, 1 ); 27 | this.scene = new THREE.Scene(); 28 | 29 | this.quad = new THREE.Mesh( new THREE.PlaneGeometry( 2, 2 ), null ); 30 | this.scene.add( this.quad ); 31 | 32 | }; 33 | 34 | THREE.ShaderPass.prototype = { 35 | 36 | render: function ( renderer, writeBuffer, readBuffer, delta ) { 37 | 38 | if ( this.uniforms[ this.textureID ] ) { 39 | 40 | this.uniforms[ this.textureID ].value = readBuffer; 41 | 42 | } 43 | 44 | this.quad.material = this.material; 45 | 46 | if ( this.renderToScreen ) { 47 | 48 | renderer.render( this.scene, this.camera ); 49 | 50 | } else { 51 | 52 | renderer.render( this.scene, this.camera, writeBuffer, this.clear ); 53 | 54 | } 55 | 56 | } 57 | 58 | }; 59 | -------------------------------------------------------------------------------- /app/js/three.js/postprocessing/TexturePass.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | */ 4 | 5 | THREE.TexturePass = function ( texture, opacity ) { 6 | 7 | if ( THREE.CopyShader === undefined ) 8 | console.error( "THREE.TexturePass relies on THREE.CopyShader" ); 9 | 10 | var shader = THREE.CopyShader; 11 | 12 | this.uniforms = THREE.UniformsUtils.clone( shader.uniforms ); 13 | 14 | this.uniforms[ "opacity" ].value = ( opacity !== undefined ) ? opacity : 1.0; 15 | this.uniforms[ "tDiffuse" ].value = texture; 16 | 17 | this.material = new THREE.ShaderMaterial( { 18 | 19 | uniforms: this.uniforms, 20 | vertexShader: shader.vertexShader, 21 | fragmentShader: shader.fragmentShader 22 | 23 | } ); 24 | 25 | this.enabled = true; 26 | this.needsSwap = false; 27 | 28 | 29 | 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.PlaneGeometry( 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 | -------------------------------------------------------------------------------- /app/js/three.js/shaders/BasicShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author mrdoob / http://www.mrdoob.com 3 | * 4 | * Simple test shader 5 | */ 6 | 7 | THREE.BasicShader = { 8 | 9 | uniforms: {}, 10 | 11 | vertexShader: [ 12 | 13 | "void main() {", 14 | 15 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 16 | 17 | "}" 18 | 19 | ].join("\n"), 20 | 21 | fragmentShader: [ 22 | 23 | "void main() {", 24 | 25 | "gl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );", 26 | 27 | "}" 28 | 29 | ].join("\n") 30 | 31 | }; 32 | -------------------------------------------------------------------------------- /app/js/three.js/shaders/BleachBypassShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * 4 | * Bleach bypass shader [http://en.wikipedia.org/wiki/Bleach_bypass] 5 | * - based on Nvidia example 6 | * http://developer.download.nvidia.com/shaderlibrary/webpages/shader_library.html#post_bleach_bypass 7 | */ 8 | 9 | THREE.BleachBypassShader = { 10 | 11 | uniforms: { 12 | 13 | "tDiffuse": { type: "t", value: null }, 14 | "opacity": { type: "f", value: 1.0 } 15 | 16 | }, 17 | 18 | vertexShader: [ 19 | 20 | "varying vec2 vUv;", 21 | 22 | "void main() {", 23 | 24 | "vUv = uv;", 25 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 26 | 27 | "}" 28 | 29 | ].join("\n"), 30 | 31 | fragmentShader: [ 32 | 33 | "uniform float opacity;", 34 | 35 | "uniform sampler2D tDiffuse;", 36 | 37 | "varying vec2 vUv;", 38 | 39 | "void main() {", 40 | 41 | "vec4 base = texture2D( tDiffuse, vUv );", 42 | 43 | "vec3 lumCoeff = vec3( 0.25, 0.65, 0.1 );", 44 | "float lum = dot( lumCoeff, base.rgb );", 45 | "vec3 blend = vec3( lum );", 46 | 47 | "float L = min( 1.0, max( 0.0, 10.0 * ( lum - 0.45 ) ) );", 48 | 49 | "vec3 result1 = 2.0 * base.rgb * blend;", 50 | "vec3 result2 = 1.0 - 2.0 * ( 1.0 - blend ) * ( 1.0 - base.rgb );", 51 | 52 | "vec3 newColor = mix( result1, result2, L );", 53 | 54 | "float A2 = opacity * base.a;", 55 | "vec3 mixRGB = A2 * newColor.rgb;", 56 | "mixRGB += ( ( 1.0 - A2 ) * base.rgb );", 57 | 58 | "gl_FragColor = vec4( mixRGB, base.a );", 59 | 60 | "}" 61 | 62 | ].join("\n") 63 | 64 | }; 65 | -------------------------------------------------------------------------------- /app/js/three.js/shaders/BlendShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * 4 | * Blend two textures 5 | */ 6 | 7 | THREE.BlendShader = { 8 | 9 | uniforms: { 10 | 11 | "tDiffuse1": { type: "t", value: null }, 12 | "tDiffuse2": { type: "t", value: null }, 13 | "mixRatio": { type: "f", value: 0.5 }, 14 | "opacity": { type: "f", value: 1.0 } 15 | 16 | }, 17 | 18 | vertexShader: [ 19 | 20 | "varying vec2 vUv;", 21 | 22 | "void main() {", 23 | 24 | "vUv = uv;", 25 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 26 | 27 | "}" 28 | 29 | ].join("\n"), 30 | 31 | fragmentShader: [ 32 | 33 | "uniform float opacity;", 34 | "uniform float mixRatio;", 35 | 36 | "uniform sampler2D tDiffuse1;", 37 | "uniform sampler2D tDiffuse2;", 38 | 39 | "varying vec2 vUv;", 40 | 41 | "void main() {", 42 | 43 | "vec4 texel1 = texture2D( tDiffuse1, vUv );", 44 | "vec4 texel2 = texture2D( tDiffuse2, vUv );", 45 | "gl_FragColor = opacity * mix( texel1, texel2, mixRatio );", 46 | 47 | "}" 48 | 49 | ].join("\n") 50 | 51 | }; 52 | -------------------------------------------------------------------------------- /app/js/three.js/shaders/BrightnessContrastShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author tapio / http://tapio.github.com/ 3 | * 4 | * Brightness and contrast adjustment 5 | * https://github.com/evanw/glfx.js 6 | * brightness: -1 to 1 (-1 is solid black, 0 is no change, and 1 is solid white) 7 | * contrast: -1 to 1 (-1 is solid gray, 0 is no change, and 1 is maximum contrast) 8 | */ 9 | 10 | THREE.BrightnessContrastShader = { 11 | 12 | uniforms: { 13 | 14 | "tDiffuse": { type: "t", value: null }, 15 | "brightness": { type: "f", value: 0 }, 16 | "contrast": { type: "f", value: 0 } 17 | 18 | }, 19 | 20 | vertexShader: [ 21 | 22 | "varying vec2 vUv;", 23 | 24 | "void main() {", 25 | 26 | "vUv = uv;", 27 | 28 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 29 | 30 | "}" 31 | 32 | ].join("\n"), 33 | 34 | fragmentShader: [ 35 | 36 | "uniform sampler2D tDiffuse;", 37 | "uniform float brightness;", 38 | "uniform float contrast;", 39 | 40 | "varying vec2 vUv;", 41 | 42 | "void main() {", 43 | 44 | "gl_FragColor = texture2D( tDiffuse, vUv );", 45 | 46 | "gl_FragColor.rgb += brightness;", 47 | 48 | "if (contrast > 0.0) {", 49 | "gl_FragColor.rgb = (gl_FragColor.rgb - 0.5) / (1.0 - contrast) + 0.5;", 50 | "} else {", 51 | "gl_FragColor.rgb = (gl_FragColor.rgb - 0.5) * (1.0 + contrast) + 0.5;", 52 | "}", 53 | 54 | "}" 55 | 56 | ].join("\n") 57 | 58 | }; 59 | -------------------------------------------------------------------------------- /app/js/three.js/shaders/ColorCorrectionShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * 4 | * Color correction 5 | */ 6 | 7 | THREE.ColorCorrectionShader = { 8 | 9 | uniforms: { 10 | 11 | "tDiffuse": { type: "t", value: null }, 12 | "powRGB": { type: "v3", value: new THREE.Vector3( 2, 2, 2 ) }, 13 | "mulRGB": { type: "v3", value: new THREE.Vector3( 1, 1, 1 ) } 14 | 15 | }, 16 | 17 | vertexShader: [ 18 | 19 | "varying vec2 vUv;", 20 | 21 | "void main() {", 22 | 23 | "vUv = uv;", 24 | 25 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 26 | 27 | "}" 28 | 29 | ].join("\n"), 30 | 31 | fragmentShader: [ 32 | 33 | "uniform sampler2D tDiffuse;", 34 | "uniform vec3 powRGB;", 35 | "uniform vec3 mulRGB;", 36 | 37 | "varying vec2 vUv;", 38 | 39 | "void main() {", 40 | 41 | "gl_FragColor = texture2D( tDiffuse, vUv );", 42 | "gl_FragColor.rgb = mulRGB * pow( gl_FragColor.rgb, powRGB );", 43 | 44 | "}" 45 | 46 | ].join("\n") 47 | 48 | }; 49 | -------------------------------------------------------------------------------- /app/js/three.js/shaders/ColorifyShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * 4 | * Colorify shader 5 | */ 6 | 7 | THREE.ColorifyShader = { 8 | 9 | uniforms: { 10 | 11 | "tDiffuse": { type: "t", value: null }, 12 | "color": { type: "c", value: new THREE.Color( 0xffffff ) } 13 | 14 | }, 15 | 16 | vertexShader: [ 17 | 18 | "varying vec2 vUv;", 19 | 20 | "void main() {", 21 | 22 | "vUv = uv;", 23 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 24 | 25 | "}" 26 | 27 | ].join("\n"), 28 | 29 | fragmentShader: [ 30 | 31 | "uniform vec3 color;", 32 | "uniform sampler2D tDiffuse;", 33 | 34 | "varying vec2 vUv;", 35 | 36 | "void main() {", 37 | 38 | "vec4 texel = texture2D( tDiffuse, vUv );", 39 | 40 | "vec3 luma = vec3( 0.299, 0.587, 0.114 );", 41 | "float v = dot( texel.xyz, luma );", 42 | 43 | "gl_FragColor = vec4( v * color, texel.w );", 44 | 45 | "}" 46 | 47 | ].join("\n") 48 | 49 | }; 50 | -------------------------------------------------------------------------------- /app/js/three.js/shaders/CopyShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * 4 | * Full-screen textured quad shader 5 | */ 6 | 7 | THREE.CopyShader = { 8 | 9 | uniforms: { 10 | 11 | "tDiffuse": { type: "t", value: null }, 12 | "opacity": { type: "f", value: 1.0 } 13 | 14 | }, 15 | 16 | vertexShader: [ 17 | 18 | "varying vec2 vUv;", 19 | 20 | "void main() {", 21 | 22 | "vUv = uv;", 23 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 24 | 25 | "}" 26 | 27 | ].join("\n"), 28 | 29 | fragmentShader: [ 30 | 31 | "uniform float opacity;", 32 | 33 | "uniform sampler2D tDiffuse;", 34 | 35 | "varying vec2 vUv;", 36 | 37 | "void main() {", 38 | 39 | "vec4 texel = texture2D( tDiffuse, vUv );", 40 | "gl_FragColor = opacity * texel;", 41 | 42 | "}" 43 | 44 | ].join("\n") 45 | 46 | }; 47 | -------------------------------------------------------------------------------- /app/js/three.js/shaders/DOFMipMapShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * 4 | * Depth-of-field shader using mipmaps 5 | * - from Matt Handley @applmak 6 | * - requires power-of-2 sized render target with enabled mipmaps 7 | */ 8 | 9 | THREE.DOFMipMapShader = { 10 | 11 | uniforms: { 12 | 13 | "tColor": { type: "t", value: null }, 14 | "tDepth": { type: "t", value: null }, 15 | "focus": { type: "f", value: 1.0 }, 16 | "maxblur": { type: "f", value: 1.0 } 17 | 18 | }, 19 | 20 | vertexShader: [ 21 | 22 | "varying vec2 vUv;", 23 | 24 | "void main() {", 25 | 26 | "vUv = uv;", 27 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 28 | 29 | "}" 30 | 31 | ].join("\n"), 32 | 33 | fragmentShader: [ 34 | 35 | "uniform float focus;", 36 | "uniform float maxblur;", 37 | 38 | "uniform sampler2D tColor;", 39 | "uniform sampler2D tDepth;", 40 | 41 | "varying vec2 vUv;", 42 | 43 | "void main() {", 44 | 45 | "vec4 depth = texture2D( tDepth, vUv );", 46 | 47 | "float factor = depth.x - focus;", 48 | 49 | "vec4 col = texture2D( tColor, vUv, 2.0 * maxblur * abs( focus - depth.x ) );", 50 | 51 | "gl_FragColor = col;", 52 | "gl_FragColor.a = 1.0;", 53 | 54 | "}" 55 | 56 | ].join("\n") 57 | 58 | }; 59 | -------------------------------------------------------------------------------- /app/js/three.js/shaders/DotMatrixShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by yutaka.sano on 2014/10/08. 3 | */ 4 | /** 5 | * @author felixturner / http://airtight.cc/ 6 | * 7 | * Renders texture as a grid of dots like an LED display. 8 | * Pass in the webgl canvas dimensions to give accurate pixelization. 9 | * 10 | * spacing: distance between dots in px 11 | * size: radius of dots in px 12 | * blur: blur radius of dots in px 13 | * resolution: width and height of webgl canvas 14 | */ 15 | 16 | THREE.DotMatrixShader = { 17 | 18 | uniforms: { 19 | 20 | "tDiffuse": { 21 | type: "t", 22 | value: null 23 | }, 24 | "spacing": { 25 | type: "f", 26 | value: 10.0 27 | }, 28 | "size": { 29 | type: "f", 30 | value: 4.0 31 | }, 32 | "blur": { 33 | type: "f", 34 | value: 4.0 35 | }, 36 | "resolution": { 37 | type: "v2", 38 | value: new THREE.Vector2(800, 600) 39 | } 40 | 41 | }, 42 | 43 | vertexShader: [ 44 | 45 | "varying vec2 vUv;", 46 | 47 | "void main() {", 48 | 49 | "vUv = uv;", "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 50 | 51 | "}" 52 | 53 | ].join("\n"), 54 | 55 | fragmentShader: [ 56 | 57 | "uniform sampler2D tDiffuse;", "uniform float spacing;", "uniform float size;", "uniform float blur;", "uniform vec2 resolution;", 58 | 59 | "varying vec2 vUv;", 60 | 61 | "void main() {", 62 | 63 | "vec2 count = vec2(resolution/spacing);", "vec2 p = floor(vUv*count)/count;", 64 | 65 | "vec4 color = texture2D(tDiffuse, p);", 66 | 67 | "vec2 pos = mod(gl_FragCoord.xy, vec2(spacing)) - vec2(spacing/2.0);", "float dist_squared = dot(pos, pos);", "gl_FragColor = mix(color, vec4(0.0), smoothstep(size, size + blur, dist_squared));", 68 | 69 | "}" 70 | 71 | ].join("\n") 72 | 73 | }; -------------------------------------------------------------------------------- /app/js/three.js/shaders/DotScreenShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * 4 | * Dot screen shader 5 | * based on glfx.js sepia shader 6 | * https://github.com/evanw/glfx.js 7 | */ 8 | 9 | THREE.DotScreenShader = { 10 | 11 | uniforms: { 12 | 13 | "tDiffuse": { type: "t", value: null }, 14 | "tSize": { type: "v2", value: new THREE.Vector2( 256, 256 ) }, 15 | "center": { type: "v2", value: new THREE.Vector2( 0.5, 0.5 ) }, 16 | "angle": { type: "f", value: 1.57 }, 17 | "scale": { type: "f", value: 1.0 } 18 | 19 | }, 20 | 21 | vertexShader: [ 22 | 23 | "varying vec2 vUv;", 24 | 25 | "void main() {", 26 | 27 | "vUv = uv;", 28 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 29 | 30 | "}" 31 | 32 | ].join("\n"), 33 | 34 | fragmentShader: [ 35 | 36 | "uniform vec2 center;", 37 | "uniform float angle;", 38 | "uniform float scale;", 39 | "uniform vec2 tSize;", 40 | 41 | "uniform sampler2D tDiffuse;", 42 | 43 | "varying vec2 vUv;", 44 | 45 | "float pattern() {", 46 | 47 | "float s = sin( angle ), c = cos( angle );", 48 | 49 | "vec2 tex = vUv * tSize - center;", 50 | "vec2 point = vec2( c * tex.x - s * tex.y, s * tex.x + c * tex.y ) * scale;", 51 | 52 | "return ( sin( point.x ) * sin( point.y ) ) * 4.0;", 53 | 54 | "}", 55 | 56 | "void main() {", 57 | 58 | "vec4 color = texture2D( tDiffuse, vUv );", 59 | 60 | "float average = ( color.r + color.g + color.b ) / 3.0;", 61 | 62 | "gl_FragColor = vec4( vec3( average * 10.0 - 5.0 + pattern() ), color.a );", 63 | 64 | "}" 65 | 66 | ].join("\n") 67 | 68 | }; 69 | -------------------------------------------------------------------------------- /app/js/three.js/shaders/EdgeShader2.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author zz85 / https://github.com/zz85 | https://www.lab4games.net/zz85/blog 3 | * 4 | * Edge Detection Shader using Sobel filter 5 | * Based on http://rastergrid.com/blog/2011/01/frei-chen-edge-detector 6 | * 7 | * aspect: vec2 of (1/width, 1/height) 8 | */ 9 | 10 | THREE.EdgeShader2 = { 11 | 12 | uniforms: { 13 | 14 | "tDiffuse": { type: "t", value: null }, 15 | "aspect": { type: "v2", value: new THREE.Vector2( 512, 512 ) }, 16 | }, 17 | 18 | vertexShader: [ 19 | 20 | "varying vec2 vUv;", 21 | 22 | "void main() {", 23 | 24 | "vUv = uv;", 25 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 26 | 27 | "}" 28 | 29 | ].join("\n"), 30 | 31 | fragmentShader: [ 32 | 33 | "uniform sampler2D tDiffuse;", 34 | "varying vec2 vUv;", 35 | "uniform vec2 aspect;", 36 | 37 | 38 | "vec2 texel = vec2(1.0 / aspect.x, 1.0 / aspect.y);", 39 | 40 | "mat3 G[2];", 41 | 42 | "const mat3 g0 = mat3( 1.0, 2.0, 1.0, 0.0, 0.0, 0.0, -1.0, -2.0, -1.0 );", 43 | "const mat3 g1 = mat3( 1.0, 0.0, -1.0, 2.0, 0.0, -2.0, 1.0, 0.0, -1.0 );", 44 | 45 | 46 | "void main(void)", 47 | "{", 48 | "mat3 I;", 49 | "float cnv[2];", 50 | "vec3 sample;", 51 | 52 | "G[0] = g0;", 53 | "G[1] = g1;", 54 | 55 | /* fetch the 3x3 neighbourhood and use the RGB vector's length as intensity value */ 56 | "for (float i=0.0; i<3.0; i++)", 57 | "for (float j=0.0; j<3.0; j++) {", 58 | "sample = texture2D( tDiffuse, vUv + texel * vec2(i-1.0,j-1.0) ).rgb;", 59 | "I[int(i)][int(j)] = length(sample);", 60 | "}", 61 | 62 | /* calculate the convolution values for all the masks */ 63 | "for (int i=0; i<2; i++) {", 64 | "float dp3 = dot(G[i][0], I[0]) + dot(G[i][1], I[1]) + dot(G[i][2], I[2]);", 65 | "cnv[i] = dp3 * dp3; ", 66 | "}", 67 | 68 | "gl_FragColor = vec4(0.5 * sqrt(cnv[0]*cnv[0]+cnv[1]*cnv[1]));", 69 | "} ", 70 | 71 | ].join("\n") 72 | 73 | }; 74 | -------------------------------------------------------------------------------- /app/js/three.js/shaders/HorizontalBlurShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author zz85 / http://www.lab4games.net/zz85/blog 3 | * 4 | * Two pass Gaussian blur filter (horizontal and vertical blur shaders) 5 | * - described in http://www.gamerendering.com/2008/10/11/gaussian-blur-filter-shader/ 6 | * and used in http://www.cake23.de/traveling-wavefronts-lit-up.html 7 | * 8 | * - 9 samples per pass 9 | * - standard deviation 2.7 10 | * - "h" and "v" parameters should be set to "1 / width" and "1 / height" 11 | */ 12 | 13 | THREE.HorizontalBlurShader = { 14 | 15 | uniforms: { 16 | 17 | "tDiffuse": { type: "t", value: null }, 18 | "h": { type: "f", value: 1.0 / 512.0 } 19 | 20 | }, 21 | 22 | vertexShader: [ 23 | 24 | "varying vec2 vUv;", 25 | 26 | "void main() {", 27 | 28 | "vUv = uv;", 29 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 30 | 31 | "}" 32 | 33 | ].join("\n"), 34 | 35 | fragmentShader: [ 36 | 37 | "uniform sampler2D tDiffuse;", 38 | "uniform float h;", 39 | 40 | "varying vec2 vUv;", 41 | 42 | "void main() {", 43 | 44 | "vec4 sum = vec4( 0.0 );", 45 | 46 | "sum += texture2D( tDiffuse, vec2( vUv.x - 4.0 * h, vUv.y ) ) * 0.051;", 47 | "sum += texture2D( tDiffuse, vec2( vUv.x - 3.0 * h, vUv.y ) ) * 0.0918;", 48 | "sum += texture2D( tDiffuse, vec2( vUv.x - 2.0 * h, vUv.y ) ) * 0.12245;", 49 | "sum += texture2D( tDiffuse, vec2( vUv.x - 1.0 * h, vUv.y ) ) * 0.1531;", 50 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;", 51 | "sum += texture2D( tDiffuse, vec2( vUv.x + 1.0 * h, vUv.y ) ) * 0.1531;", 52 | "sum += texture2D( tDiffuse, vec2( vUv.x + 2.0 * h, vUv.y ) ) * 0.12245;", 53 | "sum += texture2D( tDiffuse, vec2( vUv.x + 3.0 * h, vUv.y ) ) * 0.0918;", 54 | "sum += texture2D( tDiffuse, vec2( vUv.x + 4.0 * h, vUv.y ) ) * 0.051;", 55 | 56 | "gl_FragColor = sum;", 57 | 58 | "}" 59 | 60 | ].join("\n") 61 | 62 | }; 63 | -------------------------------------------------------------------------------- /app/js/three.js/shaders/HorizontalTiltShiftShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * 4 | * Simple fake tilt-shift effect, modulating two pass Gaussian blur (see above) by vertical position 5 | * 6 | * - 9 samples per pass 7 | * - standard deviation 2.7 8 | * - "h" and "v" parameters should be set to "1 / width" and "1 / height" 9 | * - "r" parameter control where "focused" horizontal line lies 10 | */ 11 | 12 | THREE.HorizontalTiltShiftShader = { 13 | 14 | uniforms: { 15 | 16 | "tDiffuse": { type: "t", value: null }, 17 | "h": { type: "f", value: 1.0 / 512.0 }, 18 | "r": { type: "f", value: 0.35 } 19 | 20 | }, 21 | 22 | vertexShader: [ 23 | 24 | "varying vec2 vUv;", 25 | 26 | "void main() {", 27 | 28 | "vUv = uv;", 29 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 30 | 31 | "}" 32 | 33 | ].join("\n"), 34 | 35 | fragmentShader: [ 36 | 37 | "uniform sampler2D tDiffuse;", 38 | "uniform float h;", 39 | "uniform float r;", 40 | 41 | "varying vec2 vUv;", 42 | 43 | "void main() {", 44 | 45 | "vec4 sum = vec4( 0.0 );", 46 | 47 | "float hh = h * abs( r - vUv.y );", 48 | 49 | "sum += texture2D( tDiffuse, vec2( vUv.x - 4.0 * hh, vUv.y ) ) * 0.051;", 50 | "sum += texture2D( tDiffuse, vec2( vUv.x - 3.0 * hh, vUv.y ) ) * 0.0918;", 51 | "sum += texture2D( tDiffuse, vec2( vUv.x - 2.0 * hh, vUv.y ) ) * 0.12245;", 52 | "sum += texture2D( tDiffuse, vec2( vUv.x - 1.0 * hh, vUv.y ) ) * 0.1531;", 53 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;", 54 | "sum += texture2D( tDiffuse, vec2( vUv.x + 1.0 * hh, vUv.y ) ) * 0.1531;", 55 | "sum += texture2D( tDiffuse, vec2( vUv.x + 2.0 * hh, vUv.y ) ) * 0.12245;", 56 | "sum += texture2D( tDiffuse, vec2( vUv.x + 3.0 * hh, vUv.y ) ) * 0.0918;", 57 | "sum += texture2D( tDiffuse, vec2( vUv.x + 4.0 * hh, vUv.y ) ) * 0.051;", 58 | 59 | "gl_FragColor = sum;", 60 | 61 | "}" 62 | 63 | ].join("\n") 64 | 65 | }; 66 | -------------------------------------------------------------------------------- /app/js/three.js/shaders/HueSaturationShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author tapio / http://tapio.github.com/ 3 | * 4 | * Hue and saturation adjustment 5 | * https://github.com/evanw/glfx.js 6 | * hue: -1 to 1 (-1 is 180 degrees in the negative direction, 0 is no change, etc. 7 | * saturation: -1 to 1 (-1 is solid gray, 0 is no change, and 1 is maximum contrast) 8 | */ 9 | 10 | THREE.HueSaturationShader = { 11 | 12 | uniforms: { 13 | 14 | "tDiffuse": { type: "t", value: null }, 15 | "hue": { type: "f", value: 0 }, 16 | "saturation": { type: "f", value: 0 } 17 | 18 | }, 19 | 20 | vertexShader: [ 21 | 22 | "varying vec2 vUv;", 23 | 24 | "void main() {", 25 | 26 | "vUv = uv;", 27 | 28 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 29 | 30 | "}" 31 | 32 | ].join("\n"), 33 | 34 | fragmentShader: [ 35 | 36 | "uniform sampler2D tDiffuse;", 37 | "uniform float hue;", 38 | "uniform float saturation;", 39 | 40 | "varying vec2 vUv;", 41 | 42 | "void main() {", 43 | 44 | "gl_FragColor = texture2D( tDiffuse, vUv );", 45 | 46 | // hue 47 | "float angle = hue * 3.14159265;", 48 | "float s = sin(angle), c = cos(angle);", 49 | "vec3 weights = (vec3(2.0 * c, -sqrt(3.0) * s - c, sqrt(3.0) * s - c) + 1.0) / 3.0;", 50 | "float len = length(gl_FragColor.rgb);", 51 | "gl_FragColor.rgb = vec3(", 52 | "dot(gl_FragColor.rgb, weights.xyz),", 53 | "dot(gl_FragColor.rgb, weights.zxy),", 54 | "dot(gl_FragColor.rgb, weights.yzx)", 55 | ");", 56 | 57 | // saturation 58 | "float average = (gl_FragColor.r + gl_FragColor.g + gl_FragColor.b) / 3.0;", 59 | "if (saturation > 0.0) {", 60 | "gl_FragColor.rgb += (average - gl_FragColor.rgb) * (1.0 - 1.0 / (1.001 - saturation));", 61 | "} else {", 62 | "gl_FragColor.rgb += (average - gl_FragColor.rgb) * (-saturation);", 63 | "}", 64 | 65 | "}" 66 | 67 | ].join("\n") 68 | 69 | }; 70 | -------------------------------------------------------------------------------- /app/js/three.js/shaders/KaleidoShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author felixturner / http://airtight.cc/ 3 | * 4 | * Kaleidoscope Shader 5 | * Radial reflection around center point 6 | * Ported from: http://pixelshaders.com/editor/ 7 | * by Toby Schachman / http://tobyschachman.com/ 8 | * 9 | * sides: number of reflections 10 | * angle: initial angle in radians 11 | */ 12 | 13 | THREE.KaleidoShader = { 14 | 15 | uniforms: { 16 | 17 | "tDiffuse": { type: "t", value: null }, 18 | "sides": { type: "f", value: 6.0 }, 19 | "angle": { type: "f", value: 0.0 } 20 | 21 | }, 22 | 23 | vertexShader: [ 24 | 25 | "varying vec2 vUv;", 26 | 27 | "void main() {", 28 | 29 | "vUv = uv;", 30 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 31 | 32 | "}" 33 | 34 | ].join("\n"), 35 | 36 | fragmentShader: [ 37 | 38 | "uniform sampler2D tDiffuse;", 39 | "uniform float sides;", 40 | "uniform float angle;", 41 | 42 | "varying vec2 vUv;", 43 | 44 | "void main() {", 45 | 46 | "vec2 p = vUv - 0.5;", 47 | "float r = length(p);", 48 | "float a = atan(p.y, p.x) + angle;", 49 | "float tau = 2. * 3.1416 ;", 50 | "a = mod(a, tau/sides);", 51 | "a = abs(a - tau/sides/2.) ;", 52 | "p = r * vec2(cos(a), sin(a));", 53 | "vec4 color = texture2D(tDiffuse, p + 0.5);", 54 | "gl_FragColor = color;", 55 | 56 | "}" 57 | 58 | ].join("\n") 59 | 60 | }; 61 | -------------------------------------------------------------------------------- /app/js/three.js/shaders/LuminosityShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * 4 | * Luminosity 5 | * http://en.wikipedia.org/wiki/Luminosity 6 | */ 7 | 8 | THREE.LuminosityShader = { 9 | 10 | uniforms: { 11 | 12 | "tDiffuse": { type: "t", value: null } 13 | 14 | }, 15 | 16 | vertexShader: [ 17 | 18 | "varying vec2 vUv;", 19 | 20 | "void main() {", 21 | 22 | "vUv = uv;", 23 | 24 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 25 | 26 | "}" 27 | 28 | ].join("\n"), 29 | 30 | fragmentShader: [ 31 | 32 | "uniform sampler2D tDiffuse;", 33 | 34 | "varying vec2 vUv;", 35 | 36 | "void main() {", 37 | 38 | "vec4 texel = texture2D( tDiffuse, vUv );", 39 | 40 | "vec3 luma = vec3( 0.299, 0.587, 0.114 );", 41 | 42 | "float v = dot( texel.xyz, luma );", 43 | 44 | "gl_FragColor = vec4( v, v, v, texel.w );", 45 | 46 | "}" 47 | 48 | ].join("\n") 49 | 50 | }; 51 | -------------------------------------------------------------------------------- /app/js/three.js/shaders/MirrorShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author felixturner / http://airtight.cc/ 3 | * 4 | * Mirror Shader 5 | * Copies half the input to the other half 6 | * 7 | * side: side of input to mirror (0 = left, 1 = right, 2 = top, 3 = bottom) 8 | */ 9 | 10 | THREE.MirrorShader = { 11 | 12 | uniforms: { 13 | 14 | "tDiffuse": { type: "t", value: null }, 15 | "side": { type: "i", value: 1 } 16 | 17 | }, 18 | 19 | vertexShader: [ 20 | 21 | "varying vec2 vUv;", 22 | 23 | "void main() {", 24 | 25 | "vUv = uv;", 26 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 27 | 28 | "}" 29 | 30 | ].join("\n"), 31 | 32 | fragmentShader: [ 33 | 34 | "uniform sampler2D tDiffuse;", 35 | "uniform int side;", 36 | 37 | "varying vec2 vUv;", 38 | 39 | "void main() {", 40 | 41 | "vec2 p = vUv;", 42 | "if (side == 0){", 43 | "if (p.x > 0.5) p.x = 1.0 - p.x;", 44 | "}else if (side == 1){", 45 | "if (p.x < 0.5) p.x = 1.0 - p.x;", 46 | "}else if (side == 2){", 47 | "if (p.y < 0.5) p.y = 1.0 - p.y;", 48 | "}else if (side == 3){", 49 | "if (p.y > 0.5) p.y = 1.0 - p.y;", 50 | "} ", 51 | "vec4 color = texture2D(tDiffuse, p);", 52 | "gl_FragColor = color;", 53 | 54 | "}" 55 | 56 | ].join("\n") 57 | 58 | }; 59 | -------------------------------------------------------------------------------- /app/js/three.js/shaders/NormalMapShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * 4 | * Normal map shader 5 | * - compute normals from heightmap 6 | */ 7 | 8 | THREE.NormalMapShader = { 9 | 10 | uniforms: { 11 | 12 | "heightMap": { type: "t", value: null }, 13 | "resolution": { type: "v2", value: new THREE.Vector2( 512, 512 ) }, 14 | "scale": { type: "v2", value: new THREE.Vector2( 1, 1 ) }, 15 | "height": { type: "f", value: 0.05 } 16 | 17 | }, 18 | 19 | vertexShader: [ 20 | 21 | "varying vec2 vUv;", 22 | 23 | "void main() {", 24 | 25 | "vUv = uv;", 26 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 27 | 28 | "}" 29 | 30 | ].join("\n"), 31 | 32 | fragmentShader: [ 33 | 34 | "uniform float height;", 35 | "uniform vec2 resolution;", 36 | "uniform sampler2D heightMap;", 37 | 38 | "varying vec2 vUv;", 39 | 40 | "void main() {", 41 | 42 | "float val = texture2D( heightMap, vUv ).x;", 43 | 44 | "float valU = texture2D( heightMap, vUv + vec2( 1.0 / resolution.x, 0.0 ) ).x;", 45 | "float valV = texture2D( heightMap, vUv + vec2( 0.0, 1.0 / resolution.y ) ).x;", 46 | 47 | "gl_FragColor = vec4( ( 0.5 * normalize( vec3( val - valU, val - valV, height ) ) + 0.5 ), 1.0 );", 48 | 49 | "}" 50 | 51 | ].join("\n") 52 | 53 | }; 54 | -------------------------------------------------------------------------------- /app/js/three.js/shaders/RGBShiftShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author felixturner / http://airtight.cc/ 3 | * 4 | * RGB Shift Shader 5 | * Shifts red and blue channels from center in opposite directions 6 | * Ported from http://kriss.cx/tom/2009/05/rgb-shift/ 7 | * by Tom Butterworth / http://kriss.cx/tom/ 8 | * 9 | * amount: shift distance (1 is width of input) 10 | * angle: shift angle in radians 11 | */ 12 | 13 | THREE.RGBShiftShader = { 14 | 15 | uniforms: { 16 | 17 | "tDiffuse": { type: "t", value: null }, 18 | "amount": { type: "f", value: 0.005 }, 19 | "angle": { type: "f", value: 0.0 } 20 | 21 | }, 22 | 23 | vertexShader: [ 24 | 25 | "varying vec2 vUv;", 26 | 27 | "void main() {", 28 | 29 | "vUv = uv;", 30 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 31 | 32 | "}" 33 | 34 | ].join("\n"), 35 | 36 | fragmentShader: [ 37 | 38 | "uniform sampler2D tDiffuse;", 39 | "uniform float amount;", 40 | "uniform float angle;", 41 | 42 | "varying vec2 vUv;", 43 | 44 | "void main() {", 45 | 46 | "vec2 offset = amount * vec2( cos(angle), sin(angle));", 47 | "vec4 cr = texture2D(tDiffuse, vUv + offset);", 48 | "vec4 cga = texture2D(tDiffuse, vUv);", 49 | "vec4 cb = texture2D(tDiffuse, vUv - offset);", 50 | "gl_FragColor = vec4(cr.r, cga.g, cb.b, cga.a);", 51 | 52 | "}" 53 | 54 | ].join("\n") 55 | 56 | }; 57 | -------------------------------------------------------------------------------- /app/js/three.js/shaders/SepiaShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * 4 | * Sepia tone shader 5 | * based on glfx.js sepia shader 6 | * https://github.com/evanw/glfx.js 7 | */ 8 | 9 | THREE.SepiaShader = { 10 | 11 | uniforms: { 12 | 13 | "tDiffuse": { type: "t", value: null }, 14 | "amount": { type: "f", value: 1.0 } 15 | 16 | }, 17 | 18 | vertexShader: [ 19 | 20 | "varying vec2 vUv;", 21 | 22 | "void main() {", 23 | 24 | "vUv = uv;", 25 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 26 | 27 | "}" 28 | 29 | ].join("\n"), 30 | 31 | fragmentShader: [ 32 | 33 | "uniform float amount;", 34 | 35 | "uniform sampler2D tDiffuse;", 36 | 37 | "varying vec2 vUv;", 38 | 39 | "void main() {", 40 | 41 | "vec4 color = texture2D( tDiffuse, vUv );", 42 | "vec3 c = color.rgb;", 43 | 44 | "color.r = dot( c, vec3( 1.0 - 0.607 * amount, 0.769 * amount, 0.189 * amount ) );", 45 | "color.g = dot( c, vec3( 0.349 * amount, 1.0 - 0.314 * amount, 0.168 * amount ) );", 46 | "color.b = dot( c, vec3( 0.272 * amount, 0.534 * amount, 1.0 - 0.869 * amount ) );", 47 | 48 | "gl_FragColor = vec4( min( vec3( 1.0 ), color.rgb ), color.a );", 49 | 50 | "}" 51 | 52 | ].join("\n") 53 | 54 | }; 55 | -------------------------------------------------------------------------------- /app/js/three.js/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 | -------------------------------------------------------------------------------- /app/js/three.js/shaders/TriangleBlurShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author zz85 / http://www.lab4games.net/zz85/blog 3 | * 4 | * Triangle blur shader 5 | * based on glfx.js triangle blur shader 6 | * https://github.com/evanw/glfx.js 7 | * 8 | * A basic blur filter, which convolves the image with a 9 | * pyramid filter. The pyramid filter is separable and is applied as two 10 | * perpendicular triangle filters. 11 | */ 12 | 13 | THREE.TriangleBlurShader = { 14 | 15 | uniforms : { 16 | 17 | "texture": { type: "t", value: null }, 18 | "delta": { type: "v2", value:new THREE.Vector2( 1, 1 ) } 19 | 20 | }, 21 | 22 | vertexShader: [ 23 | 24 | "varying vec2 vUv;", 25 | 26 | "void main() {", 27 | 28 | "vUv = uv;", 29 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 30 | 31 | "}" 32 | 33 | ].join("\n"), 34 | 35 | fragmentShader: [ 36 | 37 | "#define ITERATIONS 10.0", 38 | 39 | "uniform sampler2D texture;", 40 | "uniform vec2 delta;", 41 | 42 | "varying vec2 vUv;", 43 | 44 | "float random( vec3 scale, float seed ) {", 45 | 46 | // use the fragment position for a different seed per-pixel 47 | 48 | "return fract( sin( dot( gl_FragCoord.xyz + seed, scale ) ) * 43758.5453 + seed );", 49 | 50 | "}", 51 | 52 | "void main() {", 53 | 54 | "vec4 color = vec4( 0.0 );", 55 | 56 | "float total = 0.0;", 57 | 58 | // randomize the lookup values to hide the fixed number of samples 59 | 60 | "float offset = random( vec3( 12.9898, 78.233, 151.7182 ), 0.0 );", 61 | 62 | "for ( float t = -ITERATIONS; t <= ITERATIONS; t ++ ) {", 63 | 64 | "float percent = ( t + offset - 0.5 ) / ITERATIONS;", 65 | "float weight = 1.0 - abs( percent );", 66 | 67 | "color += texture2D( texture, vUv + delta * percent ) * weight;", 68 | "total += weight;", 69 | 70 | "}", 71 | 72 | "gl_FragColor = color / total;", 73 | 74 | "}" 75 | 76 | ].join("\n") 77 | 78 | }; 79 | -------------------------------------------------------------------------------- /app/js/three.js/shaders/UnpackDepthRGBAShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * 4 | * Unpack RGBA depth shader 5 | * - show RGBA encoded depth as monochrome color 6 | */ 7 | 8 | THREE.UnpackDepthRGBAShader = { 9 | 10 | uniforms: { 11 | 12 | "tDiffuse": { type: "t", value: null }, 13 | "opacity": { type: "f", value: 1.0 } 14 | 15 | }, 16 | 17 | vertexShader: [ 18 | 19 | "varying vec2 vUv;", 20 | 21 | "void main() {", 22 | 23 | "vUv = uv;", 24 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 25 | 26 | "}" 27 | 28 | ].join("\n"), 29 | 30 | fragmentShader: [ 31 | 32 | "uniform float opacity;", 33 | 34 | "uniform sampler2D tDiffuse;", 35 | 36 | "varying vec2 vUv;", 37 | 38 | // RGBA depth 39 | 40 | "float unpackDepth( const in vec4 rgba_depth ) {", 41 | 42 | "const vec4 bit_shift = vec4( 1.0 / ( 256.0 * 256.0 * 256.0 ), 1.0 / ( 256.0 * 256.0 ), 1.0 / 256.0, 1.0 );", 43 | "float depth = dot( rgba_depth, bit_shift );", 44 | "return depth;", 45 | 46 | "}", 47 | 48 | "void main() {", 49 | 50 | "float depth = 1.0 - unpackDepth( texture2D( tDiffuse, vUv ) );", 51 | "gl_FragColor = opacity * vec4( vec3( depth ), 1.0 );", 52 | 53 | "}" 54 | 55 | ].join("\n") 56 | 57 | }; 58 | -------------------------------------------------------------------------------- /app/js/three.js/shaders/VerticalBlurShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author zz85 / http://www.lab4games.net/zz85/blog 3 | * 4 | * Two pass Gaussian blur filter (horizontal and vertical blur shaders) 5 | * - described in http://www.gamerendering.com/2008/10/11/gaussian-blur-filter-shader/ 6 | * and used in http://www.cake23.de/traveling-wavefronts-lit-up.html 7 | * 8 | * - 9 samples per pass 9 | * - standard deviation 2.7 10 | * - "h" and "v" parameters should be set to "1 / width" and "1 / height" 11 | */ 12 | 13 | THREE.VerticalBlurShader = { 14 | 15 | uniforms: { 16 | 17 | "tDiffuse": { type: "t", value: null }, 18 | "v": { type: "f", value: 1.0 / 512.0 } 19 | 20 | }, 21 | 22 | vertexShader: [ 23 | 24 | "varying vec2 vUv;", 25 | 26 | "void main() {", 27 | 28 | "vUv = uv;", 29 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 30 | 31 | "}" 32 | 33 | ].join("\n"), 34 | 35 | fragmentShader: [ 36 | 37 | "uniform sampler2D tDiffuse;", 38 | "uniform float v;", 39 | 40 | "varying vec2 vUv;", 41 | 42 | "void main() {", 43 | 44 | "vec4 sum = vec4( 0.0 );", 45 | 46 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 4.0 * v ) ) * 0.051;", 47 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 3.0 * v ) ) * 0.0918;", 48 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 2.0 * v ) ) * 0.12245;", 49 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 1.0 * v ) ) * 0.1531;", 50 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;", 51 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 1.0 * v ) ) * 0.1531;", 52 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 2.0 * v ) ) * 0.12245;", 53 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 3.0 * v ) ) * 0.0918;", 54 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 4.0 * v ) ) * 0.051;", 55 | 56 | "gl_FragColor = sum;", 57 | 58 | "}" 59 | 60 | ].join("\n") 61 | 62 | }; 63 | -------------------------------------------------------------------------------- /app/js/three.js/shaders/VerticalTiltShiftShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * 4 | * Simple fake tilt-shift effect, modulating two pass Gaussian blur (see above) by vertical position 5 | * 6 | * - 9 samples per pass 7 | * - standard deviation 2.7 8 | * - "h" and "v" parameters should be set to "1 / width" and "1 / height" 9 | * - "r" parameter control where "focused" horizontal line lies 10 | */ 11 | 12 | THREE.VerticalTiltShiftShader = { 13 | 14 | uniforms: { 15 | 16 | "tDiffuse": { type: "t", value: null }, 17 | "v": { type: "f", value: 1.0 / 512.0 }, 18 | "r": { type: "f", value: 0.35 } 19 | 20 | }, 21 | 22 | vertexShader: [ 23 | 24 | "varying vec2 vUv;", 25 | 26 | "void main() {", 27 | 28 | "vUv = uv;", 29 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 30 | 31 | "}" 32 | 33 | ].join("\n"), 34 | 35 | fragmentShader: [ 36 | 37 | "uniform sampler2D tDiffuse;", 38 | "uniform float v;", 39 | "uniform float r;", 40 | 41 | "varying vec2 vUv;", 42 | 43 | "void main() {", 44 | 45 | "vec4 sum = vec4( 0.0 );", 46 | 47 | "float vv = v * abs( r - vUv.y );", 48 | 49 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 4.0 * vv ) ) * 0.051;", 50 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 3.0 * vv ) ) * 0.0918;", 51 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 2.0 * vv ) ) * 0.12245;", 52 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 1.0 * vv ) ) * 0.1531;", 53 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;", 54 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 1.0 * vv ) ) * 0.1531;", 55 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 2.0 * vv ) ) * 0.12245;", 56 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 3.0 * vv ) ) * 0.0918;", 57 | "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 4.0 * vv ) ) * 0.051;", 58 | 59 | "gl_FragColor = sum;", 60 | 61 | "}" 62 | 63 | ].join("\n") 64 | 65 | }; 66 | -------------------------------------------------------------------------------- /app/js/three.js/shaders/VignetteShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * 4 | * Vignette shader 5 | * based on PaintEffect postprocess from ro.me 6 | * http://code.google.com/p/3-dreams-of-black/source/browse/deploy/js/effects/PaintEffect.js 7 | */ 8 | 9 | THREE.VignetteShader = { 10 | 11 | uniforms: { 12 | 13 | "tDiffuse": { type: "t", value: null }, 14 | "offset": { type: "f", value: 1.0 }, 15 | "darkness": { type: "f", value: 1.0 } 16 | 17 | }, 18 | 19 | vertexShader: [ 20 | 21 | "varying vec2 vUv;", 22 | 23 | "void main() {", 24 | 25 | "vUv = uv;", 26 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 27 | 28 | "}" 29 | 30 | ].join("\n"), 31 | 32 | fragmentShader: [ 33 | 34 | "uniform float offset;", 35 | "uniform float darkness;", 36 | 37 | "uniform sampler2D tDiffuse;", 38 | 39 | "varying vec2 vUv;", 40 | 41 | "void main() {", 42 | 43 | // Eskil's vignette 44 | 45 | "vec4 texel = texture2D( tDiffuse, vUv );", 46 | "vec2 uv = ( vUv - vec2( 0.5 ) ) * vec2( offset );", 47 | "gl_FragColor = vec4( mix( texel.rgb, vec3( 1.0 - darkness ), dot( uv, uv ) ), texel.a );", 48 | 49 | /* 50 | // alternative version from glfx.js 51 | // this one makes more "dusty" look (as opposed to "burned") 52 | 53 | "vec4 color = texture2D( tDiffuse, vUv );", 54 | "float dist = distance( vUv, vec2( 0.5 ) );", 55 | "color.rgb *= smoothstep( 0.8, offset * 0.799, dist *( darkness + offset ) );", 56 | "gl_FragColor = color;", 57 | */ 58 | 59 | "}" 60 | 61 | ].join("\n") 62 | 63 | }; 64 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "game.js", 3 | "version": "0.0.0", 4 | "homepage": "https://github.com/verytired/three.js-game", 5 | "authors": [ 6 | "verytired" 7 | ], 8 | "main": "app/app.js", 9 | "license": "MIT", 10 | "ignore": [ 11 | "**/.*", 12 | "node_modules", 13 | "bower_components", 14 | "test", 15 | "tests" 16 | ], 17 | "dependencies": { 18 | "jquery": "~2.1.3", 19 | "threejs": "*", 20 | "requirejs": "~2.1.17" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /gulpfile.coffee: -------------------------------------------------------------------------------- 1 | gulp = require 'gulp' 2 | gutil = require 'gulp-util' 3 | parentDir = "app/" 4 | 5 | #load all module 6 | $ = require('gulp-load-plugins')({ 7 | pattern: ['gulp-*', 'gulp.*'], 8 | replaceString: /\bgulp[\-.]/ 9 | }) 10 | 11 | browserSync = require 'browser-sync' 12 | reload = browserSync.reload 13 | runSequence = require('run-sequence'); 14 | 15 | gulp.task 'default', -> 16 | console.log 'gulp!' 17 | 18 | #coffee compile 19 | gulp.task 'coffee', -> 20 | gulp 21 | .src ['src/coffee/*.coffee'] 22 | .pipe $.plumber() 23 | .pipe $.coffee() 24 | .pipe gulp.dest parentDir + 'js' 25 | 26 | #typescript compile using gulp-typescript 27 | gulp.task 'typescript', () -> 28 | gulp 29 | .src ['src/*.ts','src/*/*.ts'] 30 | .pipe $.plumber() 31 | .pipe $.typescript { 32 | # module:"amd" 33 | # target: 'ES6' 34 | removeComments: true 35 | sortOutput: false 36 | sourcemap: false 37 | out: 'app.js' 38 | } 39 | .pipe gulp.dest parentDir + 'js' 40 | 41 | #run server / watch 42 | gulp.task 'serve', ['default'], -> 43 | browserSync 44 | notify: false 45 | server: 46 | baseDir: [parentDir] 47 | gulp.watch ['src/coffee/*.coffee'], ['script'] 48 | gulp.watch ['src/*.ts','src/*/*.ts'], ['script_type'] 49 | gulp.watch [parentDir + '*.html'], reload 50 | 51 | #coffee compile&reload 52 | gulp.task 'script', -> 53 | runSequence 'coffee', reload 54 | 55 | #typescript compile&reload 56 | gulp.task 'script_type', -> 57 | runSequence 'typescript', reload 58 | -------------------------------------------------------------------------------- /npm-debug.log: -------------------------------------------------------------------------------- 1 | 0 info it worked if it ends with ok 2 | 1 verbose cli [ 'node', '/usr/local/bin/npm', 'start' ] 3 | 2 info using npm@2.12.1 4 | 3 info using node@v0.12.7 5 | 4 verbose stack Error: Failed to parse json 6 | 4 verbose stack Unexpected token 't' at 8:6 7 | 4 verbose stack "test": "echo \"Error: no test specified\" && exit 1" 8 | 4 verbose stack ^ 9 | 4 verbose stack at parseError (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:379:11) 10 | 4 verbose stack at parseJson (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:68:23) 11 | 4 verbose stack at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:48:5 12 | 4 verbose stack at evalmachine.:334:14 13 | 4 verbose stack at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:102:5 14 | 4 verbose stack at FSReqWrap.oncomplete (evalmachine.:95:15) 15 | 5 verbose cwd /Users/yutaka.sano/Sites/three.js-game 16 | 6 error Darwin 13.4.0 17 | 7 error argv "node" "/usr/local/bin/npm" "start" 18 | 8 error node v0.12.7 19 | 9 error npm v2.12.1 20 | 10 error file /Users/yutaka.sano/Sites/three.js-game/package.json 21 | 11 error code EJSONPARSE 22 | 12 error Failed to parse json 23 | 12 error Unexpected token 't' at 8:6 24 | 12 error "test": "echo \"Error: no test specified\" && exit 1" 25 | 12 error ^ 26 | 13 error File: /Users/yutaka.sano/Sites/three.js-game/package.json 27 | 14 error Failed to parse package.json data. 28 | 14 error package.json must be actual JSON, not just JavaScript. 29 | 14 error 30 | 14 error This is not a bug in npm. 31 | 14 error Tell the package author to fix their package.json file. JSON.parse 32 | 15 verbose exit [ 1, true ] 33 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "practice-threejs", 3 | "version": "0.0.0", 4 | "description": "Practice Three.js", 5 | "main": "index.js", 6 | "scripts": { 7 | "start": "gulp serve", 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "git://github.com/verytired/practice-threejs.git" 13 | }, 14 | "author": "", 15 | "license": "ISC", 16 | "bugs": { 17 | "url": "https://github.com/verytired/practice-threejs/issues" 18 | }, 19 | "homepage": "https://github.com/verytired/practice-threejs", 20 | "devDependencies": { 21 | "browser-sync": "^1.3.6", 22 | "coffee-script": "*", 23 | "gulp": "~3.8.7", 24 | "gulp-clean": "~0.3.1", 25 | "gulp-coffee": "~2.1.2", 26 | "gulp-compass": "~1.3.1", 27 | "gulp-if": "~1.2.4", 28 | "gulp-load-plugins": "~0.5.3", 29 | "gulp-plumber": "^0.6.6", 30 | "gulp-ruby-sass": "~0.7.1", 31 | "gulp-tsc": "*", 32 | "gulp-typescript": "*", 33 | "gulp-uglify": "~0.3.1", 34 | "gulp-util": "~3.0.0", 35 | "run-sequence": "^0.3.6" 36 | }, 37 | "dependencies": { 38 | "gulp": "^3.9.0" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/app.ts: -------------------------------------------------------------------------------- 1 | /// 2 | //window.addEventListener("load", (e) => { 3 | GameManager.getInstance().initialize(); 4 | // 5 | -------------------------------------------------------------------------------- /src/framework/CMover.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | 4 | class CMover extends events.EventDispatcher implements IMover { 5 | 6 | public x = 0; 7 | public y = 0; 8 | public z = 0; 9 | 10 | public vx = 0; 11 | public vy = 0; 12 | 13 | public _obj: THREE.Object3D; 14 | 15 | public waitRemove: boolean = false; 16 | 17 | constructor() { 18 | super(); 19 | this._obj = new THREE.Object3D(); 20 | } 21 | 22 | public update(nowFrame) { 23 | //todo 24 | } 25 | 26 | public getObject() { 27 | return this._obj; 28 | } 29 | 30 | public remove() { 31 | //todo implemation 32 | } 33 | 34 | public setPosition(x, y, z) { 35 | this.x = x; 36 | this.y = y; 37 | this.z = z; 38 | this._obj.position.set(x, y, z); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/framework/IMover.ts: -------------------------------------------------------------------------------- 1 | 2 | interface IMover{ 3 | x : number; 4 | y : number; 5 | z : number; 6 | vx : number; 7 | vy : number; 8 | 9 | 10 | //内部情報更新 11 | update(nowFrame):void; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/game/BulletEnemy.ts: -------------------------------------------------------------------------------- 1 | //弾クラス 2 | /// 3 | 4 | class BulletEnemy extends Bullet { 5 | 6 | constructor(vx, vy) { 7 | super(vx, vy); 8 | } 9 | 10 | public generateSprite() { 11 | var canvas = document.createElement("canvas"); 12 | canvas.width = 100; 13 | canvas.height = 100; 14 | var context = canvas.getContext("2d"); 15 | var gradient = context.createRadialGradient(canvas.width / 2, canvas.height / 2, 0, canvas.width / 2, canvas.height / 2, 16 | canvas.width / 2); 17 | gradient.addColorStop(0, "rgba(255,255,255,1)"); 18 | gradient.addColorStop(0.2, "rgba(255,0,255,1)"); 19 | gradient.addColorStop(0.4, "rgba(64,0,0,1)"); 20 | gradient.addColorStop(1, "rgba(0,0,0,1)"); 21 | context.fillStyle = gradient; 22 | context.fillRect(0, 0, canvas.width, canvas.height); 23 | return canvas; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/game/EnemySmall.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by yutaka.sano on 2015/06/02. 3 | */ 4 | //敵クラス 5 | 6 | class EnemySmall extends Enemy { 7 | 8 | constructor(startframe) { 9 | super(startframe); 10 | } 11 | 12 | public initialize() { 13 | this.vy = -8; 14 | //var material = new THREE.MeshBasicMaterial({ 15 | // color: this.baseColor, 16 | // wireframe: true 17 | //}); 18 | //this._obj.add(new THREE.Mesh(new THREE.CylinderGeometry(20,40,40,16), material)); 19 | var materials = [ 20 | new THREE.MeshLambertMaterial({ 21 | color: this.baseColor, 22 | }), 23 | new THREE.MeshBasicMaterial({ 24 | color: 0x000000, 25 | wireframe: true, 26 | transparent: true 27 | }) 28 | ]; 29 | this._obj = THREE.SceneUtils.createMultiMaterialObject(new THREE.CylinderGeometry(20, 40, 40, 16), materials); 30 | 31 | this._obj.castShadow = true; 32 | this._obj.rotation.x = 90; 33 | this.hitArea.push(new HitArea(20, 20, this.x, this.y)); 34 | this.hitAreaPos.push(new THREE.Vector2(0, 0)); 35 | this.setShooter(new SingleShooter()); 36 | } 37 | 38 | public doAction() { 39 | if (this.currentFrame >= this.lifeTime) { 40 | this.isDead = true; 41 | this.waitRemove = true; 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/game/HitArea.ts: -------------------------------------------------------------------------------- 1 | 2 | class HitArea { 3 | 4 | public center: THREE.Vector2;//中心座標 5 | private width;//横幅 6 | private height;//縦幅 7 | private positions: THREE.Vector2[] = new Array(); 8 | 9 | constructor(w, h, x, y) { 10 | this.center = new THREE.Vector2(x, y); 11 | this.width = w; 12 | this.height = h; 13 | } 14 | 15 | public update(x, y) { 16 | this.center.set(x, y); 17 | this.positions[0] = new THREE.Vector2(this.center.x - this.width / 2, this.center.y - this.height / 2); 18 | this.positions[1] = new THREE.Vector2(this.center.x + this.width / 2, this.center.y - this.height / 2); 19 | this.positions[2] = new THREE.Vector2(this.center.x - this.width / 2, this.center.y + this.height / 2); 20 | this.positions[3] = new THREE.Vector2(this.center.x + this.width / 2, this.center.y + this.height / 2); 21 | } 22 | 23 | public hitTest(area: HitArea) { 24 | var pos = area.getPositions(); 25 | for (var i = 0; i < pos.length; i++) { 26 | var p: THREE.Vector2 = pos[i]; 27 | if (p.x > (this.center.x - this.width / 2) && p.x < (this.center.x + this.width / 2) && p.y > (this.center.y - this.height / 2) && p.y < (this.center.y + this.height / 2)) { 28 | return true; 29 | } 30 | } 31 | return false; 32 | } 33 | 34 | public getPositions() { 35 | return this.positions; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/game/Mover.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | class Mover extends CMover { 4 | 5 | public isDead: boolean = false; 6 | 7 | public hitArea: HitArea[] = new Array(); 8 | public hitAreaPos: THREE.Vector2[] = new Array(); 9 | 10 | constructor() { 11 | super(); 12 | } 13 | 14 | public explode() { 15 | //todo implemation 16 | } 17 | 18 | public hitTest(hitAreaArray) { 19 | for (var i = 0; i < this.hitArea.length; i++) { 20 | for (var j = 0; j < hitAreaArray.length; j++) { 21 | if (this.hitArea[i].hitTest(hitAreaArray[j]) == true) { 22 | return true; 23 | } 24 | if (hitAreaArray[j].hitTest(this.hitArea[i]) == true) { 25 | return true; 26 | } 27 | } 28 | } 29 | return false; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/game/MyShip.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | 4 | class MyShip extends Mover { 5 | 6 | constructor() { 7 | super(); 8 | 9 | this.vy = -2; 10 | 11 | var geometry = new THREE.BoxGeometry(20, 20, 20); 12 | 13 | //複数のマテリアルを使用する 14 | //var material = new THREE.MeshBasicMaterial({ 15 | // color: 0xff0000, 16 | // wireframe: true 17 | //}); 18 | 19 | var materials = [ 20 | new THREE.MeshLambertMaterial({ 21 | color: 0xff0000, 22 | }), 23 | new THREE.MeshBasicMaterial({ 24 | color: 0x000000, 25 | wireframe: true, 26 | transparent: true 27 | }) 28 | ]; 29 | this._obj = THREE.SceneUtils.createMultiMaterialObject(geometry, materials); 30 | 31 | this._obj.castShadow = true; 32 | 33 | this.hitArea.push(new HitArea(20, 20, this.x, this.y)); 34 | this.hitAreaPos.push(new THREE.Vector2(0, 0)); 35 | } 36 | 37 | public update(nowFrame) { 38 | this.setPosition(this.x, this.y, this.z); 39 | } 40 | 41 | public explode() { 42 | this.waitRemove = true; 43 | 44 | var v = GameApp.getInstance().getCurrentView(); 45 | //v.remove(this._obj) 46 | var ex = new Explosion(this.x, this.y, 0xFF0000); 47 | v.addMover(ex); 48 | } 49 | 50 | public setPosition(x, y, z) { 51 | for (var i = 0; i < this.hitArea.length; i++) { 52 | this.hitArea[i].update(x + this.hitAreaPos[i].x, y + this.hitAreaPos[i].y); 53 | } 54 | super.setPosition(x, y, z); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/game/SceneData.ts: -------------------------------------------------------------------------------- 1 | class SceneData { 2 | 3 | private _data; 4 | 5 | constructor(data) { 6 | this._data = data; 7 | } 8 | 9 | public getData(index) { 10 | return this._data[index]; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/game/Score.ts: -------------------------------------------------------------------------------- 1 | class Score { 2 | 3 | private static _instance: Score = null; 4 | 5 | private score = 0; 6 | private $viewScore: any = null; 7 | 8 | constructor() { 9 | if (Score._instance) { 10 | throw new Error("must use the getInstance."); 11 | } 12 | Score._instance = this; 13 | } 14 | 15 | public static getInstance(): Score { 16 | if (Score._instance === null) { 17 | Score._instance = new Score(); 18 | Score._instance.initialize(); 19 | } 20 | return Score._instance; 21 | } 22 | 23 | public initialize() { 24 | this.$viewScore = $("#score"); 25 | } 26 | 27 | public addScore(p) { 28 | this.score += p; 29 | this.$viewScore.html("Score:" + this.score); 30 | } 31 | 32 | public setScore(p) { 33 | this.score = p; 34 | this.$viewScore.html("Score:" + this.score); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/game/Shooter.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | class Shooter { 4 | 5 | private bullets: Mover[] = new Array(); 6 | 7 | constructor() { 8 | //todo implemation 9 | } 10 | 11 | public update(frame) { 12 | for (var i = 0; i < this.bullets.length; i++) { 13 | this.bullets[i].update(frame); 14 | } 15 | } 16 | 17 | public shot(x, y, vx, vy) { 18 | var b = new BulletEnemy(vx, vy); 19 | var v = GameApp.getInstance().getCurrentView(); 20 | var z = GameManager.getInstance().zPosition; 21 | b.setPosition(x, y, z); 22 | v.addMover(b); 23 | this.bullets.push(b); 24 | } 25 | 26 | public getBullets() { 27 | return this.bullets; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/game/ShooterNway.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | class ShooterNway extends Shooter { 4 | 5 | constructor() { 6 | super(); 7 | } 8 | 9 | public shot(x, y, nway, durationRad, speed = 5) { 10 | if (nway <= 1) {return;} 11 | var baseForward = 270; 12 | var totalRad = durationRad * (nway - 1); 13 | var startRad = baseForward - totalRad / 2; 14 | var v = GameApp.getInstance().getCurrentView(); 15 | 16 | var z = GameManager.getInstance().zPosition; 17 | for (var i = 0; i < nway; i++) { 18 | var vx = Math.cos((startRad + durationRad * i) * (Math.PI / 180)) * speed; 19 | var vy = Math.sin((startRad + durationRad * i) * (Math.PI / 180)) * speed; 20 | var b = new BulletEnemy(vx, vy); 21 | b.setPosition(x, y, z); 22 | v.addMover(b); 23 | this.getBullets().push(b); 24 | } 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/game/ShooterSingle.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | class SingleShooter extends Shooter { 4 | 5 | constructor() { 6 | super(); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/game/Stage.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | class Stage extends Mover { 4 | 5 | constructor() { 6 | super(); 7 | } 8 | 9 | public init() { 10 | 11 | //create background 12 | //var pGeometry = new THREE.PlaneBufferGeometry(480, 1280); 13 | //var pMaterial = new THREE.MeshBasicMaterial({ 14 | // color: 0x999999, 15 | // side: THREE.DoubleSide, 16 | // wireframe:true 17 | //}); 18 | //this._obj = new THREE.Mesh(pGeometry, pMaterial); 19 | var geometry2 = new THREE.PlaneGeometry(480, 1280, 48, 128); 20 | var material2 = new THREE.MeshBasicMaterial({ color: 0x00FFFF, wireframe: true }); 21 | this._obj.add(new THREE.Mesh(geometry2, material2)); 22 | 23 | //var pn = new SimplexNoise(); 24 | //for (var i = 0; i < geometry2.vertices.length; i++) { 25 | // var vertex = geometry2.vertices[ i ]; 26 | // vertex.z = pn.noise(vertex.x /5 , vertex.y / 5); 27 | //} 28 | //geometry2.computeFaceNormals(); 29 | //geometry2.computeVertexNormals(); 30 | 31 | this._obj.position.set(0, 0, 0); 32 | this.vy = -1; 33 | } 34 | 35 | public destructor() { 36 | //todo implemation 37 | } 38 | 39 | public update() { 40 | this.y += this.vy; 41 | if (this.y <= -320) { 42 | this.y = 0; 43 | } 44 | this._obj.position.set(this.x, this.y, 0); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/game/TopView.ts: -------------------------------------------------------------------------------- 1 | class TopView extends CView { 2 | 3 | constructor() { 4 | super(); 5 | $("#view-top").show(); 6 | //this.resize(); 7 | 8 | //todo test 2d 9 | //THREE.ImageUtils.loadTexture("image/ui/title.png", undefined, (texture)=> { 10 | // texture.minFilter = THREE.NearestFilter; 11 | // var material = new THREE.SpriteMaterial({map: texture, color: 0xFFFFFF}); 12 | // var w = texture.image.width, h = texture.image.height; 13 | // texture.flipY = false; 14 | // var sprite = new THREE.Sprite(material); 15 | // sprite.position.set(window.innerWidth * 0.5, window.innerHeight * 0.5-100, -1); 16 | // sprite.scale.set(w, h, 1); 17 | // sprite.scale.y = h 18 | // this.add2d(sprite); 19 | //}) 20 | //THREE.ImageUtils.loadTexture("image/ui/press_space.png", undefined, (texture)=> { 21 | // texture.minFilter = THREE.NearestFilter; 22 | // var material = new THREE.SpriteMaterial({map: texture, color: 0xFFFFFF}); 23 | // var w = texture.image.width, h = texture.image.height; 24 | // texture.flipY = false; 25 | // var sprite = new THREE.Sprite(material); 26 | // sprite.position.set(window.innerWidth * 0.5, window.innerHeight * 0.5+100, -3); 27 | // sprite.scale.set(w, h, 1); 28 | // sprite.scale.y = h 29 | // this.add2d(sprite); 30 | //}) 31 | } 32 | 33 | public keyEvent(e: any) { 34 | switch (e.data.keyCode) { 35 | case 32: 36 | this.moveNextScene(); 37 | $("#view-top").hide(); 38 | break; 39 | } 40 | } 41 | 42 | public onMouseDown(e: any) { 43 | this.moveNextScene(); 44 | $("#view-top").hide(); 45 | } 46 | 47 | public moveNextScene() { 48 | $("#overlay").hide(); 49 | this.app.setView(new GameView()); 50 | } 51 | 52 | } 53 | --------------------------------------------------------------------------------