support search skeleton animation clips (#3175)

* support search skeleton animation clips

* fixed node property

* fixed comment

* fixed test
This commit is contained in:
yinkaile
2018-09-02 23:51:54 +08:00
committed by pandamicro
parent a33be26b1a
commit 6d9c3c7089
3 changed files with 53 additions and 26 deletions
+28
View File
@@ -41,6 +41,10 @@ var SkeletonAnimation = cc.Class({
name: 'cc.SkeletonAnimation',
extends: Animation,
editor: CC_EDITOR && {
inspector: 'packages://inspector/inspectors/comps/skeleton-animation.js',
},
properties: {
_model: Model,
_nodes: [cc.Node],
@@ -82,6 +86,30 @@ var SkeletonAnimation = cc.Class({
let clip = state.clip;
clip.init(this._nodes);
return state;
},
searchClips: CC_EDITOR && function () {
this._clips.length = 0;
let self = this;
Editor.assetdb.queryPathByUuid(this._model._uuid, function (err, modelPath) {
if (err) return console.error(err);
const Path = require('fire-path');
let queryPath = Path.relative(Editor.remote.Project.path, modelPath);
queryPath = Path.join(Path.dirname(queryPath), Path.basenameNoExt(queryPath));
queryPath = `db://${queryPath}*/*.sac`;
Editor.assetdb.queryAssets(queryPath, null, function (err, results) {
if (results) {
for (let i = 0; i < results.length; i++) {
let clip = new SkeletonAnimationClip();
clip._uuid = results[i].uuid;
self._clips.push(clip);
}
self._defaultClip = self._clips[0];
}
});
});
}
});
+1 -1
View File
@@ -30,7 +30,7 @@ const Model = require('./CCModel');
*/
/**
* !#en SkeletonAnimationClip Asset.
* !#zh 网格资源。
* !#zh 骨骼动画剪辑。
* @class SkeletonAnimationClip
* @extends AnimationClip
*/
+24 -25
View File
@@ -713,24 +713,6 @@ var Node = cc.Class({
* node.rotation = 90;
* cc.log("Node Rotation: " + node.rotation);
*/
rotation: {
get () {
return this._rotationX;
},
set (value) {
if (this._rotationX !== value || this._rotationY !== value) {
this._rotationX = this._rotationY = value;
// Update quaternion from rotation
math.quat.fromEuler(this._quat, 0, 0, -value);
this.setLocalDirty(LocalDirtyFlag.ROTATION);
this._renderFlag |= RenderFlow.FLAG_TRANSFORM;
if (this._eventMask & ROTATION_ON) {
this.emit(EventType.ROTATION_CHANGED);
}
}
}
},
/**
* !#en The rotation as Euler angles in degrees, used in 2.5D project.
@@ -2131,19 +2113,36 @@ var Node = cc.Class({
}
},
/**
* !#en Set rotation of node (along z axi).
* !#zh 设置该节点以局部坐标系 Z 轴为轴进行旋转的角度。
* @method setRotation
* @param {Number} rotation Degree rotation value
*/
/**
* !#en Get rotation of node (along z axi).
* !#zh 获取该节点以局部坐标系 Z 轴为轴进行旋转的角度。
* @method getRotation
* @param {Number} rotation Degree rotation value
*/
getRotation () {
return this._rotationX;
},
/**
* !#en Set rotation of node (along z axi).
* !#zh 设置该节点以局部坐标系 Z 轴为轴进行旋转的角度。
* @method setRotation
* @param {Number} rotation Degree rotation value
*/
setRotation (value) {
if (this._rotationX !== value || this._rotationY !== value) {
this._rotationX = this._rotationY = value;
// Update quaternion from rotation
math.quat.fromEuler(this._quat, 0, 0, -value);
this.setLocalDirty(LocalDirtyFlag.ROTATION);
this._renderFlag |= RenderFlow.FLAG_TRANSFORM;
if (this._eventMask & ROTATION_ON) {
this.emit(EventType.ROTATION_CHANGED);
}
}
},
/**
* !#en