Skip to content

Commit 3ee75a7

Browse files
committed
Merge branch 'master' of https://github.com/photonstorm/phaser
2 parents cc2981d + d823c66 commit 3ee75a7

9 files changed

Lines changed: 123 additions & 71 deletions

File tree

src/boot/Config.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,13 @@ var ValueToColor = require('../display/color/ValueToColor');
3131
/**
3232
* Config object containing various sound settings.
3333
*
34-
* @typedef {object} SoundConfig
34+
* @typedef {object} AudioConfig
3535
*
36-
* @property {boolean} [mute=false] - Boolean indicating whether the sound should be muted or not.
37-
* @property {number} [volume=1] - A value between 0 (silence) and 1 (full volume).
38-
* @property {number} [rate=1] - Defines the speed at which the sound should be played.
39-
* @property {number} [detune=0] - Represents detuning of sound in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29).
40-
* @property {number} [seek=0] - Position of playback for this sound, in seconds.
41-
* @property {boolean} [loop=false] - Whether or not the sound or current sound marker should loop.
42-
* @property {number} [delay=0] - Time, in seconds, that should elapse before the sound actually starts its playback.
36+
* @property {boolean} [disableWebAudio=false] - Use HTML5 Audio instead of Web Audio.
37+
* @property {AudioContext} [context] - An existing Web Audio context.
38+
* @property {boolean} [noAudio=false] - Disable all audio output.
39+
*
40+
* @see Phaser.Sound.SoundManagerCreator
4341
*/
4442

4543
/**
@@ -481,7 +479,7 @@ var Config = new Class({
481479
this.disableContextMenu = GetValue(config, 'disableContextMenu', false);
482480

483481
/**
484-
* @const {SoundConfig} Phaser.Boot.Config#audio - The Audio Configuration object.
482+
* @const {AudioConfig} Phaser.Boot.Config#audio - The Audio Configuration object.
485483
*/
486484
this.audio = GetValue(config, 'audio');
487485

