|
@@ -18814,7 +18814,7 @@ var BABYLON;
|
|
|
this.actionManager = null;
|
|
|
}
|
|
|
// Skeleton
|
|
|
- this.skeleton = null;
|
|
|
+ this._skeleton = null;
|
|
|
// Physics
|
|
|
if (this.physicsImpostor) {
|
|
|
this.physicsImpostor.dispose();
|
|
@@ -21677,16 +21677,19 @@ var BABYLON;
|
|
|
* @type {BABYLON.Observable}
|
|
|
*/
|
|
|
this.onDisposeObservable = new BABYLON.Observable();
|
|
|
+ this._onDisposeObserver = null;
|
|
|
/**
|
|
|
* An event triggered before rendering the scene (right after animations and physics)
|
|
|
* @type {BABYLON.Observable}
|
|
|
*/
|
|
|
this.onBeforeRenderObservable = new BABYLON.Observable();
|
|
|
+ this._onBeforeRenderObserver = null;
|
|
|
/**
|
|
|
* An event triggered after rendering the scene
|
|
|
* @type {BABYLON.Observable}
|
|
|
*/
|
|
|
this.onAfterRenderObservable = new BABYLON.Observable();
|
|
|
+ this._onAfterRenderObserver = null;
|
|
|
/**
|
|
|
* An event triggered before animating the scene
|
|
|
* @type {BABYLON.Observable}
|
|
@@ -21727,11 +21730,13 @@ var BABYLON;
|
|
|
* @type {BABYLON.Observable}
|
|
|
*/
|
|
|
this.onBeforeCameraRenderObservable = new BABYLON.Observable();
|
|
|
+ this._onBeforeCameraRenderObserver = null;
|
|
|
/**
|
|
|
* An event triggered after rendering a camera
|
|
|
* @type {BABYLON.Observable}
|
|
|
*/
|
|
|
this.onAfterCameraRenderObservable = new BABYLON.Observable();
|
|
|
+ this._onAfterCameraRenderObserver = null;
|
|
|
/**
|
|
|
* An event triggered when active meshes evaluation is about to start
|
|
|
* @type {BABYLON.Observable}
|
|
@@ -23440,9 +23445,7 @@ var BABYLON;
|
|
|
this.beginAnimation(animatables[index], from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent);
|
|
|
}
|
|
|
}
|
|
|
- if (stopCurrent) {
|
|
|
- animatable.reset();
|
|
|
- }
|
|
|
+ animatable.reset();
|
|
|
return animatable;
|
|
|
};
|
|
|
/**
|
|
@@ -23492,6 +23495,20 @@ var BABYLON;
|
|
|
}
|
|
|
return null;
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Gets all animatables associated with a given target
|
|
|
+ * @param target defines the target to look animatables for
|
|
|
+ * @returns an array of Animatables
|
|
|
+ */
|
|
|
+ Scene.prototype.getAllAnimatablesByTarget = function (target) {
|
|
|
+ var result = [];
|
|
|
+ for (var index = 0; index < this._activeAnimatables.length; index++) {
|
|
|
+ if (this._activeAnimatables[index].target === target) {
|
|
|
+ result.push(this._activeAnimatables[index]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ };
|
|
|
Object.defineProperty(Scene.prototype, "animatables", {
|
|
|
get: function () {
|
|
|
return this._activeAnimatables;
|
|
@@ -23502,12 +23519,13 @@ var BABYLON;
|
|
|
/**
|
|
|
* Will stop the animation of the given target
|
|
|
* @param target - the target
|
|
|
- * @param animationName - the name of the animation to stop (all animations will be stopped is empty)
|
|
|
+ * @param animationName - the name of the animation to stop (all animations will be stopped if empty)
|
|
|
* @see beginAnimation
|
|
|
*/
|
|
|
Scene.prototype.stopAnimation = function (target, animationName) {
|
|
|
- var animatable = this.getAnimatableByTarget(target);
|
|
|
- if (animatable) {
|
|
|
+ var animatables = this.getAllAnimatablesByTarget(target);
|
|
|
+ for (var _i = 0, animatables_1 = animatables; _i < animatables_1.length; _i++) {
|
|
|
+ var animatable = animatables_1[_i];
|
|
|
animatable.stop(animationName);
|
|
|
}
|
|
|
};
|
|
@@ -47966,12 +47984,16 @@ var BABYLON;
|
|
|
* @param scene defines the hosting scene
|
|
|
*/
|
|
|
function RuntimeAnimation(target, animation, scene) {
|
|
|
+ this.currentFrame = 0;
|
|
|
this._offsetsCache = {};
|
|
|
this._highLimitsCache = {};
|
|
|
this._stopped = false;
|
|
|
this._blendingFactor = 0;
|
|
|
+ this._targetPath = "";
|
|
|
this._weight = 1.0;
|
|
|
this._ratioOffset = 0;
|
|
|
+ this._previousDelay = 0;
|
|
|
+ this._previousRatio = 0;
|
|
|
this._animation = animation;
|
|
|
this._target = target;
|
|
|
this._scene = scene;
|
|
@@ -48183,7 +48205,7 @@ var BABYLON;
|
|
|
for (var index = 1; index < targetPropertyPath.length - 1; index++) {
|
|
|
property = property[targetPropertyPath[index]];
|
|
|
}
|
|
|
- path = [targetPropertyPath.length - 1];
|
|
|
+ path = targetPropertyPath[targetPropertyPath.length - 1];
|
|
|
destination = property;
|
|
|
}
|
|
|
else {
|
|
@@ -48196,7 +48218,18 @@ var BABYLON;
|
|
|
// Blending
|
|
|
var enableBlending = this._target && this._target.animationPropertiesOverride ? this._target.animationPropertiesOverride.enableBlending : this._animation.enableBlending;
|
|
|
var blendingSpeed = this._target && this._target.animationPropertiesOverride ? this._target.animationPropertiesOverride.blendingSpeed : this._animation.blendingSpeed;
|
|
|
- if (enableBlending && this._blendingFactor <= 1.0 || weight !== -1.0) {
|
|
|
+ if (enableBlending && this._blendingFactor <= 1.0) {
|
|
|
+ if (!this._originalBlendValue) {
|
|
|
+ var originalValue = destination[path];
|
|
|
+ if (originalValue.clone) {
|
|
|
+ this._originalBlendValue = originalValue.clone();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ this._originalBlendValue = originalValue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (weight !== -1.0) {
|
|
|
if (!this._originalValue) {
|
|
|
var originalValue = void 0;
|
|
|
if (destination.getRestPose) {
|
|
@@ -48214,31 +48247,30 @@ var BABYLON;
|
|
|
}
|
|
|
}
|
|
|
if (enableBlending && this._blendingFactor <= 1.0) {
|
|
|
- if (this._originalValue.prototype) {
|
|
|
- if (this._originalValue.prototype.Lerp) {
|
|
|
- this._currentValue = this._originalValue.construtor.prototype.Lerp(currentValue, this._originalValue, this._blendingFactor);
|
|
|
+ if (this._originalBlendValue.prototype) {
|
|
|
+ if (this._originalBlendValue.prototype.Lerp) {
|
|
|
+ this._currentValue = this._originalBlendValue.construtor.prototype.Lerp(currentValue, this._originalBlendValue, this._blendingFactor);
|
|
|
}
|
|
|
else {
|
|
|
this._currentValue = currentValue;
|
|
|
}
|
|
|
}
|
|
|
- else if (this._originalValue.m) {
|
|
|
- this._currentValue = BABYLON.Matrix.Lerp(this._originalValue, currentValue, this._blendingFactor);
|
|
|
+ else if (this._originalBlendValue.m) {
|
|
|
+ this._currentValue = BABYLON.Matrix.Lerp(this._originalBlendValue, currentValue, this._blendingFactor);
|
|
|
}
|
|
|
else {
|
|
|
- this._currentValue = this._originalValue * (1.0 - this._blendingFactor) + this._blendingFactor * currentValue;
|
|
|
+ this._currentValue = this._originalBlendValue * (1.0 - this._blendingFactor) + this._blendingFactor * currentValue;
|
|
|
}
|
|
|
this._blendingFactor += blendingSpeed;
|
|
|
- destination[path] = this._currentValue;
|
|
|
}
|
|
|
else {
|
|
|
this._currentValue = currentValue;
|
|
|
- if (weight !== -1.0) {
|
|
|
- this._scene._registerTargetForLateAnimationBinding(this);
|
|
|
- }
|
|
|
- else {
|
|
|
- destination[path] = this._currentValue;
|
|
|
- }
|
|
|
+ }
|
|
|
+ if (weight !== -1.0) {
|
|
|
+ this._scene._registerTargetForLateAnimationBinding(this);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ destination[path] = this._currentValue;
|
|
|
}
|
|
|
if (this._target.markAsDirty) {
|
|
|
this._target.markAsDirty(this._animation.targetProperty);
|
|
@@ -48618,6 +48650,9 @@ var BABYLON;
|
|
|
this._localDelayOffset += delay - this._pausedDelay;
|
|
|
this._pausedDelay = null;
|
|
|
}
|
|
|
+ if (this._weight === 0) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
// Animating
|
|
|
var running = false;
|
|
|
var runtimeAnimations = this._runtimeAnimations;
|
|
@@ -79449,11 +79484,10 @@ var BABYLON;
|
|
|
this._tmpImpostorsArray = [];
|
|
|
this._tmpPositionVector = BABYLON.Vector3.Zero();
|
|
|
this.BJSOIMO = typeof OIMO !== 'undefined' ? OIMO : (typeof require !== 'undefined' ? require('./Oimo') : undefined);
|
|
|
- this.world = new this.BJSOIMO.World(1 / 60, 2, iterations, true);
|
|
|
- this.world.worldscale(1);
|
|
|
+ this.world = new this.BJSOIMO.World({
|
|
|
+ iterations: iterations
|
|
|
+ });
|
|
|
this.world.clear();
|
|
|
- //making sure no stats are calculated
|
|
|
- this.world.isNoStat = true;
|
|
|
}
|
|
|
OimoJSPlugin.prototype.setGravity = function (gravity) {
|
|
|
this.world.gravity.copy(gravity);
|
|
@@ -79495,8 +79529,8 @@ var BABYLON;
|
|
|
}
|
|
|
};
|
|
|
OimoJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
|
|
|
- var mass = impostor.physicsBody.massInfo.mass;
|
|
|
- impostor.physicsBody.applyImpulse(contactPoint.scale(this.BJSOIMO.INV_SCALE), force.scale(this.BJSOIMO.INV_SCALE * mass));
|
|
|
+ var mass = impostor.physicsBody.mass;
|
|
|
+ impostor.physicsBody.applyImpulse(contactPoint.scale(this.world.invScale), force.scale(this.world.invScale * mass));
|
|
|
};
|
|
|
OimoJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
|
|
|
BABYLON.Tools.Warn("Oimo doesn't support applying force. Using impule instead.");
|
|
@@ -79521,8 +79555,13 @@ var BABYLON;
|
|
|
size: [],
|
|
|
type: [],
|
|
|
pos: [],
|
|
|
+ posShape: [],
|
|
|
rot: [],
|
|
|
+ rotShape: [],
|
|
|
move: impostor.getParam("mass") !== 0,
|
|
|
+ density: impostor.getParam("mass"),
|
|
|
+ friction: impostor.getParam("friction"),
|
|
|
+ restitution: impostor.getParam("restitution"),
|
|
|
//Supporting older versions of Oimo
|
|
|
world: this.world
|
|
|
};
|
|
@@ -79542,18 +79581,14 @@ var BABYLON;
|
|
|
return Math.max(value, BABYLON.PhysicsEngine.Epsilon);
|
|
|
};
|
|
|
impostors.forEach(function (i) {
|
|
|
- if (!impostor.object.rotationQuaternion) {
|
|
|
+ if (!i.object.rotationQuaternion) {
|
|
|
return;
|
|
|
}
|
|
|
//get the correct bounding box
|
|
|
var oldQuaternion = i.object.rotationQuaternion;
|
|
|
- var rot = new _this.BJSOIMO.Euler().setFromQuaternion({
|
|
|
- x: impostor.object.rotationQuaternion.x,
|
|
|
- y: impostor.object.rotationQuaternion.y,
|
|
|
- z: impostor.object.rotationQuaternion.z,
|
|
|
- s: impostor.object.rotationQuaternion.w
|
|
|
- });
|
|
|
+ var rot = oldQuaternion.toEulerAngles();
|
|
|
var extendSize = i.getObjectExtendSize();
|
|
|
+ var radToDeg = 57.295779513082320876;
|
|
|
if (i === impostor) {
|
|
|
var center = impostor.getObjectCenter();
|
|
|
impostor.object.getAbsolutePivotPoint().subtractToRef(center, _this._tmpPositionVector);
|
|
@@ -79562,25 +79597,31 @@ var BABYLON;
|
|
|
bodyConfig.pos.push(center.x);
|
|
|
bodyConfig.pos.push(center.y);
|
|
|
bodyConfig.pos.push(center.z);
|
|
|
+ bodyConfig.posShape.push(0, 0, 0);
|
|
|
//tmp solution
|
|
|
- bodyConfig.rot.push(rot.x / (_this.BJSOIMO.degtorad || _this.BJSOIMO.TO_RAD));
|
|
|
- bodyConfig.rot.push(rot.y / (_this.BJSOIMO.degtorad || _this.BJSOIMO.TO_RAD));
|
|
|
- bodyConfig.rot.push(rot.z / (_this.BJSOIMO.degtorad || _this.BJSOIMO.TO_RAD));
|
|
|
+ bodyConfig.rot.push(rot.x * radToDeg);
|
|
|
+ bodyConfig.rot.push(rot.y * radToDeg);
|
|
|
+ bodyConfig.rot.push(rot.z * radToDeg);
|
|
|
+ bodyConfig.rotShape.push(0, 0, 0);
|
|
|
}
|
|
|
else {
|
|
|
var localPosition = i.object.getAbsolutePosition().subtract(impostor.object.getAbsolutePosition());
|
|
|
- bodyConfig.pos.push(localPosition.x);
|
|
|
- bodyConfig.pos.push(localPosition.y);
|
|
|
- bodyConfig.pos.push(localPosition.z);
|
|
|
+ bodyConfig.posShape.push(localPosition.x);
|
|
|
+ bodyConfig.posShape.push(localPosition.y);
|
|
|
+ bodyConfig.posShape.push(localPosition.z);
|
|
|
+ bodyConfig.pos.push(0, 0, 0);
|
|
|
//tmp solution until https://github.com/lo-th/OIMO.js/pull/37 is merged
|
|
|
bodyConfig.rot.push(0);
|
|
|
bodyConfig.rot.push(0);
|
|
|
bodyConfig.rot.push(0);
|
|
|
+ bodyConfig.rotShape.push(rot.x * radToDeg);
|
|
|
+ bodyConfig.rotShape.push(rot.y * radToDeg);
|
|
|
+ bodyConfig.rotShape.push(rot.z * radToDeg);
|
|
|
}
|
|
|
// register mesh
|
|
|
switch (i.type) {
|
|
|
case BABYLON.PhysicsImpostor.ParticleImpostor:
|
|
|
- BABYLON.Tools.Warn("No Particle support in this.BJSOIMO.js. using SphereImpostor instead");
|
|
|
+ BABYLON.Tools.Warn("No Particle support in OIMO.js. using SphereImpostor instead");
|
|
|
case BABYLON.PhysicsImpostor.SphereImpostor:
|
|
|
var radiusX = extendSize.x;
|
|
|
var radiusY = extendSize.y;
|
|
@@ -79608,15 +79649,19 @@ var BABYLON;
|
|
|
var sizeY = checkWithEpsilon_1(extendSize.y);
|
|
|
var sizeZ = checkWithEpsilon_1(extendSize.z);
|
|
|
bodyConfig.type.push('box');
|
|
|
+ //if (i === impostor) {
|
|
|
bodyConfig.size.push(sizeX);
|
|
|
bodyConfig.size.push(sizeY);
|
|
|
bodyConfig.size.push(sizeZ);
|
|
|
+ //} else {
|
|
|
+ // bodyConfig.size.push(0,0,0);
|
|
|
+ //}
|
|
|
break;
|
|
|
}
|
|
|
//actually not needed, but hey...
|
|
|
i.object.rotationQuaternion = oldQuaternion;
|
|
|
});
|
|
|
- impostor.physicsBody = new this.BJSOIMO.Body(bodyConfig).body; //this.world.add(bodyConfig);
|
|
|
+ impostor.physicsBody = this.world.add(bodyConfig);
|
|
|
}
|
|
|
else {
|
|
|
this._tmpPositionVector.copyFromFloats(0, 0, 0);
|
|
@@ -79658,7 +79703,7 @@ var BABYLON;
|
|
|
type = "jointBall";
|
|
|
break;
|
|
|
case BABYLON.PhysicsJoint.SpringJoint:
|
|
|
- BABYLON.Tools.Warn("this.BJSOIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");
|
|
|
+ BABYLON.Tools.Warn("OIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");
|
|
|
var springData = jointData;
|
|
|
nativeJointData.min = springData.length || nativeJointData.min;
|
|
|
//Max should also be set, just make sure it is at least min
|
|
@@ -79682,7 +79727,7 @@ var BABYLON;
|
|
|
break;
|
|
|
}
|
|
|
nativeJointData.type = type;
|
|
|
- impostorJoint.joint.physicsJoint = new this.BJSOIMO.Link(nativeJointData).joint; //this.world.add(nativeJointData);
|
|
|
+ impostorJoint.joint.physicsJoint = this.world.add(nativeJointData);
|
|
|
};
|
|
|
OimoJSPlugin.prototype.removeJoint = function (impostorJoint) {
|
|
|
//Bug in Oimo prevents us from disposing a joint in the playground
|
|
@@ -79701,35 +79746,32 @@ var BABYLON;
|
|
|
OimoJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
|
|
|
if (!impostor.physicsBody.sleeping) {
|
|
|
//TODO check that
|
|
|
- if (impostor.physicsBody.shapes.next) {
|
|
|
+ /*if (impostor.physicsBody.shapes.next) {
|
|
|
var parentShape = this._getLastShape(impostor.physicsBody);
|
|
|
- impostor.object.position.x = parentShape.position.x * this.BJSOIMO.WORLD_SCALE;
|
|
|
- impostor.object.position.y = parentShape.position.y * this.BJSOIMO.WORLD_SCALE;
|
|
|
- impostor.object.position.z = parentShape.position.z * this.BJSOIMO.WORLD_SCALE;
|
|
|
- }
|
|
|
- else {
|
|
|
- impostor.object.position.copyFrom(impostor.physicsBody.getPosition());
|
|
|
- }
|
|
|
+ impostor.object.position.copyFrom(parentShape.position);
|
|
|
+ console.log(parentShape.position);
|
|
|
+ } else {*/
|
|
|
+ impostor.object.position.copyFrom(impostor.physicsBody.getPosition());
|
|
|
+ //}
|
|
|
if (impostor.object.rotationQuaternion) {
|
|
|
impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.getQuaternion());
|
|
|
- impostor.object.rotationQuaternion.normalize();
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
OimoJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
|
|
|
var body = impostor.physicsBody;
|
|
|
- body.position.init(newPosition.x * this.BJSOIMO.INV_SCALE, newPosition.y * this.BJSOIMO.INV_SCALE, newPosition.z * this.BJSOIMO.INV_SCALE);
|
|
|
- body.orientation.init(newRotation.w, newRotation.x, newRotation.y, newRotation.z);
|
|
|
+ body.position.copy(newPosition);
|
|
|
+ body.orientation.copy(newRotation);
|
|
|
body.syncShapes();
|
|
|
body.awake();
|
|
|
};
|
|
|
- OimoJSPlugin.prototype._getLastShape = function (body) {
|
|
|
+ /*private _getLastShape(body: any): any {
|
|
|
var lastShape = body.shapes;
|
|
|
while (lastShape.next) {
|
|
|
lastShape = lastShape.next;
|
|
|
}
|
|
|
return lastShape;
|
|
|
- };
|
|
|
+ }*/
|
|
|
OimoJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
|
|
|
impostor.physicsBody.linearVelocity.init(velocity.x, velocity.y, velocity.z);
|
|
|
};
|