Browse files

Update build.

  • Loading branch information...
1 parent 636a9cd commit ab6809f1a713cfaf5162bfa2bb09a6aec0417dc7 @tapio committed Oct 24, 2013
Showing with 35 additions and 35 deletions.
  1. +35 −35 build/game.min.js
View
70 build/game.min.js
@@ -58,38 +58,38 @@ u.distance);c.position.copy(u.position),c.position.y=n.roomHeight,c.target.posit
n+"/"+n+".js",f(e,(new THREE.Vector3).copy(e.monsters[t].position),e.monsters[t].angle,assets.monsters[n]),a+n)}},this.getTriggerAt=function(e){if(!this.level||!this.level.triggers)return!1;var t=this.level.triggers;for(var n=0;n<t.length;++n)if(Math.abs(e.x-t[n].position.x*this.level.gridSize)<=1&&Math.abs(e.z-t[n].position.z*this.level.gridSize)<=1)return t[n]},this.isAtExit=function(e){return this.level&&Math.abs(e.x-this.level.exit[0]*this.level.gridSize)<.5*this.level.gridSize&&Math.abs(e.z-this.level.exit
[1]*this.level.gridSize)<.5*this.level.gridSize},n=n||hashParams.level||"01-intro";if(n=="rand"){var c=new MapGen;l(c.generate())}else if(n.length>24){var h=window.atob(n);l(JSON.parse(h))}else $.get("assets/levels/"+n+".json",l);this.serialize=function(){return JSON.stringify(this.level)},this.ready=function(e){this.onLoad===!0?e():this.onLoad=e}}function initUI(){var e=document.getElementById("container");e.appendChild(renderer.domElement),renderStats=new Stats,renderStats.domElement.style.position="absolute"
,renderStats.domElement.style.bottom="0px",e.appendChild(renderStats.domElement),physicsStats=new Stats,physicsStats.domElement.style.position="absolute",physicsStats.domElement.style.bottom="0px",physicsStats.domElement.style.left="85px",e.appendChild(physicsStats.domElement),CONFIG.showStats||(renderStats.domElement.style.display="none",physicsStats.domElement.style.display="none"),rendererInfo=document.getElementById("renderer-info"),e.requestPointerLock=e.requestPointerLock||e.mozRequestPointerLock||e.webkitRequestPointerLock
-,e.requestFullscreen=e.requestFullscreen||e.mozRequestFullscreen||e.mozRequestFullScreen||e.webkitRequestFullscreen,$(window).resize(onWindowResize),$(window).blur(pause),$(window).focus(resume),$("#instructions").click(function(){if(CONFIG.fullscreen||/Firefox/i.test(navigator.userAgent)){var t=function(n){if(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullscreenElement||document.mozFullScreenElement)document.removeEventListener("fullscreenchange",t),document.removeEventListener
-("mozfullscreenchange",t),document.removeEventListener("webkitfullscreenchange",t),e.requestPointerLock()};document.addEventListener("fullscreenchange",t,!1),document.addEventListener("mozfullscreenchange",t,!1),document.addEventListener("webkitfullscreenchange",t,!1),e.requestFullscreen()}else e.requestPointerLock()}),document.addEventListener("pointerlockchange",onPointerLockChange,!1),document.addEventListener("webkitpointerlockchange",onPointerLockChange,!1),document.addEventListener("mozpointerlockchange"
-,onPointerLockChange,!1),$("#instructions").show(),dat.GUI.TEXT_CLOSED="Close Options",dat.GUI.TEXT_OPEN="Options";var t=new dat.GUI;t.add(CONFIG,"fullscreen").onChange(updateConfig),t.add(CONFIG,"resolution",.1,1).step(.1).onChange(function(){updateConfig(),onWindowResize()}),t.add(CONFIG,"physicsFPS",30,100).step(10).onChange(updateConfig),t.add(CONFIG,"showStats").onChange(updateConfig),t.add(controls,"mouseFallback"),t.add(window,"editLevel");var n=t.addFolder("Audio");n.add(CONFIG,"sounds").onChange(updateConfig
-),n.add(CONFIG,"music").onChange(function(){CONFIG.music?soundManager.playMusic("dark-ambiance-01"):soundManager.stopMusic(),updateConfig()});var r=t.addFolder("Renderer options (reload required)");r.add(CONFIG,"antialias").onChange(updateConfig),r.add(CONFIG,"physicalShading").onChange(updateConfig),r.add(CONFIG,"normalMapping").onChange(updateConfig),r.add(CONFIG,"specularMapping").onChange(updateConfig),r.add(CONFIG,"particles").onChange(updateConfig),r.add(window,"reload");var i=t.addFolder("Light and shadow"
-);i.add(CONFIG,"maxLights",0,6).step(1).onChange(updateConfig),i.add(CONFIG,"maxShadows",0,6).step(1).onChange(updateConfig),i.add(CONFIG,"shadows").onChange(updateMaterials),i.add(CONFIG,"softShadows").onChange(updateMaterials);var s=t.addFolder("Texture options");s.add(CONFIG,"textureQuality",0,2).step(1).onChange(updateConfig),s.add(CONFIG,"anisotropy",1,renderer.getMaxAnisotropy()).step(1).onChange(updateTextures),s.add(CONFIG,"linearTextureFilter").onChange(updateTextures);var o=t.addFolder("Post-processing"
-);o.add(CONFIG,"postprocessing").onChange(updateConfig),o.add(CONFIG,"SSAO").onChange(updateConfig),o.add(CONFIG,"FXAA").onChange(updateConfig),o.add(CONFIG,"bloom").onChange(updateConfig),t.close()}function updateHUD(){$("#health").html(pl.hp),$("#bullets").html(pl.bullets),$("#clips").html(pl.clips)}function displayMessage(e){var t=$("#message");messageTimer&&window.clearTimeout(messageTimer),t.is(":visible")&&t.stop(!0,!0).hide(),t.html(e).fadeIn(2e3),messageTimer=window.setTimeout(function(){t.fadeOut(5e3
-),messageTimer=null},3e3)}function displayMinorMessage(e){var t=$("#minor-messages");t.is(":visible")||t.html(""),t.stop(!0,!0),t.prepend(e+"<br/>").show().fadeOut(5e3)}function editLevel(){var e="editor/index.html#level="+window.btoa(dungeon.serialize());window.open(e,"_blank")}function onWindowResize(){var e=CONFIG.resolution;pl.camera.aspect=window.innerWidth/window.innerHeight,pl.camera.updateProjectionMatrix(),renderer.setSize(window.innerWidth*e,window.innerHeight*e),colorTarget=new THREE.WebGLRenderTarget
-(window.innerWidth*e,window.innerHeight*e,renderTargetParametersRGB),composer.reset(colorTarget),depthTarget=new THREE.WebGLRenderTarget(window.innerWidth*e,window.innerHeight*e,renderTargetParametersRGBA),depthPassPlugin.renderTarget=depthTarget,passes.ssao.uniforms.tDepth.value=depthTarget,passes.ssao.uniforms.size.value.set(window.innerWidth*e,window.innerHeight*e),passes.fxaa.uniforms.resolution.value.set(e/window.innerWidth,e/window.innerHeight),controls.handleResize()}function onPointerLockChange(){document
-.pointerLockElement||document.mozPointerLockElement||document.webkitPointerLockElement?(controls.pointerLockEnabled=!0,$("#instructions").hide()):(controls.pointerLockEnabled=!1,pl.dead||$("#instructions").show())}function pause(){controls.active=!1}function resume(){controls.active=!0}function reload(){updateConfig(),window.location.reload()}function init(){scene=new Physijs.Scene({fixedTimeStep:1/CONFIG.physicsFPS}),scene.setGravity(new THREE.Vector3(0,-10,0)),scene.fog=new THREE.FogExp2(0,.05),scene.addEventListener
-("update",function(){CONFIG.showStats&&physicsStats.update()}),pl=new Physijs.CapsuleMesh(new THREE.CylinderGeometry(.8,.8,2),new THREE.MeshBasicMaterial({color:16711935}),100),pl.visible=!1,pl.addEventListener("collision",function(e,t,n){if(this.dead)return;if(e.items){for(var r in e.items)pl[r]!==undefined&&(typeof e.items[r]=="number"?pl[r]+=e.items[r]:pl[r]=e.items[r]);soundManager.play("pick-up"),displayMinorMessage("Picked up "+e.itemName),updateHUD(),e.items=undefined,e.visible=!1,e.parent.remove(e)}e
-.damage&&e.position.y>.3&&pl.faction!=e.faction&&(this.hp-=e.damage,updateHUD())});var e={};hashParams.level&&localStorage.getItem("campaingState-"+hashParams.level)?(e=JSON.parse(localStorage.getItem("campaingState-"+hashParams.level)),pl.hp=e.hp,pl.bulletsPerClip=e.bulletsPerClip,pl.bullets=e.bullets,pl.clips=e.clips,pl.ammoType=e.ammoType||"plain"):(pl.hp=100,pl.bulletsPerClip=15,pl.bullets=pl.bulletsPerClip,pl.clips=5,pl.ammoType="plain"),pl.reloading=!1,pl.faction=0,updateHUD(),pl.camera=new THREE.PerspectiveCamera
-(60,window.innerWidth/window.innerHeight,.1,25),controls=new Controls(pl.camera,{mouse:mouseHandler}),controls.movementSpeed=10,controls.lookSpeed=.5,controls.lookVertical=!0,controls.constrainVerticalLook=!0,controls.verticalMin=1.1,controls.verticalMax=2.2,renderer=new THREE.WebGLRenderer({clearColor:0,maxLights:CONFIG.maxLights+2,antialias:CONFIG.antialias,preserveDrawingBuffer:!0}),renderer.setSize(window.innerWidth,window.innerHeight),renderer.shadowMapEnabled=CONFIG.shadows,renderer.shadowMapSoft=CONFIG
-.softShadows,renderer.shadowMapDebug=!1,renderer.gammaInput=!0,renderer.gammaOutput=!0,renderer.physicallyBasedShading=CONFIG.physicalShading,renderer.autoClear=!1,CONFIG.anisotropy||(CONFIG.anisotropy=renderer.getMaxAnisotropy()),renderTargetParametersRGB={minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBFormat},renderTargetParametersRGBA={minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat},depthTarget=new THREE.WebGLRenderTarget(window.innerWidth,window
-.innerHeight,renderTargetParametersRGBA),colorTarget=new THREE.WebGLRenderTarget(window.innerWidth,window.innerHeight,renderTargetParametersRGB),passes.scene=new THREE.RenderPass(scene,pl.camera),passes.ssao=new THREE.ShaderPass(THREE.ShaderExtras.ssao),passes.ssao.uniforms.tDepth.value=depthTarget,passes.ssao.uniforms.size.value.set(window.innerWidth,window.innerHeight),passes.ssao.uniforms.cameraNear.value=pl.camera.near,passes.ssao.uniforms.cameraFar.value=pl.camera.far,passes.ssao.uniforms.fogNear.value=
-scene.fog.near,passes.ssao.uniforms.fogFar.value=scene.fog.far,passes.ssao.uniforms.fogEnabled.value=0,passes.ssao.uniforms.aoClamp.value=.4,passes.ssao.uniforms.onlyAO.value=0,passes.fxaa=new THREE.ShaderPass(THREE.ShaderExtras.fxaa),passes.fxaa.uniforms.resolution.value.set(1/window.innerWidth,1/window.innerHeight),passes.bloom=new THREE.BloomPass(.5),passes.adjust=new THREE.ShaderPass(THREE.ShaderExtras.hueSaturation),passes.adjust.uniforms.saturation.value=.2,composer=new THREE.EffectComposer(renderer,colorTarget
-),composer.addPass(passes.ssao),composer.addPass(passes.fxaa),composer.addPass(passes.bloom),composer.addPass(passes.adjust),composer.passes[composer.passes.length-1].renderToScreen=!0,depthPassPlugin=new THREE.DepthPassPlugin,depthPassPlugin.renderTarget=depthTarget,renderer.addPrePlugin(depthPassPlugin),CONFIG.resolution!=1&&onWindowResize(),resetLevel(),updateConfig(),dumpInfo(),initUI()}function resetLevel(e){if(e=="[credits]"){window.location="credits.html";return}dungeon&&(e&&(window.location.hash="#level="+
-e),window.location.reload(!0)),lightManager=new LightManager({maxLights:CONFIG.maxLights,maxShadows:CONFIG.maxShadows}),animationManager=new AnimationManager,soundManager=new SoundManager,aiManager=new AIManager,dungeon=new Dungeon(scene,pl,e),CONFIG.music&&soundManager.playMusic("dark-ambiance-01")}function savePlayerState(e){if(!e||e=="[credits]")return;var t={hp:pl.hp,bulletsPerClip:pl.bulletsPerClip,bullets:pl.bullets,clips:pl.clips,ammoType:pl.ammoType};localStorage.setItem("campaingState-"+e,JSON.stringify
-(t))}function shoot(e,t,n,r,i){var s=dungeon.forks[dungeon.forkIndex];dungeon.forkIndex=(dungeon.forkIndex+1)%dungeon.forks.length,s.position.copy(e.matrixWorld.getPosition()),soundManager.playSpatial("shoot",s.position,20),s.matrixRotationWorld.extractRotation(e.matrixWorld),i&&s.matrixRotationWorld.rotateY(Math.PI),s.rotation.setEulerFromRotationMatrix(s.matrixRotationWorld),s.updateMatrix(),s.matrixRotationWorld.multiplyVector3(shootVector.set(0,0,1)),s.translateX(r.x),s.translateY(r.y),s.translateZ(r.z),
-s.__dirtyPosition=!0,s.__dirtyRotation=!0;var o=e.parent instanceof THREE.Scene?e:e.parent;s.setLinearVelocity(shootVector.multiplyScalar(25).addSelf(o.getLinearVelocity())),s.damage=dungeon.forkTypes[t].damage,s.material=dungeon.forkTypes[t].material,s.faction=n,s.visible=!0}function reload(){if(pl.reloading||pl.bullets>=pl.bulletsPerClip)return;if(pl.clips<=0){displayMinorMessage("Out of ammo");return}pl.reloading=!0,window.setTimeout(function(){pl.bullets=pl.bulletsPerClip,--pl.clips,updateHUD(),pl.reloading=!1
-,pl.rhand.material.materials[2]=pl.rhand.ammoGood,pl.rhand.materialNeedsUpdate=!0},2e3),soundManager.play("reload")}function mouseHandler(e){if(e==0&&pl.rhand&&pl.bullets<=0&&!pl.reloading)soundManager.play("shoot-dry"),reload();else if(e==0&&pl.rhand&&pl.bullets>0&&!pl.reloading)--pl.bullets,pl.bullets<=0&&(pl.rhand.material.materials[2]=pl.rhand.ammoOut,pl.rhand.materialNeedsUpdate=!0),shoot(pl.rhand,pl.ammoType,pl.faction,{x:0,y:.11,z:1},!0),updateHUD();else if(e==2){shootVector.set(0,0,1),projector.unprojectVector
-(shootVector,pl.camera);var t=new THREE.Ray(pl.camera.position,shootVector.subSelf(pl.camera.position).normalize()),n=t.intersectObjects(dungeon.objects);if(n.length>0){var r=n[0].object;r.position.distanceToSquared(pl.position)<9&&r.applyCentralImpulse(shootVector.multiplyScalar(1e4))}}}function animate(e){function t(e){return Math.abs(e-(e|0)-.5)*2}function n(e){return e-(e|0)}var r,i=new THREE.Vector3;animationManager.update(e);var s=(new Date).getTime();for(r=0;r<lightManager.lights.length;++r){var o=lightManager
-.lights[r];o.visible&&o.emitter&&o.emitter.update(e).render()}dungeon.exitParticles&&dungeon.exitParticles.update(e).render(),pl.light.position.set(pl.position.x,pl.position.y+.2,pl.position.z),pl.shadow.position.copy(pl.light.position),pl.shadow.target.position.copy(controls.target)}Detector.webgl||(Detector.addGetWebGLMessage(),document.getElementById("container").innerHTML=""),Physijs.scripts.worker="libs/physijs_worker.js",Physijs.scripts.ammo="../libs/ammo.js";var hashParams=function(){var e={},t,n=window
-.location.hash.replace("#","").split("&");for(var r=0;r<n.length;++r)t=n[r].split("="),e[t[0]]=t[1];return e}(),CONFIG={fullscreen:!1,showStats:!1,resolution:1,physicsFPS:60,sounds:!0,music:!0,postprocessing:!0,particles:!0,maxLights:4,maxShadows:2,antialias:!0,anisotropy:0,shadows:!0,softShadows:!0,physicalShading:!0,normalMapping:!0,specularMapping:!0,linearTextureFilter:!0,bloom:!0,SSAO:!0,FXAA:!1,textureQuality:2},updateConfig=function(){lightManager.maxLights=CONFIG.maxLights,lightManager.maxShadows=CONFIG
-.maxShadows,renderer.shadowMapEnabled=CONFIG.shadows,renderer.shadowMapSoft=CONFIG.softShadows,renderer.physicallyBasedShading=CONFIG.physicalShading,passes.bloom.enabled=CONFIG.bloom,passes.ssao.enabled=CONFIG.SSAO,passes.fxaa.enabled=CONFIG.FXAA,scene.setFixedTimeStep(1/CONFIG.physicsFPS);var e=CONFIG.showStats?"block":"none";renderStats&&(renderStats.domElement.style.display=e),physicsStats&&(physicsStats.domElement.style.display=e),rendererInfo&&(rendererInfo.style.display=e),localStorage.setItem("CONFIG"
-,JSON.stringify(CONFIG))};(function(){var e=localStorage.getItem("CONFIG");if(e){e=JSON.parse(e);for(var t in e)e.hasOwnProperty(t)&&typeof e[t]!="function"&&(CONFIG[t]=e[t])}})(),"use strict","use strict",PlaneGeometry.prototype=Object.create(THREE.Geometry.prototype),"use strict",BlockGeometry.prototype=Object.create(THREE.Geometry.prototype),"use strict",AnimationManager.prototype.createAnimatedMesh=function(e,t,n){var r;for(var i=0;i<t.length;++i)n.animation.type==="morph"?(t[i].morphTargets=!0,t[i].morphNormals=!0
-):n.animation.type==="bones"&&(t[i].skinning=!0);var s=t.length>1?new THREE.MeshFaceMaterial(t):t[0];return n.animation.type==="morph"?(e.computeMorphNormals(),r=new THREE.MorphAnimMesh(e,s),r.duration=n.animation.duration,r.time=r.duration*Math.random()):n.animation.type==="bones"&&(r=new THREE.SkinnedMesh(e,s),THREE.AnimationHandler.add(e.animation),r.animation=new THREE.Animation(r,"walk")),this.anims.push(r),r},AnimationManager.prototype.update=function(e){for(var t=0;t<this.anims.length;++t){var n=this.
-anims[t];n.animation&&(!n.animation.isPlaying&&n.animate?n.animation.play():n.animation.isPlaying&&!n.animate&&n.animation.stop());if(n.dead)continue;n.updateAnimation&&n.animate&&n.updateAnimation(e*1e3)}THREE.AnimationHandler.update(e*1e3)},"use strict";var _textures=[],performance=window.performance||{};performance.now=function(){return performance.now||performance.mozNow||performance.msNow||performance.oNow||performance.webkitNow||function(){return(new Date).getTime()}}(),"use strict";var _novaTexture=null
-,_fireTexture=null;"use strict";var assets={objects:{"barrel-blue":{collision:"cylinder",mass:250,sound:"metal"},"barrel-red":{collision:"cylinder",mass:250,sound:"metal"},"barrel-rusty":{collision:"cylinder",mass:250,sound:"metal"},"gas-tank":{collision:"cylinder",mass:350,sound:"metal"},"military-box":{collision:"box",mass:200,sound:"metal"},trash:{collision:"box",mass:150},turbine:{collision:"box",sound:"metal"}},items:{"ammo-box":{name:"ammo",collision:"box",mass:250,sound:"metal",item:{type:"clips",value
-:2}},"health-box":{name:"health pack",collision:"box",mass:250,sound:"metal",item:{type:"hp",value:25}},"heated-forks-box":{name:"heated forks ammo upgrade",collision:"box",mass:150,item:{type:"ammoType",value:"heated"}},"plasma-forks-box":{name:"plasma forks ammo upgrade",collision:"box",mass:150,item:{type:"ammoType",value:"plasma"}}},monsters:{robot:{collision:"capsule",character:{speed:4,hp:50},animation:{type:"morph",duration:"750"},sound:"metal"}},lights:{"ceiling-lamp":{type:"ceiling",offset:{x:0,y:-0.2
-,z:0}}},sounds:{shoot:["fork-launch.ogg"],"shoot-dry":["empty-gun.ogg"],reload:["reload.ogg"],"pick-up":["pick-up.ogg"],metal:["metal-1.ogg","metal-2.ogg","metal-3.ogg"],"robot-death":["robot-death.ogg"]},materials:{"metal-01":{repeat:4},"metal-02":{},"metal-03":{},"metal-bumps-01":{repeat:2},"metal-bumps-02":{},"metal-bumps-03":{},"metal-colored-01":{},"metal-colored-02":{repeat:2},"metal-colored-03":{},"metal-colored-04":{},"metal-colored-05":{},"metal-colored-06":{},"metal-colored-07":{},"metal-colored-08"
-:{repeat:2},"metal-colored-09":{},"metal-corrugated-01":{repeat:2},"metal-corrugated-02":{},"metal-worn-01":{},"metal-worn-02":{}},environments:{}};"use strict";var VOID=" ",OPEN=".",WALL="#",DIAG="%";"use strict","use strict","use strict";var renderStats,physicsStats,rendererInfo,messageTimer=null;"use strict";var pl,controls,scene,renderer,composer,renderTargetParametersRGBA,renderTargetParametersRGB,colorTarget,depthTarget,depthPassPlugin,lightManager,animationManager,soundManager,aiManager,dungeon,projector=new
-THREE.Projector,clock=new THREE.Clock,cache=new Cache,passes={},shootVector=new THREE.Vector3;$(document).ready(function(){function n(e){var t=["Prog:",e.memory.programs,"Geom:",e.memory.geometries,"Tex:",e.memory.textures,"Calls:",e.render.calls,"Verts:",e.render.vertices,"Faces:",e.render.faces,"Pts:",e.render.points];return t.join(" ")}function r(){requestAnimationFrame(r);if(pl.dead)return;var i=clock.getDelta();i>.05&&(i=.05),e.set(pl.camera.position.x,0,pl.camera.position.z),controls.update(i),t.set(pl
-.camera.position.x,0,pl.camera.position.z),t.subSelf(e),t.divideScalar(i);var s=pl.getLinearVelocity().y;pl.setLinearVelocity({x:t.x,y:s<0?s:0,z:t.z}),scene.simulate(),controls.object.position.set(pl.position.x,pl.position.y+.5,pl.position.z),pl.rotation.copy(pl.camera.rotation),pl.__dirtyRotation=!0,animate(i),renderer.clear(),CONFIG.postprocessing?(renderer.shadowMapEnabled=CONFIG.shadows,depthPassPlugin.enabled=!0,renderer.render(scene,pl.camera,composer.renderTarget2,!0),CONFIG.showStats&&(rendererInfo.innerHTML=
-n(renderer.info)),renderer.shadowMapEnabled=!1,depthPassPlugin.enabled=!1,composer.render(i)):(renderer.render(scene,pl.camera),CONFIG.showStats&&(rendererInfo.innerHTML=n(renderer.info))),CONFIG.showStats&&renderStats.update()}var e=new THREE.Vector3,t=new THREE.Vector3;init(),dungeon.ready(function(){window.setInterval(function(){lightManager.update(pl)},690),window.setInterval(function(){pl.dead||aiManager.process()},100),window.setInterval(function(){!pl.dead&&pl.hp<=0&&(pl.dead=!0,controls.active=!1,$("#deathscreen"
-).is(":visible")||$("#deathscreen").fadeIn(500),$("#instructions").hide());var e=dungeon.getTriggerAt(pl.position);e&&e.type=="message"&&displayMessage(e.message),dungeon.isAtExit(pl.position)&&(savePlayerState(dungeon.level.next),resetLevel(dungeon.level.next))},45),r()})});
+,e.requestFullscreen=e.requestFullscreen||e.mozRequestFullscreen||e.mozRequestFullScreen||e.webkitRequestFullscreen,$(window).resize(onWindowResize),$(window).blur(pause),$(window).focus(resume),$("#instructions").click(function(){if(CONFIG.fullscreen){var t=function(n){if(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullscreenElement||document.mozFullScreenElement)document.removeEventListener("fullscreenchange",t),document.removeEventListener("mozfullscreenchange",t),document.removeEventListener
+("webkitfullscreenchange",t),e.requestPointerLock()};document.addEventListener("fullscreenchange",t,!1),document.addEventListener("mozfullscreenchange",t,!1),document.addEventListener("webkitfullscreenchange",t,!1),e.requestFullscreen()}else e.requestPointerLock()}),document.addEventListener("pointerlockchange",onPointerLockChange,!1),document.addEventListener("webkitpointerlockchange",onPointerLockChange,!1),document.addEventListener("mozpointerlockchange",onPointerLockChange,!1),$("#instructions").show(),dat
+.GUI.TEXT_CLOSED="Close Options",dat.GUI.TEXT_OPEN="Options";var t=new dat.GUI;t.add(CONFIG,"fullscreen").onChange(updateConfig),t.add(CONFIG,"resolution",.1,1).step(.1).onChange(function(){updateConfig(),onWindowResize()}),t.add(CONFIG,"physicsFPS",30,100).step(10).onChange(updateConfig),t.add(CONFIG,"showStats").onChange(updateConfig),t.add(controls,"mouseFallback"),t.add(window,"editLevel");var n=t.addFolder("Audio");n.add(CONFIG,"sounds").onChange(updateConfig),n.add(CONFIG,"music").onChange(function(){CONFIG
+.music?soundManager.playMusic("dark-ambiance-01"):soundManager.stopMusic(),updateConfig()});var r=t.addFolder("Renderer options (reload required)");r.add(CONFIG,"antialias").onChange(updateConfig),r.add(CONFIG,"physicalShading").onChange(updateConfig),r.add(CONFIG,"normalMapping").onChange(updateConfig),r.add(CONFIG,"specularMapping").onChange(updateConfig),r.add(CONFIG,"particles").onChange(updateConfig),r.add(window,"reload");var i=t.addFolder("Light and shadow");i.add(CONFIG,"maxLights",0,6).step(1).onChange
+(updateConfig),i.add(CONFIG,"maxShadows",0,6).step(1).onChange(updateConfig),i.add(CONFIG,"shadows").onChange(updateMaterials),i.add(CONFIG,"softShadows").onChange(updateMaterials);var s=t.addFolder("Texture options");s.add(CONFIG,"textureQuality",0,2).step(1).onChange(updateConfig),s.add(CONFIG,"anisotropy",1,renderer.getMaxAnisotropy()).step(1).onChange(updateTextures),s.add(CONFIG,"linearTextureFilter").onChange(updateTextures);var o=t.addFolder("Post-processing");o.add(CONFIG,"postprocessing").onChange(updateConfig
+),o.add(CONFIG,"SSAO").onChange(updateConfig),o.add(CONFIG,"FXAA").onChange(updateConfig),o.add(CONFIG,"bloom").onChange(updateConfig),t.close()}function updateHUD(){$("#health").html(pl.hp),$("#bullets").html(pl.bullets),$("#clips").html(pl.clips)}function displayMessage(e){var t=$("#message");messageTimer&&window.clearTimeout(messageTimer),t.is(":visible")&&t.stop(!0,!0).hide(),t.html(e).fadeIn(2e3),messageTimer=window.setTimeout(function(){t.fadeOut(5e3),messageTimer=null},3e3)}function displayMinorMessage
+(e){var t=$("#minor-messages");t.is(":visible")||t.html(""),t.stop(!0,!0),t.prepend(e+"<br/>").show().fadeOut(5e3)}function editLevel(){var e="editor/index.html#level="+window.btoa(dungeon.serialize());window.open(e,"_blank")}function onWindowResize(){var e=CONFIG.resolution;pl.camera.aspect=window.innerWidth/window.innerHeight,pl.camera.updateProjectionMatrix(),renderer.setSize(window.innerWidth*e,window.innerHeight*e),colorTarget=new THREE.WebGLRenderTarget(window.innerWidth*e,window.innerHeight*e,renderTargetParametersRGB
+),composer.reset(colorTarget),depthTarget=new THREE.WebGLRenderTarget(window.innerWidth*e,window.innerHeight*e,renderTargetParametersRGBA),depthPassPlugin.renderTarget=depthTarget,passes.ssao.uniforms.tDepth.value=depthTarget,passes.ssao.uniforms.size.value.set(window.innerWidth*e,window.innerHeight*e),passes.fxaa.uniforms.resolution.value.set(e/window.innerWidth,e/window.innerHeight),controls.handleResize()}function onPointerLockChange(){document.pointerLockElement||document.mozPointerLockElement||document.
+webkitPointerLockElement?(controls.pointerLockEnabled=!0,$("#instructions").hide()):(controls.pointerLockEnabled=!1,pl.dead||$("#instructions").show())}function pause(){controls.active=!1}function resume(){controls.active=!0}function reload(){updateConfig(),window.location.reload()}function init(){scene=new Physijs.Scene({fixedTimeStep:1/CONFIG.physicsFPS}),scene.setGravity(new THREE.Vector3(0,-10,0)),scene.fog=new THREE.FogExp2(0,.05),scene.addEventListener("update",function(){CONFIG.showStats&&physicsStats
+.update()}),pl=new Physijs.CapsuleMesh(new THREE.CylinderGeometry(.8,.8,2),new THREE.MeshBasicMaterial({color:16711935}),100),pl.visible=!1,pl.addEventListener("collision",function(e,t,n){if(this.dead)return;if(e.items){for(var r in e.items)pl[r]!==undefined&&(typeof e.items[r]=="number"?pl[r]+=e.items[r]:pl[r]=e.items[r]);soundManager.play("pick-up"),displayMinorMessage("Picked up "+e.itemName),updateHUD(),e.items=undefined,e.visible=!1,e.parent.remove(e)}e.damage&&e.position.y>.3&&pl.faction!=e.faction&&(this
+.hp-=e.damage,updateHUD())});var e={};hashParams.level&&localStorage.getItem("campaingState-"+hashParams.level)?(e=JSON.parse(localStorage.getItem("campaingState-"+hashParams.level)),pl.hp=e.hp,pl.bulletsPerClip=e.bulletsPerClip,pl.bullets=e.bullets,pl.clips=e.clips,pl.ammoType=e.ammoType||"plain"):(pl.hp=100,pl.bulletsPerClip=15,pl.bullets=pl.bulletsPerClip,pl.clips=5,pl.ammoType="plain"),pl.reloading=!1,pl.faction=0,updateHUD(),pl.camera=new THREE.PerspectiveCamera(60,window.innerWidth/window.innerHeight,.1
+,25),controls=new Controls(pl.camera,{mouse:mouseHandler}),controls.movementSpeed=10,controls.lookSpeed=.5,controls.lookVertical=!0,controls.constrainVerticalLook=!0,controls.verticalMin=1.1,controls.verticalMax=2.2,renderer=new THREE.WebGLRenderer({clearColor:0,maxLights:CONFIG.maxLights+2,antialias:CONFIG.antialias,preserveDrawingBuffer:!0}),renderer.setSize(window.innerWidth,window.innerHeight),renderer.shadowMapEnabled=CONFIG.shadows,renderer.shadowMapSoft=CONFIG.softShadows,renderer.shadowMapDebug=!1,renderer
+.gammaInput=!0,renderer.gammaOutput=!0,renderer.physicallyBasedShading=CONFIG.physicalShading,renderer.autoClear=!1,CONFIG.anisotropy||(CONFIG.anisotropy=renderer.getMaxAnisotropy()),renderTargetParametersRGB={minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBFormat},renderTargetParametersRGBA={minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat},depthTarget=new THREE.WebGLRenderTarget(window.innerWidth,window.innerHeight,renderTargetParametersRGBA),colorTarget=new
+THREE.WebGLRenderTarget(window.innerWidth,window.innerHeight,renderTargetParametersRGB),passes.scene=new THREE.RenderPass(scene,pl.camera),passes.ssao=new THREE.ShaderPass(THREE.ShaderExtras.ssao),passes.ssao.uniforms.tDepth.value=depthTarget,passes.ssao.uniforms.size.value.set(window.innerWidth,window.innerHeight),passes.ssao.uniforms.cameraNear.value=pl.camera.near,passes.ssao.uniforms.cameraFar.value=pl.camera.far,passes.ssao.uniforms.fogNear.value=scene.fog.near,passes.ssao.uniforms.fogFar.value=scene.fog
+.far,passes.ssao.uniforms.fogEnabled.value=0,passes.ssao.uniforms.aoClamp.value=.4,passes.ssao.uniforms.onlyAO.value=0,passes.fxaa=new THREE.ShaderPass(THREE.ShaderExtras.fxaa),passes.fxaa.uniforms.resolution.value.set(1/window.innerWidth,1/window.innerHeight),passes.bloom=new THREE.BloomPass(.5),passes.adjust=new THREE.ShaderPass(THREE.ShaderExtras.hueSaturation),passes.adjust.uniforms.saturation.value=.2,composer=new THREE.EffectComposer(renderer,colorTarget),composer.addPass(passes.ssao),composer.addPass(
+passes.fxaa),composer.addPass(passes.bloom),composer.addPass(passes.adjust),composer.passes[composer.passes.length-1].renderToScreen=!0,depthPassPlugin=new THREE.DepthPassPlugin,depthPassPlugin.renderTarget=depthTarget,renderer.addPrePlugin(depthPassPlugin),CONFIG.resolution!=1&&onWindowResize(),resetLevel(),updateConfig(),dumpInfo(),initUI()}function resetLevel(e){if(e=="[credits]"){window.location="credits.html";return}dungeon&&(e&&(window.location.hash="#level="+e),window.location.reload(!0)),lightManager=new
+LightManager({maxLights:CONFIG.maxLights,maxShadows:CONFIG.maxShadows}),animationManager=new AnimationManager,soundManager=new SoundManager,aiManager=new AIManager,dungeon=new Dungeon(scene,pl,e),CONFIG.music&&soundManager.playMusic("dark-ambiance-01")}function savePlayerState(e){if(!e||e=="[credits]")return;var t={hp:pl.hp,bulletsPerClip:pl.bulletsPerClip,bullets:pl.bullets,clips:pl.clips,ammoType:pl.ammoType};localStorage.setItem("campaingState-"+e,JSON.stringify(t))}function shoot(e,t,n,r,i){var s=dungeon
+.forks[dungeon.forkIndex];dungeon.forkIndex=(dungeon.forkIndex+1)%dungeon.forks.length,s.position.copy(e.matrixWorld.getPosition()),soundManager.playSpatial("shoot",s.position,20),s.matrixRotationWorld.extractRotation(e.matrixWorld),i&&s.matrixRotationWorld.rotateY(Math.PI),s.rotation.setEulerFromRotationMatrix(s.matrixRotationWorld),s.updateMatrix(),s.matrixRotationWorld.multiplyVector3(shootVector.set(0,0,1)),s.translateX(r.x),s.translateY(r.y),s.translateZ(r.z),s.__dirtyPosition=!0,s.__dirtyRotation=!0;var o=
+e.parent instanceof THREE.Scene?e:e.parent;s.setLinearVelocity(shootVector.multiplyScalar(25).addSelf(o.getLinearVelocity())),s.damage=dungeon.forkTypes[t].damage,s.material=dungeon.forkTypes[t].material,s.faction=n,s.visible=!0}function reload(){if(pl.reloading||pl.bullets>=pl.bulletsPerClip)return;if(pl.clips<=0){displayMinorMessage("Out of ammo");return}pl.reloading=!0,window.setTimeout(function(){pl.bullets=pl.bulletsPerClip,--pl.clips,updateHUD(),pl.reloading=!1,pl.rhand.material.materials[2]=pl.rhand.ammoGood
+,pl.rhand.materialNeedsUpdate=!0},2e3),soundManager.play("reload")}function mouseHandler(e){if(e==0&&pl.rhand&&pl.bullets<=0&&!pl.reloading)soundManager.play("shoot-dry"),reload();else if(e==0&&pl.rhand&&pl.bullets>0&&!pl.reloading)--pl.bullets,pl.bullets<=0&&(pl.rhand.material.materials[2]=pl.rhand.ammoOut,pl.rhand.materialNeedsUpdate=!0),shoot(pl.rhand,pl.ammoType,pl.faction,{x:0,y:.11,z:1},!0),updateHUD();else if(e==2){shootVector.set(0,0,1),projector.unprojectVector(shootVector,pl.camera);var t=new THREE
+.Ray(pl.camera.position,shootVector.subSelf(pl.camera.position).normalize()),n=t.intersectObjects(dungeon.objects);if(n.length>0){var r=n[0].object;r.position.distanceToSquared(pl.position)<9&&r.applyCentralImpulse(shootVector.multiplyScalar(1e4))}}}function animate(e){function t(e){return Math.abs(e-(e|0)-.5)*2}function n(e){return e-(e|0)}var r,i=new THREE.Vector3;animationManager.update(e);var s=(new Date).getTime();for(r=0;r<lightManager.lights.length;++r){var o=lightManager.lights[r];o.visible&&o.emitter&&
+o.emitter.update(e).render()}dungeon.exitParticles&&dungeon.exitParticles.update(e).render(),pl.light.position.set(pl.position.x,pl.position.y+.2,pl.position.z),pl.shadow.position.copy(pl.light.position),pl.shadow.target.position.copy(controls.target)}Detector.webgl||(Detector.addGetWebGLMessage(),document.getElementById("container").innerHTML=""),Physijs.scripts.worker="libs/physijs_worker.js",Physijs.scripts.ammo="../libs/ammo.js";var hashParams=function(){var e={},t,n=window.location.hash.replace("#","").
+split("&");for(var r=0;r<n.length;++r)t=n[r].split("="),e[t[0]]=t[1];return e}(),CONFIG={fullscreen:!1,showStats:!1,resolution:1,physicsFPS:60,sounds:!0,music:!0,postprocessing:!0,particles:!0,maxLights:4,maxShadows:2,antialias:!0,anisotropy:0,shadows:!0,softShadows:!0,physicalShading:!0,normalMapping:!0,specularMapping:!0,linearTextureFilter:!0,bloom:!0,SSAO:!0,FXAA:!1,textureQuality:2},updateConfig=function(){lightManager.maxLights=CONFIG.maxLights,lightManager.maxShadows=CONFIG.maxShadows,renderer.shadowMapEnabled=
+CONFIG.shadows,renderer.shadowMapSoft=CONFIG.softShadows,renderer.physicallyBasedShading=CONFIG.physicalShading,passes.bloom.enabled=CONFIG.bloom,passes.ssao.enabled=CONFIG.SSAO,passes.fxaa.enabled=CONFIG.FXAA,scene.setFixedTimeStep(1/CONFIG.physicsFPS);var e=CONFIG.showStats?"block":"none";renderStats&&(renderStats.domElement.style.display=e),physicsStats&&(physicsStats.domElement.style.display=e),rendererInfo&&(rendererInfo.style.display=e),localStorage.setItem("CONFIG",JSON.stringify(CONFIG))};(function()
+{var e=localStorage.getItem("CONFIG");if(e){e=JSON.parse(e);for(var t in e)e.hasOwnProperty(t)&&typeof e[t]!="function"&&(CONFIG[t]=e[t])}})(),"use strict","use strict",PlaneGeometry.prototype=Object.create(THREE.Geometry.prototype),"use strict",BlockGeometry.prototype=Object.create(THREE.Geometry.prototype),"use strict",AnimationManager.prototype.createAnimatedMesh=function(e,t,n){var r;for(var i=0;i<t.length;++i)n.animation.type==="morph"?(t[i].morphTargets=!0,t[i].morphNormals=!0):n.animation.type==="bones"&&
+(t[i].skinning=!0);var s=t.length>1?new THREE.MeshFaceMaterial(t):t[0];return n.animation.type==="morph"?(e.computeMorphNormals(),r=new THREE.MorphAnimMesh(e,s),r.duration=n.animation.duration,r.time=r.duration*Math.random()):n.animation.type==="bones"&&(r=new THREE.SkinnedMesh(e,s),THREE.AnimationHandler.add(e.animation),r.animation=new THREE.Animation(r,"walk")),this.anims.push(r),r},AnimationManager.prototype.update=function(e){for(var t=0;t<this.anims.length;++t){var n=this.anims[t];n.animation&&(!n.animation
+.isPlaying&&n.animate?n.animation.play():n.animation.isPlaying&&!n.animate&&n.animation.stop());if(n.dead)continue;n.updateAnimation&&n.animate&&n.updateAnimation(e*1e3)}THREE.AnimationHandler.update(e*1e3)},"use strict";var _textures=[],performance=window.performance||{};performance.now=function(){return performance.now||performance.mozNow||performance.msNow||performance.oNow||performance.webkitNow||function(){return(new Date).getTime()}}(),"use strict";var _novaTexture=null,_fireTexture=null;"use strict";var assets=
+{objects:{"barrel-blue":{collision:"cylinder",mass:250,sound:"metal"},"barrel-red":{collision:"cylinder",mass:250,sound:"metal"},"barrel-rusty":{collision:"cylinder",mass:250,sound:"metal"},"gas-tank":{collision:"cylinder",mass:350,sound:"metal"},"military-box":{collision:"box",mass:200,sound:"metal"},trash:{collision:"box",mass:150},turbine:{collision:"box",sound:"metal"}},items:{"ammo-box":{name:"ammo",collision:"box",mass:250,sound:"metal",item:{type:"clips",value:2}},"health-box":{name:"health pack",collision
+:"box",mass:250,sound:"metal",item:{type:"hp",value:25}},"heated-forks-box":{name:"heated forks ammo upgrade",collision:"box",mass:150,item:{type:"ammoType",value:"heated"}},"plasma-forks-box":{name:"plasma forks ammo upgrade",collision:"box",mass:150,item:{type:"ammoType",value:"plasma"}}},monsters:{robot:{collision:"capsule",character:{speed:4,hp:50},animation:{type:"morph",duration:"750"},sound:"metal"}},lights:{"ceiling-lamp":{type:"ceiling",offset:{x:0,y:-0.2,z:0}}},sounds:{shoot:["fork-launch.ogg"],"shoot-dry"
+:["empty-gun.ogg"],reload:["reload.ogg"],"pick-up":["pick-up.ogg"],metal:["metal-1.ogg","metal-2.ogg","metal-3.ogg"],"robot-death":["robot-death.ogg"]},materials:{"metal-01":{repeat:4},"metal-02":{},"metal-03":{},"metal-bumps-01":{repeat:2},"metal-bumps-02":{},"metal-bumps-03":{},"metal-colored-01":{},"metal-colored-02":{repeat:2},"metal-colored-03":{},"metal-colored-04":{},"metal-colored-05":{},"metal-colored-06":{},"metal-colored-07":{},"metal-colored-08":{repeat:2},"metal-colored-09":{},"metal-corrugated-01"
+:{repeat:2},"metal-corrugated-02":{},"metal-worn-01":{},"metal-worn-02":{}},environments:{}};"use strict";var VOID=" ",OPEN=".",WALL="#",DIAG="%";"use strict","use strict","use strict";var renderStats,physicsStats,rendererInfo,messageTimer=null;"use strict";var pl,controls,scene,renderer,composer,renderTargetParametersRGBA,renderTargetParametersRGB,colorTarget,depthTarget,depthPassPlugin,lightManager,animationManager,soundManager,aiManager,dungeon,projector=new THREE.Projector,clock=new THREE.Clock,cache=new
+Cache,passes={},shootVector=new THREE.Vector3;$(document).ready(function(){function n(e){var t=["Prog:",e.memory.programs,"Geom:",e.memory.geometries,"Tex:",e.memory.textures,"Calls:",e.render.calls,"Verts:",e.render.vertices,"Faces:",e.render.faces,"Pts:",e.render.points];return t.join(" ")}function r(){requestAnimationFrame(r);if(pl.dead)return;var i=clock.getDelta();i>.05&&(i=.05),e.set(pl.camera.position.x,0,pl.camera.position.z),controls.update(i),t.set(pl.camera.position.x,0,pl.camera.position.z),t.subSelf
+(e),t.divideScalar(i);var s=pl.getLinearVelocity().y;pl.setLinearVelocity({x:t.x,y:s<0?s:0,z:t.z}),scene.simulate(),controls.object.position.set(pl.position.x,pl.position.y+.5,pl.position.z),pl.rotation.copy(pl.camera.rotation),pl.__dirtyRotation=!0,animate(i),renderer.clear(),CONFIG.postprocessing?(renderer.shadowMapEnabled=CONFIG.shadows,depthPassPlugin.enabled=!0,renderer.render(scene,pl.camera,composer.renderTarget2,!0),CONFIG.showStats&&(rendererInfo.innerHTML=n(renderer.info)),renderer.shadowMapEnabled=!1
+,depthPassPlugin.enabled=!1,composer.render(i)):(renderer.render(scene,pl.camera),CONFIG.showStats&&(rendererInfo.innerHTML=n(renderer.info))),CONFIG.showStats&&renderStats.update()}var e=new THREE.Vector3,t=new THREE.Vector3;init(),dungeon.ready(function(){window.setInterval(function(){lightManager.update(pl)},690),window.setInterval(function(){pl.dead||aiManager.process()},100),window.setInterval(function(){!pl.dead&&pl.hp<=0&&(pl.dead=!0,controls.active=!1,$("#deathscreen").is(":visible")||$("#deathscreen"
+).fadeIn(500),$("#instructions").hide());var e=dungeon.getTriggerAt(pl.position);e&&e.type=="message"&&displayMessage(e.message),dungeon.isAtExit(pl.position)&&(savePlayerState(dungeon.level.next),resetLevel(dungeon.level.next))},45),r()})});

0 comments on commit ab6809f

Please sign in to comment.