mirror of
https://github.com/wassname/phaser-plugin-isometric.git
synced 2026-08-25 11:22:47 +08:00
486 lines
14 KiB
HTML
486 lines
14 KiB
HTML
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Phaser Isometric Source: Point3.js</title>
|
|
|
|
<!--[if lt IE 9]>
|
|
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
|
<![endif]-->
|
|
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
|
|
|
|
<link type="text/css" rel="stylesheet" href="styles/site.cerulean.css">
|
|
|
|
</head>
|
|
|
|
<body>
|
|
<div class="container-fluid">
|
|
<div class="navbar navbar-fixed-top navbar-inverse">
|
|
<div class="navbar-inner">
|
|
<a class="brand" href="index.html">Phaser Isometric</a>
|
|
<ul class="nav">
|
|
|
|
<li class="dropdown">
|
|
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b
|
|
class="caret"></b></a>
|
|
|
|
<ul class="dropdown-menu ">
|
|
|
|
<li>
|
|
<a href="Phaser.Plugin.Isometric.html">Phaser.Plugin.Isometric</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="Phaser.Plugin.Isometric.Arcade.html">Phaser.Plugin.Isometric.Arcade</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="Phaser.Plugin.Isometric.Body.html">Phaser.Plugin.Isometric.Body</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="Phaser.Plugin.Isometric.Cube.html">Phaser.Plugin.Isometric.Cube</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="Phaser.Plugin.Isometric.IsoSprite.html">Phaser.Plugin.Isometric.IsoSprite</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="Phaser.Plugin.Isometric.Octree.html">Phaser.Plugin.Isometric.Octree</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="Phaser.Plugin.Isometric.Point3.html">Phaser.Plugin.Isometric.Point3</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="Phaser.Plugin.Isometric.Projector.html">Phaser.Plugin.Isometric.Projector</a>
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
</li>
|
|
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row-fluid">
|
|
|
|
|
|
<div class="span12">
|
|
|
|
<div id="main">
|
|
|
|
|
|
|
|
<h1 class="page-title">Source: Point3.js</h1>
|
|
|
|
<section>
|
|
<article>
|
|
<pre
|
|
class="sunlight-highlight-javascript linenums">/**
|
|
* @class Phaser.Plugin.Isometric.Point3
|
|
* @classdesc
|
|
* The Point3 object represents a location in a three-dimensional coordinate system,
|
|
* where x and y represent the horizontal axes and z represents the vertical axis.
|
|
* The following code creates a point at (0,0,0):
|
|
* `var myPoint = new Phaser.Plugin.Isometric.Point3();`
|
|
*/
|
|
|
|
/**
|
|
* Creates a new Point3 object. If you pass no parameters a Point3 is created set to (0, 0, 0).
|
|
*
|
|
* @constructor
|
|
* @param {number} [x=0] - The horizontal X position of this Point.
|
|
* @param {number} [y=0] - The horizontal Y position of this Point.
|
|
* @param {number} [z=0] - The vertical position of this Point.
|
|
*/
|
|
Phaser.Plugin.Isometric.Point3 = function (x, y, z) {
|
|
x = x || 0;
|
|
y = y || 0;
|
|
z = z || 0;
|
|
|
|
/**
|
|
* @property {number} x - The x value of the point.
|
|
*/
|
|
this.x = x;
|
|
|
|
/**
|
|
* @property {number} y - The y value of the point.
|
|
*/
|
|
this.y = y;
|
|
|
|
/**
|
|
* @property {number} z - The z value of the point.
|
|
*/
|
|
this.z = z;
|
|
};
|
|
|
|
Phaser.Plugin.Isometric.Point3.prototype = {
|
|
/**
|
|
* Copies the x, y and z properties from any given object to this Point3.
|
|
*
|
|
* @method Phaser.Plugin.Isometric.Point3#copyFrom
|
|
* @param {any} source - The object to copy from.
|
|
* @return {Phaser.Plugin.Isometric.Point3} This Point3 object.
|
|
*/
|
|
copyFrom: function (source) {
|
|
|
|
return this.setTo(source.x, source.y, source.z);
|
|
|
|
},
|
|
|
|
/**
|
|
* Copies the x, y and z properties from this Point3 to any given object.
|
|
*
|
|
* @method Phaser.Plugin.Isometric.Point3#copyTo
|
|
* @param {any} dest - The object to copy to.
|
|
* @return {Object} The dest object.
|
|
*/
|
|
copyTo: function (dest) {
|
|
|
|
dest.x = this.x;
|
|
dest.y = this.y;
|
|
dest.z = this.z;
|
|
|
|
return dest;
|
|
|
|
},
|
|
|
|
/**
|
|
* Determines whether the given object's x/y/z values are equal to this Point3 object.
|
|
*
|
|
* @method Phaser.Plugin.Isometric.Point3#equals
|
|
* @param {Phaser.Plugin.Isometric.Point3|any} a - The object to compare with this Point3.
|
|
* @return {boolean} A value of true if the x and y points are equal, otherwise false.
|
|
*/
|
|
equals: function (a) {
|
|
|
|
return (a.x === this.x && a.y === this.y && a.z === this.z);
|
|
|
|
},
|
|
|
|
/**
|
|
* Sets the x, y and z values of this Point3 object to the given values.
|
|
* If you omit the y and z value then the x value will be applied to all three, for example:
|
|
* `Point3.set(2)` is the same as `Point3.set(2, 2, 2)`
|
|
* If however you set both x and y, but no z, the z value will be set to 0.
|
|
*
|
|
* @method Phaser.Plugin.Isometric.Point3#set
|
|
* @param {number} x - The x value of this point.
|
|
* @param {number} [y] - The y value of this point. If not given the x value will be used in its place.
|
|
* @param {number} [z] - The z value of this point. If not given and the y value is also not given, the x value will be used in its place.
|
|
* @return {Phaser.Plugin.Isometric.Point3} This Point3 object. Useful for chaining method calls.
|
|
*/
|
|
set: function (x, y, z) {
|
|
this.x = x || 0;
|
|
this.y = y || ((y !== 0) ? this.x : 0);
|
|
this.z = z || ((typeof y === "undefined") ? this.x : 0);
|
|
|
|
return this;
|
|
},
|
|
|
|
/**
|
|
* Sets the x, y and z values of this Point3 object to the given values.
|
|
* If you omit the y and z value then the x value will be applied to all three, for example:
|
|
* `Point3.setTo(2)` is the same as `Point3.setTo(2, 2, 2)`
|
|
* If however you set both x and y, but no z, the z value will be set to 0.
|
|
*
|
|
* @method Phaser.Plugin.Isometric.Point3#setTo
|
|
* @param {number} x - The x value of this point.
|
|
* @param {number} [y] - The y value of this point. If not given the x value will be used in its place.
|
|
* @param {number} [z] - The z value of this point. If not given and the y value is also not given, the x value will be used in its place.
|
|
* @return {Phaser.Plugin.Isometric.Point3} This Point3 object. Useful for chaining method calls.
|
|
*/
|
|
setTo: function (x, y, z) {
|
|
return this.set(x, y, z);
|
|
},
|
|
|
|
/**
|
|
* Adds the given x, y and z values to this Point3.
|
|
*
|
|
* @method Phaser.Plugin.Isometric.Point3#add
|
|
* @param {number} x - The value to add to Point3.x.
|
|
* @param {number} y - The value to add to Point3.y.
|
|
* @param {number} z - The value to add to Point3.z.
|
|
* @return {Phaser.Plugin.Isometric.Point3} This Point3 object. Useful for chaining method calls.
|
|
*/
|
|
add: function (x, y) {
|
|
|
|
this.x += x || 0;
|
|
this.y += y || 0;
|
|
return this;
|
|
|
|
},
|
|
|
|
/**
|
|
* Subtracts the given x, y and z values from this Point3.
|
|
*
|
|
* @method Phaser.Plugin.Isometric.Point3#subtract
|
|
* @param {number} x - The value to subtract from Point3.x.
|
|
* @param {number} y - The value to subtract from Point3.y.
|
|
* @param {number} z - The value to subtract from Point3.z.
|
|
* @return {Phaser.Plugin.Isometric.Point3} This Point3 object. Useful for chaining method calls.
|
|
*/
|
|
subtract: function (x, y, z) {
|
|
|
|
this.x -= x || 0;
|
|
this.y -= y || 0;
|
|
this.z -= z || 0;
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
/**
|
|
* Multiplies Point3.x, Point3.y and Point3.z by the given x and y values. Sometimes known as `Scale`.
|
|
*
|
|
* @method Phaser.Plugin.Isometric.Point3#multiply
|
|
* @param {number} x - The value to multiply Point3.x by.
|
|
* @param {number} y - The value to multiply Point3.y by.
|
|
* @param {number} z - The value to multiply Point3.z by.
|
|
* @return {Phaser.Plugin.Isometric.Point3} This Point3 object. Useful for chaining method calls.
|
|
*/
|
|
multiply: function (x, y, z) {
|
|
|
|
this.x *= x || 1;
|
|
this.y *= y || 1;
|
|
this.z *= z || 1;
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
/**
|
|
* Divides Point3.x, Point3.y and Point3.z by the given x, y and z values.
|
|
*
|
|
* @method Phaser.Plugin.Isometric.Point3#divide
|
|
* @param {number} x - The value to divide Point3.x by.
|
|
* @param {number} y - The value to divide Point3.y by.
|
|
* @param {number} z - The value to divide Point3.z by.
|
|
* @return {Phaser.Plugin.Isometric.Point3} This Point3 object. Useful for chaining method calls.
|
|
*/
|
|
divide: function (x, y, z) {
|
|
|
|
this.x /= x || 1;
|
|
this.y /= y || 1;
|
|
this.z /= z || 1;
|
|
|
|
return this;
|
|
|
|
}
|
|
};
|
|
|
|
Phaser.Plugin.Isometric.Point3.prototype.constructor = Phaser.Plugin.Isometric.Point3;
|
|
|
|
/**
|
|
* Adds the coordinates of two points together to create a new point.
|
|
*
|
|
* @method Phaser.Plugin.Isometric.Point3.add
|
|
* @param {Phaser.Plugin.Isometric.Point3} a - The first Point3 object.
|
|
* @param {Phaser.Plugin.Isometric.Point3} b - The second Point3 object.
|
|
* @param {Phaser.Plugin.Isometric.Point3} [out] - Optional Point3 to store the value in, if not supplied a new Point3 object will be created.
|
|
* @return {Phaser.Plugin.Isometric.Point3} The new Point3 object.
|
|
*/
|
|
Phaser.Plugin.Isometric.Point3.add = function (a, b, out) {
|
|
|
|
if (typeof out === "undefined") {
|
|
out = new Phaser.Plugin.Isometric.Point3();
|
|
}
|
|
|
|
out.x = a.x + b.x;
|
|
out.y = a.y + b.y;
|
|
out.z = a.z + b.z;
|
|
|
|
return out;
|
|
|
|
};
|
|
|
|
/**
|
|
* Subtracts the coordinates of two points to create a new point.
|
|
*
|
|
* @method Phaser.Plugin.Isometric.Point3.subtract
|
|
* @param {Phaser.Plugin.Isometric.Point3} a - The first Point3 object.
|
|
* @param {Phaser.Plugin.Isometric.Point3} b - The second Point3 object.
|
|
* @param {Phaser.Plugin.Isometric.Point3} [out] - Optional Point3 to store the value in, if not supplied a new Point3 object will be created.
|
|
* @return {Phaser.Plugin.Isometric.Point3} The new Point3 object.
|
|
*/
|
|
Phaser.Plugin.Isometric.Point3.subtract = function (a, b, out) {
|
|
|
|
if (typeof out === "undefined") {
|
|
out = new Phaser.Plugin.Isometric.Point3();
|
|
}
|
|
|
|
out.x = a.x - b.x;
|
|
out.y = a.y - b.y;
|
|
out.z = a.z - b.z;
|
|
|
|
return out;
|
|
|
|
};
|
|
|
|
/**
|
|
* Multiplies the coordinates of two points to create a new point.
|
|
*
|
|
* @method Phaser.Plugin.Isometric.Point3.multiply
|
|
* @param {Phaser.Plugin.Isometric.Point3} a - The first Point3 object.
|
|
* @param {Phaser.Plugin.Isometric.Point3} b - The second Point3 object.
|
|
* @param {Phaser.Plugin.Isometric.Point3} [out] - Optional Point3 to store the value in, if not supplied a new Point3 object will be created.
|
|
* @return {Phaser.Plugin.Isometric.Point3} The new Point3 object.
|
|
*/
|
|
Phaser.Plugin.Isometric.Point3.multiply = function (a, b, out) {
|
|
|
|
if (typeof out === "undefined") {
|
|
out = new Phaser.Plugin.Isometric.Point3();
|
|
}
|
|
|
|
out.x = a.x * b.x;
|
|
out.y = a.y * b.y;
|
|
out.z = a.z * b.z;
|
|
|
|
return out;
|
|
|
|
};
|
|
|
|
/**
|
|
* Divides the coordinates of two points to create a new point.
|
|
*
|
|
* @method Phaser.Plugin.Isometric.Point3.divide
|
|
* @param {Phaser.Plugin.Isometric.Point3} a - The first Point3 object.
|
|
* @param {Phaser.Plugin.Isometric.Point3} b - The second Point3 object.
|
|
* @param {Phaser.Plugin.Isometric.Point3} [out] - Optional Point3 to store the value in, if not supplied a new Point3 object3 will be created.
|
|
* @return {Phaser.Plugin.Isometric.Point3} The new Point3 object.
|
|
*/
|
|
Phaser.Plugin.Isometric.Point3.divide = function (a, b, out) {
|
|
|
|
if (typeof out === "undefined") {
|
|
out = new Phaser.Plugin.Isometric.Point3();
|
|
}
|
|
|
|
out.x = a.x / b.x;
|
|
out.y = a.y / b.y;
|
|
out.z = a.z / b.z;
|
|
|
|
return out;
|
|
|
|
};
|
|
|
|
/**
|
|
* Determines whether the two given Point3 objects are equal. They are considered equal if they have the same x, y and z values.
|
|
*
|
|
* @method Phaser.Plugin.Isometric.Point3.equals
|
|
* @param {Phaser.Plugin.Isometric.Point3} a - The first Point3 object.
|
|
* @param {Phaser.Plugin.Isometric.Point3} b - The second Point3 object.
|
|
* @return {boolean} A value of true if the Points3 are equal, otherwise false.
|
|
*/
|
|
Phaser.Plugin.Isometric.Point3.equals = function (a, b) {
|
|
|
|
return (a.x === b.x && a.y === b.y && a.z === b.z);
|
|
|
|
};
|
|
</pre>
|
|
</article>
|
|
</section>
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<div class="clearfix"></div>
|
|
<footer>
|
|
|
|
|
|
<span class="copyright">
|
|
Copyright © 2014 Lewis Lane - Rotates.org
|
|
</span>
|
|
<br />
|
|
|
|
<span class="jsdoc-message">
|
|
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a>
|
|
on Wed Aug 6th 2014 using the <a
|
|
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
|
</span>
|
|
</footer>
|
|
</div>
|
|
|
|
|
|
<br clear="both">
|
|
</div>
|
|
|
|
</div>
|
|
<!--<script src="scripts/sunlight.js"></script>-->
|
|
<script src="scripts/docstrap.lib.js"></script>
|
|
<script src="scripts/bootstrap-dropdown.js"></script>
|
|
<script src="scripts/toc.js"></script>
|
|
|
|
<script>
|
|
$( function () {
|
|
$( "[id*='$']" ).each( function () {
|
|
var $this = $( this );
|
|
|
|
$this.attr( "id", $this.attr( "id" ).replace( "$", "__" ) );
|
|
} );
|
|
|
|
$( "#toc" ).toc( {
|
|
anchorName : function ( i, heading, prefix ) {
|
|
return $( heading ).attr( "id" ) || ( prefix + i );
|
|
},
|
|
selectors : "h1,h2,h3,h4",
|
|
showAndHide : false,
|
|
scrollTo : "100px"
|
|
} );
|
|
|
|
$( "#toc>ul" ).addClass( "nav nav-pills nav-stacked" );
|
|
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
|
|
$( '.dropdown-toggle' ).dropdown();
|
|
// $( ".tutorial-section pre, .readme-section pre" ).addClass( "sunlight-highlight-javascript" ).addClass( "linenums" );
|
|
|
|
$( ".tutorial-section pre, .readme-section pre" ).each( function () {
|
|
var $this = $( this );
|
|
|
|
var example = $this.find( "code" );
|
|
exampleText = example.html();
|
|
var lang = /{@lang (.*?)}/.exec( exampleText );
|
|
if ( lang && lang[1] ) {
|
|
exampleText = exampleText.replace( lang[0], "" );
|
|
example.html( exampleText );
|
|
lang = lang[1];
|
|
} else {
|
|
lang = "javascript";
|
|
}
|
|
|
|
if ( lang ) {
|
|
|
|
$this
|
|
.addClass( "sunlight-highlight-" + lang )
|
|
.addClass( "linenums" )
|
|
.html( example.html() );
|
|
|
|
}
|
|
} );
|
|
|
|
Sunlight.highlightAll( {
|
|
lineNumbers : true,
|
|
showMenu : true,
|
|
enableDoclinks : true
|
|
} );
|
|
} );
|
|
</script>
|
|
|
|
|
|
|
|
<!--Navigation and Symbol Display-->
|
|
|
|
|
|
|
|
<!--Google Analytics-->
|
|
|
|
|
|
</body>
|
|
</html>
|