diff --git a/build/p2.js b/build/p2.js index 610db237..7d5bb9eb 100644 --- a/build/p2.js +++ b/build/p2.js @@ -1,18 +1,18 @@ /** * The MIT License (MIT) - * - * Copyright (c) 2013 p2.js authors - * + * + * Copyright (c) 2015 p2.js authors + * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -21,1399 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -!function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.p2=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o - * License: MIT - * - * `npm install buffer` - */ - -var base64 = _dereq_('base64-js') -var ieee754 = _dereq_('ieee754') - -exports.Buffer = Buffer -exports.SlowBuffer = Buffer -exports.INSPECT_MAX_BYTES = 50 -Buffer.poolSize = 8192 - -/** - * If `Buffer._useTypedArrays`: - * === true Use Uint8Array implementation (fastest) - * === false Use Object implementation (compatible down to IE6) - */ -Buffer._useTypedArrays = (function () { - // Detect if browser supports Typed Arrays. Supported browsers are IE 10+, - // Firefox 4+, Chrome 7+, Safari 5.1+, Opera 11.6+, iOS 4.2+. - if (typeof Uint8Array !== 'function' || typeof ArrayBuffer !== 'function') - return false - - // Does the browser support adding properties to `Uint8Array` instances? If - // not, then that's the same as no `Uint8Array` support. We need to be able to - // add all the node Buffer API methods. - // Bug in Firefox 4-29, now fixed: https://bugzilla.mozilla.org/show_bug.cgi?id=695438 - try { - var arr = new Uint8Array(0) - arr.foo = function () { return 42 } - return 42 === arr.foo() && - typeof arr.subarray === 'function' // Chrome 9-10 lack `subarray` - } catch (e) { - return false - } -})() - -/** - * Class: Buffer - * ============= - * - * The Buffer constructor returns instances of `Uint8Array` that are augmented - * with function properties for all the node `Buffer` API functions. We use - * `Uint8Array` so that square bracket notation works as expected -- it returns - * a single octet. - * - * By augmenting the instances, we can avoid modifying the `Uint8Array` - * prototype. - */ -function Buffer (subject, encoding, noZero) { - if (!(this instanceof Buffer)) - return new Buffer(subject, encoding, noZero) - - var type = typeof subject - - // Workaround: node's base64 implementation allows for non-padded strings - // while base64-js does not. - if (encoding === 'base64' && type === 'string') { - subject = stringtrim(subject) - while (subject.length % 4 !== 0) { - subject = subject + '=' - } - } - - // Find the length - var length - if (type === 'number') - length = coerce(subject) - else if (type === 'string') - length = Buffer.byteLength(subject, encoding) - else if (type === 'object') - length = coerce(subject.length) // Assume object is an array - else - throw new Error('First argument needs to be a number, array or string.') - - var buf - if (Buffer._useTypedArrays) { - // Preferred: Return an augmented `Uint8Array` instance for best performance - buf = augment(new Uint8Array(length)) - } else { - // Fallback: Return THIS instance of Buffer (created by `new`) - buf = this - buf.length = length - buf._isBuffer = true - } - - var i - if (Buffer._useTypedArrays && typeof Uint8Array === 'function' && - subject instanceof Uint8Array) { - // Speed optimization -- use set if we're copying from a Uint8Array - buf._set(subject) - } else if (isArrayish(subject)) { - // Treat array-ish objects as a byte array - for (i = 0; i < length; i++) { - if (Buffer.isBuffer(subject)) - buf[i] = subject.readUInt8(i) - else - buf[i] = subject[i] - } - } else if (type === 'string') { - buf.write(subject, 0, encoding) - } else if (type === 'number' && !Buffer._useTypedArrays && !noZero) { - for (i = 0; i < length; i++) { - buf[i] = 0 - } - } - - return buf -} - -// STATIC METHODS -// ============== - -Buffer.isEncoding = function (encoding) { - switch (String(encoding).toLowerCase()) { - case 'hex': - case 'utf8': - case 'utf-8': - case 'ascii': - case 'binary': - case 'base64': - case 'raw': - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return true - default: - return false - } -} - -Buffer.isBuffer = function (b) { - return !!(b !== null && b !== undefined && b._isBuffer) -} - -Buffer.byteLength = function (str, encoding) { - var ret - str = str + '' - switch (encoding || 'utf8') { - case 'hex': - ret = str.length / 2 - break - case 'utf8': - case 'utf-8': - ret = utf8ToBytes(str).length - break - case 'ascii': - case 'binary': - case 'raw': - ret = str.length - break - case 'base64': - ret = base64ToBytes(str).length - break - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - ret = str.length * 2 - break - default: - throw new Error('Unknown encoding') - } - return ret -} - -Buffer.concat = function (list, totalLength) { - assert(isArray(list), 'Usage: Buffer.concat(list, [totalLength])\n' + - 'list should be an Array.') - - if (list.length === 0) { - return new Buffer(0) - } else if (list.length === 1) { - return list[0] - } - - var i - if (typeof totalLength !== 'number') { - totalLength = 0 - for (i = 0; i < list.length; i++) { - totalLength += list[i].length - } - } - - var buf = new Buffer(totalLength) - var pos = 0 - for (i = 0; i < list.length; i++) { - var item = list[i] - item.copy(buf, pos) - pos += item.length - } - return buf -} - -// BUFFER INSTANCE METHODS -// ======================= - -function _hexWrite (buf, string, offset, length) { - offset = Number(offset) || 0 - var remaining = buf.length - offset - if (!length) { - length = remaining - } else { - length = Number(length) - if (length > remaining) { - length = remaining - } - } - - // must be an even number of digits - var strLen = string.length - assert(strLen % 2 === 0, 'Invalid hex string') - - if (length > strLen / 2) { - length = strLen / 2 - } - for (var i = 0; i < length; i++) { - var byte = parseInt(string.substr(i * 2, 2), 16) - assert(!isNaN(byte), 'Invalid hex string') - buf[offset + i] = byte - } - Buffer._charsWritten = i * 2 - return i -} - -function _utf8Write (buf, string, offset, length) { - var charsWritten = Buffer._charsWritten = - blitBuffer(utf8ToBytes(string), buf, offset, length) - return charsWritten -} - -function _asciiWrite (buf, string, offset, length) { - var charsWritten = Buffer._charsWritten = - blitBuffer(asciiToBytes(string), buf, offset, length) - return charsWritten -} - -function _binaryWrite (buf, string, offset, length) { - return _asciiWrite(buf, string, offset, length) -} - -function _base64Write (buf, string, offset, length) { - var charsWritten = Buffer._charsWritten = - blitBuffer(base64ToBytes(string), buf, offset, length) - return charsWritten -} - -function _utf16leWrite (buf, string, offset, length) { - var charsWritten = Buffer._charsWritten = - blitBuffer(utf16leToBytes(string), buf, offset, length) - return charsWritten -} - -Buffer.prototype.write = function (string, offset, length, encoding) { - // Support both (string, offset, length, encoding) - // and the legacy (string, encoding, offset, length) - if (isFinite(offset)) { - if (!isFinite(length)) { - encoding = length - length = undefined - } - } else { // legacy - var swap = encoding - encoding = offset - offset = length - length = swap - } - - offset = Number(offset) || 0 - var remaining = this.length - offset - if (!length) { - length = remaining - } else { - length = Number(length) - if (length > remaining) { - length = remaining - } - } - encoding = String(encoding || 'utf8').toLowerCase() - - var ret - switch (encoding) { - case 'hex': - ret = _hexWrite(this, string, offset, length) - break - case 'utf8': - case 'utf-8': - ret = _utf8Write(this, string, offset, length) - break - case 'ascii': - ret = _asciiWrite(this, string, offset, length) - break - case 'binary': - ret = _binaryWrite(this, string, offset, length) - break - case 'base64': - ret = _base64Write(this, string, offset, length) - break - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - ret = _utf16leWrite(this, string, offset, length) - break - default: - throw new Error('Unknown encoding') - } - return ret -} - -Buffer.prototype.toString = function (encoding, start, end) { - var self = this - - encoding = String(encoding || 'utf8').toLowerCase() - start = Number(start) || 0 - end = (end !== undefined) - ? Number(end) - : end = self.length - - // Fastpath empty strings - if (end === start) - return '' - - var ret - switch (encoding) { - case 'hex': - ret = _hexSlice(self, start, end) - break - case 'utf8': - case 'utf-8': - ret = _utf8Slice(self, start, end) - break - case 'ascii': - ret = _asciiSlice(self, start, end) - break - case 'binary': - ret = _binarySlice(self, start, end) - break - case 'base64': - ret = _base64Slice(self, start, end) - break - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - ret = _utf16leSlice(self, start, end) - break - default: - throw new Error('Unknown encoding') - } - return ret -} - -Buffer.prototype.toJSON = function () { - return { - type: 'Buffer', - data: Array.prototype.slice.call(this._arr || this, 0) - } -} - -// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) -Buffer.prototype.copy = function (target, target_start, start, end) { - var source = this - - if (!start) start = 0 - if (!end && end !== 0) end = this.length - if (!target_start) target_start = 0 - - // Copy 0 bytes; we're done - if (end === start) return - if (target.length === 0 || source.length === 0) return - - // Fatal error conditions - assert(end >= start, 'sourceEnd < sourceStart') - assert(target_start >= 0 && target_start < target.length, - 'targetStart out of bounds') - assert(start >= 0 && start < source.length, 'sourceStart out of bounds') - assert(end >= 0 && end <= source.length, 'sourceEnd out of bounds') - - // Are we oob? - if (end > this.length) - end = this.length - if (target.length - target_start < end - start) - end = target.length - target_start + start - - // copy! - for (var i = 0; i < end - start; i++) - target[i + target_start] = this[i + start] -} - -function _base64Slice (buf, start, end) { - if (start === 0 && end === buf.length) { - return base64.fromByteArray(buf) - } else { - return base64.fromByteArray(buf.slice(start, end)) - } -} - -function _utf8Slice (buf, start, end) { - var res = '' - var tmp = '' - end = Math.min(buf.length, end) - - for (var i = start; i < end; i++) { - if (buf[i] <= 0x7F) { - res += decodeUtf8Char(tmp) + String.fromCharCode(buf[i]) - tmp = '' - } else { - tmp += '%' + buf[i].toString(16) - } - } - - return res + decodeUtf8Char(tmp) -} - -function _asciiSlice (buf, start, end) { - var ret = '' - end = Math.min(buf.length, end) - - for (var i = start; i < end; i++) - ret += String.fromCharCode(buf[i]) - return ret -} - -function _binarySlice (buf, start, end) { - return _asciiSlice(buf, start, end) -} - -function _hexSlice (buf, start, end) { - var len = buf.length - - if (!start || start < 0) start = 0 - if (!end || end < 0 || end > len) end = len - - var out = '' - for (var i = start; i < end; i++) { - out += toHex(buf[i]) - } - return out -} - -function _utf16leSlice (buf, start, end) { - var bytes = buf.slice(start, end) - var res = '' - for (var i = 0; i < bytes.length; i += 2) { - res += String.fromCharCode(bytes[i] + bytes[i+1] * 256) - } - return res -} - -Buffer.prototype.slice = function (start, end) { - var len = this.length - start = clamp(start, len, 0) - end = clamp(end, len, len) - - if (Buffer._useTypedArrays) { - return augment(this.subarray(start, end)) - } else { - var sliceLen = end - start - var newBuf = new Buffer(sliceLen, undefined, true) - for (var i = 0; i < sliceLen; i++) { - newBuf[i] = this[i + start] - } - return newBuf - } -} - -// `get` will be removed in Node 0.13+ -Buffer.prototype.get = function (offset) { - console.log('.get() is deprecated. Access using array indexes instead.') - return this.readUInt8(offset) -} - -// `set` will be removed in Node 0.13+ -Buffer.prototype.set = function (v, offset) { - console.log('.set() is deprecated. Access using array indexes instead.') - return this.writeUInt8(v, offset) -} - -Buffer.prototype.readUInt8 = function (offset, noAssert) { - if (!noAssert) { - assert(offset !== undefined && offset !== null, 'missing offset') - assert(offset < this.length, 'Trying to read beyond buffer length') - } - - if (offset >= this.length) - return - - return this[offset] -} - -function _readUInt16 (buf, offset, littleEndian, noAssert) { - if (!noAssert) { - assert(typeof littleEndian === 'boolean', 'missing or invalid endian') - assert(offset !== undefined && offset !== null, 'missing offset') - assert(offset + 1 < buf.length, 'Trying to read beyond buffer length') - } - - var len = buf.length - if (offset >= len) - return - - var val - if (littleEndian) { - val = buf[offset] - if (offset + 1 < len) - val |= buf[offset + 1] << 8 - } else { - val = buf[offset] << 8 - if (offset + 1 < len) - val |= buf[offset + 1] - } - return val -} - -Buffer.prototype.readUInt16LE = function (offset, noAssert) { - return _readUInt16(this, offset, true, noAssert) -} - -Buffer.prototype.readUInt16BE = function (offset, noAssert) { - return _readUInt16(this, offset, false, noAssert) -} - -function _readUInt32 (buf, offset, littleEndian, noAssert) { - if (!noAssert) { - assert(typeof littleEndian === 'boolean', 'missing or invalid endian') - assert(offset !== undefined && offset !== null, 'missing offset') - assert(offset + 3 < buf.length, 'Trying to read beyond buffer length') - } - - var len = buf.length - if (offset >= len) - return - - var val - if (littleEndian) { - if (offset + 2 < len) - val = buf[offset + 2] << 16 - if (offset + 1 < len) - val |= buf[offset + 1] << 8 - val |= buf[offset] - if (offset + 3 < len) - val = val + (buf[offset + 3] << 24 >>> 0) - } else { - if (offset + 1 < len) - val = buf[offset + 1] << 16 - if (offset + 2 < len) - val |= buf[offset + 2] << 8 - if (offset + 3 < len) - val |= buf[offset + 3] - val = val + (buf[offset] << 24 >>> 0) - } - return val -} - -Buffer.prototype.readUInt32LE = function (offset, noAssert) { - return _readUInt32(this, offset, true, noAssert) -} - -Buffer.prototype.readUInt32BE = function (offset, noAssert) { - return _readUInt32(this, offset, false, noAssert) -} - -Buffer.prototype.readInt8 = function (offset, noAssert) { - if (!noAssert) { - assert(offset !== undefined && offset !== null, - 'missing offset') - assert(offset < this.length, 'Trying to read beyond buffer length') - } - - if (offset >= this.length) - return - - var neg = this[offset] & 0x80 - if (neg) - return (0xff - this[offset] + 1) * -1 - else - return this[offset] -} - -function _readInt16 (buf, offset, littleEndian, noAssert) { - if (!noAssert) { - assert(typeof littleEndian === 'boolean', 'missing or invalid endian') - assert(offset !== undefined && offset !== null, 'missing offset') - assert(offset + 1 < buf.length, 'Trying to read beyond buffer length') - } - - var len = buf.length - if (offset >= len) - return - - var val = _readUInt16(buf, offset, littleEndian, true) - var neg = val & 0x8000 - if (neg) - return (0xffff - val + 1) * -1 - else - return val -} - -Buffer.prototype.readInt16LE = function (offset, noAssert) { - return _readInt16(this, offset, true, noAssert) -} - -Buffer.prototype.readInt16BE = function (offset, noAssert) { - return _readInt16(this, offset, false, noAssert) -} - -function _readInt32 (buf, offset, littleEndian, noAssert) { - if (!noAssert) { - assert(typeof littleEndian === 'boolean', 'missing or invalid endian') - assert(offset !== undefined && offset !== null, 'missing offset') - assert(offset + 3 < buf.length, 'Trying to read beyond buffer length') - } - - var len = buf.length - if (offset >= len) - return - - var val = _readUInt32(buf, offset, littleEndian, true) - var neg = val & 0x80000000 - if (neg) - return (0xffffffff - val + 1) * -1 - else - return val -} - -Buffer.prototype.readInt32LE = function (offset, noAssert) { - return _readInt32(this, offset, true, noAssert) -} - -Buffer.prototype.readInt32BE = function (offset, noAssert) { - return _readInt32(this, offset, false, noAssert) -} - -function _readFloat (buf, offset, littleEndian, noAssert) { - if (!noAssert) { - assert(typeof littleEndian === 'boolean', 'missing or invalid endian') - assert(offset + 3 < buf.length, 'Trying to read beyond buffer length') - } - - return ieee754.read(buf, offset, littleEndian, 23, 4) -} - -Buffer.prototype.readFloatLE = function (offset, noAssert) { - return _readFloat(this, offset, true, noAssert) -} - -Buffer.prototype.readFloatBE = function (offset, noAssert) { - return _readFloat(this, offset, false, noAssert) -} - -function _readDouble (buf, offset, littleEndian, noAssert) { - if (!noAssert) { - assert(typeof littleEndian === 'boolean', 'missing or invalid endian') - assert(offset + 7 < buf.length, 'Trying to read beyond buffer length') - } - - return ieee754.read(buf, offset, littleEndian, 52, 8) -} - -Buffer.prototype.readDoubleLE = function (offset, noAssert) { - return _readDouble(this, offset, true, noAssert) -} - -Buffer.prototype.readDoubleBE = function (offset, noAssert) { - return _readDouble(this, offset, false, noAssert) -} - -Buffer.prototype.writeUInt8 = function (value, offset, noAssert) { - if (!noAssert) { - assert(value !== undefined && value !== null, 'missing value') - assert(offset !== undefined && offset !== null, 'missing offset') - assert(offset < this.length, 'trying to write beyond buffer length') - verifuint(value, 0xff) - } - - if (offset >= this.length) return - - this[offset] = value -} - -function _writeUInt16 (buf, value, offset, littleEndian, noAssert) { - if (!noAssert) { - assert(value !== undefined && value !== null, 'missing value') - assert(typeof littleEndian === 'boolean', 'missing or invalid endian') - assert(offset !== undefined && offset !== null, 'missing offset') - assert(offset + 1 < buf.length, 'trying to write beyond buffer length') - verifuint(value, 0xffff) - } - - var len = buf.length - if (offset >= len) - return - - for (var i = 0, j = Math.min(len - offset, 2); i < j; i++) { - buf[offset + i] = - (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> - (littleEndian ? i : 1 - i) * 8 - } -} - -Buffer.prototype.writeUInt16LE = function (value, offset, noAssert) { - _writeUInt16(this, value, offset, true, noAssert) -} - -Buffer.prototype.writeUInt16BE = function (value, offset, noAssert) { - _writeUInt16(this, value, offset, false, noAssert) -} - -function _writeUInt32 (buf, value, offset, littleEndian, noAssert) { - if (!noAssert) { - assert(value !== undefined && value !== null, 'missing value') - assert(typeof littleEndian === 'boolean', 'missing or invalid endian') - assert(offset !== undefined && offset !== null, 'missing offset') - assert(offset + 3 < buf.length, 'trying to write beyond buffer length') - verifuint(value, 0xffffffff) - } - - var len = buf.length - if (offset >= len) - return - - for (var i = 0, j = Math.min(len - offset, 4); i < j; i++) { - buf[offset + i] = - (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff - } -} - -Buffer.prototype.writeUInt32LE = function (value, offset, noAssert) { - _writeUInt32(this, value, offset, true, noAssert) -} - -Buffer.prototype.writeUInt32BE = function (value, offset, noAssert) { - _writeUInt32(this, value, offset, false, noAssert) -} - -Buffer.prototype.writeInt8 = function (value, offset, noAssert) { - if (!noAssert) { - assert(value !== undefined && value !== null, 'missing value') - assert(offset !== undefined && offset !== null, 'missing offset') - assert(offset < this.length, 'Trying to write beyond buffer length') - verifsint(value, 0x7f, -0x80) - } - - if (offset >= this.length) - return - - if (value >= 0) - this.writeUInt8(value, offset, noAssert) - else - this.writeUInt8(0xff + value + 1, offset, noAssert) -} - -function _writeInt16 (buf, value, offset, littleEndian, noAssert) { - if (!noAssert) { - assert(value !== undefined && value !== null, 'missing value') - assert(typeof littleEndian === 'boolean', 'missing or invalid endian') - assert(offset !== undefined && offset !== null, 'missing offset') - assert(offset + 1 < buf.length, 'Trying to write beyond buffer length') - verifsint(value, 0x7fff, -0x8000) - } - - var len = buf.length - if (offset >= len) - return - - if (value >= 0) - _writeUInt16(buf, value, offset, littleEndian, noAssert) - else - _writeUInt16(buf, 0xffff + value + 1, offset, littleEndian, noAssert) -} - -Buffer.prototype.writeInt16LE = function (value, offset, noAssert) { - _writeInt16(this, value, offset, true, noAssert) -} - -Buffer.prototype.writeInt16BE = function (value, offset, noAssert) { - _writeInt16(this, value, offset, false, noAssert) -} - -function _writeInt32 (buf, value, offset, littleEndian, noAssert) { - if (!noAssert) { - assert(value !== undefined && value !== null, 'missing value') - assert(typeof littleEndian === 'boolean', 'missing or invalid endian') - assert(offset !== undefined && offset !== null, 'missing offset') - assert(offset + 3 < buf.length, 'Trying to write beyond buffer length') - verifsint(value, 0x7fffffff, -0x80000000) - } - - var len = buf.length - if (offset >= len) - return - - if (value >= 0) - _writeUInt32(buf, value, offset, littleEndian, noAssert) - else - _writeUInt32(buf, 0xffffffff + value + 1, offset, littleEndian, noAssert) -} - -Buffer.prototype.writeInt32LE = function (value, offset, noAssert) { - _writeInt32(this, value, offset, true, noAssert) -} - -Buffer.prototype.writeInt32BE = function (value, offset, noAssert) { - _writeInt32(this, value, offset, false, noAssert) -} - -function _writeFloat (buf, value, offset, littleEndian, noAssert) { - if (!noAssert) { - assert(value !== undefined && value !== null, 'missing value') - assert(typeof littleEndian === 'boolean', 'missing or invalid endian') - assert(offset !== undefined && offset !== null, 'missing offset') - assert(offset + 3 < buf.length, 'Trying to write beyond buffer length') - verifIEEE754(value, 3.4028234663852886e+38, -3.4028234663852886e+38) - } - - var len = buf.length - if (offset >= len) - return - - ieee754.write(buf, value, offset, littleEndian, 23, 4) -} - -Buffer.prototype.writeFloatLE = function (value, offset, noAssert) { - _writeFloat(this, value, offset, true, noAssert) -} - -Buffer.prototype.writeFloatBE = function (value, offset, noAssert) { - _writeFloat(this, value, offset, false, noAssert) -} - -function _writeDouble (buf, value, offset, littleEndian, noAssert) { - if (!noAssert) { - assert(value !== undefined && value !== null, 'missing value') - assert(typeof littleEndian === 'boolean', 'missing or invalid endian') - assert(offset !== undefined && offset !== null, 'missing offset') - assert(offset + 7 < buf.length, - 'Trying to write beyond buffer length') - verifIEEE754(value, 1.7976931348623157E+308, -1.7976931348623157E+308) - } - - var len = buf.length - if (offset >= len) - return - - ieee754.write(buf, value, offset, littleEndian, 52, 8) -} - -Buffer.prototype.writeDoubleLE = function (value, offset, noAssert) { - _writeDouble(this, value, offset, true, noAssert) -} - -Buffer.prototype.writeDoubleBE = function (value, offset, noAssert) { - _writeDouble(this, value, offset, false, noAssert) -} - -// fill(value, start=0, end=buffer.length) -Buffer.prototype.fill = function (value, start, end) { - if (!value) value = 0 - if (!start) start = 0 - if (!end) end = this.length - - if (typeof value === 'string') { - value = value.charCodeAt(0) - } - - assert(typeof value === 'number' && !isNaN(value), 'value is not a number') - assert(end >= start, 'end < start') - - // Fill 0 bytes; we're done - if (end === start) return - if (this.length === 0) return - - assert(start >= 0 && start < this.length, 'start out of bounds') - assert(end >= 0 && end <= this.length, 'end out of bounds') - - for (var i = start; i < end; i++) { - this[i] = value - } -} - -Buffer.prototype.inspect = function () { - var out = [] - var len = this.length - for (var i = 0; i < len; i++) { - out[i] = toHex(this[i]) - if (i === exports.INSPECT_MAX_BYTES) { - out[i + 1] = '...' - break - } - } - return '' -} - -/** - * Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance. - * Added in Node 0.12. Only available in browsers that support ArrayBuffer. - */ -Buffer.prototype.toArrayBuffer = function () { - if (typeof Uint8Array === 'function') { - if (Buffer._useTypedArrays) { - return (new Buffer(this)).buffer - } else { - var buf = new Uint8Array(this.length) - for (var i = 0, len = buf.length; i < len; i += 1) - buf[i] = this[i] - return buf.buffer - } - } else { - throw new Error('Buffer.toArrayBuffer not supported in this browser') - } -} - -// HELPER FUNCTIONS -// ================ - -function stringtrim (str) { - if (str.trim) return str.trim() - return str.replace(/^\s+|\s+$/g, '') -} - -var BP = Buffer.prototype - -/** - * Augment the Uint8Array *instance* (not the class!) with Buffer methods - */ -function augment (arr) { - arr._isBuffer = true - - // save reference to original Uint8Array get/set methods before overwriting - arr._get = arr.get - arr._set = arr.set - - // deprecated, will be removed in node 0.13+ - arr.get = BP.get - arr.set = BP.set - - arr.write = BP.write - arr.toString = BP.toString - arr.toLocaleString = BP.toString - arr.toJSON = BP.toJSON - arr.copy = BP.copy - arr.slice = BP.slice - arr.readUInt8 = BP.readUInt8 - arr.readUInt16LE = BP.readUInt16LE - arr.readUInt16BE = BP.readUInt16BE - arr.readUInt32LE = BP.readUInt32LE - arr.readUInt32BE = BP.readUInt32BE - arr.readInt8 = BP.readInt8 - arr.readInt16LE = BP.readInt16LE - arr.readInt16BE = BP.readInt16BE - arr.readInt32LE = BP.readInt32LE - arr.readInt32BE = BP.readInt32BE - arr.readFloatLE = BP.readFloatLE - arr.readFloatBE = BP.readFloatBE - arr.readDoubleLE = BP.readDoubleLE - arr.readDoubleBE = BP.readDoubleBE - arr.writeUInt8 = BP.writeUInt8 - arr.writeUInt16LE = BP.writeUInt16LE - arr.writeUInt16BE = BP.writeUInt16BE - arr.writeUInt32LE = BP.writeUInt32LE - arr.writeUInt32BE = BP.writeUInt32BE - arr.writeInt8 = BP.writeInt8 - arr.writeInt16LE = BP.writeInt16LE - arr.writeInt16BE = BP.writeInt16BE - arr.writeInt32LE = BP.writeInt32LE - arr.writeInt32BE = BP.writeInt32BE - arr.writeFloatLE = BP.writeFloatLE - arr.writeFloatBE = BP.writeFloatBE - arr.writeDoubleLE = BP.writeDoubleLE - arr.writeDoubleBE = BP.writeDoubleBE - arr.fill = BP.fill - arr.inspect = BP.inspect - arr.toArrayBuffer = BP.toArrayBuffer - - return arr -} - -// slice(start, end) -function clamp (index, len, defaultValue) { - if (typeof index !== 'number') return defaultValue - index = ~~index; // Coerce to integer. - if (index >= len) return len - if (index >= 0) return index - index += len - if (index >= 0) return index - return 0 -} - -function coerce (length) { - // Coerce length to a number (possibly NaN), round up - // in case it's fractional (e.g. 123.456) then do a - // double negate to coerce a NaN to 0. Easy, right? - length = ~~Math.ceil(+length) - return length < 0 ? 0 : length -} - -function isArray (subject) { - return (Array.isArray || function (subject) { - return Object.prototype.toString.call(subject) === '[object Array]' - })(subject) -} - -function isArrayish (subject) { - return isArray(subject) || Buffer.isBuffer(subject) || - subject && typeof subject === 'object' && - typeof subject.length === 'number' -} - -function toHex (n) { - if (n < 16) return '0' + n.toString(16) - return n.toString(16) -} - -function utf8ToBytes (str) { - var byteArray = [] - for (var i = 0; i < str.length; i++) { - var b = str.charCodeAt(i) - if (b <= 0x7F) - byteArray.push(str.charCodeAt(i)) - else { - var start = i - if (b >= 0xD800 && b <= 0xDFFF) i++ - var h = encodeURIComponent(str.slice(start, i+1)).substr(1).split('%') - for (var j = 0; j < h.length; j++) - byteArray.push(parseInt(h[j], 16)) - } - } - return byteArray -} - -function asciiToBytes (str) { - var byteArray = [] - for (var i = 0; i < str.length; i++) { - // Node's code seems to be doing this and not & 0x7F.. - byteArray.push(str.charCodeAt(i) & 0xFF) - } - return byteArray -} - -function utf16leToBytes (str) { - var c, hi, lo - var byteArray = [] - for (var i = 0; i < str.length; i++) { - c = str.charCodeAt(i) - hi = c >> 8 - lo = c % 256 - byteArray.push(lo) - byteArray.push(hi) - } - - return byteArray -} - -function base64ToBytes (str) { - return base64.toByteArray(str) -} - -function blitBuffer (src, dst, offset, length) { - var pos - for (var i = 0; i < length; i++) { - if ((i + offset >= dst.length) || (i >= src.length)) - break - dst[i + offset] = src[i] - } - return i -} - -function decodeUtf8Char (str) { - try { - return decodeURIComponent(str) - } catch (err) { - return String.fromCharCode(0xFFFD) // UTF 8 invalid char - } -} - -/* - * We have to make sure that the value is a valid integer. This means that it - * is non-negative. It has no fractional component and that it does not - * exceed the maximum allowed value. - */ -function verifuint (value, max) { - assert(typeof value === 'number', 'cannot write a non-number as a number') - assert(value >= 0, 'specified a negative value for writing an unsigned value') - assert(value <= max, 'value is larger than maximum value for type') - assert(Math.floor(value) === value, 'value has a fractional component') -} - -function verifsint (value, max, min) { - assert(typeof value === 'number', 'cannot write a non-number as a number') - assert(value <= max, 'value larger than maximum allowed value') - assert(value >= min, 'value smaller than minimum allowed value') - assert(Math.floor(value) === value, 'value has a fractional component') -} - -function verifIEEE754 (value, max, min) { - assert(typeof value === 'number', 'cannot write a non-number as a number') - assert(value <= max, 'value larger than maximum allowed value') - assert(value >= min, 'value smaller than minimum allowed value') -} - -function assert (test, message) { - if (!test) throw new Error(message || 'Failed assertion') -} - -}).call(this,_dereq_("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},_dereq_("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/grunt-browserify/node_modules/browserify/node_modules/buffer/index.js","/../node_modules/grunt-browserify/node_modules/browserify/node_modules/buffer") -},{"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,"base64-js":2,"buffer":1,"ieee754":3}],2:[function(_dereq_,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ -var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; - -;(function (exports) { - 'use strict'; - - var Arr = (typeof Uint8Array !== 'undefined') - ? Uint8Array - : Array - - var ZERO = '0'.charCodeAt(0) - var PLUS = '+'.charCodeAt(0) - var SLASH = '/'.charCodeAt(0) - var NUMBER = '0'.charCodeAt(0) - var LOWER = 'a'.charCodeAt(0) - var UPPER = 'A'.charCodeAt(0) - - function decode (elt) { - var code = elt.charCodeAt(0) - if (code === PLUS) - return 62 // '+' - if (code === SLASH) - return 63 // '/' - if (code < NUMBER) - return -1 //no match - if (code < NUMBER + 10) - return code - NUMBER + 26 + 26 - if (code < UPPER + 26) - return code - UPPER - if (code < LOWER + 26) - return code - LOWER + 26 - } - - function b64ToByteArray (b64) { - var i, j, l, tmp, placeHolders, arr - - if (b64.length % 4 > 0) { - throw new Error('Invalid string. Length must be a multiple of 4') - } - - // the number of equal signs (place holders) - // if there are two placeholders, than the two characters before it - // represent one byte - // if there is only one, then the three characters before it represent 2 bytes - // this is just a cheap hack to not do indexOf twice - var len = b64.length - placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0 - - // base64 is 4/3 + up to two characters of the original data - arr = new Arr(b64.length * 3 / 4 - placeHolders) - - // if there are placeholders, only get up to the last complete 4 chars - l = placeHolders > 0 ? b64.length - 4 : b64.length - - var L = 0 - - function push (v) { - arr[L++] = v - } - - for (i = 0, j = 0; i < l; i += 4, j += 3) { - tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3)) - push((tmp & 0xFF0000) >> 16) - push((tmp & 0xFF00) >> 8) - push(tmp & 0xFF) - } - - if (placeHolders === 2) { - tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4) - push(tmp & 0xFF) - } else if (placeHolders === 1) { - tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2) - push((tmp >> 8) & 0xFF) - push(tmp & 0xFF) - } - - return arr - } - - function uint8ToBase64 (uint8) { - var i, - extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes - output = "", - temp, length - - function encode (num) { - return lookup.charAt(num) - } - - function tripletToBase64 (num) { - return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F) - } - - // go through the array every three bytes, we'll deal with trailing stuff later - for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) { - temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]) - output += tripletToBase64(temp) - } - - // pad the end with zeros, but make sure to not forget the extra bytes - switch (extraBytes) { - case 1: - temp = uint8[uint8.length - 1] - output += encode(temp >> 2) - output += encode((temp << 4) & 0x3F) - output += '==' - break - case 2: - temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1]) - output += encode(temp >> 10) - output += encode((temp >> 4) & 0x3F) - output += encode((temp << 2) & 0x3F) - output += '=' - break - } - - return output - } - - module.exports.toByteArray = b64ToByteArray - module.exports.fromByteArray = uint8ToBase64 -}()) - -}).call(this,_dereq_("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},_dereq_("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/grunt-browserify/node_modules/browserify/node_modules/buffer/node_modules/base64-js/lib/b64.js","/../node_modules/grunt-browserify/node_modules/browserify/node_modules/buffer/node_modules/base64-js/lib") -},{"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,"buffer":1}],3:[function(_dereq_,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ -exports.read = function(buffer, offset, isLE, mLen, nBytes) { - var e, m, - eLen = nBytes * 8 - mLen - 1, - eMax = (1 << eLen) - 1, - eBias = eMax >> 1, - nBits = -7, - i = isLE ? (nBytes - 1) : 0, - d = isLE ? -1 : 1, - s = buffer[offset + i]; - - i += d; - - e = s & ((1 << (-nBits)) - 1); - s >>= (-nBits); - nBits += eLen; - for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8); - - m = e & ((1 << (-nBits)) - 1); - e >>= (-nBits); - nBits += mLen; - for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8); - - if (e === 0) { - e = 1 - eBias; - } else if (e === eMax) { - return m ? NaN : ((s ? -1 : 1) * Infinity); - } else { - m = m + Math.pow(2, mLen); - e = e - eBias; - } - return (s ? -1 : 1) * m * Math.pow(2, e - mLen); -}; - -exports.write = function(buffer, value, offset, isLE, mLen, nBytes) { - var e, m, c, - eLen = nBytes * 8 - mLen - 1, - eMax = (1 << eLen) - 1, - eBias = eMax >> 1, - rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0), - i = isLE ? 0 : (nBytes - 1), - d = isLE ? 1 : -1, - s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0; - - value = Math.abs(value); - - if (isNaN(value) || value === Infinity) { - m = isNaN(value) ? 1 : 0; - e = eMax; - } else { - e = Math.floor(Math.log(value) / Math.LN2); - if (value * (c = Math.pow(2, -e)) < 1) { - e--; - c *= 2; - } - if (e + eBias >= 1) { - value += rt / c; - } else { - value += rt * Math.pow(2, 1 - eBias); - } - if (value * c >= 2) { - e++; - c /= 2; - } - - if (e + eBias >= eMax) { - m = 0; - e = eMax; - } else if (e + eBias >= 1) { - m = (value * c - 1) * Math.pow(2, mLen); - e = e + eBias; - } else { - m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen); - e = 0; - } - } - - for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8); - - e = (e << mLen) | m; - eLen += mLen; - for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8); - - buffer[offset + i - d] |= s * 128; -}; - -}).call(this,_dereq_("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},_dereq_("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/grunt-browserify/node_modules/browserify/node_modules/buffer/node_modules/ieee754/index.js","/../node_modules/grunt-browserify/node_modules/browserify/node_modules/buffer/node_modules/ieee754") -},{"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,"buffer":1}],4:[function(_dereq_,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ -// shim for using process in browser - -var process = module.exports = {}; - -process.nextTick = (function () { - var canSetImmediate = typeof window !== 'undefined' - && window.setImmediate; - var canPost = typeof window !== 'undefined' - && window.postMessage && window.addEventListener - ; - - if (canSetImmediate) { - return function (f) { return window.setImmediate(f) }; - } - - if (canPost) { - var queue = []; - window.addEventListener('message', function (ev) { - var source = ev.source; - if ((source === window || source === null) && ev.data === 'process-tick') { - ev.stopPropagation(); - if (queue.length > 0) { - var fn = queue.shift(); - fn(); - } - } - }, true); - - return function nextTick(fn) { - queue.push(fn); - window.postMessage('process-tick', '*'); - }; - } - - return function nextTick(fn) { - setTimeout(fn, 0); - }; -})(); - -process.title = 'browser'; -process.browser = true; -process.env = {}; -process.argv = []; - -function noop() {} - -process.on = noop; -process.once = noop; -process.off = noop; -process.emit = noop; - -process.binding = function (name) { - throw new Error('process.binding is not supported'); -} - -// TODO(shtylman) -process.cwd = function () { return '/' }; -process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); -}; - -}).call(this,_dereq_("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},_dereq_("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js","/../node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process") -},{"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,"buffer":1}],5:[function(_dereq_,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +!function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&false)define(e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.p2=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o (http://steffe.se)", "keywords": [ @@ -2130,8 +729,7 @@ module.exports={ } } -},{}],11:[function(_dereq_,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +},{}],7:[function(_dereq_,module,exports){ var vec2 = _dereq_('../math/vec2') , Utils = _dereq_('../utils/Utils'); @@ -2283,9 +881,7 @@ AABB.prototype.overlaps = function(aabb){ ((l2[1] <= u1[1] && u1[1] <= u2[1]) || (l1[1] <= u2[1] && u2[1] <= u1[1])); }; -}).call(this,_dereq_("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},_dereq_("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/collision/AABB.js","/collision") -},{"../math/vec2":33,"../utils/Utils":52,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,"buffer":1}],12:[function(_dereq_,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +},{"../math/vec2":31,"../utils/Utils":50}],8:[function(_dereq_,module,exports){ var vec2 = _dereq_('../math/vec2'); var Body = _dereq_('../objects/Body'); @@ -2379,13 +975,7 @@ Broadphase.boundingRadiusCheck = function(bodyA, bodyB){ * @return {Boolean} */ Broadphase.aabbCheck = function(bodyA, bodyB){ - if(bodyA.aabbNeedsUpdate){ - bodyA.updateAABB(); - } - if(bodyB.aabbNeedsUpdate){ - bodyB.updateAABB(); - } - return bodyA.aabb.overlaps(bodyB.aabb); + return bodyA.getAABB().overlaps(bodyB.getAABB()); }; /** @@ -2453,9 +1043,7 @@ Broadphase.canCollide = function(bodyA, bodyB){ Broadphase.NAIVE = 1; Broadphase.SAP = 2; -}).call(this,_dereq_("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},_dereq_("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/collision/Broadphase.js","/collision") -},{"../math/vec2":33,"../objects/Body":34,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,"buffer":1}],13:[function(_dereq_,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +},{"../math/vec2":31,"../objects/Body":32}],9:[function(_dereq_,module,exports){ var Circle = _dereq_('../shapes/Circle') , Plane = _dereq_('../shapes/Plane') , Particle = _dereq_('../shapes/Particle') @@ -2502,6 +1090,7 @@ function GridBroadphase(options){ this.binsizeY = (this.ymax-this.ymin) / this.ny; } GridBroadphase.prototype = new Broadphase(); +GridBroadphase.prototype.constructor = GridBroadphase; /** * Get collision pairs. @@ -2574,9 +1163,7 @@ GridBroadphase.prototype.getCollisionPairs = function(world){ return result; }; -}).call(this,_dereq_("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},_dereq_("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/collision/GridBroadphase.js","/collision") -},{"../collision/Broadphase":12,"../math/vec2":33,"../shapes/Circle":40,"../shapes/Particle":44,"../shapes/Plane":45,"../utils/Utils":52,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,"buffer":1}],14:[function(_dereq_,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +},{"../collision/Broadphase":8,"../math/vec2":31,"../shapes/Circle":38,"../shapes/Particle":42,"../shapes/Plane":43,"../utils/Utils":50}],10:[function(_dereq_,module,exports){ var Circle = _dereq_('../shapes/Circle'), Plane = _dereq_('../shapes/Plane'), Shape = _dereq_('../shapes/Shape'), @@ -2597,6 +1184,7 @@ function NaiveBroadphase(){ Broadphase.call(this, Broadphase.NAIVE); } NaiveBroadphase.prototype = new Broadphase(); +NaiveBroadphase.prototype.constructor = NaiveBroadphase; /** * Get the colliding pairs @@ -2625,9 +1213,33 @@ NaiveBroadphase.prototype.getCollisionPairs = function(world){ return result; }; -}).call(this,_dereq_("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},_dereq_("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/collision/NaiveBroadphase.js","/collision") -},{"../collision/Broadphase":12,"../math/vec2":33,"../shapes/Circle":40,"../shapes/Particle":44,"../shapes/Plane":45,"../shapes/Shape":47,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,"buffer":1}],15:[function(_dereq_,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +/** + * Returns all the bodies within an AABB. + * @method aabbQuery + * @param {World} world + * @param {AABB} aabb + * @param {array} result An array to store resulting bodies in. + * @return {array} + */ +NaiveBroadphase.prototype.aabbQuery = function(world, aabb, result){ + result = result || []; + + var bodies = world.bodies; + for(var i = 0; i < bodies.length; i++){ + var b = bodies[i]; + + if(b.aabbNeedsUpdate){ + b.updateAABB(); + } + + if(b.aabb.overlaps(aabb)){ + result.push(b); + } + } + + return result; +}; +},{"../collision/Broadphase":8,"../math/vec2":31,"../shapes/Circle":38,"../shapes/Particle":42,"../shapes/Plane":43,"../shapes/Shape":45}],11:[function(_dereq_,module,exports){ var vec2 = _dereq_('../math/vec2') , sub = vec2.sub , add = vec2.add @@ -2694,6 +1306,13 @@ function Narrowphase(){ */ this.enableFriction = true; + /** + * Whether to make equations enabled in upcoming contacts. + * @property enabledEquations + * @type {Boolean} + */ + this.enabledEquations = true; + /** * The friction slip force to use when creating friction equations. * @property slipForce @@ -2768,13 +1387,61 @@ function Narrowphase(){ */ this.collidingBodiesLastStep = new TupleDictionary(); - /** - * Contact skin size value to use in the next contact equations. - * @property {Number} collidingBodiesLastStep - * @default 0.01 - */ - this.contactSkinSize = 0.01; -} + /** + * Contact skin size value to use in the next contact equations. + * @property {Number} contactSkinSize + * @default 0.01 + */ + this.contactSkinSize = 0.01; +} + +var bodiesOverlap_shapePositionA = vec2.create(); +var bodiesOverlap_shapePositionB = vec2.create(); + +/** + * @method bodiesOverlap + * @param {Body} bodyA + * @param {Body} bodyB + * @return {Boolean} + */ +Narrowphase.prototype.bodiesOverlap = function(bodyA, bodyB){ + var shapePositionA = bodiesOverlap_shapePositionA; + var shapePositionB = bodiesOverlap_shapePositionB; + + // Loop over all shapes of bodyA + for(var k=0, Nshapesi=bodyA.shapes.length; k!==Nshapesi; k++){ + var shapeA = bodyA.shapes[k], + positionA = bodyA.shapeOffsets[k], + angleA = bodyA.shapeAngles[k]; + + bodyA.toWorldFrame(shapePositionA, positionA); + + // All shapes of body j + for(var l=0, Nshapesj=bodyB.shapes.length; l!==Nshapesj; l++){ + var shapeB = bodyB.shapes[l], + positionB = bodyB.shapeOffsets[l], + angleB = bodyB.shapeAngles[l]; + + bodyB.toWorldFrame(shapePositionB, positionB); + + if(this[shapeA.type | shapeB.type]( + bodyA, + shapeA, + shapePositionA, + shapeA.angle + bodyA.angle, + bodyB, + shapeB, + shapePositionB, + shapeB.angle + bodyB.angle, + true + )){ + return true; + } + } + } + + return false; +}; /** * Check if the bodies were in contact since the last reset(). @@ -2836,7 +1503,7 @@ Narrowphase.prototype.createContactEquation = function(bodyA, bodyB, shapeA, sha c.stiffness = this.stiffness; c.relaxation = this.relaxation; c.needsUpdate = true; - c.enabled = true; + c.enabled = this.enabledEquations; c.offset = this.contactSkinSize; return c; @@ -2858,7 +1525,7 @@ Narrowphase.prototype.createFrictionEquation = function(bodyA, bodyB, shapeA, sh c.setSlipForce(this.slipForce); c.frictionCoefficient = this.frictionCoefficient; c.relativeVelocity = this.surfaceVelocity; - c.enabled = true; + c.enabled = this.enabledEquations; c.needsUpdate = true; c.stiffness = this.frictionStiffness; c.relaxation = this.frictionRelaxation; @@ -2883,9 +1550,6 @@ Narrowphase.prototype.createFrictionFromContact = function(c){ // Take the average N latest contact point on the plane. Narrowphase.prototype.createFrictionFromAverage = function(numContacts){ - if(!numContacts){ - throw new Error("numContacts == 0!"); - } var c = this.contactEquations[this.contactEquations.length - 1]; var eq = this.createFrictionEquation(c.bodyA, c.bodyB, c.shapeA, c.shapeB); var bodyA = c.bodyA; @@ -4791,10 +3455,12 @@ Narrowphase.prototype.circleHeightfield = function( circleBody,circleShape,circl return justTest ? false : 0; } + /* if(circlePos[1]+radius < min){ // Below the minimum point... We can just guess. // TODO } + */ // 1. Check so center of circle is not inside the field. If it is, this wont work... // 2. For each edge @@ -4939,63 +3605,750 @@ Narrowphase.prototype.convexHeightfield = function( convexBody,convexShape,conve var idxA = Math.floor( (convexBody.aabb.lowerBound[0] - hfPos[0]) / w ), idxB = Math.ceil( (convexBody.aabb.upperBound[0] - hfPos[0]) / w ); - if(idxA < 0){ - idxA = 0; - } - if(idxB >= data.length){ - idxB = data.length-1; + if(idxA < 0){ + idxA = 0; + } + if(idxB >= data.length){ + idxB = data.length-1; + } + + // Get max and min + var max = data[idxA], + min = data[idxB]; + for(var i=idxA; i max){ + max = data[i]; + } + } + + if(convexBody.aabb.lowerBound[1] > max){ + return justTest ? false : 0; + } + + var found = false; + var numContacts = 0; + + // Loop over all edges + // TODO: If possible, construct a convex from several data points (need o check if the points make a convex shape) + for(var i=idxA; i shape.boundingSphereRadius ) { + return; + } + + var method = this[shape.type]; + if(method){ + method.call(this, shape, angle, position, body); + } +}; + +var vector = vec2.create(); +var normal = vec2.create(); +var intersectPoint = vec2.create(); + +var a = vec2.create(); +var b = vec2.create(); +var c = vec2.create(); +var d = vec2.create(); + +var tmpRaycastResult = new RaycastResult(); +var intersectRectangle_direction = vec2.create(); +var intersectRectangle_rayStart = vec2.create(); +var intersectRectangle_worldNormalMin = vec2.create(); +var intersectRectangle_worldNormalMax = vec2.create(); +var intersectRectangle_hitPointWorld = vec2.create(); +var intersectRectangle_boxMin = vec2.create(); +var intersectRectangle_boxMax = vec2.create(); + +/** + * @method intersectRectangle + * @private + * @param {Shape} shape + * @param {number} angle + * @param {array} position + * @param {Body} body + */ +Ray.prototype.intersectRectangle = function(shape, angle, position, body){ + var tmin = -Number.MAX_VALUE; + var tmax = Number.MAX_VALUE; + + var direction = intersectRectangle_direction; + var rayStart = intersectRectangle_rayStart; + var worldNormalMin = intersectRectangle_worldNormalMin; + var worldNormalMax = intersectRectangle_worldNormalMax; + var hitPointWorld = intersectRectangle_hitPointWorld; + var boxMin = intersectRectangle_boxMin; + var boxMax = intersectRectangle_boxMax; + + vec2.set(boxMin, -shape.width * 0.5, -shape.height * 0.5); + vec2.set(boxMax, shape.width * 0.5, shape.height * 0.5); + + // Transform the ray direction and start to local space + vec2.rotate(direction, this._direction, -angle); + body.toLocalFrame(rayStart, this.from); + + if (direction[0] !== 0) { + var tx1 = (boxMin[0] - rayStart[0]) / direction[0]; + var tx2 = (boxMax[0] - rayStart[0]) / direction[0]; + + var tminOld = tmin; + tmin = Math.max(tmin, Math.min(tx1, tx2)); + if(tmin !== tminOld){ + vec2.set(worldNormalMin, tx1 > tx2 ? 1 : -1, 0); + } + + var tmaxOld = tmax; + tmax = Math.min(tmax, Math.max(tx1, tx2)); + if(tmax !== tmaxOld){ + vec2.set(worldNormalMax, tx1 < tx2 ? 1 : -1, 0); + } + } + + if (direction[1] !== 0) { + var ty1 = (boxMin[1] - rayStart[1]) / direction[1]; + var ty2 = (boxMax[1] - rayStart[1]) / direction[1]; + + var tminOld = tmin; + tmin = Math.max(tmin, Math.min(ty1, ty2)); + if(tmin !== tminOld){ + vec2.set(worldNormalMin, 0, ty1 > ty2 ? 1 : -1); + } + + var tmaxOld = tmax; + tmax = Math.min(tmax, Math.max(ty1, ty2)); + if(tmax !== tmaxOld){ + vec2.set(worldNormalMax, 0, ty1 < ty2 ? 1 : -1); + } + } + + if(tmax >= tmin){ + // Hit point + vec2.set( + hitPointWorld, + rayStart[0] + direction[0] * tmin, + rayStart[1] + direction[1] * tmin + ); + + vec2.rotate(worldNormalMin, worldNormalMin, angle); + + body.toWorldFrame(hitPointWorld, hitPointWorld); + + this.reportIntersection(worldNormalMin, hitPointWorld, shape, body, -1); + if(this._shouldStop){ + return; + } + + vec2.rotate(worldNormalMax, worldNormalMax, angle); + + // Hit point + vec2.set( + hitPointWorld, + rayStart[0] + direction[0] * tmax, + rayStart[1] + direction[1] * tmax + ); + body.toWorldFrame(hitPointWorld, hitPointWorld); + + this.reportIntersection(worldNormalMax, hitPointWorld, shape, body, -1); + } +}; +Ray.prototype[Shape.RECTANGLE] = Ray.prototype.intersectRectangle; + +var intersectPlane_planePointToFrom = vec2.create(); +var intersectPlane_dir_scaled_with_t = vec2.create(); +var intersectPlane_hitPointWorld = vec2.create(); +var intersectPlane_worldNormal = vec2.create(); +var intersectPlane_len = vec2.create(); + +/** + * @method intersectPlane + * @private + * @param {Shape} shape + * @param {number} angle + * @param {array} position + * @param {Body} body + */ +Ray.prototype.intersectPlane = function(shape, angle, position, body){ + var from = this.from; + var to = this.to; + var direction = this._direction; + + var planePointToFrom = intersectPlane_planePointToFrom; + var dir_scaled_with_t = intersectPlane_dir_scaled_with_t; + var hitPointWorld = intersectPlane_hitPointWorld; + var worldNormal = intersectPlane_worldNormal; + var len = intersectPlane_len; + + // Get plane normal + vec2.set(worldNormal, 0, 1); + vec2.rotate(worldNormal, worldNormal, angle); + + vec2.sub(len, from, position); //from.vsub(position, len); + var planeToFrom = vec2.dot(len, worldNormal); // len.dot(worldNormal); + vec2.sub(len, to, position); // to.vsub(position, len); + var planeToTo = vec2.dot(len, worldNormal); // len.dot(worldNormal); + + if(planeToFrom * planeToTo > 0){ + // "from" and "to" are on the same side of the plane... bail out + return; + } + + if(vec2.distance(from, to) /* from.distanceTo(to) */ < planeToFrom){ + return; + } + + var n_dot_dir = vec2.dot(worldNormal, direction); // worldNormal.dot(direction); + + // if (Math.abs(n_dot_dir) < this.precision) { + // // No intersection + // return; + // } + + vec2.sub(planePointToFrom, from, position); // from.vsub(position, planePointToFrom); + var t = -vec2.dot(worldNormal, planePointToFrom) / n_dot_dir; // - worldNormal.dot(planePointToFrom) / n_dot_dir; + vec2.scale(dir_scaled_with_t, direction, t); // direction.scale(t, dir_scaled_with_t); + vec2.add(hitPointWorld, from, dir_scaled_with_t); // from.vadd(dir_scaled_with_t, hitPointWorld); + + this.reportIntersection(worldNormal, hitPointWorld, shape, body, -1); +}; +Ray.prototype[Shape.PLANE] = Ray.prototype.intersectPlane; + +var Ray_intersectSphere_intersectionPoint = vec2.create(); +var Ray_intersectSphere_normal = vec2.create(); +Ray.prototype.intersectCircle = function(shape, angle, position, body){ + var from = this.from, + to = this.to, + r = shape.radius; + + var a = Math.pow(to[0] - from[0], 2) + Math.pow(to[1] - from[1], 2); + var b = 2 * ((to[0] - from[0]) * (from[0] - position[0]) + (to[1] - from[1]) * (from[1] - position[1])); + var c = Math.pow(from[0] - position[0], 2) + Math.pow(from[1] - position[1], 2) - Math.pow(r, 2); + + var delta = Math.pow(b, 2) - 4 * a * c; + + var intersectionPoint = Ray_intersectSphere_intersectionPoint; + var normal = Ray_intersectSphere_normal; + + if(delta < 0){ + // No intersection + return; + + } else if(delta === 0){ + // single intersection point + vec2.lerp(intersectionPoint, from, to, delta); // from.lerp(to, delta, intersectionPoint); + + vec2.sub(normal, intersectionPoint, position); // intersectionPoint.vsub(position, normal); + vec2.normalize(normal,normal); //normal.normalize(); + + this.reportIntersection(normal, intersectionPoint, shape, body, -1); + + } else { + var d1 = (- b - Math.sqrt(delta)) / (2 * a); + var d2 = (- b + Math.sqrt(delta)) / (2 * a); + + vec2.lerp(intersectionPoint, from, to, d1); // from.lerp(to, d1, intersectionPoint); + + vec2.sub(normal, intersectionPoint, position); // intersectionPoint.vsub(position, normal); + vec2.normalize(normal,normal); //normal.normalize(); + + this.reportIntersection(normal, intersectionPoint, shape, body, -1); + + if(this.result._shouldStop){ + return; + } + + vec2.lerp(intersectionPoint, from, to, d2); // from.lerp(to, d2, intersectionPoint); + + vec2.sub(normal, intersectionPoint, position); // intersectionPoint.vsub(position, normal); + vec2.normalize(normal,normal); //normal.normalize(); + + this.reportIntersection(normal, intersectionPoint, shape, body, -1); + } +}; +Ray.prototype[Shape.CIRCLE] = Ray.prototype.intersectCircle; + +/** + * Get the AABB of the ray. + * @method getAABB + * @param {AABB} aabb + */ +Ray.prototype.getAABB = function(result){ + var to = this.to; + var from = this.from; + result.lowerBound[0] = Math.min(to[0], from[0]); + result.lowerBound[1] = Math.min(to[1], from[1]); + result.upperBound[0] = Math.max(to[0], from[0]); + result.upperBound[1] = Math.max(to[1], from[1]); +}; + +/** + * @method reportIntersection + * @private + * @param {array} normal + * @param {array} hitPointWorld + * @param {Shape} shape + * @param {Body} body + * @return {boolean} True if the intersections should continue + */ +Ray.prototype.reportIntersection = function(normal, hitPointWorld, shape, body, hitFaceIndex){ + var from = this.from; + var to = this.to; + var distance = vec2.distance(from, hitPointWorld); // from.distanceTo(hitPointWorld); + var result = this.result; + + // Skip back faces? + if(this.skipBackfaces && /* normal.dot(this._direction) */ vec2.dot(normal, this._direction) > 0){ + return; } - // Get max and min - var max = data[idxA], - min = data[idxB]; - for(var i=idxA; i max){ - max = data[i]; + result.hitFaceIndex = typeof(hitFaceIndex) !== 'undefined' ? hitFaceIndex : -1; + + switch(this.mode){ + case Ray.ALL: + this.hasHit = true; + result.set( + from, + to, + normal, + hitPointWorld, + shape, + body, + distance + ); + result.hasHit = true; + this.callback(result); + break; + + case Ray.CLOSEST: + + // Store if closer than current closest + if(distance < result.distance || !result.hasHit){ + this.hasHit = true; + result.hasHit = true; + result.set( + from, + to, + normal, + hitPointWorld, + shape, + body, + distance + ); } - } + break; - if(convexBody.aabb.lowerBound[1] > max){ - return justTest ? false : 0; + case Ray.ANY: + + // Report and stop. + this.hasHit = true; + result.hasHit = true; + result.set( + from, + to, + normal, + hitPointWorld, + shape, + body, + distance + ); + result._shouldStop = true; + break; } +}; - var found = false; - var numContacts = 0; +var v0 = vec2.create(), + intersect = vec2.create(); +function distanceFromIntersection(from, direction, position) { - // Loop over all edges - // TODO: If possible, construct a convex from several data points (need o check if the points make a convex shape) - for(var i=idxA; i= tmin && iter < this.ccdIterations) { + iter++; + + // calculate the midpoint + tmid = (tmax - tmin) / 2; + + // Move the body to that point + vec2.scale(integrate_velodt, startToEnd, timeOfImpact); + vec2.add(this.position, rememberPosition, integrate_velodt); + this.angle = rememberAngle + startToEndAngle * timeOfImpact; + this.updateAABB(); + + // check overlap + var overlaps = this.aabb.overlaps(hit.aabb) && this.world.narrowphase.bodiesOverlap(this, hit); + + if (overlaps) { + // change min to search upper interval + tmin = tmid; + } else { + // change max to search lower interval + tmax = tmid; + } + } + + timeOfImpact = tmid; + + vec2.copy(this.position, rememberPosition); + this.angle = rememberAngle; + + // move to TOI + vec2.scale(integrate_velodt, startToEnd, timeOfImpact); + vec2.add(this.position, this.position, integrate_velodt); + if(!this.fixedRotation){ + this.angle += startToEndAngle * timeOfImpact; + } + + return true; +}; + /** * @event sleepy */ @@ -9327,9 +8866,7 @@ Body.SLEEPY = 1; Body.SLEEPING = 2; -}).call(this,_dereq_("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},_dereq_("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/objects/Body.js","/objects") -},{"../collision/AABB":11,"../events/EventEmitter":29,"../math/vec2":33,"../shapes/Convex":41,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,"buffer":1,"poly-decomp":9}],35:[function(_dereq_,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +},{"../collision/AABB":7,"../events/EventEmitter":27,"../math/vec2":31,"../shapes/Convex":39,"poly-decomp":5}],33:[function(_dereq_,module,exports){ var vec2 = _dereq_('../math/vec2'); var Spring = _dereq_('./Spring'); var Utils = _dereq_('../utils/Utils'); @@ -9393,6 +8930,7 @@ function LinearSpring(bodyA,bodyB,options){ this.restLength = typeof(options.restLength) === "number" ? options.restLength : worldDistance; } LinearSpring.prototype = new Spring(); +LinearSpring.prototype.constructor = LinearSpring; /** * Set the anchor point on body A, using world coordinates. @@ -9498,9 +9036,7 @@ LinearSpring.prototype.applyForce = function(){ bodyB.angularForce += rj_x_f; }; -}).call(this,_dereq_("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},_dereq_("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/objects/LinearSpring.js","/objects") -},{"../math/vec2":33,"../utils/Utils":52,"./Spring":37,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,"buffer":1}],36:[function(_dereq_,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +},{"../math/vec2":31,"../utils/Utils":50,"./Spring":35}],34:[function(_dereq_,module,exports){ var vec2 = _dereq_('../math/vec2'); var Spring = _dereq_('./Spring'); @@ -9534,6 +9070,7 @@ function RotationalSpring(bodyA, bodyB, options){ this.restAngle = typeof(options.restAngle) === "number" ? options.restAngle : bodyB.angle - bodyA.angle; } RotationalSpring.prototype = new Spring(); +RotationalSpring.prototype.constructor = RotationalSpring; /** * Apply the spring force to the connected bodies. @@ -9554,9 +9091,7 @@ RotationalSpring.prototype.applyForce = function(){ bodyB.angularForce += torque; }; -}).call(this,_dereq_("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},_dereq_("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/objects/RotationalSpring.js","/objects") -},{"../math/vec2":33,"./Spring":37,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,"buffer":1}],37:[function(_dereq_,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +},{"../math/vec2":31,"./Spring":35}],35:[function(_dereq_,module,exports){ var vec2 = _dereq_('../math/vec2'); var Utils = _dereq_('../utils/Utils'); @@ -9620,9 +9155,7 @@ Spring.prototype.applyForce = function(){ // To be implemented by subclasses }; -}).call(this,_dereq_("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},_dereq_("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/objects/Spring.js","/objects") -},{"../math/vec2":33,"../utils/Utils":52,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,"buffer":1}],38:[function(_dereq_,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +},{"../math/vec2":31,"../utils/Utils":50}],36:[function(_dereq_,module,exports){ // Export p2 classes module.exports = { AABB : _dereq_('./collision/AABB'), @@ -9652,6 +9185,8 @@ module.exports = { Plane : _dereq_('./shapes/Plane'), RevoluteConstraint : _dereq_('./constraints/RevoluteConstraint'), PrismaticConstraint : _dereq_('./constraints/PrismaticConstraint'), + Ray : _dereq_('./collision/Ray'), + RaycastResult : _dereq_('./collision/RaycastResult'), Rectangle : _dereq_('./shapes/Rectangle'), RotationalVelocityEquation : _dereq_('./equations/RotationalVelocityEquation'), SAPBroadphase : _dereq_('./collision/SAPBroadphase'), @@ -9666,9 +9201,7 @@ module.exports = { version : _dereq_('../package.json').version, }; -}).call(this,_dereq_("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},_dereq_("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/p2.js","/") -},{"../package.json":10,"./collision/AABB":11,"./collision/Broadphase":12,"./collision/GridBroadphase":13,"./collision/NaiveBroadphase":14,"./collision/Narrowphase":15,"./collision/SAPBroadphase":16,"./constraints/Constraint":17,"./constraints/DistanceConstraint":18,"./constraints/GearConstraint":19,"./constraints/LockConstraint":20,"./constraints/PrismaticConstraint":21,"./constraints/RevoluteConstraint":22,"./equations/AngleLockEquation":23,"./equations/ContactEquation":24,"./equations/Equation":25,"./equations/FrictionEquation":26,"./equations/RotationalVelocityEquation":28,"./events/EventEmitter":29,"./material/ContactMaterial":30,"./material/Material":31,"./math/vec2":33,"./objects/Body":34,"./objects/LinearSpring":35,"./objects/RotationalSpring":36,"./objects/Spring":37,"./shapes/Capsule":39,"./shapes/Circle":40,"./shapes/Convex":41,"./shapes/Heightfield":42,"./shapes/Line":43,"./shapes/Particle":44,"./shapes/Plane":45,"./shapes/Rectangle":46,"./shapes/Shape":47,"./solver/GSSolver":48,"./solver/Solver":49,"./utils/Utils":52,"./world/World":56,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,"buffer":1}],39:[function(_dereq_,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +},{"../package.json":6,"./collision/AABB":7,"./collision/Broadphase":8,"./collision/GridBroadphase":9,"./collision/NaiveBroadphase":10,"./collision/Narrowphase":11,"./collision/Ray":12,"./collision/RaycastResult":13,"./collision/SAPBroadphase":14,"./constraints/Constraint":15,"./constraints/DistanceConstraint":16,"./constraints/GearConstraint":17,"./constraints/LockConstraint":18,"./constraints/PrismaticConstraint":19,"./constraints/RevoluteConstraint":20,"./equations/AngleLockEquation":21,"./equations/ContactEquation":22,"./equations/Equation":23,"./equations/FrictionEquation":24,"./equations/RotationalVelocityEquation":26,"./events/EventEmitter":27,"./material/ContactMaterial":28,"./material/Material":29,"./math/vec2":31,"./objects/Body":32,"./objects/LinearSpring":33,"./objects/RotationalSpring":34,"./objects/Spring":35,"./shapes/Capsule":37,"./shapes/Circle":38,"./shapes/Convex":39,"./shapes/Heightfield":40,"./shapes/Line":41,"./shapes/Particle":42,"./shapes/Plane":43,"./shapes/Rectangle":44,"./shapes/Shape":45,"./solver/GSSolver":46,"./solver/Solver":47,"./utils/Utils":50,"./world/World":54}],37:[function(_dereq_,module,exports){ var Shape = _dereq_('./Shape') , vec2 = _dereq_('../math/vec2'); @@ -9679,8 +9212,13 @@ module.exports = Capsule; * @class Capsule * @constructor * @extends Shape - * @param {Number} [length] The distance between the end points - * @param {Number} [radius] Radius of the capsule + * @param {Number} [length=1] The distance between the end points + * @param {Number} [radius=1] Radius of the capsule + * @example + * var radius = 1; + * var length = 2; + * var capsuleShape = new Capsule(length, radius); + * body.addShape(capsuleShape); */ function Capsule(length, radius){ @@ -9699,6 +9237,7 @@ function Capsule(length, radius){ Shape.call(this,Shape.CAPSULE); } Capsule.prototype = new Shape(); +Capsule.prototype.constructor = Capsule; /** * Compute the mass moment of inertia of the Capsule. @@ -9757,9 +9296,7 @@ Capsule.prototype.computeAABB = function(out, position, angle){ vec2.add(out.upperBound, out.upperBound, position); }; -}).call(this,_dereq_("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},_dereq_("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/shapes/Capsule.js","/shapes") -},{"../math/vec2":33,"./Shape":47,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,"buffer":1}],40:[function(_dereq_,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +},{"../math/vec2":31,"./Shape":45}],38:[function(_dereq_,module,exports){ var Shape = _dereq_('./Shape') , vec2 = _dereq_('../math/vec2'); @@ -9771,6 +9308,11 @@ module.exports = Circle; * @extends Shape * @constructor * @param {number} [radius=1] The radius of this circle + * + * @example + * var radius = 1; + * var circleShape = new Circle(radius); + * body.addShape(circleShape); */ function Circle(radius){ @@ -9784,6 +9326,7 @@ function Circle(radius){ Shape.call(this,Shape.CIRCLE); } Circle.prototype = new Shape(); +Circle.prototype.constructor = Circle; /** * @method computeMomentOfInertia @@ -9827,9 +9370,7 @@ Circle.prototype.computeAABB = function(out, position, angle){ } }; -}).call(this,_dereq_("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},_dereq_("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/shapes/Circle.js","/shapes") -},{"../math/vec2":33,"./Shape":47,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,"buffer":1}],41:[function(_dereq_,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +},{"../math/vec2":31,"./Shape":45}],39:[function(_dereq_,module,exports){ var Shape = _dereq_('./Shape') , vec2 = _dereq_('../math/vec2') , polyk = _dereq_('../math/polyk') @@ -9843,7 +9384,12 @@ module.exports = Convex; * @constructor * @extends Shape * @param {Array} vertices An array of vertices that span this shape. Vertices are given in counter-clockwise (CCW) direction. - * @param {Array} axes An array of unit length vectors + * @param {Array} [axes] An array of unit length vectors, representing the symmetry axes in the convex. + * @example + * // Create a box + * var vertices = [[-1,-1], [1,-1], [1,1], [-1,1]]; + * var convexShape = new Convex(vertices); + * body.addShape(convexShape); */ function Convex(vertices, axes){ @@ -9928,6 +9474,7 @@ function Convex(vertices, axes){ } } Convex.prototype = new Shape(); +Convex.prototype.constructor = Convex; var tmpVec1 = vec2.create(); var tmpVec2 = vec2.create(); @@ -10151,9 +9698,7 @@ Convex.prototype.computeAABB = function(out, position, angle){ out.setFromPoints(this.vertices, position, angle, 0); }; -}).call(this,_dereq_("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},_dereq_("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/shapes/Convex.js","/shapes") -},{"../math/polyk":32,"../math/vec2":33,"./Shape":47,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,"buffer":1,"poly-decomp":9}],42:[function(_dereq_,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +},{"../math/polyk":30,"../math/vec2":31,"./Shape":45,"poly-decomp":5}],40:[function(_dereq_,module,exports){ var Shape = _dereq_('./Shape') , vec2 = _dereq_('../math/vec2') , Utils = _dereq_('../utils/Utils'); @@ -10236,6 +9781,7 @@ function Heightfield(data, options){ Shape.call(this,Shape.HEIGHTFIELD); } Heightfield.prototype = new Shape(); +Heightfield.prototype.constructor = Heightfield; /** * @method computeMomentOfInertia @@ -10273,9 +9819,7 @@ Heightfield.prototype.computeAABB = function(out, position, angle){ out.lowerBound[1] = -Number.MAX_VALUE; // Infinity }; -}).call(this,_dereq_("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},_dereq_("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/shapes/Heightfield.js","/shapes") -},{"../math/vec2":33,"../utils/Utils":52,"./Shape":47,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,"buffer":1}],43:[function(_dereq_,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +},{"../math/vec2":31,"../utils/Utils":50,"./Shape":45}],41:[function(_dereq_,module,exports){ var Shape = _dereq_('./Shape') , vec2 = _dereq_('../math/vec2'); @@ -10284,7 +9828,7 @@ module.exports = Line; /** * Line shape class. The line shape is along the x direction, and stretches from [-length/2, 0] to [length/2,0]. * @class Line - * @param {Number} length The total length of the line + * @param {Number} [length=1] The total length of the line * @extends Shape * @constructor */ @@ -10300,6 +9844,8 @@ function Line(length){ Shape.call(this,Shape.LINE); } Line.prototype = new Shape(); +Line.prototype.constructor = Line; + Line.prototype.computeMomentOfInertia = function(mass){ return mass * Math.pow(this.length,2) / 12; }; @@ -10324,9 +9870,7 @@ Line.prototype.computeAABB = function(out, position, angle){ }; -}).call(this,_dereq_("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},_dereq_("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/shapes/Line.js","/shapes") -},{"../math/vec2":33,"./Shape":47,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,"buffer":1}],44:[function(_dereq_,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +},{"../math/vec2":31,"./Shape":45}],42:[function(_dereq_,module,exports){ var Shape = _dereq_('./Shape') , vec2 = _dereq_('../math/vec2'); @@ -10342,6 +9886,8 @@ function Particle(){ Shape.call(this,Shape.PARTICLE); } Particle.prototype = new Shape(); +Particle.prototype.constructor = Particle; + Particle.prototype.computeMomentOfInertia = function(mass){ return 0; // Can't rotate a particle }; @@ -10361,9 +9907,7 @@ Particle.prototype.computeAABB = function(out, position, angle){ vec2.copy(out.upperBound, position); }; -}).call(this,_dereq_("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},_dereq_("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/shapes/Particle.js","/shapes") -},{"../math/vec2":33,"./Shape":47,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,"buffer":1}],45:[function(_dereq_,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +},{"../math/vec2":31,"./Shape":45}],43:[function(_dereq_,module,exports){ var Shape = _dereq_('./Shape') , vec2 = _dereq_('../math/vec2') , Utils = _dereq_('../utils/Utils'); @@ -10380,6 +9924,7 @@ function Plane(){ Shape.call(this,Shape.PLANE); } Plane.prototype = new Shape(); +Plane.prototype.constructor = Plane; /** * Compute moment of inertia @@ -10441,9 +9986,7 @@ Plane.prototype.updateArea = function(){ }; -}).call(this,_dereq_("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},_dereq_("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/shapes/Plane.js","/shapes") -},{"../math/vec2":33,"../utils/Utils":52,"./Shape":47,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,"buffer":1}],46:[function(_dereq_,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +},{"../math/vec2":31,"../utils/Utils":50,"./Shape":45}],44:[function(_dereq_,module,exports){ var vec2 = _dereq_('../math/vec2') , Shape = _dereq_('./Shape') , Convex = _dereq_('./Convex'); @@ -10454,8 +9997,8 @@ module.exports = Rectangle; * Rectangle shape class. * @class Rectangle * @constructor - * @param {Number} width Width - * @param {Number} height Height + * @param {Number} [width=1] Width + * @param {Number} [height=1] Height * @extends Convex */ function Rectangle(width, height){ @@ -10485,6 +10028,7 @@ function Rectangle(width, height){ this.type = Shape.RECTANGLE; } Rectangle.prototype = new Convex([]); +Rectangle.prototype.constructor = Rectangle; /** * Compute moment of inertia @@ -10528,9 +10072,7 @@ Rectangle.prototype.updateArea = function(){ }; -}).call(this,_dereq_("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},_dereq_("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/shapes/Rectangle.js","/shapes") -},{"../math/vec2":33,"./Convex":41,"./Shape":47,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,"buffer":1}],47:[function(_dereq_,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +},{"../math/vec2":31,"./Convex":39,"./Shape":45}],45:[function(_dereq_,module,exports){ module.exports = Shape; /** @@ -10602,6 +10144,12 @@ function Shape(type){ */ this.collisionGroup = 1; + /** + * Whether to produce contact forces when in contact with other bodies. Note that contacts will be generated, but they will be disabled. That means that this shape will move through other body shapes, but it will still trigger contact events, etc. + * @property {Boolean} collisionResponse + */ + this.collisionResponse = true; + /** * Collision mask of this shape. See .collisionGroup. * @property collisionMask @@ -10723,9 +10271,7 @@ Shape.prototype.computeAABB = function(out, position, angle){ // To be implemented in each subclass }; -}).call(this,_dereq_("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},_dereq_("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/shapes/Shape.js","/shapes") -},{"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,"buffer":1}],48:[function(_dereq_,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +},{}],46:[function(_dereq_,module,exports){ var vec2 = _dereq_('../math/vec2') , Solver = _dereq_('./Solver') , Utils = _dereq_('../utils/Utils') @@ -10788,6 +10334,7 @@ function GSSolver(options){ this.usedIterations = 0; } GSSolver.prototype = new Solver(); +GSSolver.prototype.constructor = GSSolver; function setArrayZero(array){ var l = array.length; @@ -10969,9 +10516,7 @@ GSSolver.iterateEquation = function(j,eq,eps,Bs,invCs,lambda,useZeroRHS,dt,iter) return deltalambda; }; -}).call(this,_dereq_("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},_dereq_("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/solver/GSSolver.js","/solver") -},{"../equations/FrictionEquation":26,"../math/vec2":33,"../utils/Utils":52,"./Solver":49,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,"buffer":1}],49:[function(_dereq_,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +},{"../equations/FrictionEquation":24,"../math/vec2":31,"../utils/Utils":50,"./Solver":47}],47:[function(_dereq_,module,exports){ var Utils = _dereq_('../utils/Utils') , EventEmitter = _dereq_('../events/EventEmitter'); @@ -11006,6 +10551,7 @@ function Solver(options,type){ this.equationSortFunction = options.equationSortFunction || false; } Solver.prototype = new EventEmitter(); +Solver.prototype.constructor = Solver; /** * Method to be implemented in each subclass @@ -11105,9 +10651,7 @@ Solver.prototype.removeAllEquations = function(){ Solver.GS = 1; Solver.ISLAND = 2; -}).call(this,_dereq_("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},_dereq_("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/solver/Solver.js","/solver") -},{"../events/EventEmitter":29,"../utils/Utils":52,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,"buffer":1}],50:[function(_dereq_,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +},{"../events/EventEmitter":27,"../utils/Utils":50}],48:[function(_dereq_,module,exports){ var TupleDictionary = _dereq_('./TupleDictionary'); var Utils = _dereq_('./Utils'); @@ -11323,9 +10867,7 @@ OverlapKeeperRecord.prototype.set = function(bodyA, shapeA, bodyB, shapeB){ OverlapKeeperRecord.call(this, bodyA, shapeA, bodyB, shapeB); }; -}).call(this,_dereq_("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},_dereq_("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/utils/OverlapKeeper.js","/utils") -},{"./TupleDictionary":51,"./Utils":52,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,"buffer":1}],51:[function(_dereq_,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +},{"./TupleDictionary":49,"./Utils":50}],49:[function(_dereq_,module,exports){ var Utils = _dereq_('./Utils'); module.exports = TupleDictionary; @@ -11447,9 +10989,7 @@ TupleDictionary.prototype.copy = function(dict) { } }; -}).call(this,_dereq_("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},_dereq_("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/utils/TupleDictionary.js","/utils") -},{"./Utils":52,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,"buffer":1}],52:[function(_dereq_,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +},{"./Utils":50}],50:[function(_dereq_,module,exports){ /* global P2_ARRAY_TYPE */ module.exports = Utils; @@ -11544,9 +11084,7 @@ Utils.defaults = function(options, defaults){ return options; }; -}).call(this,_dereq_("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},_dereq_("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/utils/Utils.js","/utils") -},{"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,"buffer":1}],53:[function(_dereq_,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +},{}],51:[function(_dereq_,module,exports){ var Body = _dereq_('../objects/Body'); module.exports = Island; @@ -11633,9 +11171,7 @@ Island.prototype.sleep = function(){ return true; }; -}).call(this,_dereq_("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},_dereq_("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/world/Island.js","/world") -},{"../objects/Body":34,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,"buffer":1}],54:[function(_dereq_,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +},{"../objects/Body":32}],52:[function(_dereq_,module,exports){ var vec2 = _dereq_('../math/vec2') , Island = _dereq_('./Island') , IslandNode = _dereq_('./IslandNode') @@ -11822,9 +11358,7 @@ IslandManager.prototype.split = function(world){ return islands; }; -}).call(this,_dereq_("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},_dereq_("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/world/IslandManager.js","/world") -},{"../math/vec2":33,"../objects/Body":34,"./Island":53,"./IslandNode":55,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,"buffer":1}],55:[function(_dereq_,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +},{"../math/vec2":31,"../objects/Body":32,"./Island":51,"./IslandNode":53}],53:[function(_dereq_,module,exports){ module.exports = IslandNode; /** @@ -11872,15 +11406,14 @@ IslandNode.prototype.reset = function(){ this.body = null; }; -}).call(this,_dereq_("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},_dereq_("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/world/IslandNode.js","/world") -},{"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,"buffer":1}],56:[function(_dereq_,module,exports){ -(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__filename,__dirname){ +},{}],54:[function(_dereq_,module,exports){ /* global performance */ /*jshint -W020 */ var GSSolver = _dereq_('../solver/GSSolver') , Solver = _dereq_('../solver/Solver') , NaiveBroadphase = _dereq_('../collision/NaiveBroadphase') +, Ray = _dereq_('../collision/Ray') , vec2 = _dereq_('../math/vec2') , Circle = _dereq_('../shapes/Circle') , Rectangle = _dereq_('../shapes/Rectangle') @@ -12041,7 +11574,7 @@ function World(options){ * @property broadphase * @type {Broadphase} */ - this.broadphase = options.broadphase || new NaiveBroadphase(); + this.broadphase = options.broadphase || new SAPBroadphase(); this.broadphase.setWorld(this); /** @@ -12273,6 +11806,7 @@ function World(options){ this.overlapKeeper = new OverlapKeeper(); } World.prototype = new Object(EventEmitter.prototype); +World.prototype.constructor = World; /** * Never deactivate bodies. @@ -12483,9 +12017,7 @@ World.prototype.internalStep = function(dt){ // Update approximate friction gravity. if(this.useWorldGravityAsFrictionGravity){ var gravityLen = vec2.length(this.gravity); - if(gravityLen === 0 && this.useFrictionGravityOnZeroGravity){ - // Leave friction gravity as it is. - } else { + if(!(gravityLen === 0 && this.useFrictionGravityOnZeroGravity)){ // Nonzero gravity. Use it. this.frictionGravity = gravityLen; } @@ -12603,7 +12135,7 @@ World.prototype.internalStep = function(dt){ e.shapeA = data.shapeA; e.shapeB = data.shapeB; e.bodyA = data.bodyA; - e.bodyB = data.bodyA; + e.bodyB = data.bodyB; this.emit(e); } } @@ -12661,7 +12193,7 @@ World.prototype.internalStep = function(dt){ var body = bodies[i]; if(body.sleepState !== Body.SLEEPING && body.type !== Body.STATIC){ - World.integrateBody(body,dt); + body.integrate(dt); } } @@ -12725,42 +12257,6 @@ World.prototype.internalStep = function(dt){ this.emit(this.postStepEvent); }; -var ib_fhMinv = vec2.create(); -var ib_velodt = vec2.create(); - -/** - * Move a body forward in time. - * @static - * @method integrateBody - * @param {Body} body - * @param {Number} dt - * @todo Move to Body.prototype? - */ -World.integrateBody = function(body,dt){ - var minv = body.invMass, - f = body.force, - pos = body.position, - velo = body.velocity; - - // Save old position - vec2.copy(body.previousPosition, body.position); - body.previousAngle = body.angle; - - // Angular step - if(!body.fixedRotation){ - body.angularVelocity += body.angularForce * body.invInertia * dt; - body.angle += body.angularVelocity * dt; - } - - // Linear step - vec2.scale(ib_fhMinv,f,dt*minv); - vec2.add(velo,ib_fhMinv,velo); - vec2.scale(ib_velodt,velo,dt); - vec2.add(pos,pos,ib_velodt); - - body.aabbNeedsUpdate = true; -}; - /** * Runs narrowphase for the shape pair i and j. * @method runNarrowphase @@ -12808,6 +12304,7 @@ World.prototype.runNarrowphase = function(np,bi,si,xi,ai,bj,sj,xj,aj,cm,glen){ np.stiffness = cm.stiffness; np.relaxation = cm.relaxation; np.contactSkinSize = cm.contactSkinSize; + np.enabledEquations = bi.collisionResponse && bj.collisionResponse && si.collisionResponse && sj.collisionResponse; var resolver = np[si.type | sj.type], numContacts = 0; @@ -13200,7 +12697,70 @@ World.prototype.setGlobalRelaxation = function(relaxation){ }); }; -}).call(this,_dereq_("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},_dereq_("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/world/World.js","/world") -},{"../../package.json":10,"../collision/Broadphase":12,"../collision/NaiveBroadphase":14,"../collision/Narrowphase":15,"../collision/SAPBroadphase":16,"../constraints/Constraint":17,"../constraints/DistanceConstraint":18,"../constraints/GearConstraint":19,"../constraints/LockConstraint":20,"../constraints/PrismaticConstraint":21,"../constraints/RevoluteConstraint":22,"../events/EventEmitter":29,"../material/ContactMaterial":30,"../material/Material":31,"../math/vec2":33,"../objects/Body":34,"../objects/LinearSpring":35,"../objects/RotationalSpring":36,"../shapes/Capsule":39,"../shapes/Circle":40,"../shapes/Convex":41,"../shapes/Line":43,"../shapes/Particle":44,"../shapes/Plane":45,"../shapes/Rectangle":46,"../shapes/Shape":47,"../solver/GSSolver":48,"../solver/Solver":49,"../utils/OverlapKeeper":50,"../utils/Utils":52,"./IslandManager":54,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,"buffer":1}]},{},[38]) -(38) +var tmpRay = new Ray(); + +/** + * Ray cast against all bodies. The provided callback will be executed for each hit with a RaycastResult as single argument. + * @method raycastAll + * @param {Vec3} from + * @param {Vec3} to + * @param {Object} options + * @param {number} [options.collisionMask=-1] + * @param {number} [options.collisionGroup=-1] + * @param {boolean} [options.skipBackfaces=false] + * @param {boolean} [options.checkCollisionResponse=true] + * @param {Function} callback + * @return {boolean} True if any body was hit. + */ +World.prototype.raycastAll = function(from, to, options, callback){ + options.mode = Ray.ALL; + options.from = from; + options.to = to; + options.callback = callback; + return tmpRay.intersectWorld(this, options); +}; + +/** + * Ray cast, and stop at the first result. Note that the order is random - but the method is fast. + * @method raycastAny + * @param {Vec3} from + * @param {Vec3} to + * @param {Object} options + * @param {number} [options.collisionMask=-1] + * @param {number} [options.collisionGroup=-1] + * @param {boolean} [options.skipBackfaces=false] + * @param {boolean} [options.checkCollisionResponse=true] + * @param {RaycastResult} result + * @return {boolean} True if any body was hit. + */ +World.prototype.raycastAny = function(from, to, options, result){ + options.mode = Ray.ANY; + options.from = from; + options.to = to; + options.result = result; + return tmpRay.intersectWorld(this, options); +}; + +/** + * Ray cast, and return information of the closest hit. + * @method raycastClosest + * @param {Vec3} from + * @param {Vec3} to + * @param {Object} options + * @param {number} [options.collisionMask=-1] + * @param {number} [options.collisionGroup=-1] + * @param {boolean} [options.skipBackfaces=false] + * @param {boolean} [options.checkCollisionResponse=true] + * @param {RaycastResult} result + * @return {boolean} True if any body was hit. + */ +World.prototype.raycastClosest = function(from, to, options, result){ + options.mode = Ray.CLOSEST; + options.from = from; + options.to = to; + options.result = result; + return tmpRay.intersectWorld(this, options); +}; +},{"../../package.json":6,"../collision/Broadphase":8,"../collision/NaiveBroadphase":10,"../collision/Narrowphase":11,"../collision/Ray":12,"../collision/SAPBroadphase":14,"../constraints/Constraint":15,"../constraints/DistanceConstraint":16,"../constraints/GearConstraint":17,"../constraints/LockConstraint":18,"../constraints/PrismaticConstraint":19,"../constraints/RevoluteConstraint":20,"../events/EventEmitter":27,"../material/ContactMaterial":28,"../material/Material":29,"../math/vec2":31,"../objects/Body":32,"../objects/LinearSpring":33,"../objects/RotationalSpring":34,"../shapes/Capsule":37,"../shapes/Circle":38,"../shapes/Convex":39,"../shapes/Line":41,"../shapes/Particle":42,"../shapes/Plane":43,"../shapes/Rectangle":44,"../shapes/Shape":45,"../solver/GSSolver":46,"../solver/Solver":47,"../utils/OverlapKeeper":48,"../utils/Utils":50,"./IslandManager":52}]},{},[36]) +(36) });; \ No newline at end of file diff --git a/build/p2.min.js b/build/p2.min.js index 1f1b2107..2f02593a 100644 --- a/build/p2.min.js +++ b/build/p2.min.js @@ -1,18 +1,18 @@ /** * The MIT License (MIT) - * - * Copyright (c) 2013 p2.js authors - * + * + * Copyright (c) 2015 p2.js authors + * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -21,8 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -!function(a){if("object"==typeof exports)module.exports=a();else if("function"==typeof define&&define.amd)define(a);else{var b;"undefined"!=typeof window?b=window:"undefined"!=typeof global?b=global:"undefined"!=typeof self&&(b=self),b.p2=a()}}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;gh;h++)g[h]=e.isBuffer(a)?a.readUInt8(h):a[h];else if("string"===d)g.write(a,0,b);else if("number"===d&&!e._useTypedArrays&&!c)for(h=0;f>h;h++)g[h]=0;return g}function f(a,b,c,d){c=Number(c)||0;var f=a.length-c;d?(d=Number(d),d>f&&(d=f)):d=f;var g=b.length;T(g%2===0,"Invalid hex string"),d>g/2&&(d=g/2);for(var h=0;d>h;h++){var i=parseInt(b.substr(2*h,2),16);T(!isNaN(i),"Invalid hex string"),a[c+h]=i}return e._charsWritten=2*h,h}function g(a,b,c,d){var f=e._charsWritten=O(K(b),a,c,d);return f}function h(a,b,c,d){var f=e._charsWritten=O(L(b),a,c,d);return f}function i(a,b,c,d){return h(a,b,c,d)}function j(a,b,c,d){var f=e._charsWritten=O(N(b),a,c,d);return f}function k(a,b,c,d){var f=e._charsWritten=O(M(b),a,c,d);return f}function l(a,b,c){return U.fromByteArray(0===b&&c===a.length?a:a.slice(b,c))}function m(a,b,c){var d="",e="";c=Math.min(a.length,c);for(var f=b;c>f;f++)a[f]<=127?(d+=P(e)+String.fromCharCode(a[f]),e=""):e+="%"+a[f].toString(16);return d+P(e)}function n(a,b,c){var d="";c=Math.min(a.length,c);for(var e=b;c>e;e++)d+=String.fromCharCode(a[e]);return d}function o(a,b,c){return n(a,b,c)}function p(a,b,c){var d=a.length;(!b||0>b)&&(b=0),(!c||0>c||c>d)&&(c=d);for(var e="",f=b;c>f;f++)e+=J(a[f]);return e}function q(a,b,c){for(var d=a.slice(b,c),e="",f=0;f=e)){var f;return c?(f=a[b],e>b+1&&(f|=a[b+1]<<8)):(f=a[b]<<8,e>b+1&&(f|=a[b+1])),f}}function s(a,b,c,d){d||(T("boolean"==typeof c,"missing or invalid endian"),T(void 0!==b&&null!==b,"missing offset"),T(b+3=e)){var f;return c?(e>b+2&&(f=a[b+2]<<16),e>b+1&&(f|=a[b+1]<<8),f|=a[b],e>b+3&&(f+=a[b+3]<<24>>>0)):(e>b+1&&(f=a[b+1]<<16),e>b+2&&(f|=a[b+2]<<8),e>b+3&&(f|=a[b+3]),f+=a[b]<<24>>>0),f}}function t(a,b,c,d){d||(T("boolean"==typeof c,"missing or invalid endian"),T(void 0!==b&&null!==b,"missing offset"),T(b+1=e)){var f=r(a,b,c,!0),g=32768&f;return g?-1*(65535-f+1):f}}function u(a,b,c,d){d||(T("boolean"==typeof c,"missing or invalid endian"),T(void 0!==b&&null!==b,"missing offset"),T(b+3=e)){var f=s(a,b,c,!0),g=2147483648&f;return g?-1*(4294967295-f+1):f}}function v(a,b,c,d){return d||(T("boolean"==typeof c,"missing or invalid endian"),T(b+3=f))for(var g=0,h=Math.min(f-c,2);h>g;g++)a[c+g]=(b&255<<8*(d?g:1-g))>>>8*(d?g:1-g)}function y(a,b,c,d,e){e||(T(void 0!==b&&null!==b,"missing value"),T("boolean"==typeof d,"missing or invalid endian"),T(void 0!==c&&null!==c,"missing offset"),T(c+3=f))for(var g=0,h=Math.min(f-c,4);h>g;g++)a[c+g]=b>>>8*(d?g:3-g)&255}function z(a,b,c,d,e){e||(T(void 0!==b&&null!==b,"missing value"),T("boolean"==typeof d,"missing or invalid endian"),T(void 0!==c&&null!==c,"missing offset"),T(c+1=f||(b>=0?x(a,b,c,d,e):x(a,65535+b+1,c,d,e))}function A(a,b,c,d,e){e||(T(void 0!==b&&null!==b,"missing value"),T("boolean"==typeof d,"missing or invalid endian"),T(void 0!==c&&null!==c,"missing offset"),T(c+3=f||(b>=0?y(a,b,c,d,e):y(a,4294967295+b+1,c,d,e))}function B(a,b,c,d,e){e||(T(void 0!==b&&null!==b,"missing value"),T("boolean"==typeof d,"missing or invalid endian"),T(void 0!==c&&null!==c,"missing offset"),T(c+3=f||V.write(a,b,c,d,23,4)}function C(a,b,c,d,e){e||(T(void 0!==b&&null!==b,"missing value"),T("boolean"==typeof d,"missing or invalid endian"),T(void 0!==c&&null!==c,"missing offset"),T(c+7=f||V.write(a,b,c,d,52,8)}function D(a){return a.trim?a.trim():a.replace(/^\s+|\s+$/g,"")}function E(a){return a._isBuffer=!0,a._get=a.get,a._set=a.set,a.get=W.get,a.set=W.set,a.write=W.write,a.toString=W.toString,a.toLocaleString=W.toString,a.toJSON=W.toJSON,a.copy=W.copy,a.slice=W.slice,a.readUInt8=W.readUInt8,a.readUInt16LE=W.readUInt16LE,a.readUInt16BE=W.readUInt16BE,a.readUInt32LE=W.readUInt32LE,a.readUInt32BE=W.readUInt32BE,a.readInt8=W.readInt8,a.readInt16LE=W.readInt16LE,a.readInt16BE=W.readInt16BE,a.readInt32LE=W.readInt32LE,a.readInt32BE=W.readInt32BE,a.readFloatLE=W.readFloatLE,a.readFloatBE=W.readFloatBE,a.readDoubleLE=W.readDoubleLE,a.readDoubleBE=W.readDoubleBE,a.writeUInt8=W.writeUInt8,a.writeUInt16LE=W.writeUInt16LE,a.writeUInt16BE=W.writeUInt16BE,a.writeUInt32LE=W.writeUInt32LE,a.writeUInt32BE=W.writeUInt32BE,a.writeInt8=W.writeInt8,a.writeInt16LE=W.writeInt16LE,a.writeInt16BE=W.writeInt16BE,a.writeInt32LE=W.writeInt32LE,a.writeInt32BE=W.writeInt32BE,a.writeFloatLE=W.writeFloatLE,a.writeFloatBE=W.writeFloatBE,a.writeDoubleLE=W.writeDoubleLE,a.writeDoubleBE=W.writeDoubleBE,a.fill=W.fill,a.inspect=W.inspect,a.toArrayBuffer=W.toArrayBuffer,a}function F(a,b,c){return"number"!=typeof a?c:(a=~~a,a>=b?b:a>=0?a:(a+=b,a>=0?a:0))}function G(a){return a=~~Math.ceil(+a),0>a?0:a}function H(a){return(Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)})(a)}function I(a){return H(a)||e.isBuffer(a)||a&&"object"==typeof a&&"number"==typeof a.length}function J(a){return 16>a?"0"+a.toString(16):a.toString(16)}function K(a){for(var b=[],c=0;c=d)b.push(a.charCodeAt(c));else{var e=c;d>=55296&&57343>=d&&c++;for(var f=encodeURIComponent(a.slice(e,c+1)).substr(1).split("%"),g=0;g>8,d=b%256,e.push(d),e.push(c);return e}function N(a){return U.toByteArray(a)}function O(a,b,c,d){for(var e=0;d>e&&!(e+c>=b.length||e>=a.length);e++)b[e+c]=a[e];return e}function P(a){try{return decodeURIComponent(a)}catch(b){return String.fromCharCode(65533)}}function Q(a,b){T("number"==typeof a,"cannot write a non-number as a number"),T(a>=0,"specified a negative value for writing an unsigned value"),T(b>=a,"value is larger than maximum value for type"),T(Math.floor(a)===a,"value has a fractional component")}function R(a,b,c){T("number"==typeof a,"cannot write a non-number as a number"),T(b>=a,"value larger than maximum allowed value"),T(a>=c,"value smaller than minimum allowed value"),T(Math.floor(a)===a,"value has a fractional component")}function S(a,b,c){T("number"==typeof a,"cannot write a non-number as a number"),T(b>=a,"value larger than maximum allowed value"),T(a>=c,"value smaller than minimum allowed value")}function T(a,b){if(!a)throw new Error(b||"Failed assertion")}var U=a("base64-js"),V=a("ieee754");c.Buffer=e,c.SlowBuffer=e,c.INSPECT_MAX_BYTES=50,e.poolSize=8192,e._useTypedArrays=function(){if("function"!=typeof Uint8Array||"function"!=typeof ArrayBuffer)return!1;try{var a=new Uint8Array(0);return a.foo=function(){return 42},42===a.foo()&&"function"==typeof a.subarray}catch(b){return!1}}(),e.isEncoding=function(a){switch(String(a).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},e.isBuffer=function(a){return!(null===a||void 0===a||!a._isBuffer)},e.byteLength=function(a,b){var c;switch(a+="",b||"utf8"){case"hex":c=a.length/2;break;case"utf8":case"utf-8":c=K(a).length;break;case"ascii":case"binary":case"raw":c=a.length;break;case"base64":c=N(a).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":c=2*a.length;break;default:throw new Error("Unknown encoding")}return c},e.concat=function(a,b){if(T(H(a),"Usage: Buffer.concat(list, [totalLength])\nlist should be an Array."),0===a.length)return new e(0);if(1===a.length)return a[0];var c;if("number"!=typeof b)for(b=0,c=0;cl&&(c=l)):c=l,d=String(d||"utf8").toLowerCase();var m;switch(d){case"hex":m=f(this,a,b,c);break;case"utf8":case"utf-8":m=g(this,a,b,c);break;case"ascii":m=h(this,a,b,c);break;case"binary":m=i(this,a,b,c);break;case"base64":m=j(this,a,b,c);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":m=k(this,a,b,c);break;default:throw new Error("Unknown encoding")}return m},e.prototype.toString=function(a,b,c){var d=this;if(a=String(a||"utf8").toLowerCase(),b=Number(b)||0,c=void 0!==c?Number(c):c=d.length,c===b)return"";var e;switch(a){case"hex":e=p(d,b,c);break;case"utf8":case"utf-8":e=m(d,b,c);break;case"ascii":e=n(d,b,c);break;case"binary":e=o(d,b,c);break;case"base64":e=l(d,b,c);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":e=q(d,b,c);break;default:throw new Error("Unknown encoding")}return e},e.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},e.prototype.copy=function(a,b,c,d){var e=this;if(c||(c=0),d||0===d||(d=this.length),b||(b=0),d!==c&&0!==a.length&&0!==e.length){T(d>=c,"sourceEnd < sourceStart"),T(b>=0&&b=0&&c=0&&d<=e.length,"sourceEnd out of bounds"),d>this.length&&(d=this.length),a.length-bf;f++)a[f+b]=this[f+c]}},e.prototype.slice=function(a,b){var c=this.length;if(a=F(a,c,0),b=F(b,c,c),e._useTypedArrays)return E(this.subarray(a,b));for(var d=b-a,f=new e(d,void 0,!0),g=0;d>g;g++)f[g]=this[g+a];return f},e.prototype.get=function(a){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(a)},e.prototype.set=function(a,b){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(a,b)},e.prototype.readUInt8=function(a,b){return b||(T(void 0!==a&&null!==a,"missing offset"),T(a=this.length?void 0:this[a]},e.prototype.readUInt16LE=function(a,b){return r(this,a,!0,b)},e.prototype.readUInt16BE=function(a,b){return r(this,a,!1,b)},e.prototype.readUInt32LE=function(a,b){return s(this,a,!0,b)},e.prototype.readUInt32BE=function(a,b){return s(this,a,!1,b)},e.prototype.readInt8=function(a,b){if(b||(T(void 0!==a&&null!==a,"missing offset"),T(a=this.length)){var c=128&this[a];return c?-1*(255-this[a]+1):this[a]}},e.prototype.readInt16LE=function(a,b){return t(this,a,!0,b)},e.prototype.readInt16BE=function(a,b){return t(this,a,!1,b)},e.prototype.readInt32LE=function(a,b){return u(this,a,!0,b)},e.prototype.readInt32BE=function(a,b){return u(this,a,!1,b)},e.prototype.readFloatLE=function(a,b){return v(this,a,!0,b)},e.prototype.readFloatBE=function(a,b){return v(this,a,!1,b)},e.prototype.readDoubleLE=function(a,b){return w(this,a,!0,b)},e.prototype.readDoubleBE=function(a,b){return w(this,a,!1,b)},e.prototype.writeUInt8=function(a,b,c){c||(T(void 0!==a&&null!==a,"missing value"),T(void 0!==b&&null!==b,"missing offset"),T(b=this.length||(this[b]=a)},e.prototype.writeUInt16LE=function(a,b,c){x(this,a,b,!0,c)},e.prototype.writeUInt16BE=function(a,b,c){x(this,a,b,!1,c)},e.prototype.writeUInt32LE=function(a,b,c){y(this,a,b,!0,c)},e.prototype.writeUInt32BE=function(a,b,c){y(this,a,b,!1,c)},e.prototype.writeInt8=function(a,b,c){c||(T(void 0!==a&&null!==a,"missing value"),T(void 0!==b&&null!==b,"missing offset"),T(b=this.length||(a>=0?this.writeUInt8(a,b,c):this.writeUInt8(255+a+1,b,c))},e.prototype.writeInt16LE=function(a,b,c){z(this,a,b,!0,c)},e.prototype.writeInt16BE=function(a,b,c){z(this,a,b,!1,c)},e.prototype.writeInt32LE=function(a,b,c){A(this,a,b,!0,c)},e.prototype.writeInt32BE=function(a,b,c){A(this,a,b,!1,c)},e.prototype.writeFloatLE=function(a,b,c){B(this,a,b,!0,c)},e.prototype.writeFloatBE=function(a,b,c){B(this,a,b,!1,c)},e.prototype.writeDoubleLE=function(a,b,c){C(this,a,b,!0,c)},e.prototype.writeDoubleBE=function(a,b,c){C(this,a,b,!1,c)},e.prototype.fill=function(a,b,c){if(a||(a=0),b||(b=0),c||(c=this.length),"string"==typeof a&&(a=a.charCodeAt(0)),T("number"==typeof a&&!isNaN(a),"value is not a number"),T(c>=b,"end < start"),c!==b&&0!==this.length){T(b>=0&&b=0&&c<=this.length,"end out of bounds");for(var d=b;c>d;d++)this[d]=a}},e.prototype.inspect=function(){for(var a=[],b=this.length,d=0;b>d;d++)if(a[d]=J(this[d]),d===c.INSPECT_MAX_BYTES){a[d+1]="...";break}return""},e.prototype.toArrayBuffer=function(){if("function"==typeof Uint8Array){if(e._useTypedArrays)return new e(this).buffer;for(var a=new Uint8Array(this.length),b=0,c=a.length;c>b;b+=1)a[b]=this[b];return a.buffer}throw new Error("Buffer.toArrayBuffer not supported in this browser")};var W=e.prototype}).call(this,a("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/grunt-browserify/node_modules/browserify/node_modules/buffer/index.js","/../node_modules/grunt-browserify/node_modules/browserify/node_modules/buffer")},{"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,"base64-js":2,buffer:1,ieee754:3}],2:[function(a,b){(function(){var a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(){"use strict";function c(a){var b=a.charCodeAt(0);return b===g?62:b===h?63:i>b?-1:i+10>b?b-i+26+26:k+26>b?b-k:j+26>b?b-j+26:void 0}function d(a){function b(a){j[l++]=a}var d,e,g,h,i,j;if(a.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var k=a.length;i="="===a.charAt(k-2)?2:"="===a.charAt(k-1)?1:0,j=new f(3*a.length/4-i),g=i>0?a.length-4:a.length;var l=0;for(d=0,e=0;g>d;d+=4,e+=3)h=c(a.charAt(d))<<18|c(a.charAt(d+1))<<12|c(a.charAt(d+2))<<6|c(a.charAt(d+3)),b((16711680&h)>>16),b((65280&h)>>8),b(255&h);return 2===i?(h=c(a.charAt(d))<<2|c(a.charAt(d+1))>>4,b(255&h)):1===i&&(h=c(a.charAt(d))<<10|c(a.charAt(d+1))<<4|c(a.charAt(d+2))>>2,b(h>>8&255),b(255&h)),j}function e(b){function c(b){return a.charAt(b)}function d(a){return c(a>>18&63)+c(a>>12&63)+c(a>>6&63)+c(63&a)}var e,f,g,h=b.length%3,i="";for(e=0,g=b.length-h;g>e;e+=3)f=(b[e]<<16)+(b[e+1]<<8)+b[e+2],i+=d(f);switch(h){case 1:f=b[b.length-1],i+=c(f>>2),i+=c(f<<4&63),i+="==";break;case 2:f=(b[b.length-2]<<8)+b[b.length-1],i+=c(f>>10),i+=c(f>>4&63),i+=c(f<<2&63),i+="="}return i}var f="undefined"!=typeof Uint8Array?Uint8Array:Array,g=("0".charCodeAt(0),"+".charCodeAt(0)),h="/".charCodeAt(0),i="0".charCodeAt(0),j="a".charCodeAt(0),k="A".charCodeAt(0);b.exports.toByteArray=d,b.exports.fromByteArray=e}()}).call(this,a("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/grunt-browserify/node_modules/browserify/node_modules/buffer/node_modules/base64-js/lib/b64.js","/../node_modules/grunt-browserify/node_modules/browserify/node_modules/buffer/node_modules/base64-js/lib")},{"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,buffer:1}],3:[function(a,b,c){(function(){c.read=function(a,b,c,d,e){var f,g,h=8*e-d-1,i=(1<>1,k=-7,l=c?e-1:0,m=c?-1:1,n=a[b+l];for(l+=m,f=n&(1<<-k)-1,n>>=-k,k+=h;k>0;f=256*f+a[b+l],l+=m,k-=8);for(g=f&(1<<-k)-1,f>>=-k,k+=d;k>0;g=256*g+a[b+l],l+=m,k-=8);if(0===f)f=1-j;else{if(f===i)return g?0/0:1/0*(n?-1:1);g+=Math.pow(2,d),f-=j}return(n?-1:1)*g*Math.pow(2,f-d)},c.write=function(a,b,c,d,e,f){var g,h,i,j=8*f-e-1,k=(1<>1,m=23===e?Math.pow(2,-24)-Math.pow(2,-77):0,n=d?0:f-1,o=d?1:-1,p=0>b||0===b&&0>1/b?1:0;for(b=Math.abs(b),isNaN(b)||1/0===b?(h=isNaN(b)?1:0,g=k):(g=Math.floor(Math.log(b)/Math.LN2),b*(i=Math.pow(2,-g))<1&&(g--,i*=2),b+=g+l>=1?m/i:m*Math.pow(2,1-l),b*i>=2&&(g++,i/=2),g+l>=k?(h=0,g=k):g+l>=1?(h=(b*i-1)*Math.pow(2,e),g+=l):(h=b*Math.pow(2,l-1)*Math.pow(2,e),g=0));e>=8;a[c+n]=255&h,n+=o,h/=256,e-=8);for(g=g<0;a[c+n]=255&g,n+=o,g/=256,j-=8);a[c+n-o]|=128*p}}).call(this,a("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/grunt-browserify/node_modules/browserify/node_modules/buffer/node_modules/ieee754/index.js","/../node_modules/grunt-browserify/node_modules/browserify/node_modules/buffer/node_modules/ieee754")},{"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,buffer:1}],4:[function(a,b){(function(a){function c(){}var a=b.exports={};a.nextTick=function(){var a="undefined"!=typeof window&&window.setImmediate,b="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(a)return function(a){return window.setImmediate(a)};if(b){var c=[];return window.addEventListener("message",function(a){var b=a.source;if((b===window||null===b)&&"process-tick"===a.data&&(a.stopPropagation(),c.length>0)){var d=c.shift();d()}},!0),function(a){c.push(a),window.postMessage("process-tick","*")}}return function(a){setTimeout(a,0)}}(),a.title="browser",a.browser=!0,a.env={},a.argv=[],a.on=c,a.once=c,a.off=c,a.emit=c,a.binding=function(){throw new Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(){throw new Error("process.chdir is not supported")}}).call(this,a("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js","/../node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process")},{"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,buffer:1}],5:[function(a,b){(function(){function c(){}var d=a("./Scalar");b.exports=c,c.lineInt=function(a,b,c){c=c||0;var e,f,g,h,i,j,k,l=[0,0];return e=a[1][1]-a[0][1],f=a[0][0]-a[1][0],g=e*a[0][0]+f*a[0][1],h=b[1][1]-b[0][1],i=b[0][0]-b[1][0],j=h*b[0][0]+i*b[0][1],k=e*i-h*f,d.eq(k,0,c)||(l[0]=(i*g-f*j)/k,l[1]=(e*j-h*g)/k),l},c.segmentsIntersect=function(a,b,c,d){var e=b[0]-a[0],f=b[1]-a[1],g=d[0]-c[0],h=d[1]-c[1];if(g*f-h*e==0)return!1;var i=(e*(c[1]-a[1])+f*(a[0]-c[0]))/(g*f-h*e),j=(g*(a[1]-c[1])+h*(c[0]-a[0]))/(h*e-g*f);return i>=0&&1>=i&&j>=0&&1>=j}}).call(this,a("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/poly-decomp/src/Line.js","/../node_modules/poly-decomp/src")},{"./Scalar":8,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,buffer:1}],6:[function(a,b){(function(){function a(){}b.exports=a,a.area=function(a,b,c){return(b[0]-a[0])*(c[1]-a[1])-(c[0]-a[0])*(b[1]-a[1])},a.left=function(b,c,d){return a.area(b,c,d)>0},a.leftOn=function(b,c,d){return a.area(b,c,d)>=0},a.right=function(b,c,d){return a.area(b,c,d)<0},a.rightOn=function(b,c,d){return a.area(b,c,d)<=0};var c=[],d=[];a.collinear=function(b,e,f,g){if(g){var h=c,i=d;h[0]=e[0]-b[0],h[1]=e[1]-b[1],i[0]=f[0]-e[0],i[1]=f[1]-e[1];var j=h[0]*i[0]+h[1]*i[1],k=Math.sqrt(h[0]*h[0]+h[1]*h[1]),l=Math.sqrt(i[0]*i[0]+i[1]*i[1]),m=Math.acos(j/(k*l));return g>m}return 0==a.area(b,e,f)},a.sqdist=function(a,b){var c=b[0]-a[0],d=b[1]-a[1];return c*c+d*d}}).call(this,a("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/poly-decomp/src/Point.js","/../node_modules/poly-decomp/src")},{"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,buffer:1}],7:[function(a,b){(function(){function c(){this.vertices=[]}function d(a,b,c,d,e){e=e||0;var f=b[1]-a[1],h=a[0]-b[0],i=f*a[0]+h*a[1],j=d[1]-c[1],k=c[0]-d[0],l=j*c[0]+k*c[1],m=f*k-j*h;return g.eq(m,0,e)?[0,0]:[(k*i-h*l)/m,(f*l-j*i)/m]}var e=a("./Line"),f=a("./Point"),g=a("./Scalar");b.exports=c,c.prototype.at=function(a){var b=this.vertices,c=b.length;return b[0>a?a%c+c:a%c]},c.prototype.first=function(){return this.vertices[0]},c.prototype.last=function(){return this.vertices[this.vertices.length-1]},c.prototype.clear=function(){this.vertices.length=0},c.prototype.append=function(a,b,c){if("undefined"==typeof b)throw new Error("From is not given!");if("undefined"==typeof c)throw new Error("To is not given!");if(b>c-1)throw new Error("lol1");if(c>a.vertices.length)throw new Error("lol2");if(0>b)throw new Error("lol3");for(var d=b;c>d;d++)this.vertices.push(a.vertices[d])},c.prototype.makeCCW=function(){for(var a=0,b=this.vertices,c=1;cb[a][0])&&(a=c);f.left(this.at(a-1),this.at(a),this.at(a+1))||this.reverse()},c.prototype.reverse=function(){for(var a=[],b=0,c=this.vertices.length;b!==c;b++)a.push(this.vertices.pop());this.vertices=a},c.prototype.isReflex=function(a){return f.right(this.at(a-1),this.at(a),this.at(a+1))};var h=[],i=[];c.prototype.canSee=function(a,b){var c,d,g=h,j=i;if(f.leftOn(this.at(a+1),this.at(a),this.at(b))&&f.rightOn(this.at(a-1),this.at(a),this.at(b)))return!1;d=f.sqdist(this.at(a),this.at(b));for(var k=0;k!==this.vertices.length;++k)if((k+1)%this.vertices.length!==a&&k!==a&&f.leftOn(this.at(a),this.at(b),this.at(k+1))&&f.rightOn(this.at(a),this.at(b),this.at(k))&&(g[0]=this.at(a),g[1]=this.at(b),j[0]=this.at(k),j[1]=this.at(k+1),c=e.lineInt(g,j),f.sqdist(this.at(a),c)a)for(var f=a;b>=f;f++)e.vertices.push(this.vertices[f]);else{for(var f=0;b>=f;f++)e.vertices.push(this.vertices[f]);for(var f=a;f0?this.slice(a):[this]},c.prototype.slice=function(a){if(0==a.length)return[this];if(a instanceof Array&&a.length&&a[0]instanceof Array&&2==a[0].length&&a[0][0]instanceof Array){for(var b=[this],c=0;cc;c++)if(e.segmentsIntersect(a[b],a[b+1],a[c],a[c+1]))return!1;for(var b=1;bh)return console.warn("quickDecomp: max level ("+h+") reached."),a;for(var x=0;xo&&(n=o,k=l,r=y))),f.left(v.at(x+1),v.at(x),v.at(y+1))&&f.rightOn(v.at(x+1),v.at(x),v.at(y))&&(l=d(v.at(x+1),v.at(x),v.at(y),v.at(y+1)),f.left(v.at(x-1),v.at(x),l)&&(o=f.sqdist(v.vertices[x],l),m>o&&(m=o,j=l,q=y)));if(r==(q+1)%this.vertices.length)l[0]=(k[0]+j[0])/2,l[1]=(k[1]+j[1])/2,e.push(l),q>x?(t.append(v,x,q+1),t.vertices.push(l),u.vertices.push(l),0!=r&&u.append(v,r,v.vertices.length),u.append(v,0,x+1)):(0!=x&&t.append(v,x,v.vertices.length),t.append(v,0,q+1),t.vertices.push(l),u.vertices.push(l),u.append(v,r,x+1));else{if(r>q&&(q+=this.vertices.length),p=Number.MAX_VALUE,r>q)return a;for(var y=r;q>=y;++y)f.leftOn(v.at(x-1),v.at(x),v.at(y))&&f.rightOn(v.at(x+1),v.at(x),v.at(y))&&(o=f.sqdist(v.at(x),v.at(y)),p>o&&(p=o,s=y%this.vertices.length));s>x?(t.append(v,x,s+1),0!=s&&u.append(v,s,w.length),u.append(v,0,x+1)):(0!=x&&t.append(v,x,w.length),t.append(v,0,s+1),u.append(v,s,x+1))}return t.vertices.length3&&c>=0;--c)f.collinear(this.at(c-1),this.at(c),this.at(c+1),a)&&(this.vertices.splice(c%this.vertices.length,1),c--,b++);return b}}).call(this,a("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/poly-decomp/src/Polygon.js","/../node_modules/poly-decomp/src")},{"./Line":5,"./Point":6,"./Scalar":8,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,buffer:1}],8:[function(a,b){(function(){function a(){}b.exports=a,a.eq=function(a,b,c){return c=c||0,Math.abs(a-b) (http://steffe.se)",keywords:["p2.js","p2","physics","engine","2d"],main:"./src/p2.js",engines:{node:"*"},repository:{type:"git",url:"https://github.com/schteppe/p2.js.git"},bugs:{url:"https://github.com/schteppe/p2.js/issues"},licenses:[{type:"MIT"}],devDependencies:{grunt:"~0.4.0","grunt-contrib-jshint":"~0.9.2","grunt-contrib-nodeunit":"~0.1.2","grunt-contrib-uglify":"~0.4.0","grunt-contrib-watch":"~0.5.0","grunt-browserify":"~2.0.1","grunt-contrib-concat":"^0.4.0"},dependencies:{"poly-decomp":"0.1.0"}}},{}],11:[function(a,b){(function(){function c(a){this.lowerBound=d.create(),a&&a.lowerBound&&d.copy(this.lowerBound,a.lowerBound),this.upperBound=d.create(),a&&a.upperBound&&d.copy(this.upperBound,a.upperBound)}{var d=a("../math/vec2");a("../utils/Utils")}b.exports=c;var e=d.create();c.prototype.setFromPoints=function(a,b,c,f){var g=this.lowerBound,h=this.upperBound;"number"!=typeof c&&(c=0),0!==c?d.rotate(g,a[0],c):d.copy(g,a[0]),d.copy(h,g);for(var i=Math.cos(c),j=Math.sin(c),k=1;ko;o++)l[o]>h[o]&&(h[o]=l[o]),l[o]c&&(this.lowerBound[b]=c);var d=a.upperBound[b];this.upperBound[b]=c},c.aabbCheck=function(a,b){return a.aabbNeedsUpdate&&a.updateAABB(),b.aabbNeedsUpdate&&b.updateAABB(),a.aabb.overlaps(b.aabb)},c.prototype.boundingVolumeCheck=function(a,b){var d;switch(this.boundingVolumeType){case c.BOUNDING_CIRCLE:d=c.boundingRadiusCheck(a,b);break;case c.AABB:d=c.aabbCheck(a,b);break;default:throw new Error("Bounding volume type not recognized: "+this.boundingVolumeType)}return d},c.canCollide=function(a,b){return a.type===e.STATIC&&b.type===e.STATIC?!1:a.type===e.KINEMATIC&&b.type===e.STATIC||a.type===e.STATIC&&b.type===e.KINEMATIC?!1:a.type===e.KINEMATIC&&b.type===e.KINEMATIC?!1:a.sleepState===e.SLEEPING&&b.sleepState===e.SLEEPING?!1:a.sleepState===e.SLEEPING&&b.type===e.STATIC||b.sleepState===e.SLEEPING&&a.type===e.STATIC?!1:!0},c.NAIVE=1,c.SAP=2}).call(this,a("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/collision/Broadphase.js","/collision")},{"../math/vec2":33,"../objects/Body":34,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,buffer:1}],13:[function(a,b){(function(){function c(a){d.apply(this),a=e.defaults(a,{xmin:-100,xmax:100,ymin:-100,ymax:100,nx:10,ny:10}),this.xmin=a.xmin,this.ymin=a.ymin,this.xmax=a.xmax,this.ymax=a.ymax,this.nx=a.nx,this.ny=a.ny,this.binsizeX=(this.xmax-this.xmin)/this.nx,this.binsizeY=(this.ymax-this.ymin)/this.ny}var d=(a("../shapes/Circle"),a("../shapes/Plane"),a("../shapes/Particle"),a("../collision/Broadphase")),e=(a("../math/vec2"),a("../utils/Utils"));b.exports=c,c.prototype=new d,c.prototype.getCollisionPairs=function(a){for(var b=[],c=a.bodies,e=c.length,f=(this.binsizeX,this.binsizeY,this.nx),g=this.ny,h=this.xmin,i=this.ymin,j=this.xmax,k=this.ymax,l=[],m=f*g,n=0;m>n;n++)l.push([]);for(var o=f/(j-h),p=g/(k-i),n=0;n!==e;n++)for(var q=c[n],r=q.aabb,s=Math.max(r.lowerBound[0],h),t=Math.max(r.lowerBound[1],i),u=Math.min(r.upperBound[0],j),v=Math.min(r.upperBound[1],k),w=Math.floor(o*(s-h)),x=Math.floor(p*(t-i)),y=Math.floor(o*(u-h)),z=Math.floor(p*(v-i)),A=w;y>=A;A++)for(var B=x;z>=B;B++){var C=A,D=B,E=C*(g-1)+D;E>=0&&m>E&&l[E].push(q)}for(var n=0;n!==m;n++)for(var F=l[n],A=0,G=F.length;A!==G;A++)for(var q=F[A],B=0;B!==A;B++){var H=F[B];d.canCollide(q,H)&&this.boundingVolumeCheck(q,H)&&b.push(q,H)}return b}}).call(this,a("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/collision/GridBroadphase.js","/collision")},{"../collision/Broadphase":12,"../math/vec2":33,"../shapes/Circle":40,"../shapes/Particle":44,"../shapes/Plane":45,"../utils/Utils":52,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,buffer:1}],14:[function(a,b){(function(){function c(){d.call(this,d.NAIVE)}{var d=(a("../shapes/Circle"),a("../shapes/Plane"),a("../shapes/Shape"),a("../shapes/Particle"),a("../collision/Broadphase"));a("../math/vec2")}b.exports=c,c.prototype=new d,c.prototype.getCollisionPairs=function(a){var b=a.bodies,c=this.result;c.length=0;for(var e=0,f=b.length;e!==f;e++)for(var g=b[e],h=0;e>h;h++){var i=b[h];d.canCollide(g,i)&&this.boundingVolumeCheck(g,i)&&c.push(g,i)}return c}}).call(this,a("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/collision/NaiveBroadphase.js","/collision")},{"../collision/Broadphase":12,"../math/vec2":33,"../shapes/Circle":40,"../shapes/Particle":44,"../shapes/Plane":45,"../shapes/Shape":47,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,buffer:1}],15:[function(a,b){(function(){function c(){this.contactEquations=[],this.frictionEquations=[],this.enableFriction=!0,this.slipForce=10,this.frictionCoefficient=.3,this.surfaceVelocity=0,this.reuseObjects=!0,this.reusableContactEquations=[],this.reusableFrictionEquations=[],this.restitution=0,this.stiffness=l.DEFAULT_STIFFNESS,this.relaxation=l.DEFAULT_RELAXATION,this.frictionStiffness=l.DEFAULT_STIFFNESS,this.frictionRelaxation=l.DEFAULT_RELAXATION,this.enableFrictionReduction=!0,this.collidingBodiesLastStep=new k,this.contactSkinSize=.01}function d(a,b){f.set(a.vertices[0],.5*-b.length,-b.radius),f.set(a.vertices[1],.5*b.length,-b.radius),f.set(a.vertices[2],.5*b.length,b.radius),f.set(a.vertices[3],.5*-b.length,b.radius)}function e(a,b,c,d){for(var e=R,i=S,j=T,k=U,l=a,m=b.vertices,n=null,o=0;o!==m.length+1;o++){var p=m[o%m.length],q=m[(o+1)%m.length];f.rotate(e,p,d),f.rotate(i,q,d),h(e,e,c),h(i,i,c),g(j,e,l),g(k,i,l);var r=f.crossLength(j,k);if(null===n&&(n=r),0>=r*n)return!1;n=r}return!0}var f=a("../math/vec2"),g=f.sub,h=f.add,i=f.dot,j=a("../utils/Utils"),k=a("../utils/TupleDictionary"),l=a("../equations/Equation"),m=a("../equations/ContactEquation"),n=a("../equations/FrictionEquation"),o=a("../shapes/Circle"),p=a("../shapes/Convex"),q=a("../shapes/Shape"),r=(a("../objects/Body"),a("../shapes/Rectangle"));b.exports=c;var s=f.fromValues(0,1),t=f.fromValues(0,0),u=f.fromValues(0,0),v=f.fromValues(0,0),w=f.fromValues(0,0),x=f.fromValues(0,0),y=f.fromValues(0,0),z=f.fromValues(0,0),A=f.fromValues(0,0),B=f.fromValues(0,0),C=f.fromValues(0,0),D=f.fromValues(0,0),E=f.fromValues(0,0),F=f.fromValues(0,0),G=f.fromValues(0,0),H=f.fromValues(0,0),I=f.fromValues(0,0),J=f.fromValues(0,0),K=f.fromValues(0,0),L=[];c.prototype.collidedLastStep=function(a,b){var c=0|a.id,d=0|b.id;return!!this.collidingBodiesLastStep.get(c,d)},c.prototype.reset=function(){this.collidingBodiesLastStep.reset();for(var a=this.contactEquations,b=a.length;b--;){var c=a[b],d=c.bodyA.id,e=c.bodyB.id;this.collidingBodiesLastStep.set(d,e,!0)}if(this.reuseObjects){var f=this.contactEquations,g=this.frictionEquations,h=this.reusableFrictionEquations,i=this.reusableContactEquations;j.appendArray(i,f),j.appendArray(h,g)}this.contactEquations.length=this.frictionEquations.length=0},c.prototype.createContactEquation=function(a,b,c,d){var e=this.reusableContactEquations.length?this.reusableContactEquations.pop():new m(a,b);return e.bodyA=a,e.bodyB=b,e.shapeA=c,e.shapeB=d,e.restitution=this.restitution,e.firstImpact=!this.collidedLastStep(a,b),e.stiffness=this.stiffness,e.relaxation=this.relaxation,e.needsUpdate=!0,e.enabled=!0,e.offset=this.contactSkinSize,e},c.prototype.createFrictionEquation=function(a,b,c,d){var e=this.reusableFrictionEquations.length?this.reusableFrictionEquations.pop():new n(a,b);return e.bodyA=a,e.bodyB=b,e.shapeA=c,e.shapeB=d,e.setSlipForce(this.slipForce),e.frictionCoefficient=this.frictionCoefficient,e.relativeVelocity=this.surfaceVelocity,e.enabled=!0,e.needsUpdate=!0,e.stiffness=this.frictionStiffness,e.relaxation=this.frictionRelaxation,e.contactEquations.length=0,e},c.prototype.createFrictionFromContact=function(a){var b=this.createFrictionEquation(a.bodyA,a.bodyB,a.shapeA,a.shapeB);return f.copy(b.contactPointA,a.contactPointA),f.copy(b.contactPointB,a.contactPointB),f.rotate90cw(b.t,a.normalA),b.contactEquations.push(a),b},c.prototype.createFrictionFromAverage=function(a){if(!a)throw new Error("numContacts == 0!");{var b=this.contactEquations[this.contactEquations.length-1],c=this.createFrictionEquation(b.bodyA,b.bodyB,b.shapeA,b.shapeB),d=b.bodyA;b.bodyB}f.set(c.contactPointA,0,0),f.set(c.contactPointB,0,0),f.set(c.t,0,0);for(var e=0;e!==a;e++)b=this.contactEquations[this.contactEquations.length-1-e],b.bodyA===d?(f.add(c.t,c.t,b.normalA),f.add(c.contactPointA,c.contactPointA,b.contactPointA),f.add(c.contactPointB,c.contactPointB,b.contactPointB)):(f.sub(c.t,c.t,b.normalA),f.add(c.contactPointA,c.contactPointA,b.contactPointB),f.add(c.contactPointB,c.contactPointB,b.contactPointA)),c.contactEquations.push(b);var g=1/a;return f.scale(c.contactPointA,c.contactPointA,g),f.scale(c.contactPointB,c.contactPointB,g),f.normalize(c.t,c.t),f.rotate90cw(c.t,c.t),c},c.prototype[q.LINE|q.CONVEX]=c.prototype.convexLine=function(a,b,c,d,e,f,g,h,i){return i?!1:0},c.prototype[q.LINE|q.RECTANGLE]=c.prototype.lineRectangle=function(a,b,c,d,e,f,g,h,i){return i?!1:0};var M=new r(1,1),N=f.create();c.prototype[q.CAPSULE|q.CONVEX]=c.prototype[q.CAPSULE|q.RECTANGLE]=c.prototype.convexCapsule=function(a,b,c,e,g,h,i,j,k){var l=N;f.set(l,h.length/2,0),f.rotate(l,l,j),f.add(l,l,i);var m=this.circleConvex(g,h,l,j,a,b,c,e,k,h.radius);f.set(l,-h.length/2,0),f.rotate(l,l,j),f.add(l,l,i);var n=this.circleConvex(g,h,l,j,a,b,c,e,k,h.radius);if(k&&(m||n))return!0;var o=M;d(o,h);var p=this.convexConvex(a,b,c,e,g,o,i,j,k);return p+m+n},c.prototype[q.CAPSULE|q.LINE]=c.prototype.lineCapsule=function(a,b,c,d,e,f,g,h,i){return i?!1:0};var O=f.create(),P=f.create(),Q=new r(1,1);c.prototype[q.CAPSULE|q.CAPSULE]=c.prototype.capsuleCapsule=function(a,b,c,e,g,h,i,j,k){for(var l,m=O,n=P,o=0,p=0;2>p;p++){f.set(m,(0===p?-1:1)*b.length/2,0),f.rotate(m,m,e),f.add(m,m,c);for(var q=0;2>q;q++){f.set(n,(0===q?-1:1)*h.length/2,0),f.rotate(n,n,j),f.add(n,n,i),this.enableFrictionReduction&&(l=this.enableFriction,this.enableFriction=!1);var r=this.circleCircle(a,b,m,e,g,h,n,j,k,b.radius,h.radius);if(this.enableFrictionReduction&&(this.enableFriction=l),k&&r)return!0;o+=r}}this.enableFrictionReduction&&(l=this.enableFriction,this.enableFriction=!1);var s=Q;d(s,b);var t=this.convexCapsule(a,s,c,e,g,h,i,j,k);if(this.enableFrictionReduction&&(this.enableFriction=l),k&&t)return!0;if(o+=t,this.enableFrictionReduction){var l=this.enableFriction;this.enableFriction=!1}d(s,h);var u=this.convexCapsule(g,s,i,j,a,b,c,e,k);return this.enableFrictionReduction&&(this.enableFriction=l),k&&u?!0:(o+=u,this.enableFrictionReduction&&o&&this.enableFriction&&this.frictionEquations.push(this.createFrictionFromAverage(o)),o)},c.prototype[q.LINE|q.LINE]=c.prototype.lineLine=function(a,b,c,d,e,f,g,h,i){return i?!1:0},c.prototype[q.PLANE|q.LINE]=c.prototype.planeLine=function(a,b,c,d,e,j,k,l,m){var n=t,o=u,p=v,q=w,r=x,C=y,D=z,E=A,F=B,G=L,H=0;f.set(n,-j.length/2,0),f.set(o,j.length/2,0),f.rotate(p,n,l),f.rotate(q,o,l),h(p,p,k),h(q,q,k),f.copy(n,p),f.copy(o,q),g(r,o,n),f.normalize(C,r),f.rotate90cw(F,C),f.rotate(E,s,d),G[0]=n,G[1]=o;for(var I=0;IK){if(m)return!0;var M=this.createContactEquation(a,e,b,j);H++,f.copy(M.normalA,E),f.normalize(M.normalA,M.normalA),f.scale(D,E,K),g(M.contactPointA,J,D),g(M.contactPointA,M.contactPointA,a.position),g(M.contactPointB,J,k),h(M.contactPointB,M.contactPointB,k),g(M.contactPointB,M.contactPointB,e.position),this.contactEquations.push(M),this.enableFrictionReduction||this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(M))}}return m?!1:(this.enableFrictionReduction||H&&this.enableFriction&&this.frictionEquations.push(this.createFrictionFromAverage(H)),H)},c.prototype[q.PARTICLE|q.CAPSULE]=c.prototype.particleCapsule=function(a,b,c,d,e,f,g,h,i){return this.circleLine(a,b,c,d,e,f,g,h,i,f.radius,0)},c.prototype[q.CIRCLE|q.LINE]=c.prototype.circleLine=function(a,b,c,d,e,j,k,l,m,n,o){var n=n||0,o="undefined"!=typeof o?o:b.radius,p=t,q=u,r=v,s=w,H=x,I=y,J=z,K=A,M=B,N=C,O=D,P=E,Q=F,R=G,S=L;f.set(K,-j.length/2,0),f.set(M,j.length/2,0),f.rotate(N,K,l),f.rotate(O,M,l),h(N,N,k),h(O,O,k),f.copy(K,N),f.copy(M,O),g(I,M,K),f.normalize(J,I),f.rotate90cw(H,J),g(P,c,K);var T=i(P,H);g(s,K,k),g(Q,c,k);var U=o+n;if(Math.abs(T)W&&X>V){if(m)return!0;var Y=this.createContactEquation(a,e,b,j);return f.scale(Y.normalA,p,-1),f.normalize(Y.normalA,Y.normalA),f.scale(Y.contactPointA,Y.normalA,o),h(Y.contactPointA,Y.contactPointA,c),g(Y.contactPointA,Y.contactPointA,a.position),g(Y.contactPointB,r,k),h(Y.contactPointB,Y.contactPointB,k),g(Y.contactPointB,Y.contactPointB,e.position),this.contactEquations.push(Y),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(Y)),1}}S[0]=K,S[1]=M;for(var Z=0;ZQ&&(f.copy(J,B),L=Q,f.scale(A,s,Q),f.add(A,A,B),K=!0)}}if(K){if(m)return!0;var R=this.createContactEquation(a,i,b,j);return f.sub(R.normalA,J,c),f.normalize(R.normalA,R.normalA),f.scale(R.contactPointA,R.normalA,n),h(R.contactPointA,R.contactPointA,c),g(R.contactPointA,R.contactPointA,a.position),g(R.contactPointB,A,k),h(R.contactPointB,R.contactPointB,k),g(R.contactPointB,R.contactPointB,i.position),this.contactEquations.push(R),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(R)),1}if(n>0)for(var N=0;NQ&&(I=Q,f.scale(E,s,Q),f.add(E,E,c),f.copy(H,s),L=!0)}if(L){var R=this.createContactEquation(a,j,b,k);return f.scale(R.normalA,H,-1),f.normalize(R.normalA,R.normalA),f.set(R.contactPointA,0,0),h(R.contactPointA,R.contactPointA,c),g(R.contactPointA,R.contactPointA,a.position),g(R.contactPointB,E,l),h(R.contactPointB,R.contactPointB,l),g(R.contactPointB,R.contactPointB,j.position),this.contactEquations.push(R),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(R)),1}return 0},c.prototype[q.CIRCLE]=c.prototype.circleCircle=function(a,b,c,d,e,i,j,k,l,m,n){var o=t,m=m||b.radius,n=n||i.radius;g(o,c,j);var p=m+n;if(f.squaredLength(o)>Math.pow(p,2))return 0;if(l)return!0;var q=this.createContactEquation(a,e,b,i);return g(q.normalA,j,c),f.normalize(q.normalA,q.normalA),f.scale(q.contactPointA,q.normalA,m),f.scale(q.contactPointB,q.normalA,-n),h(q.contactPointA,q.contactPointA,c),g(q.contactPointA,q.contactPointA,a.position),h(q.contactPointB,q.contactPointB,j),g(q.contactPointB,q.contactPointB,e.position),this.contactEquations.push(q),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(q)),1},c.prototype[q.PLANE|q.CONVEX]=c.prototype[q.PLANE|q.RECTANGLE]=c.prototype.planeConvex=function(a,b,c,d,e,j,k,l,m){var n=t,o=u,p=v,q=0;f.rotate(o,s,d);for(var r=0;r!==j.vertices.length;r++){var w=j.vertices[r];if(f.rotate(n,w,l),h(n,n,k),g(p,n,c),i(p,o)<=0){if(m)return!0;q++;var x=this.createContactEquation(a,e,b,j);g(p,n,c),f.copy(x.normalA,o);var y=i(p,x.normalA);f.scale(p,x.normalA,y),g(x.contactPointB,n,e.position),g(x.contactPointA,n,p),g(x.contactPointA,x.contactPointA,a.position),this.contactEquations.push(x),this.enableFrictionReduction||this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(x))}}return this.enableFrictionReduction&&this.enableFriction&&q&&this.frictionEquations.push(this.createFrictionFromAverage(q)),q},c.prototype[q.PARTICLE|q.PLANE]=c.prototype.particlePlane=function(a,b,c,d,e,h,j,k,l){var m=t,n=u;k=k||0,g(m,c,j),f.rotate(n,s,k);var o=i(m,n);if(o>0)return 0;if(l)return!0;var p=this.createContactEquation(e,a,h,b);return f.copy(p.normalA,n),f.scale(m,p.normalA,o),g(p.contactPointA,c,m),g(p.contactPointA,p.contactPointA,e.position),g(p.contactPointB,c,a.position),this.contactEquations.push(p),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(p)),1},c.prototype[q.CIRCLE|q.PARTICLE]=c.prototype.circleParticle=function(a,b,c,d,e,i,j,k,l){var m=t;if(g(m,j,c),f.squaredLength(m)>Math.pow(b.radius,2))return 0;if(l)return!0;var n=this.createContactEquation(a,e,b,i);return f.copy(n.normalA,m),f.normalize(n.normalA,n.normalA),f.scale(n.contactPointA,n.normalA,b.radius),h(n.contactPointA,n.contactPointA,c),g(n.contactPointA,n.contactPointA,a.position),g(n.contactPointB,j,e.position),this.contactEquations.push(n),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(n)),1};{var V=new o(1),W=f.create(),X=f.create();f.create()}c.prototype[q.PLANE|q.CAPSULE]=c.prototype.planeCapsule=function(a,b,c,d,e,g,i,j,k){var l=W,m=X,n=V;f.set(l,-g.length/2,0),f.rotate(l,l,j),h(l,l,i),f.set(m,g.length/2,0),f.rotate(m,m,j),h(m,m,i),n.radius=g.radius;var o;this.enableFrictionReduction&&(o=this.enableFriction,this.enableFriction=!1);var p=this.circlePlane(e,n,l,0,a,b,c,d,k),q=this.circlePlane(e,n,m,0,a,b,c,d,k);if(this.enableFrictionReduction&&(this.enableFriction=o),k)return p||q;var r=p+q;return this.enableFrictionReduction&&r&&this.frictionEquations.push(this.createFrictionFromAverage(r)),r},c.prototype[q.CIRCLE|q.PLANE]=c.prototype.circlePlane=function(a,b,c,d,e,j,k,l,m){var n=a,o=b,p=c,q=e,r=k,w=l;w=w||0;var x=t,y=u,z=v;g(x,p,r),f.rotate(y,s,w);var A=i(y,x);if(A>o.radius)return 0;if(m)return!0;var B=this.createContactEquation(q,n,j,b);return f.copy(B.normalA,y),f.scale(B.contactPointB,B.normalA,-o.radius),h(B.contactPointB,B.contactPointB,p),g(B.contactPointB,B.contactPointB,n.position),f.scale(z,B.normalA,A),g(B.contactPointA,x,z),h(B.contactPointA,B.contactPointA,r),g(B.contactPointA,B.contactPointA,q.position),this.contactEquations.push(B),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(B)),1},c.prototype[q.CONVEX]=c.prototype[q.CONVEX|q.RECTANGLE]=c.prototype[q.RECTANGLE]=c.prototype.convexConvex=function(a,b,d,e,j,k,l,m,n,o){var p=t,q=u,r=v,s=w,y=x,C=z,D=A,E=B,F=0,o="number"==typeof o?o:0,G=c.findSeparatingAxis(b,d,e,k,l,m,p);if(!G)return 0;g(D,l,d),i(p,D)>0&&f.scale(p,p,-1);var H=c.getClosestEdge(b,e,p,!0),I=c.getClosestEdge(k,m,p);if(-1===H||-1===I)return 0;for(var J=0;2>J;J++){var K=H,L=I,M=b,N=k,O=d,P=l,Q=e,R=m,S=a,T=j;if(0===J){var U;U=K,K=L,L=U,U=M,M=N,N=U,U=O,O=P,P=U,U=Q,Q=R,R=U,U=S,S=T,T=U}for(var V=L;L+2>V;V++){var W=N.vertices[(V+N.vertices.length)%N.vertices.length];f.rotate(q,W,R),h(q,q,P);for(var X=0,Y=K-1;K+2>Y;Y++){var Z=M.vertices[(Y+M.vertices.length)%M.vertices.length],$=M.vertices[(Y+1+M.vertices.length)%M.vertices.length];f.rotate(r,Z,Q),f.rotate(s,$,Q),h(r,r,O),h(s,s,O),g(y,s,r),f.rotate90cw(E,y),f.normalize(E,E),g(D,q,r);var _=i(E,D);(Y===K&&o>=_||Y!==K&&0>=_)&&X++}if(X>=3){if(n)return!0;var ab=this.createContactEquation(S,T,M,N);F++;var Z=M.vertices[K%M.vertices.length],$=M.vertices[(K+1)%M.vertices.length];f.rotate(r,Z,Q),f.rotate(s,$,Q),h(r,r,O),h(s,s,O),g(y,s,r),f.rotate90cw(ab.normalA,y),f.normalize(ab.normalA,ab.normalA),g(D,q,r);var _=i(ab.normalA,D);f.scale(C,ab.normalA,_),g(ab.contactPointA,q,O),g(ab.contactPointA,ab.contactPointA,C),h(ab.contactPointA,ab.contactPointA,O),g(ab.contactPointA,ab.contactPointA,S.position),g(ab.contactPointB,q,P),h(ab.contactPointB,ab.contactPointB,P),g(ab.contactPointB,ab.contactPointB,T.position),this.contactEquations.push(ab),this.enableFrictionReduction||this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(ab))}}}return this.enableFrictionReduction&&this.enableFriction&&F&&this.frictionEquations.push(this.createFrictionFromAverage(F)),F};var Y=f.fromValues(0,0);c.projectConvexOntoAxis=function(a,b,c,d,e){var g,h,j=null,k=null,l=Y;f.rotate(l,d,-c);for(var m=0;mj)&&(j=h),(null===k||k>h)&&(k=h);if(k>j){var n=k;k=j,j=n}var o=i(b,d);f.set(e,k+o,j+o)};var Z=f.fromValues(0,0),$=f.fromValues(0,0),_=f.fromValues(0,0),ab=f.fromValues(0,0),bb=f.fromValues(0,0),cb=f.fromValues(0,0);c.findSeparatingAxis=function(a,b,d,e,h,i,j){var k=null,l=!1,m=!1,n=Z,o=$,p=_,q=ab,s=bb,t=cb;if(a instanceof r&&e instanceof r)for(var u=0;2!==u;u++){var v=a,w=d;1===u&&(v=e,w=i);for(var x=0;2!==x;x++){0===x?f.set(q,0,1):1===x&&f.set(q,1,0),0!==w&&f.rotate(q,q,w),c.projectConvexOntoAxis(a,b,d,q,s),c.projectConvexOntoAxis(e,h,i,q,t);var y=s,z=t,A=!1;s[0]>t[0]&&(z=s,y=t,A=!0);var B=z[0]-y[1];l=0>=B,(null===k||B>k)&&(f.copy(j,q),k=B,m=l)}}else for(var u=0;2!==u;u++){var v=a,w=d;1===u&&(v=e,w=i);for(var x=0;x!==v.vertices.length;x++){f.rotate(o,v.vertices[x],w),f.rotate(p,v.vertices[(x+1)%v.vertices.length],w),g(n,p,o),f.rotate90cw(q,n),f.normalize(q,q),c.projectConvexOntoAxis(a,b,d,q,s),c.projectConvexOntoAxis(e,h,i,q,t);var y=s,z=t,A=!1;s[0]>t[0]&&(z=s,y=t,A=!0);var B=z[0]-y[1];l=0>=B,(null===k||B>k)&&(f.copy(j,q),k=B,m=l)}}return m};var db=f.fromValues(0,0),eb=f.fromValues(0,0),fb=f.fromValues(0,0);c.getClosestEdge=function(a,b,c,d){var e=db,h=eb,j=fb;f.rotate(e,c,-b),d&&f.scale(e,e,-1);for(var k=-1,l=a.vertices.length,m=-1,n=0;n!==l;n++){g(h,a.vertices[(n+1)%l],a.vertices[n%l]),f.rotate90cw(j,h),f.normalize(j,j);var o=i(j,e);(-1===k||o>m)&&(k=n%l,m=o)}return k};var gb=f.create(),hb=f.create(),ib=f.create(),jb=f.create(),kb=f.create(),lb=f.create(),mb=f.create();c.prototype[q.CIRCLE|q.HEIGHTFIELD]=c.prototype.circleHeightfield=function(a,b,c,d,e,i,j,k,l,m){var n=i.data,m=m||b.radius,o=i.elementWidth,p=hb,q=gb,r=kb,s=mb,t=lb,u=ib,v=jb,w=Math.floor((c[0]-m-j[0])/o),x=Math.ceil((c[0]+m-j[0])/o);0>w&&(w=0),x>=n.length&&(x=n.length-1);for(var y=n[w],z=n[x],A=w;x>A;A++)n[A]y&&(y=n[A]);if(c[1]-m>y)return l?!1:0;c[1]+mA;A++){f.set(u,A*o,n[A]),f.set(v,(A+1)*o,n[A+1]),f.add(u,u,j),f.add(v,v,j),f.sub(t,v,u),f.rotate(t,t,Math.PI/2),f.normalize(t,t),f.scale(q,t,-m),f.add(q,q,c),f.sub(p,q,u);var C=f.dot(p,t);if(q[0]>=u[0]&&q[0]=C){if(l)return!0;B=!0,f.scale(p,t,-C),f.add(r,q,p),f.copy(s,t);var D=this.createContactEquation(e,a,i,b);f.copy(D.normalA,s),f.scale(D.contactPointB,D.normalA,-m),h(D.contactPointB,D.contactPointB,c),g(D.contactPointB,D.contactPointB,a.position),f.copy(D.contactPointA,r),f.sub(D.contactPointA,D.contactPointA,e.position),this.contactEquations.push(D),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(D))}}if(B=!1,m>0)for(var A=w;x>=A;A++)if(f.set(u,A*o,n[A]),f.add(u,u,j),f.sub(p,c,u),f.squaredLength(p)q&&(q=0),r>=k.length&&(r=k.length-1);for(var s=k[q],t=k[r],u=q;r>u;u++)k[u]s&&(s=k[u]);if(a.aabb.lowerBound[1]>s)return j?!1:0;for(var v=0,u=q;r>u;u++){f.set(m,u*l,k[u]),f.set(n,(u+1)*l,k[u+1]),f.add(m,m,h),f.add(n,n,h);var w=100;f.set(o,.5*(n[0]+m[0]),.5*(n[1]+m[1]-w)),f.sub(p.vertices[0],n,o),f.sub(p.vertices[1],m,o),f.copy(p.vertices[2],p.vertices[1]),f.copy(p.vertices[3],p.vertices[0]),p.vertices[2][1]-=w,p.vertices[3][1]-=w,v+=this.convexConvex(a,b,c,d,e,p,o,0,j)}return v}}).call(this,a("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/collision/Narrowphase.js","/collision")},{"../equations/ContactEquation":24,"../equations/Equation":25,"../equations/FrictionEquation":26,"../math/vec2":33,"../objects/Body":34,"../shapes/Circle":40,"../shapes/Convex":41,"../shapes/Rectangle":46,"../shapes/Shape":47,"../utils/TupleDictionary":51,"../utils/Utils":52,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,buffer:1}],16:[function(a,b){(function(){function c(){e.call(this,e.SAP),this.axisList=[],this.world=null,this.axisIndex=0;var a=this.axisList;this._addBodyHandler=function(b){a.push(b.body)},this._removeBodyHandler=function(b){var c=a.indexOf(b.body);-1!==c&&a.splice(c,1)}}var d=a("../utils/Utils"),e=a("../collision/Broadphase");b.exports=c,c.prototype=new e,c.prototype.setWorld=function(a){this.axisList.length=0,d.appendArray(this.axisList,a.bodies),a.off("addBody",this._addBodyHandler).off("removeBody",this._removeBodyHandler),a.on("addBody",this._addBodyHandler).on("removeBody",this._removeBodyHandler),this.world=a},c.sortAxisList=function(a,b){b=0|b;for(var c=1,d=a.length;d>c;c++){for(var e=a[c],f=c-1;f>=0&&!(a[f].aabb.lowerBound[b]<=e.aabb.lowerBound[b]);f--)a[f+1]=a[f];a[f+1]=e}return a},c.prototype.getCollisionPairs=function(){var a=this.axisList,b=this.result,d=this.axisIndex;b.length=0;for(var f=a.length;f--;){var g=a[f];g.aabbNeedsUpdate&&g.updateAABB()}c.sortAxisList(a,d);for(var h=0,i=0|a.length;h!==i;h++)for(var j=a[h],k=h+1;i>k;k++){var l=a[k],m=l.aabb.lowerBound[d]<=j.aabb.upperBound[d];if(!m)break;e.canCollide(j,l)&&this.boundingVolumeCheck(j,l)&&b.push(j,l)}return b}}).call(this,a("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/collision/SAPBroadphase.js","/collision")},{"../collision/Broadphase":12,"../utils/Utils":52,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,buffer:1}],17:[function(a,b){(function(){function c(a,b,c,e){this.type=c,e=d.defaults(e,{collideConnected:!0,wakeUpBodies:!0}),this.equations=[],this.bodyA=a,this.bodyB=b,this.collideConnected=e.collideConnected,e.wakeUpBodies&&(a&&a.wakeUp(),b&&b.wakeUp())}b.exports=c;var d=a("../utils/Utils");c.prototype.update=function(){throw new Error("method update() not implmemented in this Constraint subclass!")},c.DISTANCE=1,c.GEAR=2,c.LOCK=3,c.PRISMATIC=4,c.REVOLUTE=5,c.prototype.setStiffness=function(a){for(var b=this.equations,c=0;c!==b.length;c++){var d=b[c];d.stiffness=a,d.needsUpdate=!0}},c.prototype.setRelaxation=function(a){for(var b=this.equations,c=0;c!==b.length;c++){var d=b[c];d.relaxation=a,d.needsUpdate=!0}}}).call(this,a("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/constraints/Constraint.js","/constraints")},{"../utils/Utils":52,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,buffer:1}],18:[function(a,b){(function(){function c(a,b,c){c=g.defaults(c,{localAnchorA:[0,0],localAnchorB:[0,0]}),d.call(this,a,b,d.DISTANCE,c),this.localAnchorA=f.fromValues(c.localAnchorA[0],c.localAnchorA[1]),this.localAnchorB=f.fromValues(c.localAnchorB[0],c.localAnchorB[1]);var h=this.localAnchorA,i=this.localAnchorB;if(this.distance=0,"number"==typeof c.distance)this.distance=c.distance;else{var j=f.create(),k=f.create(),l=f.create();f.rotate(j,h,a.angle),f.rotate(k,i,b.angle),f.add(l,b.position,k),f.sub(l,l,j),f.sub(l,l,a.position),this.distance=f.length(l)}var m;m="undefined"==typeof c.maxForce?Number.MAX_VALUE:c.maxForce;var n=new e(a,b,-m,m);this.equations=[n],this.maxForce=m;var l=f.create(),o=f.create(),p=f.create(),q=this;n.computeGq=function(){var a=this.bodyA,b=this.bodyB,c=a.position,d=b.position;return f.rotate(o,h,a.angle),f.rotate(p,i,b.angle),f.add(l,d,p),f.sub(l,l,o),f.sub(l,l,c),f.length(l)-q.distance},this.setMaxForce(m),this.upperLimitEnabled=!1,this.upperLimit=1,this.lowerLimitEnabled=!1,this.lowerLimit=0,this.position=0}var d=a("./Constraint"),e=a("../equations/Equation"),f=a("../math/vec2"),g=a("../utils/Utils"); -b.exports=c,c.prototype=new d;var h=f.create(),i=f.create(),j=f.create();c.prototype.update=function(){var a=this.equations[0],b=this.bodyA,c=this.bodyB,d=(this.distance,b.position),e=c.position,g=this.equations[0],k=a.G;f.rotate(i,this.localAnchorA,b.angle),f.rotate(j,this.localAnchorB,c.angle),f.add(h,e,j),f.sub(h,h,i),f.sub(h,h,d),this.position=f.length(h);var l=!1;if(this.upperLimitEnabled&&this.position>this.upperLimit&&(g.maxForce=0,g.minForce=-this.maxForce,this.distance=this.upperLimit,l=!0),this.lowerLimitEnabled&&this.positionc)g.scale(e.normalA,i,-1),g.sub(e.contactPointA,j,h.position),g.sub(e.contactPointB,k,o.position),g.scale(n,i,c),g.add(e.contactPointA,e.contactPointA,n),-1===a.indexOf(e)&&a.push(e);else{var u=a.indexOf(e);-1!==u&&a.splice(u,1)}if(this.lowerLimitEnabled&&d>s)g.scale(f.normalA,i,1),g.sub(f.contactPointA,j,h.position),g.sub(f.contactPointB,k,o.position),g.scale(n,i,d),g.sub(f.contactPointB,f.contactPointB,n),-1===a.indexOf(f)&&a.push(f);else{var u=a.indexOf(f);-1!==u&&a.splice(u,1)}},c.prototype.enableMotor=function(){this.motorEnabled||(this.equations.push(this.motorEquation),this.motorEnabled=!0)},c.prototype.disableMotor=function(){if(this.motorEnabled){var a=this.equations.indexOf(this.motorEquation);this.equations.splice(a,1),this.motorEnabled=!1}},c.prototype.setLimits=function(a,b){"number"==typeof a?(this.lowerLimit=a,this.lowerLimitEnabled=!0):(this.lowerLimit=a,this.lowerLimitEnabled=!1),"number"==typeof b?(this.upperLimit=b,this.upperLimitEnabled=!0):(this.upperLimit=b,this.upperLimitEnabled=!1)}}).call(this,a("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/constraints/PrismaticConstraint.js","/constraints")},{"../equations/ContactEquation":24,"../equations/Equation":25,"../equations/RotationalLockEquation":27,"../math/vec2":33,"./Constraint":17,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,buffer:1}],22:[function(a,b){(function(){function c(a,b,c){c=c||{},d.call(this,a,b,d.REVOLUTE,c);var n=this.maxForce="undefined"!=typeof c.maxForce?c.maxForce:Number.MAX_VALUE;this.pivotA=h.create(),this.pivotB=h.create(),c.worldPivot?(h.sub(this.pivotA,c.worldPivot,a.position),h.sub(this.pivotB,c.worldPivot,b.position),h.rotate(this.pivotA,this.pivotA,-a.angle),h.rotate(this.pivotB,this.pivotB,-b.angle)):(h.copy(this.pivotA,c.localPivotA),h.copy(this.pivotB,c.localPivotB));var o=this.equations=[new e(a,b,-n,n),new e(a,b,-n,n)],p=o[0],q=o[1],r=this;p.computeGq=function(){return h.rotate(i,r.pivotA,a.angle),h.rotate(j,r.pivotB,b.angle),h.add(m,b.position,j),h.sub(m,m,a.position),h.sub(m,m,i),h.dot(m,k)},q.computeGq=function(){return h.rotate(i,r.pivotA,a.angle),h.rotate(j,r.pivotB,b.angle),h.add(m,b.position,j),h.sub(m,m,a.position),h.sub(m,m,i),h.dot(m,l)},q.minForce=p.minForce=-n,q.maxForce=p.maxForce=n,this.motorEquation=new f(a,b),this.motorEnabled=!1,this.angle=0,this.lowerLimitEnabled=!1,this.upperLimitEnabled=!1,this.lowerLimit=0,this.upperLimit=0,this.upperLimitEquation=new g(a,b),this.lowerLimitEquation=new g(a,b),this.upperLimitEquation.minForce=0,this.lowerLimitEquation.maxForce=0}var d=a("./Constraint"),e=a("../equations/Equation"),f=a("../equations/RotationalVelocityEquation"),g=a("../equations/RotationalLockEquation"),h=a("../math/vec2");b.exports=c;var i=h.create(),j=h.create(),k=h.fromValues(1,0),l=h.fromValues(0,1),m=h.create();c.prototype=new d,c.prototype.setLimits=function(a,b){"number"==typeof a?(this.lowerLimit=a,this.lowerLimitEnabled=!0):(this.lowerLimit=a,this.lowerLimitEnabled=!1),"number"==typeof b?(this.upperLimit=b,this.upperLimitEnabled=!0):(this.upperLimit=b,this.upperLimitEnabled=!1)},c.prototype.update=function(){var a=this.bodyA,b=this.bodyB,c=this.pivotA,d=this.pivotB,e=this.equations,f=(e[0],e[1],e[0]),g=e[1],m=this.upperLimit,n=this.lowerLimit,o=this.upperLimitEquation,p=this.lowerLimitEquation,q=this.angle=b.angle-a.angle;if(this.upperLimitEnabled&&q>m)o.angle=m,-1===e.indexOf(o)&&e.push(o);else{var r=e.indexOf(o);-1!==r&&e.splice(r,1)}if(this.lowerLimitEnabled&&n>q)p.angle=n,-1===e.indexOf(p)&&e.push(p);else{var r=e.indexOf(p);-1!==r&&e.splice(r,1)}h.rotate(i,c,a.angle),h.rotate(j,d,b.angle),f.G[0]=-1,f.G[1]=0,f.G[2]=-h.crossLength(i,k),f.G[3]=1,f.G[4]=0,f.G[5]=h.crossLength(j,k),g.G[0]=0,g.G[1]=-1,g.G[2]=-h.crossLength(i,l),g.G[3]=0,g.G[4]=1,g.G[5]=h.crossLength(j,l)},c.prototype.enableMotor=function(){this.motorEnabled||(this.equations.push(this.motorEquation),this.motorEnabled=!0)},c.prototype.disableMotor=function(){if(this.motorEnabled){var a=this.equations.indexOf(this.motorEquation);this.equations.splice(a,1),this.motorEnabled=!1}},c.prototype.motorIsEnabled=function(){return!!this.motorEnabled},c.prototype.setMotorSpeed=function(a){if(this.motorEnabled){var b=this.equations.indexOf(this.motorEquation);this.equations[b].relativeVelocity=a}},c.prototype.getMotorSpeed=function(){return this.motorEnabled?this.motorEquation.relativeVelocity:!1}}).call(this,a("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/constraints/RevoluteConstraint.js","/constraints")},{"../equations/Equation":25,"../equations/RotationalLockEquation":27,"../equations/RotationalVelocityEquation":28,"../math/vec2":33,"./Constraint":17,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,buffer:1}],23:[function(a,b){(function(){function c(a,b,c){c=c||{},d.call(this,a,b,-Number.MAX_VALUE,Number.MAX_VALUE),this.angle=c.angle||0,this.ratio="number"==typeof c.ratio?c.ratio:1,this.setRatio(this.ratio)}{var d=a("./Equation");a("../math/vec2")}b.exports=c,c.prototype=new d,c.prototype.constructor=c,c.prototype.computeGq=function(){return this.ratio*this.bodyA.angle-this.bodyB.angle+this.angle},c.prototype.setRatio=function(a){var b=this.G;b[2]=a,b[5]=-1,this.ratio=a},c.prototype.setMaxTorque=function(a){this.maxForce=a,this.minForce=-a}}).call(this,a("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/equations/AngleLockEquation.js","/equations")},{"../math/vec2":33,"./Equation":25,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,buffer:1}],24:[function(a,b){(function(){function c(a,b){d.call(this,a,b,0,Number.MAX_VALUE),this.contactPointA=e.create(),this.penetrationVec=e.create(),this.contactPointB=e.create(),this.normalA=e.create(),this.restitution=0,this.firstImpact=!1,this.shapeA=null,this.shapeB=null}var d=a("./Equation"),e=a("../math/vec2");b.exports=c,c.prototype=new d,c.prototype.constructor=c,c.prototype.computeB=function(a,b,c){var d=this.bodyA,f=this.bodyB,g=this.contactPointA,h=this.contactPointB,i=d.position,j=f.position,k=this.penetrationVec,l=this.normalA,m=this.G,n=e.crossLength(g,l),o=e.crossLength(h,l);m[0]=-l[0],m[1]=-l[1],m[2]=-n,m[3]=l[0],m[4]=l[1],m[5]=o,e.add(k,j,h),e.sub(k,k,i),e.sub(k,k,g);var p,q;this.firstImpact&&0!==this.restitution?(q=0,p=1/b*(1+this.restitution)*this.computeGW()):(q=e.dot(l,k)+this.offset,p=this.computeGW());var r=this.computeGiMf(),s=-q*a-p*b-c*r;return s}}).call(this,a("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/equations/ContactEquation.js","/equations")},{"../math/vec2":33,"./Equation":25,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,buffer:1}],25:[function(a,b){(function(){function c(a,b,d,f){this.minForce="undefined"==typeof d?-Number.MAX_VALUE:d,this.maxForce="undefined"==typeof f?Number.MAX_VALUE:f,this.bodyA=a,this.bodyB=b,this.stiffness=c.DEFAULT_STIFFNESS,this.relaxation=c.DEFAULT_RELAXATION,this.G=new e.ARRAY_TYPE(6);for(var g=0;6>g;g++)this.G[g]=0;this.offset=0,this.a=0,this.b=0,this.epsilon=0,this.timeStep=1/60,this.needsUpdate=!0,this.multiplier=0,this.relativeVelocity=0,this.enabled=!0}b.exports=c;{var d=a("../math/vec2"),e=a("../utils/Utils");a("../objects/Body")}c.prototype.constructor=c,c.DEFAULT_STIFFNESS=1e6,c.DEFAULT_RELAXATION=4,c.prototype.update=function(){var a=this.stiffness,b=this.relaxation,c=this.timeStep;this.a=4/(c*(1+4*b)),this.b=4*b/(1+4*b),this.epsilon=4/(c*c*a*(1+4*b)),this.needsUpdate=!1},c.prototype.gmult=function(a,b,c,d,e){return a[0]*b[0]+a[1]*b[1]+a[2]*c+a[3]*d[0]+a[4]*d[1]+a[5]*e},c.prototype.computeB=function(a,b,c){var d=this.computeGW(),e=this.computeGq(),f=this.computeGiMf();return-e*a-d*b-f*c};var f=d.create(),g=d.create();c.prototype.computeGq=function(){var a=this.G,b=this.bodyA,c=this.bodyB,d=(b.position,c.position,b.angle),e=c.angle;return this.gmult(a,f,d,g,e)+this.offset},c.prototype.computeGW=function(){var a=this.G,b=this.bodyA,c=this.bodyB,d=b.velocity,e=c.velocity,f=b.angularVelocity,g=c.angularVelocity;return this.gmult(a,d,f,e,g)+this.relativeVelocity},c.prototype.computeGWlambda=function(){var a=this.G,b=this.bodyA,c=this.bodyB,d=b.vlambda,e=c.vlambda,f=b.wlambda,g=c.wlambda;return this.gmult(a,d,f,e,g)};var h=d.create(),i=d.create();c.prototype.computeGiMf=function(){var a=this.bodyA,b=this.bodyB,c=a.force,e=a.angularForce,f=b.force,g=b.angularForce,j=a.invMassSolve,k=b.invMassSolve,l=a.invInertiaSolve,m=b.invInertiaSolve,n=this.G;return d.scale(h,c,j),d.scale(i,f,k),this.gmult(n,h,e*l,i,g*m)},c.prototype.computeGiMGt=function(){var a=this.bodyA,b=this.bodyB,c=a.invMassSolve,d=b.invMassSolve,e=a.invInertiaSolve,f=b.invInertiaSolve,g=this.G;return g[0]*g[0]*c+g[1]*g[1]*c+g[2]*g[2]*e+g[3]*g[3]*d+g[4]*g[4]*d+g[5]*g[5]*f};{var j=d.create(),k=d.create(),l=d.create();d.create(),d.create(),d.create()}c.prototype.addToWlambda=function(a){var b=this.bodyA,c=this.bodyB,e=j,f=k,g=l,h=b.invMassSolve,i=c.invMassSolve,m=b.invInertiaSolve,n=c.invInertiaSolve,o=this.G;f[0]=o[0],f[1]=o[1],g[0]=o[3],g[1]=o[4],d.scale(e,f,h*a),d.add(b.vlambda,b.vlambda,e),b.wlambda+=m*o[2]*a,d.scale(e,g,i*a),d.add(c.vlambda,c.vlambda,e),c.wlambda+=n*o[5]*a},c.prototype.computeInvC=function(a){return 1/(this.computeGiMGt()+a)}}).call(this,a("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/equations/Equation.js","/equations")},{"../math/vec2":33,"../objects/Body":34,"../utils/Utils":52,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,buffer:1}],26:[function(a,b){(function(){function c(a,b,c){e.call(this,a,b,-c,c),this.contactPointA=d.create(),this.contactPointB=d.create(),this.t=d.create(),this.contactEquations=[],this.shapeA=null,this.shapeB=null,this.frictionCoefficient=.3}{var d=a("../math/vec2"),e=a("./Equation");a("../utils/Utils")}b.exports=c,c.prototype=new e,c.prototype.constructor=c,c.prototype.setSlipForce=function(a){this.maxForce=a,this.minForce=-a},c.prototype.getSlipForce=function(){return this.maxForce},c.prototype.computeB=function(a,b,c){var e=(this.bodyA,this.bodyB,this.contactPointA),f=this.contactPointB,g=this.t,h=this.G;h[0]=-g[0],h[1]=-g[1],h[2]=-d.crossLength(e,g),h[3]=g[0],h[4]=g[1],h[5]=d.crossLength(f,g);var i=this.computeGW(),j=this.computeGiMf(),k=-i*b-c*j;return k}}).call(this,a("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/equations/FrictionEquation.js","/equations")},{"../math/vec2":33,"../utils/Utils":52,"./Equation":25,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,buffer:1}],27:[function(a,b){(function(){function c(a,b,c){c=c||{},d.call(this,a,b,-Number.MAX_VALUE,Number.MAX_VALUE),this.angle=c.angle||0;var e=this.G;e[2]=1,e[5]=-1}var d=a("./Equation"),e=a("../math/vec2");b.exports=c,c.prototype=new d,c.prototype.constructor=c;var f=e.create(),g=e.create(),h=e.fromValues(1,0),i=e.fromValues(0,1);c.prototype.computeGq=function(){return e.rotate(f,h,this.bodyA.angle+this.angle),e.rotate(g,i,this.bodyB.angle),e.dot(f,g)}}).call(this,a("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/equations/RotationalLockEquation.js","/equations")},{"../math/vec2":33,"./Equation":25,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,buffer:1}],28:[function(a,b){(function(){function c(a,b){d.call(this,a,b,-Number.MAX_VALUE,Number.MAX_VALUE),this.relativeVelocity=1,this.ratio=1}{var d=a("./Equation");a("../math/vec2")}b.exports=c,c.prototype=new d,c.prototype.constructor=c,c.prototype.computeB=function(a,b,c){var d=this.G;d[2]=-1,d[5]=this.ratio;var e=this.computeGiMf(),f=this.computeGW(),g=-f*b-c*e;return g}}).call(this,a("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/equations/RotationalVelocityEquation.js","/equations")},{"../math/vec2":33,"./Equation":25,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,buffer:1}],29:[function(a,b){(function(){var a=function(){};b.exports=a,a.prototype={constructor:a,on:function(a,b,c){b.context=c||this,void 0===this._listeners&&(this._listeners={});var d=this._listeners;return void 0===d[a]&&(d[a]=[]),-1===d[a].indexOf(b)&&d[a].push(b),this},has:function(a,b){if(void 0===this._listeners)return!1;var c=this._listeners;if(b){if(void 0!==c[a]&&-1!==c[a].indexOf(b))return!0}else if(void 0!==c[a])return!0;return!1},off:function(a,b){if(void 0===this._listeners)return this;var c=this._listeners,d=c[a].indexOf(b);return-1!==d&&c[a].splice(d,1),this},emit:function(a){if(void 0===this._listeners)return this;var b=this._listeners,c=b[a.type];if(void 0!==c){a.target=this;for(var d=0,e=c.length;e>d;d++){var f=c[d];f.call(f.context,a)}}return this}}}).call(this,a("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/events/EventEmitter.js","/events")},{"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,buffer:1}],30:[function(a,b){(function(){function c(a,b,f){if(f=f||{},!(a instanceof d&&b instanceof d))throw new Error("First two arguments must be Material instances.");this.id=c.idCounter++,this.materialA=a,this.materialB=b,this.friction="undefined"!=typeof f.friction?Number(f.friction):.3,this.restitution="undefined"!=typeof f.restitution?Number(f.restitution):0,this.stiffness="undefined"!=typeof f.stiffness?Number(f.stiffness):e.DEFAULT_STIFFNESS,this.relaxation="undefined"!=typeof f.relaxation?Number(f.relaxation):e.DEFAULT_RELAXATION,this.frictionStiffness="undefined"!=typeof f.frictionStiffness?Number(f.frictionStiffness):e.DEFAULT_STIFFNESS,this.frictionRelaxation="undefined"!=typeof f.frictionRelaxation?Number(f.frictionRelaxation):e.DEFAULT_RELAXATION,this.surfaceVelocity="undefined"!=typeof f.surfaceVelocity?Number(f.surfaceVelocity):0,this.contactSkinSize=.005}var d=a("./Material"),e=a("../equations/Equation");b.exports=c,c.idCounter=0}).call(this,a("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/material/ContactMaterial.js","/material")},{"../equations/Equation":25,"./Material":31,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,buffer:1}],31:[function(a,b){(function(){function a(b){this.id=b||a.idCounter++}b.exports=a,a.idCounter=0}).call(this,a("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/material/Material.js","/material")},{"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,buffer:1}],32:[function(a,b){(function(){var a={};a.GetArea=function(a){if(a.length<6)return 0;for(var b=a.length-2,c=0,d=0;b>d;d+=2)c+=(a[d+2]-a[d])*(a[d+1]+a[d+3]);return c+=(a[0]-a[b])*(a[b+1]+a[1]),.5*-c},a.Triangulate=function(b){var c=b.length>>1;if(3>c)return[];for(var d=[],e=[],f=0;c>f;f++)e.push(f);for(var f=0,g=c;g>3;){var h=e[(f+0)%g],i=e[(f+1)%g],j=e[(f+2)%g],k=b[2*h],l=b[2*h+1],m=b[2*i],n=b[2*i+1],o=b[2*j],p=b[2*j+1],q=!1;if(a._convex(k,l,m,n,o,p)){q=!0;for(var r=0;g>r;r++){var s=e[r];if(s!=h&&s!=i&&s!=j&&a._PointInTriangle(b[2*s],b[2*s+1],k,l,m,n,o,p)){q=!1;break}}}if(q)d.push(h,i,j),e.splice((f+1)%g,1),g--,f=0;else if(f++>3*g)break}return d.push(e[0],e[1],e[2]),d},a._PointInTriangle=function(a,b,c,d,e,f,g,h){var i=g-c,j=h-d,k=e-c,l=f-d,m=a-c,n=b-d,o=i*i+j*j,p=i*k+j*l,q=i*m+j*n,r=k*k+l*l,s=k*m+l*n,t=1/(o*r-p*p),u=(r*q-p*s)*t,v=(o*s-p*q)*t;return u>=0&&v>=0&&1>u+v},a._convex=function(a,b,c,d,e,f){return(b-d)*(e-c)+(c-a)*(f-d)>=0},b.exports=a}).call(this,a("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/math/polyk.js","/math")},{"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,buffer:1}],33:[function(a,b){(function(){var c=b.exports={},d=a("../utils/Utils");c.crossLength=function(a,b){return a[0]*b[1]-a[1]*b[0]},c.crossVZ=function(a,b,d){return c.rotate(a,b,-Math.PI/2),c.scale(a,a,d),a},c.crossZV=function(a,b,d){return c.rotate(a,d,Math.PI/2),c.scale(a,a,b),a},c.rotate=function(a,b,c){if(0!==c){var d=Math.cos(c),e=Math.sin(c),f=b[0],g=b[1];a[0]=d*f-e*g,a[1]=e*f+d*g}else a[0]=b[0],a[1]=b[1]},c.rotate90cw=function(a,b){var c=b[0],d=b[1];a[0]=d,a[1]=-c},c.toLocalFrame=function(a,b,d,e){c.copy(a,b),c.sub(a,a,d),c.rotate(a,a,-e)},c.toGlobalFrame=function(a,b,d,e){c.copy(a,b),c.rotate(a,a,e),c.add(a,a,d)},c.centroid=function(a,b,d,e){return c.add(a,b,d),c.add(a,a,e),c.scale(a,a,1/3),a},c.create=function(){var a=new d.ARRAY_TYPE(2);return a[0]=0,a[1]=0,a},c.clone=function(a){var b=new d.ARRAY_TYPE(2);return b[0]=a[0],b[1]=a[1],b},c.fromValues=function(a,b){var c=new d.ARRAY_TYPE(2);return c[0]=a,c[1]=b,c},c.copy=function(a,b){return a[0]=b[0],a[1]=b[1],a},c.set=function(a,b,c){return a[0]=b,a[1]=c,a},c.add=function(a,b,c){return a[0]=b[0]+c[0],a[1]=b[1]+c[1],a},c.subtract=function(a,b,c){return a[0]=b[0]-c[0],a[1]=b[1]-c[1],a},c.sub=c.subtract,c.multiply=function(a,b,c){return a[0]=b[0]*c[0],a[1]=b[1]*c[1],a},c.mul=c.multiply,c.divide=function(a,b,c){return a[0]=b[0]/c[0],a[1]=b[1]/c[1],a},c.div=c.divide,c.scale=function(a,b,c){return a[0]=b[0]*c,a[1]=b[1]*c,a},c.distance=function(a,b){var c=b[0]-a[0],d=b[1]-a[1];return Math.sqrt(c*c+d*d)},c.dist=c.distance,c.squaredDistance=function(a,b){var c=b[0]-a[0],d=b[1]-a[1];return c*c+d*d},c.sqrDist=c.squaredDistance,c.length=function(a){var b=a[0],c=a[1];return Math.sqrt(b*b+c*c)},c.len=c.length,c.squaredLength=function(a){var b=a[0],c=a[1];return b*b+c*c},c.sqrLen=c.squaredLength,c.negate=function(a,b){return a[0]=-b[0],a[1]=-b[1],a},c.normalize=function(a,b){var c=b[0],d=b[1],e=c*c+d*d;return e>0&&(e=1/Math.sqrt(e),a[0]=b[0]*e,a[1]=b[1]*e),a},c.dot=function(a,b){return a[0]*b[0]+a[1]*b[1]},c.str=function(a){return"vec2("+a[0]+", "+a[1]+")"}}).call(this,a("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/math/vec2.js","/math")},{"../utils/Utils":52,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,buffer:1}],34:[function(a,b){(function(){function c(a){a=a||{},h.call(this),this.id=++c._idCounter,this.world=null,this.shapes=[],this.shapeOffsets=[],this.shapeAngles=[],this.mass=a.mass||0,this.invMass=0,this.inertia=0,this.invInertia=0,this.invMassSolve=0,this.invInertiaSolve=0,this.fixedRotation=!!a.fixedRotation||!1,this.position=d.fromValues(0,0),a.position&&d.copy(this.position,a.position),this.interpolatedPosition=d.fromValues(0,0),this.interpolatedAngle=0,this.previousPosition=d.fromValues(0,0),this.previousAngle=0,this.velocity=d.fromValues(0,0),a.velocity&&d.copy(this.velocity,a.velocity),this.vlambda=d.fromValues(0,0),this.wlambda=0,this.angle=a.angle||0,this.angularVelocity=a.angularVelocity||0,this.force=d.create(),a.force&&d.copy(this.force,a.force),this.angularForce=a.angularForce||0,this.damping="number"==typeof a.damping?a.damping:.1,this.angularDamping="number"==typeof a.angularDamping?a.angularDamping:.1,this.type=c.STATIC,this.type="undefined"!=typeof a.type?a.type:a.mass?c.DYNAMIC:c.STATIC,this.boundingRadius=0,this.aabb=new g,this.aabbNeedsUpdate=!0,this.allowSleep=!0,this.wantsToSleep=!1,this.sleepState=c.AWAKE,this.sleepSpeedLimit=.2,this.sleepTimeLimit=1,this.gravityScale=1,this.timeLastSleepy=0,this.concavePath=null,this.lastDampingScale=1,this.lastAngularDampingScale=1,this.lastDampingTimeStep=-1,this._wakeUpAfterNarrowphase=!1,this.updateMassProperties()}var d=a("../math/vec2"),e=a("poly-decomp"),f=a("../shapes/Convex"),g=a("../collision/AABB"),h=a("../events/EventEmitter");b.exports=c,c.prototype=new h,c._idCounter=0,c.prototype.updateSolveMassProperties=function(){this.sleepState===c.SLEEPING||this.type===c.KINEMATIC?(this.invMassSolve=0,this.invInertiaSolve=0):(this.invMassSolve=this.invMass,this.invInertiaSolve=this.invInertia)},c.prototype.setDensity=function(a){var b=this.getArea();this.mass=b*a,this.updateMassProperties()},c.prototype.getArea=function(){for(var a=0,b=0;be&&(e=h+i)}this.boundingRadius=e},c.prototype.addShape=function(a,b,c){c=c||0,b=b?d.fromValues(b[0],b[1]):d.fromValues(0,0),this.shapes.push(a),this.shapeOffsets.push(b),this.shapeAngles.push(c),this.updateMassProperties(),this.updateBoundingRadius(),this.aabbNeedsUpdate=!0},c.prototype.removeShape=function(a){var b=this.shapes.indexOf(a);return-1!==b?(this.shapes.splice(b,1),this.shapeOffsets.splice(b,1),this.shapeAngles.splice(b,1),this.aabbNeedsUpdate=!0,!0):!1},c.prototype.updateMassProperties=function(){if(this.type===c.STATIC||this.type===c.KINEMATIC)this.mass=Number.MAX_VALUE,this.invMass=0,this.inertia=Number.MAX_VALUE,this.invInertia=0;else{var a=this.shapes,b=a.length,e=this.mass/b,f=0;if(this.fixedRotation)this.inertia=Number.MAX_VALUE,this.invInertia=0;else{for(var g=0;b>g;g++){var h=a[g],i=d.squaredLength(this.shapeOffsets[g]),j=h.computeMomentOfInertia(e);f+=j+e*i}this.inertia=f,this.invInertia=f>0?1/f:0}this.invMass=1/this.mass}};var k=d.create();c.prototype.applyForce=function(a,b){var c=k;d.sub(c,b,this.position),d.add(this.force,this.force,a);var e=d.crossLength(c,a);this.angularForce+=e},c.prototype.toLocalFrame=function(a,b){d.toLocalFrame(a,b,this.position,this.angle)},c.prototype.toWorldFrame=function(a,b){d.toGlobalFrame(a,b,this.position,this.angle)},c.prototype.fromPolygon=function(a,b){b=b||{};for(var c=this.shapes.length;c>=0;--c)this.removeShape(this.shapes[c]);var g=new e.Polygon;if(g.vertices=a,g.makeCCW(),"number"==typeof b.removeCollinearPoints&&g.removeCollinearPoints(b.removeCollinearPoints),"undefined"==typeof b.skipSimpleCheck&&!g.isSimple())return!1;this.concavePath=g.vertices.slice(0);for(var c=0;c=g?(this.idleTime=0,this.sleepState=c.AWAKE):(this.idleTime+=e,this.sleepState=c.SLEEPY),this.idleTime>this.sleepTimeLimit&&(b?this.wantsToSleep=!0:this.sleep())}},c.prototype.getVelocityFromPosition=function(a,b){return a=a||d.create(),d.sub(a,this.position,this.previousPosition),d.scale(a,a,1/b),a},c.prototype.getAngularVelocityFromPosition=function(a){return(this.angle-this.previousAngle)/a},c.prototype.overlaps=function(a){return this.world.overlapKeeper.bodiesAreOverlapping(this,a)},c.sleepyEvent={type:"sleepy"},c.sleepEvent={type:"sleep"},c.wakeUpEvent={type:"wakeup"},c.DYNAMIC=1,c.STATIC=2,c.KINEMATIC=4,c.AWAKE=0,c.SLEEPY=1,c.SLEEPING=2}).call(this,a("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/objects/Body.js","/objects")},{"../collision/AABB":11,"../events/EventEmitter":29,"../math/vec2":33,"../shapes/Convex":41,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,buffer:1,"poly-decomp":9}],35:[function(a,b){(function(){function c(a,b,c){c=c||{},e.call(this,a,b,c),this.localAnchorA=d.fromValues(0,0),this.localAnchorB=d.fromValues(0,0),c.localAnchorA&&d.copy(this.localAnchorA,c.localAnchorA),c.localAnchorB&&d.copy(this.localAnchorB,c.localAnchorB),c.worldAnchorA&&this.setWorldAnchorA(c.worldAnchorA),c.worldAnchorB&&this.setWorldAnchorB(c.worldAnchorB);var f=d.create(),g=d.create();this.getWorldAnchorA(f),this.getWorldAnchorB(g);var h=d.distance(f,g);this.restLength="number"==typeof c.restLength?c.restLength:h}{var d=a("../math/vec2"),e=a("./Spring");a("../utils/Utils")}b.exports=c,c.prototype=new e,c.prototype.setWorldAnchorA=function(a){this.bodyA.toLocalFrame(this.localAnchorA,a)},c.prototype.setWorldAnchorB=function(a){this.bodyB.toLocalFrame(this.localAnchorB,a)},c.prototype.getWorldAnchorA=function(a){this.bodyA.toWorldFrame(a,this.localAnchorA)},c.prototype.getWorldAnchorB=function(a){this.bodyB.toWorldFrame(a,this.localAnchorB)};var f=d.create(),g=d.create(),h=d.create(),i=d.create(),j=d.create(),k=d.create(),l=d.create(),m=d.create(),n=d.create();c.prototype.applyForce=function(){var a=this.stiffness,b=this.damping,c=this.restLength,e=this.bodyA,o=this.bodyB,p=f,q=g,r=h,s=i,t=n,u=j,v=k,w=l,x=m;this.getWorldAnchorA(u),this.getWorldAnchorB(v),d.sub(w,u,e.position),d.sub(x,v,o.position),d.sub(p,v,u);var y=d.len(p);d.normalize(q,p),d.sub(r,o.velocity,e.velocity),d.crossZV(t,o.angularVelocity,x),d.add(r,r,t),d.crossZV(t,e.angularVelocity,w),d.sub(r,r,t),d.scale(s,q,-a*(y-c)-b*d.dot(r,q)),d.sub(e.force,e.force,s),d.add(o.force,o.force,s);var z=d.crossLength(w,s),A=d.crossLength(x,s);e.angularForce-=z,o.angularForce+=A}}).call(this,a("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/objects/LinearSpring.js","/objects")},{"../math/vec2":33,"../utils/Utils":52,"./Spring":37,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,buffer:1}],36:[function(a,b){(function(){function c(a,b,c){c=c||{},d.call(this,a,b,c),this.restAngle="number"==typeof c.restAngle?c.restAngle:b.angle-a.angle}var d=(a("../math/vec2"),a("./Spring"));b.exports=c,c.prototype=new d,c.prototype.applyForce=function(){var a=this.stiffness,b=this.damping,c=this.restAngle,d=this.bodyA,e=this.bodyB,f=e.angle-d.angle,g=e.angularVelocity-d.angularVelocity,h=-a*(f-c)-b*g*0;d.angularForce-=h,e.angularForce+=h}}).call(this,a("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/objects/RotationalSpring.js","/objects")},{"../math/vec2":33,"./Spring":37,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,buffer:1}],37:[function(a,b){(function(){function c(a,b,c){c=d.defaults(c,{stiffness:100,damping:1}),this.stiffness=c.stiffness,this.damping=c.damping,this.bodyA=a,this.bodyB=b}var d=(a("../math/vec2"),a("../utils/Utils"));b.exports=c,c.prototype.applyForce=function(){}}).call(this,a("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/objects/Spring.js","/objects")},{"../math/vec2":33,"../utils/Utils":52,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,buffer:1}],38:[function(a,b){(function(){b.exports={AABB:a("./collision/AABB"),AngleLockEquation:a("./equations/AngleLockEquation"),Body:a("./objects/Body"),Broadphase:a("./collision/Broadphase"),Capsule:a("./shapes/Capsule"),Circle:a("./shapes/Circle"),Constraint:a("./constraints/Constraint"),ContactEquation:a("./equations/ContactEquation"),ContactMaterial:a("./material/ContactMaterial"),Convex:a("./shapes/Convex"),DistanceConstraint:a("./constraints/DistanceConstraint"),Equation:a("./equations/Equation"),EventEmitter:a("./events/EventEmitter"),FrictionEquation:a("./equations/FrictionEquation"),GearConstraint:a("./constraints/GearConstraint"),GridBroadphase:a("./collision/GridBroadphase"),GSSolver:a("./solver/GSSolver"),Heightfield:a("./shapes/Heightfield"),Line:a("./shapes/Line"),LockConstraint:a("./constraints/LockConstraint"),Material:a("./material/Material"),Narrowphase:a("./collision/Narrowphase"),NaiveBroadphase:a("./collision/NaiveBroadphase"),Particle:a("./shapes/Particle"),Plane:a("./shapes/Plane"),RevoluteConstraint:a("./constraints/RevoluteConstraint"),PrismaticConstraint:a("./constraints/PrismaticConstraint"),Rectangle:a("./shapes/Rectangle"),RotationalVelocityEquation:a("./equations/RotationalVelocityEquation"),SAPBroadphase:a("./collision/SAPBroadphase"),Shape:a("./shapes/Shape"),Solver:a("./solver/Solver"),Spring:a("./objects/Spring"),LinearSpring:a("./objects/LinearSpring"),RotationalSpring:a("./objects/RotationalSpring"),Utils:a("./utils/Utils"),World:a("./world/World"),vec2:a("./math/vec2"),version:a("../package.json").version}}).call(this,a("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/p2.js","/")},{"../package.json":10,"./collision/AABB":11,"./collision/Broadphase":12,"./collision/GridBroadphase":13,"./collision/NaiveBroadphase":14,"./collision/Narrowphase":15,"./collision/SAPBroadphase":16,"./constraints/Constraint":17,"./constraints/DistanceConstraint":18,"./constraints/GearConstraint":19,"./constraints/LockConstraint":20,"./constraints/PrismaticConstraint":21,"./constraints/RevoluteConstraint":22,"./equations/AngleLockEquation":23,"./equations/ContactEquation":24,"./equations/Equation":25,"./equations/FrictionEquation":26,"./equations/RotationalVelocityEquation":28,"./events/EventEmitter":29,"./material/ContactMaterial":30,"./material/Material":31,"./math/vec2":33,"./objects/Body":34,"./objects/LinearSpring":35,"./objects/RotationalSpring":36,"./objects/Spring":37,"./shapes/Capsule":39,"./shapes/Circle":40,"./shapes/Convex":41,"./shapes/Heightfield":42,"./shapes/Line":43,"./shapes/Particle":44,"./shapes/Plane":45,"./shapes/Rectangle":46,"./shapes/Shape":47,"./solver/GSSolver":48,"./solver/Solver":49,"./utils/Utils":52,"./world/World":56,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,buffer:1}],39:[function(a,b){(function(){function c(a,b){this.length=a||1,this.radius=b||1,d.call(this,d.CAPSULE)}var d=a("./Shape"),e=a("../math/vec2");b.exports=c,c.prototype=new d,c.prototype.computeMomentOfInertia=function(a){var b=this.radius,c=this.length+b,d=2*b;return a*(d*d+c*c)/12},c.prototype.updateBoundingRadius=function(){this.boundingRadius=this.radius+this.length/2},c.prototype.updateArea=function(){this.area=Math.PI*this.radius*this.radius+2*this.radius*this.length};var f=e.create();c.prototype.computeAABB=function(a,b,c){var d=this.radius;e.set(f,this.length/2,0),0!==c&&e.rotate(f,f,c),e.set(a.upperBound,Math.max(f[0]+d,-f[0]+d),Math.max(f[1]+d,-f[1]+d)),e.set(a.lowerBound,Math.min(f[0]-d,-f[0]-d),Math.min(f[1]-d,-f[1]-d)),e.add(a.lowerBound,a.lowerBound,b),e.add(a.upperBound,a.upperBound,b)}}).call(this,a("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/shapes/Capsule.js","/shapes")},{"../math/vec2":33,"./Shape":47,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,buffer:1}],40:[function(a,b){(function(){function c(a){this.radius=a||1,d.call(this,d.CIRCLE)}var d=a("./Shape"),e=a("../math/vec2");b.exports=c,c.prototype=new d,c.prototype.computeMomentOfInertia=function(a){var b=this.radius;return a*b*b/2},c.prototype.updateBoundingRadius=function(){this.boundingRadius=this.radius},c.prototype.updateArea=function(){this.area=Math.PI*this.radius*this.radius},c.prototype.computeAABB=function(a,b){var c=this.radius;e.set(a.upperBound,c,c),e.set(a.lowerBound,-c,-c),b&&(e.add(a.lowerBound,a.lowerBound,b),e.add(a.upperBound,a.upperBound,b))}}).call(this,a("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/shapes/Circle.js","/shapes")},{"../math/vec2":33,"./Shape":47,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,buffer:1}],41:[function(a,b){(function(){function c(a,b){this.vertices=[],this.axes=[];for(var c=0;cf)&&(f=d),(null===h||h>d)&&(h=d);if(h>f){var j=h;h=f,f=j}e.set(b,h,f)},c.prototype.projectOntoWorldAxis=function(a,b,c,d){var f=h;this.projectOntoLocalAxis(a,d),0!==c?e.rotate(f,a,c):f=a;var g=e.dot(b,f);e.set(d,d[0]+g,d[1]+g)},c.prototype.updateTriangles=function(){this.triangles.length=0;for(var a=[],b=0;bg;f=g,g++){var h=this.vertices[f],i=this.vertices[g],j=Math.abs(e.crossLength(h,i)),k=e.dot(i,i)+e.dot(i,h)+e.dot(h,h);b+=j*k,c+=j}return a/6*(b/c)},c.prototype.updateBoundingRadius=function(){for(var a=this.vertices,b=0,c=0;c!==a.length;c++){var d=e.squaredLength(a[c]);d>b&&(b=d)}this.boundingRadius=Math.sqrt(b)},c.triangleArea=function(a,b,c){return.5*((b[0]-a[0])*(c[1]-a[1])-(c[0]-a[0])*(b[1]-a[1]))},c.prototype.updateArea=function(){this.updateTriangles(),this.area=0;for(var a=this.triangles,b=this.vertices,d=0;d!==a.length;d++){var e=a[d],f=b[e[0]],g=b[e[1]],h=b[e[2]],i=c.triangleArea(f,g,h);this.area+=i}},c.prototype.computeAABB=function(a,b,c){a.setFromPoints(this.vertices,b,c,0)}}).call(this,a("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/shapes/Convex.js","/shapes")},{"../math/polyk":32,"../math/vec2":33,"./Shape":47,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,buffer:1,"poly-decomp":9}],42:[function(a,b){(function(){function c(a,b){if(b=e.defaults(b,{maxValue:null,minValue:null,elementWidth:.1}),null===b.minValue||null===b.maxValue){b.maxValue=a[0],b.minValue=a[0];for(var c=0;c!==a.length;c++){var f=a[c];f>b.maxValue&&(b.maxValue=f),f=w*w)break}for(c.updateMultipliers(k,q,1/a),x=0;x!==l;x++){var z=k[x];if(z instanceof h){for(var A=0,B=0;B!==z.contactEquations.length;B++)A+=z.contactEquations[B].multiplier;A*=z.frictionCoefficient/z.contactEquations.length,z.maxForce=A,z.minForce=-A}}}for(f=0;f!==i;f++){for(w=0,x=0;x!==l;x++){v=k[x];var y=c.iterateEquation(x,v,v.epsilon,u,t,q,p,a,f);w+=Math.abs(y)}if(this.usedIterations++,m>=w*w)break}for(r=0;r!==o;r++)n[r].addConstraintVelocity();c.updateMultipliers(k,q,1/a)}},c.updateMultipliers=function(a,b,c){for(var d=a.length;d--;)a[d].multiplier=b[d]*c},c.iterateEquation=function(a,b,c,d,e,f,g,h){var i=d[a],j=e[a],k=f[a],l=b.computeGWlambda(),m=b.maxForce,n=b.minForce;g&&(i=0);var o=j*(i-l-c*k),p=k+o;return n*h>p?o=n*h-k:p>m*h&&(o=m*h-k),f[a]+=o,b.addToWlambda(o),o}}).call(this,a("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/solver/GSSolver.js","/solver")},{"../equations/FrictionEquation":26,"../math/vec2":33,"../utils/Utils":52,"./Solver":49,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,buffer:1}],49:[function(a,b){(function(){function c(a,b){a=a||{},d.call(this),this.type=b,this.equations=[],this.equationSortFunction=a.equationSortFunction||!1}var d=(a("../utils/Utils"),a("../events/EventEmitter"));b.exports=c,c.prototype=new d,c.prototype.solve=function(){throw new Error("Solver.solve should be implemented by subclasses!")};var e={bodies:[]};c.prototype.solveIsland=function(a,b){this.removeAllEquations(),b.equations.length&&(this.addEquations(b.equations),e.bodies.length=0,b.getBodies(e.bodies),e.bodies.length&&this.solve(a,e))},c.prototype.sortEquations=function(){this.equationSortFunction&&this.equations.sort(this.equationSortFunction)},c.prototype.addEquation=function(a){a.enabled&&this.equations.push(a)},c.prototype.addEquations=function(a){for(var b=0,c=a.length;b!==c;b++){var d=a[b];d.enabled&&this.equations.push(d)}},c.prototype.removeEquation=function(a){var b=this.equations.indexOf(a);-1!==b&&this.equations.splice(b,1)},c.prototype.removeAllEquations=function(){this.equations.length=0},c.GS=1,c.ISLAND=2}).call(this,a("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/solver/Solver.js","/solver")},{"../events/EventEmitter":29,"../utils/Utils":52,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,buffer:1}],50:[function(a,b){(function(){function c(){this.overlappingShapesLastState=new e,this.overlappingShapesCurrentState=new e,this.recordPool=[],this.tmpDict=new e,this.tmpArray1=[]}function d(a,b,c,d){this.shapeA=b,this.shapeB=d,this.bodyA=a,this.bodyB=c}{var e=a("./TupleDictionary");a("./Utils")}b.exports=c,c.prototype.tick=function(){for(var a=this.overlappingShapesLastState,b=this.overlappingShapesCurrentState,c=a.keys.length;c--;){var d=a.keys[c],e=a.getByKey(d),f=b.getByKey(d);e&&!f&&this.recordPool.push(e)}a.reset(),a.copy(b),b.reset()},c.prototype.setOverlapping=function(a,b,c,e){var f=(this.overlappingShapesLastState,this.overlappingShapesCurrentState);if(!f.get(b.id,e.id)){var g;this.recordPool.length?(g=this.recordPool.pop(),g.set(a,b,c,e)):g=new d(a,b,c,e),f.set(b.id,e.id,g)}},c.prototype.getNewOverlaps=function(a){return this.getDiff(this.overlappingShapesLastState,this.overlappingShapesCurrentState,a)},c.prototype.getEndOverlaps=function(a){return this.getDiff(this.overlappingShapesCurrentState,this.overlappingShapesLastState,a)},c.prototype.bodiesAreOverlapping=function(a,b){for(var c=this.overlappingShapesCurrentState,d=c.keys.length;d--;){var e=c.keys[d],f=c.data[e];if(f.bodyA===a&&f.bodyB===b||f.bodyA===b&&f.bodyB===a)return!0}return!1},c.prototype.getDiff=function(a,b,c){var c=c||[],d=a,e=b;c.length=0;for(var f=e.keys.length;f--;){var g=e.keys[f],h=e.data[g];if(!h)throw new Error("Key "+g+" had no data!");var i=d.data[g];i||c.push(h)}return c},c.prototype.isNewOverlap=function(a,b){var c=0|a.id,d=0|b.id,e=this.overlappingShapesLastState,f=this.overlappingShapesCurrentState;return!e.get(c,d)&&!!f.get(c,d)},c.prototype.getNewBodyOverlaps=function(a){this.tmpArray1.length=0;var b=this.getNewOverlaps(this.tmpArray1);return this.getBodyDiff(b,a)},c.prototype.getEndBodyOverlaps=function(a){this.tmpArray1.length=0;var b=this.getEndOverlaps(this.tmpArray1);return this.getBodyDiff(b,a)},c.prototype.getBodyDiff=function(a,b){b=b||[];for(var c=this.tmpDict,d=a.length;d--;){var e=a[d]; -c.set(0|e.bodyA.id,0|e.bodyB.id,e)}for(d=c.keys.length;d--;){var e=c.getByKey(c.keys[d]);e&&b.push(e.bodyA,e.bodyB)}return c.reset(),b},d.prototype.set=function(a,b,c,e){d.call(this,a,b,c,e)}}).call(this,a("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/utils/OverlapKeeper.js","/utils")},{"./TupleDictionary":51,"./Utils":52,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,buffer:1}],51:[function(a,b){(function(){function c(){this.data={},this.keys=[]}var d=a("./Utils");b.exports=c,c.prototype.getKey=function(a,b){return a=0|a,b=0|b,(0|a)===(0|b)?-1:0|((0|a)>(0|b)?a<<16|65535&b:b<<16|65535&a)},c.prototype.getByKey=function(a){return a=0|a,this.data[a]},c.prototype.get=function(a,b){return this.data[this.getKey(a,b)]},c.prototype.set=function(a,b,c){if(!c)throw new Error("No data!");var d=this.getKey(a,b);return this.data[d]||this.keys.push(d),this.data[d]=c,d},c.prototype.reset=function(){for(var a=this.data,b=this.keys,c=b.length;c--;)delete a[b[c]];b.length=0},c.prototype.copy=function(a){this.reset(),d.appendArray(this.keys,a.keys);for(var b=a.keys.length;b--;){var c=a.keys[b];this.data[c]=a.data[c]}}}).call(this,a("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/utils/TupleDictionary.js","/utils")},{"./Utils":52,"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,buffer:1}],52:[function(a,b){(function(){function a(){}b.exports=a,a.appendArray=function(a,b){if(b.length<15e4)a.push.apply(a,b);else for(var c=0,d=b.length;c!==d;++c)a.push(b[c])},a.splice=function(a,b,c){c=c||1;for(var d=b,e=a.length-c;e>d;d++)a[d]=a[d+c];a.length=e},a.ARRAY_TYPE="undefined"!=typeof P2_ARRAY_TYPE?P2_ARRAY_TYPE:"undefined"!=typeof Float32Array?Float32Array:Array,a.extend=function(a,b){for(var c in b)a[c]=b[c]},a.defaults=function(a,b){a=a||{};for(var c in b)c in a||(a[c]=b[c]);return a}}).call(this,a("/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/utils/Utils.js","/utils")},{"/Users/schteppe/git/p2.js/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":4,buffer:1}],53:[function(a,b){(function(){function c(){this.equations=[],this.bodies=[]}var d=a("../objects/Body");b.exports=c,c.prototype.reset=function(){this.equations.length=this.bodies.length=0};var e=[];c.prototype.getBodies=function(a){var b=a||[],c=this.equations;e.length=0;for(var d=0;d!==c.length;d++){var f=c[d];-1===e.indexOf(f.bodyA.id)&&(b.push(f.bodyA),e.push(f.bodyA.id)),-1===e.indexOf(f.bodyB.id)&&(b.push(f.bodyB),e.push(f.bodyB.id))}return b},c.prototype.wantsToSleep=function(){for(var a=0;a1e3*a));g++);this.time+=b;for(var h=this.time%a,i=h/a,j=0;j!==this.bodies.length;j++){var k=this.bodies[j];k.type!==m.STATIC&&k.sleepState!==m.SLEEPING?(f.sub(x,k.position,k.previousPosition),f.scale(x,x,i),f.add(k.interpolatedPosition,k.position,x),k.interpolatedAngle=k.angle+(k.angle-k.previousAngle)*i):(f.copy(k.interpolatedPosition,k.position),k.interpolatedAngle=k.angle)}}};var y=[];c.prototype.internalStep=function(a){this.stepping=!0;var b,d,e=this,g=this.doProfiling,h=this.springs.length,i=this.springs,j=this.bodies,k=this.gravity,l=this.solver,n=this.bodies.length,o=this.broadphase,p=this.narrowphase,r=this.constraints,s=u,t=(f.scale,f.add),v=(f.rotate,this.islandManager);if(this.overlapKeeper.tick(),this.lastTimeStep=a,g&&(b=performance.now()),this.useWorldGravityAsFrictionGravity){var w=f.length(this.gravity);0===w&&this.useFrictionGravityOnZeroGravity||(this.frictionGravity=w)}if(this.applyGravity)for(var x=0;x!==n;x++){var z=j[x],A=z.force;z.type===m.DYNAMIC&&z.sleepState!==m.SLEEPING&&(f.scale(s,k,z.mass*z.gravityScale),t(A,A,s))}if(this.applySpringForces)for(var x=0;x!==h;x++){var B=i[x];B.applyForce()}if(this.applyDamping)for(var x=0;x!==n;x++){var z=j[x];z.type===m.DYNAMIC&&z.applyDamping(a)}for(var C=o.getCollisionPairs(this),D=this.disabledBodyCollisionPairs,x=D.length-2;x>=0;x-=2)for(var E=C.length-2;E>=0;E-=2)(D[x]===C[E]&&D[x+1]===C[E+1]||D[x+1]===C[E]&&D[x]===C[E+1])&&C.splice(E,2);var F=r.length;for(x=0;x!==F;x++){var G=r[x];if(!G.collideConnected)for(var E=C.length-2;E>=0;E-=2)(G.bodyA===C[E]&&G.bodyB===C[E+1]||G.bodyB===C[E]&&G.bodyA===C[E+1])&&C.splice(E,2)}this.postBroadphaseEvent.pairs=C,this.emit(this.postBroadphaseEvent),p.reset(this);for(var x=0,H=C.length;x!==H;x+=2)for(var I=C[x],J=C[x+1],K=0,L=I.shapes.length;K!==L;K++)for(var M=I.shapes[K],N=I.shapeOffsets[K],O=I.shapeAngles[K],P=0,Q=J.shapes.length;P!==Q;P++){var R=J.shapes[P],S=J.shapeOffsets[P],T=J.shapeAngles[P],U=this.defaultContactMaterial;if(M.material&&R.material){var V=this.getContactMaterial(M.material,R.material);V&&(U=V)}this.runNarrowphase(p,I,M,N,O,J,R,S,T,U,this.frictionGravity)}for(var x=0;x!==n;x++){var W=j[x];W._wakeUpAfterNarrowphase&&(W.wakeUp(),W._wakeUpAfterNarrowphase=!1)}if(this.has("endContact")){this.overlapKeeper.getEndOverlaps(y);for(var X=this.endContactEvent,P=y.length;P--;){var Y=y[P];X.shapeA=Y.shapeA,X.shapeB=Y.shapeB,X.bodyA=Y.bodyA,X.bodyB=Y.bodyA,this.emit(X)}}var Z=this.preSolveEvent;Z.contactEquations=p.contactEquations,Z.frictionEquations=p.frictionEquations,this.emit(Z);var F=r.length;for(x=0;x!==F;x++)r[x].update();if(p.contactEquations.length||p.frictionEquations.length||r.length)if(this.islandSplit){for(v.equations.length=0,q.appendArray(v.equations,p.contactEquations),q.appendArray(v.equations,p.frictionEquations),x=0;x!==F;x++)q.appendArray(v.equations,r[x].equations);v.split(this);for(var x=0;x!==v.islands.length;x++){var $=v.islands[x];$.equations.length&&l.solveIsland(a,$)}}else{for(l.addEquations(p.contactEquations),l.addEquations(p.frictionEquations),x=0;x!==F;x++)l.addEquations(r[x].equations);this.solveConstraints&&l.solve(a,this),l.removeAllEquations()}for(var x=0;x!==n;x++){var W=j[x];W.sleepState!==m.SLEEPING&&W.type!==m.STATIC&&c.integrateBody(W,a)}for(var x=0;x!==n;x++)j[x].setZeroForce();if(g&&(d=performance.now(),e.lastStepTime=d-b),this.emitImpactEvent&&this.has("impact"))for(var _=this.impactEvent,x=0;x!==p.contactEquations.length;x++){var ab=p.contactEquations[x];ab.firstImpact&&(_.bodyA=ab.bodyA,_.bodyB=ab.bodyB,_.shapeA=ab.shapeA,_.shapeB=ab.shapeB,_.contactEquation=ab,this.emit(_))}if(this.sleepMode===c.BODY_SLEEPING)for(x=0;x!==n;x++)j[x].sleepTick(this.time,!1,a);else if(this.sleepMode===c.ISLAND_SLEEPING&&this.islandSplit){for(x=0;x!==n;x++)j[x].sleepTick(this.time,!0,a);for(var x=0;x0,a.frictionCoefficient=k.friction;var p;p=b.type===m.STATIC||b.type===m.KINEMATIC?g.mass:g.type===m.STATIC||g.type===m.KINEMATIC?b.mass:b.mass*g.mass/(b.mass+g.mass),a.slipForce=k.friction*l*p,a.restitution=k.restitution,a.surfaceVelocity=k.surfaceVelocity,a.frictionStiffness=k.frictionStiffness,a.frictionRelaxation=k.frictionRelaxation,a.stiffness=k.stiffness,a.relaxation=k.relaxation,a.contactSkinSize=k.contactSkinSize;var q=a[c.type|h.type],r=0;if(q){var s=c.sensor||h.sensor,t=a.frictionEquations.length;r=c.type=2*y&&(b._wakeUpAfterNarrowphase=!0)}if(g.allowSleep&&g.type===m.DYNAMIC&&g.sleepState===m.SLEEPING&&b.sleepState===m.AWAKE&&b.type!==m.STATIC){var z=f.squaredLength(b.velocity)+Math.pow(b.angularVelocity,2),A=Math.pow(b.sleepSpeedLimit,2);z>=2*A&&(g._wakeUpAfterNarrowphase=!0)}if(this.overlapKeeper.setOverlapping(b,c,g,h),this.has("beginContact")&&this.overlapKeeper.isNewOverlap(c,h)){var B=this.beginContactEvent;if(B.shapeA=c,B.shapeB=h,B.bodyA=b,B.bodyB=g,B.contactEquations.length=0,"number"==typeof r)for(var C=a.contactEquations.length-r;C1)for(var C=a.frictionEquations.length-u;C=0;b--)this.removeConstraint(a[b]);for(var d=this.bodies,b=d.length-1;b>=0;b--)this.removeBody(d[b]);for(var e=this.springs,b=e.length-1;b>=0;b--)this.removeSpring(e[b]);for(var f=this.contactMaterials,b=f.length-1;b>=0;b--)this.removeContactMaterial(f[b]);c.apply(this)},c.prototype.clone=function(){var a=new c;return a.fromJSON(this.toJSON()),a};var B=f.create(),C=f.fromValues(0,0),D=f.fromValues(0,0);c.prototype.hitTest=function(a,b,c){c=c||0;var d=new m({position:a}),e=new k,l=a,n=0,o=B,p=C,q=D;d.addShape(e);for(var r=this.narrowphase,s=[],t=0,u=b.length;t!==u;t++)for(var v=b[t],w=0,x=v.shapes.length;w!==x;w++){var y=v.shapes[w],z=v.shapeOffsets[w]||p,A=v.shapeAngles[w]||0;f.rotate(o,z,v.angle),f.add(o,o,v.position);var E=A+v.angle;(y instanceof g&&r.circleParticle(v,y,o,E,d,e,l,n,!0)||y instanceof h&&r.particleConvex(d,e,l,n,v,y,o,E,!0)||y instanceof i&&r.particlePlane(d,e,l,n,v,y,o,E,!0)||y instanceof j&&r.particleCapsule(d,e,l,n,v,y,o,E,!0)||y instanceof k&&f.squaredLength(f.sub(q,o,a))=0&&1>=i&&j>=0&&1>=j}},{"./Scalar":4}],2:[function(a,b){function c(){}b.exports=c,c.area=function(a,b,c){return(b[0]-a[0])*(c[1]-a[1])-(c[0]-a[0])*(b[1]-a[1])},c.left=function(a,b,d){return c.area(a,b,d)>0},c.leftOn=function(a,b,d){return c.area(a,b,d)>=0},c.right=function(a,b,d){return c.area(a,b,d)<0},c.rightOn=function(a,b,d){return c.area(a,b,d)<=0};var d=[],e=[];c.collinear=function(a,b,f,g){if(g){var h=d,i=e;h[0]=b[0]-a[0],h[1]=b[1]-a[1],i[0]=f[0]-b[0],i[1]=f[1]-b[1];var j=h[0]*i[0]+h[1]*i[1],k=Math.sqrt(h[0]*h[0]+h[1]*h[1]),l=Math.sqrt(i[0]*i[0]+i[1]*i[1]),m=Math.acos(j/(k*l));return g>m}return 0==c.area(a,b,f)},c.sqdist=function(a,b){var c=b[0]-a[0],d=b[1]-a[1];return c*c+d*d}},{}],3:[function(a,b){function c(){this.vertices=[]}function d(a,b,c,d,e){e=e||0;var f=b[1]-a[1],h=a[0]-b[0],i=f*a[0]+h*a[1],j=d[1]-c[1],k=c[0]-d[0],l=j*c[0]+k*c[1],m=f*k-j*h;return g.eq(m,0,e)?[0,0]:[(k*i-h*l)/m,(f*l-j*i)/m]}var e=a("./Line"),f=a("./Point"),g=a("./Scalar");b.exports=c,c.prototype.at=function(a){var b=this.vertices,c=b.length;return b[0>a?a%c+c:a%c]},c.prototype.first=function(){return this.vertices[0]},c.prototype.last=function(){return this.vertices[this.vertices.length-1]},c.prototype.clear=function(){this.vertices.length=0},c.prototype.append=function(a,b,c){if("undefined"==typeof b)throw new Error("From is not given!");if("undefined"==typeof c)throw new Error("To is not given!");if(b>c-1)throw new Error("lol1");if(c>a.vertices.length)throw new Error("lol2");if(0>b)throw new Error("lol3");for(var d=b;c>d;d++)this.vertices.push(a.vertices[d])},c.prototype.makeCCW=function(){for(var a=0,b=this.vertices,c=1;cb[a][0])&&(a=c);f.left(this.at(a-1),this.at(a),this.at(a+1))||this.reverse()},c.prototype.reverse=function(){for(var a=[],b=0,c=this.vertices.length;b!==c;b++)a.push(this.vertices.pop());this.vertices=a},c.prototype.isReflex=function(a){return f.right(this.at(a-1),this.at(a),this.at(a+1))};var h=[],i=[];c.prototype.canSee=function(a,b){var c,d,g=h,j=i;if(f.leftOn(this.at(a+1),this.at(a),this.at(b))&&f.rightOn(this.at(a-1),this.at(a),this.at(b)))return!1;d=f.sqdist(this.at(a),this.at(b));for(var k=0;k!==this.vertices.length;++k)if((k+1)%this.vertices.length!==a&&k!==a&&f.leftOn(this.at(a),this.at(b),this.at(k+1))&&f.rightOn(this.at(a),this.at(b),this.at(k))&&(g[0]=this.at(a),g[1]=this.at(b),j[0]=this.at(k),j[1]=this.at(k+1),c=e.lineInt(g,j),f.sqdist(this.at(a),c)a)for(var f=a;b>=f;f++)e.vertices.push(this.vertices[f]);else{for(var f=0;b>=f;f++)e.vertices.push(this.vertices[f]);for(var f=a;f0?this.slice(a):[this]},c.prototype.slice=function(a){if(0==a.length)return[this];if(a instanceof Array&&a.length&&a[0]instanceof Array&&2==a[0].length&&a[0][0]instanceof Array){for(var b=[this],c=0;cc;c++)if(e.segmentsIntersect(a[b],a[b+1],a[c],a[c+1]))return!1;for(var b=1;bh)return console.warn("quickDecomp: max level ("+h+") reached."),a;for(var x=0;xo&&(n=o,k=l,r=y))),f.left(v.at(x+1),v.at(x),v.at(y+1))&&f.rightOn(v.at(x+1),v.at(x),v.at(y))&&(l=d(v.at(x+1),v.at(x),v.at(y),v.at(y+1)),f.left(v.at(x-1),v.at(x),l)&&(o=f.sqdist(v.vertices[x],l),m>o&&(m=o,j=l,q=y)));if(r==(q+1)%this.vertices.length)l[0]=(k[0]+j[0])/2,l[1]=(k[1]+j[1])/2,e.push(l),q>x?(t.append(v,x,q+1),t.vertices.push(l),u.vertices.push(l),0!=r&&u.append(v,r,v.vertices.length),u.append(v,0,x+1)):(0!=x&&t.append(v,x,v.vertices.length),t.append(v,0,q+1),t.vertices.push(l),u.vertices.push(l),u.append(v,r,x+1));else{if(r>q&&(q+=this.vertices.length),p=Number.MAX_VALUE,r>q)return a;for(var y=r;q>=y;++y)f.leftOn(v.at(x-1),v.at(x),v.at(y))&&f.rightOn(v.at(x+1),v.at(x),v.at(y))&&(o=f.sqdist(v.at(x),v.at(y)),p>o&&(p=o,s=y%this.vertices.length));s>x?(t.append(v,x,s+1),0!=s&&u.append(v,s,w.length),u.append(v,0,x+1)):(0!=x&&t.append(v,x,w.length),t.append(v,0,s+1),u.append(v,s,x+1))}return t.vertices.length3&&c>=0;--c)f.collinear(this.at(c-1),this.at(c),this.at(c+1),a)&&(this.vertices.splice(c%this.vertices.length,1),c--,b++);return b}},{"./Line":1,"./Point":2,"./Scalar":4}],4:[function(a,b){function c(){}b.exports=c,c.eq=function(a,b,c){return c=c||0,Math.abs(a-b) (http://steffe.se)",keywords:["p2.js","p2","physics","engine","2d"],main:"./src/p2.js",engines:{node:"*"},repository:{type:"git",url:"https://github.com/schteppe/p2.js.git"},bugs:{url:"https://github.com/schteppe/p2.js/issues"},licenses:[{type:"MIT"}],devDependencies:{grunt:"~0.4.0","grunt-contrib-jshint":"~0.9.2","grunt-contrib-nodeunit":"~0.1.2","grunt-contrib-uglify":"~0.4.0","grunt-contrib-watch":"~0.5.0","grunt-browserify":"~2.0.1","grunt-contrib-concat":"^0.4.0"},dependencies:{"poly-decomp":"0.1.0"}}},{}],7:[function(a,b){function c(a){this.lowerBound=d.create(),a&&a.lowerBound&&d.copy(this.lowerBound,a.lowerBound),this.upperBound=d.create(),a&&a.upperBound&&d.copy(this.upperBound,a.upperBound)}{var d=a("../math/vec2");a("../utils/Utils")}b.exports=c;var e=d.create();c.prototype.setFromPoints=function(a,b,c,f){var g=this.lowerBound,h=this.upperBound;"number"!=typeof c&&(c=0),0!==c?d.rotate(g,a[0],c):d.copy(g,a[0]),d.copy(h,g);for(var i=Math.cos(c),j=Math.sin(c),k=1;ko;o++)l[o]>h[o]&&(h[o]=l[o]),l[o]c&&(this.lowerBound[b]=c);var d=a.upperBound[b];this.upperBound[b]=c},c.aabbCheck=function(a,b){return a.getAABB().overlaps(b.getAABB())},c.prototype.boundingVolumeCheck=function(a,b){var d;switch(this.boundingVolumeType){case c.BOUNDING_CIRCLE:d=c.boundingRadiusCheck(a,b);break;case c.AABB:d=c.aabbCheck(a,b);break;default:throw new Error("Bounding volume type not recognized: "+this.boundingVolumeType)}return d},c.canCollide=function(a,b){return a.type===e.STATIC&&b.type===e.STATIC?!1:a.type===e.KINEMATIC&&b.type===e.STATIC||a.type===e.STATIC&&b.type===e.KINEMATIC?!1:a.type===e.KINEMATIC&&b.type===e.KINEMATIC?!1:a.sleepState===e.SLEEPING&&b.sleepState===e.SLEEPING?!1:a.sleepState===e.SLEEPING&&b.type===e.STATIC||b.sleepState===e.SLEEPING&&a.type===e.STATIC?!1:!0},c.NAIVE=1,c.SAP=2},{"../math/vec2":31,"../objects/Body":32}],9:[function(a,b){function c(a){d.apply(this),a=e.defaults(a,{xmin:-100,xmax:100,ymin:-100,ymax:100,nx:10,ny:10}),this.xmin=a.xmin,this.ymin=a.ymin,this.xmax=a.xmax,this.ymax=a.ymax,this.nx=a.nx,this.ny=a.ny,this.binsizeX=(this.xmax-this.xmin)/this.nx,this.binsizeY=(this.ymax-this.ymin)/this.ny}var d=(a("../shapes/Circle"),a("../shapes/Plane"),a("../shapes/Particle"),a("../collision/Broadphase")),e=(a("../math/vec2"),a("../utils/Utils"));b.exports=c,c.prototype=new d,c.prototype.constructor=c,c.prototype.getCollisionPairs=function(a){for(var b=[],c=a.bodies,e=c.length,f=(this.binsizeX,this.binsizeY,this.nx),g=this.ny,h=this.xmin,i=this.ymin,j=this.xmax,k=this.ymax,l=[],m=f*g,n=0;m>n;n++)l.push([]);for(var o=f/(j-h),p=g/(k-i),n=0;n!==e;n++)for(var q=c[n],r=q.aabb,s=Math.max(r.lowerBound[0],h),t=Math.max(r.lowerBound[1],i),u=Math.min(r.upperBound[0],j),v=Math.min(r.upperBound[1],k),w=Math.floor(o*(s-h)),x=Math.floor(p*(t-i)),y=Math.floor(o*(u-h)),z=Math.floor(p*(v-i)),A=w;y>=A;A++)for(var B=x;z>=B;B++){var C=A,D=B,E=C*(g-1)+D;E>=0&&m>E&&l[E].push(q)}for(var n=0;n!==m;n++)for(var F=l[n],A=0,G=F.length;A!==G;A++)for(var q=F[A],B=0;B!==A;B++){var H=F[B];d.canCollide(q,H)&&this.boundingVolumeCheck(q,H)&&b.push(q,H)}return b}},{"../collision/Broadphase":8,"../math/vec2":31,"../shapes/Circle":38,"../shapes/Particle":42,"../shapes/Plane":43,"../utils/Utils":50}],10:[function(a,b){function c(){d.call(this,d.NAIVE)}{var d=(a("../shapes/Circle"),a("../shapes/Plane"),a("../shapes/Shape"),a("../shapes/Particle"),a("../collision/Broadphase"));a("../math/vec2")}b.exports=c,c.prototype=new d,c.prototype.constructor=c,c.prototype.getCollisionPairs=function(a){var b=a.bodies,c=this.result;c.length=0;for(var e=0,f=b.length;e!==f;e++)for(var g=b[e],h=0;e>h;h++){var i=b[h];d.canCollide(g,i)&&this.boundingVolumeCheck(g,i)&&c.push(g,i)}return c},c.prototype.aabbQuery=function(a,b,c){c=c||[];for(var d=a.bodies,e=0;e=r*n)return!1;n=r}return!0}var f=a("../math/vec2"),g=f.sub,h=f.add,i=f.dot,j=a("../utils/Utils"),k=a("../utils/TupleDictionary"),l=a("../equations/Equation"),m=a("../equations/ContactEquation"),n=a("../equations/FrictionEquation"),o=a("../shapes/Circle"),p=a("../shapes/Convex"),q=a("../shapes/Shape"),r=(a("../objects/Body"),a("../shapes/Rectangle"));b.exports=c;var s=f.fromValues(0,1),t=f.fromValues(0,0),u=f.fromValues(0,0),v=f.fromValues(0,0),w=f.fromValues(0,0),x=f.fromValues(0,0),y=f.fromValues(0,0),z=f.fromValues(0,0),A=f.fromValues(0,0),B=f.fromValues(0,0),C=f.fromValues(0,0),D=f.fromValues(0,0),E=f.fromValues(0,0),F=f.fromValues(0,0),G=f.fromValues(0,0),H=f.fromValues(0,0),I=f.fromValues(0,0),J=f.fromValues(0,0),K=f.fromValues(0,0),L=[],M=f.create(),N=f.create();c.prototype.bodiesOverlap=function(a,b){for(var c=M,d=N,e=0,f=a.shapes.length;e!==f;e++){{var g=a.shapes[e],h=a.shapeOffsets[e];a.shapeAngles[e]}a.toWorldFrame(c,h);for(var i=0,j=b.shapes.length;i!==j;i++){{var k=b.shapes[i],l=b.shapeOffsets[i];b.shapeAngles[i]}if(b.toWorldFrame(d,l),this[g.type|k.type](a,g,c,g.angle+a.angle,b,k,d,k.angle+b.angle,!0))return!0}}return!1},c.prototype.collidedLastStep=function(a,b){var c=0|a.id,d=0|b.id;return!!this.collidingBodiesLastStep.get(c,d)},c.prototype.reset=function(){this.collidingBodiesLastStep.reset();for(var a=this.contactEquations,b=a.length;b--;){var c=a[b],d=c.bodyA.id,e=c.bodyB.id;this.collidingBodiesLastStep.set(d,e,!0)}if(this.reuseObjects){var f=this.contactEquations,g=this.frictionEquations,h=this.reusableFrictionEquations,i=this.reusableContactEquations;j.appendArray(i,f),j.appendArray(h,g)}this.contactEquations.length=this.frictionEquations.length=0},c.prototype.createContactEquation=function(a,b,c,d){var e=this.reusableContactEquations.length?this.reusableContactEquations.pop():new m(a,b);return e.bodyA=a,e.bodyB=b,e.shapeA=c,e.shapeB=d,e.restitution=this.restitution,e.firstImpact=!this.collidedLastStep(a,b),e.stiffness=this.stiffness,e.relaxation=this.relaxation,e.needsUpdate=!0,e.enabled=this.enabledEquations,e.offset=this.contactSkinSize,e},c.prototype.createFrictionEquation=function(a,b,c,d){var e=this.reusableFrictionEquations.length?this.reusableFrictionEquations.pop():new n(a,b);return e.bodyA=a,e.bodyB=b,e.shapeA=c,e.shapeB=d,e.setSlipForce(this.slipForce),e.frictionCoefficient=this.frictionCoefficient,e.relativeVelocity=this.surfaceVelocity,e.enabled=this.enabledEquations,e.needsUpdate=!0,e.stiffness=this.frictionStiffness,e.relaxation=this.frictionRelaxation,e.contactEquations.length=0,e},c.prototype.createFrictionFromContact=function(a){var b=this.createFrictionEquation(a.bodyA,a.bodyB,a.shapeA,a.shapeB);return f.copy(b.contactPointA,a.contactPointA),f.copy(b.contactPointB,a.contactPointB),f.rotate90cw(b.t,a.normalA),b.contactEquations.push(a),b},c.prototype.createFrictionFromAverage=function(a){{var b=this.contactEquations[this.contactEquations.length-1],c=this.createFrictionEquation(b.bodyA,b.bodyB,b.shapeA,b.shapeB),d=b.bodyA;b.bodyB}f.set(c.contactPointA,0,0),f.set(c.contactPointB,0,0),f.set(c.t,0,0);for(var e=0;e!==a;e++)b=this.contactEquations[this.contactEquations.length-1-e],b.bodyA===d?(f.add(c.t,c.t,b.normalA),f.add(c.contactPointA,c.contactPointA,b.contactPointA),f.add(c.contactPointB,c.contactPointB,b.contactPointB)):(f.sub(c.t,c.t,b.normalA),f.add(c.contactPointA,c.contactPointA,b.contactPointB),f.add(c.contactPointB,c.contactPointB,b.contactPointA)),c.contactEquations.push(b);var g=1/a;return f.scale(c.contactPointA,c.contactPointA,g),f.scale(c.contactPointB,c.contactPointB,g),f.normalize(c.t,c.t),f.rotate90cw(c.t,c.t),c},c.prototype[q.LINE|q.CONVEX]=c.prototype.convexLine=function(a,b,c,d,e,f,g,h,i){return i?!1:0},c.prototype[q.LINE|q.RECTANGLE]=c.prototype.lineRectangle=function(a,b,c,d,e,f,g,h,i){return i?!1:0};var O=new r(1,1),P=f.create();c.prototype[q.CAPSULE|q.CONVEX]=c.prototype[q.CAPSULE|q.RECTANGLE]=c.prototype.convexCapsule=function(a,b,c,e,g,h,i,j,k){var l=P;f.set(l,h.length/2,0),f.rotate(l,l,j),f.add(l,l,i);var m=this.circleConvex(g,h,l,j,a,b,c,e,k,h.radius);f.set(l,-h.length/2,0),f.rotate(l,l,j),f.add(l,l,i);var n=this.circleConvex(g,h,l,j,a,b,c,e,k,h.radius);if(k&&(m||n))return!0;var o=O;d(o,h);var p=this.convexConvex(a,b,c,e,g,o,i,j,k);return p+m+n},c.prototype[q.CAPSULE|q.LINE]=c.prototype.lineCapsule=function(a,b,c,d,e,f,g,h,i){return i?!1:0};var Q=f.create(),R=f.create(),S=new r(1,1);c.prototype[q.CAPSULE|q.CAPSULE]=c.prototype.capsuleCapsule=function(a,b,c,e,g,h,i,j,k){for(var l,m=Q,n=R,o=0,p=0;2>p;p++){f.set(m,(0===p?-1:1)*b.length/2,0),f.rotate(m,m,e),f.add(m,m,c);for(var q=0;2>q;q++){f.set(n,(0===q?-1:1)*h.length/2,0),f.rotate(n,n,j),f.add(n,n,i),this.enableFrictionReduction&&(l=this.enableFriction,this.enableFriction=!1);var r=this.circleCircle(a,b,m,e,g,h,n,j,k,b.radius,h.radius);if(this.enableFrictionReduction&&(this.enableFriction=l),k&&r)return!0;o+=r}}this.enableFrictionReduction&&(l=this.enableFriction,this.enableFriction=!1);var s=S;d(s,b);var t=this.convexCapsule(a,s,c,e,g,h,i,j,k);if(this.enableFrictionReduction&&(this.enableFriction=l),k&&t)return!0;if(o+=t,this.enableFrictionReduction){var l=this.enableFriction;this.enableFriction=!1}d(s,h);var u=this.convexCapsule(g,s,i,j,a,b,c,e,k);return this.enableFrictionReduction&&(this.enableFriction=l),k&&u?!0:(o+=u,this.enableFrictionReduction&&o&&this.enableFriction&&this.frictionEquations.push(this.createFrictionFromAverage(o)),o)},c.prototype[q.LINE|q.LINE]=c.prototype.lineLine=function(a,b,c,d,e,f,g,h,i){return i?!1:0},c.prototype[q.PLANE|q.LINE]=c.prototype.planeLine=function(a,b,c,d,e,j,k,l,m){var n=t,o=u,p=v,q=w,r=x,C=y,D=z,E=A,F=B,G=L,H=0;f.set(n,-j.length/2,0),f.set(o,j.length/2,0),f.rotate(p,n,l),f.rotate(q,o,l),h(p,p,k),h(q,q,k),f.copy(n,p),f.copy(o,q),g(r,o,n),f.normalize(C,r),f.rotate90cw(F,C),f.rotate(E,s,d),G[0]=n,G[1]=o;for(var I=0;IK){if(m)return!0;var M=this.createContactEquation(a,e,b,j);H++,f.copy(M.normalA,E),f.normalize(M.normalA,M.normalA),f.scale(D,E,K),g(M.contactPointA,J,D),g(M.contactPointA,M.contactPointA,a.position),g(M.contactPointB,J,k),h(M.contactPointB,M.contactPointB,k),g(M.contactPointB,M.contactPointB,e.position),this.contactEquations.push(M),this.enableFrictionReduction||this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(M))}}return m?!1:(this.enableFrictionReduction||H&&this.enableFriction&&this.frictionEquations.push(this.createFrictionFromAverage(H)),H)},c.prototype[q.PARTICLE|q.CAPSULE]=c.prototype.particleCapsule=function(a,b,c,d,e,f,g,h,i){return this.circleLine(a,b,c,d,e,f,g,h,i,f.radius,0)},c.prototype[q.CIRCLE|q.LINE]=c.prototype.circleLine=function(a,b,c,d,e,j,k,l,m,n,o){var n=n||0,o="undefined"!=typeof o?o:b.radius,p=t,q=u,r=v,s=w,H=x,I=y,J=z,K=A,M=B,N=C,O=D,P=E,Q=F,R=G,S=L;f.set(K,-j.length/2,0),f.set(M,j.length/2,0),f.rotate(N,K,l),f.rotate(O,M,l),h(N,N,k),h(O,O,k),f.copy(K,N),f.copy(M,O),g(I,M,K),f.normalize(J,I),f.rotate90cw(H,J),g(P,c,K);var T=i(P,H);g(s,K,k),g(Q,c,k);var U=o+n;if(Math.abs(T)W&&X>V){if(m)return!0;var Y=this.createContactEquation(a,e,b,j);return f.scale(Y.normalA,p,-1),f.normalize(Y.normalA,Y.normalA),f.scale(Y.contactPointA,Y.normalA,o),h(Y.contactPointA,Y.contactPointA,c),g(Y.contactPointA,Y.contactPointA,a.position),g(Y.contactPointB,r,k),h(Y.contactPointB,Y.contactPointB,k),g(Y.contactPointB,Y.contactPointB,e.position),this.contactEquations.push(Y),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(Y)),1}}S[0]=K,S[1]=M;for(var Z=0;ZQ&&(f.copy(J,B),L=Q,f.scale(A,s,Q),f.add(A,A,B),K=!0)}}if(K){if(m)return!0;var R=this.createContactEquation(a,i,b,j);return f.sub(R.normalA,J,c),f.normalize(R.normalA,R.normalA),f.scale(R.contactPointA,R.normalA,n),h(R.contactPointA,R.contactPointA,c),g(R.contactPointA,R.contactPointA,a.position),g(R.contactPointB,A,k),h(R.contactPointB,R.contactPointB,k),g(R.contactPointB,R.contactPointB,i.position),this.contactEquations.push(R),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(R)),1}if(n>0)for(var N=0;NQ&&(I=Q,f.scale(E,s,Q),f.add(E,E,c),f.copy(H,s),L=!0)}if(L){var R=this.createContactEquation(a,j,b,k);return f.scale(R.normalA,H,-1),f.normalize(R.normalA,R.normalA),f.set(R.contactPointA,0,0),h(R.contactPointA,R.contactPointA,c),g(R.contactPointA,R.contactPointA,a.position),g(R.contactPointB,E,l),h(R.contactPointB,R.contactPointB,l),g(R.contactPointB,R.contactPointB,j.position),this.contactEquations.push(R),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(R)),1}return 0},c.prototype[q.CIRCLE]=c.prototype.circleCircle=function(a,b,c,d,e,i,j,k,l,m,n){var o=t,m=m||b.radius,n=n||i.radius;g(o,c,j);var p=m+n;if(f.squaredLength(o)>Math.pow(p,2))return 0;if(l)return!0;var q=this.createContactEquation(a,e,b,i);return g(q.normalA,j,c),f.normalize(q.normalA,q.normalA),f.scale(q.contactPointA,q.normalA,m),f.scale(q.contactPointB,q.normalA,-n),h(q.contactPointA,q.contactPointA,c),g(q.contactPointA,q.contactPointA,a.position),h(q.contactPointB,q.contactPointB,j),g(q.contactPointB,q.contactPointB,e.position),this.contactEquations.push(q),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(q)),1},c.prototype[q.PLANE|q.CONVEX]=c.prototype[q.PLANE|q.RECTANGLE]=c.prototype.planeConvex=function(a,b,c,d,e,j,k,l,m){var n=t,o=u,p=v,q=0;f.rotate(o,s,d);for(var r=0;r!==j.vertices.length;r++){var w=j.vertices[r];if(f.rotate(n,w,l),h(n,n,k),g(p,n,c),i(p,o)<=0){if(m)return!0;q++;var x=this.createContactEquation(a,e,b,j);g(p,n,c),f.copy(x.normalA,o);var y=i(p,x.normalA);f.scale(p,x.normalA,y),g(x.contactPointB,n,e.position),g(x.contactPointA,n,p),g(x.contactPointA,x.contactPointA,a.position),this.contactEquations.push(x),this.enableFrictionReduction||this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(x))}}return this.enableFrictionReduction&&this.enableFriction&&q&&this.frictionEquations.push(this.createFrictionFromAverage(q)),q},c.prototype[q.PARTICLE|q.PLANE]=c.prototype.particlePlane=function(a,b,c,d,e,h,j,k,l){var m=t,n=u;k=k||0,g(m,c,j),f.rotate(n,s,k);var o=i(m,n);if(o>0)return 0;if(l)return!0;var p=this.createContactEquation(e,a,h,b);return f.copy(p.normalA,n),f.scale(m,p.normalA,o),g(p.contactPointA,c,m),g(p.contactPointA,p.contactPointA,e.position),g(p.contactPointB,c,a.position),this.contactEquations.push(p),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(p)),1},c.prototype[q.CIRCLE|q.PARTICLE]=c.prototype.circleParticle=function(a,b,c,d,e,i,j,k,l){var m=t;if(g(m,j,c),f.squaredLength(m)>Math.pow(b.radius,2))return 0;if(l)return!0;var n=this.createContactEquation(a,e,b,i);return f.copy(n.normalA,m),f.normalize(n.normalA,n.normalA),f.scale(n.contactPointA,n.normalA,b.radius),h(n.contactPointA,n.contactPointA,c),g(n.contactPointA,n.contactPointA,a.position),g(n.contactPointB,j,e.position),this.contactEquations.push(n),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(n)),1};{var X=new o(1),Y=f.create(),Z=f.create();f.create()}c.prototype[q.PLANE|q.CAPSULE]=c.prototype.planeCapsule=function(a,b,c,d,e,g,i,j,k){var l=Y,m=Z,n=X;f.set(l,-g.length/2,0),f.rotate(l,l,j),h(l,l,i),f.set(m,g.length/2,0),f.rotate(m,m,j),h(m,m,i),n.radius=g.radius;var o;this.enableFrictionReduction&&(o=this.enableFriction,this.enableFriction=!1);var p=this.circlePlane(e,n,l,0,a,b,c,d,k),q=this.circlePlane(e,n,m,0,a,b,c,d,k);if(this.enableFrictionReduction&&(this.enableFriction=o),k)return p||q;var r=p+q;return this.enableFrictionReduction&&r&&this.frictionEquations.push(this.createFrictionFromAverage(r)),r},c.prototype[q.CIRCLE|q.PLANE]=c.prototype.circlePlane=function(a,b,c,d,e,j,k,l,m){var n=a,o=b,p=c,q=e,r=k,w=l;w=w||0;var x=t,y=u,z=v;g(x,p,r),f.rotate(y,s,w);var A=i(y,x);if(A>o.radius)return 0;if(m)return!0;var B=this.createContactEquation(q,n,j,b);return f.copy(B.normalA,y),f.scale(B.contactPointB,B.normalA,-o.radius),h(B.contactPointB,B.contactPointB,p),g(B.contactPointB,B.contactPointB,n.position),f.scale(z,B.normalA,A),g(B.contactPointA,x,z),h(B.contactPointA,B.contactPointA,r),g(B.contactPointA,B.contactPointA,q.position),this.contactEquations.push(B),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(B)),1},c.prototype[q.CONVEX]=c.prototype[q.CONVEX|q.RECTANGLE]=c.prototype[q.RECTANGLE]=c.prototype.convexConvex=function(a,b,d,e,j,k,l,m,n,o){var p=t,q=u,r=v,s=w,y=x,C=z,D=A,E=B,F=0,o="number"==typeof o?o:0,G=c.findSeparatingAxis(b,d,e,k,l,m,p);if(!G)return 0;g(D,l,d),i(p,D)>0&&f.scale(p,p,-1);var H=c.getClosestEdge(b,e,p,!0),I=c.getClosestEdge(k,m,p);if(-1===H||-1===I)return 0;for(var J=0;2>J;J++){var K=H,L=I,M=b,N=k,O=d,P=l,Q=e,R=m,S=a,T=j;if(0===J){var U;U=K,K=L,L=U,U=M,M=N,N=U,U=O,O=P,P=U,U=Q,Q=R,R=U,U=S,S=T,T=U}for(var V=L;L+2>V;V++){var W=N.vertices[(V+N.vertices.length)%N.vertices.length];f.rotate(q,W,R),h(q,q,P);for(var X=0,Y=K-1;K+2>Y;Y++){var Z=M.vertices[(Y+M.vertices.length)%M.vertices.length],$=M.vertices[(Y+1+M.vertices.length)%M.vertices.length];f.rotate(r,Z,Q),f.rotate(s,$,Q),h(r,r,O),h(s,s,O),g(y,s,r),f.rotate90cw(E,y),f.normalize(E,E),g(D,q,r);var _=i(E,D);(Y===K&&o>=_||Y!==K&&0>=_)&&X++}if(X>=3){if(n)return!0;var ab=this.createContactEquation(S,T,M,N);F++;var Z=M.vertices[K%M.vertices.length],$=M.vertices[(K+1)%M.vertices.length];f.rotate(r,Z,Q),f.rotate(s,$,Q),h(r,r,O),h(s,s,O),g(y,s,r),f.rotate90cw(ab.normalA,y),f.normalize(ab.normalA,ab.normalA),g(D,q,r);var _=i(ab.normalA,D);f.scale(C,ab.normalA,_),g(ab.contactPointA,q,O),g(ab.contactPointA,ab.contactPointA,C),h(ab.contactPointA,ab.contactPointA,O),g(ab.contactPointA,ab.contactPointA,S.position),g(ab.contactPointB,q,P),h(ab.contactPointB,ab.contactPointB,P),g(ab.contactPointB,ab.contactPointB,T.position),this.contactEquations.push(ab),this.enableFrictionReduction||this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(ab))}}}return this.enableFrictionReduction&&this.enableFriction&&F&&this.frictionEquations.push(this.createFrictionFromAverage(F)),F};var $=f.fromValues(0,0);c.projectConvexOntoAxis=function(a,b,c,d,e){var g,h,j=null,k=null,l=$;f.rotate(l,d,-c);for(var m=0;mj)&&(j=h),(null===k||k>h)&&(k=h);if(k>j){var n=k;k=j,j=n}var o=i(b,d);f.set(e,k+o,j+o)};var _=f.fromValues(0,0),ab=f.fromValues(0,0),bb=f.fromValues(0,0),cb=f.fromValues(0,0),db=f.fromValues(0,0),eb=f.fromValues(0,0);c.findSeparatingAxis=function(a,b,d,e,h,i,j){var k=null,l=!1,m=!1,n=_,o=ab,p=bb,q=cb,s=db,t=eb;if(a instanceof r&&e instanceof r)for(var u=0;2!==u;u++){var v=a,w=d;1===u&&(v=e,w=i);for(var x=0;2!==x;x++){0===x?f.set(q,0,1):1===x&&f.set(q,1,0),0!==w&&f.rotate(q,q,w),c.projectConvexOntoAxis(a,b,d,q,s),c.projectConvexOntoAxis(e,h,i,q,t);var y=s,z=t,A=!1;s[0]>t[0]&&(z=s,y=t,A=!0);var B=z[0]-y[1];l=0>=B,(null===k||B>k)&&(f.copy(j,q),k=B,m=l)}}else for(var u=0;2!==u;u++){var v=a,w=d;1===u&&(v=e,w=i);for(var x=0;x!==v.vertices.length;x++){f.rotate(o,v.vertices[x],w),f.rotate(p,v.vertices[(x+1)%v.vertices.length],w),g(n,p,o),f.rotate90cw(q,n),f.normalize(q,q),c.projectConvexOntoAxis(a,b,d,q,s),c.projectConvexOntoAxis(e,h,i,q,t);var y=s,z=t,A=!1;s[0]>t[0]&&(z=s,y=t,A=!0);var B=z[0]-y[1];l=0>=B,(null===k||B>k)&&(f.copy(j,q),k=B,m=l)}}return m};var fb=f.fromValues(0,0),gb=f.fromValues(0,0),hb=f.fromValues(0,0);c.getClosestEdge=function(a,b,c,d){var e=fb,h=gb,j=hb;f.rotate(e,c,-b),d&&f.scale(e,e,-1);for(var k=-1,l=a.vertices.length,m=-1,n=0;n!==l;n++){g(h,a.vertices[(n+1)%l],a.vertices[n%l]),f.rotate90cw(j,h),f.normalize(j,j);var o=i(j,e);(-1===k||o>m)&&(k=n%l,m=o)}return k};var ib=f.create(),jb=f.create(),kb=f.create(),lb=f.create(),mb=f.create(),nb=f.create(),ob=f.create();c.prototype[q.CIRCLE|q.HEIGHTFIELD]=c.prototype.circleHeightfield=function(a,b,c,d,e,i,j,k,l,m){var n=i.data,m=m||b.radius,o=i.elementWidth,p=jb,q=ib,r=mb,s=ob,t=nb,u=kb,v=lb,w=Math.floor((c[0]-m-j[0])/o),x=Math.ceil((c[0]+m-j[0])/o); +0>w&&(w=0),x>=n.length&&(x=n.length-1);for(var y=n[w],z=n[x],A=w;x>A;A++)n[A]y&&(y=n[A]);if(c[1]-m>y)return l?!1:0;for(var B=!1,A=w;x>A;A++){f.set(u,A*o,n[A]),f.set(v,(A+1)*o,n[A+1]),f.add(u,u,j),f.add(v,v,j),f.sub(t,v,u),f.rotate(t,t,Math.PI/2),f.normalize(t,t),f.scale(q,t,-m),f.add(q,q,c),f.sub(p,q,u);var C=f.dot(p,t);if(q[0]>=u[0]&&q[0]=C){if(l)return!0;B=!0,f.scale(p,t,-C),f.add(r,q,p),f.copy(s,t);var D=this.createContactEquation(e,a,i,b);f.copy(D.normalA,s),f.scale(D.contactPointB,D.normalA,-m),h(D.contactPointB,D.contactPointB,c),g(D.contactPointB,D.contactPointB,a.position),f.copy(D.contactPointA,r),f.sub(D.contactPointA,D.contactPointA,e.position),this.contactEquations.push(D),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(D))}}if(B=!1,m>0)for(var A=w;x>=A;A++)if(f.set(u,A*o,n[A]),f.add(u,u,j),f.sub(p,c,u),f.squaredLength(p)q&&(q=0),r>=k.length&&(r=k.length-1);for(var s=k[q],t=k[r],u=q;r>u;u++)k[u]s&&(s=k[u]);if(a.aabb.lowerBound[1]>s)return j?!1:0;for(var v=0,u=q;r>u;u++){f.set(m,u*l,k[u]),f.set(n,(u+1)*l,k[u+1]),f.add(m,m,h),f.add(n,n,h);var w=100;f.set(o,.5*(n[0]+m[0]),.5*(n[1]+m[1]-w)),f.sub(p.vertices[0],n,o),f.sub(p.vertices[1],m,o),f.copy(p.vertices[2],p.vertices[1]),f.copy(p.vertices[3],p.vertices[0]),p.vertices[2][1]-=w,p.vertices[3][1]-=w,v+=this.convexConvex(a,b,c,d,e,p,o,0,j)}return v}},{"../equations/ContactEquation":22,"../equations/Equation":23,"../equations/FrictionEquation":24,"../math/vec2":31,"../objects/Body":32,"../shapes/Circle":38,"../shapes/Convex":39,"../shapes/Rectangle":44,"../shapes/Shape":45,"../utils/TupleDictionary":49,"../utils/Utils":50}],12:[function(a,b){function c(a){a=a||{},this.from=a.from?e.fromValues(a.from[0],a.from[1]):e.create(),this.to=a.to?e.fromValues(a.to[0],a.to[1]):e.create(),this._direction=e.create(),this.precision=1e-4,this.checkCollisionResponse=!0,this.skipBackfaces=!1,this.collisionMask=-1,this.collisionGroup=-1,this.mode=c.ANY,this.result=new f,this.hasHit=!1,this.callback=function(){}}function d(a,b,c){e.sub(z,c,a);var d=e.dot(z,b);e.scale(A,b,d),e.add(A,A,a);var f=e.distance(c,A);return f}b.exports=c;var e=a("../math/vec2"),f=a("../collision/RaycastResult"),g=a("../shapes/Shape"),h=a("../collision/AABB");c.prototype.constructor=c,c.CLOSEST=1,c.ANY=2,c.ALL=4;var i=new h,j=[];c.prototype.intersectWorld=function(a,b){return this.mode=b.mode||c.ANY,this.result=b.result||new f,this.skipBackfaces=!!b.skipBackfaces,this.collisionMask="undefined"!=typeof b.collisionMask?b.collisionMask:-1,this.collisionGroup="undefined"!=typeof b.collisionGroup?b.collisionGroup:-1,b.from&&e.copy(this.from,b.from),b.to&&e.copy(this.to,b.to),this.callback=b.callback||function(){},this.hasHit=!1,this.result.reset(),this._updateDirection(),this.getAABB(i),j.length=0,a.broadphase.aabbQuery(a,i,j),this.intersectBodies(j),this.hasHit};var k=(e.create(),e.create(),e.create());c.prototype.intersectBody=function(a,b){b&&(this.result=b,this._updateDirection());var c=this.checkCollisionResponse;if(!c||a.collisionResponse)for(var d=k,f=0,g=a.shapes.length;g>f;f++){var h=a.shapes[f];if(!c||h.collisionResponse){e.copy(d,a.shapeOffsets[f]),e.rotate(d,d,a.angle),e.add(d,d,a.position);var i=a.shapeAngles[f]+a.angle;if(this.intersectShape(h,i,d,a),this.result._shouldStop)break}}},c.prototype.intersectBodies=function(a,b){b&&(this.result=b,this._updateDirection());for(var c=0,d=a.length;!this.result._shouldStop&&d>c;c++)this.intersectBody(a[c])},c.prototype._updateDirection=function(){var a=this._direction;e.sub(a,this.to,this.from),e.normalize(a,a)},c.prototype.intersectShape=function(a,b,c,e){var f=this.from,g=d(f,this._direction,c);if(!(g>a.boundingSphereRadius)){var h=this[a.type];h&&h.call(this,a,b,c,e)}};var l=(e.create(),e.create(),e.create(),e.create(),e.create(),e.create(),e.create(),new f,e.create()),m=e.create(),n=e.create(),o=e.create(),p=e.create(),q=e.create(),r=e.create();c.prototype.intersectRectangle=function(a,b,c,d){var f=-Number.MAX_VALUE,g=Number.MAX_VALUE,h=l,i=m,j=n,k=o,s=p,t=q,u=r;if(e.set(t,.5*-a.width,.5*-a.height),e.set(u,.5*a.width,.5*a.height),e.rotate(h,this._direction,-b),d.toLocalFrame(i,this.from),0!==h[0]){var v=(t[0]-i[0])/h[0],w=(u[0]-i[0])/h[0],x=f;f=Math.max(f,Math.min(v,w)),f!==x&&e.set(j,v>w?1:-1,0);var y=g;g=Math.min(g,Math.max(v,w)),g!==y&&e.set(k,w>v?1:-1,0)}if(0!==h[1]){var z=(t[1]-i[1])/h[1],A=(u[1]-i[1])/h[1],x=f;f=Math.max(f,Math.min(z,A)),f!==x&&e.set(j,0,z>A?1:-1);var y=g;g=Math.min(g,Math.max(z,A)),g!==y&&e.set(k,0,A>z?1:-1)}if(g>=f){if(e.set(s,i[0]+h[0]*f,i[1]+h[1]*f),e.rotate(j,j,b),d.toWorldFrame(s,s),this.reportIntersection(j,s,a,d,-1),this._shouldStop)return;e.rotate(k,k,b),e.set(s,i[0]+h[0]*g,i[1]+h[1]*g),d.toWorldFrame(s,s),this.reportIntersection(k,s,a,d,-1)}},c.prototype[g.RECTANGLE]=c.prototype.intersectRectangle;var s=e.create(),t=e.create(),u=e.create(),v=e.create(),w=e.create();c.prototype.intersectPlane=function(a,b,c,d){var f=this.from,g=this.to,h=this._direction,i=s,j=t,k=u,l=v,m=w;e.set(l,0,1),e.rotate(l,l,b),e.sub(m,f,c);var n=e.dot(m,l);e.sub(m,g,c);var o=e.dot(m,l);if(!(n*o>0||e.distance(f,g)l))if(0===l)e.lerp(m,f,g,l),e.sub(n,m,c),e.normalize(n,n),this.reportIntersection(n,m,a,d,-1);else{var o=(-j-Math.sqrt(l))/(2*i),p=(-j+Math.sqrt(l))/(2*i);if(e.lerp(m,f,g,o),e.sub(n,m,c),e.normalize(n,n),this.reportIntersection(n,m,a,d,-1),this.result._shouldStop)return;e.lerp(m,f,g,p),e.sub(n,m,c),e.normalize(n,n),this.reportIntersection(n,m,a,d,-1)}},c.prototype[g.CIRCLE]=c.prototype.intersectCircle,c.prototype.getAABB=function(a){var b=this.to,c=this.from;a.lowerBound[0]=Math.min(b[0],c[0]),a.lowerBound[1]=Math.min(b[1],c[1]),a.upperBound[0]=Math.max(b[0],c[0]),a.upperBound[1]=Math.max(b[1],c[1])},c.prototype.reportIntersection=function(a,b,d,f,g){var h=this.from,i=this.to,j=e.distance(h,b),k=this.result;if(!(this.skipBackfaces&&e.dot(a,this._direction)>0))switch(k.hitFaceIndex="undefined"!=typeof g?g:-1,this.mode){case c.ALL:this.hasHit=!0,k.set(h,i,a,b,d,f,j),k.hasHit=!0,this.callback(k);break;case c.CLOSEST:(jc;c++){for(var e=a[c],f=c-1;f>=0&&!(a[f].aabb.lowerBound[b]<=e.aabb.lowerBound[b]);f--)a[f+1]=a[f];a[f+1]=e}return a},c.prototype.sortList=function(){var a=this.axisList,b=this.axisIndex;c.sortAxisList(a,b)},c.prototype.getCollisionPairs=function(){var a=this.axisList,b=this.result,c=this.axisIndex;b.length=0;for(var d=a.length;d--;){var f=a[d];f.aabbNeedsUpdate&&f.updateAABB()}this.sortList();for(var g=0,h=0|a.length;g!==h;g++)for(var i=a[g],j=g+1;h>j;j++){var k=a[j],l=k.aabb.lowerBound[c]<=i.aabb.upperBound[c];if(!l)break;e.canCollide(i,k)&&this.boundingVolumeCheck(i,k)&&b.push(i,k)}return b},c.prototype.aabbQuery=function(a,b,c){c=c||[],this.sortList();var d=this.axisIndex,e="x";1===d&&(e="y"),2===d&&(e="z");for(var f=this.axisList,g=(b.lowerBound[e],b.upperBound[e],0);gthis.upperLimit&&(g.maxForce=0,g.minForce=-this.maxForce,this.distance=this.upperLimit,l=!0),this.lowerLimitEnabled&&this.positionc)g.scale(e.normalA,i,-1),g.sub(e.contactPointA,j,h.position),g.sub(e.contactPointB,k,o.position),g.scale(n,i,c),g.add(e.contactPointA,e.contactPointA,n),-1===a.indexOf(e)&&a.push(e);else{var u=a.indexOf(e);-1!==u&&a.splice(u,1)}if(this.lowerLimitEnabled&&d>s)g.scale(f.normalA,i,1),g.sub(f.contactPointA,j,h.position),g.sub(f.contactPointB,k,o.position),g.scale(n,i,d),g.sub(f.contactPointB,f.contactPointB,n),-1===a.indexOf(f)&&a.push(f);else{var u=a.indexOf(f);-1!==u&&a.splice(u,1)}},c.prototype.enableMotor=function(){this.motorEnabled||(this.equations.push(this.motorEquation),this.motorEnabled=!0)},c.prototype.disableMotor=function(){if(this.motorEnabled){var a=this.equations.indexOf(this.motorEquation);this.equations.splice(a,1),this.motorEnabled=!1}},c.prototype.setLimits=function(a,b){"number"==typeof a?(this.lowerLimit=a,this.lowerLimitEnabled=!0):(this.lowerLimit=a,this.lowerLimitEnabled=!1),"number"==typeof b?(this.upperLimit=b,this.upperLimitEnabled=!0):(this.upperLimit=b,this.upperLimitEnabled=!1)}},{"../equations/ContactEquation":22,"../equations/Equation":23,"../equations/RotationalLockEquation":25,"../math/vec2":31,"./Constraint":15}],20:[function(a,b){function c(a,b,c){c=c||{},d.call(this,a,b,d.REVOLUTE,c);var n=this.maxForce="undefined"!=typeof c.maxForce?c.maxForce:Number.MAX_VALUE;this.pivotA=h.create(),this.pivotB=h.create(),c.worldPivot?(h.sub(this.pivotA,c.worldPivot,a.position),h.sub(this.pivotB,c.worldPivot,b.position),h.rotate(this.pivotA,this.pivotA,-a.angle),h.rotate(this.pivotB,this.pivotB,-b.angle)):(h.copy(this.pivotA,c.localPivotA),h.copy(this.pivotB,c.localPivotB));var o=this.equations=[new e(a,b,-n,n),new e(a,b,-n,n)],p=o[0],q=o[1],r=this;p.computeGq=function(){return h.rotate(i,r.pivotA,a.angle),h.rotate(j,r.pivotB,b.angle),h.add(m,b.position,j),h.sub(m,m,a.position),h.sub(m,m,i),h.dot(m,k)},q.computeGq=function(){return h.rotate(i,r.pivotA,a.angle),h.rotate(j,r.pivotB,b.angle),h.add(m,b.position,j),h.sub(m,m,a.position),h.sub(m,m,i),h.dot(m,l)},q.minForce=p.minForce=-n,q.maxForce=p.maxForce=n,this.motorEquation=new f(a,b),this.motorEnabled=!1,this.angle=0,this.lowerLimitEnabled=!1,this.upperLimitEnabled=!1,this.lowerLimit=0,this.upperLimit=0,this.upperLimitEquation=new g(a,b),this.lowerLimitEquation=new g(a,b),this.upperLimitEquation.minForce=0,this.lowerLimitEquation.maxForce=0}var d=a("./Constraint"),e=a("../equations/Equation"),f=a("../equations/RotationalVelocityEquation"),g=a("../equations/RotationalLockEquation"),h=a("../math/vec2");b.exports=c;var i=h.create(),j=h.create(),k=h.fromValues(1,0),l=h.fromValues(0,1),m=h.create();c.prototype=new d,c.prototype.constructor=c,c.prototype.setLimits=function(a,b){"number"==typeof a?(this.lowerLimit=a,this.lowerLimitEnabled=!0):(this.lowerLimit=a,this.lowerLimitEnabled=!1),"number"==typeof b?(this.upperLimit=b,this.upperLimitEnabled=!0):(this.upperLimit=b,this.upperLimitEnabled=!1)},c.prototype.update=function(){var a=this.bodyA,b=this.bodyB,c=this.pivotA,d=this.pivotB,e=this.equations,f=(e[0],e[1],e[0]),g=e[1],m=this.upperLimit,n=this.lowerLimit,o=this.upperLimitEquation,p=this.lowerLimitEquation,q=this.angle=b.angle-a.angle;if(this.upperLimitEnabled&&q>m)o.angle=m,-1===e.indexOf(o)&&e.push(o);else{var r=e.indexOf(o);-1!==r&&e.splice(r,1)}if(this.lowerLimitEnabled&&n>q)p.angle=n,-1===e.indexOf(p)&&e.push(p);else{var r=e.indexOf(p);-1!==r&&e.splice(r,1)}h.rotate(i,c,a.angle),h.rotate(j,d,b.angle),f.G[0]=-1,f.G[1]=0,f.G[2]=-h.crossLength(i,k),f.G[3]=1,f.G[4]=0,f.G[5]=h.crossLength(j,k),g.G[0]=0,g.G[1]=-1,g.G[2]=-h.crossLength(i,l),g.G[3]=0,g.G[4]=1,g.G[5]=h.crossLength(j,l)},c.prototype.enableMotor=function(){this.motorEnabled||(this.equations.push(this.motorEquation),this.motorEnabled=!0)},c.prototype.disableMotor=function(){if(this.motorEnabled){var a=this.equations.indexOf(this.motorEquation);this.equations.splice(a,1),this.motorEnabled=!1}},c.prototype.motorIsEnabled=function(){return!!this.motorEnabled},c.prototype.setMotorSpeed=function(a){if(this.motorEnabled){var b=this.equations.indexOf(this.motorEquation);this.equations[b].relativeVelocity=a}},c.prototype.getMotorSpeed=function(){return this.motorEnabled?this.motorEquation.relativeVelocity:!1}},{"../equations/Equation":23,"../equations/RotationalLockEquation":25,"../equations/RotationalVelocityEquation":26,"../math/vec2":31,"./Constraint":15}],21:[function(a,b){function c(a,b,c){c=c||{},d.call(this,a,b,-Number.MAX_VALUE,Number.MAX_VALUE),this.angle=c.angle||0,this.ratio="number"==typeof c.ratio?c.ratio:1,this.setRatio(this.ratio)}{var d=a("./Equation");a("../math/vec2")}b.exports=c,c.prototype=new d,c.prototype.constructor=c,c.prototype.computeGq=function(){return this.ratio*this.bodyA.angle-this.bodyB.angle+this.angle},c.prototype.setRatio=function(a){var b=this.G;b[2]=a,b[5]=-1,this.ratio=a},c.prototype.setMaxTorque=function(a){this.maxForce=a,this.minForce=-a}},{"../math/vec2":31,"./Equation":23}],22:[function(a,b){function c(a,b){d.call(this,a,b,0,Number.MAX_VALUE),this.contactPointA=e.create(),this.penetrationVec=e.create(),this.contactPointB=e.create(),this.normalA=e.create(),this.restitution=0,this.firstImpact=!1,this.shapeA=null,this.shapeB=null}var d=a("./Equation"),e=a("../math/vec2");b.exports=c,c.prototype=new d,c.prototype.constructor=c,c.prototype.computeB=function(a,b,c){var d=this.bodyA,f=this.bodyB,g=this.contactPointA,h=this.contactPointB,i=d.position,j=f.position,k=this.penetrationVec,l=this.normalA,m=this.G,n=e.crossLength(g,l),o=e.crossLength(h,l);m[0]=-l[0],m[1]=-l[1],m[2]=-n,m[3]=l[0],m[4]=l[1],m[5]=o,e.add(k,j,h),e.sub(k,k,i),e.sub(k,k,g);var p,q;this.firstImpact&&0!==this.restitution?(q=0,p=1/b*(1+this.restitution)*this.computeGW()):(q=e.dot(l,k)+this.offset,p=this.computeGW());var r=this.computeGiMf(),s=-q*a-p*b-c*r;return s}},{"../math/vec2":31,"./Equation":23}],23:[function(a,b){function c(a,b,d,f){this.minForce="undefined"==typeof d?-Number.MAX_VALUE:d,this.maxForce="undefined"==typeof f?Number.MAX_VALUE:f,this.bodyA=a,this.bodyB=b,this.stiffness=c.DEFAULT_STIFFNESS,this.relaxation=c.DEFAULT_RELAXATION,this.G=new e.ARRAY_TYPE(6);for(var g=0;6>g;g++)this.G[g]=0;this.offset=0,this.a=0,this.b=0,this.epsilon=0,this.timeStep=1/60,this.needsUpdate=!0,this.multiplier=0,this.relativeVelocity=0,this.enabled=!0}b.exports=c;{var d=a("../math/vec2"),e=a("../utils/Utils");a("../objects/Body")}c.prototype.constructor=c,c.DEFAULT_STIFFNESS=1e6,c.DEFAULT_RELAXATION=4,c.prototype.update=function(){var a=this.stiffness,b=this.relaxation,c=this.timeStep;this.a=4/(c*(1+4*b)),this.b=4*b/(1+4*b),this.epsilon=4/(c*c*a*(1+4*b)),this.needsUpdate=!1},c.prototype.gmult=function(a,b,c,d,e){return a[0]*b[0]+a[1]*b[1]+a[2]*c+a[3]*d[0]+a[4]*d[1]+a[5]*e},c.prototype.computeB=function(a,b,c){var d=this.computeGW(),e=this.computeGq(),f=this.computeGiMf();return-e*a-d*b-f*c};var f=d.create(),g=d.create();c.prototype.computeGq=function(){var a=this.G,b=this.bodyA,c=this.bodyB,d=(b.position,c.position,b.angle),e=c.angle;return this.gmult(a,f,d,g,e)+this.offset},c.prototype.computeGW=function(){var a=this.G,b=this.bodyA,c=this.bodyB,d=b.velocity,e=c.velocity,f=b.angularVelocity,g=c.angularVelocity;return this.gmult(a,d,f,e,g)+this.relativeVelocity},c.prototype.computeGWlambda=function(){var a=this.G,b=this.bodyA,c=this.bodyB,d=b.vlambda,e=c.vlambda,f=b.wlambda,g=c.wlambda;return this.gmult(a,d,f,e,g)};var h=d.create(),i=d.create();c.prototype.computeGiMf=function(){var a=this.bodyA,b=this.bodyB,c=a.force,e=a.angularForce,f=b.force,g=b.angularForce,j=a.invMassSolve,k=b.invMassSolve,l=a.invInertiaSolve,m=b.invInertiaSolve,n=this.G;return d.scale(h,c,j),d.scale(i,f,k),this.gmult(n,h,e*l,i,g*m)},c.prototype.computeGiMGt=function(){var a=this.bodyA,b=this.bodyB,c=a.invMassSolve,d=b.invMassSolve,e=a.invInertiaSolve,f=b.invInertiaSolve,g=this.G;return g[0]*g[0]*c+g[1]*g[1]*c+g[2]*g[2]*e+g[3]*g[3]*d+g[4]*g[4]*d+g[5]*g[5]*f};{var j=d.create(),k=d.create(),l=d.create();d.create(),d.create(),d.create()}c.prototype.addToWlambda=function(a){var b=this.bodyA,c=this.bodyB,e=j,f=k,g=l,h=b.invMassSolve,i=c.invMassSolve,m=b.invInertiaSolve,n=c.invInertiaSolve,o=this.G;f[0]=o[0],f[1]=o[1],g[0]=o[3],g[1]=o[4],d.scale(e,f,h*a),d.add(b.vlambda,b.vlambda,e),b.wlambda+=m*o[2]*a,d.scale(e,g,i*a),d.add(c.vlambda,c.vlambda,e),c.wlambda+=n*o[5]*a},c.prototype.computeInvC=function(a){return 1/(this.computeGiMGt()+a)}},{"../math/vec2":31,"../objects/Body":32,"../utils/Utils":50}],24:[function(a,b){function c(a,b,c){e.call(this,a,b,-c,c),this.contactPointA=d.create(),this.contactPointB=d.create(),this.t=d.create(),this.contactEquations=[],this.shapeA=null,this.shapeB=null,this.frictionCoefficient=.3}{var d=a("../math/vec2"),e=a("./Equation");a("../utils/Utils")}b.exports=c,c.prototype=new e,c.prototype.constructor=c,c.prototype.setSlipForce=function(a){this.maxForce=a,this.minForce=-a},c.prototype.getSlipForce=function(){return this.maxForce},c.prototype.computeB=function(a,b,c){var e=(this.bodyA,this.bodyB,this.contactPointA),f=this.contactPointB,g=this.t,h=this.G;h[0]=-g[0],h[1]=-g[1],h[2]=-d.crossLength(e,g),h[3]=g[0],h[4]=g[1],h[5]=d.crossLength(f,g);var i=this.computeGW(),j=this.computeGiMf(),k=-i*b-c*j;return k}},{"../math/vec2":31,"../utils/Utils":50,"./Equation":23}],25:[function(a,b){function c(a,b,c){c=c||{},d.call(this,a,b,-Number.MAX_VALUE,Number.MAX_VALUE),this.angle=c.angle||0;var e=this.G;e[2]=1,e[5]=-1}var d=a("./Equation"),e=a("../math/vec2");b.exports=c,c.prototype=new d,c.prototype.constructor=c;var f=e.create(),g=e.create(),h=e.fromValues(1,0),i=e.fromValues(0,1);c.prototype.computeGq=function(){return e.rotate(f,h,this.bodyA.angle+this.angle),e.rotate(g,i,this.bodyB.angle),e.dot(f,g)}},{"../math/vec2":31,"./Equation":23}],26:[function(a,b){function c(a,b){d.call(this,a,b,-Number.MAX_VALUE,Number.MAX_VALUE),this.relativeVelocity=1,this.ratio=1}{var d=a("./Equation");a("../math/vec2")}b.exports=c,c.prototype=new d,c.prototype.constructor=c,c.prototype.computeB=function(a,b,c){var d=this.G;d[2]=-1,d[5]=this.ratio;var e=this.computeGiMf(),f=this.computeGW(),g=-f*b-c*e;return g}},{"../math/vec2":31,"./Equation":23}],27:[function(a,b){var c=function(){};b.exports=c,c.prototype={constructor:c,on:function(a,b,c){b.context=c||this,void 0===this._listeners&&(this._listeners={});var d=this._listeners;return void 0===d[a]&&(d[a]=[]),-1===d[a].indexOf(b)&&d[a].push(b),this},has:function(a,b){if(void 0===this._listeners)return!1;var c=this._listeners;if(b){if(void 0!==c[a]&&-1!==c[a].indexOf(b))return!0}else if(void 0!==c[a])return!0;return!1},off:function(a,b){if(void 0===this._listeners)return this;var c=this._listeners,d=c[a].indexOf(b);return-1!==d&&c[a].splice(d,1),this},emit:function(a){if(void 0===this._listeners)return this;var b=this._listeners,c=b[a.type];if(void 0!==c){a.target=this;for(var d=0,e=c.length;e>d;d++){var f=c[d];f.call(f.context,a)}}return this}}},{}],28:[function(a,b){function c(a,b,f){if(f=f||{},!(a instanceof d&&b instanceof d))throw new Error("First two arguments must be Material instances.");this.id=c.idCounter++,this.materialA=a,this.materialB=b,this.friction="undefined"!=typeof f.friction?Number(f.friction):.3,this.restitution="undefined"!=typeof f.restitution?Number(f.restitution):0,this.stiffness="undefined"!=typeof f.stiffness?Number(f.stiffness):e.DEFAULT_STIFFNESS,this.relaxation="undefined"!=typeof f.relaxation?Number(f.relaxation):e.DEFAULT_RELAXATION,this.frictionStiffness="undefined"!=typeof f.frictionStiffness?Number(f.frictionStiffness):e.DEFAULT_STIFFNESS,this.frictionRelaxation="undefined"!=typeof f.frictionRelaxation?Number(f.frictionRelaxation):e.DEFAULT_RELAXATION,this.surfaceVelocity="undefined"!=typeof f.surfaceVelocity?Number(f.surfaceVelocity):0,this.contactSkinSize=.005}var d=a("./Material"),e=a("../equations/Equation");b.exports=c,c.idCounter=0},{"../equations/Equation":23,"./Material":29}],29:[function(a,b){function c(a){this.id=a||c.idCounter++}b.exports=c,c.idCounter=0},{}],30:[function(a,b){var c={};c.GetArea=function(a){if(a.length<6)return 0;for(var b=a.length-2,c=0,d=0;b>d;d+=2)c+=(a[d+2]-a[d])*(a[d+1]+a[d+3]);return c+=(a[0]-a[b])*(a[b+1]+a[1]),.5*-c},c.Triangulate=function(a){var b=a.length>>1;if(3>b)return[];for(var d=[],e=[],f=0;b>f;f++)e.push(f);for(var f=0,g=b;g>3;){var h=e[(f+0)%g],i=e[(f+1)%g],j=e[(f+2)%g],k=a[2*h],l=a[2*h+1],m=a[2*i],n=a[2*i+1],o=a[2*j],p=a[2*j+1],q=!1;if(c._convex(k,l,m,n,o,p)){q=!0;for(var r=0;g>r;r++){var s=e[r];if(s!=h&&s!=i&&s!=j&&c._PointInTriangle(a[2*s],a[2*s+1],k,l,m,n,o,p)){q=!1;break}}}if(q)d.push(h,i,j),e.splice((f+1)%g,1),g--,f=0;else if(f++>3*g)break}return d.push(e[0],e[1],e[2]),d},c._PointInTriangle=function(a,b,c,d,e,f,g,h){var i=g-c,j=h-d,k=e-c,l=f-d,m=a-c,n=b-d,o=i*i+j*j,p=i*k+j*l,q=i*m+j*n,r=k*k+l*l,s=k*m+l*n,t=1/(o*r-p*p),u=(r*q-p*s)*t,v=(o*s-p*q)*t;return u>=0&&v>=0&&1>u+v},c._convex=function(a,b,c,d,e,f){return(b-d)*(e-c)+(c-a)*(f-d)>=0},b.exports=c},{}],31:[function(a,b){var c=b.exports={},d=a("../utils/Utils");c.crossLength=function(a,b){return a[0]*b[1]-a[1]*b[0]},c.crossVZ=function(a,b,d){return c.rotate(a,b,-Math.PI/2),c.scale(a,a,d),a},c.crossZV=function(a,b,d){return c.rotate(a,d,Math.PI/2),c.scale(a,a,b),a},c.rotate=function(a,b,c){if(0!==c){var d=Math.cos(c),e=Math.sin(c),f=b[0],g=b[1];a[0]=d*f-e*g,a[1]=e*f+d*g}else a[0]=b[0],a[1]=b[1]},c.rotate90cw=function(a,b){var c=b[0],d=b[1];a[0]=d,a[1]=-c},c.toLocalFrame=function(a,b,d,e){c.copy(a,b),c.sub(a,a,d),c.rotate(a,a,-e)},c.toGlobalFrame=function(a,b,d,e){c.copy(a,b),c.rotate(a,a,e),c.add(a,a,d) +},c.centroid=function(a,b,d,e){return c.add(a,b,d),c.add(a,a,e),c.scale(a,a,1/3),a},c.create=function(){var a=new d.ARRAY_TYPE(2);return a[0]=0,a[1]=0,a},c.clone=function(a){var b=new d.ARRAY_TYPE(2);return b[0]=a[0],b[1]=a[1],b},c.fromValues=function(a,b){var c=new d.ARRAY_TYPE(2);return c[0]=a,c[1]=b,c},c.copy=function(a,b){return a[0]=b[0],a[1]=b[1],a},c.set=function(a,b,c){return a[0]=b,a[1]=c,a},c.add=function(a,b,c){return a[0]=b[0]+c[0],a[1]=b[1]+c[1],a},c.subtract=function(a,b,c){return a[0]=b[0]-c[0],a[1]=b[1]-c[1],a},c.sub=c.subtract,c.multiply=function(a,b,c){return a[0]=b[0]*c[0],a[1]=b[1]*c[1],a},c.mul=c.multiply,c.divide=function(a,b,c){return a[0]=b[0]/c[0],a[1]=b[1]/c[1],a},c.div=c.divide,c.scale=function(a,b,c){return a[0]=b[0]*c,a[1]=b[1]*c,a},c.distance=function(a,b){var c=b[0]-a[0],d=b[1]-a[1];return Math.sqrt(c*c+d*d)},c.dist=c.distance,c.squaredDistance=function(a,b){var c=b[0]-a[0],d=b[1]-a[1];return c*c+d*d},c.sqrDist=c.squaredDistance,c.length=function(a){var b=a[0],c=a[1];return Math.sqrt(b*b+c*c)},c.len=c.length,c.squaredLength=function(a){var b=a[0],c=a[1];return b*b+c*c},c.sqrLen=c.squaredLength,c.negate=function(a,b){return a[0]=-b[0],a[1]=-b[1],a},c.normalize=function(a,b){var c=b[0],d=b[1],e=c*c+d*d;return e>0&&(e=1/Math.sqrt(e),a[0]=b[0]*e,a[1]=b[1]*e),a},c.dot=function(a,b){return a[0]*b[0]+a[1]*b[1]},c.str=function(a){return"vec2("+a[0]+", "+a[1]+")"},c.lerp=function(a,b,c,d){var e=b[0],f=b[1];return a[0]=e+d*(c[0]-e),a[1]=f+d*(c[1]-f),a}},{"../utils/Utils":50}],32:[function(a,b){function c(a){a=a||{},h.call(this),this.id=++c._idCounter,this.world=null,this.shapes=[],this.shapeOffsets=[],this.shapeAngles=[],this.mass=a.mass||0,this.invMass=0,this.inertia=0,this.invInertia=0,this.invMassSolve=0,this.invInertiaSolve=0,this.fixedRotation=!!a.fixedRotation,this.position=d.fromValues(0,0),a.position&&d.copy(this.position,a.position),this.interpolatedPosition=d.fromValues(0,0),this.interpolatedAngle=0,this.previousPosition=d.fromValues(0,0),this.previousAngle=0,this.velocity=d.fromValues(0,0),a.velocity&&d.copy(this.velocity,a.velocity),this.vlambda=d.fromValues(0,0),this.wlambda=0,this.angle=a.angle||0,this.angularVelocity=a.angularVelocity||0,this.force=d.create(),a.force&&d.copy(this.force,a.force),this.angularForce=a.angularForce||0,this.damping="number"==typeof a.damping?a.damping:.1,this.angularDamping="number"==typeof a.angularDamping?a.angularDamping:.1,this.type=c.STATIC,this.type="undefined"!=typeof a.type?a.type:a.mass?c.DYNAMIC:c.STATIC,this.boundingRadius=0,this.aabb=new g,this.aabbNeedsUpdate=!0,this.allowSleep=!0,this.wantsToSleep=!1,this.sleepState=c.AWAKE,this.sleepSpeedLimit=.2,this.sleepTimeLimit=1,this.gravityScale=1,this.collisionResponse=!0,this.idleTime=0,this.timeLastSleepy=0,this.ccdSpeedThreshold=void 0!==a.ccdSpeedThreshold?a.ccdSpeedThreshold:-1,this.ccdIterations=void 0!==a.ccdIterations?a.ccdIterations:10,this.concavePath=null,this._wakeUpAfterNarrowphase=!1,this.updateMassProperties()}var d=a("../math/vec2"),e=a("poly-decomp"),f=a("../shapes/Convex"),g=a("../collision/AABB"),h=a("../events/EventEmitter");b.exports=c,c.prototype=new h,c.prototype.constructor=c,c._idCounter=0,c.prototype.updateSolveMassProperties=function(){this.sleepState===c.SLEEPING||this.type===c.KINEMATIC?(this.invMassSolve=0,this.invInertiaSolve=0):(this.invMassSolve=this.invMass,this.invInertiaSolve=this.invInertia)},c.prototype.setDensity=function(a){var b=this.getArea();this.mass=b*a,this.updateMassProperties()},c.prototype.getArea=function(){for(var a=0,b=0;be&&(e=h+i)}this.boundingRadius=e},c.prototype.addShape=function(a,b,c){c=c||0,b=b?d.fromValues(b[0],b[1]):d.fromValues(0,0),this.shapes.push(a),this.shapeOffsets.push(b),this.shapeAngles.push(c),this.updateMassProperties(),this.updateBoundingRadius(),this.aabbNeedsUpdate=!0},c.prototype.removeShape=function(a){var b=this.shapes.indexOf(a);return-1!==b?(this.shapes.splice(b,1),this.shapeOffsets.splice(b,1),this.shapeAngles.splice(b,1),this.aabbNeedsUpdate=!0,!0):!1},c.prototype.updateMassProperties=function(){if(this.type===c.STATIC||this.type===c.KINEMATIC)this.mass=Number.MAX_VALUE,this.invMass=0,this.inertia=Number.MAX_VALUE,this.invInertia=0;else{var a=this.shapes,b=a.length,e=this.mass/b,f=0;if(this.fixedRotation)this.inertia=Number.MAX_VALUE,this.invInertia=0;else{for(var g=0;b>g;g++){var h=a[g],i=d.squaredLength(this.shapeOffsets[g]),j=h.computeMomentOfInertia(e);f+=j+e*i}this.inertia=f,this.invInertia=f>0?1/f:0}this.invMass=1/this.mass}};var k=d.create();c.prototype.applyForce=function(a,b){var c=k;d.sub(c,b,this.position),d.add(this.force,this.force,a);var e=d.crossLength(c,a);this.angularForce+=e},c.prototype.toLocalFrame=function(a,b){d.toLocalFrame(a,b,this.position,this.angle)},c.prototype.toWorldFrame=function(a,b){d.toGlobalFrame(a,b,this.position,this.angle)},c.prototype.fromPolygon=function(a,b){b=b||{};for(var c=this.shapes.length;c>=0;--c)this.removeShape(this.shapes[c]);var g=new e.Polygon;if(g.vertices=a,g.makeCCW(),"number"==typeof b.removeCollinearPoints&&g.removeCollinearPoints(b.removeCollinearPoints),"undefined"==typeof b.skipSimpleCheck&&!g.isSimple())return!1;this.concavePath=g.vertices.slice(0);for(var c=0;c=g?(this.idleTime=0,this.sleepState=c.AWAKE):(this.idleTime+=e,this.sleepState=c.SLEEPY),this.idleTime>this.sleepTimeLimit&&(b?this.wantsToSleep=!0:this.sleep())}},c.prototype.getVelocityFromPosition=function(a,b){return a=a||d.create(),d.sub(a,this.position,this.previousPosition),d.scale(a,a,1/b),a},c.prototype.getAngularVelocityFromPosition=function(a){return(this.angle-this.previousAngle)/a},c.prototype.overlaps=function(a){return this.world.overlapKeeper.bodiesAreOverlapping(this,a)};var o=d.create(),p=d.create();c.prototype.integrate=function(a){var b=this.invMass,c=this.force,e=this.position,f=this.velocity;d.copy(this.previousPosition,this.position),this.previousAngle=this.angle,this.fixedRotation||(this.angularVelocity+=this.angularForce*this.invInertia*a),d.scale(o,c,a*b),d.add(f,o,f),this.integrateToTimeOfImpact(a)||(d.scale(p,f,a),d.add(e,e,p),this.fixedRotation||(this.angle+=this.angularVelocity*a)),this.aabbNeedsUpdate=!0};var q=d.create(),r=d.create(),s=d.create(),t=d.create();c.prototype.integrateToTimeOfImpact=function(a){if(this.ccdSpeedThreshold<0||d.squaredLength(this.velocity)=j&&if)&&(f=d),(null===h||h>d)&&(h=d);if(h>f){var j=h;h=f,f=j}e.set(b,h,f)},c.prototype.projectOntoWorldAxis=function(a,b,c,d){var f=h;this.projectOntoLocalAxis(a,d),0!==c?e.rotate(f,a,c):f=a;var g=e.dot(b,f);e.set(d,d[0]+g,d[1]+g)},c.prototype.updateTriangles=function(){this.triangles.length=0;for(var a=[],b=0;bg;f=g,g++){var h=this.vertices[f],i=this.vertices[g],j=Math.abs(e.crossLength(h,i)),k=e.dot(i,i)+e.dot(i,h)+e.dot(h,h);b+=j*k,c+=j}return a/6*(b/c)},c.prototype.updateBoundingRadius=function(){for(var a=this.vertices,b=0,c=0;c!==a.length;c++){var d=e.squaredLength(a[c]);d>b&&(b=d)}this.boundingRadius=Math.sqrt(b)},c.triangleArea=function(a,b,c){return.5*((b[0]-a[0])*(c[1]-a[1])-(c[0]-a[0])*(b[1]-a[1]))},c.prototype.updateArea=function(){this.updateTriangles(),this.area=0;for(var a=this.triangles,b=this.vertices,d=0;d!==a.length;d++){var e=a[d],f=b[e[0]],g=b[e[1]],h=b[e[2]],i=c.triangleArea(f,g,h);this.area+=i}},c.prototype.computeAABB=function(a,b,c){a.setFromPoints(this.vertices,b,c,0)}},{"../math/polyk":30,"../math/vec2":31,"./Shape":45,"poly-decomp":5}],40:[function(a,b){function c(a,b){if(b=e.defaults(b,{maxValue:null,minValue:null,elementWidth:.1}),null===b.minValue||null===b.maxValue){b.maxValue=a[0],b.minValue=a[0];for(var c=0;c!==a.length;c++){var f=a[c];f>b.maxValue&&(b.maxValue=f),f=w*w)break}for(c.updateMultipliers(k,q,1/a),x=0;x!==l;x++){var z=k[x];if(z instanceof h){for(var A=0,B=0;B!==z.contactEquations.length;B++)A+=z.contactEquations[B].multiplier;A*=z.frictionCoefficient/z.contactEquations.length,z.maxForce=A,z.minForce=-A}}}for(f=0;f!==i;f++){for(w=0,x=0;x!==l;x++){v=k[x];var y=c.iterateEquation(x,v,v.epsilon,u,t,q,p,a,f);w+=Math.abs(y)}if(this.usedIterations++,m>=w*w)break}for(r=0;r!==o;r++)n[r].addConstraintVelocity();c.updateMultipliers(k,q,1/a)}},c.updateMultipliers=function(a,b,c){for(var d=a.length;d--;)a[d].multiplier=b[d]*c},c.iterateEquation=function(a,b,c,d,e,f,g,h){var i=d[a],j=e[a],k=f[a],l=b.computeGWlambda(),m=b.maxForce,n=b.minForce;g&&(i=0);var o=j*(i-l-c*k),p=k+o;return n*h>p?o=n*h-k:p>m*h&&(o=m*h-k),f[a]+=o,b.addToWlambda(o),o}},{"../equations/FrictionEquation":24,"../math/vec2":31,"../utils/Utils":50,"./Solver":47}],47:[function(a,b){function c(a,b){a=a||{},d.call(this),this.type=b,this.equations=[],this.equationSortFunction=a.equationSortFunction||!1}var d=(a("../utils/Utils"),a("../events/EventEmitter"));b.exports=c,c.prototype=new d,c.prototype.constructor=c,c.prototype.solve=function(){throw new Error("Solver.solve should be implemented by subclasses!")};var e={bodies:[]};c.prototype.solveIsland=function(a,b){this.removeAllEquations(),b.equations.length&&(this.addEquations(b.equations),e.bodies.length=0,b.getBodies(e.bodies),e.bodies.length&&this.solve(a,e))},c.prototype.sortEquations=function(){this.equationSortFunction&&this.equations.sort(this.equationSortFunction)},c.prototype.addEquation=function(a){a.enabled&&this.equations.push(a)},c.prototype.addEquations=function(a){for(var b=0,c=a.length;b!==c;b++){var d=a[b];d.enabled&&this.equations.push(d)}},c.prototype.removeEquation=function(a){var b=this.equations.indexOf(a);-1!==b&&this.equations.splice(b,1)},c.prototype.removeAllEquations=function(){this.equations.length=0},c.GS=1,c.ISLAND=2},{"../events/EventEmitter":27,"../utils/Utils":50}],48:[function(a,b){function c(){this.overlappingShapesLastState=new e,this.overlappingShapesCurrentState=new e,this.recordPool=[],this.tmpDict=new e,this.tmpArray1=[]}function d(a,b,c,d){this.shapeA=b,this.shapeB=d,this.bodyA=a,this.bodyB=c}{var e=a("./TupleDictionary");a("./Utils")}b.exports=c,c.prototype.tick=function(){for(var a=this.overlappingShapesLastState,b=this.overlappingShapesCurrentState,c=a.keys.length;c--;){var d=a.keys[c],e=a.getByKey(d),f=b.getByKey(d);e&&!f&&this.recordPool.push(e)}a.reset(),a.copy(b),b.reset()},c.prototype.setOverlapping=function(a,b,c,e){var f=(this.overlappingShapesLastState,this.overlappingShapesCurrentState);if(!f.get(b.id,e.id)){var g;this.recordPool.length?(g=this.recordPool.pop(),g.set(a,b,c,e)):g=new d(a,b,c,e),f.set(b.id,e.id,g)}},c.prototype.getNewOverlaps=function(a){return this.getDiff(this.overlappingShapesLastState,this.overlappingShapesCurrentState,a)},c.prototype.getEndOverlaps=function(a){return this.getDiff(this.overlappingShapesCurrentState,this.overlappingShapesLastState,a)},c.prototype.bodiesAreOverlapping=function(a,b){for(var c=this.overlappingShapesCurrentState,d=c.keys.length;d--;){var e=c.keys[d],f=c.data[e];if(f.bodyA===a&&f.bodyB===b||f.bodyA===b&&f.bodyB===a)return!0}return!1},c.prototype.getDiff=function(a,b,c){var c=c||[],d=a,e=b;c.length=0;for(var f=e.keys.length;f--;){var g=e.keys[f],h=e.data[g];if(!h)throw new Error("Key "+g+" had no data!");var i=d.data[g];i||c.push(h)}return c},c.prototype.isNewOverlap=function(a,b){var c=0|a.id,d=0|b.id,e=this.overlappingShapesLastState,f=this.overlappingShapesCurrentState;return!e.get(c,d)&&!!f.get(c,d)},c.prototype.getNewBodyOverlaps=function(a){this.tmpArray1.length=0;var b=this.getNewOverlaps(this.tmpArray1);return this.getBodyDiff(b,a)},c.prototype.getEndBodyOverlaps=function(a){this.tmpArray1.length=0;var b=this.getEndOverlaps(this.tmpArray1);return this.getBodyDiff(b,a)},c.prototype.getBodyDiff=function(a,b){b=b||[];for(var c=this.tmpDict,d=a.length;d--;){var e=a[d];c.set(0|e.bodyA.id,0|e.bodyB.id,e)}for(d=c.keys.length;d--;){var e=c.getByKey(c.keys[d]);e&&b.push(e.bodyA,e.bodyB)}return c.reset(),b},d.prototype.set=function(a,b,c,e){d.call(this,a,b,c,e)}},{"./TupleDictionary":49,"./Utils":50}],49:[function(a,b){function c(){this.data={},this.keys=[]}var d=a("./Utils");b.exports=c,c.prototype.getKey=function(a,b){return a=0|a,b=0|b,(0|a)===(0|b)?-1:0|((0|a)>(0|b)?a<<16|65535&b:b<<16|65535&a)},c.prototype.getByKey=function(a){return a=0|a,this.data[a]},c.prototype.get=function(a,b){return this.data[this.getKey(a,b)]},c.prototype.set=function(a,b,c){if(!c)throw new Error("No data!");var d=this.getKey(a,b);return this.data[d]||this.keys.push(d),this.data[d]=c,d},c.prototype.reset=function(){for(var a=this.data,b=this.keys,c=b.length;c--;)delete a[b[c]];b.length=0},c.prototype.copy=function(a){this.reset(),d.appendArray(this.keys,a.keys);for(var b=a.keys.length;b--;){var c=a.keys[b];this.data[c]=a.data[c]}}},{"./Utils":50}],50:[function(a,b){function c(){}b.exports=c,c.appendArray=function(a,b){if(b.length<15e4)a.push.apply(a,b);else for(var c=0,d=b.length;c!==d;++c)a.push(b[c])},c.splice=function(a,b,c){c=c||1;for(var d=b,e=a.length-c;e>d;d++)a[d]=a[d+c];a.length=e},c.ARRAY_TYPE="undefined"!=typeof P2_ARRAY_TYPE?P2_ARRAY_TYPE:"undefined"!=typeof Float32Array?Float32Array:Array,c.extend=function(a,b){for(var c in b)a[c]=b[c]},c.defaults=function(a,b){a=a||{};for(var c in b)c in a||(a[c]=b[c]);return a}},{}],51:[function(a,b){function c(){this.equations=[],this.bodies=[]}var d=a("../objects/Body");b.exports=c,c.prototype.reset=function(){this.equations.length=this.bodies.length=0};var e=[];c.prototype.getBodies=function(a){var b=a||[],c=this.equations;e.length=0;for(var d=0;d!==c.length;d++){var f=c[d];-1===e.indexOf(f.bodyA.id)&&(b.push(f.bodyA),e.push(f.bodyA.id)),-1===e.indexOf(f.bodyB.id)&&(b.push(f.bodyB),e.push(f.bodyB.id))}return b},c.prototype.wantsToSleep=function(){for(var a=0;a1e3*a));g++);this.time+=b;for(var h=this.time%a,i=h/a,j=0;j!==this.bodies.length;j++){var k=this.bodies[j];k.type!==m.STATIC&&k.sleepState!==m.SLEEPING?(f.sub(y,k.position,k.previousPosition),f.scale(y,y,i),f.add(k.interpolatedPosition,k.position,y),k.interpolatedAngle=k.angle+(k.angle-k.previousAngle)*i):(f.copy(k.interpolatedPosition,k.position),k.interpolatedAngle=k.angle)}}};var z=[];c.prototype.internalStep=function(a){this.stepping=!0;var b,d,e=this,g=this.doProfiling,h=this.springs.length,i=this.springs,j=this.bodies,k=this.gravity,l=this.solver,n=this.bodies.length,o=this.broadphase,p=this.narrowphase,q=this.constraints,s=v,t=(f.scale,f.add),u=(f.rotate,this.islandManager);if(this.overlapKeeper.tick(),this.lastTimeStep=a,g&&(b=performance.now()),this.useWorldGravityAsFrictionGravity){var w=f.length(this.gravity);0===w&&this.useFrictionGravityOnZeroGravity||(this.frictionGravity=w)}if(this.applyGravity)for(var x=0;x!==n;x++){var y=j[x],A=y.force;y.type===m.DYNAMIC&&y.sleepState!==m.SLEEPING&&(f.scale(s,k,y.mass*y.gravityScale),t(A,A,s))}if(this.applySpringForces)for(var x=0;x!==h;x++){var B=i[x];B.applyForce()}if(this.applyDamping)for(var x=0;x!==n;x++){var y=j[x];y.type===m.DYNAMIC&&y.applyDamping(a)}for(var C=o.getCollisionPairs(this),D=this.disabledBodyCollisionPairs,x=D.length-2;x>=0;x-=2)for(var E=C.length-2;E>=0;E-=2)(D[x]===C[E]&&D[x+1]===C[E+1]||D[x+1]===C[E]&&D[x]===C[E+1])&&C.splice(E,2);var F=q.length;for(x=0;x!==F;x++){var G=q[x];if(!G.collideConnected)for(var E=C.length-2;E>=0;E-=2)(G.bodyA===C[E]&&G.bodyB===C[E+1]||G.bodyB===C[E]&&G.bodyA===C[E+1])&&C.splice(E,2)}this.postBroadphaseEvent.pairs=C,this.emit(this.postBroadphaseEvent),p.reset(this);for(var x=0,H=C.length;x!==H;x+=2)for(var I=C[x],J=C[x+1],K=0,L=I.shapes.length;K!==L;K++)for(var M=I.shapes[K],N=I.shapeOffsets[K],O=I.shapeAngles[K],P=0,Q=J.shapes.length;P!==Q;P++){var R=J.shapes[P],S=J.shapeOffsets[P],T=J.shapeAngles[P],U=this.defaultContactMaterial;if(M.material&&R.material){var V=this.getContactMaterial(M.material,R.material);V&&(U=V)}this.runNarrowphase(p,I,M,N,O,J,R,S,T,U,this.frictionGravity)}for(var x=0;x!==n;x++){var W=j[x];W._wakeUpAfterNarrowphase&&(W.wakeUp(),W._wakeUpAfterNarrowphase=!1)}if(this.has("endContact")){this.overlapKeeper.getEndOverlaps(z);for(var X=this.endContactEvent,P=z.length;P--;){var Y=z[P];X.shapeA=Y.shapeA,X.shapeB=Y.shapeB,X.bodyA=Y.bodyA,X.bodyB=Y.bodyB,this.emit(X)}}var Z=this.preSolveEvent;Z.contactEquations=p.contactEquations,Z.frictionEquations=p.frictionEquations,this.emit(Z);var F=q.length;for(x=0;x!==F;x++)q[x].update();if(p.contactEquations.length||p.frictionEquations.length||q.length)if(this.islandSplit){for(u.equations.length=0,r.appendArray(u.equations,p.contactEquations),r.appendArray(u.equations,p.frictionEquations),x=0;x!==F;x++)r.appendArray(u.equations,q[x].equations);u.split(this);for(var x=0;x!==u.islands.length;x++){var $=u.islands[x];$.equations.length&&l.solveIsland(a,$)}}else{for(l.addEquations(p.contactEquations),l.addEquations(p.frictionEquations),x=0;x!==F;x++)l.addEquations(q[x].equations);this.solveConstraints&&l.solve(a,this),l.removeAllEquations()}for(var x=0;x!==n;x++){var W=j[x];W.sleepState!==m.SLEEPING&&W.type!==m.STATIC&&W.integrate(a)}for(var x=0;x!==n;x++)j[x].setZeroForce();if(g&&(d=performance.now(),e.lastStepTime=d-b),this.emitImpactEvent&&this.has("impact"))for(var _=this.impactEvent,x=0;x!==p.contactEquations.length;x++){var ab=p.contactEquations[x];ab.firstImpact&&(_.bodyA=ab.bodyA,_.bodyB=ab.bodyB,_.shapeA=ab.shapeA,_.shapeB=ab.shapeB,_.contactEquation=ab,this.emit(_))}if(this.sleepMode===c.BODY_SLEEPING)for(x=0;x!==n;x++)j[x].sleepTick(this.time,!1,a);else if(this.sleepMode===c.ISLAND_SLEEPING&&this.islandSplit){for(x=0;x!==n;x++)j[x].sleepTick(this.time,!0,a);for(var x=0;x0,a.frictionCoefficient=k.friction;var p;p=b.type===m.STATIC||b.type===m.KINEMATIC?g.mass:g.type===m.STATIC||g.type===m.KINEMATIC?b.mass:b.mass*g.mass/(b.mass+g.mass),a.slipForce=k.friction*l*p,a.restitution=k.restitution,a.surfaceVelocity=k.surfaceVelocity,a.frictionStiffness=k.frictionStiffness,a.frictionRelaxation=k.frictionRelaxation,a.stiffness=k.stiffness,a.relaxation=k.relaxation,a.contactSkinSize=k.contactSkinSize,a.enabledEquations=b.collisionResponse&&g.collisionResponse&&c.collisionResponse&&h.collisionResponse;var q=a[c.type|h.type],r=0;if(q){var s=c.sensor||h.sensor,t=a.frictionEquations.length;r=c.type=2*y&&(b._wakeUpAfterNarrowphase=!0)}if(g.allowSleep&&g.type===m.DYNAMIC&&g.sleepState===m.SLEEPING&&b.sleepState===m.AWAKE&&b.type!==m.STATIC){var z=f.squaredLength(b.velocity)+Math.pow(b.angularVelocity,2),A=Math.pow(b.sleepSpeedLimit,2);z>=2*A&&(g._wakeUpAfterNarrowphase=!0)}if(this.overlapKeeper.setOverlapping(b,c,g,h),this.has("beginContact")&&this.overlapKeeper.isNewOverlap(c,h)){var B=this.beginContactEvent;if(B.shapeA=c,B.shapeB=h,B.bodyA=b,B.bodyB=g,B.contactEquations.length=0,"number"==typeof r)for(var C=a.contactEquations.length-r;C1)for(var C=a.frictionEquations.length-u;C=0;b--)this.removeConstraint(a[b]);for(var d=this.bodies,b=d.length-1;b>=0;b--)this.removeBody(d[b]);for(var e=this.springs,b=e.length-1;b>=0;b--)this.removeSpring(e[b]);for(var f=this.contactMaterials,b=f.length-1;b>=0;b--)this.removeContactMaterial(f[b]);c.apply(this)},c.prototype.clone=function(){var a=new c;return a.fromJSON(this.toJSON()),a};var A=f.create(),B=f.fromValues(0,0),C=f.fromValues(0,0);c.prototype.hitTest=function(a,b,c){c=c||0;var d=new m({position:a}),e=new k,l=a,n=0,o=A,p=B,q=C;d.addShape(e);for(var r=this.narrowphase,s=[],t=0,u=b.length;t!==u;t++)for(var v=b[t],w=0,x=v.shapes.length;w!==x;w++){var y=v.shapes[w],z=v.shapeOffsets[w]||p,D=v.shapeAngles[w]||0;f.rotate(o,z,v.angle),f.add(o,o,v.position);var E=D+v.angle;(y instanceof g&&r.circleParticle(v,y,o,E,d,e,l,n,!0)||y instanceof h&&r.particleConvex(d,e,l,n,v,y,o,E,!0)||y instanceof i&&r.particlePlane(d,e,l,n,v,y,o,E,!0)||y instanceof j&&r.particleCapsule(d,e,l,n,v,y,o,E,!0)||y instanceof k&&f.squaredLength(f.sub(q,o,a))0&&(e.Texture.frameUpdates.length=0)},e.CanvasRenderer.prototype.resize=function(a,b){this.width=a,this.height=b,this.view.width=a,this.view.height=b},e.CanvasRenderer.prototype.renderDisplayObject=function(a,b){this.renderSession.context=b||this.context,a._renderCanvas(this.renderSession)},e.CanvasRenderer.prototype.renderStripFlat=function(a){var b=this.context,c=a.verticies,d=c.length/2;this.count++,b.beginPath();for(var e=1;d-2>e;e++){var f=2*e,g=c[f],h=c[f+2],i=c[f+4],j=c[f+1],k=c[f+3],l=c[f+5];b.moveTo(g,j),b.lineTo(h,k),b.lineTo(i,l)}b.fillStyle="#FF0000",b.fill(),b.closePath()},e.CanvasRenderer.prototype.renderStrip=function(a){var b=this.context,c=a.verticies,d=a.uvs,e=c.length/2;this.count++;for(var f=1;e-2>f;f++){var g=2*f,h=c[g],i=c[g+2],j=c[g+4],k=c[g+1],l=c[g+3],m=c[g+5],n=d[g]*a.texture.width,o=d[g+2]*a.texture.width,p=d[g+4]*a.texture.width,q=d[g+1]*a.texture.height,r=d[g+3]*a.texture.height,s=d[g+5]*a.texture.height;b.save(),b.beginPath(),b.moveTo(h,k),b.lineTo(i,l),b.lineTo(j,m),b.closePath(),b.clip();var t=n*r+q*p+o*s-r*p-q*o-n*s,u=h*r+q*j+i*s-r*j-q*i-h*s,v=n*i+h*p+o*j-i*p-h*o-n*j,w=n*r*j+q*i*p+h*o*s-h*r*p-q*o*j-n*i*s,x=k*r+q*m+l*s-r*m-q*l-k*s,y=n*l+k*p+o*m-l*p-k*o-n*m,z=n*r*m+q*l*p+k*o*s-k*r*p-q*o*m-n*l*s;b.transform(u/t,x/t,v/t,y/t,w/t,z/t),b.drawImage(a.texture.baseTexture.source,0,0),b.restore()}},e.CanvasBuffer=function(a,b){this.width=a,this.height=b,this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d"),this.canvas.width=a,this.canvas.height=b},e.CanvasBuffer.prototype.clear=function(){this.context.clearRect(0,0,this.width,this.height)},e.CanvasBuffer.prototype.resize=function(a,b){this.width=this.canvas.width=a,this.height=this.canvas.height=b},e.CanvasGraphics=function(){},e.CanvasGraphics.renderGraphics=function(a,b){for(var c=a.worldAlpha,d="",f=0;f1&&(c=1,window.console.log("Pixi.js warning: masks in canvas can only mask using the first path in the graphics object"));for(var d=0;1>d;d++){var f=a.graphicsData[d],g=f.points;if(f.type===e.Graphics.POLY){b.beginPath(),b.moveTo(g[0],g[1]);for(var h=1;hc;c++)this.children[c]._renderWebGL(a);a.spriteBatch.stop()}this._filters&&a.filterManager.popFilter(),this._mask&&a.maskManager.popMask(a),a.drawCount++,a.spriteBatch.start()}},e.Graphics.prototype._renderCanvas=function(a){if(this.visible!==!1&&0!==this.alpha&&this.isMask!==!0){var b=a.context,c=this.worldTransform;this.blendMode!==a.currentBlendMode&&(a.currentBlendMode=this.blendMode,b.globalCompositeOperation=e.blendModesCanvas[a.currentBlendMode]),b.setTransform(c[0],c[3],c[1],c[4],c[2],c[5]),e.CanvasGraphics.renderGraphics(this,b);for(var d=0,f=this.children.length;f>d;d++)this.children[d]._renderCanvas(a)}},e.Graphics.prototype.getBounds=function(){this.bounds||this.updateBounds();var a=this.bounds.x,b=this.bounds.width+this.bounds.x,c=this.bounds.y,d=this.bounds.height+this.bounds.y,e=this.worldTransform,f=e[0],g=e[3],h=e[1],i=e[4],j=e[2],k=e[5],l=f*b+h*d+j,m=i*d+g*b+k,n=f*a+h*d+j,o=i*d+g*a+k,p=f*a+h*c+j,q=i*c+g*a+k,r=f*b+h*c+j,s=i*c+g*b+k,t=-1/0,u=-1/0,v=1/0,w=1/0;v=v>l?l:v,v=v>n?n:v,v=v>p?p:v,v=v>r?r:v,w=w>m?m:w,w=w>o?o:w,w=w>q?q:w,w=w>s?s:w,t=l>t?l:t,t=n>t?n:t,t=p>t?p:t,t=r>t?r:t,u=m>u?m:u,u=o>u?o:u,u=q>u?q:u,u=s>u?s:u;var x=this._bounds;return x.x=v,x.width=t-v,x.y=w,x.height=u-w,x},e.Graphics.prototype.updateBounds=function(){for(var a,b,c,d=1/0,f=-1/0,g=1/0,h=-1/0,i=0;ib?b:d,f=b+m>f?b+m:f,g=g>c?b:g,h=c+n>h?c+n:h}else if(k===e.Graphics.CIRC||k===e.Graphics.ELIP){b=a.x,c=a.y;var o=a.radius+l/2;d=d>b-o?b-o:d,f=b+o>f?b+o:f,g=g>c-o?c-o:g,h=c+o>h?c+o:h}else for(var p=0;pb-l?b-l:d,f=b+l>f?b+l:f,g=g>c-l?c-l:g,h=c+l>h?c+l:h}var q=this.boundsPadding;this.bounds=new e.Rectangle(d-q,g-q,f-d+2*q,h-g+2*q)},e.Graphics.prototype._generateCachedSprite=function(){var a=this.getBounds();if(this._cachedSprite)this._cachedSprite.buffer.resize(a.width,a.height);else{var b=new e.CanvasBuffer(a.width,a.height),c=e.Texture.fromCanvas(b.canvas);this._cachedSprite=new e.Sprite(c),this._cachedSprite.buffer=b,this._cachedSprite.worldTransform=this.worldTransform}this._cachedSprite.anchor.x=-(a.x/a.width),this._cachedSprite.anchor.y=-(a.y/a.height),this._cachedSprite.buffer.context.translate(-a.x,-a.y),e.CanvasGraphics.renderGraphics(this,this._cachedSprite.buffer.context)},e.Graphics.prototype.destroyCachedSprite=function(){this._cachedSprite.texture.destroy(!0),this._cachedSprite=null},e.Graphics.POLY=0,e.Graphics.RECT=1,e.Graphics.CIRC=2,e.Graphics.ELIP=3,e.Strip=function(a,b,c){e.DisplayObjectContainer.call(this),this.texture=a,this.blendMode=e.blendModes.NORMAL;try{this.uvs=new Float32Array([0,1,1,1,1,0,0,1]),this.verticies=new Float32Array([0,0,0,0,0,0,0,0,0]),this.colors=new Float32Array([1,1,1,1]),this.indices=new Uint16Array([0,1,2,3])}catch(d){this.uvs=[0,1,1,1,1,0,0,1],this.verticies=[0,0,0,0,0,0,0,0,0],this.colors=[1,1,1,1],this.indices=[0,1,2,3]}this.width=b,this.height=c,a.baseTexture.hasLoaded?(this.width=this.texture.frame.width,this.height=this.texture.frame.height,this.updateFrame=!0):(this.onTextureUpdateBind=this.onTextureUpdate.bind(this),this.texture.addEventListener("update",this.onTextureUpdateBind)),this.renderable=!0},e.Strip.prototype=Object.create(e.DisplayObjectContainer.prototype),e.Strip.prototype.constructor=e.Strip,e.Strip.prototype.setTexture=function(a){this.texture=a,this.width=a.frame.width,this.height=a.frame.height,this.updateFrame=!0},e.Strip.prototype.onTextureUpdate=function(){this.updateFrame=!0},e.Rope=function(a,b){e.Strip.call(this,a),this.points=b;try{this.verticies=new Float32Array(4*b.length),this.uvs=new Float32Array(4*b.length),this.colors=new Float32Array(2*b.length),this.indices=new Uint16Array(2*b.length)}catch(c){this.verticies=new Array(4*b.length),this.uvs=new Array(4*b.length),this.colors=new Array(2*b.length),this.indices=new Array(2*b.length)}this.refresh()},e.Rope.prototype=Object.create(e.Strip.prototype),e.Rope.prototype.constructor=e.Rope,e.Rope.prototype.refresh=function(){var a=this.points;if(!(a.length<1)){var b=this.uvs,c=a[0],d=this.indices,e=this.colors;this.count-=.2,b[0]=0,b[1]=1,b[2]=0,b[3]=1,e[0]=1,e[1]=1,d[0]=0,d[1]=1;for(var f,g,h,i=a.length,j=1;i>j;j++)f=a[j],g=4*j,h=j/(i-1),j%2?(b[g]=h,b[g+1]=0,b[g+2]=h,b[g+3]=1):(b[g]=h,b[g+1]=0,b[g+2]=h,b[g+3]=1),g=2*j,e[g]=1,e[g+1]=1,g=2*j,d[g]=g,d[g+1]=g+1,c=f}},e.Rope.prototype.updateTransform=function(){var a=this.points;if(!(a.length<1)){var b,c=a[0],d={x:0,y:0};this.count-=.2;var f=this.verticies;f[0]=c.x+d.x,f[1]=c.y+d.y,f[2]=c.x-d.x,f[3]=c.y-d.y;for(var g,h,i,j,k,l=a.length,m=1;l>m;m++)g=a[m],h=4*m,b=m1&&(i=1),j=Math.sqrt(d.x*d.x+d.y*d.y),k=this.texture.height/2,d.x/=j,d.y/=j,d.x*=k,d.y*=k,f[h]=g.x+d.x,f[h+1]=g.y+d.y,f[h+2]=g.x-d.x,f[h+3]=g.y-d.y,c=g;e.DisplayObjectContainer.prototype.updateTransform.call(this)}},e.Rope.prototype.setTexture=function(a){this.texture=a,this.updateFrame=!0},e.TilingSprite=function(a,b,c){e.Sprite.call(this,a),this.width=b||100,this.height=c||100,this.tileScale=new e.Point(1,1),this.tileScaleOffset=new e.Point(1,1),this.tilePosition=new e.Point(0,0),this.renderable=!0,this.tint=16777215,this.blendMode=e.blendModes.NORMAL},e.TilingSprite.prototype=Object.create(e.Sprite.prototype),e.TilingSprite.prototype.constructor=e.TilingSprite,Object.defineProperty(e.TilingSprite.prototype,"width",{get:function(){return this._width},set:function(a){this._width=a}}),Object.defineProperty(e.TilingSprite.prototype,"height",{get:function(){return this._height},set:function(a){this._height=a}}),e.TilingSprite.prototype.onTextureUpdate=function(){this.updateFrame=!0},e.TilingSprite.prototype._renderWebGL=function(a){if(this.visible!==!1&&0!==this.alpha){var b,c;if(this.mask||this.filters){for(this.mask&&(a.spriteBatch.stop(),a.maskManager.pushMask(this.mask,a.projection),a.spriteBatch.start()),this.filters&&(a.spriteBatch.flush(),a.filterManager.pushFilter(this._filterBlock)),this.tilingTexture?a.spriteBatch.renderTilingSprite(this):this.generateTilingTexture(!0),b=0,c=this.children.length;c>b;b++)this.children[b]._renderWebGL(a);a.spriteBatch.stop(),this.filters&&a.filterManager.popFilter(),this.mask&&a.maskManager.popMask(a.projection),a.spriteBatch.start()}else for(this.tilingTexture?a.spriteBatch.renderTilingSprite(this):this.generateTilingTexture(!0),b=0,c=this.children.length;c>b;b++)this.children[b]._renderWebGL(a)}},e.TilingSprite.prototype._renderCanvas=function(a){if(this.visible!==!1&&0!==this.alpha){var b=a.context;b.globalAlpha=this.worldAlpha;var c=this.worldTransform;b.setTransform(c[0],c[3],c[1],c[4],c[2],c[5]),this.__tilePattern||(this.generateTilingTexture(!1),this.tilingTexture&&(this.__tilePattern=b.createPattern(this.tilingTexture.baseTexture.source,"repeat"))),this.blendMode!==a.currentBlendMode&&(a.currentBlendMode=this.blendMode,b.globalCompositeOperation=e.blendModesCanvas[a.currentBlendMode]),b.beginPath();var d=this.tilePosition.x%this.tilingTexture.width,f=this.tilePosition.y%this.tilingTexture.height,g=this.tileScale;b.scale(g.x,g.y),b.translate(d,f),b.fillStyle=this.__tilePattern,b.fillRect(-d,-f,this.width/g.x,this.height/g.y),b.scale(1/g.x,1/g.y),b.translate(-d,-f),b.closePath()}},e.TilingSprite.prototype.getBounds=function(){var a=this._width,b=this._height,c=a*(1-this.anchor.x),d=a*-this.anchor.x,e=b*(1-this.anchor.y),f=b*-this.anchor.y,g=this.worldTransform,h=g[0],i=g[3],j=g[1],k=g[4],l=g[2],m=g[5],n=h*d+j*f+l,o=k*f+i*d+m,p=h*c+j*f+l,q=k*f+i*c+m,r=h*c+j*e+l,s=k*e+i*c+m,t=h*d+j*e+l,u=k*e+i*d+m,v=-1/0,w=-1/0,x=1/0,y=1/0;x=x>n?n:x,x=x>p?p:x,x=x>r?r:x,x=x>t?t:x,y=y>o?o:y,y=y>q?q:y,y=y>s?s:y,y=y>u?u:y,v=n>v?n:v,v=p>v?p:v,v=r>v?r:v,v=t>v?t:v,w=o>w?o:w,w=q>w?q:w,w=s>w?s:w,w=u>w?u:w;var z=this._bounds;return z.x=x,z.width=v-x,z.y=y,z.height=w-y,this._currentBounds=z,z},e.TilingSprite.prototype.generateTilingTexture=function(a){var b=this.texture;if(b.baseTexture.hasLoaded){var c,d,f=b.baseTexture,g=b.frame,h=g.width!==f.width||g.height!==f.height;this.tilingTexture=b;var i=!1;if(a?(c=e.getNextPowerOfTwo(b.frame.width),d=e.getNextPowerOfTwo(b.frame.height),g.width!==c&&g.height!==d&&(i=!0)):h&&(c=g.width,d=g.height,i=!0),i){var j=new e.CanvasBuffer(c,d);j.context.drawImage(b.baseTexture.source,g.x,g.y,g.width,g.height,0,0,c,d),this.tilingTexture=e.Texture.fromCanvas(j.canvas),this.tileScaleOffset.x=g.width/c,this.tileScaleOffset.y=g.height/d}this.tilingTexture.baseTexture._powerOf2=!0}};var j={};j.BoneData=function(a,b){this.name=a,this.parent=b},j.BoneData.prototype={length:0,x:0,y:0,rotation:0,scaleX:1,scaleY:1},j.SlotData=function(a,b){this.name=a,this.boneData=b},j.SlotData.prototype={r:1,g:1,b:1,a:1,attachmentName:null},j.Bone=function(a,b){this.data=a,this.parent=b,this.setToSetupPose()},j.Bone.yDown=!1,j.Bone.prototype={x:0,y:0,rotation:0,scaleX:1,scaleY:1,m00:0,m01:0,worldX:0,m10:0,m11:0,worldY:0,worldRotation:0,worldScaleX:1,worldScaleY:1,updateWorldTransform:function(a,b){var c=this.parent;null!=c?(this.worldX=this.x*c.m00+this.y*c.m01+c.worldX,this.worldY=this.x*c.m10+this.y*c.m11+c.worldY,this.worldScaleX=c.worldScaleX*this.scaleX,this.worldScaleY=c.worldScaleY*this.scaleY,this.worldRotation=c.worldRotation+this.rotation):(this.worldX=this.x,this.worldY=this.y,this.worldScaleX=this.scaleX,this.worldScaleY=this.scaleY,this.worldRotation=this.rotation);var d=this.worldRotation*Math.PI/180,e=Math.cos(d),f=Math.sin(d);this.m00=e*this.worldScaleX,this.m10=f*this.worldScaleX,this.m01=-f*this.worldScaleY,this.m11=e*this.worldScaleY,a&&(this.m00=-this.m00,this.m01=-this.m01),b&&(this.m10=-this.m10,this.m11=-this.m11),j.Bone.yDown&&(this.m10=-this.m10,this.m11=-this.m11)},setToSetupPose:function(){var a=this.data;this.x=a.x,this.y=a.y,this.rotation=a.rotation,this.scaleX=a.scaleX,this.scaleY=a.scaleY}},j.Slot=function(a,b,c){this.data=a,this.skeleton=b,this.bone=c,this.setToSetupPose()},j.Slot.prototype={r:1,g:1,b:1,a:1,_attachmentTime:0,attachment:null,setAttachment:function(a){this.attachment=a,this._attachmentTime=this.skeleton.time},setAttachmentTime:function(a){this._attachmentTime=this.skeleton.time-a},getAttachmentTime:function(){return this.skeleton.time-this._attachmentTime},setToSetupPose:function(){var a=this.data;this.r=a.r,this.g=a.g,this.b=a.b,this.a=a.a;for(var b=this.skeleton.data.slots,c=0,d=b.length;d>c;c++)if(b[c]==a){this.setAttachment(a.attachmentName?this.skeleton.getAttachmentBySlotIndex(c,a.attachmentName):null);break}}},j.Skin=function(a){this.name=a,this.attachments={}},j.Skin.prototype={addAttachment:function(a,b,c){this.attachments[a+":"+b]=c},getAttachment:function(a,b){return this.attachments[a+":"+b]},_attachAll:function(a,b){for(var c in b.attachments){var d=c.indexOf(":"),e=parseInt(c.substring(0,d),10),f=c.substring(d+1),g=a.slots[e];if(g.attachment&&g.attachment.name==f){var h=this.getAttachment(e,f);h&&g.setAttachment(h)}}}},j.Animation=function(a,b,c){this.name=a,this.timelines=b,this.duration=c},j.Animation.prototype={apply:function(a,b,c){c&&this.duration&&(b%=this.duration);for(var d=this.timelines,e=0,f=d.length;f>e;e++)d[e].apply(a,b,1)},mix:function(a,b,c,d){c&&this.duration&&(b%=this.duration);for(var e=this.timelines,f=0,g=e.length;g>f;f++)e[f].apply(a,b,d)}},j.binarySearch=function(a,b,c){var d=0,e=Math.floor(a.length/c)-2;if(!e)return c;for(var f=e>>>1;;){if(a[(f+1)*c]<=b?d=f+1:e=f,d==e)return(d+1)*c;f=d+e>>>1}},j.linearSearch=function(a,b,c){for(var d=0,e=a.length-c;e>=d;d+=c)if(a[d]>b)return d;return-1},j.Curves=function(a){this.curves=[],this.curves.length=6*(a-1)},j.Curves.prototype={setLinear:function(a){this.curves[6*a]=0},setStepped:function(a){this.curves[6*a]=-1},setCurve:function(a,b,c,d,e){var f=.1,g=f*f,h=g*f,i=3*f,j=3*g,k=6*g,l=6*h,m=2*-b+d,n=2*-c+e,o=3*(b-d)+1,p=3*(c-e)+1,q=6*a,r=this.curves;r[q]=b*i+m*j+o*h,r[q+1]=c*i+n*j+p*h,r[q+2]=m*k+o*l,r[q+3]=n*k+p*l,r[q+4]=o*l,r[q+5]=p*l},getCurvePercent:function(a,b){b=0>b?0:b>1?1:b;var c=6*a,d=this.curves,e=d[c];if(!e)return b;if(-1==e)return 0;for(var f=d[c+1],g=d[c+2],h=d[c+3],i=d[c+4],j=d[c+5],k=e,l=f,m=8;;){if(k>=b){var n=k-e,o=l-f;return o+(l-o)*(b-n)/(k-n)}if(!m)break;m--,e+=g,f+=h,g+=i,h+=j,k+=e,l+=f}return l+(1-l)*(b-k)/(1-k)}},j.RotateTimeline=function(a){this.curves=new j.Curves(a),this.frames=[],this.frames.length=2*a},j.RotateTimeline.prototype={boneIndex:0,getFrameCount:function(){return this.frames.length/2},setFrame:function(a,b,c){a*=2,this.frames[a]=b,this.frames[a+1]=c},apply:function(a,b,c){var d,e=this.frames;if(!(b=e[e.length-2]){for(d=f.data.rotation+e[e.length-1]-f.rotation;d>180;)d-=360;for(;-180>d;)d+=360;return void(f.rotation+=d*c)}var g=j.binarySearch(e,b,2),h=e[g-1],i=e[g],k=1-(b-i)/(e[g-2]-i);for(k=this.curves.getCurvePercent(g/2-1,k),d=e[g+1]-h;d>180;)d-=360;for(;-180>d;)d+=360;for(d=f.data.rotation+(h+d*k)-f.rotation;d>180;)d-=360;for(;-180>d;)d+=360;f.rotation+=d*c}}},j.TranslateTimeline=function(a){this.curves=new j.Curves(a),this.frames=[],this.frames.length=3*a},j.TranslateTimeline.prototype={boneIndex:0,getFrameCount:function(){return this.frames.length/3},setFrame:function(a,b,c,d){a*=3,this.frames[a]=b,this.frames[a+1]=c,this.frames[a+2]=d},apply:function(a,b,c){var d=this.frames;if(!(b=d[d.length-3])return e.x+=(e.data.x+d[d.length-2]-e.x)*c,void(e.y+=(e.data.y+d[d.length-1]-e.y)*c);var f=j.binarySearch(d,b,3),g=d[f-2],h=d[f-1],i=d[f],k=1-(b-i)/(d[f+-3]-i);k=this.curves.getCurvePercent(f/3-1,k),e.x+=(e.data.x+g+(d[f+1]-g)*k-e.x)*c,e.y+=(e.data.y+h+(d[f+2]-h)*k-e.y)*c}}},j.ScaleTimeline=function(a){this.curves=new j.Curves(a),this.frames=[],this.frames.length=3*a},j.ScaleTimeline.prototype={boneIndex:0,getFrameCount:function(){return this.frames.length/3},setFrame:function(a,b,c,d){a*=3,this.frames[a]=b,this.frames[a+1]=c,this.frames[a+2]=d},apply:function(a,b,c){var d=this.frames;if(!(b=d[d.length-3])return e.scaleX+=(e.data.scaleX-1+d[d.length-2]-e.scaleX)*c,void(e.scaleY+=(e.data.scaleY-1+d[d.length-1]-e.scaleY)*c);var f=j.binarySearch(d,b,3),g=d[f-2],h=d[f-1],i=d[f],k=1-(b-i)/(d[f+-3]-i);k=this.curves.getCurvePercent(f/3-1,k),e.scaleX+=(e.data.scaleX-1+g+(d[f+1]-g)*k-e.scaleX)*c,e.scaleY+=(e.data.scaleY-1+h+(d[f+2]-h)*k-e.scaleY)*c}}},j.ColorTimeline=function(a){this.curves=new j.Curves(a),this.frames=[],this.frames.length=5*a},j.ColorTimeline.prototype={slotIndex:0,getFrameCount:function(){return this.frames.length/2},setFrame:function(c,d){c*=5,this.frames[c]=d,this.frames[c+1]=r,this.frames[c+2]=g,this.frames[c+3]=b,this.frames[c+4]=a},apply:function(a,b,c){var d=this.frames;if(!(b=d[d.length-5]){var f=d.length-1;return e.r=d[f-3],e.g=d[f-2],e.b=d[f-1],void(e.a=d[f])}var g=j.binarySearch(d,b,5),h=d[g-4],i=d[g-3],k=d[g-2],l=d[g-1],m=d[g],n=1-(b-m)/(d[g-5]-m);n=this.curves.getCurvePercent(g/5-1,n);var o=h+(d[g+1]-h)*n,p=i+(d[g+2]-i)*n,q=k+(d[g+3]-k)*n,r=l+(d[g+4]-l)*n;1>c?(e.r+=(o-e.r)*c,e.g+=(p-e.g)*c,e.b+=(q-e.b)*c,e.a+=(r-e.a)*c):(e.r=o,e.g=p,e.b=q,e.a=r)}}},j.AttachmentTimeline=function(a){this.curves=new j.Curves(a),this.frames=[],this.frames.length=a,this.attachmentNames=[],this.attachmentNames.length=a},j.AttachmentTimeline.prototype={slotIndex:0,getFrameCount:function(){return this.frames.length},setFrame:function(a,b,c){this.frames[a]=b,this.attachmentNames[a]=c},apply:function(a,b){var c=this.frames;if(!(b=c[c.length-1]?c.length-1:j.binarySearch(c,b,1)-1;var e=this.attachmentNames[d];a.slots[this.slotIndex].setAttachment(e?a.getAttachmentBySlotIndex(this.slotIndex,e):null)}}},j.SkeletonData=function(){this.bones=[],this.slots=[],this.skins=[],this.animations=[]},j.SkeletonData.prototype={defaultSkin:null,findBone:function(a){for(var b=this.bones,c=0,d=b.length;d>c;c++)if(b[c].name==a)return b[c];return null},findBoneIndex:function(a){for(var b=this.bones,c=0,d=b.length;d>c;c++)if(b[c].name==a)return c;return-1},findSlot:function(a){for(var b=this.slots,c=0,d=b.length;d>c;c++)if(b[c].name==a)return slot[c];return null},findSlotIndex:function(a){for(var b=this.slots,c=0,d=b.length;d>c;c++)if(b[c].name==a)return c;return-1},findSkin:function(a){for(var b=this.skins,c=0,d=b.length;d>c;c++)if(b[c].name==a)return b[c];return null},findAnimation:function(a){for(var b=this.animations,c=0,d=b.length;d>c;c++)if(b[c].name==a)return b[c];return null}},j.Skeleton=function(a){this.data=a,this.bones=[];for(var b=0,c=a.bones.length;c>b;b++){var d=a.bones[b],e=d.parent?this.bones[a.bones.indexOf(d.parent)]:null;this.bones.push(new j.Bone(d,e))}for(this.slots=[],this.drawOrder=[],b=0,c=a.slots.length;c>b;b++){var f=a.slots[b],g=this.bones[a.bones.indexOf(f.boneData)],h=new j.Slot(f,this,g);this.slots.push(h),this.drawOrder.push(h)}},j.Skeleton.prototype={x:0,y:0,skin:null,r:1,g:1,b:1,a:1,time:0,flipX:!1,flipY:!1,updateWorldTransform:function(){for(var a=this.flipX,b=this.flipY,c=this.bones,d=0,e=c.length;e>d;d++)c[d].updateWorldTransform(a,b)},setToSetupPose:function(){this.setBonesToSetupPose(),this.setSlotsToSetupPose()},setBonesToSetupPose:function(){for(var a=this.bones,b=0,c=a.length;c>b;b++)a[b].setToSetupPose()},setSlotsToSetupPose:function(){for(var a=this.slots,b=0,c=a.length;c>b;b++)a[b].setToSetupPose(b)},getRootBone:function(){return this.bones.length?this.bones[0]:null},findBone:function(a){for(var b=this.bones,c=0,d=b.length;d>c;c++)if(b[c].data.name==a)return b[c];return null},findBoneIndex:function(a){for(var b=this.bones,c=0,d=b.length;d>c;c++)if(b[c].data.name==a)return c;return-1},findSlot:function(a){for(var b=this.slots,c=0,d=b.length;d>c;c++)if(b[c].data.name==a)return b[c];return null},findSlotIndex:function(a){for(var b=this.slots,c=0,d=b.length;d>c;c++)if(b[c].data.name==a)return c;return-1},setSkinByName:function(a){var b=this.data.findSkin(a);if(!b)throw"Skin not found: "+a;this.setSkin(b)},setSkin:function(a){this.skin&&a&&a._attachAll(this,this.skin),this.skin=a},getAttachmentBySlotName:function(a,b){return this.getAttachmentBySlotIndex(this.data.findSlotIndex(a),b)},getAttachmentBySlotIndex:function(a,b){if(this.skin){var c=this.skin.getAttachment(a,b);if(c)return c}return this.data.defaultSkin?this.data.defaultSkin.getAttachment(a,b):null},setAttachment:function(a,b){for(var c=this.slots,d=0,e=c.size;e>d;d++){var f=c[d];if(f.data.name==a){var g=null;if(b&&(g=this.getAttachment(d,b),null==g))throw"Attachment not found: "+b+", for slot: "+a;return void f.setAttachment(g)}}throw"Slot not found: "+a},update:function(a){time+=a}},j.AttachmentType={region:0},j.RegionAttachment=function(){this.offset=[],this.offset.length=8,this.uvs=[],this.uvs.length=8},j.RegionAttachment.prototype={x:0,y:0,rotation:0,scaleX:1,scaleY:1,width:0,height:0,rendererObject:null,regionOffsetX:0,regionOffsetY:0,regionWidth:0,regionHeight:0,regionOriginalWidth:0,regionOriginalHeight:0,setUVs:function(a,b,c,d,e){var f=this.uvs; e?(f[2]=a,f[3]=d,f[4]=a,f[5]=b,f[6]=c,f[7]=b,f[0]=c,f[1]=d):(f[0]=a,f[1]=d,f[2]=a,f[3]=b,f[4]=c,f[5]=b,f[6]=c,f[7]=d)},updateOffset:function(){var a=this.width/this.regionOriginalWidth*this.scaleX,b=this.height/this.regionOriginalHeight*this.scaleY,c=-this.width/2*this.scaleX+this.regionOffsetX*a,d=-this.height/2*this.scaleY+this.regionOffsetY*b,e=c+this.regionWidth*a,f=d+this.regionHeight*b,g=this.rotation*Math.PI/180,h=Math.cos(g),i=Math.sin(g),j=c*h+this.x,k=c*i,l=d*h+this.y,m=d*i,n=e*h+this.x,o=e*i,p=f*h+this.y,q=f*i,r=this.offset;r[0]=j-m,r[1]=l+k,r[2]=j-q,r[3]=p+k,r[4]=n-q,r[5]=p+o,r[6]=n-m,r[7]=l+o},computeVertices:function(a,b,c,d){a+=c.worldX,b+=c.worldY;var e=c.m00,f=c.m01,g=c.m10,h=c.m11,i=this.offset;d[0]=i[0]*e+i[1]*f+a,d[1]=i[0]*g+i[1]*h+b,d[2]=i[2]*e+i[3]*f+a,d[3]=i[2]*g+i[3]*h+b,d[4]=i[4]*e+i[5]*f+a,d[5]=i[4]*g+i[5]*h+b,d[6]=i[6]*e+i[7]*f+a,d[7]=i[6]*g+i[7]*h+b}},j.AnimationStateData=function(a){this.skeletonData=a,this.animationToMixTime={}},j.AnimationStateData.prototype={defaultMix:0,setMixByName:function(a,b,c){var d=this.skeletonData.findAnimation(a);if(!d)throw"Animation not found: "+a;var e=this.skeletonData.findAnimation(b);if(!e)throw"Animation not found: "+b;this.setMix(d,e,c)},setMix:function(a,b,c){this.animationToMixTime[a.name+":"+b.name]=c},getMix:function(a,b){var c=this.animationToMixTime[a.name+":"+b.name];return c?c:this.defaultMix}},j.AnimationState=function(a){this.data=a,this.queue=[]},j.AnimationState.prototype={current:null,previous:null,currentTime:0,previousTime:0,currentLoop:!1,previousLoop:!1,mixTime:0,mixDuration:0,update:function(a){if(this.currentTime+=a,this.previousTime+=a,this.mixTime+=a,this.queue.length>0){var b=this.queue[0];this.currentTime>=b.delay&&(this._setAnimation(b.animation,b.loop),this.queue.shift())}},apply:function(a){if(this.current)if(this.previous){this.previous.apply(a,this.previousTime,this.previousLoop);var b=this.mixTime/this.mixDuration;b>=1&&(b=1,this.previous=null),this.current.mix(a,this.currentTime,this.currentLoop,b)}else this.current.apply(a,this.currentTime,this.currentLoop)},clearAnimation:function(){this.previous=null,this.current=null,this.queue.length=0},_setAnimation:function(a,b){this.previous=null,a&&this.current&&(this.mixDuration=this.data.getMix(this.current,a),this.mixDuration>0&&(this.mixTime=0,this.previous=this.current,this.previousTime=this.currentTime,this.previousLoop=this.currentLoop)),this.current=a,this.currentLoop=b,this.currentTime=0},setAnimationByName:function(a,b){var c=this.data.skeletonData.findAnimation(a);if(!c)throw"Animation not found: "+a;this.setAnimation(c,b)},setAnimation:function(a,b){this.queue.length=0,this._setAnimation(a,b)},addAnimationByName:function(a,b,c){var d=this.data.skeletonData.findAnimation(a);if(!d)throw"Animation not found: "+a;this.addAnimation(d,b,c)},addAnimation:function(a,b,c){var d={};if(d.animation=a,d.loop=b,!c||0>=c){var e=this.queue.length?this.queue[this.queue.length-1].animation:this.current;c=null!=e?e.duration-this.data.getMix(e,a)+(c||0):0}d.delay=c,this.queue.push(d)},isComplete:function(){return!this.current||this.currentTime>=this.current.duration}},j.SkeletonJson=function(a){this.attachmentLoader=a},j.SkeletonJson.prototype={scale:1,readSkeletonData:function(a){for(var b,c=new j.SkeletonData,d=a.bones,e=0,f=d.length;f>e;e++){var g=d[e],h=null;if(g.parent&&(h=c.findBone(g.parent),!h))throw"Parent bone not found: "+g.parent;b=new j.BoneData(g.name,h),b.length=(g.length||0)*this.scale,b.x=(g.x||0)*this.scale,b.y=(g.y||0)*this.scale,b.rotation=g.rotation||0,b.scaleX=g.scaleX||1,b.scaleY=g.scaleY||1,c.bones.push(b)}var i=a.slots;for(e=0,f=i.length;f>e;e++){var k=i[e];if(b=c.findBone(k.bone),!b)throw"Slot bone not found: "+k.bone;var l=new j.SlotData(k.name,b),m=k.color;m&&(l.r=j.SkeletonJson.toColor(m,0),l.g=j.SkeletonJson.toColor(m,1),l.b=j.SkeletonJson.toColor(m,2),l.a=j.SkeletonJson.toColor(m,3)),l.attachmentName=k.attachment,c.slots.push(l)}var n=a.skins;for(var o in n)if(n.hasOwnProperty(o)){var p=n[o],q=new j.Skin(o);for(var r in p)if(p.hasOwnProperty(r)){var s=c.findSlotIndex(r),t=p[r];for(var u in t)if(t.hasOwnProperty(u)){var v=this.readAttachment(q,u,t[u]);null!=v&&q.addAttachment(s,u,v)}}c.skins.push(q),"default"==q.name&&(c.defaultSkin=q)}var w=a.animations;for(var x in w)w.hasOwnProperty(x)&&this.readAnimation(x,w[x],c);return c},readAttachment:function(a,b,c){b=c.name||b;var d=j.AttachmentType[c.type||"region"];if(d==j.AttachmentType.region){var e=new j.RegionAttachment;return e.x=(c.x||0)*this.scale,e.y=(c.y||0)*this.scale,e.scaleX=c.scaleX||1,e.scaleY=c.scaleY||1,e.rotation=c.rotation||0,e.width=(c.width||32)*this.scale,e.height=(c.height||32)*this.scale,e.updateOffset(),e.rendererObject={},e.rendererObject.name=b,e.rendererObject.scale={},e.rendererObject.scale.x=e.scaleX,e.rendererObject.scale.y=e.scaleY,e.rendererObject.rotation=-e.rotation*Math.PI/180,e}throw"Unknown attachment type: "+d},readAnimation:function(a,b,c){var d,e,f,g,h,i,k,l=[],m=0,n=b.bones;for(var o in n)if(n.hasOwnProperty(o)){var p=c.findBoneIndex(o);if(-1==p)throw"Bone not found: "+o;var q=n[o];for(f in q)if(q.hasOwnProperty(f))if(h=q[f],"rotate"==f){for(e=new j.RotateTimeline(h.length),e.boneIndex=p,d=0,i=0,k=h.length;k>i;i++)g=h[i],e.setFrame(d,g.time,g.angle),j.SkeletonJson.readCurve(e,d,g),d++;l.push(e),m=Math.max(m,e.frames[2*e.getFrameCount()-2])}else{if("translate"!=f&&"scale"!=f)throw"Invalid timeline type for a bone: "+f+" ("+o+")";var r=1;for("scale"==f?e=new j.ScaleTimeline(h.length):(e=new j.TranslateTimeline(h.length),r=this.scale),e.boneIndex=p,d=0,i=0,k=h.length;k>i;i++){g=h[i];var s=(g.x||0)*r,t=(g.y||0)*r;e.setFrame(d,g.time,s,t),j.SkeletonJson.readCurve(e,d,g),d++}l.push(e),m=Math.max(m,e.frames[3*e.getFrameCount()-3])}}var u=b.slots;for(var v in u)if(u.hasOwnProperty(v)){var w=u[v],x=c.findSlotIndex(v);for(f in w)if(w.hasOwnProperty(f))if(h=w[f],"color"==f){for(e=new j.ColorTimeline(h.length),e.slotIndex=x,d=0,i=0,k=h.length;k>i;i++){g=h[i];var y=g.color,z=j.SkeletonJson.toColor(y,0),A=j.SkeletonJson.toColor(y,1),B=j.SkeletonJson.toColor(y,2),C=j.SkeletonJson.toColor(y,3);e.setFrame(d,g.time,z,A,B,C),j.SkeletonJson.readCurve(e,d,g),d++}l.push(e),m=Math.max(m,e.frames[5*e.getFrameCount()-5])}else{if("attachment"!=f)throw"Invalid timeline type for a slot: "+f+" ("+v+")";for(e=new j.AttachmentTimeline(h.length),e.slotIndex=x,d=0,i=0,k=h.length;k>i;i++)g=h[i],e.setFrame(d++,g.time,g.name);l.push(e),m=Math.max(m,e.frames[e.getFrameCount()-1])}}c.animations.push(new j.Animation(a,l,m))}},j.SkeletonJson.readCurve=function(a,b,c){var d=c.curve;d&&("stepped"==d?a.curves.setStepped(b):d instanceof Array&&a.curves.setCurve(b,d[0],d[1],d[2],d[3]))},j.SkeletonJson.toColor=function(a,b){if(8!=a.length)throw"Color hexidecimal length must be 8, recieved: "+a;return parseInt(a.substring(2*b,2),16)/255},j.Atlas=function(a,b){this.textureLoader=b,this.pages=[],this.regions=[];var c=new j.AtlasReader(a),d=[];d.length=4;for(var e=null;;){var f=c.readLine();if(null==f)break;if(f=c.trim(f),f.length)if(e){var g=new j.AtlasRegion;g.name=f,g.page=e,g.rotate="true"==c.readValue(),c.readTuple(d);var h=parseInt(d[0],10),i=parseInt(d[1],10);c.readTuple(d);var k=parseInt(d[0],10),l=parseInt(d[1],10);g.u=h/e.width,g.v=i/e.height,g.rotate?(g.u2=(h+l)/e.width,g.v2=(i+k)/e.height):(g.u2=(h+k)/e.width,g.v2=(i+l)/e.height),g.x=h,g.y=i,g.width=Math.abs(k),g.height=Math.abs(l),4==c.readTuple(d)&&(g.splits=[parseInt(d[0],10),parseInt(d[1],10),parseInt(d[2],10),parseInt(d[3],10)],4==c.readTuple(d)&&(g.pads=[parseInt(d[0],10),parseInt(d[1],10),parseInt(d[2],10),parseInt(d[3],10)],c.readTuple(d))),g.originalWidth=parseInt(d[0],10),g.originalHeight=parseInt(d[1],10),c.readTuple(d),g.offsetX=parseInt(d[0],10),g.offsetY=parseInt(d[1],10),g.index=parseInt(c.readValue(),10),this.regions.push(g)}else{e=new j.AtlasPage,e.name=f,e.format=j.Atlas.Format[c.readValue()],c.readTuple(d),e.minFilter=j.Atlas.TextureFilter[d[0]],e.magFilter=j.Atlas.TextureFilter[d[1]];var m=c.readValue();e.uWrap=j.Atlas.TextureWrap.clampToEdge,e.vWrap=j.Atlas.TextureWrap.clampToEdge,"x"==m?e.uWrap=j.Atlas.TextureWrap.repeat:"y"==m?e.vWrap=j.Atlas.TextureWrap.repeat:"xy"==m&&(e.uWrap=e.vWrap=j.Atlas.TextureWrap.repeat),b.load(e,f),this.pages.push(e)}else e=null}},j.Atlas.prototype={findRegion:function(a){for(var b=this.regions,c=0,d=b.length;d>c;c++)if(b[c].name==a)return b[c];return null},dispose:function(){for(var a=this.pages,b=0,c=a.length;c>b;b++)this.textureLoader.unload(a[b].rendererObject)},updateUVs:function(a){for(var b=this.regions,c=0,d=b.length;d>c;c++){var e=b[c];e.page==a&&(e.u=e.x/a.width,e.v=e.y/a.height,e.rotate?(e.u2=(e.x+e.height)/a.width,e.v2=(e.y+e.width)/a.height):(e.u2=(e.x+e.width)/a.width,e.v2=(e.y+e.height)/a.height))}}},j.Atlas.Format={alpha:0,intensity:1,luminanceAlpha:2,rgb565:3,rgba4444:4,rgb888:5,rgba8888:6},j.Atlas.TextureFilter={nearest:0,linear:1,mipMap:2,mipMapNearestNearest:3,mipMapLinearNearest:4,mipMapNearestLinear:5,mipMapLinearLinear:6},j.Atlas.TextureWrap={mirroredRepeat:0,clampToEdge:1,repeat:2},j.AtlasPage=function(){},j.AtlasPage.prototype={name:null,format:null,minFilter:null,magFilter:null,uWrap:null,vWrap:null,rendererObject:null,width:0,height:0},j.AtlasRegion=function(){},j.AtlasRegion.prototype={page:null,name:null,x:0,y:0,width:0,height:0,u:0,v:0,u2:0,v2:0,offsetX:0,offsetY:0,originalWidth:0,originalHeight:0,index:0,rotate:!1,splits:null,pads:null},j.AtlasReader=function(a){this.lines=a.split(/\r\n|\r|\n/)},j.AtlasReader.prototype={index:0,trim:function(a){return a.replace(/^\s+|\s+$/g,"")},readLine:function(){return this.index>=this.lines.length?null:this.lines[this.index++]},readValue:function(){var a=this.readLine(),b=a.indexOf(":");if(-1==b)throw"Invalid line: "+a;return this.trim(a.substring(b+1))},readTuple:function(a){var b=this.readLine(),c=b.indexOf(":");if(-1==c)throw"Invalid line: "+b;for(var d=0,e=c+1;3>d;d++){var f=b.indexOf(",",e);if(-1==f){if(!d)throw"Invalid line: "+b;break}a[d]=this.trim(b.substr(e,f-e)),e=f+1}return a[d]=this.trim(b.substring(e)),d+1}},j.AtlasAttachmentLoader=function(a){this.atlas=a},j.AtlasAttachmentLoader.prototype={newAttachment:function(a,b,c){switch(b){case j.AttachmentType.region:var d=this.atlas.findRegion(c);if(!d)throw"Region not found in atlas: "+c+" ("+b+")";var e=new j.RegionAttachment(c);return e.rendererObject=d,e.setUVs(d.u,d.v,d.u2,d.v2,d.rotate),e.regionOffsetX=d.offsetX,e.regionOffsetY=d.offsetY,e.regionWidth=d.width,e.regionHeight=d.height,e.regionOriginalWidth=d.originalWidth,e.regionOriginalHeight=d.originalHeight,e}throw"Unknown attachment type: "+b}},j.Bone.yDown=!0,e.AnimCache={},e.Spine=function(a){if(e.DisplayObjectContainer.call(this),this.spineData=e.AnimCache[a],!this.spineData)throw new Error("Spine data must be preloaded using PIXI.SpineLoader or PIXI.AssetLoader: "+a);this.skeleton=new j.Skeleton(this.spineData),this.skeleton.updateWorldTransform(),this.stateData=new j.AnimationStateData(this.spineData),this.state=new j.AnimationState(this.stateData),this.slotContainers=[];for(var b=0,c=this.skeleton.drawOrder.length;c>b;b++){var d=this.skeleton.drawOrder[b],f=d.attachment,g=new e.DisplayObjectContainer;if(this.slotContainers.push(g),this.addChild(g),f instanceof j.RegionAttachment){var h=f.rendererObject.name,i=this.createSprite(d,f.rendererObject);d.currentSprite=i,d.currentSpriteName=h,g.addChild(i)}}},e.Spine.prototype=Object.create(e.DisplayObjectContainer.prototype),e.Spine.prototype.constructor=e.Spine,e.Spine.prototype.updateTransform=function(){this.lastTime=this.lastTime||Date.now();var a=.001*(Date.now()-this.lastTime);this.lastTime=Date.now(),this.state.update(a),this.state.apply(this.skeleton),this.skeleton.updateWorldTransform();for(var b=this.skeleton.drawOrder,c=0,d=b.length;d>c;c++){var f=b[c],g=f.attachment,h=this.slotContainers[c];if(g instanceof j.RegionAttachment){if(g.rendererObject&&(!f.currentSpriteName||f.currentSpriteName!=g.name)){var i=g.rendererObject.name;if(void 0!==f.currentSprite&&(f.currentSprite.visible=!1),f.sprites=f.sprites||{},void 0!==f.sprites[i])f.sprites[i].visible=!0;else{var k=this.createSprite(f,g.rendererObject);h.addChild(k)}f.currentSprite=f.sprites[i],f.currentSpriteName=i}h.visible=!0;var l=f.bone;h.position.x=l.worldX+g.x*l.m00+g.y*l.m01,h.position.y=l.worldY+g.x*l.m10+g.y*l.m11,h.scale.x=l.worldScaleX,h.scale.y=l.worldScaleY,h.rotation=-(f.bone.worldRotation*Math.PI/180)}else h.visible=!1}e.DisplayObjectContainer.prototype.updateTransform.call(this)},e.Spine.prototype.createSprite=function(a,b){var c=e.TextureCache[b.name]?b.name:b.name+".png",d=new e.Sprite(e.Texture.fromFrame(c));return d.scale=b.scale,d.rotation=b.rotation,d.anchor.x=d.anchor.y=.5,a.sprites=a.sprites||{},a.sprites[b.name]=d,d},e.BaseTextureCache={},e.texturesToUpdate=[],e.texturesToDestroy=[],e.BaseTexture=function(a,b){if(e.EventTarget.call(this),this.width=100,this.height=100,this.scaleMode=b||e.BaseTexture.SCALE_MODE.DEFAULT,this.hasLoaded=!1,this.source=a,a){if(this.source instanceof Image||this.source instanceof HTMLImageElement)if(this.source.complete)this.hasLoaded=!0,this.width=this.source.width,this.height=this.source.height,e.texturesToUpdate.push(this);else{var c=this;this.source.onload=function(){c.hasLoaded=!0,c.width=c.source.width,c.height=c.source.height,e.texturesToUpdate.push(c),c.dispatchEvent({type:"loaded",content:c})}}else this.hasLoaded=!0,this.width=this.source.width,this.height=this.source.height,e.texturesToUpdate.push(this);this.imageUrl=null,this._powerOf2=!1,this._glTextures=[]}},e.BaseTexture.prototype.constructor=e.BaseTexture,e.BaseTexture.prototype.destroy=function(){this.source instanceof Image&&(this.imageUrl in e.BaseTextureCache&&delete e.BaseTextureCache[this.imageUrl],this.imageUrl=null,this.source.src=null),this.source=null,e.texturesToDestroy.push(this)},e.BaseTexture.prototype.updateSourceImage=function(a){this.hasLoaded=!1,this.source.src=null,this.source.src=a},e.BaseTexture.fromImage=function(a,b,c){var d=e.BaseTextureCache[a];if(!d){var f=new Image;b&&(f.crossOrigin=""),f.src=a,d=new e.BaseTexture(f,c),d.imageUrl=a,e.BaseTextureCache[a]=d}return d},e.BaseTexture.SCALE_MODE={DEFAULT:0,LINEAR:0,NEAREST:1},e.TextureCache={},e.FrameCache={},e.Texture=function(a,b){if(e.EventTarget.call(this),b||(this.noFrame=!0,b=new e.Rectangle(0,0,1,1)),a instanceof e.Texture&&(a=a.baseTexture),this.baseTexture=a,this.frame=b,this.trim=new e.Point,this.scope=this,a.hasLoaded)this.noFrame&&(b=new e.Rectangle(0,0,a.width,a.height)),this.setFrame(b);else{var c=this;a.addEventListener("loaded",function(){c.onBaseTextureLoaded()})}},e.Texture.prototype.constructor=e.Texture,e.Texture.prototype.onBaseTextureLoaded=function(){var a=this.baseTexture;a.removeEventListener("loaded",this.onLoaded),this.noFrame&&(this.frame=new e.Rectangle(0,0,a.width,a.height)),this.setFrame(this.frame),this.scope.dispatchEvent({type:"update",content:this})},e.Texture.prototype.destroy=function(a){a&&this.baseTexture.destroy()},e.Texture.prototype.setFrame=function(a){if(this.frame=a,this.width=a.width,this.height=a.height,a.x+a.width>this.baseTexture.width||a.y+a.height>this.baseTexture.height)throw new Error("Texture Error: frame does not fit inside the base Texture dimensions "+this);this.updateFrame=!0,e.Texture.frameUpdates.push(this)},e.Texture.prototype._updateWebGLuvs=function(){this._uvs||(this._uvs=new Float32Array(8));var a=this.frame,b=this.baseTexture.width,c=this.baseTexture.height;this._uvs[0]=a.x/b,this._uvs[1]=a.y/c,this._uvs[2]=(a.x+a.width)/b,this._uvs[3]=a.y/c,this._uvs[4]=(a.x+a.width)/b,this._uvs[5]=(a.y+a.height)/c,this._uvs[6]=a.x/b,this._uvs[7]=(a.y+a.height)/c},e.Texture.fromImage=function(a,b,c){var d=e.TextureCache[a];return d||(d=new e.Texture(e.BaseTexture.fromImage(a,b,c)),e.TextureCache[a]=d),d},e.Texture.fromFrame=function(a){var b=e.TextureCache[a];if(!b)throw new Error('The frameId "'+a+'" does not exist in the texture cache '+this);return b},e.Texture.fromCanvas=function(a,b){var c=new e.BaseTexture(a,b);return new e.Texture(c)},e.Texture.addTextureToCache=function(a,b){e.TextureCache[b]=a},e.Texture.removeTextureFromCache=function(a){var b=e.TextureCache[a];return e.TextureCache[a]=null,b},e.Texture.frameUpdates=[],e.Texture.SCALE_MODE=e.BaseTexture.SCALE_MODE,e.RenderTexture=function(a,b,c){if(e.EventTarget.call(this),this.width=a||100,this.height=b||100,this.indetityMatrix=e.mat3.create(),this.frame=new e.Rectangle(0,0,this.width,this.height),this.baseTexture=new e.BaseTexture,this.baseTexture.width=this.width,this.baseTexture.height=this.height,this.baseTexture._glTextures=[],this.baseTexture.hasLoaded=!0,this.renderer=c||e.defaultRenderer,this.renderer.type===e.WEBGL_RENDERER){var d=this.renderer.gl;this.textureBuffer=new e.FilterTexture(d,this.width,this.height),this.baseTexture._glTextures[d.id]=this.textureBuffer.texture,this.render=this.renderWebGL,this.projection=new e.Point(this.width/2,-this.height/2)}else this.render=this.renderCanvas,this.textureBuffer=new e.CanvasBuffer(this.width,this.height),this.baseTexture.source=this.textureBuffer.canvas;e.Texture.frameUpdates.push(this)},e.RenderTexture.prototype=Object.create(e.Texture.prototype),e.RenderTexture.prototype.constructor=e.RenderTexture,e.RenderTexture.prototype.resize=function(a,b){if(this.width=a,this.height=b,this.frame.width=this.width,this.frame.height=this.height,this.renderer.type===e.WEBGL_RENDERER){this.projection.x=this.width/2,this.projection.y=-this.height/2;var c=this.gl;c.bindTexture(c.TEXTURE_2D,this.baseTexture._glTextures[c.id]),c.texImage2D(c.TEXTURE_2D,0,c.RGBA,this.width,this.height,0,c.RGBA,c.UNSIGNED_BYTE,null)}else this.textureBuffer.resize(this.width,this.height);e.Texture.frameUpdates.push(this)},e.RenderTexture.prototype.renderWebGL=function(a,b,c){var d=this.renderer.gl;d.colorMask(!0,!0,!0,!0),d.viewport(0,0,this.width,this.height),d.bindFramebuffer(d.FRAMEBUFFER,this.textureBuffer.frameBuffer),c&&this.textureBuffer.clear();var f=a.children,g=a.worldTransform;a.worldTransform=e.mat3.create(),a.worldTransform[4]=-1,a.worldTransform[5]=-2*this.projection.y,b&&(a.worldTransform[2]=b.x,a.worldTransform[5]-=b.y);for(var h=0,i=f.length;i>h;h++)f[h].updateTransform();this.renderer.renderDisplayObject(a,this.projection),a.worldTransform=g},e.RenderTexture.prototype.renderCanvas=function(a,b,c){var d=a.children;a.worldTransform=e.mat3.create(),b&&(a.worldTransform[2]=b.x,a.worldTransform[5]=b.y);for(var f=0,g=d.length;g>f;f++)d[f].updateTransform();c&&this.textureBuffer.clear();var h=this.textureBuffer.context;this.renderer.renderDisplayObject(a,h),h.setTransform(1,0,0,1,0,0)},e.AssetLoader=function(a,b){e.EventTarget.call(this),this.assetURLs=a,this.crossorigin=b,this.loadersByType={jpg:e.ImageLoader,jpeg:e.ImageLoader,png:e.ImageLoader,gif:e.ImageLoader,json:e.JsonLoader,atlas:e.AtlasLoader,anim:e.SpineLoader,xml:e.BitmapFontLoader,fnt:e.BitmapFontLoader}},e.AssetLoader.prototype.constructor=e.AssetLoader,e.AssetLoader.prototype._getDataType=function(a){var b="data:",c=a.slice(0,b.length).toLowerCase();if(c===b){var d=a.slice(b.length),e=d.indexOf(",");if(-1===e)return null;var f=d.slice(0,e).split(";")[0];return f&&"text/plain"!==f.toLowerCase()?f.split("/").pop().toLowerCase():"txt"}return null},e.AssetLoader.prototype.load=function(){function a(){b.onAssetLoaded()}var b=this;this.loadCount=this.assetURLs.length;for(var c=0;c0){if(f===g)this.atlas.meta.image.push(a[g]),c=this.atlas.meta.image.length-1,this.atlas.frames.push({}),b=-3;else if(b>0)if(b%7===1)null!=d&&(this.atlas.frames[c][d.name]=d),d={name:a[g],frame:{}};else{var j=a[g].split(" ");if(b%7===3)d.frame.x=Number(j[1].replace(",","")),d.frame.y=Number(j[2]);else if(b%7===4)d.frame.w=Number(j[1].replace(",","")),d.frame.h=Number(j[2]);else if(b%7===5){var k={x:0,y:0,w:Number(j[1].replace(",","")),h:Number(j[2])};k.w>d.frame.w||k.h>d.frame.h?(d.trimmed=!0,d.realSize=k):d.trimmed=!1}}b++}if(null!=d&&(this.atlas.frames[c][d.name]=d),this.atlas.meta.image.length>0){for(this.images=[],h=0;hthis.currentImageId?(this.currentImageId++,this.images[this.currentImageId].load()):(this.loaded=!0,this.dispatchEvent({type:"loaded",content:this}))},e.AtlasLoader.prototype.onError=function(){this.dispatchEvent({type:"error",content:this})},e.SpriteSheetLoader=function(a,b){e.EventTarget.call(this),this.url=a,this.crossorigin=b,this.baseUrl=a.replace(/[^\/]*$/,""),this.texture=null,this.frames={}},e.SpriteSheetLoader.prototype.constructor=e.SpriteSheetLoader,e.SpriteSheetLoader.prototype.load=function(){var a=this,b=new e.JsonLoader(this.url,this.crossorigin);b.addEventListener("loaded",function(b){a.json=b.content.json,a.onLoaded()}),b.load()},e.SpriteSheetLoader.prototype.onLoaded=function(){this.dispatchEvent({type:"loaded",content:this})},e.ImageLoader=function(a,b){e.EventTarget.call(this),this.texture=e.Texture.fromImage(a,b),this.frames=[]},e.ImageLoader.prototype.constructor=e.ImageLoader,e.ImageLoader.prototype.load=function(){if(this.texture.baseTexture.hasLoaded)this.onLoaded();else{var a=this;this.texture.baseTexture.addEventListener("loaded",function(){a.onLoaded()})}},e.ImageLoader.prototype.onLoaded=function(){this.dispatchEvent({type:"loaded",content:this})},e.ImageLoader.prototype.loadFramedSpriteSheet=function(a,b,c){this.frames=[];for(var d=Math.floor(this.texture.width/a),f=Math.floor(this.texture.height/b),g=0,h=0;f>h;h++)for(var i=0;d>i;i++,g++){var j=new e.Texture(this.texture,{x:i*a,y:h*b,width:a,height:b});this.frames.push(j),c&&(e.TextureCache[c+"-"+g]=j)}if(this.texture.baseTexture.hasLoaded)this.onLoaded();else{var k=this;this.texture.baseTexture.addEventListener("loaded",function(){k.onLoaded()})}},e.BitmapFontLoader=function(a,b){e.EventTarget.call(this),this.url=a,this.crossorigin=b,this.baseUrl=a.replace(/[^\/]*$/,""),this.texture=null},e.BitmapFontLoader.prototype.constructor=e.BitmapFontLoader,e.BitmapFontLoader.prototype.load=function(){this.ajaxRequest=new XMLHttpRequest;var a=this;this.ajaxRequest.onreadystatechange=function(){a.onXMLLoaded()},this.ajaxRequest.open("GET",this.url,!0),this.ajaxRequest.overrideMimeType&&this.ajaxRequest.overrideMimeType("application/xml"),this.ajaxRequest.send(null)},e.BitmapFontLoader.prototype.onXMLLoaded=function(){if(4===this.ajaxRequest.readyState&&(200===this.ajaxRequest.status||-1===window.location.protocol.indexOf("http"))){var a=this.ajaxRequest.responseXML;if(!a||/MSIE 9/i.test(navigator.userAgent)||navigator.isCocoonJS)if("function"==typeof window.DOMParser){var b=new DOMParser;a=b.parseFromString(this.ajaxRequest.responseText,"text/xml")}else{var c=document.createElement("div");c.innerHTML=this.ajaxRequest.responseText,a=c}var d=this.baseUrl+a.getElementsByTagName("page")[0].getAttribute("file"),f=new e.ImageLoader(d,this.crossorigin);this.texture=f.texture.baseTexture;var g={},h=a.getElementsByTagName("info")[0],i=a.getElementsByTagName("common")[0];g.font=h.getAttribute("face"),g.size=parseInt(h.getAttribute("size"),10),g.lineHeight=parseInt(i.getAttribute("lineHeight"),10),g.chars={};for(var j=a.getElementsByTagName("char"),k=0;k=0;d--)c=[a[d].apply(this,c)];return c[0]}},each:function(b,c,d){if(b)if(a&&b.forEach&&b.forEach===a)b.forEach(c,d);else if(b.length===b.length+0){for(var e=0,f=b.length;f>e;e++)if(e in b&&c.call(d,b[e],e)===this.BREAK)return}else for(var e in b)if(c.call(d,b[e],e)===this.BREAK)return},defer:function(a){setTimeout(a,0)},toArray:function(a){return a.toArray?a.toArray():b.call(a)},isUndefined:function(a){return void 0===a},isNull:function(a){return null===a},isNaN:function(a){return a!==a},isArray:Array.isArray||function(a){return a.constructor===Array},isObject:function(a){return a===Object(a)},isNumber:function(a){return a===a+0},isString:function(a){return a===a+""},isBoolean:function(a){return a===!1||a===!0},isFunction:function(a){return"[object Function]"===Object.prototype.toString.call(a)}}}(),dat.controllers.Controller=function(a){var b=function(a,b){this.initialValue=a[b],this.domElement=document.createElement("div"),this.object=a,this.property=b,this.__onChange=void 0,this.__onFinishChange=void 0};return a.extend(b.prototype,{onChange:function(a){return this.__onChange=a,this},onFinishChange:function(a){return this.__onFinishChange=a,this},setValue:function(a){return this.object[this.property]=a,this.__onChange&&this.__onChange.call(this,a),this.updateDisplay(),this},getValue:function(){return this.object[this.property]},updateDisplay:function(){return this},isModified:function(){return this.initialValue!==this.getValue()}}),b}(dat.utils.common),dat.dom.dom=function(a){function b(b){if("0"===b||a.isUndefined(b))return 0;var c=b.match(e);return a.isNull(c)?0:parseFloat(c[1])}var c={HTMLEvents:["change"],MouseEvents:["click","mousemove","mousedown","mouseup","mouseover"],KeyboardEvents:["keydown"]},d={};a.each(c,function(b,c){a.each(b,function(a){d[a]=c})});var e=/(\d+(\.\d+)?)px/,f={makeSelectable:function(a,b){void 0!==a&&void 0!==a.style&&(a.onselectstart=b?function(){return!1}:function(){},a.style.MozUserSelect=b?"auto":"none",a.style.KhtmlUserSelect=b?"auto":"none",a.unselectable=b?"on":"off")},makeFullscreen:function(b,c,d){a.isUndefined(c)&&(c=!0),a.isUndefined(d)&&(d=!0),b.style.position="absolute",c&&(b.style.left=0,b.style.right=0),d&&(b.style.top=0,b.style.bottom=0)},fakeEvent:function(b,c,e,f){e=e||{};var g=d[c];if(!g)throw new Error("Event type "+c+" not supported.");var h=document.createEvent(g);switch(g){case"MouseEvents":var i=e.x||e.clientX||0,j=e.y||e.clientY||0;h.initMouseEvent(c,e.bubbles||!1,e.cancelable||!0,window,e.clickCount||1,0,0,i,j,!1,!1,!1,!1,0,null);break;case"KeyboardEvents":var k=h.initKeyboardEvent||h.initKeyEvent;a.defaults(e,{cancelable:!0,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1,keyCode:void 0,charCode:void 0}),k(c,e.bubbles||!1,e.cancelable,window,e.ctrlKey,e.altKey,e.shiftKey,e.metaKey,e.keyCode,e.charCode);break;default:h.initEvent(c,e.bubbles||!1,e.cancelable||!0)}a.defaults(h,f),b.dispatchEvent(h)},bind:function(a,b,c,d){return d=d||!1,a.addEventListener?a.addEventListener(b,c,d):a.attachEvent&&a.attachEvent("on"+b,c),f},unbind:function(a,b,c,d){return d=d||!1,a.removeEventListener?a.removeEventListener(b,c,d):a.detachEvent&&a.detachEvent("on"+b,c),f},addClass:function(a,b){if(void 0===a.className)a.className=b;else if(a.className!==b){var c=a.className.split(/ +/);-1==c.indexOf(b)&&(c.push(b),a.className=c.join(" ").replace(/^\s+/,"").replace(/\s+$/,""))}return f},removeClass:function(a,b){if(b)if(void 0===a.className);else if(a.className===b)a.removeAttribute("class");else{var c=a.className.split(/ +/),d=c.indexOf(b);-1!=d&&(c.splice(d,1),a.className=c.join(" "))}else a.className=void 0;return f},hasClass:function(a,b){return new RegExp("(?:^|\\s+)"+b+"(?:\\s+|$)").test(a.className)||!1},getWidth:function(a){var c=getComputedStyle(a);return b(c["border-left-width"])+b(c["border-right-width"])+b(c["padding-left"])+b(c["padding-right"])+b(c.width)},getHeight:function(a){var c=getComputedStyle(a);return b(c["border-top-width"])+b(c["border-bottom-width"])+b(c["padding-top"])+b(c["padding-bottom"])+b(c.height)},getOffset:function(a){var b={left:0,top:0};if(a.offsetParent)do b.left+=a.offsetLeft,b.top+=a.offsetTop;while(a=a.offsetParent);return b},isActive:function(a){return a===document.activeElement&&(a.type||a.href)}};return f}(dat.utils.common),dat.controllers.OptionController=function(a,b,c){var d=function(a,e,f){d.superclass.call(this,a,e);var g=this;if(this.__select=document.createElement("select"),c.isArray(f)){var h={};c.each(f,function(a){h[a]=a}),f=h}c.each(f,function(a,b){var c=document.createElement("option");c.innerHTML=b,c.setAttribute("value",a),g.__select.appendChild(c)}),this.updateDisplay(),b.bind(this.__select,"change",function(){var a=this.options[this.selectedIndex].value;g.setValue(a)}),this.domElement.appendChild(this.__select)};return d.superclass=a,c.extend(d.prototype,a.prototype,{setValue:function(a){var b=d.superclass.prototype.setValue.call(this,a);return this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue()),b},updateDisplay:function(){return this.__select.value=this.getValue(),d.superclass.prototype.updateDisplay.call(this)}}),d}(dat.controllers.Controller,dat.dom.dom,dat.utils.common),dat.controllers.NumberController=function(a,b){function c(a){return a=a.toString(),a.indexOf(".")>-1?a.length-a.indexOf(".")-1:0}var d=function(a,e,f){d.superclass.call(this,a,e),f=f||{},this.__min=f.min,this.__max=f.max,this.__step=f.step,this.__impliedStep=b.isUndefined(this.__step)?0==this.initialValue?1:Math.pow(10,Math.floor(Math.log(this.initialValue)/Math.LN10))/10:this.__step,this.__precision=c(this.__impliedStep)};return d.superclass=a,b.extend(d.prototype,a.prototype,{setValue:function(a){return void 0!==this.__min&&athis.__max&&(a=this.__max),void 0!==this.__step&&a%this.__step!=0&&(a=Math.round(a/this.__step)*this.__step),d.superclass.prototype.setValue.call(this,a)},min:function(a){return this.__min=a,this},max:function(a){return this.__max=a,this},step:function(a){return this.__step=a,this.__impliedStep=a,this.__precision=c(a),this}}),d}(dat.controllers.Controller,dat.utils.common),dat.controllers.NumberControllerBox=function(a,b,c){function d(a,b){var c=Math.pow(10,b);return Math.round(a*c)/c}var e=function(a,d,f){function g(){var a=parseFloat(m.__input.value);c.isNaN(a)||m.setValue(a)}function h(){g(),m.__onFinishChange&&m.__onFinishChange.call(m,m.getValue())}function i(a){b.bind(window,"mousemove",j),b.bind(window,"mouseup",k),l=a.clientY}function j(a){var b=l-a.clientY;m.setValue(m.getValue()+b*m.__impliedStep),l=a.clientY}function k(){b.unbind(window,"mousemove",j),b.unbind(window,"mouseup",k)}this.__truncationSuspended=!1,e.superclass.call(this,a,d,f);var l,m=this;this.__input=document.createElement("input"),this.__input.setAttribute("type","text"),b.bind(this.__input,"change",g),b.bind(this.__input,"blur",h),b.bind(this.__input,"mousedown",i),b.bind(this.__input,"keydown",function(a){13===a.keyCode&&(m.__truncationSuspended=!0,this.blur(),m.__truncationSuspended=!1)}),this.updateDisplay(),this.domElement.appendChild(this.__input)};return e.superclass=a,c.extend(e.prototype,a.prototype,{updateDisplay:function(){return this.__input.value=this.__truncationSuspended?this.getValue():d(this.getValue(),this.__precision),e.superclass.prototype.updateDisplay.call(this)}}),e}(dat.controllers.NumberController,dat.dom.dom,dat.utils.common),dat.controllers.NumberControllerSlider=function(a,b,c,d,e){function f(a,b,c,d,e){return d+(e-d)*((a-b)/(c-b))}var g=function(a,c,d,e,h){function i(a){b.bind(window,"mousemove",j),b.bind(window,"mouseup",k),j(a)}function j(a){a.preventDefault();var c=b.getOffset(l.__background),d=b.getWidth(l.__background);return l.setValue(f(a.clientX,c.left,c.left+d,l.__min,l.__max)),!1}function k(){b.unbind(window,"mousemove",j),b.unbind(window,"mouseup",k),l.__onFinishChange&&l.__onFinishChange.call(l,l.getValue())}g.superclass.call(this,a,c,{min:d,max:e,step:h});var l=this;this.__background=document.createElement("div"),this.__foreground=document.createElement("div"),b.bind(this.__background,"mousedown",i),b.addClass(this.__background,"slider"),b.addClass(this.__foreground,"slider-fg"),this.updateDisplay(),this.__background.appendChild(this.__foreground),this.domElement.appendChild(this.__background)};return g.superclass=a,g.useDefaultStyles=function(){c.inject(e)},d.extend(g.prototype,a.prototype,{updateDisplay:function(){var a=(this.getValue()-this.__min)/(this.__max-this.__min);return this.__foreground.style.width=100*a+"%",g.superclass.prototype.updateDisplay.call(this)}}),g}(dat.controllers.NumberController,dat.dom.dom,dat.utils.css,dat.utils.common,"/**\n * dat-gui JavaScript Controller Library\n * http://code.google.com/p/dat-gui\n *\n * Copyright 2011 Data Arts Team, Google Creative Lab\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n */\n\n.slider {\n box-shadow: inset 0 2px 4px rgba(0,0,0,0.15);\n height: 1em;\n border-radius: 1em;\n background-color: #eee;\n padding: 0 0.5em;\n overflow: hidden;\n}\n\n.slider-fg {\n padding: 1px 0 2px 0;\n background-color: #aaa;\n height: 1em;\n margin-left: -0.5em;\n padding-right: 0.5em;\n border-radius: 1em 0 0 1em;\n}\n\n.slider-fg:after {\n display: inline-block;\n border-radius: 1em;\n background-color: #fff;\n border: 1px solid #aaa;\n content: '';\n float: right;\n margin-right: -1em;\n margin-top: -1px;\n height: 0.9em;\n width: 0.9em;\n}"),dat.controllers.FunctionController=function(a,b,c){var d=function(a,c,e){d.superclass.call(this,a,c);var f=this;this.__button=document.createElement("div"),this.__button.innerHTML=void 0===e?"Fire":e,b.bind(this.__button,"click",function(a){return a.preventDefault(),f.fire(),!1}),b.addClass(this.__button,"button"),this.domElement.appendChild(this.__button)};return d.superclass=a,c.extend(d.prototype,a.prototype,{fire:function(){this.__onChange&&this.__onChange.call(this),this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue()),this.getValue().call(this.object)}}),d}(dat.controllers.Controller,dat.dom.dom,dat.utils.common),dat.controllers.BooleanController=function(a,b,c){var d=function(a,c){function e(){f.setValue(!f.__prev)}d.superclass.call(this,a,c);var f=this;this.__prev=this.getValue(),this.__checkbox=document.createElement("input"),this.__checkbox.setAttribute("type","checkbox"),b.bind(this.__checkbox,"change",e,!1),this.domElement.appendChild(this.__checkbox),this.updateDisplay()};return d.superclass=a,c.extend(d.prototype,a.prototype,{setValue:function(a){var b=d.superclass.prototype.setValue.call(this,a);return this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue()),this.__prev=this.getValue(),b},updateDisplay:function(){return this.getValue()===!0?(this.__checkbox.setAttribute("checked","checked"),this.__checkbox.checked=!0):this.__checkbox.checked=!1,d.superclass.prototype.updateDisplay.call(this)}}),d}(dat.controllers.Controller,dat.dom.dom,dat.utils.common),dat.color.toString=function(a){return function(b){if(1==b.a||a.isUndefined(b.a)){for(var c=b.hex.toString(16);c.length<6;)c="0"+c;return"#"+c}return"rgba("+Math.round(b.r)+","+Math.round(b.g)+","+Math.round(b.b)+","+b.a+")"}}(dat.utils.common),dat.color.interpret=function(a,b){var c,d,e=function(){d=!1;var a=arguments.length>1?b.toArray(arguments):arguments[0];return b.each(f,function(e){return e.litmus(a)?(b.each(e.conversions,function(e,f){return c=e.read(a),d===!1&&c!==!1?(d=c,c.conversionName=f,c.conversion=e,b.BREAK):void 0}),b.BREAK):void 0}),d},f=[{litmus:b.isString,conversions:{THREE_CHAR_HEX:{read:function(a){var b=a.match(/^#([A-F0-9])([A-F0-9])([A-F0-9])$/i);return null===b?!1:{space:"HEX",hex:parseInt("0x"+b[1].toString()+b[1].toString()+b[2].toString()+b[2].toString()+b[3].toString()+b[3].toString())}},write:a},SIX_CHAR_HEX:{read:function(a){var b=a.match(/^#([A-F0-9]{6})$/i);return null===b?!1:{space:"HEX",hex:parseInt("0x"+b[1].toString())}},write:a},CSS_RGB:{read:function(a){var b=a.match(/^rgb\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\)/);return null===b?!1:{space:"RGB",r:parseFloat(b[1]),g:parseFloat(b[2]),b:parseFloat(b[3])}},write:a},CSS_RGBA:{read:function(a){var b=a.match(/^rgba\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\,\s*(.+)\s*\)/);return null===b?!1:{space:"RGB",r:parseFloat(b[1]),g:parseFloat(b[2]),b:parseFloat(b[3]),a:parseFloat(b[4])}},write:a}}},{litmus:b.isNumber,conversions:{HEX:{read:function(a){return{space:"HEX",hex:a,conversionName:"HEX"}},write:function(a){return a.hex}}}},{litmus:b.isArray,conversions:{RGB_ARRAY:{read:function(a){return 3!=a.length?!1:{space:"RGB",r:a[0],g:a[1],b:a[2]}},write:function(a){return[a.r,a.g,a.b]}},RGBA_ARRAY:{read:function(a){return 4!=a.length?!1:{space:"RGB",r:a[0],g:a[1],b:a[2],a:a[3]}},write:function(a){return[a.r,a.g,a.b,a.a]}}}},{litmus:b.isObject,conversions:{RGBA_OBJ:{read:function(a){return b.isNumber(a.r)&&b.isNumber(a.g)&&b.isNumber(a.b)&&b.isNumber(a.a)?{space:"RGB",r:a.r,g:a.g,b:a.b,a:a.a}:!1},write:function(a){return{r:a.r,g:a.g,b:a.b,a:a.a}}},RGB_OBJ:{read:function(a){return b.isNumber(a.r)&&b.isNumber(a.g)&&b.isNumber(a.b)?{space:"RGB",r:a.r,g:a.g,b:a.b}:!1},write:function(a){return{r:a.r,g:a.g,b:a.b}}},HSVA_OBJ:{read:function(a){return b.isNumber(a.h)&&b.isNumber(a.s)&&b.isNumber(a.v)&&b.isNumber(a.a)?{space:"HSV",h:a.h,s:a.s,v:a.v,a:a.a}:!1},write:function(a){return{h:a.h,s:a.s,v:a.v,a:a.a}}},HSV_OBJ:{read:function(a){return b.isNumber(a.h)&&b.isNumber(a.s)&&b.isNumber(a.v)?{space:"HSV",h:a.h,s:a.s,v:a.v}:!1},write:function(a){return{h:a.h,s:a.s,v:a.v}}}}}];return e}(dat.color.toString,dat.utils.common),dat.GUI=dat.gui.GUI=function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o){function p(a,b,c,f){if(void 0===b[c])throw new Error("Object "+b+' has no property "'+c+'"');var g;if(f.color)g=new k(b,c);else{var h=[b,c].concat(f.factoryArgs);g=d.apply(a,h)}f.before instanceof e&&(f.before=f.before.__li),s(a,g),n.addClass(g.domElement,"c");var i=document.createElement("span");n.addClass(i,"property-name"),i.innerHTML=g.property;var j=document.createElement("div");j.appendChild(i),j.appendChild(g.domElement);var l=q(a,j,f.before);return n.addClass(l,M.CLASS_CONTROLLER_ROW),n.addClass(l,typeof g.getValue()),r(a,l,g),a.__controllers.push(g),g}function q(a,b,c){var d=document.createElement("li");return b&&d.appendChild(b),c?a.__ul.insertBefore(d,params.before):a.__ul.appendChild(d),a.onResize(),d}function r(a,b,c){if(c.__li=b,c.__gui=a,o.extend(c,{options:function(b){return arguments.length>1?(c.remove(),p(a,c.object,c.property,{before:c.__li.nextElementSibling,factoryArgs:[o.toArray(arguments)]})):o.isArray(b)||o.isObject(b)?(c.remove(),p(a,c.object,c.property,{before:c.__li.nextElementSibling,factoryArgs:[b]})):void 0},name:function(a){return c.__li.firstElementChild.firstElementChild.innerHTML=a,c},listen:function(){return c.__gui.listen(c),c},remove:function(){return c.__gui.remove(c),c}}),c instanceof i){var d=new h(c.object,c.property,{min:c.__min,max:c.__max,step:c.__step});o.each(["updateDisplay","onChange","onFinishChange"],function(a){var b=c[a],e=d[a];c[a]=d[a]=function(){var a=Array.prototype.slice.call(arguments);return b.apply(c,a),e.apply(d,a)}}),n.addClass(b,"has-slider"),c.domElement.insertBefore(d.domElement,c.domElement.firstElementChild)}else if(c instanceof h){var e=function(b){return o.isNumber(c.__min)&&o.isNumber(c.__max)?(c.remove(),p(a,c.object,c.property,{before:c.__li.nextElementSibling,factoryArgs:[c.__min,c.__max,c.__step]})):b};c.min=o.compose(e,c.min),c.max=o.compose(e,c.max)}else c instanceof f?(n.bind(b,"click",function(){n.fakeEvent(c.__checkbox,"click")}),n.bind(c.__checkbox,"click",function(a){a.stopPropagation()})):c instanceof g?(n.bind(b,"click",function(){n.fakeEvent(c.__button,"click")}),n.bind(b,"mouseover",function(){n.addClass(c.__button,"hover")}),n.bind(b,"mouseout",function(){n.removeClass(c.__button,"hover")})):c instanceof k&&(n.addClass(b,"color"),c.updateDisplay=o.compose(function(a){return b.style.borderLeftColor=c.__color.toString(),a},c.updateDisplay),c.updateDisplay());c.setValue=o.compose(function(b){return a.getRoot().__preset_select&&c.isModified()&&A(a.getRoot(),!0),b},c.setValue)}function s(a,b){var c=a.getRoot(),d=c.__rememberedObjects.indexOf(b.object);if(-1!=d){var e=c.__rememberedObjectIndecesToControllers[d];if(void 0===e&&(e={},c.__rememberedObjectIndecesToControllers[d]=e),e[b.property]=b,c.load&&c.load.remembered){var f,g=c.load.remembered;if(g[a.preset])f=g[a.preset];else{if(!g[H])return;f=g[H]}if(f[d]&&void 0!==f[d][b.property]){var h=f[d][b.property];b.initialValue=h,b.setValue(h)}}}}function t(a,b){return document.location.href+"."+b}function u(a){function b(){j.style.display=a.useLocalStorage?"block":"none"}var c=a.__save_row=document.createElement("li");n.addClass(a.domElement,"has-save"),a.__ul.insertBefore(c,a.__ul.firstChild),n.addClass(c,"save-row");var d=document.createElement("span");d.innerHTML=" ",n.addClass(d,"button gears");var e=document.createElement("span");e.innerHTML="Save",n.addClass(e,"button"),n.addClass(e,"save");var f=document.createElement("span");f.innerHTML="New",n.addClass(f,"button"),n.addClass(f,"save-as");var g=document.createElement("span");g.innerHTML="Revert",n.addClass(g,"button"),n.addClass(g,"revert");var h=a.__preset_select=document.createElement("select");if(a.load&&a.load.remembered?o.each(a.load.remembered,function(b,c){y(a,c,c==a.preset)}):y(a,H,!1),n.bind(h,"change",function(){for(var b=0;b0&&(a.preset=this.preset,a.remembered||(a.remembered={}),a.remembered[this.preset]=x(this)),a.folders={},o.each(this.__folders,function(b,c){a.folders[c]=b.getSaveObject()}),a},save:function(){this.load.remembered||(this.load.remembered={}),this.load.remembered[this.preset]=x(this),A(this,!1),this.saveToLocalStorageIfPossible()},saveAs:function(a){this.load.remembered||(this.load.remembered={},this.load.remembered[H]=x(this,!0)),this.load.remembered[a]=x(this),this.preset=a,y(this,a,!0),this.saveToLocalStorageIfPossible()},revert:function(a){o.each(this.__controllers,function(b){this.getRoot().load.remembered?s(a||this.getRoot(),b):b.setValue(b.initialValue)},this),o.each(this.__folders,function(a){a.revert(a)}),a||A(this.getRoot(),!1)},listen:function(a){var b=0==this.__listening.length;this.__listening.push(a),b&&B(this.__listening)}}),M}(dat.utils.css,'
\n\n Here\'s the new load parameter for your GUI\'s constructor:\n\n \n\n
\n\n Automatically save\n values to localStorage on exit.\n\n
The values saved to localStorage will\n override those passed to dat.GUI\'s constructor. This makes it\n easier to work incrementally, but localStorage is fragile,\n and your friends may not see the same values you do.\n \n
\n \n
\n\n
',".dg {\n /** Clear list styles */\n /* Auto-place container */\n /* Auto-placed GUI's */\n /* Line items that don't contain folders. */\n /** Folder names */\n /** Hides closed items */\n /** Controller row */\n /** Name-half (left) */\n /** Controller-half (right) */\n /** Controller placement */\n /** Shorter number boxes when slider is present. */\n /** Ensure the entire boolean and function row shows a hand */ }\n .dg ul {\n list-style: none;\n margin: 0;\n padding: 0;\n width: 100%;\n clear: both; }\n .dg.ac {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n height: 0;\n z-index: 0; }\n .dg:not(.ac) .main {\n /** Exclude mains in ac so that we don't hide close button */\n overflow: hidden; }\n .dg.main {\n -webkit-transition: opacity 0.1s linear;\n -o-transition: opacity 0.1s linear;\n -moz-transition: opacity 0.1s linear;\n transition: opacity 0.1s linear; }\n .dg.main.taller-than-window {\n overflow-y: auto; }\n .dg.main.taller-than-window .close-button {\n opacity: 1;\n /* TODO, these are style notes */\n margin-top: -1px;\n border-top: 1px solid #2c2c2c; }\n .dg.main ul.closed .close-button {\n opacity: 1 !important; }\n .dg.main:hover .close-button,\n .dg.main .close-button.drag {\n opacity: 1; }\n .dg.main .close-button {\n /*opacity: 0;*/\n -webkit-transition: opacity 0.1s linear;\n -o-transition: opacity 0.1s linear;\n -moz-transition: opacity 0.1s linear;\n transition: opacity 0.1s linear;\n border: 0;\n position: absolute;\n line-height: 19px;\n height: 20px;\n /* TODO, these are style notes */\n cursor: pointer;\n text-align: center;\n background-color: #000; }\n .dg.main .close-button:hover {\n background-color: #111; }\n .dg.a {\n float: right;\n margin-right: 15px;\n overflow-x: hidden; }\n .dg.a.has-save > ul {\n margin-top: 27px; }\n .dg.a.has-save > ul.closed {\n margin-top: 0; }\n .dg.a .save-row {\n position: fixed;\n top: 0;\n z-index: 1002; }\n .dg li {\n -webkit-transition: height 0.1s ease-out;\n -o-transition: height 0.1s ease-out;\n -moz-transition: height 0.1s ease-out;\n transition: height 0.1s ease-out; }\n .dg li:not(.folder) {\n cursor: auto;\n height: 27px;\n line-height: 27px;\n overflow: hidden;\n padding: 0 4px 0 5px; }\n .dg li.folder {\n padding: 0;\n border-left: 4px solid rgba(0, 0, 0, 0); }\n .dg li.title {\n cursor: pointer;\n margin-left: -4px; }\n .dg .closed li:not(.title),\n .dg .closed ul li,\n .dg .closed ul li > * {\n height: 0;\n overflow: hidden;\n border: 0; }\n .dg .cr {\n clear: both;\n padding-left: 3px;\n height: 27px; }\n .dg .property-name {\n cursor: default;\n float: left;\n clear: left;\n width: 40%;\n overflow: hidden;\n text-overflow: ellipsis; }\n .dg .c {\n float: left;\n width: 60%; }\n .dg .c input[type=text] {\n border: 0;\n margin-top: 4px;\n padding: 3px;\n width: 100%;\n float: right; }\n .dg .has-slider input[type=text] {\n width: 30%;\n /*display: none;*/\n margin-left: 0; }\n .dg .slider {\n float: left;\n width: 66%;\n margin-left: -5px;\n margin-right: 0;\n height: 19px;\n margin-top: 4px; }\n .dg .slider-fg {\n height: 100%; }\n .dg .c input[type=checkbox] {\n margin-top: 9px; }\n .dg .c select {\n margin-top: 5px; }\n .dg .cr.function,\n .dg .cr.function .property-name,\n .dg .cr.function *,\n .dg .cr.boolean,\n .dg .cr.boolean * {\n cursor: pointer; }\n .dg .selector {\n display: none;\n position: absolute;\n margin-left: -9px;\n margin-top: 23px;\n z-index: 10; }\n .dg .c:hover .selector,\n .dg .selector.drag {\n display: block; }\n .dg li.save-row {\n padding: 0; }\n .dg li.save-row .button {\n display: inline-block;\n padding: 0px 6px; }\n .dg.dialogue {\n background-color: #222;\n width: 460px;\n padding: 15px;\n font-size: 13px;\n line-height: 15px; }\n\n/* TODO Separate style and structure */\n#dg-new-constructor {\n padding: 10px;\n color: #222;\n font-family: Monaco, monospace;\n font-size: 10px;\n border: 0;\n resize: none;\n box-shadow: inset 1px 1px 1px #888;\n word-wrap: break-word;\n margin: 12px 0;\n display: block;\n width: 440px;\n overflow-y: scroll;\n height: 100px;\n position: relative; }\n\n#dg-local-explain {\n display: none;\n font-size: 11px;\n line-height: 17px;\n border-radius: 3px;\n background-color: #333;\n padding: 8px;\n margin-top: 10px; }\n #dg-local-explain code {\n font-size: 10px; }\n\n#dat-gui-save-locally {\n display: none; }\n\n/** Main type */\n.dg {\n color: #eee;\n font: 11px 'Lucida Grande', sans-serif;\n text-shadow: 0 -1px 0 #111;\n /** Auto place */\n /* Controller row,
  • */\n /** Controllers */ }\n .dg.main {\n /** Scrollbar */ }\n .dg.main::-webkit-scrollbar {\n width: 5px;\n background: #1a1a1a; }\n .dg.main::-webkit-scrollbar-corner {\n height: 0;\n display: none; }\n .dg.main::-webkit-scrollbar-thumb {\n border-radius: 5px;\n background: #676767; }\n .dg li:not(.folder) {\n background: #1a1a1a;\n border-bottom: 1px solid #2c2c2c; }\n .dg li.save-row {\n line-height: 25px;\n background: #dad5cb;\n border: 0; }\n .dg li.save-row select {\n margin-left: 5px;\n width: 108px; }\n .dg li.save-row .button {\n margin-left: 5px;\n margin-top: 1px;\n border-radius: 2px;\n font-size: 9px;\n line-height: 7px;\n padding: 4px 4px 5px 4px;\n background: #c5bdad;\n color: #fff;\n text-shadow: 0 1px 0 #b0a58f;\n box-shadow: 0 -1px 0 #b0a58f;\n cursor: pointer; }\n .dg li.save-row .button.gears {\n background: #c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;\n height: 7px;\n width: 8px; }\n .dg li.save-row .button:hover {\n background-color: #bab19e;\n box-shadow: 0 -1px 0 #b0a58f; }\n .dg li.folder {\n border-bottom: 0; }\n .dg li.title {\n padding-left: 16px;\n background: black url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;\n cursor: pointer;\n border-bottom: 1px solid rgba(255, 255, 255, 0.2); }\n .dg .closed li.title {\n background-image: url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==); }\n .dg .cr.boolean {\n border-left: 3px solid #806787; }\n .dg .cr.function {\n border-left: 3px solid #e61d5f; }\n .dg .cr.number {\n border-left: 3px solid #2fa1d6; }\n .dg .cr.number input[type=text] {\n color: #2fa1d6; }\n .dg .cr.string {\n border-left: 3px solid #1ed36f; }\n .dg .cr.string input[type=text] {\n color: #1ed36f; }\n .dg .cr.function:hover, .dg .cr.boolean:hover {\n background: #111; }\n .dg .c input[type=text] {\n background: #303030;\n outline: none; }\n .dg .c input[type=text]:hover {\n background: #3c3c3c; }\n .dg .c input[type=text]:focus {\n background: #494949;\n color: #fff; }\n .dg .c .slider {\n background: #303030;\n cursor: ew-resize; }\n .dg .c .slider-fg {\n background: #2fa1d6; }\n .dg .c .slider:hover {\n background: #3c3c3c; }\n .dg .c .slider:hover .slider-fg {\n background: #44abda; }\n",dat.controllers.factory=function(a,b,c,d,e,f,g){return function(h,i){var j=h[i];return g.isArray(arguments[2])||g.isObject(arguments[2])?new a(h,i,arguments[2]):g.isNumber(j)?g.isNumber(arguments[2])&&g.isNumber(arguments[3])?new c(h,i,arguments[2],arguments[3]):new b(h,i,{min:arguments[2],max:arguments[3]}):g.isString(j)?new d(h,i):g.isFunction(j)?new e(h,i,""):g.isBoolean(j)?new f(h,i):void 0}}(dat.controllers.OptionController,dat.controllers.NumberControllerBox,dat.controllers.NumberControllerSlider,dat.controllers.StringController=function(a,b,c){var d=function(a,c){function e(){g.setValue(g.__input.value)}function f(){g.__onFinishChange&&g.__onFinishChange.call(g,g.getValue())}d.superclass.call(this,a,c);var g=this;this.__input=document.createElement("input"),this.__input.setAttribute("type","text"),b.bind(this.__input,"keyup",e),b.bind(this.__input,"change",e),b.bind(this.__input,"blur",f),b.bind(this.__input,"keydown",function(a){13===a.keyCode&&this.blur()}),this.updateDisplay(),this.domElement.appendChild(this.__input)};return d.superclass=a,c.extend(d.prototype,a.prototype,{updateDisplay:function(){return b.isActive(this.__input)||(this.__input.value=this.getValue()),d.superclass.prototype.updateDisplay.call(this)}}),d}(dat.controllers.Controller,dat.dom.dom,dat.utils.common),dat.controllers.FunctionController,dat.controllers.BooleanController,dat.utils.common),dat.controllers.Controller,dat.controllers.BooleanController,dat.controllers.FunctionController,dat.controllers.NumberControllerBox,dat.controllers.NumberControllerSlider,dat.controllers.OptionController,dat.controllers.ColorController=function(a,b,c,d,e){function f(a,b,c,d){a.style.background="",e.each(i,function(e){a.style.cssText+="background: "+e+"linear-gradient("+b+", "+c+" 0%, "+d+" 100%); "})}function g(a){a.style.background="",a.style.cssText+="background: -moz-linear-gradient(top, #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);",a.style.cssText+="background: -webkit-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",a.style.cssText+="background: -o-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",a.style.cssText+="background: -ms-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",a.style.cssText+="background: linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);"}var h=function(a,i){function j(a){n(a),b.bind(window,"mousemove",n),b.bind(window,"mouseup",k)}function k(){b.unbind(window,"mousemove",n),b.unbind(window,"mouseup",k)}function l(){var a=d(this.value);a!==!1?(p.__color.__state=a,p.setValue(p.__color.toOriginal())):this.value=p.__color.toString()}function m(){b.unbind(window,"mousemove",o),b.unbind(window,"mouseup",m)}function n(a){a.preventDefault();var c=b.getWidth(p.__saturation_field),d=b.getOffset(p.__saturation_field),e=(a.clientX-d.left+document.body.scrollLeft)/c,f=1-(a.clientY-d.top+document.body.scrollTop)/c;return f>1?f=1:0>f&&(f=0),e>1?e=1:0>e&&(e=0),p.__color.v=f,p.__color.s=e,p.setValue(p.__color.toOriginal()),!1}function o(a){a.preventDefault();var c=b.getHeight(p.__hue_field),d=b.getOffset(p.__hue_field),e=1-(a.clientY-d.top+document.body.scrollTop)/c;return e>1?e=1:0>e&&(e=0),p.__color.h=360*e,p.setValue(p.__color.toOriginal()),!1}h.superclass.call(this,a,i),this.__color=new c(this.getValue()),this.__temp=new c(0);var p=this;this.domElement=document.createElement("div"),b.makeSelectable(this.domElement,!1),this.__selector=document.createElement("div"),this.__selector.className="selector",this.__saturation_field=document.createElement("div"),this.__saturation_field.className="saturation-field",this.__field_knob=document.createElement("div"),this.__field_knob.className="field-knob",this.__field_knob_border="2px solid ",this.__hue_knob=document.createElement("div"),this.__hue_knob.className="hue-knob",this.__hue_field=document.createElement("div"),this.__hue_field.className="hue-field",this.__input=document.createElement("input"),this.__input.type="text",this.__input_textShadow="0 1px 1px ",b.bind(this.__input,"keydown",function(a){13===a.keyCode&&l.call(this)}),b.bind(this.__input,"blur",l),b.bind(this.__selector,"mousedown",function(){b.addClass(this,"drag").bind(window,"mouseup",function(){b.removeClass(p.__selector,"drag")})});var q=document.createElement("div");e.extend(this.__selector.style,{width:"122px",height:"102px",padding:"3px",backgroundColor:"#222",boxShadow:"0px 1px 3px rgba(0,0,0,0.3)"}),e.extend(this.__field_knob.style,{position:"absolute",width:"12px",height:"12px",border:this.__field_knob_border+(this.__color.v<.5?"#fff":"#000"),boxShadow:"0px 1px 3px rgba(0,0,0,0.5)",borderRadius:"12px",zIndex:1}),e.extend(this.__hue_knob.style,{position:"absolute",width:"15px",height:"2px",borderRight:"4px solid #fff",zIndex:1}),e.extend(this.__saturation_field.style,{width:"100px",height:"100px",border:"1px solid #555",marginRight:"3px",display:"inline-block",cursor:"pointer"}),e.extend(q.style,{width:"100%",height:"100%",background:"none"}),f(q,"top","rgba(0,0,0,0)","#000"),e.extend(this.__hue_field.style,{width:"15px",height:"100px",display:"inline-block",border:"1px solid #555",cursor:"ns-resize"}),g(this.__hue_field),e.extend(this.__input.style,{outline:"none",textAlign:"center",color:"#fff",border:0,fontWeight:"bold",textShadow:this.__input_textShadow+"rgba(0,0,0,0.7)"}),b.bind(this.__saturation_field,"mousedown",j),b.bind(this.__field_knob,"mousedown",j),b.bind(this.__hue_field,"mousedown",function(a){o(a),b.bind(window,"mousemove",o),b.bind(window,"mouseup",m)}),this.__saturation_field.appendChild(q),this.__selector.appendChild(this.__field_knob),this.__selector.appendChild(this.__saturation_field),this.__selector.appendChild(this.__hue_field),this.__hue_field.appendChild(this.__hue_knob),this.domElement.appendChild(this.__input),this.domElement.appendChild(this.__selector),this.updateDisplay()};h.superclass=a,e.extend(h.prototype,a.prototype,{updateDisplay:function(){var a=d(this.getValue());if(a!==!1){var b=!1;e.each(c.COMPONENTS,function(c){return e.isUndefined(a[c])||e.isUndefined(this.__color.__state[c])||a[c]===this.__color.__state[c]?void 0:(b=!0,{})},this),b&&e.extend(this.__color.__state,a)}e.extend(this.__temp.__state,this.__color.__state),this.__temp.a=1;var g=this.__color.v<.5||this.__color.s>.5?255:0,h=255-g;e.extend(this.__field_knob.style,{marginLeft:100*this.__color.s-7+"px",marginTop:100*(1-this.__color.v)-7+"px",backgroundColor:this.__temp.toString(),border:this.__field_knob_border+"rgb("+g+","+g+","+g+")"}),this.__hue_knob.style.marginTop=100*(1-this.__color.h/360)+"px",this.__temp.s=1,this.__temp.v=1,f(this.__saturation_field,"left","#fff",this.__temp.toString()),e.extend(this.__input.style,{backgroundColor:this.__input.value=this.__color.toString(),color:"rgb("+g+","+g+","+g+")",textShadow:this.__input_textShadow+"rgba("+h+","+h+","+h+",.7)"})}});var i=["-moz-","-o-","-webkit-","-ms-",""];return h}(dat.controllers.Controller,dat.dom.dom,dat.color.Color=function(a,b,c,d){function e(a,b,c){Object.defineProperty(a,b,{get:function(){return"RGB"===this.__state.space?this.__state[b]:(g(this,b,c),this.__state[b])},set:function(a){"RGB"!==this.__state.space&&(g(this,b,c),this.__state.space="RGB"),this.__state[b]=a}})}function f(a,b){Object.defineProperty(a,b,{get:function(){return"HSV"===this.__state.space?this.__state[b]:(h(this),this.__state[b])},set:function(a){"HSV"!==this.__state.space&&(h(this),this.__state.space="HSV"),this.__state[b]=a}})}function g(a,c,e){if("HEX"===a.__state.space)a.__state[c]=b.component_from_hex(a.__state.hex,e);else{if("HSV"!==a.__state.space)throw"Corrupted color state";d.extend(a.__state,b.hsv_to_rgb(a.__state.h,a.__state.s,a.__state.v))}}function h(a){var c=b.rgb_to_hsv(a.r,a.g,a.b);d.extend(a.__state,{s:c.s,v:c.v}),d.isNaN(c.h)?d.isUndefined(a.__state.h)&&(a.__state.h=0):a.__state.h=c.h}var i=function(){if(this.__state=a.apply(this,arguments),this.__state===!1)throw"Failed to interpret color arguments";this.__state.a=this.__state.a||1};return i.COMPONENTS=["r","g","b","h","s","v","hex","a"],d.extend(i.prototype,{toString:function(){return c(this)},toOriginal:function(){return this.__state.conversion.write(this)}}),e(i.prototype,"r",2),e(i.prototype,"g",1),e(i.prototype,"b",0),f(i.prototype,"h"),f(i.prototype,"s"),f(i.prototype,"v"),Object.defineProperty(i.prototype,"a",{get:function(){return this.__state.a},set:function(a){this.__state.a=a}}),Object.defineProperty(i.prototype,"hex",{get:function(){return"HEX"!==!this.__state.space&&(this.__state.hex=b.rgb_to_hex(this.r,this.g,this.b)),this.__state.hex},set:function(a){this.__state.space="HEX",this.__state.hex=a}}),i}(dat.color.interpret,dat.color.math=function(){var a;return{hsv_to_rgb:function(a,b,c){var d=Math.floor(a/60)%6,e=a/60-Math.floor(a/60),f=c*(1-b),g=c*(1-e*b),h=c*(1-(1-e)*b),i=[[c,h,f],[g,c,f],[f,c,h],[f,g,c],[h,f,c],[c,f,g]][d];return{r:255*i[0],g:255*i[1],b:255*i[2]}},rgb_to_hsv:function(a,b,c){var d,e,f=Math.min(a,b,c),g=Math.max(a,b,c),h=g-f;return 0==g?{h:0/0,s:0,v:0}:(e=h/g,d=a==g?(b-c)/h:b==g?2+(c-a)/h:4+(a-b)/h,d/=6,0>d&&(d+=1),{h:360*d,s:e,v:g/255})},rgb_to_hex:function(a,b,c){var d=this.hex_with_component(0,2,a);return d=this.hex_with_component(d,1,b),d=this.hex_with_component(d,0,c)},component_from_hex:function(a,b){return a>>8*b&255},hex_with_component:function(b,c,d){return d<<(a=8*c)|b&~(255<0&&(d=e.shift(),d.type===a.Body.STATIC);)d=null;if(d){d.wakeUp(),this.setState(b.DRAGGING);var f=a.vec2.create();d.toLocalFrame(f,c),this.world.addBody(this.nullBody),this.mouseConstraint=new a.RevoluteConstraint(this.nullBody,d,{localPivotA:c,localPivotB:f}),this.world.addConstraint(this.mouseConstraint)}else this.setState(b.PANNING);break;case b.DRAWPOLYGON:this.setState(b.DRAWINGPOLYGON),this.drawPoints=[];var g=a.vec2.create();a.vec2.copy(g,c),this.drawPoints.push(g),this.emit(this.drawPointsChangeEvent);break;case b.DRAWCIRCLE:this.setState(b.DRAWINGCIRCLE),a.vec2.copy(this.drawCircleCenter,c),a.vec2.copy(this.drawCirclePoint,c),this.emit(this.drawCircleChangeEvent);break;case b.DRAWRECTANGLE:this.setState(b.DRAWINGRECTANGLE),a.vec2.copy(this.drawRectStart,c),a.vec2.copy(this.drawRectEnd,c),this.emit(this.drawRectangleChangeEvent)}},b.prototype.handleMouseMove=function(c){var d=.4;switch(this.state){case b.DEFAULT:case b.DRAGGING:this.mouseConstraint&&(a.vec2.copy(this.mouseConstraint.pivotA,c),this.mouseConstraint.bodyA.wakeUp(),this.mouseConstraint.bodyB.wakeUp());break;case b.DRAWINGPOLYGON:var e=a.vec2.dist(c,this.drawPoints[this.drawPoints.length-1]);if(e>d*d){var f=[0,0];a.vec2.copy(f,c),this.drawPoints.push(f),this.emit(this.drawPointsChangeEvent)}break;case b.DRAWINGCIRCLE:a.vec2.copy(this.drawCirclePoint,c),this.emit(this.drawCircleChangeEvent);break;case b.DRAWINGRECTANGLE:a.vec2.copy(this.drawRectEnd,c),this.emit(this.drawRectangleChangeEvent)}},b.prototype.handleMouseUp=function(){var c;switch(this.state){case b.DEFAULT:break;case b.DRAGGING:this.world.removeConstraint(this.mouseConstraint),this.mouseConstraint=null,this.world.removeBody(this.nullBody),this.setState(b.DEFAULT);break;case b.PANNING:this.setState(b.DEFAULT);break;case b.DRAWINGPOLYGON:this.setState(b.DRAWPOLYGON),this.drawPoints.length>3&&(c=new a.Body({mass:1}),c.fromPolygon(this.drawPoints,{removeCollinearPoints:.01})&&this.world.addBody(c)),this.drawPoints=[],this.emit(this.drawPointsChangeEvent);break;case b.DRAWINGCIRCLE:this.setState(b.DRAWCIRCLE);var d=a.vec2.dist(this.drawCircleCenter,this.drawCirclePoint);if(d>0){c=new a.Body({mass:1,position:this.drawCircleCenter});var e=new a.Circle(d);c.addShape(e),this.world.addBody(c)}a.vec2.copy(this.drawCircleCenter,this.drawCirclePoint),this.emit(this.drawCircleChangeEvent);break;case b.DRAWINGRECTANGLE:this.setState(b.DRAWRECTANGLE);for(var f=this.drawRectStart,g=this.drawRectEnd,h=0;2>h;h++)if(f[h]>g[h]){var i=g[h];g[h]=f[h],f[h]=i}var j=Math.abs(f[0]-g[0]),k=Math.abs(f[1]-g[1]);if(j>0&&k>0){c=new a.Body({mass:1,position:[this.drawRectStart[0]+.5*j,this.drawRectStart[1]+.5*k]});var l=new a.Rectangle(j,k);c.addShape(l),this.world.addBody(c)}a.vec2.copy(this.drawRectEnd,this.drawRectStart),this.emit(this.drawRectangleChangeEvent)}if(c){c.wakeUp();for(var h=0;h","

    p2.js

    ","

    Physics Engine

    ",'',""].join(""),this.elementContainer.appendChild(b),!function(a,b,c){var d,e=a.getElementsByTagName(b)[0],f=/^http:/.test(a.location)?"http":"https";a.getElementById(c)||(d=a.createElement(b),d.id=c,d.src=f+"://platform.twitter.com/widgets.js",e.parentNode.insertBefore(d,e))}(document,"script","twitter-wjs")},b.zoomInEvent={type:"zoomin"},b.zoomOutEvent={type:"zoomout"},b.prototype.setEquationParameters=function(){this.world.setGlobalEquationParameters({stiffness:this.settings.stiffness,relaxation:this.settings.relaxation})}}(p2),function(a){function b(b,c){c=c||{};var d=this,e={lineWidth:.01,scrollFactor:.1,width:1280,height:720,useDeviceAspect:!1,sleepOpacity:.2};for(var g in c)e[g]=c[g];e.useDeviceAspect&&(e.height=window.innerHeight/window.innerWidth*e.width),this.lineWidth=e.lineWidth,this.scrollFactor=e.scrollFactor,this.sleepOpacity=e.sleepOpacity,this.sprites=[],this.springSprites=[],this.debugPolygons=!1,f.call(this,b);for(var g in e)this.settings[g]=e[g];this.pickPrecision=.1,this.on("drawPointsChange",function(){var a=d.drawShapeGraphics,b=d.drawPoints;a.clear();for(var c=[],e=0;ee?-1>e?(-Math.pow(e,2)-h)/g:e:(Math.pow(e,2)+h)/g;var i=Math.min(Math.max(e/2,-1),1),j=i>=0;"undefined"!=typeof n&&d.zoom(n,o,j,void 0,void 0,i)}var c=(this.w,this.h,this.settings),d=this,e=(this.renderer=PIXI.autoDetectRenderer(c.width,c.height,null,null,!0),this.stage=new PIXI.DisplayObjectContainer),i=this.container=new PIXI.Stage(16777215,!0),j=this.element=this.renderer.view;j.tabIndex=1,j.classList.add(f.elementClass),j.setAttribute("style","width:100%;");var k=this.elementContainer=document.createElement("div");k.classList.add(f.containerClass),k.setAttribute("style","width:100%; height:100%"),k.appendChild(j),document.body.appendChild(k),j.focus(),j.oncontextmenu=function(){return!1},this.container.addChild(e),this.drawShapeGraphics=new PIXI.Graphics,e.addChild(this.drawShapeGraphics),this.contactGraphics=new PIXI.Graphics,e.addChild(this.contactGraphics),this.aabbGraphics=new PIXI.Graphics,e.addChild(this.aabbGraphics),e.scale.x=200,e.scale.y=-200;var l,m,n,o,p,q,r=!1,s=a.vec2.create(),t=a.vec2.create(),u=a.vec2.create(),v=0,w=1,x=1,y=0;i.mousedown=i.touchstart=function(b){if(n=b.global.x,o=b.global.y,b.originalEvent.touches&&(y=b.originalEvent.touches.length),b.originalEvent.touches&&2===b.originalEvent.touches.length){var c=d.container.interactionManager.touchs[0],f=d.container.interactionManager.touchs[1],i=c.getLocalPosition(e);a.vec2.set(u,i.x,i.y),d.stagePositionToPhysics(s,u);var i=f.getLocalPosition(e);a.vec2.set(u,i.x,i.y),d.stagePositionToPhysics(t,u),v=a.vec2.dist(s,t);{e.scale.x,e.scale.y}}else{l=b.global.x,m=b.global.y,p=e.position.x,q=e.position.y,r=!0,d.lastMousePos=b.global;var i=b.getLocalPosition(e);a.vec2.set(g,i.x,i.y),d.stagePositionToPhysics(h,g),d.handleMouseDown(h)}},i.mousemove=i.touchmove=function(b){if(b.originalEvent.touches&&(y!==b.originalEvent.touches.length&&(l=b.global.x,m=b.global.y,p=e.position.x,q=e.position.y),y=b.originalEvent.touches.length),n=b.global.x,o=b.global.y,b.originalEvent.touches&&2===b.originalEvent.touches.length){var c=d.container.interactionManager.touchs[0],i=d.container.interactionManager.touchs[1],j=c.getLocalPosition(e);a.vec2.set(u,j.x,j.y),d.stagePositionToPhysics(s,u);var j=i.getLocalPosition(e);a.vec2.set(u,j.x,j.y),d.stagePositionToPhysics(t,u);var k=a.vec2.dist(s,t);return a.vec2.add(s,s,t),a.vec2.scale(s,s,.5),void d.zoom(.5*(c.global.x+i.global.x),.5*(c.global.y+i.global.y),null,k/v*w,k/v*x)}r&&d.state===f.PANNING&&(e.position.x=b.global.x-l+p,e.position.y=b.global.y-m+q),d.lastMousePos=b.global;var j=b.getLocalPosition(e);a.vec2.set(g,j.x,j.y),d.stagePositionToPhysics(h,g),d.handleMouseMove(h)},i.mouseup=i.touchend=function(b){b.originalEvent.touches&&(y=b.originalEvent.touches.length),r=!1,n=b.global.x,o=b.global.y,d.lastMousePos=b.global;var c=b.getLocalPosition(e);a.vec2.set(g,c.x,c.y),d.stagePositionToPhysics(h,g),d.handleMouseUp(h)},this.element.ontouchmove=function(a){a.preventDefault()},j.addEventListener?(j.addEventListener("mousewheel",b,!1),j.addEventListener("DOMMouseScroll",b,!1)):j.attachEvent("onmousewheel",b),this.centerCamera(0,0)},b.prototype.zoom=function(a,b,c,d,e,f){var g=this.scrollFactor,h=this.stage;"undefined"==typeof d?(c||(g*=-1),g*=Math.abs(f),h.scale.x*=1+g,h.scale.y*=1+g,h.position.x+=g*(h.position.x-a),h.position.y+=g*(h.position.y-b)):(h.scale.x*=d,h.scale.y*=e,h.position.x+=(d-1)*(h.position.x-a),h.position.y+=(e-1)*(h.position.y-b)),h.updateTransform()},b.prototype.centerCamera=function(a,b){this.stage.position.x=this.renderer.width/2-this.stage.scale.x*a,this.stage.position.y=this.renderer.height/2-this.stage.scale.y*b},b.prototype.frame=function(a,b,c,d){var e=this.renderer.width/this.renderer.height;c/d>e?(this.stage.scale.x=this.renderer.width/c,this.stage.scale.y=-this.stage.scale.x):(this.stage.scale.y=-this.renderer.height/d,this.stage.scale.x=-this.stage.scale.y),this.centerCamera(a,b)},b.prototype.drawCircle=function(a,b,c,d,e,f,g,h){g="number"==typeof g?g:1,f="number"==typeof f?f:16777215,a.lineStyle(g,0,1),a.beginFill(f,h?this.sleepOpacity:1),a.drawCircle(b,c,e),a.endFill(),a.moveTo(b,c),a.lineTo(b+e*Math.cos(d),c+e*Math.sin(d))},b.drawSpring=function(a,b,c,d){d="number"==typeof d?d:1,c="undefined"==typeof c?16777215:c,a.lineStyle(d,c,1),10*d>b&&(b=10*d);var e=12,f=b/e;a.moveTo(-b/2,0);for(var g=1;e>g;g++){var h=-b/2+f*g,i=0;1>=g||g>=e-1||(g%2===0?i-=.1*b:i+=.1*b),a.lineTo(h,i)}a.lineTo(b/2,0)},b.drawPlane=function(a,b,c,d,e,f,g,h,i){f="number"==typeof f?f:1,d="undefined"==typeof d?16777215:d,a.lineStyle(f,e,1),a.lineStyle(0,0,0),a.beginFill(d);var j=i;a.moveTo(-j,0),a.lineTo(j,0),a.lineTo(j,-j),a.lineTo(-j,-j),a.endFill(),a.lineStyle(f,e),a.moveTo(-j,0),a.lineTo(j,0)},b.drawLine=function(b,c,d,e,f,g){g="number"==typeof g?g:1,f="undefined"==typeof f?0:f,b.lineStyle(g,f,1);var h=a.vec2.fromValues(-e/2,0),i=a.vec2.fromValues(e/2,0);a.vec2.rotate(h,h,d),a.vec2.rotate(i,i,d),a.vec2.add(h,h,c),a.vec2.add(i,i,c),b.moveTo(h[0],h[1]),b.lineTo(i[0],i[1])},b.prototype.drawCapsule=function(a,b,c,d,e,f,g,h,i,j){i="number"==typeof i?i:1,g="undefined"==typeof g?0:g,a.lineStyle(i,g,1);var k=Math.cos(d),l=Math.sin(d);a.beginFill(h,j?this.sleepOpacity:1),a.drawCircle(-e/2*k+b,-e/2*l+c,f),a.drawCircle(e/2*k+b,e/2*l+c,f),a.endFill(),a.lineStyle(i,g,0),a.beginFill(h,j?this.sleepOpacity:1),a.moveTo(-e/2*k+f*l+b,-e/2*l+f*k+c),a.lineTo(e/2*k+f*l+b,e/2*l+f*k+c),a.lineTo(e/2*k-f*l+b,e/2*l-f*k+c),a.lineTo(-e/2*k-f*l+b,-e/2*l-f*k+c),a.endFill(),a.lineStyle(i,g,1),a.moveTo(-e/2*k+f*l+b,-e/2*l+f*k+c),a.lineTo(e/2*k+f*l+b,e/2*l+f*k+c),a.moveTo(-e/2*k-f*l+b,-e/2*l-f*k+c),a.lineTo(e/2*k-f*l+b,e/2*l-f*k+c)},b.prototype.drawRectangle=function(a,b,c,d,e,f,g,h,i,j){i="number"==typeof i?i:1,g="number"==typeof g?g:16777215,h="number"==typeof h?h:16777215,a.lineStyle(i),a.beginFill(h,j?this.sleepOpacity:1),a.drawRect(b-e/2,c-f/2,e,f)},b.prototype.drawConvex=function(a,b,c,d,e,f,g,h,i){if(f="number"==typeof f?f:1,d="undefined"==typeof d?0:d,g){for(var j=[16711680,65280,255],k=0;k!==b.length+1;k++){var l=b[k%b.length],m=b[(k+1)%b.length],n=l[0],o=l[1],p=m[0],q=m[1];a.lineStyle(f,j[k%j.length],1),a.moveTo(n,o),a.lineTo(p,q),a.drawCircle(n,o,2*f)}a.lineStyle(f,0,1),a.drawCircle(h[0],h[1],2*f)}else{a.lineStyle(f,d,1),a.beginFill(e,i?this.sleepOpacity:1);for(var k=0;k!==b.length;k++){var r=b[k],s=r[0],t=r[1];0===k?a.moveTo(s,t):a.lineTo(s,t)}a.endFill(),b.length>2&&(a.moveTo(b[b.length-1][0],b[b.length-1][1]),a.lineTo(b[0][0],b[0][1]))}},b.prototype.drawPath=function(a,b,c,d,e,f){e="number"==typeof e?e:1,c="undefined"==typeof c?0:c,a.lineStyle(e,c,1),"number"==typeof d&&a.beginFill(d,f?this.sleepOpacity:1);for(var g=null,h=null,i=0;i2&&"number"==typeof d&&(a.moveTo(b[b.length-1][0],b[b.length-1][1]),a.lineTo(b[0][0],b[0][1]))},b.prototype.updateSpriteTransform=function(a,b){this.useInterpolatedPositions?(a.position.x=b.interpolatedPosition[0],a.position.y=b.interpolatedPosition[1],a.rotation=b.interpolatedAngle):(a.position.x=b.position[0],a.position.y=b.position[1],a.rotation=b.angle)};var i=a.vec2.fromValues(1,0),j=a.vec2.fromValues(0,0),k=a.vec2.fromValues(0,0),l=a.vec2.fromValues(0,0);b.prototype.render=function(){for(var b=(this.renderer.width,this.renderer.height,this.springSprites),c=(this.sprites,0);c!==this.bodies.length;c++)this.updateSpriteTransform(this.sprites[c],this.bodies[c]);for(var c=0;c!==this.bodies.length;c++){var d=this.bodies[c].sleepState===a.Body.SLEEPING,e=this.sprites[c],f=this.bodies[c];e.drawnSleeping!==d&&(e.clear(),this.drawRenderable(f,e,e.drawnColor,e.drawnLineColor))}for(var c=0;c!==this.springs.length;c++){var g=this.springs[c],e=b[c],h=g.bodyA,m=g.bodyB;if(this.useInterpolatedPositions?(a.vec2.toGlobalFrame(k,g.localAnchorA,h.interpolatedPosition,h.interpolatedAngle),a.vec2.toGlobalFrame(l,g.localAnchorB,m.interpolatedPosition,m.interpolatedAngle)):(g.getWorldAnchorA(k),g.getWorldAnchorB(l)),e.scale.y=1,k[1]0&&(a.preset=this.preset,a.remembered||(a.remembered={}),a.remembered[this.preset]=x(this)),a.folders={},o.each(this.__folders,function(b,c){a.folders[c]=b.getSaveObject()}),a},save:function(){this.load.remembered||(this.load.remembered={}),this.load.remembered[this.preset]=x(this),A(this,!1),this.saveToLocalStorageIfPossible()},saveAs:function(a){this.load.remembered||(this.load.remembered={},this.load.remembered[H]=x(this,!0)),this.load.remembered[a]=x(this),this.preset=a,y(this,a,!0),this.saveToLocalStorageIfPossible()},revert:function(a){o.each(this.__controllers,function(b){this.getRoot().load.remembered?s(a||this.getRoot(),b):b.setValue(b.initialValue)},this),o.each(this.__folders,function(a){a.revert(a)}),a||A(this.getRoot(),!1)},listen:function(a){var b=0==this.__listening.length;this.__listening.push(a),b&&B(this.__listening)}}),M}(dat.utils.css,'
    \n\n Here\'s the new load parameter for your GUI\'s constructor:\n\n \n\n
    \n\n Automatically save\n values to localStorage on exit.\n\n
    The values saved to localStorage will\n override those passed to dat.GUI\'s constructor. This makes it\n easier to work incrementally, but localStorage is fragile,\n and your friends may not see the same values you do.\n \n
    \n \n
    \n\n
    ',".dg {\n /** Clear list styles */\n /* Auto-place container */\n /* Auto-placed GUI's */\n /* Line items that don't contain folders. */\n /** Folder names */\n /** Hides closed items */\n /** Controller row */\n /** Name-half (left) */\n /** Controller-half (right) */\n /** Controller placement */\n /** Shorter number boxes when slider is present. */\n /** Ensure the entire boolean and function row shows a hand */ }\n .dg ul {\n list-style: none;\n margin: 0;\n padding: 0;\n width: 100%;\n clear: both; }\n .dg.ac {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n height: 0;\n z-index: 0; }\n .dg:not(.ac) .main {\n /** Exclude mains in ac so that we don't hide close button */\n overflow: hidden; }\n .dg.main {\n -webkit-transition: opacity 0.1s linear;\n -o-transition: opacity 0.1s linear;\n -moz-transition: opacity 0.1s linear;\n transition: opacity 0.1s linear; }\n .dg.main.taller-than-window {\n overflow-y: auto; }\n .dg.main.taller-than-window .close-button {\n opacity: 1;\n /* TODO, these are style notes */\n margin-top: -1px;\n border-top: 1px solid #2c2c2c; }\n .dg.main ul.closed .close-button {\n opacity: 1 !important; }\n .dg.main:hover .close-button,\n .dg.main .close-button.drag {\n opacity: 1; }\n .dg.main .close-button {\n /*opacity: 0;*/\n -webkit-transition: opacity 0.1s linear;\n -o-transition: opacity 0.1s linear;\n -moz-transition: opacity 0.1s linear;\n transition: opacity 0.1s linear;\n border: 0;\n position: absolute;\n line-height: 19px;\n height: 20px;\n /* TODO, these are style notes */\n cursor: pointer;\n text-align: center;\n background-color: #000; }\n .dg.main .close-button:hover {\n background-color: #111; }\n .dg.a {\n float: right;\n margin-right: 15px;\n overflow-x: hidden; }\n .dg.a.has-save > ul {\n margin-top: 27px; }\n .dg.a.has-save > ul.closed {\n margin-top: 0; }\n .dg.a .save-row {\n position: fixed;\n top: 0;\n z-index: 1002; }\n .dg li {\n -webkit-transition: height 0.1s ease-out;\n -o-transition: height 0.1s ease-out;\n -moz-transition: height 0.1s ease-out;\n transition: height 0.1s ease-out; }\n .dg li:not(.folder) {\n cursor: auto;\n height: 27px;\n line-height: 27px;\n overflow: hidden;\n padding: 0 4px 0 5px; }\n .dg li.folder {\n padding: 0;\n border-left: 4px solid rgba(0, 0, 0, 0); }\n .dg li.title {\n cursor: pointer;\n margin-left: -4px; }\n .dg .closed li:not(.title),\n .dg .closed ul li,\n .dg .closed ul li > * {\n height: 0;\n overflow: hidden;\n border: 0; }\n .dg .cr {\n clear: both;\n padding-left: 3px;\n height: 27px; }\n .dg .property-name {\n cursor: default;\n float: left;\n clear: left;\n width: 40%;\n overflow: hidden;\n text-overflow: ellipsis; }\n .dg .c {\n float: left;\n width: 60%; }\n .dg .c input[type=text] {\n border: 0;\n margin-top: 4px;\n padding: 3px;\n width: 100%;\n float: right; }\n .dg .has-slider input[type=text] {\n width: 30%;\n /*display: none;*/\n margin-left: 0; }\n .dg .slider {\n float: left;\n width: 66%;\n margin-left: -5px;\n margin-right: 0;\n height: 19px;\n margin-top: 4px; }\n .dg .slider-fg {\n height: 100%; }\n .dg .c input[type=checkbox] {\n margin-top: 9px; }\n .dg .c select {\n margin-top: 5px; }\n .dg .cr.function,\n .dg .cr.function .property-name,\n .dg .cr.function *,\n .dg .cr.boolean,\n .dg .cr.boolean * {\n cursor: pointer; }\n .dg .selector {\n display: none;\n position: absolute;\n margin-left: -9px;\n margin-top: 23px;\n z-index: 10; }\n .dg .c:hover .selector,\n .dg .selector.drag {\n display: block; }\n .dg li.save-row {\n padding: 0; }\n .dg li.save-row .button {\n display: inline-block;\n padding: 0px 6px; }\n .dg.dialogue {\n background-color: #222;\n width: 460px;\n padding: 15px;\n font-size: 13px;\n line-height: 15px; }\n\n/* TODO Separate style and structure */\n#dg-new-constructor {\n padding: 10px;\n color: #222;\n font-family: Monaco, monospace;\n font-size: 10px;\n border: 0;\n resize: none;\n box-shadow: inset 1px 1px 1px #888;\n word-wrap: break-word;\n margin: 12px 0;\n display: block;\n width: 440px;\n overflow-y: scroll;\n height: 100px;\n position: relative; }\n\n#dg-local-explain {\n display: none;\n font-size: 11px;\n line-height: 17px;\n border-radius: 3px;\n background-color: #333;\n padding: 8px;\n margin-top: 10px; }\n #dg-local-explain code {\n font-size: 10px; }\n\n#dat-gui-save-locally {\n display: none; }\n\n/** Main type */\n.dg {\n color: #eee;\n font: 11px 'Lucida Grande', sans-serif;\n text-shadow: 0 -1px 0 #111;\n /** Auto place */\n /* Controller row,
  • */\n /** Controllers */ }\n .dg.main {\n /** Scrollbar */ }\n .dg.main::-webkit-scrollbar {\n width: 5px;\n background: #1a1a1a; }\n .dg.main::-webkit-scrollbar-corner {\n height: 0;\n display: none; }\n .dg.main::-webkit-scrollbar-thumb {\n border-radius: 5px;\n background: #676767; }\n .dg li:not(.folder) {\n background: #1a1a1a;\n border-bottom: 1px solid #2c2c2c; }\n .dg li.save-row {\n line-height: 25px;\n background: #dad5cb;\n border: 0; }\n .dg li.save-row select {\n margin-left: 5px;\n width: 108px; }\n .dg li.save-row .button {\n margin-left: 5px;\n margin-top: 1px;\n border-radius: 2px;\n font-size: 9px;\n line-height: 7px;\n padding: 4px 4px 5px 4px;\n background: #c5bdad;\n color: #fff;\n text-shadow: 0 1px 0 #b0a58f;\n box-shadow: 0 -1px 0 #b0a58f;\n cursor: pointer; }\n .dg li.save-row .button.gears {\n background: #c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;\n height: 7px;\n width: 8px; }\n .dg li.save-row .button:hover {\n background-color: #bab19e;\n box-shadow: 0 -1px 0 #b0a58f; }\n .dg li.folder {\n border-bottom: 0; }\n .dg li.title {\n padding-left: 16px;\n background: black url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;\n cursor: pointer;\n border-bottom: 1px solid rgba(255, 255, 255, 0.2); }\n .dg .closed li.title {\n background-image: url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==); }\n .dg .cr.boolean {\n border-left: 3px solid #806787; }\n .dg .cr.function {\n border-left: 3px solid #e61d5f; }\n .dg .cr.number {\n border-left: 3px solid #2fa1d6; }\n .dg .cr.number input[type=text] {\n color: #2fa1d6; }\n .dg .cr.string {\n border-left: 3px solid #1ed36f; }\n .dg .cr.string input[type=text] {\n color: #1ed36f; }\n .dg .cr.function:hover, .dg .cr.boolean:hover {\n background: #111; }\n .dg .c input[type=text] {\n background: #303030;\n outline: none; }\n .dg .c input[type=text]:hover {\n background: #3c3c3c; }\n .dg .c input[type=text]:focus {\n background: #494949;\n color: #fff; }\n .dg .c .slider {\n background: #303030;\n cursor: ew-resize; }\n .dg .c .slider-fg {\n background: #2fa1d6; }\n .dg .c .slider:hover {\n background: #3c3c3c; }\n .dg .c .slider:hover .slider-fg {\n background: #44abda; }\n",dat.controllers.factory=function(a,b,c,d,e,f,g){return function(h,i){var j=h[i];return g.isArray(arguments[2])||g.isObject(arguments[2])?new a(h,i,arguments[2]):g.isNumber(j)?g.isNumber(arguments[2])&&g.isNumber(arguments[3])?new c(h,i,arguments[2],arguments[3]):new b(h,i,{min:arguments[2],max:arguments[3]}):g.isString(j)?new d(h,i):g.isFunction(j)?new e(h,i,""):g.isBoolean(j)?new f(h,i):void 0}}(dat.controllers.OptionController,dat.controllers.NumberControllerBox,dat.controllers.NumberControllerSlider,dat.controllers.StringController=function(a,b,c){var d=function(a,c){function e(){g.setValue(g.__input.value)}function f(){g.__onFinishChange&&g.__onFinishChange.call(g,g.getValue())}d.superclass.call(this,a,c);var g=this;this.__input=document.createElement("input"),this.__input.setAttribute("type","text"),b.bind(this.__input,"keyup",e),b.bind(this.__input,"change",e),b.bind(this.__input,"blur",f),b.bind(this.__input,"keydown",function(a){13===a.keyCode&&this.blur()}),this.updateDisplay(),this.domElement.appendChild(this.__input)};return d.superclass=a,c.extend(d.prototype,a.prototype,{updateDisplay:function(){return b.isActive(this.__input)||(this.__input.value=this.getValue()),d.superclass.prototype.updateDisplay.call(this)}}),d}(dat.controllers.Controller,dat.dom.dom,dat.utils.common),dat.controllers.FunctionController,dat.controllers.BooleanController,dat.utils.common),dat.controllers.Controller,dat.controllers.BooleanController,dat.controllers.FunctionController,dat.controllers.NumberControllerBox,dat.controllers.NumberControllerSlider,dat.controllers.OptionController,dat.controllers.ColorController=function(a,b,c,d,e){function f(a,b,c,d){a.style.background="",e.each(i,function(e){a.style.cssText+="background: "+e+"linear-gradient("+b+", "+c+" 0%, "+d+" 100%); "})}function g(a){a.style.background="",a.style.cssText+="background: -moz-linear-gradient(top, #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);",a.style.cssText+="background: -webkit-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",a.style.cssText+="background: -o-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",a.style.cssText+="background: -ms-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",a.style.cssText+="background: linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);"}var h=function(a,i){function j(a){n(a),b.bind(window,"mousemove",n),b.bind(window,"mouseup",k)}function k(){b.unbind(window,"mousemove",n),b.unbind(window,"mouseup",k)}function l(){var a=d(this.value);a!==!1?(p.__color.__state=a,p.setValue(p.__color.toOriginal())):this.value=p.__color.toString()}function m(){b.unbind(window,"mousemove",o),b.unbind(window,"mouseup",m)}function n(a){a.preventDefault();var c=b.getWidth(p.__saturation_field),d=b.getOffset(p.__saturation_field),e=(a.clientX-d.left+document.body.scrollLeft)/c,f=1-(a.clientY-d.top+document.body.scrollTop)/c;return f>1?f=1:0>f&&(f=0),e>1?e=1:0>e&&(e=0),p.__color.v=f,p.__color.s=e,p.setValue(p.__color.toOriginal()),!1}function o(a){a.preventDefault();var c=b.getHeight(p.__hue_field),d=b.getOffset(p.__hue_field),e=1-(a.clientY-d.top+document.body.scrollTop)/c;return e>1?e=1:0>e&&(e=0),p.__color.h=360*e,p.setValue(p.__color.toOriginal()),!1}h.superclass.call(this,a,i),this.__color=new c(this.getValue()),this.__temp=new c(0);var p=this;this.domElement=document.createElement("div"),b.makeSelectable(this.domElement,!1),this.__selector=document.createElement("div"),this.__selector.className="selector",this.__saturation_field=document.createElement("div"),this.__saturation_field.className="saturation-field",this.__field_knob=document.createElement("div"),this.__field_knob.className="field-knob",this.__field_knob_border="2px solid ",this.__hue_knob=document.createElement("div"),this.__hue_knob.className="hue-knob",this.__hue_field=document.createElement("div"),this.__hue_field.className="hue-field",this.__input=document.createElement("input"),this.__input.type="text",this.__input_textShadow="0 1px 1px ",b.bind(this.__input,"keydown",function(a){13===a.keyCode&&l.call(this)}),b.bind(this.__input,"blur",l),b.bind(this.__selector,"mousedown",function(){b.addClass(this,"drag").bind(window,"mouseup",function(){b.removeClass(p.__selector,"drag")})});var q=document.createElement("div");e.extend(this.__selector.style,{width:"122px",height:"102px",padding:"3px",backgroundColor:"#222",boxShadow:"0px 1px 3px rgba(0,0,0,0.3)"}),e.extend(this.__field_knob.style,{position:"absolute",width:"12px",height:"12px",border:this.__field_knob_border+(this.__color.v<.5?"#fff":"#000"),boxShadow:"0px 1px 3px rgba(0,0,0,0.5)",borderRadius:"12px",zIndex:1}),e.extend(this.__hue_knob.style,{position:"absolute",width:"15px",height:"2px",borderRight:"4px solid #fff",zIndex:1}),e.extend(this.__saturation_field.style,{width:"100px",height:"100px",border:"1px solid #555",marginRight:"3px",display:"inline-block",cursor:"pointer"}),e.extend(q.style,{width:"100%",height:"100%",background:"none"}),f(q,"top","rgba(0,0,0,0)","#000"),e.extend(this.__hue_field.style,{width:"15px",height:"100px",display:"inline-block",border:"1px solid #555",cursor:"ns-resize"}),g(this.__hue_field),e.extend(this.__input.style,{outline:"none",textAlign:"center",color:"#fff",border:0,fontWeight:"bold",textShadow:this.__input_textShadow+"rgba(0,0,0,0.7)"}),b.bind(this.__saturation_field,"mousedown",j),b.bind(this.__field_knob,"mousedown",j),b.bind(this.__hue_field,"mousedown",function(a){o(a),b.bind(window,"mousemove",o),b.bind(window,"mouseup",m)}),this.__saturation_field.appendChild(q),this.__selector.appendChild(this.__field_knob),this.__selector.appendChild(this.__saturation_field),this.__selector.appendChild(this.__hue_field),this.__hue_field.appendChild(this.__hue_knob),this.domElement.appendChild(this.__input),this.domElement.appendChild(this.__selector),this.updateDisplay()};h.superclass=a,e.extend(h.prototype,a.prototype,{updateDisplay:function(){var a=d(this.getValue());if(a!==!1){var b=!1;e.each(c.COMPONENTS,function(c){return e.isUndefined(a[c])||e.isUndefined(this.__color.__state[c])||a[c]===this.__color.__state[c]?void 0:(b=!0,{})},this),b&&e.extend(this.__color.__state,a)}e.extend(this.__temp.__state,this.__color.__state),this.__temp.a=1;var g=this.__color.v<.5||this.__color.s>.5?255:0,h=255-g;e.extend(this.__field_knob.style,{marginLeft:100*this.__color.s-7+"px",marginTop:100*(1-this.__color.v)-7+"px",backgroundColor:this.__temp.toString(),border:this.__field_knob_border+"rgb("+g+","+g+","+g+")"}),this.__hue_knob.style.marginTop=100*(1-this.__color.h/360)+"px",this.__temp.s=1,this.__temp.v=1,f(this.__saturation_field,"left","#fff",this.__temp.toString()),e.extend(this.__input.style,{backgroundColor:this.__input.value=this.__color.toString(),color:"rgb("+g+","+g+","+g+")",textShadow:this.__input_textShadow+"rgba("+h+","+h+","+h+",.7)"})}});var i=["-moz-","-o-","-webkit-","-ms-",""];return h}(dat.controllers.Controller,dat.dom.dom,dat.color.Color=function(a,b,c,d){function e(a,b,c){Object.defineProperty(a,b,{get:function(){return"RGB"===this.__state.space?this.__state[b]:(g(this,b,c),this.__state[b])},set:function(a){"RGB"!==this.__state.space&&(g(this,b,c),this.__state.space="RGB"),this.__state[b]=a}})}function f(a,b){Object.defineProperty(a,b,{get:function(){return"HSV"===this.__state.space?this.__state[b]:(h(this),this.__state[b])},set:function(a){"HSV"!==this.__state.space&&(h(this),this.__state.space="HSV"),this.__state[b]=a}})}function g(a,c,e){if("HEX"===a.__state.space)a.__state[c]=b.component_from_hex(a.__state.hex,e);else{if("HSV"!==a.__state.space)throw"Corrupted color state";d.extend(a.__state,b.hsv_to_rgb(a.__state.h,a.__state.s,a.__state.v))}}function h(a){var c=b.rgb_to_hsv(a.r,a.g,a.b);d.extend(a.__state,{s:c.s,v:c.v}),d.isNaN(c.h)?d.isUndefined(a.__state.h)&&(a.__state.h=0):a.__state.h=c.h}var i=function(){if(this.__state=a.apply(this,arguments),this.__state===!1)throw"Failed to interpret color arguments";this.__state.a=this.__state.a||1};return i.COMPONENTS=["r","g","b","h","s","v","hex","a"],d.extend(i.prototype,{toString:function(){return c(this)},toOriginal:function(){return this.__state.conversion.write(this)}}),e(i.prototype,"r",2),e(i.prototype,"g",1),e(i.prototype,"b",0),f(i.prototype,"h"),f(i.prototype,"s"),f(i.prototype,"v"),Object.defineProperty(i.prototype,"a",{get:function(){return this.__state.a},set:function(a){this.__state.a=a}}),Object.defineProperty(i.prototype,"hex",{get:function(){return"HEX"!==!this.__state.space&&(this.__state.hex=b.rgb_to_hex(this.r,this.g,this.b)),this.__state.hex},set:function(a){this.__state.space="HEX",this.__state.hex=a}}),i}(dat.color.interpret,dat.color.math=function(){var a;return{hsv_to_rgb:function(a,b,c){var d=Math.floor(a/60)%6,e=a/60-Math.floor(a/60),f=c*(1-b),g=c*(1-e*b),h=c*(1-(1-e)*b),i=[[c,h,f],[g,c,f],[f,c,h],[f,g,c],[h,f,c],[c,f,g]][d];return{r:255*i[0],g:255*i[1],b:255*i[2]}},rgb_to_hsv:function(a,b,c){var d,e,f=Math.min(a,b,c),g=Math.max(a,b,c),h=g-f;return 0==g?{h:0/0,s:0,v:0}:(e=h/g,d=a==g?(b-c)/h:b==g?2+(c-a)/h:4+(a-b)/h,d/=6,0>d&&(d+=1),{h:360*d,s:e,v:g/255})},rgb_to_hex:function(a,b,c){var d=this.hex_with_component(0,2,a);return d=this.hex_with_component(d,1,b),d=this.hex_with_component(d,0,c)},component_from_hex:function(a,b){return a>>8*b&255},hex_with_component:function(b,c,d){return d<<(a=8*c)|b&~(255<0&&(d=e.shift(),d.type===a.Body.STATIC);)d=null;if(d){d.wakeUp(),this.setState(b.DRAGGING);var f=a.vec2.create();d.toLocalFrame(f,c),this.world.addBody(this.nullBody),this.mouseConstraint=new a.RevoluteConstraint(this.nullBody,d,{localPivotA:c,localPivotB:f}),this.world.addConstraint(this.mouseConstraint)}else this.setState(b.PANNING);break;case b.DRAWPOLYGON:this.setState(b.DRAWINGPOLYGON),this.drawPoints=[];var g=a.vec2.create();a.vec2.copy(g,c),this.drawPoints.push(g),this.emit(this.drawPointsChangeEvent);break;case b.DRAWCIRCLE:this.setState(b.DRAWINGCIRCLE),a.vec2.copy(this.drawCircleCenter,c),a.vec2.copy(this.drawCirclePoint,c),this.emit(this.drawCircleChangeEvent);break;case b.DRAWRECTANGLE:this.setState(b.DRAWINGRECTANGLE),a.vec2.copy(this.drawRectStart,c),a.vec2.copy(this.drawRectEnd,c),this.emit(this.drawRectangleChangeEvent)}},b.prototype.handleMouseMove=function(c){var d=.4;switch(this.state){case b.DEFAULT:case b.DRAGGING:this.mouseConstraint&&(a.vec2.copy(this.mouseConstraint.pivotA,c),this.mouseConstraint.bodyA.wakeUp(),this.mouseConstraint.bodyB.wakeUp());break;case b.DRAWINGPOLYGON:var e=a.vec2.dist(c,this.drawPoints[this.drawPoints.length-1]);if(e>d*d){var f=[0,0];a.vec2.copy(f,c),this.drawPoints.push(f),this.emit(this.drawPointsChangeEvent)}break;case b.DRAWINGCIRCLE:a.vec2.copy(this.drawCirclePoint,c),this.emit(this.drawCircleChangeEvent);break;case b.DRAWINGRECTANGLE:a.vec2.copy(this.drawRectEnd,c),this.emit(this.drawRectangleChangeEvent)}},b.prototype.handleMouseUp=function(){var c;switch(this.state){case b.DEFAULT:break;case b.DRAGGING:this.world.removeConstraint(this.mouseConstraint),this.mouseConstraint=null,this.world.removeBody(this.nullBody),this.setState(b.DEFAULT);break;case b.PANNING:this.setState(b.DEFAULT);break;case b.DRAWINGPOLYGON:this.setState(b.DRAWPOLYGON),this.drawPoints.length>3&&(c=new a.Body({mass:1}),c.fromPolygon(this.drawPoints,{removeCollinearPoints:.01})&&this.world.addBody(c)),this.drawPoints=[],this.emit(this.drawPointsChangeEvent);break;case b.DRAWINGCIRCLE:this.setState(b.DRAWCIRCLE);var d=a.vec2.dist(this.drawCircleCenter,this.drawCirclePoint);if(d>0){c=new a.Body({mass:1,position:this.drawCircleCenter});var e=new a.Circle(d);c.addShape(e),this.world.addBody(c)}a.vec2.copy(this.drawCircleCenter,this.drawCirclePoint),this.emit(this.drawCircleChangeEvent);break;case b.DRAWINGRECTANGLE:this.setState(b.DRAWRECTANGLE);for(var f=this.drawRectStart,g=this.drawRectEnd,h=0;2>h;h++)if(f[h]>g[h]){var i=g[h];g[h]=f[h],f[h]=i}var j=Math.abs(f[0]-g[0]),k=Math.abs(f[1]-g[1]);if(j>0&&k>0){c=new a.Body({mass:1,position:[this.drawRectStart[0]+.5*j,this.drawRectStart[1]+.5*k]});var l=new a.Rectangle(j,k);c.addShape(l),this.world.addBody(c)}a.vec2.copy(this.drawRectEnd,this.drawRectStart),this.emit(this.drawRectangleChangeEvent)}if(c){c.wakeUp();for(var h=0;h","

    p2.js

    ","

    Physics Engine

    ",'',""].join(""),this.elementContainer.appendChild(b),!function(a,b,c){var d,e=a.getElementsByTagName(b)[0],f=/^http:/.test(a.location)?"http":"https";a.getElementById(c)||(d=a.createElement(b),d.id=c,d.src=f+"://platform.twitter.com/widgets.js",e.parentNode.insertBefore(d,e))}(document,"script","twitter-wjs")},b.zoomInEvent={type:"zoomin"},b.zoomOutEvent={type:"zoomout"},b.prototype.setEquationParameters=function(){this.world.setGlobalEquationParameters({stiffness:this.settings.stiffness,relaxation:this.settings.relaxation})}}(p2),function(a){function b(b,c){c=c||{};var d=this,e={lineWidth:.01,scrollFactor:.1,width:1280,height:720,useDeviceAspect:!1,sleepOpacity:.2};for(var g in c)e[g]=c[g];e.useDeviceAspect&&(e.height=window.innerHeight/window.innerWidth*e.width),this.lineWidth=e.lineWidth,this.scrollFactor=e.scrollFactor,this.sleepOpacity=e.sleepOpacity,this.sprites=[],this.springSprites=[],this.debugPolygons=!1,f.call(this,b,c);for(var g in e)this.settings[g]=e[g];this.pickPrecision=.1,this.on("drawPointsChange",function(){var a=d.drawShapeGraphics,b=d.drawPoints;a.clear();for(var c=[],e=0;ee?-1>e?(-Math.pow(e,2)-h)/g:e:(Math.pow(e,2)+h)/g;var i=Math.min(Math.max(e/2,-1),1),j=i>=0;"undefined"!=typeof n&&d.zoom(n,o,j,void 0,void 0,i)}var c=(this.w,this.h,this.settings),d=this,e=(this.renderer=PIXI.autoDetectRenderer(c.width,c.height,null,null,!0),this.stage=new PIXI.DisplayObjectContainer),i=this.container=new PIXI.Stage(16777215,!0),j=this.element=this.renderer.view;j.tabIndex=1,j.classList.add(f.elementClass),j.setAttribute("style","width:100%;");var k=this.elementContainer=document.createElement("div");k.classList.add(f.containerClass),k.setAttribute("style","width:100%; height:100%"),k.appendChild(j),document.body.appendChild(k),j.focus(),j.oncontextmenu=function(){return!1},this.container.addChild(e),this.drawShapeGraphics=new PIXI.Graphics,e.addChild(this.drawShapeGraphics),this.contactGraphics=new PIXI.Graphics,e.addChild(this.contactGraphics),this.aabbGraphics=new PIXI.Graphics,e.addChild(this.aabbGraphics),e.scale.x=200,e.scale.y=-200;var l,m,n,o,p,q,r=!1,s=a.vec2.create(),t=a.vec2.create(),u=a.vec2.create(),v=0,w=1,x=1,y=0;i.mousedown=i.touchstart=function(b){if(n=b.global.x,o=b.global.y,b.originalEvent.touches&&(y=b.originalEvent.touches.length),b.originalEvent.touches&&2===b.originalEvent.touches.length){var c=d.container.interactionManager.touchs[0],f=d.container.interactionManager.touchs[1],i=c.getLocalPosition(e);a.vec2.set(u,i.x,i.y),d.stagePositionToPhysics(s,u);var i=f.getLocalPosition(e);a.vec2.set(u,i.x,i.y),d.stagePositionToPhysics(t,u),v=a.vec2.dist(s,t);{e.scale.x,e.scale.y}}else{l=b.global.x,m=b.global.y,p=e.position.x,q=e.position.y,r=!0,d.lastMousePos=b.global;var i=b.getLocalPosition(e);a.vec2.set(g,i.x,i.y),d.stagePositionToPhysics(h,g),d.handleMouseDown(h)}},i.mousemove=i.touchmove=function(b){if(b.originalEvent.touches&&(y!==b.originalEvent.touches.length&&(l=b.global.x,m=b.global.y,p=e.position.x,q=e.position.y),y=b.originalEvent.touches.length),n=b.global.x,o=b.global.y,b.originalEvent.touches&&2===b.originalEvent.touches.length){var c=d.container.interactionManager.touchs[0],i=d.container.interactionManager.touchs[1],j=c.getLocalPosition(e);a.vec2.set(u,j.x,j.y),d.stagePositionToPhysics(s,u);var j=i.getLocalPosition(e);a.vec2.set(u,j.x,j.y),d.stagePositionToPhysics(t,u);var k=a.vec2.dist(s,t);return a.vec2.add(s,s,t),a.vec2.scale(s,s,.5),void d.zoom(.5*(c.global.x+i.global.x),.5*(c.global.y+i.global.y),null,k/v*w,k/v*x)}r&&d.state===f.PANNING&&(e.position.x=b.global.x-l+p,e.position.y=b.global.y-m+q),d.lastMousePos=b.global;var j=b.getLocalPosition(e);a.vec2.set(g,j.x,j.y),d.stagePositionToPhysics(h,g),d.handleMouseMove(h)},i.mouseup=i.touchend=function(b){b.originalEvent.touches&&(y=b.originalEvent.touches.length),r=!1,n=b.global.x,o=b.global.y,d.lastMousePos=b.global;var c=b.getLocalPosition(e);a.vec2.set(g,c.x,c.y),d.stagePositionToPhysics(h,g),d.handleMouseUp(h)},this.element.ontouchmove=function(a){a.preventDefault()},j.addEventListener?(j.addEventListener("mousewheel",b,!1),j.addEventListener("DOMMouseScroll",b,!1)):j.attachEvent("onmousewheel",b),this.centerCamera(0,0)},b.prototype.zoom=function(a,b,c,d,e,f){var g=this.scrollFactor,h=this.stage;"undefined"==typeof d?(c||(g*=-1),g*=Math.abs(f),h.scale.x*=1+g,h.scale.y*=1+g,h.position.x+=g*(h.position.x-a),h.position.y+=g*(h.position.y-b)):(h.scale.x*=d,h.scale.y*=e,h.position.x+=(d-1)*(h.position.x-a),h.position.y+=(e-1)*(h.position.y-b)),h.updateTransform()},b.prototype.centerCamera=function(a,b){this.stage.position.x=this.renderer.width/2-this.stage.scale.x*a,this.stage.position.y=this.renderer.height/2-this.stage.scale.y*b},b.prototype.frame=function(a,b,c,d){var e=this.renderer.width/this.renderer.height;c/d>e?(this.stage.scale.x=this.renderer.width/c,this.stage.scale.y=-this.stage.scale.x):(this.stage.scale.y=-this.renderer.height/d,this.stage.scale.x=-this.stage.scale.y),this.centerCamera(a,b)},b.prototype.drawCircle=function(a,b,c,d,e,f,g,h){g="number"==typeof g?g:1,f="number"==typeof f?f:16777215,a.lineStyle(g,0,1),a.beginFill(f,h?this.sleepOpacity:1),a.drawCircle(b,c,e),a.endFill(),a.moveTo(b,c),a.lineTo(b+e*Math.cos(d),c+e*Math.sin(d))},b.drawSpring=function(a,b,c,d){d="number"==typeof d?d:1,c="undefined"==typeof c?16777215:c,a.lineStyle(d,c,1),10*d>b&&(b=10*d);var e=12,f=b/e;a.moveTo(-b/2,0);for(var g=1;e>g;g++){var h=-b/2+f*g,i=0;1>=g||g>=e-1||(g%2===0?i-=.1*b:i+=.1*b),a.lineTo(h,i)}a.lineTo(b/2,0)},b.drawPlane=function(a,b,c,d,e,f,g,h,i){f="number"==typeof f?f:1,d="undefined"==typeof d?16777215:d,a.lineStyle(f,e,1),a.lineStyle(0,0,0),a.beginFill(d);var j=i;a.moveTo(-j,0),a.lineTo(j,0),a.lineTo(j,-j),a.lineTo(-j,-j),a.endFill(),a.lineStyle(f,e),a.moveTo(-j,0),a.lineTo(j,0)},b.drawLine=function(b,c,d,e,f,g){g="number"==typeof g?g:1,f="undefined"==typeof f?0:f,b.lineStyle(g,f,1);var h=a.vec2.fromValues(-e/2,0),i=a.vec2.fromValues(e/2,0);a.vec2.rotate(h,h,d),a.vec2.rotate(i,i,d),a.vec2.add(h,h,c),a.vec2.add(i,i,c),b.moveTo(h[0],h[1]),b.lineTo(i[0],i[1])},b.prototype.drawCapsule=function(a,b,c,d,e,f,g,h,i,j){i="number"==typeof i?i:1,g="undefined"==typeof g?0:g,a.lineStyle(i,g,1);var k=Math.cos(d),l=Math.sin(d);a.beginFill(h,j?this.sleepOpacity:1),a.drawCircle(-e/2*k+b,-e/2*l+c,f),a.drawCircle(e/2*k+b,e/2*l+c,f),a.endFill(),a.lineStyle(i,g,0),a.beginFill(h,j?this.sleepOpacity:1),a.moveTo(-e/2*k+f*l+b,-e/2*l+f*k+c),a.lineTo(e/2*k+f*l+b,e/2*l+f*k+c),a.lineTo(e/2*k-f*l+b,e/2*l-f*k+c),a.lineTo(-e/2*k-f*l+b,-e/2*l-f*k+c),a.endFill(),a.lineStyle(i,g,1),a.moveTo(-e/2*k+f*l+b,-e/2*l+f*k+c),a.lineTo(e/2*k+f*l+b,e/2*l+f*k+c),a.moveTo(-e/2*k-f*l+b,-e/2*l-f*k+c),a.lineTo(e/2*k-f*l+b,e/2*l-f*k+c)},b.prototype.drawRectangle=function(a,b,c,d,e,f,g,h,i,j){i="number"==typeof i?i:1,g="number"==typeof g?g:16777215,h="number"==typeof h?h:16777215,a.lineStyle(i),a.beginFill(h,j?this.sleepOpacity:1),a.drawRect(b-e/2,c-f/2,e,f)},b.prototype.drawConvex=function(a,b,c,d,e,f,g,h,i){if(f="number"==typeof f?f:1,d="undefined"==typeof d?0:d,g){for(var j=[16711680,65280,255],k=0;k!==b.length+1;k++){var l=b[k%b.length],m=b[(k+1)%b.length],n=l[0],o=l[1],p=m[0],q=m[1];a.lineStyle(f,j[k%j.length],1),a.moveTo(n,o),a.lineTo(p,q),a.drawCircle(n,o,2*f)}a.lineStyle(f,0,1),a.drawCircle(h[0],h[1],2*f)}else{a.lineStyle(f,d,1),a.beginFill(e,i?this.sleepOpacity:1);for(var k=0;k!==b.length;k++){var r=b[k],s=r[0],t=r[1];0===k?a.moveTo(s,t):a.lineTo(s,t)}a.endFill(),b.length>2&&(a.moveTo(b[b.length-1][0],b[b.length-1][1]),a.lineTo(b[0][0],b[0][1]))}},b.prototype.drawPath=function(a,b,c,d,e,f){e="number"==typeof e?e:1,c="undefined"==typeof c?0:c,a.lineStyle(e,c,1),"number"==typeof d&&a.beginFill(d,f?this.sleepOpacity:1);for(var g=null,h=null,i=0;i2&&"number"==typeof d&&(a.moveTo(b[b.length-1][0],b[b.length-1][1]),a.lineTo(b[0][0],b[0][1]))},b.prototype.updateSpriteTransform=function(a,b){this.useInterpolatedPositions?(a.position.x=b.interpolatedPosition[0],a.position.y=b.interpolatedPosition[1],a.rotation=b.interpolatedAngle):(a.position.x=b.position[0],a.position.y=b.position[1],a.rotation=b.angle)};var i=a.vec2.fromValues(1,0),j=a.vec2.fromValues(0,0),k=a.vec2.fromValues(0,0),l=a.vec2.fromValues(0,0);b.prototype.render=function(){for(var b=(this.renderer.width,this.renderer.height,this.springSprites),c=(this.sprites,0);c!==this.bodies.length;c++)this.updateSpriteTransform(this.sprites[c],this.bodies[c]);for(var c=0;c!==this.bodies.length;c++){var d=this.bodies[c].sleepState===a.Body.SLEEPING,e=this.sprites[c],f=this.bodies[c];e.drawnSleeping!==d&&(e.clear(),this.drawRenderable(f,e,e.drawnColor,e.drawnLineColor))}for(var c=0;c!==this.springs.length;c++){var g=this.springs[c],e=b[c],h=g.bodyA,m=g.bodyB;if(this.useInterpolatedPositions?(a.vec2.toGlobalFrame(k,g.localAnchorA,h.interpolatedPosition,h.interpolatedAngle),a.vec2.toGlobalFrame(l,g.localAnchorB,m.interpolatedPosition,m.interpolatedAngle)):(g.getWorldAnchorA(k),g.getWorldAnchorB(l)),e.scale.y=1,k[1]= 200 && status < 300)) { + if (res.ioResponse.readyState === 4 && (!status || (status >= 200 && status < 300))) { pjax.initClassTabView(); } @@ -295,7 +295,7 @@ pjax.handleFiles = function (req, res, next) { var status = res.ioResponse.status; // Handles success and local filesystem XHRs. - if (!status || (status >= 200 && status < 300)) { + if (res.ioResponse.readyState === 4 && (!status || (status >= 200 && status < 300))) { pjax.initLineNumbers(); } diff --git a/docs/classes/AABB.html b/docs/classes/AABB.html index 6ceb74b9..38260cf4 100644 --- a/docs/classes/AABB.html +++ b/docs/classes/AABB.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,438 +25,280 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    AABB Class

    +

    AABB Class

    - - - - - -
    -

    Axis aligned bounding box class.

    -

    Constructor

    -

    AABB

    - - -
    - (
      - -
    • - - [options] - -
    • - -
    ) -
    - - - - - - - - - - - - - - - - -
    +

    AABB

    + +
    + (
      +
    • + [options] +
    • +
    ) +
    - - -

    - - Defined in + + + + + + + +

    +

    + Defined in + src/collision/AABB.js:6 +

    + + + +
    + +
    - +
    +
    +

    Parameters:

    - src/collision/AABB.js:6 +
      +
    • + [options] + Object + optional -

      - - - +
      + +
      + +
        +
      • + [upperBound] + Array + optional + +
        + +
        + +
      • +
      • + [lowerBound] + Array + optional + +
        + +
        + +
      • +
      +
    • +
    +
    + -
    - -
    -
    - - -
    -

    Parameters:

    - -
      - -
    • - - [options] - Object - optional - - - - -
      - -
      - - -
        - -
      • - - [upperBound] - Array - optional - - -
        - -
        - - -
      • - -
      • - - [lowerBound] - Array - optional - - -
        - -
        - - -
      • - -
      - -
    • - -
    - - - - - -
    -
    -

    Item Index

    -

    Methods

    - -

    Properties

    - - -
    -

    Methods

    - -
    +

    copy

    -
    (
      -
    • - aabb -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - src/collision/AABB.js:98 -

    - -
    @@ -466,87 +306,52 @@

    copy

    -

    Parameters:

      -
    • - aabb AABB - -
      -
    • -
    - - - -
    - -
    +
    +

    extend

    -
    (
      -
    • - aabb -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - src/collision/AABB.js:108 -

    - -
    @@ -554,91 +359,55 @@

    extend

    -

    Parameters:

      -
    • - aabb AABB - -
      -
    • -
    - - - -
    - -
    +
    +

    overlaps

    -
    (
      -
    • - aabb -
    • -
    )
    - - Boolean - - - - - - -
    - - -

    - Defined in - - - - src/collision/AABB.js:131 -

    - -
    @@ -646,99 +415,59 @@

    overlaps

    -

    Parameters:

      -
    • - aabb AABB - -
      -
    • -
    - -

    Returns:

    - - Boolean: - -
    - - -
    - -
    +
    +

    setFromPoints

    -
    (
      -
    • - points -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - src/collision/AABB.js:39 -

    - -
    @@ -746,145 +475,87 @@

    setFromPoints

    -

    Parameters:

      -
    • - points Array - -

      An array of vec2's.

      -
    • -
    - - - -
    - +
    - -

    Properties

    -
    -

    lowerBound

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/collision/AABB.js:16 - -

    - - - - -
    - -
    -

    The lower bound of the bounding box.

    - -
    - - - - - - -
    - - +

    lowerBound

    + Array + + + + + +
    +

    + Defined in + src/collision/AABB.js:16 +

    + + +
    + +
    +

    The lower bound of the bounding box.

    + +
    + + + +
    -

    upperBound

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/collision/AABB.js:26 - -

    - - - - -
    - -
    -

    The upper bound of the bounding box.

    - -
    - - - - - - -
    - - +

    upperBound

    + Array + + + + + +
    +

    + Defined in + src/collision/AABB.js:26 +

    + + +
    + +
    +

    The upper bound of the bounding box.

    + +
    + + + +
    - - -
    -
    diff --git a/docs/classes/AngleLockEquation.html b/docs/classes/AngleLockEquation.html index 8c1b3168..910fa4aa 100644 --- a/docs/classes/AngleLockEquation.html +++ b/docs/classes/AngleLockEquation.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,609 +25,383 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    AngleLockEquation Class

    +

    AngleLockEquation Class

    - -
    Extends Equation
    - - - - -
    -

    Locks the relative angle between two bodies. The constraint tries to keep the dot product between two vectors, local in each body, to zero. The local angle in body i is a parameter.

    -

    Constructor

    -

    AngleLockEquation

    - - -
    - (
      - -
    • - - bodyA - -
    • - -
    • - - bodyB - -
    • - -
    • - - [options] - -
    • - -
    ) -
    - - - - - - - - - - - - - - - - -
    +

    AngleLockEquation

    + +
    + (
      +
    • + bodyA +
    • +
    • + bodyB +
    • +
    • + [options] +
    • +
    ) +
    - - -

    - - Defined in + + + + + + + +

    +

    + Defined in + src/equations/AngleLockEquation.js:6 +

    + + + +
    + +
    - +
    +
    +

    Parameters:

    - src/equations/AngleLockEquation.js:6 +
      +
    • + bodyA + Body -

      - - - +
      + +
      + +
    • +
    • + bodyB + Body + + +
      + +
      + +
    • +
    • + [options] + Object + optional + + +
      + +
      + +
        +
      • + [angle] + Number + optional + +
        +

        Angle to add to the local vector in body A.

        + +
        + +
      • +
      • + [ratio] + Number + optional + +
        +

        Gear ratio

        + +
        + +
      • +
      +
    • +
    +
    + -
    - -
    -
    - - -
    -

    Parameters:

    - -
      - -
    • - - bodyA - Body - - - - -
      - -
      - - -
    • - -
    • - - bodyB - Body - - - - -
      - -
      - - -
    • - -
    • - - [options] - Object - optional - - - - -
      - -
      - - -
        - -
      • - - [angle] - Number - optional - - -
        -

        Angle to add to the local vector in body A.

        - -
        - - -
      • - -
      • - - [ratio] - Number - optional - - -
        -

        Gear ratio

        - -
        - - -
      • - -
      - -
    • - -
    - - - - - -
    -
    -

    Item Index

    -

    Methods

    - -

    Properties

    - - -
    -

    Methods

    - -
    +

    addToWlambda

    -
    (
      -
    • - deltalambda -
    • -
    )
    - - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:268 -

    - -
    @@ -637,78 +409,49 @@

    addToWlambda

    -

    Parameters:

      -
    • - deltalambda Number - -
      -
    • -
    - - - -
    - -
    +
    +

    computeB

    - () - - Number - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:150 -

    - -
    @@ -716,67 +459,40 @@

    computeB

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    computeGiMf

    - () - - Number - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:213 -

    - -
    @@ -784,67 +500,40 @@

    computeGiMf

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    computeGiMGt

    - () - - Number - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:239 -

    - -
    @@ -852,67 +541,40 @@

    computeGiMGt

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    computeGq

    - () - - Number - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:162 -

    - -
    @@ -920,67 +582,40 @@

    computeGq

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    computeGW

    - () - - Number - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:181 -

    - -
    @@ -988,67 +623,40 @@

    computeGW

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    computeGWlambda

    - () - - Number - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:197 -

    - -
    @@ -1056,77 +664,46 @@

    computeGWlambda

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    computeInvC

    -
    (
      -
    • - eps -
    • -
    )
    - - Number - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:309 -

    - -
    @@ -1134,90 +711,56 @@

    computeInvC

    -

    Parameters:

      -
    • - eps Number - -
      -
    • -
    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    gmult

    - () - - Number - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:136 -

    - -
    @@ -1225,76 +768,43 @@

    gmult

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    setMaxTorque

    -
    (
      -
    • - torque -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - src/equations/AngleLockEquation.js:52 -

    - -
    @@ -1302,87 +812,52 @@

    setMaxTorque

    -

    Parameters:

      -
    • - torque Number - -
      -
    • -
    - - - -
    - -
    +
    +

    setRatio

    -
    (
      -
    • - ratio -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - src/equations/AngleLockEquation.js:40 -

    - -
    @@ -1390,74 +865,46 @@

    setRatio

    -

    Parameters:

      -
    • - ratio Number - -
      -
    • -
    - - - -
    - -
    +
    +

    update

    - () - - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:120 -

    - -
    @@ -1465,540 +912,321 @@

    update

    - - - -
    - +
    - -

    Properties

    -
    -

    bodyA

    - Body - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:32 - -

    - - - - -
    - -
    -

    First body participating in the constraint

    - -
    - - - - - - -
    - - +

    bodyA

    + Body + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:32 +

    + + +
    + +
    +

    First body participating in the constraint

    + +
    + + + +
    -

    bodyB

    - Body - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:39 - -

    - - - - -
    - -
    -

    Second body participating in the constraint

    - -
    - - - - - - -
    - - -
    -

    enabled

    - Boolean - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:96 - -

    - - - - -
    - -
    -

    Whether this equation is enabled or not. If true, it will be added to the solver.

    - -
    - - - - - - -
    - - +

    bodyB

    + Body + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:39 +

    + + +
    + +
    +

    Second body participating in the constraint

    + +
    + + + +
    +
    +

    enabled

    + Boolean + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:96 +

    + + +
    + +
    +

    Whether this equation is enabled or not. If true, it will be added to the solver.

    + +
    + + + +
    -

    G

    - Array - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:60 - -

    - - - - -
    - -
    -

    The Jacobian entry of this equation. 6 numbers, 3 per body (x,y,angle).

    - -
    - - - - - - -
    - - +

    G

    + Array + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:60 +

    + + +
    + +
    +

    The Jacobian entry of this equation. 6 numbers, 3 per body (x,y,angle).

    + +
    + + + +
    -

    maxForce

    - Number - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:25 - -

    - - - - -
    - -
    -

    Max force to apply when solving.

    - -
    - - - - - - -
    - - +

    maxForce

    + Number + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:25 +

    + + +
    + +
    +

    Max force to apply when solving.

    + +
    + + + +
    -

    minForce

    - Number - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:18 - -

    - - - - -
    - -
    -

    Minimum force to apply when solving.

    - -
    - - - - - - -
    - - +

    minForce

    + Number + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:18 +

    + + +
    + +
    +

    Minimum force to apply when solving.

    + +
    + + + +
    -

    multiplier

    - Number - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:83 - -

    - - - - -
    - -
    -

    The resulting constraint multiplier from the last solve. This is mostly equivalent to the force produced by the constraint.

    - -
    - - - - - - -
    - - +

    multiplier

    + Number + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:83 +

    + + +
    + +
    +

    The resulting constraint multiplier from the last solve. This is mostly equivalent to the force produced by the constraint.

    + +
    + + + +
    -

    needsUpdate

    - Boolean - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:77 - -

    - - - - -
    - -
    -

    Indicates if stiffness or relaxation was changed.

    - -
    - - - - - - -
    - - +

    needsUpdate

    + Boolean + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:77 +

    + + +
    + +
    +

    Indicates if stiffness or relaxation was changed.

    + +
    + + + +
    -

    ratio

    - Number - - - - - private - - - - - - -
    - - - -

    - - Defined in - - - - - src/equations/AngleLockEquation.js:23 - -

    - - - - -
    - -
    -

    The gear ratio.

    - -
    - - - - - - -
    - - +

    ratio

    + Number + + + private + + + +
    +

    + Defined in + src/equations/AngleLockEquation.js:23 +

    + + +
    + +
    +

    The gear ratio.

    + +
    + + + +
    -

    relativeVelocity

    - Number - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:90 - -

    - - - - -
    - -
    -

    Relative velocity.

    - -
    - - - - - - -
    - - +

    relativeVelocity

    + Number + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:90 +

    + + +
    + +
    +

    Relative velocity.

    + +
    + + + +
    -

    relaxation

    - Number - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:53 - -

    - - - - -
    - -
    -

    The number of time steps needed to stabilize the constraint equation. Typically between 3 and 5 time steps.

    - -
    - - - - - - -
    - - +

    relaxation

    + Number + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:53 +

    + + +
    + +
    +

    The number of time steps needed to stabilize the constraint equation. Typically between 3 and 5 time steps.

    + +
    + + + +
    -

    stiffness

    - Number - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:46 - -

    - - - - -
    - -
    -

    The stiffness of this equation. Typically chosen to a large number (~1e7), but can be chosen somewhat freely to get a stable simulation.

    - -
    - - - - - - -
    - - +

    stiffness

    + Number + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:46 +

    + + +
    + +
    +

    The stiffness of this equation. Typically chosen to a large number (~1e7), but can be chosen somewhat freely to get a stable simulation.

    + +
    + + + + - - - - diff --git a/docs/classes/Body.html b/docs/classes/Body.html index 44e7137c..ab9a1edb 100644 --- a/docs/classes/Body.html +++ b/docs/classes/Body.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,1004 +25,665 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    Body Class

    +

    Body Class

    - -
    Extends EventEmitter
    - -
    Defined in: src/objects/Body.js:9
    - - -
    -

    A rigid body. Has got a center of mass, position, velocity and a number of shapes that are used for collisions.

    -

    Constructor

    -

    Body

    - - -
    - (
      - -
    • - - [options] - -
    • - -
    ) -
    - - - - - - - - - - - - - - - - -
    +

    Body

    + +
    + (
      +
    • + [options] +
    • +
    ) +
    - - -

    - - Defined in + + + + + + + +

    +

    + Defined in + src/objects/Body.js:9 +

    + + + +
    + +
    - +
    +
    +

    Parameters:

    + +
      +
    • + [options] + Object + optional + + +
      + +
      + +
        +
      • + [mass=0] + Number + optional + +
        +

        A number >= 0. If zero, the .type will be set to Body.STATIC.

        + +
        + +
      • +
      • + [position] + Array + optional + +
        + +
        + +
      • +
      • + [velocity] + Array + optional + +
        + +
        + +
      • +
      • + [angle=0] + Number + optional + +
        + +
        + +
      • +
      • + [angularVelocity=0] + Number + optional + +
        + +
        + +
      • +
      • + [force] + Array + optional + +
        + +
        + +
      • +
      • + [angularForce=0] + Number + optional + +
        + +
        + +
      • +
      • + [fixedRotation=false] + Number + optional + +
        + +
        + +
      • +
      • + [ccdSpeedThreshold=-1] + Number + optional + +
        + +
        + +
      • +
      • + [ccdIterations=10] + Number + optional + +
        + +
        + +
      • +
      +
    • +
    +
    - src/objects/Body.js:9 -

    - - - +
    +

    Example:

    -
    - -
    +
    +
    // Create a typical dynamic body
    +        var body = new Body({
    +            mass: 1,
    +            position: [0, 0],
    +            angle: 0,
    +            velocity: [0, 0],
    +            angularVelocity: 0
    +        });
             
    -    
    - - -
    -

    Parameters:

    - -
      - -
    • - - [options] - Object - optional - - - - -
      - + // Add a circular shape to the body + body.addShape(new Circle(1)); + + // Add the body to the world + world.addBody(body); +
      - - -
        - -
      • - - [mass=0] - Number - optional - - -
        -

        A number >= 0. If zero, the .type will be set to Body.STATIC.

        - -
        - - -
      • - -
      • - - [position] - Array - optional - - -
        - -
        - - -
      • - -
      • - - [velocity] - Array - optional - - -
        - -
        - - -
      • - -
      • - - [angle=0] - Number - optional - - -
        - -
        - - -
      • - -
      • - - [angularVelocity=0] - Number - optional - - -
        - -
        - - -
      • - -
      • - - [force] - Array - optional - - -
        - -
        - - -
      • - -
      • - - [angularForce=0] - Number - optional - - -
        - -
        - - -
      • - -
      • - - [fixedRotation=false] - Number - optional - - -
        - -
        - - -
      • - -
      - -
    • - -
    -
    - - - - - -
    -

    Example:

    - -
    -
    // Create a typical dynamic body
    -var body = new Body({
    -    mass: 1,
    -    position: [0, 0],
    -    angle: 0,
    -    velocity: [0, 0],
    -    angularVelocity: 0
    -});
    -
    -// Add a circular shape to the body
    -body.addShape(new Circle(1));
    -
    -// Add the body to the world
    -world.addBody(body);
    - -
    +
    - -
    -
    -

    Item Index

    -

    Methods

    - -

    Properties

    - - -

    Events

    -
    -

    Methods

    - -
    +

    addShape

    -
    (
      -
    • - shape -
    • -
    • - [offset] -
    • -
    • - [angle] -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - - src/objects/Body.js:491 - + src/objects/Body.js:517

    - -
    @@ -1034,68 +693,49 @@

    addShape

    -

    Parameters:

      -
    • - shape Shape - -
      -
    • -
    • - [offset] Array optional - -

      Local body offset of the shape.

      -
    • -
    • - [angle] Number optional - -

      Local body angle.

      -
    • -
    - - - +

    Example:

    @@ -1110,54 +750,31 @@

    Example:

    body.addShape(shape,[1,0]); // Add another shape to the body, positioned 1 unit length from the body center of mass along the local y-axis, and rotated 90 degrees CCW. -body.addShape(shape,[0,1],Math.PI/2); - +body.addShape(shape,[0,1],Math.PI/2); +
    -
    - - -
    +

    adjustCenterOfMass

    - () - - - - - - - -
    - - -

    - Defined in - - - - - src/objects/Body.js:726 - + src/objects/Body.js:752

    - -
    @@ -1165,64 +782,36 @@

    adjustCenterOfMass

    - - - -
    - -
    +
    +

    applyDamping

    -
    (
      -
    • - dt -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - - src/objects/Body.js:795 - + src/objects/Body.js:821

    - -
    @@ -1230,94 +819,56 @@

    applyDamping

    -

    Parameters:

      -
    • - dt Number - -

      Current time step

      -
    • -
    - - - -
    - -
    +
    +

    applyForce

    -
    (
      -
    • - force -
    • -
    • - worldPoint -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - - src/objects/Body.js:600 - + src/objects/Body.js:626

    - -
    @@ -1325,105 +876,67 @@

    applyForce

    -

    Parameters:

      -
    • - force Array - -

      The force to add.

      -
    • -
    • - worldPoint Array - -

      A world point to apply the force on.

      -
    • -
    - - - -
    - -
    +
    +

    emit

    -
    (
      -
    • - event -
    • -
    )
    - - EventEmitter - - - - - - -
    - -

    Inherited from EventEmitter: - - - src/events/EventEmitter.js:79 -

    - -
    @@ -1431,128 +944,78 @@

    emit

    -

    Parameters:

      -
    • - event Object - -
      -
        -
      • - type String -
        -
      • -
      -
    • -
    - -

    Returns:

    - - EventEmitter: -

    The self object, for chainability.

    -
    - - -
    - -
    +
    +

    fromPolygon

    -
    (
      -
    • - path -
    • -
    • - [options] -
    • -
    )
    - - Boolean - - - - - - -
    - - -

    - Defined in - - - - - src/objects/Body.js:641 - + src/objects/Body.js:667

    - -
    @@ -1560,157 +1023,102 @@

    fromPolygon

    -

    Parameters:

      -
    • - path Array - -

      An array of 2d vectors, e.g. [[0,0],[0,1],...] that resembles a concave or convex polygon. The shape must be simple and without holes.

      -
    • -
    • - [options] Object optional - -
      -
        -
      • - [optimalDecomp=false] Boolean optional -

        Set to true if you need optimal decomposition. Warning: very slow for polygons with more than 10 vertices.

        -
      • -
      • - [skipSimpleCheck=false] Boolean optional -

        Set to true if you already know that the path is not intersecting itself.

        -
      • -
      • - [removeCollinearPoints=false] Boolean | Number optional -

        Set to a number (angle threshold value) to remove collinear points, or false to keep all points.

        -
      • -
      -
    • -
    - -

    Returns:

    - - Boolean: -

    True on success, else false.

    -
    - - -
    - -
    +
    +

    getAABB

    - () - - - - - - - -
    - - -

    - Defined in - - - - - src/objects/Body.js:421 - + src/objects/Body.js:447

    - -
    @@ -1718,58 +1126,33 @@

    getAABB

    - - - -
    - -
    +
    +

    getArea

    - () - - Number - - - - - - -
    - - -

    - Defined in - - - - - src/objects/Body.js:408 - + src/objects/Body.js:434

    - -
    @@ -1777,83 +1160,49 @@

    getArea

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    has

    -
    (
      -
    • - type -
    • -
    • - listener -
    • -
    )
    - - Boolean - - - - - - -
    - -

    Inherited from EventEmitter: - - - src/events/EventEmitter.js:35 -

    - -
    @@ -1861,121 +1210,128 @@

    has

    -

    Parameters:

      -
    • - type String - -
      -
    • -
    • - listener Function - -
      -
    • -
    - -

    Returns:

    - - Boolean: - -
    - - +
    +
    +

    integrate

    - -
    +
    + (
      +
    • + dt +
    • +
    ) +
    + + + + + + + + +
    +

    + Defined in + src/objects/Body.js:935 +

    + + + +
    + +
    +

    Move the body forward in time given its current velocity.

    + +
    + +
    +

    Parameters:

    + +
      +
    • + dt + Number + + +
      + +
      + +
    • +
    +
    + + + +
    +

    off

    -
    (
      -
    • - type -
    • -
    • - listener -
    • -
    )
    - - EventEmitter - - - - - - -
    - -

    Inherited from EventEmitter: - - - src/events/EventEmitter.js:60 -

    - -
    @@ -1983,123 +1339,77 @@

    off

    -

    Parameters:

      -
    • - type String - -
      -
    • -
    • - listener Function - -
      -
    • -
    - -

    Returns:

    - - EventEmitter: -

    The self object, for chainability.

    -
    - - -
    - -
    +
    +

    on

    -
    (
      -
    • - type -
    • -
    • - listener -
    • -
    )
    - - EventEmitter - - - - - - -
    - -

    Inherited from EventEmitter: - - - src/events/EventEmitter.js:13 -

    - -
    @@ -2107,120 +1417,74 @@

    on

    -

    Parameters:

      -
    • - type String - -
      -
    • -
    • - listener Function - -
      -
    • -
    - -

    Returns:

    - - EventEmitter: -

    The self object, for chainability.

    -
    - - -
    - -
    +
    +

    overlaps

    -
    (
      -
    • - body -
    • -
    )
    - - Boolean - - - - - - -
    - - -

    - Defined in - - - - - src/objects/Body.js:903 - + src/objects/Body.js:922

    - -
    @@ -2228,103 +1492,62 @@

    overlaps

    -

    Parameters:

      -
    • - body Body - -
      -
    • -
    - -

    Returns:

    - - Boolean: - -
    - - -
    - -
    +
    +

    removeShape

    -
    (
      -
    • - shape -
    • -
    )
    - - Boolean - - - - - - -
    - - -

    - Defined in - - - - - src/objects/Body.js:533 - + src/objects/Body.js:559

    - -
    @@ -2332,91 +1555,55 @@

    removeShape

    -

    Parameters:

      -
    • - shape Shape - -
      -
    • -
    - -

    Returns:

    - - Boolean: -

    True if the shape was found and removed, else false.

    -
    - - -
    - -
    +
    +

    setDensity

    - () - - - - - - - -
    - - -

    - Defined in - - - - - src/objects/Body.js:398 - + src/objects/Body.js:424

    - -
    @@ -2424,54 +1611,30 @@

    setDensity

    - - - -
    - -
    +
    +

    setZeroForce

    - () - - - - - - - -
    - - -

    - Defined in - - - - - src/objects/Body.js:772 - + src/objects/Body.js:798

    - -
    @@ -2479,54 +1642,30 @@

    setZeroForce

    - - - -
    - -
    +
    +

    sleep

    - () - - - - - - - -
    - - -

    - Defined in - - - - - src/objects/Body.js:830 - + src/objects/Body.js:848

    - -
    @@ -2534,76 +1673,42 @@

    sleep

    - - - -
    - -
    +
    +

    sleepTick

    -
    (
      -
    • - time -
    • -
    • - dontSleep -
    • -
    • - dt -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - - src/objects/Body.js:843 - + src/objects/Body.js:861

    - -
    @@ -2611,124 +1716,76 @@

    sleepTick

    -

    Parameters:

      -
    • - time Number - -

      The world time in seconds

      -
    • -
    • - dontSleep Boolean - -
      -
    • -
    • - dt Number - -
      -
    • -
    - - - -
    - -
    +
    +

    toLocalFrame

    -
    (
      -
    • - out -
    • -
    • - worldPoint -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - - src/objects/Body.js:621 - + src/objects/Body.js:647

    - -
    @@ -2736,110 +1793,67 @@

    toLocalFrame

    -

    Parameters:

      -
    • - out Array - -

      The vector to store the result in

      -
    • -
    • - worldPoint Array - -

      The input world vector

      -
    • -
    - - - -
    - -
    +
    +

    toWorldFrame

    -
    (
      -
    • - out -
    • -
    • - localPoint -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - - src/objects/Body.js:631 - + src/objects/Body.js:657

    - -
    @@ -2847,94 +1861,58 @@

    toWorldFrame

    -

    Parameters:

      -
    • - out Array - -

      The vector to store the result in

      -
    • -
    • - localPoint Array - -

      The input local vector

      -
    • -
    - - - -
    - -
    +
    +

    updateAABB

    - () - - - - - - - -
    - - -

    - Defined in - - - - - src/objects/Body.js:435 - + src/objects/Body.js:461

    - -
    @@ -2942,54 +1920,30 @@

    updateAABB

    - - - -
    - -
    +
    +

    updateBoundingRadius

    - () - - - - - - - -
    - - -

    - Defined in - - - - - src/objects/Body.js:468 - + src/objects/Body.js:494

    - -
    @@ -2998,54 +1952,30 @@

    updateBoundingRadius

    - - - -
    - -
    +
    +

    updateMassProperties

    - () - - - - - - - -
    - - -

    - Defined in - - - - - src/objects/Body.js:553 - + src/objects/Body.js:579

    - -
    @@ -3054,64 +1984,39 @@

    updateMassProperties

    - - - +

    Example:

    body.mass += 1;
    -body.updateMassProperties();
    - +body.updateMassProperties(); +
    -
    - - -
    +

    wakeUp

    - () - - - - - - - -
    - - -

    - Defined in - - - - - src/objects/Body.js:816 - + src/objects/Body.js:834

    - -
    @@ -3120,2067 +2025,1281 @@

    wakeUp

    - - - -
    - +
    - -

    Properties

    -
    -

    aabb

    - AABB - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:302 - -

    - - - - -
    - -
    -

    Bounding box of this body.

    - -
    - - - - - - -
    - - +

    aabb

    + AABB + + + + + +
    +

    + Defined in + src/objects/Body.js:305 +

    + + +
    + +
    +

    Bounding box of this body.

    + +
    + + + +
    -

    aabbNeedsUpdate

    - Boolean - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:309 - -

    - - - - -
    - -
    -

    Indicates if the AABB needs update. Update it with .updateAABB().

    - -
    - - - - -
    -

    Example:

    - -
    -
    // Force update the AABB
    -body.aabbNeedsUpdate = true;
    -body.updateAABB();
    -console.log(body.aabbNeedsUpdate); // false
    - -
    -
    - - - -
    - - +

    aabbNeedsUpdate

    + Boolean + + + + + +
    +

    + Defined in + src/objects/Body.js:312 +

    + + +
    + +
    +

    Indicates if the AABB needs update. Update it with .updateAABB().

    + +
    + + +
    +

    Example:

    + +
    +
    // Force update the AABB
    +                    body.aabbNeedsUpdate = true;
    +                    body.updateAABB();
    +                    console.log(body.aabbNeedsUpdate); // false
    +                    
    +
    +
    + +
    -

    allowSleep

    - Boolean - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:323 - -

    - - - - -
    - -
    -

    If true, the body will automatically fall to sleep. Note that you need to enable sleeping in the World before anything will happen.

    - -
    - - -

    Default: true

    - - - - - -
    - - +

    allowSleep

    + Boolean + + + + + +
    +

    + Defined in + src/objects/Body.js:326 +

    + + +
    + +
    +

    If true, the body will automatically fall to sleep. Note that you need to enable sleeping in the World before anything will happen.

    + +
    + +

    Default: true

    + + +
    -

    angle

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:185 - -

    - - - - -
    - -
    -

    The angle of the body, in radians.

    - -
    - - - - -
    -

    Example:

    - -
    -
    // The angle property is not normalized to the interval 0 to 2*pi, it can be any value.
    -// If you need a value between 0 and 2*pi, use the following function to normalize it.
    -function normalizeAngle(angle){
    -    angle = angle % (2*Math.PI);
    -    if(angle < 0){
    -        angle += (2*Math.PI);
    -    }
    -    return angle;
    -}
    - -
    -
    - - - -
    - - +

    angle

    + Number + + + + + +
    +

    + Defined in + src/objects/Body.js:188 +

    + + +
    + +
    +

    The angle of the body, in radians.

    + +
    + + +
    +

    Example:

    + +
    +
    // The angle property is not normalized to the interval 0 to 2*pi, it can be any value.
    +                    // If you need a value between 0 and 2*pi, use the following function to normalize it.
    +                    function normalizeAngle(angle){
    +                        angle = angle % (2*Math.PI);
    +                        if(angle < 0){
    +                            angle += (2*Math.PI);
    +                        }
    +                        return angle;
    +                    }
    +                    
    +
    +
    + +
    -

    angularDamping

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:248 - -

    - - - - -
    - -
    -

    The angular force acting on the body. Should be a value between 0 and 1.

    - -
    - - -

    Default: 0.1

    - - - - - -
    - - +

    angularDamping

    + Number + + + + + +
    +

    + Defined in + src/objects/Body.js:251 +

    + + +
    + +
    +

    The angular force acting on the body. Should be a value between 0 and 1.

    + +
    + +

    Default: 0.1

    + + +
    -

    angularForce

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:233 - -

    - - - - -
    - -
    -

    The angular force acting on the body. See force.

    - -
    - - - - - - -
    - - +

    angularForce

    + Number + + + + + +
    +

    + Defined in + src/objects/Body.js:236 +

    + + +
    + +
    +

    The angular force acting on the body. See force.

    + +
    + + + +
    -

    angularVelocity

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:202 - -

    - - - - -
    - -
    -

    The angular velocity of the body, in radians per second.

    - -
    - - - - - - -
    - - +

    angularVelocity

    + Number + + + + + +
    +

    + Defined in + src/objects/Body.js:205 +

    + + +
    + +
    +

    The angular velocity of the body, in radians per second.

    + +
    + + + +
    -

    AWAKE

    - Number - - - - - - - - - static - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:958 - -

    - - - - -
    - -
    - -
    - - - - - - -
    - - +

    AWAKE

    + Number + + + + + static + +
    +

    + Defined in + src/objects/Body.js:1101 +

    + + +
    + +
    + +
    + + + +
    -

    boundingRadius

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:295 - -

    - - - - -
    - -
    -

    Bounding circle radius.

    - -
    - - - - - - -
    - - +

    boundingRadius

    + Number + + + + + +
    +

    + Defined in + src/objects/Body.js:298 +

    + + +
    + +
    +

    Bounding circle radius.

    + +
    + + + +
    +
    +

    ccdIterations

    + Number + + + + + +
    +

    + Defined in + src/objects/Body.js:396 +

    + + +
    + +
    +

    The number of iterations that should be used when searching for the time of impact during CCD. A larger number will assure that there's a small penetration on CCD collision, but a small number will give more performance.

    + +
    + +

    Default: 10

    + + +
    +
    +

    ccdSpeedThreshold

    + Number + + + + + +
    +

    + Defined in + src/objects/Body.js:389 +

    + + +
    + +
    +

    If the body speed exceeds this threshold, CCD (continuous collision detection) will be enabled. Set it to a negative number to disable CCD completely for this body.

    + +
    + +

    Default: -1

    + + +
    +
    +

    collisionResponse

    + Boolean + + + + + +
    +

    + Defined in + src/objects/Body.js:370 +

    + + +
    + +
    +

    Whether to produce contact forces when in contact with other bodies. Note that contacts will be generated, but they will be disabled. That means that this body will move through other bodies, but it will still trigger contact events, etc.

    + +
    + + + +
    -

    damping

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:240 - -

    - - - - -
    - -
    -

    The linear damping acting on the body in the velocity direction. Should be a value between 0 and 1.

    - -
    - - -

    Default: 0.1

    - - - - - -
    - - +

    damping

    + Number + + + + + +
    +

    + Defined in + src/objects/Body.js:243 +

    + + +
    + +
    +

    The linear damping acting on the body in the velocity direction. Should be a value between 0 and 1.

    + +
    + +

    Default: 0.1

    + + +
    -

    DYNAMIC

    - Number - - - - - - - - - static - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:934 - -

    - - - - -
    - -
    -

    Dynamic body.

    - -
    - - - - - - -
    - - +

    DYNAMIC

    + Number + + + + + static + +
    +

    + Defined in + src/objects/Body.js:1077 +

    + + +
    + +
    +

    Dynamic body.

    + +
    + + + +
    -

    fixedRotation

    - Boolean - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:116 - -

    - - - - -
    - -
    -

    Set to true if you want to fix the rotation of the body.

    - -
    - - - - - - -
    - - +

    fixedRotation

    + Boolean + + + + + +
    +

    + Defined in + src/objects/Body.js:119 +

    + + +
    + +
    +

    Set to true if you want to fix the rotation of the body.

    + +
    + + + +
    -

    force

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:209 - -

    - - - - -
    - -
    -

    The force acting on the body. Since the body force (and angularForce) will be zeroed after each step, so you need to set the force before each step.

    - -
    - - - - -
    -

    Example:

    - -
    -
    // This produces a forcefield of 1 Newton in the positive x direction.
    -for(var i=0; i<numSteps; i++){
    -    body.force[0] = 1;
    -    world.step(1/60);
    -}
    -
    // This will apply a rotational force on the body
    -for(var i=0; i<numSteps; i++){
    -    body.angularForce = -3;
    -    world.step(1/60);
    -}
    - -
    -
    - - - -
    - - +

    force

    + Array + + + + + +
    +

    + Defined in + src/objects/Body.js:212 +

    + + +
    + +
    +

    The force acting on the body. Since the body force (and angularForce) will be zeroed after each step, so you need to set the force before each step.

    + +
    + + +
    +

    Example:

    + +
    +
    // This produces a forcefield of 1 Newton in the positive x direction.
    +                    for(var i=0; i<numSteps; i++){
    +                        body.force[0] = 1;
    +                        world.step(1/60);
    +                    }
    +                    
    // This will apply a rotational force on the body
    +                    for(var i=0; i<numSteps; i++){
    +                        body.angularForce = -3;
    +                        world.step(1/60);
    +                    }
    +                    
    +
    +
    + +
    -

    gravityScale

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:360 - -

    - - - - -
    - -
    -

    Gravity scaling factor. If you want the body to ignore gravity, set this to zero. If you want to reverse gravity, set it to -1.

    - -
    - - -

    Default: 1

    - - - - - -
    - - +

    gravityScale

    + Number + + + + + +
    +

    + Defined in + src/objects/Body.js:363 +

    + + +
    + +
    +

    Gravity scaling factor. If you want the body to ignore gravity, set this to zero. If you want to reverse gravity, set it to -1.

    + +
    + +

    Default: 1

    + + +
    -

    id

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:47 - -

    - - - - -
    - -
    -

    The body identifyer

    - -
    - - - - - - -
    - - -
    -

    inertia

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:99 - -

    - - - - -
    - -
    -

    The inertia of the body around the Z axis.

    - -
    - - - - - - -
    - - -
    -

    interpolatedAngle

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:140 - -

    - - - - -
    - -
    -

    The interpolated angle of the body.

    - -
    - - - - - - -
    - - +

    id

    + Number + + + + + +
    +

    + Defined in + src/objects/Body.js:50 +

    + + +
    + +
    +

    The body identifyer

    + +
    + + + + +
    +

    idleTime

    + Number + + + + + +
    +

    + Defined in + src/objects/Body.js:376 +

    + + +
    + +
    +

    How long the body has been sleeping.

    + +
    + + + +
    +
    +

    inertia

    + Number + + + + + +
    +

    + Defined in + src/objects/Body.js:102 +

    + + +
    + +
    +

    The inertia of the body around the Z axis.

    + +
    + + + +
    +
    +

    interpolatedAngle

    + Number + + + + + +
    +

    + Defined in + src/objects/Body.js:143 +

    + + +
    + +
    +

    The interpolated angle of the body.

    + +
    + + + +
    -

    interpolatedPosition

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:133 - -

    - - - - -
    - -
    -

    The interpolated position of the body.

    - -
    - - - - - - -
    - - +

    interpolatedPosition

    + Array + + + + + +
    +

    + Defined in + src/objects/Body.js:136 +

    + + +
    + +
    +

    The interpolated position of the body.

    + +
    + + + +
    -

    invInertia

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:106 - -

    - - - - -
    - -
    -

    The inverse inertia of the body.

    - -
    - - - - - - -
    - - +

    invInertia

    + Number + + + + + +
    +

    + Defined in + src/objects/Body.js:109 +

    + + +
    + +
    +

    The inverse inertia of the body.

    + +
    + + + +
    -

    invMass

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:92 - -

    - - - - -
    - -
    -

    The inverse mass of the body.

    - -
    - - - - - - -
    - - +

    invMass

    + Number + + + + + +
    +

    + Defined in + src/objects/Body.js:95 +

    + + +
    + +
    +

    The inverse mass of the body.

    + +
    + + + +
    -

    KINEMATIC

    - Number - - - - - - - - - static - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:950 - -

    - - - - -
    - -
    -

    Kinematic body.

    - -
    - - - - - - -
    - - -
    -

    mass

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:85 - -

    - - - - -
    - -
    -

    The mass of the body.

    - -
    - - - - - - -
    - - +

    KINEMATIC

    + Number + + + + + static + +
    +

    + Defined in + src/objects/Body.js:1093 +

    + + +
    + +
    +

    Kinematic body.

    + +
    + + + + +
    +

    mass

    + Number + + + + + +
    +

    + Defined in + src/objects/Body.js:88 +

    + + +
    + +
    +

    The mass of the body.

    + +
    + + + +
    -

    position

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:123 - -

    - - - - -
    - -
    -

    The position of the body

    - -
    - - - - - - -
    - - +

    position

    + Array + + + + + +
    +

    + Defined in + src/objects/Body.js:126 +

    + + +
    + +
    +

    The position of the body

    + +
    + + + +
    -

    previousAngle

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:154 - -

    - - - - -
    - -
    -

    The previous angle of the body.

    - -
    - - - - - - -
    - - +

    previousAngle

    + Number + + + + + +
    +

    + Defined in + src/objects/Body.js:157 +

    + + +
    + +
    +

    The previous angle of the body.

    + +
    + + + +
    -

    previousPosition

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:147 - -

    - - - - -
    - -
    -

    The previous position of the body.

    - -
    - - - - - - -
    - - +

    previousPosition

    + Array + + + + + +
    +

    + Defined in + src/objects/Body.js:150 +

    + + +
    + +
    +

    The previous position of the body.

    + +
    + + + +
    -

    shapeAngles

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:78 - -

    - - - - -
    - -
    -

    The body-local shape angle transforms. This is an array of numbers (angles).

    - -
    - - - - - - -
    - - +

    shapeAngles

    + Array + + + + + +
    +

    + Defined in + src/objects/Body.js:81 +

    + + +
    + +
    +

    The body-local shape angle transforms. This is an array of numbers (angles).

    + +
    + + + +
    -

    shapeOffsets

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:70 - -

    - - - - -
    - -
    -

    The local shape offsets, relative to the body center of mass. This is an -array of Array.

    - -
    - - - - - - -
    - - +

    shapeOffsets

    + Array + + + + + +
    +

    + Defined in + src/objects/Body.js:73 +

    + + +
    + +
    +

    The local shape offsets, relative to the body center of mass. This is an + array of Array.

    + +
    + + + +
    -

    shapes

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:61 - -

    - - - - -
    - -
    -

    The shapes of the body. The local transform of the shape in .shapes[i] is -defined by .shapeOffsets[i] and .shapeAngles[i].

    - -
    - - - - - - -
    - - +

    shapes

    + Array + + + + + +
    +

    + Defined in + src/objects/Body.js:64 +

    + + +
    + +
    +

    The shapes of the body. The local transform of the shape in .shapes[i] is + defined by .shapeOffsets[i] and .shapeAngles[i].

    + +
    + + + +
    -

    SLEEPING

    - Number - - - - - - - - - static - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:972 - -

    - - - - -
    - -
    - -
    - - - - - - -
    - - +

    SLEEPING

    + Number + + + + + static + +
    +

    + Defined in + src/objects/Body.js:1115 +

    + + +
    + +
    + +
    + + + +
    -

    sleepSpeedLimit

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:344 - -

    - - - - -
    - -
    -

    If the speed (the norm of the velocity) is smaller than this value, the body is considered sleepy.

    - -
    - - -

    Default: 0.2

    - - - - - -
    - - +

    sleepSpeedLimit

    + Number + + + + + +
    +

    + Defined in + src/objects/Body.js:347 +

    + + +
    + +
    +

    If the speed (the norm of the velocity) is smaller than this value, the body is considered sleepy.

    + +
    + +

    Default: 0.2

    + + +
    -

    sleepState

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:333 - -

    - - - - -
    - -
    -

    One of Body.AWAKE, Body.SLEEPY and Body.SLEEPING.

    -

    The body is initially Body.AWAKE. If its velocity norm is below .sleepSpeedLimit, the sleepState will become Body.SLEEPY. If the body continues to be Body.SLEEPY for .sleepTimeLimit seconds, it will fall asleep (Body.SLEEPY).

    - -
    - - -

    Default: Body.AWAKE

    - - - - - -
    - - -
    -

    sleepTimeLimit

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:352 - -

    - - - - -
    - -
    -

    If the body has been sleepy for this sleepTimeLimit seconds, it is considered sleeping.

    - -
    - - -

    Default: 1

    - - - - - -
    - - -
    -

    SLEEPY

    - Number - - - - - - - - - static - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:965 - -

    - - - - -
    - -
    - -
    - - - - - - -
    - - +

    sleepState

    + Number + + + + + +
    +

    + Defined in + src/objects/Body.js:336 +

    + + +
    + +
    +

    One of Body.AWAKE, Body.SLEEPY and Body.SLEEPING.

    +

    The body is initially Body.AWAKE. If its velocity norm is below .sleepSpeedLimit, the sleepState will become Body.SLEEPY. If the body continues to be Body.SLEEPY for .sleepTimeLimit seconds, it will fall asleep (Body.SLEEPY).

    + +
    + +

    Default: Body.AWAKE

    + + + +
    +

    sleepTimeLimit

    + Number + + + + + +
    +

    + Defined in + src/objects/Body.js:355 +

    + + +
    + +
    +

    If the body has been sleepy for this sleepTimeLimit seconds, it is considered sleeping.

    + +
    + +

    Default: 1

    + + +
    +
    +

    SLEEPY

    + Number + + + + + static + +
    +

    + Defined in + src/objects/Body.js:1108 +

    + + +
    + +
    + +
    + + + +
    -

    STATIC

    - Number - - - - - - - - - static - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:942 - -

    - - - - -
    - -
    -

    Static body.

    - -
    - - - - - - -
    - - +

    STATIC

    + Number + + + + + static + +
    +

    + Defined in + src/objects/Body.js:1085 +

    + + +
    + +
    +

    Static body.

    + +
    + + + +
    -

    timeLastSleepy

    - Number - - - - - private - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:367 - -

    - - - - -
    - -
    -

    The last time when the body went to SLEEPY state.

    - -
    - - - - - - -
    - - +

    timeLastSleepy

    + Number + + + private + + + +
    +

    + Defined in + src/objects/Body.js:382 +

    + + +
    + +
    +

    The last time when the body went to SLEEPY state.

    + +
    + + + +
    -

    type

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:256 - -

    - - - - -
    - -
    -

    The type of motion this body has. Should be one of: Body.STATIC, Body.DYNAMIC and Body.KINEMATIC.

    -
      -
    • Static bodies do not move, and they do not respond to forces or collision.
    • -
    • Dynamic bodies body can move and respond to collisions and forces.
    • -
    • Kinematic bodies only moves according to its .velocity, and does not respond to collisions or force.
    • -
    - -
    - - - - -
    -

    Example:

    - -
    -
    // Bodies are static by default. Static bodies will never move.
    -var body = new Body();
    -console.log(body.type == Body.STATIC); // true
    -
    // By setting the mass of a body to a nonzero number, the body
    -// will become dynamic and will move and interact with other bodies.
    -var dynamicBody = new Body({
    -    mass : 1
    -});
    -console.log(dynamicBody.type == Body.DYNAMIC); // true
    -
    // Kinematic bodies will only move if you change their velocity.
    -var kinematicBody = new Body({
    -    type: Body.KINEMATIC // Type can be set via the options object.
    -});
    - -
    -
    - - - -
    - - +

    type

    + Number + + + + + +
    +

    + Defined in + src/objects/Body.js:259 +

    + + +
    + +
    +

    The type of motion this body has. Should be one of: Body.STATIC, Body.DYNAMIC and Body.KINEMATIC.

    +
      +
    • Static bodies do not move, and they do not respond to forces or collision.
    • +
    • Dynamic bodies body can move and respond to collisions and forces.
    • +
    • Kinematic bodies only moves according to its .velocity, and does not respond to collisions or force.
    • +
    + +
    + + +
    +

    Example:

    + +
    +
    // Bodies are static by default. Static bodies will never move.
    +                    var body = new Body();
    +                    console.log(body.type == Body.STATIC); // true
    +                    
    // By setting the mass of a body to a nonzero number, the body
    +                    // will become dynamic and will move and interact with other bodies.
    +                    var dynamicBody = new Body({
    +                        mass : 1
    +                    });
    +                    console.log(dynamicBody.type == Body.DYNAMIC); // true
    +                    
    // Kinematic bodies will only move if you change their velocity.
    +                    var kinematicBody = new Body({
    +                        type: Body.KINEMATIC // Type can be set via the options object.
    +                    });
    +                    
    +
    +
    + +
    -

    velocity

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:161 - -

    - - - - -
    - -
    -

    The velocity of the body

    - -
    - - - - - - -
    - - -
    -

    vlambda

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:171 - -

    - - - - -
    - -
    -

    Constraint velocity that was added to the body during the last step.

    - -
    - - - - - - -
    - - +

    velocity

    + Array + + + + + +
    +

    + Defined in + src/objects/Body.js:164 +

    + + +
    + +
    +

    The velocity of the body

    + +
    + + + + +
    +

    vlambda

    + Array + + + + + +
    +

    + Defined in + src/objects/Body.js:174 +

    + + +
    + +
    +

    Constraint velocity that was added to the body during the last step.

    + +
    + + + +
    -

    wlambda

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:178 - -

    - - - - -
    - -
    -

    Angular constraint velocity that was added to the body during last step.

    - -
    - - - - - - -
    - - +

    wlambda

    + Array + + + + + +
    +

    + Defined in + src/objects/Body.js:181 +

    + + +
    + +
    +

    Angular constraint velocity that was added to the body during last step.

    + +
    + + + +
    -

    world

    - World - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:54 - -

    - - - - -
    - -
    -

    The world that this body is added to. This property is set to NULL if the body is not added to any world.

    - -
    - - - - - - -
    - - +

    world

    + World + + + + + +
    +

    + Defined in + src/objects/Body.js:57 +

    + + +
    + +
    +

    The world that this body is added to. This property is set to NULL if the body is not added to any world.

    + +
    + + + + - - -

    Events

    -
    -

    sleep

    - - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:920 - -

    - - - - -
    - -
    - -
    - - - - - -
    - - +

    sleep

    + + + + + + +
    +

    + Defined in + src/objects/Body.js:1063 +

    + + +
    + +
    + +
    + + + +
    -

    sleepy

    - - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:913 - -

    - - - - -
    - -
    - -
    - - - - - -
    - - +

    sleepy

    + + + + + + +
    +

    + Defined in + src/objects/Body.js:1056 +

    + + +
    + +
    + +
    + + + +
    -

    wakeup

    - - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/Body.js:927 - -

    - - - - -
    - -
    - -
    - - - - - -
    - - +

    wakeup

    + + + + + + +
    +

    + Defined in + src/objects/Body.js:1070 +

    + + +
    + +
    + +
    + + + + - - diff --git a/docs/classes/Broadphase.html b/docs/classes/Broadphase.html index 451d7e07..8d1c51dd 100644 --- a/docs/classes/Broadphase.html +++ b/docs/classes/Broadphase.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,421 +25,263 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    Broadphase Class

    +

    Broadphase Class

    - - - - - -
    -

    Base class for broadphase implementations.

    -

    Constructor

    -

    Broadphase

    - - - () - - - - - - - - - - - - - - - - -
    +

    Broadphase

    - - -

    - - Defined in - - + () - src/collision/Broadphase.js:6 -

    - - - -
    - -
    + + +
    +

    + Defined in + src/collision/Broadphase.js:6 +

    + + + +
    + +
    + +
    + + + + +
    - - - - - -
    - -
    - -

    Item Index

    - - -

    Properties

    - - -
    -

    Methods

    - -
    +

    boundingRadiusCheck

    -
    (
      -
    • - bodyA -
    • -
    • - bodyB -
    • -
    )
    - - Boolean - - - - - - -
    - - -

    - Defined in - - - - src/collision/Broadphase.js:72 -

    - -
    @@ -449,124 +289,75 @@

    boundingRadiusCheck

    -

    Parameters:

      -
    • - bodyA Body - -
      -
    • -
    • - bodyB Body - -
      -
    • -
    - -

    Returns:

    - - Boolean: - -
    - - -
    - -
    +
    +

    boundingRadiusCheck

    -
    (
      -
    • - bodyA -
    • -
    • - bodyB -
    • -
    )
    - - Boolean - - - - - - -
    - - -

    - Defined in - - - - src/collision/Broadphase.js:86 -

    - -
    @@ -574,124 +365,75 @@

    boundingRadiusCheck

    -

    Parameters:

      -
    • - bodyA Body - -
      -
    • -
    • - bodyB Body - -
      -
    • -
    - -

    Returns:

    - - Boolean: - -
    - - -
    - -
    +
    +

    boundingRadiusCheck

    -
    (
      -
    • - bodyA -
    • -
    • - bodyB -
    • -
    )
    - - Boolean - - - - - - -
    @@ -699,124 +441,75 @@

    boundingRadiusCheck

    -

    Parameters:

      -
    • - bodyA Body - -
      -
    • -
    • - bodyB Body - -
      -
    • -
    - -

    Returns:

    - - Boolean: - -
    - - -
    - -
    +
    +

    canCollide

    -
    (
      -
    • - bodyA -
    • -
    • - bodyB -
    • -
    )
    - - Boolean - - - - - - -
    @@ -824,118 +517,72 @@

    canCollide

    -

    Parameters:

      -
    • - bodyA Body - -
      -
    • -
    • - bodyB Body - -
      -
    • -
    - -

    Returns:

    - - Boolean: - -
    - - -
    - -
    +
    +

    getCollisionPairs

    -
    (
      -
    • - world -
    • -
    )
    - - Array - - - - - - -
    - - -

    - Defined in - - - - src/collision/Broadphase.js:60 -

    - -
    @@ -943,102 +590,62 @@

    getCollisionPairs

    -

    Parameters:

      -
    • - world World - -

      The world to search in.

      -
    • -
    - -

    Returns:

    - - Array: -

    An array of the bodies, ordered in pairs. Example: A result of [a,b,c,d] means that the potential pairs are: (a,b), (c,d).

    -
    - - -
    - -
    +
    +

    setWorld

    -
    (
      -
    • - world -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - src/collision/Broadphase.js:51 -

    - -
    @@ -1046,283 +653,163 @@

    setWorld

    -

    Parameters:

      -
    • - world World - -
      -
    • -
    - - - -
    - +
    - -

    Properties

    -
    -

    AABB

    - Number - - - - - - - - - static - - -
    - - - -

    - - Defined in - - - - - src/collision/Broadphase.js:37 - -

    - - - - -
    - -
    -

    Axis aligned bounding box type.

    - -
    - - - - - - -
    - - +

    AABB

    + Number + + + + + static + +
    +

    + Defined in + src/collision/Broadphase.js:37 +

    + + +
    + +
    +

    Axis aligned bounding box type.

    + +
    + + + +
    -

    BOUNDING_CIRCLE

    - Number - - - - - - - - - static - - -
    - - - -

    - - Defined in - - - - - src/collision/Broadphase.js:44 - -

    - - - - -
    - -
    -

    Bounding circle type.

    - -
    - - - - - - -
    - - +

    BOUNDING_CIRCLE

    + Number + + + + + static + +
    +

    + Defined in + src/collision/Broadphase.js:44 +

    + + +
    + +
    +

    Bounding circle type.

    + +
    + + + +
    -

    boundingVolumeType

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/collision/Broadphase.js:30 - -

    - - - - -
    - -
    -

    The bounding volume type to use in the broadphase algorithms.

    - -
    - - - - - - -
    - - +

    boundingVolumeType

    + Number + + + + + +
    +

    + Defined in + src/collision/Broadphase.js:30 +

    + + +
    + +
    +

    The bounding volume type to use in the broadphase algorithms.

    + +
    + + + +
    -

    result

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/collision/Broadphase.js:15 - -

    - - - - -
    - -
    -

    The resulting overlapping pairs. Will be filled with results during .getCollisionPairs().

    - -
    - - - - - - -
    - - +

    result

    + Array + + + + + +
    +

    + Defined in + src/collision/Broadphase.js:15 +

    + + +
    + +
    +

    The resulting overlapping pairs. Will be filled with results during .getCollisionPairs().

    + +
    + + + +
    -

    world

    - World - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/collision/Broadphase.js:22 - -

    - - - - -
    - -
    -

    The world to search for collision pairs in. To change it, use .setWorld()

    - -
    - - - - - - -
    - - +

    world

    + World + + + + + +
    +

    + Defined in + src/collision/Broadphase.js:22 +

    + + +
    + +
    +

    The world to search for collision pairs in. To change it, use .setWorld()

    + +
    + + + +
    - - - - diff --git a/docs/classes/Capsule.html b/docs/classes/Capsule.html index 55a0d513..3c4487fc 100644 --- a/docs/classes/Capsule.html +++ b/docs/classes/Capsule.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,628 +25,413 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    Capsule Class

    +

    Capsule Class

    - -
    Extends Shape
    - - - - -
    -

    Capsule shape class.

    -

    Constructor

    -

    Capsule

    - - -
    - (
      - -
    • - - [length] - -
    • - -
    • - - [radius] - -
    • - -
    ) -
    - - - - - - - - - - - - - - - - -
    +

    Capsule

    + +
    + (
      +
    • + [length=1] +
    • +
    • + [radius=1] +
    • +
    ) +
    - - -

    - - Defined in + + + + + + + +

    +

    + Defined in + src/shapes/Capsule.js:6 +

    + + + +
    + +
    - +
    +
    +

    Parameters:

    - src/shapes/Capsule.js:6 +
      +
    • + [length=1] + Number + optional -

      - - - +
      +

      The distance between the end points

      -
      - -
      +
      -
    - - -
    -

    Parameters:

    - -
      - -
    • - - [length] - Number - optional - - - - -
      -

      The distance between the end points

      - -
      - - -
    • - -
    • - - [radius] - Number - optional - - - - -
      -

      Radius of the capsule

      - +
    • +
    • + [radius=1] + Number + optional + + +
      +

      Radius of the capsule

      + +
      + +
    • +
    +
    + + + +
    +

    Example:

    + +
    +
    var radius = 1;
    +        var length = 2;
    +        var capsuleShape = new Capsule(length, radius);
    +        body.addShape(capsuleShape);
    +        
    - - -
  • - - + - - - - - - - -

    Item Index

    - - -

    Properties

    - - -
    -

    Methods

    - -
    +

    computeAABB

    -
    (
      -
    • - out -
    • -
    • - position -
    • -
    • - angle -
    • -
    )
    - - - - - - - -
    -

    Inherited from Shape - but overwritten in - - - - src/shapes/Capsule.js:63 - + src/shapes/Capsule.js:69

    - -
    -

    Parameters:

      -
    • - out AABB - -

      The resulting AABB.

      -
    • -
    • - position Array - -
      -
    • -
    • - angle Number - -
      -
    • -
    - - - -
    - -
    +
    +

    computeMomentOfInertia

    -
    (
      -
    • - mass -
    • -
    )
    - - Number - - - - - - -
    - -

    Inherited from Shape: - - - - src/shapes/Shape.js:155 - + src/shapes/Shape.js:161

    - -
    @@ -656,105 +439,64 @@

    computeMomentOfInertia

    -

    Parameters:

      -
    • - mass Number - -
      -
    • -
    - -

    Returns:

    - - Number: -

    If the inertia is infinity or if the object simply isn't possible to rotate, return 0.

    -
    - - -
    - -
    +
    +

    conputeMomentOfInertia

    -
    (
      -
    • - mass -
    • -
    )
    - - Number - - - - - - -
    - - -

    - Defined in - - - - - src/shapes/Capsule.js:32 - + src/shapes/Capsule.js:38

    - -
    @@ -762,639 +504,422 @@

    conputeMomentOfInertia

    -

    Parameters:

      -
    • - mass Number - -
      -
    • -
    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    updateArea

    - () - - - - - - - -
    -

    Inherited from Shape - but overwritten in - - - - src/shapes/Capsule.js:54 - + src/shapes/Capsule.js:60

    - -
    - - - -
    - -
    +
    +

    updateBoundingRadius

    - () - - - - - - - -
    -

    Inherited from Shape - but overwritten in - - - - src/shapes/Capsule.js:47 - + src/shapes/Capsule.js:53

    - -
    - - - -
    - +
    - -

    Properties

    -
    -

    area

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:89 - -

    - - - - -
    - -
    -

    Area of this shape.

    - -
    - - - - - - -
    - - +

    area

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:95 +

    + + +
    + +
    +

    Area of this shape.

    + +
    + + + +
    -

    boundingRadius

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:34 - -

    - - - - -
    - -
    -

    Bounding circle radius of this shape

    - -
    - - - - - - -
    - - +

    boundingRadius

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:34 +

    + + +
    + +
    +

    Bounding circle radius of this shape

    + +
    + + + +
    -

    collisionGroup

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:41 - -

    - - - - -
    - -
    -

    Collision group that this shape belongs to (bit mask). See this tutorial.

    - -
    - - - - -
    -

    Example:

    - -
    -
    // Setup bits for each available group
    -var PLAYER = Math.pow(2,0),
    -    ENEMY =  Math.pow(2,1),
    -    GROUND = Math.pow(2,2)
    -
    -// Put shapes into their groups
    -player1Shape.collisionGroup = PLAYER;
    -player2Shape.collisionGroup = PLAYER;
    -enemyShape  .collisionGroup = ENEMY;
    -groundShape .collisionGroup = GROUND;
    -
    -// Assign groups that each shape collide with.
    -// Note that the players can collide with ground and enemies, but not with other players.
    -player1Shape.collisionMask = ENEMY | GROUND;
    -player2Shape.collisionMask = ENEMY | GROUND;
    -enemyShape  .collisionMask = PLAYER | GROUND;
    -groundShape .collisionMask = PLAYER | ENEMY;
    -
    // How collision check is done
    -if(shapeA.collisionGroup & shapeB.collisionMask)!=0 && (shapeB.collisionGroup & shapeA.collisionMask)!=0){
    -    // The shapes will collide
    -}
    - -
    -
    - - - -
    - - +

    collisionGroup

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:41 +

    + + +
    + +
    +

    Collision group that this shape belongs to (bit mask). See this tutorial.

    + +
    + + +
    +

    Example:

    + +
    +
    // Setup bits for each available group
    +                    var PLAYER = Math.pow(2,0),
    +                        ENEMY =  Math.pow(2,1),
    +                        GROUND = Math.pow(2,2)
    +                    
    +                    // Put shapes into their groups
    +                    player1Shape.collisionGroup = PLAYER;
    +                    player2Shape.collisionGroup = PLAYER;
    +                    enemyShape  .collisionGroup = ENEMY;
    +                    groundShape .collisionGroup = GROUND;
    +                    
    +                    // Assign groups that each shape collide with.
    +                    // Note that the players can collide with ground and enemies, but not with other players.
    +                    player1Shape.collisionMask = ENEMY | GROUND;
    +                    player2Shape.collisionMask = ENEMY | GROUND;
    +                    enemyShape  .collisionMask = PLAYER | GROUND;
    +                    groundShape .collisionMask = PLAYER | ENEMY;
    +                    
    // How collision check is done
    +                    if(shapeA.collisionGroup & shapeB.collisionMask)!=0 && (shapeB.collisionGroup & shapeA.collisionMask)!=0){
    +                        // The shapes will collide
    +                    }
    +                    
    +
    +
    + +
    -

    collisionMask

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:72 - -

    - - - - -
    - -
    -

    Collision mask of this shape. See .collisionGroup.

    - -
    - - - - - - -
    - - +

    collisionMask

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:78 +

    + + +
    + +
    +

    Collision mask of this shape. See .collisionGroup.

    + +
    + + + + +
    +

    collisionResponse

    + Boolean + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:72 +

    + + +
    + +
    +

    Whether to produce contact forces when in contact with other bodies. Note that contacts will be generated, but they will be disabled. That means that this shape will move through other body shapes, but it will still trigger contact events, etc.

    + +
    + + + +
    -

    id

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:27 - -

    - - - - -
    - -
    -

    Shape object identifier.

    - -
    - - - - - - -
    - - +

    id

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:27 +

    + + +
    + +
    +

    Shape object identifier.

    + +
    + + + +
    -

    length

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/shapes/Capsule.js:16 - -

    - - - - -
    - -
    -

    The distance between the end points.

    - -
    - - - - - - -
    - - +

    length

    + Number + + + + + +
    +

    + Defined in + src/shapes/Capsule.js:21 +

    + + +
    + +
    +

    The distance between the end points.

    + +
    + + + +
    -

    material

    - Material - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:82 - -

    - - - - -
    - -
    -

    Material to use in collisions for this Shape. If this is set to null, the world will use default material properties instead.

    - -
    - - - - - - -
    - - +

    material

    + Material + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:88 +

    + + +
    + +
    +

    Material to use in collisions for this Shape. If this is set to null, the world will use default material properties instead.

    + +
    + + + +
    -

    radius

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/shapes/Capsule.js:22 - -

    - - - - -
    - -
    -

    The radius of the capsule.

    - -
    - - - - - - -
    - - +

    radius

    + Number + + + + + +
    +

    + Defined in + src/shapes/Capsule.js:27 +

    + + +
    + +
    +

    The radius of the capsule.

    + +
    + + + +
    -

    sensor

    - Boolean - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:96 - -

    - - - - -
    - -
    -

    Set to true if you want this shape to be a sensor. A sensor does not generate contacts, but it still reports contact events. This is good if you want to know if a shape is overlapping another shape, without them generating contacts.

    - -
    - - - - - - -
    - - +

    sensor

    + Boolean + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:102 +

    + + +
    + +
    +

    Set to true if you want this shape to be a sensor. A sensor does not generate contacts, but it still reports contact events. This is good if you want to know if a shape is overlapping another shape, without them generating contacts.

    + +
    + + + +
    -

    type

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:11 - -

    - - - - -
    - - - - - - - - -
    - - +

    type

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:11 +

    + + +
    + + + + + + - - - - diff --git a/docs/classes/Circle.html b/docs/classes/Circle.html index cd3a61c8..d2b6b2c2 100644 --- a/docs/classes/Circle.html +++ b/docs/classes/Circle.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,1220 +25,809 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    Circle Class

    +

    Circle Class

    - -
    Extends Shape
    - - - - -
    -

    Circle shape class.

    -

    Constructor

    -

    Circle

    - - -
    - (
      - -
    • - - [radius=1] - -
    • - -
    ) -
    - - - - - - - - - - - - - - - - -
    +

    Circle

    + +
    + (
      +
    • + [radius=1] +
    • +
    ) +
    - - -

    - - Defined in + + + + + + + +

    +

    + Defined in + src/shapes/Circle.js:6 +

    + + + +
    + +
    - +
    +
    +

    Parameters:

    - src/shapes/Circle.js:6 +
      +
    • + [radius=1] + Number + optional -

      - - - +
      +

      The radius of this circle

      -
      - -
      +
      -
    - - -
    -

    Parameters:

    - -
      - -
    • - - [radius=1] - Number - optional - - - - -
      -

      The radius of this circle

      - +
    • +
    +
    + + + +
    +

    Example:

    + +
    +
    var radius = 1;
    +        var circleShape = new Circle(radius);
    +        body.addShape(circleShape);
    +        
    - - - - - +
    - - - - - -
    -
    -

    Item Index

    - - -

    Properties

    - - -
    -

    Methods

    - -
    +

    computeAABB

    -
    (
      -
    • - out -
    • -
    • - position -
    • -
    • - angle -
    • -
    )
    - - - - - - - -
    -

    Inherited from Shape - but overwritten in - - - - src/shapes/Circle.js:52 - + src/shapes/Circle.js:58

    - -
    -

    Parameters:

      -
    • - out AABB - -

      The resulting AABB.

      -
    • -
    • - position Array - -
      -
    • -
    • - angle Number - -
      -
    • -
    - - - -
    - -
    +
    +

    computeMomentOfInertia

    -
    (
      -
    • - mass -
    • -
    )
    - - Number - - - - - - -
    -

    Inherited from Shape - but overwritten in - - - - src/shapes/Circle.js:26 - + src/shapes/Circle.js:32

    - -
    -

    Parameters:

      -
    • - mass Number - -
      -
    • -
    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    updateArea

    - () - - Number - - - - - - -
    -

    Inherited from Shape - but overwritten in - - - - src/shapes/Circle.js:44 - + src/shapes/Circle.js:50

    - -
    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    updateBoundingRadius

    - () - - Number - - - - - - -
    -

    Inherited from Shape - but overwritten in - - - - src/shapes/Circle.js:36 - + src/shapes/Circle.js:42

    - -
    - -

    Returns:

    - - Number: - -
    - - -
    - +
    - -

    Properties

    -
    -

    area

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:89 - -

    - - - - -
    - -
    -

    Area of this shape.

    - -
    - - - - - - -
    - - +

    area

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:95 +

    + + +
    + +
    +

    Area of this shape.

    + +
    + + + +
    -

    boundingRadius

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:34 - -

    - - - - -
    - -
    -

    Bounding circle radius of this shape

    - -
    - - - - - - -
    - - +

    boundingRadius

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:34 +

    + + +
    + +
    +

    Bounding circle radius of this shape

    + +
    + + + +
    -

    collisionGroup

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:41 - -

    - - - - -
    - -
    -

    Collision group that this shape belongs to (bit mask). See this tutorial.

    - -
    - - - - -
    -

    Example:

    - -
    -
    // Setup bits for each available group
    -var PLAYER = Math.pow(2,0),
    -    ENEMY =  Math.pow(2,1),
    -    GROUND = Math.pow(2,2)
    -
    -// Put shapes into their groups
    -player1Shape.collisionGroup = PLAYER;
    -player2Shape.collisionGroup = PLAYER;
    -enemyShape  .collisionGroup = ENEMY;
    -groundShape .collisionGroup = GROUND;
    -
    -// Assign groups that each shape collide with.
    -// Note that the players can collide with ground and enemies, but not with other players.
    -player1Shape.collisionMask = ENEMY | GROUND;
    -player2Shape.collisionMask = ENEMY | GROUND;
    -enemyShape  .collisionMask = PLAYER | GROUND;
    -groundShape .collisionMask = PLAYER | ENEMY;
    -
    // How collision check is done
    -if(shapeA.collisionGroup & shapeB.collisionMask)!=0 && (shapeB.collisionGroup & shapeA.collisionMask)!=0){
    -    // The shapes will collide
    -}
    - -
    -
    - - - -
    - - +

    collisionGroup

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:41 +

    + + +
    + +
    +

    Collision group that this shape belongs to (bit mask). See this tutorial.

    + +
    + + +
    +

    Example:

    + +
    +
    // Setup bits for each available group
    +                    var PLAYER = Math.pow(2,0),
    +                        ENEMY =  Math.pow(2,1),
    +                        GROUND = Math.pow(2,2)
    +                    
    +                    // Put shapes into their groups
    +                    player1Shape.collisionGroup = PLAYER;
    +                    player2Shape.collisionGroup = PLAYER;
    +                    enemyShape  .collisionGroup = ENEMY;
    +                    groundShape .collisionGroup = GROUND;
    +                    
    +                    // Assign groups that each shape collide with.
    +                    // Note that the players can collide with ground and enemies, but not with other players.
    +                    player1Shape.collisionMask = ENEMY | GROUND;
    +                    player2Shape.collisionMask = ENEMY | GROUND;
    +                    enemyShape  .collisionMask = PLAYER | GROUND;
    +                    groundShape .collisionMask = PLAYER | ENEMY;
    +                    
    // How collision check is done
    +                    if(shapeA.collisionGroup & shapeB.collisionMask)!=0 && (shapeB.collisionGroup & shapeA.collisionMask)!=0){
    +                        // The shapes will collide
    +                    }
    +                    
    +
    +
    + +
    -

    collisionMask

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:72 - -

    - - - - -
    - -
    -

    Collision mask of this shape. See .collisionGroup.

    - -
    - - - - - - -
    - - +

    collisionMask

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:78 +

    + + +
    + +
    +

    Collision mask of this shape. See .collisionGroup.

    + +
    + + + +
    +
    +

    collisionResponse

    + Boolean + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:72 +

    + + +
    + +
    +

    Whether to produce contact forces when in contact with other bodies. Note that contacts will be generated, but they will be disabled. That means that this shape will move through other body shapes, but it will still trigger contact events, etc.

    + +
    + + + +
    -

    id

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:27 - -

    - - - - -
    - -
    -

    Shape object identifier.

    - -
    - - - - - - -
    - - +

    id

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:27 +

    + + +
    + +
    +

    Shape object identifier.

    + +
    + + + +
    -

    material

    - Material - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:82 - -

    - - - - -
    - -
    -

    Material to use in collisions for this Shape. If this is set to null, the world will use default material properties instead.

    - -
    - - - - - - -
    - - +

    material

    + Material + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:88 +

    + + +
    + +
    +

    Material to use in collisions for this Shape. If this is set to null, the world will use default material properties instead.

    + +
    + + + +
    -

    radius

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/shapes/Circle.js:15 - -

    - - - - -
    - -
    -

    The radius of the circle.

    - -
    - - - - - - -
    - - +

    radius

    + Number + + + + + +
    +

    + Defined in + src/shapes/Circle.js:20 +

    + + +
    + +
    +

    The radius of the circle.

    + +
    + + + +
    -

    sensor

    - Boolean - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:96 - -

    - - - - -
    - -
    -

    Set to true if you want this shape to be a sensor. A sensor does not generate contacts, but it still reports contact events. This is good if you want to know if a shape is overlapping another shape, without them generating contacts.

    - -
    - - - - - - -
    - - +

    sensor

    + Boolean + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:102 +

    + + +
    + +
    +

    Set to true if you want this shape to be a sensor. A sensor does not generate contacts, but it still reports contact events. This is good if you want to know if a shape is overlapping another shape, without them generating contacts.

    + +
    + + + +
    -

    type

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:11 - -

    - - - - -
    - - - - - - - - -
    - - +

    type

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:11 +

    + + +
    + + + + + + - - - - diff --git a/docs/classes/Constraint.html b/docs/classes/Constraint.html index 8d8a546e..d42f2a7f 100644 --- a/docs/classes/Constraint.html +++ b/docs/classes/Constraint.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,494 +25,342 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    Constraint Class

    +

    Constraint Class

    - - - - - -
    -

    Base constraint class.

    -

    Constructor

    -

    Constraint

    - - -
    - (
      - -
    • - - bodyA - -
    • - -
    • - - bodyB - -
    • - -
    • - - type - -
    • - -
    • - - [options] - -
    • - -
    ) -
    - - - - - - - - - - - - - - - - -
    +

    Constraint

    + +
    + (
      +
    • + bodyA +
    • +
    • + bodyB +
    • +
    • + type +
    • +
    • + [options] +
    • +
    ) +
    - - -

    - - Defined in + + + + + + + +

    +

    + Defined in + src/constraints/Constraint.js:5 +

    + + + +
    + +
    - +
    +
    +

    Parameters:

    - src/constraints/Constraint.js:5 +
      +
    • + bodyA + Body -

      - - - +
      + +
      + +
    • +
    • + bodyB + Body + + +
      + +
      + +
    • +
    • + type + Number + + +
      + +
      + +
    • +
    • + [options] + Object + optional + + +
      + +
      + +
        +
      • + [collideConnected=true] + Object + optional + +
        + +
        + +
      • +
      +
    • +
    +
    + -
    - -
    -
    - - -
    -

    Parameters:

    - -
      - -
    • - - bodyA - Body - - - - -
      - -
      - - -
    • - -
    • - - bodyB - Body - - - - -
      - -
      - - -
    • - -
    • - - type - Number - - - - -
      - -
      - - -
    • - -
    • - - [options] - Object - optional - - - - -
      - -
      - - -
        - -
      • - - [collideConnected=true] - Object - optional - - -
        - -
        - - -
      • - -
      - -
    • - -
    - - - - - -
    -
    -

    Item Index

    -

    Methods

    - -

    Properties

    - - -
    -

    Methods

    - -
    +

    setRelaxation

    -
    (
      -
    • - relaxation -
    • -
    )
    - - - - - - - -
    @@ -522,87 +368,52 @@

    setRelaxation

    -

    Parameters:

      -
    • - relaxation Number - -
      -
    • -
    - - - -
    - -
    +
    +

    setStiffness

    -
    (
      -
    • - stiffness -
    • -
    )
    - - - - - - - -
    @@ -610,77 +421,46 @@

    setStiffness

    -

    Parameters:

      -
    • - stiffness Number - -
      -
    • -
    - - - -
    - -
    +
    +

    update

    - () - - - - - - - -
    @@ -688,213 +468,271 @@

    update

    - - - -
    - +
    - -

    Properties

    -
    -

    bodyA

    - Body - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/constraints/Constraint.js:33 - -

    - - - - -
    - -
    -

    First body participating in the constraint.

    - -
    - - - - - - -
    - - +

    bodyA

    + Body + + + + + +
    +

    + Defined in + src/constraints/Constraint.js:38 +

    + + +
    + +
    +

    First body participating in the constraint.

    + +
    + + + +
    -

    bodyB

    - Body - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/constraints/Constraint.js:40 - -

    - - - - -
    - -
    -

    Second body participating in the constraint.

    - -
    - - - - - - -
    - - +

    bodyB

    + Body + + + + + +
    +

    + Defined in + src/constraints/Constraint.js:45 +

    + + +
    + +
    +

    Second body participating in the constraint.

    + +
    + + + +
    -

    collideConnected

    - Boolean - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/constraints/Constraint.js:47 - -

    - - - - -
    - -
    -

    Set to true if you want the connected bodies to collide.

    - -
    - - -

    Default: true

    - - - - - -
    - - +

    collideConnected

    + Boolean + + + + + +
    +

    + Defined in + src/constraints/Constraint.js:52 +

    + + +
    + +
    +

    Set to true if you want the connected bodies to collide.

    + +
    + +

    Default: true

    + + +
    +
    +

    DISTANCE

    + Number + + + + + static + +
    +

    + Defined in + src/constraints/Constraint.js:79 +

    + + +
    + +
    + +
    + + + +
    -

    equations

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/constraints/Constraint.js:25 - -

    - - - - -
    - -
    -

    Equations to be solved in this constraint

    - -
    - - - - - - -
    - - +

    equations

    + Array + + + + + +
    +

    + Defined in + src/constraints/Constraint.js:30 +

    + + +
    + +
    +

    Equations to be solved in this constraint

    + +
    + + + +
    +
    +

    GEAR

    + Number + + + + + static + +
    +

    + Defined in + src/constraints/Constraint.js:85 +

    + + +
    + +
    + +
    + + + +
    +
    +

    LOCK

    + Number + + + + + static + +
    +

    + Defined in + src/constraints/Constraint.js:91 +

    + + +
    + +
    + +
    + + + +
    +
    +

    PRISMATIC

    + Number + + + + + static + +
    +

    + Defined in + src/constraints/Constraint.js:97 +

    + + +
    + +
    + +
    + + + +
    +
    +

    REVOLUTE

    + Number + + + + + static + +
    +

    + Defined in + src/constraints/Constraint.js:103 +

    + + +
    + +
    + +
    + + + +
    +
    +

    type

    + Number + + + + + +
    +

    + Defined in + src/constraints/Constraint.js:19 +

    + + +
    + +
    +

    The type of constraint. May be one of Constraint.DISTANCE, Constraint.GEAR, Constraint.LOCK, Constraint.PRISMATIC or Constraint.REVOLUTE.

    + +
    + + + +
    - - -
    - diff --git a/docs/classes/ContactEquation.html b/docs/classes/ContactEquation.html index 974f62cb..a2d2dcdb 100644 --- a/docs/classes/ContactEquation.html +++ b/docs/classes/ContactEquation.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,581 +25,361 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    ContactEquation Class

    +

    ContactEquation Class

    - -
    Extends Equation
    - - - - -
    -

    Non-penetration constraint equation. Tries to make the contactPointA and contactPointB vectors coincide, while keeping the applied force repulsive.

    -

    Constructor

    -

    ContactEquation

    - - -
    - (
      - -
    • - - bodyA - -
    • - -
    • - - bodyB - -
    • - -
    ) -
    - - - - - - - - - - - - - - - - -
    +

    ContactEquation

    + +
    + (
      +
    • + bodyA +
    • +
    • + bodyB +
    • +
    ) +
    - - -

    - - Defined in + + + + + + + +

    +

    + Defined in + src/equations/ContactEquation.js:6 +

    + + + +
    + +
    - +
    +
    +

    Parameters:

    - src/equations/ContactEquation.js:6 +
      +
    • + bodyA + Body -

      - - - +
      + +
      + +
    • +
    • + bodyB + Body + + +
      + +
      + +
    • +
    +
    + -
    - -
    -
    - - -
    -

    Parameters:

    - -
      - -
    • - - bodyA - Body - - - - -
      - -
      - - -
    • - -
    • - - bodyB - Body - - - - -
      - -
      - - -
    • - -
    - - - - - -
    -
    -

    Item Index

    -

    Methods

    - -

    Properties

    - - -
    -

    Methods

    - -
    +

    addToWlambda

    -
    (
      -
    • - deltalambda -
    • -
    )
    - - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:268 -

    - -
    @@ -609,78 +387,49 @@

    addToWlambda

    -

    Parameters:

      -
    • - deltalambda Number - -
      -
    • -
    - - - -
    - -
    +
    +

    computeB

    - () - - Number - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:150 -

    - -
    @@ -688,67 +437,40 @@

    computeB

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    computeGiMf

    - () - - Number - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:213 -

    - -
    @@ -756,67 +478,40 @@

    computeGiMf

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    computeGiMGt

    - () - - Number - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:239 -

    - -
    @@ -824,67 +519,40 @@

    computeGiMGt

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    computeGq

    - () - - Number - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:162 -

    - -
    @@ -892,67 +560,40 @@

    computeGq

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    computeGW

    - () - - Number - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:181 -

    - -
    @@ -960,67 +601,40 @@

    computeGW

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    computeGWlambda

    - () - - Number - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:197 -

    - -
    @@ -1028,77 +642,46 @@

    computeGWlambda

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    computeInvC

    -
    (
      -
    • - eps -
    • -
    )
    - - Number - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:309 -

    - -
    @@ -1106,90 +689,56 @@

    computeInvC

    -

    Parameters:

      -
    • - eps Number - -
      -
    • -
    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    gmult

    - () - - Number - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:136 -

    - -
    @@ -1197,63 +746,37 @@

    gmult

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    update

    - () - - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:120 -

    - -
    @@ -1261,808 +784,470 @@

    update

    - - - -
    - +
    - -

    Properties

    -
    -

    bodyA

    - Body - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:32 - -

    - - - - -
    - -
    -

    First body participating in the constraint

    - -
    - - - - - - -
    - - +

    bodyA

    + Body + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:32 +

    + + +
    + +
    +

    First body participating in the constraint

    + +
    + + + +
    -

    bodyB

    - Body - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:39 - -

    - - - - -
    - -
    -

    Second body participating in the constraint

    - -
    - - - - - - -
    - - +

    bodyB

    + Body + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:39 +

    + + +
    + +
    +

    Second body participating in the constraint

    + +
    + + + +
    -

    contactPointA

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/equations/ContactEquation.js:18 - -

    - - - - -
    - -
    -

    Vector from body i center of mass to the contact point.

    - -
    - - - - - - -
    - - +

    contactPointA

    + Array + + + + + +
    +

    + Defined in + src/equations/ContactEquation.js:18 +

    + + +
    + +
    +

    Vector from body i center of mass to the contact point.

    + +
    + + + +
    -

    contactPointB

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/equations/ContactEquation.js:26 - -

    - - - - -
    - -
    -

    World-oriented vector from body A center of mass to the contact point.

    - -
    - - - - - - -
    - - +

    contactPointB

    + Array + + + + + +
    +

    + Defined in + src/equations/ContactEquation.js:26 +

    + + +
    + +
    +

    World-oriented vector from body A center of mass to the contact point.

    + +
    + + + +
    -

    enabled

    - Boolean - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:96 - -

    - - - - -
    - -
    -

    Whether this equation is enabled or not. If true, it will be added to the solver.

    - -
    - - - - - - -
    - - +

    enabled

    + Boolean + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:96 +

    + + +
    + +
    +

    Whether this equation is enabled or not. If true, it will be added to the solver.

    + +
    + + + +
    -

    firstImpact

    - Boolean - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/equations/ContactEquation.js:47 - -

    - - - - -
    - -
    -

    This property is set to true if this is the first impact between the bodies (not persistant contact).

    - -
    - - - - - - -
    - - +

    firstImpact

    + Boolean + + + + + +
    +

    + Defined in + src/equations/ContactEquation.js:47 +

    + + +
    + +
    +

    This property is set to true if this is the first impact between the bodies (not persistant contact).

    + +
    + + + +
    -

    G

    - Array - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:60 - -

    - - - - -
    - -
    -

    The Jacobian entry of this equation. 6 numbers, 3 per body (x,y,angle).

    - -
    - - - - - - -
    - - +

    G

    + Array + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:60 +

    + + +
    + +
    +

    The Jacobian entry of this equation. 6 numbers, 3 per body (x,y,angle).

    + +
    + + + +
    -

    maxForce

    - Number - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:25 - -

    - - - - -
    - -
    -

    Max force to apply when solving.

    - -
    - - - - - - -
    - - +

    maxForce

    + Number + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:25 +

    + + +
    + +
    +

    Max force to apply when solving.

    + +
    + + + +
    -

    minForce

    - Number - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:18 - -

    - - - - -
    - -
    -

    Minimum force to apply when solving.

    - -
    - - - - - - -
    - - +

    minForce

    + Number + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:18 +

    + + +
    + +
    +

    Minimum force to apply when solving.

    + +
    + + + +
    -

    multiplier

    - Number - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:83 - -

    - - - - -
    - -
    -

    The resulting constraint multiplier from the last solve. This is mostly equivalent to the force produced by the constraint.

    - -
    - - - - - - -
    - - +

    multiplier

    + Number + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:83 +

    + + +
    + +
    +

    The resulting constraint multiplier from the last solve. This is mostly equivalent to the force produced by the constraint.

    + +
    + + + +
    -

    needsUpdate

    - Boolean - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:77 - -

    - - - - -
    - -
    -

    Indicates if stiffness or relaxation was changed.

    - -
    - - - - - - -
    - - -
    -

    normalA

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/equations/ContactEquation.js:33 - -

    - - - - -
    - -
    -

    The normal vector, pointing out of body i

    - -
    - - - - - - -
    - - -
    -

    relativeVelocity

    - Number - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:90 - -

    - - - - -
    - -
    -

    Relative velocity.

    - -
    - - - - - - -
    - - +

    needsUpdate

    + Boolean + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:77 +

    + + +
    + +
    +

    Indicates if stiffness or relaxation was changed.

    + +
    + + + + +
    +

    normalA

    + Array + + + + + +
    +

    + Defined in + src/equations/ContactEquation.js:33 +

    + + +
    + +
    +

    The normal vector, pointing out of body i

    + +
    + + + +
    +
    +

    relativeVelocity

    + Number + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:90 +

    + + +
    + +
    +

    Relative velocity.

    + +
    + + + +
    -

    relaxation

    - Number - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:53 - -

    - - - - -
    - -
    -

    The number of time steps needed to stabilize the constraint equation. Typically between 3 and 5 time steps.

    - -
    - - - - - - -
    - - +

    relaxation

    + Number + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:53 +

    + + +
    + +
    +

    The number of time steps needed to stabilize the constraint equation. Typically between 3 and 5 time steps.

    + +
    + + + +
    -

    restitution

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/equations/ContactEquation.js:40 - -

    - - - - -
    - -
    -

    The restitution to use (0=no bounciness, 1=max bounciness).

    - -
    - - - - - - -
    - - +

    restitution

    + Number + + + + + +
    +

    + Defined in + src/equations/ContactEquation.js:40 +

    + + +
    + +
    +

    The restitution to use (0=no bounciness, 1=max bounciness).

    + +
    + + + +
    -

    shapeA

    - Shape - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/equations/ContactEquation.js:55 - -

    - - - - -
    - -
    -

    The shape in body i that triggered this contact.

    - -
    - - - - - - -
    - - +

    shapeA

    + Shape + + + + + +
    +

    + Defined in + src/equations/ContactEquation.js:55 +

    + + +
    + +
    +

    The shape in body i that triggered this contact.

    + +
    + + + +
    -

    shapeB

    - Shape - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/equations/ContactEquation.js:62 - -

    - - - - -
    - -
    -

    The shape in body j that triggered this contact.

    - -
    - - - - - - -
    - - +

    shapeB

    + Shape + + + + + +
    +

    + Defined in + src/equations/ContactEquation.js:62 +

    + + +
    + +
    +

    The shape in body j that triggered this contact.

    + +
    + + + +
    -

    stiffness

    - Number - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:46 - -

    - - - - -
    - -
    -

    The stiffness of this equation. Typically chosen to a large number (~1e7), but can be chosen somewhat freely to get a stable simulation.

    - -
    - - - - - - -
    - - +

    stiffness

    + Number + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:46 +

    + + +
    + +
    +

    The stiffness of this equation. Typically chosen to a large number (~1e7), but can be chosen somewhat freely to get a stable simulation.

    + +
    + + + + - - - - diff --git a/docs/classes/ContactMaterial.html b/docs/classes/ContactMaterial.html index 3865af10..5b4c0a4f 100644 --- a/docs/classes/ContactMaterial.html +++ b/docs/classes/ContactMaterial.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,1038 +25,631 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    ContactMaterial Class

    +

    ContactMaterial Class

    - - - - - -
    -

    Defines what happens when two materials meet, such as what friction coefficient to use. You can also set other things such as restitution, surface velocity and constraint parameters.

    -

    Constructor

    -

    ContactMaterial

    - - -
    - (
      - -
    • - - materialA - -
    • - -
    • - - materialB - -
    • - -
    • - - [options] - -
    • - -
    ) -
    - - - - - - - - - - - - - - - - -
    +

    ContactMaterial

    + +
    + (
      +
    • + materialA +
    • +
    • + materialB +
    • +
    • + [options] +
    • +
    ) +
    - - -

    - - Defined in + + + + + + + +

    +

    + Defined in + src/material/ContactMaterial.js:6 +

    + + + +
    + +
    - +
    +
    +

    Parameters:

    - src/material/ContactMaterial.js:6 +
      +
    • + materialA + Material -

      - - - +
      + +
      + +
    • +
    • + materialB + Material + + +
      + +
      + +
    • +
    • + [options] + Object + optional + + +
      + +
      + +
        +
      • + [friction=0.3] + Number + optional + +
        +

        Friction coefficient.

        + +
        + +
      • +
      • + [restitution=0] + Number + optional + +
        +

        Restitution coefficient aka "bounciness".

        + +
        + +
      • +
      • + [stiffness] + Number + optional + +
        +

        ContactEquation stiffness.

        + +
        + +
      • +
      • + [relaxation] + Number + optional + +
        +

        ContactEquation relaxation.

        + +
        + +
      • +
      • + [frictionStiffness] + Number + optional + +
        +

        FrictionEquation stiffness.

        + +
        + +
      • +
      • + [frictionRelaxation] + Number + optional + +
        +

        FrictionEquation relaxation.

        + +
        + +
      • +
      • + [surfaceVelocity=0] + Number + optional + +
        +

        Surface velocity.

        + +
        + +
      • +
      +
    • +
    +
    + -
    - -
    -
    - - -
    -

    Parameters:

    - -
      - -
    • - - materialA - Material - - - - -
      - -
      - - -
    • - -
    • - - materialB - Material - - - - -
      - -
      - - -
    • - -
    • - - [options] - Object - optional - - - - -
      - -
      - - -
        - -
      • - - [friction=0.3] - Number - optional - - -
        -

        Friction coefficient.

        - -
        - - -
      • - -
      • - - [restitution=0] - Number - optional - - -
        -

        Restitution coefficient aka "bounciness".

        - -
        - - -
      • - -
      • - - [stiffness] - Number - optional - - -
        -

        ContactEquation stiffness.

        - -
        - - -
      • - -
      • - - [relaxation] - Number - optional - - -
        -

        ContactEquation relaxation.

        - -
        - - -
      • - -
      • - - [frictionStiffness] - Number - optional - - -
        -

        FrictionEquation stiffness.

        - -
        - - -
      • - -
      • - - [frictionRelaxation] - Number - optional - - -
        -

        FrictionEquation relaxation.

        - -
        - - -
      • - -
      • - - [surfaceVelocity=0] - Number - optional - - -
        -

        Surface velocity.

        - -
        - - -
      • - -
      - -
    • - -
    - - - - - -
    -
    -

    Item Index

    - -

    Properties

    - - -
    - -

    Properties

    -
    -

    contactSkinSize

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/material/ContactMaterial.js:98 - -

    - - - - -
    - -
    -

    Offset to be set on ContactEquations. A positive value will make the bodies penetrate more into each other. Can be useful in scenes where contacts need to be more persistent, for example when stacking. Aka "cure for nervous contacts".

    - -
    - - - - - - -
    - - -
    -

    friction

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/material/ContactMaterial.js:50 - -

    - - - - -
    - -
    -

    Friction to use in the contact of these two materials

    - -
    - - - - - - -
    - - +

    contactSkinSize

    + Number + + + + + +
    +

    + Defined in + src/material/ContactMaterial.js:98 +

    + + +
    + +
    +

    Offset to be set on ContactEquations. A positive value will make the bodies penetrate more into each other. Can be useful in scenes where contacts need to be more persistent, for example when stacking. Aka "cure for nervous contacts".

    + +
    + + + +
    +
    +

    friction

    + Number + + + + + +
    +

    + Defined in + src/material/ContactMaterial.js:50 +

    + + +
    + +
    +

    Friction to use in the contact of these two materials

    + +
    + + + +
    -

    frictionRelaxation

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/material/ContactMaterial.js:85 - -

    - - - - -
    - -
    -

    Relaxation of the resulting FrictionEquation that this ContactMaterial generate

    - -
    - - - - - - -
    - - +

    frictionRelaxation

    + Number + + + + + +
    +

    + Defined in + src/material/ContactMaterial.js:85 +

    + + +
    + +
    +

    Relaxation of the resulting FrictionEquation that this ContactMaterial generate

    + +
    + + + +
    -

    frictionStiffness

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/material/ContactMaterial.js:78 - -

    - - - - -
    - -
    -

    Stiffness of the resulting FrictionEquation that this ContactMaterial generate

    - -
    - - - - - - -
    - - +

    frictionStiffness

    + Number + + + + + +
    +

    + Defined in + src/material/ContactMaterial.js:78 +

    + + +
    + +
    +

    Stiffness of the resulting FrictionEquation that this ContactMaterial generate

    + +
    + + + +
    -

    id

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/material/ContactMaterial.js:29 - -

    - - - - -
    - -
    -

    The contact material identifier

    - -
    - - - - - - -
    - - +

    id

    + Number + + + + + +
    +

    + Defined in + src/material/ContactMaterial.js:29 +

    + + +
    + +
    +

    The contact material identifier

    + +
    + + + +
    -

    materialA

    - Material - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/material/ContactMaterial.js:36 - -

    - - - - -
    - -
    -

    First material participating in the contact material

    - -
    - - - - - - -
    - - +

    materialA

    + Material + + + + + +
    +

    + Defined in + src/material/ContactMaterial.js:36 +

    + + +
    + +
    +

    First material participating in the contact material

    + +
    + + + +
    -

    materialB

    - Material - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/material/ContactMaterial.js:43 - -

    - - - - -
    - -
    -

    Second material participating in the contact material

    - -
    - - - - - - -
    - - +

    materialB

    + Material + + + + + +
    +

    + Defined in + src/material/ContactMaterial.js:43 +

    + + +
    + +
    +

    Second material participating in the contact material

    + +
    + + + +
    -

    relaxation

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/material/ContactMaterial.js:71 - -

    - - - - -
    - -
    -

    Relaxation of the resulting ContactEquation that this ContactMaterial generate

    - -
    - - - - - - -
    - - +

    relaxation

    + Number + + + + + +
    +

    + Defined in + src/material/ContactMaterial.js:71 +

    + + +
    + +
    +

    Relaxation of the resulting ContactEquation that this ContactMaterial generate

    + +
    + + + +
    -

    restitution

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/material/ContactMaterial.js:57 - -

    - - - - -
    - -
    -

    Restitution to use in the contact of these two materials

    - -
    - - - - - - -
    - - +

    restitution

    + Number + + + + + +
    +

    + Defined in + src/material/ContactMaterial.js:57 +

    + + +
    + +
    +

    Restitution to use in the contact of these two materials

    + +
    + + + +
    -

    stiffness

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/material/ContactMaterial.js:64 - -

    - - - - -
    - -
    -

    Stiffness of the resulting ContactEquation that this ContactMaterial generate

    - -
    - - - - - - -
    - - +

    stiffness

    + Number + + + + + +
    +

    + Defined in + src/material/ContactMaterial.js:64 +

    + + +
    + +
    +

    Stiffness of the resulting ContactEquation that this ContactMaterial generate

    + +
    + + + +
    -

    surfaceVelocity

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/material/ContactMaterial.js:92 - -

    - - - - -
    - -
    -

    Will add surface velocity to this material. If bodyA rests on top if bodyB, and the surface velocity is positive, bodyA will slide to the right.

    - -
    - - - - - - -
    - - +

    surfaceVelocity

    + Number + + + + + +
    +

    + Defined in + src/material/ContactMaterial.js:92 +

    + + +
    + +
    +

    Will add surface velocity to this material. If bodyA rests on top if bodyB, and the surface velocity is positive, bodyA will slide to the right.

    + +
    + + + + - - - - diff --git a/docs/classes/Convex.html b/docs/classes/Convex.html index ef1c2668..3260e9c9 100644 --- a/docs/classes/Convex.html +++ b/docs/classes/Convex.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,667 +25,436 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    Convex Class

    +

    Convex Class

    - -
    Extends Shape
    - - - - -
    -

    Convex shape class.

    -

    Constructor

    -

    Convex

    - - -
    - (
      - -
    • - - vertices - -
    • - -
    • - - axes - -
    • - -
    ) -
    - - - - - - - - - - - - - - - - -
    +

    Convex

    + +
    + (
      +
    • + vertices +
    • +
    • + [axes] +
    • +
    ) +
    - - -

    - - Defined in + + + + + + + +

    +

    + Defined in + src/shapes/Convex.js:8 +

    + + + +
    + +
    - +
    +
    +

    Parameters:

    - src/shapes/Convex.js:8 +
      +
    • + vertices + Array -

      - - - +
      +

      An array of vertices that span this shape. Vertices are given in counter-clockwise (CCW) direction.

      -
      - -
      +
      -
    - - -
    -

    Parameters:

    - -
      - -
    • - - vertices - Array - - - - -
      -

      An array of vertices that span this shape. Vertices are given in counter-clockwise (CCW) direction.

      - -
      - - -
    • - -
    • - - axes - Array - - - - -
      -

      An array of unit length vectors

      - +
    • +
    • + [axes] + Array + optional + + +
      +

      An array of unit length vectors, representing the symmetry axes in the convex.

      + +
      + +
    • +
    +
    + + + +
    +

    Example:

    + +
    +
    // Create a box
    +        var vertices = [[-1,-1], [1,-1], [1,1], [-1,1]];
    +        var convexShape = new Convex(vertices);
    +        body.addShape(convexShape);
    +        
    - - - - - +
    - - - - - -
    -
    -

    Item Index

    -

    Methods

    - -

    Properties

    - - -
    -

    Methods

    - -
    +

    computeAABB

    -
    (
      -
    • - out -
    • -
    • - position -
    • -
    • - angle -
    • -
    )
    - - - - - - - -
    -

    Inherited from Shape - but overwritten in - - - - src/shapes/Convex.js:312 - + src/shapes/Convex.js:318

    - -
    -

    Parameters:

      -
    • - out AABB - -
      -
    • -
    • - position Array - -
      -
    • -
    • - angle Number - -
      -
    • -
    - - - -
    - -
    +
    +

    computeMomentOfInertia

    -
    (
      -
    • - mass -
    • -
    )
    - - Number - - - - - - -
    -

    Inherited from Shape - but overwritten in - - - - src/shapes/Convex.js:237 - + src/shapes/Convex.js:243

    - -
    @@ -695,113 +462,66 @@

    computeMomentOfInertia

    -

    Parameters:

      -
    • - mass Number - -
      -
    • -
    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    projectOntoAxis

    -
    (
      -
    • - offset -
    • -
    • - localAxis -
    • -
    • - result -
    • -
    )
    - - - - - - static - - -
    - - -

    - Defined in - - - - - src/shapes/Convex.js:103 - + src/shapes/Convex.js:109

    - -
    @@ -809,135 +529,82 @@

    projectOntoAxis

    -

    Parameters:

      -
    • - offset Array - -
      -
    • -
    • - localAxis Array - -
      -
    • -
    • - result Array - -
      -
    • -
    - - - -
    - -
    +
    +

    triangleArea

    -
    (
      -
    • - a -
    • -
    • - b -
    • -
    • - c -
    • -
    )
    - - Number - - - - - static - - -
    - - -

    - Defined in - - - - - src/shapes/Convex.js:277 - + src/shapes/Convex.js:283

    - -
    @@ -945,119 +612,76 @@

    triangleArea

    -

    Parameters:

      -
    • - a Array - -
      -
    • -
    • - b Array - -
      -
    • -
    • - c Array - -
      -
    • -
    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    updateArea

    - () - - - - - - - -
    -

    Inherited from Shape - but overwritten in - - - - src/shapes/Convex.js:290 - + src/shapes/Convex.js:296

    - -
    @@ -1065,54 +689,33 @@

    updateArea

    - - - -
    - -
    +
    +

    updateBoundingRadius

    - () - - - - - - - -
    -

    Inherited from Shape - but overwritten in - - - - src/shapes/Convex.js:259 - + src/shapes/Convex.js:265

    - -
    @@ -1120,54 +723,30 @@

    updateBoundingRadius

    - - - -
    - -
    +
    +

    updateCenterOfMass

    - () - - - - - - - -
    - - -

    - Defined in - - - - - src/shapes/Convex.js:195 - + src/shapes/Convex.js:201

    - -
    @@ -1175,54 +754,30 @@

    updateCenterOfMass

    - - - -
    - -
    +
    +

    updateTriangles

    - () - - - - - - - -
    - - -

    - Defined in - - - - - src/shapes/Convex.js:156 - + src/shapes/Convex.js:162

    - -
    @@ -1230,589 +785,386 @@

    updateTriangles

    - - - -
    - +
    - -

    Properties

    -
    -

    area

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:89 - -

    - - - - -
    - -
    -

    Area of this shape.

    - -
    - - - - - - -
    - - +

    area

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:95 +

    + + +
    + +
    +

    Area of this shape.

    + +
    + + + +
    -

    axes

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/shapes/Convex.js:25 - -

    - - - - -
    - -
    -

    Axes defined in the local frame.

    - -
    - - - - - - -
    - - +

    axes

    + Array + + + + + +
    +

    + Defined in + src/shapes/Convex.js:30 +

    + + +
    + +
    +

    Axes defined in the local frame.

    + +
    + + + +
    -

    boundingRadius

    - Number - - - - - - - - - -
    - -

    Inherited from - - Shape - - - but overwritten in - - - - src/shapes/Convex.js:83 - -

    - - - - -
    - -
    -

    The bounding radius of the convex

    - -
    - - - - - - -
    - - +

    boundingRadius

    + Number + + + + + +
    +

    Inherited from + + Shape + + but overwritten in + src/shapes/Convex.js:88 +

    + + +
    + +
    +

    The bounding radius of the convex

    + +
    + + + +
    -

    centerOfMass

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/shapes/Convex.js:64 - -

    - - - - -
    - -
    -

    The center of mass of the Convex

    - -
    - - - - - - -
    - - +

    centerOfMass

    + Array + + + + + +
    +

    + Defined in + src/shapes/Convex.js:69 +

    + + +
    + +
    +

    The center of mass of the Convex

    + +
    + + + +
    -

    collisionGroup

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:41 - -

    - - - - -
    - -
    -

    Collision group that this shape belongs to (bit mask). See this tutorial.

    - -
    - - - - -
    -

    Example:

    - -
    -
    // Setup bits for each available group
    -var PLAYER = Math.pow(2,0),
    -    ENEMY =  Math.pow(2,1),
    -    GROUND = Math.pow(2,2)
    -
    -// Put shapes into their groups
    -player1Shape.collisionGroup = PLAYER;
    -player2Shape.collisionGroup = PLAYER;
    -enemyShape  .collisionGroup = ENEMY;
    -groundShape .collisionGroup = GROUND;
    -
    -// Assign groups that each shape collide with.
    -// Note that the players can collide with ground and enemies, but not with other players.
    -player1Shape.collisionMask = ENEMY | GROUND;
    -player2Shape.collisionMask = ENEMY | GROUND;
    -enemyShape  .collisionMask = PLAYER | GROUND;
    -groundShape .collisionMask = PLAYER | ENEMY;
    -
    // How collision check is done
    -if(shapeA.collisionGroup & shapeB.collisionMask)!=0 && (shapeB.collisionGroup & shapeA.collisionMask)!=0){
    -    // The shapes will collide
    -}
    - -
    -
    - - - -
    - - +

    collisionGroup

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:41 +

    + + +
    + +
    +

    Collision group that this shape belongs to (bit mask). See this tutorial.

    + +
    + + +
    +

    Example:

    + +
    +
    // Setup bits for each available group
    +                    var PLAYER = Math.pow(2,0),
    +                        ENEMY =  Math.pow(2,1),
    +                        GROUND = Math.pow(2,2)
    +                    
    +                    // Put shapes into their groups
    +                    player1Shape.collisionGroup = PLAYER;
    +                    player2Shape.collisionGroup = PLAYER;
    +                    enemyShape  .collisionGroup = ENEMY;
    +                    groundShape .collisionGroup = GROUND;
    +                    
    +                    // Assign groups that each shape collide with.
    +                    // Note that the players can collide with ground and enemies, but not with other players.
    +                    player1Shape.collisionMask = ENEMY | GROUND;
    +                    player2Shape.collisionMask = ENEMY | GROUND;
    +                    enemyShape  .collisionMask = PLAYER | GROUND;
    +                    groundShape .collisionMask = PLAYER | ENEMY;
    +                    
    // How collision check is done
    +                    if(shapeA.collisionGroup & shapeB.collisionMask)!=0 && (shapeB.collisionGroup & shapeA.collisionMask)!=0){
    +                        // The shapes will collide
    +                    }
    +                    
    +
    +
    + +
    -

    collisionMask

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:72 - -

    - - - - -
    - -
    -

    Collision mask of this shape. See .collisionGroup.

    - -
    - - - - - - -
    - - +

    collisionMask

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:78 +

    + + +
    + +
    +

    Collision mask of this shape. See .collisionGroup.

    + +
    + + + +
    +
    +

    collisionResponse

    + Boolean + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:72 +

    + + +
    + +
    +

    Whether to produce contact forces when in contact with other bodies. Note that contacts will be generated, but they will be disabled. That means that this shape will move through other body shapes, but it will still trigger contact events, etc.

    + +
    + + + +
    -

    id

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:27 - -

    - - - - -
    - -
    -

    Shape object identifier.

    - -
    - - - - - - -
    - - +

    id

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:27 +

    + + +
    + +
    +

    Shape object identifier.

    + +
    + + + +
    -

    material

    - Material - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:82 - -

    - - - - -
    - -
    -

    Material to use in collisions for this Shape. If this is set to null, the world will use default material properties instead.

    - -
    - - - - - - -
    - - +

    material

    + Material + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:88 +

    + + +
    + +
    +

    Material to use in collisions for this Shape. If this is set to null, the world will use default material properties instead.

    + +
    + + + +
    -

    sensor

    - Boolean - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:96 - -

    - - - - -
    - -
    -

    Set to true if you want this shape to be a sensor. A sensor does not generate contacts, but it still reports contact events. This is good if you want to know if a shape is overlapping another shape, without them generating contacts.

    - -
    - - - - - - -
    - - +

    sensor

    + Boolean + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:102 +

    + + +
    + +
    +

    Set to true if you want this shape to be a sensor. A sensor does not generate contacts, but it still reports contact events. This is good if you want to know if a shape is overlapping another shape, without them generating contacts.

    + +
    + + + +
    -

    triangles

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/shapes/Convex.js:71 - -

    - - - - -
    - -
    -

    Triangulated version of this convex. The structure is Array of 3-Arrays, and each subarray contains 3 integers, referencing the vertices.

    - -
    - - - - - - -
    - - +

    triangles

    + Array + + + + + +
    +

    + Defined in + src/shapes/Convex.js:76 +

    + + +
    + +
    +

    Triangulated version of this convex. The structure is Array of 3-Arrays, and each subarray contains 3 integers, referencing the vertices.

    + +
    + + + +
    -

    type

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:11 - -

    - - - - -
    - - - - - - - - -
    - - +

    type

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:11 +

    + + +
    + + + + + +
    -

    vertices

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/shapes/Convex.js:18 - -

    - - - - -
    - -
    -

    Vertices defined in the local frame.

    - -
    - - - - - - -
    - - +

    vertices

    + Array + + + + + +
    +

    + Defined in + src/shapes/Convex.js:23 +

    + + +
    + +
    +

    Vertices defined in the local frame.

    + +
    + + + + - - - - diff --git a/docs/classes/DistanceConstraint.html b/docs/classes/DistanceConstraint.html index 6eb2e615..96e0f0e9 100644 --- a/docs/classes/DistanceConstraint.html +++ b/docs/classes/DistanceConstraint.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,612 +25,399 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    DistanceConstraint Class

    +

    DistanceConstraint Class

    - -
    Extends Constraint
    - - - - -
    -

    Constraint that tries to keep the distance between two bodies constant.

    -

    Constructor

    -

    DistanceConstraint

    - - -
    - (
      - -
    • - - bodyA - -
    • - -
    • - - bodyB - -
    • - -
    • - - [options] - -
    • - -
    ) -
    - - - - - - - - - - - - - - - - -
    +

    DistanceConstraint

    + +
    + (
      +
    • + bodyA +
    • +
    • + bodyB +
    • +
    • + [options] +
    • +
    ) +
    - - -

    - - Defined in + + + + + + + +

    +

    + Defined in + src/constraints/DistanceConstraint.js:8 +

    + + + +
    + +
    - +
    +
    +

    Parameters:

    - src/constraints/DistanceConstraint.js:8 +
      +
    • + bodyA + Body -

      - - - +
      + +
      -
    - -
    + +
  • + bodyB + Body -
  • - - -
    -

    Parameters:

    - -
      - -
    • - - bodyA - Body - - - - -
      - -
      - - -
    • - -
    • - - bodyB - Body - - - - -
      - -
      - - -
    • - -
    • - - [options] - Object - optional - - - - -
      - + +
      + +
      + +
    • +
    • + [options] + Object + optional + + +
      + +
      + +
        +
      • + [distance] + Number + optional + +
        +

        The distance to keep between the anchor points. Defaults to the current distance between the bodies.

        + +
        + +
      • +
      • + [localAnchorA] The anchor point for bodyA, defined locally in bodyA frame. Defaults to [0,0] + Array + optional + +
        +

        .

        + +
        + +
      • +
      • + [localAnchorB] The anchor point for bodyB, defined locally in bodyB frame. Defaults to [0,0] + Array + optional + +
        +

        .

        + +
        + +
      • +
      • + [maxForce=Number.MAX_VALUE] + Object + optional + +
        +

        Maximum force to apply.

        + +
        + +
      • +
      +
    • +
    +
    + + + +
    +

    Example:

    + +
    +
    // If distance is not given as an option, then the current distance between the bodies is used.
    +        // In this example, the bodies will be constrained to have a distance of 2 between their centers.
    +        var bodyA = new Body({ mass: 1, position: [-1, 0] });
    +        var bodyB = new Body({ mass: 1, position: [1, 0] });
    +        var constraint = new DistanceConstraint(bodyA, bodyB);
    +        
    var constraint = new DistanceConstraint(bodyA, bodyB, {
    +            distance: 1,          // Distance to keep between the points
    +            localAnchorA: [1, 0], // Point on bodyA
    +            localAnchorB: [-1, 0] // Point on bodyB
    +        });
    +        
    - - -
      - -
    • - - [distance] - Number - optional - - -
      -

      The distance to keep between the anchor points. Defaults to the current distance between the bodies.

      - -
      - - -
    • - -
    • - - [localAnchorA] - Array - optional - - -
      -

      The anchor point for bodyA, defined locally in bodyA frame. Defaults to [0,0].

      - -
      - - -
    • - -
    • - - [localAnchorB] - Array - optional - - -
      -

      The anchor point for bodyB, defined locally in bodyB frame. Defaults to [0,0].

      - -
      - - -
    • - -
    • - - [maxForce=Number.MAX_VALUE] - Object - optional - - -
      -

      Maximum force to apply.

      - -
      - - -
    • - -
    - - - - -
    - - - - - -
    -

    Example:

    - -
    -
    // If distance is not given as an option, then the current distance between the bodies is used.
    -// In this example, the bodies will be constrained to have a distance of 2 between their centers.
    -var bodyA = new Body({ mass: 1, position: [-1, 0] });
    -var bodyB = new Body({ mass: 1, position: [1, 0] });
    -var constraint = new DistanceConstraint(bodyA, bodyB);
    -
    var constraint = new DistanceConstraint(bodyA, bodyB, {
    -    distance: 1,          // Distance to keep between the points
    -    localAnchorA: [1, 0], // Point on bodyA
    -    localAnchorB: [-1, 0] // Point on bodyB
    -});
    - -
    +
    - -
    -
    -

    Item Index

    -

    Methods

    - -

    Properties

    - - -
    -

    Methods

    - -
    +

    getMaxForce

    - () - - Number - - - - - - -
    @@ -640,76 +425,43 @@

    getMaxForce

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    setMaxForce

    -
    (
      -
    • - f -
    • -
    )
    - - - - - - - -
    @@ -717,84 +469,52 @@

    setMaxForce

    -

    Parameters:

      -
    • - f Number - -
      -
    • -
    - - - -
    - -
    +
    +

    setRelaxation

    -
    (
      -
    • - relaxation -
    • -
    )
    - - - - - - - -
    @@ -802,84 +522,52 @@

    setRelaxation

    -

    Parameters:

      -
    • - relaxation Number - -
      -
    • -
    - - - -
    - -
    +
    +

    setStiffness

    -
    (
      -
    • - stiffness -
    • -
    )
    - - - - - - - -
    @@ -887,77 +575,49 @@

    setStiffness

    -

    Parameters:

      -
    • - stiffness Number - -
      -
    • -
    - - - -
    - -
    +
    +

    update

    - () - - - - - - - -
    @@ -965,606 +625,371 @@

    update

    - - - -
    - +
    - -

    Properties

    -
    -

    bodyA

    - Body - - - - - - - - - -
    - - -

    Inherited from - Constraint: - - - - src/constraints/Constraint.js:33 - -

    - - - - -
    - -
    -

    First body participating in the constraint.

    - -
    - - - - - - -
    - - +

    bodyA

    + Body + + + + + +
    +

    Inherited from + Constraint: + src/constraints/Constraint.js:38 +

    + + +
    + +
    +

    First body participating in the constraint.

    + +
    + + + +
    -

    bodyB

    - Body - - - - - - - - - -
    - - -

    Inherited from - Constraint: - - - - src/constraints/Constraint.js:40 - -

    - - - - -
    - -
    -

    Second body participating in the constraint.

    - -
    - - - - - - -
    - - +

    bodyB

    + Body + + + + + +
    +

    Inherited from + Constraint: + src/constraints/Constraint.js:45 +

    + + +
    + +
    +

    Second body participating in the constraint.

    + +
    + + + +
    -

    collideConnected

    - Boolean - - - - - - - - - -
    - - -

    Inherited from - Constraint: - - - - src/constraints/Constraint.js:47 - -

    - - - - -
    - -
    -

    Set to true if you want the connected bodies to collide.

    - -
    - - -

    Default: true

    - - - - - -
    - - +

    collideConnected

    + Boolean + + + + + +
    +

    Inherited from + Constraint: + src/constraints/Constraint.js:52 +

    + + +
    + +
    +

    Set to true if you want the connected bodies to collide.

    + +
    + +

    Default: true

    + + +
    -

    distance

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/constraints/DistanceConstraint.js:62 - -

    - - - - -
    - -
    -

    The distance to keep.

    - -
    - - - - - - -
    - - +

    distance

    + Number + + + + + +
    +

    + Defined in + src/constraints/DistanceConstraint.js:62 +

    + + +
    + +
    +

    The distance to keep.

    + +
    + + + +
    -

    equations

    - Array - - - - - - - - - -
    - - -

    Inherited from - Constraint: - - - - src/constraints/Constraint.js:25 - -

    - - - - -
    - -
    -

    Equations to be solved in this constraint

    - -
    - - - - - - -
    - - +

    equations

    + Array + + + + + +
    +

    Inherited from + Constraint: + src/constraints/Constraint.js:30 +

    + + +
    + +
    +

    Equations to be solved in this constraint

    + +
    + + + +
    -

    localAnchorA

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/constraints/DistanceConstraint.js:45 - -

    - - - - -
    - -
    -

    Local anchor in body A.

    - -
    - - - - - - -
    - - +

    localAnchorA

    + Array + + + + + +
    +

    + Defined in + src/constraints/DistanceConstraint.js:45 +

    + + +
    + +
    +

    Local anchor in body A.

    + +
    + + + +
    -

    localAnchorB

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/constraints/DistanceConstraint.js:52 - -

    - - - - -
    - -
    -

    Local anchor in body B.

    - -
    - - - - - - -
    - - +

    localAnchorB

    + Array + + + + + +
    +

    + Defined in + src/constraints/DistanceConstraint.js:52 +

    + + +
    + +
    +

    Local anchor in body B.

    + +
    + + + +
    -

    lowerLimit

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/constraints/DistanceConstraint.js:162 - -

    - - - - -
    - -
    -

    The lower constraint limit.

    - -
    - - - - - - -
    - - +

    lowerLimit

    + Number + + + + + + + +
    +

    The lower constraint limit.

    + +
    + + + +
    -

    lowerLimitEnabled

    - Boolean - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/constraints/DistanceConstraint.js:156 - -

    - - - - -
    - -
    -

    If the lower limit is enabled or not.

    - -
    - - - - - - -
    - - +

    lowerLimitEnabled

    + Boolean + + + + + + + +
    +

    If the lower limit is enabled or not.

    + +
    + + + +
    -

    maxForce

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/constraints/DistanceConstraint.js:98 - -

    - - - - -
    - -
    -

    Max force to apply.

    - -
    - - - - - - -
    - - +

    maxForce

    + Number + + + + + +
    +

    + Defined in + src/constraints/DistanceConstraint.js:98 +

    + + +
    + +
    +

    Max force to apply.

    + +
    + + + +
    -

    position

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/constraints/DistanceConstraint.js:168 - -

    - - - - -
    - -
    -

    Current constraint position. This is equal to the current distance between the world anchor points.

    - -
    - - - - - - -
    - - +

    position

    + Number + + + + + + + +
    +

    Current constraint position. This is equal to the current distance between the world anchor points.

    + +
    + + + + +
    +

    type

    + Number + + + + + +
    +

    Inherited from + Constraint: + src/constraints/Constraint.js:19 +

    + + +
    + +
    +

    The type of constraint. May be one of Constraint.DISTANCE, Constraint.GEAR, Constraint.LOCK, Constraint.PRISMATIC or Constraint.REVOLUTE.

    + +
    + + + +
    -

    upperLimit

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/constraints/DistanceConstraint.js:150 - -

    - - - - -
    - -
    -

    The upper constraint limit.

    - -
    - - - - - - -
    - - +

    upperLimit

    + Number + + + + + + + +
    +

    The upper constraint limit.

    + +
    + + + +
    -

    upperLimitEnabled

    - Boolean - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/constraints/DistanceConstraint.js:144 - -

    - - - - -
    - -
    -

    If the upper limit is enabled or not.

    - -
    - - - - - - -
    - - +

    upperLimitEnabled

    + Boolean + + + + + + + +
    +

    If the upper limit is enabled or not.

    + +
    + + + + - - - - diff --git a/docs/classes/Equation.html b/docs/classes/Equation.html index d435a6e6..dbe2e05c 100644 --- a/docs/classes/Equation.html +++ b/docs/classes/Equation.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,595 +25,370 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    Equation Class

    +

    Equation Class

    - - - - - -
    -

    Base class for constraint equations.

    -

    Constructor

    -

    Equation

    - - -
    - (
      - -
    • - - bodyA - -
    • - -
    • - - bodyB - -
    • - -
    • - - minForce - -
    • - -
    • - - maxForce - -
    • - -
    ) -
    - - - - - - - - - - - - - - - - -
    +

    Equation

    + +
    + (
      +
    • + bodyA +
    • +
    • + bodyB +
    • +
    • + minForce +
    • +
    • + maxForce +
    • +
    ) +
    - - -

    - - Defined in + + + + + + + +

    +

    + Defined in + src/equations/Equation.js:7 +

    + + + +
    + +
    - +
    +
    +

    Parameters:

    - src/equations/Equation.js:7 +
      +
    • + bodyA + Body -

      - - - +
      +

      First body participating in the equation

      + +
      + +
    • +
    • + bodyB + Body + + +
      +

      Second body participating in the equation

      + +
      + +
    • +
    • + minForce + Number + + +
      +

      Minimum force to apply. Default: -Number.MAX_VALUE

      + +
      + +
    • +
    • + maxForce + Number + + +
      +

      Maximum force to apply. Default: Number.MAX_VALUE

      + +
      + +
    • +
    +
    + -
    - -
    -
    - - -
    -

    Parameters:

    - -
      - -
    • - - bodyA - Body - - - - -
      -

      First body participating in the equation

      - -
      - - -
    • - -
    • - - bodyB - Body - - - - -
      -

      Second body participating in the equation

      - -
      - - -
    • - -
    • - - minForce - Number - - - - -
      -

      Minimum force to apply. Default: -Number.MAX_VALUE

      - -
      - - -
    • - -
    • - - maxForce - Number - - - - -
      -

      Maximum force to apply. Default: Number.MAX_VALUE

      - -
      - - -
    • - -
    - - - - - -
    -
    -

    Item Index

    -

    Methods

    - -

    Properties

    - - -
    -

    Methods

    - -
    +

    addToWlambda

    -
    (
      -
    • - deltalambda -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - src/equations/Equation.js:268 -

    - -
    @@ -623,81 +396,49 @@

    addToWlambda

    -

    Parameters:

      -
    • - deltalambda Number - -
      -
    • -
    - - - -
    - -
    +
    +

    computeB

    - () - - Number - - - - - - -
    - - -

    - Defined in - - - - src/equations/Equation.js:150 -

    - -
    @@ -705,70 +446,40 @@

    computeB

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    computeGiMf

    - () - - Number - - - - - - -
    - - -

    - Defined in - - - - src/equations/Equation.js:213 -

    - -
    @@ -776,70 +487,40 @@

    computeGiMf

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    computeGiMGt

    - () - - Number - - - - - - -
    - - -

    - Defined in - - - - src/equations/Equation.js:239 -

    - -
    @@ -847,70 +528,40 @@

    computeGiMGt

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    computeGq

    - () - - Number - - - - - - -
    - - -

    - Defined in - - - - src/equations/Equation.js:162 -

    - -
    @@ -918,70 +569,40 @@

    computeGq

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    computeGW

    - () - - Number - - - - - - -
    - - -

    - Defined in - - - - src/equations/Equation.js:181 -

    - -
    @@ -989,70 +610,40 @@

    computeGW

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    computeGWlambda

    - () - - Number - - - - - - -
    - - -

    - Defined in - - - - src/equations/Equation.js:197 -

    - -
    @@ -1060,80 +651,46 @@

    computeGWlambda

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    computeInvC

    -
    (
      -
    • - eps -
    • -
    )
    - - Number - - - - - - -
    - - -

    - Defined in - - - - src/equations/Equation.js:309 -

    - -
    @@ -1141,93 +698,56 @@

    computeInvC

    -

    Parameters:

      -
    • - eps Number - -
      -
    • -
    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    gmult

    - () - - Number - - - - - - -
    - - -

    - Defined in - - - - src/equations/Equation.js:136 -

    - -
    @@ -1235,66 +755,37 @@

    gmult

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    update

    - () - - - - - - - -
    - - -

    - Defined in - - - - src/equations/Equation.js:120 -

    - -
    @@ -1302,624 +793,349 @@

    update

    - - - -
    - +
    - -

    Properties

    -
    -

    bodyA

    - Body - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/equations/Equation.js:32 - -

    - - - - -
    - -
    -

    First body participating in the constraint

    - -
    - - - - - - -
    - - +

    bodyA

    + Body + + + + + +
    +

    + Defined in + src/equations/Equation.js:32 +

    + + +
    + +
    +

    First body participating in the constraint

    + +
    + + + +
    -

    bodyB

    - Body - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/equations/Equation.js:39 - -

    - - - - -
    - -
    -

    Second body participating in the constraint

    - -
    - - - - - - -
    - - -
    -

    DEFAULT_RELAXATION

    - Number - - - - - - - - - static - - -
    - - - -

    - - Defined in - - - - - src/equations/Equation.js:112 - -

    - - - - -
    - -
    -

    The default relaxation when creating a new Equation.

    - -
    - - -

    Default: 4

    - - - - - -
    - - +

    bodyB

    + Body + + + + + +
    +

    + Defined in + src/equations/Equation.js:39 +

    + + +
    + +
    +

    Second body participating in the constraint

    + +
    + + + +
    +
    +

    DEFAULT_RELAXATION

    + Number + + + + + static + +
    +

    + Defined in + src/equations/Equation.js:112 +

    + + +
    + +
    +

    The default relaxation when creating a new Equation.

    + +
    + +

    Default: 4

    + + +
    -

    DEFAULT_STIFFNESS

    - Number - - - - - - - - - static - - -
    - - - -

    - - Defined in - - - - - src/equations/Equation.js:104 - -

    - - - - -
    - -
    -

    The default stiffness when creating a new Equation.

    - -
    - - -

    Default: 1e6

    - - - - - -
    - - +

    DEFAULT_STIFFNESS

    + Number + + + + + static + +
    +

    + Defined in + src/equations/Equation.js:104 +

    + + +
    + +
    +

    The default stiffness when creating a new Equation.

    + +
    + +

    Default: 1e6

    + + +
    -

    enabled

    - Boolean - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/equations/Equation.js:96 - -

    - - - - -
    - -
    -

    Whether this equation is enabled or not. If true, it will be added to the solver.

    - -
    - - - - - - -
    - - +

    enabled

    + Boolean + + + + + +
    +

    + Defined in + src/equations/Equation.js:96 +

    + + +
    + +
    +

    Whether this equation is enabled or not. If true, it will be added to the solver.

    + +
    + + + +
    -

    G

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/equations/Equation.js:60 - -

    - - - - -
    - -
    -

    The Jacobian entry of this equation. 6 numbers, 3 per body (x,y,angle).

    - -
    - - - - - - -
    - - +

    G

    + Array + + + + + +
    +

    + Defined in + src/equations/Equation.js:60 +

    + + +
    + +
    +

    The Jacobian entry of this equation. 6 numbers, 3 per body (x,y,angle).

    + +
    + + + +
    -

    maxForce

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/equations/Equation.js:25 - -

    - - - - -
    - -
    -

    Max force to apply when solving.

    - -
    - - - - - - -
    - - -
    -

    minForce

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/equations/Equation.js:18 - -

    - - - - -
    - -
    -

    Minimum force to apply when solving.

    - -
    - - - - - - -
    - - +

    maxForce

    + Number + + + + + +
    +

    + Defined in + src/equations/Equation.js:25 +

    + + +
    + +
    +

    Max force to apply when solving.

    + +
    + + + +
    +
    +

    minForce

    + Number + + + + + +
    +

    + Defined in + src/equations/Equation.js:18 +

    + + +
    + +
    +

    Minimum force to apply when solving.

    + +
    + + + +
    -

    multiplier

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/equations/Equation.js:83 - -

    - - - - -
    - -
    -

    The resulting constraint multiplier from the last solve. This is mostly equivalent to the force produced by the constraint.

    - -
    - - - - - - -
    - - +

    multiplier

    + Number + + + + + +
    +

    + Defined in + src/equations/Equation.js:83 +

    + + +
    + +
    +

    The resulting constraint multiplier from the last solve. This is mostly equivalent to the force produced by the constraint.

    + +
    + + + +
    -

    needsUpdate

    - Boolean - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/equations/Equation.js:77 - -

    - - - - -
    - -
    -

    Indicates if stiffness or relaxation was changed.

    - -
    - - - - - - -
    - - +

    needsUpdate

    + Boolean + + + + + +
    +

    + Defined in + src/equations/Equation.js:77 +

    + + +
    + +
    +

    Indicates if stiffness or relaxation was changed.

    + +
    + + + +
    -

    relativeVelocity

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/equations/Equation.js:90 - -

    - - - - -
    - -
    -

    Relative velocity.

    - -
    - - - - - - -
    - - +

    relativeVelocity

    + Number + + + + + +
    +

    + Defined in + src/equations/Equation.js:90 +

    + + +
    + +
    +

    Relative velocity.

    + +
    + + + +
    -

    relaxation

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/equations/Equation.js:53 - -

    - - - - -
    - -
    -

    The number of time steps needed to stabilize the constraint equation. Typically between 3 and 5 time steps.

    - -
    - - - - - - -
    - - +

    relaxation

    + Number + + + + + +
    +

    + Defined in + src/equations/Equation.js:53 +

    + + +
    + +
    +

    The number of time steps needed to stabilize the constraint equation. Typically between 3 and 5 time steps.

    + +
    + + + +
    -

    stiffness

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/equations/Equation.js:46 - -

    - - - - -
    - -
    -

    The stiffness of this equation. Typically chosen to a large number (~1e7), but can be chosen somewhat freely to get a stable simulation.

    - -
    - - - - - - -
    - - +

    stiffness

    + Number + + + + + +
    +

    + Defined in + src/equations/Equation.js:46 +

    + + +
    + +
    +

    The stiffness of this equation. Typically chosen to a large number (~1e7), but can be chosen somewhat freely to get a stable simulation.

    + +
    + + + + - - - - diff --git a/docs/classes/EventEmitter.html b/docs/classes/EventEmitter.html index 25ec21c5..91ba5bb7 100644 --- a/docs/classes/EventEmitter.html +++ b/docs/classes/EventEmitter.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,352 +25,223 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    EventEmitter Class

    +

    EventEmitter Class

    - - - - - -
    -

    Base class for objects that dispatches events.

    -

    Constructor

    -

    EventEmitter

    - - - () - - - - - - - - - - - - - - - - -
    +

    EventEmitter

    - - -

    - - Defined in - - + () - src/events/EventEmitter.js:1 -

    - - - -
    - -
    + + +
    +

    + Defined in + src/events/EventEmitter.js:1 +

    + + + +
    + +
    + +
    + + + + +
    - - - - - -
    - -
    - -

    Item Index

    -

    Methods

    - - - -
    -

    Methods

    - -
    +

    emit

    -
    (
      -
    • - event -
    • -
    )
    - - EventEmitter - - - - - - -
    - - -

    - Defined in - - - - src/events/EventEmitter.js:79 -

    - -
    @@ -380,128 +249,78 @@

    emit

    -

    Parameters:

      -
    • - event Object - -
      -
        -
      • - type String -
        -
      • -
      -
    • -
    - -

    Returns:

    - - EventEmitter: -

    The self object, for chainability.

    -
    - - -
    - -
    +
    +

    has

    -
    (
      -
    • - type -
    • -
    • - listener -
    • -
    )
    - - Boolean - - - - - - -
    - - -

    - Defined in - - - - src/events/EventEmitter.js:35 -

    - -
    @@ -509,124 +328,75 @@

    has

    -

    Parameters:

      -
    • - type String - -
      -
    • -
    • - listener Function - -
      -
    • -
    - -

    Returns:

    - - Boolean: - -
    - - -
    - -
    +
    +

    off

    -
    (
      -
    • - type -
    • -
    • - listener -
    • -
    )
    - - EventEmitter - - - - - - -
    - - -

    - Defined in - - - - src/events/EventEmitter.js:60 -

    - -
    @@ -634,126 +404,77 @@

    off

    -

    Parameters:

      -
    • - type String - -
      -
    • -
    • - listener Function - -
      -
    • -
    - -

    Returns:

    - - EventEmitter: -

    The self object, for chainability.

    -
    - - -
    - -
    +
    +

    on

    -
    (
      -
    • - type -
    • -
    • - listener -
    • -
    )
    - - EventEmitter - - - - - - -
    - - -

    - Defined in - - - - src/events/EventEmitter.js:13 -

    - -
    @@ -761,77 +482,51 @@

    on

    -

    Parameters:

      -
    • - type String - -
      -
    • -
    • - listener Function - -
      -
    • -
    - -

    Returns:

    - - EventEmitter: -

    The self object, for chainability.

    -
    - - -
    - +
    - - - -
    -
    diff --git a/docs/classes/FrictionEquation.html b/docs/classes/FrictionEquation.html index d71c0aaa..cf34693d 100644 --- a/docs/classes/FrictionEquation.html +++ b/docs/classes/FrictionEquation.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,616 +25,382 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    FrictionEquation Class

    +

    FrictionEquation Class

    - -
    Extends Equation
    - - - - -
    -

    Constrains the slipping in a contact along a tangent

    -

    Constructor

    -

    FrictionEquation

    - - -
    - (
      - -
    • - - bodyA - -
    • - -
    • - - bodyB - -
    • - -
    • - - slipForce - -
    • - -
    ) -
    - - - - - - - - - - - - - - - - -
    +

    FrictionEquation

    + +
    + (
      +
    • + bodyA +
    • +
    • + bodyB +
    • +
    • + slipForce +
    • +
    ) +
    - - -

    - - Defined in + + + + + + + +

    +

    + Defined in + src/equations/FrictionEquation.js:7 +

    + + + +
    + +
    - +
    +
    +

    Parameters:

    - src/equations/FrictionEquation.js:7 +
      +
    • + bodyA + Body -

      - - - +
      + +
      + +
    • +
    • + bodyB + Body + + +
      + +
      + +
    • +
    • + slipForce + Number + + +
      + +
      + +
    • +
    +
    + -
    - -
    -
    - - -
    -

    Parameters:

    - -
      - -
    • - - bodyA - Body - - - - -
      - -
      - - -
    • - -
    • - - bodyB - Body - - - - -
      - -
      - - -
    • - -
    • - - slipForce - Number - - - - -
      - -
      - - -
    • - -
    - - - - - -
    -
    -

    Item Index

    -

    Methods

    - -

    Properties

    - - -
    -

    Methods

    - -
    +

    addToWlambda

    -
    (
      -
    • - deltalambda -
    • -
    )
    - - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:268 -

    - -
    @@ -644,78 +408,49 @@

    addToWlambda

    -

    Parameters:

      -
    • - deltalambda Number - -
      -
    • -
    - - - -
    - -
    +
    +

    computeB

    - () - - Number - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:150 -

    - -
    @@ -723,67 +458,40 @@

    computeB

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    computeGiMf

    - () - - Number - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:213 -

    - -
    @@ -791,67 +499,40 @@

    computeGiMf

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    computeGiMGt

    - () - - Number - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:239 -

    - -
    @@ -859,67 +540,40 @@

    computeGiMGt

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    computeGq

    - () - - Number - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:162 -

    - -
    @@ -927,67 +581,40 @@

    computeGq

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    computeGW

    - () - - Number - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:181 -

    - -
    @@ -995,67 +622,40 @@

    computeGW

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    computeGWlambda

    - () - - Number - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:197 -

    - -
    @@ -1063,77 +663,46 @@

    computeGWlambda

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    computeInvC

    -
    (
      -
    • - eps -
    • -
    )
    - - Number - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:309 -

    - -
    @@ -1141,93 +710,56 @@

    computeInvC

    -

    Parameters:

      -
    • - eps Number - -
      -
    • -
    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    getSlipForce

    - () - - Number - - - - - - -
    - - -

    - Defined in - - - - src/equations/FrictionEquation.js:85 -

    - -
    @@ -1235,67 +767,40 @@

    getSlipForce

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    gmult

    - () - - Number - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:136 -

    - -
    @@ -1303,76 +808,43 @@

    gmult

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    setSlipForce

    -
    (
      -
    • - slipForce -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - src/equations/FrictionEquation.js:74 -

    - -
    @@ -1381,74 +853,46 @@

    setSlipForce

    -

    Parameters:

      -
    • - slipForce Number - -
      -
    • -
    - - - -
    - -
    +
    +

    update

    - () - - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:120 -

    - -
    @@ -1456,808 +900,470 @@

    update

    - - - -
    - +
    - -

    Properties

    -
    -

    bodyA

    - Body - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:32 - -

    - - - - -
    - -
    -

    First body participating in the constraint

    - -
    - - - - - - -
    - - +

    bodyA

    + Body + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:32 +

    + + +
    + +
    +

    First body participating in the constraint

    + +
    + + + +
    -

    bodyB

    - Body - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:39 - -

    - - - - -
    - -
    -

    Second body participating in the constraint

    - -
    - - - - - - -
    - - +

    bodyB

    + Body + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:39 +

    + + +
    + +
    +

    Second body participating in the constraint

    + +
    + + + +
    -

    contactEquations

    - ContactEquation - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/equations/FrictionEquation.js:41 - -

    - - - - -
    - -
    -

    A ContactEquation connected to this friction. The contact equations can be used to rescale the max force for the friction. If more than one contact equation is given, then the max force can be set to the average.

    - -
    - - - - - - -
    - - +

    contactEquations

    + ContactEquation + + + + + +
    +

    + Defined in + src/equations/FrictionEquation.js:41 +

    + + +
    + +
    +

    A ContactEquation connected to this friction. The contact equations can be used to rescale the max force for the friction. If more than one contact equation is given, then the max force can be set to the average.

    + +
    + + + +
    -

    contactPointA

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/equations/FrictionEquation.js:20 - -

    - - - - -
    - -
    -

    Relative vector from center of body A to the contact point, world oriented.

    - -
    - - - - - - -
    - - +

    contactPointA

    + Array + + + + + +
    +

    + Defined in + src/equations/FrictionEquation.js:20 +

    + + +
    + +
    +

    Relative vector from center of body A to the contact point, world oriented.

    + +
    + + + +
    -

    contactPointB

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/equations/FrictionEquation.js:27 - -

    - - - - -
    - -
    -

    Relative vector from center of body B to the contact point, world oriented.

    - -
    - - - - - - -
    - - +

    contactPointB

    + Array + + + + + +
    +

    + Defined in + src/equations/FrictionEquation.js:27 +

    + + +
    + +
    +

    Relative vector from center of body B to the contact point, world oriented.

    + +
    + + + +
    -

    enabled

    - Boolean - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:96 - -

    - - - - -
    - -
    -

    Whether this equation is enabled or not. If true, it will be added to the solver.

    - -
    - - - - - - -
    - - +

    enabled

    + Boolean + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:96 +

    + + +
    + +
    +

    Whether this equation is enabled or not. If true, it will be added to the solver.

    + +
    + + + +
    -

    frictionCoefficient

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/equations/FrictionEquation.js:64 - -

    - - - - -
    - -
    -

    The friction coefficient to use.

    - -
    - - - - - - -
    - - +

    frictionCoefficient

    + Number + + + + + +
    +

    + Defined in + src/equations/FrictionEquation.js:64 +

    + + +
    + +
    +

    The friction coefficient to use.

    + +
    + + + +
    -

    G

    - Array - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:60 - -

    - - - - -
    - -
    -

    The Jacobian entry of this equation. 6 numbers, 3 per body (x,y,angle).

    - -
    - - - - - - -
    - - +

    G

    + Array + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:60 +

    + + +
    + +
    +

    The Jacobian entry of this equation. 6 numbers, 3 per body (x,y,angle).

    + +
    + + + +
    -

    maxForce

    - Number - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:25 - -

    - - - - -
    - -
    -

    Max force to apply when solving.

    - -
    - - - - - - -
    - - +

    maxForce

    + Number + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:25 +

    + + +
    + +
    +

    Max force to apply when solving.

    + +
    + + + +
    -

    minForce

    - Number - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:18 - -

    - - - - -
    - -
    -

    Minimum force to apply when solving.

    - -
    - - - - - - -
    - - +

    minForce

    + Number + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:18 +

    + + +
    + +
    +

    Minimum force to apply when solving.

    + +
    + + + +
    -

    multiplier

    - Number - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:83 - -

    - - - - -
    - -
    -

    The resulting constraint multiplier from the last solve. This is mostly equivalent to the force produced by the constraint.

    - -
    - - - - - - -
    - - +

    multiplier

    + Number + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:83 +

    + + +
    + +
    +

    The resulting constraint multiplier from the last solve. This is mostly equivalent to the force produced by the constraint.

    + +
    + + + +
    -

    needsUpdate

    - Boolean - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:77 - -

    - - - - -
    - -
    -

    Indicates if stiffness or relaxation was changed.

    - -
    - - - - - - -
    - - -
    -

    relativeVelocity

    - Number - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:90 - -

    - - - - -
    - -
    -

    Relative velocity.

    - -
    - - - - - - -
    - - +

    needsUpdate

    + Boolean + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:77 +

    + + +
    + +
    +

    Indicates if stiffness or relaxation was changed.

    + +
    + + + + +
    +

    relativeVelocity

    + Number + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:90 +

    + + +
    + +
    +

    Relative velocity.

    + +
    + + + +
    -

    relaxation

    - Number - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:53 - -

    - - - - -
    - -
    -

    The number of time steps needed to stabilize the constraint equation. Typically between 3 and 5 time steps.

    - -
    - - - - - - -
    - - +

    relaxation

    + Number + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:53 +

    + + +
    + +
    +

    The number of time steps needed to stabilize the constraint equation. Typically between 3 and 5 time steps.

    + +
    + + + +
    -

    shapeA

    - Shape - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/equations/FrictionEquation.js:48 - -

    - - - - -
    - -
    -

    The shape in body i that triggered this friction.

    - -
    - - - - - - -
    - - +

    shapeA

    + Shape + + + + + +
    +

    + Defined in + src/equations/FrictionEquation.js:48 +

    + + +
    + +
    +

    The shape in body i that triggered this friction.

    + +
    + + + +
    -

    shapeB

    - Shape - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/equations/FrictionEquation.js:56 - -

    - - - - -
    - -
    -

    The shape in body j that triggered this friction.

    - -
    - - - - - - -
    - - +

    shapeB

    + Shape + + + + + +
    +

    + Defined in + src/equations/FrictionEquation.js:56 +

    + + +
    + +
    +

    The shape in body j that triggered this friction.

    + +
    + + + +
    -

    stiffness

    - Number - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:46 - -

    - - - - -
    - -
    -

    The stiffness of this equation. Typically chosen to a large number (~1e7), but can be chosen somewhat freely to get a stable simulation.

    - -
    - - - - - - -
    - - +

    stiffness

    + Number + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:46 +

    + + +
    + +
    +

    The stiffness of this equation. Typically chosen to a large number (~1e7), but can be chosen somewhat freely to get a stable simulation.

    + +
    + + + +
    -

    t

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/equations/FrictionEquation.js:34 - -

    - - - - -
    - -
    -

    Tangent vector that the friction force will act along. World oriented.

    - -
    - - - - - - -
    - - +

    t

    + Array + + + + + +
    +

    + Defined in + src/equations/FrictionEquation.js:34 +

    + + +
    + +
    +

    Tangent vector that the friction force will act along. World oriented.

    + +
    + + + + - - - - diff --git a/docs/classes/GSSolver.html b/docs/classes/GSSolver.html index 829581ec..65a76636 100644 --- a/docs/classes/GSSolver.html +++ b/docs/classes/GSSolver.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,523 +25,331 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    GSSolver Class

    +

    GSSolver Class

    - -
    Extends Solver
    - - - - -
    -

    Iterative Gauss-Seidel constraint equation solver.

    -

    Constructor

    -

    GSSolver

    - - -
    - (
      - -
    • - - [options] - -
    • - -
    ) -
    - - - - - - - - - - - - - - - - -
    +

    GSSolver

    + +
    + (
      +
    • + [options] +
    • +
    ) +
    - - -

    - - Defined in + + + + + + + +

    +

    + Defined in + src/solver/GSSolver.js:8 +

    + + + +
    + +
    - +
    +
    +

    Parameters:

    - src/solver/GSSolver.js:8 +
      +
    • + [options] + Object + optional -

      - - - +
      + +
      + +
        +
      • + [iterations=10] + Number + optional + +
        + +
        + +
      • +
      • + [tolerance=0] + Number + optional + +
        + +
        + +
      • +
      +
    • +
    +
    + -
    - -
    -
    - - -
    -

    Parameters:

    - -
      - -
    • - - [options] - Object - optional - - - - -
      - -
      - - -
        - -
      • - - [iterations=10] - Number - optional - - -
        - -
        - - -
      • - -
      • - - [tolerance=0] - Number - optional - - -
        - -
        - - -
      • - -
      - -
    • - -
    - - - - - -
    -
    -

    Item Index

    -

    Methods

    - -

    Properties

    - - -
    -

    Methods

    - -
    +

    addEquation

    -
    (
      -
    • - eq -
    • -
    )
    - - - - - - - -
    - -

    Inherited from Solver: - - - - src/solver/Solver.js:81 - + src/solver/Solver.js:82

    - -
    @@ -551,84 +357,52 @@

    addEquation

    -

    Parameters:

    - - - -
    - -
    +
    +

    addEquations

    -
    (
      -
    • - eqs -
    • -
    )
    - - - - - - - -
    - -

    Inherited from Solver: - - - - src/solver/Solver.js:93 - + src/solver/Solver.js:94

    - -
    @@ -636,88 +410,55 @@

    addEquations

    -

    Parameters:

      -
    • - eqs Array - -
      -
    • -
    - - - -
    - -
    +
    +

    emit

    -
    (
      -
    • - event -
    • -
    )
    - - EventEmitter - - - - - - -
    - -

    Inherited from EventEmitter: - - - src/events/EventEmitter.js:79 -

    - -
    @@ -725,125 +466,78 @@

    emit

    -

    Parameters:

      -
    • - event Object - -
      -
        -
      • - type String -
        -
      • -
      -
    • -
    - -

    Returns:

    - - EventEmitter: -

    The self object, for chainability.

    -
    - - -
    - -
    +
    +

    has

    -
    (
      -
    • - type -
    • -
    • - listener -
    • -
    )
    - - Boolean - - - - - - -
    - -

    Inherited from EventEmitter: - - - src/events/EventEmitter.js:35 -

    - -
    @@ -851,121 +545,75 @@

    has

    -

    Parameters:

      -
    • - type String - -
      -
    • -
    • - listener Function - -
      -
    • -
    - -

    Returns:

    - - Boolean: - -
    - - -
    - -
    +
    +

    off

    -
    (
      -
    • - type -
    • -
    • - listener -
    • -
    )
    - - EventEmitter - - - - - - -
    - -

    Inherited from EventEmitter: - - - src/events/EventEmitter.js:60 -

    - -
    @@ -973,123 +621,77 @@

    off

    -

    Parameters:

      -
    • - type String - -
      -
    • -
    • - listener Function - -
      -
    • -
    - -

    Returns:

    - - EventEmitter: -

    The self object, for chainability.

    -
    - - -
    - -
    +
    +

    on

    -
    (
      -
    • - type -
    • -
    • - listener -
    • -
    )
    - - EventEmitter - - - - - - -
    - -

    Inherited from EventEmitter: - - - src/events/EventEmitter.js:13 -

    - -
    @@ -1097,103 +699,65 @@

    on

    -

    Parameters:

      -
    • - type String - -
      -
    • -
    • - listener Function - -
      -
    • -
    - -

    Returns:

    - - EventEmitter: -

    The self object, for chainability.

    -
    - - -
    - -
    +
    +

    removeAllEquations

    - () - - - - - - - -
    - -

    Inherited from Solver: - - - - src/solver/Solver.js:122 - + src/solver/Solver.js:123

    - -
    @@ -1201,61 +765,36 @@

    removeAllEquations

    - - - -
    - -
    +
    +

    removeEquation

    -
    (
      -
    • - eq -
    • -
    )
    - - - - - - - -
    - -

    Inherited from Solver: - - - - src/solver/Solver.js:109 - + src/solver/Solver.js:110

    - -
    @@ -1263,93 +802,58 @@

    removeEquation

    -

    Parameters:

    - - - -
    - -
    +
    +

    solve

    -
    (
      -
    • - h -
    • -
    • - world -
    • -
    )
    - - - - - - - -
    -

    Inherited from Solver - but overwritten in - - - - src/solver/GSSolver.js:71 - + src/solver/GSSolver.js:72

    - -
    @@ -1357,107 +861,67 @@

    solve

    -

    Parameters:

      -
    • - h Number - -

      Time step

      -
    • -
    • - world World - -

      World to solve

      -
    • -
    - - - -
    - -
    +
    +

    solveIsland

    -
    (
      -
    • - dt -
    • -
    • - island -
    • -
    )
    - - - - - - - -
    - -

    Inherited from Solver: - - - - src/solver/Solver.js:48 - + src/solver/Solver.js:49

    - -
    @@ -1465,89 +929,56 @@

    solveIsland

    -

    Parameters:

      -
    • - dt Number - -
      -
    • -
    • - island Island - -
      -
    • -
    - - - -
    - -
    +
    +

    sortEquations

    - () - - - - - - - -
    - -

    Inherited from Solver: - - - - src/solver/Solver.js:71 - + src/solver/Solver.js:72

    - -
    @@ -1555,341 +986,196 @@

    sortEquations

    - - - -
    - +
    - -

    Properties

    -
    -

    equations

    - Array - - - - - - - - - -
    - - -

    Inherited from - Solver: - - - - src/solver/Solver.js:19 - -

    - - - - -
    - -
    -

    Current equations in the solver.

    - -
    - - - - - - -
    - - +

    equations

    + Array + + + + + +
    +

    Inherited from + Solver: + src/solver/Solver.js:19 +

    + + +
    + +
    +

    Current equations in the solver.

    + +
    + + + +
    -

    equationSortFunction

    - Function | Boolean - - - - - - - - - -
    - - -

    Inherited from - Solver: - - - - src/solver/Solver.js:27 - -

    - - - - -
    - -
    -

    Function that is used to sort all equations before each solve.

    - -
    - - - - - - -
    - - +

    equationSortFunction

    + Function | Boolean + + + + + +
    +

    Inherited from + Solver: + src/solver/Solver.js:27 +

    + + +
    + +
    +

    Function that is used to sort all equations before each solve.

    + +
    + + + +
    -

    frictionIterations

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/solver/GSSolver.js:48 - -

    - - - - -
    - -
    -

    Number of solver iterations that are done to approximate normal forces. When these iterations are done, friction force will be computed from the contact normal forces. These friction forces will override any other friction forces set from the World for example. -The solver will use less iterations if the solution is below the .tolerance.

    - -
    - - - - - - -
    - - +

    frictionIterations

    + Number + + + + + +
    +

    + Defined in + src/solver/GSSolver.js:48 +

    + + +
    + +
    +

    Number of solver iterations that are done to approximate normal forces. When these iterations are done, friction force will be computed from the contact normal forces. These friction forces will override any other friction forces set from the World for example. + The solver will use less iterations if the solution is below the .tolerance.

    + +
    + + + +
    -

    iterations

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/solver/GSSolver.js:22 - -

    - - - - -
    - -
    -

    The number of iterations to do when solving. More gives better results, but is more expensive.

    - -
    - - - - - - -
    - - +

    iterations

    + Number + + + + + +
    +

    + Defined in + src/solver/GSSolver.js:22 +

    + + +
    + +
    +

    The number of iterations to do when solving. More gives better results, but is more expensive.

    + +
    + + + +
    -

    tolerance

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/solver/GSSolver.js:29 - -

    - - - - -
    - -
    -

    The error tolerance, per constraint. If the total error is below this limit, the solver will stop iterating. Set to zero for as good solution as possible, but to something larger than zero to make computations faster.

    - -
    - - - - - - -
    - - +

    tolerance

    + Number + + + + + +
    +

    + Defined in + src/solver/GSSolver.js:29 +

    + + +
    + +
    +

    The error tolerance, per constraint. If the total error is below this limit, the solver will stop iterating. Set to zero for as good solution as possible, but to something larger than zero to make computations faster.

    + +
    + + + +
    -

    usedIterations

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/solver/GSSolver.js:56 - -

    - - - - -
    - -
    -

    The number of iterations that were made during the last solve. If .tolerance is zero, this value will always be equal to .iterations, but if .tolerance is larger than zero, and the solver can quit early, then this number will be somewhere between 1 and .iterations.

    - -
    - - - - - - -
    - - +

    usedIterations

    + Number + + + + + +
    +

    + Defined in + src/solver/GSSolver.js:56 +

    + + +
    + +
    +

    The number of iterations that were made during the last solve. If .tolerance is zero, this value will always be equal to .iterations, but if .tolerance is larger than zero, and the solver can quit early, then this number will be somewhere between 1 and .iterations.

    + +
    + + + +
    -

    useZeroRHS

    - Boolean - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/solver/GSSolver.js:41 - -

    - - - - -
    - -
    -

    Set to true to set all right hand side terms to zero when solving. Can be handy for a few applications.

    - -
    - - - - - - -
    - - +

    useZeroRHS

    + Boolean + + + + + +
    +

    + Defined in + src/solver/GSSolver.js:41 +

    + + +
    + +
    +

    Set to true to set all right hand side terms to zero when solving. Can be handy for a few applications.

    + +
    + + + +
    - - - - diff --git a/docs/classes/GearConstraint.html b/docs/classes/GearConstraint.html index 7f43b805..1baef383 100644 --- a/docs/classes/GearConstraint.html +++ b/docs/classes/GearConstraint.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,530 +25,343 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    GearConstraint Class

    +

    GearConstraint Class

    - -
    Extends Constraint
    - - - - -
    -

    Connects two bodies at given offset points, letting them rotate relative to each other around this point.

    -

    Constructor

    -

    GearConstraint

    - - -
    - (
      - -
    • - - bodyA - -
    • - -
    • - - bodyB - -
    • - -
    • - - [options] - -
    • - -
    ) -
    - - - - - - - - - - - - - - - - -
    +

    GearConstraint

    + +
    + (
      +
    • + bodyA +
    • +
    • + bodyB +
    • +
    • + [options] +
    • +
    ) +
    - - -

    - - Defined in + + + + + + + +

    +

    + Defined in + src/constraints/GearConstraint.js:8 +

    + + + +
    + +
    - +
    +
    +

    Parameters:

    - src/constraints/GearConstraint.js:8 +
      +
    • + bodyA + Body -

      - - - +
      + +
      + +
    • +
    • + bodyB + Body + + +
      + +
      + +
    • +
    • + [options] + Object + optional + + +
      + +
      + +
        +
      • + [angle=0] + Number + optional + +
        +

        Relative angle between the bodies. Will be set to the current angle between the bodies (the gear ratio is accounted for).

        + +
        + +
      • +
      • + [ratio=1] + Number + optional + +
        +

        Gear ratio.

        + +
        + +
      • +
      • + [maxTorque] + Number + optional + +
        +

        Maximum torque to apply.

        + +
        + +
      • +
      +
    • +
    +
    + -
    - -
    -
    - - -
    -

    Parameters:

    - -
      - -
    • - - bodyA - Body - - - - -
      - -
      - - -
    • - -
    • - - bodyB - Body - - - - -
      - -
      - - -
    • - -
    • - - [options] - Object - optional - - - - -
      - -
      - - -
        - -
      • - - [angle=0] - Number - optional - - -
        -

        Relative angle between the bodies. Will be set to the current angle between the bodies (the gear ratio is accounted for).

        - -
        - - -
      • - -
      • - - [ratio=1] - Number - optional - - -
        -

        Gear ratio.

        - -
        - - -
      • - -
      • - - [maxTorque] - Number - optional - - -
        -

        Maximum torque to apply.

        - -
        - - -
      • - -
      - -
    • - -
    - - - - - -
    -
    -

    Item Index

    -

    Methods

    - -

    Properties

    - - -
    -

    Methods

    - -
    +

    getMaxTorque

    - () - - Number - - - - - - -
    @@ -558,76 +369,43 @@

    getMaxTorque

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    setMaxTorque

    -
    (
      -
    • - torque -
    • -
    )
    - - - - - - - -
    @@ -635,84 +413,52 @@

    setMaxTorque

    -

    Parameters:

      -
    • - torque Number - -
      -
    • -
    - - - -
    - -
    +
    +

    setRelaxation

    -
    (
      -
    • - relaxation -
    • -
    )
    - - - - - - - -
    @@ -720,84 +466,52 @@

    setRelaxation

    -

    Parameters:

      -
    • - relaxation Number - -
      -
    • -
    - - - -
    - -
    +
    +

    setStiffness

    -
    (
      -
    • - stiffness -
    • -
    )
    - - - - - - - -
    @@ -805,74 +519,46 @@

    setStiffness

    -

    Parameters:

      -
    • - stiffness Number - -
      -
    • -
    - - - -
    - -
    +
    +

    update

    - () - - - - - - - -
    @@ -880,291 +566,196 @@

    update

    - - - -
    - +
    - -

    Properties

    -
    -

    angle

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/constraints/GearConstraint.js:34 - -

    - - - - -
    - -
    -

    The relative angle

    - -
    - - - - - - -
    - - +

    angle

    + Number + + + + + +
    +

    + Defined in + src/constraints/GearConstraint.js:34 +

    + + +
    + +
    +

    The relative angle

    + +
    + + + +
    -

    bodyA

    - Body - - - - - - - - - -
    - - -

    Inherited from - Constraint: - - - - src/constraints/Constraint.js:33 - -

    - - - - -
    - -
    -

    First body participating in the constraint.

    - -
    - - - - - - -
    - - +

    bodyA

    + Body + + + + + +
    +

    Inherited from + Constraint: + src/constraints/Constraint.js:38 +

    + + +
    + +
    +

    First body participating in the constraint.

    + +
    + + + +
    -

    bodyB

    - Body - - - - - - - - - -
    - - -

    Inherited from - Constraint: - - - - src/constraints/Constraint.js:40 - -

    - - - - -
    - -
    -

    Second body participating in the constraint.

    - -
    - - - - - - -
    - - +

    bodyB

    + Body + + + + + +
    +

    Inherited from + Constraint: + src/constraints/Constraint.js:45 +

    + + +
    + +
    +

    Second body participating in the constraint.

    + +
    + + + +
    -

    collideConnected

    - Boolean - - - - - - - - - -
    - - -

    Inherited from - Constraint: - - - - src/constraints/Constraint.js:47 - -

    - - - - -
    - -
    -

    Set to true if you want the connected bodies to collide.

    - -
    - - -

    Default: true

    - - - - - -
    - - +

    collideConnected

    + Boolean + + + + + +
    +

    Inherited from + Constraint: + src/constraints/Constraint.js:52 +

    + + +
    + +
    +

    Set to true if you want the connected bodies to collide.

    + +
    + +

    Default: true

    + + +
    -

    equations

    - Array - - - - - - - - - -
    - - -

    Inherited from - Constraint: - - - - src/constraints/Constraint.js:25 - -

    - - - - -
    - -
    -

    Equations to be solved in this constraint

    - -
    - - - - - - -
    - - +

    equations

    + Array + + + + + +
    +

    Inherited from + Constraint: + src/constraints/Constraint.js:30 +

    + + +
    + +
    +

    Equations to be solved in this constraint

    + +
    + + + +
    -

    ratio

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/constraints/GearConstraint.js:27 - -

    - - - - -
    - -
    -

    The gear ratio.

    - -
    - - - - - - -
    - - +

    ratio

    + Number + + + + + +
    +

    + Defined in + src/constraints/GearConstraint.js:27 +

    + + +
    + +
    +

    The gear ratio.

    + +
    + + + +
    +
    +

    type

    + Number + + + + + +
    +

    Inherited from + Constraint: + src/constraints/Constraint.js:19 +

    + + +
    + +
    +

    The type of constraint. May be one of Constraint.DISTANCE, Constraint.GEAR, Constraint.LOCK, Constraint.PRISMATIC or Constraint.REVOLUTE.

    + +
    + + + +
    - - - - diff --git a/docs/classes/GridBroadphase.html b/docs/classes/GridBroadphase.html index ca2db6a1..2d370fd8 100644 --- a/docs/classes/GridBroadphase.html +++ b/docs/classes/GridBroadphase.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,521 +25,342 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    GridBroadphase Class

    +

    GridBroadphase Class

    - -
    Extends Broadphase
    - - - - -
    -

    Broadphase that uses axis-aligned bins.

    -

    Constructor

    -

    GridBroadphase

    - - -
    - (
      - -
    • - - [options] - -
    • - -
    ) -
    - - - - - - - - - - - - - - - - -
    +

    GridBroadphase

    + +
    + (
      +
    • + [options] +
    • +
    ) +
    - - -

    - - Defined in + + + + + + + +

    +

    + Defined in + src/collision/GridBroadphase.js:10 +

    + + + +
    + +
    - +
    +
    +

    Parameters:

    - src/collision/GridBroadphase.js:10 +
      +
    • + [options] + Object + optional -

      - - - +
      + +
      + +
        +
      • + [xmin] + Number + optional + +
        +

        Lower x bound of the grid

        + +
        + +
      • +
      • + [xmax] + Number + optional + +
        +

        Upper x bound

        + +
        + +
      • +
      • + [ymin] + Number + optional + +
        +

        Lower y bound

        + +
        + +
      • +
      • + [ymax] + Number + optional + +
        +

        Upper y bound

        + +
        + +
      • +
      • + [nx] + Number + optional + +
        +

        Number of bins along x axis

        + +
        + +
      • +
      • + [ny] + Number + optional + +
        +

        Number of bins along y axis

        + +
        + +
      • +
      +
    • +
    +
    + -
    - -
    -
    - - -
    -

    Parameters:

    - -
      - -
    • - - [options] - Object - optional - - - - -
      - -
      - - -
        - -
      • - - [xmin] - Number - optional - - -
        -

        Lower x bound of the grid

        - -
        - - -
      • - -
      • - - [xmax] - Number - optional - - -
        -

        Upper x bound

        - -
        - - -
      • - -
      • - - [ymin] - Number - optional - - -
        -

        Lower y bound

        - -
        - - -
      • - -
      • - - [ymax] - Number - optional - - -
        -

        Upper y bound

        - -
        - - -
      • - -
      • - - [nx] - Number - optional - - -
        -

        Number of bins along x axis

        - -
        - - -
      • - -
      • - - [ny] - Number - optional - - -
        -

        Number of bins along y axis

        - -
        - - -
      • - -
      - -
    • - -
    - - - - - -
    -
    -

    Item Index

    -

    Methods

    - -

    Properties

    - - -
    -

    Methods

    - -
    +

    boundingRadiusCheck

    -
    (
      -
    • - bodyA -
    • -
    • - bodyB -
    • -
    )
    - - Boolean - - - - - - -
    -

    Inherited from Broadphase - but overwritten in - - - src/collision/Broadphase.js:72 -

    - -
    @@ -549,121 +368,75 @@

    boundingRadiusCheck

    -

    Parameters:

      -
    • - bodyA Body - -
      -
    • -
    • - bodyB Body - -
      -
    • -
    - -

    Returns:

    - - Boolean: - -
    - - -
    - -
    +
    +

    canCollide

    -
    (
      -
    • - bodyA -
    • -
    • - bodyB -
    • -
    )
    - - Boolean - - - - - - -
    @@ -671,118 +444,75 @@

    canCollide

    -

    Parameters:

      -
    • - bodyA Body - -
      -
    • -
    • - bodyB Body - -
      -
    • -
    - -

    Returns:

    - - Boolean: - -
    - - -
    - -
    +
    +

    getCollisionPairs

    -
    (
      -
    • - world -
    • -
    )
    - - Array - - - - - - -
    -

    Inherited from Broadphase - but overwritten in - - - - src/collision/GridBroadphase.js:48 - + src/collision/GridBroadphase.js:49

    - -
    @@ -790,96 +520,59 @@

    getCollisionPairs

    -

    Parameters:

      -
    • - world World - -
      -
    • -
    - -

    Returns:

    - - Array: - -
    - - -
    - -
    +
    +

    setWorld

    -
    (
      -
    • - world -
    • -
    )
    - - - - - - - -
    - -

    Inherited from Broadphase: - - - src/collision/Broadphase.js:51 -

    - -
    @@ -887,180 +580,111 @@

    setWorld

    -

    Parameters:

      -
    • - world World - -
      -
    • -
    - - - -
    - +
    - -

    Properties

    -
    -

    boundingVolumeType

    - Number - - - - - - - - - -
    - - -

    Inherited from - Broadphase: - - - - src/collision/Broadphase.js:30 - -

    - - - - -
    - -
    -

    The bounding volume type to use in the broadphase algorithms.

    - -
    - - - - - - -
    - - +

    boundingVolumeType

    + Number + + + + + +
    +

    Inherited from + Broadphase: + src/collision/Broadphase.js:30 +

    + + +
    + +
    +

    The bounding volume type to use in the broadphase algorithms.

    + +
    + + + +
    -

    result

    - Array - - - - - - - - - -
    - - -

    Inherited from - Broadphase: - - - - src/collision/Broadphase.js:15 - -

    - - - - -
    - -
    -

    The resulting overlapping pairs. Will be filled with results during .getCollisionPairs().

    - -
    - - - - - - -
    - - +

    result

    + Array + + + + + +
    +

    Inherited from + Broadphase: + src/collision/Broadphase.js:15 +

    + + +
    + +
    +

    The resulting overlapping pairs. Will be filled with results during .getCollisionPairs().

    + +
    + + + +
    -

    world

    - World - - - - - - - - - -
    - - -

    Inherited from - Broadphase: - - - - src/collision/Broadphase.js:22 - -

    - - - - -
    - -
    -

    The world to search for collision pairs in. To change it, use .setWorld()

    - -
    - - - - - - -
    - - +

    world

    + World + + + + + +
    +

    Inherited from + Broadphase: + src/collision/Broadphase.js:22 +

    + + +
    + +
    +

    The world to search for collision pairs in. To change it, use .setWorld()

    + +
    + + + +
    - - -
    -
    diff --git a/docs/classes/Heightfield.html b/docs/classes/Heightfield.html index 569709e3..e93ff69b 100644 --- a/docs/classes/Heightfield.html +++ b/docs/classes/Heightfield.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,792 +25,515 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    Heightfield Class

    +

    Heightfield Class

    - -
    Extends Shape
    - - - - -
    -

    Heightfield shape class. Height data is given as an array. These data points are spread out evenly with a distance "elementWidth".

    -

    Constructor

    -

    Heightfield

    - - -
    - (
      - -
    • - - data - -
    • - -
    • - - options - -
    • - -
    ) -
    - - - - - - - - - - - - - - - - -
    +

    Heightfield

    + +
    + (
      +
    • + data +
    • +
    • + options +
    • +
    ) +
    - - -

    - - Defined in + + + + + + + +

    +

    + Defined in + src/shapes/Heightfield.js:7 +

    + + + +
    + +
    - +
    +
    +

    Parameters:

    - src/shapes/Heightfield.js:7 +
      +
    • + data + Array -

      - - - +
      +

      An array of Y values that will be used to construct the terrain.

      -
      - -
      +
      -
    - - -
    -

    Parameters:

    - -
      - -
    • - - data - Array - - - - -
      -

      An array of Y values that will be used to construct the terrain.

      - -
      - - -
    • - -
    • - - options - Object - - - - -
      - +
    • +
    • + options + Object + + +
      + +
      + +
        +
      • + [minValue] + Number + optional + +
        +

        Minimum value of the data points in the data array. Will be computed automatically if not given.

        + +
        + +
      • +
      • + [maxValue] + Number + optional + +
        +

        Maximum value.

        + +
        + +
      • +
      • + [elementWidth=0.1] + Number + optional + +
        +

        World spacing between the data points in X direction.

        + +
        + +
      • +
      +
    • +
    +
    + + + +
    +

    Example:

    + +
    +
    // Generate some height data (y-values).
    +        var data = [];
    +        for(var i = 0; i < 1000; i++){
    +            var y = 0.5 * Math.cos(0.2 * i);
    +            data.push(y);
    +        }
    +        
    +        // Create the heightfield shape
    +        var heightfieldShape = new Heightfield(data, {
    +            elementWidth: 1 // Distance between the data points in X direction
    +        });
    +        var heightfieldBody = new Body();
    +        heightfieldBody.addShape(heightfieldShape);
    +        world.addBody(heightfieldBody);
    +        
    - - -
      - -
    • - - [minValue] - Number - optional - - -
      -

      Minimum value of the data points in the data array. Will be computed automatically if not given.

      - -
      - - -
    • - -
    • - - [maxValue] - Number - optional - - -
      -

      Maximum value.

      - -
      - - -
    • - -
    • - - [elementWidth=0.1] - Number - optional - - -
      -

      World spacing between the data points in X direction.

      - -
      - - -
    • - -
    - - - - -
    - - - - - -
    -

    Example:

    - -
    -
    // Generate some height data (y-values).
    -var data = [];
    -for(var i = 0; i < 1000; i++){
    -    var y = 0.5 * Math.cos(0.2 * i);
    -    data.push(y);
    -}
    -
    -// Create the heightfield shape
    -var heightfieldShape = new Heightfield(data, {
    -    elementWidth: 1 // Distance between the data points in X direction
    -});
    -var heightfieldBody = new Body();
    -heightfieldBody.addShape(heightfieldShape);
    -world.addBody(heightfieldBody);
    - -
    +
    - -
    -
    -

    Item Index

    - - -

    Properties

    - - -
    -

    Methods

    - -
    +

    computeAABB

    -
    (
      -
    • - out -
    • -
    • - position -
    • -
    • - angle -
    • -
    )
    - - - - - - - -
    -

    Inherited from Shape - but overwritten in - - - - src/shapes/Heightfield.js:106 - + src/shapes/Heightfield.js:107

    - -
    -

    Parameters:

      -
    • - out AABB - -

      The resulting AABB.

      -
    • -
    • - position Array - -
      -
    • -
    • - angle Number - -
      -
    • -
    - - - -
    - -
    +
    +

    computeMomentOfInertia

    -
    (
      -
    • - mass -
    • -
    )
    - - Number - - - - - - -
    -

    Inherited from Shape - but overwritten in - - - - src/shapes/Heightfield.js:84 - + src/shapes/Heightfield.js:85

    - -
    -

    Parameters:

      -
    • - mass Number - -
      -
    • -
    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    updateArea

    - () - - - - - - - -
    - -

    Inherited from Shape: - - - - src/shapes/Shape.js:174 - + src/shapes/Shape.js:180

    - -
    @@ -820,55 +541,33 @@

    updateArea

    - - - -
    - -
    +
    +

    updateBoundingRadius

    - () - - Number - - - - - - -
    - -

    Inherited from Shape: - - - - src/shapes/Shape.js:165 - + src/shapes/Shape.js:171

    - -
    @@ -876,598 +575,390 @@

    updateBoundingRadius

    - -

    Returns:

    - - Number: - -
    - - -
    - +
    - -

    Properties

    -
    -

    area

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:89 - -

    - - - - -
    - -
    -

    Area of this shape.

    - -
    - - - - - - -
    - - +

    area

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:95 +

    + + +
    + +
    +

    Area of this shape.

    + +
    + + + +
    -

    boundingRadius

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:34 - -

    - - - - -
    - -
    -

    Bounding circle radius of this shape

    - -
    - - - - - - -
    - - +

    boundingRadius

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:34 +

    + + +
    + +
    +

    Bounding circle radius of this shape

    + +
    + + + +
    -

    collisionGroup

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:41 - -

    - - - - -
    - -
    -

    Collision group that this shape belongs to (bit mask). See this tutorial.

    - -
    - - - - -
    -

    Example:

    - -
    -
    // Setup bits for each available group
    -var PLAYER = Math.pow(2,0),
    -    ENEMY =  Math.pow(2,1),
    -    GROUND = Math.pow(2,2)
    -
    -// Put shapes into their groups
    -player1Shape.collisionGroup = PLAYER;
    -player2Shape.collisionGroup = PLAYER;
    -enemyShape  .collisionGroup = ENEMY;
    -groundShape .collisionGroup = GROUND;
    -
    -// Assign groups that each shape collide with.
    -// Note that the players can collide with ground and enemies, but not with other players.
    -player1Shape.collisionMask = ENEMY | GROUND;
    -player2Shape.collisionMask = ENEMY | GROUND;
    -enemyShape  .collisionMask = PLAYER | GROUND;
    -groundShape .collisionMask = PLAYER | ENEMY;
    -
    // How collision check is done
    -if(shapeA.collisionGroup & shapeB.collisionMask)!=0 && (shapeB.collisionGroup & shapeA.collisionMask)!=0){
    -    // The shapes will collide
    -}
    - -
    -
    - - - -
    - - +

    collisionGroup

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:41 +

    + + +
    + +
    +

    Collision group that this shape belongs to (bit mask). See this tutorial.

    + +
    + + +
    +

    Example:

    + +
    +
    // Setup bits for each available group
    +                    var PLAYER = Math.pow(2,0),
    +                        ENEMY =  Math.pow(2,1),
    +                        GROUND = Math.pow(2,2)
    +                    
    +                    // Put shapes into their groups
    +                    player1Shape.collisionGroup = PLAYER;
    +                    player2Shape.collisionGroup = PLAYER;
    +                    enemyShape  .collisionGroup = ENEMY;
    +                    groundShape .collisionGroup = GROUND;
    +                    
    +                    // Assign groups that each shape collide with.
    +                    // Note that the players can collide with ground and enemies, but not with other players.
    +                    player1Shape.collisionMask = ENEMY | GROUND;
    +                    player2Shape.collisionMask = ENEMY | GROUND;
    +                    enemyShape  .collisionMask = PLAYER | GROUND;
    +                    groundShape .collisionMask = PLAYER | ENEMY;
    +                    
    // How collision check is done
    +                    if(shapeA.collisionGroup & shapeB.collisionMask)!=0 && (shapeB.collisionGroup & shapeA.collisionMask)!=0){
    +                        // The shapes will collide
    +                    }
    +                    
    +
    +
    + +
    -

    collisionMask

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:72 - -

    - - - - -
    - -
    -

    Collision mask of this shape. See .collisionGroup.

    - -
    - - - - - - -
    - - +

    collisionMask

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:78 +

    + + +
    + +
    +

    Collision mask of this shape. See .collisionGroup.

    + +
    + + + +
    +
    +

    collisionResponse

    + Boolean + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:72 +

    + + +
    + +
    +

    Whether to produce contact forces when in contact with other bodies. Note that contacts will be generated, but they will be disabled. That means that this shape will move through other body shapes, but it will still trigger contact events, etc.

    + +
    + + + +
    -

    data

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/shapes/Heightfield.js:56 - -

    - - - - -
    - -
    -

    An array of numbers, or height values, that are spread out along the x axis.

    - -
    - - - - - - -
    - - +

    data

    + Array + + + + + +
    +

    + Defined in + src/shapes/Heightfield.js:56 +

    + + +
    + +
    +

    An array of numbers, or height values, that are spread out along the x axis.

    + +
    + + + +
    -

    elementWidth

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/shapes/Heightfield.js:74 - -

    - - - - -
    - -
    -

    The width of each element

    - -
    - - - - - - -
    - - +

    elementWidth

    + Number + + + + + +
    +

    + Defined in + src/shapes/Heightfield.js:74 +

    + + +
    + +
    +

    The width of each element

    + +
    + + + +
    -

    id

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:27 - -

    - - - - -
    - -
    -

    Shape object identifier.

    - -
    - - - - - - -
    - - +

    id

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:27 +

    + + +
    + +
    +

    Shape object identifier.

    + +
    + + + +
    -

    material

    - Material - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:82 - -

    - - - - -
    - -
    -

    Material to use in collisions for this Shape. If this is set to null, the world will use default material properties instead.

    - -
    - - - - - - -
    - - +

    material

    + Material + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:88 +

    + + +
    + +
    +

    Material to use in collisions for this Shape. If this is set to null, the world will use default material properties instead.

    + +
    + + + +
    -

    maxValue

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/shapes/Heightfield.js:62 - -

    - - - - -
    - -
    -

    Max value of the data

    - -
    - - - - - - -
    - - +

    maxValue

    + Number + + + + + +
    +

    + Defined in + src/shapes/Heightfield.js:62 +

    + + +
    + +
    +

    Max value of the data

    + +
    + + + +
    -

    minValue

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/shapes/Heightfield.js:68 - -

    - - - - -
    - -
    -

    Max value of the data

    - -
    - - - - - - -
    - - +

    minValue

    + Number + + + + + +
    +

    + Defined in + src/shapes/Heightfield.js:68 +

    + + +
    + +
    +

    Max value of the data

    + +
    + + + +
    -

    sensor

    - Boolean - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:96 - -

    - - - - -
    - -
    -

    Set to true if you want this shape to be a sensor. A sensor does not generate contacts, but it still reports contact events. This is good if you want to know if a shape is overlapping another shape, without them generating contacts.

    - -
    - - - - - - -
    - - +

    sensor

    + Boolean + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:102 +

    + + +
    + +
    +

    Set to true if you want this shape to be a sensor. A sensor does not generate contacts, but it still reports contact events. This is good if you want to know if a shape is overlapping another shape, without them generating contacts.

    + +
    + + + +
    -

    type

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:11 - -

    - - - - -
    - - - - - - - - -
    - - +

    type

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:11 +

    + + +
    + + + + + + - - - - diff --git a/docs/classes/Island.html b/docs/classes/Island.html index 9e35b8b3..a1f622a3 100644 --- a/docs/classes/Island.html +++ b/docs/classes/Island.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,366 +25,232 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    Island Class

    +

    Island Class

    - - -
    Defined in: src/world/Island.js:5
    - - -
    -

    An island of bodies connected with equations.

    -

    Constructor

    -

    Island

    - - - () - - - - - - - - - - - - - - - - -
    +

    Island

    - - -

    - - Defined in - - + () - src/world/Island.js:5 -

    - - - -
    - -
    + + +
    +

    + Defined in + src/world/Island.js:5 +

    + + + +
    + +
    + +
    + + + + +
    - - - - - -
    - -
    - -

    Item Index

    -

    Methods

    - -

    Properties

    - - -
    -

    Methods

    - -
    +

    getBodies

    - () - - Array - - - - - - -
    - - -

    - Defined in - - - - src/world/Island.js:37 -

    - -
    @@ -394,68 +258,39 @@

    getBodies

    - -

    Returns:

    - - Array: -

    An array of Body

    -
    - - -
    - -
    +
    +

    reset

    - () - - - - - - - -
    - - -

    - Defined in - - - - src/world/Island.js:27 -

    - -
    @@ -463,54 +298,30 @@

    reset

    - - - -
    - -
    +
    +

    sleep

    - () - - - - - - - -
    - - -

    - Defined in - - - - src/world/Island.js:75 -

    - -
    @@ -518,58 +329,33 @@

    sleep

    - - - -
    - -
    +
    +

    wantsToSleep

    - () - - Boolean - - - - - - -
    - - -

    - Defined in - - - - src/world/Island.js:60 -

    - -
    @@ -577,133 +363,77 @@

    wantsToSleep

    - -

    Returns:

    - - Boolean: - -
    - - -
    - +
    - -

    Properties

    -
    -

    bodies

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/Island.js:19 - -

    - - - - -
    - -
    -

    Current bodies in this island.

    - -
    - - - - - - -
    - - +

    bodies

    + Array + + + + + +
    +

    + Defined in + src/world/Island.js:19 +

    + + +
    + +
    +

    Current bodies in this island.

    + +
    + + + +
    -

    equations

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/Island.js:12 - -

    - - - - -
    - -
    -

    Current equations in this island.

    - -
    - - - - - - -
    - - +

    equations

    + Array + + + + + +
    +

    + Defined in + src/world/Island.js:12 +

    + + +
    + +
    +

    Current equations in this island.

    + +
    + + + +
    - - -
    -
    diff --git a/docs/classes/IslandManager.html b/docs/classes/IslandManager.html index 37fde99d..5eb0238d 100644 --- a/docs/classes/IslandManager.html +++ b/docs/classes/IslandManager.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,507 +25,318 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    IslandManager Class

    +

    IslandManager Class

    - -
    Extends Solver
    - - - - -
    -

    Splits the system of bodies and equations into independent islands

    -

    Constructor

    -

    IslandManager

    - - -
    - (
      - -
    • - - [options] - -
    • - -
    ) -
    - - - - - - - - - - - - - - - - -
    +

    IslandManager

    + +
    + (
      +
    • + [options] +
    • +
    ) +
    - - -

    - - Defined in + + + + + + + +

    +

    + Defined in + src/world/IslandManager.js:8 +

    + + + +
    + +
    - +
    +
    +

    Parameters:

    - src/world/IslandManager.js:8 +
      +
    • + [options] + Object + optional -

      - - - +
      + +
      + +
    • +
    +
    + -
    - -
    -
    - - -
    -

    Parameters:

    - -
      - -
    • - - [options] - Object - optional - - - - -
      - -
      - - -
    • - -
    - - - - - -
    -
    -

    Item Index

    -

    Methods

    - -

    Properties

    - - -
    -

    Methods

    - -
    +

    addEquation

    -
    (
      -
    • - eq -
    • -
    )
    - - - - - - - -
    - -

    Inherited from Solver: - - - - src/solver/Solver.js:81 - + src/solver/Solver.js:82

    - -
    @@ -535,84 +344,52 @@

    addEquation

    -

    Parameters:

    - - - -
    - -
    +
    +

    addEquations

    -
    (
      -
    • - eqs -
    • -
    )
    - - - - - - - -
    - -

    Inherited from Solver: - - - - src/solver/Solver.js:93 - + src/solver/Solver.js:94

    - -
    @@ -620,99 +397,58 @@

    addEquations

    -

    Parameters:

      -
    • - eqs Array - -
      -
    • -
    - - - -
    - -
    +
    +

    bfs

    -
    (
      -
    • - root -
    • -
    • - bds -
    • -
    • - eqs -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - src/world/IslandManager.js:84 -

    - -
    @@ -720,121 +456,78 @@

    bfs

    -

    Parameters:

      -
    • - root IslandNode - -

      The node to start from

      -
    • -
    • - bds Array - -

      An array to append resulting Bodies to.

      -
    • -
    • - eqs Array - -

      An array to append resulting Equations to.

      -
    • -
    - - - -
    - -
    +
    +

    emit

    -
    (
      -
    • - event -
    • -
    )
    - - EventEmitter - - - - - - -
    - -

    Inherited from EventEmitter: - - - src/events/EventEmitter.js:79 -

    - -
    @@ -842,124 +535,76 @@

    emit

    -

    Parameters:

      -
    • - event Object - -
      -
        -
      • - type String -
        -
      • -
      -
    • -
    - -

    Returns:

    - - EventEmitter: -

    The self object, for chainability.

    -
    - - -
    - -
    +
    +

    getUnvisitedNode

    -
    (
      -
    • - nodes -
    • -
    )
    - - IslandNode | Boolean - - - - - static - - -
    - - -

    - Defined in - - - - src/world/IslandManager.js:48 -

    - -
    @@ -967,108 +612,67 @@

    getUnvisitedNode

    -

    Parameters:

      -
    • - nodes Array - -
      -
    • -
    - -

    Returns:

    - - IslandNode | Boolean: -

    The node if found, else false.

    -
    - - -
    - -
    +
    +

    has

    -
    (
      -
    • - type -
    • -
    • - listener -
    • -
    )
    - - Boolean - - - - - - -
    - -

    Inherited from EventEmitter: - - - src/events/EventEmitter.js:35 -

    - -
    @@ -1076,121 +680,75 @@

    has

    -

    Parameters:

      -
    • - type String - -
      -
    • -
    • - listener Function - -
      -
    • -
    - -

    Returns:

    - - Boolean: - -
    - - -
    - -
    +
    +

    off

    -
    (
      -
    • - type -
    • -
    • - listener -
    • -
    )
    - - EventEmitter - - - - - - -
    - -

    Inherited from EventEmitter: - - - src/events/EventEmitter.js:60 -

    - -
    @@ -1198,123 +756,77 @@

    off

    -

    Parameters:

      -
    • - type String - -
      -
    • -
    • - listener Function - -
      -
    • -
    - -

    Returns:

    - - EventEmitter: -

    The self object, for chainability.

    -
    - - -
    - -
    +
    +

    on

    -
    (
      -
    • - type -
    • -
    • - listener -
    • -
    )
    - - EventEmitter - - - - - - -
    - -

    Inherited from EventEmitter: - - - src/events/EventEmitter.js:13 -

    - -
    @@ -1322,103 +834,65 @@

    on

    -

    Parameters:

      -
    • - type String - -
      -
    • -
    • - listener Function - -
      -
    • -
    - -

    Returns:

    - - EventEmitter: -

    The self object, for chainability.

    -
    - - -
    - -
    +
    +

    removeAllEquations

    - () - - - - - - - -
    - -

    Inherited from Solver: - - - - src/solver/Solver.js:122 - + src/solver/Solver.js:123

    - -
    @@ -1426,61 +900,36 @@

    removeAllEquations

    - - - -
    - -
    +
    +

    removeEquation

    -
    (
      -
    • - eq -
    • -
    )
    - - - - - - - -
    - -

    Inherited from Solver: - - - - src/solver/Solver.js:109 - + src/solver/Solver.js:110

    - -
    @@ -1488,90 +937,55 @@

    removeEquation

    -

    Parameters:

    - - - -
    - -
    +
    +

    solve

    -
    (
      -
    • - dt -
    • -
    • - world -
    • -
    )
    - - - - - - - -
    - -

    Inherited from Solver: - - - - src/solver/Solver.js:36 - + src/solver/Solver.js:37

    - -
    @@ -1579,105 +993,65 @@

    solve

    -

    Parameters:

      -
    • - dt Number - -
      -
    • -
    • - world World - -
      -
    • -
    - - - -
    - -
    +
    +

    solveIsland

    -
    (
      -
    • - dt -
    • -
    • - island -
    • -
    )
    - - - - - - - -
    - -

    Inherited from Solver: - - - - src/solver/Solver.js:48 - + src/solver/Solver.js:49

    - -
    @@ -1685,89 +1059,56 @@

    solveIsland

    -

    Parameters:

      -
    • - dt Number - -
      -
    • -
    • - island Island - -
      -
    • -
    - - - -
    - -
    +
    +

    sortEquations

    - () - - - - - - - -
    - -

    Inherited from Solver: - - - - src/solver/Solver.js:71 - + src/solver/Solver.js:72

    - -
    @@ -1775,68 +1116,39 @@

    sortEquations

    - - - -
    - -
    +
    +

    split

    -
    (
      -
    • - world -
    • -
    )
    - - Array - - - - - - -
    - - -

    - Defined in - - - - src/world/IslandManager.js:122 -

    - -
    @@ -1844,113 +1156,67 @@

    split

    -

    Parameters:

      -
    • - world World - -
      -
    • -
    - -

    Returns:

    - - Array: -

    The generated islands

    -
    - - -
    - -
    +
    +

    visit

    -
    (
      -
    • - node -
    • -
    • - bds -
    • -
    • - eqs -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - src/world/IslandManager.js:66 -

    - -
    @@ -1958,308 +1224,185 @@

    visit

    -

    Parameters:

      -
    • - node IslandNode - -
      -
    • -
    • - bds Array - -
      -
    • -
    • - eqs Array - -
      -
    • -
    - - - -
    - +
    - -

    Properties

    -
    -

    equations

    - Array - - - - - - - - - -
    - -

    Inherited from - - Solver - - - but overwritten in - - - - src/world/IslandManager.js:22 - -

    - - - - -
    - -
    -

    The equations to split. Manually fill this array before running .split().

    - -
    - - - - - - -
    - - +

    equations

    + Array + + + + + +
    +

    Inherited from + + Solver + + but overwritten in + src/world/IslandManager.js:22 +

    + + +
    + +
    +

    The equations to split. Manually fill this array before running .split().

    + +
    + + + +
    -

    equationSortFunction

    - Function | Boolean - - - - - - - - - -
    - - -

    Inherited from - Solver: - - - - src/solver/Solver.js:27 - -

    - - - - -
    - -
    -

    Function that is used to sort all equations before each solve.

    - -
    - - - - - - -
    - - +

    equationSortFunction

    + Function | Boolean + + + + + +
    +

    Inherited from + Solver: + src/solver/Solver.js:27 +

    + + +
    + +
    +

    Function that is used to sort all equations before each solve.

    + +
    + + + +
    -

    islands

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/IslandManager.js:28 - -

    - - - - -
    - -
    -

    The resulting Islands.

    - -
    - - - - - - -
    - - +

    islands

    + Array + + + + + +
    +

    + Defined in + src/world/IslandManager.js:28 +

    + + +
    + +
    +

    The resulting Islands.

    + +
    + + + +
    -

    nodes

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/IslandManager.js:34 - -

    - - - - -
    - -
    -

    The resulting graph nodes.

    - -
    - - - - - - -
    - - +

    nodes

    + Array + + + + + +
    +

    + Defined in + src/world/IslandManager.js:34 +

    + + +
    + +
    +

    The resulting graph nodes.

    + +
    + + + +
    -

    queue

    - Array - - - - - private - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/IslandManager.js:40 - -

    - - - - -
    - -
    -

    The node queue, used when traversing the graph of nodes.

    - -
    - - - - - - -
    - - +

    queue

    + Array + + + private + + + +
    +

    + Defined in + src/world/IslandManager.js:40 +

    + + +
    + +
    +

    The node queue, used when traversing the graph of nodes.

    + +
    + + + +
    - - -
    - diff --git a/docs/classes/IslandNode.html b/docs/classes/IslandNode.html index af45e7e4..c6e5ef25 100644 --- a/docs/classes/IslandNode.html +++ b/docs/classes/IslandNode.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,388 +25,247 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    IslandNode Class

    +

    IslandNode Class

    - - - - - -
    -

    Holds a body and keeps track of some additional properties needed for graph traversal.

    -

    Constructor

    -

    IslandNode

    - - -
    - (
      - -
    • - - body - -
    • - -
    ) -
    - - - - - - - - - - - - - - - - -
    +

    IslandNode

    + +
    + (
      +
    • + body +
    • +
    ) +
    - - -

    - - Defined in + + + + + + + +

    +

    + Defined in + src/world/IslandNode.js:3 +

    + + + +
    + +
    - +
    +
    +

    Parameters:

    - src/world/IslandNode.js:3 +
      +
    • + body + Body -

      - - - +
      + +
      + +
    • +
    +
    + -
    - -
    -
    - - -
    -

    Parameters:

    - -
      - -
    • - - body - Body - - - - -
      - -
      - - -
    • - -
    - - - - - -
    -
    -

    Item Index

    -

    Methods

    - -

    Properties

    - - -
    -

    Methods

    - -
    +

    reset

    - () - - - - - - - -
    - - -

    - Defined in - - - - src/world/IslandNode.js:37 -

    - -
    @@ -416,211 +273,120 @@

    reset

    - - - -
    - +
    - -

    Properties

    -
    -

    body

    - Body - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/IslandNode.js:11 - -

    - - - - -
    - -
    -

    The body that is contained in this node.

    - -
    - - - - - - -
    - - +

    body

    + Body + + + + + +
    +

    + Defined in + src/world/IslandNode.js:11 +

    + + +
    + +
    +

    The body that is contained in this node.

    + +
    + + + +
    -

    equations

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/IslandNode.js:23 - -

    - - - - -
    - -
    -

    Equations connected to this node.

    - -
    - - - - - - -
    - - +

    equations

    + Array + + + + + +
    +

    + Defined in + src/world/IslandNode.js:23 +

    + + +
    + +
    +

    Equations connected to this node.

    + +
    + + + +
    -

    neighbors

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/IslandNode.js:17 - -

    - - - - -
    - -
    -

    Neighboring IslandNodes

    - -
    - - - - - - -
    - - +

    neighbors

    + Array + + + + + +
    +

    + Defined in + src/world/IslandNode.js:17 +

    + + +
    + +
    +

    Neighboring IslandNodes

    + +
    + + + +
    -

    visited

    - Boolean - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/IslandNode.js:29 - -

    - - - - -
    - -
    -

    If this node was visiting during the graph traversal.

    - -
    - - - - - - -
    - - +

    visited

    + Boolean + + + + + +
    +

    + Defined in + src/world/IslandNode.js:29 +

    + + +
    + +
    +

    If this node was visiting during the graph traversal.

    + +
    + + + +
    - - -
    - diff --git a/docs/classes/Line.html b/docs/classes/Line.html index 56530cba..5a5b0398 100644 --- a/docs/classes/Line.html +++ b/docs/classes/Line.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,590 +25,379 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    Line Class

    +

    Line Class

    - -
    Extends Shape
    - -
    Defined in: src/shapes/Line.js:6
    - - -
    -

    Line shape class. The line shape is along the x direction, and stretches from [-length/2, 0] to [length/2,0].

    -

    Constructor

    -

    Line

    - - -
    - (
      - -
    • - - length - -
    • - -
    ) -
    - - - - - - - - - - - - - - - - -
    +

    Line

    + +
    + (
      +
    • + [length=1] +
    • +
    ) +
    - - -

    - - Defined in + + + + + + + +

    +

    + Defined in + src/shapes/Line.js:6 +

    + + + +
    + +
    - +
    +
    +

    Parameters:

    - src/shapes/Line.js:6 +
      +
    • + [length=1] + Number + optional -

      - - - +
      +

      The total length of the line

      + +
      + +
    • +
    +
    + -
    - -
    -
    - - -
    -

    Parameters:

    - -
      - -
    • - - length - Number - - - - -
      -

      The total length of the line

      - -
      - - -
    • - -
    - - - - - -
    -
    -

    Item Index

    - - -

    Properties

    - - -
    -

    Methods

    - -
    +

    computeAABB

    -
    (
      -
    • - out -
    • -
    • - position -
    • -
    • - angle -
    • -
    )
    - - - - - - - -
    -

    Inherited from Shape - but overwritten in - - - - src/shapes/Line.js:35 - + src/shapes/Line.js:37

    - -
    -

    Parameters:

      -
    • - out AABB - -

      The resulting AABB.

      -
    • -
    • - position Array - -
      -
    • -
    • - angle Number - -
      -
    • -
    - - - -
    - -
    +
    +

    computeMomentOfInertia

    -
    (
      -
    • - mass -
    • -
    )
    - - Number - - - - - - -
    - -

    Inherited from Shape: - - - - src/shapes/Shape.js:155 - + src/shapes/Shape.js:161

    - -
    @@ -618,88 +405,55 @@

    computeMomentOfInertia

    -

    Parameters:

      -
    • - mass Number - -
      -
    • -
    - -

    Returns:

    - - Number: -

    If the inertia is infinity or if the object simply isn't possible to rotate, return 0.

    -
    - - -
    - -
    +
    +

    updateArea

    - () - - - - - - - -
    - -

    Inherited from Shape: - - - - src/shapes/Shape.js:174 - + src/shapes/Shape.js:180

    - -
    @@ -707,55 +461,33 @@

    updateArea

    - - - -
    - -
    +
    +

    updateBoundingRadius

    - () - - Number - - - - - - -
    - -

    Inherited from Shape: - - - - src/shapes/Shape.js:165 - + src/shapes/Shape.js:171

    - -
    @@ -763,463 +495,315 @@

    updateBoundingRadius

    - -

    Returns:

    - - Number: - -
    - - -
    - +
    - -

    Properties

    -
    -

    area

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:89 - -

    - - - - -
    - -
    -

    Area of this shape.

    - -
    - - - - - - -
    - - +

    area

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:95 +

    + + +
    + +
    +

    Area of this shape.

    + +
    + + + +
    -

    boundingRadius

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:34 - -

    - - - - -
    - -
    -

    Bounding circle radius of this shape

    - -
    - - - - - - -
    - - +

    boundingRadius

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:34 +

    + + +
    + +
    +

    Bounding circle radius of this shape

    + +
    + + + +
    -

    collisionGroup

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:41 - -

    - - - - -
    - -
    -

    Collision group that this shape belongs to (bit mask). See this tutorial.

    - -
    - - - - -
    -

    Example:

    - -
    -
    // Setup bits for each available group
    -var PLAYER = Math.pow(2,0),
    -    ENEMY =  Math.pow(2,1),
    -    GROUND = Math.pow(2,2)
    -
    -// Put shapes into their groups
    -player1Shape.collisionGroup = PLAYER;
    -player2Shape.collisionGroup = PLAYER;
    -enemyShape  .collisionGroup = ENEMY;
    -groundShape .collisionGroup = GROUND;
    -
    -// Assign groups that each shape collide with.
    -// Note that the players can collide with ground and enemies, but not with other players.
    -player1Shape.collisionMask = ENEMY | GROUND;
    -player2Shape.collisionMask = ENEMY | GROUND;
    -enemyShape  .collisionMask = PLAYER | GROUND;
    -groundShape .collisionMask = PLAYER | ENEMY;
    -
    // How collision check is done
    -if(shapeA.collisionGroup & shapeB.collisionMask)!=0 && (shapeB.collisionGroup & shapeA.collisionMask)!=0){
    -    // The shapes will collide
    -}
    - -
    -
    - - - -
    - - +

    collisionGroup

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:41 +

    + + +
    + +
    +

    Collision group that this shape belongs to (bit mask). See this tutorial.

    + +
    + + +
    +

    Example:

    + +
    +
    // Setup bits for each available group
    +                    var PLAYER = Math.pow(2,0),
    +                        ENEMY =  Math.pow(2,1),
    +                        GROUND = Math.pow(2,2)
    +                    
    +                    // Put shapes into their groups
    +                    player1Shape.collisionGroup = PLAYER;
    +                    player2Shape.collisionGroup = PLAYER;
    +                    enemyShape  .collisionGroup = ENEMY;
    +                    groundShape .collisionGroup = GROUND;
    +                    
    +                    // Assign groups that each shape collide with.
    +                    // Note that the players can collide with ground and enemies, but not with other players.
    +                    player1Shape.collisionMask = ENEMY | GROUND;
    +                    player2Shape.collisionMask = ENEMY | GROUND;
    +                    enemyShape  .collisionMask = PLAYER | GROUND;
    +                    groundShape .collisionMask = PLAYER | ENEMY;
    +                    
    // How collision check is done
    +                    if(shapeA.collisionGroup & shapeB.collisionMask)!=0 && (shapeB.collisionGroup & shapeA.collisionMask)!=0){
    +                        // The shapes will collide
    +                    }
    +                    
    +
    +
    + +
    -

    collisionMask

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:72 - -

    - - - - -
    - -
    -

    Collision mask of this shape. See .collisionGroup.

    - -
    - - - - - - -
    - - +

    collisionMask

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:78 +

    + + +
    + +
    +

    Collision mask of this shape. See .collisionGroup.

    + +
    + + + +
    +
    +

    collisionResponse

    + Boolean + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:72 +

    + + +
    + +
    +

    Whether to produce contact forces when in contact with other bodies. Note that contacts will be generated, but they will be disabled. That means that this shape will move through other body shapes, but it will still trigger contact events, etc.

    + +
    + + + +
    -

    id

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:27 - -

    - - - - -
    - -
    -

    Shape object identifier.

    - -
    - - - - - - -
    - - +

    id

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:27 +

    + + +
    + +
    +

    Shape object identifier.

    + +
    + + + +
    -

    length

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/shapes/Line.js:15 - -

    - - - - -
    - -
    -

    Length of this line

    - -
    - - - - - - -
    - - +

    length

    + Number + + + + + +
    +

    + Defined in + src/shapes/Line.js:15 +

    + + +
    + +
    +

    Length of this line

    + +
    + + + +
    -

    material

    - Material - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:82 - -

    - - - - -
    - -
    -

    Material to use in collisions for this Shape. If this is set to null, the world will use default material properties instead.

    - -
    - - - - - - -
    - - +

    material

    + Material + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:88 +

    + + +
    + +
    +

    Material to use in collisions for this Shape. If this is set to null, the world will use default material properties instead.

    + +
    + + + +
    -

    sensor

    - Boolean - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:96 - -

    - - - - -
    - -
    -

    Set to true if you want this shape to be a sensor. A sensor does not generate contacts, but it still reports contact events. This is good if you want to know if a shape is overlapping another shape, without them generating contacts.

    - -
    - - - - - - -
    - - +

    sensor

    + Boolean + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:102 +

    + + +
    + +
    +

    Set to true if you want this shape to be a sensor. A sensor does not generate contacts, but it still reports contact events. This is good if you want to know if a shape is overlapping another shape, without them generating contacts.

    + +
    + + + +
    -

    type

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:11 - -

    - - - - -
    - - - - - - - - -
    - - +

    type

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:11 +

    + + +
    + + + + + + - - - - diff --git a/docs/classes/LinearSpring.html b/docs/classes/LinearSpring.html index fb8fee37..59b822e4 100644 --- a/docs/classes/LinearSpring.html +++ b/docs/classes/LinearSpring.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,592 +25,386 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    LinearSpring Class

    +

    LinearSpring Class

    - -
    Extends Spring
    - - - - -
    -

    A spring, connecting two bodies.

    The Spring explicitly adds force and angularForce to the bodies.

    -

    Constructor

    -

    LinearSpring

    - - -
    - (
      - -
    • - - bodyA - -
    • - -
    • - - bodyB - -
    • - -
    • - - [options] - -
    • - -
    ) -
    - - - - - - - - - - - - - - - - -
    +

    LinearSpring

    + +
    + (
      +
    • + bodyA +
    • +
    • + bodyB +
    • +
    • + [options] +
    • +
    ) +
    - - -

    - - Defined in + + + + + + + +

    +

    + Defined in + src/objects/LinearSpring.js:7 +

    + + + +
    + +
    - +
    +
    +

    Parameters:

    - src/objects/LinearSpring.js:7 +
      +
    • + bodyA + Body -

      - - - +
      + +
      + +
    • +
    • + bodyB + Body + + +
      + +
      + +
    • +
    • + [options] + Object + optional + + +
      + +
      + +
        +
      • + [restLength] + Number + optional + +
        +

        A number > 0. Default is the current distance between the world anchor points.

        + +
        + +
      • +
      • + [stiffness=100] + Number + optional + +
        +

        Spring constant (see Hookes Law). A number >= 0.

        + +
        + +
      • +
      • + [damping=1] + Number + optional + +
        +

        A number >= 0. Default: 1

        + +
        + +
      • +
      • + [worldAnchorA] + Array + optional + +
        +

        Where to hook the spring to body A, in world coordinates. Overrides the option "localAnchorA" if given.

        + +
        + +
      • +
      • + [worldAnchorB] + Array + optional + +
        + +
        + +
      • +
      • + [localAnchorA] + Array + optional + +
        +

        Where to hook the spring to body A, in local body coordinates. Defaults to the body center.

        + +
        + +
      • +
      • + [localAnchorB] + Array + optional + +
        + +
        + +
      • +
      +
    • +
    +
    + -
    - -
    -
    - - -
    -

    Parameters:

    - -
      - -
    • - - bodyA - Body - - - - -
      - -
      - - -
    • - -
    • - - bodyB - Body - - - - -
      - -
      - - -
    • - -
    • - - [options] - Object - optional - - - - -
      - -
      - - -
        - -
      • - - [restLength] - Number - optional - - -
        -

        A number > 0. Default is the current distance between the world anchor points.

        - -
        - - -
      • - -
      • - - [stiffness=100] - Number - optional - - -
        -

        Spring constant (see Hookes Law). A number >= 0.

        - -
        - - -
      • - -
      • - - [damping=1] - Number - optional - - -
        -

        A number >= 0. Default: 1

        - -
        - - -
      • - -
      • - - [worldAnchorA] - Array - optional - - -
        -

        Where to hook the spring to body A, in world coordinates. Overrides the option "localAnchorA" if given.

        - -
        - - -
      • - -
      • - - [worldAnchorB] - Array - optional - - -
        - -
        - - -
      • - -
      • - - [localAnchorA] - Array - optional - - -
        -

        Where to hook the spring to body A, in local body coordinates. Defaults to the body center.

        - -
        - - -
      • - -
      • - - [localAnchorB] - Array - optional - - -
        - -
        - - -
      • - -
      - -
    • - -
    - - - - - -
    -
    -

    Item Index

    - - -

    Properties

    - - -
    -

    Methods

    - -
    +

    applyForce

    - () - - - - - - - -
    -

    Inherited from Spring - but overwritten in - - - - src/objects/LinearSpring.js:111 - + src/objects/LinearSpring.js:112

    - -
    @@ -620,64 +412,36 @@

    applyForce

    - - - -
    - -
    +
    +

    getWorldAnchorA

    -
    (
      -
    • - result -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - - src/objects/LinearSpring.js:83 - + src/objects/LinearSpring.js:84

    - -
    @@ -685,88 +449,53 @@

    getWorldAnchorA

    -

    Parameters:

      -
    • - result Array - -

      The vector to store the result in.

      -
    • -
    - - - -
    - -
    +
    +

    getWorldAnchorB

    -
    (
      -
    • - result -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - - src/objects/LinearSpring.js:92 - + src/objects/LinearSpring.js:93

    - -
    @@ -774,88 +503,53 @@

    getWorldAnchorB

    -

    Parameters:

      -
    • - result Array - -

      The vector to store the result in.

      -
    • -
    - - - -
    - -
    +
    +

    setWorldAnchorA

    -
    (
      -
    • - worldAnchorA -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - - src/objects/LinearSpring.js:65 - + src/objects/LinearSpring.js:66

    - -
    @@ -863,87 +557,52 @@

    setWorldAnchorA

    -

    Parameters:

      -
    • - worldAnchorA Array - -
      -
    • -
    - - - -
    - -
    +
    +

    setWorldAnchorB

    -
    (
      -
    • - worldAnchorB -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - - src/objects/LinearSpring.js:74 - + src/objects/LinearSpring.js:75

    - -
    @@ -951,357 +610,211 @@

    setWorldAnchorB

    -

    Parameters:

      -
    • - worldAnchorB Array - -
      -
    • -
    - - - -
    - +
    - -

    Properties

    -
    -

    bodyA

    - Body - - - - - - - - - -
    - - -

    Inherited from - Spring: - - - - src/objects/Spring.js:41 - -

    - - - - -
    - -
    -

    First connected body.

    - -
    - - - - - - -
    - - +

    bodyA

    + Body + + + + + +
    +

    Inherited from + Spring: + src/objects/Spring.js:41 +

    + + +
    + +
    +

    First connected body.

    + +
    + + + +
    -

    bodyB

    - Body - - - - - - - - - -
    - - -

    Inherited from - Spring: - - - - src/objects/Spring.js:48 - -

    - - - - -
    - -
    -

    Second connected body.

    - -
    - - - - - - -
    - - +

    bodyB

    + Body + + + + + +
    +

    Inherited from + Spring: + src/objects/Spring.js:48 +

    + + +
    + +
    +

    Second connected body.

    + +
    + + + +
    -

    damping

    - Number - - - - - - - - - -
    - - -

    Inherited from - Spring: - - - - src/objects/Spring.js:34 - -

    - - - - -
    - -
    -

    Damping of the spring.

    - -
    - - - - - - -
    - - +

    damping

    + Number + + + + + +
    +

    Inherited from + Spring: + src/objects/Spring.js:34 +

    + + +
    + +
    +

    Damping of the spring.

    + +
    + + + +
    -

    localAnchorA

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/LinearSpring.js:31 - -

    - - - - -
    - -
    -

    Anchor for bodyA in local bodyA coordinates.

    - -
    - - - - - - -
    - - +

    localAnchorA

    + Array + + + + + +
    +

    + Defined in + src/objects/LinearSpring.js:31 +

    + + +
    + +
    +

    Anchor for bodyA in local bodyA coordinates.

    + +
    + + + +
    -

    localAnchorB

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/LinearSpring.js:38 - -

    - - - - -
    - -
    -

    Anchor for bodyB in local bodyB coordinates.

    - -
    - - - - - - -
    - - +

    localAnchorB

    + Array + + + + + +
    +

    + Defined in + src/objects/LinearSpring.js:38 +

    + + +
    + +
    +

    Anchor for bodyB in local bodyB coordinates.

    + +
    + + + +
    -

    restLength

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/LinearSpring.js:56 - -

    - - - - -
    - -
    -

    Rest length of the spring.

    - -
    - - - - - - -
    - - +

    restLength

    + Number + + + + + +
    +

    + Defined in + src/objects/LinearSpring.js:56 +

    + + +
    + +
    +

    Rest length of the spring.

    + +
    + + + +
    -

    stiffness

    - Number - - - - - - - - - -
    - - -

    Inherited from - Spring: - - - - src/objects/Spring.js:27 - -

    - - - - -
    - -
    -

    Stiffness of the spring.

    - -
    - - - - - - -
    - - +

    stiffness

    + Number + + + + + +
    +

    Inherited from + Spring: + src/objects/Spring.js:27 +

    + + +
    + +
    +

    Stiffness of the spring.

    + +
    + + + +
    - - - - diff --git a/docs/classes/LockConstraint.html b/docs/classes/LockConstraint.html index 9b7e59ae..70f4bc58 100644 --- a/docs/classes/LockConstraint.html +++ b/docs/classes/LockConstraint.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,529 +25,342 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    LockConstraint Class

    +

    LockConstraint Class

    - -
    Extends Constraint
    - - - - -
    -

    Locks the relative position between two bodies.

    -

    Constructor

    -

    LockConstraint

    - - -
    - (
      - -
    • - - bodyA - -
    • - -
    • - - bodyB - -
    • - -
    • - - [options] - -
    • - -
    ) -
    - - - - - - - - - - - - - - - - -
    +

    LockConstraint

    + +
    + (
      +
    • + bodyA +
    • +
    • + bodyB +
    • +
    • + [options] +
    • +
    ) +
    - - -

    - - Defined in + + + + + + + +

    +

    + Defined in + src/constraints/LockConstraint.js:7 +

    + + + +
    + +
    - +
    +
    +

    Parameters:

    - src/constraints/LockConstraint.js:7 +
      +
    • + bodyA + Body -

      - - - +
      + +
      + +
    • +
    • + bodyB + Body + + +
      + +
      + +
    • +
    • + [options] + Object + optional + + +
      + +
      + +
        +
      • + [localOffsetB] + Array + optional + +
        +

        The offset of bodyB in bodyA's frame. If not given the offset is computed from current positions.

        + +
        + +
      • +
      • + [localAngleB] + Number + optional + +
        +

        The angle of bodyB in bodyA's frame. If not given, the angle is computed from current angles.

        + +
        + +
      • +
      • + [maxForce] + Number + optional + +
        + +
        + +
      • +
      +
    • +
    +
    + -
    - -
    -
    - - -
    -

    Parameters:

    - -
      - -
    • - - bodyA - Body - - - - -
      - -
      - - -
    • - -
    • - - bodyB - Body - - - - -
      - -
      - - -
    • - -
    • - - [options] - Object - optional - - - - -
      - -
      - - -
        - -
      • - - [localOffsetB] - Array - optional - - -
        -

        The offset of bodyB in bodyA's frame. If not given the offset is computed from current positions.

        - -
        - - -
      • - -
      • - - [localAngleB] - Number - optional - - -
        -

        The angle of bodyB in bodyA's frame. If not given, the angle is computed from current angles.

        - -
        - - -
      • - -
      • - - [maxForce] - Number - optional - - -
        - -
        - - -
      • - -
      - -
    • - -
    - - - - - -
    -
    -

    Item Index

    -

    Methods

    - -

    Properties

    - - -
    -

    Methods

    - -
    +

    getMaxForce

    - () - - Number - - - - - - -
    @@ -557,76 +368,43 @@

    getMaxForce

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    setMaxForce

    -
    (
      -
    • - force -
    • -
    )
    - - - - - - - -
    @@ -634,84 +412,52 @@

    setMaxForce

    -

    Parameters:

      -
    • - force Number - -
      -
    • -
    - - - -
    - -
    +
    +

    setRelaxation

    -
    (
      -
    • - relaxation -
    • -
    )
    - - - - - - - -
    @@ -719,84 +465,52 @@

    setRelaxation

    -

    Parameters:

      -
    • - relaxation Number - -
      -
    • -
    - - - -
    - -
    +
    +

    setStiffness

    -
    (
      -
    • - stiffness -
    • -
    )
    - - - - - - - -
    @@ -804,74 +518,46 @@

    setStiffness

    -

    Parameters:

      -
    • - stiffness Number - -
      -
    • -
    - - - -
    - -
    +
    +

    update

    - () - - - - - - - -
    @@ -879,291 +565,196 @@

    update

    - - - -
    - +
    - -

    Properties

    -
    -

    bodyA

    - Body - - - - - - - - - -
    - - -

    Inherited from - Constraint: - - - - src/constraints/Constraint.js:33 - -

    - - - - -
    - -
    -

    First body participating in the constraint.

    - -
    - - - - - - -
    - - +

    bodyA

    + Body + + + + + +
    +

    Inherited from + Constraint: + src/constraints/Constraint.js:38 +

    + + +
    + +
    +

    First body participating in the constraint.

    + +
    + + + +
    -

    bodyB

    - Body - - - - - - - - - -
    - - -

    Inherited from - Constraint: - - - - src/constraints/Constraint.js:40 - -

    - - - - -
    - -
    -

    Second body participating in the constraint.

    - -
    - - - - - - -
    - - +

    bodyB

    + Body + + + + + +
    +

    Inherited from + Constraint: + src/constraints/Constraint.js:45 +

    + + +
    + +
    +

    Second body participating in the constraint.

    + +
    + + + +
    -

    collideConnected

    - Boolean - - - - - - - - - -
    - - -

    Inherited from - Constraint: - - - - src/constraints/Constraint.js:47 - -

    - - - - -
    - -
    -

    Set to true if you want the connected bodies to collide.

    - -
    - - -

    Default: true

    - - - - - -
    - - +

    collideConnected

    + Boolean + + + + + +
    +

    Inherited from + Constraint: + src/constraints/Constraint.js:52 +

    + + +
    + +
    +

    Set to true if you want the connected bodies to collide.

    + +
    + +

    Default: true

    + + +
    -

    equations

    - Array - - - - - - - - - -
    - - -

    Inherited from - Constraint: - - - - src/constraints/Constraint.js:25 - -

    - - - - -
    - -
    -

    Equations to be solved in this constraint

    - -
    - - - - - - -
    - - +

    equations

    + Array + + + + + +
    +

    Inherited from + Constraint: + src/constraints/Constraint.js:30 +

    + + +
    + +
    +

    Equations to be solved in this constraint

    + +
    + + + +
    -

    localAngleB

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/constraints/LockConstraint.js:96 - -

    - - - - -
    - -
    -

    The offset angle of bodyB in bodyA's frame.

    - -
    - - - - - - -
    - - +

    localAngleB

    + Number + + + + + +
    +

    + Defined in + src/constraints/LockConstraint.js:96 +

    + + +
    + +
    +

    The offset angle of bodyB in bodyA's frame.

    + +
    + + + +
    -

    localOffsetB

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/constraints/LockConstraint.js:83 - -

    - - - - -
    - -
    -

    The offset of bodyB in bodyA's frame.

    - -
    - - - - - - -
    - - +

    localOffsetB

    + Array + + + + + +
    +

    + Defined in + src/constraints/LockConstraint.js:83 +

    + + +
    + +
    +

    The offset of bodyB in bodyA's frame.

    + +
    + + + +
    +
    +

    type

    + Number + + + + + +
    +

    Inherited from + Constraint: + src/constraints/Constraint.js:19 +

    + + +
    + +
    +

    The type of constraint. May be one of Constraint.DISTANCE, Constraint.GEAR, Constraint.LOCK, Constraint.PRISMATIC or Constraint.REVOLUTE.

    + +
    + + + +
    - - - - diff --git a/docs/classes/Material.html b/docs/classes/Material.html index d5e763b6..ec2d4697 100644 --- a/docs/classes/Material.html +++ b/docs/classes/Material.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,367 +25,236 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    Material Class

    +

    Material Class

    - - - - - -
    -

    Defines a physics material.

    -

    Constructor

    -

    Material

    - - -
    - (
      - -
    • - - id - -
    • - -
    ) -
    - - - - - - - - - - - - - - - - -
    +

    Material

    - - -

    - - Defined in +

    + (
      +
    • + id +
    • +
    ) +
    + + + + + + + + +
    +

    + Defined in + src/material/Material.js:3 +

    + + + +
    + +
    - +
    +
    +

    Parameters:

    - src/material/Material.js:3 +
      +
    • + id + Number -

      - - - +
      +

      Material identifier

      + +
      + +
    • +
    +
    + -
    - -
    -
    - - -
    -

    Parameters:

    - -
      - -
    • - - id - Number - - - - -
      -

      Material identifier

      - -
      - - -
    • - -
    - - - - - -
    -
    -

    Item Index

    - -

    Properties

      -
    • id - -
    • -
    - - -
    - -

    Properties

    -
    -

    id

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/material/Material.js:11 - -

    - - - - -
    - -
    -

    The material identifier

    - -
    - - - - - - -
    - - +

    id

    + Number + + + + + +
    +

    + Defined in + src/material/Material.js:11 +

    + + +
    + +
    +

    The material identifier

    + +
    + + + +
    - - -
    -
    diff --git a/docs/classes/NaiveBroadphase.html b/docs/classes/NaiveBroadphase.html index 5694ca13..955d5664 100644 --- a/docs/classes/NaiveBroadphase.html +++ b/docs/classes/NaiveBroadphase.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,393 +25,345 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    NaiveBroadphase Class

    +

    NaiveBroadphase Class

    - -
    Extends Broadphase
    - - - - -
    -

    Naive broadphase implementation. Does N^2 tests.

    -

    Constructor

    -

    NaiveBroadphase

    - - - () - - - - - - - - - - - - - - - - -
    +

    NaiveBroadphase

    - - -

    - - Defined in - - + () - src/collision/NaiveBroadphase.js:10 -

    - - - -
    - -
    + + +
    +

    + Defined in + src/collision/NaiveBroadphase.js:10 +

    + + + +
    + +
    + +
    + + + + +
    - - - - - -
    - -
    - -

    Item Index

    -

    Methods

    - -

    Properties

    - - -
    -

    Methods

    - -
    +
    +

    aabbQuery

    + +
    + (
      +
    • + world +
    • +
    • + aabb +
    • +
    • + result +
    • +
    ) +
    + + + Array + + + + + + + + +
    +

    + Defined in + src/collision/NaiveBroadphase.js:50 +

    + + + +
    + +
    +

    Returns all the bodies within an AABB.

    + +
    + +
    +

    Parameters:

    + +
      +
    • + world + World + + +
      + +
      + +
    • +
    • + aabb + AABB + + +
      + +
      + +
    • +
    • + result + Array + + +
      +

      An array to store resulting bodies in.

      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + Array: +
    +
    + + +
    +

    boundingRadiusCheck

    -
    (
      -
    • - bodyA -
    • -
    • - bodyB -
    • -
    )
    - - Boolean - - - - - - -
    -

    Inherited from Broadphase - but overwritten in - - - src/collision/Broadphase.js:72 -

    - -
    @@ -421,121 +371,75 @@

    boundingRadiusCheck

    -

    Parameters:

      -
    • - bodyA Body - -
      -
    • -
    • - bodyB Body - -
      -
    • -
    - -

    Returns:

    - - Boolean: - -
    - - -
    - -
    +
    +

    canCollide

    -
    (
      -
    • - bodyA -
    • -
    • - bodyB -
    • -
    )
    - - Boolean - - - - - - -
    @@ -543,118 +447,75 @@

    canCollide

    -

    Parameters:

      -
    • - bodyA Body - -
      -
    • -
    • - bodyB Body - -
      -
    • -
    - -

    Returns:

    - - Boolean: - -
    - - -
    - -
    +
    +

    getCollisionPairs

    -
    (
      -
    • - world -
    • -
    )
    - - Array - - - - - - -
    -

    Inherited from Broadphase - but overwritten in - - - - src/collision/NaiveBroadphase.js:22 - + src/collision/NaiveBroadphase.js:23

    - -
    @@ -662,96 +523,59 @@

    getCollisionPairs

    -

    Parameters:

      -
    • - world World - -
      -
    • -
    - -

    Returns:

    - - Array: - -
    - - -
    - -
    +
    +

    setWorld

    -
    (
      -
    • - world -
    • -
    )
    - - - - - - - -
    - -

    Inherited from Broadphase: - - - src/collision/Broadphase.js:51 -

    - -
    @@ -759,180 +583,111 @@

    setWorld

    -

    Parameters:

      -
    • - world World - -
      -
    • -
    - - - -
    - +
    - -

    Properties

    -
    -

    boundingVolumeType

    - Number - - - - - - - - - -
    - - -

    Inherited from - Broadphase: - - - - src/collision/Broadphase.js:30 - -

    - - - - -
    - -
    -

    The bounding volume type to use in the broadphase algorithms.

    - -
    - - - - - - -
    - - +

    boundingVolumeType

    + Number + + + + + +
    +

    Inherited from + Broadphase: + src/collision/Broadphase.js:30 +

    + + +
    + +
    +

    The bounding volume type to use in the broadphase algorithms.

    + +
    + + + +
    -

    result

    - Array - - - - - - - - - -
    - - -

    Inherited from - Broadphase: - - - - src/collision/Broadphase.js:15 - -

    - - - - -
    - -
    -

    The resulting overlapping pairs. Will be filled with results during .getCollisionPairs().

    - -
    - - - - - - -
    - - +

    result

    + Array + + + + + +
    +

    Inherited from + Broadphase: + src/collision/Broadphase.js:15 +

    + + +
    + +
    +

    The resulting overlapping pairs. Will be filled with results during .getCollisionPairs().

    + +
    + + + +
    -

    world

    - World - - - - - - - - - -
    - - -

    Inherited from - Broadphase: - - - - src/collision/Broadphase.js:22 - -

    - - - - -
    - -
    -

    The world to search for collision pairs in. To change it, use .setWorld()

    - -
    - - - - - - -
    - - +

    world

    + World + + + + + +
    +

    Inherited from + Broadphase: + src/collision/Broadphase.js:22 +

    + + +
    + +
    +

    The world to search for collision pairs in. To change it, use .setWorld()

    + +
    + + + +
    - - -
    - diff --git a/docs/classes/Narrowphase.html b/docs/classes/Narrowphase.html index 172a30e7..365be166 100644 --- a/docs/classes/Narrowphase.html +++ b/docs/classes/Narrowphase.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,674 +25,487 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    Narrowphase Class

    +

    Narrowphase Class

    - - - - - -
    -

    Narrowphase. Creates contacts and friction given shapes and transforms.

    -

    Constructor

    -

    Narrowphase

    - - - () - - - - - - - - - - - - - - - - -
    +

    Narrowphase

    - - -

    - - Defined in - - + () - src/collision/Narrowphase.js:41 -

    - - - -
    - -
    + + +
    +

    + Defined in + src/collision/Narrowphase.js:41 +

    + + + +
    + +
    + +
    + + + + +
    - - - - - -
    - -
    - -
    -

    Methods

    - -
    +
    +

    bodiesOverlap

    + +
    + (
      +
    • + bodyA +
    • +
    • + bodyB +
    • +
    ) +
    + + + Boolean + + + + + + + + +
    +

    + Defined in + src/collision/Narrowphase.js:159 +

    + + + +
    + +
    + +
    + +
    +

    Parameters:

    + +
      +
    • + bodyA + Body + + +
      + +
      + +
    • +
    • + bodyB + Body + + +
      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + Boolean: +
    +
    + + +
    +

    capsuleCapsule

    -
    (
      -
    • - bi -
    • -
    • - si -
    • -
    • - xi -
    • -
    • - ai -
    • -
    • - bj -
    • -
    • - sj -
    • -
    • - xj -
    • -
    • - aj -
    • -
    )
    - - - - - - - -
    @@ -702,234 +513,143 @@

    capsuleCapsule

    -

    Parameters:

      -
    • - bi Body - -
      -
    • -
    • - si Capsule - -
      -
    • -
    • - xi Array - -
      -
    • -
    • - ai Number - -
      -
    • -
    • - bj Body - -
      -
    • -
    • - sj Capsule - -
      -
    • -
    • - xj Array - -
      -
    • -
    • - aj Number - -
      -
    • -
    - - - -
    - -
    +
    +

    circleCapsule

    -
    (
      -
    • - bi -
    • -
    • - si -
    • -
    • - xi -
    • -
    • - ai -
    • -
    • - bj -
    • -
    • - sj -
    • -
    • - xj -
    • -
    • - aj -
    • -
    )
    - - - - - - - -
    @@ -937,252 +657,152 @@

    circleCapsule

    -

    Parameters:

      -
    • - bi Body - -
      -
    • -
    • - si Circle - -
      -
    • -
    • - xi Array - -
      -
    • -
    • - ai Number - -
      -
    • -
    • - bj Body - -
      -
    • -
    • - sj Line - -
      -
    • -
    • - xj Array - -
      -
    • -
    • - aj Number - -
      -
    • -
    - - - -
    - -
    +
    +

    circleCircle

    -
    (
      -
    • - bodyA -
    • -
    • - shapeA -
    • -
    • - offsetA -
    • -
    • - angleA -
    • -
    • - bodyB -
    • -
    • - shapeB -
    • -
    • - offsetB -
    • -
    • - angleB -
    • -
    • - justTest -
    • -
    • - [radiusA] -
    • -
    • - [radiusB] -
    • -
    )
    - - - - - - - -
    @@ -1190,295 +810,183 @@

    circleCircle

    -

    Parameters:

      -
    • - bodyA Body - -
      -
    • -
    • - shapeA Circle - -
      -
    • -
    • - offsetA Array - -
      -
    • -
    • - angleA Number - -
      -
    • -
    • - bodyB Body - -
      -
    • -
    • - shapeB Circle - -
      -
    • -
    • - offsetB Array - -
      -
    • -
    • - angleB Number - -
      -
    • -
    • - justTest Boolean - -
      -
    • -
    • - [radiusA] Number optional - -

      Optional radius to use for shapeA

      -
    • -
    • - [radiusB] Number optional - -

      Optional radius to use for shapeB

      -
    • -
    - - - -
    - -
    +
    +

    circleConvex

    -
    (
      -
    • - circleBody -
    • -
    • - circleShape -
    • -
    • - circleOffset -
    • -
    • - circleAngle -
    • -
    • - convexBody -
    • -
    • - convexShape -
    • -
    • - convexOffset -
    • -
    • - convexAngle -
    • -
    • - justTest -
    • -
    • - circleRadius -
    • -
    )
    - - - - - - - -
    @@ -1486,708 +994,432 @@

    circleConvex

    -

    Parameters:

      -
    • - circleBody Body - -
      -
    • -
    • - circleShape Circle - -
      -
    • -
    • - circleOffset Array - -
      -
    • -
    • - circleAngle Number - -
      -
    • -
    • - convexBody Body - -
      -
    • -
    • - convexShape Convex - -
      -
    • -
    • - convexOffset Array - -
      -
    • -
    • - convexAngle Number - -
      -
    • -
    • - justTest Boolean - -
      -
    • -
    • - circleRadius Number - -
      -
    • -
    - - - -
    - -
    +
    +

    circleHeightfield

    -
    (
      -
    • - bi -
    • -
    • - si -
    • -
    • - xi -
    • -
    • - bj -
    • -
    • - sj -
    • -
    • - xj -
    • -
    • - aj -
    • -
    )
    - - - - - - - -
    -

    Parameters:

      -
    • - bi Body - -
      -
    • -
    • - si Circle - -
      -
    • -
    • - xi Array - -
      -
    • -
    • - bj Body - -
      -
    • -
    • - sj Heightfield - -
      -
    • -
    • - xj Array - -
      -
    • -
    • - aj Number - -
      -
    • -
    - - - -
    - -
    +
    +

    circleHeightfield

    -
    (
      -
    • - bi -
    • -
    • - si -
    • -
    • - xi -
    • -
    • - bj -
    • -
    • - sj -
    • -
    • - xj -
    • -
    • - aj -
    • -
    )
    - - - - - - - -
    -

    Parameters:

      -
    • - bi Body - -
      -
    • -
    • - si Circle - -
      -
    • -
    • - xi Array - -
      -
    • -
    • - bj Body - -
      -
    • -
    • - sj Heightfield - -
      -
    • -
    • - xj Array - -
      -
    • -
    • - aj Number - -
      -
    • -
    - - - -
    - -
    +
    +

    circleLine

    -
    (
      -
    • - circleBody -
    • -
    • - circleShape -
    • -
    • - circleOffset -
    • -
    • - circleAngle -
    • -
    • - lineBody -
    • -
    • - lineShape -
    • -
    • - lineOffset -
    • -
    • - lineAngle -
    • -
    • - justTest -
    • -
    • - lineRadius -
    • -
    • - circleRadius -
    • -
    )
    - - - - - - - -
    @@ -2195,288 +1427,179 @@

    circleLine

    -

    Parameters:

      -
    • - circleBody Body - -
      -
    • -
    • - circleShape Circle - -
      -
    • -
    • - circleOffset Array - -
      -
    • -
    • - circleAngle Number - -
      -
    • -
    • - lineBody Body - -
      -
    • -
    • - lineShape Line - -
      -
    • -
    • - lineOffset Array - -
      -
    • -
    • - lineAngle Number - -
      -
    • -
    • - justTest Boolean - -

      If set to true, this function will return the result (intersection or not) without adding equations.

      -
    • -
    • - lineRadius Number - -

      Radius to add to the line. Can be used to test Capsules.

      -
    • -
    • - circleRadius Number - -

      If set, this value overrides the circle shape radius.

      -
    • -
    - - - -
    - -
    +
    +

    circleParticle

    -
    (
      -
    • - circleBody -
    • -
    • - circleShape -
    • -
    • - circleOffset -
    • -
    • - circleAngle -
    • -
    • - particleBody -
    • -
    • - particleShape -
    • -
    • - particleOffset -
    • -
    • - particleAngle -
    • -
    • - justTest -
    • -
    )
    - - - - - - - -
    @@ -2484,243 +1607,150 @@

    circleParticle

    -

    Parameters:

      -
    • - circleBody Body - -
      -
    • -
    • - circleShape Circle - -
      -
    • -
    • - circleOffset Array - -
      -
    • -
    • - circleAngle Number - -
      -
    • -
    • - particleBody Body - -
      -
    • -
    • - particleShape Particle - -
      -
    • -
    • - particleOffset Array - -
      -
    • -
    • - particleAngle Number - -
      -
    • -
    • - justTest Boolean - -
      -
    • -
    - - - -
    - -
    +
    +

    circlePlane

    -
    (
      -
    • - bi -
    • -
    • - si -
    • -
    • - xi -
    • -
    • - bj -
    • -
    • - sj -
    • -
    • - xj -
    • -
    • - aj -
    • -
    )
    - - - - - - - -
    @@ -2728,194 +1758,125 @@

    circlePlane

    -

    Parameters:

      -
    • - bi Body - -

      The first body that should be connected to the equations.

      -
    • -
    • - si Circle - -

      The circle shape participating in the collision.

      -
    • -
    • - xi Array - -

      Extra offset to take into account for the Shape, in addition to the one in circleBody.position. Will not be rotated by circleBody.angle (maybe it should, for sake of homogenity?). Set to null if none.

      -
    • -
    • - bj Body - -

      The second body that should be connected to the equations.

      -
    • -
    • - sj Plane - -

      The Plane shape that is participating

      -
    • -
    • - xj Array - -

      Extra offset for the plane shape.

      -
    • -
    • - aj Number - -

      Extra angle to apply to the plane

      -
    • -
    - - - -
    - -
    +
    +

    collidedLastStep

    -
    (
      -
    • - bodyA -
    • -
    • - bodyB -
    • -
    )
    - - Boolean - - - - - - -
    @@ -2923,156 +1884,90 @@

    collidedLastStep

    -

    Parameters:

      -
    • - bodyA Body - -
      -
    • -
    • - bodyB Body - -
      -
    • -
    - -

    Returns:

    - - Boolean: - -
    - - -
    - -
    +
    +

    convexCapsule

    -
    (
      -
    • - convexBody -
    • -
    • - convexShape -
    • -
    • - convexPosition -
    • -
    • - convexAngle -
    • -
    • - capsuleBody -
    • -
    • - capsuleShape -
    • -
    • - capsulePosition -
    • -
    • - capsuleAngle -
    • -
    )
    - - - - - - - -
    @@ -3080,234 +1975,143 @@

    convexCapsule

    -

    Parameters:

      -
    • - convexBody Body - -
      -
    • -
    • - convexShape Convex - -
      -
    • -
    • - convexPosition Array - -
      -
    • -
    • - convexAngle Number - -
      -
    • -
    • - capsuleBody Body - -
      -
    • -
    • - capsuleShape Capsule - -
      -
    • -
    • - capsulePosition Array - -
      -
    • -
    • - capsuleAngle Number - -
      -
    • -
    - - - -
    - -
    +
    +

    convexConvex

    -
    (
      -
    • - bi -
    • -
    • - si -
    • -
    • - xi -
    • -
    • - ai -
    • -
    • - bj -
    • -
    • - sj -
    • -
    • - xj -
    • -
    • - aj -
    • -
    )
    - - - - - - - -
    @@ -3315,240 +2119,146 @@

    convexConvex

    -

    Parameters:

      -
    • - bi Body - -
      -
    • -
    • - si Convex - -
      -
    • -
    • - xi Array - -
      -
    • -
    • - ai Number - -
      -
    • -
    • - bj Body - -
      -
    • -
    • - sj Convex - -
      -
    • -
    • - xj Array - -
      -
    • -
    • - aj Number - -
      -
    • -
    - - - -
    - -
    +
    +

    convexLine

    -
    (
      -
    • - convexBody -
    • -
    • - convexShape -
    • -
    • - convexOffset -
    • -
    • - convexAngle -
    • -
    • - lineBody -
    • -
    • - lineShape -
    • -
    • - lineOffset -
    • -
    • - lineAngle -
    • -
    • - justTest -
    • -
    )
    - - - - - - - -
    @@ -3556,217 +2266,138 @@

    convexLine

    -

    Parameters:

      -
    • - convexBody Body - -
      -
    • -
    • - convexShape Convex - -
      -
    • -
    • - convexOffset Array - -
      -
    • -
    • - convexAngle Number - -
      -
    • -
    • - lineBody Body - -
      -
    • -
    • - lineShape Line - -
      -
    • -
    • - lineOffset Array - -
      -
    • -
    • - lineAngle Number - -
      -
    • -
    • - justTest Boolean - -
      -
    • -
    - - - -
    - -
    +
    +

    createContactEquation

    -
    (
      -
    • - bodyA -
    • -
    • - bodyB -
    • -
    )
    - - ContactEquation - - - - - - -
    @@ -3774,124 +2405,75 @@

    createContactEquation

    -

    Parameters:

      -
    • - bodyA Body - -
      -
    • -
    • - bodyB Body - -
      -
    • -
    - -

    Returns:

    - - ContactEquation: - -
    - - -
    - -
    +
    +

    createFrictionEquation

    -
    (
      -
    • - bodyA -
    • -
    • - bodyB -
    • -
    )
    - - FrictionEquation - - - - - - -
    @@ -3899,118 +2481,72 @@

    createFrictionEquation

    -

    Parameters:

      -
    • - bodyA Body - -
      -
    • -
    • - bodyB Body - -
      -
    • -
    - -

    Returns:

    - - FrictionEquation: - -
    - - -
    - -
    +
    +

    createFrictionFromContact

    -
    (
      -
    • - contactEquation -
    • -
    )
    - - FrictionEquation - - - - - - -
    @@ -4018,141 +2554,81 @@

    createFrictionFromContact

    -

    Parameters:

    - -

    Returns:

    - - FrictionEquation: - -
    - - -
    - -
    +
    +

    findSeparatingAxis

    -
    (
      -
    • - c1 -
    • -
    • - offset1 -
    • -
    • - angle1 -
    • -
    • - c2 -
    • -
    • - offset2 -
    • -
    • - angle2 -
    • -
    • - sepAxis -
    • -
    )
    - - Boolean - - - - - static - - -
    @@ -4160,216 +2636,135 @@

    findSeparatingAxis

    -

    Parameters:

      -
    • - c1 Convex - -
      -
    • -
    • - offset1 Array - -
      -
    • -
    • - angle1 Number - -
      -
    • -
    • - c2 Convex - -
      -
    • -
    • - offset2 Array - -
      -
    • -
    • - angle2 Number - -
      -
    • -
    • - sepAxis Array - -

      The resulting axis

      -
    • -
    - -

    Returns:

    - - Boolean: -

    Whether the axis could be found.

    -
    - - -
    - -
    +
    +

    getClosestEdge

    -
    (
      -
    • - c -
    • -
    • - angle -
    • -
    • - axis -
    • -
    • - flip -
    • -
    )
    - - Number - - - - - static - - -
    @@ -4377,188 +2772,112 @@

    getClosestEdge

    -

    Parameters:

      -
    • - c Convex - -
      -
    • -
    • - angle Number - -
      -
    • -
    • - axis Array - -
      -
    • -
    • - flip Boolean - -
      -
    • -
    - -

    Returns:

    - - Number: -

    Index of the edge that is closest. This index and the next spans the resulting edge. Returns -1 if failed.

    -
    - - -
    - -
    +
    +

    lineCapsule

    -
    (
      -
    • - lineBody -
    • -
    • - lineShape -
    • -
    • - linePosition -
    • -
    • - lineAngle -
    • -
    • - capsuleBody -
    • -
    • - capsuleShape -
    • -
    • - capsulePosition -
    • -
    • - capsuleAngle -
    • -
    )
    - - - - - - - -
    @@ -4566,234 +2885,143 @@

    lineCapsule

    -

    Parameters:

      -
    • - lineBody Body - -
      -
    • -
    • - lineShape Line - -
      -
    • -
    • - linePosition Array - -
      -
    • -
    • - lineAngle Number - -
      -
    • -
    • - capsuleBody Body - -
      -
    • -
    • - capsuleShape Capsule - -
      -
    • -
    • - capsulePosition Array - -
      -
    • -
    • - capsuleAngle Number - -
      -
    • -
    - - - -
    - -
    +
    +

    lineLine

    -
    (
      -
    • - bodyA -
    • -
    • - shapeA -
    • -
    • - positionA -
    • -
    • - angleA -
    • -
    • - bodyB -
    • -
    • - shapeB -
    • -
    • - positionB -
    • -
    • - angleB -
    • -
    )
    - - - - - - - -
    @@ -4801,240 +3029,146 @@

    lineLine

    -

    Parameters:

      -
    • - bodyA Body - -
      -
    • -
    • - shapeA Line - -
      -
    • -
    • - positionA Array - -
      -
    • -
    • - angleA Number - -
      -
    • -
    • - bodyB Body - -
      -
    • -
    • - shapeB Line - -
      -
    • -
    • - positionB Array - -
      -
    • -
    • - angleB Number - -
      -
    • -
    - - - -
    - -
    +
    +

    lineRectangle

    -
    (
      -
    • - lineBody -
    • -
    • - lineShape -
    • -
    • - lineOffset -
    • -
    • - lineAngle -
    • -
    • - rectangleBody -
    • -
    • - rectangleShape -
    • -
    • - rectangleOffset -
    • -
    • - rectangleAngle -
    • -
    • - justTest -
    • -
    )
    - - - - - - - -
    @@ -5042,255 +3176,156 @@

    lineRectangle

    -

    Parameters:

      -
    • - lineBody Body - -
      -
    • -
    • - lineShape Line - -
      -
    • -
    • - lineOffset Array - -
      -
    • -
    • - lineAngle Number - -
      -
    • -
    • - rectangleBody Body - -
      -
    • -
    • - rectangleShape Rectangle - -
      -
    • -
    • - rectangleOffset Array - -
      -
    • -
    • - rectangleAngle Number - -
      -
    • -
    • - justTest Boolean - -
      -
    • -
    - - - -
    - -
    +
    +

    particleConvex

    -
    (
      -
    • - particleBody -
    • -
    • - particleShape -
    • -
    • - particleOffset -
    • -
    • - particleAngle -
    • -
    • - convexBody -
    • -
    • - convexShape -
    • -
    • - convexOffset -
    • -
    • - convexAngle -
    • -
    • - justTest -
    • -
    )
    - - - - - - - -
    @@ -5298,255 +3333,156 @@

    particleConvex

    -

    Parameters:

      -
    • - particleBody Body - -
      -
    • -
    • - particleShape Particle - -
      -
    • -
    • - particleOffset Array - -
      -
    • -
    • - particleAngle Number - -
      -
    • -
    • - convexBody Body - -
      -
    • -
    • - convexShape Convex - -
      -
    • -
    • - convexOffset Array - -
      -
    • -
    • - convexAngle Number - -
      -
    • -
    • - justTest Boolean - -
      -
    • -
    - - - -
    - -
    +
    +

    particlePlane

    -
    (
      -
    • - particleBody -
    • -
    • - particleShape -
    • -
    • - particleOffset -
    • -
    • - particleAngle -
    • -
    • - planeBody -
    • -
    • - planeShape -
    • -
    • - planeOffset -
    • -
    • - planeAngle -
    • -
    • - justTest -
    • -
    )
    - - - - - - - -
    @@ -5554,510 +3490,312 @@

    particlePlane

    -

    Parameters:

      -
    • - particleBody Body - -
      -
    • -
    • - particleShape Particle - -
      -
    • -
    • - particleOffset Array - -
      -
    • -
    • - particleAngle Number - -
      -
    • -
    • - planeBody Body - -
      -
    • -
    • - planeShape Plane - -
      -
    • -
    • - planeOffset Array - -
      -
    • -
    • - planeAngle Number - -
      -
    • -
    • - justTest Boolean - -
      -
    • -
    - - - -
    - -
    +
    +

    planeCapsule

    -
    (
      -
    • - planeBody -
    • -
    • - planeShape -
    • -
    • - planeOffset -
    • -
    • - planeAngle -
    • -
    • - capsuleBody -
    • -
    • - capsuleShape -
    • -
    • - capsuleOffset -
    • -
    • - capsuleAngle -
    • -
    • - justTest -
    • -
    )
    - - - - - - - -
    -

    Parameters:

      -
    • - planeBody Body - -
      -
    • -
    • - planeShape Circle - -
      -
    • -
    • - planeOffset Array - -
      -
    • -
    • - planeAngle Number - -
      -
    • -
    • - capsuleBody Body - -
      -
    • -
    • - capsuleShape Particle - -
      -
    • -
    • - capsuleOffset Array - -
      -
    • -
    • - capsuleAngle Number - -
      -
    • -
    • - justTest Boolean - -
      -
    • -
    - - - -
    - -
    +
    +

    planeConvex

    -
    (
      -
    • - planeBody -
    • -
    • - planeShape -
    • -
    • - planeOffset -
    • -
    • - planeAngle -
    • -
    • - convexBody -
    • -
    • - convexShape -
    • -
    • - convexOffset -
    • -
    • - convexAngle -
    • -
    • - justTest -
    • -
    )
    - - - - - - - -
    @@ -6065,249 +3803,153 @@

    planeConvex

    -

    Parameters:

      -
    • - planeBody Body - -
      -
    • -
    • - planeShape Plane - -
      -
    • -
    • - planeOffset Array - -
      -
    • -
    • - planeAngle Number - -
      -
    • -
    • - convexBody Body - -
      -
    • -
    • - convexShape Convex - -
      -
    • -
    • - convexOffset Array - -
      -
    • -
    • - convexAngle Number - -
      -
    • -
    • - justTest Boolean - -
      -
    • -
    - - - -
    - -
    +
    +

    planeLine

    -
    (
      -
    • - planeBody -
    • -
    • - planeShape -
    • -
    • - planeOffset -
    • -
    • - planeAngle -
    • -
    • - lineBody -
    • -
    • - lineShape -
    • -
    • - lineOffset -
    • -
    • - lineAngle -
    • -
    )
    - - - - - - - -
    @@ -6315,218 +3957,135 @@

    planeLine

    -

    Parameters:

      -
    • - planeBody Body - -
      -
    • -
    • - planeShape Plane - -
      -
    • -
    • - planeOffset Array - -
      -
    • -
    • - planeAngle Number - -
      -
    • -
    • - lineBody Body - -
      -
    • -
    • - lineShape Line - -
      -
    • -
    • - lineOffset Array - -
      -
    • -
    • - lineAngle Number - -
      -
    • -
    - - - -
    - -
    +
    +

    projectConvexOntoAxis

    -
    (
      -
    • - convexShape -
    • -
    • - convexOffset -
    • -
    • - convexAngle -
    • -
    • - worldAxis -
    • -
    • - result -
    • -
    )
    - - - - - - static - - -
    @@ -6534,137 +4093,86 @@

    projectConvexOntoAxis

    -

    Parameters:

      -
    • - convexShape Convex - -
      -
    • -
    • - convexOffset Array - -
      -
    • -
    • - convexAngle Number - -
      -
    • -
    • - worldAxis Array - -
      -
    • -
    • - result Array - -
      -
    • -
    - - - -
    - -
    +
    +

    reset

    - () - - - - - - - -
    @@ -6672,669 +4180,398 @@

    reset

    - - - -
    - +
    - -

    Properties

    - -
    -

    collidingBodiesLastStep

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/collision/Narrowphase.js:141 - -

    - - - - -
    - -
    -

    Contact skin size value to use in the next contact equations.

    - -
    - - -

    Default: 0.01

    - - - - - -
    - -
    -

    collidingBodiesLastStep

    - TupleDictionary - - - - - private - - - - - - -
    - - - -

    - - Defined in - - - - - src/collision/Narrowphase.js:133 - -

    - - - - -
    - -
    -

    Keeps track of the colliding bodies last step.

    - -
    - - - - - - -
    - - +

    collidingBodiesLastStep

    + TupleDictionary + + + private + + + +
    +

    + Defined in + src/collision/Narrowphase.js:140 +

    + + +
    + +
    +

    Keeps track of the colliding bodies last step.

    + +
    + + + +
    -

    contactEquations

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/collision/Narrowphase.js:48 - -

    - - - - -
    - -
    - -
    - - - - - - -
    - - +

    contactEquations

    + Array + + + + + +
    +

    + Defined in + src/collision/Narrowphase.js:48 +

    + + +
    + +
    + +
    + + + +
    +
    +

    contactSkinSize

    + Number + + + + + +
    +

    + Defined in + src/collision/Narrowphase.js:148 +

    + + +
    + +
    +

    Contact skin size value to use in the next contact equations.

    + +
    + +

    Default: 0.01

    + + +
    +
    +

    enabledEquations

    + Boolean + + + + + +
    +

    + Defined in + src/collision/Narrowphase.js:67 +

    + + +
    + +
    +

    Whether to make equations enabled in upcoming contacts.

    + +
    + + + +
    -

    enableFriction

    - Boolean - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/collision/Narrowphase.js:60 - -

    - - - - -
    - -
    -

    Whether to make friction equations in the upcoming contacts.

    - -
    - - - - - - -
    - - +

    enableFriction

    + Boolean + + + + + +
    +

    + Defined in + src/collision/Narrowphase.js:60 +

    + + +
    + +
    +

    Whether to make friction equations in the upcoming contacts.

    + +
    + + + +
    -

    enableFrictionReduction

    - Boolean - - - deprecated - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/collision/Narrowphase.js:124 - -

    - - -

    Deprecated: This flag will be removed when the feature is stable enough.

    - - - -
    - -
    -

    Enable reduction of friction equations. If disabled, a box on a plane will generate 2 contact equations and 2 friction equations. If enabled, there will be only one friction equation. Same kind of simplifications are made for all collision types.

    - -
    - - -

    Default: true

    - - - - - -
    - - +

    enableFrictionReduction

    + Boolean + + deprecated + + + + +
    +

    + Defined in + src/collision/Narrowphase.js:131 +

    + +

    Deprecated: This flag will be removed when the feature is stable enough.

    + +
    + +
    +

    Enable reduction of friction equations. If disabled, a box on a plane will generate 2 contact equations and 2 friction equations. If enabled, there will be only one friction equation. Same kind of simplifications are made for all collision types.

    + +
    + +

    Default: true

    + + +
    -

    frictionCoefficient

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/collision/Narrowphase.js:74 - -

    - - - - -
    - -
    -

    The friction value to use in the upcoming friction equations.

    - -
    - - - - - - -
    - - +

    frictionCoefficient

    + Number + + + + + +
    +

    + Defined in + src/collision/Narrowphase.js:81 +

    + + +
    + +
    +

    The friction value to use in the upcoming friction equations.

    + +
    + + + +
    -

    frictionEquations

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/collision/Narrowphase.js:54 - -

    - - - - -
    - -
    - -
    - - - - - - -
    - - +

    frictionEquations

    + Array + + + + + +
    +

    + Defined in + src/collision/Narrowphase.js:54 +

    + + +
    + +
    + +
    + + + +
    -

    frictionRelaxation

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/collision/Narrowphase.js:117 - -

    - - - - -
    - -
    -

    The relaxation value to use in the next friction equations.

    - -
    - - - - - - -
    - - -
    -

    frictionStiffness

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/collision/Narrowphase.js:110 - -

    - - - - -
    - -
    -

    The stiffness value to use in the next friction equations.

    - -
    - - - - - - -
    - - +

    frictionRelaxation

    + Number + + + + + +
    +

    + Defined in + src/collision/Narrowphase.js:124 +

    + + +
    + +
    +

    The relaxation value to use in the next friction equations.

    + +
    + + + + +
    +

    frictionStiffness

    + Number + + + + + +
    +

    + Defined in + src/collision/Narrowphase.js:117 +

    + + +
    + +
    +

    The stiffness value to use in the next friction equations.

    + +
    + + + +
    -

    restitution

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/collision/Narrowphase.js:91 - -

    - - - - -
    - -
    -

    The restitution value to use in the next contact equations.

    - -
    - - - - - - -
    - - +

    restitution

    + Number + + + + + +
    +

    + Defined in + src/collision/Narrowphase.js:98 +

    + + +
    + +
    +

    The restitution value to use in the next contact equations.

    + +
    + + + +
    -

    slipForce

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/collision/Narrowphase.js:67 - -

    - - - - -
    - -
    -

    The friction slip force to use when creating friction equations.

    - -
    - - - - - - -
    - - +

    slipForce

    + Number + + + + + +
    +

    + Defined in + src/collision/Narrowphase.js:74 +

    + + +
    + +
    +

    The friction slip force to use when creating friction equations.

    + +
    + + + +
    -

    stiffness

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/collision/Narrowphase.js:98 - -

    - - - - -
    - -
    -

    The stiffness value to use in the next contact equations.

    - -
    - - - - - - -
    - - +

    stiffness

    + Number + + + + + +
    +

    + Defined in + src/collision/Narrowphase.js:105 +

    + + +
    + +
    +

    The stiffness value to use in the next contact equations.

    + +
    + + + +
    -

    stiffness

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/collision/Narrowphase.js:104 - -

    - - - - -
    - -
    -

    The stiffness value to use in the next contact equations.

    - -
    - - - - - - -
    - - +

    stiffness

    + Number + + + + + +
    +

    + Defined in + src/collision/Narrowphase.js:111 +

    + + +
    + +
    +

    The stiffness value to use in the next contact equations.

    + +
    + + + +
    -

    surfaceVelocity

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/collision/Narrowphase.js:81 - -

    - - - - -
    - -
    -

    Will be the .relativeVelocity in each produced FrictionEquation.

    - -
    - - - - - - -
    - - +

    surfaceVelocity

    + Number + + + + + +
    +

    + Defined in + src/collision/Narrowphase.js:88 +

    + + +
    + +
    +

    Will be the .relativeVelocity in each produced FrictionEquation.

    + +
    + + + + - - - - diff --git a/docs/classes/OverlapKeeper.html b/docs/classes/OverlapKeeper.html index 6b15c961..49d7bd14 100644 --- a/docs/classes/OverlapKeeper.html +++ b/docs/classes/OverlapKeeper.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,351 +25,222 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    OverlapKeeper Class

    +

    OverlapKeeper Class

    - - - - - -
    -

    Keeps track of overlaps in the current state and the last step state.

    -

    Constructor

    -

    OverlapKeeper

    - - - () - - - - - - - - - - - - - - - - -
    +

    OverlapKeeper

    - - -

    - - Defined in - - + () - src/utils/OverlapKeeper.js:6 -

    - - - -
    - -
    + + +
    +

    + Defined in + src/utils/OverlapKeeper.js:6 +

    + + + +
    + +
    + +
    + + + + +
    - - - - - -
    - -
    - -

    Item Index

    -

    Methods

    - - - -
    -

    Methods

    - -
    +

    bodiesAreOverlapping

    -
    (
      -
    • - bodyA -
    • -
    • - bodyB -
    • -
    )
    - - Boolean - - - - - - -
    - - -

    - Defined in - - - - src/utils/OverlapKeeper.js:83 -

    - -
    @@ -379,254 +248,154 @@

    bodiesAreOverlapping

    -

    Parameters:

      -
    • - bodyA Body - -
      -
    • -
    • - bodyB Body - -
      -
    • -
    - -

    Returns:

    - - Boolean: - -
    - - -
    - -
    +
    +

    setOverlapping

    -
    (
      -
    • - bodyA -
    • -
    • - shapeA -
    • -
    • - bodyB -
    • -
    • - shapeB -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - src/utils/OverlapKeeper.js:49 -

    - -
    -

    Parameters:

      -
    • - bodyA Body - -
      -
    • -
    • - shapeA Body - -
      -
    • -
    • - bodyB Body - -
      -
    • -
    • - shapeB Body - -
      -
    • -
    - - - -
    - -
    +
    +

    tick

    - () - - - - - - - -
    - - -

    - Defined in - - - - src/utils/OverlapKeeper.js:19 -

    - -
    @@ -634,25 +403,16 @@

    tick

    - - - -
    - +
    - - - -
    -
    diff --git a/docs/classes/OverlapKeeperRecord.html b/docs/classes/OverlapKeeperRecord.html index 15030466..f1bd1bcb 100644 --- a/docs/classes/OverlapKeeperRecord.html +++ b/docs/classes/OverlapKeeperRecord.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,479 +25,301 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    OverlapKeeperRecord Class

    +

    OverlapKeeperRecord Class

    - - - - - -
    -

    Overlap data container for the OverlapKeeper

    -

    Constructor

    -

    OverlapKeeperRecord

    - - -
    - (
      - -
    • - - bodyA - -
    • - -
    • - - shapeA - -
    • - -
    • - - bodyB - -
    • - -
    • - - shapeB - -
    • - -
    ) -
    - - - - - - - - - - - - - - - - -
    +

    OverlapKeeperRecord

    + +
    + (
      +
    • + bodyA +
    • +
    • + shapeA +
    • +
    • + bodyB +
    • +
    • + shapeB +
    • +
    ) +
    - - -

    - - Defined in + + + + + + + +

    +

    + Defined in + src/utils/OverlapKeeper.js:176 +

    + + + +
    + +
    - +
    +
    +

    Parameters:

    - src/utils/OverlapKeeper.js:176 +
      +
    • + bodyA + Body -

      - - - +
      + +
      + +
    • +
    • + shapeA + Shape + + +
      + +
      + +
    • +
    • + bodyB + Body + + +
      + +
      + +
    • +
    • + shapeB + Shape + + +
      + +
      + +
    • +
    +
    + -
    - -
    -
    - - -
    -

    Parameters:

    - -
      - -
    • - - bodyA - Body - - - - -
      - -
      - - -
    • - -
    • - - shapeA - Shape - - - - -
      - -
      - - -
    • - -
    • - - bodyB - Body - - - - -
      - -
      - - -
    • - -
    • - - shapeB - Shape - - - - -
      - -
      - - -
    • - -
    - - - - - -
    -
    -

    Item Index

    -

    Methods

    - -

    Properties

    - - -
    -

    Methods

    - -
    +

    set

    -
    (
      -
    • - bodyA -
    • -
    • - shapeA -
    • -
    • - bodyB -
    • -
    • - shapeB -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - src/utils/OverlapKeeper.js:204 -

    - -
    @@ -507,275 +327,162 @@

    set

    -

    Parameters:

      -
    • - bodyA Body - -
      -
    • -
    • - shapeA Shape - -
      -
    • -
    • - bodyB Body - -
      -
    • -
    • - shapeB Shape - -
      -
    • -
    - - - -
    - +
    - -

    Properties

    -
    -

    bodyA

    - Body - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/utils/OverlapKeeper.js:194 - -

    - - - - -
    - -
    - -
    - - - - - - -
    - - +

    bodyA

    + Body + + + + + +
    +

    + Defined in + src/utils/OverlapKeeper.js:194 +

    + + +
    + +
    + +
    + + + +
    -

    bodyB

    - Body - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/utils/OverlapKeeper.js:198 - -

    - - - - -
    - -
    - -
    - - - - - - -
    - - +

    bodyB

    + Body + + + + + +
    +

    + Defined in + src/utils/OverlapKeeper.js:198 +

    + + +
    + +
    + +
    + + + +
    -

    shapeA

    - Shape - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/utils/OverlapKeeper.js:186 - -

    - - - - -
    - -
    - -
    - - - - - - -
    - - +

    shapeA

    + Shape + + + + + +
    +

    + Defined in + src/utils/OverlapKeeper.js:186 +

    + + +
    + +
    + +
    + + + +
    -

    shapeB

    - Shape - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/utils/OverlapKeeper.js:190 - -

    - - - - -
    - -
    - -
    - - - - - - -
    - - +

    shapeB

    + Shape + + + + + +
    +

    + Defined in + src/utils/OverlapKeeper.js:190 +

    + + +
    + +
    + +
    + + + +
    - - -
    - diff --git a/docs/classes/Particle.html b/docs/classes/Particle.html index 0c762682..3aa43626 100644 --- a/docs/classes/Particle.html +++ b/docs/classes/Particle.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,548 +25,350 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    Particle Class

    +

    Particle Class

    - -
    Extends Shape
    - - - - -
    -

    Particle shape class.

    -

    Constructor

    -

    Particle

    - - - () - - - - - - - - - - - - - - - - -
    +

    Particle

    - - -

    - - Defined in - - + () - src/shapes/Particle.js:6 -

    - - - -
    - -
    + + +
    +

    + Defined in + src/shapes/Particle.js:6 +

    + + + +
    + +
    + +
    + + + + +
    - - - - - -
    - -
    - -

    Item Index

    - - -

    Properties

    - - -
    -

    Methods

    - -
    +

    computeAABB

    -
    (
      -
    • - out -
    • -
    • - position -
    • -
    • - angle -
    • -
    )
    - - - - - - - -
    -

    Inherited from Shape - but overwritten in - - - - src/shapes/Particle.js:24 - + src/shapes/Particle.js:26

    - -
    -

    Parameters:

      -
    • - out AABB - -
      -
    • -
    • - position Array - -
      -
    • -
    • - angle Number - -
      -
    • -
    - - - -
    - -
    +
    +

    computeMomentOfInertia

    -
    (
      -
    • - mass -
    • -
    )
    - - Number - - - - - - -
    - -

    Inherited from Shape: - - - - src/shapes/Shape.js:155 - + src/shapes/Shape.js:161

    - -
    @@ -576,88 +376,55 @@

    computeMomentOfInertia

    -

    Parameters:

      -
    • - mass Number - -
      -
    • -
    - -

    Returns:

    - - Number: -

    If the inertia is infinity or if the object simply isn't possible to rotate, return 0.

    -
    - - -
    - -
    +
    +

    updateArea

    - () - - - - - - - -
    - -

    Inherited from Shape: - - - - src/shapes/Shape.js:174 - + src/shapes/Shape.js:180

    - -
    @@ -665,55 +432,33 @@

    updateArea

    - - - -
    - -
    +
    +

    updateBoundingRadius

    - () - - Number - - - - - - -
    - -

    Inherited from Shape: - - - - src/shapes/Shape.js:165 - + src/shapes/Shape.js:171

    - -
    @@ -721,418 +466,290 @@

    updateBoundingRadius

    - -

    Returns:

    - - Number: - -
    - - -
    - +
    - -

    Properties

    -
    -

    area

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:89 - -

    - - - - -
    - -
    -

    Area of this shape.

    - -
    - - - - - - -
    - - +

    area

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:95 +

    + + +
    + +
    +

    Area of this shape.

    + +
    + + + +
    -

    boundingRadius

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:34 - -

    - - - - -
    - -
    -

    Bounding circle radius of this shape

    - -
    - - - - - - -
    - - +

    boundingRadius

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:34 +

    + + +
    + +
    +

    Bounding circle radius of this shape

    + +
    + + + +
    -

    collisionGroup

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:41 - -

    - - - - -
    - -
    -

    Collision group that this shape belongs to (bit mask). See this tutorial.

    - -
    - - - - -
    -

    Example:

    - -
    -
    // Setup bits for each available group
    -var PLAYER = Math.pow(2,0),
    -    ENEMY =  Math.pow(2,1),
    -    GROUND = Math.pow(2,2)
    -
    -// Put shapes into their groups
    -player1Shape.collisionGroup = PLAYER;
    -player2Shape.collisionGroup = PLAYER;
    -enemyShape  .collisionGroup = ENEMY;
    -groundShape .collisionGroup = GROUND;
    -
    -// Assign groups that each shape collide with.
    -// Note that the players can collide with ground and enemies, but not with other players.
    -player1Shape.collisionMask = ENEMY | GROUND;
    -player2Shape.collisionMask = ENEMY | GROUND;
    -enemyShape  .collisionMask = PLAYER | GROUND;
    -groundShape .collisionMask = PLAYER | ENEMY;
    -
    // How collision check is done
    -if(shapeA.collisionGroup & shapeB.collisionMask)!=0 && (shapeB.collisionGroup & shapeA.collisionMask)!=0){
    -    // The shapes will collide
    -}
    - -
    -
    - - - -
    - - +

    collisionGroup

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:41 +

    + + +
    + +
    +

    Collision group that this shape belongs to (bit mask). See this tutorial.

    + +
    + + +
    +

    Example:

    + +
    +
    // Setup bits for each available group
    +                    var PLAYER = Math.pow(2,0),
    +                        ENEMY =  Math.pow(2,1),
    +                        GROUND = Math.pow(2,2)
    +                    
    +                    // Put shapes into their groups
    +                    player1Shape.collisionGroup = PLAYER;
    +                    player2Shape.collisionGroup = PLAYER;
    +                    enemyShape  .collisionGroup = ENEMY;
    +                    groundShape .collisionGroup = GROUND;
    +                    
    +                    // Assign groups that each shape collide with.
    +                    // Note that the players can collide with ground and enemies, but not with other players.
    +                    player1Shape.collisionMask = ENEMY | GROUND;
    +                    player2Shape.collisionMask = ENEMY | GROUND;
    +                    enemyShape  .collisionMask = PLAYER | GROUND;
    +                    groundShape .collisionMask = PLAYER | ENEMY;
    +                    
    // How collision check is done
    +                    if(shapeA.collisionGroup & shapeB.collisionMask)!=0 && (shapeB.collisionGroup & shapeA.collisionMask)!=0){
    +                        // The shapes will collide
    +                    }
    +                    
    +
    +
    + +
    -

    collisionMask

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:72 - -

    - - - - -
    - -
    -

    Collision mask of this shape. See .collisionGroup.

    - -
    - - - - - - -
    - - +

    collisionMask

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:78 +

    + + +
    + +
    +

    Collision mask of this shape. See .collisionGroup.

    + +
    + + + +
    +
    +

    collisionResponse

    + Boolean + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:72 +

    + + +
    + +
    +

    Whether to produce contact forces when in contact with other bodies. Note that contacts will be generated, but they will be disabled. That means that this shape will move through other body shapes, but it will still trigger contact events, etc.

    + +
    + + + +
    -

    id

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:27 - -

    - - - - -
    - -
    -

    Shape object identifier.

    - -
    - - - - - - -
    - - +

    id

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:27 +

    + + +
    + +
    +

    Shape object identifier.

    + +
    + + + +
    -

    material

    - Material - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:82 - -

    - - - - -
    - -
    -

    Material to use in collisions for this Shape. If this is set to null, the world will use default material properties instead.

    - -
    - - - - - - -
    - - +

    material

    + Material + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:88 +

    + + +
    + +
    +

    Material to use in collisions for this Shape. If this is set to null, the world will use default material properties instead.

    + +
    + + + +
    -

    sensor

    - Boolean - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:96 - -

    - - - - -
    - -
    -

    Set to true if you want this shape to be a sensor. A sensor does not generate contacts, but it still reports contact events. This is good if you want to know if a shape is overlapping another shape, without them generating contacts.

    - -
    - - - - - - -
    - - +

    sensor

    + Boolean + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:102 +

    + + +
    + +
    +

    Set to true if you want this shape to be a sensor. A sensor does not generate contacts, but it still reports contact events. This is good if you want to know if a shape is overlapping another shape, without them generating contacts.

    + +
    + + + +
    -

    type

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:11 - -

    - - - - -
    - - - - - - - - -
    - - +

    type

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:11 +

    + + +
    + + + + + + - - - - diff --git a/docs/classes/Plane.html b/docs/classes/Plane.html index 5dc66a29..97eaf806 100644 --- a/docs/classes/Plane.html +++ b/docs/classes/Plane.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,537 +25,344 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    Plane Class

    +

    Plane Class

    - -
    Extends Shape
    - -
    Defined in: src/shapes/Plane.js:7
    - - -
    -

    Plane shape class. The plane is facing in the Y direction.

    -

    Constructor

    -

    Plane

    - - - () - - - - - - - - - - - - - - - - -
    +

    Plane

    - - -

    - - Defined in - - + () - src/shapes/Plane.js:7 -

    - - - -
    - -
    + + +
    +

    + Defined in + src/shapes/Plane.js:7 +

    + + + +
    + +
    + +
    + + + + +
    - - - - - -
    - -
    - -

    Item Index

    - - -

    Properties

    - - -
    -

    Methods

    - -
    +

    computeAABB

    -
    (
      -
    • - out -
    • -
    • - position -
    • -
    • - angle -
    • -
    )
    - - - - - - - -
    -

    Inherited from Shape - but overwritten in - - - - src/shapes/Plane.js:34 - + src/shapes/Plane.js:35

    - -
    -

    Parameters:

      -
    • - out AABB - -
      -
    • -
    • - position Array - -
      -
    • -
    • - angle Number - -
      -
    • -
    - - - -
    - -
    +
    +

    computeMomentOfInertia

    - () - - - - - - - -
    -

    Inherited from Shape - but overwritten in - - - - src/shapes/Plane.js:18 - + src/shapes/Plane.js:19

    - -
    @@ -565,51 +370,30 @@

    computeMomentOfInertia

    - - - -
    - -
    +
    +

    updateArea

    - () - - - - - - - -
    - -

    Inherited from Shape: - - - - src/shapes/Shape.js:174 - + src/shapes/Shape.js:180

    - -
    @@ -617,54 +401,33 @@

    updateArea

    - - - -
    - -
    +
    +

    updateBoundingRadius

    - () - - - - - - - -
    -

    Inherited from Shape - but overwritten in - - - - src/shapes/Plane.js:26 - + src/shapes/Plane.js:27

    - -
    @@ -672,406 +435,283 @@

    updateBoundingRadius

    - - - -
    - +
    - -

    Properties

    -
    -

    area

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:89 - -

    - - - - -
    - -
    -

    Area of this shape.

    - -
    - - - - - - -
    - - +

    area

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:95 +

    + + +
    + +
    +

    Area of this shape.

    + +
    + + + +
    -

    boundingRadius

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:34 - -

    - - - - -
    - -
    -

    Bounding circle radius of this shape

    - -
    - - - - - - -
    - - +

    boundingRadius

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:34 +

    + + +
    + +
    +

    Bounding circle radius of this shape

    + +
    + + + +
    -

    collisionGroup

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:41 - -

    - - - - -
    - -
    -

    Collision group that this shape belongs to (bit mask). See this tutorial.

    - -
    - - - - -
    -

    Example:

    - -
    -
    // Setup bits for each available group
    -var PLAYER = Math.pow(2,0),
    -    ENEMY =  Math.pow(2,1),
    -    GROUND = Math.pow(2,2)
    -
    -// Put shapes into their groups
    -player1Shape.collisionGroup = PLAYER;
    -player2Shape.collisionGroup = PLAYER;
    -enemyShape  .collisionGroup = ENEMY;
    -groundShape .collisionGroup = GROUND;
    -
    -// Assign groups that each shape collide with.
    -// Note that the players can collide with ground and enemies, but not with other players.
    -player1Shape.collisionMask = ENEMY | GROUND;
    -player2Shape.collisionMask = ENEMY | GROUND;
    -enemyShape  .collisionMask = PLAYER | GROUND;
    -groundShape .collisionMask = PLAYER | ENEMY;
    -
    // How collision check is done
    -if(shapeA.collisionGroup & shapeB.collisionMask)!=0 && (shapeB.collisionGroup & shapeA.collisionMask)!=0){
    -    // The shapes will collide
    -}
    - -
    -
    - - - -
    - - +

    collisionGroup

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:41 +

    + + +
    + +
    +

    Collision group that this shape belongs to (bit mask). See this tutorial.

    + +
    + + +
    +

    Example:

    + +
    +
    // Setup bits for each available group
    +                    var PLAYER = Math.pow(2,0),
    +                        ENEMY =  Math.pow(2,1),
    +                        GROUND = Math.pow(2,2)
    +                    
    +                    // Put shapes into their groups
    +                    player1Shape.collisionGroup = PLAYER;
    +                    player2Shape.collisionGroup = PLAYER;
    +                    enemyShape  .collisionGroup = ENEMY;
    +                    groundShape .collisionGroup = GROUND;
    +                    
    +                    // Assign groups that each shape collide with.
    +                    // Note that the players can collide with ground and enemies, but not with other players.
    +                    player1Shape.collisionMask = ENEMY | GROUND;
    +                    player2Shape.collisionMask = ENEMY | GROUND;
    +                    enemyShape  .collisionMask = PLAYER | GROUND;
    +                    groundShape .collisionMask = PLAYER | ENEMY;
    +                    
    // How collision check is done
    +                    if(shapeA.collisionGroup & shapeB.collisionMask)!=0 && (shapeB.collisionGroup & shapeA.collisionMask)!=0){
    +                        // The shapes will collide
    +                    }
    +                    
    +
    +
    + +
    -

    collisionMask

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:72 - -

    - - - - -
    - -
    -

    Collision mask of this shape. See .collisionGroup.

    - -
    - - - - - - -
    - - +

    collisionMask

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:78 +

    + + +
    + +
    +

    Collision mask of this shape. See .collisionGroup.

    + +
    + + + +
    +
    +

    collisionResponse

    + Boolean + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:72 +

    + + +
    + +
    +

    Whether to produce contact forces when in contact with other bodies. Note that contacts will be generated, but they will be disabled. That means that this shape will move through other body shapes, but it will still trigger contact events, etc.

    + +
    + + + +
    -

    id

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:27 - -

    - - - - -
    - -
    -

    Shape object identifier.

    - -
    - - - - - - -
    - - +

    id

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:27 +

    + + +
    + +
    +

    Shape object identifier.

    + +
    + + + +
    -

    material

    - Material - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:82 - -

    - - - - -
    - -
    -

    Material to use in collisions for this Shape. If this is set to null, the world will use default material properties instead.

    - -
    - - - - - - -
    - - +

    material

    + Material + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:88 +

    + + +
    + +
    +

    Material to use in collisions for this Shape. If this is set to null, the world will use default material properties instead.

    + +
    + + + +
    -

    sensor

    - Boolean - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:96 - -

    - - - - -
    - -
    -

    Set to true if you want this shape to be a sensor. A sensor does not generate contacts, but it still reports contact events. This is good if you want to know if a shape is overlapping another shape, without them generating contacts.

    - -
    - - - - - - -
    - - +

    sensor

    + Boolean + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:102 +

    + + +
    + +
    +

    Set to true if you want this shape to be a sensor. A sensor does not generate contacts, but it still reports contact events. This is good if you want to know if a shape is overlapping another shape, without them generating contacts.

    + +
    + + + +
    -

    type

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:11 - -

    - - - - -
    - - - - - - - - -
    - - +

    type

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:11 +

    + + +
    + + + + + + - - - - diff --git a/docs/classes/PrismaticConstraint.html b/docs/classes/PrismaticConstraint.html index 0e49a57a..534ad76e 100644 --- a/docs/classes/PrismaticConstraint.html +++ b/docs/classes/PrismaticConstraint.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,654 +25,422 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    PrismaticConstraint Class

    +

    PrismaticConstraint Class

    - -
    Extends Constraint
    - - - - -
    -

    Constraint that only allows bodies to move along a line, relative to each other. See this tutorial.

    -

    Constructor

    -

    PrismaticConstraint

    - - -
    - (
      - -
    • - - bodyA - -
    • - -
    • - - bodyB - -
    • - -
    • - - [options] - -
    • - -
    ) -
    - - - - - - - - - - - - - - - - -
    +

    PrismaticConstraint

    + +
    + (
      +
    • + bodyA +
    • +
    • + bodyB +
    • +
    • + [options] +
    • +
    ) +
    - - -

    - - Defined in + + + + + + + +

    +

    + Defined in + src/constraints/PrismaticConstraint.js:9 +

    + + + +
    + +
    - +
    +
    +

    Parameters:

    - src/constraints/PrismaticConstraint.js:9 +
      +
    • + bodyA + Body -

      - - - +
      + +
      + +
    • +
    • + bodyB + Body + + +
      + +
      + +
    • +
    • + [options] + Object + optional + + +
      + +
      + +
        +
      • + [maxForce] + Number + optional + +
        +

        Max force to be applied by the constraint

        + +
        + +
      • +
      • + [localAnchorA] + Array + optional + +
        +

        Body A's anchor point, defined in its own local frame.

        + +
        + +
      • +
      • + [localAnchorB] + Array + optional + +
        +

        Body B's anchor point, defined in its own local frame.

        + +
        + +
      • +
      • + [localAxisA] + Array + optional + +
        +

        An axis, defined in body A frame, that body B's anchor point may slide along.

        + +
        + +
      • +
      • + [disableRotationalLock] + Boolean + optional + +
        +

        If set to true, bodyB will be free to rotate around its anchor point.

        + +
        + +
      • +
      • + [upperLimit] + Number + optional + +
        + +
        + +
      • +
      • + [lowerLimit] + Number + optional + +
        + +
        + +
      • +
      +
    • +
    +
    + -
    - -
    -
    - - -
    -

    Parameters:

    - -
      - -
    • - - bodyA - Body - - - - -
      - -
      - - -
    • - -
    • - - bodyB - Body - - - - -
      - -
      - - -
    • - -
    • - - [options] - Object - optional - - - - -
      - -
      - - -
        - -
      • - - [maxForce] - Number - optional - - -
        -

        Max force to be applied by the constraint

        - -
        - - -
      • - -
      • - - [localAnchorA] - Array - optional - - -
        -

        Body A's anchor point, defined in its own local frame.

        - -
        - - -
      • - -
      • - - [localAnchorB] - Array - optional - - -
        -

        Body B's anchor point, defined in its own local frame.

        - -
        - - -
      • - -
      • - - [localAxisA] - Array - optional - - -
        -

        An axis, defined in body A frame, that body B's anchor point may slide along.

        - -
        - - -
      • - -
      • - - [disableRotationalLock] - Boolean - optional - - -
        -

        If set to true, bodyB will be free to rotate around its anchor point.

        - -
        - - -
      • - -
      • - - [upperLimit] - Number - optional - - -
        - -
        - - -
      • - -
      • - - [lowerLimit] - Number - optional - - -
        - -
        - - -
      • - -
      - -
    • - -
    - - - - - -
    -
    -

    Item Index

    -

    Methods

    - -

    Properties

    - - -
    -

    Methods

    - -
    +

    disableMotor

    - () - - - - - - - -
    @@ -682,54 +448,30 @@

    disableMotor

    - - - -
    - -
    +
    +

    enableMotor

    - () - - - - - - - -
    @@ -737,70 +479,39 @@

    enableMotor

    - - - -
    - -
    +
    +

    setLimits

    -
    (
      -
    • - lower -
    • -
    • - upper -
    • -
    )
    - - - - - - - -
    @@ -808,101 +519,64 @@

    setLimits

    -

    Parameters:

      -
    • - lower Number - -

      Lower limit.

      -
    • -
    • - upper Number - -

      Upper limit.

      -
    • -
    - - - -
    - -
    +
    +

    setRelaxation

    -
    (
      -
    • - relaxation -
    • -
    )
    - - - - - - - -
    @@ -910,84 +584,52 @@

    setRelaxation

    -

    Parameters:

      -
    • - relaxation Number - -
      -
    • -
    - - - -
    - -
    +
    +

    setStiffness

    -
    (
      -
    • - stiffness -
    • -
    )
    - - - - - - - -
    @@ -995,77 +637,49 @@

    setStiffness

    -

    Parameters:

      -
    • - stiffness Number - -
      -
    • -
    - - - -
    - -
    +
    +

    update

    - () - - - - - - - -
    @@ -1073,693 +687,418 @@

    update

    - - - -
    - +
    - -

    Properties

    -
    -

    bodyA

    - Body - - - - - - - - - -
    - - -

    Inherited from - Constraint: - - - - src/constraints/Constraint.js:33 - -

    - - - - -
    - -
    -

    First body participating in the constraint.

    - -
    - - - - - - -
    - - +

    bodyA

    + Body + + + + + +
    +

    Inherited from + Constraint: + src/constraints/Constraint.js:38 +

    + + +
    + +
    +

    First body participating in the constraint.

    + +
    + + + +
    -

    bodyB

    - Body - - - - - - - - - -
    - - -

    Inherited from - Constraint: - - - - src/constraints/Constraint.js:40 - -

    - - - - -
    - -
    -

    Second body participating in the constraint.

    - -
    - - - - - - -
    - - +

    bodyB

    + Body + + + + + +
    +

    Inherited from + Constraint: + src/constraints/Constraint.js:45 +

    + + +
    + +
    +

    Second body participating in the constraint.

    + +
    + + + +
    -

    collideConnected

    - Boolean - - - - - - - - - -
    - - -

    Inherited from - Constraint: - - - - src/constraints/Constraint.js:47 - -

    - - - - -
    - -
    -

    Set to true if you want the connected bodies to collide.

    - -
    - - -

    Default: true

    - - - - - -
    - - +

    collideConnected

    + Boolean + + + + + +
    +

    Inherited from + Constraint: + src/constraints/Constraint.js:52 +

    + + +
    + +
    +

    Set to true if you want the connected bodies to collide.

    + +
    + +

    Default: true

    + + +
    -

    equations

    - Array - - - - - - - - - -
    - - -

    Inherited from - Constraint: - - - - src/constraints/Constraint.js:25 - -

    - - - - -
    - -
    -

    Equations to be solved in this constraint

    - -
    - - - - - - -
    - - +

    equations

    + Array + + + + + +
    +

    Inherited from + Constraint: + src/constraints/Constraint.js:30 +

    + + +
    + +
    +

    Equations to be solved in this constraint

    + +
    + + + +
    -

    localAnchorA

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/constraints/PrismaticConstraint.js:40 - -

    - - - - -
    - -
    - -
    - - - - - - -
    - - +

    localAnchorA

    + Array + + + + + + + +
    + +
    + + + +
    -

    localAnchorB

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/constraints/PrismaticConstraint.js:46 - -

    - - - - -
    - -
    - -
    - - - - - - -
    - - +

    localAnchorB

    + Array + + + + + + + +
    + +
    + + + +
    -

    localAxisA

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/constraints/PrismaticConstraint.js:52 - -

    - - - - -
    - -
    - -
    - - - - - - -
    - - +

    localAxisA

    + Array + + + + + + + +
    + +
    + + + +
    -

    lowerLimit

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/constraints/PrismaticConstraint.js:137 - -

    - - - - -
    - -
    -

    Lower constraint limit. The constraint position is forced to be larger than this value.

    - -
    - - - - - - -
    - - +

    lowerLimit

    + Number + + + + + + + +
    +

    Lower constraint limit. The constraint position is forced to be larger than this value.

    + +
    + + + +
    -

    lowerLimitEnabled

    - Boolean - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/constraints/PrismaticConstraint.js:123 - -

    - - - - -
    - -
    -

    Set to true to enable lower limit.

    - -
    - - - - - - -
    - - +

    lowerLimitEnabled

    + Boolean + + + + + + + +
    +

    Set to true to enable lower limit.

    + +
    + + + +
    -

    motorEnabled

    - Boolean - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/constraints/PrismaticConstraint.js:166 - -

    - - - - -
    - -
    -

    The current motor state. Enable or disable the motor using .enableMotor

    - -
    - - - - - - -
    - - +

    motorEnabled

    + Boolean + + + + + + + +
    +

    The current motor state. Enable or disable the motor using .enableMotor

    + +
    + + + +
    -

    motorEquation

    - Equation - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/constraints/PrismaticConstraint.js:159 - -

    - - - - -
    - -
    -

    Equation used for the motor.

    - -
    - - - - - - -
    - - +

    motorEquation

    + Equation + + + + + + + +
    +

    Equation used for the motor.

    + +
    + + + +
    -

    motorSpeed

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/constraints/PrismaticConstraint.js:173 - -

    - - - - -
    - -
    -

    Set the target speed for the motor.

    - -
    - - - - - - -
    - - +

    motorSpeed

    + Number + + + + + + + +
    +

    Set the target speed for the motor.

    + +
    + + + +
    -

    position

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/constraints/PrismaticConstraint.js:114 - -

    - - - - -
    - -
    -

    The position of anchor A relative to anchor B, along the constraint axis.

    - -
    - - - - - - -
    - - +

    position

    + Number + + + + + + + +
    +

    The position of anchor A relative to anchor B, along the constraint axis.

    + +
    + + + + +
    +

    type

    + Number + + + + + +
    +

    Inherited from + Constraint: + src/constraints/Constraint.js:19 +

    + + +
    + +
    +

    The type of constraint. May be one of Constraint.DISTANCE, Constraint.GEAR, Constraint.LOCK, Constraint.PRISMATIC or Constraint.REVOLUTE.

    + +
    + + + +
    -

    upperLimit

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/constraints/PrismaticConstraint.js:144 - -

    - - - - -
    - -
    -

    Upper constraint limit. The constraint position is forced to be smaller than this value.

    - -
    - - - - - - -
    - - +

    upperLimit

    + Number + + + + + + + +
    +

    Upper constraint limit. The constraint position is forced to be smaller than this value.

    + +
    + + + +
    -

    upperLimitEnabled

    - Boolean - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/constraints/PrismaticConstraint.js:130 - -

    - - - - -
    - -
    -

    Set to true to enable upper limit.

    - -
    - - - - - - -
    - - +

    upperLimitEnabled

    + Boolean + + + + + + + +
    +

    Set to true to enable upper limit.

    + +
    + + + + - - - - diff --git a/docs/classes/Ray.html b/docs/classes/Ray.html new file mode 100644 index 00000000..4e9eb5ad --- /dev/null +++ b/docs/classes/Ray.html @@ -0,0 +1,1294 @@ + + + + + Ray - p2.js + + + + + + + + +
    +
    +
    +

    +
    +
    + API Docs for: 0.6.1 +
    +
    +
    + + +
    +
    + Show: + + + + + + + +
    + +
    +
    +
    +

    Ray Class

    +
    + + +
    + Defined in: src/collision/Ray.js:8 +
    + + +
    + + +
    +

    A line with a start and end point that is used to intersect shapes.

    + +
    + +
    +

    Constructor

    +
    +

    Ray

    + + () + + + + + + + + +
    +

    + Defined in + src/collision/Ray.js:8 +

    + + + +
    + +
    + +
    + + + + +
    +
    + +
    + + +
    +
    +

    Item Index

    + +
    +

    Methods

    + + +
    + +
    +

    Properties

    + + +
    + + +
    + +
    +

    Methods

    + +
    +

    _updateDirection

    + + () + + + + private + + + + + +
    +

    + Defined in + src/collision/Ray.js:200 +

    + + + +
    + +
    +

    Updates the _direction vector.

    + +
    + + + + +
    +
    +

    getAABB

    + +
    + (
      +
    • + aabb +
    • +
    ) +
    + + + + + + + + +
    +

    + Defined in + src/collision/Ray.js:459 +

    + + + +
    + +
    +

    Get the AABB of the ray.

    + +
    + +
    +

    Parameters:

    + +
      +
    • + aabb + AABB + + +
      + +
      + +
    • +
    +
    + + + +
    +
    +

    intersectBodies

    + +
    + (
      +
    • + bodies +
    • +
    • + [result] +
    • +
    ) +
    + + + + + + + + +
    +

    + Defined in + src/collision/Ray.js:184 +

    + + + +
    + +
    + +
    + +
    +

    Parameters:

    + +
      +
    • + bodies + Array + + +
      +

      An array of Body objects.

      + +
      + +
    • +
    • + [result] + RaycastResult + optional + + +
      +

      Deprecated

      + +
      + +
    • +
    +
    + + + +
    +
    +

    intersectBody

    + +
    + (
      +
    • + body +
    • +
    • + [result] +
    • +
    ) +
    + + + + private + + + + + +
    +

    + Defined in + src/collision/Ray.js:133 +

    + + + +
    + +
    +

    Shoot a ray at a body, get back information about the hit.

    + +
    + +
    +

    Parameters:

    + +
      +
    • + body + Body + + +
      + +
      + +
    • +
    • + [result] + RaycastResult + optional + + +
      +

      Deprecated - set the result property of the Ray instead.

      + +
      + +
    • +
    +
    + + + +
    +
    +

    intersectPlane

    + +
    + (
      +
    • + shape +
    • +
    • + angle +
    • +
    • + position +
    • +
    • + body +
    • +
    ) +
    + + + + private + + + + + +
    +

    + Defined in + src/collision/Ray.js:352 +

    + + + +
    + +
    + +
    + +
    +

    Parameters:

    + +
      +
    • + shape + Shape + + +
      + +
      + +
    • +
    • + angle + Number + + +
      + +
      + +
    • +
    • + position + Array + + +
      + +
      + +
    • +
    • + body + Body + + +
      + +
      + +
    • +
    +
    + + + +
    +
    +

    intersectRectangle

    + +
    + (
      +
    • + shape +
    • +
    • + angle +
    • +
    • + position +
    • +
    • + body +
    • +
    ) +
    + + + + private + + + + + +
    +

    + Defined in + src/collision/Ray.js:253 +

    + + + +
    + +
    + +
    + +
    +

    Parameters:

    + +
      +
    • + shape + Shape + + +
      + +
      + +
    • +
    • + angle + Number + + +
      + +
      + +
    • +
    • + position + Array + + +
      + +
      + +
    • +
    • + body + Body + + +
      + +
      + +
    • +
    +
    + + + +
    +
    +

    intersectShape

    + +
    + (
      +
    • + shape +
    • +
    • + angle +
    • +
    • + position +
    • +
    • + body +
    • +
    ) +
    + + + + private + + + + + +
    +

    + Defined in + src/collision/Ray.js:211 +

    + + + +
    + +
    + +
    + +
    +

    Parameters:

    + +
      +
    • + shape + Shape + + +
      + +
      + +
    • +
    • + angle + Number + + +
      + +
      + +
    • +
    • + position + Array + + +
      + +
      + +
    • +
    • + body + Body + + +
      + +
      + +
    • +
    +
    + + + +
    +
    +

    intersectWorld

    + +
    + (
      +
    • + world +
    • +
    • + options +
    • +
    ) +
    + + + Boolean + + + + + + + + +
    +

    + Defined in + src/collision/Ray.js:95 +

    + + + +
    + +
    +

    Do itersection against all bodies in the given World.

    + +
    + +
    +

    Parameters:

    + +
      +
    • + world + World + + +
      + +
      + +
    • +
    • + options + Object + + +
      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + Boolean: +

    True if the ray hit anything, otherwise false.

    + +
    +
    + + +
    +
    +

    reportIntersection

    + +
    + (
      +
    • + normal +
    • +
    • + hitPointWorld +
    • +
    • + shape +
    • +
    • + body +
    • +
    ) +
    + + + Boolean + + + + private + + + + + +
    +

    + Defined in + src/collision/Ray.js:473 +

    + + + +
    + +
    + +
    + +
    +

    Parameters:

    + +
      +
    • + normal + Array + + +
      + +
      + +
    • +
    • + hitPointWorld + Array + + +
      + +
      + +
    • +
    • + shape + Shape + + +
      + +
      + +
    • +
    • + body + Body + + +
      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + Boolean: +

    True if the intersections should continue

    + +
    +
    + + +
    +
    + +
    +

    Properties

    + +
    +

    _direction

    + Array + + + private + + + +
    +

    + Defined in + src/collision/Ray.js:26 +

    + + +
    + +
    + +
    + + + +
    +
    +

    callback

    + Function + + + + + +
    +

    + Defined in + src/collision/Ray.js:80 +

    + + +
    + +
    +

    Current, user-provided result callback. Will be used if mode is Ray.ALL.

    + +
    + + + +
    +
    +

    checkCollisionResponse

    + Boolean + + + + + +
    +

    + Defined in + src/collision/Ray.js:38 +

    + + +
    + +
    +

    Set to true if you want the Ray to take .collisionResponse flags into account on bodies and shapes.

    + +
    + + + +
    +
    +

    collisionGroup

    + Number + + + + + +
    +

    + Defined in + src/collision/Ray.js:56 +

    + + +
    + +
    + +
    + +

    Default: -1

    + + +
    +
    +

    collisionMask

    + Number + + + + + +
    +

    + Defined in + src/collision/Ray.js:50 +

    + + +
    + +
    + +
    + +

    Default: -1

    + + +
    +
    +

    from

    + Array + + + + + +
    +

    + Defined in + src/collision/Ray.js:16 +

    + + +
    + +
    + +
    + + + +
    +
    +

    hasHit

    + Boolean + + + + + +
    +

    + Defined in + src/collision/Ray.js:74 +

    + + +
    + +
    +

    Will be set to true during intersectWorld() if the ray hit anything.

    + +
    + + + +
    +
    +

    mode

    + Number + + + + + +
    +

    + Defined in + src/collision/Ray.js:62 +

    + + +
    + +
    +

    The intersection mode. Should be Ray.ANY, Ray.ALL or Ray.CLOSEST.

    + +
    + + + +
    +
    +

    precision

    + Number + + + + + +
    +

    + Defined in + src/collision/Ray.js:32 +

    + + +
    + +
    +

    The precision of the ray. Used when checking parallelity etc.

    + +
    + + + +
    +
    +

    result

    + RaycastResult + + + + + +
    +

    + Defined in + src/collision/Ray.js:68 +

    + + +
    + +
    +

    Current result object.

    + +
    + + + +
    +
    +

    skipBackfaces

    + Boolean + + + + + +
    +

    + Defined in + src/collision/Ray.js:44 +

    + + +
    + +
    +

    If set to true, the ray skips any hits with normal.dot(rayDirection) < 0.

    + +
    + + + +
    +
    +

    to

    + Array + + + + + +
    +

    + Defined in + src/collision/Ray.js:21 +

    + + +
    + +
    + +
    + + + +
    +
    + + +
    +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + diff --git a/docs/classes/RaycastResult.html b/docs/classes/RaycastResult.html new file mode 100644 index 00000000..50fddaae --- /dev/null +++ b/docs/classes/RaycastResult.html @@ -0,0 +1,724 @@ + + + + + RaycastResult - p2.js + + + + + + + + +
    +
    +
    +

    +
    +
    + API Docs for: 0.6.1 +
    +
    +
    + + +
    +
    + Show: + + + + + + + +
    + +
    +
    +
    +

    RaycastResult Class

    +
    + + + + + +
    + + +
    +

    Storage for Ray casting data.

    + +
    + +
    +

    Constructor

    +
    +

    RaycastResult

    + + () + + + + + + + + +
    +

    + Defined in + src/collision/RaycastResult.js:5 +

    + + + +
    + +
    + +
    + + + + +
    +
    + +
    + + +
    +
    +

    Item Index

    + +
    +

    Methods

    + + +
    + +
    +

    Properties

    + + +
    + + +
    + +
    +

    Methods

    + +
    +

    abort

    + + () + + + + + + + + +
    +

    + Defined in + src/collision/RaycastResult.js:89 +

    + + + +
    + +
    + +
    + + + + +
    +
    +

    reset

    + + () + + + + + + + + +
    +

    + Defined in + src/collision/RaycastResult.js:72 +

    + + + +
    + +
    +

    Reset all result data.

    + +
    + + + + +
    +
    +

    set

    + +
    + (
      +
    • + rayFromWorld +
    • +
    • + rayToWorld +
    • +
    • + hitNormalWorld +
    • +
    • + hitPointWorld +
    • +
    • + shape +
    • +
    • + body +
    • +
    • + distance +
    • +
    ) +
    + + + + + + + + +
    +

    + Defined in + src/collision/RaycastResult.js:96 +

    + + + +
    + +
    + +
    + +
    +

    Parameters:

    + +
      +
    • + rayFromWorld + Array + + +
      + +
      + +
    • +
    • + rayToWorld + Array + + +
      + +
      + +
    • +
    • + hitNormalWorld + Array + + +
      + +
      + +
    • +
    • + hitPointWorld + Array + + +
      + +
      + +
    • +
    • + shape + Shape + + +
      + +
      + +
    • +
    • + body + Body + + +
      + +
      + +
    • +
    • + distance + Number + + +
      + +
      + +
    • +
    +
    + + + +
    +
    + +
    +

    Properties

    + +
    +

    _shouldStop

    + Boolean + + + private + + + +
    +

    + Defined in + src/collision/RaycastResult.js:63 +

    + + +
    + +
    +

    If the ray should stop traversing the bodies.

    + +
    + +

    Default: false

    + + +
    +
    +

    body

    + Body + + + + + +
    +

    + Defined in + src/collision/RaycastResult.js:43 +

    + + +
    + +
    +

    The hit body, or null.

    + +
    + + + +
    +
    +

    distance

    + Number + + + + + +
    +

    + Defined in + src/collision/RaycastResult.js:56 +

    + + +
    + +
    +

    Distance to the hit. Will be set to -1 if there was no hit.

    + +
    + +

    Default: -1

    + + +
    +
    +

    hasHit

    + Boolean + + + + + +
    +

    + Defined in + src/collision/RaycastResult.js:32 +

    + + +
    + +
    + +
    + + + +
    +
    +

    hitFaceIndex

    + Number + + + + + +
    +

    + Defined in + src/collision/RaycastResult.js:49 +

    + + +
    + +
    +

    The index of the hit triangle, if the hit shape was a trimesh.

    + +
    + +

    Default: -1

    + + +
    +
    +

    hitNormalWorld

    + Array + + + + + +
    +

    + Defined in + src/collision/RaycastResult.js:22 +

    + + +
    + +
    + +
    + + + +
    +
    +

    hitPointWorld

    + Array + + + + + +
    +

    + Defined in + src/collision/RaycastResult.js:27 +

    + + +
    + +
    + +
    + + + +
    +
    +

    rayFromWorld

    + Array + + + + + +
    +

    + Defined in + src/collision/RaycastResult.js:12 +

    + + +
    + +
    + +
    + + + +
    +
    +

    rayToWorld

    + Array + + + + + +
    +

    + Defined in + src/collision/RaycastResult.js:17 +

    + + +
    + +
    + +
    + + + +
    +
    +

    shape

    + Shape + + + + + +
    +

    + Defined in + src/collision/RaycastResult.js:37 +

    + + +
    + +
    +

    The hit shape, or null.

    + +
    + + + +
    +
    + + +
    +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + diff --git a/docs/classes/Rectangle.html b/docs/classes/Rectangle.html index 2423edf0..eccd7f7a 100644 --- a/docs/classes/Rectangle.html +++ b/docs/classes/Rectangle.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,664 +25,425 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    Rectangle Class

    +

    Rectangle Class

    - -
    Extends Convex
    - - - - -
    -

    Rectangle shape class.

    -

    Constructor

    -

    Rectangle

    - - -
    - (
      - -
    • - - width - -
    • - -
    • - - height - -
    • - -
    ) -
    - - - - - - - - - - - - - - - - -
    +

    Rectangle

    + +
    + (
      +
    • + [width=1] +
    • +
    • + [height=1] +
    • +
    ) +
    - - -

    - - Defined in + + + + + + + +

    +

    + Defined in + src/shapes/Rectangle.js:7 +

    + + + +
    + +
    - +
    +
    +

    Parameters:

    - src/shapes/Rectangle.js:7 +
      +
    • + [width=1] + Number + optional -

      - - - +
      +

      Width

      + +
      + +
    • +
    • + [height=1] + Number + optional + + +
      +

      Height

      + +
      + +
    • +
    +
    + -
    - -
    -
    - - -
    -

    Parameters:

    - -
      - -
    • - - width - Number - - - - -
      -

      Width

      - -
      - - -
    • - -
    • - - height - Number - - - - -
      -

      Height

      - -
      - - -
    • - -
    - - - - - -
    -
    -

    Item Index

    - - -

    Properties

    - - -
    -

    Methods

    - -
    +

    computeAABB

    -
    (
      -
    • - out -
    • -
    • - position -
    • -
    • - angle -
    • -
    )
    - - - - - - - -
    -

    Inherited from Shape - but overwritten in - - - - src/shapes/Rectangle.js:70 - + src/shapes/Rectangle.js:71

    - -
    -

    Parameters:

      -
    • - out AABB - -

      The resulting AABB.

      -
    • -
    • - position Array - -
      -
    • -
    • - angle Number - -
      -
    • -
    - - - -
    - -
    +
    +

    computeMomentOfInertia

    -
    (
      -
    • - mass -
    • -
    )
    - - Number - - - - - - -
    -

    Inherited from Shape - but overwritten in - - - - src/shapes/Rectangle.js:43 - + src/shapes/Rectangle.js:44

    - -
    @@ -692,89 +451,56 @@

    computeMomentOfInertia

    -

    Parameters:

      -
    • - mass Number - -
      -
    • -
    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    updateArea

    - () - - - - - - - -
    -

    Inherited from Shape - but overwritten in - - - - src/shapes/Convex.js:290 - + src/shapes/Convex.js:296

    - -
    @@ -782,54 +508,33 @@

    updateArea

    - - - -
    - -
    +
    +

    updateBoundingRadius

    - () - - - - - - - -
    -

    Inherited from Shape - but overwritten in - - - - src/shapes/Rectangle.js:55 - + src/shapes/Rectangle.js:56

    - -
    @@ -837,51 +542,30 @@

    updateBoundingRadius

    - - - -
    - -
    +
    +

    updateCenterOfMass

    - () - - - - - - - -
    - -

    Inherited from Convex: - - - - src/shapes/Convex.js:195 - + src/shapes/Convex.js:201

    - -
    @@ -889,51 +573,30 @@

    updateCenterOfMass

    - - - -
    - -
    +
    +

    updateTriangles

    - () - - - - - - - -
    - -

    Inherited from Convex: - - - - src/shapes/Convex.js:156 - + src/shapes/Convex.js:162

    - -
    @@ -941,667 +604,436 @@

    updateTriangles

    - - - -
    - +
    - -

    Properties

    -
    -

    area

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:89 - -

    - - - - -
    - -
    -

    Area of this shape.

    - -
    - - - - - - -
    - - +

    area

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:95 +

    + + +
    + +
    +

    Area of this shape.

    + +
    + + + +
    -

    axes

    - Array - - - - - - - - - -
    - - -

    Inherited from - Convex: - - - - src/shapes/Convex.js:25 - -

    - - - - -
    - -
    -

    Axes defined in the local frame.

    - -
    - - - - - - -
    - - +

    axes

    + Array + + + + + +
    +

    Inherited from + Convex: + src/shapes/Convex.js:30 +

    + + +
    + +
    +

    Axes defined in the local frame.

    + +
    + + + +
    -

    boundingRadius

    - Number - - - - - - - - - -
    - -

    Inherited from - - Shape - - - but overwritten in - - - - src/shapes/Convex.js:83 - -

    - - - - -
    - -
    -

    The bounding radius of the convex

    - -
    - - - - - - -
    - - +

    boundingRadius

    + Number + + + + + +
    +

    Inherited from + + Shape + + but overwritten in + src/shapes/Convex.js:88 +

    + + +
    + +
    +

    The bounding radius of the convex

    + +
    + + + +
    -

    centerOfMass

    - Array - - - - - - - - - -
    - - -

    Inherited from - Convex: - - - - src/shapes/Convex.js:64 - -

    - - - - -
    - -
    -

    The center of mass of the Convex

    - -
    - - - - - - -
    - - +

    centerOfMass

    + Array + + + + + +
    +

    Inherited from + Convex: + src/shapes/Convex.js:69 +

    + + +
    + +
    +

    The center of mass of the Convex

    + +
    + + + +
    -

    collisionGroup

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:41 - -

    - - - - -
    - -
    -

    Collision group that this shape belongs to (bit mask). See this tutorial.

    - -
    - - - - -
    -

    Example:

    - -
    -
    // Setup bits for each available group
    -var PLAYER = Math.pow(2,0),
    -    ENEMY =  Math.pow(2,1),
    -    GROUND = Math.pow(2,2)
    -
    -// Put shapes into their groups
    -player1Shape.collisionGroup = PLAYER;
    -player2Shape.collisionGroup = PLAYER;
    -enemyShape  .collisionGroup = ENEMY;
    -groundShape .collisionGroup = GROUND;
    -
    -// Assign groups that each shape collide with.
    -// Note that the players can collide with ground and enemies, but not with other players.
    -player1Shape.collisionMask = ENEMY | GROUND;
    -player2Shape.collisionMask = ENEMY | GROUND;
    -enemyShape  .collisionMask = PLAYER | GROUND;
    -groundShape .collisionMask = PLAYER | ENEMY;
    -
    // How collision check is done
    -if(shapeA.collisionGroup & shapeB.collisionMask)!=0 && (shapeB.collisionGroup & shapeA.collisionMask)!=0){
    -    // The shapes will collide
    -}
    - -
    -
    - - - -
    - - -
    -

    collisionMask

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:72 - -

    - - - - -
    - -
    -

    Collision mask of this shape. See .collisionGroup.

    - -
    - - - - - - -
    - - +

    collisionGroup

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:41 +

    + + +
    + +
    +

    Collision group that this shape belongs to (bit mask). See this tutorial.

    + +
    + + +
    +

    Example:

    + +
    +
    // Setup bits for each available group
    +                    var PLAYER = Math.pow(2,0),
    +                        ENEMY =  Math.pow(2,1),
    +                        GROUND = Math.pow(2,2)
    +                    
    +                    // Put shapes into their groups
    +                    player1Shape.collisionGroup = PLAYER;
    +                    player2Shape.collisionGroup = PLAYER;
    +                    enemyShape  .collisionGroup = ENEMY;
    +                    groundShape .collisionGroup = GROUND;
    +                    
    +                    // Assign groups that each shape collide with.
    +                    // Note that the players can collide with ground and enemies, but not with other players.
    +                    player1Shape.collisionMask = ENEMY | GROUND;
    +                    player2Shape.collisionMask = ENEMY | GROUND;
    +                    enemyShape  .collisionMask = PLAYER | GROUND;
    +                    groundShape .collisionMask = PLAYER | ENEMY;
    +                    
    // How collision check is done
    +                    if(shapeA.collisionGroup & shapeB.collisionMask)!=0 && (shapeB.collisionGroup & shapeA.collisionMask)!=0){
    +                        // The shapes will collide
    +                    }
    +                    
    +
    +
    + +
    +
    +

    collisionMask

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:78 +

    + + +
    + +
    +

    Collision mask of this shape. See .collisionGroup.

    + +
    + + + +
    +
    +

    collisionResponse

    + Boolean + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:72 +

    + + +
    + +
    +

    Whether to produce contact forces when in contact with other bodies. Note that contacts will be generated, but they will be disabled. That means that this shape will move through other body shapes, but it will still trigger contact events, etc.

    + +
    + + + +
    -

    height

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/shapes/Rectangle.js:24 - -

    - - - - -
    - -
    -

    Total height of the rectangle

    - -
    - - - - - - -
    - - +

    height

    + Number + + + + + +
    +

    + Defined in + src/shapes/Rectangle.js:24 +

    + + +
    + +
    +

    Total height of the rectangle

    + +
    + + + +
    -

    id

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:27 - -

    - - - - -
    - -
    -

    Shape object identifier.

    - -
    - - - - - - -
    - - +

    id

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:27 +

    + + +
    + +
    +

    Shape object identifier.

    + +
    + + + +
    -

    material

    - Material - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:82 - -

    - - - - -
    - -
    -

    Material to use in collisions for this Shape. If this is set to null, the world will use default material properties instead.

    - -
    - - - - - - -
    - - +

    material

    + Material + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:88 +

    + + +
    + +
    +

    Material to use in collisions for this Shape. If this is set to null, the world will use default material properties instead.

    + +
    + + + +
    -

    sensor

    - Boolean - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:96 - -

    - - - - -
    - -
    -

    Set to true if you want this shape to be a sensor. A sensor does not generate contacts, but it still reports contact events. This is good if you want to know if a shape is overlapping another shape, without them generating contacts.

    - -
    - - - - - - -
    - - +

    sensor

    + Boolean + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:102 +

    + + +
    + +
    +

    Set to true if you want this shape to be a sensor. A sensor does not generate contacts, but it still reports contact events. This is good if you want to know if a shape is overlapping another shape, without them generating contacts.

    + +
    + + + +
    -

    triangles

    - Array - - - - - - - - - -
    - - -

    Inherited from - Convex: - - - - src/shapes/Convex.js:71 - -

    - - - - -
    - -
    -

    Triangulated version of this convex. The structure is Array of 3-Arrays, and each subarray contains 3 integers, referencing the vertices.

    - -
    - - - - - - -
    - - +

    triangles

    + Array + + + + + +
    +

    Inherited from + Convex: + src/shapes/Convex.js:76 +

    + + +
    + +
    +

    Triangulated version of this convex. The structure is Array of 3-Arrays, and each subarray contains 3 integers, referencing the vertices.

    + +
    + + + +
    -

    type

    - Number - - - - - - - - - -
    - - -

    Inherited from - Shape: - - - - src/shapes/Shape.js:11 - -

    - - - - -
    - - - - - - - - -
    - - +

    type

    + Number + + + + + +
    +

    Inherited from + Shape: + src/shapes/Shape.js:11 +

    + + +
    + + + + + +
    -

    vertices

    - Array - - - - - - - - - -
    - - -

    Inherited from - Convex: - - - - src/shapes/Convex.js:18 - -

    - - - - -
    - -
    -

    Vertices defined in the local frame.

    - -
    - - - - - - -
    - - +

    vertices

    + Array + + + + + +
    +

    Inherited from + Convex: + src/shapes/Convex.js:23 +

    + + +
    + +
    +

    Vertices defined in the local frame.

    + +
    + + + +
    -

    width

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/shapes/Rectangle.js:17 - -

    - - - - -
    - -
    -

    Total width of the rectangle

    - -
    - - - - - - -
    - - +

    width

    + Number + + + + + +
    +

    + Defined in + src/shapes/Rectangle.js:17 +

    + + +
    + +
    +

    Total width of the rectangle

    + +
    + + + + - - - - diff --git a/docs/classes/RevoluteConstraint.html b/docs/classes/RevoluteConstraint.html index d88dd2d5..db019432 100644 --- a/docs/classes/RevoluteConstraint.html +++ b/docs/classes/RevoluteConstraint.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,632 +25,412 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    RevoluteConstraint Class

    +

    RevoluteConstraint Class

    - -
    Extends Constraint
    - - - - -
    -

    Connects two bodies at given offset points, letting them rotate relative to each other around this point.

    -

    Constructor

    -

    RevoluteConstraint

    - - -
    - (
      - -
    • - - bodyA - -
    • - -
    • - - bodyB - -
    • - -
    • - - [options] - -
    • - -
    ) -
    - - - - - - - - - - - - - - - - -
    +

    RevoluteConstraint

    + +
    + (
      +
    • + bodyA +
    • +
    • + bodyB +
    • +
    • + [options] +
    • +
    ) +
    - - -

    - - Defined in + + + + + + + +

    +

    + Defined in + src/constraints/RevoluteConstraint.js:15 +

    + + + +
    + +
    - +
    +
    +

    Parameters:

    - src/constraints/RevoluteConstraint.js:15 +
      +
    • + bodyA + Body -

      - - - +
      + +
      -
    - -
    + +
  • + bodyB + Body -
  • - - -
    -

    Parameters:

    - -
      - -
    • - - bodyA - Body - - - - -
      - -
      - - -
    • - -
    • - - bodyB - Body - - - - -
      - -
      - - -
    • - -
    • - - [options] - Object - optional - - - - -
      - + +
      + +
      + +
    • +
    • + [options] + Object + optional + + +
      + +
      + +
        +
      • + [worldPivot] + Array + optional + +
        +

        A pivot point given in world coordinates. If specified, localPivotA and localPivotB are automatically computed from this value.

        + +
        + +
      • +
      • + [localPivotA] + Array + optional + +
        +

        The point relative to the center of mass of bodyA which bodyA is constrained to.

        + +
        + +
      • +
      • + [localPivotB] + Array + optional + +
        +

        See localPivotA.

        + +
        + +
      • +
      • + [maxForce] + Number + optional + +
        +

        The maximum force that should be applied to constrain the bodies.

        + +
        + +
      • +
      +
    • +
    +
    + + + +
    +

    Example:

    + +
    +
    // This will create a revolute constraint between two bodies with pivot point in between them.
    +        var bodyA = new Body({ mass: 1, position: [-1, 0] });
    +        var bodyB = new Body({ mass: 1, position: [1, 0] });
    +        var constraint = new RevoluteConstraint(bodyA, bodyB, {
    +            worldPivot: [0, 0]
    +        });
    +        world.addConstraint(constraint);
    +        
    +        // Using body-local pivot points, the constraint could have been constructed like this:
    +        var constraint = new RevoluteConstraint(bodyA, bodyB, {
    +            localPivotA: [1, 0],
    +            localPivotB: [-1, 0]
    +        });
    +        
    - - -
      - -
    • - - [worldPivot] - Array - optional - - -
      -

      A pivot point given in world coordinates. If specified, localPivotA and localPivotB are automatically computed from this value.

      - -
      - - -
    • - -
    • - - [localPivotA] - Array - optional - - -
      -

      The point relative to the center of mass of bodyA which bodyA is constrained to.

      - -
      - - -
    • - -
    • - - [localPivotB] - Array - optional - - -
      -

      See localPivotA.

      - -
      - - -
    • - -
    • - - [maxForce] - Number - optional - - -
      -

      The maximum force that should be applied to constrain the bodies.

      - -
      - - -
    • - -
    - - - - -
    - - - - - -
    -

    Example:

    - -
    -
    // This will create a revolute constraint between two bodies with pivot point in between them.
    -var bodyA = new Body({ mass: 1, position: [-1, 0] });
    -var bodyB = new Body({ mass: 1, position: [1, 0] });
    -var constraint = new RevoluteConstraint(bodyA, bodyB, {
    -    worldPivot: [0, 0]
    -});
    -world.addConstraint(constraint);
    -
    -// Using body-local pivot points, the constraint could have been constructed like this:
    -var constraint = new RevoluteConstraint(bodyA, bodyB, {
    -    localPivotA: [1, 0],
    -    localPivotB: [-1, 0]
    -});
    - -
    +
    - -
    -
    -

    Item Index

    -

    Methods

    - -

    Properties

    - - -
    -

    Methods

    - -
    +

    disableMotor

    - () - - - - - - - -
    @@ -660,54 +438,30 @@

    disableMotor

    - - - -
    - -
    +
    +

    enableMotor

    - () - - - - - - - -
    @@ -715,58 +469,33 @@

    enableMotor

    - - - -
    - -
    +
    +

    getMotorSpeed

    - () - - Number - - - - - - -
    @@ -774,72 +503,44 @@

    getMotorSpeed

    - -

    Returns:

    - - Number: -

    The current speed, or false if the motor is not enabled.

    -
    - - -
    - -
    +
    +

    motorIsEnabled

    - () - - Boolean - - + deprecated - - - - -
    - - -

    - Defined in - - - - - src/constraints/RevoluteConstraint.js:291 - + src/constraints/RevoluteConstraint.js:292

    - +

    Deprecated: use property motorEnabled instead.

    -
    @@ -847,82 +548,46 @@

    motorIsEnabled

    - -

    Returns:

    - - Boolean: - -
    - - -
    - -
    +
    +

    setLimits

    -
    (
      -
    • - lower -
    • -
    • - upper -
    • -
    )
    - - - - - - - -
    @@ -930,104 +595,64 @@

    setLimits

    -

    Parameters:

      -
    • - lower Number - -

      Lower angle limit.

      -
    • -
    • - upper Number - -

      Upper angle limit.

      -
    • -
    - - - -
    - -
    +
    +

    setMotorSpeed

    -
    (
      -
    • - speed -
    • -
    )
    - - - - - - - -
    @@ -1035,84 +660,52 @@

    setMotorSpeed

    -

    Parameters:

      -
    • - speed Number - -
      -
    • -
    - - - -
    - -
    +
    +

    setRelaxation

    -
    (
      -
    • - relaxation -
    • -
    )
    - - - - - - - -
    @@ -1120,84 +713,52 @@

    setRelaxation

    -

    Parameters:

      -
    • - relaxation Number - -
      -
    • -
    - - - -
    - -
    +
    +

    setStiffness

    -
    (
      -
    • - stiffness -
    • -
    )
    - - - - - - - -
    @@ -1205,74 +766,46 @@

    setStiffness

    -

    Parameters:

      -
    • - stiffness Number - -
      -
    • -
    - - - -
    - -
    +
    +

    update

    - () - - - - - - - -
    @@ -1280,559 +813,344 @@

    update

    - - - -
    - +
    - -

    Properties

    -
    -

    angle

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/constraints/RevoluteConstraint.js:113 - -

    - - - - -
    - -
    -

    The constraint position.

    - -
    - - - - - - -
    - - +

    angle

    + Number + + + + + + + +
    +

    The constraint position.

    + +
    + + + +
    -

    bodyA

    - Body - - - - - - - - - -
    - - -

    Inherited from - Constraint: - - - - src/constraints/Constraint.js:33 - -

    - - - - -
    - -
    -

    First body participating in the constraint.

    - -
    - - - - - - -
    - - +

    bodyA

    + Body + + + + + +
    +

    Inherited from + Constraint: + src/constraints/Constraint.js:38 +

    + + +
    + +
    +

    First body participating in the constraint.

    + +
    + + + +
    -

    bodyB

    - Body - - - - - - - - - -
    - - -

    Inherited from - Constraint: - - - - src/constraints/Constraint.js:40 - -

    - - - - -
    - -
    -

    Second body participating in the constraint.

    - -
    - - - - - - -
    - - +

    bodyB

    + Body + + + + + +
    +

    Inherited from + Constraint: + src/constraints/Constraint.js:45 +

    + + +
    + +
    +

    Second body participating in the constraint.

    + +
    + + + +
    -

    collideConnected

    - Boolean - - - - - - - - - -
    - - -

    Inherited from - Constraint: - - - - src/constraints/Constraint.js:47 - -

    - - - - -
    - -
    -

    Set to true if you want the connected bodies to collide.

    - -
    - - -

    Default: true

    - - - - - -
    - - +

    collideConnected

    + Boolean + + + + + +
    +

    Inherited from + Constraint: + src/constraints/Constraint.js:52 +

    + + +
    + +
    +

    Set to true if you want the connected bodies to collide.

    + +
    + +

    Default: true

    + + +
    -

    equations

    - Array - - - - - - - - - -
    - - -

    Inherited from - Constraint: - - - - src/constraints/Constraint.js:25 - -

    - - - - -
    - -
    -

    Equations to be solved in this constraint

    - -
    - - - - - - -
    - - +

    equations

    + Array + + + + + +
    +

    Inherited from + Constraint: + src/constraints/Constraint.js:30 +

    + + +
    + +
    +

    Equations to be solved in this constraint

    + +
    + + + +
    -

    lowerLimit

    - Boolean - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/constraints/RevoluteConstraint.js:135 - -

    - - - - -
    - -
    -

    The lower limit on the constraint angle.

    - -
    - - - - - - -
    - - +

    lowerLimit

    + Boolean + + + + + + + +
    +

    The lower limit on the constraint angle.

    + +
    + + + +
    -

    lowerLimitEnabled

    - Boolean - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/constraints/RevoluteConstraint.js:121 - -

    - - - - -
    - -
    -

    Set to true to enable lower limit

    - -
    - - - - - - -
    - - +

    lowerLimitEnabled

    + Boolean + + + + + + + +
    +

    Set to true to enable lower limit

    + +
    + + + +
    -

    motorEnabled

    - Boolean - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/constraints/RevoluteConstraint.js:106 - -

    - - - - -
    - -
    -

    Indicates whether the motor is enabled. Use .enableMotor() to enable the constraint motor.

    - -
    - - - - - - -
    - - +

    motorEnabled

    + Boolean + + + + + + + +
    +

    Indicates whether the motor is enabled. Use .enableMotor() to enable the constraint motor.

    + +
    + + + +
    -

    pivotA

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/constraints/RevoluteConstraint.js:50 - -

    - - - - -
    - -
    - -
    - - - - - - -
    - - +

    pivotA

    + Array + + + + + +
    +

    + Defined in + src/constraints/RevoluteConstraint.js:50 +

    + + +
    + +
    + +
    + + + +
    -

    pivotB

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/constraints/RevoluteConstraint.js:55 - -

    - - - - -
    - -
    - -
    - - - - - - -
    - - +

    pivotB

    + Array + + + + + +
    +

    + Defined in + src/constraints/RevoluteConstraint.js:55 +

    + + +
    + +
    + +
    + + + + +
    +

    type

    + Number + + + + + +
    +

    Inherited from + Constraint: + src/constraints/Constraint.js:19 +

    + + +
    + +
    +

    The type of constraint. May be one of Constraint.DISTANCE, Constraint.GEAR, Constraint.LOCK, Constraint.PRISMATIC or Constraint.REVOLUTE.

    + +
    + + + +
    -

    upperLimit

    - Boolean - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/constraints/RevoluteConstraint.js:142 - -

    - - - - -
    - -
    -

    The upper limit on the constraint angle.

    - -
    - - - - - - -
    - - +

    upperLimit

    + Boolean + + + + + + + +
    +

    The upper limit on the constraint angle.

    + +
    + + + +
    -

    upperLimitEnabled

    - Boolean - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/constraints/RevoluteConstraint.js:128 - -

    - - - - -
    - -
    -

    Set to true to enable upper limit

    - -
    - - - - - - -
    - - +

    upperLimitEnabled

    + Boolean + + + + + + + +
    +

    Set to true to enable upper limit

    + +
    + + + + - - - - diff --git a/docs/classes/RotationalLockEquation.html b/docs/classes/RotationalLockEquation.html index 1ec2d9dd..f6c83d94 100644 --- a/docs/classes/RotationalLockEquation.html +++ b/docs/classes/RotationalLockEquation.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,580 +25,364 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    RotationalLockEquation Class

    +

    RotationalLockEquation Class

    - -
    Extends Equation
    - - - - -
    -

    Locks the relative angle between two bodies. The constraint tries to keep the dot product between two vectors, local in each body, to zero. The local angle in body i is a parameter.

    -

    Constructor

    -

    RotationalLockEquation

    - - -
    - (
      - -
    • - - bodyA - -
    • - -
    • - - bodyB - -
    • - -
    • - - [options] - -
    • - -
    ) -
    - - - - - - - - - - - - - - - - -
    +

    RotationalLockEquation

    + +
    + (
      +
    • + bodyA +
    • +
    • + bodyB +
    • +
    • + [options] +
    • +
    ) +
    - - -

    - - Defined in + + + + + + + +

    +

    + Defined in + src/equations/RotationalLockEquation.js:6 +

    + + + +
    + +
    - +
    +
    +

    Parameters:

    - src/equations/RotationalLockEquation.js:6 +
      +
    • + bodyA + Body -

      - - - +
      + +
      + +
    • +
    • + bodyB + Body + + +
      + +
      + +
    • +
    • + [options] + Object + optional + + +
      + +
      + +
        +
      • + [angle] + Number + optional + +
        +

        Angle to add to the local vector in bodyA.

        + +
        + +
      • +
      +
    • +
    +
    + -
    - -
    -
    - - -
    -

    Parameters:

    - -
      - -
    • - - bodyA - Body - - - - -
      - -
      - - -
    • - -
    • - - bodyB - Body - - - - -
      - -
      - - -
    • - -
    • - - [options] - Object - optional - - - - -
      - -
      - - -
        - -
      • - - [angle] - Number - optional - - -
        -

        Angle to add to the local vector in bodyA.

        - -
        - - -
      • - -
      - -
    • - -
    - - - - - -
    -
    -

    Item Index

    -

    Methods

    - -

    Properties

    - - -
    -

    Methods

    - -
    +

    addToWlambda

    -
    (
      -
    • - deltalambda -
    • -
    )
    - - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:268 -

    - -
    @@ -608,78 +390,49 @@

    addToWlambda

    -

    Parameters:

      -
    • - deltalambda Number - -
      -
    • -
    - - - -
    - -
    +
    +

    computeB

    - () - - Number - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:150 -

    - -
    @@ -687,67 +440,40 @@

    computeB

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    computeGiMf

    - () - - Number - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:213 -

    - -
    @@ -755,67 +481,40 @@

    computeGiMf

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    computeGiMGt

    - () - - Number - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:239 -

    - -
    @@ -823,67 +522,40 @@

    computeGiMGt

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    computeGq

    - () - - Number - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:162 -

    - -
    @@ -891,67 +563,40 @@

    computeGq

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    computeGW

    - () - - Number - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:181 -

    - -
    @@ -959,67 +604,40 @@

    computeGW

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    computeGWlambda

    - () - - Number - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:197 -

    - -
    @@ -1027,77 +645,46 @@

    computeGWlambda

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    computeInvC

    -
    (
      -
    • - eps -
    • -
    )
    - - Number - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:309 -

    - -
    @@ -1105,90 +692,56 @@

    computeInvC

    -

    Parameters:

      -
    • - eps Number - -
      -
    • -
    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    gmult

    - () - - Number - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:136 -

    - -
    @@ -1196,63 +749,37 @@

    gmult

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    update

    - () - - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:120 -

    - -
    @@ -1260,537 +787,319 @@

    update

    - - - -
    - +
    - -

    Properties

    -
    -

    angle

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/equations/RotationalLockEquation.js:21 - -

    - - - - -
    - -
    - -
    - - - - - - -
    - - +

    angle

    + Number + + + + + + + +
    + +
    + + + +
    -

    bodyA

    - Body - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:32 - -

    - - - - -
    - -
    -

    First body participating in the constraint

    - -
    - - - - - - -
    - - +

    bodyA

    + Body + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:32 +

    + + +
    + +
    +

    First body participating in the constraint

    + +
    + + + +
    -

    bodyB

    - Body - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:39 - -

    - - - - -
    - -
    -

    Second body participating in the constraint

    - -
    - - - - - - -
    - - -
    -

    enabled

    - Boolean - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:96 - -

    - - - - -
    - -
    -

    Whether this equation is enabled or not. If true, it will be added to the solver.

    - -
    - - - - - - -
    - - +

    bodyB

    + Body + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:39 +

    + + +
    + +
    +

    Second body participating in the constraint

    + +
    + + + +
    +
    +

    enabled

    + Boolean + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:96 +

    + + +
    + +
    +

    Whether this equation is enabled or not. If true, it will be added to the solver.

    + +
    + + + +
    -

    G

    - Array - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:60 - -

    - - - - -
    - -
    -

    The Jacobian entry of this equation. 6 numbers, 3 per body (x,y,angle).

    - -
    - - - - - - -
    - - +

    G

    + Array + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:60 +

    + + +
    + +
    +

    The Jacobian entry of this equation. 6 numbers, 3 per body (x,y,angle).

    + +
    + + + +
    -

    maxForce

    - Number - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:25 - -

    - - - - -
    - -
    -

    Max force to apply when solving.

    - -
    - - - - - - -
    - - +

    maxForce

    + Number + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:25 +

    + + +
    + +
    +

    Max force to apply when solving.

    + +
    + + + +
    -

    minForce

    - Number - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:18 - -

    - - - - -
    - -
    -

    Minimum force to apply when solving.

    - -
    - - - - - - -
    - - +

    minForce

    + Number + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:18 +

    + + +
    + +
    +

    Minimum force to apply when solving.

    + +
    + + + +
    -

    multiplier

    - Number - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:83 - -

    - - - - -
    - -
    -

    The resulting constraint multiplier from the last solve. This is mostly equivalent to the force produced by the constraint.

    - -
    - - - - - - -
    - - +

    multiplier

    + Number + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:83 +

    + + +
    + +
    +

    The resulting constraint multiplier from the last solve. This is mostly equivalent to the force produced by the constraint.

    + +
    + + + +
    -

    needsUpdate

    - Boolean - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:77 - -

    - - - - -
    - -
    -

    Indicates if stiffness or relaxation was changed.

    - -
    - - - - - - -
    - - +

    needsUpdate

    + Boolean + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:77 +

    + + +
    + +
    +

    Indicates if stiffness or relaxation was changed.

    + +
    + + + +
    -

    relativeVelocity

    - Number - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:90 - -

    - - - - -
    - -
    -

    Relative velocity.

    - -
    - - - - - - -
    - - +

    relativeVelocity

    + Number + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:90 +

    + + +
    + +
    +

    Relative velocity.

    + +
    + + + +
    -

    relaxation

    - Number - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:53 - -

    - - - - -
    - -
    -

    The number of time steps needed to stabilize the constraint equation. Typically between 3 and 5 time steps.

    - -
    - - - - - - -
    - - +

    relaxation

    + Number + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:53 +

    + + +
    + +
    +

    The number of time steps needed to stabilize the constraint equation. Typically between 3 and 5 time steps.

    + +
    + + + +
    -

    stiffness

    - Number - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:46 - -

    - - - - -
    - -
    -

    The stiffness of this equation. Typically chosen to a large number (~1e7), but can be chosen somewhat freely to get a stable simulation.

    - -
    - - - - - - -
    - - +

    stiffness

    + Number + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:46 +

    + + +
    + +
    +

    The stiffness of this equation. Typically chosen to a large number (~1e7), but can be chosen somewhat freely to get a stable simulation.

    + +
    + + + + - - - - diff --git a/docs/classes/RotationalSpring.html b/docs/classes/RotationalSpring.html index ca974906..990077a5 100644 --- a/docs/classes/RotationalSpring.html +++ b/docs/classes/RotationalSpring.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,492 +25,320 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    RotationalSpring Class

    +

    RotationalSpring Class

    - -
    Extends Spring
    - - - - -
    -

    A rotational spring, connecting two bodies rotation. This spring explicitly adds angularForce (torque) to the bodies.

    The spring can be combined with a RevoluteConstraint to make, for example, a mouse trap.

    -

    Constructor

    -

    RotationalSpring

    - - -
    - (
      - -
    • - - bodyA - -
    • - -
    • - - bodyB - -
    • - -
    • - - [options] - -
    • - -
    ) -
    - - - - - - - - - - - - - - - - -
    +

    RotationalSpring

    + +
    + (
      +
    • + bodyA +
    • +
    • + bodyB +
    • +
    • + [options] +
    • +
    ) +
    - - -

    - - Defined in + + + + + + + +

    +

    + Defined in + src/objects/RotationalSpring.js:6 +

    + + + +
    + +
    - +
    +
    +

    Parameters:

    - src/objects/RotationalSpring.js:6 +
      +
    • + bodyA + Body -

      - - - +
      + +
      + +
    • +
    • + bodyB + Body + + +
      + +
      + +
    • +
    • + [options] + Object + optional + + +
      + +
      + +
        +
      • + [restAngle] + Number + optional + +
        +

        The relative angle of bodies at which the spring is at rest. If not given, it's set to the current relative angle between the bodies.

        + +
        + +
      • +
      • + [stiffness=100] + Number + optional + +
        +

        Spring constant (see Hookes Law). A number >= 0.

        + +
        + +
      • +
      • + [damping=1] + Number + optional + +
        +

        A number >= 0.

        + +
        + +
      • +
      +
    • +
    +
    + -
    - -
    -
    - - -
    -

    Parameters:

    - -
      - -
    • - - bodyA - Body - - - - -
      - -
      - - -
    • - -
    • - - bodyB - Body - - - - -
      - -
      - - -
    • - -
    • - - [options] - Object - optional - - - - -
      - -
      - - -
        - -
      • - - [restAngle] - Number - optional - - -
        -

        The relative angle of bodies at which the spring is at rest. If not given, it's set to the current relative angle between the bodies.

        - -
        - - -
      • - -
      • - - [stiffness=100] - Number - optional - - -
        -

        Spring constant (see Hookes Law). A number >= 0.

        - -
        - - -
      • - -
      • - - [damping=1] - Number - optional - - -
        -

        A number >= 0.

        - -
        - - -
      • - -
      - -
    • - -
    - - - - - -
    -
    -

    Item Index

    -

    Methods

    - -

    Properties

    - - -
    -

    Methods

    - -
    +

    applyForce

    - () - - - - - - - -
    -

    Inherited from Spring - but overwritten in - - - - src/objects/RotationalSpring.js:35 - + src/objects/RotationalSpring.js:36

    - -
    @@ -520,244 +346,145 @@

    applyForce

    - - - -
    - +
    - -

    Properties

    -
    -

    bodyA

    - Body - - - - - - - - - -
    - - -

    Inherited from - Spring: - - - - src/objects/Spring.js:41 - -

    - - - - -
    - -
    -

    First connected body.

    - -
    - - - - - - -
    - - +

    bodyA

    + Body + + + + + +
    +

    Inherited from + Spring: + src/objects/Spring.js:41 +

    + + +
    + +
    +

    First connected body.

    + +
    + + + +
    -

    bodyB

    - Body - - - - - - - - - -
    - - -

    Inherited from - Spring: - - - - src/objects/Spring.js:48 - -

    - - - - -
    - -
    -

    Second connected body.

    - -
    - - - - - - -
    - - +

    bodyB

    + Body + + + + + +
    +

    Inherited from + Spring: + src/objects/Spring.js:48 +

    + + +
    + +
    +

    Second connected body.

    + +
    + + + +
    -

    damping

    - Number - - - - - - - - - -
    - - -

    Inherited from - Spring: - - - - src/objects/Spring.js:34 - -

    - - - - -
    - -
    -

    Damping of the spring.

    - -
    - - - - - - -
    - - +

    damping

    + Number + + + + + +
    +

    Inherited from + Spring: + src/objects/Spring.js:34 +

    + + +
    + +
    +

    Damping of the spring.

    + +
    + + + +
    -

    restAngle

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/RotationalSpring.js:26 - -

    - - - - -
    - -
    -

    Rest angle of the spring.

    - -
    - - - - - - -
    - - +

    restAngle

    + Number + + + + + +
    +

    + Defined in + src/objects/RotationalSpring.js:26 +

    + + +
    + +
    +

    Rest angle of the spring.

    + +
    + + + +
    -

    stiffness

    - Number - - - - - - - - - -
    - - -

    Inherited from - Spring: - - - - src/objects/Spring.js:27 - -

    - - - - -
    - -
    -

    Stiffness of the spring.

    - -
    - - - - - - -
    - - +

    stiffness

    + Number + + + + + +
    +

    Inherited from + Spring: + src/objects/Spring.js:27 +

    + + +
    + +
    +

    Stiffness of the spring.

    + +
    + + + +
    - - -
    - diff --git a/docs/classes/RotationalVelocityEquation.html b/docs/classes/RotationalVelocityEquation.html index 6dcb1652..268f5658 100644 --- a/docs/classes/RotationalVelocityEquation.html +++ b/docs/classes/RotationalVelocityEquation.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,532 +25,333 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    RotationalVelocityEquation Class

    +

    RotationalVelocityEquation Class

    - -
    Extends Equation
    - - - - -
    -

    Syncs rotational velocity of two bodies, or sets a relative velocity (motor).

    -

    Constructor

    -

    RotationalVelocityEquation

    - - -
    - (
      - -
    • - - bodyA - -
    • - -
    • - - bodyB - -
    • - -
    ) -
    - - - - - - - - - - - - - - - - -
    +

    RotationalVelocityEquation

    + +
    + (
      +
    • + bodyA +
    • +
    • + bodyB +
    • +
    ) +
    - - -

    - - Defined in + + + + + + + +

    + +
    - +
    +
    +

    Parameters:

    - src/equations/RotationalVelocityEquation.js:6 +
      +
    • + bodyA + Body -

      - - - +
      + +
      + +
    • +
    • + bodyB + Body + + +
      + +
      + +
    • +
    +
    + -
    - -
    -
    - - -
    -

    Parameters:

    - -
      - -
    • - - bodyA - Body - - - - -
      - -
      - - -
    • - -
    • - - bodyB - Body - - - - -
      - -
      - - -
    • - -
    - - - - - -
    -
    -

    Item Index

    -

    Methods

    - -

    Properties

    - - -
    -

    Methods

    - -
    +

    addToWlambda

    -
    (
      -
    • - deltalambda -
    • -
    )
    - - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:268 -

    - -
    @@ -560,78 +359,49 @@

    addToWlambda

    -

    Parameters:

      -
    • - deltalambda Number - -
      -
    • -
    - - - -
    - -
    +
    +

    computeB

    - () - - Number - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:150 -

    - -
    @@ -639,67 +409,40 @@

    computeB

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    computeGiMf

    - () - - Number - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:213 -

    - -
    @@ -707,67 +450,40 @@

    computeGiMf

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    computeGiMGt

    - () - - Number - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:239 -

    - -
    @@ -775,67 +491,40 @@

    computeGiMGt

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    computeGq

    - () - - Number - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:162 -

    - -
    @@ -843,67 +532,40 @@

    computeGq

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    computeGW

    - () - - Number - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:181 -

    - -
    @@ -911,67 +573,40 @@

    computeGW

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    computeGWlambda

    - () - - Number - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:197 -

    - -
    @@ -979,77 +614,46 @@

    computeGWlambda

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    computeInvC

    -
    (
      -
    • - eps -
    • -
    )
    - - Number - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:309 -

    - -
    @@ -1057,90 +661,56 @@

    computeInvC

    -

    Parameters:

      -
    • - eps Number - -
      -
    • -
    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    gmult

    - () - - Number - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:136 -

    - -
    @@ -1148,63 +718,37 @@

    gmult

    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    update

    - () - - - - - - - -
    - -

    Inherited from Equation: - - - src/equations/Equation.js:120 -

    - -
    @@ -1212,493 +756,295 @@

    update

    - - - -
    - +
    - -

    Properties

    -
    -

    bodyA

    - Body - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:32 - -

    - - - - -
    - -
    -

    First body participating in the constraint

    - -
    - - - - - - -
    - - +

    bodyA

    + Body + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:32 +

    + + +
    + +
    +

    First body participating in the constraint

    + +
    + + + +
    -

    bodyB

    - Body - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:39 - -

    - - - - -
    - -
    -

    Second body participating in the constraint

    - -
    - - - - - - -
    - - +

    bodyB

    + Body + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:39 +

    + + +
    + +
    +

    Second body participating in the constraint

    + +
    + + + +
    -

    enabled

    - Boolean - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:96 - -

    - - - - -
    - -
    -

    Whether this equation is enabled or not. If true, it will be added to the solver.

    - -
    - - - - - - -
    - - +

    enabled

    + Boolean + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:96 +

    + + +
    + +
    +

    Whether this equation is enabled or not. If true, it will be added to the solver.

    + +
    + + + +
    -

    G

    - Array - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:60 - -

    - - - - -
    - -
    -

    The Jacobian entry of this equation. 6 numbers, 3 per body (x,y,angle).

    - -
    - - - - - - -
    - - +

    G

    + Array + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:60 +

    + + +
    + +
    +

    The Jacobian entry of this equation. 6 numbers, 3 per body (x,y,angle).

    + +
    + + + +
    -

    maxForce

    - Number - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:25 - -

    - - - - -
    - -
    -

    Max force to apply when solving.

    - -
    - - - - - - -
    - - +

    maxForce

    + Number + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:25 +

    + + +
    + +
    +

    Max force to apply when solving.

    + +
    + + + +
    -

    minForce

    - Number - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:18 - -

    - - - - -
    - -
    -

    Minimum force to apply when solving.

    - -
    - - - - - - -
    - - +

    minForce

    + Number + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:18 +

    + + +
    + +
    +

    Minimum force to apply when solving.

    + +
    + + + +
    -

    multiplier

    - Number - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:83 - -

    - - - - -
    - -
    -

    The resulting constraint multiplier from the last solve. This is mostly equivalent to the force produced by the constraint.

    - -
    - - - - - - -
    - - +

    multiplier

    + Number + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:83 +

    + + +
    + +
    +

    The resulting constraint multiplier from the last solve. This is mostly equivalent to the force produced by the constraint.

    + +
    + + + +
    -

    needsUpdate

    - Boolean - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:77 - -

    - - - - -
    - -
    -

    Indicates if stiffness or relaxation was changed.

    - -
    - - - - - - -
    - - +

    needsUpdate

    + Boolean + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:77 +

    + + +
    + +
    +

    Indicates if stiffness or relaxation was changed.

    + +
    + + + +
    -

    relativeVelocity

    - Number - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:90 - -

    - - - - -
    - -
    -

    Relative velocity.

    - -
    - - - - - - -
    - - +

    relativeVelocity

    + Number + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:90 +

    + + +
    + +
    +

    Relative velocity.

    + +
    + + + +
    -

    relaxation

    - Number - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:53 - -

    - - - - -
    - -
    -

    The number of time steps needed to stabilize the constraint equation. Typically between 3 and 5 time steps.

    - -
    - - - - - - -
    - - +

    relaxation

    + Number + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:53 +

    + + +
    + +
    +

    The number of time steps needed to stabilize the constraint equation. Typically between 3 and 5 time steps.

    + +
    + + + +
    -

    stiffness

    - Number - - - - - - - - - -
    - - -

    Inherited from - Equation: - - - - src/equations/Equation.js:46 - -

    - - - - -
    - -
    -

    The stiffness of this equation. Typically chosen to a large number (~1e7), but can be chosen somewhat freely to get a stable simulation.

    - -
    - - - - - - -
    - - +

    stiffness

    + Number + + + + + +
    +

    Inherited from + Equation: + src/equations/Equation.js:46 +

    + + +
    + +
    +

    The stiffness of this equation. Typically chosen to a large number (~1e7), but can be chosen somewhat freely to get a stable simulation.

    + +
    + + + + - - - - diff --git a/docs/classes/SAPBroadphase.html b/docs/classes/SAPBroadphase.html index 60f4f65e..ef7537cc 100644 --- a/docs/classes/SAPBroadphase.html +++ b/docs/classes/SAPBroadphase.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,655 +25,509 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    SAPBroadphase Class

    +

    SAPBroadphase Class

    - -
    Extends Broadphase
    - - - - -
    -

    Sweep and prune broadphase along one axis.

    -

    Constructor

    -

    SAPBroadphase

    - - - () - - - - - - - - - - - - - - - - -
    +

    SAPBroadphase

    - - -

    - - Defined in - - + () - src/collision/SAPBroadphase.js:6 -

    - - - -
    - -
    + + +
    +

    + Defined in + src/collision/SAPBroadphase.js:6 +

    + + + +
    + +
    + +
    + + + + +
    - - - - - -
    - -
    - -

    Item Index

    -

    Methods

    - -

    Properties

    - - -
    -

    Methods

    - -
    -

    boundingRadiusCheck

    +
    +

    aabbQuery

    -
    (
      -
    • - - bodyA - + world
    • -
    • - - bodyB - + aabb +
    • +
    • + result
    • -
    )
    - - - Boolean + Array - - - - - - -
    - -

    Inherited from - - Broadphase - - - but overwritten in - - - - src/collision/Broadphase.js:72 - +

    + Defined in + src/collision/SAPBroadphase.js:146

    - -
    -

    Check whether the bounding radius of two bodies overlap.

    +

    Returns all the bodies within an AABB.

    -

    Parameters:

      -
    • - - bodyA - Body - + world + World -
      - +
      -
    • -
    • - - bodyB - Body - + aabb + AABB -
      - + +
      + +
    • +
    • + result + Array + + +
      +

      An array to store resulting bodies in.

      +
      -
    • -
    - -

    Returns:

    - - - Boolean: - - + Array:
    - - -
    - -
    -

    canCollide

    +
    +
    +

    boundingRadiusCheck

    -
    (
      -
    • - bodyA -
    • -
    • - bodyB -
    • -
    )
    - - Boolean - - - - - - -
    - - -

    Inherited from - Broadphase: - - - - src/collision/Broadphase.js:126 - +

    Inherited from + + Broadphase + + but overwritten in + src/collision/Broadphase.js:72

    - -
    -

    Check whether two bodies are allowed to collide at all.

    +

    Check whether the bounding radius of two bodies overlap.

    -

    Parameters:

      -
    • - bodyA Body - -
      -
    • -
    • - bodyB Body - -
      -
    • -
    - -

    Returns:

    - - Boolean: - -
    - - +
    +
    +

    canCollide

    - -
    +
    + (
      +
    • + bodyA +
    • +
    • + bodyB +
    • +
    ) +
    + + + Boolean + + + + + + + + +
    +

    Inherited from + Broadphase: + src/collision/Broadphase.js:120 +

    + + + +
    + +
    +

    Check whether two bodies are allowed to collide at all.

    + +
    + +
    +

    Parameters:

    + +
      +
    • + bodyA + Body + + +
      + +
      + +
    • +
    • + bodyB + Body + + +
      + +
      + +
    • +
    +
    + +
    +

    Returns:

    + +
    + Boolean: +
    +
    + + +
    +

    getCollisionPairs

    -
    (
      -
    • - world -
    • -
    )
    - - Array - - - - - - -
    -

    Inherited from Broadphase - but overwritten in - - - - src/collision/SAPBroadphase.js:98 - + src/collision/SAPBroadphase.js:99

    - -
    @@ -683,99 +535,62 @@

    getCollisionPairs

    -

    Parameters:

      -
    • - world World - -
      -
    • -
    - -

    Returns:

    - - Array: - -
    - - -
    - -
    +
    +

    setWorld

    -
    (
      -
    • - world -
    • -
    )
    - - - - - - - -
    -

    Inherited from Broadphase - but overwritten in - - - - src/collision/SAPBroadphase.js:53 - + src/collision/SAPBroadphase.js:46

    - -
    @@ -783,97 +598,58 @@

    setWorld

    -

    Parameters:

      -
    • - world World - -
      -
    • -
    - - - -
    - -
    +
    +

    sortAxisList

    -
    (
      -
    • - a -
    • -
    • - axisIndex -
    • -
    )
    - - Array - - - - - - -
    @@ -881,300 +657,178 @@

    sortAxisList

    -

    Parameters:

      -
    • - a Array - -
      -
    • -
    • - axisIndex Number - -
      -
    • -
    - -

    Returns:

    - - Array: - -
    - - -
    - +
    - -

    Properties

    -
    -

    axisIndex

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/collision/SAPBroadphase.js:30 - -

    - - - - -
    - -
    -

    The axis to sort along.

    - -
    - - - - - - -
    - - +

    axisIndex

    + Number + + + + + +
    +

    + Defined in + src/collision/SAPBroadphase.js:23 +

    + + +
    + +
    +

    The axis to sort along. 0 means x-axis and 1 y-axis. If your bodies are more spread out over the X axis, set axisIndex to 0, and you will gain some performance.

    + +
    + + + +
    -

    axisList

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/collision/SAPBroadphase.js:16 - -

    - - - - -
    - -
    -

    List of bodies currently in the broadphase.

    - -
    - - - - - - -
    - - +

    axisList

    + Array + + + + + +
    +

    + Defined in + src/collision/SAPBroadphase.js:16 +

    + + +
    + +
    +

    List of bodies currently in the broadphase.

    + +
    + + + +
    -

    boundingVolumeType

    - Number - - - - - - - - - -
    - - -

    Inherited from - Broadphase: - - - - src/collision/Broadphase.js:30 - -

    - - - - -
    - -
    -

    The bounding volume type to use in the broadphase algorithms.

    - -
    - - - - - - -
    - - +

    boundingVolumeType

    + Number + + + + + +
    +

    Inherited from + Broadphase: + src/collision/Broadphase.js:30 +

    + + +
    + +
    +

    The bounding volume type to use in the broadphase algorithms.

    + +
    + + + +
    -

    result

    - Array - - - - - - - - - -
    - - -

    Inherited from - Broadphase: - - - - src/collision/Broadphase.js:15 - -

    - - - - -
    - -
    -

    The resulting overlapping pairs. Will be filled with results during .getCollisionPairs().

    - -
    - - - - - - -
    - - -
    -

    world

    - World - - - - - - - - - -
    - -

    Inherited from - - Broadphase - - - but overwritten in - - - - src/collision/SAPBroadphase.js:23 - -

    - - - - -
    - -
    -

    The world to search in.

    - -
    - - - - - - -
    - - +

    result

    + Array + + + + + +
    +

    Inherited from + Broadphase: + src/collision/Broadphase.js:15 +

    + + +
    + +
    +

    The resulting overlapping pairs. Will be filled with results during .getCollisionPairs().

    + +
    + + + +
    +
    +

    world

    + World + + + + + +
    +

    Inherited from + Broadphase: + src/collision/Broadphase.js:22 +

    + + +
    + +
    +

    The world to search for collision pairs in. To change it, use .setWorld()

    + +
    + + + +
    - - -
    - diff --git a/docs/classes/Shape.html b/docs/classes/Shape.html index 8844e1f6..a5166eb6 100644 --- a/docs/classes/Shape.html +++ b/docs/classes/Shape.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,531 +25,331 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    Shape Class

    +

    Shape Class

    - - -
    Defined in: src/shapes/Shape.js:3
    - - -
    -

    Base class for shapes.

    -

    Constructor

    -

    Shape

    - - -
    - (
      - -
    • - - type - -
    • - -
    ) -
    - - - - - - - - - - - - - - - - -
    +

    Shape

    + +
    + (
      +
    • + type +
    • +
    ) +
    - - -

    - - Defined in + + + + + + + +

    +

    + Defined in + src/shapes/Shape.js:3 +

    + + + +
    + +
    - +
    +
    +

    Parameters:

    - src/shapes/Shape.js:3 +
      +
    • + type + Number -

      - - - +
      + +
      + +
    • +
    +
    + -
    - -
    -
    - - -
    -

    Parameters:

    - -
      - -
    • - - type - Number - - - - -
      - -
      - - -
    • - -
    - - - - - -
    -
    -

    Item Index

    - - -

    Properties

    - - -
    -

    Methods

    - -
    +

    computeAABB

    -
    (
      -
    • - out -
    • -
    • - position -
    • -
    • - angle -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - - src/shapes/Shape.js:182 - + src/shapes/Shape.js:188

    - -
    @@ -559,122 +357,76 @@

    computeAABB

    -

    Parameters:

      -
    • - out AABB - -

      The resulting AABB.

      -
    • -
    • - position Array - -
      -
    • -
    • - angle Number - -
      -
    • -
    - - - -
    - -
    +
    +

    computeMomentOfInertia

    -
    (
      -
    • - mass -
    • -
    )
    - - Number - - - - - - -
    - - -

    - Defined in - - - - - src/shapes/Shape.js:155 - + src/shapes/Shape.js:161

    - -
    @@ -682,91 +434,55 @@

    computeMomentOfInertia

    -

    Parameters:

      -
    • - mass Number - -
      -
    • -
    - -

    Returns:

    - - Number: -

    If the inertia is infinity or if the object simply isn't possible to rotate, return 0.

    -
    - - -
    - -
    +
    +

    updateArea

    - () - - - - - - - -
    - - -

    - Defined in - - - - - src/shapes/Shape.js:174 - + src/shapes/Shape.js:180

    - -
    @@ -774,58 +490,33 @@

    updateArea

    - - - -
    - -
    +
    +

    updateBoundingRadius

    - () - - Number - - - - - - -
    - - -

    - Defined in - - - - - src/shapes/Shape.js:165 - + src/shapes/Shape.js:171

    - -
    @@ -833,810 +524,490 @@

    updateBoundingRadius

    - -

    Returns:

    - - Number: - -
    - - -
    - +
    - -

    Properties

    -
    -

    area

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/shapes/Shape.js:89 - -

    - - - - -
    - -
    -

    Area of this shape.

    - -
    - - - - - - -
    - - +

    area

    + Number + + + + + +
    +

    + Defined in + src/shapes/Shape.js:95 +

    + + +
    + +
    +

    Area of this shape.

    + +
    + + + +
    -

    boundingRadius

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/shapes/Shape.js:34 - -

    - - - - -
    - -
    -

    Bounding circle radius of this shape

    - -
    - - - - - - -
    - - +

    boundingRadius

    + Number + + + + + +
    +

    + Defined in + src/shapes/Shape.js:34 +

    + + +
    + +
    +

    Bounding circle radius of this shape

    + +
    + + + +
    -

    CAPSULE

    - Number - - - - - - - - - static - - -
    - - - -

    - - Defined in - - - - - src/shapes/Shape.js:143 - -

    - - - - -
    - -
    - -
    - - - - - - -
    - - +

    CAPSULE

    + Number + + + + + static + +
    +

    + Defined in + src/shapes/Shape.js:149 +

    + + +
    + +
    + +
    + + + +
    -

    CIRCLE

    - Number - - - - - - - - - static - - -
    - - - -

    - - Defined in - - - - - src/shapes/Shape.js:107 - -

    - - - - -
    - -
    - -
    - - - - - - -
    - - +

    CIRCLE

    + Number + + + + + static + +
    +

    + Defined in + src/shapes/Shape.js:113 +

    + + +
    + +
    + +
    + + + +
    -

    collisionGroup

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/shapes/Shape.js:41 - -

    - - - - -
    - -
    -

    Collision group that this shape belongs to (bit mask). See this tutorial.

    - -
    - - - - -
    -

    Example:

    - -
    -
    // Setup bits for each available group
    -var PLAYER = Math.pow(2,0),
    -    ENEMY =  Math.pow(2,1),
    -    GROUND = Math.pow(2,2)
    -
    -// Put shapes into their groups
    -player1Shape.collisionGroup = PLAYER;
    -player2Shape.collisionGroup = PLAYER;
    -enemyShape  .collisionGroup = ENEMY;
    -groundShape .collisionGroup = GROUND;
    -
    -// Assign groups that each shape collide with.
    -// Note that the players can collide with ground and enemies, but not with other players.
    -player1Shape.collisionMask = ENEMY | GROUND;
    -player2Shape.collisionMask = ENEMY | GROUND;
    -enemyShape  .collisionMask = PLAYER | GROUND;
    -groundShape .collisionMask = PLAYER | ENEMY;
    -
    // How collision check is done
    -if(shapeA.collisionGroup & shapeB.collisionMask)!=0 && (shapeB.collisionGroup & shapeA.collisionMask)!=0){
    -    // The shapes will collide
    -}
    - -
    -
    - - - -
    - - +

    collisionGroup

    + Number + + + + + +
    +

    + Defined in + src/shapes/Shape.js:41 +

    + + +
    + +
    +

    Collision group that this shape belongs to (bit mask). See this tutorial.

    + +
    + + +
    +

    Example:

    + +
    +
    // Setup bits for each available group
    +                    var PLAYER = Math.pow(2,0),
    +                        ENEMY =  Math.pow(2,1),
    +                        GROUND = Math.pow(2,2)
    +                    
    +                    // Put shapes into their groups
    +                    player1Shape.collisionGroup = PLAYER;
    +                    player2Shape.collisionGroup = PLAYER;
    +                    enemyShape  .collisionGroup = ENEMY;
    +                    groundShape .collisionGroup = GROUND;
    +                    
    +                    // Assign groups that each shape collide with.
    +                    // Note that the players can collide with ground and enemies, but not with other players.
    +                    player1Shape.collisionMask = ENEMY | GROUND;
    +                    player2Shape.collisionMask = ENEMY | GROUND;
    +                    enemyShape  .collisionMask = PLAYER | GROUND;
    +                    groundShape .collisionMask = PLAYER | ENEMY;
    +                    
    // How collision check is done
    +                    if(shapeA.collisionGroup & shapeB.collisionMask)!=0 && (shapeB.collisionGroup & shapeA.collisionMask)!=0){
    +                        // The shapes will collide
    +                    }
    +                    
    +
    +
    + +
    -

    collisionMask

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/shapes/Shape.js:72 - -

    - - - - -
    - -
    -

    Collision mask of this shape. See .collisionGroup.

    - -
    - - - - - - -
    - - +

    collisionMask

    + Number + + + + + +
    +

    + Defined in + src/shapes/Shape.js:78 +

    + + +
    + +
    +

    Collision mask of this shape. See .collisionGroup.

    + +
    + + + +
    +
    +

    collisionResponse

    + Boolean + + + + + +
    +

    + Defined in + src/shapes/Shape.js:72 +

    + + +
    + +
    +

    Whether to produce contact forces when in contact with other bodies. Note that contacts will be generated, but they will be disabled. That means that this shape will move through other body shapes, but it will still trigger contact events, etc.

    + +
    + + + +
    -

    CONVEX

    - Number - - - - - - - - - static - - -
    - - - -

    - - Defined in - - - - - src/shapes/Shape.js:125 - -

    - - - - -
    - -
    - -
    - - - - - - -
    - - +

    CONVEX

    + Number + + + + + static + +
    +

    + Defined in + src/shapes/Shape.js:131 +

    + + +
    + +
    + +
    + + + +
    -

    HEIGHTFIELD

    - Number - - - - - - - - - static - - -
    - - - -

    - - Defined in - - - - - src/shapes/Shape.js:149 - -

    - - - - -
    - -
    - -
    - - - - - - -
    - - +

    HEIGHTFIELD

    + Number + + + + + static + +
    +

    + Defined in + src/shapes/Shape.js:155 +

    + + +
    + +
    + +
    + + + +
    -

    id

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/shapes/Shape.js:27 - -

    - - - - -
    - -
    -

    Shape object identifier.

    - -
    - - - - - - -
    - - +

    id

    + Number + + + + + +
    +

    + Defined in + src/shapes/Shape.js:27 +

    + + +
    + +
    +

    Shape object identifier.

    + +
    + + + +
    -

    LINE

    - Number - - - - - - - - - static - - -
    - - - -

    - - Defined in - - - - - src/shapes/Shape.js:131 - -

    - - - - -
    - -
    - -
    - - - - - - -
    - - -
    -

    material

    - Material - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/shapes/Shape.js:82 - -

    - - - - -
    - -
    -

    Material to use in collisions for this Shape. If this is set to null, the world will use default material properties instead.

    - -
    - - - - - - -
    - - +

    LINE

    + Number + + + + + static + +
    +

    + Defined in + src/shapes/Shape.js:137 +

    + + +
    + +
    + +
    + + + + +
    +

    material

    + Material + + + + + +
    +

    + Defined in + src/shapes/Shape.js:88 +

    + + +
    + +
    +

    Material to use in collisions for this Shape. If this is set to null, the world will use default material properties instead.

    + +
    + + + +
    -

    PARTICLE

    - Number - - - - - - - - - static - - -
    - - - -

    - - Defined in - - - - - src/shapes/Shape.js:113 - -

    - - - - -
    - -
    - -
    - - - - - - -
    - - +

    PARTICLE

    + Number + + + + + static + +
    +

    + Defined in + src/shapes/Shape.js:119 +

    + + +
    + +
    + +
    + + + +
    -

    PLANE

    - Number - - - - - - - - - static - - -
    - - - -

    - - Defined in - - - - - src/shapes/Shape.js:119 - -

    - - - - -
    - -
    - -
    - - - - - - -
    - - +

    PLANE

    + Number + + + + + static + +
    +

    + Defined in + src/shapes/Shape.js:125 +

    + + +
    + +
    + +
    + + + +
    -

    RECTANGLE

    - Number - - - - - - - - - static - - -
    - - - -

    - - Defined in - - - - - src/shapes/Shape.js:137 - -

    - - - - -
    - -
    - -
    - - - - - - -
    - - +

    RECTANGLE

    + Number + + + + + static + +
    +

    + Defined in + src/shapes/Shape.js:143 +

    + + +
    + +
    + +
    + + + +
    -

    sensor

    - Boolean - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/shapes/Shape.js:96 - -

    - - - - -
    - -
    -

    Set to true if you want this shape to be a sensor. A sensor does not generate contacts, but it still reports contact events. This is good if you want to know if a shape is overlapping another shape, without them generating contacts.

    - -
    - - - - - - -
    - - +

    sensor

    + Boolean + + + + + +
    +

    + Defined in + src/shapes/Shape.js:102 +

    + + +
    + +
    +

    Set to true if you want this shape to be a sensor. A sensor does not generate contacts, but it still reports contact events. This is good if you want to know if a shape is overlapping another shape, without them generating contacts.

    + +
    + + + +
    -

    type

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/shapes/Shape.js:11 - -

    - - - - -
    - - - - - - - - -
    - - +

    type

    + Number + + + + + +
    +

    + Defined in + src/shapes/Shape.js:11 +

    + + +
    + + + + + + - - - - diff --git a/docs/classes/Solver.html b/docs/classes/Solver.html index 8afd5cc3..adf9af8f 100644 --- a/docs/classes/Solver.html +++ b/docs/classes/Solver.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,425 +25,266 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    Solver Class

    +

    Solver Class

    - -
    Extends EventEmitter
    - - - - -
    -

    Base class for constraint solvers.

    -

    Constructor

    -

    Solver

    - - - () - - - - - - - - - - - - - - - - -
    +

    Solver

    - - -

    - - Defined in - - + () - src/solver/Solver.js:6 -

    - - - -
    - -
    + + +
    +

    + Defined in + src/solver/Solver.js:6 +

    + + + +
    + +
    + +
    + + + + +
    - - - - - -
    - -
    - -

    Item Index

    -

    Methods

    - -

    Properties

    - - -
    -

    Methods

    - -
    +

    addEquation

    -
    (
      -
    • - eq -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - - src/solver/Solver.js:81 - + src/solver/Solver.js:82

    - -
    @@ -453,87 +292,52 @@

    addEquation

    -

    Parameters:

    - - - -
    - -
    +
    +

    addEquations

    -
    (
      -
    • - eqs -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - - src/solver/Solver.js:93 - + src/solver/Solver.js:94

    - -
    @@ -541,88 +345,55 @@

    addEquations

    -

    Parameters:

      -
    • - eqs Array - -
      -
    • -
    - - - -
    - -
    +
    +

    emit

    -
    (
      -
    • - event -
    • -
    )
    - - EventEmitter - - - - - - -
    - -

    Inherited from EventEmitter: - - - src/events/EventEmitter.js:79 -

    - -
    @@ -630,125 +401,78 @@

    emit

    -

    Parameters:

      -
    • - event Object - -
      -
        -
      • - type String -
        -
      • -
      -
    • -
    - -

    Returns:

    - - EventEmitter: -

    The self object, for chainability.

    -
    - - -
    - -
    +
    +

    has

    -
    (
      -
    • - type -
    • -
    • - listener -
    • -
    )
    - - Boolean - - - - - - -
    - -

    Inherited from EventEmitter: - - - src/events/EventEmitter.js:35 -

    - -
    @@ -756,121 +480,75 @@

    has

    -

    Parameters:

      -
    • - type String - -
      -
    • -
    • - listener Function - -
      -
    • -
    - -

    Returns:

    - - Boolean: - -
    - - -
    - -
    +
    +

    off

    -
    (
      -
    • - type -
    • -
    • - listener -
    • -
    )
    - - EventEmitter - - - - - - -
    - -

    Inherited from EventEmitter: - - - src/events/EventEmitter.js:60 -

    - -
    @@ -878,123 +556,77 @@

    off

    -

    Parameters:

      -
    • - type String - -
      -
    • -
    • - listener Function - -
      -
    • -
    - -

    Returns:

    - - EventEmitter: -

    The self object, for chainability.

    -
    - - -
    - -
    +
    +

    on

    -
    (
      -
    • - type -
    • -
    • - listener -
    • -
    )
    - - EventEmitter - - - - - - -
    - -

    Inherited from EventEmitter: - - - src/events/EventEmitter.js:13 -

    - -
    @@ -1002,106 +634,65 @@

    on

    -

    Parameters:

      -
    • - type String - -
      -
    • -
    • - listener Function - -
      -
    • -
    - -

    Returns:

    - - EventEmitter: -

    The self object, for chainability.

    -
    - - -
    - -
    +
    +

    removeAllEquations

    - () - - - - - - - -
    - - -

    - Defined in - - - - - src/solver/Solver.js:122 - + src/solver/Solver.js:123

    - -
    @@ -1109,64 +700,36 @@

    removeAllEquations

    - - - -
    - -
    +
    +

    removeEquation

    -
    (
      -
    • - eq -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - - src/solver/Solver.js:109 - + src/solver/Solver.js:110

    - -
    @@ -1174,93 +737,55 @@

    removeEquation

    -

    Parameters:

    - - - -
    - -
    +
    +

    solve

    -
    (
      -
    • - dt -
    • -
    • - world -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - - src/solver/Solver.js:36 - + src/solver/Solver.js:37

    - -
    @@ -1268,108 +793,65 @@

    solve

    -

    Parameters:

      -
    • - dt Number - -
      -
    • -
    • - world World - -
      -
    • -
    - - - -
    - -
    +
    +

    solveIsland

    -
    (
      -
    • - dt -
    • -
    • - island -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - - src/solver/Solver.js:48 - + src/solver/Solver.js:49

    - -
    @@ -1377,92 +859,56 @@

    solveIsland

    -

    Parameters:

      -
    • - dt Number - -
      -
    • -
    • - island Island - -
      -
    • -
    - - - -
    - -
    +
    +

    sortEquations

    - () - - - - - - - -
    - - -

    - Defined in - - - - - src/solver/Solver.js:71 - + src/solver/Solver.js:72

    - -
    @@ -1470,121 +916,70 @@

    sortEquations

    - - - -
    - +
    - -

    Properties

    -
    -

    equations

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/solver/Solver.js:19 - -

    - - - - -
    - -
    -

    Current equations in the solver.

    - -
    - - - - - - -
    - - +

    equations

    + Array + + + + + +
    +

    + Defined in + src/solver/Solver.js:19 +

    + + +
    + +
    +

    Current equations in the solver.

    + +
    + + + +
    -

    equationSortFunction

    - Function | Boolean - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/solver/Solver.js:27 - -

    - - - - -
    - -
    -

    Function that is used to sort all equations before each solve.

    - -
    - - - - - - -
    - - +

    equationSortFunction

    + Function | Boolean + + + + + +
    +

    + Defined in + src/solver/Solver.js:27 +

    + + +
    + +
    +

    Function that is used to sort all equations before each solve.

    + +
    + + + +
    - - -
    -
    diff --git a/docs/classes/Spring.html b/docs/classes/Spring.html index 7bacc62b..4e8b02f7 100644 --- a/docs/classes/Spring.html +++ b/docs/classes/Spring.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,523 +25,340 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    Spring Class

    +

    Spring Class

    - - - - - -
    -

    A spring, connecting two bodies. The Spring explicitly adds force and angularForce to the bodies and does therefore not put load on the constraint solver.

    -

    Constructor

    -

    Spring

    - - -
    - (
      - -
    • - - bodyA - -
    • - -
    • - - bodyB - -
    • - -
    • - - [options] - -
    • - -
    ) -
    - - - - - - - - - - - - - - - - -
    +

    Spring

    + +
    + (
      +
    • + bodyA +
    • +
    • + bodyB +
    • +
    • + [options] +
    • +
    ) +
    - - -

    - - Defined in + + + + + + + +

    +

    + Defined in + src/objects/Spring.js:6 +

    + + + +
    + +
    - +
    +
    +

    Parameters:

    - src/objects/Spring.js:6 +
      +
    • + bodyA + Body -

      - - - +
      + +
      + +
    • +
    • + bodyB + Body + + +
      + +
      + +
    • +
    • + [options] + Object + optional + + +
      + +
      + +
        +
      • + [stiffness=100] + Number + optional + +
        +

        Spring constant (see Hookes Law). A number >= 0.

        + +
        + +
      • +
      • + [damping=1] + Number + optional + +
        +

        A number >= 0. Default: 1

        + +
        + +
      • +
      • + [localAnchorA] + Array + optional + +
        +

        Where to hook the spring to body A, in local body coordinates. Defaults to the body center.

        + +
        + +
      • +
      • + [localAnchorB] + Array + optional + +
        + +
        + +
      • +
      • + [worldAnchorA] + Array + optional + +
        +

        Where to hook the spring to body A, in world coordinates. Overrides the option "localAnchorA" if given.

        + +
        + +
      • +
      • + [worldAnchorB] + Array + optional + +
        + +
        + +
      • +
      +
    • +
    +
    + -
    - -
    -
    - - -
    -

    Parameters:

    - -
      - -
    • - - bodyA - Body - - - - -
      - -
      - - -
    • - -
    • - - bodyB - Body - - - - -
      - -
      - - -
    • - -
    • - - [options] - Object - optional - - - - -
      - -
      - - -
        - -
      • - - [stiffness=100] - Number - optional - - -
        -

        Spring constant (see Hookes Law). A number >= 0.

        - -
        - - -
      • - -
      • - - [damping=1] - Number - optional - - -
        -

        A number >= 0. Default: 1

        - -
        - - -
      • - -
      • - - [localAnchorA] - Array - optional - - -
        -

        Where to hook the spring to body A, in local body coordinates. Defaults to the body center.

        - -
        - - -
      • - -
      • - - [localAnchorB] - Array - optional - - -
        - -
        - - -
      • - -
      • - - [worldAnchorA] - Array - optional - - -
        -

        Where to hook the spring to body A, in world coordinates. Overrides the option "localAnchorA" if given.

        - -
        - - -
      • - -
      • - - [worldAnchorB] - Array - optional - - -
        - -
        - - -
      • - -
      - -
    • - -
    - - - - - -
    -
    -

    Item Index

    -

    Methods

    - -

    Properties

    - - -
    -

    Methods

    - -
    +

    applyForce

    - () - - - - - - - -
    - - -

    - Defined in - - - - src/objects/Spring.js:56 -

    - -
    @@ -551,211 +366,120 @@

    applyForce

    - - - -
    - +
    - -

    Properties

    -
    -

    bodyA

    - Body - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/Spring.js:41 - -

    - - - - -
    - -
    -

    First connected body.

    - -
    - - - - - - -
    - - +

    bodyA

    + Body + + + + + +
    +

    + Defined in + src/objects/Spring.js:41 +

    + + +
    + +
    +

    First connected body.

    + +
    + + + +
    -

    bodyB

    - Body - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/Spring.js:48 - -

    - - - - -
    - -
    -

    Second connected body.

    - -
    - - - - - - -
    - - +

    bodyB

    + Body + + + + + +
    +

    + Defined in + src/objects/Spring.js:48 +

    + + +
    + +
    +

    Second connected body.

    + +
    + + + +
    -

    damping

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/Spring.js:34 - -

    - - - - -
    - -
    -

    Damping of the spring.

    - -
    - - - - - - -
    - - +

    damping

    + Number + + + + + +
    +

    + Defined in + src/objects/Spring.js:34 +

    + + +
    + +
    +

    Damping of the spring.

    + +
    + + + +
    -

    stiffness

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/objects/Spring.js:27 - -

    - - - - -
    - -
    -

    Stiffness of the spring.

    - -
    - - - - - - -
    - - +

    stiffness

    + Number + + + + + +
    +

    + Defined in + src/objects/Spring.js:27 +

    + + +
    + +
    +

    Stiffness of the spring.

    + +
    + + + +
    - - -
    - diff --git a/docs/classes/TupleDictionary.html b/docs/classes/TupleDictionary.html index be2ab73f..d979232c 100644 --- a/docs/classes/TupleDictionary.html +++ b/docs/classes/TupleDictionary.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,385 +25,242 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    TupleDictionary Class

    +

    TupleDictionary Class

    - - - - - -
    -
    -

    Constructor

    -

    TupleDictionary

    - - - () - - - - - - - - - - - - - - - - -
    +

    TupleDictionary

    - - -

    - - Defined in - - + () - src/utils/TupleDictionary.js:5 -

    - - - -
    - -
    + + +
    +

    + Defined in + src/utils/TupleDictionary.js:5 +

    + + + +
    + +
    + +
    + + + + +
    - - - - - -
    - -
    - -

    Item Index

    -

    Methods

    - -

    Properties

    - - -
    -

    Methods

    - -
    +

    copy

    -
    (
      -
    • - dict -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - src/utils/TupleDictionary.js:107 -

    - -
    @@ -413,325 +268,196 @@

    copy

    -

    Parameters:

      -
    • - dict TupleDictionary - -

      The TupleDictionary to copy into this one.

      -
    • -
    - - - -
    - -
    +
    +

    get

    -
    (
      -
    • - i -
    • -
    • - j -
    • -
    )
    - - Number - - - - - - -
    - - -

    - Defined in - - - - src/utils/TupleDictionary.js:57 -

    - -
    -

    Parameters:

      -
    • - i Number - -
      -
    • -
    • - j Number - -
      -
    • -
    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    getByKey

    -
    (
      -
    • - key -
    • -
    )
    - - Object - - - - - - -
    - - -

    - Defined in - - - - src/utils/TupleDictionary.js:47 -

    - -
    -

    Parameters:

      -
    • - key Number - -
      -
    • -
    - -

    Returns:

    - - Object: - -
    - - -
    - -
    +
    +

    getKey

    -
    (
      -
    • - i -
    • -
    • - j -
    • -
    )
    - - String - - - - - - -
    - - -

    - Defined in - - - - src/utils/TupleDictionary.js:25 -

    - -
    @@ -739,104 +465,63 @@

    getKey

    -

    Parameters:

      -
    • - i Number - -
      -
    • -
    • - j Number - -
      -
    • -
    - -

    Returns:

    - - String: - -
    - - -
    - -
    +
    +

    reset

    - () - - - - - - - -
    - - -

    - Defined in - - - - src/utils/TupleDictionary.js:91 -

    - -
    @@ -844,76 +529,42 @@

    reset

    - - - -
    - -
    +
    +

    set

    -
    (
      -
    • - i -
    • -
    • - j -
    • -
    • - value -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - src/utils/TupleDictionary.js:67 -

    - -
    @@ -921,174 +572,106 @@

    set

    -

    Parameters:

      -
    • - i Number - -
      -
    • -
    • - j Number - -
      -
    • -
    • - value Number - -
      -
    • -
    - - - -
    - +
    - -

    Properties

    -
    -

    data

    - Object - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/utils/TupleDictionary.js:11 - -

    - - - - -
    - -
    -

    The data storage

    - -
    - - - - - - -
    - - +

    data

    + Object + + + + + +
    +

    + Defined in + src/utils/TupleDictionary.js:11 +

    + + +
    + +
    +

    The data storage

    + +
    + + + +
    -

    keys

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/utils/TupleDictionary.js:18 - -

    - - - - -
    - -
    -

    Keys that are currently used.

    - -
    - - - - - - -
    - - +

    keys

    + Array + + + + + +
    +

    + Defined in + src/utils/TupleDictionary.js:18 +

    + + +
    + +
    +

    Keys that are currently used.

    + +
    + + + +
    - - -
    -
    diff --git a/docs/classes/Utils.html b/docs/classes/Utils.html index bb63dc2d..629bade1 100644 --- a/docs/classes/Utils.html +++ b/docs/classes/Utils.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,383 +25,240 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    Utils Class

    +

    Utils Class

    - - -
    Defined in: src/utils/Utils.js:5
    - - -
    -

    Misc utility functions

    -

    Constructor

    -

    Utils

    - - - () - - - - - - - - - - - - - - - - -
    +

    Utils

    - - -

    - - Defined in - - + () - src/utils/Utils.js:5 -

    - - - -
    - -
    + + +
    +

    + Defined in + src/utils/Utils.js:5 +

    + + + +
    + +
    + +
    + + + + +
    - - - - - -
    - -
    - -

    Item Index

    -

    Methods

    - -

    Properties

    - - -
    -

    Methods

    - -
    +

    appendArray

    -
    (
      -
    • - a -
    • -
    • - b -
    • -
    )
    - - - - - - static - - -
    - - -

    - Defined in - - - - src/utils/Utils.js:12 -

    - -
    @@ -411,114 +266,69 @@

    appendArray

    -

    Parameters:

      -
    • - a Array - -
      -
    • -
    • - b Array - -
      -
    • -
    - - - -
    - -
    +
    +

    defaults

    -
    (
      -
    • - options -
    • -
    • - defaults -
    • -
    )
    - - Object - - - - - static - - -
    - - -

    - Defined in - - - - src/utils/Utils.js:77 -

    - -
    @@ -526,126 +336,77 @@

    defaults

    -

    Parameters:

      -
    • - options Object - -

      The options object. May be falsy: in this case, a new object is created and returned.

      -
    • -
    • - defaults Object - -

      An object containing default values.

      -
    • -
    - -

    Returns:

    - - Object: -

    The modified options object.

    -
    - - -
    - -
    +
    +

    extend

    -
    (
      -
    • - a -
    • -
    • - b -
    • -
    )
    - - - - - - static - - -
    - - -

    - Defined in - - - - src/utils/Utils.js:64 -

    - -
    @@ -653,116 +414,69 @@

    extend

    -

    Parameters:

      -
    • - a Object - -
      -
    • -
    • - b Object - -
      -
    • -
    - - - -
    - -
    +
    +

    splice

    -
    (
      -
    • - array -
    • -
    • - index -
    • -
    • - howmany -
    • -
    )
    - - - - - - static - - -
    - - -

    - Defined in - - - - src/utils/Utils.js:29 -

    - -
    @@ -770,144 +484,94 @@

    splice

    -

    Parameters:

      -
    • - array Array - -
      -
    • -
    • - index Number - -
      -
    • -
    • - howmany Number - -
      -
    • -
    - - - -
    - +
    - -

    Properties

    -
    -

    ARRAY_TYPE

    - Function - - - - - - - - - static - - -
    - - - -

    - - Defined in - - - - - src/utils/Utils.js:45 - -

    - - - - -
    - -
    -

    The array type to use for internal numeric computations throughout the library. Float32Array is used if it is available, but falls back on Array. If you want to set array type manually, inject it via the global variable P2_ARRAY_TYPE. See example below.

    - -
    - - - - -
    -

    Example:

    - -
    -
    <script>
    -    <!-- Inject your preferred array type before loading p2.js -->
    -    P2_ARRAY_TYPE = Array;
    -</script>
    -<script src="p2.js"></script>
    - -
    -
    - - - -
    - - +

    ARRAY_TYPE

    + Function + + + + + static + +
    +

    + Defined in + src/utils/Utils.js:45 +

    + + +
    + +
    +

    The array type to use for internal numeric computations throughout the library. Float32Array is used if it is available, but falls back on Array. If you want to set array type manually, inject it via the global variable P2_ARRAY_TYPE. See example below.

    + +
    + + +
    +

    Example:

    + +
    +
    <script>
    +                        <!-- Inject your preferred array type before loading p2.js -->
    +                        P2_ARRAY_TYPE = Array;
    +                    </script>
    +                    <script src="p2.js"></script>
    +                    
    +
    +
    + +
    - - -
    -
    diff --git a/docs/classes/World.html b/docs/classes/World.html index 0852f0ce..fa6d66c9 100644 --- a/docs/classes/World.html +++ b/docs/classes/World.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,937 +25,584 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    World Class

    +

    World Class

    - -
    Extends EventEmitter
    - -
    - Defined in: src/world/World.js:51 + Defined in: src/world/World.js:52
    - - -
    -

    The dynamics world, where all bodies and constraints lives.

    -

    Constructor

    -

    World

    - - -
    - (
      - -
    • - - [options] - -
    • - -
    ) -
    - - - - - - - - - - - - - - - - -
    +

    World

    + +
    + (
      +
    • + [options] +
    • +
    ) +
    - - -

    - - Defined in + + + + + + + +

    +

    + Defined in + src/world/World.js:52 +

    + + + +
    + +
    - +
    +
    +

    Parameters:

    - src/world/World.js:51 +
      +
    • + [options] + Object + optional -

      - - - +
      + +
      -
    - -
    +
      +
    • + [solver] + Solver + optional -
    - - -
    -

    Parameters:

    - -
      - -
    • - - [options] - Object - optional - - - - -
      - +
      +

      Defaults to GSSolver.

      + +
      + +
    • +
    • + [gravity] Defaults to [0,-9.78] + Array + optional + +
      + +
      + +
    • +
    • + [broadphase] + Broadphase + optional + +
      +

      Defaults to NaiveBroadphase

      + +
      + +
    • +
    • + [islandSplit=false] + Boolean + optional + +
      + +
      + +
    • +
    • + [doProfiling=false] + Boolean + optional + +
      + +
      + +
    • +
    + + +
    + + + +
    +

    Example:

    + +
    +
    var world = new World({
    +            gravity: [0, -9.81],
    +            broadphase: new SAPBroadphase()
    +        });
    +        
    - - -
      - -
    • - - [solver] - Solver - optional - - -
      -

      Defaults to GSSolver.

      - -
      - - -
    • - -
    • - - [gravity] - Array - optional - - -
      -

      Defaults to [0,-9.78]

      - -
      - - -
    • - -
    • - - [broadphase] - Broadphase - optional - - -
      -

      Defaults to NaiveBroadphase

      - -
      - - -
    • - -
    • - - [islandSplit=false] - Boolean - optional - - -
      - -
      - - -
    • - -
    • - - [doProfiling=false] - Boolean - optional - - -
      - -
      - - -
    • - -
    - - - - -
    - - - - - -
    -

    Example:

    - -
    -
    var world = new World({
    -    gravity: [0, -9.81],
    -    broadphase: new SAPBroadphase()
    -});
    - -
    +
    - -
    -
    -

    Item Index

    - - - - - -

    Events

    -
    -

    Methods

    - -
    +

    addBody

    -
    (
      -
    • - body -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - - src/world/World.js:1034 - + src/world/World.js:999

    - -
    @@ -965,98 +610,62 @@

    addBody

    -

    Parameters:

      -
    • - body Body - -
      -
    • -
    - - - +

    Example:

    var world = new World(),
         body = new Body();
    -world.addBody(body);
    - +world.addBody(body); +
    -
    - - -
    +

    addConstraint

    -
    (
      -
    • - c -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - - src/world/World.js:421 - + src/world/World.js:423

    - -
    @@ -1064,87 +673,52 @@

    addConstraint

    -

    Parameters:

    - - - -
    - -
    +
    +

    addContactMaterial

    -
    (
      -
    • - contactMaterial -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - - src/world/World.js:431 - + src/world/World.js:433

    - -
    @@ -1152,87 +726,52 @@

    addContactMaterial

    -

    Parameters:

    - - - -
    - -
    +
    +

    addSpring

    -
    (
      -
    • - s -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - - src/world/World.js:1009 - + src/world/World.js:974

    - -
    @@ -1240,77 +779,46 @@

    addSpring

    -

    Parameters:

    - - - -
    - -
    +
    +

    clear

    - () - - - - - - - -
    - - -

    - Defined in - - - - - src/world/World.js:1146 - + src/world/World.js:1111

    - -
    @@ -1318,58 +826,33 @@

    clear

    - - - -
    - -
    +
    +

    clone

    - () - - World - - - - - - -
    - - -

    - Defined in - - - - - src/world/World.js:1188 - + src/world/World.js:1153

    - -
    @@ -1377,82 +860,46 @@

    clone

    - -

    Returns:

    - - World: - -
    - - -
    - -
    +
    +

    disableCollision

    -
    (
      -
    • - bodyA -
    • -
    • - bodyB -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - - src/world/World.js:1092 - + src/world/World.js:1057

    - -
    @@ -1460,103 +907,65 @@

    disableCollision

    -

    Parameters:

      -
    • - bodyA Body - -
      -
    • -
    • - bodyB Body - -
      -
    • -
    - - - -
    - -
    +
    +

    emit

    -
    (
      -
    • - event -
    • -
    )
    - - EventEmitter - - - - - - -
    - -

    Inherited from EventEmitter: - - - src/events/EventEmitter.js:79 -

    - -
    @@ -1564,124 +973,75 @@

    emit

    -

    Parameters:

      -
    • - event Object - -
      -
        -
      • - type String -
        -
      • -
      -
    • -
    - -

    Returns:

    - - EventEmitter: -

    The self object, for chainability.

    -
    - - -
    - -
    +
    +

    enableCollision

    -
    (
      -
    • - bodyA -
    • -
    • - bodyB -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - - src/world/World.js:1102 - + src/world/World.js:1067

    - -
    @@ -1689,96 +1049,59 @@

    enableCollision

    -

    Parameters:

      -
    • - bodyA Body - -
      -
    • -
    • - bodyB Body - -
      -
    • -
    - - - -
    - -
    +
    +

    getBodyById

    - () - - Body | Boolean - - - - - - -
    - - -

    - Defined in - - - - - src/world/World.js:1076 - + src/world/World.js:1041

    - -
    @@ -1786,88 +1109,51 @@

    getBodyById

    - -

    Returns:

    - - Body | Boolean: -

    The body, or false if it was not found.

    -
    - - -
    - -
    +
    +

    getContactMaterial

    -
    (
      -
    • - materialA -
    • -
    • - materialB -
    • -
    )
    - - ContactMaterial - - - - - - -
    - - -

    - Defined in - - - - - src/world/World.js:453 - + src/world/World.js:455

    - -
    @@ -1875,123 +1161,77 @@

    getContactMaterial

    -

    Parameters:

    - -

    Returns:

    - - ContactMaterial: -

    The matching ContactMaterial, or false on fail.

    -
    - - -
    - -
    +
    +

    has

    -
    (
      -
    • - type -
    • -
    • - listener -
    • -
    )
    - - Boolean - - - - - - -
    - -

    Inherited from EventEmitter: - - - src/events/EventEmitter.js:35 -

    - -
    @@ -1999,130 +1239,78 @@

    has

    -

    Parameters:

      -
    • - type String - -
      -
    • -
    • - listener Function - -
      -
    • -
    - -

    Returns:

    - - Boolean: - -
    - - -
    - -
    +
    +

    hitTest

    -
    (
      -
    • - worldPoint -
    • -
    • - bodies -
    • -
    • - precision -
    • -
    )
    - - Array - - - - - - -
    - - -

    - Defined in - - - - - src/world/World.js:1203 - + src/world/World.js:1168

    - -
    @@ -2130,989 +1318,971 @@

    hitTest

    -

    Parameters:

      -
    • - worldPoint Array - -

      Point to use for intersection tests

      -
    • -
    • - bodies Array - -

      A list of objects to check for intersection

      -
    • -
    • - precision Number - -

      Used for matching against particles and lines. Adds some margin to these infinitesimal objects.

      -
    • -
    - -

    Returns:

    - - Array: -

    Array of bodies that overlap the point

    -
    - - -
    - -
    -

    integrateBody

    +
    +
    +

    internalStep

    -
    (
      - -
    • - - body - -
    • -
    • - dt -
    • -
    )
    - - - - + private - - - static - - -
    - - -

    - Defined in - - - - - src/world/World.js:854 - + src/world/World.js:571

    - -
    -

    Move a body forward in time.

    +

    Make a fixed step.

    -

    Parameters:

      - -
    • - - body - Body - - - - -
      - -
      - - -
    • -
    • - dt Number - -
      -
    • -
    - - - -
    - -
    -

    internalStep

    +
    +
    +

    off

    -
    (
      -
    • - - dt - + type +
    • +
    • + listener
    • -
    )
    - - + + EventEmitter + - - - private - - - - -
    - - - -

    - - Defined in - - - - - src/world/World.js:569 - +

    Inherited from + EventEmitter: + src/events/EventEmitter.js:60

    - -
    -

    Make a fixed step.

    +

    Remove an event listener

    -

    Parameters:

      -
    • - - dt - Number - + type + String -
      - +
      -
    • - -
    -
    - +
  • + listener + Function - - -
  • +
    + +
    - -
    -

    off

    + + +
    + +
    +

    Returns:

    + +
    + EventEmitter: +

    The self object, for chainability.

    + +
    +
    + + +
    +
    +

    on

    -
    (
      -
    • - type -
    • -
    • - listener -
    • -
    )
    - - EventEmitter - - - - - - -
    -

    Remove an event listener

    +

    Add an event listener

    -

    Parameters:

      -
    • - type String - -
      -
    • -
    • - listener Function - -
      -
    • -
    - -

    Returns:

    - - EventEmitter: -

    The self object, for chainability.

    -
    - - -
    - -
    -

    on

    +
    +
    +

    raycastAll

    -
    (
      -
    • - - type - + from
    • -
    • - - listener - + to +
    • +
    • + options +
    • +
    • + callback
    • -
    )
    - - - EventEmitter + Boolean - - - - - - -
    - - -

    Inherited from - EventEmitter: - - - - src/events/EventEmitter.js:13 - +

    + Defined in + src/world/World.js:1293

    - -
    -

    Add an event listener

    +

    Ray cast against all bodies. The provided callback will be executed for each hit with a RaycastResult as single argument.

    -

    Parameters:

      -
    • - - type - String - + from + Vec3 -
      - +
      -
    • -
    • - - listener + to + Vec3 + + +
      + +
      + +
    • +
    • + options + Object + + +
      + +
      + +
        +
      • + [collisionMask=-1] + Number + optional + +
        + +
        + +
      • +
      • + [collisionGroup=-1] + Number + optional + +
        + +
        + +
      • +
      • + [skipBackfaces=false] + Boolean + optional + +
        + +
        + +
      • +
      • + [checkCollisionResponse=true] + Boolean + optional + +
        + +
        + +
      • +
      +
    • +
    • + callback Function - -
      - +
      -
    • -
    - -

    Returns:

    - - - EventEmitter: - -

    The self object, for chainability.

    + Boolean: +

    True if any body was hit.

    -
    - - -
    - -
    -

    removeBody

    +
    +
    +

    raycastAny

    -
    (
      -
    • - - body - + from +
    • +
    • + to +
    • +
    • + options +
    • +
    • + result
    • -
    )
    - - + + Boolean + - - - - - -
    - - -

    - Defined in - - - - - src/world/World.js:1055 - + src/world/World.js:1314

    - -
    -

    Remove a body from the simulation. If this method is called during step(), the body removal is scheduled to after the step.

    +

    Ray cast, and stop at the first result. Note that the order is random - but the method is fast.

    -

    Parameters:

      -
    • - - body - Body - + from + Vec3 -
      -
    • - -
    -
    - - - +
  • + to + Vec3 - -
  • - -
    -

    removeConstraint

    +
    + +
    - -
    - (
      - -
    • - - c -
    • - -
    ) -
    - +
  • + options + Object - - +
    + +
    + +
      +
    • + [collisionMask=-1] + Number + optional + +
      + +
      + +
    • +
    • + [collisionGroup=-1] + Number + optional + +
      + +
      + +
    • +
    • + [skipBackfaces=false] + Boolean + optional + +
      + +
      + +
    • +
    • + [checkCollisionResponse=true] + Boolean + optional + +
      + +
      + +
    • +
    +
  • +
  • + result + RaycastResult + + +
    + +
    + +
  • + +
    + +
    +

    Returns:

    + +
    + Boolean: +

    True if any body was hit.

    + +
    +
    + + +
    +
    +

    raycastClosest

    + +
    + (
      +
    • + from +
    • +
    • + to +
    • +
    • + options +
    • +
    • + result +
    • +
    ) +
    + + + Boolean + + - - - - -
    - - -

    - Defined in - - - - - src/world/World.js:473 - + src/world/World.js:1335

    - -
    -

    Removes a constraint

    +

    Ray cast, and return information of the closest hit.

    -

    Parameters:

      -
    • - - c - Constraint - + from + Vec3 + + +
      + +
      + +
    • +
    • + to + Vec3 + + +
      + +
      + +
    • +
    • + options + Object + + +
      + +
      + +
        +
      • + [collisionMask=-1] + Number + optional + +
        + +
        + +
      • +
      • + [collisionGroup=-1] + Number + optional + +
        + +
        + +
      • +
      • + [skipBackfaces=false] + Boolean + optional + +
        + +
        + +
      • +
      • + [checkCollisionResponse=true] + Boolean + optional + +
        + +
        + +
      • +
      +
    • +
    • + result + RaycastResult -
      -
    • -
    - - +
    +

    Returns:

    - -
    +
    + Boolean: +

    True if any body was hit.

    - -
    -

    removeContactMaterial

    +
    +
    + + +
    +
    +

    removeBody

    -
    (
      -
    • - - cm - + body
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - - src/world/World.js:440 - + src/world/World.js:1020

    - -
    -

    Removes a contact material

    +

    Remove a body from the simulation. If this method is called during step(), the body removal is scheduled to after the step.

    -

    Parameters:

    - - - -
    - -
    -

    removeSpring

    +
    +
    +

    removeConstraint

    -
    (
      -
    • - - s - + c
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - - src/world/World.js:1021 - + src/world/World.js:475

    - -
    -

    Remove a spring

    +

    Removes a constraint

    -

    Parameters:

    - - - -
    - -
    -

    runNarrowphase

    +
    +
    +

    removeContactMaterial

    -
    (
      - -
    • - - np - -
    • - -
    • - - bi - -
    • - -
    • - - si - -
    • - -
    • - - xi - -
    • -
    • - - ai - + cm +
    • +
    ) +
    + + + + + + + + +
    +

    + Defined in + src/world/World.js:442 +

    + + + +
    + +
    +

    Removes a contact material

    + +
    + +
    +

    Parameters:

    + + +
    + + + +
    +
    +

    removeSpring

    + +
    + (
      +
    • + s +
    • +
    ) +
    + + + + + + + + +
    +

    + Defined in + src/world/World.js:986 +

    + + + +
    + +
    +

    Remove a spring

    + +
    + +
    +

    Parameters:

    + +
      +
    • + s + Spring + + +
      + +
      + +
    • +
    +
    + + + +
    +
    +

    runNarrowphase

    + +
    + (
      +
    • + np +
    • +
    • + bi +
    • +
    • + si +
    • +
    • + xi +
    • +
    • + ai
    • -
    • - bj -
    • -
    • - sj -
    • -
    • - xj -
    • -
    • - aj -
    • -
    • - mu -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - - src/world/World.js:887 - + src/world/World.js:851

    - -
    @@ -3120,222 +2290,142 @@

    runNarrowphase

    -

    Parameters:

      -
    • - np Narrowphase - -
      -
    • -
    • - bi Body - -
      -
    • -
    • - si Shape - -
      -
    • -
    • - xi Array - -
      -
    • -
    • - ai Number - -
      -
    • -
    • - bj Body - -
      -
    • -
    • - sj Shape - -
      -
    • -
    • - xj Array - -
      -
    • -
    • - aj Number - -
      -
    • -
    • - mu Number - -
      -
    • -
    - - - -
    - -
    +
    +

    setGlobalEquationParameters

    -
    (
      -
    • - [parameters] -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - - src/world/World.js:1254 - + src/world/World.js:1219

    - -
    @@ -3343,120 +2433,75 @@

    setGlobalEquationParameters

    -

    Parameters:

      -
    • - [parameters] Object optional - -
      -
        -
      • - [relaxation] Number optional -
        -
      • -
      • - [stiffness] Number optional -
        -
      • -
      -
    • -
    - - - -
    - -
    +
    +

    setGlobalRelaxation

    -
    (
      -
    • - relaxation -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - - src/world/World.js:1315 - + src/world/World.js:1280

    - -
    @@ -3464,87 +2509,52 @@

    setGlobalRelaxation

    -

    Parameters:

      -
    • - relaxation Number - -
      -
    • -
    - - - -
    - -
    +
    +

    setGlobalStiffness

    -
    (
      -
    • - stiffness -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - - src/world/World.js:1304 - + src/world/World.js:1269

    - -
    @@ -3552,99 +2562,58 @@

    setGlobalStiffness

    -

    Parameters:

      -
    • - stiffness Number - -
      -
    • -
    - - - -
    - -
    +
    +

    step

    -
    (
      -
    • - dt -
    • -
    • - [timeSinceLastCalled=0] -
    • -
    • - [maxSubSteps=10] -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - - src/world/World.js:498 - + src/world/World.js:500

    - -
    @@ -3653,2249 +2622,1315 @@

    step

    -

    Parameters:

      -
    • - dt Number - -

      The fixed time step size to use.

      -
    • -
    • - [timeSinceLastCalled=0] Number optional - -

      The time elapsed since the function was last called.

      -
    • -
    • - [maxSubSteps=10] Number optional - -

      Maximum number of fixed steps to take per function call.

      -
    • -
    - - - +

    Example:

    // fixed timestepping without interpolation
     var world = new World();
    -world.step(0.01);
    - +world.step(0.01); +
    -
    - -
    - -

    Properties

    -
    -

    applyDamping

    - Boolean - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/World.js:204 - -

    - - - - -
    - -
    -

    Enable to automatically apply body damping each step.

    - -
    - - - - - - -
    - - +

    applyDamping

    + Boolean + + + + + +
    +

    + Defined in + src/world/World.js:205 +

    + + +
    + +
    +

    Enable to automatically apply body damping each step.

    + +
    + + + +
    -

    applyGravity

    - Boolean - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/World.js:211 - -

    - - - - -
    - -
    -

    Enable to automatically apply gravity each step.

    - -
    - - - - - - -
    - - +

    applyGravity

    + Boolean + + + + + +
    +

    + Defined in + src/world/World.js:212 +

    + + +
    + +
    +

    Enable to automatically apply gravity each step.

    + +
    + + + +
    -

    applySpringForces

    - Boolean - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/World.js:197 - -

    - - - - -
    - -
    -

    Enable to automatically apply spring forces each step.

    - -
    - - - - - - -
    - - +

    applySpringForces

    + Boolean + + + + + +
    +

    + Defined in + src/world/World.js:198 +

    + + +
    + +
    +

    Enable to automatically apply spring forces each step.

    + +
    + + + +
    -

    bodies

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/World.js:83 - -

    - - - - -
    - -
    -

    All bodies in the world. To add a body to the world, use addBody.

    - -
    - - - - - - -
    - - +

    bodies

    + Array + + + + + +
    +

    + Defined in + src/world/World.js:84 +

    + + +
    + +
    +

    All bodies in the world. To add a body to the world, use addBody.

    + +
    + + + +
    -

    bodiesToBeRemoved

    - Array - - - - - private - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/World.js:245 - -

    - - - - -
    - -
    -

    Bodies that are scheduled to be removed at the end of the step.

    - -
    - - - - - - -
    - - +

    bodiesToBeRemoved

    + Array + + + private + + + +
    +

    + Defined in + src/world/World.js:246 +

    + + +
    + +
    +

    Bodies that are scheduled to be removed at the end of the step.

    + +
    + + + +
    -

    BODY_SLEEPING

    - Number - - - - - - - - - static - - -
    - - - -

    - - Defined in - - - - - src/world/World.js:407 - -

    - - - - -
    - -
    -

    Deactivate individual bodies if they are sleepy.

    - -
    - - - - - - -
    - - +

    BODY_SLEEPING

    + Number + + + + + static + +
    +

    + Defined in + src/world/World.js:409 +

    + + +
    + +
    +

    Deactivate individual bodies if they are sleepy.

    + +
    + + + +
    -

    broadphase

    - Broadphase - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/World.js:161 - -

    - - - - -
    - -
    -

    The broadphase algorithm to use.

    - -
    - - - - - - -
    - - +

    broadphase

    + Broadphase + + + + + +
    +

    + Defined in + src/world/World.js:162 +

    + + +
    + +
    +

    The broadphase algorithm to use.

    + +
    + + + +
    -

    constraints

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/World.js:170 - -

    - - - - -
    - -
    -

    User-added constraints.

    - -
    - - - - - - -
    - - +

    constraints

    + Array + + + + + +
    +

    + Defined in + src/world/World.js:171 +

    + + +
    + +
    +

    User-added constraints.

    + +
    + + + +
    -

    contactMaterials

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/World.js:225 - -

    - - - - -
    - -
    -

    The ContactMaterials added to the World.

    - -
    - - - - - - -
    - - +

    contactMaterials

    + Array + + + + + +
    +

    + Defined in + src/world/World.js:226 +

    + + +
    + +
    +

    The ContactMaterials added to the World.

    + +
    + + + +
    -

    defaultContactMaterial

    - ContactMaterial - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/World.js:184 - -

    - - - - -
    - -
    -

    The default contact material to use, if no contact material was set for the colliding materials.

    - -
    - - - - - - -
    - - -
    -

    defaultMaterial

    - Material - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/World.js:178 - -

    - - - - -
    - -
    -

    Dummy default material in the world, used in .defaultContactMaterial

    - -
    - - - - - - -
    - - +

    defaultContactMaterial

    + ContactMaterial + + + + + +
    +

    + Defined in + src/world/World.js:185 +

    + + +
    + +
    +

    The default contact material to use, if no contact material was set for the colliding materials.

    + +
    + + + + +
    +

    defaultMaterial

    + Material + + + + + +
    +

    + Defined in + src/world/World.js:179 +

    + + +
    + +
    +

    Dummy default material in the world, used in .defaultContactMaterial

    + +
    + + + +
    -

    disabledBodyCollisionPairs

    - Array - - - - - private - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/World.js:89 - -

    - - - - -
    - -
    -

    Disabled body collision pairs. See {{#crossLink "World/disableBodyCollision:method"}}.

    - -
    - - - - - - -
    - - +

    disabledBodyCollisionPairs

    + Array + + + private + + + +
    +

    + Defined in + src/world/World.js:90 +

    + + +
    + +
    +

    Disabled body collision pairs. See {{#crossLink "World/disableBodyCollision:method"}}.

    + +
    + + + +
    -

    doPofiling

    - Boolean - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/World.js:145 - -

    - - - - -
    - -
    -

    Whether to do timing measurements during the step() or not.

    - -
    - - - - - - -
    - - +

    doPofiling

    + Boolean + + + + + +
    +

    + Defined in + src/world/World.js:146 +

    + + +
    + +
    +

    Whether to do timing measurements during the step() or not.

    + +
    + + + +
    -

    emitImpactEvent

    - Boolean - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/World.js:260 - -

    - - - - -
    - -
    -

    Set to true if you want to the world to emit the "impact" event. Turning this off could improve performance.

    - -
    - - - - - - -
    - - +

    emitImpactEvent

    + Boolean + + + + + +
    +

    + Defined in + src/world/World.js:261 +

    + + +
    + +
    +

    Set to true if you want to the world to emit the "impact" event. Turning this off could improve performance.

    + +
    + + + +
    -

    frictionGravity

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/World.js:127 - -

    - - - - -
    - -
    -

    Gravity to use when approximating the friction max force (mumassgravity).

    - -
    - - - - - - -
    - - +

    frictionGravity

    + Number + + + + + +
    +

    + Defined in + src/world/World.js:128 +

    + + +
    + +
    +

    Gravity to use when approximating the friction max force (mumassgravity).

    + +
    + + + +
    -

    gravity

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/World.js:116 - -

    - - - - -
    - -
    -

    Gravity in the world. This is applied on all bodies in the beginning of each step().

    - -
    - - - - - - -
    - - +

    gravity

    + Array + + + + + +
    +

    + Defined in + src/world/World.js:117 +

    + + +
    + +
    +

    Gravity in the world. This is applied on all bodies in the beginning of each step().

    + +
    + + + +
    -

    ISLAND_SLEEPING

    - Number - - - - - - - - - static - - -
    - - - -

    - - Defined in - - - - - src/world/World.js:414 - -

    - - - - -
    - -
    -

    Deactivates bodies that are in contact, if all of them are sleepy. Note that you must enable .islandSplit for this to work.

    - -
    - - - - - - -
    - - +

    ISLAND_SLEEPING

    + Number + + + + + static + +
    +

    + Defined in + src/world/World.js:416 +

    + + +
    + +
    +

    Deactivates bodies that are in contact, if all of them are sleepy. Note that you must enable .islandSplit for this to work.

    + +
    + + + +
    -

    islandManager

    - IslandManager - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/World.js:110 - -

    - - - - -
    - -
    -

    The island manager of this world.

    - -
    - - - - - - -
    - - +

    islandManager

    + IslandManager + + + + + +
    +

    + Defined in + src/world/World.js:111 +

    + + +
    + +
    +

    The island manager of this world.

    + +
    + + + +
    -

    islandSplit

    - Boolean - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/World.js:254 - -

    - - - - -
    - -
    -

    Whether to enable island splitting. Island splitting can be an advantage for many things, including solver performance. See IslandManager.

    - -
    - - - - - - -
    - - +

    islandSplit

    + Boolean + + + + + +
    +

    + Defined in + src/world/World.js:255 +

    + + +
    + +
    +

    Whether to enable island splitting. Island splitting can be an advantage for many things, including solver performance. See IslandManager.

    + +
    + + + +
    -

    lastStepTime

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/World.js:153 - -

    - - - - -
    - -
    -

    How many millisecconds the last step() took. This is updated each step if .doProfiling is set to true.

    - -
    - - - - - - -
    - - +

    lastStepTime

    + Number + + + + + +
    +

    + Defined in + src/world/World.js:154 +

    + + +
    + +
    +

    How many millisecconds the last step() took. This is updated each step if .doProfiling is set to true.

    + +
    + + + +
    -

    lastTimeStep

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/World.js:190 - -

    - - - - -
    - -
    -

    For keeping track of what time step size we used last step

    - -
    - - - - - - -
    - - +

    lastTimeStep

    + Number + + + + + +
    +

    + Defined in + src/world/World.js:191 +

    + + +
    + +
    +

    For keeping track of what time step size we used last step

    + +
    + + + +
    -

    narrowphase

    - Narrowphase - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/World.js:102 - -

    - - - - -
    - -
    -

    The narrowphase to use to generate contacts.

    - -
    - - - - - - -
    - - +

    narrowphase

    + Narrowphase + + + + + +
    +

    + Defined in + src/world/World.js:103 +

    + + +
    + +
    +

    The narrowphase to use to generate contacts.

    + +
    + + + +
    -

    NO_SLEEPING

    - Number - - - - - - - - - static - - -
    - - - -

    - - Defined in - - - - - src/world/World.js:400 - -

    - - - - -
    - -
    -

    Never deactivate bodies.

    - -
    - - - - - - -
    - - +

    NO_SLEEPING

    + Number + + + + + static + +
    +

    + Defined in + src/world/World.js:402 +

    + + +
    + +
    +

    Never deactivate bodies.

    + +
    + + + +
    -

    sleepMode

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/World.js:336 - -

    - - - - -
    - -
    -

    How to deactivate bodies during simulation. Possible modes are: World.NO_SLEEPING, World.BODY_SLEEPING and World.ISLAND_SLEEPING. -If sleeping is enabled, you might need to wake up the bodies if they fall asleep when they shouldn't. If you want to enable sleeping in the world, but want to disable it for a particular body, see Body.allowSleep.

    - -
    - - -

    Default: World.NO_SLEEPING

    - - - - - -
    - - +

    sleepMode

    + Number + + + + + +
    +

    + Defined in + src/world/World.js:337 +

    + + +
    + +
    +

    How to deactivate bodies during simulation. Possible modes are: World.NO_SLEEPING, World.BODY_SLEEPING and World.ISLAND_SLEEPING. + If sleeping is enabled, you might need to wake up the bodies if they fall asleep when they shouldn't. If you want to enable sleeping in the world, but want to disable it for a particular body, see Body.allowSleep.

    + +
    + +

    Default: World.NO_SLEEPING

    + + +
    -

    solveConstraints

    - Boolean - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/World.js:218 - -

    - - - - -
    - -
    -

    Enable/disable constraint solving in each step.

    - -
    - - - - - - -
    - - +

    solveConstraints

    + Boolean + + + + + +
    +

    + Defined in + src/world/World.js:219 +

    + + +
    + +
    +

    Enable/disable constraint solving in each step.

    + +
    + + + +
    -

    solver

    - Solver - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/World.js:96 - -

    - - - - -
    - -
    -

    The solver used to satisfy constraints and contacts. Default is GSSolver.

    - -
    - - - - - - -
    - - +

    solver

    + Solver + + + + + +
    +

    + Defined in + src/world/World.js:97 +

    + + +
    + +
    +

    The solver used to satisfy constraints and contacts. Default is GSSolver.

    + +
    + + + +
    -

    springs

    - Array - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/World.js:75 - -

    - - - - -
    - -
    -

    All springs in the world. To add a spring to the world, use addSpring.

    - -
    - - - - - - -
    - - +

    springs

    + Array + + + + + +
    +

    + Defined in + src/world/World.js:76 +

    + + +
    + +
    +

    All springs in the world. To add a spring to the world, use addSpring.

    + +
    + + + +
    -

    stepping

    - Boolean - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/World.js:239 - -

    - - - - -
    - -
    -

    Is true during the step().

    - -
    - - - - - - -
    - - -
    -

    time

    - Number - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/World.js:232 - -

    - - - - -
    - -
    -

    World time.

    - -
    - - - - - - -
    - - +

    stepping

    + Boolean + + + + + +
    +

    + Defined in + src/world/World.js:240 +

    + + +
    + +
    +

    Is true during the step().

    + +
    + + + + +
    +

    time

    + Number + + + + + +
    +

    + Defined in + src/world/World.js:233 +

    + + +
    + +
    +

    World time.

    + +
    + + + +
    -

    useFrictionGravityOnZeroGravity

    - Boolean - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/World.js:139 - -

    - - - - -
    - -
    -

    If the length of .gravity is zero, and .useWorldGravityAsFrictionGravity=true, then switch to using .frictionGravity for friction instead. This fallback is useful for gravityless games.

    - -
    - - - - - - -
    - - +

    useFrictionGravityOnZeroGravity

    + Boolean + + + + + +
    +

    + Defined in + src/world/World.js:140 +

    + + +
    + +
    +

    If the length of .gravity is zero, and .useWorldGravityAsFrictionGravity=true, then switch to using .frictionGravity for friction instead. This fallback is useful for gravityless games.

    + +
    + + + +
    -

    useWorldGravityAsFrictionGravity

    - Boolean - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/World.js:133 - -

    - - - - -
    - -
    -

    Set to true if you want .frictionGravity to be automatically set to the length of .gravity.

    - -
    - - - - - - -
    - - +

    useWorldGravityAsFrictionGravity

    + Boolean + + + + + +
    +

    + Defined in + src/world/World.js:134 +

    + + +
    + +
    +

    Set to true if you want .frictionGravity to be automatically set to the length of .gravity.

    + +
    + + + + - - -

    Events

    -
    -

    addBody

    - - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/World.js:279 - -

    - - - - -
    - -
    -

    Fired when a body is added to the world.

    - -
    - - -
    -

    Event Payload:

    - -
      - -
    • +

      addBody

      + - body - Body - - -
      - -
      - -
    • - -
    -
    - - - - -
    - - + +
    +

    + Defined in + src/world/World.js:280 +

    + + +
    + +
    +

    Fired when a body is added to the world.

    + +
    + +
    +

    Event Payload:

    + +
      +
    • + body + Body + + +
      + +
      + +
    • +
    +
    + + +
    -

    addSpring

    - - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/World.js:299 - -

    - - - - -
    - -
    -

    Fired when a spring is added to the world.

    - -
    - - -
    -

    Event Payload:

    - -
      - -
    • +

      addSpring

      + + + + + + +
      +

      + Defined in + src/world/World.js:300 +

      + + +
      + +
      +

      Fired when a spring is added to the world.

      + +
      + +
      +

      Event Payload:

      + +
        +
      • + spring + Spring + + +
        + +
        + +
      • +
      +
      + + +
    +
    +

    beginContact

    + + + + + + +
    +

    + Defined in + src/world/World.js:346 +

    + + +
    + +
    +

    Fired when two shapes starts start to overlap. Fired in the narrowphase, during step.

    + +
    + +
    +

    Event Payload:

    + +
      +
    • + shapeA + Shape + + +
      + +
      + +
    • +
    • + shapeB + Shape + + +
      + +
      + +
    • +
    • + bodyA + Body + + +
      + +
      + +
    • +
    • + bodyB + Body + + +
      + +
      - spring - Spring +
    • +
    • + contactEquations + Array + + +
      + +
      + +
    • +
    +
    - - -
    -
    - +
    +

    endContact

    + - - - -
    - - - - -
    - - -
    -

    beginContact

    - - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/World.js:345 - -

    - - - - -
    - -
    -

    Fired when two shapes starts start to overlap. Fired in the narrowphase, during step.

    - -
    - - -
    -

    Event Payload:

    - -
      - -
    • - shapeA - Shape - - -
      - -
      - -
    • - -
    • +
      +

      + Defined in + src/world/World.js:364 +

      - shapeB - Shape - +
      - -
      - -
      - +
      +

      Fired when two shapes stop overlapping, after the narrowphase (during step).

      -
    • - -
    • +
    - bodyA - Body +
    +

    Event Payload:

    - +
      +
    • + shapeA + Shape - -
      - -
      - -
    • - -
    • +
      + +
      - bodyB - Body +
    • +
    • + shapeB + Shape - - -
      - -
      - +
      + +
      -
    • - -
    • +
    • +
    • + bodyA + Body - contactEquations - Array - +
      + +
      - -
      - -
      - +
    • +
    • + bodyB + Body -
    • - -
    -
    - - - - -
    - - -
    -

    endContact

    - - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/World.js:363 - -

    - - - - -
    - -
    -

    Fired when two shapes stop overlapping, after the narrowphase (during step).

    - -
    - - -
    -

    Event Payload:

    - -
      - -
    • - shapeA - Shape +
      + +
      - +
    • +
    • + contactEquations + Array - -
      - -
      - -
    • - -
    • +
      + +
      - shapeB - Shape +
    • +
    +
    - - -
    -
    - +
    +

    impact

    + - - -
  • - bodyA - Body - - -
    - -
    - -
  • - -
  • +
    +

    + Defined in + src/world/World.js:310 +

    - bodyB - Body - +
    - -
    - -
    - +
    +

    Fired when a first contact is created between two bodies. This event is fired after the step has been done.

    -
  • - -
  • +
  • - contactEquations - Array +
    +

    Event Payload:

    + +
      +
    • + bodyA + Body + + +
      + +
      + +
    • +
    • + bodyB + Body + + +
      + +
      + +
    • +
    +
    - - -
    -
    - +
    +

    postBroadphase

    + - - - -
    - - - - -
    - - -
    -

    impact

    - - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/World.js:309 - -

    - - - - -
    - -
    -

    Fired when a first contact is created between two bodies. This event is fired after the step has been done.

    - -
    - - -
    -

    Event Payload:

    - -
      - -
    • - bodyA - Body - - -
      - + +
      +

      + Defined in + src/world/World.js:325 +

      + + +
      + +
      +

      Fired after the Broadphase has collected collision pairs in the world. + Inside the event handler, you can modify the pairs array as you like, to + prevent collisions between objects that you don't want.

      + +
      + +
      +

      Event Payload:

      + +
        +
      • + pairs + Array + + +
        +

        An array of collision pairs. If this array is [body1,body2,body3,body4], then the body pairs 1,2 and 3,4 would advance to narrowphase.

        + +
        + +
      • +
      +
      + +
      - +
      +

      postStep

      + -
    • - -
    • - bodyB - Body - - -
      - -
      - -
    • - -
    -
    - - - - -
    - - -
    -

    postBroadphase

    - - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/World.js:324 - -

    - - - - -
    - -
    -

    Fired after the Broadphase has collected collision pairs in the world. -Inside the event handler, you can modify the pairs array as you like, to -prevent collisions between objects that you don't want.

    - -
    - - -
    -

    Event Payload:

    - -
      - -
    • +
      +

      + Defined in + src/world/World.js:272 +

      - pairs - Array - +
      - -
      -

      An array of collision pairs. If this array is [body1,body2,body3,body4], then the body pairs 1,2 and 3,4 would advance to narrowphase.

      - -
      - +
      +

      Fired after the step().

      -
    • - -
    -
    - - - - -
    - - -
    -

    postStep

    - - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/World.js:271 - -

    - - - - -
    - -
    -

    Fired after the step().

    - -
    - - - - - -
    - - -
    -

    preSolve

    - - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/World.js:380 - -

    - - - - -
    - -
    -

    Fired just before equations are added to the solver to be solved. Can be used to control what equations goes into the solver.

    - -
    - - -
    -

    Event Payload:

    - -
      - -
    • +
    - contactEquations - Array - - -
    -

    An array of contacts to be solved.

    -
    - +
    +

    preSolve

    + - - -
  • - frictionEquations - Array - - -
    -

    An array of friction equations to be solved.

    - -
    - -
  • - - -
    - - - - -
    - - -
    -

    removeBody

    - - - - - - - - - - -
    - - - -

    - - Defined in - - - - - src/world/World.js:289 - -

    - - - - -
    - -
    -

    Fired when a body is removed from the world.

    - -
    - - -
    -

    Event Payload:

    - -
      - -
    • +
      +

      + Defined in + src/world/World.js:381 +

      - body - Body - +
      + +
      +

      Fired just before equations are added to the solver to be solved. Can be used to control what equations goes into the solver.

      + +
      + +
      +

      Event Payload:

      + +
        +
      • + contactEquations + Array + + +
        +

        An array of contacts to be solved.

        + +
        + +
      • +
      • + frictionEquations + Array + + +
        +

        An array of friction equations to be solved.

        + +
        + +
      • +
      +
      + - -
      -
      - +
      +

      removeBody

      + -
    • - -
    -
    - - - - -
    - - + + + + +
    +

    + Defined in + src/world/World.js:290 +

    + + +
    + +
    +

    Fired when a body is removed from the world.

    + +
    + +
    +

    Event Payload:

    + +
      +
    • + body + Body + + +
      + +
      + +
    • +
    +
    + + +
    - - diff --git a/docs/classes/vec2.html b/docs/classes/vec2.html index 21908069..f5fd5c16 100644 --- a/docs/classes/vec2.html +++ b/docs/classes/vec2.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,574 +25,344 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    vec2 Class

    +

    vec2 Class

    - - -
    Defined in: src/math/vec2.js:23
    - - -
    -

    The vec2 object from glMatrix, with some extensions and some removed methods. See http://glmatrix.net.

    -

    Item Index

    -

    Methods

    - - - -
    -

    Methods

    - -
    +

    add

    -
    (
      -
    • - out -
    • -
    • - a -
    • -
    • - b -
    • -
    )
    - - Array - - - - - static - - -
    - - -

    - Defined in - - - - src/math/vec2.js:227 -

    - -
    @@ -602,158 +370,97 @@

    add

    -

    Parameters:

      -
    • - out Array - -

      the receiving vector

      -
    • -
    • - a Array - -

      the first operand

      -
    • -
    • - b Array - -

      the second operand

      -
    • -
    - -

    Returns:

    - - Array: -

    out

    -
    - - -
    - -
    +
    +

    centroid

    -
    (
      -
    • - out -
    • -
    • - a -
    • -
    • - b -
    • -
    • - c -
    • -
    )
    - - Array - - - - - static - - -
    - - -

    - Defined in - - - - src/math/vec2.js:139 -

    - -
    @@ -761,152 +468,95 @@

    centroid

    -

    Parameters:

      -
    • - out Array - -
      -
    • -
    • - a Array - -
      -
    • -
    • - b Array - -
      -
    • -
    • - c Array - -
      -
    • -
    - -

    Returns:

    - - Array: -

    The out object

    -
    - - -
    - -
    +
    +

    clone

    -
    (
      -
    • - a -
    • -
    )
    - - Array - - - - - static - - -
    - - -

    - Defined in - - - - src/math/vec2.js:169 -

    - -
    @@ -914,114 +564,69 @@

    clone

    -

    Parameters:

      -
    • - a Array - -

      vector to clone

      -
    • -
    - -

    Returns:

    - - Array: -

    a new 2D vector

    -
    - - -
    - -
    +
    +

    copy

    -
    (
      -
    • - out -
    • -
    • - a -
    • -
    )
    - - Array - - - - - static - - -
    - - -

    - Defined in - - - - src/math/vec2.js:198 -

    - -
    @@ -1029,114 +634,71 @@

    copy

    -

    Parameters:

      -
    • - out Array - -

      the receiving vector

      -
    • -
    • - a Array - -

      the source vector

      -
    • -
    - -

    Returns:

    - - Array: -

    out

    -
    - - -
    - -
    +
    +

    create

    - () - - Array - - - - - static - - -
    - - -

    - Defined in - - - - src/math/vec2.js:156 -

    - -
    @@ -1144,90 +706,52 @@

    create

    - -

    Returns:

    - - Array: -

    a new 2D vector

    -
    - - -
    - -
    +
    +

    crossLength

    -
    (
      -
    • - a -
    • -
    • - b -
    • -
    )
    - - Number - - - - - static - - -
    - - -

    - Defined in - - - - src/math/vec2.js:32 -

    - -
    @@ -1235,132 +759,79 @@

    crossLength

    -

    Parameters:

      -
    • - a Array - -
      -
    • -
    • - b Array - -
      -
    • -
    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    crossVZ

    -
    (
      -
    • - out -
    • -
    • - vec -
    • -
    • - zcomp -
    • -
    )
    - - Number - - - - - static - - -
    - - -

    - Defined in - - - - src/math/vec2.js:44 -

    - -
    @@ -1368,147 +839,89 @@

    crossVZ

    -

    Parameters:

      -
    • - out Array - -
      -
    • -
    • - vec Array - -
      -
    • -
    • - zcomp Number - -
      -
    • -
    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    crossZV

    -
    (
      -
    • - out -
    • -
    • - zcomp -
    • -
    • - vec -
    • -
    )
    - - Number - - - - - static - - -
    - - -

    - Defined in - - - - src/math/vec2.js:59 -

    - -
    @@ -1516,121 +929,74 @@

    crossZV

    -

    Parameters:

      -
    • - out Array - -
      -
    • -
    • - zcomp Number - -
      -
    • -
    • - vec Array - -
      -
    • -
    - -

    Returns:

    - - Number: - -
    - - -
    - -
    +
    +

    dist

    - () - - - - - - static - - -
    - - -

    - Defined in - - - - src/math/vec2.js:337 -

    - -
    @@ -1638,76 +1004,43 @@

    dist

    - - - -
    - -
    +
    +

    distance

    -
    (
      -
    • - a -
    • -
    • - b -
    • -
    )
    - - Number - - - - - static - - -
    - - -

    - Defined in - - - - src/math/vec2.js:323 -

    - -
    @@ -1715,110 +1048,68 @@

    distance

    -

    Parameters:

      -
    • - a Array - -

      the first operand

      -
    • -
    • - b Array - -

      the second operand

      -
    • -
    - -

    Returns:

    - - Number: -

    distance between a and b

    -
    - - -
    - -
    +
    +

    div

    - () - - - - - - static - - -
    - - -

    - Defined in - - - - src/math/vec2.js:301 -

    - -
    @@ -1826,82 +1117,46 @@

    div

    - - - -
    - -
    +
    +

    divide

    -
    (
      -
    • - out -
    • -
    • - a -
    • -
    • - b -
    • -
    )
    - - Array - - - - - static - - -
    - - -

    - Defined in - - - - src/math/vec2.js:286 -

    - -
    @@ -1909,146 +1164,91 @@

    divide

    -

    Parameters:

      -
    • - out Array - -

      the receiving vector

      -
    • -
    • - a Array - -

      the first operand

      -
    • -
    • - b Array - -

      the second operand

      -
    • -
    - -

    Returns:

    - - Array: -

    out

    -
    - - -
    - -
    +
    +

    dot

    -
    (
      -
    • - a -
    • -
    • - b -
    • -
    )
    - - Number - - - - - static - - -
    - - -

    - Defined in - - - - src/math/vec2.js:440 -

    - -
    @@ -2056,130 +1256,80 @@

    dot

    -

    Parameters:

      -
    • - a Array - -

      the first operand

      -
    • -
    • - b Array - -

      the second operand

      -
    • -
    - -

    Returns:

    - - Number: -

    dot product of a and b

    -
    - - -
    - -
    +
    +

    fromValues

    -
    (
      -
    • - x -
    • -
    • - y -
    • -
    )
    - - Array - - - - - static - - -
    - - -

    - Defined in - - - - src/math/vec2.js:183 -

    - -
    @@ -2187,110 +1337,68 @@

    fromValues

    -

    Parameters:

      -
    • - x Number - -

      X component

      -
    • -
    • - y Number - -

      Y component

      -
    • -
    - -

    Returns:

    - - Array: -

    a new 2D vector

    -
    - - -
    - -
    +
    +

    len

    - () - - - - - - static - - -
    - - -

    - Defined in - - - - src/math/vec2.js:378 -

    - -
    @@ -2298,70 +1406,40 @@

    len

    - - - -
    - -
    +
    +

    length

    -
    (
      -
    • - a -
    • -
    )
    - - Number - - - - - static - - -
    - - -

    - Defined in - - - - src/math/vec2.js:365 -

    - -
    @@ -2369,94 +1447,57 @@

    length

    -

    Parameters:

      -
    • - a Array - -

      vector to calculate length of

      -
    • -
    - -

    Returns:

    - - Number: -

    length of a

    -
    - - -
    - -
    +
    +

    mul

    - () - - - - - - static - - -
    - - -

    - Defined in - - - - src/math/vec2.js:279 -

    - -
    @@ -2464,82 +1505,46 @@

    mul

    - - - -
    - -
    +
    +

    multiply

    -
    (
      -
    • - out -
    • -
    • - a -
    • -
    • - b -
    • -
    )
    - - Array - - - - - static - - -
    - - -

    - Defined in - - - - src/math/vec2.js:264 -

    - -
    @@ -2547,146 +1552,91 @@

    multiply

    -

    Parameters:

      -
    • - out Array - -

      the receiving vector

      -
    • -
    • - a Array - -

      the first operand

      -
    • -
    • - b Array - -

      the second operand

      -
    • -
    - -

    Returns:

    - - Array: -

    out

    -
    - - -
    - -
    +
    +

    negate

    -
    (
      -
    • - out -
    • -
    • - a -
    • -
    )
    - - Array - - - - - static - - -
    - - -

    - Defined in - - - - src/math/vec2.js:405 -

    - -
    @@ -2694,130 +1644,80 @@

    negate

    -

    Parameters:

      -
    • - out Array - -

      the receiving vector

      -
    • -
    • - a Array - -

      vector to negate

      -
    • -
    - -

    Returns:

    - - Array: -

    out

    -
    - - -
    - -
    +
    +

    normalize

    -
    (
      -
    • - out -
    • -
    • - a -
    • -
    )
    - - Array - - - - - static - - -
    - - -

    - Defined in - - - - src/math/vec2.js:419 -

    - -
    @@ -2825,132 +1725,80 @@

    normalize

    -

    Parameters:

      -
    • - out Array - -

      the receiving vector

      -
    • -
    • - a Array - -

      vector to normalize

      -
    • -
    - -

    Returns:

    - - Array: -

    out

    -
    - - -
    - -
    +
    +

    rotate

    -
    (
      -
    • - out -
    • -
    • - a -
    • -
    • - angle -
    • -
    )
    - - - - - - static - - -
    - - -

    - Defined in - - - - src/math/vec2.js:74 -

    - -
    @@ -2958,131 +1806,79 @@

    rotate

    -

    Parameters:

      -
    • - out Array - -
      -
    • -
    • - a Array - -
      -
    • -
    • - angle Number - -
      -
    • -
    - - - -
    - -
    +
    +

    rotate90cw

    -
    (
      -
    • - out -
    • -
    • - a -
    • -
    • - angle -
    • -
    )
    - - - - - - static - - -
    - - -

    - Defined in - - - - src/math/vec2.js:96 -

    - -
    @@ -3090,135 +1886,82 @@

    rotate90cw

    -

    Parameters:

      -
    • - out Array - -
      -
    • -
    • - a Array - -
      -
    • -
    • - angle Number - -
      -
    • -
    - - - -
    - -
    +
    +

    scale

    -
    (
      -
    • - out -
    • -
    • - a -
    • -
    • - b -
    • -
    )
    - - Array - - - - - static - - -
    - - -

    - Defined in - - - - src/math/vec2.js:308 -

    - -
    @@ -3226,152 +1969,94 @@

    scale

    -

    Parameters:

      -
    • - out Array - -

      the receiving vector

      -
    • -
    • - a Array - -

      the vector to scale

      -
    • -
    • - b Number - -

      amount to scale the vector by

      -
    • -
    - -

    Returns:

    - - Array: -

    out

    -
    - - -
    - -
    +
    +

    set

    -
    (
      -
    • - out -
    • -
    • - x -
    • -
    • - y -
    • -
    )
    - - Array - - - - - static - - -
    - - -

    - Defined in - - - - src/math/vec2.js:212 -

    - -
    @@ -3379,126 +2064,79 @@

    set

    -

    Parameters:

      -
    • - out Array - -

      the receiving vector

      -
    • -
    • - x Number - -

      X component

      -
    • -
    • - y Number - -

      Y component

      -
    • -
    - -

    Returns:

    - - Array: -

    out

    -
    - - -
    - -
    +
    +

    sqrDist

    - () - - - - - - static - - -
    - - -

    - Defined in - - - - src/math/vec2.js:358 -

    - -
    @@ -3506,56 +2144,31 @@

    sqrDist

    - - - -
    - -
    +
    +

    sqrLen

    - () - - - - - - static - - -
    - - -

    - Defined in - - - - src/math/vec2.js:398 -

    - -
    @@ -3563,76 +2176,43 @@

    sqrLen

    - - - -
    - -
    +
    +

    squaredDistance

    -
    (
      -
    • - a -
    • -
    • - b -
    • -
    )
    - - Number - - - - - static - - -
    - - -

    - Defined in - - - - src/math/vec2.js:344 -

    - -
    @@ -3640,124 +2220,77 @@

    squaredDistance

    -

    Parameters:

      -
    • - a Array - -

      the first operand

      -
    • -
    • - b Array - -

      the second operand

      -
    • -
    - -

    Returns:

    - - Number: -

    squared distance between a and b

    -
    - - -
    - -
    +
    +

    squaredLength

    -
    (
      -
    • - a -
    • -
    )
    - - Number - - - - - static - - -
    - - -

    - Defined in - - - - src/math/vec2.js:385 -

    - -
    @@ -3765,108 +2298,66 @@

    squaredLength

    -

    Parameters:

      -
    • - a Array - -

      vector to calculate squared length of

      -
    • -
    - -

    Returns:

    - - Number: -

    squared length of a

    -
    - - -
    - -
    +
    +

    str

    -
    (
      -
    • - vec -
    • -
    )
    - - String - - - - - static - - -
    - - -

    - Defined in - - - - src/math/vec2.js:452 -

    - -
    @@ -3874,94 +2365,57 @@

    str

    -

    Parameters:

      -
    • - vec Array - -

      vector to represent as a string

      -
    • -
    - -

    Returns:

    - - String: -

    string representation of the vector

    -
    - - -
    - -
    +
    +

    sub

    - () - - - - - - static - - -
    - - -

    - Defined in - - - - src/math/vec2.js:257 -

    - -
    @@ -3969,82 +2423,46 @@

    sub

    - - - -
    - -
    +
    +

    subtract

    -
    (
      -
    • - out -
    • -
    • - a -
    • -
    • - b -
    • -
    )
    - - Array - - - - - static - - -
    - - -

    - Defined in - - - - src/math/vec2.js:242 -

    - -
    @@ -4052,152 +2470,93 @@

    subtract

    -

    Parameters:

      -
    • - out Array - -

      the receiving vector

      -
    • -
    • - a Array - -

      the first operand

      -
    • -
    • - b Array - -

      the second operand

      -
    • -
    - -

    Returns:

    - - Array: -

    out

    -
    - - -
    - -
    +
    +

    toGlobalFrame

    -
    (
      -
    • - out -
    • -
    • - localPoint -
    • -
    • - framePosition -
    • -
    • - frameAngle -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - src/math/vec2.js:125 -

    - -
    @@ -4205,150 +2564,91 @@

    toGlobalFrame

    -

    Parameters:

      -
    • - out Array - -
      -
    • -
    • - localPoint Array - -
      -
    • -
    • - framePosition Array - -
      -
    • -
    • - frameAngle Number - -
      -
    • -
    - - - -
    - -
    +
    +

    toLocalFrame

    -
    (
      -
    • - out -
    • -
    • - worldPoint -
    • -
    • - framePosition -
    • -
    • - frameAngle -
    • -
    )
    - - - - - - - -
    - - -

    - Defined in - - - - src/math/vec2.js:111 -

    - -
    @@ -4356,93 +2656,62 @@

    toLocalFrame

    -

    Parameters:

      -
    • - out Array - -
      -
    • -
    • - worldPoint Array - -
      -
    • -
    • - framePosition Array - -
      -
    • -
    • - frameAngle Number - -
      -
    • -
    - - - -
    - +
    - - - -
    -
    diff --git a/docs/data.json b/docs/data.json index fb795e02..c0a715fa 100644 --- a/docs/data.json +++ b/docs/data.json @@ -2,7 +2,7 @@ "project": { "name": "p2.js", "description": "A JavaScript 2D physics engine.", - "version": "0.6.0" + "version": "0.6.1" }, "files": { "src/collision/AABB.js": { @@ -50,6 +50,24 @@ "fors": {}, "namespaces": {} }, + "src/collision/Ray.js": { + "name": "src/collision/Ray.js", + "modules": {}, + "classes": { + "Ray": 1 + }, + "fors": {}, + "namespaces": {} + }, + "src/collision/RaycastResult.js": { + "name": "src/collision/RaycastResult.js", + "modules": {}, + "classes": { + "RaycastResult": 1 + }, + "fors": {}, + "namespaces": {} + }, "src/collision/SAPBroadphase.js": { "name": "src/collision/SAPBroadphase.js", "modules": {}, @@ -543,6 +561,32 @@ "description": "Narrowphase. Creates contacts and friction given shapes and transforms.", "is_constructor": 1 }, + "Ray": { + "name": "Ray", + "shortname": "Ray", + "classitems": [], + "plugins": [], + "extensions": [], + "plugin_for": [], + "extension_for": [], + "file": "src/collision/Ray.js", + "line": 8, + "description": "A line with a start and end point that is used to intersect shapes.", + "is_constructor": 1 + }, + "RaycastResult": { + "name": "RaycastResult", + "shortname": "RaycastResult", + "classitems": [], + "plugins": [], + "extensions": [], + "plugin_for": [], + "extension_for": [], + "file": "src/collision/RaycastResult.js", + "line": 5, + "description": "Storage for Ray casting data.", + "is_constructor": 1 + }, "SAPBroadphase": { "name": "SAPBroadphase", "shortname": "SAPBroadphase", @@ -640,14 +684,14 @@ "optional": true }, { - "name": "localAnchorA", - "description": "The anchor point for bodyA, defined locally in bodyA frame. Defaults to [0,0].", + "name": "localAnchorA] The anchor point for bodyA, defined locally in bodyA frame. Defaults to [0,0", + "description": ".", "type": "Array", "optional": true }, { - "name": "localAnchorB", - "description": "The anchor point for bodyB, defined locally in bodyB frame. Defaults to [0,0].", + "name": "localAnchorB] The anchor point for bodyB, defined locally in bodyB frame. Defaults to [0,0", + "description": ".", "type": "Array", "optional": true }, @@ -1321,12 +1365,26 @@ "type": "Number", "optional": true, "optdefault": "false" + }, + { + "name": "ccdSpeedThreshold", + "description": "", + "type": "Number", + "optional": true, + "optdefault": "-1" + }, + { + "name": "ccdIterations", + "description": "", + "type": "Number", + "optional": true, + "optdefault": "10" } ] } ], "example": [ - "\n // Create a typical dynamic body\n var body = new Body({\n mass: 1,\n position: [0, 0],\n angle: 0,\n velocity: [0, 0],\n angularVelocity: 0\n });\n\n // Add a circular shape to the body\n body.addShape(new Circle(1));\n\n // Add the body to the world\n world.addBody(body);" + "\n\n // Create a typical dynamic body\n var body = new Body({\n mass: 1,\n position: [0, 0],\n angle: 0,\n velocity: [0, 0],\n angularVelocity: 0\n });\n\n // Add a circular shape to the body\n body.addShape(new Circle(1));\n\n // Add the body to the world\n world.addBody(body);" ] }, "LinearSpring": { @@ -1550,14 +1608,19 @@ "name": "length", "description": "The distance between the end points", "type": "Number", - "optional": true + "optional": true, + "optdefault": "1" }, { "name": "radius", "description": "Radius of the capsule", "type": "Number", - "optional": true + "optional": true, + "optdefault": "1" } + ], + "example": [ + "\n var radius = 1;\n var length = 2;\n var capsuleShape = new Capsule(length, radius);\n body.addShape(capsuleShape);" ] }, "Circle": { @@ -1581,6 +1644,9 @@ "optional": true, "optdefault": "1" } + ], + "example": [ + "\n var radius = 1;\n var circleShape = new Circle(radius);\n body.addShape(circleShape);" ] }, "Convex": { @@ -1604,9 +1670,13 @@ }, { "name": "axes", - "description": "An array of unit length vectors", - "type": "Array" + "description": "An array of unit length vectors, representing the symmetry axes in the convex.", + "type": "Array", + "optional": true } + ], + "example": [ + "\n // Create a box\n var vertices = [[-1,-1], [1,-1], [1,1], [-1,1]];\n var convexShape = new Convex(vertices);\n body.addShape(convexShape);" ] }, "Heightfield": { @@ -1678,7 +1748,9 @@ { "name": "length", "description": "The total length of the line", - "type": "Number" + "type": "Number", + "optional": true, + "optdefault": "1" } ], "extends": "Shape", @@ -1728,12 +1800,16 @@ { "name": "width", "description": "Width", - "type": "Number" + "type": "Number", + "optional": true, + "optdefault": "1" }, { "name": "height", "description": "Height", - "type": "Number" + "type": "Number", + "optional": true, + "optdefault": "1" } ], "extends": "Convex" @@ -1947,7 +2023,7 @@ "plugin_for": [], "extension_for": [], "file": "src/world/World.js", - "line": 51, + "line": 52, "description": "The dynamics world, where all bodies and constraints lives.", "is_constructor": 1, "params": [ @@ -1964,8 +2040,8 @@ "optional": true }, { - "name": "gravity", - "description": "Defaults to [0,-9.78]", + "name": "gravity] Defaults to [0,-9.78", + "description": "", "type": "Array", "optional": true }, @@ -2213,7 +2289,7 @@ }, { "file": "src/collision/Broadphase.js", - "line": 103, + "line": 97, "description": "Check whether the bounding radius of two bodies overlap.", "itemtype": "method", "name": "boundingRadiusCheck", @@ -2237,7 +2313,7 @@ }, { "file": "src/collision/Broadphase.js", - "line": 126, + "line": 120, "description": "Check whether two bodies are allowed to collide at all.", "itemtype": "method", "name": "canCollide", @@ -2261,7 +2337,7 @@ }, { "file": "src/collision/GridBroadphase.js", - "line": 48, + "line": 49, "description": "Get collision pairs.", "itemtype": "method", "name": "getCollisionPairs", @@ -2280,7 +2356,7 @@ }, { "file": "src/collision/NaiveBroadphase.js", - "line": 22, + "line": 23, "description": "Get the colliding pairs", "itemtype": "method", "name": "getCollisionPairs", @@ -2297,6 +2373,35 @@ }, "class": "NaiveBroadphase" }, + { + "file": "src/collision/NaiveBroadphase.js", + "line": 50, + "description": "Returns all the bodies within an AABB.", + "itemtype": "method", + "name": "aabbQuery", + "params": [ + { + "name": "world", + "description": "", + "type": "World" + }, + { + "name": "aabb", + "description": "", + "type": "AABB" + }, + { + "name": "result", + "description": "An array to store resulting bodies in.", + "type": "Array" + } + ], + "return": { + "description": "", + "type": "Array" + }, + "class": "NaiveBroadphase" + }, { "file": "src/collision/Narrowphase.js", "line": 48, @@ -2325,6 +2430,15 @@ { "file": "src/collision/Narrowphase.js", "line": 67, + "description": "Whether to make equations enabled in upcoming contacts.", + "itemtype": "property", + "name": "enabledEquations", + "type": "{Boolean}", + "class": "Narrowphase" + }, + { + "file": "src/collision/Narrowphase.js", + "line": 74, "description": "The friction slip force to use when creating friction equations.", "itemtype": "property", "name": "slipForce", @@ -2333,7 +2447,7 @@ }, { "file": "src/collision/Narrowphase.js", - "line": 74, + "line": 81, "description": "The friction value to use in the upcoming friction equations.", "itemtype": "property", "name": "frictionCoefficient", @@ -2342,7 +2456,7 @@ }, { "file": "src/collision/Narrowphase.js", - "line": 81, + "line": 88, "description": "Will be the .relativeVelocity in each produced FrictionEquation.", "itemtype": "property", "name": "surfaceVelocity", @@ -2351,7 +2465,7 @@ }, { "file": "src/collision/Narrowphase.js", - "line": 91, + "line": 98, "description": "The restitution value to use in the next contact equations.", "itemtype": "property", "name": "restitution", @@ -2360,7 +2474,7 @@ }, { "file": "src/collision/Narrowphase.js", - "line": 98, + "line": 105, "description": "The stiffness value to use in the next contact equations.", "itemtype": "property", "name": "stiffness", @@ -2369,7 +2483,7 @@ }, { "file": "src/collision/Narrowphase.js", - "line": 104, + "line": 111, "description": "The stiffness value to use in the next contact equations.", "itemtype": "property", "name": "stiffness", @@ -2378,7 +2492,7 @@ }, { "file": "src/collision/Narrowphase.js", - "line": 110, + "line": 117, "description": "The stiffness value to use in the next friction equations.", "itemtype": "property", "name": "frictionStiffness", @@ -2387,7 +2501,7 @@ }, { "file": "src/collision/Narrowphase.js", - "line": 117, + "line": 124, "description": "The relaxation value to use in the next friction equations.", "itemtype": "property", "name": "frictionRelaxation", @@ -2396,7 +2510,7 @@ }, { "file": "src/collision/Narrowphase.js", - "line": 124, + "line": 131, "description": "Enable reduction of friction equations. If disabled, a box on a plane will generate 2 contact equations and 2 friction equations. If enabled, there will be only one friction equation. Same kind of simplifications are made for all collision types.", "itemtype": "property", "name": "enableFrictionReduction", @@ -2408,7 +2522,7 @@ }, { "file": "src/collision/Narrowphase.js", - "line": 133, + "line": 140, "description": "Keeps track of the colliding bodies last step.", "access": "private", "tagname": "", @@ -2419,17 +2533,40 @@ }, { "file": "src/collision/Narrowphase.js", - "line": 141, + "line": 148, "description": "Contact skin size value to use in the next contact equations.", "itemtype": "property", - "name": "collidingBodiesLastStep", + "name": "contactSkinSize", "type": "Number", "default": "0.01", "class": "Narrowphase" }, { "file": "src/collision/Narrowphase.js", - "line": 149, + "line": 159, + "itemtype": "method", + "name": "bodiesOverlap", + "params": [ + { + "name": "bodyA", + "description": "", + "type": "Body" + }, + { + "name": "bodyB", + "description": "", + "type": "Body" + } + ], + "return": { + "description": "", + "type": "Boolean" + }, + "class": "Narrowphase" + }, + { + "file": "src/collision/Narrowphase.js", + "line": 204, "description": "Check if the bodies were in contact since the last reset().", "itemtype": "method", "name": "collidedLastStep", @@ -2453,7 +2590,7 @@ }, { "file": "src/collision/Narrowphase.js", - "line": 162, + "line": 217, "description": "Throws away the old equations and gets ready to create new", "itemtype": "method", "name": "reset", @@ -2461,7 +2598,7 @@ }, { "file": "src/collision/Narrowphase.js", - "line": 191, + "line": 246, "description": "Creates a ContactEquation, either by reusing an existing object or creating a new one.", "itemtype": "method", "name": "createContactEquation", @@ -2485,7 +2622,7 @@ }, { "file": "src/collision/Narrowphase.js", - "line": 215, + "line": 270, "description": "Creates a FrictionEquation, either by reusing an existing object or creating a new one.", "itemtype": "method", "name": "createFrictionEquation", @@ -2509,7 +2646,7 @@ }, { "file": "src/collision/Narrowphase.js", - "line": 239, + "line": 294, "description": "Creates a FrictionEquation given the data in the ContactEquation. Uses same offset vectors ri and rj, but the tangent vector will be constructed from the collision normal.", "itemtype": "method", "name": "createFrictionFromContact", @@ -2528,7 +2665,7 @@ }, { "file": "src/collision/Narrowphase.js", - "line": 288, + "line": 340, "description": "Convex/line narrowphase", "itemtype": "method", "name": "convexLine", @@ -2586,7 +2723,7 @@ }, { "file": "src/collision/Narrowphase.js", - "line": 322, + "line": 374, "description": "Line/rectangle narrowphase", "itemtype": "method", "name": "lineRectangle", @@ -2644,7 +2781,7 @@ }, { "file": "src/collision/Narrowphase.js", - "line": 366, + "line": 418, "description": "Convex/capsule narrowphase", "itemtype": "method", "name": "convexCapsule", @@ -2694,7 +2831,7 @@ }, { "file": "src/collision/Narrowphase.js", - "line": 417, + "line": 469, "description": "Capsule/line narrowphase", "itemtype": "method", "name": "lineCapsule", @@ -2747,7 +2884,7 @@ }, { "file": "src/collision/Narrowphase.js", - "line": 454, + "line": 506, "description": "Capsule/capsule narrowphase", "itemtype": "method", "name": "capsuleCapsule", @@ -2797,7 +2934,7 @@ }, { "file": "src/collision/Narrowphase.js", - "line": 559, + "line": 611, "description": "Line/line narrowphase", "itemtype": "method", "name": "lineLine", @@ -2850,7 +2987,7 @@ }, { "file": "src/collision/Narrowphase.js", - "line": 592, + "line": 644, "description": "Plane/line Narrowphase", "itemtype": "method", "name": "planeLine", @@ -2900,7 +3037,7 @@ }, { "file": "src/collision/Narrowphase.js", - "line": 714, + "line": 766, "description": "Circle/line Narrowphase", "itemtype": "method", "name": "circleLine", @@ -2965,7 +3102,7 @@ }, { "file": "src/collision/Narrowphase.js", - "line": 884, + "line": 936, "description": "Circle/capsule Narrowphase", "itemtype": "method", "name": "circleCapsule", @@ -3015,7 +3152,7 @@ }, { "file": "src/collision/Narrowphase.js", - "line": 901, + "line": 953, "description": "Circle/convex Narrowphase.", "itemtype": "method", "name": "circleConvex", @@ -3075,7 +3212,7 @@ }, { "file": "src/collision/Narrowphase.js", - "line": 1112, + "line": 1164, "description": "Particle/convex Narrowphase", "itemtype": "method", "name": "particleConvex", @@ -3135,7 +3272,7 @@ }, { "file": "src/collision/Narrowphase.js", - "line": 1242, + "line": 1294, "description": "Circle/circle Narrowphase", "itemtype": "method", "name": "circleCircle", @@ -3202,7 +3339,7 @@ }, { "file": "src/collision/Narrowphase.js", - "line": 1307, + "line": 1359, "description": "Plane/Convex Narrowphase", "itemtype": "method", "name": "planeConvex", @@ -3257,7 +3394,7 @@ }, { "file": "src/collision/Narrowphase.js", - "line": 1392, + "line": 1444, "description": "Narrowphase for particle vs plane", "itemtype": "method", "name": "particlePlane", @@ -3312,7 +3449,7 @@ }, { "file": "src/collision/Narrowphase.js", - "line": 1455, + "line": 1507, "description": "Circle/Particle Narrowphase", "itemtype": "method", "name": "circleParticle", @@ -3367,7 +3504,7 @@ }, { "file": "src/collision/Narrowphase.js", - "line": 1516, + "line": 1568, "itemtype": "method", "name": "planeCapsule", "params": [ @@ -3421,7 +3558,7 @@ }, { "file": "src/collision/Narrowphase.js", - "line": 1586, + "line": 1638, "description": "Creates ContactEquations and FrictionEquations for a collision.", "itemtype": "method", "name": "circlePlane", @@ -3466,7 +3603,7 @@ }, { "file": "src/collision/Narrowphase.js", - "line": 1656, + "line": 1708, "description": "Convex/convex Narrowphase.See this article for more info.", "itemtype": "method", "name": "convexConvex", @@ -3516,7 +3653,7 @@ }, { "file": "src/collision/Narrowphase.js", - "line": 1838, + "line": 1890, "description": "Project a Convex onto a world-oriented axis", "itemtype": "method", "name": "projectConvexOntoAxis", @@ -3552,7 +3689,7 @@ }, { "file": "src/collision/Narrowphase.js", - "line": 1890, + "line": 1942, "description": "Find a separating axis between the shapes, that maximizes the separating distance between them.", "itemtype": "method", "name": "findSeparatingAxis", @@ -3602,7 +3739,7 @@ }, { "file": "src/collision/Narrowphase.js", - "line": 2060, + "line": 2112, "description": "Get the edge that has a normal closest to an axis.", "itemtype": "method", "name": "getClosestEdge", @@ -3637,7 +3774,7 @@ }, { "file": "src/collision/Narrowphase.js", - "line": 2110, + "line": 2162, "itemtype": "method", "name": "circleHeightfield", "params": [ @@ -3681,7 +3818,7 @@ }, { "file": "src/collision/Narrowphase.js", - "line": 2287, + "line": 2341, "itemtype": "method", "name": "circleHeightfield", "params": [ @@ -3724,64 +3861,550 @@ "class": "Narrowphase" }, { - "file": "src/collision/SAPBroadphase.js", + "file": "src/collision/Ray.js", "line": 16, - "description": "List of bodies currently in the broadphase.", "itemtype": "property", - "name": "axisList", - "type": "{Array}", - "class": "SAPBroadphase" + "name": "from", + "type": "Array", + "class": "Ray" }, { - "file": "src/collision/SAPBroadphase.js", - "line": 23, - "description": "The world to search in.", + "file": "src/collision/Ray.js", + "line": 21, "itemtype": "property", - "name": "world", - "type": "{World}", - "class": "SAPBroadphase" + "name": "to", + "type": "Array", + "class": "Ray" }, { - "file": "src/collision/SAPBroadphase.js", - "line": 30, - "description": "The axis to sort along.", + "file": "src/collision/Ray.js", + "line": 26, + "access": "private", + "tagname": "", "itemtype": "property", - "name": "axisIndex", - "type": "{Number}", - "class": "SAPBroadphase" + "name": "_direction", + "type": "Array", + "class": "Ray" }, { - "file": "src/collision/SAPBroadphase.js", - "line": 53, - "description": "Change the world", + "file": "src/collision/Ray.js", + "line": 32, + "description": "The precision of the ray. Used when checking parallelity etc.", + "itemtype": "property", + "name": "precision", + "type": "Number", + "class": "Ray" + }, + { + "file": "src/collision/Ray.js", + "line": 38, + "description": "Set to true if you want the Ray to take .collisionResponse flags into account on bodies and shapes.", + "itemtype": "property", + "name": "checkCollisionResponse", + "type": "Boolean", + "class": "Ray" + }, + { + "file": "src/collision/Ray.js", + "line": 44, + "description": "If set to true, the ray skips any hits with normal.dot(rayDirection) < 0.", + "itemtype": "property", + "name": "skipBackfaces", + "type": "Boolean", + "class": "Ray" + }, + { + "file": "src/collision/Ray.js", + "line": 50, + "itemtype": "property", + "name": "collisionMask", + "type": "Number", + "default": "-1", + "class": "Ray" + }, + { + "file": "src/collision/Ray.js", + "line": 56, + "itemtype": "property", + "name": "collisionGroup", + "type": "Number", + "default": "-1", + "class": "Ray" + }, + { + "file": "src/collision/Ray.js", + "line": 62, + "description": "The intersection mode. Should be Ray.ANY, Ray.ALL or Ray.CLOSEST.", + "itemtype": "property", + "name": "mode", + "type": "Number", + "class": "Ray" + }, + { + "file": "src/collision/Ray.js", + "line": 68, + "description": "Current result object.", + "itemtype": "property", + "name": "result", + "type": "RaycastResult", + "class": "Ray" + }, + { + "file": "src/collision/Ray.js", + "line": 74, + "description": "Will be set to true during intersectWorld() if the ray hit anything.", + "itemtype": "property", + "name": "hasHit", + "type": "Boolean", + "class": "Ray" + }, + { + "file": "src/collision/Ray.js", + "line": 80, + "description": "Current, user-provided result callback. Will be used if mode is Ray.ALL.", + "itemtype": "property", + "name": "callback", + "type": "Function", + "class": "Ray" + }, + { + "file": "src/collision/Ray.js", + "line": 95, + "description": "Do itersection against all bodies in the given World.", "itemtype": "method", - "name": "setWorld", + "name": "intersectWorld", "params": [ { "name": "world", "description": "", "type": "World" + }, + { + "name": "options", + "description": "", + "type": "Object" } ], - "class": "SAPBroadphase" + "return": { + "description": "True if the ray hit anything, otherwise false.", + "type": "Boolean" + }, + "class": "Ray" }, { - "file": "src/collision/SAPBroadphase.js", - "line": 76, - "description": "Sorts bodies along an axis.", + "file": "src/collision/Ray.js", + "line": 133, + "description": "Shoot a ray at a body, get back information about the hit.", "itemtype": "method", - "name": "sortAxisList", + "name": "intersectBody", + "access": "private", + "tagname": "", "params": [ { - "name": "a", + "name": "body", "description": "", - "type": "Array" + "type": "Body" }, { - "name": "axisIndex", - "description": "", - "type": "Number" - } + "name": "result", + "description": "Deprecated - set the result property of the Ray instead.", + "type": "RaycastResult", + "optional": true + } + ], + "class": "Ray" + }, + { + "file": "src/collision/Ray.js", + "line": 184, + "itemtype": "method", + "name": "intersectBodies", + "params": [ + { + "name": "bodies", + "description": "An array of Body objects.", + "type": "Array" + }, + { + "name": "result", + "description": "Deprecated", + "type": "RaycastResult", + "optional": true + } + ], + "class": "Ray" + }, + { + "file": "src/collision/Ray.js", + "line": 200, + "description": "Updates the _direction vector.", + "access": "private", + "tagname": "", + "itemtype": "method", + "name": "_updateDirection", + "class": "Ray" + }, + { + "file": "src/collision/Ray.js", + "line": 211, + "itemtype": "method", + "name": "intersectShape", + "access": "private", + "tagname": "", + "params": [ + { + "name": "shape", + "description": "", + "type": "Shape" + }, + { + "name": "angle", + "description": "", + "type": "Number" + }, + { + "name": "position", + "description": "", + "type": "Array" + }, + { + "name": "body", + "description": "", + "type": "Body" + } + ], + "class": "Ray" + }, + { + "file": "src/collision/Ray.js", + "line": 253, + "itemtype": "method", + "name": "intersectRectangle", + "access": "private", + "tagname": "", + "params": [ + { + "name": "shape", + "description": "", + "type": "Shape" + }, + { + "name": "angle", + "description": "", + "type": "Number" + }, + { + "name": "position", + "description": "", + "type": "Array" + }, + { + "name": "body", + "description": "", + "type": "Body" + } + ], + "class": "Ray" + }, + { + "file": "src/collision/Ray.js", + "line": 352, + "itemtype": "method", + "name": "intersectPlane", + "access": "private", + "tagname": "", + "params": [ + { + "name": "shape", + "description": "", + "type": "Shape" + }, + { + "name": "angle", + "description": "", + "type": "Number" + }, + { + "name": "position", + "description": "", + "type": "Array" + }, + { + "name": "body", + "description": "", + "type": "Body" + } + ], + "class": "Ray" + }, + { + "file": "src/collision/Ray.js", + "line": 459, + "description": "Get the AABB of the ray.", + "itemtype": "method", + "name": "getAABB", + "params": [ + { + "name": "aabb", + "description": "", + "type": "AABB" + } + ], + "class": "Ray" + }, + { + "file": "src/collision/Ray.js", + "line": 473, + "itemtype": "method", + "name": "reportIntersection", + "access": "private", + "tagname": "", + "params": [ + { + "name": "normal", + "description": "", + "type": "Array" + }, + { + "name": "hitPointWorld", + "description": "", + "type": "Array" + }, + { + "name": "shape", + "description": "", + "type": "Shape" + }, + { + "name": "body", + "description": "", + "type": "Body" + } + ], + "return": { + "description": "True if the intersections should continue", + "type": "Boolean" + }, + "class": "Ray" + }, + { + "file": "src/collision/RaycastResult.js", + "line": 12, + "itemtype": "property", + "name": "rayFromWorld", + "type": "Array", + "class": "RaycastResult" + }, + { + "file": "src/collision/RaycastResult.js", + "line": 17, + "itemtype": "property", + "name": "rayToWorld", + "type": "Array", + "class": "RaycastResult" + }, + { + "file": "src/collision/RaycastResult.js", + "line": 22, + "itemtype": "property", + "name": "hitNormalWorld", + "type": "Array", + "class": "RaycastResult" + }, + { + "file": "src/collision/RaycastResult.js", + "line": 27, + "itemtype": "property", + "name": "hitPointWorld", + "type": "Array", + "class": "RaycastResult" + }, + { + "file": "src/collision/RaycastResult.js", + "line": 32, + "itemtype": "property", + "name": "hasHit", + "type": "Boolean", + "class": "RaycastResult" + }, + { + "file": "src/collision/RaycastResult.js", + "line": 37, + "description": "The hit shape, or null.", + "itemtype": "property", + "name": "shape", + "type": "Shape", + "class": "RaycastResult" + }, + { + "file": "src/collision/RaycastResult.js", + "line": 43, + "description": "The hit body, or null.", + "itemtype": "property", + "name": "body", + "type": "Body", + "class": "RaycastResult" + }, + { + "file": "src/collision/RaycastResult.js", + "line": 49, + "description": "The index of the hit triangle, if the hit shape was a trimesh.", + "itemtype": "property", + "name": "hitFaceIndex", + "type": "Number", + "default": "-1", + "class": "RaycastResult" + }, + { + "file": "src/collision/RaycastResult.js", + "line": 56, + "description": "Distance to the hit. Will be set to -1 if there was no hit.", + "itemtype": "property", + "name": "distance", + "type": "Number", + "default": "-1", + "class": "RaycastResult" + }, + { + "file": "src/collision/RaycastResult.js", + "line": 63, + "description": "If the ray should stop traversing the bodies.", + "access": "private", + "tagname": "", + "itemtype": "property", + "name": "_shouldStop", + "type": "Boolean", + "default": "false", + "class": "RaycastResult" + }, + { + "file": "src/collision/RaycastResult.js", + "line": 72, + "description": "Reset all result data.", + "itemtype": "method", + "name": "reset", + "class": "RaycastResult" + }, + { + "file": "src/collision/RaycastResult.js", + "line": 89, + "itemtype": "method", + "name": "abort", + "class": "RaycastResult" + }, + { + "file": "src/collision/RaycastResult.js", + "line": 96, + "itemtype": "method", + "name": "set", + "params": [ + { + "name": "rayFromWorld", + "description": "", + "type": "Array" + }, + { + "name": "rayToWorld", + "description": "", + "type": "Array" + }, + { + "name": "hitNormalWorld", + "description": "", + "type": "Array" + }, + { + "name": "hitPointWorld", + "description": "", + "type": "Array" + }, + { + "name": "shape", + "description": "", + "type": "Shape" + }, + { + "name": "body", + "description": "", + "type": "Body" + }, + { + "name": "distance", + "description": "", + "type": "Number" + } + ], + "class": "RaycastResult" + }, + { + "file": "src/collision/SAPBroadphase.js", + "line": 16, + "description": "List of bodies currently in the broadphase.", + "itemtype": "property", + "name": "axisList", + "type": "{Array}", + "class": "SAPBroadphase" + }, + { + "file": "src/collision/SAPBroadphase.js", + "line": 23, + "description": "The axis to sort along. 0 means x-axis and 1 y-axis. If your bodies are more spread out over the X axis, set axisIndex to 0, and you will gain some performance.", + "itemtype": "property", + "name": "axisIndex", + "type": "{Number}", + "class": "SAPBroadphase" + }, + { + "file": "src/collision/SAPBroadphase.js", + "line": 46, + "description": "Change the world", + "itemtype": "method", + "name": "setWorld", + "params": [ + { + "name": "world", + "description": "", + "type": "World" + } + ], + "class": "SAPBroadphase" + }, + { + "file": "src/collision/SAPBroadphase.js", + "line": 69, + "description": "Sorts bodies along an axis.", + "itemtype": "method", + "name": "sortAxisList", + "params": [ + { + "name": "a", + "description": "", + "type": "Array" + }, + { + "name": "axisIndex", + "description": "", + "type": "Number" + } + ], + "return": { + "description": "", + "type": "Array" + }, + "class": "SAPBroadphase" + }, + { + "file": "src/collision/SAPBroadphase.js", + "line": 99, + "description": "Get the colliding pairs", + "itemtype": "method", + "name": "getCollisionPairs", + "params": [ + { + "name": "world", + "description": "", + "type": "World" + } ], "return": { "description": "", @@ -3791,15 +4414,25 @@ }, { "file": "src/collision/SAPBroadphase.js", - "line": 98, - "description": "Get the colliding pairs", + "line": 146, + "description": "Returns all the bodies within an AABB.", "itemtype": "method", - "name": "getCollisionPairs", + "name": "aabbQuery", "params": [ { "name": "world", "description": "", "type": "World" + }, + { + "name": "aabb", + "description": "", + "type": "AABB" + }, + { + "name": "result", + "description": "An array to store resulting bodies in.", + "type": "Array" } ], "return": { @@ -3810,7 +4443,16 @@ }, { "file": "src/constraints/Constraint.js", - "line": 25, + "line": 19, + "description": "The type of constraint. May be one of Constraint.DISTANCE, Constraint.GEAR, Constraint.LOCK, Constraint.PRISMATIC or Constraint.REVOLUTE.", + "itemtype": "property", + "name": "type", + "type": "Number", + "class": "Constraint" + }, + { + "file": "src/constraints/Constraint.js", + "line": 30, "description": "Equations to be solved in this constraint", "itemtype": "property", "name": "equations", @@ -3819,7 +4461,7 @@ }, { "file": "src/constraints/Constraint.js", - "line": 33, + "line": 38, "description": "First body participating in the constraint.", "itemtype": "property", "name": "bodyA", @@ -3828,7 +4470,7 @@ }, { "file": "src/constraints/Constraint.js", - "line": 40, + "line": 45, "description": "Second body participating in the constraint.", "itemtype": "property", "name": "bodyB", @@ -3837,7 +4479,7 @@ }, { "file": "src/constraints/Constraint.js", - "line": 47, + "line": 52, "description": "Set to true if you want the connected bodies to collide.", "itemtype": "property", "name": "collideConnected", @@ -3847,7 +4489,7 @@ }, { "file": "src/constraints/Constraint.js", - "line": 66, + "line": 71, "description": "Updates the internal constraint parameters before solve.", "itemtype": "method", "name": "update", @@ -3855,7 +4497,52 @@ }, { "file": "src/constraints/Constraint.js", - "line": 80, + "line": 79, + "static": 1, + "itemtype": "property", + "name": "DISTANCE", + "type": "Number", + "class": "Constraint" + }, + { + "file": "src/constraints/Constraint.js", + "line": 85, + "static": 1, + "itemtype": "property", + "name": "GEAR", + "type": "Number", + "class": "Constraint" + }, + { + "file": "src/constraints/Constraint.js", + "line": 91, + "static": 1, + "itemtype": "property", + "name": "LOCK", + "type": "Number", + "class": "Constraint" + }, + { + "file": "src/constraints/Constraint.js", + "line": 97, + "static": 1, + "itemtype": "property", + "name": "PRISMATIC", + "type": "Number", + "class": "Constraint" + }, + { + "file": "src/constraints/Constraint.js", + "line": 103, + "static": 1, + "itemtype": "property", + "name": "REVOLUTE", + "type": "Number", + "class": "Constraint" + }, + { + "file": "src/constraints/Constraint.js", + "line": 109, "description": "Set stiffness for this constraint.", "itemtype": "method", "name": "setStiffness", @@ -3870,7 +4557,7 @@ }, { "file": "src/constraints/Constraint.js", - "line": 94, + "line": 123, "description": "Set relaxation for this constraint.", "itemtype": "method", "name": "setRelaxation", @@ -3966,7 +4653,7 @@ }, { "file": "src/constraints/DistanceConstraint.js", - "line": 176, + "line": 177, "description": "Update the constraint equations. Should be done if any of the bodies changed position, before solving.", "itemtype": "method", "name": "update", @@ -3974,7 +4661,7 @@ }, { "file": "src/constraints/DistanceConstraint.js", - "line": 245, + "line": 246, "description": "Set the max force to be used", "itemtype": "method", "name": "setMaxForce", @@ -3989,7 +4676,7 @@ }, { "file": "src/constraints/DistanceConstraint.js", - "line": 256, + "line": 257, "description": "Get the max force", "itemtype": "method", "name": "getMaxForce", @@ -4019,7 +4706,7 @@ }, { "file": "src/constraints/GearConstraint.js", - "line": 64, + "line": 65, "description": "Set the max torque for the constraint.", "itemtype": "method", "name": "setMaxTorque", @@ -4034,7 +4721,7 @@ }, { "file": "src/constraints/GearConstraint.js", - "line": 73, + "line": 74, "description": "Get the max torque for the constraint.", "itemtype": "method", "name": "getMaxTorque", @@ -4064,7 +4751,7 @@ }, { "file": "src/constraints/LockConstraint.js", - "line": 113, + "line": 114, "description": "Set the maximum force to be applied.", "itemtype": "method", "name": "setMaxForce", @@ -4079,7 +4766,7 @@ }, { "file": "src/constraints/LockConstraint.js", - "line": 126, + "line": 127, "description": "Get the max force.", "itemtype": "method", "name": "getMaxForce", @@ -4124,7 +4811,7 @@ }, { "file": "src/constraints/PrismaticConstraint.js", - "line": 123, + "line": 124, "description": "Set to true to enable lower limit.", "itemtype": "property", "name": "lowerLimitEnabled", @@ -4133,7 +4820,7 @@ }, { "file": "src/constraints/PrismaticConstraint.js", - "line": 130, + "line": 131, "description": "Set to true to enable upper limit.", "itemtype": "property", "name": "upperLimitEnabled", @@ -4142,7 +4829,7 @@ }, { "file": "src/constraints/PrismaticConstraint.js", - "line": 137, + "line": 138, "description": "Lower constraint limit. The constraint position is forced to be larger than this value.", "itemtype": "property", "name": "lowerLimit", @@ -4151,7 +4838,7 @@ }, { "file": "src/constraints/PrismaticConstraint.js", - "line": 144, + "line": 145, "description": "Upper constraint limit. The constraint position is forced to be smaller than this value.", "itemtype": "property", "name": "upperLimit", @@ -4160,7 +4847,7 @@ }, { "file": "src/constraints/PrismaticConstraint.js", - "line": 159, + "line": 160, "description": "Equation used for the motor.", "itemtype": "property", "name": "motorEquation", @@ -4169,7 +4856,7 @@ }, { "file": "src/constraints/PrismaticConstraint.js", - "line": 166, + "line": 167, "description": "The current motor state. Enable or disable the motor using .enableMotor", "itemtype": "property", "name": "motorEnabled", @@ -4178,7 +4865,7 @@ }, { "file": "src/constraints/PrismaticConstraint.js", - "line": 173, + "line": 174, "description": "Set the target speed for the motor.", "itemtype": "property", "name": "motorSpeed", @@ -4187,7 +4874,7 @@ }, { "file": "src/constraints/PrismaticConstraint.js", - "line": 205, + "line": 207, "description": "Update the constraint equations. Should be done if any of the bodies changed position, before solving.", "itemtype": "method", "name": "update", @@ -4195,7 +4882,7 @@ }, { "file": "src/constraints/PrismaticConstraint.js", - "line": 302, + "line": 304, "description": "Enable the motor", "itemtype": "method", "name": "enableMotor", @@ -4203,7 +4890,7 @@ }, { "file": "src/constraints/PrismaticConstraint.js", - "line": 314, + "line": 316, "description": "Disable the rotational motor", "itemtype": "method", "name": "disableMotor", @@ -4211,7 +4898,7 @@ }, { "file": "src/constraints/PrismaticConstraint.js", - "line": 327, + "line": 329, "description": "Set the constraint limits.", "itemtype": "method", "name": "setLimits", @@ -4303,7 +4990,7 @@ }, { "file": "src/constraints/RevoluteConstraint.js", - "line": 156, + "line": 157, "description": "Set the constraint angle limits.", "itemtype": "method", "name": "setLimits", @@ -4323,7 +5010,7 @@ }, { "file": "src/constraints/RevoluteConstraint.js", - "line": 266, + "line": 267, "description": "Enable the rotational motor", "itemtype": "method", "name": "enableMotor", @@ -4331,7 +5018,7 @@ }, { "file": "src/constraints/RevoluteConstraint.js", - "line": 278, + "line": 279, "description": "Disable the rotational motor", "itemtype": "method", "name": "disableMotor", @@ -4339,10 +5026,12 @@ }, { "file": "src/constraints/RevoluteConstraint.js", - "line": 291, + "line": 292, "description": "Check if the motor is enabled.", "itemtype": "method", "name": "motorIsEnabled", + "deprecated": true, + "deprecationMessage": "use property motorEnabled instead.", "return": { "description": "", "type": "Boolean" @@ -4351,7 +5040,7 @@ }, { "file": "src/constraints/RevoluteConstraint.js", - "line": 300, + "line": 302, "description": "Set the speed of the rotational constraint motor", "itemtype": "method", "name": "setMotorSpeed", @@ -4366,7 +5055,7 @@ }, { "file": "src/constraints/RevoluteConstraint.js", - "line": 313, + "line": 315, "description": "Get the speed of the rotational constraint motor", "itemtype": "method", "name": "getMotorSpeed", @@ -5786,7 +6475,7 @@ }, { "file": "src/objects/Body.js", - "line": 47, + "line": 50, "description": "The body identifyer", "itemtype": "property", "name": "id", @@ -5795,7 +6484,7 @@ }, { "file": "src/objects/Body.js", - "line": 54, + "line": 57, "description": "The world that this body is added to. This property is set to NULL if the body is not added to any world.", "itemtype": "property", "name": "world", @@ -5804,7 +6493,7 @@ }, { "file": "src/objects/Body.js", - "line": 61, + "line": 64, "description": "The shapes of the body. The local transform of the shape in .shapes[i] is\ndefined by .shapeOffsets[i] and .shapeAngles[i].", "itemtype": "property", "name": "shapes", @@ -5813,7 +6502,7 @@ }, { "file": "src/objects/Body.js", - "line": 70, + "line": 73, "description": "The local shape offsets, relative to the body center of mass. This is an\narray of Array.", "itemtype": "property", "name": "shapeOffsets", @@ -5822,7 +6511,7 @@ }, { "file": "src/objects/Body.js", - "line": 78, + "line": 81, "description": "The body-local shape angle transforms. This is an array of numbers (angles).", "itemtype": "property", "name": "shapeAngles", @@ -5831,7 +6520,7 @@ }, { "file": "src/objects/Body.js", - "line": 85, + "line": 88, "description": "The mass of the body.", "itemtype": "property", "name": "mass", @@ -5840,7 +6529,7 @@ }, { "file": "src/objects/Body.js", - "line": 92, + "line": 95, "description": "The inverse mass of the body.", "itemtype": "property", "name": "invMass", @@ -5849,7 +6538,7 @@ }, { "file": "src/objects/Body.js", - "line": 99, + "line": 102, "description": "The inertia of the body around the Z axis.", "itemtype": "property", "name": "inertia", @@ -5858,7 +6547,7 @@ }, { "file": "src/objects/Body.js", - "line": 106, + "line": 109, "description": "The inverse inertia of the body.", "itemtype": "property", "name": "invInertia", @@ -5867,7 +6556,7 @@ }, { "file": "src/objects/Body.js", - "line": 116, + "line": 119, "description": "Set to true if you want to fix the rotation of the body.", "itemtype": "property", "name": "fixedRotation", @@ -5876,7 +6565,7 @@ }, { "file": "src/objects/Body.js", - "line": 123, + "line": 126, "description": "The position of the body", "itemtype": "property", "name": "position", @@ -5885,7 +6574,7 @@ }, { "file": "src/objects/Body.js", - "line": 133, + "line": 136, "description": "The interpolated position of the body.", "itemtype": "property", "name": "interpolatedPosition", @@ -5894,7 +6583,7 @@ }, { "file": "src/objects/Body.js", - "line": 140, + "line": 143, "description": "The interpolated angle of the body.", "itemtype": "property", "name": "interpolatedAngle", @@ -5903,7 +6592,7 @@ }, { "file": "src/objects/Body.js", - "line": 147, + "line": 150, "description": "The previous position of the body.", "itemtype": "property", "name": "previousPosition", @@ -5912,7 +6601,7 @@ }, { "file": "src/objects/Body.js", - "line": 154, + "line": 157, "description": "The previous angle of the body.", "itemtype": "property", "name": "previousAngle", @@ -5921,7 +6610,7 @@ }, { "file": "src/objects/Body.js", - "line": 161, + "line": 164, "description": "The velocity of the body", "itemtype": "property", "name": "velocity", @@ -5930,7 +6619,7 @@ }, { "file": "src/objects/Body.js", - "line": 171, + "line": 174, "description": "Constraint velocity that was added to the body during the last step.", "itemtype": "property", "name": "vlambda", @@ -5939,7 +6628,7 @@ }, { "file": "src/objects/Body.js", - "line": 178, + "line": 181, "description": "Angular constraint velocity that was added to the body during last step.", "itemtype": "property", "name": "wlambda", @@ -5948,7 +6637,7 @@ }, { "file": "src/objects/Body.js", - "line": 185, + "line": 188, "description": "The angle of the body, in radians.", "itemtype": "property", "name": "angle", @@ -5960,7 +6649,7 @@ }, { "file": "src/objects/Body.js", - "line": 202, + "line": 205, "description": "The angular velocity of the body, in radians per second.", "itemtype": "property", "name": "angularVelocity", @@ -5969,7 +6658,7 @@ }, { "file": "src/objects/Body.js", - "line": 209, + "line": 212, "description": "The force acting on the body. Since the body force (and {{#crossLink \"Body/angularForce:property\"}}{{/crossLink}}) will be zeroed after each step, so you need to set the force before each step.", "itemtype": "property", "name": "force", @@ -5982,7 +6671,7 @@ }, { "file": "src/objects/Body.js", - "line": 233, + "line": 236, "description": "The angular force acting on the body. See {{#crossLink \"Body/force:property\"}}{{/crossLink}}.", "itemtype": "property", "name": "angularForce", @@ -5991,7 +6680,7 @@ }, { "file": "src/objects/Body.js", - "line": 240, + "line": 243, "description": "The linear damping acting on the body in the velocity direction. Should be a value between 0 and 1.", "itemtype": "property", "name": "damping", @@ -6001,7 +6690,7 @@ }, { "file": "src/objects/Body.js", - "line": 248, + "line": 251, "description": "The angular force acting on the body. Should be a value between 0 and 1.", "itemtype": "property", "name": "angularDamping", @@ -6011,7 +6700,7 @@ }, { "file": "src/objects/Body.js", - "line": 256, + "line": 259, "description": "The type of motion this body has. Should be one of: {{#crossLink \"Body/STATIC:property\"}}Body.STATIC{{/crossLink}}, {{#crossLink \"Body/DYNAMIC:property\"}}Body.DYNAMIC{{/crossLink}} and {{#crossLink \"Body/KINEMATIC:property\"}}Body.KINEMATIC{{/crossLink}}.\n\n* Static bodies do not move, and they do not respond to forces or collision.\n* Dynamic bodies body can move and respond to collisions and forces.\n* Kinematic bodies only moves according to its .velocity, and does not respond to collisions or force.", "itemtype": "property", "name": "type", @@ -6025,7 +6714,7 @@ }, { "file": "src/objects/Body.js", - "line": 295, + "line": 298, "description": "Bounding circle radius.", "itemtype": "property", "name": "boundingRadius", @@ -6034,7 +6723,7 @@ }, { "file": "src/objects/Body.js", - "line": 302, + "line": 305, "description": "Bounding box of this body.", "itemtype": "property", "name": "aabb", @@ -6043,7 +6732,7 @@ }, { "file": "src/objects/Body.js", - "line": 309, + "line": 312, "description": "Indicates if the AABB needs update. Update it with {{#crossLink \"Body/updateAABB:method\"}}.updateAABB(){{/crossLink}}.", "itemtype": "property", "name": "aabbNeedsUpdate", @@ -6058,7 +6747,7 @@ }, { "file": "src/objects/Body.js", - "line": 323, + "line": 326, "description": "If true, the body will automatically fall to sleep. Note that you need to enable sleeping in the {{#crossLink \"World\"}}{{/crossLink}} before anything will happen.", "itemtype": "property", "name": "allowSleep", @@ -6068,7 +6757,7 @@ }, { "file": "src/objects/Body.js", - "line": 333, + "line": 336, "description": "One of {{#crossLink \"Body/AWAKE:property\"}}Body.AWAKE{{/crossLink}}, {{#crossLink \"Body/SLEEPY:property\"}}Body.SLEEPY{{/crossLink}} and {{#crossLink \"Body/SLEEPING:property\"}}Body.SLEEPING{{/crossLink}}.\n\nThe body is initially Body.AWAKE. If its velocity norm is below .sleepSpeedLimit, the sleepState will become Body.SLEEPY. If the body continues to be Body.SLEEPY for .sleepTimeLimit seconds, it will fall asleep (Body.SLEEPY).", "itemtype": "property", "name": "sleepState", @@ -6078,7 +6767,7 @@ }, { "file": "src/objects/Body.js", - "line": 344, + "line": 347, "description": "If the speed (the norm of the velocity) is smaller than this value, the body is considered sleepy.", "itemtype": "property", "name": "sleepSpeedLimit", @@ -6088,7 +6777,7 @@ }, { "file": "src/objects/Body.js", - "line": 352, + "line": 355, "description": "If the body has been sleepy for this sleepTimeLimit seconds, it is considered sleeping.", "itemtype": "property", "name": "sleepTimeLimit", @@ -6098,7 +6787,7 @@ }, { "file": "src/objects/Body.js", - "line": 360, + "line": 363, "description": "Gravity scaling factor. If you want the body to ignore gravity, set this to zero. If you want to reverse gravity, set it to -1.", "itemtype": "property", "name": "gravityScale", @@ -6108,7 +6797,25 @@ }, { "file": "src/objects/Body.js", - "line": 367, + "line": 370, + "description": "Whether to produce contact forces when in contact with other bodies. Note that contacts will be generated, but they will be disabled. That means that this body will move through other bodies, but it will still trigger contact events, etc.", + "itemtype": "property", + "name": "collisionResponse", + "type": "Boolean", + "class": "Body" + }, + { + "file": "src/objects/Body.js", + "line": 376, + "description": "How long the body has been sleeping.", + "itemtype": "property", + "name": "idleTime", + "type": "Number", + "class": "Body" + }, + { + "file": "src/objects/Body.js", + "line": 382, "description": "The last time when the body went to SLEEPY state.", "itemtype": "property", "name": "timeLastSleepy", @@ -6119,7 +6826,27 @@ }, { "file": "src/objects/Body.js", - "line": 398, + "line": 389, + "description": "If the body speed exceeds this threshold, CCD (continuous collision detection) will be enabled. Set it to a negative number to disable CCD completely for this body.", + "itemtype": "property", + "name": "ccdSpeedThreshold", + "type": "Number", + "default": "-1", + "class": "Body" + }, + { + "file": "src/objects/Body.js", + "line": 396, + "description": "The number of iterations that should be used when searching for the time of impact during CCD. A larger number will assure that there's a small penetration on CCD collision, but a small number will give more performance.", + "itemtype": "property", + "name": "ccdIterations", + "type": "Number", + "default": "10", + "class": "Body" + }, + { + "file": "src/objects/Body.js", + "line": 424, "description": "Set the total density of the body", "itemtype": "method", "name": "setDensity", @@ -6127,7 +6854,7 @@ }, { "file": "src/objects/Body.js", - "line": 408, + "line": 434, "description": "Get the total area of all shapes in the body", "itemtype": "method", "name": "getArea", @@ -6139,7 +6866,7 @@ }, { "file": "src/objects/Body.js", - "line": 421, + "line": 447, "description": "Get the AABB from the body. The AABB is updated if necessary.", "itemtype": "method", "name": "getAABB", @@ -6147,7 +6874,7 @@ }, { "file": "src/objects/Body.js", - "line": 435, + "line": 461, "description": "Updates the AABB of the Body", "itemtype": "method", "name": "updateAABB", @@ -6155,7 +6882,7 @@ }, { "file": "src/objects/Body.js", - "line": 468, + "line": 494, "description": "Update the bounding radius of the body. Should be done if any of the shapes\nare changed.", "itemtype": "method", "name": "updateBoundingRadius", @@ -6163,7 +6890,7 @@ }, { "file": "src/objects/Body.js", - "line": 491, + "line": 517, "description": "Add a shape to the body. You can pass a local transform when adding a shape,\nso that the shape gets an offset and angle relative to the body center of mass.\nWill automatically update the mass properties and bounding radius.", "itemtype": "method", "name": "addShape", @@ -6193,7 +6920,7 @@ }, { "file": "src/objects/Body.js", - "line": 533, + "line": 559, "description": "Remove a shape", "itemtype": "method", "name": "removeShape", @@ -6212,7 +6939,7 @@ }, { "file": "src/objects/Body.js", - "line": 553, + "line": 579, "description": "Updates .inertia, .invMass, .invInertia for this Body. Should be called when\nchanging the structure or mass of the Body.", "itemtype": "method", "name": "updateMassProperties", @@ -6223,7 +6950,7 @@ }, { "file": "src/objects/Body.js", - "line": 600, + "line": 626, "description": "Apply force to a world point. This could for example be a point on the RigidBody surface. Applying force this way will add to Body.force and Body.angularForce.", "itemtype": "method", "name": "applyForce", @@ -6243,7 +6970,7 @@ }, { "file": "src/objects/Body.js", - "line": 621, + "line": 647, "description": "Transform a world point to local body frame.", "itemtype": "method", "name": "toLocalFrame", @@ -6263,7 +6990,7 @@ }, { "file": "src/objects/Body.js", - "line": 631, + "line": 657, "description": "Transform a local point to world frame.", "itemtype": "method", "name": "toWorldFrame", @@ -6283,7 +7010,7 @@ }, { "file": "src/objects/Body.js", - "line": 641, + "line": 667, "description": "Reads a polygon shape path, and assembles convex shapes from that and puts them at proper offset points.", "itemtype": "method", "name": "fromPolygon", @@ -6331,7 +7058,7 @@ }, { "file": "src/objects/Body.js", - "line": 726, + "line": 752, "description": "Moves the shape offsets so their center of mass becomes the body center of mass.", "itemtype": "method", "name": "adjustCenterOfMass", @@ -6339,7 +7066,7 @@ }, { "file": "src/objects/Body.js", - "line": 772, + "line": 798, "description": "Sets the force on the body to zero.", "itemtype": "method", "name": "setZeroForce", @@ -6347,7 +7074,7 @@ }, { "file": "src/objects/Body.js", - "line": 795, + "line": 821, "description": "Apply damping, see this for details.", "itemtype": "method", "name": "applyDamping", @@ -6362,7 +7089,7 @@ }, { "file": "src/objects/Body.js", - "line": 816, + "line": 834, "description": "Wake the body up. Normally you should not need this, as the body is automatically awoken at events such as collisions.\nSets the sleepState to {{#crossLink \"Body/AWAKE:property\"}}Body.AWAKE{{/crossLink}} and emits the wakeUp event if the body wasn't awake before.", "itemtype": "method", "name": "wakeUp", @@ -6370,7 +7097,7 @@ }, { "file": "src/objects/Body.js", - "line": 830, + "line": 848, "description": "Force body sleep", "itemtype": "method", "name": "sleep", @@ -6378,7 +7105,7 @@ }, { "file": "src/objects/Body.js", - "line": 843, + "line": 861, "description": "Called every timestep to update internal sleep timer and change sleep state if needed.", "itemtype": "method", "name": "sleepTick", @@ -6403,7 +7130,7 @@ }, { "file": "src/objects/Body.js", - "line": 903, + "line": 922, "description": "Check if the body is overlapping another body. Note that this method only works if the body was added to a World and if at least one step was taken.", "itemtype": "method", "name": "overlaps", @@ -6422,28 +7149,43 @@ }, { "file": "src/objects/Body.js", - "line": 913, + "line": 935, + "description": "Move the body forward in time given its current velocity.", + "itemtype": "method", + "name": "integrate", + "params": [ + { + "name": "dt", + "description": "", + "type": "Number" + } + ], + "class": "Body" + }, + { + "file": "src/objects/Body.js", + "line": 1056, "itemtype": "event", "name": "sleepy", "class": "Body" }, { "file": "src/objects/Body.js", - "line": 920, + "line": 1063, "itemtype": "event", "name": "sleep", "class": "Body" }, { "file": "src/objects/Body.js", - "line": 927, + "line": 1070, "itemtype": "event", "name": "wakeup", "class": "Body" }, { "file": "src/objects/Body.js", - "line": 934, + "line": 1077, "description": "Dynamic body.", "itemtype": "property", "name": "DYNAMIC", @@ -6453,7 +7195,7 @@ }, { "file": "src/objects/Body.js", - "line": 942, + "line": 1085, "description": "Static body.", "itemtype": "property", "name": "STATIC", @@ -6463,7 +7205,7 @@ }, { "file": "src/objects/Body.js", - "line": 950, + "line": 1093, "description": "Kinematic body.", "itemtype": "property", "name": "KINEMATIC", @@ -6473,7 +7215,7 @@ }, { "file": "src/objects/Body.js", - "line": 958, + "line": 1101, "itemtype": "property", "name": "AWAKE", "type": "{Number}", @@ -6482,7 +7224,7 @@ }, { "file": "src/objects/Body.js", - "line": 965, + "line": 1108, "itemtype": "property", "name": "SLEEPY", "type": "{Number}", @@ -6491,7 +7233,7 @@ }, { "file": "src/objects/Body.js", - "line": 972, + "line": 1115, "itemtype": "property", "name": "SLEEPING", "type": "{Number}", @@ -6527,7 +7269,7 @@ }, { "file": "src/objects/LinearSpring.js", - "line": 65, + "line": 66, "description": "Set the anchor point on body A, using world coordinates.", "itemtype": "method", "name": "setWorldAnchorA", @@ -6542,7 +7284,7 @@ }, { "file": "src/objects/LinearSpring.js", - "line": 74, + "line": 75, "description": "Set the anchor point on body B, using world coordinates.", "itemtype": "method", "name": "setWorldAnchorB", @@ -6557,7 +7299,7 @@ }, { "file": "src/objects/LinearSpring.js", - "line": 83, + "line": 84, "description": "Get the anchor point on body A, in world coordinates.", "itemtype": "method", "name": "getWorldAnchorA", @@ -6572,7 +7314,7 @@ }, { "file": "src/objects/LinearSpring.js", - "line": 92, + "line": 93, "description": "Get the anchor point on body B, in world coordinates.", "itemtype": "method", "name": "getWorldAnchorB", @@ -6587,7 +7329,7 @@ }, { "file": "src/objects/LinearSpring.js", - "line": 111, + "line": 112, "description": "Apply the spring force to the connected bodies.", "itemtype": "method", "name": "applyForce", @@ -6604,7 +7346,7 @@ }, { "file": "src/objects/RotationalSpring.js", - "line": 35, + "line": 36, "description": "Apply the spring force to the connected bodies.", "itemtype": "method", "name": "applyForce", @@ -6656,7 +7398,7 @@ }, { "file": "src/shapes/Capsule.js", - "line": 16, + "line": 21, "description": "The distance between the end points.", "itemtype": "property", "name": "length", @@ -6665,7 +7407,7 @@ }, { "file": "src/shapes/Capsule.js", - "line": 22, + "line": 27, "description": "The radius of the capsule.", "itemtype": "property", "name": "radius", @@ -6674,7 +7416,7 @@ }, { "file": "src/shapes/Capsule.js", - "line": 32, + "line": 38, "description": "Compute the mass moment of inertia of the Capsule.", "itemtype": "method", "name": "conputeMomentOfInertia", @@ -6696,21 +7438,21 @@ }, { "file": "src/shapes/Capsule.js", - "line": 47, + "line": 53, "itemtype": "method", "name": "updateBoundingRadius", "class": "Capsule" }, { "file": "src/shapes/Capsule.js", - "line": 54, + "line": 60, "itemtype": "method", "name": "updateArea", "class": "Capsule" }, { "file": "src/shapes/Capsule.js", - "line": 63, + "line": 69, "itemtype": "method", "name": "computeAABB", "params": [ @@ -6734,7 +7476,7 @@ }, { "file": "src/shapes/Circle.js", - "line": 15, + "line": 20, "description": "The radius of the circle.", "itemtype": "property", "name": "radius", @@ -6743,7 +7485,7 @@ }, { "file": "src/shapes/Circle.js", - "line": 26, + "line": 32, "itemtype": "method", "name": "computeMomentOfInertia", "params": [ @@ -6761,7 +7503,7 @@ }, { "file": "src/shapes/Circle.js", - "line": 36, + "line": 42, "itemtype": "method", "name": "updateBoundingRadius", "return": { @@ -6772,7 +7514,7 @@ }, { "file": "src/shapes/Circle.js", - "line": 44, + "line": 50, "itemtype": "method", "name": "updateArea", "return": { @@ -6783,7 +7525,7 @@ }, { "file": "src/shapes/Circle.js", - "line": 52, + "line": 58, "itemtype": "method", "name": "computeAABB", "params": [ @@ -6807,7 +7549,7 @@ }, { "file": "src/shapes/Convex.js", - "line": 18, + "line": 23, "description": "Vertices defined in the local frame.", "itemtype": "property", "name": "vertices", @@ -6816,7 +7558,7 @@ }, { "file": "src/shapes/Convex.js", - "line": 25, + "line": 30, "description": "Axes defined in the local frame.", "itemtype": "property", "name": "axes", @@ -6825,7 +7567,7 @@ }, { "file": "src/shapes/Convex.js", - "line": 64, + "line": 69, "description": "The center of mass of the Convex", "itemtype": "property", "name": "centerOfMass", @@ -6834,7 +7576,7 @@ }, { "file": "src/shapes/Convex.js", - "line": 71, + "line": 76, "description": "Triangulated version of this convex. The structure is Array of 3-Arrays, and each subarray contains 3 integers, referencing the vertices.", "itemtype": "property", "name": "triangles", @@ -6843,7 +7585,7 @@ }, { "file": "src/shapes/Convex.js", - "line": 83, + "line": 88, "description": "The bounding radius of the convex", "itemtype": "property", "name": "boundingRadius", @@ -6852,7 +7594,7 @@ }, { "file": "src/shapes/Convex.js", - "line": 103, + "line": 109, "description": "Project a Convex onto a world-oriented axis", "itemtype": "method", "name": "projectOntoAxis", @@ -6878,7 +7620,7 @@ }, { "file": "src/shapes/Convex.js", - "line": 156, + "line": 162, "description": "Update the .triangles property", "itemtype": "method", "name": "updateTriangles", @@ -6886,7 +7628,7 @@ }, { "file": "src/shapes/Convex.js", - "line": 195, + "line": 201, "description": "Update the .centerOfMass property.", "itemtype": "method", "name": "updateCenterOfMass", @@ -6894,7 +7636,7 @@ }, { "file": "src/shapes/Convex.js", - "line": 237, + "line": 243, "description": "Compute the mass moment of inertia of the Convex.", "itemtype": "method", "name": "computeMomentOfInertia", @@ -6916,7 +7658,7 @@ }, { "file": "src/shapes/Convex.js", - "line": 259, + "line": 265, "description": "Updates the .boundingRadius property", "itemtype": "method", "name": "updateBoundingRadius", @@ -6924,7 +7666,7 @@ }, { "file": "src/shapes/Convex.js", - "line": 277, + "line": 283, "description": "Get the area of the triangle spanned by the three points a, b, c. The area is positive if the points are given in counter-clockwise order, otherwise negative.", "static": 1, "itemtype": "method", @@ -6954,7 +7696,7 @@ }, { "file": "src/shapes/Convex.js", - "line": 290, + "line": 296, "description": "Update the .area", "itemtype": "method", "name": "updateArea", @@ -6962,7 +7704,7 @@ }, { "file": "src/shapes/Convex.js", - "line": 312, + "line": 318, "itemtype": "method", "name": "computeAABB", "params": [ @@ -7022,7 +7764,7 @@ }, { "file": "src/shapes/Heightfield.js", - "line": 84, + "line": 85, "itemtype": "method", "name": "computeMomentOfInertia", "params": [ @@ -7040,7 +7782,7 @@ }, { "file": "src/shapes/Heightfield.js", - "line": 106, + "line": 107, "itemtype": "method", "name": "computeAABB", "params": [ @@ -7073,7 +7815,7 @@ }, { "file": "src/shapes/Line.js", - "line": 35, + "line": 37, "itemtype": "method", "name": "computeAABB", "params": [ @@ -7097,7 +7839,7 @@ }, { "file": "src/shapes/Particle.js", - "line": 24, + "line": 26, "itemtype": "method", "name": "computeAABB", "params": [ @@ -7121,7 +7863,7 @@ }, { "file": "src/shapes/Plane.js", - "line": 18, + "line": 19, "description": "Compute moment of inertia", "itemtype": "method", "name": "computeMomentOfInertia", @@ -7129,7 +7871,7 @@ }, { "file": "src/shapes/Plane.js", - "line": 26, + "line": 27, "description": "Update the bounding radius", "itemtype": "method", "name": "updateBoundingRadius", @@ -7137,7 +7879,7 @@ }, { "file": "src/shapes/Plane.js", - "line": 34, + "line": 35, "itemtype": "method", "name": "computeAABB", "params": [ @@ -7179,7 +7921,7 @@ }, { "file": "src/shapes/Rectangle.js", - "line": 43, + "line": 44, "description": "Compute moment of inertia", "itemtype": "method", "name": "computeMomentOfInertia", @@ -7198,7 +7940,7 @@ }, { "file": "src/shapes/Rectangle.js", - "line": 55, + "line": 56, "description": "Update the bounding radius", "itemtype": "method", "name": "updateBoundingRadius", @@ -7206,7 +7948,7 @@ }, { "file": "src/shapes/Rectangle.js", - "line": 70, + "line": 71, "itemtype": "method", "name": "computeAABB", "params": [ @@ -7270,7 +8012,16 @@ }, { "file": "src/shapes/Shape.js", - "line": 72, + "line": 72, + "description": "Whether to produce contact forces when in contact with other bodies. Note that contacts will be generated, but they will be disabled. That means that this shape will move through other body shapes, but it will still trigger contact events, etc.", + "itemtype": "property", + "name": "collisionResponse", + "type": "Boolean", + "class": "Shape" + }, + { + "file": "src/shapes/Shape.js", + "line": 78, "description": "Collision mask of this shape. See .collisionGroup.", "itemtype": "property", "name": "collisionMask", @@ -7279,7 +8030,7 @@ }, { "file": "src/shapes/Shape.js", - "line": 82, + "line": 88, "description": "Material to use in collisions for this Shape. If this is set to null, the world will use default material properties instead.", "itemtype": "property", "name": "material", @@ -7288,7 +8039,7 @@ }, { "file": "src/shapes/Shape.js", - "line": 89, + "line": 95, "description": "Area of this shape.", "itemtype": "property", "name": "area", @@ -7297,7 +8048,7 @@ }, { "file": "src/shapes/Shape.js", - "line": 96, + "line": 102, "description": "Set to true if you want this shape to be a sensor. A sensor does not generate contacts, but it still reports contact events. This is good if you want to know if a shape is overlapping another shape, without them generating contacts.", "itemtype": "property", "name": "sensor", @@ -7306,7 +8057,7 @@ }, { "file": "src/shapes/Shape.js", - "line": 107, + "line": 113, "static": 1, "itemtype": "property", "name": "CIRCLE", @@ -7315,7 +8066,7 @@ }, { "file": "src/shapes/Shape.js", - "line": 113, + "line": 119, "static": 1, "itemtype": "property", "name": "PARTICLE", @@ -7324,7 +8075,7 @@ }, { "file": "src/shapes/Shape.js", - "line": 119, + "line": 125, "static": 1, "itemtype": "property", "name": "PLANE", @@ -7333,7 +8084,7 @@ }, { "file": "src/shapes/Shape.js", - "line": 125, + "line": 131, "static": 1, "itemtype": "property", "name": "CONVEX", @@ -7342,7 +8093,7 @@ }, { "file": "src/shapes/Shape.js", - "line": 131, + "line": 137, "static": 1, "itemtype": "property", "name": "LINE", @@ -7351,7 +8102,7 @@ }, { "file": "src/shapes/Shape.js", - "line": 137, + "line": 143, "static": 1, "itemtype": "property", "name": "RECTANGLE", @@ -7360,7 +8111,7 @@ }, { "file": "src/shapes/Shape.js", - "line": 143, + "line": 149, "static": 1, "itemtype": "property", "name": "CAPSULE", @@ -7369,7 +8120,7 @@ }, { "file": "src/shapes/Shape.js", - "line": 149, + "line": 155, "static": 1, "itemtype": "property", "name": "HEIGHTFIELD", @@ -7378,7 +8129,7 @@ }, { "file": "src/shapes/Shape.js", - "line": 155, + "line": 161, "description": "Should return the moment of inertia around the Z axis of the body given the total mass. See Wikipedia's list of moments of inertia.", "itemtype": "method", "name": "computeMomentOfInertia", @@ -7397,7 +8148,7 @@ }, { "file": "src/shapes/Shape.js", - "line": 165, + "line": 171, "description": "Returns the bounding circle radius of this shape.", "itemtype": "method", "name": "updateBoundingRadius", @@ -7409,7 +8160,7 @@ }, { "file": "src/shapes/Shape.js", - "line": 174, + "line": 180, "description": "Update the .area property of the shape.", "itemtype": "method", "name": "updateArea", @@ -7417,7 +8168,7 @@ }, { "file": "src/shapes/Shape.js", - "line": 182, + "line": 188, "description": "Compute the world axis-aligned bounding box (AABB) of this shape.", "itemtype": "method", "name": "computeAABB", @@ -7487,7 +8238,7 @@ }, { "file": "src/solver/GSSolver.js", - "line": 71, + "line": 72, "description": "Solve the system of equations", "itemtype": "method", "name": "solve", @@ -7525,7 +8276,7 @@ }, { "file": "src/solver/Solver.js", - "line": 36, + "line": 37, "description": "Method to be implemented in each subclass", "itemtype": "method", "name": "solve", @@ -7545,7 +8296,7 @@ }, { "file": "src/solver/Solver.js", - "line": 48, + "line": 49, "description": "Solves all constraints in an island.", "itemtype": "method", "name": "solveIsland", @@ -7565,7 +8316,7 @@ }, { "file": "src/solver/Solver.js", - "line": 71, + "line": 72, "description": "Sort all equations using the .equationSortFunction. Should be called by subclasses before solving.", "itemtype": "method", "name": "sortEquations", @@ -7573,7 +8324,7 @@ }, { "file": "src/solver/Solver.js", - "line": 81, + "line": 82, "description": "Add an equation to be solved.", "itemtype": "method", "name": "addEquation", @@ -7588,7 +8339,7 @@ }, { "file": "src/solver/Solver.js", - "line": 93, + "line": 94, "description": "Add equations. Same as .addEquation, but this time the argument is an array of Equations", "itemtype": "method", "name": "addEquations", @@ -7603,7 +8354,7 @@ }, { "file": "src/solver/Solver.js", - "line": 109, + "line": 110, "description": "Remove an equation.", "itemtype": "method", "name": "removeEquation", @@ -7618,7 +8369,7 @@ }, { "file": "src/solver/Solver.js", - "line": 122, + "line": 123, "description": "Remove all currently added equations.", "itemtype": "method", "name": "removeAllEquations", @@ -8215,7 +8966,7 @@ }, { "file": "src/world/World.js", - "line": 75, + "line": 76, "description": "All springs in the world. To add a spring to the world, use {{#crossLink \"World/addSpring:method\"}}{{/crossLink}}.", "itemtype": "property", "name": "springs", @@ -8224,7 +8975,7 @@ }, { "file": "src/world/World.js", - "line": 83, + "line": 84, "description": "All bodies in the world. To add a body to the world, use {{#crossLink \"World/addBody:method\"}}{{/crossLink}}.", "itemtype": "property", "name": "bodies", @@ -8233,7 +8984,7 @@ }, { "file": "src/world/World.js", - "line": 89, + "line": 90, "description": "Disabled body collision pairs. See {{#crossLink \"World/disableBodyCollision:method\"}}.", "access": "private", "tagname": "", @@ -8244,7 +8995,7 @@ }, { "file": "src/world/World.js", - "line": 96, + "line": 97, "description": "The solver used to satisfy constraints and contacts. Default is {{#crossLink \"GSSolver\"}}{{/crossLink}}.", "itemtype": "property", "name": "solver", @@ -8253,7 +9004,7 @@ }, { "file": "src/world/World.js", - "line": 102, + "line": 103, "description": "The narrowphase to use to generate contacts.", "itemtype": "property", "name": "narrowphase", @@ -8262,7 +9013,7 @@ }, { "file": "src/world/World.js", - "line": 110, + "line": 111, "description": "The island manager of this world.", "itemtype": "property", "name": "islandManager", @@ -8271,7 +9022,7 @@ }, { "file": "src/world/World.js", - "line": 116, + "line": 117, "description": "Gravity in the world. This is applied on all bodies in the beginning of each step().", "itemtype": "property", "name": "gravity", @@ -8280,7 +9031,7 @@ }, { "file": "src/world/World.js", - "line": 127, + "line": 128, "description": "Gravity to use when approximating the friction max force (mu*mass*gravity).", "itemtype": "property", "name": "frictionGravity", @@ -8289,7 +9040,7 @@ }, { "file": "src/world/World.js", - "line": 133, + "line": 134, "description": "Set to true if you want .frictionGravity to be automatically set to the length of .gravity.", "itemtype": "property", "name": "useWorldGravityAsFrictionGravity", @@ -8298,7 +9049,7 @@ }, { "file": "src/world/World.js", - "line": 139, + "line": 140, "description": "If the length of .gravity is zero, and .useWorldGravityAsFrictionGravity=true, then switch to using .frictionGravity for friction instead. This fallback is useful for gravityless games.", "itemtype": "property", "name": "useFrictionGravityOnZeroGravity", @@ -8307,7 +9058,7 @@ }, { "file": "src/world/World.js", - "line": 145, + "line": 146, "description": "Whether to do timing measurements during the step() or not.", "itemtype": "property", "name": "doPofiling", @@ -8316,7 +9067,7 @@ }, { "file": "src/world/World.js", - "line": 153, + "line": 154, "description": "How many millisecconds the last step() took. This is updated each step if .doProfiling is set to true.", "itemtype": "property", "name": "lastStepTime", @@ -8325,7 +9076,7 @@ }, { "file": "src/world/World.js", - "line": 161, + "line": 162, "description": "The broadphase algorithm to use.", "itemtype": "property", "name": "broadphase", @@ -8334,7 +9085,7 @@ }, { "file": "src/world/World.js", - "line": 170, + "line": 171, "description": "User-added constraints.", "itemtype": "property", "name": "constraints", @@ -8343,7 +9094,7 @@ }, { "file": "src/world/World.js", - "line": 178, + "line": 179, "description": "Dummy default material in the world, used in .defaultContactMaterial", "itemtype": "property", "name": "defaultMaterial", @@ -8352,7 +9103,7 @@ }, { "file": "src/world/World.js", - "line": 184, + "line": 185, "description": "The default contact material to use, if no contact material was set for the colliding materials.", "itemtype": "property", "name": "defaultContactMaterial", @@ -8361,7 +9112,7 @@ }, { "file": "src/world/World.js", - "line": 190, + "line": 191, "description": "For keeping track of what time step size we used last step", "itemtype": "property", "name": "lastTimeStep", @@ -8370,7 +9121,7 @@ }, { "file": "src/world/World.js", - "line": 197, + "line": 198, "description": "Enable to automatically apply spring forces each step.", "itemtype": "property", "name": "applySpringForces", @@ -8379,7 +9130,7 @@ }, { "file": "src/world/World.js", - "line": 204, + "line": 205, "description": "Enable to automatically apply body damping each step.", "itemtype": "property", "name": "applyDamping", @@ -8388,7 +9139,7 @@ }, { "file": "src/world/World.js", - "line": 211, + "line": 212, "description": "Enable to automatically apply gravity each step.", "itemtype": "property", "name": "applyGravity", @@ -8397,7 +9148,7 @@ }, { "file": "src/world/World.js", - "line": 218, + "line": 219, "description": "Enable/disable constraint solving in each step.", "itemtype": "property", "name": "solveConstraints", @@ -8406,7 +9157,7 @@ }, { "file": "src/world/World.js", - "line": 225, + "line": 226, "description": "The ContactMaterials added to the World.", "itemtype": "property", "name": "contactMaterials", @@ -8415,7 +9166,7 @@ }, { "file": "src/world/World.js", - "line": 232, + "line": 233, "description": "World time.", "itemtype": "property", "name": "time", @@ -8424,7 +9175,7 @@ }, { "file": "src/world/World.js", - "line": 239, + "line": 240, "description": "Is true during the step().", "itemtype": "property", "name": "stepping", @@ -8433,7 +9184,7 @@ }, { "file": "src/world/World.js", - "line": 245, + "line": 246, "description": "Bodies that are scheduled to be removed at the end of the step.", "itemtype": "property", "name": "bodiesToBeRemoved", @@ -8444,7 +9195,7 @@ }, { "file": "src/world/World.js", - "line": 254, + "line": 255, "description": "Whether to enable island splitting. Island splitting can be an advantage for many things, including solver performance. See {{#crossLink \"IslandManager\"}}{{/crossLink}}.", "itemtype": "property", "name": "islandSplit", @@ -8453,7 +9204,7 @@ }, { "file": "src/world/World.js", - "line": 260, + "line": 261, "description": "Set to true if you want to the world to emit the \"impact\" event. Turning this off could improve performance.", "itemtype": "property", "name": "emitImpactEvent", @@ -8462,7 +9213,7 @@ }, { "file": "src/world/World.js", - "line": 271, + "line": 272, "description": "Fired after the step().", "itemtype": "event", "name": "postStep", @@ -8470,7 +9221,7 @@ }, { "file": "src/world/World.js", - "line": 279, + "line": 280, "description": "Fired when a body is added to the world.", "itemtype": "event", "name": "addBody", @@ -8485,7 +9236,7 @@ }, { "file": "src/world/World.js", - "line": 289, + "line": 290, "description": "Fired when a body is removed from the world.", "itemtype": "event", "name": "removeBody", @@ -8500,7 +9251,7 @@ }, { "file": "src/world/World.js", - "line": 299, + "line": 300, "description": "Fired when a spring is added to the world.", "itemtype": "event", "name": "addSpring", @@ -8515,7 +9266,7 @@ }, { "file": "src/world/World.js", - "line": 309, + "line": 310, "description": "Fired when a first contact is created between two bodies. This event is fired after the step has been done.", "itemtype": "event", "name": "impact", @@ -8535,7 +9286,7 @@ }, { "file": "src/world/World.js", - "line": 324, + "line": 325, "description": "Fired after the Broadphase has collected collision pairs in the world.\nInside the event handler, you can modify the pairs array as you like, to\nprevent collisions between objects that you don't want.", "itemtype": "event", "name": "postBroadphase", @@ -8550,7 +9301,7 @@ }, { "file": "src/world/World.js", - "line": 336, + "line": 337, "description": "How to deactivate bodies during simulation. Possible modes are: {{#crossLink \"World/NO_SLEEPING:property\"}}World.NO_SLEEPING{{/crossLink}}, {{#crossLink \"World/BODY_SLEEPING:property\"}}World.BODY_SLEEPING{{/crossLink}} and {{#crossLink \"World/ISLAND_SLEEPING:property\"}}World.ISLAND_SLEEPING{{/crossLink}}.\nIf sleeping is enabled, you might need to {{#crossLink \"Body/wakeUp:method\"}}wake up{{/crossLink}} the bodies if they fall asleep when they shouldn't. If you want to enable sleeping in the world, but want to disable it for a particular body, see {{#crossLink \"Body/allowSleep:property\"}}Body.allowSleep{{/crossLink}}.", "itemtype": "property", "name": "sleepMode", @@ -8560,7 +9311,7 @@ }, { "file": "src/world/World.js", - "line": 345, + "line": 346, "description": "Fired when two shapes starts start to overlap. Fired in the narrowphase, during step.", "itemtype": "event", "name": "beginContact", @@ -8595,7 +9346,7 @@ }, { "file": "src/world/World.js", - "line": 363, + "line": 364, "description": "Fired when two shapes stop overlapping, after the narrowphase (during step).", "itemtype": "event", "name": "endContact", @@ -8630,7 +9381,7 @@ }, { "file": "src/world/World.js", - "line": 380, + "line": 381, "description": "Fired just before equations are added to the solver to be solved. Can be used to control what equations goes into the solver.", "itemtype": "event", "name": "preSolve", @@ -8650,7 +9401,7 @@ }, { "file": "src/world/World.js", - "line": 400, + "line": 402, "description": "Never deactivate bodies.", "static": 1, "itemtype": "property", @@ -8660,7 +9411,7 @@ }, { "file": "src/world/World.js", - "line": 407, + "line": 409, "description": "Deactivate individual bodies if they are sleepy.", "static": 1, "itemtype": "property", @@ -8670,7 +9421,7 @@ }, { "file": "src/world/World.js", - "line": 414, + "line": 416, "description": "Deactivates bodies that are in contact, if all of them are sleepy. Note that you must enable {{#crossLink \"World/islandSplit:property\"}}.islandSplit{{/crossLink}} for this to work.", "static": 1, "itemtype": "property", @@ -8680,7 +9431,7 @@ }, { "file": "src/world/World.js", - "line": 421, + "line": 423, "description": "Add a constraint to the simulation.", "itemtype": "method", "name": "addConstraint", @@ -8695,7 +9446,7 @@ }, { "file": "src/world/World.js", - "line": 431, + "line": 433, "description": "Add a ContactMaterial to the simulation.", "itemtype": "method", "name": "addContactMaterial", @@ -8710,7 +9461,7 @@ }, { "file": "src/world/World.js", - "line": 440, + "line": 442, "description": "Removes a contact material", "itemtype": "method", "name": "removeContactMaterial", @@ -8725,7 +9476,7 @@ }, { "file": "src/world/World.js", - "line": 453, + "line": 455, "description": "Get a contact material given two materials", "itemtype": "method", "name": "getContactMaterial", @@ -8752,7 +9503,7 @@ }, { "file": "src/world/World.js", - "line": 473, + "line": 475, "description": "Removes a constraint", "itemtype": "method", "name": "removeConstraint", @@ -8767,7 +9518,7 @@ }, { "file": "src/world/World.js", - "line": 498, + "line": 500, "description": "Step the physics world forward in time.\n\nThere are two modes. The simple mode is fixed timestepping without interpolation. In this case you only use the first argument. The second case uses interpolation. In that you also provide the time since the function was last used, as well as the maximum fixed timesteps to take.", "itemtype": "method", "name": "step", @@ -8802,7 +9553,7 @@ }, { "file": "src/world/World.js", - "line": 569, + "line": 571, "description": "Make a fixed step.", "itemtype": "method", "name": "internalStep", @@ -8819,31 +9570,7 @@ }, { "file": "src/world/World.js", - "line": 854, - "description": "Move a body forward in time.", - "static": 1, - "itemtype": "method", - "name": "integrateBody", - "params": [ - { - "name": "body", - "description": "", - "type": "Body" - }, - { - "name": "dt", - "description": "", - "type": "Number" - } - ], - "todo": [ - "Move to Body.prototype?" - ], - "class": "World" - }, - { - "file": "src/world/World.js", - "line": 887, + "line": 851, "description": "Runs narrowphase for the shape pair i and j.", "itemtype": "method", "name": "runNarrowphase", @@ -8903,7 +9630,7 @@ }, { "file": "src/world/World.js", - "line": 1009, + "line": 974, "description": "Add a spring to the simulation", "itemtype": "method", "name": "addSpring", @@ -8918,7 +9645,7 @@ }, { "file": "src/world/World.js", - "line": 1021, + "line": 986, "description": "Remove a spring", "itemtype": "method", "name": "removeSpring", @@ -8933,7 +9660,7 @@ }, { "file": "src/world/World.js", - "line": 1034, + "line": 999, "description": "Add a body to the simulation", "itemtype": "method", "name": "addBody", @@ -8954,7 +9681,7 @@ }, { "file": "src/world/World.js", - "line": 1055, + "line": 1020, "description": "Remove a body from the simulation. If this method is called during step(), the body removal is scheduled to after the step.", "itemtype": "method", "name": "removeBody", @@ -8969,7 +9696,7 @@ }, { "file": "src/world/World.js", - "line": 1076, + "line": 1041, "description": "Get a body by its id.", "itemtype": "method", "name": "getBodyById", @@ -8981,7 +9708,7 @@ }, { "file": "src/world/World.js", - "line": 1092, + "line": 1057, "description": "Disable collision between two bodies", "itemtype": "method", "name": "disableCollision", @@ -9001,7 +9728,7 @@ }, { "file": "src/world/World.js", - "line": 1102, + "line": 1067, "description": "Enable collisions between the given two bodies", "itemtype": "method", "name": "enableCollision", @@ -9021,7 +9748,7 @@ }, { "file": "src/world/World.js", - "line": 1146, + "line": 1111, "description": "Resets the World, removes all bodies, constraints and springs.", "itemtype": "method", "name": "clear", @@ -9029,7 +9756,7 @@ }, { "file": "src/world/World.js", - "line": 1188, + "line": 1153, "description": "Get a copy of this World instance", "itemtype": "method", "name": "clone", @@ -9041,7 +9768,7 @@ }, { "file": "src/world/World.js", - "line": 1203, + "line": 1168, "description": "Test if a world point overlaps bodies", "itemtype": "method", "name": "hitTest", @@ -9070,7 +9797,7 @@ }, { "file": "src/world/World.js", - "line": 1254, + "line": 1219, "description": "Sets the Equation parameters for all constraints and contact materials.", "itemtype": "method", "name": "setGlobalEquationParameters", @@ -9100,7 +9827,7 @@ }, { "file": "src/world/World.js", - "line": 1304, + "line": 1269, "description": "Set the stiffness for all equations and contact materials.", "itemtype": "method", "name": "setGlobalStiffness", @@ -9115,7 +9842,7 @@ }, { "file": "src/world/World.js", - "line": 1315, + "line": 1280, "description": "Set the relaxation for all equations and contact materials.", "itemtype": "method", "name": "setGlobalRelaxation", @@ -9127,6 +9854,198 @@ } ], "class": "World" + }, + { + "file": "src/world/World.js", + "line": 1293, + "description": "Ray cast against all bodies. The provided callback will be executed for each hit with a RaycastResult as single argument.", + "itemtype": "method", + "name": "raycastAll", + "params": [ + { + "name": "from", + "description": "", + "type": "Vec3" + }, + { + "name": "to", + "description": "", + "type": "Vec3" + }, + { + "name": "options", + "description": "", + "type": "Object", + "props": [ + { + "name": "collisionMask", + "description": "", + "type": "Number", + "optional": true, + "optdefault": "-1" + }, + { + "name": "collisionGroup", + "description": "", + "type": "Number", + "optional": true, + "optdefault": "-1" + }, + { + "name": "skipBackfaces", + "description": "", + "type": "Boolean", + "optional": true, + "optdefault": "false" + }, + { + "name": "checkCollisionResponse", + "description": "", + "type": "Boolean", + "optional": true, + "optdefault": "true" + } + ] + }, + { + "name": "callback", + "description": "", + "type": "Function" + } + ], + "return": { + "description": "True if any body was hit.", + "type": "Boolean" + }, + "class": "World" + }, + { + "file": "src/world/World.js", + "line": 1314, + "description": "Ray cast, and stop at the first result. Note that the order is random - but the method is fast.", + "itemtype": "method", + "name": "raycastAny", + "params": [ + { + "name": "from", + "description": "", + "type": "Vec3" + }, + { + "name": "to", + "description": "", + "type": "Vec3" + }, + { + "name": "options", + "description": "", + "type": "Object", + "props": [ + { + "name": "collisionMask", + "description": "", + "type": "Number", + "optional": true, + "optdefault": "-1" + }, + { + "name": "collisionGroup", + "description": "", + "type": "Number", + "optional": true, + "optdefault": "-1" + }, + { + "name": "skipBackfaces", + "description": "", + "type": "Boolean", + "optional": true, + "optdefault": "false" + }, + { + "name": "checkCollisionResponse", + "description": "", + "type": "Boolean", + "optional": true, + "optdefault": "true" + } + ] + }, + { + "name": "result", + "description": "", + "type": "RaycastResult" + } + ], + "return": { + "description": "True if any body was hit.", + "type": "Boolean" + }, + "class": "World" + }, + { + "file": "src/world/World.js", + "line": 1335, + "description": "Ray cast, and return information of the closest hit.", + "itemtype": "method", + "name": "raycastClosest", + "params": [ + { + "name": "from", + "description": "", + "type": "Vec3" + }, + { + "name": "to", + "description": "", + "type": "Vec3" + }, + { + "name": "options", + "description": "", + "type": "Object", + "props": [ + { + "name": "collisionMask", + "description": "", + "type": "Number", + "optional": true, + "optdefault": "-1" + }, + { + "name": "collisionGroup", + "description": "", + "type": "Number", + "optional": true, + "optdefault": "-1" + }, + { + "name": "skipBackfaces", + "description": "", + "type": "Boolean", + "optional": true, + "optdefault": "false" + }, + { + "name": "checkCollisionResponse", + "description": "", + "type": "Boolean", + "optional": true, + "optdefault": "true" + } + ] + }, + { + "name": "result", + "description": "", + "type": "RaycastResult" + } + ], + "return": { + "description": "True if any body was hit.", + "type": "Boolean" + }, + "class": "World" } ], "warnings": [] diff --git a/docs/files/src_collision_AABB.js.html b/docs/files/src_collision_AABB.js.html index 4d1a87b2..b074925d 100644 --- a/docs/files/src_collision_AABB.js.html +++ b/docs/files/src_collision_AABB.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    File: src/collision/AABB.js

    +

    File: src/collision/AABB.js

    @@ -327,7 +278,6 @@ 

    File: src/collision/AABB.js

    -
    diff --git a/docs/files/src_collision_Broadphase.js.html b/docs/files/src_collision_Broadphase.js.html index 9a29aa32..9f0ab402 100644 --- a/docs/files/src_collision_Broadphase.js.html +++ b/docs/files/src_collision_Broadphase.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    File: src/collision/Broadphase.js

    +

    File: src/collision/Broadphase.js

    @@ -267,13 +218,7 @@ 

    File: src/collision/Broadphase.js

    * @return {Boolean} */ Broadphase.aabbCheck = function(bodyA, bodyB){ - if(bodyA.aabbNeedsUpdate){ - bodyA.updateAABB(); - } - if(bodyB.aabbNeedsUpdate){ - bodyB.updateAABB(); - } - return bodyA.aabb.overlaps(bodyB.aabb); + return bodyA.getAABB().overlaps(bodyB.getAABB()); }; /** @@ -343,7 +288,6 @@

    File: src/collision/Broadphase.js

    -
    diff --git a/docs/files/src_collision_GridBroadphase.js.html b/docs/files/src_collision_GridBroadphase.js.html index 33eff7c1..50649a37 100644 --- a/docs/files/src_collision_GridBroadphase.js.html +++ b/docs/files/src_collision_GridBroadphase.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    File: src/collision/GridBroadphase.js

    +

    File: src/collision/GridBroadphase.js

    @@ -220,6 +171,7 @@ 

    File: src/collision/GridBroadphase.js

    this.binsizeY = (this.ymax-this.ymin) / this.ny; } GridBroadphase.prototype = new Broadphase(); +GridBroadphase.prototype.constructor = GridBroadphase; /** * Get collision pairs. @@ -294,7 +246,6 @@

    File: src/collision/GridBroadphase.js

    -
    diff --git a/docs/files/src_collision_NaiveBroadphase.js.html b/docs/files/src_collision_NaiveBroadphase.js.html index 36768d50..50cd1f12 100644 --- a/docs/files/src_collision_NaiveBroadphase.js.html +++ b/docs/files/src_collision_NaiveBroadphase.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    File: src/collision/NaiveBroadphase.js

    +

    File: src/collision/NaiveBroadphase.js

    @@ -194,6 +145,7 @@ 

    File: src/collision/NaiveBroadphase.js

    Broadphase.call(this, Broadphase.NAIVE); } NaiveBroadphase.prototype = new Broadphase(); +NaiveBroadphase.prototype.constructor = NaiveBroadphase; /** * Get the colliding pairs @@ -222,9 +174,34 @@

    File: src/collision/NaiveBroadphase.js

    return result; }; +/** + * Returns all the bodies within an AABB. + * @method aabbQuery + * @param {World} world + * @param {AABB} aabb + * @param {array} result An array to store resulting bodies in. + * @return {array} + */ +NaiveBroadphase.prototype.aabbQuery = function(world, aabb, result){ + result = result || []; + + var bodies = world.bodies; + for(var i = 0; i < bodies.length; i++){ + var b = bodies[i]; + + if(b.aabbNeedsUpdate){ + b.updateAABB(); + } + + if(b.aabb.overlaps(aabb)){ + result.push(b); + } + } + + return result; +};
    -
    diff --git a/docs/files/src_collision_Narrowphase.js.html b/docs/files/src_collision_Narrowphase.js.html index 0779fa05..0453f60a 100644 --- a/docs/files/src_collision_Narrowphase.js.html +++ b/docs/files/src_collision_Narrowphase.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    -
    -
    - -
    -
    -
    -
    - Show: - - - - - - - -
    - -
    -

    File: src/collision/Narrowphase.js

    +

    File: src/collision/Narrowphase.js

    @@ -240,6 +191,13 @@ 

    File: src/collision/Narrowphase.js

    */ this.enableFriction = true; + /** + * Whether to make equations enabled in upcoming contacts. + * @property enabledEquations + * @type {Boolean} + */ + this.enabledEquations = true; + /** * The friction slip force to use when creating friction equations. * @property slipForce @@ -316,12 +274,60 @@

    File: src/collision/Narrowphase.js

    /** * Contact skin size value to use in the next contact equations. - * @property {Number} collidingBodiesLastStep + * @property {Number} contactSkinSize * @default 0.01 */ this.contactSkinSize = 0.01; } +var bodiesOverlap_shapePositionA = vec2.create(); +var bodiesOverlap_shapePositionB = vec2.create(); + +/** + * @method bodiesOverlap + * @param {Body} bodyA + * @param {Body} bodyB + * @return {Boolean} + */ +Narrowphase.prototype.bodiesOverlap = function(bodyA, bodyB){ + var shapePositionA = bodiesOverlap_shapePositionA; + var shapePositionB = bodiesOverlap_shapePositionB; + + // Loop over all shapes of bodyA + for(var k=0, Nshapesi=bodyA.shapes.length; k!==Nshapesi; k++){ + var shapeA = bodyA.shapes[k], + positionA = bodyA.shapeOffsets[k], + angleA = bodyA.shapeAngles[k]; + + bodyA.toWorldFrame(shapePositionA, positionA); + + // All shapes of body j + for(var l=0, Nshapesj=bodyB.shapes.length; l!==Nshapesj; l++){ + var shapeB = bodyB.shapes[l], + positionB = bodyB.shapeOffsets[l], + angleB = bodyB.shapeAngles[l]; + + bodyB.toWorldFrame(shapePositionB, positionB); + + if(this[shapeA.type | shapeB.type]( + bodyA, + shapeA, + shapePositionA, + shapeA.angle + bodyA.angle, + bodyB, + shapeB, + shapePositionB, + shapeB.angle + bodyB.angle, + true + )){ + return true; + } + } + } + + return false; +}; + /** * Check if the bodies were in contact since the last reset(). * @method collidedLastStep @@ -382,7 +388,7 @@

    File: src/collision/Narrowphase.js

    c.stiffness = this.stiffness; c.relaxation = this.relaxation; c.needsUpdate = true; - c.enabled = true; + c.enabled = this.enabledEquations; c.offset = this.contactSkinSize; return c; @@ -404,7 +410,7 @@

    File: src/collision/Narrowphase.js

    c.setSlipForce(this.slipForce); c.frictionCoefficient = this.frictionCoefficient; c.relativeVelocity = this.surfaceVelocity; - c.enabled = true; + c.enabled = this.enabledEquations; c.needsUpdate = true; c.stiffness = this.frictionStiffness; c.relaxation = this.frictionRelaxation; @@ -429,9 +435,6 @@

    File: src/collision/Narrowphase.js

    // Take the average N latest contact point on the plane. Narrowphase.prototype.createFrictionFromAverage = function(numContacts){ - if(!numContacts){ - throw new Error("numContacts == 0!"); - } var c = this.contactEquations[this.contactEquations.length - 1]; var eq = this.createFrictionEquation(c.bodyA, c.bodyB, c.shapeA, c.shapeB); var bodyA = c.bodyA; @@ -2337,10 +2340,12 @@

    File: src/collision/Narrowphase.js

    return justTest ? false : 0; } + /* if(circlePos[1]+radius < min){ // Below the minimum point... We can just guess. // TODO } + */ // 1. Check so center of circle is not inside the field. If it is, this wont work... // 2. For each edge @@ -2541,7 +2546,6 @@

    File: src/collision/Narrowphase.js

    };
    -
    diff --git a/docs/files/src_collision_Ray.js.html b/docs/files/src_collision_Ray.js.html new file mode 100644 index 00000000..309f194a --- /dev/null +++ b/docs/files/src_collision_Ray.js.html @@ -0,0 +1,710 @@ + + + + + src/collision/Ray.js - p2.js + + + + + + + + +
    +
    +
    +

    +
    +
    + API Docs for: 0.6.1 +
    +
    +
    + + +
    +
    + Show: + + + + + + + +
    + +
    +
    +
    +

    File: src/collision/Ray.js

    + +
    +
    +module.exports = Ray;
    +
    +var vec2 = require('../math/vec2');
    +var RaycastResult = require('../collision/RaycastResult');
    +var Shape = require('../shapes/Shape');
    +var AABB = require('../collision/AABB');
    +
    +/**
    + * A line with a start and end point that is used to intersect shapes.
    + * @class Ray
    + * @constructor
    + */
    +function Ray(options){
    +    options = options || {};
    +
    +    /**
    +     * @property {array} from
    +     */
    +    this.from = options.from ? vec2.fromValues(options.from[0], options.from[1]) : vec2.create();
    +
    +    /**
    +     * @property {array} to
    +     */
    +    this.to = options.to ? vec2.fromValues(options.to[0], options.to[1]) : vec2.create();
    +
    +    /**
    +     * @private
    +     * @property {array} _direction
    +     */
    +    this._direction = vec2.create();
    +
    +    /**
    +     * The precision of the ray. Used when checking parallelity etc.
    +     * @property {Number} precision
    +     */
    +    this.precision = 0.0001;
    +
    +    /**
    +     * Set to true if you want the Ray to take .collisionResponse flags into account on bodies and shapes.
    +     * @property {Boolean} checkCollisionResponse
    +     */
    +    this.checkCollisionResponse = true;
    +
    +    /**
    +     * If set to true, the ray skips any hits with normal.dot(rayDirection) < 0.
    +     * @property {Boolean} skipBackfaces
    +     */
    +    this.skipBackfaces = false;
    +
    +    /**
    +     * @property {number} collisionMask
    +     * @default -1
    +     */
    +    this.collisionMask = -1;
    +
    +    /**
    +     * @property {number} collisionGroup
    +     * @default -1
    +     */
    +    this.collisionGroup = -1;
    +
    +    /**
    +     * The intersection mode. Should be Ray.ANY, Ray.ALL or Ray.CLOSEST.
    +     * @property {number} mode
    +     */
    +    this.mode = Ray.ANY;
    +
    +    /**
    +     * Current result object.
    +     * @property {RaycastResult} result
    +     */
    +    this.result = new RaycastResult();
    +
    +    /**
    +     * Will be set to true during intersectWorld() if the ray hit anything.
    +     * @property {Boolean} hasHit
    +     */
    +    this.hasHit = false;
    +
    +    /**
    +     * Current, user-provided result callback. Will be used if mode is Ray.ALL.
    +     * @property {Function} callback
    +     */
    +    this.callback = function(result){};
    +}
    +Ray.prototype.constructor = Ray;
    +
    +Ray.CLOSEST = 1;
    +Ray.ANY = 2;
    +Ray.ALL = 4;
    +
    +var tmpAABB = new AABB();
    +var tmpArray = [];
    +
    +/**
    + * Do itersection against all bodies in the given World.
    + * @method intersectWorld
    + * @param  {World} world
    + * @param  {object} options
    + * @return {Boolean} True if the ray hit anything, otherwise false.
    + */
    +Ray.prototype.intersectWorld = function (world, options) {
    +    this.mode = options.mode || Ray.ANY;
    +    this.result = options.result || new RaycastResult();
    +    this.skipBackfaces = !!options.skipBackfaces;
    +    this.collisionMask = typeof(options.collisionMask) !== 'undefined' ? options.collisionMask : -1;
    +    this.collisionGroup = typeof(options.collisionGroup) !== 'undefined' ? options.collisionGroup : -1;
    +    if(options.from){
    +        vec2.copy(this.from, options.from);
    +    }
    +    if(options.to){
    +        vec2.copy(this.to, options.to);
    +    }
    +    this.callback = options.callback || function(){};
    +    this.hasHit = false;
    +
    +    this.result.reset();
    +    this._updateDirection();
    +
    +    this.getAABB(tmpAABB);
    +    tmpArray.length = 0;
    +    world.broadphase.aabbQuery(world, tmpAABB, tmpArray);
    +    this.intersectBodies(tmpArray);
    +
    +    return this.hasHit;
    +};
    +
    +var v1 = vec2.create(),
    +    v2 = vec2.create();
    +
    +var intersectBody_worldPosition = vec2.create();
    +
    +/**
    + * Shoot a ray at a body, get back information about the hit.
    + * @method intersectBody
    + * @private
    + * @param {Body} body
    + * @param {RaycastResult} [result] Deprecated - set the result property of the Ray instead.
    + */
    +Ray.prototype.intersectBody = function (body, result) {
    +
    +    if(result){
    +        this.result = result;
    +        this._updateDirection();
    +    }
    +    var checkCollisionResponse = this.checkCollisionResponse;
    +
    +    if(checkCollisionResponse && !body.collisionResponse){
    +        return;
    +    }
    +
    +    // if((this.collisionGroup & body.collisionMask)===0 || (body.collisionGroup & this.collisionMask)===0){
    +    //     return;
    +    // }
    +
    +    var worldPosition = intersectBody_worldPosition;
    +
    +    for (var i = 0, N = body.shapes.length; i < N; i++) {
    +        var shape = body.shapes[i];
    +
    +        if(checkCollisionResponse && !shape.collisionResponse){
    +            continue; // Skip
    +        }
    +
    +        // Get world angle and position of the shape
    +        vec2.copy(worldPosition, body.shapeOffsets[i]);
    +        vec2.rotate(worldPosition, worldPosition, body.angle);
    +        vec2.add(worldPosition, worldPosition, body.position);
    +        var worldAngle = body.shapeAngles[i] + body.angle;
    +
    +        this.intersectShape(
    +            shape,
    +            worldAngle,
    +            worldPosition,
    +            body
    +        );
    +
    +        if(this.result._shouldStop){
    +            break;
    +        }
    +    }
    +};
    +
    +/**
    + * @method intersectBodies
    + * @param {Array} bodies An array of Body objects.
    + * @param {RaycastResult} [result] Deprecated
    + */
    +Ray.prototype.intersectBodies = function (bodies, result) {
    +    if(result){
    +        this.result = result;
    +        this._updateDirection();
    +    }
    +
    +    for ( var i = 0, l = bodies.length; !this.result._shouldStop && i < l; i ++ ) {
    +        this.intersectBody(bodies[i]);
    +    }
    +};
    +
    +/**
    + * Updates the _direction vector.
    + * @private
    + * @method _updateDirection
    + */
    +Ray.prototype._updateDirection = function(){
    +    var d = this._direction;
    +    vec2.sub(d, this.to, this.from); // this.to.vsub(this.from, this._direction);
    +    vec2.normalize(d, d); // this._direction.normalize();
    +};
    +
    +/**
    + * @method intersectShape
    + * @private
    + * @param {Shape} shape
    + * @param {number} angle
    + * @param {array} position
    + * @param {Body} body
    + */
    +Ray.prototype.intersectShape = function(shape, angle, position, body){
    +    var from = this.from;
    +
    +
    +    // Checking boundingSphere
    +    var distance = distanceFromIntersection(from, this._direction, position);
    +    if ( distance > shape.boundingSphereRadius ) {
    +        return;
    +    }
    +
    +    var method = this[shape.type];
    +    if(method){
    +        method.call(this, shape, angle, position, body);
    +    }
    +};
    +
    +var vector = vec2.create();
    +var normal = vec2.create();
    +var intersectPoint = vec2.create();
    +
    +var a = vec2.create();
    +var b = vec2.create();
    +var c = vec2.create();
    +var d = vec2.create();
    +
    +var tmpRaycastResult = new RaycastResult();
    +var intersectRectangle_direction = vec2.create();
    +var intersectRectangle_rayStart = vec2.create();
    +var intersectRectangle_worldNormalMin = vec2.create();
    +var intersectRectangle_worldNormalMax = vec2.create();
    +var intersectRectangle_hitPointWorld = vec2.create();
    +var intersectRectangle_boxMin = vec2.create();
    +var intersectRectangle_boxMax = vec2.create();
    +
    +/**
    + * @method intersectRectangle
    + * @private
    + * @param  {Shape} shape
    + * @param  {number} angle
    + * @param  {array} position
    + * @param  {Body} body
    + */
    +Ray.prototype.intersectRectangle = function(shape, angle, position, body){
    +    var tmin = -Number.MAX_VALUE;
    +    var tmax = Number.MAX_VALUE;
    +
    +    var direction = intersectRectangle_direction;
    +    var rayStart = intersectRectangle_rayStart;
    +    var worldNormalMin = intersectRectangle_worldNormalMin;
    +    var worldNormalMax = intersectRectangle_worldNormalMax;
    +    var hitPointWorld = intersectRectangle_hitPointWorld;
    +    var boxMin = intersectRectangle_boxMin;
    +    var boxMax = intersectRectangle_boxMax;
    +
    +    vec2.set(boxMin, -shape.width * 0.5, -shape.height * 0.5);
    +    vec2.set(boxMax, shape.width * 0.5, shape.height * 0.5);
    +
    +    // Transform the ray direction and start to local space
    +    vec2.rotate(direction, this._direction, -angle);
    +    body.toLocalFrame(rayStart, this.from);
    +
    +    if (direction[0] !== 0) {
    +        var tx1 = (boxMin[0] - rayStart[0]) / direction[0];
    +        var tx2 = (boxMax[0] - rayStart[0]) / direction[0];
    +
    +        var tminOld = tmin;
    +        tmin = Math.max(tmin, Math.min(tx1, tx2));
    +        if(tmin !== tminOld){
    +            vec2.set(worldNormalMin, tx1 > tx2 ? 1 : -1, 0);
    +        }
    +
    +        var tmaxOld = tmax;
    +        tmax = Math.min(tmax, Math.max(tx1, tx2));
    +        if(tmax !== tmaxOld){
    +            vec2.set(worldNormalMax, tx1 < tx2 ? 1 : -1, 0);
    +        }
    +    }
    +
    +    if (direction[1] !== 0) {
    +        var ty1 = (boxMin[1] - rayStart[1]) / direction[1];
    +        var ty2 = (boxMax[1] - rayStart[1]) / direction[1];
    +
    +        var tminOld = tmin;
    +        tmin = Math.max(tmin, Math.min(ty1, ty2));
    +        if(tmin !== tminOld){
    +            vec2.set(worldNormalMin, 0, ty1 > ty2 ? 1 : -1);
    +        }
    +
    +        var tmaxOld = tmax;
    +        tmax = Math.min(tmax, Math.max(ty1, ty2));
    +        if(tmax !== tmaxOld){
    +            vec2.set(worldNormalMax, 0, ty1 < ty2 ? 1 : -1);
    +        }
    +    }
    +
    +    if(tmax >= tmin){
    +        // Hit point
    +        vec2.set(
    +            hitPointWorld,
    +            rayStart[0] + direction[0] * tmin,
    +            rayStart[1] + direction[1] * tmin
    +        );
    +
    +        vec2.rotate(worldNormalMin, worldNormalMin, angle);
    +
    +        body.toWorldFrame(hitPointWorld, hitPointWorld);
    +
    +        this.reportIntersection(worldNormalMin, hitPointWorld, shape, body, -1);
    +        if(this._shouldStop){
    +            return;
    +        }
    +
    +        vec2.rotate(worldNormalMax, worldNormalMax, angle);
    +
    +        // Hit point
    +        vec2.set(
    +            hitPointWorld,
    +            rayStart[0] + direction[0] * tmax,
    +            rayStart[1] + direction[1] * tmax
    +        );
    +        body.toWorldFrame(hitPointWorld, hitPointWorld);
    +
    +        this.reportIntersection(worldNormalMax, hitPointWorld, shape, body, -1);
    +    }
    +};
    +Ray.prototype[Shape.RECTANGLE] = Ray.prototype.intersectRectangle;
    +
    +var intersectPlane_planePointToFrom = vec2.create();
    +var intersectPlane_dir_scaled_with_t = vec2.create();
    +var intersectPlane_hitPointWorld = vec2.create();
    +var intersectPlane_worldNormal = vec2.create();
    +var intersectPlane_len = vec2.create();
    +
    +/**
    + * @method intersectPlane
    + * @private
    + * @param  {Shape} shape
    + * @param  {number} angle
    + * @param  {array} position
    + * @param  {Body} body
    + */
    +Ray.prototype.intersectPlane = function(shape, angle, position, body){
    +    var from = this.from;
    +    var to = this.to;
    +    var direction = this._direction;
    +
    +    var planePointToFrom = intersectPlane_planePointToFrom;
    +    var dir_scaled_with_t = intersectPlane_dir_scaled_with_t;
    +    var hitPointWorld = intersectPlane_hitPointWorld;
    +    var worldNormal = intersectPlane_worldNormal;
    +    var len = intersectPlane_len;
    +
    +    // Get plane normal
    +    vec2.set(worldNormal, 0, 1);
    +    vec2.rotate(worldNormal, worldNormal, angle);
    +
    +    vec2.sub(len, from, position); //from.vsub(position, len);
    +    var planeToFrom = vec2.dot(len, worldNormal); // len.dot(worldNormal);
    +    vec2.sub(len, to, position); // to.vsub(position, len);
    +    var planeToTo = vec2.dot(len, worldNormal); // len.dot(worldNormal);
    +
    +    if(planeToFrom * planeToTo > 0){
    +        // "from" and "to" are on the same side of the plane... bail out
    +        return;
    +    }
    +
    +    if(vec2.distance(from, to) /* from.distanceTo(to) */ < planeToFrom){
    +        return;
    +    }
    +
    +    var n_dot_dir = vec2.dot(worldNormal, direction); // worldNormal.dot(direction);
    +
    +    // if (Math.abs(n_dot_dir) < this.precision) {
    +    //     // No intersection
    +    //     return;
    +    // }
    +
    +    vec2.sub(planePointToFrom, from, position); // from.vsub(position, planePointToFrom);
    +    var t = -vec2.dot(worldNormal, planePointToFrom) / n_dot_dir; // - worldNormal.dot(planePointToFrom) / n_dot_dir;
    +    vec2.scale(dir_scaled_with_t, direction, t); // direction.scale(t, dir_scaled_with_t);
    +    vec2.add(hitPointWorld, from, dir_scaled_with_t); // from.vadd(dir_scaled_with_t, hitPointWorld);
    +
    +    this.reportIntersection(worldNormal, hitPointWorld, shape, body, -1);
    +};
    +Ray.prototype[Shape.PLANE] = Ray.prototype.intersectPlane;
    +
    +var Ray_intersectSphere_intersectionPoint = vec2.create();
    +var Ray_intersectSphere_normal = vec2.create();
    +Ray.prototype.intersectCircle = function(shape, angle, position, body){
    +    var from = this.from,
    +        to = this.to,
    +        r = shape.radius;
    +
    +    var a = Math.pow(to[0] - from[0], 2) + Math.pow(to[1] - from[1], 2);
    +    var b = 2 * ((to[0] - from[0]) * (from[0] - position[0]) + (to[1] - from[1]) * (from[1] - position[1]));
    +    var c = Math.pow(from[0] - position[0], 2) + Math.pow(from[1] - position[1], 2) - Math.pow(r, 2);
    +
    +    var delta = Math.pow(b, 2) - 4 * a * c;
    +
    +    var intersectionPoint = Ray_intersectSphere_intersectionPoint;
    +    var normal = Ray_intersectSphere_normal;
    +
    +    if(delta < 0){
    +        // No intersection
    +        return;
    +
    +    } else if(delta === 0){
    +        // single intersection point
    +        vec2.lerp(intersectionPoint, from, to, delta); // from.lerp(to, delta, intersectionPoint);
    +
    +        vec2.sub(normal, intersectionPoint, position); // intersectionPoint.vsub(position, normal);
    +        vec2.normalize(normal,normal); //normal.normalize();
    +
    +        this.reportIntersection(normal, intersectionPoint, shape, body, -1);
    +
    +    } else {
    +        var d1 = (- b - Math.sqrt(delta)) / (2 * a);
    +        var d2 = (- b + Math.sqrt(delta)) / (2 * a);
    +
    +        vec2.lerp(intersectionPoint, from, to, d1); // from.lerp(to, d1, intersectionPoint);
    +
    +        vec2.sub(normal, intersectionPoint, position); // intersectionPoint.vsub(position, normal);
    +        vec2.normalize(normal,normal); //normal.normalize();
    +
    +        this.reportIntersection(normal, intersectionPoint, shape, body, -1);
    +
    +        if(this.result._shouldStop){
    +            return;
    +        }
    +
    +        vec2.lerp(intersectionPoint, from, to, d2); // from.lerp(to, d2, intersectionPoint);
    +
    +        vec2.sub(normal, intersectionPoint, position); // intersectionPoint.vsub(position, normal);
    +        vec2.normalize(normal,normal); //normal.normalize();
    +
    +        this.reportIntersection(normal, intersectionPoint, shape, body, -1);
    +    }
    +};
    +Ray.prototype[Shape.CIRCLE] = Ray.prototype.intersectCircle;
    +
    +/**
    + * Get the AABB of the ray.
    + * @method getAABB
    + * @param  {AABB} aabb
    + */
    +Ray.prototype.getAABB = function(result){
    +    var to = this.to;
    +    var from = this.from;
    +    result.lowerBound[0] = Math.min(to[0], from[0]);
    +    result.lowerBound[1] = Math.min(to[1], from[1]);
    +    result.upperBound[0] = Math.max(to[0], from[0]);
    +    result.upperBound[1] = Math.max(to[1], from[1]);
    +};
    +
    +/**
    + * @method reportIntersection
    + * @private
    + * @param  {array} normal
    + * @param  {array} hitPointWorld
    + * @param  {Shape} shape
    + * @param  {Body} body
    + * @return {boolean} True if the intersections should continue
    + */
    +Ray.prototype.reportIntersection = function(normal, hitPointWorld, shape, body, hitFaceIndex){
    +    var from = this.from;
    +    var to = this.to;
    +    var distance = vec2.distance(from, hitPointWorld); // from.distanceTo(hitPointWorld);
    +    var result = this.result;
    +
    +    // Skip back faces?
    +    if(this.skipBackfaces && /* normal.dot(this._direction) */ vec2.dot(normal, this._direction) > 0){
    +        return;
    +    }
    +
    +    result.hitFaceIndex = typeof(hitFaceIndex) !== 'undefined' ? hitFaceIndex : -1;
    +
    +    switch(this.mode){
    +    case Ray.ALL:
    +        this.hasHit = true;
    +        result.set(
    +            from,
    +            to,
    +            normal,
    +            hitPointWorld,
    +            shape,
    +            body,
    +            distance
    +        );
    +        result.hasHit = true;
    +        this.callback(result);
    +        break;
    +
    +    case Ray.CLOSEST:
    +
    +        // Store if closer than current closest
    +        if(distance < result.distance || !result.hasHit){
    +            this.hasHit = true;
    +            result.hasHit = true;
    +            result.set(
    +                from,
    +                to,
    +                normal,
    +                hitPointWorld,
    +                shape,
    +                body,
    +                distance
    +            );
    +        }
    +        break;
    +
    +    case Ray.ANY:
    +
    +        // Report and stop.
    +        this.hasHit = true;
    +        result.hasHit = true;
    +        result.set(
    +            from,
    +            to,
    +            normal,
    +            hitPointWorld,
    +            shape,
    +            body,
    +            distance
    +        );
    +        result._shouldStop = true;
    +        break;
    +    }
    +};
    +
    +var v0 = vec2.create(),
    +    intersect = vec2.create();
    +function distanceFromIntersection(from, direction, position) {
    +
    +    // v0 is vector from from to position
    +    vec2.sub(v0, position, from); // position.vsub(from,v0);
    +    var dot = vec2.dot(v0, direction); // v0.dot(direction);
    +
    +    // intersect = direction*dot + from
    +    vec2.scale(intersect, direction, dot); //direction.mult(dot,intersect);
    +    vec2.add(intersect, intersect, from); // intersect.vadd(from, intersect);
    +
    +    var distance = vec2.distance(position, intersect); // position.distanceTo(intersect);
    +
    +    return distance;
    +}
    +
    +
    +    
    +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + diff --git a/docs/files/src_collision_RaycastResult.js.html b/docs/files/src_collision_RaycastResult.js.html new file mode 100644 index 00000000..f3c74f69 --- /dev/null +++ b/docs/files/src_collision_RaycastResult.js.html @@ -0,0 +1,267 @@ + + + + + src/collision/RaycastResult.js - p2.js + + + + + + + + +
    +
    +
    +

    +
    +
    + API Docs for: 0.6.1 +
    +
    +
    + + +
    +
    + Show: + + + + + + + +
    + +
    +
    +
    +

    File: src/collision/RaycastResult.js

    + +
    +
    +var vec2 = require('../math/vec2');
    +
    +module.exports = RaycastResult;
    +
    +/**
    + * Storage for Ray casting data.
    + * @class RaycastResult
    + * @constructor
    + */
    +function RaycastResult(){
    +
    +	/**
    +	 * @property {array} rayFromWorld
    +	 */
    +	this.rayFromWorld = vec2.create();
    +
    +	/**
    +	 * @property {array} rayToWorld
    +	 */
    +	this.rayToWorld = vec2.create();
    +
    +	/**
    +	 * @property {array} hitNormalWorld
    +	 */
    +	this.hitNormalWorld = vec2.create();
    +
    +	/**
    +	 * @property {array} hitPointWorld
    +	 */
    +	this.hitPointWorld = vec2.create();
    +
    +	/**
    +	 * @property {boolean} hasHit
    +	 */
    +	this.hasHit = false;
    +
    +	/**
    +	 * The hit shape, or null.
    +	 * @property {Shape} shape
    +	 */
    +	this.shape = null;
    +
    +	/**
    +	 * The hit body, or null.
    +	 * @property {Body} body
    +	 */
    +	this.body = null;
    +
    +	/**
    +	 * The index of the hit triangle, if the hit shape was a trimesh.
    +	 * @property {number} hitFaceIndex
    +	 * @default -1
    +	 */
    +	this.hitFaceIndex = -1;
    +
    +	/**
    +	 * Distance to the hit. Will be set to -1 if there was no hit.
    +	 * @property {number} distance
    +	 * @default -1
    +	 */
    +	this.distance = -1;
    +
    +	/**
    +	 * If the ray should stop traversing the bodies.
    +	 * @private
    +	 * @property {Boolean} _shouldStop
    +	 * @default false
    +	 */
    +	this._shouldStop = false;
    +}
    +
    +/**
    + * Reset all result data.
    + * @method reset
    + */
    +RaycastResult.prototype.reset = function () {
    +	vec2.set(this.rayFromWorld, 0, 0);
    +	vec2.set(this.rayToWorld, 0, 0);
    +	vec2.set(this.hitNormalWorld, 0, 0);
    +	vec2.set(this.hitPointWorld, 0, 0);
    +	this.hasHit = false;
    +	this.shape = null;
    +	this.body = null;
    +	this.hitFaceIndex = -1;
    +	this.distance = -1;
    +	this._shouldStop = false;
    +};
    +
    +/**
    + * @method abort
    + */
    +RaycastResult.prototype.abort = function(){
    +	this._shouldStop = true;
    +};
    +
    +/**
    + * @method set
    + * @param {array} rayFromWorld
    + * @param {array} rayToWorld
    + * @param {array} hitNormalWorld
    + * @param {array} hitPointWorld
    + * @param {Shape} shape
    + * @param {Body} body
    + * @param {number} distance
    + */
    +RaycastResult.prototype.set = function(
    +	rayFromWorld,
    +	rayToWorld,
    +	hitNormalWorld,
    +	hitPointWorld,
    +	shape,
    +	body,
    +	distance
    +){
    +	vec2.copy(this.rayFromWorld, rayFromWorld);
    +	vec2.copy(this.rayToWorld, rayToWorld);
    +	vec2.copy(this.hitNormalWorld, hitNormalWorld);
    +	vec2.copy(this.hitPointWorld, hitPointWorld);
    +	this.shape = shape;
    +	this.body = body;
    +	this.distance = distance;
    +};
    +    
    +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + diff --git a/docs/files/src_collision_SAPBroadphase.js.html b/docs/files/src_collision_SAPBroadphase.js.html index 97282efd..02b33987 100644 --- a/docs/files/src_collision_SAPBroadphase.js.html +++ b/docs/files/src_collision_SAPBroadphase.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    File: src/collision/SAPBroadphase.js

    +

    File: src/collision/SAPBroadphase.js

    @@ -197,39 +148,32 @@ 

    File: src/collision/SAPBroadphase.js

    this.axisList = []; /** - * The world to search in. - * @property world - * @type {World} - */ - this.world = null; - - /** - * The axis to sort along. + * The axis to sort along. 0 means x-axis and 1 y-axis. If your bodies are more spread out over the X axis, set axisIndex to 0, and you will gain some performance. * @property axisIndex * @type {Number} */ this.axisIndex = 0; - var axisList = this.axisList; - + var that = this; this._addBodyHandler = function(e){ - axisList.push(e.body); + that.axisList.push(e.body); }; this._removeBodyHandler = function(e){ // Remove from list - var idx = axisList.indexOf(e.body); + var idx = that.axisList.indexOf(e.body); if(idx !== -1){ - axisList.splice(idx,1); + that.axisList.splice(idx,1); } }; } SAPBroadphase.prototype = new Broadphase(); +SAPBroadphase.prototype.constructor = SAPBroadphase; /** * Change the world * @method setWorld - * @param {World} world + * @param {World} world */ SAPBroadphase.prototype.setWorld = function(world){ // Clear the old axis array @@ -271,6 +215,14 @@

    File: src/collision/SAPBroadphase.js

    return a; }; +SAPBroadphase.prototype.sortList = function(){ + var bodies = this.axisList, + axisIndex = this.axisIndex; + + // Sort the lists + SAPBroadphase.sortAxisList(bodies, axisIndex); +}; + /** * Get the colliding pairs * @method getCollisionPairs @@ -294,7 +246,7 @@

    File: src/collision/SAPBroadphase.js

    } // Sort the lists - SAPBroadphase.sortAxisList(bodies, axisIndex); + this.sortList(); // Look through the X list for(var i=0, N=bodies.length|0; i!==N; i++){ @@ -318,10 +270,43 @@

    File: src/collision/SAPBroadphase.js

    return result; }; +/** + * Returns all the bodies within an AABB. + * @method aabbQuery + * @param {World} world + * @param {AABB} aabb + * @param {array} result An array to store resulting bodies in. + * @return {array} + */ +SAPBroadphase.prototype.aabbQuery = function(world, aabb, result){ + result = result || []; + this.sortList(); + + var axisIndex = this.axisIndex; + var axis = 'x'; + if(axisIndex === 1){ axis = 'y'; } + if(axisIndex === 2){ axis = 'z'; } + + var axisList = this.axisList; + var lower = aabb.lowerBound[axis]; + var upper = aabb.upperBound[axis]; + for(var i = 0; i < axisList.length; i++){ + var b = axisList[i]; + + if(b.aabbNeedsUpdate){ + b.updateAABB(); + } + + if(b.aabb.overlaps(aabb)){ + result.push(b); + } + } + + return result; +};
    -
    diff --git a/docs/files/src_constraints_Constraint.js.html b/docs/files/src_constraints_Constraint.js.html index 954d68af..71f54d3a 100644 --- a/docs/files/src_constraints_Constraint.js.html +++ b/docs/files/src_constraints_Constraint.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    File: src/constraints/Constraint.js

    +

    File: src/constraints/Constraint.js

    @@ -191,6 +142,11 @@ 

    File: src/constraints/Constraint.js

    * @param {Object} [options.collideConnected=true] */ function Constraint(bodyA, bodyB, type, options){ + + /** + * The type of constraint. May be one of Constraint.DISTANCE, Constraint.GEAR, Constraint.LOCK, Constraint.PRISMATIC or Constraint.REVOLUTE. + * @property {number} type + */ this.type = type; options = Utils.defaults(options,{ @@ -247,10 +203,34 @@

    File: src/constraints/Constraint.js

    throw new Error("method update() not implmemented in this Constraint subclass!"); }; +/** + * @static + * @property {number} DISTANCE + */ Constraint.DISTANCE = 1; + +/** + * @static + * @property {number} GEAR + */ Constraint.GEAR = 2; + +/** + * @static + * @property {number} LOCK + */ Constraint.LOCK = 3; + +/** + * @static + * @property {number} PRISMATIC + */ Constraint.PRISMATIC = 4; + +/** + * @static + * @property {number} REVOLUTE + */ Constraint.REVOLUTE = 5; /** @@ -283,7 +263,6 @@

    File: src/constraints/Constraint.js

    -
    diff --git a/docs/files/src_constraints_DistanceConstraint.js.html b/docs/files/src_constraints_DistanceConstraint.js.html index 96d3baf1..0642a125 100644 --- a/docs/files/src_constraints_DistanceConstraint.js.html +++ b/docs/files/src_constraints_DistanceConstraint.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    File: src/constraints/DistanceConstraint.js

    +

    File: src/constraints/DistanceConstraint.js

    @@ -348,6 +299,7 @@ 

    File: src/constraints/DistanceConstraint.js

    this.position = 0; } DistanceConstraint.prototype = new Constraint(); +DistanceConstraint.prototype.constructor = DistanceConstraint; /** * Update the constraint equations. Should be done if any of the bodies changed position, before solving. @@ -441,7 +393,6 @@

    File: src/constraints/DistanceConstraint.js

    -
    diff --git a/docs/files/src_constraints_GearConstraint.js.html b/docs/files/src_constraints_GearConstraint.js.html index 4fe63fce..2f132258 100644 --- a/docs/files/src_constraints_GearConstraint.js.html +++ b/docs/files/src_constraints_GearConstraint.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    File: src/constraints/GearConstraint.js

    +

    File: src/constraints/GearConstraint.js

    @@ -228,6 +179,7 @@ 

    File: src/constraints/GearConstraint.js

    } } GearConstraint.prototype = new Constraint(); +GearConstraint.prototype.constructor = GearConstraint; GearConstraint.prototype.update = function(){ var eq = this.equations[0]; @@ -256,7 +208,6 @@

    File: src/constraints/GearConstraint.js

    };
    -
    diff --git a/docs/files/src_constraints_LockConstraint.js.html b/docs/files/src_constraints_LockConstraint.js.html index 99373fb4..ab3b1e32 100644 --- a/docs/files/src_constraints_LockConstraint.js.html +++ b/docs/files/src_constraints_LockConstraint.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    File: src/constraints/LockConstraint.js

    +

    File: src/constraints/LockConstraint.js

    @@ -285,6 +236,7 @@ 

    File: src/constraints/LockConstraint.js

    this.setMaxForce(maxForce); } LockConstraint.prototype = new Constraint(); +LockConstraint.prototype.constructor = LockConstraint; /** * Set the maximum force to be applied. @@ -346,7 +298,6 @@

    File: src/constraints/LockConstraint.js

    -
    diff --git a/docs/files/src_constraints_PrismaticConstraint.js.html b/docs/files/src_constraints_PrismaticConstraint.js.html index fdf1012d..91d66381 100644 --- a/docs/files/src_constraints_PrismaticConstraint.js.html +++ b/docs/files/src_constraints_PrismaticConstraint.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    File: src/constraints/PrismaticConstraint.js

    +

    File: src/constraints/PrismaticConstraint.js

    @@ -294,6 +245,7 @@ 

    File: src/constraints/PrismaticConstraint.js

    */ this.position = 0; + // Is this one used at all? this.velocity = 0; /** @@ -370,6 +322,7 @@

    File: src/constraints/PrismaticConstraint.js

    } PrismaticConstraint.prototype = new Constraint(); +PrismaticConstraint.prototype.constructor = PrismaticConstraint; var worldAxisA = vec2.create(), worldAnchorA = vec2.create(), @@ -527,7 +480,6 @@

    File: src/constraints/PrismaticConstraint.js

    -
    diff --git a/docs/files/src_constraints_RevoluteConstraint.js.html b/docs/files/src_constraints_RevoluteConstraint.js.html index 39301157..f1371fab 100644 --- a/docs/files/src_constraints_RevoluteConstraint.js.html +++ b/docs/files/src_constraints_RevoluteConstraint.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    File: src/constraints/RevoluteConstraint.js

    +

    File: src/constraints/RevoluteConstraint.js

    @@ -328,6 +279,7 @@ 

    File: src/constraints/RevoluteConstraint.js

    this.lowerLimitEquation.maxForce = 0; } RevoluteConstraint.prototype = new Constraint(); +RevoluteConstraint.prototype.constructor = RevoluteConstraint; /** * Set the constraint angle limits. @@ -467,6 +419,7 @@

    File: src/constraints/RevoluteConstraint.js

    /** * Check if the motor is enabled. * @method motorIsEnabled + * @deprecated use property motorEnabled instead. * @return {Boolean} */ RevoluteConstraint.prototype.motorIsEnabled = function(){ @@ -489,7 +442,7 @@

    File: src/constraints/RevoluteConstraint.js

    /** * Get the speed of the rotational constraint motor * @method getMotorSpeed - * @return {Number} The current speed, or false if the motor is not enabled. + * @return {Number} The current speed, or false if the motor is not enabled. */ RevoluteConstraint.prototype.getMotorSpeed = function(){ if(!this.motorEnabled){ @@ -500,7 +453,6 @@

    File: src/constraints/RevoluteConstraint.js

    -
    diff --git a/docs/files/src_equations_AngleLockEquation.js.html b/docs/files/src_equations_AngleLockEquation.js.html index 8e746633..3703ff66 100644 --- a/docs/files/src_equations_AngleLockEquation.js.html +++ b/docs/files/src_equations_AngleLockEquation.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    File: src/equations/AngleLockEquation.js

    +

    File: src/equations/AngleLockEquation.js

    @@ -237,7 +188,6 @@ 

    File: src/equations/AngleLockEquation.js

    -
    diff --git a/docs/files/src_equations_ContactEquation.js.html b/docs/files/src_equations_ContactEquation.js.html index aa4e5282..270d21b4 100644 --- a/docs/files/src_equations_ContactEquation.js.html +++ b/docs/files/src_equations_ContactEquation.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    File: src/equations/ContactEquation.js

    +

    File: src/equations/ContactEquation.js

    @@ -291,7 +242,6 @@ 

    File: src/equations/ContactEquation.js

    -
    diff --git a/docs/files/src_equations_Equation.js.html b/docs/files/src_equations_Equation.js.html index 9ddcb25e..47d2a799 100644 --- a/docs/files/src_equations_Equation.js.html +++ b/docs/files/src_equations_Equation.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    File: src/equations/Equation.js

    +

    File: src/equations/Equation.js

    @@ -494,7 +445,6 @@ 

    File: src/equations/Equation.js

    -
    diff --git a/docs/files/src_equations_FrictionEquation.js.html b/docs/files/src_equations_FrictionEquation.js.html index f9b82896..b5add78a 100644 --- a/docs/files/src_equations_FrictionEquation.js.html +++ b/docs/files/src_equations_FrictionEquation.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    File: src/equations/FrictionEquation.js

    +

    File: src/equations/FrictionEquation.js

    @@ -294,7 +245,6 @@ 

    File: src/equations/FrictionEquation.js

    -
    diff --git a/docs/files/src_equations_RotationalLockEquation.js.html b/docs/files/src_equations_RotationalLockEquation.js.html index b9cbc770..d9865c9a 100644 --- a/docs/files/src_equations_RotationalLockEquation.js.html +++ b/docs/files/src_equations_RotationalLockEquation.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    File: src/equations/RotationalLockEquation.js

    +

    File: src/equations/RotationalLockEquation.js

    @@ -218,7 +169,6 @@ 

    File: src/equations/RotationalLockEquation.js

    -
    diff --git a/docs/files/src_equations_RotationalVelocityEquation.js.html b/docs/files/src_equations_RotationalVelocityEquation.js.html index 426a21df..0ad78e7c 100644 --- a/docs/files/src_equations_RotationalVelocityEquation.js.html +++ b/docs/files/src_equations_RotationalVelocityEquation.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    File: src/equations/RotationalVelocityEquation.js

    +

    File: src/equations/RotationalVelocityEquation.js

    @@ -209,7 +160,6 @@ 

    File: src/equations/RotationalVelocityEquation.js

    -
    diff --git a/docs/files/src_events_EventEmitter.js.html b/docs/files/src_events_EventEmitter.js.html index 2c9a80c1..e52e6c16 100644 --- a/docs/files/src_events_EventEmitter.js.html +++ b/docs/files/src_events_EventEmitter.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    File: src/events/EventEmitter.js

    +

    File: src/events/EventEmitter.js

    @@ -278,7 +229,6 @@ 

    File: src/events/EventEmitter.js

    -
    diff --git a/docs/files/src_material_ContactMaterial.js.html b/docs/files/src_material_ContactMaterial.js.html index 0a059603..7360163d 100644 --- a/docs/files/src_material_ContactMaterial.js.html +++ b/docs/files/src_material_ContactMaterial.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    File: src/material/ContactMaterial.js

    +

    File: src/material/ContactMaterial.js

    @@ -283,7 +234,6 @@ 

    File: src/material/ContactMaterial.js

    -
    diff --git a/docs/files/src_material_Material.js.html b/docs/files/src_material_Material.js.html index 05ba5bca..801b8571 100644 --- a/docs/files/src_material_Material.js.html +++ b/docs/files/src_material_Material.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    File: src/material/Material.js

    +

    File: src/material/Material.js

    @@ -196,7 +147,6 @@ 

    File: src/material/Material.js

    -
    diff --git a/docs/files/src_math_vec2.js.html b/docs/files/src_math_vec2.js.html index cf1166b5..2e409cdd 100644 --- a/docs/files/src_math_vec2.js.html +++ b/docs/files/src_math_vec2.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    File: src/math/vec2.js

    +

    File: src/math/vec2.js

    @@ -636,9 +587,16 @@ 

    File: src/math/vec2.js

    return 'vec2(' + a[0] + ', ' + a[1] + ')'; }; +vec2.lerp = function (out, a, b, t) { + var ax = a[0], + ay = a[1]; + out[0] = ax + t * (b[0] - ax); + out[1] = ay + t * (b[1] - ay); + return out; +}; +
    -
    diff --git a/docs/files/src_objects_Body.js.html b/docs/files/src_objects_Body.js.html index fb63ceaa..57e65452 100644 --- a/docs/files/src_objects_Body.js.html +++ b/docs/files/src_objects_Body.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    -
    -
    - -
    -
    -
    -
    - Show: - - - - - - - -
    - -
    -

    File: src/objects/Body.js

    +

    File: src/objects/Body.js

    @@ -198,8 +149,11 @@ 

    File: src/objects/Body.js

    * @param {Array} [options.force] * @param {Number} [options.angularForce=0] * @param {Number} [options.fixedRotation=false] + * @param {Number} [options.ccdSpeedThreshold=-1] + * @param {Number} [options.ccdIterations=10] * * @example + * * // Create a typical dynamic body * var body = new Body({ * mass: 1, @@ -294,7 +248,7 @@

    File: src/objects/Body.js

    * @property fixedRotation * @type {Boolean} */ - this.fixedRotation = !!options.fixedRotation || false; + this.fixedRotation = !!options.fixedRotation; /** * The position of the body @@ -540,6 +494,18 @@

    File: src/objects/Body.js

    */ this.gravityScale = 1; + /** + * Whether to produce contact forces when in contact with other bodies. Note that contacts will be generated, but they will be disabled. That means that this body will move through other bodies, but it will still trigger contact events, etc. + * @property {Boolean} collisionResponse + */ + this.collisionResponse = true; + + /** + * How long the body has been sleeping. + * @property {Number} idleTime + */ + this.idleTime = 0; + /** * The last time when the body went to SLEEPY state. * @property {Number} timeLastSleepy @@ -547,17 +513,28 @@

    File: src/objects/Body.js

    */ this.timeLastSleepy = 0; - this.concavePath = null; + /** + * If the body speed exceeds this threshold, CCD (continuous collision detection) will be enabled. Set it to a negative number to disable CCD completely for this body. + * @property {number} ccdSpeedThreshold + * @default -1 + */ + this.ccdSpeedThreshold = options.ccdSpeedThreshold !== undefined ? options.ccdSpeedThreshold : -1; - this.lastDampingScale = 1; - this.lastAngularDampingScale = 1; - this.lastDampingTimeStep = -1; + /** + * The number of iterations that should be used when searching for the time of impact during CCD. A larger number will assure that there's a small penetration on CCD collision, but a small number will give more performance. + * @property {number} ccdIterations + * @default 10 + */ + this.ccdIterations = options.ccdIterations !== undefined ? options.ccdIterations : 10; + + this.concavePath = null; this._wakeUpAfterNarrowphase = false; this.updateMassProperties(); } Body.prototype = new EventEmitter(); +Body.prototype.constructor = Body; Body._idCounter = 0; @@ -975,17 +952,9 @@

    File: src/objects/Body.js

    */ Body.prototype.applyDamping = function(dt){ if(this.type === Body.DYNAMIC){ // Only for dynamic bodies - - // Since Math.pow generates garbage we check if we can reuse the scaling coefficient from last step - if(dt !== this.lastDampingTimeStep){ - this.lastDampingScale = Math.pow(1.0 - this.damping,dt); - this.lastAngularDampingScale = Math.pow(1.0 - this.angularDamping,dt); - this.lastDampingTimeStep = dt; - } - var v = this.velocity; - vec2.scale(v,v,this.lastDampingScale); - this.angularVelocity *= this.lastAngularDampingScale; + vec2.scale(v, v, Math.pow(1.0 - this.damping,dt)); + this.angularVelocity *= Math.pow(1.0 - this.angularDamping,dt); } }; @@ -1072,6 +1041,7 @@

    File: src/objects/Body.js

    vec2.scale(store, store, 1/timeStep); return store; }; + Body.prototype.getAngularVelocityFromPosition = function(timeStep){ return (this.angle - this.previousAngle) / timeStep; }; @@ -1086,6 +1056,130 @@

    File: src/objects/Body.js

    return this.world.overlapKeeper.bodiesAreOverlapping(this, body); }; +var integrate_fhMinv = vec2.create(); +var integrate_velodt = vec2.create(); + +/** + * Move the body forward in time given its current velocity. + * @method integrate + * @param {Number} dt + */ +Body.prototype.integrate = function(dt){ + var minv = this.invMass, + f = this.force, + pos = this.position, + velo = this.velocity; + + // Save old position + vec2.copy(this.previousPosition, this.position); + this.previousAngle = this.angle; + + // Velocity update + if(!this.fixedRotation){ + this.angularVelocity += this.angularForce * this.invInertia * dt; + } + vec2.scale(integrate_fhMinv, f, dt * minv); + vec2.add(velo, integrate_fhMinv, velo); + + // CCD + if(!this.integrateToTimeOfImpact(dt)){ + + // Regular position update + vec2.scale(integrate_velodt, velo, dt); + vec2.add(pos, pos, integrate_velodt); + if(!this.fixedRotation){ + this.angle += this.angularVelocity * dt; + } + } + + this.aabbNeedsUpdate = true; +}; + +var direction = vec2.create(); +var end = vec2.create(); +var startToEnd = vec2.create(); +var rememberPosition = vec2.create(); +Body.prototype.integrateToTimeOfImpact = function(dt){ + + if(this.ccdSpeedThreshold < 0 || vec2.squaredLength(this.velocity) < Math.pow(this.ccdSpeedThreshold, 2)){ + return false; + } + + vec2.normalize(direction, this.velocity); + + vec2.scale(end, this.velocity, dt); + vec2.add(end, end, this.position); + + vec2.sub(startToEnd, end, this.position); + var startToEndAngle = this.angularVelocity * dt; + var len = vec2.length(startToEnd); + + var timeOfImpact = 1; + + var hit; + var that = this; + this.world.raycastAll(this.position, end, {}, function (result) { + if(result.body === that){ + return; + } + hit = result.body; + vec2.copy(end, result.hitPointWorld); + vec2.sub(startToEnd, result.hitPointWorld, that.position); + timeOfImpact = vec2.length(startToEnd) / len; + result.abort(); + }); + + if(!hit){ + return false; + } + + var rememberAngle = this.angle; + vec2.copy(rememberPosition, this.position); + + // Got a start and end point. Approximate time of impact using binary search + var iter = 0; + var tmin = 0; + var tmid = 0; + var tmax = timeOfImpact; + while (tmax >= tmin && iter < this.ccdIterations) { + iter++; + + // calculate the midpoint + tmid = (tmax - tmin) / 2; + + // Move the body to that point + vec2.scale(integrate_velodt, startToEnd, timeOfImpact); + vec2.add(this.position, rememberPosition, integrate_velodt); + this.angle = rememberAngle + startToEndAngle * timeOfImpact; + this.updateAABB(); + + // check overlap + var overlaps = this.aabb.overlaps(hit.aabb) && this.world.narrowphase.bodiesOverlap(this, hit); + + if (overlaps) { + // change min to search upper interval + tmin = tmid; + } else { + // change max to search lower interval + tmax = tmid; + } + } + + timeOfImpact = tmid; + + vec2.copy(this.position, rememberPosition); + this.angle = rememberAngle; + + // move to TOI + vec2.scale(integrate_velodt, startToEnd, timeOfImpact); + vec2.add(this.position, this.position, integrate_velodt); + if(!this.fixedRotation){ + this.angle += startToEndAngle * timeOfImpact; + } + + return true; +}; + /** * @event sleepy */ @@ -1155,7 +1249,6 @@

    File: src/objects/Body.js

    -
    diff --git a/docs/files/src_objects_LinearSpring.js.html b/docs/files/src_objects_LinearSpring.js.html index 53afb6bb..4468a9bb 100644 --- a/docs/files/src_objects_LinearSpring.js.html +++ b/docs/files/src_objects_LinearSpring.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    File: src/objects/LinearSpring.js

    +

    File: src/objects/LinearSpring.js

    @@ -237,6 +188,7 @@ 

    File: src/objects/LinearSpring.js

    this.restLength = typeof(options.restLength) === "number" ? options.restLength : worldDistance; } LinearSpring.prototype = new Spring(); +LinearSpring.prototype.constructor = LinearSpring; /** * Set the anchor point on body A, using world coordinates. @@ -344,7 +296,6 @@

    File: src/objects/LinearSpring.js

    -
    diff --git a/docs/files/src_objects_RotationalSpring.js.html b/docs/files/src_objects_RotationalSpring.js.html index 9a9e51d0..2c66217f 100644 --- a/docs/files/src_objects_RotationalSpring.js.html +++ b/docs/files/src_objects_RotationalSpring.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    File: src/objects/RotationalSpring.js

    +

    File: src/objects/RotationalSpring.js

    @@ -207,6 +158,7 @@ 

    File: src/objects/RotationalSpring.js

    this.restAngle = typeof(options.restAngle) === "number" ? options.restAngle : bodyB.angle - bodyA.angle; } RotationalSpring.prototype = new Spring(); +RotationalSpring.prototype.constructor = RotationalSpring; /** * Apply the spring force to the connected bodies. @@ -229,7 +181,6 @@

    File: src/objects/RotationalSpring.js

    -
    diff --git a/docs/files/src_objects_Spring.js.html b/docs/files/src_objects_Spring.js.html index d8ce4d60..55006e65 100644 --- a/docs/files/src_objects_Spring.js.html +++ b/docs/files/src_objects_Spring.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    File: src/objects/Spring.js

    +

    File: src/objects/Spring.js

    @@ -239,7 +190,6 @@ 

    File: src/objects/Spring.js

    -
    diff --git a/docs/files/src_shapes_Capsule.js.html b/docs/files/src_shapes_Capsule.js.html index 74ec6dab..4fc90966 100644 --- a/docs/files/src_shapes_Capsule.js.html +++ b/docs/files/src_shapes_Capsule.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    File: src/shapes/Capsule.js

    +

    File: src/shapes/Capsule.js

    @@ -184,8 +135,13 @@ 

    File: src/shapes/Capsule.js

    * @class Capsule * @constructor * @extends Shape - * @param {Number} [length] The distance between the end points - * @param {Number} [radius] Radius of the capsule + * @param {Number} [length=1] The distance between the end points + * @param {Number} [radius=1] Radius of the capsule + * @example + * var radius = 1; + * var length = 2; + * var capsuleShape = new Capsule(length, radius); + * body.addShape(capsuleShape); */ function Capsule(length, radius){ @@ -204,6 +160,7 @@

    File: src/shapes/Capsule.js

    Shape.call(this,Shape.CAPSULE); } Capsule.prototype = new Shape(); +Capsule.prototype.constructor = Capsule; /** * Compute the mass moment of inertia of the Capsule. @@ -264,7 +221,6 @@

    File: src/shapes/Capsule.js

    -
    diff --git a/docs/files/src_shapes_Circle.js.html b/docs/files/src_shapes_Circle.js.html index ae83cd4a..b68b4d06 100644 --- a/docs/files/src_shapes_Circle.js.html +++ b/docs/files/src_shapes_Circle.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    File: src/shapes/Circle.js

    +

    File: src/shapes/Circle.js

    @@ -185,6 +136,11 @@ 

    File: src/shapes/Circle.js

    * @extends Shape * @constructor * @param {number} [radius=1] The radius of this circle + * + * @example + * var radius = 1; + * var circleShape = new Circle(radius); + * body.addShape(circleShape); */ function Circle(radius){ @@ -198,6 +154,7 @@

    File: src/shapes/Circle.js

    Shape.call(this,Shape.CIRCLE); } Circle.prototype = new Shape(); +Circle.prototype.constructor = Circle; /** * @method computeMomentOfInertia @@ -243,7 +200,6 @@

    File: src/shapes/Circle.js

    -
    diff --git a/docs/files/src_shapes_Convex.js.html b/docs/files/src_shapes_Convex.js.html index 1e1786e0..1bc7063b 100644 --- a/docs/files/src_shapes_Convex.js.html +++ b/docs/files/src_shapes_Convex.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    File: src/shapes/Convex.js

    +

    File: src/shapes/Convex.js

    @@ -187,7 +138,12 @@ 

    File: src/shapes/Convex.js

    * @constructor * @extends Shape * @param {Array} vertices An array of vertices that span this shape. Vertices are given in counter-clockwise (CCW) direction. - * @param {Array} axes An array of unit length vectors + * @param {Array} [axes] An array of unit length vectors, representing the symmetry axes in the convex. + * @example + * // Create a box + * var vertices = [[-1,-1], [1,-1], [1,1], [-1,1]]; + * var convexShape = new Convex(vertices); + * body.addShape(convexShape); */ function Convex(vertices, axes){ @@ -272,6 +228,7 @@

    File: src/shapes/Convex.js

    } } Convex.prototype = new Shape(); +Convex.prototype.constructor = Convex; var tmpVec1 = vec2.create(); var tmpVec2 = vec2.create(); @@ -497,7 +454,6 @@

    File: src/shapes/Convex.js

    -
    diff --git a/docs/files/src_shapes_Heightfield.js.html b/docs/files/src_shapes_Heightfield.js.html index 5a14ba7c..aa6529f1 100644 --- a/docs/files/src_shapes_Heightfield.js.html +++ b/docs/files/src_shapes_Heightfield.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    File: src/shapes/Heightfield.js

    +

    File: src/shapes/Heightfield.js

    @@ -256,6 +207,7 @@ 

    File: src/shapes/Heightfield.js

    Shape.call(this,Shape.HEIGHTFIELD); } Heightfield.prototype = new Shape(); +Heightfield.prototype.constructor = Heightfield; /** * @method computeMomentOfInertia @@ -295,7 +247,6 @@

    File: src/shapes/Heightfield.js

    -
    diff --git a/docs/files/src_shapes_Line.js.html b/docs/files/src_shapes_Line.js.html index f7aec97d..01742aad 100644 --- a/docs/files/src_shapes_Line.js.html +++ b/docs/files/src_shapes_Line.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    File: src/shapes/Line.js

    +

    File: src/shapes/Line.js

    @@ -182,7 +133,7 @@ 

    File: src/shapes/Line.js

    /** * Line shape class. The line shape is along the x direction, and stretches from [-length/2, 0] to [length/2,0]. * @class Line - * @param {Number} length The total length of the line + * @param {Number} [length=1] The total length of the line * @extends Shape * @constructor */ @@ -198,6 +149,8 @@

    File: src/shapes/Line.js

    Shape.call(this,Shape.LINE); } Line.prototype = new Shape(); +Line.prototype.constructor = Line; + Line.prototype.computeMomentOfInertia = function(mass){ return mass * Math.pow(this.length,2) / 12; }; @@ -224,7 +177,6 @@

    File: src/shapes/Line.js

    -
    diff --git a/docs/files/src_shapes_Particle.js.html b/docs/files/src_shapes_Particle.js.html index f5e77f8d..761bbaf6 100644 --- a/docs/files/src_shapes_Particle.js.html +++ b/docs/files/src_shapes_Particle.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    File: src/shapes/Particle.js

    +

    File: src/shapes/Particle.js

    @@ -189,6 +140,8 @@ 

    File: src/shapes/Particle.js

    Shape.call(this,Shape.PARTICLE); } Particle.prototype = new Shape(); +Particle.prototype.constructor = Particle; + Particle.prototype.computeMomentOfInertia = function(mass){ return 0; // Can't rotate a particle }; @@ -210,7 +163,6 @@

    File: src/shapes/Particle.js

    -
    diff --git a/docs/files/src_shapes_Plane.js.html b/docs/files/src_shapes_Plane.js.html index e24070cc..642ae1e4 100644 --- a/docs/files/src_shapes_Plane.js.html +++ b/docs/files/src_shapes_Plane.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    File: src/shapes/Plane.js

    +

    File: src/shapes/Plane.js

    @@ -190,6 +141,7 @@ 

    File: src/shapes/Plane.js

    Shape.call(this,Shape.PLANE); } Plane.prototype = new Shape(); +Plane.prototype.constructor = Plane; /** * Compute moment of inertia @@ -253,7 +205,6 @@

    File: src/shapes/Plane.js

    -
    diff --git a/docs/files/src_shapes_Rectangle.js.html b/docs/files/src_shapes_Rectangle.js.html index 1ce71b42..e581a878 100644 --- a/docs/files/src_shapes_Rectangle.js.html +++ b/docs/files/src_shapes_Rectangle.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    File: src/shapes/Rectangle.js

    +

    File: src/shapes/Rectangle.js

    @@ -184,8 +135,8 @@ 

    File: src/shapes/Rectangle.js

    * Rectangle shape class. * @class Rectangle * @constructor - * @param {Number} width Width - * @param {Number} height Height + * @param {Number} [width=1] Width + * @param {Number} [height=1] Height * @extends Convex */ function Rectangle(width, height){ @@ -215,6 +166,7 @@

    File: src/shapes/Rectangle.js

    this.type = Shape.RECTANGLE; } Rectangle.prototype = new Convex([]); +Rectangle.prototype.constructor = Rectangle; /** * Compute moment of inertia @@ -260,7 +212,6 @@

    File: src/shapes/Rectangle.js

    -
    diff --git a/docs/files/src_shapes_Shape.js.html b/docs/files/src_shapes_Shape.js.html index e8d1ed80..552d18be 100644 --- a/docs/files/src_shapes_Shape.js.html +++ b/docs/files/src_shapes_Shape.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    File: src/shapes/Shape.js

    +

    File: src/shapes/Shape.js

    @@ -245,6 +196,12 @@ 

    File: src/shapes/Shape.js

    */ this.collisionGroup = 1; + /** + * Whether to produce contact forces when in contact with other bodies. Note that contacts will be generated, but they will be disabled. That means that this shape will move through other body shapes, but it will still trigger contact events, etc. + * @property {Boolean} collisionResponse + */ + this.collisionResponse = true; + /** * Collision mask of this shape. See .collisionGroup. * @property collisionMask @@ -368,7 +325,6 @@

    File: src/shapes/Shape.js

    -
    diff --git a/docs/files/src_solver_GSSolver.js.html b/docs/files/src_solver_GSSolver.js.html index 2c991765..daded225 100644 --- a/docs/files/src_solver_GSSolver.js.html +++ b/docs/files/src_solver_GSSolver.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    File: src/solver/GSSolver.js

    +

    File: src/solver/GSSolver.js

    @@ -236,6 +187,7 @@ 

    File: src/solver/GSSolver.js

    this.usedIterations = 0; } GSSolver.prototype = new Solver(); +GSSolver.prototype.constructor = GSSolver; function setArrayZero(array){ var l = array.length; @@ -419,7 +371,6 @@

    File: src/solver/GSSolver.js

    -
    diff --git a/docs/files/src_solver_Solver.js.html b/docs/files/src_solver_Solver.js.html index 2cde33a7..2516f2b4 100644 --- a/docs/files/src_solver_Solver.js.html +++ b/docs/files/src_solver_Solver.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    File: src/solver/Solver.js

    +

    File: src/solver/Solver.js

    @@ -208,6 +159,7 @@ 

    File: src/solver/Solver.js

    this.equationSortFunction = options.equationSortFunction || false; } Solver.prototype = new EventEmitter(); +Solver.prototype.constructor = Solver; /** * Method to be implemented in each subclass @@ -309,7 +261,6 @@

    File: src/solver/Solver.js

    -
    diff --git a/docs/files/src_utils_OverlapKeeper.js.html b/docs/files/src_utils_OverlapKeeper.js.html index f6446bee..011d4041 100644 --- a/docs/files/src_utils_OverlapKeeper.js.html +++ b/docs/files/src_utils_OverlapKeeper.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    File: src/utils/OverlapKeeper.js

    +

    File: src/utils/OverlapKeeper.js

    @@ -391,7 +342,6 @@ 

    File: src/utils/OverlapKeeper.js

    -
    diff --git a/docs/files/src_utils_TupleDictionary.js.html b/docs/files/src_utils_TupleDictionary.js.html index bc9331f3..4d2ce603 100644 --- a/docs/files/src_utils_TupleDictionary.js.html +++ b/docs/files/src_utils_TupleDictionary.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    File: src/utils/TupleDictionary.js

    +

    File: src/utils/TupleDictionary.js

    @@ -297,7 +248,6 @@ 

    File: src/utils/TupleDictionary.js

    -
    diff --git a/docs/files/src_utils_Utils.js.html b/docs/files/src_utils_Utils.js.html index e30e33e9..5e4481d3 100644 --- a/docs/files/src_utils_Utils.js.html +++ b/docs/files/src_utils_Utils.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    File: src/utils/Utils.js

    +

    File: src/utils/Utils.js

    @@ -270,7 +221,6 @@ 

    File: src/utils/Utils.js

    -
    diff --git a/docs/files/src_world_Island.js.html b/docs/files/src_world_Island.js.html index 3261ab0a..076bc104 100644 --- a/docs/files/src_world_Island.js.html +++ b/docs/files/src_world_Island.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    File: src/world/Island.js

    +

    File: src/world/Island.js

    @@ -262,7 +213,6 @@ 

    File: src/world/Island.js

    -
    diff --git a/docs/files/src_world_IslandManager.js.html b/docs/files/src_world_IslandManager.js.html index 44adc0fd..4699587d 100644 --- a/docs/files/src_world_IslandManager.js.html +++ b/docs/files/src_world_IslandManager.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    File: src/world/IslandManager.js

    +

    File: src/world/IslandManager.js

    @@ -362,7 +313,6 @@ 

    File: src/world/IslandManager.js

    -
    diff --git a/docs/files/src_world_IslandNode.js.html b/docs/files/src_world_IslandNode.js.html index d4f080fd..d8133e2c 100644 --- a/docs/files/src_world_IslandNode.js.html +++ b/docs/files/src_world_IslandNode.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -

    File: src/world/IslandNode.js

    +

    File: src/world/IslandNode.js

    @@ -223,7 +174,6 @@ 

    File: src/world/IslandNode.js

    -
    diff --git a/docs/files/src_world_World.js.html b/docs/files/src_world_World.js.html index 1c55d379..e8bf6771 100644 --- a/docs/files/src_world_World.js.html +++ b/docs/files/src_world_World.js.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    -
    -
    - -
    -
    -
    -
    - Show: - - - - - - - -
    - -
    -

    File: src/world/World.js

    +

    File: src/world/World.js

    @@ -180,6 +131,7 @@ 

    File: src/world/World.js

    var GSSolver = require('../solver/GSSolver') , Solver = require('../solver/Solver') , NaiveBroadphase = require('../collision/NaiveBroadphase') +, Ray = require('../collision/Ray') , vec2 = require('../math/vec2') , Circle = require('../shapes/Circle') , Rectangle = require('../shapes/Rectangle') @@ -340,7 +292,7 @@

    File: src/world/World.js

    * @property broadphase * @type {Broadphase} */ - this.broadphase = options.broadphase || new NaiveBroadphase(); + this.broadphase = options.broadphase || new SAPBroadphase(); this.broadphase.setWorld(this); /** @@ -572,6 +524,7 @@

    File: src/world/World.js

    this.overlapKeeper = new OverlapKeeper(); } World.prototype = new Object(EventEmitter.prototype); +World.prototype.constructor = World; /** * Never deactivate bodies. @@ -782,9 +735,7 @@

    File: src/world/World.js

    // Update approximate friction gravity. if(this.useWorldGravityAsFrictionGravity){ var gravityLen = vec2.length(this.gravity); - if(gravityLen === 0 && this.useFrictionGravityOnZeroGravity){ - // Leave friction gravity as it is. - } else { + if(!(gravityLen === 0 && this.useFrictionGravityOnZeroGravity)){ // Nonzero gravity. Use it. this.frictionGravity = gravityLen; } @@ -902,7 +853,7 @@

    File: src/world/World.js

    e.shapeA = data.shapeA; e.shapeB = data.shapeB; e.bodyA = data.bodyA; - e.bodyB = data.bodyA; + e.bodyB = data.bodyB; this.emit(e); } } @@ -960,7 +911,7 @@

    File: src/world/World.js

    var body = bodies[i]; if(body.sleepState !== Body.SLEEPING && body.type !== Body.STATIC){ - World.integrateBody(body,dt); + body.integrate(dt); } } @@ -1024,42 +975,6 @@

    File: src/world/World.js

    this.emit(this.postStepEvent); }; -var ib_fhMinv = vec2.create(); -var ib_velodt = vec2.create(); - -/** - * Move a body forward in time. - * @static - * @method integrateBody - * @param {Body} body - * @param {Number} dt - * @todo Move to Body.prototype? - */ -World.integrateBody = function(body,dt){ - var minv = body.invMass, - f = body.force, - pos = body.position, - velo = body.velocity; - - // Save old position - vec2.copy(body.previousPosition, body.position); - body.previousAngle = body.angle; - - // Angular step - if(!body.fixedRotation){ - body.angularVelocity += body.angularForce * body.invInertia * dt; - body.angle += body.angularVelocity * dt; - } - - // Linear step - vec2.scale(ib_fhMinv,f,dt*minv); - vec2.add(velo,ib_fhMinv,velo); - vec2.scale(ib_velodt,velo,dt); - vec2.add(pos,pos,ib_velodt); - - body.aabbNeedsUpdate = true; -}; - /** * Runs narrowphase for the shape pair i and j. * @method runNarrowphase @@ -1107,6 +1022,7 @@

    File: src/world/World.js

    np.stiffness = cm.stiffness; np.relaxation = cm.relaxation; np.contactSkinSize = cm.contactSkinSize; + np.enabledEquations = bi.collisionResponse && bj.collisionResponse && si.collisionResponse && sj.collisionResponse; var resolver = np[si.type | sj.type], numContacts = 0; @@ -1499,9 +1415,72 @@

    File: src/world/World.js

    }); }; +var tmpRay = new Ray(); + +/** + * Ray cast against all bodies. The provided callback will be executed for each hit with a RaycastResult as single argument. + * @method raycastAll + * @param {Vec3} from + * @param {Vec3} to + * @param {Object} options + * @param {number} [options.collisionMask=-1] + * @param {number} [options.collisionGroup=-1] + * @param {boolean} [options.skipBackfaces=false] + * @param {boolean} [options.checkCollisionResponse=true] + * @param {Function} callback + * @return {boolean} True if any body was hit. + */ +World.prototype.raycastAll = function(from, to, options, callback){ + options.mode = Ray.ALL; + options.from = from; + options.to = to; + options.callback = callback; + return tmpRay.intersectWorld(this, options); +}; + +/** + * Ray cast, and stop at the first result. Note that the order is random - but the method is fast. + * @method raycastAny + * @param {Vec3} from + * @param {Vec3} to + * @param {Object} options + * @param {number} [options.collisionMask=-1] + * @param {number} [options.collisionGroup=-1] + * @param {boolean} [options.skipBackfaces=false] + * @param {boolean} [options.checkCollisionResponse=true] + * @param {RaycastResult} result + * @return {boolean} True if any body was hit. + */ +World.prototype.raycastAny = function(from, to, options, result){ + options.mode = Ray.ANY; + options.from = from; + options.to = to; + options.result = result; + return tmpRay.intersectWorld(this, options); +}; + +/** + * Ray cast, and return information of the closest hit. + * @method raycastClosest + * @param {Vec3} from + * @param {Vec3} to + * @param {Object} options + * @param {number} [options.collisionMask=-1] + * @param {number} [options.collisionGroup=-1] + * @param {boolean} [options.skipBackfaces=false] + * @param {boolean} [options.checkCollisionResponse=true] + * @param {RaycastResult} result + * @return {boolean} True if any body was hit. + */ +World.prototype.raycastClosest = function(from, to, options, result){ + options.mode = Ray.CLOSEST; + options.from = from; + options.to = to; + options.result = result; + return tmpRay.intersectWorld(this, options); +};
    -
    diff --git a/docs/index.html b/docs/index.html index 7831a42c..a920a6a1 100644 --- a/docs/index.html +++ b/docs/index.html @@ -6,7 +6,7 @@ - + @@ -14,12 +14,10 @@
    - -

    - +

    - API Docs for: 0.6.0 + API Docs for: 0.6.1
    @@ -27,150 +25,103 @@

    - Show: - - - - - - - -
    - - + Show: + + + + + + + +
    +
    -
    +

    Browse to a module or class using the sidebar to view its API documentation. @@ -191,7 +142,6 @@

    Keyboard Shortcuts

    -
    diff --git a/package.json b/package.json index 71ae91e7..9519de5e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "p2", - "version": "0.6.0", + "version": "0.6.1", "description": "A JavaScript 2D physics engine.", "author": "Stefan Hedman (http://steffe.se)", "keywords": [