fisrt commit

This commit is contained in:
2026-01-17 11:49:36 +03:00
commit b2dfe51b9f
5379 changed files with 4408602 additions and 0 deletions

View File

@ -0,0 +1,13 @@
var fs = require('fs-extra');
var source = './plugins/camera3d/dist/';
var dest = '../phaser3-examples/public/plugins/';
if (fs.existsSync(dest))
{
fs.copySync(source, dest, { overwrite: true });
}
else
{
console.log('Copy-to-Examples failed: Phaser 3 Examples not present at ../phaser3-examples');
}

30532
node_modules/phaser/plugins/camera3d/dist/camera3d.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

93
node_modules/phaser/plugins/camera3d/readme.md generated vendored Normal file
View File

@ -0,0 +1,93 @@
Phaser 3 Camera 3D Plugin
=========================
Note: As of 26th August 2020 this plugin is now considered deprecated and will not be supported any further. It has been fixed to work with the Phaser 3.50 release, but will not be updated beyond this. You're free to use it as you see fit, but please do not open issues about it on GitHub, thank you.
In Phaser 3.12 Camera 3D support was moved to its own external plugin.
There are two ways to use this in your games:
## 1. External Plugin
You can copy the `dist/camera3d.min.js` file to your project folder and preload it into Phaser:
```
function preload ()
{
this.load.scenePlugin('Camera3DPlugin', 'plugins/camera3d.min.js', 'Camera3DPlugin', 'cameras3d');
}
```
Then you can use it like usual.
## 2. Bundled Plugin
If you prefer you can configure Phaser to include it when it builds its dist files.
To do this you need to edit the webpack config files and change the following:
```
"typeof PLUGIN_CAMERA3D": JSON.stringify(false)
```
to
```
"typeof PLUGIN_CAMERA3D": JSON.stringify(true)
```
Then rebuild Phaser via webpack. The plugin will now be included by default and can be called from your game code.
## Using the Plugin
Here is a basic example of using the plugin. You can find many more in the Phaser 3 Examples repo in the [cameras/3D Camera](https://github.com/photonstorm/phaser3-examples/tree/master/public/src/camera/3D%20camera) folder.
```
var config = {
type: Phaser.AUTO,
width: 800,
height: 600,
scene: {
preload: preload,
create: create,
update: update
}
};
var camera;
var transform;
var game = new Phaser.Game(config);
function preload ()
{
this.load.scenePlugin('Camera3DPlugin', 'plugins/camera3d.min.js', 'Camera3DPlugin', 'cameras3d');
this.load.image('particle', 'assets/sprites/mushroom2.png');
}
function create ()
{
camera = this.cameras3d.add(85).setZ(300).setPixelScale(128);
var sprites = camera.createRect({ x: 4, y: 4, z: 16 }, { x: 48, y: 48, z: 32 }, 'particle');
// Our rotation matrix
transform = new Phaser.Math.Matrix4().rotateX(-0.01).rotateY(-0.02).rotateZ(0.01);
}
function update ()
{
camera.transformChildren(transform);
}
```
## Building the External Plugin
If you wish to edit the plugin use the following files:
`src/Camera3DPlugin.js` is the entry point for the external plugin. Edit this file if you're loading the plugin at run-time. Once you have finished making your changes, run the command `npm run plugin.cam3d` from the command-line to build a new version of the external plugin with Webpack.
## Changing the Bundled Plugin
`src/index.js` is the entry point for the bundled plugin. In here you'll find the module exports that Phaser uses when including the plugin internally. The file `CameraManager.js` is the Scene System. All other files are shared between both the external and bundled versions of the plugin.

1071
node_modules/phaser/plugins/camera3d/src/Camera.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,340 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2018 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
var BuildGameObject = require('../../../src/gameobjects/BuildGameObject');
var BuildGameObjectAnimation = require('../../../src/gameobjects/BuildGameObjectAnimation');
var Class = require('../../../src/utils/Class');
var GetAdvancedValue = require('../../../src/utils/object/GetAdvancedValue');
var OrthographicCamera = require('./OrthographicCamera');
var PerspectiveCamera = require('./PerspectiveCamera');
var ScenePlugin = require('../../../src/plugins/ScenePlugin');
var Sprite3D = require('./sprite3d/Sprite3D');
/**
* @classdesc
* The Camera 3D Plugin adds a new Camera type to Phaser that allows for movement and rendering
* in 3D space. It displays a special type of Sprite called a Sprite3D that is a billboard sprite,
* with a z-axis allowing for perspective depth.
*
* This is an external plugin which you can include in your game by preloading it:
*
* ```javascript
* this.load.scenePlugin({
* key: 'Camera3DPlugin',
* url: 'plugins/camera3d.min.js',
* sceneKey: 'cameras3d'
* });
* ```
*
* Once loaded you can create a 3D Camera using the `camera3d` property of a Scene:
*
* `var camera = this.cameras3d.add(85).setZ(500).setPixelScale(128);`
*
* See the examples for more information.
*
* @class Camera3DPlugin
* @constructor
*
* @param {Phaser.Scene} scene - The Scene to which this plugin is being installed.
* @param {Phaser.Plugins.PluginManager} pluginManager - A reference to the Phaser Plugin Manager.
*/
var Camera3DPlugin = new Class({
Extends: ScenePlugin,
initialize:
function Camera3DPlugin (scene, pluginManager)
{
ScenePlugin.call(this, scene, pluginManager);
/**
* An Array of the Camera objects being managed by this Camera Manager.
*
* @name Camera3DPlugin#cameras
* @type {Phaser.Cameras.Sprite3D.Camera[]}
* @since 3.0.0
*/
this.cameras = [];
// Register the Sprite3D Game Object
pluginManager.registerGameObject('sprite3D', this.sprite3DFactory, this.sprite3DCreator);
},
/**
* Creates a new Sprite3D Game Object and adds it to the Scene.
*
* @method Phaser.GameObjects.GameObjectFactory#sprite3D
* @since 3.0.0
*
* @param {number} x - The horizontal position of this Game Object.
* @param {number} y - The vertical position of this Game Object.
* @param {number} z - The z position of this Game Object.
* @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager.
* @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with.
*
* @return {Phaser.GameObjects.Sprite3D} The Game Object that was created.
*/
sprite3DFactory: function (x, y, z, key, frame)
{
var sprite = new Sprite3D(this.scene, x, y, z, key, frame);
this.displayList.add(sprite.gameObject);
this.updateList.add(sprite.gameObject);
return sprite;
},
/**
* Creates a new Sprite3D Game Object and returns it.
*
* @method Phaser.GameObjects.GameObjectCreator#sprite3D
* @since 3.0.0
*
* @param {object} config - The configuration object this Game Object will use to create itself.
* @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object.
*
* @return {Phaser.GameObjects.Sprite3D} The Game Object that was created.
*/
sprite3DCreator: function (config, addToScene)
{
if (config === undefined) { config = {}; }
var key = GetAdvancedValue(config, 'key', null);
var frame = GetAdvancedValue(config, 'frame', null);
var sprite = new Sprite3D(this.scene, 0, 0, key, frame);
if (addToScene !== undefined)
{
config.add = addToScene;
}
BuildGameObject(this.scene, sprite, config);
// Sprite specific config options:
BuildGameObjectAnimation(sprite, config);
return sprite;
},
/**
* This method is called automatically, only once, when the Scene is first created.
* Do not invoke it directly.
*
* @method Phaser.Cameras.Scene3D.CameraManager#boot
* @private
* @since 3.5.1
*/
boot: function ()
{
this.systems.events.once('destroy', this.destroy, this);
},
/**
* This method is called automatically by the Scene when it is starting up.
* It is responsible for creating local systems, properties and listening for Scene events.
* Do not invoke it directly.
*
* @method Camera3DPlugin#start
* @private
* @since 3.5.0
*/
start: function ()
{
var eventEmitter = this.systems.events;
eventEmitter.on('update', this.update, this);
eventEmitter.once('shutdown', this.shutdown, this);
},
/**
* [description]
*
* @method Camera3DPlugin#add
* @since 3.0.0
*
* @param {number} [fieldOfView=80] - [description]
* @param {number} [width] - [description]
* @param {number} [height] - [description]
*
* @return {Phaser.Cameras.Sprite3D.PerspectiveCamera} [description]
*/
add: function (fieldOfView, width, height)
{
return this.addPerspectiveCamera(fieldOfView, width, height);
},
/**
* [description]
*
* @method Camera3DPlugin#addOrthographicCamera
* @since 3.0.0
*
* @param {number} width - [description]
* @param {number} height - [description]
*
* @return {Phaser.Cameras.Sprite3D.OrthographicCamera} [description]
*/
addOrthographicCamera: function (width, height)
{
var config = this.scene.sys.game.config;
if (width === undefined) { width = config.width; }
if (height === undefined) { height = config.height; }
var camera = new OrthographicCamera(this.scene, width, height);
this.cameras.push(camera);
return camera;
},
/**
* [description]
*
* @method Camera3DPlugin#addPerspectiveCamera
* @since 3.0.0
*
* @param {number} [fieldOfView=80] - [description]
* @param {number} [width] - [description]
* @param {number} [height] - [description]
*
* @return {Phaser.Cameras.Sprite3D.PerspectiveCamera} [description]
*/
addPerspectiveCamera: function (fieldOfView, width, height)
{
var config = this.scene.sys.game.config;
if (fieldOfView === undefined) { fieldOfView = 80; }
if (width === undefined) { width = config.width; }
if (height === undefined) { height = config.height; }
var camera = new PerspectiveCamera(this.scene, fieldOfView, width, height);
this.cameras.push(camera);
return camera;
},
/**
* [description]
*
* @method Camera3DPlugin#getCamera
* @since 3.0.0
*
* @param {string} name - [description]
*
* @return {(Phaser.Cameras.Sprite3D.OrthographicCamera|Phaser.Cameras.Sprite3D.PerspectiveCamera)} [description]
*/
getCamera: function (name)
{
for (var i = 0; i < this.cameras.length; i++)
{
if (this.cameras[i].name === name)
{
return this.cameras[i];
}
}
return null;
},
/**
* [description]
*
* @method Camera3DPlugin#removeCamera
* @since 3.0.0
*
* @param {(Phaser.Cameras.Sprite3D.OrthographicCamera|Phaser.Cameras.Sprite3D.PerspectiveCamera)} camera - [description]
*/
removeCamera: function (camera)
{
var cameraIndex = this.cameras.indexOf(camera);
if (cameraIndex !== -1)
{
this.cameras.splice(cameraIndex, 1);
}
},
/**
* [description]
*
* @method Camera3DPlugin#removeAll
* @since 3.0.0
*
* @return {(Phaser.Cameras.Sprite3D.OrthographicCamera|Phaser.Cameras.Sprite3D.PerspectiveCamera)} [description]
*/
removeAll: function ()
{
while (this.cameras.length > 0)
{
var camera = this.cameras.pop();
camera.destroy();
}
return this.main;
},
/**
* [description]
*
* @method Camera3DPlugin#update
* @since 3.0.0
*
* @param {number} timestep - [description]
* @param {number} delta - [description]
*/
update: function (timestep, delta)
{
for (var i = 0, l = this.cameras.length; i < l; ++i)
{
this.cameras[i].update(timestep, delta);
}
},
/**
* The Scene that owns this plugin is shutting down.
* We need to kill and reset all internal properties as well as stop listening to Scene events.
*
* @method Camera3DPlugin#shutdown
* @private
* @since 3.0.0
*/
shutdown: function ()
{
var eventEmitter = this.systems.events;
eventEmitter.off('update', this.update, this);
eventEmitter.off('shutdown', this.shutdown, this);
this.removeAll();
},
/**
* The Scene that owns this plugin is being destroyed.
* We need to shutdown and then kill off all external references.
*
* @method Camera3DPlugin#destroy
* @private
* @since 3.0.0
*/
destroy: function ()
{
this.shutdown();
this.pluginManager = null;
this.game = null;
this.scene = null;
this.systems = null;
}
});
module.exports = Camera3DPlugin;

View File

@ -0,0 +1,277 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2018 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
var Class = require('../../../src/utils/Class');
var OrthographicCamera = require('./OrthographicCamera');
var PerspectiveCamera = require('./PerspectiveCamera');
var PluginCache = require('../../../src/plugins/PluginCache');
/**
* @classdesc
* [description]
*
* @class CameraManager
* @memberOf Phaser.Cameras.Sprite3D
* @constructor
* @since 3.0.0
*
* @param {Phaser.Scene} scene - [description]
*/
var CameraManager = new Class({
initialize:
function CameraManager (scene)
{
/**
* [description]
*
* @name Phaser.Cameras.Sprite3D.CameraManager#scene
* @type {Phaser.Scene}
* @since 3.0.0
*/
this.scene = scene;
/**
* [description]
*
* @name Phaser.Cameras.Sprite3D.CameraManager#systems
* @type {Phaser.Scenes.Systems}
* @since 3.0.0
*/
this.systems = scene.sys;
/**
* An Array of the Camera objects being managed by this Camera Manager.
*
* @name Phaser.Cameras.Sprite3D.CameraManager#cameras
* @type {Phaser.Cameras.Sprite3D.Camera[]}
* @since 3.0.0
*/
this.cameras = [];
scene.sys.events.once('boot', this.boot, this);
scene.sys.events.on('start', this.start, this);
},
/**
* This method is called automatically, only once, when the Scene is first created.
* Do not invoke it directly.
*
* @method Phaser.Cameras.Scene3D.CameraManager#boot
* @private
* @since 3.5.1
*/
boot: function ()
{
this.systems.events.once('destroy', this.destroy, this);
},
/**
* This method is called automatically by the Scene when it is starting up.
* It is responsible for creating local systems, properties and listening for Scene events.
* Do not invoke it directly.
*
* @method Phaser.Cameras.Sprite3D.CameraManager#start
* @private
* @since 3.5.0
*/
start: function ()
{
var eventEmitter = this.systems.events;
eventEmitter.on('update', this.update, this);
eventEmitter.once('shutdown', this.shutdown, this);
},
/**
* [description]
*
* @method Phaser.Cameras.Sprite3D.CameraManager#add
* @since 3.0.0
*
* @param {number} [fieldOfView=80] - [description]
* @param {number} [width] - [description]
* @param {number} [height] - [description]
*
* @return {Phaser.Cameras.Sprite3D.PerspectiveCamera} [description]
*/
add: function (fieldOfView, width, height)
{
return this.addPerspectiveCamera(fieldOfView, width, height);
},
/**
* [description]
*
* @method Phaser.Cameras.Sprite3D.CameraManager#addOrthographicCamera
* @since 3.0.0
*
* @param {number} width - [description]
* @param {number} height - [description]
*
* @return {Phaser.Cameras.Sprite3D.OrthographicCamera} [description]
*/
addOrthographicCamera: function (width, height)
{
var config = this.scene.sys.game.config;
if (width === undefined) { width = config.width; }
if (height === undefined) { height = config.height; }
var camera = new OrthographicCamera(this.scene, width, height);
this.cameras.push(camera);
return camera;
},
/**
* [description]
*
* @method Phaser.Cameras.Sprite3D.CameraManager#addPerspectiveCamera
* @since 3.0.0
*
* @param {number} [fieldOfView=80] - [description]
* @param {number} [width] - [description]
* @param {number} [height] - [description]
*
* @return {Phaser.Cameras.Sprite3D.PerspectiveCamera} [description]
*/
addPerspectiveCamera: function (fieldOfView, width, height)
{
var config = this.scene.sys.game.config;
if (fieldOfView === undefined) { fieldOfView = 80; }
if (width === undefined) { width = config.width; }
if (height === undefined) { height = config.height; }
var camera = new PerspectiveCamera(this.scene, fieldOfView, width, height);
this.cameras.push(camera);
return camera;
},
/**
* [description]
*
* @method Phaser.Cameras.Sprite3D.CameraManager#getCamera
* @since 3.0.0
*
* @param {string} name - [description]
*
* @return {(Phaser.Cameras.Sprite3D.OrthographicCamera|Phaser.Cameras.Sprite3D.PerspectiveCamera)} [description]
*/
getCamera: function (name)
{
for (var i = 0; i < this.cameras.length; i++)
{
if (this.cameras[i].name === name)
{
return this.cameras[i];
}
}
return null;
},
/**
* [description]
*
* @method Phaser.Cameras.Sprite3D.CameraManager#removeCamera
* @since 3.0.0
*
* @param {(Phaser.Cameras.Sprite3D.OrthographicCamera|Phaser.Cameras.Sprite3D.PerspectiveCamera)} camera - [description]
*/
removeCamera: function (camera)
{
var cameraIndex = this.cameras.indexOf(camera);
if (cameraIndex !== -1)
{
this.cameras.splice(cameraIndex, 1);
}
},
/**
* [description]
*
* @method Phaser.Cameras.Sprite3D.CameraManager#removeAll
* @since 3.0.0
*
* @return {(Phaser.Cameras.Sprite3D.OrthographicCamera|Phaser.Cameras.Sprite3D.PerspectiveCamera)} [description]
*/
removeAll: function ()
{
while (this.cameras.length > 0)
{
var camera = this.cameras.pop();
camera.destroy();
}
return this.main;
},
/**
* [description]
*
* @method Phaser.Cameras.Sprite3D.CameraManager#update
* @since 3.0.0
*
* @param {number} timestep - [description]
* @param {number} delta - [description]
*/
update: function (timestep, delta)
{
for (var i = 0, l = this.cameras.length; i < l; ++i)
{
this.cameras[i].update(timestep, delta);
}
},
/**
* The Scene that owns this plugin is shutting down.
* We need to kill and reset all internal properties as well as stop listening to Scene events.
*
* @method Phaser.Cameras.Sprite3D.CameraManager#shutdown
* @private
* @since 3.0.0
*/
shutdown: function ()
{
var eventEmitter = this.systems.events;
eventEmitter.off('update', this.update, this);
eventEmitter.off('shutdown', this.shutdown, this);
this.removeAll();
},
/**
* The Scene that owns this plugin is being destroyed.
* We need to shutdown and then kill off all external references.
*
* @method Phaser.Cameras.Sprite3D.CameraManager#destroy
* @private
* @since 3.0.0
*/
destroy: function ()
{
this.shutdown();
this.scene.sys.events.off('start', this.start, this);
this.scene = null;
this.systems = null;
}
});
PluginCache.register('CameraManager3D', CameraManager, 'cameras3d');
module.exports = CameraManager;

View File

@ -0,0 +1,181 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2018 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
var Camera = require('./Camera');
var Class = require('../../../src/utils/Class');
var Vector3 = require('../../../src/math/Vector3');
// Local cache vars
var tmpVec3 = new Vector3();
/**
* @classdesc
* [description]
*
* @class OrthographicCamera
* @extends Phaser.Cameras.Sprite3D.Camera
* @memberOf Phaser.Cameras.Sprite3D
* @constructor
* @since 3.0.0
*
* @param {Phaser.Scene} scene - [description]
* @param {integer} [viewportWidth=0] - [description]
* @param {integer} [viewportHeight=0] - [description]
*/
var OrthographicCamera = new Class({
Extends: Camera,
initialize:
function OrthographicCamera (scene, viewportWidth, viewportHeight)
{
if (viewportWidth === undefined) { viewportWidth = 0; }
if (viewportHeight === undefined) { viewportHeight = 0; }
Camera.call(this, scene);
/**
* [description]
*
* @name Phaser.Cameras.Sprite3D.OrthographicCamera#viewportWidth
* @type {integer}
* @since 3.0.0
*/
this.viewportWidth = viewportWidth;
/**
* [description]
*
* @name Phaser.Cameras.Sprite3D.OrthographicCamera#viewportHeight
* @type {integer}
* @since 3.0.0
*/
this.viewportHeight = viewportHeight;
/**
* [description]
*
* @name Phaser.Cameras.Sprite3D.OrthographicCamera#_zoom
* @type {number}
* @private
* @since 3.0.0
*/
this._zoom = 1.0;
/**
* [description]
*
* @name Phaser.Cameras.Sprite3D.OrthographicCamera#near
* @type {number}
* @default 0
* @since 3.0.0
*/
this.near = 0;
this.update();
},
/**
* [description]
*
* @method Phaser.Cameras.Sprite3D.OrthographicCamera#setToOrtho
* @since 3.0.0
*
* @param {number} yDown - [description]
* @param {number} [viewportWidth] - [description]
* @param {number} [viewportHeight] - [description]
*
* @return {Phaser.Cameras.Sprite3D.OrthographicCamera} [description]
*/
setToOrtho: function (yDown, viewportWidth, viewportHeight)
{
if (viewportWidth === undefined) { viewportWidth = this.viewportWidth; }
if (viewportHeight === undefined) { viewportHeight = this.viewportHeight; }
var zoom = this.zoom;
this.up.set(0, (yDown) ? -1 : 1, 0);
this.direction.set(0, 0, (yDown) ? 1 : -1);
this.position.set(zoom * viewportWidth / 2, zoom * viewportHeight / 2, 0);
this.viewportWidth = viewportWidth;
this.viewportHeight = viewportHeight;
return this.update();
},
/**
* [description]
*
* @method Phaser.Cameras.Sprite3D.OrthographicCamera#update
* @since 3.0.0
*
* @return {Phaser.Cameras.Sprite3D.OrthographicCamera} [description]
*/
update: function ()
{
var w = this.viewportWidth;
var h = this.viewportHeight;
var near = Math.abs(this.near);
var far = Math.abs(this.far);
var zoom = this.zoom;
if (w === 0 || h === 0)
{
// What to do here... hmm?
return this;
}
this.projection.ortho(
zoom * -w / 2, zoom * w / 2,
zoom * -h / 2, zoom * h / 2,
near,
far
);
// Build the view matrix
tmpVec3.copy(this.position).add(this.direction);
this.view.lookAt(this.position, tmpVec3, this.up);
// Projection * view matrix
this.combined.copy(this.projection).multiply(this.view);
// Invert combined matrix, used for unproject
this.invProjectionView.copy(this.combined).invert();
this.billboardMatrixDirty = true;
this.updateChildren();
return this;
},
/**
* [description]
*
* @name Phaser.Cameras.Sprite3D.OrthographicCamera#zoom
* @type {number}
* @since 3.0.0
*/
zoom: {
get: function ()
{
return this._zoom;
},
set: function (value)
{
this._zoom = value;
this.update();
}
}
});
module.exports = OrthographicCamera;

View File

@ -0,0 +1,134 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2018 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
var Camera = require('./Camera');
var Class = require('../../../src/utils/Class');
var Vector3 = require('../../../src/math/Vector3');
// Local cache vars
var tmpVec3 = new Vector3();
/**
* @classdesc
* [description]
*
* @class PerspectiveCamera
* @extends Phaser.Cameras.Sprite3D.Camera
* @memberOf Phaser.Cameras.Sprite3D
* @constructor
* @since 3.0.0
*
* @param {Phaser.Scene} scene - [description]
* @param {integer} [fieldOfView=80] - [description]
* @param {integer} [viewportWidth=0] - [description]
* @param {integer} [viewportHeight=0] - [description]
*/
var PerspectiveCamera = new Class({
Extends: Camera,
// FOV is converted to radians automatically
initialize:
function PerspectiveCamera (scene, fieldOfView, viewportWidth, viewportHeight)
{
if (fieldOfView === undefined) { fieldOfView = 80; }
if (viewportWidth === undefined) { viewportWidth = 0; }
if (viewportHeight === undefined) { viewportHeight = 0; }
Camera.call(this, scene);
/**
* [description]
*
* @name Phaser.Cameras.Sprite3D.PerspectiveCamera#viewportWidth
* @type {integer}
* @default 0
* @since 3.0.0
*/
this.viewportWidth = viewportWidth;
/**
* [description]
*
* @name Phaser.Cameras.Sprite3D.PerspectiveCamera#viewportHeight
* @type {integer}
* @default 0
* @since 3.0.0
*/
this.viewportHeight = viewportHeight;
/**
* [description]
*
* @name Phaser.Cameras.Sprite3D.PerspectiveCamera#fieldOfView
* @type {integer}
* @default 80
* @since 3.0.0
*/
this.fieldOfView = fieldOfView * Math.PI / 180;
this.update();
},
/**
* [description]
*
* @method Phaser.Cameras.Sprite3D.PerspectiveCamera#setFOV
* @since 3.0.0
*
* @param {number} value - [description]
*
* @return {Phaser.Cameras.Sprite3D.PerspectiveCamera} [description]
*/
setFOV: function (value)
{
this.fieldOfView = value * Math.PI / 180;
return this;
},
/**
* [description]
*
* @method Phaser.Cameras.Sprite3D.PerspectiveCamera#update
* @since 3.0.0
*
* @return {Phaser.Cameras.Sprite3D.PerspectiveCamera} [description]
*/
update: function ()
{
var aspect = this.viewportWidth / this.viewportHeight;
// Create a perspective matrix for our camera
this.projection.perspective(
this.fieldOfView,
aspect,
Math.abs(this.near),
Math.abs(this.far)
);
// Build the view matrix
tmpVec3.copy(this.position).add(this.direction);
this.view.lookAt(this.position, tmpVec3, this.up);
// Projection * view matrix
this.combined.copy(this.projection).multiply(this.view);
// Invert combined matrix, used for unproject
this.invProjectionView.copy(this.combined).invert();
this.billboardMatrixDirty = true;
this.updateChildren();
return this;
}
});
module.exports = PerspectiveCamera;

18
node_modules/phaser/plugins/camera3d/src/index.js generated vendored Normal file
View File

@ -0,0 +1,18 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2018 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @namespace Phaser.Cameras.Sprite3D
*/
module.exports = {
Camera: require('./Camera'),
CameraManager: require('./CameraManager'),
OrthographicCamera: require('./OrthographicCamera'),
PerspectiveCamera: require('./PerspectiveCamera')
};

View File

@ -0,0 +1,260 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2018 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
var Class = require('../../../../src/utils/Class');
var GameObject = require('../../../../src/gameobjects/GameObject');
var Sprite = require('../../../../src/gameobjects/sprite/Sprite');
var Vector2 = require('../../../../src/math/Vector2');
var Vector4 = require('../../../../src/math/Vector4');
/**
* @classdesc
* A Sprite 3D Game Object.
*
* The Sprite 3D object is an encapsulation of a standard Sprite object, with additional methods to allow
* it to be rendered by a 3D Camera. The Sprite can be positioned anywhere within 3D space.
*
* @class Sprite3D
* @extends Phaser.GameObjects.Sprite
* @memberOf Phaser.GameObjects
* @constructor
* @since 3.0.0
*
* @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time.
* @param {number} x - The x position of this Game Object.
* @param {number} y - The y position of this Game Object.
* @param {number} z - The z position of this Game Object.
* @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager.
* @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with.
*/
var Sprite3D = new Class({
Extends: GameObject,
initialize:
function Sprite3D (scene, x, y, z, texture, frame)
{
GameObject.call(this, scene, 'Sprite3D');
/**
* The encapsulated Sprite.
*
* @name Phaser.GameObjects.Sprite3D#gameObject
* @type {Phaser.GameObjects.GameObject}
* @since 3.0.0
*/
this.gameObject = new Sprite(scene, 0, 0, texture, frame);
/**
* The position of the Sprite.
*
* @name Phaser.GameObjects.Sprite3D#position
* @type {Phaser.Math.Vector4}
* @since 3.0.0
*/
this.position = new Vector4(x, y, z);
/**
* The 2D size of the Sprite.
*
* @name Phaser.GameObjects.Sprite3D#size
* @type {Phaser.Math.Vector2}
* @since 3.0.0
*/
this.size = new Vector2(this.gameObject.width, this.gameObject.height);
/**
* The 2D scale of the Sprite.
*
* @name Phaser.GameObjects.Sprite3D#scale
* @type {Phaser.Math.Vector2}
* @since 3.0.0
*/
this.scale = new Vector2(1, 1);
/**
* Whether to automatically set the horizontal scale of the encapsulated Sprite.
*
* @name Phaser.GameObjects.Sprite3D#adjustScaleX
* @type {boolean}
* @default true
* @since 3.0.0
*/
this.adjustScaleX = true;
/**
* Whether to automatically set the vertical scale of the encapsulated Sprite.
*
* @name Phaser.GameObjects.Sprite3D#adjustScaleY
* @type {boolean}
* @default true
* @since 3.0.0
*/
this.adjustScaleY = true;
/**
* The visible state of the Game Object.
*
* @name Phaser.GameObjects.Sprite3D#_visible
* @type {boolean}
* @default true
* @private
* @since 3.0.0
*/
this._visible = true;
},
/**
* Project this Sprite onto the given 3D Camera.
*
* @method Phaser.GameObjects.Sprite3D#project
* @since 3.0.0
*
* @param {Phaser.Cameras.Sprite3D.Camera} camera - The 3D Camera onto which to project this Sprite.
*/
project: function (camera)
{
var pos = this.position;
var gameObject = this.gameObject;
camera.project(pos, gameObject);
camera.getPointSize(pos, this.size, this.scale);
if (this.scale.x <= 0 || this.scale.y <= 0)
{
gameObject.setVisible(false);
}
else
{
if (!gameObject.visible)
{
gameObject.setVisible(true);
}
if (this.adjustScaleX)
{
gameObject.scaleX = this.scale.x;
}
if (this.adjustScaleY)
{
gameObject.scaleY = this.scale.y;
}
gameObject.setDepth(gameObject.z * -1);
}
},
/**
* Set the visible state of the Game Object.
*
* @method Phaser.GameObjects.Sprite3D#setVisible
* @since 3.0.0
*
* @param {boolean} value - The visible state of the Game Object.
*
* @return {Phaser.GameObjects.Sprite3D} This Sprite3D Object.
*/
setVisible: function (value)
{
this.visible = value;
return this;
},
/**
* The visible state of the Game Object.
*
* An invisible Game Object will skip rendering, but will still process update logic.
*
* @name Phaser.GameObjects.Sprite3D#visible
* @type {boolean}
* @since 3.0.0
*/
visible: {
get: function ()
{
return this._visible;
},
set: function (value)
{
this._visible = value;
this.gameObject.visible = value;
}
},
/**
* The x position of this Game Object.
*
* @name Phaser.GameObjects.Sprite3D#x
* @type {number}
* @since 3.0.0
*/
x: {
get: function ()
{
return this.position.x;
},
set: function (value)
{
this.position.x = value;
}
},
/**
* The y position of this Game Object.
*
* @name Phaser.GameObjects.Sprite3D#y
* @type {number}
* @since 3.0.0
*/
y: {
get: function ()
{
return this.position.y;
},
set: function (value)
{
this.position.y = value;
}
},
/**
* The z position of this Game Object.
*
* @name Phaser.GameObjects.Sprite3D#z
* @type {number}
* @since 3.0.0
*/
z: {
get: function ()
{
return this.position.z;
},
set: function (value)
{
this.position.z = value;
}
}
});
module.exports = Sprite3D;

View File

@ -0,0 +1,49 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2018 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
var BuildGameObject = require('../../../../src/gameobjects/BuildGameObject');
var BuildGameObjectAnimation = require('../../../../src/gameobjects/BuildGameObjectAnimation');
var GameObjectCreator = require('../../../../src/gameobjects/GameObjectCreator');
var GetAdvancedValue = require('../../../../src/utils/object/GetAdvancedValue');
var Sprite3D = require('./Sprite3D');
/**
* Creates a new Sprite3D Game Object and returns it.
*
* Note: This method will only be available if the Sprite3D Game Object has been built into Phaser.
*
* @method Phaser.GameObjects.GameObjectCreator#sprite3D
* @since 3.0.0
*
* @param {object} config - The configuration object this Game Object will use to create itself.
* @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object.
*
* @return {Phaser.GameObjects.Sprite3D} The Game Object that was created.
*/
GameObjectCreator.register('sprite3D', function (config, addToScene)
{
if (config === undefined) { config = {}; }
var key = GetAdvancedValue(config, 'key', null);
var frame = GetAdvancedValue(config, 'frame', null);
var sprite = new Sprite3D(this.scene, 0, 0, key, frame);
if (addToScene !== undefined)
{
config.add = addToScene;
}
BuildGameObject(this.scene, sprite, config);
// Sprite specific config options:
BuildGameObjectAnimation(sprite, config);
return sprite;
});
// When registering a factory function 'this' refers to the GameObjectCreator context.

View File

@ -0,0 +1,42 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2018 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
var Sprite3D = require('./Sprite3D');
var GameObjectFactory = require('../../../../src/gameobjects/GameObjectFactory');
/**
* Creates a new Sprite3D Game Object and adds it to the Scene.
*
* Note: This method will only be available if the Sprite3D Game Object has been built into Phaser.
*
* @method Phaser.GameObjects.GameObjectFactory#sprite3D
* @since 3.0.0
*
* @param {number} x - The horizontal position of this Game Object.
* @param {number} y - The vertical position of this Game Object.
* @param {number} z - The z position of this Game Object.
* @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager.
* @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with.
*
* @return {Phaser.GameObjects.Sprite3D} The Game Object that was created.
*/
GameObjectFactory.register('sprite3D', function (x, y, z, key, frame)
{
var sprite = new Sprite3D(this.scene, x, y, z, key, frame);
this.displayList.add(sprite.gameObject);
this.updateList.add(sprite.gameObject);
return sprite;
});
// When registering a factory function 'this' refers to the GameObjectFactory context.
//
// There are several properties available to use:
//
// this.scene - a reference to the Scene that owns the GameObjectFactory
// this.displayList - a reference to the Display List the Scene owns
// this.updateList - a reference to the Update List the Scene owns

63
node_modules/phaser/plugins/camera3d/webpack.config.js generated vendored Normal file
View File

@ -0,0 +1,63 @@
'use strict';
const webpack = require('webpack');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const exec = require('child_process').exec;
const RemovePlugin = require('remove-files-webpack-plugin');
module.exports = {
mode: 'production',
context: `${__dirname}/src/`,
entry: {
camera3d: './Camera3DPlugin.js',
'camera3d.min': './Camera3DPlugin.js'
},
output: {
path: `${__dirname}/dist/`,
filename: '[name].js',
library: 'Camera3DPlugin',
libraryTarget: 'var'
},
performance: { hints: false },
optimization: {
minimizer: [
new UglifyJSPlugin({
include: /\.min\.js$/,
parallel: true,
sourceMap: false,
uglifyOptions: {
compress: true,
ie8: false,
ecma: 5,
output: {comments: false},
warnings: false
},
warningsFilter: () => false
})
]
},
plugins: [
new RemovePlugin({
before: {
root: './plugins/camera3d/dist/',
include: [ 'camera3d.js', 'camera3d.min.js' ]
}
}),
{
apply: (compiler) => {
compiler.hooks.afterEmit.tap('AfterEmitPlugin', (compilation) => {
exec('node plugins/camera3d/copy-to-examples.js', (err, stdout, stderr) => {
if (stdout) process.stdout.write(stdout);
if (stderr) process.stderr.write(stderr);
});
});
}
}
]
};

84
node_modules/phaser/plugins/fbinstant/readme.md generated vendored Normal file
View File

@ -0,0 +1,84 @@
Phaser 3 Facebook Instant Games Plugin
======================================
Starting with version 3.13 Phaser now has a dedicated plugin that provides complete support for Facebook Instant Games.
If you are using the pre-built versions of Phaser then use the file `phaser-facebook-instant-games.js` which you'll find in the `dist` folder.
If you are creating your own builds using Webpack then make sure you enable the plugin using the Webpack DefinePlugin control:
```
"typeof PLUGIN_FBINSTANT": JSON.stringify(true)
```
Building Phaser via Webpack with this set to `true` will include the plugin in the build.
## Using the Plugin
You need to include the Facebook SDK in your html and wait for the `initializeAsync` Promise to resolve before you should create your game instance:
```
<!DOCTYPE html>
<html>
<head>
<title>Phaser 3 Facebook Instant Games</title>
<meta charset="utf-8">
<script src="https://connect.facebook.net/en_US/fbinstant.6.2.js"></script>
<script src="lib/phaser-facebook-instant-games.js"></script>
</head>
<body>
FBInstant.initializeAsync().then(function() {
var config = {
type: Phaser.AUTO,
width: window.innerWidth,
height: window.innerHeight,
scene: ...
};
new Phaser.Game(config);
});
</body>
</html>
```
Now, when your game starts, you'll know that the FBInstant API is enabled and ready for use. To access the plugin use `this.facebook` from within any Scene, i.e.:
```
this.add.text(0, 0).setText(this.facebook.playerName);
```
### Preloader
To hook your games preloader into the Facebook Instant Games loader you should use a Preloader Scene like below:
```
class Preloader extends Phaser.Scene {
constructor ()
{
super('Preloader');
}
preload ()
{
this.facebook.showLoadProgress(this);
this.facebook.once('startgame', this.startGame, this);
// Now load all of your assets
}
startGame ()
{
this.scene.start('MainMenu');
}
}
```
In the above Scene it has hooked the Facebook preloader with the Phaser Loader, so every file that loads (once you add some) will make the Facebook loader update. When the load is over it will call the `startGame` function that just changes the Scene to another one.
Please look at the plugin documentation and the Facebook SDK documentation for more details about what features are available.

View File

@ -0,0 +1,26 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2018 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @typedef {object} AdInstance
*
* @property {any} instance - Represents an instance of an ad.
* @property {string} placementID - The Audience Network placement ID of this ad instance.
* @property {boolean} shown - Has this ad already been shown in-game?
* @property {boolean} video - Is this a video ad?
*/
var AdInstance = function (placementID, instance, video)
{
return {
instance: instance,
placementID: placementID,
shown: false,
video: video
};
};
module.exports = AdInstance;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,308 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2018 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
var Class = require('../../../src/utils/Class');
var EventEmitter = require('eventemitter3');
var LeaderboardScore = require('./LeaderboardScore');
/**
* @classdesc
* This class represents one single Leaderboard that belongs to a Facebook Instant Game.
*
* You do not need to instantiate this class directly, it will be created when you use the
* `getLeaderboard()` method of the main plugin.
*
* @class FacebookInstantGamesLeaderboard
* @memberOf Phaser
* @constructor
* @extends Phaser.Events.EventEmitter
* @since 3.13.0
*
* @param {Phaser.FacebookInstantGamesPlugin} plugin - A reference to the Facebook Instant Games Plugin.
* @param {any} data - An Instant Game leaderboard instance.
*/
var Leaderboard = new Class({
Extends: EventEmitter,
initialize:
function Leaderboard (plugin, data)
{
EventEmitter.call(this);
/**
* A reference to the Facebook Instant Games Plugin.
*
* @name Phaser.FacebookInstantGamesLeaderboard#plugin
* @type {Phaser.FacebookInstantGamesPlugin}
* @since 3.13.0
*/
this.plugin = plugin;
/**
* An Instant Game leaderboard instance.
*
* @name Phaser.FacebookInstantGamesLeaderboard#ref
* @type {any}
* @since 3.13.0
*/
this.ref = data;
/**
* The name of the leaderboard.
*
* @name Phaser.FacebookInstantGamesLeaderboard#name
* @type {string}
* @since 3.13.0
*/
this.name = data.getName();
/**
* The ID of the context that the leaderboard is associated with, or null if the leaderboard is not tied to a particular context.
*
* @name Phaser.FacebookInstantGamesLeaderboard#contextID
* @type {string}
* @since 3.13.0
*/
this.contextID = data.getContextID();
/**
* The total number of player entries in the leaderboard.
* This value defaults to zero. Populate it via the `getEntryCount()` method.
*
* @name Phaser.FacebookInstantGamesLeaderboard#entryCount
* @type {integer}
* @since 3.13.0
*/
this.entryCount = 0;
/**
* The players score object.
* This value defaults to `null`. Populate it via the `getPlayerScore()` method.
*
* @name Phaser.FacebookInstantGamesLeaderboard#playerScore
* @type {LeaderboardScore}
* @since 3.13.0
*/
this.playerScore = null;
/**
* The scores in the Leaderboard from the currently requested range.
* This value defaults to an empty array. Populate it via the `getScores()` method.
* The contents of this array are reset each time `getScores()` is called.
*
* @name Phaser.FacebookInstantGamesLeaderboard#scores
* @type {LeaderboardScore[]}
* @since 3.13.0
*/
this.scores = [];
this.getEntryCount();
},
/**
* Fetches the total number of player entries in the leaderboard.
*
* The data is requested in an async call, so the result isn't available immediately.
*
* When the call completes this Leaderboard will emit the `getentrycount` event along with the count and name of the Leaderboard.
*
* @method Phaser.FacebookInstantGamesLeaderboard#getEntryCount
* @since 3.13.0
*
* @return {this} This Leaderboard instance.
*/
getEntryCount: function ()
{
var _this = this;
this.ref.getEntryCountAsync().then(function (count)
{
_this.entryCount = count;
_this.emit('getentrycount', count, _this.name);
}).catch(function (e)
{
console.warn(e);
});
return this;
},
/**
* Updates the player's score. If the player has an existing score, the old score will only be replaced if the new score is better than it.
* NOTE: If the leaderboard is associated with a specific context, the game must be in that context to set a score for the player.
*
* The data is requested in an async call, so the result isn't available immediately.
*
* When the call completes this Leaderboard will emit the `setscore` event along with the LeaderboardScore object and the name of the Leaderboard.
*
* If the save fails the event will send `null` as the score value.
*
* @method Phaser.FacebookInstantGamesLeaderboard#setScore
* @since 3.13.0
*
* @param {integer} score - The new score for the player. Must be a 64-bit integer number.
* @param {(string|any)} [data] - Metadata to associate with the stored score. Must be less than 2KB in size. If an object is given it will be passed to `JSON.stringify`.
*
* @return {this} This Leaderboard instance.
*/
setScore: function (score, data)
{
if (data === undefined) { data = ''; }
if (typeof data === 'object')
{
data = JSON.stringify(data);
}
var _this = this;
this.ref.setScoreAsync(score, data).then(function (entry)
{
if (entry)
{
var score = LeaderboardScore(entry);
_this.playerScore = score;
_this.emit('setscore', score, _this.name);
}
else
{
_this.emit('setscore', null, _this.name);
}
}).catch(function (e)
{
console.warn(e);
});
return this;
},
/**
* Gets the players leaderboard entry and stores it in the `playerScore` property.
*
* The data is requested in an async call, so the result isn't available immediately.
*
* When the call completes this Leaderboard will emit the `getplayerscore` event along with the score and the name of the Leaderboard.
*
* If the player has not yet saved a score, the event will send `null` as the score value, and `playerScore` will be set to `null` as well.
*
* @method Phaser.FacebookInstantGamesLeaderboard#getPlayerScore
* @since 3.13.0
*
* @return {this} This Leaderboard instance.
*/
getPlayerScore: function ()
{
var _this = this;
this.ref.getPlayerEntryAsync().then(function (entry)
{
if (entry)
{
var score = LeaderboardScore(entry);
_this.playerScore = score;
_this.emit('getplayerscore', score, _this.name);
}
else
{
_this.emit('getplayerscore', null, _this.name);
}
}).catch(function (e)
{
console.warn(e);
});
return this;
},
/**
* Retrieves a set of leaderboard entries, ordered by score ranking in the leaderboard.
*
* The data is requested in an async call, so the result isn't available immediately.
*
* When the call completes this Leaderboard will emit the `getscores` event along with an array of LeaderboardScore entries and the name of the Leaderboard.
*
* @method Phaser.FacebookInstantGamesLeaderboard#getScores
* @since 3.13.0
*
* @param {integer} [count=10] - The number of entries to attempt to fetch from the leaderboard. Currently, up to a maximum of 100 entries may be fetched per query.
* @param {integer} [offset=0] - The offset from the top of the leaderboard that entries will be fetched from.
*
* @return {this} This Leaderboard instance.
*/
getScores: function (count, offset)
{
if (count === undefined) { count = 10; }
if (offset === undefined) { offset = 0; }
var _this = this;
this.ref.getEntriesAsync(count, offset).then(function (entries)
{
_this.scores = [];
entries.forEach(function (entry)
{
_this.scores.push(LeaderboardScore(entry));
});
_this.emit('getscores', _this.scores, _this.name);
}).catch(function (e)
{
console.warn(e);
});
return this;
},
/**
* Retrieves a set of leaderboard entries, based on the current player's connected players (including the current player), ordered by local rank within the set of connected players.
*
* The data is requested in an async call, so the result isn't available immediately.
*
* When the call completes this Leaderboard will emit the `getconnectedscores` event along with an array of LeaderboardScore entries and the name of the Leaderboard.
*
* @method Phaser.FacebookInstantGamesLeaderboard#getConnectedScores
* @since 3.16.0
*
* @return {this} This Leaderboard instance.
*/
getConnectedScores: function ()
{
var _this = this;
this.ref.getConnectedPlayerEntriesAsync().then(function (entries)
{
_this.scores = [];
entries.forEach(function (entry)
{
_this.scores.push(LeaderboardScore(entry));
});
_this.emit('getconnectedscores', _this.scores, _this.name);
}).catch(function (e)
{
console.warn(e);
});
return this;
}
});
module.exports = Leaderboard;

View File

@ -0,0 +1,34 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2018 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @typedef {object} LeaderboardScore
*
* @property {integer} score - An integer score value.
* @property {string} scoreFormatted - The score value, formatted with the score format associated with the leaderboard.
* @property {integer} timestamp - The Unix timestamp of when the leaderboard entry was last updated.
* @property {integer} rank - The entry's leaderboard ranking.
* @property {string} data - The developer-specified payload associated with the score, or null if one was not set.
* @property {string} playerName - The player's localized display name.
* @property {string} playerPhotoURL - A url to the player's public profile photo.
* @property {string} playerID - The game's unique identifier for the player.
*/
var LeaderboardScore = function (entry)
{
return {
score: entry.getScore(),
scoreFormatted: entry.getFormattedScore(),
timestamp: entry.getTimestamp(),
rank: entry.getRank(),
data: entry.getExtraData(),
playerName: entry.getPlayer().getName(),
playerPhotoURL: entry.getPlayer().getPhoto(),
playerID: entry.getPlayer().getID()
};
};
module.exports = LeaderboardScore;

32
node_modules/phaser/plugins/fbinstant/src/Product.js generated vendored Normal file
View File

@ -0,0 +1,32 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2018 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
var GetFastValue = require('../../../src/utils/object/GetFastValue');
/**
* @typedef {object} Product
*
* @property {string} [title] - The title of the product.
* @property {string} [productID] - The product's game-specified identifier.
* @property {string} [description] - The product description.
* @property {string} [imageURI] - A link to the product's associated image.
* @property {string} [price] - The price of the product.
* @property {string} [priceCurrencyCode] - The currency code for the product.
*/
var Product = function (data)
{
return {
title: GetFastValue(data, 'title', ''),
productID: GetFastValue(data, 'productID', ''),
description: GetFastValue(data, 'description', ''),
imageURI: GetFastValue(data, 'imageURI', ''),
price: GetFastValue(data, 'price', ''),
priceCurrencyCode: GetFastValue(data, 'priceCurrencyCode', '')
};
};
module.exports = Product;

32
node_modules/phaser/plugins/fbinstant/src/Purchase.js generated vendored Normal file
View File

@ -0,0 +1,32 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2018 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
var GetFastValue = require('../../../src/utils/object/GetFastValue');
/**
* @typedef {object} Purchase
*
* @property {string} [developerPayload] - A developer-specified string, provided during the purchase of the product.
* @property {string} [paymentID] - The identifier for the purchase transaction.
* @property {string} [productID] - The product's game-specified identifier.
* @property {string} [purchaseTime] - Unix timestamp of when the purchase occurred.
* @property {string} [purchaseToken] - A token representing the purchase that may be used to consume the purchase.
* @property {string} [signedRequest] - Server-signed encoding of the purchase request.
*/
var Purchase = function (data)
{
return {
developerPayload: GetFastValue(data, 'developerPayload', ''),
paymentID: GetFastValue(data, 'paymentID', ''),
productID: GetFastValue(data, 'productID', ''),
purchaseTime: GetFastValue(data, 'purchaseTime', ''),
purchaseToken: GetFastValue(data, 'purchaseToken', ''),
signedRequest: GetFastValue(data, 'signedRequest', '')
};
};
module.exports = Purchase;

595
node_modules/phaser/plugins/impact/Body.js generated vendored Normal file
View File

@ -0,0 +1,595 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Class = require('../../utils/Class');
var COLLIDES = require('./COLLIDES');
var GetVelocity = require('./GetVelocity');
var TYPE = require('./TYPE');
var UpdateMotion = require('./UpdateMotion');
/**
* @callback Phaser.Types.Physics.Impact.BodyUpdateCallback
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body} body - [description]
*/
/**
* @classdesc
* An Impact.js compatible physics body.
* This re-creates the properties you'd get on an Entity and the math needed to update them.
*
* @class Body
* @memberof Phaser.Physics.Impact
* @constructor
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.World} world - [description]
* @param {number} x - [description]
* @param {number} y - [description]
* @param {number} [sx=16] - [description]
* @param {number} [sy=16] - [description]
*/
var Body = new Class({
initialize:
function Body (world, x, y, sx, sy)
{
if (sx === undefined) { sx = 16; }
if (sy === undefined) { sy = sx; }
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#world
* @type {Phaser.Physics.Impact.World}
* @since 3.0.0
*/
this.world = world;
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#gameObject
* @type {Phaser.GameObjects.GameObject}
* @default null
* @since 3.0.0
*/
this.gameObject = null;
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#enabled
* @type {boolean}
* @default true
* @since 3.0.0
*/
this.enabled = true;
/**
* The ImpactBody, ImpactSprite or ImpactImage object that owns this Body, if any.
*
* @name Phaser.Physics.Impact.Body#parent
* @type {?(Phaser.Physics.Impact.ImpactBody|Phaser.Physics.Impact.ImpactImage|Phaser.Physics.Impact.ImpactSprite)}
* @since 3.0.0
*/
this.parent;
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#id
* @type {integer}
* @since 3.0.0
*/
this.id = world.getNextID();
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#name
* @type {string}
* @default ''
* @since 3.0.0
*/
this.name = '';
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#size
* @type {Phaser.Types.Math.Vector2Like}
* @since 3.0.0
*/
this.size = { x: sx, y: sy };
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#offset
* @type {Phaser.Types.Math.Vector2Like}
* @since 3.0.0
*/
this.offset = { x: 0, y: 0 };
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#pos
* @type {Phaser.Types.Math.Vector2Like}
* @since 3.0.0
*/
this.pos = { x: x, y: y };
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#last
* @type {Phaser.Types.Math.Vector2Like}
* @since 3.0.0
*/
this.last = { x: x, y: y };
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#vel
* @type {Phaser.Types.Math.Vector2Like}
* @since 3.0.0
*/
this.vel = { x: 0, y: 0 };
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#accel
* @type {Phaser.Types.Math.Vector2Like}
* @since 3.0.0
*/
this.accel = { x: 0, y: 0 };
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#friction
* @type {Phaser.Types.Math.Vector2Like}
* @since 3.0.0
*/
this.friction = { x: 0, y: 0 };
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#maxVel
* @type {Phaser.Types.Math.Vector2Like}
* @since 3.0.0
*/
this.maxVel = { x: world.defaults.maxVelocityX, y: world.defaults.maxVelocityY };
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#standing
* @type {boolean}
* @default false
* @since 3.0.0
*/
this.standing = false;
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#gravityFactor
* @type {number}
* @since 3.0.0
*/
this.gravityFactor = world.defaults.gravityFactor;
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#bounciness
* @type {number}
* @since 3.0.0
*/
this.bounciness = world.defaults.bounciness;
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#minBounceVelocity
* @type {number}
* @since 3.0.0
*/
this.minBounceVelocity = world.defaults.minBounceVelocity;
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#accelGround
* @type {number}
* @default 0
* @since 3.0.0
*/
this.accelGround = 0;
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#accelAir
* @type {number}
* @default 0
* @since 3.0.0
*/
this.accelAir = 0;
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#jumpSpeed
* @type {number}
* @default 0
* @since 3.0.0
*/
this.jumpSpeed = 0;
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#type
* @type {Phaser.Physics.Impact.TYPE}
* @since 3.0.0
*/
this.type = TYPE.NONE;
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#checkAgainst
* @type {Phaser.Physics.Impact.TYPE}
* @since 3.0.0
*/
this.checkAgainst = TYPE.NONE;
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#collides
* @type {Phaser.Physics.Impact.COLLIDES}
* @since 3.0.0
*/
this.collides = COLLIDES.NEVER;
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#debugShowBody
* @type {boolean}
* @since 3.0.0
*/
this.debugShowBody = world.defaults.debugShowBody;
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#debugShowVelocity
* @type {boolean}
* @since 3.0.0
*/
this.debugShowVelocity = world.defaults.debugShowVelocity;
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#debugBodyColor
* @type {integer}
* @since 3.0.0
*/
this.debugBodyColor = world.defaults.bodyDebugColor;
/**
* [description]
*
* @name Phaser.Physics.Impact.Body#updateCallback
* @type {?Phaser.Types.Physics.Impact.BodyUpdateCallback}
* @since 3.0.0
*/
this.updateCallback;
/**
* min 44 deg, max 136 deg
*
* @name Phaser.Physics.Impact.Body#slopeStanding
* @type {{ min: number, max: number }}
* @since 3.0.0
*/
this.slopeStanding = { min: 0.767944870877505, max: 2.3736477827122884 };
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Body#reset
* @since 3.0.0
*
* @param {number} x - [description]
* @param {number} y - [description]
*/
reset: function (x, y)
{
this.pos = { x: x, y: y };
this.last = { x: x, y: y };
this.vel = { x: 0, y: 0 };
this.accel = { x: 0, y: 0 };
this.friction = { x: 0, y: 0 };
this.maxVel = { x: 100, y: 100 };
this.standing = false;
this.gravityFactor = 1;
this.bounciness = 0;
this.minBounceVelocity = 40;
this.accelGround = 0;
this.accelAir = 0;
this.jumpSpeed = 0;
this.type = TYPE.NONE;
this.checkAgainst = TYPE.NONE;
this.collides = COLLIDES.NEVER;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Body#update
* @since 3.0.0
*
* @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate.
*/
update: function (delta)
{
var pos = this.pos;
this.last.x = pos.x;
this.last.y = pos.y;
this.vel.y += this.world.gravity * delta * this.gravityFactor;
this.vel.x = GetVelocity(delta, this.vel.x, this.accel.x, this.friction.x, this.maxVel.x);
this.vel.y = GetVelocity(delta, this.vel.y, this.accel.y, this.friction.y, this.maxVel.y);
var mx = this.vel.x * delta;
var my = this.vel.y * delta;
var res = this.world.collisionMap.trace(pos.x, pos.y, mx, my, this.size.x, this.size.y);
if (this.handleMovementTrace(res))
{
UpdateMotion(this, res);
}
var go = this.gameObject;
if (go)
{
go.x = (pos.x - this.offset.x) + go.displayOriginX * go.scaleX;
go.y = (pos.y - this.offset.y) + go.displayOriginY * go.scaleY;
}
if (this.updateCallback)
{
this.updateCallback(this);
}
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Body#drawDebug
* @since 3.0.0
*
* @param {Phaser.GameObjects.Graphics} graphic - [description]
*/
drawDebug: function (graphic)
{
var pos = this.pos;
if (this.debugShowBody)
{
graphic.lineStyle(1, this.debugBodyColor, 1);
graphic.strokeRect(pos.x, pos.y, this.size.x, this.size.y);
}
if (this.debugShowVelocity)
{
var x = pos.x + this.size.x / 2;
var y = pos.y + this.size.y / 2;
graphic.lineStyle(1, this.world.defaults.velocityDebugColor, 1);
graphic.lineBetween(x, y, x + this.vel.x, y + this.vel.y);
}
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Body#willDrawDebug
* @since 3.0.0
*
* @return {boolean} [description]
*/
willDrawDebug: function ()
{
return (this.debugShowBody || this.debugShowVelocity);
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Body#skipHash
* @since 3.0.0
*
* @return {boolean} [description]
*/
skipHash: function ()
{
return (!this.enabled || (this.type === 0 && this.checkAgainst === 0 && this.collides === 0));
},
/**
* Determines whether the body collides with the `other` one or not.
*
* @method Phaser.Physics.Impact.Body#touches
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body} other - [description]
*
* @return {boolean} [description]
*/
touches: function (other)
{
return !(
this.pos.x >= other.pos.x + other.size.x ||
this.pos.x + this.size.x <= other.pos.x ||
this.pos.y >= other.pos.y + other.size.y ||
this.pos.y + this.size.y <= other.pos.y
);
},
/**
* Reset the size and position of the physics body.
*
* @method Phaser.Physics.Impact.Body#resetSize
* @since 3.0.0
*
* @param {number} x - The x coordinate to position the body.
* @param {number} y - The y coordinate to position the body.
* @param {number} width - The width of the body.
* @param {number} height - The height of the body.
*
* @return {Phaser.Physics.Impact.Body} This Body object.
*/
resetSize: function (x, y, width, height)
{
this.pos.x = x;
this.pos.y = y;
this.size.x = width;
this.size.y = height;
return this;
},
/**
* Export this body object to JSON.
*
* @method Phaser.Physics.Impact.Body#toJSON
* @since 3.0.0
*
* @return {Phaser.Types.Physics.Impact.JSONImpactBody} JSON representation of this body object.
*/
toJSON: function ()
{
var output = {
name: this.name,
size: { x: this.size.x, y: this.size.y },
pos: { x: this.pos.x, y: this.pos.y },
vel: { x: this.vel.x, y: this.vel.y },
accel: { x: this.accel.x, y: this.accel.y },
friction: { x: this.friction.x, y: this.friction.y },
maxVel: { x: this.maxVel.x, y: this.maxVel.y },
gravityFactor: this.gravityFactor,
bounciness: this.bounciness,
minBounceVelocity: this.minBounceVelocity,
type: this.type,
checkAgainst: this.checkAgainst,
collides: this.collides
};
return output;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Body#fromJSON
* @todo Code it!
* @since 3.0.0
*
* @param {object} config - [description]
*/
fromJSON: function ()
{
},
/**
* Can be overridden by user code
*
* @method Phaser.Physics.Impact.Body#check
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body} other - [description]
*/
check: function ()
{
},
/**
* Can be overridden by user code
*
* @method Phaser.Physics.Impact.Body#collideWith
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body} other - [description]
* @param {string} axis - [description]
*/
collideWith: function (other, axis)
{
if (this.parent && this.parent._collideCallback)
{
this.parent._collideCallback.call(this.parent._callbackScope, this, other, axis);
}
},
/**
* Can be overridden by user code but must return a boolean.
*
* @method Phaser.Physics.Impact.Body#handleMovementTrace
* @since 3.0.0
*
* @param {number} res - [description]
*
* @return {boolean} [description]
*/
handleMovementTrace: function ()
{
return true;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Body#destroy
* @since 3.0.0
*/
destroy: function ()
{
this.world.remove(this);
this.enabled = false;
this.world = null;
this.gameObject = null;
this.parent = null;
}
});
module.exports = Body;

73
node_modules/phaser/plugins/impact/COLLIDES.js generated vendored Normal file
View File

@ -0,0 +1,73 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* Collision Types - Determine if and how entities collide with each other.
*
* In ACTIVE vs. LITE or FIXED vs. ANY collisions, only the "weak" entity moves,
* while the other one stays fixed. In ACTIVE vs. ACTIVE and ACTIVE vs. PASSIVE
* collisions, both entities are moved. LITE or PASSIVE entities don't collide
* with other LITE or PASSIVE entities at all. The behavior for FIXED vs.
* FIXED collisions is undefined.
*
* @namespace Phaser.Physics.Impact.COLLIDES
* @memberof Phaser.Physics.Impact
* @since 3.0.0
*/
module.exports = {
/**
* Never collides.
*
* @name Phaser.Physics.Impact.COLLIDES.NEVER
* @type {integer}
* @const
* @since 3.0.0
*/
NEVER: 0,
/**
* Lite collision.
*
* @name Phaser.Physics.Impact.COLLIDES.LITE
* @type {integer}
* @const
* @since 3.0.0
*/
LITE: 1,
/**
* Passive collision.
*
* @name Phaser.Physics.Impact.COLLIDES.PASSIVE
* @type {integer}
* @const
* @since 3.0.0
*/
PASSIVE: 2,
/**
* Active collision.
*
* @name Phaser.Physics.Impact.COLLIDES.ACTIVE
* @type {integer}
* @const
* @since 3.0.0
*/
ACTIVE: 4,
/**
* Fixed collision.
*
* @name Phaser.Physics.Impact.COLLIDES.FIXED
* @type {integer}
* @const
* @since 3.0.0
*/
FIXED: 8
};

358
node_modules/phaser/plugins/impact/CollisionMap.js generated vendored Normal file
View File

@ -0,0 +1,358 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Class = require('../../utils/Class');
var DefaultDefs = require('./DefaultDefs');
/**
* @classdesc
* [description]
*
* @class CollisionMap
* @memberof Phaser.Physics.Impact
* @constructor
* @since 3.0.0
*
* @param {integer} [tilesize=32] - [description]
* @param {array} [data] - [description]
*/
var CollisionMap = new Class({
initialize:
function CollisionMap (tilesize, data)
{
if (tilesize === undefined) { tilesize = 32; }
/**
* [description]
*
* @name Phaser.Physics.Impact.CollisionMap#tilesize
* @type {integer}
* @default 32
* @since 3.0.0
*/
this.tilesize = tilesize;
/**
* [description]
*
* @name Phaser.Physics.Impact.CollisionMap#data
* @type {array}
* @since 3.0.0
*/
this.data = (Array.isArray(data)) ? data : [];
/**
* [description]
*
* @name Phaser.Physics.Impact.CollisionMap#width
* @type {number}
* @since 3.0.0
*/
this.width = (Array.isArray(data)) ? data[0].length : 0;
/**
* [description]
*
* @name Phaser.Physics.Impact.CollisionMap#height
* @type {number}
* @since 3.0.0
*/
this.height = (Array.isArray(data)) ? data.length : 0;
/**
* [description]
*
* @name Phaser.Physics.Impact.CollisionMap#lastSlope
* @type {integer}
* @default 55
* @since 3.0.0
*/
this.lastSlope = 55;
/**
* [description]
*
* @name Phaser.Physics.Impact.CollisionMap#tiledef
* @type {object}
* @since 3.0.0
*/
this.tiledef = DefaultDefs;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.CollisionMap#trace
* @since 3.0.0
*
* @param {number} x - [description]
* @param {number} y - [description]
* @param {number} vx - [description]
* @param {number} vy - [description]
* @param {number} objectWidth - [description]
* @param {number} objectHeight - [description]
*
* @return {boolean} [description]
*/
trace: function (x, y, vx, vy, objectWidth, objectHeight)
{
// Set up the trace-result
var res = {
collision: { x: false, y: false, slope: false },
pos: { x: x + vx, y: y + vy },
tile: { x: 0, y: 0 }
};
if (!this.data)
{
return res;
}
var steps = Math.ceil(Math.max(Math.abs(vx), Math.abs(vy)) / this.tilesize);
if (steps > 1)
{
var sx = vx / steps;
var sy = vy / steps;
for (var i = 0; i < steps && (sx || sy); i++)
{
this.step(res, x, y, sx, sy, objectWidth, objectHeight, vx, vy, i);
x = res.pos.x;
y = res.pos.y;
if (res.collision.x)
{
sx = 0;
vx = 0;
}
if (res.collision.y)
{
sy = 0;
vy = 0;
}
if (res.collision.slope)
{
break;
}
}
}
else
{
this.step(res, x, y, vx, vy, objectWidth, objectHeight, vx, vy, 0);
}
return res;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.CollisionMap#step
* @since 3.0.0
*
* @param {object} res - [description]
* @param {number} x - [description]
* @param {number} y - [description]
* @param {number} vx - [description]
* @param {number} vy - [description]
* @param {number} width - [description]
* @param {number} height - [description]
* @param {number} rvx - [description]
* @param {number} rvy - [description]
* @param {number} step - [description]
*/
step: function (res, x, y, vx, vy, width, height, rvx, rvy, step)
{
var t = 0;
var tileX;
var tileY;
var tilesize = this.tilesize;
var mapWidth = this.width;
var mapHeight = this.height;
// Horizontal
if (vx)
{
var pxOffsetX = (vx > 0 ? width : 0);
var tileOffsetX = (vx < 0 ? tilesize : 0);
var firstTileY = Math.max(Math.floor(y / tilesize), 0);
var lastTileY = Math.min(Math.ceil((y + height) / tilesize), mapHeight);
tileX = Math.floor((res.pos.x + pxOffsetX) / tilesize);
var prevTileX = Math.floor((x + pxOffsetX) / tilesize);
if (step > 0 || tileX === prevTileX || prevTileX < 0 || prevTileX >= mapWidth)
{
prevTileX = -1;
}
if (tileX >= 0 && tileX < mapWidth)
{
for (tileY = firstTileY; tileY < lastTileY; tileY++)
{
if (prevTileX !== -1)
{
t = this.data[tileY][prevTileX];
if (t > 1 && t <= this.lastSlope && this.checkDef(res, t, x, y, rvx, rvy, width, height, prevTileX, tileY))
{
break;
}
}
t = this.data[tileY][tileX];
if (t === 1 || t > this.lastSlope || (t > 1 && this.checkDef(res, t, x, y, rvx, rvy, width, height, tileX, tileY)))
{
if (t > 1 && t <= this.lastSlope && res.collision.slope)
{
break;
}
res.collision.x = true;
res.tile.x = t;
res.pos.x = (tileX * tilesize) - pxOffsetX + tileOffsetX;
x = res.pos.x;
rvx = 0;
break;
}
}
}
}
// Vertical
if (vy)
{
var pxOffsetY = (vy > 0 ? height : 0);
var tileOffsetY = (vy < 0 ? tilesize : 0);
var firstTileX = Math.max(Math.floor(res.pos.x / tilesize), 0);
var lastTileX = Math.min(Math.ceil((res.pos.x + width) / tilesize), mapWidth);
tileY = Math.floor((res.pos.y + pxOffsetY) / tilesize);
var prevTileY = Math.floor((y + pxOffsetY) / tilesize);
if (step > 0 || tileY === prevTileY || prevTileY < 0 || prevTileY >= mapHeight)
{
prevTileY = -1;
}
if (tileY >= 0 && tileY < mapHeight)
{
for (tileX = firstTileX; tileX < lastTileX; tileX++)
{
if (prevTileY !== -1)
{
t = this.data[prevTileY][tileX];
if (t > 1 && t <= this.lastSlope && this.checkDef(res, t, x, y, rvx, rvy, width, height, tileX, prevTileY))
{
break;
}
}
t = this.data[tileY][tileX];
if (t === 1 || t > this.lastSlope || (t > 1 && this.checkDef(res, t, x, y, rvx, rvy, width, height, tileX, tileY)))
{
if (t > 1 && t <= this.lastSlope && res.collision.slope)
{
break;
}
res.collision.y = true;
res.tile.y = t;
res.pos.y = tileY * tilesize - pxOffsetY + tileOffsetY;
break;
}
}
}
}
},
/**
* [description]
*
* @method Phaser.Physics.Impact.CollisionMap#checkDef
* @since 3.0.0
*
* @param {object} res - [description]
* @param {number} t - [description]
* @param {number} x - [description]
* @param {number} y - [description]
* @param {number} vx - [description]
* @param {number} vy - [description]
* @param {number} width - [description]
* @param {number} height - [description]
* @param {number} tileX - [description]
* @param {number} tileY - [description]
*
* @return {boolean} [description]
*/
checkDef: function (res, t, x, y, vx, vy, width, height, tileX, tileY)
{
var def = this.tiledef[t];
if (!def)
{
return false;
}
var tilesize = this.tilesize;
var lx = (tileX + def[0]) * tilesize;
var ly = (tileY + def[1]) * tilesize;
var lvx = (def[2] - def[0]) * tilesize;
var lvy = (def[3] - def[1]) * tilesize;
var solid = def[4];
var tx = x + vx + (lvy < 0 ? width : 0) - lx;
var ty = y + vy + (lvx > 0 ? height : 0) - ly;
if (lvx * ty - lvy * tx > 0)
{
if (vx * -lvy + vy * lvx < 0)
{
return solid;
}
var length = Math.sqrt(lvx * lvx + lvy * lvy);
var nx = lvy / length;
var ny = -lvx / length;
var proj = tx * nx + ty * ny;
var px = nx * proj;
var py = ny * proj;
if (px * px + py * py >= vx * vx + vy * vy)
{
return solid || (lvx * (ty - vy) - lvy * (tx - vx) < 0.5);
}
res.pos.x = x + vx - px;
res.pos.y = y + vy - py;
res.collision.slope = { x: lvx, y: lvy, nx: nx, ny: ny };
return true;
}
return false;
}
});
module.exports = CollisionMap;

65
node_modules/phaser/plugins/impact/DefaultDefs.js generated vendored Normal file
View File

@ -0,0 +1,65 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var H = 0.5;
var N = 1 / 3;
var M = 2 / 3;
// Tile ID to Slope defs.
// First 4 elements = line data, final = solid or non-solid behind the line
module.exports = {
2: [ 0, 1, 1, 0, true ],
3: [ 0, 1, 1, H, true ],
4: [ 0, H, 1, 0, true ],
5: [ 0, 1, 1, M, true ],
6: [ 0, M, 1, N, true ],
7: [ 0, N, 1, 0, true ],
8: [ H, 1, 0, 0, true ],
9: [ 1, 0, H, 1, true ],
10: [ H, 1, 1, 0, true ],
11: [ 0, 0, H, 1, true ],
12: [ 0, 0, 1, 0, false ],
13: [ 1, 1, 0, 0, true ],
14: [ 1, H, 0, 0, true ],
15: [ 1, 1, 0, H, true ],
16: [ 1, N, 0, 0, true ],
17: [ 1, M, 0, N, true ],
18: [ 1, 1, 0, M, true ],
19: [ 1, 1, H, 0, true ],
20: [ H, 0, 0, 1, true ],
21: [ 0, 1, H, 0, true ],
22: [ H, 0, 1, 1, true ],
23: [ 1, 1, 0, 1, false ],
24: [ 0, 0, 1, 1, true ],
25: [ 0, 0, 1, H, true ],
26: [ 0, H, 1, 1, true ],
27: [ 0, 0, 1, N, true ],
28: [ 0, N, 1, M, true ],
29: [ 0, M, 1, 1, true ],
30: [ N, 1, 0, 0, true ],
31: [ 1, 0, M, 1, true ],
32: [ M, 1, 1, 0, true ],
33: [ 0, 0, N, 1, true ],
34: [ 1, 0, 1, 1, false ],
35: [ 1, 0, 0, 1, true ],
36: [ 1, H, 0, 1, true ],
37: [ 1, 0, 0, H, true ],
38: [ 1, M, 0, 1, true ],
39: [ 1, N, 0, M, true ],
40: [ 1, 0, 0, N, true ],
41: [ M, 1, N, 0, true ],
42: [ M, 0, N, 1, true ],
43: [ N, 1, M, 0, true ],
44: [ N, 0, M, 1, true ],
45: [ 0, 1, 0, 0, false ],
52: [ 1, 1, M, 0, true ],
53: [ N, 0, 0, 1, true ],
54: [ 0, 1, N, 0, true ],
55: [ M, 0, 1, 1, true ]
};

151
node_modules/phaser/plugins/impact/Factory.js generated vendored Normal file
View File

@ -0,0 +1,151 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Class = require('../../utils/Class');
var ImpactBody = require('./ImpactBody');
var ImpactImage = require('./ImpactImage');
var ImpactSprite = require('./ImpactSprite');
/**
* @classdesc
* The Impact Physics Factory allows you to easily create Impact Physics enabled Game Objects.
* Objects that are created by this Factory are automatically added to the physics world.
*
* @class Factory
* @memberof Phaser.Physics.Impact
* @constructor
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.World} world - A reference to the Impact Physics world.
*/
var Factory = new Class({
initialize:
function Factory (world)
{
/**
* A reference to the Impact Physics world.
*
* @name Phaser.Physics.Impact.Factory#world
* @type {Phaser.Physics.Impact.World}
* @since 3.0.0
*/
this.world = world;
/**
* A reference to the Scene.Systems this Impact Physics instance belongs to.
*
* @name Phaser.Physics.Impact.Factory#sys
* @type {Phaser.Scenes.Systems}
* @since 3.0.0
*/
this.sys = world.scene.sys;
},
/**
* Creates a new ImpactBody object and adds it to the physics simulation.
*
* @method Phaser.Physics.Impact.Factory#body
* @since 3.0.0
*
* @param {number} x - The horizontal position of the body in the physics world.
* @param {number} y - The vertical position of the body in the physics world.
* @param {number} width - The width of the body.
* @param {number} height - The height of the body.
*
* @return {Phaser.Physics.Impact.ImpactBody} The ImpactBody object that was created.
*/
body: function (x, y, width, height)
{
return new ImpactBody(this.world, x, y, width, height);
},
/**
* Adds an Impact Physics Body to the given Game Object.
*
* @method Phaser.Physics.Impact.Factory#existing
* @since 3.0.0
*
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to receive the physics body.
*
* @return {Phaser.GameObjects.GameObject} The Game Object.
*/
existing: function (gameObject)
{
var x = gameObject.x - gameObject.frame.centerX;
var y = gameObject.y - gameObject.frame.centerY;
var w = gameObject.width;
var h = gameObject.height;
gameObject.body = this.world.create(x, y, w, h);
gameObject.body.parent = gameObject;
gameObject.body.gameObject = gameObject;
return gameObject;
},
/**
* Creates a new ImpactImage object and adds it to the physics world.
*
* @method Phaser.Physics.Impact.Factory#image
* @since 3.0.0
*
* @param {number} x - The horizontal position of this Game Object in the world.
* @param {number} y - The vertical position of this Game Object in the world.
* @param {string} key - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager.
* @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with.
*
* @return {Phaser.Physics.Impact.ImpactImage} The ImpactImage object that was created.
*/
image: function (x, y, key, frame)
{
var image = new ImpactImage(this.world, x, y, key, frame);
this.sys.displayList.add(image);
return image;
},
/**
* Creates a new ImpactSprite object and adds it to the physics world.
*
* @method Phaser.Physics.Impact.Factory#sprite
* @since 3.0.0
*
* @param {number} x - The horizontal position of this Game Object in the world.
* @param {number} y - The vertical position of this Game Object in the world.
* @param {string} key - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager.
* @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with.
*
* @return {Phaser.Physics.Impact.ImpactSprite} The ImpactSprite object that was created.
*/
sprite: function (x, y, key, frame)
{
var sprite = new ImpactSprite(this.world, x, y, key, frame);
this.sys.displayList.add(sprite);
this.sys.updateList.add(sprite);
return sprite;
},
/**
* Destroys this Factory.
*
* @method Phaser.Physics.Impact.Factory#destroy
* @since 3.5.0
*/
destroy: function ()
{
this.world = null;
this.sys = null;
}
});
module.exports = Factory;

50
node_modules/phaser/plugins/impact/GetVelocity.js generated vendored Normal file
View File

@ -0,0 +1,50 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Clamp = require('../../math/Clamp');
/**
* [description]
*
* @function Phaser.Physics.Impact.GetVelocity
* @since 3.0.0
*
* @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate.
* @param {number} vel - [description]
* @param {number} accel - [description]
* @param {number} friction - [description]
* @param {number} max - [description]
*
* @return {number} [description]
*/
var GetVelocity = function (delta, vel, accel, friction, max)
{
if (accel)
{
return Clamp(vel + accel * delta, -max, max);
}
else if (friction)
{
var frictionDelta = friction * delta;
if (vel - frictionDelta > 0)
{
return vel - frictionDelta;
}
else if (vel + frictionDelta < 0)
{
return vel + frictionDelta;
}
else
{
return 0;
}
}
return Clamp(vel, -max, max);
};
module.exports = GetVelocity;

127
node_modules/phaser/plugins/impact/ImpactBody.js generated vendored Normal file
View File

@ -0,0 +1,127 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Class = require('../../utils/Class');
var Components = require('./components');
/**
* @classdesc
* [description]
*
* @class ImpactBody
* @memberof Phaser.Physics.Impact
* @constructor
* @since 3.0.0
*
* @extends Phaser.Physics.Impact.Components.Acceleration
* @extends Phaser.Physics.Impact.Components.BodyScale
* @extends Phaser.Physics.Impact.Components.BodyType
* @extends Phaser.Physics.Impact.Components.Bounce
* @extends Phaser.Physics.Impact.Components.CheckAgainst
* @extends Phaser.Physics.Impact.Components.Collides
* @extends Phaser.Physics.Impact.Components.Debug
* @extends Phaser.Physics.Impact.Components.Friction
* @extends Phaser.Physics.Impact.Components.Gravity
* @extends Phaser.Physics.Impact.Components.Offset
* @extends Phaser.Physics.Impact.Components.SetGameObject
* @extends Phaser.Physics.Impact.Components.Velocity
*
* @param {Phaser.Physics.Impact.World} world - [description]
* @param {number} x - x - The horizontal position of this physics body in the world.
* @param {number} y - y - The vertical position of this physics body in the world.
* @param {number} width - The width of the physics body in the world.
* @param {number} height - [description]
*/
var ImpactBody = new Class({
Mixins: [
Components.Acceleration,
Components.BodyScale,
Components.BodyType,
Components.Bounce,
Components.CheckAgainst,
Components.Collides,
Components.Debug,
Components.Friction,
Components.Gravity,
Components.Offset,
Components.SetGameObject,
Components.Velocity
],
initialize:
function ImpactBody (world, x, y, width, height)
{
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactBody#body
* @type {Phaser.Physics.Impact.Body}
* @since 3.0.0
*/
this.body = world.create(x, y, width, height);
this.body.parent = this;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactBody#size
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.size = this.body.size;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactBody#offset
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.offset = this.body.offset;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactBody#vel
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.vel = this.body.vel;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactBody#accel
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.accel = this.body.accel;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactBody#friction
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.friction = this.body.friction;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactBody#maxVel
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.maxVel = this.body.maxVel;
}
});
module.exports = ImpactBody;

152
node_modules/phaser/plugins/impact/ImpactImage.js generated vendored Normal file
View File

@ -0,0 +1,152 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Class = require('../../utils/Class');
var Components = require('./components');
var Image = require('../../gameobjects/image/Image');
/**
* @classdesc
* An Impact Physics Image Game Object.
*
* An Image is a light-weight Game Object useful for the display of static images in your game,
* such as logos, backgrounds, scenery or other non-animated elements. Images can have input
* events and physics bodies, or be tweened, tinted or scrolled. The main difference between an
* Image and a Sprite is that you cannot animate an Image as they do not have the Animation component.
*
* @class ImpactImage
* @extends Phaser.GameObjects.Image
* @memberof Phaser.Physics.Impact
* @constructor
* @since 3.0.0
*
* @extends Phaser.Physics.Impact.Components.Acceleration
* @extends Phaser.Physics.Impact.Components.BodyScale
* @extends Phaser.Physics.Impact.Components.BodyType
* @extends Phaser.Physics.Impact.Components.Bounce
* @extends Phaser.Physics.Impact.Components.CheckAgainst
* @extends Phaser.Physics.Impact.Components.Collides
* @extends Phaser.Physics.Impact.Components.Debug
* @extends Phaser.Physics.Impact.Components.Friction
* @extends Phaser.Physics.Impact.Components.Gravity
* @extends Phaser.Physics.Impact.Components.Offset
* @extends Phaser.Physics.Impact.Components.SetGameObject
* @extends Phaser.Physics.Impact.Components.Velocity
* @extends Phaser.GameObjects.Components.Alpha
* @extends Phaser.GameObjects.Components.BlendMode
* @extends Phaser.GameObjects.Components.Depth
* @extends Phaser.GameObjects.Components.Flip
* @extends Phaser.GameObjects.Components.GetBounds
* @extends Phaser.GameObjects.Components.Origin
* @extends Phaser.GameObjects.Components.Pipeline
* @extends Phaser.GameObjects.Components.ScrollFactor
* @extends Phaser.GameObjects.Components.Size
* @extends Phaser.GameObjects.Components.Texture
* @extends Phaser.GameObjects.Components.Tint
* @extends Phaser.GameObjects.Components.Transform
* @extends Phaser.GameObjects.Components.Visible
*
* @param {Phaser.Physics.Impact.World} world - The physics world of the Impact physics system.
* @param {number} x - The horizontal position of this Game Object in the world.
* @param {number} y - The vertical position of this Game Object in the world.
* @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager.
* @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with.
*/
var ImpactImage = new Class({
Extends: Image,
Mixins: [
Components.Acceleration,
Components.BodyScale,
Components.BodyType,
Components.Bounce,
Components.CheckAgainst,
Components.Collides,
Components.Debug,
Components.Friction,
Components.Gravity,
Components.Offset,
Components.SetGameObject,
Components.Velocity
],
initialize:
function ImpactImage (world, x, y, texture, frame)
{
Image.call(this, world.scene, x, y, texture, frame);
/**
* The Physics Body linked to an ImpactImage.
*
* @name Phaser.Physics.Impact.ImpactImage#body
* @type {Phaser.Physics.Impact.Body}
* @since 3.0.0
*/
this.body = world.create(x - this.frame.centerX, y - this.frame.centerY, this.width, this.height);
this.body.parent = this;
this.body.gameObject = this;
/**
* The size of the physics Body.
*
* @name Phaser.Physics.Impact.ImpactImage#size
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.size = this.body.size;
/**
* The X and Y offset of the Body from the left and top of the Image.
*
* @name Phaser.Physics.Impact.ImpactImage#offset
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.offset = this.body.offset;
/**
* The velocity, or rate of change the Body's position. Measured in pixels per second.
*
* @name Phaser.Physics.Impact.ImpactImage#vel
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.vel = this.body.vel;
/**
* The acceleration is the rate of change of the velocity. Measured in pixels per second squared.
*
* @name Phaser.Physics.Impact.ImpactImage#accel
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.accel = this.body.accel;
/**
* Friction between colliding bodies.
*
* @name Phaser.Physics.Impact.ImpactImage#friction
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.friction = this.body.friction;
/**
* The maximum velocity of the body.
*
* @name Phaser.Physics.Impact.ImpactImage#maxVel
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.maxVel = this.body.maxVel;
}
});
module.exports = ImpactImage;

211
node_modules/phaser/plugins/impact/ImpactPhysics.js generated vendored Normal file
View File

@ -0,0 +1,211 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Class = require('../../utils/Class');
var Factory = require('./Factory');
var GetFastValue = require('../../utils/object/GetFastValue');
var Merge = require('../../utils/object/Merge');
var PluginCache = require('../../plugins/PluginCache');
var SceneEvents = require('../../scene/events');
var World = require('./World');
/**
* @classdesc
* [description]
*
* @class ImpactPhysics
* @memberof Phaser.Physics.Impact
* @constructor
* @since 3.0.0
*
* @param {Phaser.Scene} scene - [description]
*/
var ImpactPhysics = new Class({
initialize:
function ImpactPhysics (scene)
{
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactPhysics#scene
* @type {Phaser.Scene}
* @since 3.0.0
*/
this.scene = scene;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactPhysics#systems
* @type {Phaser.Scenes.Systems}
* @since 3.0.0
*/
this.systems = scene.sys;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactPhysics#config
* @type {object}
* @since 3.0.0
*/
this.config = this.getConfig();
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactPhysics#world
* @type {Phaser.Physics.Impact.World}
* @since 3.0.0
*/
this.world;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactPhysics#add
* @type {Phaser.Physics.Impact.Factory}
* @since 3.0.0
*/
this.add;
scene.sys.events.once(SceneEvents.BOOT, this.boot, this);
scene.sys.events.on(SceneEvents.START, this.start, this);
},
/**
* This method is called automatically, only once, when the Scene is first created.
* Do not invoke it directly.
*
* @method Phaser.Physics.Impact.ImpactPhysics#boot
* @private
* @since 3.5.1
*/
boot: function ()
{
this.world = new World(this.scene, this.config);
this.add = new Factory(this.world);
this.systems.events.once(SceneEvents.DESTROY, this.destroy, this);
},
/**
* This method is called automatically by the Scene when it is starting up.
* It is responsible for creating local systems, properties and listening for Scene events.
* Do not invoke it directly.
*
* @method Phaser.Physics.Impact.ImpactPhysics#start
* @private
* @since 3.5.0
*/
start: function ()
{
if (!this.world)
{
this.world = new World(this.scene, this.config);
this.add = new Factory(this.world);
}
var eventEmitter = this.systems.events;
eventEmitter.on(SceneEvents.UPDATE, this.world.update, this.world);
eventEmitter.once(SceneEvents.SHUTDOWN, this.shutdown, this);
},
/**
* [description]
*
* @method Phaser.Physics.Impact.ImpactPhysics#getConfig
* @since 3.0.0
*
* @return {object} [description]
*/
getConfig: function ()
{
var gameConfig = this.systems.game.config.physics;
var sceneConfig = this.systems.settings.physics;
var config = Merge(
GetFastValue(sceneConfig, 'impact', {}),
GetFastValue(gameConfig, 'impact', {})
);
return config;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.ImpactPhysics#pause
* @since 3.0.0
*
* @return {Phaser.Physics.Impact.World} The Impact World object.
*/
pause: function ()
{
return this.world.pause();
},
/**
* [description]
*
* @method Phaser.Physics.Impact.ImpactPhysics#resume
* @since 3.0.0
*
* @return {Phaser.Physics.Impact.World} The Impact World object.
*/
resume: function ()
{
return this.world.resume();
},
/**
* The Scene that owns this plugin is shutting down.
* We need to kill and reset all internal properties as well as stop listening to Scene events.
*
* @method Phaser.Physics.Impact.ImpactPhysics#shutdown
* @private
* @since 3.0.0
*/
shutdown: function ()
{
var eventEmitter = this.systems.events;
eventEmitter.off(SceneEvents.UPDATE, this.world.update, this.world);
eventEmitter.off(SceneEvents.SHUTDOWN, this.shutdown, this);
this.add.destroy();
this.world.destroy();
this.add = null;
this.world = null;
},
/**
* The Scene that owns this plugin is being destroyed.
* We need to shutdown and then kill off all external references.
*
* @method Phaser.Physics.Impact.ImpactPhysics#destroy
* @private
* @since 3.0.0
*/
destroy: function ()
{
this.shutdown();
this.scene.sys.events.off(SceneEvents.START, this.start, this);
this.scene = null;
this.systems = null;
}
});
PluginCache.register('ImpactPhysics', ImpactPhysics, 'impactPhysics');
module.exports = ImpactPhysics;

155
node_modules/phaser/plugins/impact/ImpactSprite.js generated vendored Normal file
View File

@ -0,0 +1,155 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Class = require('../../utils/Class');
var Components = require('./components');
var Sprite = require('../../gameobjects/sprite/Sprite');
/**
* @classdesc
* An Impact Physics Sprite Game Object.
*
* A Sprite Game Object is used for the display of both static and animated images in your game.
* Sprites can have input events and physics bodies. They can also be tweened, tinted, scrolled
* and animated.
*
* The main difference between a Sprite and an Image Game Object is that you cannot animate Images.
* As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation
* Component. If you do not require animation then you can safely use Images to replace Sprites in all cases.
*
* @class ImpactSprite
* @extends Phaser.GameObjects.Sprite
* @memberof Phaser.Physics.Impact
* @constructor
* @since 3.0.0
*
* @extends Phaser.Physics.Impact.Components.Acceleration
* @extends Phaser.Physics.Impact.Components.BodyScale
* @extends Phaser.Physics.Impact.Components.BodyType
* @extends Phaser.Physics.Impact.Components.Bounce
* @extends Phaser.Physics.Impact.Components.CheckAgainst
* @extends Phaser.Physics.Impact.Components.Collides
* @extends Phaser.Physics.Impact.Components.Debug
* @extends Phaser.Physics.Impact.Components.Friction
* @extends Phaser.Physics.Impact.Components.Gravity
* @extends Phaser.Physics.Impact.Components.Offset
* @extends Phaser.Physics.Impact.Components.SetGameObject
* @extends Phaser.Physics.Impact.Components.Velocity
* @extends Phaser.GameObjects.Components.Alpha
* @extends Phaser.GameObjects.Components.BlendMode
* @extends Phaser.GameObjects.Components.Depth
* @extends Phaser.GameObjects.Components.Flip
* @extends Phaser.GameObjects.Components.GetBounds
* @extends Phaser.GameObjects.Components.Origin
* @extends Phaser.GameObjects.Components.Pipeline
* @extends Phaser.GameObjects.Components.ScrollFactor
* @extends Phaser.GameObjects.Components.Size
* @extends Phaser.GameObjects.Components.Texture
* @extends Phaser.GameObjects.Components.Tint
* @extends Phaser.GameObjects.Components.Transform
* @extends Phaser.GameObjects.Components.Visible
*
* @param {Phaser.Physics.Impact.World} world - [description]
* @param {number} x - The horizontal position of this Game Object in the world.
* @param {number} y - The vertical position of this Game Object in the world.
* @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager.
* @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with.
*/
var ImpactSprite = new Class({
Extends: Sprite,
Mixins: [
Components.Acceleration,
Components.BodyScale,
Components.BodyType,
Components.Bounce,
Components.CheckAgainst,
Components.Collides,
Components.Debug,
Components.Friction,
Components.Gravity,
Components.Offset,
Components.SetGameObject,
Components.Velocity
],
initialize:
function ImpactSprite (world, x, y, texture, frame)
{
Sprite.call(this, world.scene, x, y, texture, frame);
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactSprite#body
* @type {Phaser.Physics.Impact.Body}
* @since 3.0.0
*/
this.body = world.create(x - this.frame.centerX, y - this.frame.centerY, this.width, this.height);
this.body.parent = this;
this.body.gameObject = this;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactSprite#size
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.size = this.body.size;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactSprite#offset
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.offset = this.body.offset;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactSprite#vel
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.vel = this.body.vel;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactSprite#accel
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.accel = this.body.accel;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactSprite#friction
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.friction = this.body.friction;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactSprite#maxVel
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.maxVel = this.body.maxVel;
}
});
module.exports = ImpactSprite;

50
node_modules/phaser/plugins/impact/SeparateX.js generated vendored Normal file
View File

@ -0,0 +1,50 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* [description]
*
* @function Phaser.Physics.Impact.SeparateX
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.World} world - [description]
* @param {Phaser.Physics.Impact.Body} left - [description]
* @param {Phaser.Physics.Impact.Body} right - [description]
* @param {Phaser.Physics.Impact.Body} [weak] - [description]
*/
var SeparateX = function (world, left, right, weak)
{
var nudge = left.pos.x + left.size.x - right.pos.x;
// We have a weak entity, so just move this one
if (weak)
{
var strong = (left === weak) ? right : left;
weak.vel.x = -weak.vel.x * weak.bounciness + strong.vel.x;
var resWeak = world.collisionMap.trace(weak.pos.x, weak.pos.y, weak === left ? -nudge : nudge, 0, weak.size.x, weak.size.y);
weak.pos.x = resWeak.pos.x;
}
else
{
var v2 = (left.vel.x - right.vel.x) / 2;
left.vel.x = -v2;
right.vel.x = v2;
var resLeft = world.collisionMap.trace(left.pos.x, left.pos.y, -nudge / 2, 0, left.size.x, left.size.y);
left.pos.x = Math.floor(resLeft.pos.x);
var resRight = world.collisionMap.trace(right.pos.x, right.pos.y, nudge / 2, 0, right.size.x, right.size.y);
right.pos.x = Math.ceil(resRight.pos.x);
}
};
module.exports = SeparateX;

79
node_modules/phaser/plugins/impact/SeparateY.js generated vendored Normal file
View File

@ -0,0 +1,79 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* [description]
*
* @function Phaser.Physics.Impact.SeparateY
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.World} world - [description]
* @param {Phaser.Physics.Impact.Body} top - [description]
* @param {Phaser.Physics.Impact.Body} bottom - [description]
* @param {Phaser.Physics.Impact.Body} [weak] - [description]
*/
var SeparateY = function (world, top, bottom, weak)
{
var nudge = (top.pos.y + top.size.y - bottom.pos.y);
var nudgeX;
var resTop;
if (weak)
{
var strong = (top === weak) ? bottom : top;
weak.vel.y = -weak.vel.y * weak.bounciness + strong.vel.y;
// Riding on a platform?
nudgeX = 0;
if (weak === top && Math.abs(weak.vel.y - strong.vel.y) < weak.minBounceVelocity)
{
weak.standing = true;
nudgeX = strong.vel.x * world.delta;
}
var resWeak = world.collisionMap.trace(weak.pos.x, weak.pos.y, nudgeX, weak === top ? -nudge : nudge, weak.size.x, weak.size.y);
weak.pos.y = resWeak.pos.y;
weak.pos.x = resWeak.pos.x;
}
else if (world.gravity && (bottom.standing || top.vel.y > 0))
{
resTop = world.collisionMap.trace(top.pos.x, top.pos.y, 0, -(top.pos.y + top.size.y - bottom.pos.y), top.size.x, top.size.y);
top.pos.y = resTop.pos.y;
if (top.bounciness > 0 && top.vel.y > top.minBounceVelocity)
{
top.vel.y *= -top.bounciness;
}
else
{
top.standing = true;
top.vel.y = 0;
}
}
else
{
var v2 = (top.vel.y - bottom.vel.y) / 2;
top.vel.y = -v2;
bottom.vel.y = v2;
nudgeX = bottom.vel.x * world.delta;
resTop = world.collisionMap.trace(top.pos.x, top.pos.y, nudgeX, -nudge / 2, top.size.x, top.size.y);
top.pos.y = resTop.pos.y;
var resBottom = world.collisionMap.trace(bottom.pos.x, bottom.pos.y, 0, nudge / 2, bottom.size.x, bottom.size.y);
bottom.pos.y = resBottom.pos.y;
}
};
module.exports = SeparateY;

70
node_modules/phaser/plugins/impact/Solver.js generated vendored Normal file
View File

@ -0,0 +1,70 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var COLLIDES = require('./COLLIDES');
var Events = require('./events');
var SeparateX = require('./SeparateX');
var SeparateY = require('./SeparateY');
/**
* Impact Physics Solver
*
* @function Phaser.Physics.Impact.Solver
* @fires Phaser.Physics.Impact.Events#COLLIDE
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.World} world - The Impact simulation to run the solver in.
* @param {Phaser.Physics.Impact.Body} bodyA - The first body in the collision.
* @param {Phaser.Physics.Impact.Body} bodyB - The second body in the collision.
*/
var Solver = function (world, bodyA, bodyB)
{
var weak = null;
if (bodyA.collides === COLLIDES.LITE || bodyB.collides === COLLIDES.FIXED)
{
weak = bodyA;
}
else if (bodyB.collides === COLLIDES.LITE || bodyA.collides === COLLIDES.FIXED)
{
weak = bodyB;
}
if (bodyA.last.x + bodyA.size.x > bodyB.last.x && bodyA.last.x < bodyB.last.x + bodyB.size.x)
{
if (bodyA.last.y < bodyB.last.y)
{
SeparateY(world, bodyA, bodyB, weak);
}
else
{
SeparateY(world, bodyB, bodyA, weak);
}
bodyA.collideWith(bodyB, 'y');
bodyB.collideWith(bodyA, 'y');
world.emit(Events.COLLIDE, bodyA, bodyB, 'y');
}
else if (bodyA.last.y + bodyA.size.y > bodyB.last.y && bodyA.last.y < bodyB.last.y + bodyB.size.y)
{
if (bodyA.last.x < bodyB.last.x)
{
SeparateX(world, bodyA, bodyB, weak);
}
else
{
SeparateX(world, bodyB, bodyA, weak);
}
bodyA.collideWith(bodyB, 'x');
bodyB.collideWith(bodyA, 'x');
world.emit(Events.COLLIDE, bodyA, bodyB, 'x');
}
};
module.exports = Solver;

62
node_modules/phaser/plugins/impact/TYPE.js generated vendored Normal file
View File

@ -0,0 +1,62 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* Collision Types - Determine if and how entities collide with each other.
*
* In ACTIVE vs. LITE or FIXED vs. ANY collisions, only the "weak" entity moves,
* while the other one stays fixed. In ACTIVE vs. ACTIVE and ACTIVE vs. PASSIVE
* collisions, both entities are moved. LITE or PASSIVE entities don't collide
* with other LITE or PASSIVE entities at all. The behavior for FIXED vs.
* FIXED collisions is undefined.
*
* @namespace Phaser.Physics.Impact.TYPE
* @memberof Phaser.Physics.Impact
* @since 3.0.0
*/
module.exports = {
/**
* Collides with nothing.
*
* @name Phaser.Physics.Impact.TYPE.NONE
* @type {integer}
* @const
* @since 3.0.0
*/
NONE: 0,
/**
* Type A. Collides with Type B.
*
* @name Phaser.Physics.Impact.TYPE.A
* @type {integer}
* @const
* @since 3.0.0
*/
A: 1,
/**
* Type B. Collides with Type A.
*
* @name Phaser.Physics.Impact.TYPE.B
* @type {integer}
* @const
* @since 3.0.0
*/
B: 2,
/**
* Collides with both types A and B.
*
* @name Phaser.Physics.Impact.TYPE.BOTH
* @type {integer}
* @const
* @since 3.0.0
*/
BOTH: 3
};

89
node_modules/phaser/plugins/impact/UpdateMotion.js generated vendored Normal file
View File

@ -0,0 +1,89 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* Set up the trace-result
* var res = {
* collision: {x: false, y: false, slope: false},
* pos: {x: x, y: y},
* tile: {x: 0, y: 0}
* };
*
* @function Phaser.Physics.Impact.UpdateMotion
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body} body - [description]
* @param {object} res - [description]
*/
var UpdateMotion = function (body, res)
{
body.standing = false;
// Y
if (res.collision.y)
{
if (body.bounciness > 0 && Math.abs(body.vel.y) > body.minBounceVelocity)
{
body.vel.y *= -body.bounciness;
}
else
{
if (body.vel.y > 0)
{
body.standing = true;
}
body.vel.y = 0;
}
}
// X
if (res.collision.x)
{
if (body.bounciness > 0 && Math.abs(body.vel.x) > body.minBounceVelocity)
{
body.vel.x *= -body.bounciness;
}
else
{
body.vel.x = 0;
}
}
// SLOPE
if (res.collision.slope)
{
var s = res.collision.slope;
if (body.bounciness > 0)
{
var proj = body.vel.x * s.nx + body.vel.y * s.ny;
body.vel.x = (body.vel.x - s.nx * proj * 2) * body.bounciness;
body.vel.y = (body.vel.y - s.ny * proj * 2) * body.bounciness;
}
else
{
var lengthSquared = s.x * s.x + s.y * s.y;
var dot = (body.vel.x * s.x + body.vel.y * s.y) / lengthSquared;
body.vel.x = s.x * dot;
body.vel.y = s.y * dot;
var angle = Math.atan2(s.x, s.y);
if (angle > body.slopeStanding.min && angle < body.slopeStanding.max)
{
body.standing = true;
}
}
}
body.pos.x = res.pos.x;
body.pos.y = res.pos.y;
};
module.exports = UpdateMotion;

979
node_modules/phaser/plugins/impact/World.js generated vendored Normal file
View File

@ -0,0 +1,979 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Body = require('./Body');
var Class = require('../../utils/Class');
var COLLIDES = require('./COLLIDES');
var CollisionMap = require('./CollisionMap');
var EventEmitter = require('eventemitter3');
var Events = require('./events');
var GetFastValue = require('../../utils/object/GetFastValue');
var HasValue = require('../../utils/object/HasValue');
var Set = require('../../structs/Set');
var Solver = require('./Solver');
var TILEMAP_FORMATS = require('../../tilemaps/Formats');
var TYPE = require('./TYPE');
/**
* @classdesc
* [description]
*
* @class World
* @extends Phaser.Events.EventEmitter
* @memberof Phaser.Physics.Impact
* @constructor
* @since 3.0.0
*
* @param {Phaser.Scene} scene - The Scene to which this Impact World instance belongs.
* @param {Phaser.Types.Physics.Impact.WorldConfig} config - [description]
*/
var World = new Class({
Extends: EventEmitter,
initialize:
function World (scene, config)
{
EventEmitter.call(this);
/**
* [description]
*
* @name Phaser.Physics.Impact.World#scene
* @type {Phaser.Scene}
* @since 3.0.0
*/
this.scene = scene;
/**
* [description]
*
* @name Phaser.Physics.Impact.World#bodies
* @type {Phaser.Structs.Set.<Phaser.Physics.Impact.Body>}
* @since 3.0.0
*/
this.bodies = new Set();
/**
* [description]
*
* @name Phaser.Physics.Impact.World#gravity
* @type {number}
* @default 0
* @since 3.0.0
*/
this.gravity = GetFastValue(config, 'gravity', 0);
/**
* Spatial hash cell dimensions
*
* @name Phaser.Physics.Impact.World#cellSize
* @type {integer}
* @default 64
* @since 3.0.0
*/
this.cellSize = GetFastValue(config, 'cellSize', 64);
/**
* [description]
*
* @name Phaser.Physics.Impact.World#collisionMap
* @type {Phaser.Physics.Impact.CollisionMap}
* @since 3.0.0
*/
this.collisionMap = new CollisionMap();
/**
* [description]
*
* @name Phaser.Physics.Impact.World#timeScale
* @type {number}
* @default 1
* @since 3.0.0
*/
this.timeScale = GetFastValue(config, 'timeScale', 1);
/**
* Impacts maximum time step is 20 fps.
*
* @name Phaser.Physics.Impact.World#maxStep
* @type {number}
* @default 0.05
* @since 3.0.0
*/
this.maxStep = GetFastValue(config, 'maxStep', 0.05);
/**
* [description]
*
* @name Phaser.Physics.Impact.World#enabled
* @type {boolean}
* @default true
* @since 3.0.0
*/
this.enabled = true;
/**
* [description]
*
* @name Phaser.Physics.Impact.World#drawDebug
* @type {boolean}
* @since 3.0.0
*/
this.drawDebug = GetFastValue(config, 'debug', false);
/**
* [description]
*
* @name Phaser.Physics.Impact.World#debugGraphic
* @type {Phaser.GameObjects.Graphics}
* @since 3.0.0
*/
this.debugGraphic;
var _maxVelocity = GetFastValue(config, 'maxVelocity', 100);
/**
* [description]
*
* @name Phaser.Physics.Impact.World#defaults
* @type {Phaser.Types.Physics.Impact.WorldDefaults}
* @since 3.0.0
*/
this.defaults = {
debugShowBody: GetFastValue(config, 'debugShowBody', true),
debugShowVelocity: GetFastValue(config, 'debugShowVelocity', true),
bodyDebugColor: GetFastValue(config, 'debugBodyColor', 0xff00ff),
velocityDebugColor: GetFastValue(config, 'debugVelocityColor', 0x00ff00),
maxVelocityX: GetFastValue(config, 'maxVelocityX', _maxVelocity),
maxVelocityY: GetFastValue(config, 'maxVelocityY', _maxVelocity),
minBounceVelocity: GetFastValue(config, 'minBounceVelocity', 40),
gravityFactor: GetFastValue(config, 'gravityFactor', 1),
bounciness: GetFastValue(config, 'bounciness', 0)
};
/**
* An object containing the 4 wall bodies that bound the physics world.
*
* @name Phaser.Physics.Impact.World#walls
* @type {Phaser.Types.Physics.Impact.WorldWalls}
* @since 3.0.0
*/
this.walls = { left: null, right: null, top: null, bottom: null };
/**
* [description]
*
* @name Phaser.Physics.Impact.World#delta
* @type {number}
* @default 0
* @since 3.0.0
*/
this.delta = 0;
/**
* [description]
*
* @name Phaser.Physics.Impact.World#_lastId
* @type {number}
* @private
* @default 0
* @since 3.0.0
*/
this._lastId = 0;
if (GetFastValue(config, 'setBounds', false))
{
var boundsConfig = config['setBounds'];
if (typeof boundsConfig === 'boolean')
{
this.setBounds();
}
else
{
var x = GetFastValue(boundsConfig, 'x', 0);
var y = GetFastValue(boundsConfig, 'y', 0);
var width = GetFastValue(boundsConfig, 'width', scene.sys.scale.width);
var height = GetFastValue(boundsConfig, 'height', scene.sys.scale.height);
var thickness = GetFastValue(boundsConfig, 'thickness', 64);
var left = GetFastValue(boundsConfig, 'left', true);
var right = GetFastValue(boundsConfig, 'right', true);
var top = GetFastValue(boundsConfig, 'top', true);
var bottom = GetFastValue(boundsConfig, 'bottom', true);
this.setBounds(x, y, width, height, thickness, left, right, top, bottom);
}
}
if (this.drawDebug)
{
this.createDebugGraphic();
}
},
/**
* Sets the collision map for the world either from a Weltmeister JSON level in the cache or from
* a 2D array. If loading from a Weltmeister level, the map must have a layer called "collision".
*
* @method Phaser.Physics.Impact.World#setCollisionMap
* @since 3.0.0
*
* @param {(string|integer[][])} key - Either a string key that corresponds to a Weltmeister level
* in the cache, or a 2D array of collision IDs.
* @param {integer} tileSize - The size of a tile. This is optional if loading from a Weltmeister
* level in the cache.
*
* @return {?Phaser.Physics.Impact.CollisionMap} The newly created CollisionMap, or null if the method failed to
* create the CollisionMap.
*/
setCollisionMap: function (key, tileSize)
{
if (typeof key === 'string')
{
var tilemapData = this.scene.cache.tilemap.get(key);
if (!tilemapData || tilemapData.format !== TILEMAP_FORMATS.WELTMEISTER)
{
console.warn('The specified key does not correspond to a Weltmeister tilemap: ' + key);
return null;
}
var layers = tilemapData.data.layer;
var collisionLayer;
for (var i = 0; i < layers.length; i++)
{
if (layers[i].name === 'collision')
{
collisionLayer = layers[i];
break;
}
}
if (tileSize === undefined) { tileSize = collisionLayer.tilesize; }
this.collisionMap = new CollisionMap(tileSize, collisionLayer.data);
}
else if (Array.isArray(key))
{
this.collisionMap = new CollisionMap(tileSize, key);
}
else
{
console.warn('Invalid Weltmeister collision map data: ' + key);
}
return this.collisionMap;
},
/**
* Sets the collision map for the world from a tilemap layer. Only tiles that are marked as
* colliding will be used. You can specify the mapping from tiles to slope IDs in a couple of
* ways. The easiest is to use Tiled and the slopeTileProperty option. Alternatively, you can
* manually create a slopeMap that stores the mapping between tile indices and slope IDs.
*
* @method Phaser.Physics.Impact.World#setCollisionMapFromTilemapLayer
* @since 3.0.0
*
* @param {(Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} tilemapLayer - The tilemap layer to use.
* @param {Phaser.Types.Physics.Impact.CollisionOptions} [options] - Options for controlling the mapping from tiles to slope IDs.
*
* @return {Phaser.Physics.Impact.CollisionMap} The newly created CollisionMap.
*/
setCollisionMapFromTilemapLayer: function (tilemapLayer, options)
{
if (options === undefined) { options = {}; }
var slopeProperty = GetFastValue(options, 'slopeProperty', null);
var slopeMap = GetFastValue(options, 'slopeMap', null);
var collidingSlope = GetFastValue(options, 'defaultCollidingSlope', null);
var nonCollidingSlope = GetFastValue(options, 'defaultNonCollidingSlope', 0);
var layerData = tilemapLayer.layer;
var tileSize = layerData.baseTileWidth;
var collisionData = [];
for (var ty = 0; ty < layerData.height; ty++)
{
collisionData[ty] = [];
for (var tx = 0; tx < layerData.width; tx++)
{
var tile = layerData.data[ty][tx];
if (tile && tile.collides)
{
if (slopeProperty !== null && HasValue(tile.properties, slopeProperty))
{
collisionData[ty][tx] = parseInt(tile.properties[slopeProperty], 10);
}
else if (slopeMap !== null && HasValue(slopeMap, tile.index))
{
collisionData[ty][tx] = slopeMap[tile.index];
}
else if (collidingSlope !== null)
{
collisionData[ty][tx] = collidingSlope;
}
else
{
collisionData[ty][tx] = tile.index;
}
}
else
{
collisionData[ty][tx] = nonCollidingSlope;
}
}
}
this.collisionMap = new CollisionMap(tileSize, collisionData);
return this.collisionMap;
},
/**
* Sets the bounds of the Physics world to match the given world pixel dimensions.
* You can optionally set which 'walls' to create: left, right, top or bottom.
* If none of the walls are given it will default to use the walls settings it had previously.
* I.e. if you previously told it to not have the left or right walls, and you then adjust the world size
* the newly created bounds will also not have the left and right walls.
* Explicitly state them in the parameters to override this.
*
* @method Phaser.Physics.Impact.World#setBounds
* @since 3.0.0
*
* @param {number} [x] - The x coordinate of the top-left corner of the bounds.
* @param {number} [y] - The y coordinate of the top-left corner of the bounds.
* @param {number} [width] - The width of the bounds.
* @param {number} [height] - The height of the bounds.
* @param {number} [thickness=64] - [description]
* @param {boolean} [left=true] - If true will create the left bounds wall.
* @param {boolean} [right=true] - If true will create the right bounds wall.
* @param {boolean} [top=true] - If true will create the top bounds wall.
* @param {boolean} [bottom=true] - If true will create the bottom bounds wall.
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
setBounds: function (x, y, width, height, thickness, left, right, top, bottom)
{
if (x === undefined) { x = 0; }
if (y === undefined) { y = 0; }
if (width === undefined) { width = this.scene.sys.scale.width; }
if (height === undefined) { height = this.scene.sys.scale.height; }
if (thickness === undefined) { thickness = 64; }
if (left === undefined) { left = true; }
if (right === undefined) { right = true; }
if (top === undefined) { top = true; }
if (bottom === undefined) { bottom = true; }
this.updateWall(left, 'left', x - thickness, y, thickness, height);
this.updateWall(right, 'right', x + width, y, thickness, height);
this.updateWall(top, 'top', x, y - thickness, width, thickness);
this.updateWall(bottom, 'bottom', x, y + height, width, thickness);
return this;
},
/**
* position = 'left', 'right', 'top' or 'bottom'
*
* @method Phaser.Physics.Impact.World#updateWall
* @since 3.0.0
*
* @param {boolean} add - [description]
* @param {string} position - [description]
* @param {number} x - [description]
* @param {number} y - [description]
* @param {number} width - [description]
* @param {number} height - [description]
*/
updateWall: function (add, position, x, y, width, height)
{
var wall = this.walls[position];
if (add)
{
if (wall)
{
wall.resetSize(x, y, width, height);
}
else
{
this.walls[position] = this.create(x, y, width, height);
this.walls[position].name = position;
this.walls[position].gravityFactor = 0;
this.walls[position].collides = COLLIDES.FIXED;
}
}
else
{
if (wall)
{
this.bodies.remove(wall);
}
this.walls[position] = null;
}
},
/**
* Creates a Graphics Game Object used for debug display and enables the world for debug drawing.
*
* @method Phaser.Physics.Impact.World#createDebugGraphic
* @since 3.0.0
*
* @return {Phaser.GameObjects.Graphics} The Graphics object created that will have the debug visuals drawn to it.
*/
createDebugGraphic: function ()
{
var graphic = this.scene.sys.add.graphics({ x: 0, y: 0 });
graphic.setDepth(Number.MAX_VALUE);
this.debugGraphic = graphic;
this.drawDebug = true;
return graphic;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#getNextID
* @since 3.0.0
*
* @return {integer} [description]
*/
getNextID: function ()
{
return this._lastId++;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#create
* @since 3.0.0
*
* @param {number} x - [description]
* @param {number} y - [description]
* @param {number} sizeX - [description]
* @param {number} sizeY - [description]
*
* @return {Phaser.Physics.Impact.Body} The Body that was added to this World.
*/
create: function (x, y, sizeX, sizeY)
{
var body = new Body(this, x, y, sizeX, sizeY);
this.bodies.set(body);
return body;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#remove
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body} object - The Body to remove from this World.
*/
remove: function (object)
{
this.bodies.delete(object);
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#pause
* @fires Phaser.Physics.Impact.Events#PAUSE
* @since 3.0.0
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
pause: function ()
{
this.enabled = false;
this.emit(Events.PAUSE);
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#resume
* @fires Phaser.Physics.Impact.Events#RESUME
* @since 3.0.0
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
resume: function ()
{
this.enabled = true;
this.emit(Events.RESUME);
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#update
* @since 3.0.0
*
* @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout.
* @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate.
*/
update: function (time, delta)
{
if (!this.enabled || this.bodies.size === 0)
{
return;
}
// Impact uses a divided delta value that is clamped to the maxStep (20fps) maximum
var clampedDelta = Math.min(delta / 1000, this.maxStep) * this.timeScale;
this.delta = clampedDelta;
// Update all active bodies
var i;
var body;
var bodies = this.bodies.entries;
var len = bodies.length;
var hash = {};
var size = this.cellSize;
for (i = 0; i < len; i++)
{
body = bodies[i];
if (body.enabled)
{
body.update(clampedDelta);
}
}
// Run collision against them all now they're in the new positions from the update
for (i = 0; i < len; i++)
{
body = bodies[i];
if (body && !body.skipHash())
{
this.checkHash(body, hash, size);
}
}
if (this.drawDebug)
{
var graphics = this.debugGraphic;
graphics.clear();
for (i = 0; i < len; i++)
{
body = bodies[i];
if (body && body.willDrawDebug())
{
body.drawDebug(graphics);
}
}
}
},
/**
* Check the body against the spatial hash.
*
* @method Phaser.Physics.Impact.World#checkHash
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body} body - [description]
* @param {object} hash - [description]
* @param {number} size - [description]
*/
checkHash: function (body, hash, size)
{
var checked = {};
var xmin = Math.floor(body.pos.x / size);
var ymin = Math.floor(body.pos.y / size);
var xmax = Math.floor((body.pos.x + body.size.x) / size) + 1;
var ymax = Math.floor((body.pos.y + body.size.y) / size) + 1;
for (var x = xmin; x < xmax; x++)
{
for (var y = ymin; y < ymax; y++)
{
if (!hash[x])
{
hash[x] = {};
hash[x][y] = [ body ];
}
else if (!hash[x][y])
{
hash[x][y] = [ body ];
}
else
{
var cell = hash[x][y];
for (var c = 0; c < cell.length; c++)
{
if (body.touches(cell[c]) && !checked[cell[c].id])
{
checked[cell[c].id] = true;
this.checkBodies(body, cell[c]);
}
}
cell.push(body);
}
}
}
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#checkBodies
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body} bodyA - [description]
* @param {Phaser.Physics.Impact.Body} bodyB - [description]
*/
checkBodies: function (bodyA, bodyB)
{
// 2 fixed bodies won't do anything
if (bodyA.collides === COLLIDES.FIXED && bodyB.collides === COLLIDES.FIXED)
{
return;
}
// bitwise checks
if (bodyA.checkAgainst & bodyB.type)
{
bodyA.check(bodyB);
}
if (bodyB.checkAgainst & bodyA.type)
{
bodyB.check(bodyA);
}
if (bodyA.collides && bodyB.collides && bodyA.collides + bodyB.collides > COLLIDES.ACTIVE)
{
Solver(this, bodyA, bodyB);
}
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#setCollidesNever
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the collides value on.
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
setCollidesNever: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
{
bodies[i].collides = COLLIDES.NEVER;
}
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#setLite
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the collides value on.
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
setLite: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
{
bodies[i].collides = COLLIDES.LITE;
}
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#setPassive
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the collides value on.
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
setPassive: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
{
bodies[i].collides = COLLIDES.PASSIVE;
}
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#setActive
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the collides value on.
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
setActive: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
{
bodies[i].collides = COLLIDES.ACTIVE;
}
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#setFixed
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the collides value on.
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
setFixed: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
{
bodies[i].collides = COLLIDES.FIXED;
}
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#setTypeNone
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the type value on.
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
setTypeNone: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
{
bodies[i].type = TYPE.NONE;
}
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#setTypeA
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the type value on.
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
setTypeA: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
{
bodies[i].type = TYPE.A;
}
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#setTypeB
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the type value on.
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
setTypeB: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
{
bodies[i].type = TYPE.B;
}
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#setAvsB
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the type value on.
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
setAvsB: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
{
bodies[i].type = TYPE.A;
bodies[i].checkAgainst = TYPE.B;
}
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#setBvsA
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the type value on.
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
setBvsA: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
{
bodies[i].type = TYPE.B;
bodies[i].checkAgainst = TYPE.A;
}
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#setCheckAgainstNone
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the type value on.
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
setCheckAgainstNone: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
{
bodies[i].checkAgainst = TYPE.NONE;
}
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#setCheckAgainstA
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the type value on.
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
setCheckAgainstA: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
{
bodies[i].checkAgainst = TYPE.A;
}
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#setCheckAgainstB
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the type value on.
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
setCheckAgainstB: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
{
bodies[i].checkAgainst = TYPE.B;
}
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#shutdown
* @since 3.0.0
*/
shutdown: function ()
{
this.removeAllListeners();
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#destroy
* @since 3.0.0
*/
destroy: function ()
{
this.removeAllListeners();
this.scene = null;
this.bodies.clear();
this.bodies = null;
this.collisionMap = null;
}
});
module.exports = World;

View File

@ -0,0 +1,71 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* The Impact Acceleration component.
* Should be applied as a mixin.
*
* @namespace Phaser.Physics.Impact.Components.Acceleration
* @since 3.0.0
*/
var Acceleration = {
/**
* Sets the horizontal acceleration of this body.
*
* @method Phaser.Physics.Impact.Components.Acceleration#setAccelerationX
* @since 3.0.0
*
* @param {number} x - The amount of acceleration to apply.
*
* @return {this} This Game Object.
*/
setAccelerationX: function (x)
{
this.accel.x = x;
return this;
},
/**
* Sets the vertical acceleration of this body.
*
* @method Phaser.Physics.Impact.Components.Acceleration#setAccelerationY
* @since 3.0.0
*
* @param {number} y - The amount of acceleration to apply.
*
* @return {this} This Game Object.
*/
setAccelerationY: function (y)
{
this.accel.y = y;
return this;
},
/**
* Sets the horizontal and vertical acceleration of this body.
*
* @method Phaser.Physics.Impact.Components.Acceleration#setAcceleration
* @since 3.0.0
*
* @param {number} x - The amount of horizontal acceleration to apply.
* @param {number} y - The amount of vertical acceleration to apply.
*
* @return {this} This Game Object.
*/
setAcceleration: function (x, y)
{
this.accel.x = x;
this.accel.y = y;
return this;
}
};
module.exports = Acceleration;

View File

@ -0,0 +1,68 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* The Impact Body Scale component.
* Should be applied as a mixin.
*
* @namespace Phaser.Physics.Impact.Components.BodyScale
* @since 3.0.0
*/
var BodyScale = {
/**
* Sets the size of the physics body.
*
* @method Phaser.Physics.Impact.Components.BodyScale#setBodySize
* @since 3.0.0
*
* @param {number} width - The width of the body in pixels.
* @param {number} [height=width] - The height of the body in pixels.
*
* @return {this} This Game Object.
*/
setBodySize: function (width, height)
{
if (height === undefined) { height = width; }
this.body.size.x = Math.round(width);
this.body.size.y = Math.round(height);
return this;
},
/**
* Sets the scale of the physics body.
*
* @method Phaser.Physics.Impact.Components.BodyScale#setBodyScale
* @since 3.0.0
*
* @param {number} scaleX - The horizontal scale of the body.
* @param {number} [scaleY] - The vertical scale of the body. If not given, will use the horizontal scale value.
*
* @return {this} This Game Object.
*/
setBodyScale: function (scaleX, scaleY)
{
if (scaleY === undefined) { scaleY = scaleX; }
var gameObject = this.body.gameObject;
if (gameObject)
{
gameObject.setScale(scaleX, scaleY);
return this.setBodySize(gameObject.width * gameObject.scaleX, gameObject.height * gameObject.scaleY);
}
else
{
return this.setBodySize(this.body.size.x * scaleX, this.body.size.y * scaleY);
}
}
};
module.exports = BodyScale;

View File

@ -0,0 +1,78 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var TYPE = require('../TYPE');
/**
* The Impact Body Type component.
* Should be applied as a mixin.
*
* @namespace Phaser.Physics.Impact.Components.BodyType
* @since 3.0.0
*/
var BodyType = {
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.BodyType#getBodyType
* @since 3.0.0
*
* @return {number} [description]
*/
getBodyType: function ()
{
return this.body.type;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.BodyType#setTypeNone
* @since 3.0.0
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setTypeNone: function ()
{
this.body.type = TYPE.NONE;
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.BodyType#setTypeA
* @since 3.0.0
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setTypeA: function ()
{
this.body.type = TYPE.A;
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.BodyType#setTypeB
* @since 3.0.0
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setTypeB: function ()
{
this.body.type = TYPE.B;
return this;
}
};
module.exports = BodyType;

View File

@ -0,0 +1,74 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* The Impact Bounce component.
* Should be applied as a mixin.
*
* @namespace Phaser.Physics.Impact.Components.Bounce
* @since 3.0.0
*/
var Bounce = {
/**
* Sets the impact physics bounce, or restitution, value.
*
* @method Phaser.Physics.Impact.Components.Bounce#setBounce
* @since 3.0.0
*
* @param {number} value - A value between 0 (no rebound) and 1 (full rebound)
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setBounce: function (value)
{
this.body.bounciness = value;
return this;
},
/**
* Sets the minimum velocity the body is allowed to be moving to be considered for rebound.
*
* @method Phaser.Physics.Impact.Components.Bounce#setMinBounceVelocity
* @since 3.0.0
*
* @param {number} value - The minimum allowed velocity.
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setMinBounceVelocity: function (value)
{
this.body.minBounceVelocity = value;
return this;
},
/**
* The bounce, or restitution, value of this body.
* A value between 0 (no rebound) and 1 (full rebound)
*
* @name Phaser.Physics.Impact.Components.Bounce#bounce
* @type {number}
* @since 3.0.0
*/
bounce: {
get: function ()
{
return this.body.bounciness;
},
set: function (value)
{
this.body.bounciness = value;
}
}
};
module.exports = Bounce;

View File

@ -0,0 +1,116 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var TYPE = require('../TYPE');
/**
* The Impact Check Against component.
* Should be applied as a mixin.
*
* @namespace Phaser.Physics.Impact.Components.CheckAgainst
* @since 3.0.0
*/
var CheckAgainst = {
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.CheckAgainst#setAvsB
* @since 3.0.0
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setAvsB: function ()
{
this.setTypeA();
return this.setCheckAgainstB();
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.CheckAgainst#setBvsA
* @since 3.0.0
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setBvsA: function ()
{
this.setTypeB();
return this.setCheckAgainstA();
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.CheckAgainst#setCheckAgainstNone
* @since 3.0.0
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setCheckAgainstNone: function ()
{
this.body.checkAgainst = TYPE.NONE;
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.CheckAgainst#setCheckAgainstA
* @since 3.0.0
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setCheckAgainstA: function ()
{
this.body.checkAgainst = TYPE.A;
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.CheckAgainst#setCheckAgainstB
* @since 3.0.0
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setCheckAgainstB: function ()
{
this.body.checkAgainst = TYPE.B;
return this;
},
/**
* [description]
*
* @name Phaser.Physics.Impact.Components.CheckAgainst#checkAgainst
* @type {number}
* @since 3.0.0
*/
checkAgainst: {
get: function ()
{
return this.body.checkAgainst;
},
set: function (value)
{
this.body.checkAgainst = value;
}
}
};
module.exports = CheckAgainst;

View File

@ -0,0 +1,150 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var COLLIDES = require('../COLLIDES');
/**
* @callback CollideCallback
*
* @param {Phaser.Physics.Impact.Body} body - [description]
* @param {Phaser.Physics.Impact.Body} other - [description]
* @param {string} axis - [description]
*/
/**
* The Impact Collides component.
* Should be applied as a mixin.
*
* @namespace Phaser.Physics.Impact.Components.Collides
* @since 3.0.0
*/
var Collides = {
_collideCallback: null,
_callbackScope: null,
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.Collides#setCollideCallback
* @since 3.0.0
*
* @param {CollideCallback} callback - [description]
* @param {*} scope - [description]
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setCollideCallback: function (callback, scope)
{
this._collideCallback = callback;
if (scope)
{
this._callbackScope = scope;
}
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.Collides#setCollidesNever
* @since 3.0.0
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setCollidesNever: function ()
{
this.body.collides = COLLIDES.NEVER;
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.Collides#setLiteCollision
* @since 3.6.0
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setLiteCollision: function ()
{
this.body.collides = COLLIDES.LITE;
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.Collides#setPassiveCollision
* @since 3.6.0
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setPassiveCollision: function ()
{
this.body.collides = COLLIDES.PASSIVE;
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.Collides#setActiveCollision
* @since 3.6.0
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setActiveCollision: function ()
{
this.body.collides = COLLIDES.ACTIVE;
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.Collides#setFixedCollision
* @since 3.6.0
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setFixedCollision: function ()
{
this.body.collides = COLLIDES.FIXED;
return this;
},
/**
* [description]
*
* @name Phaser.Physics.Impact.Components.Collides#collides
* @type {number}
* @since 3.0.0
*/
collides: {
get: function ()
{
return this.body.collides;
},
set: function (value)
{
this.body.collides = value;
}
}
};
module.exports = Collides;

119
node_modules/phaser/plugins/impact/components/Debug.js generated vendored Normal file
View File

@ -0,0 +1,119 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* The Impact Debug component.
* Should be applied as a mixin.
*
* @namespace Phaser.Physics.Impact.Components.Debug
* @since 3.0.0
*/
var Debug = {
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.Debug#setDebug
* @since 3.0.0
*
* @param {boolean} showBody - [description]
* @param {boolean} showVelocity - [description]
* @param {number} bodyColor - [description]
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setDebug: function (showBody, showVelocity, bodyColor)
{
this.debugShowBody = showBody;
this.debugShowVelocity = showVelocity;
this.debugBodyColor = bodyColor;
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.Debug#setDebugBodyColor
* @since 3.0.0
*
* @param {number} value - [description]
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setDebugBodyColor: function (value)
{
this.body.debugBodyColor = value;
return this;
},
/**
* [description]
*
* @name Phaser.Physics.Impact.Components.Debug#debugShowBody
* @type {boolean}
* @since 3.0.0
*/
debugShowBody: {
get: function ()
{
return this.body.debugShowBody;
},
set: function (value)
{
this.body.debugShowBody = value;
}
},
/**
* [description]
*
* @name Phaser.Physics.Impact.Components.Debug#debugShowVelocity
* @type {boolean}
* @since 3.0.0
*/
debugShowVelocity: {
get: function ()
{
return this.body.debugShowVelocity;
},
set: function (value)
{
this.body.debugShowVelocity = value;
}
},
/**
* [description]
*
* @name Phaser.Physics.Impact.Components.Debug#debugBodyColor
* @type {number}
* @since 3.0.0
*/
debugBodyColor: {
get: function ()
{
return this.body.debugBodyColor;
},
set: function (value)
{
this.body.debugBodyColor = value;
}
}
};
module.exports = Debug;

View File

@ -0,0 +1,71 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* The Impact Friction component.
* Should be applied as a mixin.
*
* @namespace Phaser.Physics.Impact.Components.Friction
* @since 3.0.0
*/
var Friction = {
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.Friction#setFrictionX
* @since 3.0.0
*
* @param {number} x - [description]
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setFrictionX: function (x)
{
this.friction.x = x;
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.Friction#setFrictionY
* @since 3.0.0
*
* @param {number} y - [description]
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setFrictionY: function (y)
{
this.friction.y = y;
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.Friction#setFriction
* @since 3.0.0
*
* @param {number} x - [description]
* @param {number} y - [description]
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setFriction: function (x, y)
{
this.friction.x = x;
this.friction.y = y;
return this;
}
};
module.exports = Friction;

View File

@ -0,0 +1,56 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* The Impact Gravity component.
* Should be applied as a mixin.
*
* @namespace Phaser.Physics.Impact.Components.Gravity
* @since 3.0.0
*/
var Gravity = {
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.Gravity#setGravity
* @since 3.0.0
*
* @param {number} value - [description]
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setGravity: function (value)
{
this.body.gravityFactor = value;
return this;
},
/**
* [description]
*
* @name Phaser.Physics.Impact.Components.Gravity#gravity
* @type {number}
* @since 3.0.0
*/
gravity: {
get: function ()
{
return this.body.gravityFactor;
},
set: function (value)
{
this.body.gravityFactor = value;
}
}
};
module.exports = Gravity;

View File

@ -0,0 +1,44 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* The Impact Offset component.
* Should be applied as a mixin.
*
* @namespace Phaser.Physics.Impact.Components.Offset
* @since 3.0.0
*/
var Offset = {
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.Offset#setOffset
* @since 3.0.0
*
* @param {number} x - [description]
* @param {number} y - [description]
* @param {number} [width] - [description]
* @param {number} [height] - [description]
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setOffset: function (x, y, width, height)
{
this.body.offset.x = x;
this.body.offset.y = y;
if (width)
{
this.setBodySize(width, height);
}
return this;
}
};
module.exports = Offset;

View File

@ -0,0 +1,70 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* The Impact Set Game Object component.
* Should be applied as a mixin.
*
* @namespace Phaser.Physics.Impact.Components.SetGameObject
* @since 3.0.0
*/
var SetGameObject = {
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.SetGameObject#setGameObject
* @since 3.0.0
*
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
* @param {boolean} [sync=true] - [description]
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setGameObject: function (gameObject, sync)
{
if (sync === undefined) { sync = true; }
if (gameObject)
{
this.body.gameObject = gameObject;
if (sync)
{
this.syncGameObject();
}
}
else
{
this.body.gameObject = null;
}
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Components.SetGameObject#syncGameObject
* @since 3.0.0
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
syncGameObject: function ()
{
var gameObject = this.body.gameObject;
if (gameObject)
{
this.setBodySize(gameObject.width * gameObject.scaleX, gameObject.height * gameObject.scaleY);
}
return this;
}
};
module.exports = SetGameObject;

View File

@ -0,0 +1,94 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* The Impact Velocity component.
* Should be applied as a mixin.
*
* @namespace Phaser.Physics.Impact.Components.Velocity
* @since 3.0.0
*/
var Velocity = {
/**
* Sets the horizontal velocity of the physics body.
*
* @method Phaser.Physics.Impact.Components.Velocity#setVelocityX
* @since 3.0.0
*
* @param {number} x - The horizontal velocity value.
*
* @return {this} This Game Object.
*/
setVelocityX: function (x)
{
this.vel.x = x;
return this;
},
/**
* Sets the vertical velocity of the physics body.
*
* @method Phaser.Physics.Impact.Components.Velocity#setVelocityY
* @since 3.0.0
*
* @param {number} y - The vertical velocity value.
*
* @return {this} This Game Object.
*/
setVelocityY: function (y)
{
this.vel.y = y;
return this;
},
/**
* Sets the horizontal and vertical velocities of the physics body.
*
* @method Phaser.Physics.Impact.Components.Velocity#setVelocity
* @since 3.0.0
*
* @param {number} x - The horizontal velocity value.
* @param {number} [y=x] - The vertical velocity value. If not given, defaults to the horizontal value.
*
* @return {this} This Game Object.
*/
setVelocity: function (x, y)
{
if (y === undefined) { y = x; }
this.vel.x = x;
this.vel.y = y;
return this;
},
/**
* Sets the maximum velocity this body can travel at.
*
* @method Phaser.Physics.Impact.Components.Velocity#setMaxVelocity
* @since 3.0.0
*
* @param {number} x - The maximum allowed horizontal velocity.
* @param {number} [y=x] - The maximum allowed vertical velocity. If not given, defaults to the horizontal value.
*
* @return {this} This Game Object.
*/
setMaxVelocity: function (x, y)
{
if (y === undefined) { y = x; }
this.maxVel.x = x;
this.maxVel.y = y;
return this;
}
};
module.exports = Velocity;

26
node_modules/phaser/plugins/impact/components/index.js generated vendored Normal file
View File

@ -0,0 +1,26 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* @namespace Phaser.Physics.Impact.Components
*/
module.exports = {
Acceleration: require('./Acceleration'),
BodyScale: require('./BodyScale'),
BodyType: require('./BodyType'),
Bounce: require('./Bounce'),
CheckAgainst: require('./CheckAgainst'),
Collides: require('./Collides'),
Debug: require('./Debug'),
Friction: require('./Friction'),
Gravity: require('./Gravity'),
Offset: require('./Offset'),
SetGameObject: require('./SetGameObject'),
Velocity: require('./Velocity')
};

View File

@ -0,0 +1,21 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* The Impact Physics World Collide Event.
*
* This event is dispatched by an Impact Physics World instance if two bodies collide.
*
* Listen to it from a Scene using: `this.impact.world.on('collide', listener)`.
*
* @event Phaser.Physics.Impact.Events#COLLIDE
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body} bodyA - The first body involved in the collision.
* @param {Phaser.Physics.Impact.Body} bodyB - The second body involved in the collision.
* @param {string} axis - The collision axis. Either `x` or `y`.
*/
module.exports = 'collide';

View File

@ -0,0 +1,17 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* The Impact Physics World Pause Event.
*
* This event is dispatched by an Impact Physics World instance when it is paused.
*
* Listen to it from a Scene using: `this.impact.world.on('pause', listener)`.
*
* @event Phaser.Physics.Impact.Events#PAUSE
* @since 3.0.0
*/
module.exports = 'pause';

View File

@ -0,0 +1,17 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* The Impact Physics World Resume Event.
*
* This event is dispatched by an Impact Physics World instance when it resumes from a paused state.
*
* Listen to it from a Scene using: `this.impact.world.on('resume', listener)`.
*
* @event Phaser.Physics.Impact.Events#RESUME
* @since 3.0.0
*/
module.exports = 'resume';

17
node_modules/phaser/plugins/impact/events/index.js generated vendored Normal file
View File

@ -0,0 +1,17 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* @namespace Phaser.Physics.Impact.Events
*/
module.exports = {
COLLIDE: require('./COLLIDE_EVENT'),
PAUSE: require('./PAUSE_EVENT'),
RESUME: require('./RESUME_EVENT')
};

36
node_modules/phaser/plugins/impact/index.js generated vendored Normal file
View File

@ -0,0 +1,36 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* An Impact.js compatible physics world, body and solver, for those who are used
* to the Impact way of defining and controlling physics bodies. Also works with
* the new Loader support for Weltmeister map data.
*
* World updated to run off the Phaser main loop.
* Body extended to support additional setter functions.
*
* To create the map data you'll need Weltmeister, which comes with Impact
* and can be purchased from http://impactjs.com
*
* My thanks to Dominic Szablewski for his permission to support Impact in Phaser.
*
* @namespace Phaser.Physics.Impact
*/
module.exports = {
Body: require('./Body'),
Events: require('./events'),
COLLIDES: require('./COLLIDES'),
CollisionMap: require('./CollisionMap'),
Factory: require('./Factory'),
Image: require('./ImpactImage'),
ImpactBody: require('./ImpactBody'),
ImpactPhysics: require('./ImpactPhysics'),
Sprite: require('./ImpactSprite'),
TYPE: require('./TYPE'),
World: require('./World')
};

View File

@ -0,0 +1,14 @@
/**
* @typedef {object} Phaser.Types.Physics.Impact.CollisionOptions
* @since 3.0.0
*
* @property {string} [slopeTileProperty=null] - Slope IDs can be stored on tiles directly
* using Impacts tileset editor. If a tile has a property with the given slopeTileProperty string
* name, the value of that property for the tile will be used for its slope mapping. E.g. a 45
* degree slope upward could be given a "slope" property with a value of 2.
* @property {object} [slopeMap=null] - A tile index to slope definition map.
* @property {integer} [defaultCollidingSlope=null] - If specified, the default slope ID to
* assign to a colliding tile. If not specified, the tile's index is used.
* @property {integer} [defaultNonCollidingSlope=0] - The default slope ID to assign to a
* non-colliding tile.
*/

View File

@ -0,0 +1,18 @@
/**
* @typedef {object} Phaser.Types.Physics.Impact.JSONImpactBody
* @since 3.0.0
*
* @property {string} name - [description]
* @property {Phaser.Types.Math.Vector2Like} size - [description]
* @property {Phaser.Types.Math.Vector2Like} pos - The entity's position in the game world.
* @property {Phaser.Types.Math.Vector2Like} vel - Current velocity in pixels per second.
* @property {Phaser.Types.Math.Vector2Like} accel - Current acceleration to be added to the entity's velocity per second. E.g. an entity with a `vel.x` of 0 and `accel.x` of 10 will have a `vel.x` of 100 ten seconds later.
* @property {Phaser.Types.Math.Vector2Like} friction - Deceleration to be subtracted from the entity's velocity per second. Only applies if `accel` is 0.
* @property {Phaser.Types.Math.Vector2Like} maxVel - The maximum velocity a body can move.
* @property {number} gravityFactor - [description]
* @property {number} bounciness - [description]
* @property {number} minBounceVelocity - [description]
* @property {Phaser.Physics.Impact.TYPE} type - [description]
* @property {Phaser.Physics.Impact.TYPE} checkAgainst - [description]
* @property {Phaser.Physics.Impact.COLLIDES} collides - [description]
*/

View File

@ -0,0 +1,30 @@
/**
* @typedef {object} Phaser.Types.Physics.Impact.WorldConfig
* @since 3.0.0
*
* @property {number} [gravity=0] - Sets {@link Phaser.Physics.Impact.World#gravity}
* @property {number} [cellSize=64] - The size of the cells used for the broadphase pass. Increase this value if you have lots of large objects in the world.
* @property {number} [timeScale=1] - A number that allows per-body time scaling, e.g. a force-field where bodies inside are in slow-motion, while others are at full speed.
* @property {number} [maxStep=0.05] - [description]
* @property {boolean} [debug=false] - Sets {@link Phaser.Physics.Impact.World#debug}.
* @property {number} [maxVelocity=100] - The maximum velocity a body can move.
* @property {boolean} [debugShowBody=true] - Whether the Body's boundary is drawn to the debug display.
* @property {boolean} [debugShowVelocity=true] - Whether the Body's velocity is drawn to the debug display.
* @property {number} [debugBodyColor=0xff00ff] - The color of this Body on the debug display.
* @property {number} [debugVelocityColor=0x00ff00] - The color of the Body's velocity on the debug display.
* @property {number} [maxVelocityX=maxVelocity] - Maximum X velocity objects can move.
* @property {number} [maxVelocityY=maxVelocity] - Maximum Y velocity objects can move.
* @property {number} [minBounceVelocity=40] - The minimum velocity an object can be moving at to be considered for bounce.
* @property {number} [gravityFactor=1] - Gravity multiplier. Set to 0 for no gravity.
* @property {number} [bounciness=0] - The default bounce, or restitution, of bodies in the world.
* @property {(object|boolean)} [setBounds] - Should the world have bounds enabled by default?
* @property {number} [setBounds.x=0] - The x coordinate of the world bounds.
* @property {number} [setBounds.y=0] - The y coordinate of the world bounds.
* @property {number} [setBounds.width] - The width of the world bounds.
* @property {number} [setBounds.height] - The height of the world bounds.
* @property {number} [setBounds.thickness=64] - The thickness of the walls of the world bounds.
* @property {boolean} [setBounds.left=true] - Should the left-side world bounds wall be created?
* @property {boolean} [setBounds.right=true] - Should the right-side world bounds wall be created?
* @property {boolean} [setBounds.top=true] - Should the top world bounds wall be created?
* @property {boolean} [setBounds.bottom=true] - Should the bottom world bounds wall be created?
*/

View File

@ -0,0 +1,16 @@
/**
* An object containing the 4 wall bodies that bound the physics world.
*
* @typedef {object} Phaser.Types.Physics.Impact.WorldDefaults
* @since 3.0.0
*
* @property {boolean} debugShowBody - Whether the Body's boundary is drawn to the debug display.
* @property {boolean} debugShowVelocity - Whether the Body's velocity is drawn to the debug display.
* @property {number} bodyDebugColor - The color of this Body on the debug display.
* @property {number} velocityDebugColor - The color of the Body's velocity on the debug display.
* @property {number} maxVelocityX - Maximum X velocity objects can move.
* @property {number} maxVelocityY - Maximum Y velocity objects can move.
* @property {number} minBounceVelocity - The minimum velocity an object can be moving at to be considered for bounce.
* @property {number} gravityFactor - Gravity multiplier. Set to 0 for no gravity.
* @property {number} bounciness - The default bounce, or restitution, of bodies in the world.
*/

View File

@ -0,0 +1,9 @@
/**
* @typedef {object} Phaser.Types.Physics.Impact.WorldWalls
* @since 3.0.0
*
* @property {?Phaser.Physics.Impact.Body} left - The left-side wall of the world bounds.
* @property {?Phaser.Physics.Impact.Body} right - The right-side wall of the world bounds.
* @property {?Phaser.Physics.Impact.Body} top - The top wall of the world bounds.
* @property {?Phaser.Physics.Impact.Body} bottom - The bottom wall of the world bounds.
*/

9
node_modules/phaser/plugins/impact/typedefs/index.js generated vendored Normal file
View File

@ -0,0 +1,9 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* @namespace Phaser.Types.Physics.Impact
*/

587
node_modules/phaser/plugins/layer3d/Layer3D.js generated vendored Normal file
View File

@ -0,0 +1,587 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Class = require('../../utils/Class');
var Components = require('../components');
var CONST = require('../../renderer/webgl/pipelines/const');
var GameObject = require('../GameObject');
var GameObjectEvents = require('../events');
var Layer3DCamera = require('./Layer3DCamera');
var Layer3DLight = require('./Layer3DLight');
var Layer3DRender = require('./Layer3DRender');
var Model = require('../../geom/mesh/Model');
var RGB = require('../../display/RGB');
/**
* @classdesc
* A Layer3D Game Object.
*
* The Mesh object is WebGL only and does not have a Canvas counterpart.
*
* TODO - Finish this.
*
* @class Layer3D
* @extends Phaser.GameObjects.GameObject
* @memberof Phaser.GameObjects
* @constructor
* @webglOnly
* @since 3.50.0
*
* @extends Phaser.GameObjects.Components.AlphaSingle
* @extends Phaser.GameObjects.Components.BlendMode
* @extends Phaser.GameObjects.Components.Depth
* @extends Phaser.GameObjects.Components.Mask
* @extends Phaser.GameObjects.Components.Pipeline
* @extends Phaser.GameObjects.Components.Transform
* @extends Phaser.GameObjects.Components.Visible
* @extends Phaser.GameObjects.Components.ScrollFactor
* @extends Phaser.GameObjects.Components.Size
*
* @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time.
* @param {number} [x] - The horizontal position of this Game Object in the world.
* @param {number} [y] - The vertical position of this Game Object in the world.
*/
var Layer3D = new Class({
Extends: GameObject,
Mixins: [
Components.AlphaSingle,
Components.BlendMode,
Components.Depth,
Components.Mask,
Components.Pipeline,
Components.Transform,
Components.Visible,
Components.ScrollFactor,
Components.Size,
Layer3DRender
],
initialize:
function Layer3D (scene, x, y)
{
GameObject.call(this, scene, 'Layer3D');
/**
* A Camera which can be used to control the view of the models being managed
* by this Layer3D. It will default to have an fov of 45 and be positioned at 0, 0, -10,
* with a near of 0.01 and far of 1000. You can change all of these by using the
* methods and properties available on the `Layer3DCamera` class.
*
* @name Phaser.GameObjects.Layer3D#camera
* @type {Phaser.GameObjects.Layer3DCamera}
* @since 3.50.0
*/
this.camera = new Layer3DCamera(this, 45, 0, 0, -10, 0.01, 1000);
/**
* An ambient light source for the entire Layer3D scene and all models it is rendering.
*
* It is created at a position of 0, -100, 0 with full ambient, diffuse and specular
* values. You can change all of these by using the methods and properties
* available on the `Layer3DLight` class.
*
* @name Phaser.GameObjects.Layer3D#light
* @type {Phaser.GameObjects.Layer3DLight}
* @since 3.50.0
*/
this.light = new Layer3DLight(this, 0, 100, 0);
/**
* The color of the fog.
*
* By default it is 0,0,0, which is black.
*
* @name Phaser.GameObjects.Layer3D#fogColor
* @type {Phaser.Display.RGB}
* @since 3.50.0
*/
this.fogColor = new RGB();
/**
* The minimum distance from which fog starts to affect objects closer than it.
*
* @name Phaser.GameObjects.Layer3D#fogNear
* @type {number}
* @since 3.50.0
*/
this.fogNear = 0;
/**
* The maximum distance from which fog starts to affect objects further than it.
*
* @name Phaser.GameObjects.Layer3D#fogFar
* @type {number}
* @since 3.50.0
*/
this.fogFar = Infinity;
/**
* An array of model instances that have been created in this Layer3D.
*
* This array can be sorted, by your own functions, to control model rendering order.
*
* @name Phaser.GameObjects.Layer3D#models
* @type {Phaser.Geom.Mesh.Model[]}
* @since 3.50.0
*/
this.models = [];
/**
* Internal cached value.
*
* @name Phaser.GameObjects.Layer3D#_prevWidth
* @type {number}
* @private
* @since 3.50.0
*/
this._prevWidth = 0;
/**
* Internal cached value.
*
* @name Phaser.GameObjects.Layer3D#_prevHeight
* @type {number}
* @private
* @since 3.50.0
*/
this._prevHeight = 0;
var renderer = scene.sys.renderer;
this.setPosition(x, y);
this.setSize(renderer.width, renderer.height);
this.initPipeline(CONST.MESH_PIPELINE);
this.on(GameObjectEvents.ADDED_TO_SCENE, this.addedToScene, this);
this.on(GameObjectEvents.REMOVED_FROM_SCENE, this.removedFromScene, this);
},
// Overrides Game Object method
addedToScene: function ()
{
this.scene.sys.updateList.add(this);
},
// Overrides Game Object method
removedFromScene: function ()
{
this.scene.sys.updateList.remove(this);
},
/**
* Removes all models from this Layer3D, calling `destroy` on each one of them.
*
* @method Phaser.GameObjects.Layer3D#clearModels
* @since 3.50.0
*/
clearModels: function ()
{
var models = this.models;
for (var i = 0; i < models.length; i++)
{
models[i].destroy();
}
this.models = [];
},
/**
* This method creates a new blank Model instance and adds it to this Layer3D.
*
* You still need to tell it how many vertices it's going to contain in total, but you can
* populate the vertex data at a later stage after calling this. It won't try to render
* while it has no vertices.
*
* @method Phaser.GameObjects.Layer3D#addModel
* @since 3.50.0
*
* @param {number} verticesCount - The total number of vertices this model can contain.
* @param {string|Phaser.Textures.Texture} [texture] - The key, or instance of the Texture this model will use to render with, as stored in the Texture Manager.
* @param {string|integer} [frame] - An optional frame from the Texture this model is rendering with. Ensure your UV data also matches this frame.
* @param {number} [x=0] - The x position of the Model.
* @param {number} [y=0] - The y position of the Model.
* @param {number} [z=0] - The z position of the Model.
*
* @return {Phaser.Geom.Mesh.Model} The model instance that was created.
*/
addModel: function (verticesCount, texture, frame, x, y, z)
{
var model = new Model(this, verticesCount, texture, frame, x, y, z);
this.models.push(model);
return model;
},
/**
* This method creates a new Model based on a loaded triangulated Wavefront OBJ.
*
* The obj file should have been loaded via OBJFile:
*
* ```javascript
* this.load.obj(key, url, [ flipUV ]);
* ```
*
* Then use the key it was loaded under in this method.
*
* If the model has a texture, you must provide it as the second parameter.
*
* The model is then added to this Layer3D. A single Layer3D can contain multiple models
* without impacting each other. Equally, multiple models can all share the same base OBJ
* data.
*
* Make sure your 3D package has triangulated the model data prior to exporting it.
*
* You can scale the model data during import, which will set the new 'base' scale for the model.
*
* You can also offset the models generated vertex positions via the `originX`, `originY` and `originZ`
* parameters, which will change the rotation origin of the model. The model itself can be positioned,
* rotated and scaled independantly of these settings, so don't use them to position the model, just
* use them to offset the base values.
*
* @method Phaser.GameObjects.Layer3D#addModelFromOBJ
* @since 3.50.0
*
* @param {string} key - The key of the data in the OBJ Cache to create the model from.
* @param {string|Phaser.Textures.Texture} [texture] - The key, or instance of the Texture this model will use to render with, as stored in the Texture Manager.
* @param {string|integer} [frame] - An optional frame from the Texture this model is rendering with. Ensure your UV data also matches this frame.
* @param {number} [scale=1] - An amount to scale the model data by during creation.
* @param {number} [originX=0] - The x origin of the model vertices during creation.
* @param {number} [originY=0] - The y origin of the model vertices during creation.
* @param {number} [originZ=0] - The z origin of the model vertices during creation.
*
* @return {Phaser.Geom.Mesh.Model|Phaser.Geom.Mesh.Model[]} The Model instance that was created. If the OBJ contained multiple models then an array of Model instances is returned.
*/
addModelFromOBJ: function (key, texture, frame, scale, originX, originY, originZ)
{
var model = [];
var data = this.scene.sys.cache.obj.get(key);
if (data)
{
model = this.addModelFromData(data, texture, frame, scale, originX, originY, originZ);
}
return (model.length === 1) ? model[0] : model;
},
/**
* This method creates a new Model based on the parsed triangulated model data.
*
* The data should have been parsed in advance via a function such as `ParseObj`:
*
* ```javascript
* const data = Phaser.Geom.Mesh.ParseObj(rawData, flipUV);
*
* Layer3D.addModelFromData(data, texture, frame);
* ```
*
* If the model has a texture, you must provide it as the second parameter.
*
* The model is then added to this Layer3D. A single Layer3D can contain multiple models
* without impacting each other. Equally, multiple models can all share the same base OBJ
* data.
*
* Make sure your 3D package has triangulated the model data prior to exporting it.
*
* You can scale the model data during import, which will set the new 'base' scale for the model.
*
* You can also offset the models generated vertex positions via the `originX`, `originY` and `originZ`
* parameters, which will change the rotation origin of the model. The model itself can be positioned,
* rotated and scaled independantly of these settings, so don't use them to position the model, just
* use them to offset the base values.
*
* @method Phaser.GameObjects.Layer3D#addModelFromData
* @since 3.50.0
*
* @param {array} data - The parsed model data.
* @param {string|Phaser.Textures.Texture} [texture] - The key, or instance of the Texture this model will use to render with, as stored in the Texture Manager.
* @param {string|integer} [frame] - An optional frame from the Texture this model is rendering with. Ensure your UV data also matches this frame.
* @param {number} [scale=1] - An amount to scale the model data by during creation.
* @param {number} [originX=0] - The x origin of the model vertices during creation.
* @param {number} [originY=0] - The y origin of the model vertices during creation.
* @param {number} [originZ=0] - The z origin of the model vertices during creation.
*
* @return {Phaser.Geom.Mesh.Model|Phaser.Geom.Mesh.Model[]} The Model instance that was created. If the data contained multiple models then an array of Model instances is returned.
*/
addModelFromData: function (data, texture, frame, scale, originX, originY, originZ)
{
if (scale === undefined) { scale = 1; }
if (originX === undefined) { originX = 0; }
if (originY === undefined) { originY = 0; }
if (originZ === undefined) { originZ = 0; }
var results = [];
// if (material)
// {
// material = this.parseOBJMaterial(material);
// }
for (var m = 0; m < data.models.length; m++)
{
var modelData = data.models[m];
var vertices = modelData.vertices;
var textureCoords = modelData.textureCoords;
var normals = modelData.vertexNormals;
var faces = modelData.faces;
var model = this.addModel(faces.length * 3, texture, frame);
var defaultUV1 = { u: 0, v: 1 };
var defaultUV2 = { u: 0, v: 0 };
var defaultUV3 = { u: 1, v: 1 };
for (var i = 0; i < faces.length; i++)
{
var face = faces[i];
// {textureCoordsIndex: 0, vertexIndex: 16, vertexNormalIndex: 16}
var v1 = face.vertices[0];
var v2 = face.vertices[1];
var v3 = face.vertices[2];
// {x: 0.19509, y: 0.980785, z: 0}
var m1 = vertices[v1.vertexIndex];
var m2 = vertices[v2.vertexIndex];
var m3 = vertices[v3.vertexIndex];
var n1 = normals[v1.vertexNormalIndex];
var n2 = normals[v2.vertexNormalIndex];
var n3 = normals[v3.vertexNormalIndex];
var t1 = v1.textureCoordsIndex;
var t2 = v2.textureCoordsIndex;
var t3 = v3.textureCoordsIndex;
var uv1 = (t1 === -1) ? defaultUV1 : textureCoords[t1];
var uv2 = (t2 === -1) ? defaultUV2 : textureCoords[t2];
var uv3 = (t3 === -1) ? defaultUV3 : textureCoords[t3];
// var color = 0xffffff;
// if (material && face.material !== '' && material[face.material])
// {
// color = material[face.material];
// }
model.addVertex(originX + m1.x * scale, originY + m1.y * scale, originZ + m1.z * scale, uv1.u, uv1.v, n1.x, n1.y, n1.z);
model.addVertex(originX + m2.x * scale, originY + m2.y * scale, originZ + m2.z * scale, uv2.u, uv2.v, n2.x, n2.y, n2.z);
model.addVertex(originX + m3.x * scale, originY + m3.y * scale, originZ + m3.z * scale, uv3.u, uv3.v, n3.x, n3.y, n3.z);
}
results.push(model);
}
return results;
},
/**
* This method creates a new Model based on the given triangulated vertices arrays.
*
* Adds vertices to this model by parsing the given arrays.
*
* This method will take vertex data in one of two formats, based on the `containsZ` parameter.
*
* If your vertex data are `x`, `y` pairs, then `containsZ` should be `false` (this is the default)
*
* If your vertex data is groups of `x`, `y` and `z` values, then the `containsZ` parameter must be true.
*
* The `uvs` parameter is a numeric array consisting of `u` and `v` pairs.
* The `normals` parameter is a numeric array consisting of `x`, `y` vertex normal values and, if `containsZ` is true, `z` values as well.
* The `indicies` parameter is an optional array that, if given, is an indexed list of vertices to be added.
*
* The following example will create a 256 x 256 sized quad using an index array:
*
* ```javascript
* const vertices = [
* -128, 128,
* 128, 128,
* -128, -128,
* 128, -128
* ];
*
* const uvs = [
* 0, 1,
* 1, 1,
* 0, 0,
* 1, 0
* ];
*
* const indices = [ 0, 2, 1, 2, 3, 1 ];
*
* Layer3D.addModelFromVertices(vertices, uvs, indicies);
* ```
*
* You cannot add more vertices to a model than the total specified when the model was created.
* If you need to clear all vertices first, call `Model.resetVertices`.
*
* @method Phaser.GameObjects.Layer3D#addModelFromVertices
* @since 3.50.0
*
* @param {number[]} vertices - The vertices array. Either `xy` pairs, or `xyz` if the `containsZ` parameter is `true`.
* @param {number[]} uvs - The UVs pairs array.
* @param {number[]} [normals] - Optional vertex normals array. If you don't have one, pass `null` or an empty array.
* @param {number[]} [indicies] - Optional vertex indicies array. If you don't have one, pass `null` or an empty array.
* @param {boolean} [containsZ=false] - Does the vertices data include a `z` component?
* @param {string|Phaser.Textures.Texture} [texture] - The key, or instance of the Texture the model will use to render with, as stored in the Texture Manager.
* @param {string|integer} [frame] - An optional frame from the Texture the model is rendering with.
*
* @return {Phaser.Geom.Mesh.Model} The Model instance that was created.
*/
addModelFromVertices: function (vertices, uvs, normals, indicies, containsZ, texture, frame)
{
var isIndexed = (Array.isArray(indicies) && indicies.length > 0);
var verticesCount = (isIndexed) ? indicies.length : vertices.length;
if (!isIndexed)
{
verticesCount /= 2;
}
var model = this.addModel(verticesCount, texture, frame, 0, 0, 0);
model.addVertices(vertices, uvs, normals, indicies, containsZ);
return model;
},
/**
* Sets the fog values for this Layer3D, including the fog color and the near and
* far distance values.
*
* By default, fog effects all models in this layer.
*
* If you do not wish to have a fog effect, see the `disableFog` method.
*
* @method Phaser.GameObjects.Layer3D#setFog
* @since 3.50.0
*
* @param {number} red - The red color component of the fog. A value between 0 and 1.
* @param {number} green - The green color component of the fog. A value between 0 and 1.
* @param {number} blue - The blue color component of the fog. A value between 0 and 1.
* @param {number} [near] - The 'near' value of the fog.
* @param {number} [far] - The 'far' value of the fog, beyond which objects are 'fogged' out.
*
* @return {this} This Layer3D Game Object.
*/
setFog: function (red, green, blue, near, far)
{
if (near === undefined) { near = this.fogNear; }
if (far === undefined) { far = this.fogFar; }
this.fogColor.set(red, green, blue);
this.fogNear = near;
this.fogFar = far;
return this;
},
/**
* Disables fog for this Layer3D and all models it renders.
*
* To re-enable fog, just call `setFog` and provide new color, near and far values.
*
* @method Phaser.GameObjects.Layer3D#disableFog
* @since 3.50.0
*
* @return {this} This Layer3D Game Object.
*/
disableFog: function ()
{
this.fogFar = Infinity;
return this;
},
/**
* The Layer3D update loop.
*
* @method Phaser.GameObjects.Layer3D#preUpdate
* @protected
* @since 3.50.0
*
* @param {number} time - The current timestamp.
* @param {number} delta - The delta time, in ms, elapsed since the last frame.
*/
preUpdate: function (time, delta)
{
var width = this.width;
var height = this.height;
var camera = this.camera;
if (camera.dirtyProjection || width !== this._prevWidth || height !== this._prevHeight)
{
camera.updateProjectionMatrix(width, height);
this._prevWidth = width;
this._prevHeight = height;
}
var models = this.models;
for (var i = 0; i < models.length; i++)
{
var model = models[i];
if (model.visible)
{
model.preUpdate(time, delta);
}
}
},
/**
* Resets all of the dirty cache values this Layer3D object uses.
*
* This is called automatically at the end of the render step.
*
* @method Phaser.GameObjects.Layer3D#resetDirtyFlags
* @protected
* @since 3.50.0
*/
resetDirtyFlags: function ()
{
this.camera.dirtyView = false;
this.camera.dirtyProjection = false;
this.light.ambient.dirty = false;
this.light.diffuse.dirty = false;
this.light.specular.dirty = false;
this.fogColor.dirty = false;
},
/**
* The destroy step for this Layer3D, which removes all models, destroys the camera and
* nulls external references.
*
* @method Phaser.GameObjects.Layer3D#preDestroy
* @private
* @since 3.50.0
*/
preDestroy: function ()
{
this.clearModels();
this.camera.destroy();
this.light.destroy();
this.camera = null;
this.light = null;
}
});
module.exports = Layer3D;

716
node_modules/phaser/plugins/layer3d/Layer3DCamera.js generated vendored Normal file
View File

@ -0,0 +1,716 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Class = require('../../utils/Class');
var DegToRad = require('../../math/DegToRad');
var GetFastValue = require('../../utils/object/GetFastValue');
var INPUT_EVENTS = require('../../input/events');
var Matrix4 = require('../../math/Matrix4');
var Vector3 = require('../../math/Vector3');
var Vector4 = require('../../math/Vector4');
/**
* @classdesc
* The Layer3D Camera.
*
* @class Layer3DCamera
* @memberof Phaser.GameObjects
* @constructor
* @since 3.50.0
*/
var Layer3DCamera = new Class({
initialize:
function Layer3DCamera (layer, fov, x, y, z, near, far)
{
/**
* The Layer3D instance this camera belongs to.
*
* A camera can only belong to a single Layer3D instance.
*
* You should consider this property as being read-only. You cannot move a
* camera to another Layer3D by simply changing it.
*
* @name Phaser.GameObjects.Layer3DCamera#layer
* @type {Phaser.GameObjects.Layer3D}
* @since 3.50.0
*/
this.layer = layer;
/**
* The Scene Input Plugin, as referenced via the Layer3D parent.
*
* @name Phaser.GameObjects.Layer3DCamera#input
* @type {Phaser.Input.InputPlugin}
* @since 3.50.0
*/
this.input = layer.scene.sys.input;
/**
* Internal 'dirty' flag that tells the parent Layer3D if the
* view matrix of this camera needs recalculating at the next step.
*
* @name Phaser.GameObjects.Layer3DCamera#dirtyView
* @type {boolean}
* @since 3.50.0
*/
this.dirtyView = true;
/**
* Internal 'dirty' flag that tells the parent Layer3D if the
* projection matrix of this camera needs recalculating at the next step.
*
* @name Phaser.GameObjects.Layer3DCamera#dirtyProjection
* @type {boolean}
* @since 3.50.0
*/
this.dirtyProjection = true;
/**
* Internal fov value.
*
* @name Phaser.GameObjects.Layer3DCamera#_fov
* @type {number}
* @private
* @since 3.50.0
*/
this._fov = fov;
/**
* Internal near value.
*
* @name Phaser.GameObjects.Layer3DCamera#_near
* @type {number}
* @private
* @since 3.50.0
*/
this._near = near;
/**
* Internal far value.
*
* @name Phaser.GameObjects.Layer3DCamera#_far
* @type {number}
* @private
* @since 3.50.0
*/
this._far = far;
/**
* The aspect ratio of the camera.
*
* @name Phaser.GameObjects.Layer3DCamera#aspectRatio
* @type {number}
* @since 3.50.0
*/
this.aspectRatio = 1;
/**
* The position of the camera in 3D space.
*
* You can modify this vector directly, or use the `x`, `y` and `z`
* properties of this class.
*
* @name Phaser.GameObjects.Layer3DCamera#position
* @type {Phaser.Math.Vector3}
* @since 3.50.0
*/
this.position = new Vector3(x, y, z);
/**
* The rotation of the camera in 3D space.
*
* You can modify this vector directly, or use the `rotationX`, `rotationY`
* and `rotationZ` properties of this class.
*
* @name Phaser.GameObjects.Layer3DCamera#rotation
* @type {Phaser.Math.Vector3}
* @since 3.50.0
*/
this.rotation = new Vector3();
/**
* The forward facing vector of the camera.
*
* Calculated and updated automatically when the view matrix changes.
*
* @name Phaser.GameObjects.Layer3DCamera#forward
* @type {Phaser.Math.Vector4}
* @since 3.50.0
*/
this.forward = new Vector4();
/**
* The upward facing vector of the camera.
* Invert it to get the bottom vector.
*
* Calculated and updated automatically when the view matrix changes.
*
* @name Phaser.GameObjects.Layer3DCamera#up
* @type {Phaser.Math.Vector4}
* @since 3.50.0
*/
this.up = new Vector4();
/**
* The right facing vector of the camera.
* Invert it to get the left vector.
*
* Calculated and updated automatically when the view matrix changes.
*
* @name Phaser.GameObjects.Layer3DCamera#right
* @type {Phaser.Math.Vector4}
* @since 3.50.0
*/
this.right = new Vector4();
/**
* Internal transform matrix.
*
* Calculated and updated automatically when the camera is dirty.
*
* @name Phaser.GameObjects.Layer3DCamera#matrix
* @type {Phaser.Math.Matrix4}
* @since 3.50.0
*/
this.matrix = new Matrix4();
/**
* The inverse of the transform matrix.
*
* Calculated and updated automatically when the camera is dirty.
*
* @name Phaser.GameObjects.Layer3DCamera#viewMatrix
* @type {Phaser.Math.Matrix4}
* @since 3.50.0
*/
this.viewMatrix = new Matrix4();
/**
* The perspective projection matrix.
*
* Calculated and updated automatically when the camera is dirty.
*
* @name Phaser.GameObjects.Layer3DCamera#projectionMatrix
* @type {Phaser.Math.Matrix4}
* @since 3.50.0
*/
this.projectionMatrix = new Matrix4();
/**
* The perspective projection matrix, multiplied by the view matrix.
*
* Calculated and updated automatically when the camera is dirty.
*
* @name Phaser.GameObjects.Layer3DCamera#viewProjectionMatrix
* @type {Phaser.Math.Matrix4}
* @since 3.50.0
*/
this.viewProjectionMatrix = new Matrix4();
/**
* The movement and rotation mode of this camera.
* Either ORBIT, or FREE.
*
* @name Phaser.GameObjects.Layer3DCamera#mode
* @type {number}
* @since 3.50.0
*/
this.mode = Layer3DCamera.MODE_ORBIT;
/**
* How fast to rotate the camera, in degrees per delta.
*
* This value is only used after calling the `enableControls` method,
* it does not influence changing the rotation values directly.
*
* @name Phaser.GameObjects.Layer3DCamera#rotateSpeed
* @type {number}
* @since 3.50.0
*/
this.rotateSpeed = 0.5;
/**
* How fast to pan the camera, in units per delta.
*
* This value is only used after calling the `enableControls` method,
* it does not influence calling the pan methods directly.
*
* @name Phaser.GameObjects.Layer3DCamera#panSpeed
* @type {number}
* @since 3.50.0
*/
this.panSpeed = 4;
/**
* How fast to zoom the camera.
*
* This value is only used after calling the `enableControls` method,
* it does not influence calling the panZ method directly.
*
* @name Phaser.GameObjects.Layer3DCamera#zoomSpeed
* @type {number}
* @since 3.50.0
*/
this.zoomSpeed = 3;
this.allowPan = false;
this.lockXAxis = false;
this.lockYAxis = false;
},
enableOrbitControls: function (config)
{
this.rotateSpeed = GetFastValue(config, 'rotateSpeed', this.rotateSpeed);
this.panSpeed = GetFastValue(config, 'panSpeed', this.panSpeed);
this.allowPan = GetFastValue(config, 'allowPan', this.allowPan);
this.lockXAxis = GetFastValue(config, 'lockXAxis', this.lockXAxis);
this.lockYAxis = GetFastValue(config, 'lockYAxis', this.lockYAxis);
this.input.on(INPUT_EVENTS.POINTER_MOVE, this.pointerMoveHandler, this);
},
disableOrbitControls: function ()
{
this.input.off(INPUT_EVENTS.POINTER_MOVE, this.pointerMoveHandler, this);
},
enableZoom: function (zoomSpeed)
{
if (zoomSpeed === undefined) { zoomSpeed = 3; }
this.zoomSpeed = zoomSpeed;
this.input.on(INPUT_EVENTS.POINTER_WHEEL, this.pointerWheelHandler, this);
},
disableZoom: function ()
{
this.input.off(INPUT_EVENTS.POINTER_WHEEL, this.pointerWheelHandler, this);
},
pointerMoveHandler: function (pointer)
{
if (pointer.isDown)
{
var width = this.layer.width;
var height = this.layer.height;
if (pointer.event.shiftKey && this.allowPan)
{
this.panX(pointer.velocity.x * (this.panSpeed / width));
this.panY(pointer.velocity.y * (this.panSpeed / height));
}
else
{
if (!this.lockXAxis)
{
this.rotationX -= pointer.velocity.y * (this.rotateSpeed / height);
}
if (!this.lockYAxis)
{
this.rotationY -= pointer.velocity.x * (this.rotateSpeed / width);
}
}
}
},
pointerWheelHandler: function (pointer, over, deltaX, deltaY)
{
this.panZ(deltaY * (this.zoomSpeed / this.layer.height));
},
/**
* Pans this camera on the x axis by the given amount.
*
* @method Phaser.GameObjects.Layer3DCamera#panX
* @since 3.50.0
*
* @param {number} v - The amount to pan by.
*/
panX: function (v)
{
this.updateViewMatrix();
this.position.addScale(this.right, v);
},
/**
* Pans this camera on the y axis by the given amount.
*
* @method Phaser.GameObjects.Layer3DCamera#panY
* @since 3.50.0
*
* @param {number} v - The amount to pan by.
*/
panY: function (v)
{
this.updateViewMatrix();
this.y += this.up.y * v;
if (this.mode === Layer3DCamera.MODE_ORBIT)
{
// Can only move up and down the y axis in orbit mode
return;
}
this.x += this.up.x * v;
this.z += this.up.z * v;
},
/**
* Pans this camera on the z axis by the given amount.
*
* @method Phaser.GameObjects.Layer3DCamera#panZ
* @since 3.50.0
*
* @param {number} v - The amount to pan by.
*/
panZ: function (v)
{
this.updateViewMatrix();
if (this.mode === Layer3DCamera.MODE_ORBIT)
{
// Orbit mode translates after rotatation, so only need to set Z. The rotation will handle the rest.
this.z += v;
}
else
{
// In freemode to move forward, we move based on our forward, which is relative to our current rotation.
this.position.addScale(this.forward, v);
}
},
/**
* Internal method that is called by the Layer3D instance that owns this camera
* during its `render` step. If the view matrix is dirty, it is recalculated
* and then applied to the view projection matrix, ready for rendering.
*
* @method Phaser.GameObjects.Layer3DCamera#update
* @since 3.50.0
*/
update: function ()
{
if (this.dirtyView)
{
this.updateViewMatrix();
}
if (this.dirtyView || this.dirtyProjection)
{
this.projectionMatrix.multiplyToMat4(this.viewMatrix, this.viewProjectionMatrix);
}
},
/**
* Internal method that handles the update of the view transform matrix, based on the rotation
* and position of the camera. Called automatically when the camera is updated.
*
* @method Phaser.GameObjects.Layer3DCamera#updateViewMatrix
* @since 3.50.0
*/
updateViewMatrix: function ()
{
var matView = this.matrix;
if (this.mode === Layer3DCamera.MODE_FREE)
{
matView.fromRotationXYTranslation(this.rotation, this.position, true);
}
else
{
matView.fromRotationXYTranslation(this.rotation, this.position, false);
}
this.updateDirection();
this.viewMatrix.copy(matView).invert();
},
/**
* Internal method that is called by the Layer3D instance that owns this camera
* during its `preUpdate` step. If the projection matrix is dirty, or the renderer
* width or height has changed, then a new projection matrix is calculated.
*
* @method Phaser.GameObjects.Layer3DCamera#updateProjectionMatrix
* @since 3.50.0
*
* @param {number} width - The width of the renderer.
* @param {number} height - The height of the renderer.
*/
updateProjectionMatrix: function (width, height)
{
this.aspectRatio = width / height;
this.projectionMatrix.perspective(DegToRad(this._fov), this.aspectRatio, this._near, this._far);
},
/**
* Internal method that sets the forward, up and right vectors from
* the view matrix. This is called automatically as part of the
* `updateViewMatrix` method.
*
* @method Phaser.GameObjects.Layer3DCamera#updateDirection
* @since 3.50.0
*/
updateDirection: function ()
{
var matView = this.matrix;
this.forward.set(0, 0, 1, 0).transformMat4(matView);
this.up.set(0, 1, 0, 0).transformMat4(matView);
this.right.set(1, 0, 0, 0).transformMat4(matView);
},
/**
* The field of view, in degrees, of this camera.
*
* Limited to the range of 0 to 180.
*
* @name Phaser.GameObjects.Layer3DCamera#fov
* @type {number}
* @since 3.50.0
*/
fov: {
get: function ()
{
return this._fov;
},
set: function (value)
{
if (value > 0 && value < 180)
{
this._fov = value;
this.dirtyProjection = true;
}
}
},
/**
* The minimum distance the camera can see from.
*
* It's important to consider that depth buffers are not infinite and the closer
* a camera starts, the more you may encounter depth fighting issues.
*
* @name Phaser.GameObjects.Layer3DCamera#near
* @type {number}
* @since 3.50.0
*/
near: {
get: function ()
{
return this._near;
},
set: function (value)
{
if (value > 0)
{
this._near = value;
this.dirtyProjection = true;
}
}
},
/**
* The maximum distance the camera can see to.
*
* It's important to consider that depth buffers are not infinite and the further
* a camera ends, the more you may encounter depth fighting issues.
*
* @name Phaser.GameObjects.Layer3DCamera#far
* @type {number}
* @since 3.50.0
*/
far: {
get: function ()
{
return this._far;
},
set: function (value)
{
if (value > 0)
{
this._far = value;
this.dirtyProjection = true;
}
}
},
/**
* The x position of the camera.
*
* @name Phaser.GameObjects.Layer3DCamera#x
* @type {number}
* @since 3.50.0
*/
x: {
get: function ()
{
return this.position.x;
},
set: function (value)
{
this.position.x = value;
this.dirtyView = true;
}
},
/**
* The y position of the camera.
*
* @name Phaser.GameObjects.Layer3DCamera#y
* @type {number}
* @since 3.50.0
*/
y: {
get: function ()
{
return this.position.y;
},
set: function (value)
{
this.position.y = value;
this.dirtyView = true;
}
},
/**
* The z position of the camera.
*
* @name Phaser.GameObjects.Layer3DCamera#z
* @type {number}
* @since 3.50.0
*/
z: {
get: function ()
{
return this.position.z;
},
set: function (value)
{
this.position.z = value;
this.dirtyView = true;
}
},
/**
* The x axis rotation, in radians, of the camera.
*
* @name Phaser.GameObjects.Layer3DCamera#rotationX
* @type {number}
* @since 3.50.0
*/
rotationX: {
get: function ()
{
return this.rotation.x;
},
set: function (value)
{
this.rotation.x = value;
this.dirtyView = true;
}
},
/**
* The y axis rotation, in radians, of the camera.
*
* @name Phaser.GameObjects.Layer3DCamera#rotationY
* @type {number}
* @since 3.50.0
*/
rotationY: {
get: function ()
{
return this.rotation.y;
},
set: function (value)
{
this.rotation.y = value;
this.dirtyView = true;
}
},
/**
* The z axis rotation, in radians, of the camera.
*
* @name Phaser.GameObjects.Layer3DCamera#rotationZ
* @type {number}
* @since 3.50.0
*/
rotationZ: {
get: function ()
{
return this.rotation.z;
},
set: function (value)
{
this.rotation.z = value;
this.dirtyView = true;
}
},
/**
* Destroy handler for this camera.
*
* @method Phaser.GameObjects.Layer3DCamera#destroy
* @since 3.50.0
*/
destroy: function ()
{
this.layer = null;
this.position = null;
this.rotation = null;
this.forward = null;
this.up = null;
this.right = null;
this.matrix = null;
this.viewMatrix = null;
this.projectionMatrix = null;
this.viewProjectionMatrix = null;
}
});
// Allows free movement of position and rotation
Layer3DCamera.MODE_FREE = 0;
// Movement is locked to rotate around the origin
Layer3DCamera.MODE_ORBIT = 1;
module.exports = Layer3DCamera;

View File

@ -0,0 +1,22 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* This is a stub function for Layer3D.Render. There is no Canvas renderer for Layer3D objects.
*
* @method Phaser.GameObjects.Layer3D#renderCanvas
* @since 3.50.0
* @private
*
* @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer.
* @param {Phaser.GameObjects.Layer3D} src - The Game Object being rendered in this call.
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object.
*/
var Layer3DCanvasRenderer = function ()
{
};
module.exports = Layer3DCanvasRenderer;

40
node_modules/phaser/plugins/layer3d/Layer3DCreator.js generated vendored Normal file
View File

@ -0,0 +1,40 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var BuildGameObject = require('../BuildGameObject');
var GameObjectCreator = require('../GameObjectCreator');
var Layer3D = require('./Layer3D');
/**
* Creates a new Layer3D Game Object and returns it.
*
* Note: This method will only be available if the Layer3D Game Object and WebGL support have been built into Phaser.
*
* @method Phaser.GameObjects.GameObjectCreator#layer3d
* @since 3.50.0
*
* @param {Phaser.Types.GameObjects.GameObjectConfig} config - The configuration object this Game Object will use to create itself.
* @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object.
*
* @return {Phaser.GameObjects.Layer3D} The Game Object that was created.
*/
GameObjectCreator.register('layer3d', function (config, addToScene)
{
if (config === undefined) { config = {}; }
var layer = new Layer3D(this.scene, 0, 0);
if (addToScene !== undefined)
{
config.add = addToScene;
}
BuildGameObject(this.scene, layer, config);
return layer;
});
// When registering a factory function 'this' refers to the GameObjectCreator context.

38
node_modules/phaser/plugins/layer3d/Layer3DFactory.js generated vendored Normal file
View File

@ -0,0 +1,38 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Layer3D = require('./Layer3D');
var GameObjectFactory = require('../GameObjectFactory');
/**
* Creates a new Layer3D Game Object and adds it to the Scene.
*
* Note: This method will only be available if the Layer3D Game Object and WebGL support have been built into Phaser.
*
* @method Phaser.GameObjects.GameObjectFactory#layer3d
* @webglOnly
* @since 3.50.0
*
* @param {number} [x] - The horizontal position of this Game Object in the world.
* @param {number} [y] - The vertical position of this Game Object in the world.
*
* @return {Phaser.GameObjects.Layer3D} The Game Object that was created.
*/
if (typeof WEBGL_RENDERER)
{
GameObjectFactory.register('layer3d', function (x, y)
{
return this.displayList.add(new Layer3D(this.scene, x, y));
});
}
// When registering a factory function 'this' refers to the GameObjectFactory context.
//
// There are several properties available to use:
//
// this.scene - a reference to the Scene that owns the GameObjectFactory
// this.displayList - a reference to the Display List the Scene owns
// this.updateList - a reference to the Update List the Scene owns

295
node_modules/phaser/plugins/layer3d/Layer3DLight.js generated vendored Normal file
View File

@ -0,0 +1,295 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Class = require('../../utils/Class');
var RGB = require('../../display/RGB');
var Vector3 = require('../../math/Vector3');
/**
* @classdesc
* A Layer3D Light.
*
* @class Layer3DLight
* @memberof Phaser.GameObjects
* @constructor
* @since 3.50.0
*/
var Layer3DLight = new Class({
initialize:
function Layer3DLight (layer, x, y, z)
{
/**
* The Layer3D instance this light belongs to.
*
* A light can only belong to a single Layer3D instance.
*
* You should consider this property as being read-only. You cannot move a
* light to another Layer3D by simply changing it.
*
* @name Phaser.GameObjects.Layer3DLight#layer
* @type {Phaser.GameObjects.Layer3D}
* @since 3.50.0
*/
this.layer = layer;
/**
* The position of the light in 3D space.
*
* You can modify this vector directly, or use the `x`, `y` and `z`
* properties of this class.
*
* @name Phaser.GameObjects.Layer3DLight#position
* @type {Phaser.Math.Vector3}
* @since 3.50.0
*/
this.position = new Vector3(x, y, z);
/**
* The ambient color of the light.
*
* The default ambient color is 1, 1, 1.
*
* You can modify the properties of this RGB object directly, or call
* the `setAmbient` method of this class.
*
* The values in this object are used by the `uLightAmbient` shader uniform.
*
* @name Phaser.GameObjects.Layer3DLight#ambient
* @type {Phaser.Display.RGB}
* @since 3.50.0
*/
this.ambient = new RGB(1, 1, 1);
/**
* The diffuse color of the light.
*
* The default diffuse color is 1, 1, 1.
*
* You can modify the properties of this RGB object directly, or call
* the `setDiffuse` method of this class.
*
* The values in this object are used by the `uLightDiffuse` shader uniform.
*
* @name Phaser.GameObjects.Layer3DLight#diffuse
* @type {Phaser.Display.RGB}
* @since 3.50.0
*/
this.diffuse = new RGB(1, 1, 1);
/**
* The specular color of the light.
*
* The default specular color is 1, 1, 1.
*
* You can modify the properties of this RGB object directly, or call
* the `setSpecular` method of this class.
*
* The values in this object are used by the `uLightSpecular` shader uniform.
*
* @name Phaser.GameObjects.Layer3DLight#specular
* @type {Phaser.Display.RGB}
* @since 3.50.0
*/
this.specular = new RGB(1, 1, 1);
/**
* Internal dirty cache array.
*
* @name Phaser.GameObjects.Layer3DLight#dirtyCache
* @type {number[]}
* @private
* @since 3.50.0
*/
this.dirtyCache = [ 0, 0, 0 ];
},
/**
* Checks if the position of this light is dirty.
*
* Called internally by the Mesh Pipeline `onBind` method and if dirty
* is used to set the `uLightPosition` uniform.
*
* @method Phaser.GameObjects.Layer3DLight#isDirty
* @since 3.50.0
*
* @return {boolean} `true` if this light is dirty, otherwise `false`.
*/
isDirty: function ()
{
var position = this.position;
var dirtyCache = this.dirtyCache;
var x = position.x;
var y = position.y;
var z = position.z;
var xCached = dirtyCache[0];
var yCached = dirtyCache[1];
var zCached = dirtyCache[2];
dirtyCache[0] = x;
dirtyCache[1] = y;
dirtyCache[2] = z;
return (xCached !== x || yCached !== y || zCached !== z);
},
/**
* Sets the position of this light.
*
* @method Phaser.GameObjects.Layer3DLight#setPosition
* @since 3.50.0
*
* @param {number} x - The x position of this light.
* @param {number} y - The y position of this light.
* @param {number} z - The z position of this light.
*
* @return {this} This Layer3DLight instance.
*/
setPosition: function (x, y, z)
{
this.position.set(x, y, z);
return this;
},
/**
* Sets the ambient color of this light.
*
* @method Phaser.GameObjects.Layer3DLight#setAmbient
* @since 3.50.0
*
* @param {number} r - The red color value. Between 0 and 1.
* @param {number} g - The green color value. Between 0 and 1.
* @param {number} b - The blue color value. Between 0 and 1.
*
* @return {this} This Layer3DLight instance.
*/
setAmbient: function (r, g, b)
{
this.ambient.set(r, g, b);
return this;
},
/**
* Sets the diffuse color of this light.
*
* @method Phaser.GameObjects.Layer3DLight#setDiffuse
* @since 3.50.0
*
* @param {number} r - The red color value. Between 0 and 1.
* @param {number} g - The green color value. Between 0 and 1.
* @param {number} b - The blue color value. Between 0 and 1.
*
* @return {this} This Layer3DLight instance.
*/
setDiffuse: function (r, g, b)
{
this.diffuse.set(r, g, b);
return this;
},
/**
* Sets the specular color of this light.
*
* @method Phaser.GameObjects.Layer3DLight#setSpecular
* @since 3.50.0
*
* @param {number} r - The red color value. Between 0 and 1.
* @param {number} g - The green color value. Between 0 and 1.
* @param {number} b - The blue color value. Between 0 and 1.
*
* @return {this} This Layer3DLight instance.
*/
setSpecular: function (r, g, b)
{
this.specular.set(r, g, b);
return this;
},
/**
* The x position of the light.
*
* @name Phaser.GameObjects.Layer3DLight#x
* @type {number}
* @since 3.50.0
*/
x: {
get: function ()
{
return this.position.x;
},
set: function (value)
{
this.position.x = value;
}
},
/**
* The y position of the light.
*
* @name Phaser.GameObjects.Layer3DLight#y
* @type {number}
* @since 3.50.0
*/
y: {
get: function ()
{
return this.position.y;
},
set: function (value)
{
this.position.y = value;
}
},
/**
* The z position of the light.
*
* @name Phaser.GameObjects.Layer3DLight#z
* @type {number}
* @since 3.50.0
*/
z: {
get: function ()
{
return this.position.z;
},
set: function (value)
{
this.position.z = value;
}
},
/**
* Destroy handler for this light.
*
* @method Phaser.GameObjects.Layer3DLight#destroy
* @since 3.50.0
*/
destroy: function ()
{
this.layer = null;
this.position = null;
}
});
module.exports = Layer3DLight;

25
node_modules/phaser/plugins/layer3d/Layer3DRender.js generated vendored Normal file
View File

@ -0,0 +1,25 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var renderWebGL = require('../../utils/NOOP');
var renderCanvas = require('../../utils/NOOP');
if (typeof WEBGL_RENDERER)
{
renderWebGL = require('./Layer3DWebGLRenderer');
}
if (typeof CANVAS_RENDERER)
{
renderCanvas = require('./Layer3DCanvasRenderer');
}
module.exports = {
renderWebGL: renderWebGL,
renderCanvas: renderCanvas
};

View File

@ -0,0 +1,52 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* Renders this Game Object with the WebGL Renderer to the given Camera.
* The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera.
* This method should not be called directly. It is a utility function of the Render module.
*
* @method Phaser.GameObjects.Layer3D#renderWebGL
* @since 3.50.0
* @private
*
* @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer.
* @param {Phaser.GameObjects.Layer3D} src - The Game Object being rendered in this call.
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object.
* @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested
*/
var Layer3DWebGLRenderer = function (renderer, src)
{
var models = src.models;
var totalModels = models.length;
if (totalModels === 0)
{
return;
}
renderer.pipelines.clear();
src.camera.update();
var pipeline = renderer.pipelines.set(src.pipeline, src);
for (var m = 0; m < totalModels; m++)
{
var model = models[m];
if (model.visible && model.vertexCount > 0)
{
pipeline.drawModel(src, model);
}
}
src.resetDirtyFlags();
renderer.pipelines.rebind();
};
module.exports = Layer3DWebGLRenderer;

288
node_modules/phaser/plugins/layer3d/MeshPipeline.js generated vendored Normal file
View File

@ -0,0 +1,288 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Class = require('../../../utils/Class');
var GetFastValue = require('../../../utils/object/GetFastValue');
var ShaderSourceFS = require('../shaders/Mesh-frag.js');
var ShaderSourceVS = require('../shaders/Mesh-vert.js');
var WebGLPipeline = require('../WebGLPipeline');
/**
* @classdesc
* TODO
*
* @class MeshPipeline
* @extends Phaser.Renderer.WebGL.WebGLPipeline
* @memberof Phaser.Renderer.WebGL.Pipelines
* @constructor
* @since 3.50.0
*
* @param {Phaser.Types.Renderer.WebGL.WebGLPipelineConfig} config - The configuration options for this pipeline.
*/
var MeshPipeline = new Class({
Extends: WebGLPipeline,
initialize:
function MeshPipeline (config)
{
var gl = config.game.renderer.gl;
config.fragShader = GetFastValue(config, 'fragShader', ShaderSourceFS),
config.vertShader = GetFastValue(config, 'vertShader', ShaderSourceVS),
config.vertexCapacity = GetFastValue(config, 'vertexCapacity', 8),
config.vertexSize = GetFastValue(config, 'vertexSize', 32),
config.attributes = GetFastValue(config, 'attributes', [
{
name: 'aVertexPosition',
size: 3,
type: gl.FLOAT,
normalized: false,
offset: 0,
enabled: false,
location: -1
},
{
name: 'aVertexNormal',
size: 3,
type: gl.FLOAT,
normalized: false,
offset: 12,
enabled: false,
location: -1
},
{
name: 'aTextureCoord',
size: 2,
type: gl.FLOAT,
normalized: false,
offset: 24,
enabled: false,
location: -1
}
]);
config.uniforms = GetFastValue(config, 'uniforms', [
'uViewProjectionMatrix',
'uLightPosition',
'uLightAmbient',
'uLightDiffuse',
'uLightSpecular',
'uCameraPosition',
'uFogColor',
'uFogNear',
'uFogFar',
'uModelMatrix',
'uNormalMatrix',
'uMaterialAmbient',
'uMaterialDiffuse',
'uMaterialSpecular',
'uMaterialShine',
'uTexture'
]);
WebGLPipeline.call(this, config);
this.forceZero = true;
// Cache structure:
// 0 fog near
// 1 fog far
// 2, 3, 4 model material ambient
// 5, 6, 7 model material diffuse
// 8, 9, 10 model material specular
// 11 model material shine
this.dirtyCache = [
-1,
-1,
-1, -1, -1,
-1, -1, -1,
-1, -1, -1,
-1
];
this.cullMode = 1029;
},
/**
* Called every time the pipeline is bound by the renderer.
* Sets the shader program, vertex buffer and other resources.
* Should only be called when changing pipeline.
*
* @method Phaser.Renderer.WebGL.Pipelines.MeshPipeline#bind
* @since 3.50.0
*
* @param {boolean} [reset=false] - Should the pipeline be fully re-bound after a renderer pipeline clear?
*
* @return {this} This WebGLPipeline instance.
*/
bind: function (reset)
{
if (reset === undefined) { reset = false; }
WebGLPipeline.prototype.bind.call(this, reset);
var gl = this.gl;
gl.enable(gl.DEPTH_TEST);
gl.enable(gl.CULL_FACE);
gl.cullFace(gl.BACK);
return this;
},
/**
* This method is called every time a Game Object asks the Pipeline Manager to use this pipeline.
*
* Unlike the `bind` method, which is only called once per frame, this is called for every object
* that requests it, allowing you to perform per-object GL set-up.
*
* @method Phaser.Renderer.WebGL.Pipelines.MeshPipeline#onBind
* @since 3.50.0
*
* @param {Phaser.GameObjects.Mesh} mesh - The Mesh that requested this pipeline.
*
* @return {this} This WebGLPipeline instance.
*/
onBind: function (mesh)
{
var camera = mesh.camera;
if (camera.dirtyView || camera.dirtyProjection)
{
this.setMatrix4fv('uViewProjectionMatrix', false, camera.viewProjectionMatrix.val);
this.set3f('uCameraPosition', camera.x, camera.y, camera.z);
}
var light = mesh.light;
if (light.isDirty())
{
this.set3f('uLightPosition', light.x, light.y, light.z);
}
var ambient = light.ambient;
var diffuse = light.diffuse;
var specular = light.specular;
if (ambient.dirty)
{
this.set3f('uLightAmbient', ambient.r, ambient.g, ambient.b);
}
if (diffuse.dirty)
{
this.set3f('uLightDiffuse', diffuse.r, diffuse.g, diffuse.b);
}
if (specular.dirty)
{
this.set3f('uLightSpecular', specular.r, specular.g, specular.b);
}
var fogColor = mesh.fogColor;
if (fogColor.dirty)
{
this.set3f('uFogColor', fogColor.r, fogColor.g, fogColor.b);
}
var cache = this.dirtyCache;
var fogNear = mesh.fogNear;
var fogFar = mesh.fogFar;
if (cache[0] !== fogNear)
{
this.set1f('uFogNear', fogNear);
cache[0] = fogNear;
}
if (cache[1] !== fogFar)
{
this.set1f('uFogFar', fogFar);
cache[1] = fogFar;
}
this.set1i('uTexture', 0);
},
drawModel: function (mesh, model)
{
var cache = this.dirtyCache;
this.setMatrix4fv('uModelMatrix', false, model.transformMatrix.val);
this.setMatrix4fv('uNormalMatrix', false, model.normalMatrix.val);
var ambient = model.ambient;
if (!ambient.equals(cache[2], cache[3], cache[4]))
{
this.set3f('uMaterialAmbient', ambient.r, ambient.g, ambient.b);
cache[2] = ambient.r;
cache[3] = ambient.g;
cache[4] = ambient.b;
}
var diffuse = model.diffuse;
if (!diffuse.equals(cache[5], cache[6], cache[7]))
{
this.set3f('uMaterialDiffuse', diffuse.r, diffuse.g, diffuse.b);
cache[5] = diffuse.r;
cache[6] = diffuse.g;
cache[7] = diffuse.b;
}
var specular = model.specular;
if (!specular.equals(cache[8], cache[9], cache[10]))
{
this.set3f('uMaterialSpecular', specular.r, specular.g, specular.b);
cache[8] = specular.r;
cache[9] = specular.g;
cache[10] = specular.b;
}
var shine = model.shine;
if (!shine !== cache[11])
{
this.set1f('uMaterialShine', shine);
cache[11] = specular.b;
}
this.renderer.setTextureZero(model.frame.glTexture);
// All the uniforms are finally bound, so let's buffer our data
var gl = this.gl;
var cullMode = model.cullMode;
if (cullMode !== this.cullMode)
{
this.cullMode = cullMode;
gl.cullFace(cullMode);
}
// STATIC because the buffer data doesn't change, the uniforms do
gl.bufferData(gl.ARRAY_BUFFER, model.vertexData, gl.STATIC_DRAW);
gl.drawArrays(this.topology, 0, model.vertexCount);
}
});
module.exports = MeshPipeline;

12
node_modules/phaser/plugins/spine/README.md generated vendored Normal file
View File

@ -0,0 +1,12 @@
# Updating Spine
1. Checkout the Esoteric Spine Runtimes repo to the `spine-runtimes` folder: https://github.com/EsotericSoftware/spine-runtimes/ and make sure this is in the `plugins/spine` folder, not the `plugins/spine/src` folder.
2. Run `npm i` inside the `spine-runtimes` folder.
3. Add the `offscreencanvas` module: `npm i --save-dev @types/offscreencanvas`.
4. Add the `source-map` module: `npm i --save-dev source-map`.
5. Run `npm run plugin.spine.runtimes` to build the new runtimes to the `plugins/spine/src/runtimes` folder.
You can now build a new version of the Spine Plugin:
6. `npm run plugin.spine.dist`.

20
node_modules/phaser/plugins/spine/copy-to-examples.js generated vendored Normal file
View File

@ -0,0 +1,20 @@
var fs = require('fs-extra');
var source = './plugins/spine/dist/';
var dest = '../phaser3-examples/public/plugins/3.8.95/';
if (fs.existsSync(dest))
{
fs.copySync(source, dest, { overwrite: true });
}
else
{
console.log('Copy-to-Examples failed: Phaser 3 Examples not present at ../phaser3-examples');
}
dest = '../100-phaser3-snippets/public/libs/';
if (fs.existsSync(dest))
{
fs.copySync(source, dest, { overwrite: true });
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

53766
node_modules/phaser/plugins/spine/dist/SpinePlugin.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

54733
node_modules/phaser/plugins/spine/dist/SpinePluginDebug.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

53156
node_modules/phaser/plugins/spine/dist/SpineWebGLPlugin.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

254
node_modules/phaser/plugins/spine/src/SpineFile.js generated vendored Normal file
View File

@ -0,0 +1,254 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2022 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
var Class = require('../../../src/utils/Class');
var GetFastValue = require('../../../src/utils/object/GetFastValue');
var ImageFile = require('../../../src/loader/filetypes/ImageFile.js');
var IsPlainObject = require('../../../src/utils/object/IsPlainObject');
var JSONFile = require('../../../src/loader/filetypes/JSONFile.js');
var MultiFile = require('../../../src/loader/MultiFile.js');
var TextFile = require('../../../src/loader/filetypes/TextFile.js');
/**
* @typedef {object} Phaser.Loader.FileTypes.SpineFileConfig
*
* @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager.
* @property {string|string[]} [jsonURL] - The absolute or relative URL to load the JSON file from. If undefined or `null` it will be set to `<key>.json`, i.e. if `key` was "alien" then the URL will be "alien.json".
* @property {string} [atlasURL] - The absolute or relative URL to load the texture atlas data file from. If undefined or `null` it will be set to `<key>.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt".
* @property {boolean} [preMultipliedAlpha=false] - Do the textures contain pre-multiplied alpha or not?
* @property {XHRSettingsObject} [jsonXhrSettings] - An XHR Settings configuration object for the json file. Used in replacement of the Loaders default XHR Settings.
* @property {XHRSettingsObject} [atlasXhrSettings] - An XHR Settings configuration object for the atlas data file. Used in replacement of the Loaders default XHR Settings.
*/
/**
* @classdesc
* A Spine File suitable for loading by the Loader.
*
* These are created when you use the Phaser.Loader.LoaderPlugin#spine method and are not typically created directly.
*
* For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#spine.
*
* @class SpineFile
* @extends Phaser.Loader.MultiFile
* @memberof Phaser.Loader.FileTypes
* @constructor
*
* @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file.
* @param {(string|Phaser.Loader.FileTypes.SpineFileConfig)} key - The key to use for this file, or a file configuration object.
* @param {string|string[]} [jsonURL] - The absolute or relative URL to load the JSON file from. If undefined or `null` it will be set to `<key>.json`, i.e. if `key` was "alien" then the URL will be "alien.json".
* @param {string} [atlasURL] - The absolute or relative URL to load the texture atlas data file from. If undefined or `null` it will be set to `<key>.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt".
* @param {boolean} [preMultipliedAlpha=false] - Do the textures contain pre-multiplied alpha or not?
* @param {XHRSettingsObject} [jsonXhrSettings] - An XHR Settings configuration object for the json file. Used in replacement of the Loaders default XHR Settings.
* @param {XHRSettingsObject} [atlasXhrSettings] - An XHR Settings configuration object for the atlas data file. Used in replacement of the Loaders default XHR Settings.
*/
var SpineFile = new Class({
Extends: MultiFile,
initialize:
function SpineFile (loader, key, jsonURL, atlasURL, preMultipliedAlpha, jsonXhrSettings, atlasXhrSettings)
{
var i;
var json;
var atlas;
var files = [];
var cache = loader.cacheManager.custom.spine;
// atlas can be an array of atlas files, not just a single one
if (IsPlainObject(key))
{
var config = key;
key = GetFastValue(config, 'key');
json = new JSONFile(loader, {
key: key,
url: GetFastValue(config, 'jsonURL'),
extension: GetFastValue(config, 'jsonExtension', 'json'),
xhrSettings: GetFastValue(config, 'jsonXhrSettings')
});
atlasURL = GetFastValue(config, 'atlasURL');
preMultipliedAlpha = GetFastValue(config, 'preMultipliedAlpha');
if (!Array.isArray(atlasURL))
{
atlasURL = [ atlasURL ];
}
for (i = 0; i < atlasURL.length; i++)
{
atlas = new TextFile(loader, {
key: key + '!' + i,
url: atlasURL[i],
extension: GetFastValue(config, 'atlasExtension', 'atlas'),
xhrSettings: GetFastValue(config, 'atlasXhrSettings')
});
atlas.cache = cache;
files.push(atlas);
}
}
else
{
json = new JSONFile(loader, key, jsonURL, jsonXhrSettings);
if (!Array.isArray(atlasURL))
{
atlasURL = [ atlasURL ];
}
for (i = 0; i < atlasURL.length; i++)
{
atlas = new TextFile(loader, key + '!' + i, atlasURL[i], atlasXhrSettings);
atlas.cache = cache;
files.push(atlas);
}
}
files.unshift(json);
MultiFile.call(this, loader, 'spine', key, files);
this.config.preMultipliedAlpha = preMultipliedAlpha;
},
/**
* Called by each File when it finishes loading.
*
* @method Phaser.Loader.FileTypes.SpineFile#onFileComplete
* @since 3.19.0
*
* @param {Phaser.Loader.File} file - The File that has completed processing.
*/
onFileComplete: function (file)
{
var index = this.files.indexOf(file);
if (index !== -1)
{
this.pending--;
if (file.type === 'text')
{
// Inspect the data for the files to now load
var content = file.data.split('\n');
// Extract the textures
var textures = [];
for (var t = 0; t < content.length; t++)
{
var line = content[t];
if (line.trim() === '' && t < content.length - 1)
{
line = content[t + 1];
textures.push(line);
}
}
var config = this.config;
var loader = this.loader;
var currentBaseURL = loader.baseURL;
var currentPath = loader.path;
var currentPrefix = loader.prefix;
var baseURL = GetFastValue(config, 'baseURL', this.baseURL);
var path = GetFastValue(config, 'path', file.url.match(/^.*\//))[0];
var prefix = GetFastValue(config, 'prefix', this.prefix);
var textureXhrSettings = GetFastValue(config, 'textureXhrSettings');
loader.setBaseURL(baseURL);
loader.setPath(path);
loader.setPrefix(prefix);
for (var i = 0; i < textures.length; i++)
{
var textureURL = textures[i];
var key = this.key + ':' + textureURL;
var image = new ImageFile(loader, key, textureURL, textureXhrSettings);
if (!loader.keyExists(image))
{
this.addToMultiFile(image);
loader.addFile(image);
}
}
// Reset the loader settings
loader.setBaseURL(currentBaseURL);
loader.setPath(currentPath);
loader.setPrefix(currentPrefix);
}
}
},
/**
* Adds this file to its target cache upon successful loading and processing.
*
* @method Phaser.Loader.FileTypes.SpineFile#addToCache
* @since 3.19.0
*/
addToCache: function ()
{
if (this.isReadyToProcess())
{
var fileJSON = this.files[0];
fileJSON.addToCache();
var atlasCache;
var atlasKey = '';
var combinedAtlasData = '';
var preMultipliedAlpha = (this.config.preMultipliedAlpha) ? true : false;
var textureManager = this.loader.textureManager;
for (var i = 1; i < this.files.length; i++)
{
var file = this.files[i];
if (file.type === 'text')
{
atlasKey = file.key.replace(/![\d]$/, '');
atlasCache = file.cache;
combinedAtlasData = combinedAtlasData.concat(file.data);
}
else
{
var src = file.key.trim();
var pos = src.indexOf('!');
var key = src.substr(pos + 1);
if (!textureManager.exists(key))
{
textureManager.addImage(key, file.data);
}
}
file.pendingDestroy();
}
atlasCache.add(atlasKey, { preMultipliedAlpha: preMultipliedAlpha, data: combinedAtlasData, prefix: this.prefix });
this.complete = true;
}
}
});
module.exports = SpineFile;

1263
node_modules/phaser/plugins/spine/src/SpinePlugin.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,96 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2022 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
var Class = require('../../../../src/utils/Class');
var Container = require('../../../../src/gameobjects/container/Container');
var SpineContainerRender = require('./SpineContainerRender');
/**
* @classdesc
* A Spine Container is a special kind of Container created specifically for Spine Game Objects.
*
* You have all of the same features of a standard Container, but the rendering functions are optimized specifically
* for Spine Game Objects. You must only add ever Spine Game Objects, or other Spine Containers, to this type of Container.
* Although Phaser will not prevent you from adding other types, they will not render and are likely to throw runtime errors.
*
* To create one in a Scene, use the factory methods:
*
* ```javascript
* this.add.spineContainer();
* ```
*
* or
*
* ```javascript
* this.make.spineContainer();
* ```
*
* Note that you should not nest Spine Containers inside regular Containers if you wish to use masks on the
* container children. You can, however, mask children of Spine Containers if they are embedded within other
* Spine Containers. In short, if you need masking, don't mix and match the types.
*
* See the Container documentation for further details about what Containers can do.
*
* @class SpineContainer
* @extends Phaser.GameObjects.Container
* @constructor
* @since 3.50.0
*
* @param {Phaser.Scene} scene - A reference to the Scene that this Game Object belongs to.
* @param {SpinePlugin} pluginManager - A reference to the Phaser Spine Plugin.
* @param {number} x - The horizontal position of this Game Object in the world.
* @param {number} y - The vertical position of this Game Object in the world.
* @param {SpineGameObject[]} [children] - An optional array of Spine Game Objects to add to this Container.
*/
var SpineContainer = new Class({
Extends: Container,
Mixins: [
SpineContainerRender
],
initialize:
function SpineContainer (scene, plugin, x, y, children)
{
Container.call(this, scene, x, y, children);
// Same as SpineGameObject, to prevent the renderer from mis-typing it when batching
this.type = 'Spine';
/**
* A reference to the Spine Plugin.
*
* @name SpineContainer#plugin
* @type {SpinePlugin}
* @since 3.50.0
*/
this.plugin = plugin;
},
/**
* Internal destroy handler, called as part of the destroy process.
*
* @method SpineContainer#preDestroy
* @protected
* @since 3.50.0
*/
preDestroy: function ()
{
this.removeAll(!!this.exclusive);
this.localTransform.destroy();
this.tempTransformMatrix.destroy();
this.list = [];
this._displayList = null;
this.plugin = null;
}
});
module.exports = SpineContainer;

View File

@ -0,0 +1,101 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2022 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* Renders this Game Object with the Canvas Renderer to the given Camera.
* The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera.
* This method should not be called directly. It is a utility function of the Render module.
*
* @method Phaser.GameObjects.Container#renderCanvas
* @since 3.4.0
* @private
*
* @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer.
* @param {Phaser.GameObjects.Container} container - The Game Object being rendered in this call.
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object.
* @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested
*/
var SpineContainerCanvasRenderer = function (renderer, container, camera, parentMatrix)
{
var children = container.list;
if (children.length === 0)
{
return;
}
camera.addToRenderList(container);
var transformMatrix = container.localTransform;
if (parentMatrix)
{
transformMatrix.loadIdentity();
transformMatrix.multiply(parentMatrix);
transformMatrix.translate(container.x, container.y);
transformMatrix.rotate(container.rotation);
transformMatrix.scale(container.scaleX, container.scaleY);
}
else
{
transformMatrix.applyITRS(container.x, container.y, container.rotation, container.scaleX, container.scaleY);
}
var containerHasBlendMode = (container.blendMode !== -1);
if (!containerHasBlendMode)
{
// If Container is SKIP_TEST then set blend mode to be Normal
renderer.setBlendMode(0);
}
var alpha = container._alpha;
var scrollFactorX = container.scrollFactorX;
var scrollFactorY = container.scrollFactorY;
if (container.mask)
{
container.mask.preRenderCanvas(renderer, null, camera);
}
for (var i = 0; i < children.length; i++)
{
var child = children[i];
if (!child.willRender(camera))
{
continue;
}
var childAlpha = child.alpha;
var childScrollFactorX = child.scrollFactorX;
var childScrollFactorY = child.scrollFactorY;
if (!containerHasBlendMode && child.blendMode !== renderer.currentBlendMode)
{
// If Container doesn't have its own blend mode, then a child can have one
renderer.setBlendMode(child.blendMode);
}
// Set parent values
child.setScrollFactor(childScrollFactorX * scrollFactorX, childScrollFactorY * scrollFactorY);
child.setAlpha(childAlpha * alpha);
// Render
child.renderCanvas(renderer, child, camera, transformMatrix);
// Restore original values
child.setAlpha(childAlpha);
child.setScrollFactor(childScrollFactorX, childScrollFactorY);
}
if (container.mask)
{
container.mask.postRenderCanvas(renderer);
}
};
module.exports = SpineContainerCanvasRenderer;

View File

@ -0,0 +1,25 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2022 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var renderWebGL = require('../../../../src/utils/NOOP');
var renderCanvas = require('../../../../src/utils/NOOP');
if (typeof WEBGL_RENDERER)
{
renderWebGL = require('./SpineContainerWebGLRenderer');
}
if (typeof CANVAS_RENDERER)
{
renderCanvas = require('./SpineContainerCanvasRenderer');
}
module.exports = {
renderWebGL: renderWebGL,
renderCanvas: renderCanvas
};

View File

@ -0,0 +1,120 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2022 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* Renders this Game Object with the WebGL Renderer to the given Camera.
* The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera.
* This method should not be called directly. It is a utility function of the Render module.
*
* @method SpineContainerWebGLRenderer#renderWebGL
* @since 3.50.0
* @private
*
* @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer.
* @param {SpineContainer} container - The Game Object being rendered in this call.
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object.
* @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested
*/
var SpineContainerWebGLRenderer = function (renderer, container, camera, parentMatrix)
{
var plugin = container.plugin;
var sceneRenderer = plugin.sceneRenderer;
var children = container.list;
if (children.length === 0)
{
if (sceneRenderer.batcher.isDrawing && renderer.finalType)
{
sceneRenderer.end();
renderer.pipelines.rebind();
}
return;
}
camera.addToRenderList(container);
var transformMatrix = container.localTransform;
if (parentMatrix)
{
transformMatrix.loadIdentity();
transformMatrix.multiply(parentMatrix);
transformMatrix.translate(container.x, container.y);
transformMatrix.rotate(container.rotation);
transformMatrix.scale(container.scaleX, container.scaleY);
}
else
{
transformMatrix.applyITRS(container.x, container.y, container.rotation, container.scaleX, container.scaleY);
}
if (renderer.newType)
{
// flush + clear if this is a new type
renderer.pipelines.clear();
sceneRenderer.begin();
}
var rendererNextType = renderer.nextTypeMatch;
// Force these to avoid batch flushing during SpineGameObject.renderWebGL
renderer.nextTypeMatch = true;
renderer.newType = false;
for (var i = 0; i < children.length; i++)
{
var child = children[i];
if (child.willRender(camera, container))
{
var mask = child.mask;
if (mask)
{
sceneRenderer.end();
renderer.pipelines.rebind();
mask.preRenderWebGL(renderer, child, camera);
renderer.pipelines.clear();
sceneRenderer.begin();
}
child.renderWebGL(renderer, child, camera, transformMatrix, container);
if (mask)
{
sceneRenderer.end();
renderer.pipelines.rebind();
mask.postRenderWebGL(renderer, camera);
renderer.pipelines.clear();
sceneRenderer.begin();
}
}
}
renderer.nextTypeMatch = rendererNextType;
if (!rendererNextType || container.mask)
{
// The next object in the display list is not a Spine Game Object or Spine Container, so we end the batch
sceneRenderer.end();
// And rebind the previous pipeline
renderer.pipelines.rebind();
}
};
module.exports = SpineContainerWebGLRenderer;

View File

@ -0,0 +1,13 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2022 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* The Complete Event.
*
* @event SpinePluginEvents#COMPLETE
* @since 3.19.0
*/
module.exports = 'complete';

View File

@ -0,0 +1,13 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2022 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* The Dispose Event.
*
* @event SpinePluginEvents#DISPOSE
* @since 3.19.0
*/
module.exports = 'dispose';

View File

@ -0,0 +1,13 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2022 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* The End Event.
*
* @event SpinePluginEvents#END
* @since 3.19.0
*/
module.exports = 'end';

View File

@ -0,0 +1,13 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2022 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* The Custom Event Event.
*
* @event SpinePluginEvents#EVENT
* @since 3.19.0
*/
module.exports = 'event';

View File

@ -0,0 +1,13 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2022 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* The Interrupted Event.
*
* @event SpinePluginEvents#INTERRUPTED
* @since 3.19.0
*/
module.exports = 'interrupted';

View File

@ -0,0 +1,13 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2022 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* The Start Event.
*
* @event SpinePluginEvents#START
* @since 3.19.0
*/
module.exports = 'start';

20
node_modules/phaser/plugins/spine/src/events/index.js generated vendored Normal file
View File

@ -0,0 +1,20 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2022 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* @namespace SpinePluginEvents
*/
module.exports = {
COMPLETE: require('./COMPLETE_EVENT'),
DISPOSE: require('./DISPOSE_EVENT'),
END: require('./END_EVENT'),
EVENT: require('./EVENT_EVENT'),
INTERRUPTED: require('./INTERRUPTED_EVENT'),
START: require('./START_EVENT')
};

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,116 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2022 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
var CounterClockwise = require('../../../../src/math/angle/CounterClockwise');
var RadToDeg = require('../../../../src/math/RadToDeg');
var Wrap = require('../../../../src/math/Wrap');
/**
* Renders this Game Object with the Canvas Renderer to the given Camera.
* The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera.
* This method should not be called directly. It is a utility function of the Render module.
*
* @method SpineGameObject#renderCanvas
* @since 3.19.0
* @private
*
* @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer.
* @param {SpineGameObject} src - The Game Object being rendered in this call.
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object.
* @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested
*/
var SpineGameObjectCanvasRenderer = function (renderer, src, camera, parentMatrix)
{
var context = renderer.currentContext;
var plugin = src.plugin;
var skeleton = src.skeleton;
var skeletonRenderer = plugin.skeletonRenderer;
var camMatrix = renderer._tempMatrix1;
var spriteMatrix = renderer._tempMatrix2;
var calcMatrix = renderer._tempMatrix3;
camera.addToRenderList(src);
spriteMatrix.applyITRS(src.x, src.y, src.rotation, Math.abs(src.scaleX), Math.abs(src.scaleY));
camMatrix.copyFrom(camera.matrix);
if (parentMatrix)
{
// Multiply the camera by the parent matrix
camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY);
// Undo the camera scroll
spriteMatrix.e = src.x;
spriteMatrix.f = src.y;
// Multiply by the Sprite matrix, store result in calcMatrix
camMatrix.multiply(spriteMatrix, calcMatrix);
}
else
{
spriteMatrix.e -= camera.scrollX * src.scrollFactorX;
spriteMatrix.f -= camera.scrollY * src.scrollFactorY;
// Multiply by the Sprite matrix, store result in calcMatrix
camMatrix.multiply(spriteMatrix, calcMatrix);
}
skeleton.x = calcMatrix.tx;
skeleton.y = calcMatrix.ty;
skeleton.scaleX = calcMatrix.scaleX;
// Inverse or we get upside-down skeletons
skeleton.scaleY = calcMatrix.scaleY * -1;
if (src.scaleX < 0)
{
skeleton.scaleX *= -1;
src.root.rotation = RadToDeg(calcMatrix.rotationNormalized);
}
else
{
// +90 degrees to account for the difference in Spine vs. Phaser rotation
src.root.rotation = Wrap(RadToDeg(CounterClockwise(calcMatrix.rotationNormalized)) + 90, 0, 360);
}
if (src.scaleY < 0)
{
skeleton.scaleY *= -1;
if (src.scaleX < 0)
{
src.root.rotation -= (RadToDeg(calcMatrix.rotationNormalized) * 2);
}
else
{
src.root.rotation += (RadToDeg(calcMatrix.rotationNormalized) * 2);
}
}
if (camera.renderToTexture)
{
skeleton.y = calcMatrix.ty;
skeleton.scaleY *= -1;
}
skeleton.updateWorldTransform();
skeletonRenderer.ctx = context;
skeletonRenderer.debugRendering = (plugin.drawDebug || src.drawDebug);
context.save();
skeletonRenderer.draw(skeleton);
context.restore();
};
module.exports = SpineGameObjectCanvasRenderer;

View File

@ -0,0 +1,28 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2022 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
var renderWebGL = require('../../../../src/utils/NOOP');
var renderCanvas = require('../../../../src/utils/NOOP');
var renderDirect = require('../../../../src/utils/NOOP');
if (typeof WEBGL_RENDERER)
{
renderWebGL = require('./SpineGameObjectWebGLRenderer');
renderDirect = require('./SpineGameObjectWebGLDirect');
}
if (typeof CANVAS_RENDERER)
{
renderCanvas = require('./SpineGameObjectCanvasRenderer');
}
module.exports = {
renderWebGL: renderWebGL,
renderCanvas: renderCanvas,
renderDirect: renderDirect
};

Some files were not shown because too many files have changed in this diff Show More