src/gameobjects/bitmaptext/static/BitmapText.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ var Render = require('./BitmapTextRender');
6868
*
6969
* To create a BitmapText data files you need a 3rd party app such as:
7070
*
71-
* BMFont (Windows, free): http://www.angelcode.com/products/bmfont/
72-
* Glyph Designer (OS X, commercial): http://www.71squared.com/en/glyphdesigner
73-
* Littera (Web-based, free): http://kvazars.com/littera/
71+
* BMFont (Windows, free): {@link http://www.angelcode.com/products/bmfont/|http://www.angelcode.com/products/bmfont/}
72+
* Glyph Designer (OS X, commercial): {@link http://www.71squared.com/en/glyphdesigner|http://www.71squared.com/en/glyphdesigner}
73+
* Littera (Web-based, free): {@link http://kvazars.com/littera/|http://kvazars.com/littera/}
7474
*
7575
* For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of
76-
* converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: http://codebeautify.org/xmltojson
76+
* converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: {@link http://codebeautify.org/xmltojson|http://codebeautify.org/xmltojson}
7777
*
7878
* @class BitmapText
7979
* @extends Phaser.GameObjects.GameObject

src/gameobjects/text/TextStyle.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -537,9 +537,9 @@ var TextStyle = new Class({
537537

538538
var i = 0;
539539

540-
this.fontStyle = (fontSplit.length > 2) ? fontSplit[i++] : '';
541-
this.fontSize = fontSplit[i++] || '16px';
542-
this.fontFamily = fontSplit[i++] || 'Courier';
540+
fontStyle = (fontSplit.length > 2) ? fontSplit[i++] : '';
541+
fontSize = fontSplit[i++] || '16px';
542+
fontFamily = fontSplit[i++] || 'Courier';
543543
}
544544

545545
if (fontFamily !== this.fontFamily || fontSize !== this.fontSize || fontStyle !== this.fontStyle)

src/renderer/webgl/pipelines/ForwardDiffuseLightPipeline.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@ var ForwardDiffuseLightPipeline = new Class({
4848
* @since 3.11.0
4949
*/
5050
this.defaultNormalMap;
51+
52+
/**
53+
* Inverse rotation matrix for normal map rotation fixing.
54+
*/
55+
this.inverseRotationMatrix = new Float32Array([
56+
1, 0, 0,
57+
0, 1, 0,
58+
0, 0, 1
59+
]);
5160
},
5261

5362
/**
@@ -244,6 +253,7 @@ var ForwardDiffuseLightPipeline = new Class({
244253
}
245254

246255
this.setTexture2D(normalTexture.glTexture, 1);
256+
this.setNormalMapRotation(rotation);
247257

248258
var camMatrix = this._tempMatrix1;
249259
var spriteMatrix = this._tempMatrix2;
@@ -412,6 +422,33 @@ var ForwardDiffuseLightPipeline = new Class({
412422
this.renderer.setPipeline(gameObject.defaultPipeline);
413423
},
414424

425+
/**
426+
* Rotates the normal map vectors inversely by the given angle.
427+
* Only works in 2D space.
428+
* @param {number} rotation rotation in angles
429+
*/
430+
setNormalMapRotation: function (rotation)
431+
{
432+
var inverseRotationMatrix = this.inverseRotationMatrix;
433+
if (rotation)
434+
{
435+
var rot = -rotation;
436+
var c = Math.cos(rot);
437+
var s = Math.sin(rot);
438+
439+
inverseRotationMatrix[1] = s;
440+
inverseRotationMatrix[3] = -s;
441+
inverseRotationMatrix[0] = inverseRotationMatrix[4] = c;
442+
}
443+
else
444+
{
445+
inverseRotationMatrix[0] = inverseRotationMatrix[4] = 1;
446+
inverseRotationMatrix[1] = inverseRotationMatrix[3] = 0;
447+
}
448+
449+
this.renderer.setMatrix3(this.program, 'uInverseRotationMatrix', false, inverseRotationMatrix);
450+
},
451+
415452
/**
416453
* Takes a Sprite Game Object, or any object that extends it, which has a normal texture and adds it to the batch.
417454
*
@@ -437,6 +474,7 @@ var ForwardDiffuseLightPipeline = new Class({
437474
this.renderer.setPipeline(this);
438475

439476
this.setTexture2D(normalTexture.glTexture, 1);
477+
this.setNormalMapRotation(sprite.rotation);
440478

441479
TextureTintPipeline.prototype.batchSprite.call(this, sprite, camera, parentTransformMatrix);
442480
}

src/renderer/webgl/shaders/ForwardDiffuse-frag.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ module.exports = [
1919
'uniform sampler2D uNormSampler;',
2020
'uniform vec3 uAmbientLightColor;',
2121
'uniform Light uLights[kMaxLights];',
22+
'uniform mat3 uInverseRotationMatrix;',
2223
'',
2324
'varying vec2 outTexCoord;',
2425
'varying vec4 outTint;',
@@ -28,7 +29,7 @@ module.exports = [
2829
' vec3 finalColor = vec3(0.0, 0.0, 0.0);',
2930
' vec4 color = texture2D(uMainSampler, outTexCoord) * vec4(outTint.rgb * outTint.a, outTint.a);',
3031
' vec3 normalMap = texture2D(uNormSampler, outTexCoord).rgb;',
31-
' vec3 normal = normalize(vec3(normalMap * 2.0 - 1.0));',
32+
' vec3 normal = normalize(uInverseRotationMatrix * vec3(normalMap * 2.0 - 1.0));',
3233
' vec2 res = vec2(min(uResolution.x, uResolution.y)) * uCamera.w;',
3334
'',
3435
' for (int index = 0; index < kMaxLights; ++index)',

src/renderer/webgl/shaders/src/ForwardDiffuse.frag

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ uniform sampler2D uMainSampler;
1818
uniform sampler2D uNormSampler;
1919
uniform vec3 uAmbientLightColor;
2020
uniform Light uLights[kMaxLights];
21+
uniform mat3 uInverseRotationMatrix;
2122

2223
varying vec2 outTexCoord;
2324
varying vec4 outTint;
@@ -27,7 +28,7 @@ void main()
2728
vec3 finalColor = vec3(0.0, 0.0, 0.0);
2829
vec4 color = texture2D(uMainSampler, outTexCoord) * vec4(outTint.rgb * outTint.a, outTint.a);
2930
vec3 normalMap = texture2D(uNormSampler, outTexCoord).rgb;
30-
vec3 normal = normalize(vec3(normalMap * 2.0 - 1.0));
31+
vec3 normal = normalize(uInverseRotationMatrix * vec3(normalMap * 2.0 - 1.0));
3132
vec2 res = vec2(min(uResolution.x, uResolution.y)) * uCamera.w;
3233

3334
for (int index = 0; index < kMaxLights; ++index)

src/scene/Scene.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,18 @@ var Scene = new Class({
242242
* @since 3.0.0
243243
*/
244244
this.matter;
245+
246+
if(typeof PLUGIN_FBINSTANT){
247+
/**
248+
* A scene level Facebook Instant Games Plugin.
249+
* This property will only be available if defined in the Scene Injection Map, the plugin is installed and configured.
250+
*
251+
* @name Phaser.Scene#facebook
252+
* @type {Phaser.FacebookInstantGamesPlugin}
253+
* @since 3.12.0
254+
*/
255+
this.facebook;
256+
}
245257
},
246258

247259
/**

src/scene/Systems.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ var Systems = new Class({
5858
* The Facebook Instant Games Plugin.
5959
*
6060
* @name Phaser.Scenes.Systems#facebook
61-
* @type {any}
61+
* @type {Phaser.FacebookInstantGamesPlugin}
6262
* @since 3.12.0
6363
*/
6464
this.facebook;

0 commit comments

Comments
 (0)