mirror of
https://github.com/liabru/matter-js.git
synced 2024-11-30 10:20:52 -05:00
Optimized Body's hidden class
This commit is contained in:
parent
0895d81fa1
commit
b3220cf3e8
1 changed files with 23 additions and 13 deletions
|
@ -20,6 +20,7 @@ var Common = require('../core/Common');
|
|||
var Bounds = require('../geometry/Bounds');
|
||||
var Axes = require('../geometry/Axes');
|
||||
|
||||
|
||||
(function() {
|
||||
|
||||
Body._inertiaScale = 4;
|
||||
|
@ -82,7 +83,22 @@ var Axes = require('../geometry/Axes');
|
|||
yOffset: 0
|
||||
},
|
||||
lineWidth: 0
|
||||
}
|
||||
},
|
||||
|
||||
events: null,
|
||||
bounds: null,
|
||||
chamfer: null,
|
||||
circleRadius: 0,
|
||||
positionPrev: null,
|
||||
anglePrev: 0,
|
||||
parent: null,
|
||||
|
||||
axes: null,
|
||||
area: 0,
|
||||
mass: 0,
|
||||
inertia: 0,
|
||||
|
||||
_original: null
|
||||
};
|
||||
|
||||
var body = Common.extend(defaults, options);
|
||||
|
@ -166,24 +182,18 @@ var Axes = require('../geometry/Axes');
|
|||
* Prefer to use the actual setter functions in performance critical situations.
|
||||
* @method set
|
||||
* @param {body} body
|
||||
* @param {} settings A property name (or map of properties and values) to set on the body.
|
||||
* @param {} value The value to set if `settings` is a single property name.
|
||||
* @param {object} settings A map of properties and values to set on the body.
|
||||
*/
|
||||
Body.set = function(body, settings, value) {
|
||||
var property;
|
||||
|
||||
if (typeof settings === 'string') {
|
||||
property = settings;
|
||||
settings = {};
|
||||
settings[property] = value;
|
||||
}
|
||||
Body.set = function(body, settings) {
|
||||
var property,
|
||||
value;
|
||||
|
||||
for (property in settings) {
|
||||
value = settings[property];
|
||||
|
||||
if (!settings.hasOwnProperty(property))
|
||||
continue;
|
||||
|
||||
value = settings[property];
|
||||
switch (property) {
|
||||
|
||||
case 'isStatic':
|
||||
|
@ -269,7 +279,7 @@ var Axes = require('../geometry/Axes');
|
|||
part.inverseMass = part._original.inverseMass;
|
||||
part.inverseInertia = part._original.inverseInertia;
|
||||
|
||||
delete part._original;
|
||||
part._original = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue