@petkoneo/phaser3-rex-plugins
Version:
1,690 lines (1,373 loc) • 60.7 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.rexeffectpropertiesplugin = factory());
})(this, (function () { 'use strict';
var HasProperty = function (obj, prop) {
if (!obj) {
return false;
}
if (obj.hasOwnProperty(prop)) {
return true;
}
while (obj) {
if (Object.getOwnPropertyDescriptor(obj, prop)) {
return true;
}
obj = obj.__proto__;
}
return false;
};
var GetFXFactory = function (gameObject) {
if (gameObject.preFX) {
return gameObject.preFX;
}
if (gameObject.postFX) {
return gameObject.postFX;
}
return null;
};
var AddClearEffectCallback = function (gameObject, effectSwitchName) {
if (!gameObject._effectSwitchNames) {
gameObject._effectSwitchNames = [];
gameObject.clearAllEffects = function () {
var effectSwitchNames = gameObject._effectSwitchNames;
for (var i = 0, cnt = effectSwitchNames.length; i < cnt; i++) {
gameObject[effectSwitchNames[i]] = null;
}
return gameObject;
};
gameObject.on('destroy', gameObject.clearAllEffects, gameObject);
}
gameObject._effectSwitchNames.push(effectSwitchName);
};
var AddBarrelProperties = function (gameObject) {
// Don't attach properties again
if (HasProperty(gameObject, 'barrel')) {
return gameObject;
}
var fxFactory = GetFXFactory(gameObject);
if (!fxFactory) {
return gameObject;
}
var barrel;
Object.defineProperty(gameObject, 'barrel', {
get: function () {
return barrel;
},
set: function (value) {
if (barrel === value) {
return;
}
barrel = value;
if ((barrel === null) || (barrel === false)) {
if (gameObject._barrelEffect) {
fxFactory.remove(gameObject._barrelEffect);
gameObject._barrelEffect = undefined;
}
} else {
if (!gameObject._barrelEffect) {
gameObject._barrelEffect = fxFactory.addBarrel();
}
gameObject._barrelEffect.amount = barrel;
}
},
});
gameObject.barrel = null;
AddClearEffectCallback(gameObject, 'barrel');
return gameObject;
};
var AddColorMatrixEffectPropertiesBase = function (gameObject, effectName, inputMode) {
// Don't attach properties again
if (HasProperty(gameObject, effectName)) {
return gameObject;
}
var fxFactory = GetFXFactory(gameObject);
if (!fxFactory) {
return gameObject;
}
var EffectInstancePropertyName = `_${effectName}Effect`;
var currentValue;
Object.defineProperty(gameObject, effectName, {
get: function () {
return currentValue;
},
set: function (value) {
if (currentValue === value) {
return;
}
currentValue = value;
if ((currentValue === null) || (currentValue === false)) {
if (gameObject[EffectInstancePropertyName]) {
fxFactory.remove(gameObject[EffectInstancePropertyName]);
gameObject[EffectInstancePropertyName] = undefined;
}
} else {
if (!gameObject[EffectInstancePropertyName]) {
gameObject[EffectInstancePropertyName] = fxFactory.addColorMatrix();
}
var effectInstance = gameObject[EffectInstancePropertyName];
effectInstance[effectName]((inputMode === 1) ? value : undefined);
}
},
});
gameObject[effectName] = null;
AddClearEffectCallback(gameObject, effectName);
return gameObject;
};
var AddBlackWhiteProperties = function (gameObject) {
AddColorMatrixEffectPropertiesBase(gameObject, 'blackWhite');
return gameObject;
};
var AddBloomProperties = function (gameObject) {
// Don't attach properties again
if (HasProperty(gameObject, 'bloomColor')) {
return gameObject;
}
var fxFactory = GetFXFactory(gameObject);
if (!fxFactory) {
return gameObject;
}
var bloomColor,
bloomOffsetX = 1,
bloomOffsetY = 1,
bloomBlurStrength = 1,
bloomStrength = 1,
bloomSteps = 4;
Object.defineProperty(gameObject, 'bloomColor', {
get: function () {
return bloomColor;
},
set: function (value) {
if (bloomColor === value) {
return;
}
bloomColor = value;
if ((bloomColor === null) || (bloomColor === false)) {
if (gameObject._bloom) {
fxFactory.remove(gameObject._bloom);
gameObject._bloom = undefined;
fxFactory.setPadding(0);
}
} else {
if (!gameObject._bloom) {
gameObject._bloom = fxFactory.addBloom(bloomColor, bloomOffsetX, bloomOffsetY, bloomBlurStrength, bloomStrength, bloomSteps);
fxFactory.setPadding(Math.max(bloomOffsetX, bloomOffsetY) + 1);
}
gameObject._bloom.color = bloomColor;
}
},
});
Object.defineProperty(gameObject, 'bloomOffsetX', {
get: function () {
return bloomOffsetX;
},
set: function (value) {
if (bloomOffsetX === value) {
return;
}
bloomOffsetX = value;
if (gameObject._bloom) {
var offset = Math.max(bloomOffsetX, bloomOffsetY);
fxFactory.setPadding(offset + 1);
gameObject._bloom.offsetX = bloomOffsetX;
}
},
});
Object.defineProperty(gameObject, 'bloomOffsetY', {
get: function () {
return bloomOffsetY;
},
set: function (value) {
if (bloomOffsetY === value) {
return;
}
bloomOffsetY = value;
if (gameObject._bloom) {
var offset = Math.max(bloomOffsetX, bloomOffsetY);
fxFactory.setPadding(offset + 1);
gameObject._bloom.offsetY = bloomOffsetY;
}
},
});
Object.defineProperty(gameObject, 'bloomBlurStrength', {
get: function () {
return bloomBlurStrength;
},
set: function (value) {
if (bloomBlurStrength === value) {
return;
}
bloomBlurStrength = value;
if (gameObject._bloom) {
gameObject._bloom.blurStrength = bloomBlurStrength;
}
},
});
Object.defineProperty(gameObject, 'bloomStrength', {
get: function () {
return bloomStrength;
},
set: function (value) {
if (bloomStrength === value) {
return;
}
bloomStrength = value;
if (gameObject._bloom) {
gameObject._bloom.strength = bloomStrength;
}
},
});
Object.defineProperty(gameObject, 'bloomSteps', {
get: function () {
return bloomSteps;
},
set: function (value) {
if (bloomSteps === value) {
return;
}
bloomSteps = value;
if (gameObject._bloom) {
gameObject._bloom.steps = bloomSteps;
}
},
});
gameObject.bloomColor = null;
AddClearEffectCallback(gameObject, 'bloomColor');
return gameObject;
};
var AddBlurProperties = function (gameObject) {
// Don't attach properties again
if (HasProperty(gameObject, 'blurColor')) {
return gameObject;
}
var fxFactory = GetFXFactory(gameObject);
if (!fxFactory) {
return gameObject;
}
var blurColor,
blurQuality = 0,
blurX = 1,
blurY = 1,
blurStrength = 1,
blurSteps = 4;
Object.defineProperty(gameObject, 'blurColor', {
get: function () {
return blurColor;
},
set: function (value) {
if (blurColor === value) {
return;
}
blurColor = value;
if ((blurColor === null) || (blurColor === false)) {
if (gameObject._blur) {
fxFactory.remove(gameObject._blur);
gameObject._blur = undefined;
fxFactory.setPadding(0);
}
} else {
if (!gameObject._blur) {
gameObject._blur = fxFactory.addBlur(blurQuality, blurX, blurY, blurStrength, blurColor, blurSteps);
fxFactory.setPadding(Math.max(blurX, blurY) + 1);
}
gameObject._blur.color = blurColor;
}
},
});
Object.defineProperty(gameObject, 'blurQuality', {
get: function () {
return blurQuality;
},
set: function (value) {
if (blurQuality === value) {
return;
}
blurQuality = value;
if (gameObject._blur) {
gameObject._blur.quality = blurQuality;
}
},
});
Object.defineProperty(gameObject, 'blurX', {
get: function () {
return blurX;
},
set: function (value) {
if (blurX === value) {
return;
}
blurX = value;
if (gameObject._blur) {
var offset = Math.max(blurX, blurY);
fxFactory.setPadding(offset + 1);
gameObject._blur.x = blurX;
}
},
});
Object.defineProperty(gameObject, 'blurY', {
get: function () {
return blurY;
},
set: function (value) {
if (blurY === value) {
return;
}
blurY = value;
if (gameObject._blur) {
var offset = Math.max(blurX, blurY);
fxFactory.setPadding(offset + 1);
gameObject._blur.y = blurY;
}
},
});
Object.defineProperty(gameObject, 'blurStrength', {
get: function () {
return blurStrength;
},
set: function (value) {
if (blurStrength === value) {
return;
}
blurStrength = value;
if (gameObject._blur) {
gameObject._blur.strength = blurStrength;
}
},
});
Object.defineProperty(gameObject, 'blurSteps', {
get: function () {
return blurSteps;
},
set: function (value) {
if (blurSteps === value) {
return;
}
blurSteps = value;
if (gameObject._blur) {
gameObject._blur.steps = blurSteps;
}
},
});
gameObject.blurColor = null;
AddClearEffectCallback(gameObject, 'blurColor');
return gameObject;
};
var AddBokehProperties = function (gameObject) {
// Don't attach properties again
if (HasProperty(gameObject, 'bokehRadius')) {
return gameObject;
}
var fxFactory = GetFXFactory(gameObject);
if (!fxFactory) {
return gameObject;
}
var bokehRadius,
bokehAmount = 1,
bokehContrast = 0.2;
Object.defineProperty(gameObject, 'bokehRadius', {
get: function () {
return bokehRadius;
},
set: function (value) {
if (bokehRadius === value) {
return;
}
bokehRadius = value;
if ((bokehRadius === null) || (bokehRadius === false)) {
if (gameObject._bokeh) {
fxFactory.remove(gameObject._bokeh);
gameObject._bokeh = undefined;
}
} else {
if (!gameObject._bokeh) {
gameObject._bokeh = fxFactory.addBokeh(bokehRadius, bokehAmount, bokehContrast);
}
gameObject._bokeh.radius = bokehRadius;
}
},
});
Object.defineProperty(gameObject, 'bokehAmount', {
get: function () {
return bokehAmount;
},
set: function (value) {
if (bokehAmount === value) {
return;
}
bokehAmount = value;
if (gameObject._bokeh) {
gameObject._bokeh.amount = bokehAmount;
}
},
});
Object.defineProperty(gameObject, 'bokehContrast', {
get: function () {
return bokehContrast;
},
set: function (value) {
if (bokehContrast === value) {
return;
}
bokehContrast = value;
if (gameObject._bokeh) {
gameObject._bokeh.contrast = bokehContrast;
}
},
});
gameObject.bokehRadius = null;
AddClearEffectCallback(gameObject, 'bokehRadius');
return gameObject;
};
var AddBrightnessProperties = function (gameObject) {
AddColorMatrixEffectPropertiesBase(gameObject, 'brightness', 1);
return gameObject;
};
var AddBrownProperties = function (gameObject) {
AddColorMatrixEffectPropertiesBase(gameObject, 'brown');
return gameObject;
};
var AddCircleProperties = function (gameObject) {
// Don't attach properties again
if (HasProperty(gameObject, 'circleColor')) {
return gameObject;
}
var fxFactory = GetFXFactory(gameObject);
if (!fxFactory) {
return gameObject;
}
var circleColor,
circleThickness = 8,
circleBackgroundColor = 0x000000,
circleBackgroundAlpha = 0.4,
circleScale = 1,
circleFeather = 0.005;
Object.defineProperty(gameObject, 'circleColor', {
get: function () {
return circleColor;
},
set: function (value) {
if (circleColor === value) {
return;
}
circleColor = value;
if ((circleColor === null) || (circleColor === false)) {
if (gameObject._circle) {
fxFactory.remove(gameObject._circle);
gameObject._circle = undefined;
}
} else {
if (!gameObject._circle) {
gameObject._circle = fxFactory.addCircle(circleThickness, circleColor, circleBackgroundColor, circleScale, circleFeather);
gameObject.circleBackgroundAlpha = circleBackgroundAlpha;
}
gameObject._circle.color = circleColor;
}
},
});
Object.defineProperty(gameObject, 'circleThickness', {
get: function () {
return circleThickness;
},
set: function (value) {
if (circleThickness === value) {
return;
}
circleThickness = value;
if (gameObject._circle) {
gameObject._circle.thickness = circleThickness;
}
},
});
Object.defineProperty(gameObject, 'circleBackgroundColor', {
get: function () {
return circleBackgroundColor;
},
set: function (value) {
if (circleBackgroundColor === value) {
return;
}
circleBackgroundColor = value;
if (gameObject._circle) {
gameObject._circle.backgroundColor = circleBackgroundColor;
}
},
});
Object.defineProperty(gameObject, 'circleBackgroundAlpha', {
get: function () {
return circleBackgroundAlpha;
},
set: function (value) {
if (circleBackgroundAlpha === value) {
return;
}
circleBackgroundAlpha = value;
if (gameObject._circle) {
gameObject._circle.glcolor2[3] = circleBackgroundAlpha;
}
},
});
Object.defineProperty(gameObject, 'circleScale', {
get: function () {
return circleScale;
},
set: function (value) {
if (circleScale === value) {
return;
}
circleScale = value;
if (gameObject._circle) {
gameObject._circle.scale = circleScale;
}
},
});
Object.defineProperty(gameObject, 'circleFeather', {
get: function () {
return circleFeather;
},
set: function (value) {
if (circleFeather === value) {
return;
}
circleFeather = value;
if (gameObject._circle) {
gameObject._circle.feather = circleFeather;
}
},
});
gameObject.circleColor = null;
AddClearEffectCallback(gameObject, 'circleColor');
return gameObject;
};
var AddContrastProperties = function (gameObject) {
AddColorMatrixEffectPropertiesBase(gameObject, 'contrast', 1);
return gameObject;
};
var AddDesaturateProperties = function (gameObject) {
AddColorMatrixEffectPropertiesBase(gameObject, 'desaturate', 1);
return gameObject;
};
var AddDesaturateLuminanceProperties = function (gameObject) {
AddColorMatrixEffectPropertiesBase(gameObject, 'desaturateLuminance');
return gameObject;
};
var AddDisplacementProperties = function (gameObject) {
// Don't attach properties again
if (HasProperty(gameObject, 'displacementKey')) {
return gameObject;
}
var fxFactory = GetFXFactory(gameObject);
if (!fxFactory) {
return gameObject;
}
var displacementKey,
displacementX = 0.005,
displacementY = 0.005;
Object.defineProperty(gameObject, 'displacementKey', {
get: function () {
return displacementKey;
},
set: function (value) {
if (displacementKey === value) {
return;
}
displacementKey = value;
if ((displacementKey === null) || (displacementKey === false)) {
if (gameObject._displacement) {
fxFactory.remove(gameObject._displacement);
gameObject._displacement = undefined;
}
} else {
if (!gameObject._displacement) {
gameObject._displacement = fxFactory.addDisplacement(displacementKey, displacementX, displacementY);
}
gameObject._displacement.setTexture(displacementKey);
}
},
});
Object.defineProperty(gameObject, 'displacementX', {
get: function () {
return displacementX;
},
set: function (value) {
if (displacementX === value) {
return;
}
displacementX = value;
if (gameObject._displacement) {
gameObject._displacement.x = displacementX;
}
},
});
Object.defineProperty(gameObject, 'displacementY', {
get: function () {
return displacementY;
},
set: function (value) {
if (displacementY === value) {
return;
}
displacementY = value;
if (gameObject._displacement) {
gameObject._displacement.y = displacementY;
}
},
});
gameObject.displacementKey = null;
AddClearEffectCallback(gameObject, 'displacementKey');
return gameObject;
};
var AddGlowProperties = function (gameObject) {
// Don't attach properties again
if (HasProperty(gameObject, 'glowColor')) {
return gameObject;
}
var fxFactory = GetFXFactory(gameObject);
if (!fxFactory) {
return gameObject;
}
var glowColor,
glowOuterStrength = 4,
glowInnerStrength = 0;
Object.defineProperty(gameObject, 'glowColor', {
get: function () {
return glowColor;
},
set: function (value) {
if (glowColor === value) {
return;
}
glowColor = value;
if ((glowColor === null) || (glowColor === false)) {
if (gameObject._glow) {
fxFactory.remove(gameObject._glow);
gameObject._glow = undefined;
fxFactory.setPadding(0);
}
} else {
if (!gameObject._glow) {
gameObject._glow = fxFactory.addGlow(glowColor, glowOuterStrength, glowInnerStrength);
fxFactory.setPadding(glowOuterStrength + 1);
}
gameObject._glow.color = glowColor;
}
},
});
Object.defineProperty(gameObject, 'glowOuterStrength', {
get: function () {
return glowOuterStrength;
},
set: function (value) {
if (glowOuterStrength === value) {
return;
}
glowOuterStrength = value;
if (gameObject._glow) {
fxFactory.setPadding(glowOuterStrength + 1);
gameObject._glow.outerStrength = glowOuterStrength;
}
},
});
Object.defineProperty(gameObject, 'glowInnerStrength', {
get: function () {
return glowInnerStrength;
},
set: function (value) {
if (glowInnerStrength === value) {
return;
}
glowInnerStrength = value;
if (gameObject._glow) {
gameObject._glow.innerStrength = glowInnerStrength;
}
},
});
gameObject.glowColor = null;
AddClearEffectCallback(gameObject, 'glowColor');
return gameObject;
};
var AddGradientProperties = function (gameObject) {
// Don't attach properties again
if (HasProperty(gameObject, 'gradientColor')) {
return gameObject;
}
var fxFactory = GetFXFactory(gameObject);
if (!fxFactory) {
return gameObject;
}
var gradientColor1,
gradientColor2,
gradientAlpha = 0.5,
gradientFromX = 0,
gradientFromY = 0,
gradientToX = 0,
gradientToY = 1,
gradientSize = 0;
Object.defineProperty(gameObject, 'gradientColor', {
get: function () {
return [gradientColor1, gradientColor2];
},
set: function (value) {
var color1, color2;
if ((value === null) || (value === false)) {
color1 = null;
color2 = null;
} else {
color1 = value[0];
color2 = value[1];
}
if ((gradientColor1 === color1) && (gradientColor2 === color2)) {
return;
}
gradientColor1 = color1;
gradientColor2 = color2;
if ((gradientColor1 === null) || (gradientColor1 === false)) {
if (gameObject._gradient) {
fxFactory.remove(gameObject._gradient);
gameObject._gradient = undefined;
}
} else {
if (!gameObject._gradient) {
gameObject._gradient = fxFactory.addGradient(gradientColor1, gradientColor2, gradientAlpha, gradientFromX, gradientFromY, gradientToX, gradientToY, gradientSize);
}
gameObject._gradient.color1 = gradientColor1;
gameObject._gradient.color2 = gradientColor2;
}
},
});
Object.defineProperty(gameObject, 'gradientColor1', {
get: function () {
return gradientColor1;
},
set: function (value) {
if ((value === null) || (value === false)) {
gameObject.gradientColor = value;
return;
}
if (gradientColor1 === value) {
return;
}
gradientColor1 = value;
if (gameObject._gradient) {
gameObject._gradient.color1 = gradientColor1;
}
},
});
Object.defineProperty(gameObject, 'gradientColor2', {
get: function () {
return gradientColor2;
},
set: function (value) {
if ((value === null) || (value === false)) {
gameObject.gradientColor = value;
return;
}
if (gradientColor2 === value) {
return;
}
gradientColor2 = value;
if (gameObject._gradient) {
gameObject._gradient.color2 = gradientColor2;
}
},
});
Object.defineProperty(gameObject, 'gradientAlpha', {
get: function () {
return gradientAlpha;
},
set: function (value) {
if (gradientAlpha === value) {
return;
}
gradientAlpha = value;
if (gameObject._gradient) {
gameObject._gradient.alpha = gradientAlpha;
}
},
});
Object.defineProperty(gameObject, 'gradientFromX', {
get: function () {
return gradientFromX;
},
set: function (value) {
if (gradientFromX === value) {
return;
}
gradientFromX = value;
if (gameObject._gradient) {
gameObject._gradient.fromX = gradientFromX;
}
},
});
Object.defineProperty(gameObject, 'gradientFromY', {
get: function () {
return gradientFromY;
},
set: function (value) {
if (gradientFromY === value) {
return;
}
gradientFromY = value;
if (gameObject._gradient) {
gameObject._gradient.fromY = gradientFromY;
}
},
});
Object.defineProperty(gameObject, 'gradientToX', {
get: function () {
return gradientToX;
},
set: function (value) {
if (gradientToX === value) {
return;
}
gradientToX = value;
if (gameObject._gradient) {
gameObject._gradient.toX = gradientToX;
}
},
});
Object.defineProperty(gameObject, 'gradientToY', {
get: function () {
return gradientToY;
},
set: function (value) {
if (gradientToY === value) {
return;
}
gradientToY = value;
if (gameObject._gradient) {
gameObject._gradient.toY = gradientToY;
}
},
});
Object.defineProperty(gameObject, 'gradientSize', {
get: function () {
return gradientSize;
},
set: function (value) {
if (gradientSize === value) {
return;
}
gradientSize = value;
if (gameObject._gradient) {
gameObject._gradient.size = gradientSize;
}
},
});
gameObject.gradientColor = null;
AddClearEffectCallback(gameObject, 'gradientColor');
return gameObject;
};
var AddGrayscaleProperties = function (gameObject) {
AddColorMatrixEffectPropertiesBase(gameObject, 'grayscale', 1);
return gameObject;
};
var AddHueProperties = function (gameObject) {
AddColorMatrixEffectPropertiesBase(gameObject, 'hue', 1);
return gameObject;
};
var AddKodachromeProperties = function (gameObject) {
AddColorMatrixEffectPropertiesBase(gameObject, 'kodachrome');
return gameObject;
};
var AddLSDProperties = function (gameObject) {
AddColorMatrixEffectPropertiesBase(gameObject, 'lsd');
return gameObject;
};
var AddNegativeProperties = function (gameObject) {
AddColorMatrixEffectPropertiesBase(gameObject, 'negative');
return gameObject;
};
var AddPixelateProperties = function (gameObject) {
// Don't attach properties again
if (HasProperty(gameObject, 'pixelate')) {
return gameObject;
}
var fxFactory = GetFXFactory(gameObject);
if (!fxFactory) {
return gameObject;
}
var pixelate;
Object.defineProperty(gameObject, 'pixelate', {
get: function () {
return pixelate;
},
set: function (value) {
if (pixelate === value) {
return;
}
pixelate = value;
if ((pixelate === null) || (pixelate === false)) {
if (gameObject._pixelateEffect) {
fxFactory.remove(gameObject._pixelateEffect);
gameObject._pixelateEffect = undefined;
}
} else {
if (!gameObject._pixelateEffect) {
gameObject._pixelateEffect = fxFactory.addPixelate();
}
gameObject._pixelateEffect.amount = pixelate;
}
},
});
gameObject.pixelate = null;
AddClearEffectCallback(gameObject, 'pixelate');
return gameObject;
};
var AddPolaroidProperties = function (gameObject) {
AddColorMatrixEffectPropertiesBase(gameObject, 'polaroid');
return gameObject;
};
var AddRevealProperties = function (gameObject) {
// Don't attach properties again
if (HasProperty(gameObject, 'revealLeft')) {
return gameObject;
}
var fxFactory = GetFXFactory(gameObject);
if (!fxFactory) {
return gameObject;
}
var revealLeft,
revealRight,
revealUp,
revealDown,
revealWidth = 0.1;
var ClearRevealFlags = function () {
revealLeft = null;
revealRight = null;
revealUp = null;
revealDown = null;
};
var RemoveEffect = function (gameObject) {
if (gameObject._revealEffect) {
fxFactory.remove(gameObject._revealEffect);
gameObject._revealEffect = undefined;
}
};
Object.defineProperty(gameObject, 'revealLeft', {
get: function () {
return revealLeft;
},
set: function (value) {
if (revealLeft === value) {
return;
}
ClearRevealFlags();
revealLeft = value;
if ((revealLeft === null) || (revealLeft === false)) {
RemoveEffect(gameObject);
} else {
if (!gameObject._revealEffect) {
gameObject._revealEffect = fxFactory.addReveal(revealWidth, 0, 0);
}
gameObject._revealEffect.direction = 1;
gameObject._revealEffect.axis = 0;
gameObject._revealEffect.progress = revealLeft;
}
},
});
Object.defineProperty(gameObject, 'revealRight', {
get: function () {
return revealRight;
},
set: function (value) {
if (revealRight === value) {
return;
}
ClearRevealFlags();
revealRight = value;
if ((revealRight === null) || (revealRight === false)) {
RemoveEffect(gameObject);
} else {
if (!gameObject._revealEffect) {
gameObject._revealEffect = fxFactory.addReveal(revealWidth, 0, 0);
}
gameObject._revealEffect.direction = 0;
gameObject._revealEffect.axis = 0;
gameObject._revealEffect.progress = revealRight;
}
},
});
Object.defineProperty(gameObject, 'revealUp', {
get: function () {
return revealUp;
},
set: function (value) {
if (revealUp === value) {
return;
}
ClearRevealFlags();
revealUp = value;
if ((revealUp === null) || (revealUp === false)) {
RemoveEffect(gameObject);
} else {
if (!gameObject._revealEffect) {
gameObject._revealEffect = fxFactory.addReveal(revealWidth, 0, 0);
}
gameObject._revealEffect.direction = 1;
gameObject._revealEffect.axis = 1;
gameObject._revealEffect.progress = revealUp;
}
},
});
Object.defineProperty(gameObject, 'revealDown', {
get: function () {
return revealDown;
},
set: function (value) {
if (revealDown === value) {
return;
}
ClearRevealFlags();
revealDown = value;
if ((revealDown === null) || (revealDown === false)) {
RemoveEffect(gameObject);
} else {
if (!gameObject._revealEffect) {
gameObject._revealEffect = fxFactory.addReveal(revealWidth, 0, 0);
}
gameObject._revealEffect.direction = 0;
gameObject._revealEffect.axis = 1;
gameObject._revealEffect.progress = revealDown;
}
},
});
Object.defineProperty(gameObject, 'revealWidth', {
get: function () {
return revealWidth;
},
set: function (value) {
if (revealWidth === value) {
return;
}
revealWidth = value;
if (gameObject._revealEffect) {
gameObject._revealEffect.wipeWidth = revealWidth;
}
},
});
gameObject.revealLeft = null;
AddClearEffectCallback(gameObject, 'revealLeft');
AddClearEffectCallback(gameObject, 'revealRight');
AddClearEffectCallback(gameObject, 'revealUp');
AddClearEffectCallback(gameObject, 'revealDown');
return gameObject;
};
var AddSaturateProperties = function (gameObject) {
AddColorMatrixEffectPropertiesBase(gameObject, 'saturate', 1);
return gameObject;
};
var AddSepiaProperties = function (gameObject) {
AddColorMatrixEffectPropertiesBase(gameObject, 'sepia');
return gameObject;
};
var AddShadowProperties = function (gameObject) {
// Don't attach properties again
if (HasProperty(gameObject, 'shadowColor')) {
return gameObject;
}
var fxFactory = GetFXFactory(gameObject);
if (!fxFactory) {
return gameObject;
}
var shadowColor,
shadowX = 0,
shadowY = 0,
shadowDecay = 0.1,
shadowPower = 1,
shadowSamples = 6,
shadowIntensity = 1;
Object.defineProperty(gameObject, 'shadowColor', {
get: function () {
return shadowColor;
},
set: function (value) {
if (shadowColor === value) {
return;
}
shadowColor = value;
if ((shadowColor === null) || (shadowColor === false)) {
if (gameObject._shadow) {
fxFactory.remove(gameObject._shadow);
gameObject._shadow = undefined;
}
} else {
if (!gameObject._shadow) {
gameObject._shadow = fxFactory.addShadow(shadowX, shadowY, shadowDecay, shadowPower, shadowColor, shadowSamples, shadowIntensity);
}
gameObject._shadow.color = shadowColor;
}
},
});
Object.defineProperty(gameObject, 'shadowX', {
get: function () {
return shadowX;
},
set: function (value) {
if (shadowX === value) {
return;
}
shadowX = value;
if (gameObject._shadow) {
gameObject._shadow.x = shadowX;
}
},
});
Object.defineProperty(gameObject, 'shadowY', {
get: function () {
return shadowY;
},
set: function (value) {
if (shadowY === value) {
return;
}
shadowY = value;
if (gameObject._shadow) {
gameObject._shadow.y = shadowY;
}
},
});
Object.defineProperty(gameObject, 'decay', {
get: function () {
return shadowDecay;
},
set: function (value) {
if (shadowDecay === value) {
return;
}
shadowDecay = value;
if (gameObject._shadow) {
gameObject._shadow.decay = shadowDecay;
}
},
});
Object.defineProperty(gameObject, 'shadowPower', {
get: function () {
return shadowPower;
},
set: function (value) {
if (shadowPower === value) {
return;
}
shadowPower = value;
if (gameObject._shadow) {
gameObject._shadow.power = shadowPower;
}
},
});
Object.defineProperty(gameObject, 'shadowSamples', {
get: function () {
return shadowSamples;
},
set: function (value) {
if (shadowSamples === value) {
return;
}
shadowSamples = value;
if (gameObject._shadow) {
gameObject._shadow.samples = shadowSamples;
}
},
});
Object.defineProperty(gameObject, 'shadowIntensity', {
get: function () {
return shadowIntensity;
},
set: function (value) {
if (shadowIntensity === value) {
return;
}
shadowIntensity = value;
if (gameObject._shadow) {
gameObject._shadow.intensity = shadowIntensity;
}
},
});
gameObject.shadowColor = null;
AddClearEffectCallback(gameObject, 'shadowColor');
return gameObject;
};
var AddShiftToBGRProperties = function (gameObject) {
AddColorMatrixEffectPropertiesBase(gameObject, 'shiftToBGR');
return gameObject;
};
var AddShineProperties = function (gameObject) {
// Don't attach properties again
if (HasProperty(gameObject, 'shineSpeed')) {
return gameObject;
}
var fxFactory = GetFXFactory(gameObject);
if (!fxFactory) {
return gameObject;
}
var shineSpeed,
shineLineWidth = 0.5,
shineGradient = 3;
Object.defineProperty(gameObject, 'shineSpeed', {
get: function () {
return shineSpeed;
},
set: function (value) {
if (shineSpeed === value) {
return;
}
shineSpeed = value;
if ((shineSpeed === null) || (shineSpeed === false)) {
if (gameObject._shine) {
fxFactory.remove(gameObject._shine);
gameObject._shine = undefined;
}
} else {
if (!gameObject._shine) {
gameObject._shine = fxFactory.addShine(shineSpeed, shineLineWidth, shineGradient);
}
gameObject._shine.speed = shineSpeed;
}
},
});
Object.defineProperty(gameObject, 'shineLineWidth', {
get: function () {
return shineLineWidth;
},
set: function (value) {
if (shineLineWidth === value) {
return;
}
shineLineWidth = value;
if (gameObject._shine) {
gameObject._shine.lineWidth = shineLineWidth;
}
},
});
Object.defineProperty(gameObject, 'shineGradient', {
get: function () {
return shineGradient;
},
set: function (value) {
if (shineGradient === value) {
return;
}
shineGradient = value;
if (gameObject._shine) {
gameObject._shine.gradient = shineGradient;
}
},
});
gameObject.shineSpeed = null;
AddClearEffectCallback(gameObject, 'shineSpeed');
return gameObject;
};
var AddTechnicolorProperties = function (gameObject) {
AddColorMatrixEffectPropertiesBase(gameObject, 'technicolor');
return gameObject;
};
var AddTiltShiftProperties = function (gameObject) {
// Don't attach properties again
if (HasProperty(gameObject, 'tiltShiftRadius')) {
return gameObject;
}
var fxFactory = GetFXFactory(gameObject);
if (!fxFactory) {
return gameObject;
}
var tiltShiftRadius,
tiltShiftAmount = 1,
tiltShiftContrast = 0.2,
tiltShiftBlurX = 1,
tiltShiftBlurY = 1,
tiltShiftStrength = 1;
Object.defineProperty(gameObject, 'tiltShiftRadius', {
get: function () {
return tiltShiftRadius;
},
set: function (value) {
if (tiltShiftRadius === value) {
return;
}
tiltShiftRadius = value;
if ((tiltShiftRadius === null) || (tiltShiftRadius === false)) {
if (gameObject._tiltShift) {
fxFactory.remove(gameObject._tiltShift);
gameObject._tiltShift = undefined;
}
} else {
if (!gameObject._tiltShift) {
gameObject._tiltShift = fxFactory.addTiltShift(tiltShiftRadius, tiltShiftAmount, tiltShiftContrast, tiltShiftBlurX, tiltShiftBlurY, tiltShiftStrength);
}
gameObject._tiltShift.radius = tiltShiftRadius;
}
},
});
Object.defineProperty(gameObject, 'tiltShiftAmount', {
get: function () {
return tiltShiftAmount;
},
set: function (value) {
if (tiltShiftAmount === value) {
return;
}
tiltShiftAmount = value;
if (gameObject._tiltShift) {
gameObject._tiltShift.amount = tiltShiftAmount;
}
},
});
Object.defineProperty(gameObject, 'tiltShiftContrast', {
get: function () {
return tiltShiftContrast;
},
set: function (value) {
if (tiltShiftContrast === value) {
return;
}
tiltShiftContrast = value;
if (gameObject._tiltShift) {
gameObject._tiltShift.contrast = tiltShiftContrast;
}
},
});
Object.defineProperty(gameObject, 'tiltShiftBlurX', {
get: function () {
return tiltShiftBlurX;
},
set: function (value) {
if (tiltShiftBlurX === value) {
return;
}
tiltShiftBlurX = value;
if (gameObject._tiltShift) {
gameObject._tiltShift.blurX = tiltShiftBlurX;
}
},
});
Object.defineProperty(gameObject, 'tiltShiftBlurY', {
get: function () {
return tiltShiftBlurY;
},
set: function (value) {
if (tiltShiftBlurY === value) {
return;
}
tiltShiftBlurY = value;
if (gameObject._tiltShift) {
gameObject._tiltShift.blurY = tiltShiftBlurY;
}
},
});
Object.defineProperty(gameObject, 'tiltShiftStrength', {
get: function () {
return tiltShiftStrength;
},
set: function (value) {
if (tiltShiftStrength === value) {
return;
}
tiltShiftStrength = value;
if (gameObject._tiltShift) {
gameObject._tiltShift.strength = tiltShiftStrength;
}
},
});
gameObject.tiltShiftRadius = null;
AddClearEffectCallb