var OrbitCamera=pc.createScript("orbitCamera");OrbitCamera.attributes.add("distanceMax",{type:"number",default:0,title:"Distance Max",description:"Setting this at 0 will give an infinite distance limit"}),OrbitCamera.attributes.add("distanceMin",{type:"number",default:0,title:"Distance Min"}),OrbitCamera.attributes.add("pitchAngleMax",{type:"number",default:90,title:"Pitch Angle Max (degrees)"}),OrbitCamera.attributes.add("pitchAngleMin",{type:"number",default:-90,title:"Pitch Angle Min (degrees)"}),OrbitCamera.attributes.add("leftLimit",{type:"number",default:90,title:"left Movement Limit(degrees)"}),OrbitCamera.attributes.add("RightLimit",{type:"number",default:-90,title:"Right Movement Limit (degrees)"}),OrbitCamera.attributes.add("inertiaFactor",{type:"number",default:0,title:"Inertia Factor",description:"Higher value means that the camera will continue moving after the user has stopped dragging. 0 is fully responsive."}),OrbitCamera.attributes.add("focusEntity",{type:"entity",title:"Focus Entity",description:"Entity for the camera to focus on. If blank, then the camera will use the whole scene"}),OrbitCamera.attributes.add("frameOnStart",{type:"boolean",default:!0,title:"Frame on Start",description:'Frames the entity or scene at the start of the application."'}),Object.defineProperty(OrbitCamera.prototype,"distance",{get:function(){return this._targetDistance},set:function(t){this._targetDistance=this._clampDistance(t)}}),Object.defineProperty(OrbitCamera.prototype,"pitch",{get:function(){return this._targetPitch},set:function(t){this._targetPitch=this._clampPitchAngle(t)}}),Object.defineProperty(OrbitCamera.prototype,"yaw",{get:function(){return this._targetYaw},set:function(t){this._targetYaw=t,t<=this.leftLimit?this._targetYaw=this.leftLimit:t>=this.RightLimit&&(this._targetYaw=this.RightLimit);var i=(this._targetYaw-this._yaw)%360;this._targetYaw=i>180?this._yaw-(360-i):i<-180?this._yaw+(360+i):this._yaw+i}}),Object.defineProperty(OrbitCamera.prototype,"pivotPoint",{get:function(){return this._pivotPoint},set:function(t){this._pivotPoint.copy(t)}}),OrbitCamera.prototype.focus=function(t){this._buildAabb(t,0);var i=this._modelsAabb.halfExtents,e=Math.max(i.x,Math.max(i.y,i.z));e/=Math.tan(.5*this.entity.camera.fov*pc.math.DEG_TO_RAD),e*=2,this.distance=e,this._removeInertia(),this._pivotPoint.copy(this._modelsAabb.center)},OrbitCamera.distanceBetween=new pc.Vec3,OrbitCamera.prototype.resetAndLookAtPoint=function(t,i){this.pivotPoint.copy(i),this.entity.setPosition(t),this.entity.lookAt(i);var e=OrbitCamera.distanceBetween;e.sub2(i,t),this.distance=e.length(),this.pivotPoint.copy(i);var a=this.entity.getRotation();this.yaw=this._calcYaw(a),this.pitch=this._calcPitch(a,this.yaw),this._removeInertia(),this._updatePosition()},OrbitCamera.prototype.resetAndLookAtEntity=function(t,i){this._buildAabb(i,0),this.resetAndLookAtPoint(t,this._modelsAabb.center)},OrbitCamera.prototype.reset=function(t,i,e){this.pitch=i,this.yaw=t,this.distance=e,this._removeInertia()},OrbitCamera.prototype.initialize=function(){var t=this,i=function(){t._checkAspectRatio()};window.addEventListener("resize",i,!1),this.entity.on("animation:end",this.onAnimationEnd,this),this.entity.on("animation:start",this.onAnimationStart,this),this._checkAspectRatio(),this._modelsAabb=new pc.BoundingBox,this._buildAabb(this.focusEntity||this.app.root,0),this.entity.lookAt(this._modelsAabb.center),this._pivotPoint=new pc.Vec3,this._pivotPoint.copy(this._modelsAabb.center);var e=this.entity.getRotation();if(this._yaw=this._calcYaw(e),this._pitch=this._clampPitchAngle(this._calcPitch(e,this._yaw)),this.entity.setLocalEulerAngles(this._pitch,this._yaw,0),this._distance=0,this._targetYaw=this._yaw,this._targetPitch=this._pitch,this.frameOnStart)this.focus(this.focusEntity||this.app.root);else{var a=new pc.Vec3;a.sub2(this.entity.getPosition(),this._pivotPoint),this._distance=this._clampDistance(a.length())}this._targetDistance=this._distance,this.on("attr:distanceMin",function(t,i){this._targetDistance=this._clampDistance(this._distance)}),this.on("attr:distanceMax",function(t,i){this._targetDistance=this._clampDistance(this._distance)}),this.on("attr:pitchAngleMin",function(t,i){this._targetPitch=this._clampPitchAngle(this._pitch)}),this.on("attr:pitchAngleMax",function(t,i){this._targetPitch=this._clampPitchAngle(this._pitch)}),this.on("attr:focusEntity",function(t,i){this.frameOnStart?this.focus(t||this.app.root):this.resetAndLookAtEntity(this.entity.getPosition(),t||this.app.root)}),this.on("attr:frameOnStart",function(t,i){t&&this.focus(this.focusEntity||this.app.root)}),this.on("destroy",function(){window.removeEventListener("resize",i,!1)})},OrbitCamera.prototype.onAnimationEnd=function(){},OrbitCamera.prototype.onAnimationStart=function(){},OrbitCamera.prototype.update=function(t){var i=0===this.inertiaFactor?1:Math.min(t/this.inertiaFactor,1);this._distance=pc.math.lerp(this._distance,this._targetDistance,i),this._yaw=pc.math.lerp(this._yaw,this._targetYaw,i),this._pitch=pc.math.lerp(this._pitch,this._targetPitch,i),this._updatePosition()},OrbitCamera.prototype._updatePosition=function(){this.entity.setLocalPosition(0,0,0),this.entity.setLocalEulerAngles(this._pitch,this._yaw,0);var t=this.entity.getPosition();t.copy(this.entity.forward),t.scale(-this._distance),t.add(this.pivotPoint),this.entity.setPosition(t)},OrbitCamera.prototype._removeInertia=function(){this._yaw=this._targetYaw,this._pitch=this._targetPitch,this._distance=this._targetDistance},OrbitCamera.prototype._checkAspectRatio=function(){var t=this.app.graphicsDevice.height,i=this.app.graphicsDevice.width;this.entity.camera.horizontalFov=t>i},OrbitCamera.prototype._buildAabb=function(t,i){var e=0;if(t.model){var a=t.model.meshInstances;for(e=0;e0?pc.math.clamp(t,this.distanceMin,this.distanceMax):Math.max(t,this.distanceMin)},OrbitCamera.prototype._clampPitchAngle=function(t){return pc.math.clamp(t,-this.pitchAngleMax,-this.pitchAngleMin)},OrbitCamera.quatWithoutYaw=new pc.Quat,OrbitCamera.yawOffset=new pc.Quat,OrbitCamera.prototype._calcPitch=function(t,i){var e=OrbitCamera.quatWithoutYaw,a=OrbitCamera.yawOffset;a.setFromEulerAngles(0,-i,0),e.mul2(a,t);var n=new pc.Vec3;return e.transformVector(pc.Vec3.FORWARD,n),Math.atan2(n.y,-n.z)*pc.math.RAD_TO_DEG};var MouseInput=pc.createScript("mouseInput");MouseInput.attributes.add("orbitSensitivity",{type:"number",default:.3,title:"Orbit Sensitivity",description:"How fast the camera moves around the orbit. Higher is faster"}),MouseInput.attributes.add("distanceSensitivity",{type:"number",default:.15,title:"Distance Sensitivity",description:"How fast the camera moves in and out. Higher is faster"}),MouseInput.prototype.initialize=function(){if(this.orbitCamera=this.entity.script.orbitCamera,this.entity.on("animation:end",this.onAnimationEnd,this),this.entity.on("animation:start",this.onAnimationStart,this),this.FOV=this.entity.camera.fov,this.orbitCamera){var t=this,e=function(e){t.onMouseOut(e)};this.app.mouse.on(pc.EVENT_MOUSEDOWN,this.onMouseDown,this),this.app.mouse.on(pc.EVENT_MOUSEUP,this.onMouseUp,this),this.app.mouse.on(pc.EVENT_MOUSEMOVE,this.onMouseMove,this),this.app.mouse.on(pc.EVENT_MOUSEWHEEL,this.onMouseWheel,this),window.addEventListener("mouseout",e,!1),this.on("destroy",function(){this.app.mouse.off(pc.EVENT_MOUSEDOWN,this.onMouseDown,this),this.app.mouse.off(pc.EVENT_MOUSEUP,this.onMouseUp,this),this.app.mouse.off(pc.EVENT_MOUSEMOVE,this.onMouseMove,this),this.app.mouse.off(pc.EVENT_MOUSEWHEEL,this.onMouseWheel,this),window.removeEventListener("mouseout",e,!1)})}this.lookButtonDown=!1,this.panButtonDown=!1,this.lastPoint=new pc.Vec2},MouseInput.prototype.onAnimationEnd=function(){clearInterval(e);fov=this.FOV-5,targetfov=fov+5,camera.fov=fov,camera=this.entity.camera;var t=Date.now(),e=setInterval(function(){var o=500-(Date.now()-t);o<=0?clearInterval(e):function draw(t){camera.postEffects.effects[0].effect.bloomIntensity=t/450,camera.postEffects.effects[3].effect.darkness=1+5e-4*t,camera.fov=1e3?clearInterval(o):function draw(t){camera.postEffects.effects[0].effect.bloomIntensity=t/450,camera.postEffects.effects[3].effect.darkness=1+5e-4*t,camera.fov>targetfov&&(camera.fov=camera.fov-.35)}(t)},20)},MouseInput.prototype.onMouseMove=function(t){pc.app.mouse;this.orbitCamera.pitch-=t.dy*this.orbitSensitivity,this.orbitCamera.yaw-=t.dx*this.orbitSensitivity,this.lastPoint.set(t.x,t.y)},MouseInput.prototype.onMouseWheel=function(t){this.orbitCamera.distance-=t.wheel*this.distanceSensitivity*(.1*this.orbitCamera.distance),t.event.preventDefault()},MouseInput.prototype.onMouseOut=function(t){this.lookButtonDown=!1,this.panButtonDown=!1};var KeyboardInput=pc.createScript("keyboardInput");KeyboardInput.prototype.initialize=function(){this.orbitCamera=this.entity.script.orbitCamera},KeyboardInput.prototype.postInitialize=function(){this.orbitCamera&&(this.startDistance=this.orbitCamera.distance,this.startYaw=this.orbitCamera.yaw,this.startPitch=this.orbitCamera.pitch,this.startPivotPosition=this.orbitCamera.pivotPoint.clone())},KeyboardInput.prototype.update=function(t){this.orbitCamera&&this.app.keyboard.wasPressed(pc.KEY_SPACE)&&(this.orbitCamera.reset(this.startYaw,this.startPitch,this.startDistance),this.orbitCamera.pivotPoint=this.startPivotPosition)};var Camera=pc.createScript("camera");Camera.attributes.add("maxElevation",{type:"number",title:"Max Elevation",default:70}),Camera.prototype.initialize=function(){this.viewPos=new pc.Vec3,this.targetViewPos=new pc.Vec3,this.tempVec=new pc.Vec3,this.distance=3,this.targetDistance=3,this.rotX=-180,this.rotY=0,this.targetRotX=-40,this.targetRotY=30,this.quatX=new pc.Quat,this.quatY=new pc.Quat,this.transformStarted=!1,this.app.mouse.disableContextMenu(),this.setBestCameraPositionForModel();var t,e,a;this.hammer=Hammer(this.app.graphicsDevice.canvas,{prevent_default:!0,drag_max_touches:2,transform_min_scale:.08,transform_min_rotation:180,transform_always_block:!0,hold:!1,release:!1,swipe:!1,tap:!1}),this.hammer.on("transformstart",function(e){this.transformStarted=!0,t=this.targetDistance,e.preventDefault(),this.hammer.options.drag=!1}.bind(this)),this.hammer.on("transformend",function(t){this.transformStarted=!1,this.hammer.options.drag=!0}.bind(this)),this.hammer.on("transform",function(e){if(this.transformStarted){var a=e.gesture.scale;this.targetDistance=t/a}}.bind(this)),this.hammer.on("dragstart",function(t){if(!this.transformStarted){var s=t.gesture,i=void 0!==s.touches?s.touches.length:1;this.panning=2===i,this.dragStarted=!0,e=s.center.pageX,a=s.center.pageY}}.bind(this)),this.hammer.on("dragend",function(t){this.dragStarted&&(this.dragStarted=!1,this.panning=!1)}.bind(this)),this.hammer.on("drag",function(t){var s=t.gesture,i=s.center.pageX-e,r=s.center.pageY-a;this.panning?this.pan(-.025*i,.025*r):this.orbit(.5*i,.5*r),e=s.center.pageX,a=s.center.pageY}.bind(this)),this.app.mouse.on(pc.EVENT_MOUSEMOVE,this.onMouseMove,this),this.app.mouse.on(pc.EVENT_MOUSEWHEEL,this.onMouseWheel,this)},Camera.prototype.setBestCameraPositionForModel=function(){var t,e,a=this.app.scene.getModels(),s=function(t){for(var e=t.node.getParent();e;){if(e.camera)return!0;e=e.getParent()}return!1},i=[];for(t=0;t0){var n=new pc.shape.Aabb;for(n.copy(i[0].aabb),t=0;t=AnimationBlending.states.idle_1.times&&(this.entity.animation.currentTime=0,AnimationBlending.states.count=0,this.switchAnimation("idle_2"))):this.entity.animation.currentTime===this.entity.animation.duration&&(this.entity.animation.currAnim===AnimationBlending.states.punch_1.animation?(this.actionTo.fire("animation:end"),this.switchAnimation("idle_1")):this.entity.animation.currAnim===AnimationBlending.states.punch_2.animation?(this.actionTo.fire("animation:end"),this.switchAnimation("idle_1")):this.entity.animation.currAnim===AnimationBlending.states.idle_2.animation&&this.switchAnimation("idle_1"))},AnimationBlending.prototype.switchAnimation=function(i){AnimationBlending.states;switch("idle_1"!==i&&this.entity.sound.stop(i),i){case"punch_1":case"punch_2":case"idle_1":case"idle_2":this.setState(i);break;default:this.setState(i)}},AnimationBlending.prototype.onMouseDown=function(i){this.entity.animation.currAnim!==AnimationBlending.states.idle_1.animation&&this.entity.animation.currAnim!==AnimationBlending.states.idle_2.animation||(this.actionTo.fire("animation:start"),this.entity.animation.prevAnim===AnimationBlending.states.punch_1.animation?this.switchAnimation("punch_2"):this.switchAnimation("punch_1"))};pc.extend(pc,function(){var e=15;function computeGaussian(e,t){return 1/Math.sqrt(2*Math.PI*t)*Math.exp(-e*e/(2*t*t))}function calculateBlurValues(t,s,r,o,i){t[0]=computeGaussian(0,i),s[0]=0,s[1]=0;var a,l,u=t[0];for(a=0,l=Math.floor(e/2);a>1,height:u>>1});n.minFilter=pc.FILTER_LINEAR,n.magFilter=pc.FILTER_LINEAR,n.addressU=pc.ADDRESS_CLAMP_TO_EDGE,n.addressV=pc.ADDRESS_CLAMP_TO_EDGE;var f=new pc.RenderTarget(t,n,{depth:!1});this.targets.push(f)}this.bloomThreshold=.25,this.blurAmount=4,this.bloomIntensity=1.25,this.sampleWeights=new Float32Array(e),this.sampleOffsets=new Float32Array(2*e)};return(t=pc.inherits(t,pc.PostEffect)).prototype=pc.extend(t.prototype,{render:function(e,t,s){var r=this.device,o=r.scope;o.resolve("uBloomThreshold").setValue(this.bloomThreshold),o.resolve("uBaseTexture").setValue(e.colorBuffer),pc.drawFullscreenQuad(r,this.targets[0],this.vertexBuffer,this.extractShader),calculateBlurValues(this.sampleWeights,this.sampleOffsets,1/this.targets[1].width,0,this.blurAmount),o.resolve("uBlurWeights[0]").setValue(this.sampleWeights),o.resolve("uBlurOffsets[0]").setValue(this.sampleOffsets),o.resolve("uBloomTexture").setValue(this.targets[0].colorBuffer),pc.drawFullscreenQuad(r,this.targets[1],this.vertexBuffer,this.blurShader),calculateBlurValues(this.sampleWeights,this.sampleOffsets,0,1/this.targets[0].height,this.blurAmount),o.resolve("uBlurWeights[0]").setValue(this.sampleWeights),o.resolve("uBlurOffsets[0]").setValue(this.sampleOffsets),o.resolve("uBloomTexture").setValue(this.targets[1].colorBuffer),pc.drawFullscreenQuad(r,this.targets[0],this.vertexBuffer,this.blurShader),o.resolve("uBloomEffectIntensity").setValue(this.bloomIntensity),o.resolve("uBloomTexture").setValue(this.targets[0].colorBuffer),o.resolve("uBaseTexture").setValue(e.colorBuffer),pc.drawFullscreenQuad(r,t,this.vertexBuffer,this.combineShader,s)}}),{BloomEffect:t}}());var Bloom=pc.createScript("bloom");Bloom.attributes.add("bloomIntensity",{type:"number",default:1,min:0,title:"Intensity"}),Bloom.attributes.add("bloomThreshold",{type:"number",default:.25,min:0,max:1,precision:2,title:"Threshold"}),Bloom.attributes.add("blurAmount",{type:"number",default:4,min:1,title:"Blur amount"}),Bloom.prototype.initialize=function(){this.effect=new pc.BloomEffect(this.app.graphicsDevice),this.effect.bloomThreshold=this.bloomThreshold,this.effect.blurAmount=this.blurAmount,this.effect.bloomIntensity=this.bloomIntensity;var e=this.entity.camera.postEffects;e.addEffect(this.effect),this.on("attr",function(e,t){this.effect[e]=t},this),this.on("state",function(t){t?e.addEffect(this.effect):e.removeEffect(this.effect)}),this.on("destroy",function(){e.removeEffect(this.effect)})};pc.extend(pc,function(){var t=function(t){this.shader=new pc.Shader(t,{attributes:{aPosition:pc.SEMANTIC_POSITION},vshader:["attribute vec2 aPosition;","","varying vec2 vUv0;","","void main(void)","{"," gl_Position = vec4(aPosition, 0.0, 1.0);"," vUv0 = (aPosition.xy + 1.0) * 0.5;","}"].join("\n"),fshader:["precision "+t.precision+" float;","uniform sampler2D uColorBuffer;","uniform float uBrightness;","uniform float uContrast;","varying vec2 vUv0;","void main() {","gl_FragColor = texture2D( uColorBuffer, vUv0 );","gl_FragColor.rgb += uBrightness;","if (uContrast > 0.0) {","gl_FragColor.rgb = (gl_FragColor.rgb - 0.5) / (1.0 - uContrast) + 0.5;","} else {","gl_FragColor.rgb = (gl_FragColor.rgb - 0.5) * (1.0 + uContrast) + 0.5;","}","}"].join("\n")}),this.brightness=0,this.contrast=0};return(t=pc.inherits(t,pc.PostEffect)).prototype=pc.extend(t.prototype,{render:function(t,e,r){var s=this.device,i=s.scope;i.resolve("uBrightness").setValue(this.brightness),i.resolve("uContrast").setValue(this.contrast),i.resolve("uColorBuffer").setValue(t.colorBuffer),pc.drawFullscreenQuad(s,e,this.vertexBuffer,this.shader,r)}}),{BrightnessContrastEffect:t}}());var BrightnessContrast=pc.createScript("brightnessContrast");BrightnessContrast.attributes.add("brightness",{type:"number",default:0,min:-1,max:1,precision:5,title:"Brightness"}),BrightnessContrast.attributes.add("contrast",{type:"number",default:0,min:-1,max:1,precision:5,title:"Contrast"}),BrightnessContrast.prototype.initialize=function(){this.effect=new pc.BrightnessContrastEffect(this.app.graphicsDevice),this.effect.brightness=this.brightness,this.effect.contrast=this.contrast,this.on("attr",function(t,e){this.effect[t]=e},this);var t=this.entity.camera.postEffects;t.addEffect(this.effect),this.on("state",function(e){e?t.addEffect(this.effect):t.removeEffect(this.effect)}),this.on("destroy",function(){t.removeEffect(this.effect)})};pc.extend(pc,function(){var t=function(t){this.shader=new pc.Shader(t,{attributes:{aPosition:pc.SEMANTIC_POSITION},vshader:["attribute vec2 aPosition;","","varying vec2 vUv0;","","void main(void)","{"," gl_Position = vec4(aPosition, 0.0, 1.0);"," vUv0 = (aPosition.xy + 1.0) * 0.5;","}"].join("\n"),fshader:["precision "+t.precision+" float;","uniform sampler2D uColorBuffer;","uniform float uHue;","uniform float uSaturation;","varying vec2 vUv0;","void main() {","gl_FragColor = texture2D( uColorBuffer, vUv0 );","float angle = uHue * 3.14159265;","float s = sin(angle), c = cos(angle);","vec3 weights = (vec3(2.0 * c, -sqrt(3.0) * s - c, sqrt(3.0) * s - c) + 1.0) / 3.0;","float len = length(gl_FragColor.rgb);","gl_FragColor.rgb = vec3(","dot(gl_FragColor.rgb, weights.xyz),","dot(gl_FragColor.rgb, weights.zxy),","dot(gl_FragColor.rgb, weights.yzx)",");","float average = (gl_FragColor.r + gl_FragColor.g + gl_FragColor.b) / 3.0;","if (uSaturation > 0.0) {","gl_FragColor.rgb += (average - gl_FragColor.rgb) * (1.0 - 1.0 / (1.001 - uSaturation));","} else {","gl_FragColor.rgb += (average - gl_FragColor.rgb) * (-uSaturation);","}","}"].join("\n")}),this.hue=0,this.saturation=0};return(t=pc.inherits(t,pc.PostEffect)).prototype=pc.extend(t.prototype,{render:function(t,e,r){var o=this.device,a=o.scope;a.resolve("uHue").setValue(this.hue),a.resolve("uSaturation").setValue(this.saturation),a.resolve("uColorBuffer").setValue(t.colorBuffer),pc.drawFullscreenQuad(o,e,this.vertexBuffer,this.shader,r)}}),{HueSaturationEffect:t}}());var HueSaturation=pc.createScript("hueSaturation");HueSaturation.attributes.add("hue",{type:"number",default:0,min:-1,max:1,precision:5,title:"Hue"}),HueSaturation.attributes.add("saturation",{type:"number",default:0,min:-1,max:1,precision:5,title:"Saturation"}),HueSaturation.prototype.initialize=function(){this.effect=new pc.HueSaturationEffect(this.app.graphicsDevice),this.effect.hue=this.hue,this.effect.saturation=this.saturation,this.on("attr",function(t,e){this.effect[t]=e},this);var t=this.entity.camera.postEffects;t.addEffect(this.effect),this.on("state",function(e){e?t.addEffect(this.effect):t.removeEffect(this.effect)}),this.on("destroy",function(){t.removeEffect(this.effect)})};pc.extend(pc,function(){var e=function(e){var o={aPosition:pc.SEMANTIC_POSITION},r=["attribute vec2 aPosition;","","void main(void)","{"," gl_Position = vec4(aPosition, 0.0, 1.0);","}"].join("\n"),a=["precision "+e.precision+" float;","","uniform sampler2D uColorBuffer;","uniform vec2 uResolution;","","#define FXAA_REDUCE_MIN (1.0/128.0)","#define FXAA_REDUCE_MUL (1.0/8.0)","#define FXAA_SPAN_MAX 8.0","","void main()","{"," vec3 rgbNW = texture2D( uColorBuffer, ( gl_FragCoord.xy + vec2( -1.0, -1.0 ) ) * uResolution ).xyz;"," vec3 rgbNE = texture2D( uColorBuffer, ( gl_FragCoord.xy + vec2( 1.0, -1.0 ) ) * uResolution ).xyz;"," vec3 rgbSW = texture2D( uColorBuffer, ( gl_FragCoord.xy + vec2( -1.0, 1.0 ) ) * uResolution ).xyz;"," vec3 rgbSE = texture2D( uColorBuffer, ( gl_FragCoord.xy + vec2( 1.0, 1.0 ) ) * uResolution ).xyz;"," vec4 rgbaM = texture2D( uColorBuffer, gl_FragCoord.xy * uResolution );"," vec3 rgbM = rgbaM.xyz;"," float opacity = rgbaM.w;",""," vec3 luma = vec3( 0.299, 0.587, 0.114 );",""," float lumaNW = dot( rgbNW, luma );"," float lumaNE = dot( rgbNE, luma );"," float lumaSW = dot( rgbSW, luma );"," float lumaSE = dot( rgbSE, luma );"," float lumaM = dot( rgbM, luma );"," float lumaMin = min( lumaM, min( min( lumaNW, lumaNE ), min( lumaSW, lumaSE ) ) );"," float lumaMax = max( lumaM, max( max( lumaNW, lumaNE) , max( lumaSW, lumaSE ) ) );",""," vec2 dir;"," dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));"," dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));",""," float dirReduce = max( ( lumaNW + lumaNE + lumaSW + lumaSE ) * ( 0.25 * FXAA_REDUCE_MUL ), FXAA_REDUCE_MIN );",""," float rcpDirMin = 1.0 / ( min( abs( dir.x ), abs( dir.y ) ) + dirReduce );"," dir = min( vec2( FXAA_SPAN_MAX, FXAA_SPAN_MAX), max( vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), dir * rcpDirMin)) * uResolution;",""," vec3 rgbA = 0.5 * ("," texture2D( uColorBuffer, gl_FragCoord.xy * uResolution + dir * ( 1.0 / 3.0 - 0.5 ) ).xyz +"," texture2D( uColorBuffer, gl_FragCoord.xy * uResolution + dir * ( 2.0 / 3.0 - 0.5 ) ).xyz );",""," vec3 rgbB = rgbA * 0.5 + 0.25 * ("," texture2D( uColorBuffer, gl_FragCoord.xy * uResolution + dir * -0.5 ).xyz +"," texture2D( uColorBuffer, gl_FragCoord.xy * uResolution + dir * 0.5 ).xyz );",""," float lumaB = dot( rgbB, luma );",""," if ( ( lumaB < lumaMin ) || ( lumaB > lumaMax ) )"," {"," gl_FragColor = vec4( rgbA, opacity );"," }"," else"," {"," gl_FragColor = vec4( rgbB, opacity );"," }","}"].join("\n");this.fxaaShader=new pc.Shader(e,{attributes:o,vshader:r,fshader:a}),this.resolution=new Float32Array(2)};return(e=pc.inherits(e,pc.PostEffect)).prototype=pc.extend(e.prototype,{render:function(e,o,r){var a=this.device,t=a.scope;this.resolution[0]=1/e.width,this.resolution[1]=1/e.height,t.resolve("uResolution").setValue(this.resolution),t.resolve("uColorBuffer").setValue(e.colorBuffer),pc.drawFullscreenQuad(a,o,this.vertexBuffer,this.fxaaShader,r)}}),{FxaaEffect:e}}());var Fxaa=pc.createScript("fxaa");Fxaa.prototype.initialize=function(){this.effect=new pc.FxaaEffect(this.app.graphicsDevice);var e=this.entity.camera.postEffects;e.addEffect(this.effect),this.on("state",function(o){o?e.addEffect(this.effect):e.removeEffect(this.effect)}),this.on("destroy",function(){e.removeEffect(this.effect)})};pc.extend(pc,function(){var e=function(e){var t={aPosition:pc.SEMANTIC_POSITION},i=["attribute vec2 aPosition;","","varying vec2 vUv0;","","void main(void)","{"," gl_Position = vec4(aPosition, 0.0, 1.0);"," vUv0 = (aPosition.xy + 1.0) * 0.5;","}"].join("\n"),s=["precision "+e.precision+" float;","","uniform sampler2D uColorBuffer;","uniform float uDarkness;","uniform float uOffset;","","varying vec2 vUv0;","","void main() {"," vec4 texel = texture2D(uColorBuffer, vUv0);"," vec2 uv = (vUv0 - vec2(0.5)) * vec2(uOffset);"," gl_FragColor = vec4(mix(texel.rgb, vec3(1.0 - uDarkness), dot(uv, uv)), texel.a);","}"].join("\n");this.vignetteShader=new pc.Shader(e,{attributes:t,vshader:i,fshader:s}),this.offset=1,this.darkness=1};return(e=pc.inherits(e,pc.PostEffect)).prototype=pc.extend(e,{render:function(e,t,i){var s=this.device,f=s.scope;f.resolve("uColorBuffer").setValue(e.colorBuffer),f.resolve("uOffset").setValue(this.offset),f.resolve("uDarkness").setValue(this.darkness),pc.drawFullscreenQuad(s,t,this.vertexBuffer,this.vignetteShader,i)}}),{VignetteEffect:e}}());var Vignette=pc.createScript("vignette");Vignette.attributes.add("offset",{type:"number",default:1,min:0,precision:5,title:"Offset"}),Vignette.attributes.add("darkness",{type:"number",default:1,precision:5,title:"Darkness"}),Vignette.prototype.initialize=function(){this.effect=new pc.VignetteEffect(this.app.graphicsDevice),this.effect.offset=this.offset,this.effect.darkness=this.darkness,this.on("attr",function(e,t){this.effect[e]=t},this);var e=this.entity.camera.postEffects;e.addEffect(this.effect),this.on("state",function(t){t?e.addEffect(this.effect):e.removeEffect(this.effect)}),this.on("destroy",function(){e.removeEffect(this.effect)})};var ScrollingTexture=pc.createScript("scrollingTexture");ScrollingTexture.attributes.add("materialAsset",{type:"asset"}),ScrollingTexture.attributes.add("speed",{type:"vec2"}),ScrollingTexture.tmp=new pc.Vec2,ScrollingTexture.prototype.initialize=function(){this.materialAsset&&(this.material=this.materialAsset.resource)},ScrollingTexture.prototype.update=function(e){var t=ScrollingTexture.tmp;t.set(this.speed.x,this.speed.y),t.scale(e),this.material.diffuseMapOffset=this.material.diffuseMapOffset.add(t),this.material.normalMapOffset.add(t),this.material.update()};