Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/v2.1-release'
Browse files Browse the repository at this point in the history
  • Loading branch information
pandamicro committed Jan 9, 2019
2 parents f4d7225 + 05ddefc commit 1c9b517
Show file tree
Hide file tree
Showing 87 changed files with 2,137 additions and 1,008 deletions.
161 changes: 38 additions & 123 deletions cocos2d/actions/CCActionInterval.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@
THE SOFTWARE.
****************************************************************************/

const quat = cc.vmath.quat;
let _quat_tmp = cc.quat();
let _vec3_tmp = cc.v3();


/**
* @module cc
Expand Down Expand Up @@ -871,54 +867,35 @@ cc.Spawn._actionOneTwo = function (action1, action2) {


/*
* Rotates a Node object to a certain angle by modifying its rotation property. <br/>
* Rotates a Node object to a certain angle by modifying its angle property. <br/>
* The direction will be decided by the shortest angle.
* @class RotateTo
* @extends ActionInterval
* @param {Number} duration duration in seconds
* @param {Number|Vec3} deltaAngleX deltaAngleX in degrees.
* @param {Number} [deltaAngleY] deltaAngleY in degrees.
* @param {Number} dstAngle dstAngle in degrees.
* @example
* var rotateTo = new cc.RotateTo(2, 61.0);
*/
cc.RotateTo = cc.Class({
name: 'cc.RotateTo',
extends: cc.ActionInterval,

ctor:function (duration, dstAngleX, dstAngleY) {
this._angle = cc.v3();
this._startAngle = cc.v3();
this._dstAngle = cc.v3();
this._need3D = false;
dstAngleX !== undefined && this.initWithDuration(duration, dstAngleX, dstAngleY);
ctor:function (duration, dstAngle) {
this._startAngle = 0;
this._dstAngle = 0;
this._angle = 0;
dstAngle !== undefined && this.initWithDuration(duration, dstAngle);
},

/*
* Initializes the action.
* @param {Number} duration
* @param {Number|Vec3} dstAngleX
* @param {Number} dstAngleY
* @param {Number} dstAngle
* @return {Boolean}
*/
initWithDuration:function (duration, dstAngleX, dstAngleY) {
initWithDuration:function (duration, dstAngle) {
if (cc.ActionInterval.prototype.initWithDuration.call(this, duration)) {
let dstAngle = this._dstAngle;
if (dstAngleX instanceof cc.Vec3) {
dstAngle.set(dstAngleX);
if (dstAngleX.x || dstAngleX.y) {
this._need3D = true;
}
}
else if (dstAngleY !== undefined) {
dstAngle.x = dstAngleX;
dstAngle.y = dstAngleY;
dstAngle.z = 0;
this._need3D = true;
}
else {
dstAngle.x = dstAngle.y = 0;
dstAngle.z = dstAngleX;
}
this._dstAngle = dstAngle;
return true;
}
return false;
Expand All @@ -931,27 +908,14 @@ cc.RotateTo = cc.Class({
return action;
},

_formatAngle (angle) {
if (angle > 180) angle -= 360;
if (angle < -180) angle += 360;
return angle;
},

startWithTarget:function (target) {
cc.ActionInterval.prototype.startWithTarget.call(this, target);

this._startAngle.set(target.eulerAngles);

let angle = this._angle;
cc.vmath.vec3.sub(angle, this._dstAngle, this._startAngle);

angle.x = this._formatAngle(angle.x);
angle.y = this._formatAngle(angle.y);
angle.z = this._formatAngle(angle.z);

if (this._need3D) {
target.is3DNode = true;
}
this._startAngle = target.angle % 360;
let angle = this._dstAngle - this._startAngle;
if (angle > 180) angle -= 360;
if (angle < -180) angle += 360;
this._angle = angle;
},

reverse:function () {
Expand All @@ -961,88 +925,58 @@ cc.RotateTo = cc.Class({
update:function (dt) {
dt = this._computeEaseTime(dt);
if (this.target) {
let angle = this._angle;
let startAngle = this._startAngle;
let rotationZ = -(startAngle.z + angle.z * dt);
if (this._need3D) {
let rotationX = startAngle.x + angle.x * dt;
let rotationY = startAngle.y + angle.y * dt;
quat.fromEuler(_quat_tmp, rotationX, rotationY, rotationZ);
this.target.setRotation(_quat_tmp);
}
else {
this.target.angle = rotationZ;
}
this.target.angle = this._startAngle + this._angle * dt;
}
}
});

/**
* !#en
* Rotates a Node object to a certain angle by modifying its rotation property. <br/>
* Rotates a Node object to a certain angle by modifying its angle property. <br/>
* The direction will be decided by the shortest angle.
* !#zh 旋转到目标角度,通过逐帧修改它的 rotation 属性,旋转方向将由最短的角度决定。
* !#zh 旋转到目标角度,通过逐帧修改它的 angle 属性,旋转方向将由最短的角度决定。
* @method rotateTo
* @param {Number} duration duration in seconds
* @param {Number} deltaAngleX deltaAngleX in degrees.
* @param {Number} [deltaAngleY] deltaAngleY in degrees.
* @param {Number} dstAngle dstAngle in degrees.
* @return {ActionInterval}
* @example
* // example
* var rotateTo = cc.rotateTo(2, 61.0);
*/
cc.rotateTo = function (duration, deltaAngleX, deltaAngleY) {
return new cc.RotateTo(duration, deltaAngleX, deltaAngleY);
cc.rotateTo = function (duration, dstAngle) {
return new cc.RotateTo(duration, dstAngle);
};


/*
* Rotates a Node object clockwise a number of degrees by modifying its rotation property.
* Rotates a Node object clockwise a number of degrees by modifying its angle property.
* Relative to its properties to modify.
* @class RotateBy
* @extends ActionInterval
* @param {Number} duration duration in seconds
* @param {Number|Vec3} deltaAngleX deltaAngleX in degrees
* @param {Number} [deltaAngleY] deltaAngleY in degrees
* @param {Number} deltaAngle deltaAngle in degrees
* @example
* var actionBy = new cc.RotateBy(2, 360);
*/
cc.RotateBy = cc.Class({
name: 'cc.RotateBy',
extends: cc.ActionInterval,

ctor: function (duration, deltaAngleX, deltaAngleY) {
this._angle = cc.v3();
this._startAngle = cc.v3();
this._need3D = false;
deltaAngleX !== undefined && this.initWithDuration(duration, deltaAngleX, deltaAngleY);
ctor: function (duration, deltaAngle) {
this._deltaAngle = cc.v3();
this._startAngle = 0;
deltaAngle !== undefined && this.initWithDuration(duration, deltaAngle);
},

/*
* Initializes the action.
* @param {Number} duration duration in seconds
* @param {Number|Vec3} deltaAngleX deltaAngleX in degrees
* @param {Number} [deltaAngleY=] deltaAngleY in degrees
* @param {Number} deltaAngle deltaAngle in degrees
* @return {Boolean}
*/
initWithDuration:function (duration, deltaAngleX, deltaAngleY) {
initWithDuration:function (duration, deltaAngle) {
if (cc.ActionInterval.prototype.initWithDuration.call(this, duration)) {
if (deltaAngleX instanceof cc.Vec3) {
this._angle.set(deltaAngleX);
if (deltaAngleX.x || deltaAngleX.y) {
this._need3D = true;
}
}
else if (deltaAngleY !== undefined) {
this._angle.x = deltaAngleX;
this._angle.y = deltaAngleY;
this._angle.z = 0;
this._need3D = true;
}
else {
this._angle.x = this._angle.y = 0;
this._angle.z = deltaAngleX;
}
this._deltaAngle = deltaAngle;
return true;
}
return false;
Expand All @@ -1051,42 +985,24 @@ cc.RotateBy = cc.Class({
clone:function () {
var action = new cc.RotateBy();
this._cloneDecoration(action);
action.initWithDuration(this._duration, this._angle);
action.initWithDuration(this._duration, this._deltaAngle);
return action;
},

startWithTarget:function (target) {
cc.ActionInterval.prototype.startWithTarget.call(this, target);
this._startAngle.set(target.eulerAngles);
if (this._need3D) {
target.is3DNode = true;
}
this._startAngle = target.angle;
},

update:function (dt) {
dt = this._computeEaseTime(dt);
if (this.target) {
let angle = this._angle;
let startAngle = this._startAngle;
let rotationZ = -(startAngle.z + angle.z * dt);
if (this._need3D) {
let rotationX = startAngle.x + angle.x * dt;
let rotationY = startAngle.y + angle.y * dt;
quat.fromEuler(_quat_tmp, rotationX, rotationY, rotationZ);
this.target.setRotation(_quat_tmp);
}
else {
this.target.angle = rotationZ;
}
this.target.angle = this._startAngle + this._deltaAngle * dt;
}
},

reverse:function () {
let angle = this._angle;
_vec3_tmp.x = -angle.x;
_vec3_tmp.y = -angle.y;
_vec3_tmp.z = -angle.z;
var action = new cc.RotateBy(this._duration, _vec3_tmp);
var action = new cc.RotateBy(this._duration, -this._deltaAngle);
this._cloneDecoration(action);
this._reverseEaseList(action);
return action;
Expand All @@ -1095,20 +1011,19 @@ cc.RotateBy = cc.Class({

/**
* !#en
* Rotates a Node object clockwise a number of degrees by modifying its rotation property.
* Rotates a Node object clockwise a number of degrees by modifying its angle property.
* Relative to its properties to modify.
* !#zh 旋转指定的角度。
* @method rotateBy
* @param {Number} duration duration in seconds
* @param {Number} deltaAngleX deltaAngleX in degrees
* @param {Number} [deltaAngleY] deltaAngleY in degrees
* @param {Number} deltaAngle deltaAngle in degrees
* @return {ActionInterval}
* @example
* // example
* var actionBy = cc.rotateBy(2, 360);
*/
cc.rotateBy = function (duration, deltaAngleX, deltaAngleY) {
return new cc.RotateBy(duration, deltaAngleX, deltaAngleY);
cc.rotateBy = function (duration, deltaAngle) {
return new cc.RotateBy(duration, deltaAngle);
};


Expand Down
8 changes: 4 additions & 4 deletions cocos2d/animation/animation-animator.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,10 @@ function initClipData (root, state) {
var curves = state.curves;
curves.length = 0;

state.duration = clip.duration;
state.speed = clip.speed;
state.wrapMode = clip.wrapMode;
state.frameRate = clip.sample;
state.duration = Number.parseFloat(clip.duration);
state.speed = Number.parseFloat(clip.speed);
state.wrapMode = Number.parseInt(clip.wrapMode);
state.frameRate = Number.parseFloat(clip.sample);

if ((state.wrapMode & WrapModeMask.Loop) === WrapModeMask.Loop) {
state.repeatCount = Infinity;
Expand Down
2 changes: 1 addition & 1 deletion cocos2d/audio/CCAudioEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ let getAudioFromId = function (id) {
};

let handleVolume = function (volume) {
if (!volume) {
if (volume === undefined) {
// set default volume as 1
volume = 1;
}
Expand Down
7 changes: 0 additions & 7 deletions cocos2d/core/3d/CCModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,20 +268,15 @@ let Model = cc.Class({
this._initNodes();

let gltf = this._gltf;
let bin = this._bin;

let accessors = gltf.accessors;
let gltfAnimation = gltf.animations[clip._animationID];

clip.name = gltfAnimation.name;
clip.wrapMode = cc.WrapMode.Loop;
let duration = 0;

let curveData = clip.curveData;
let paths = curveData.paths = {};

let nodes = gltf.nodes;
let rootNode = nodes[0];

let samplers = gltfAnimation.samplers;
let channels = gltfAnimation.channels;
Expand All @@ -292,8 +287,6 @@ let Model = cc.Class({
let inputArray = this._createArray(gltf, sampler.input);
let outputArray = this._createArray(gltf, sampler.output);

let interpolation = sampler.interpolation;

let target = gltfChannel.target;
let node = nodes[target.node];

Expand Down
Loading

0 comments on commit 1c9b517

Please sign in to comment.