mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-02 00:22:43 +08:00
913c9013eb
* Modify part of asset classes * Update import * Update * mesh-loader * Update the import statement of JsonAsset as default import * Rename files * Remove old asset and asset-mng * Copyrights * Fix some bugs * Fix imports of vmath classes; Fix errors of decorator property's ts comment notation;Adjust the order of member declarations for better IDE intelligense * Transplant loader of animation clip; Unify export statement style according rules * Skeleton asset and SkeletonInstance class * Rename * Fix material annotation * fix import path * fix annotation error * Rename update to flush, fix index.js files. * support original gltf animation;use creator's texture2d instead * Fix build issues * Avoid system absent issue caused by ecs import * add renderer to ccgame, add camera component * apply stash * fix predefine.js * add renderable and rendersystem * fix format * Fix core/utils module * Rename file and fix issues * add renderer to ccgame, add camera component * apply stash * fix predefine.js * add renderable and rendersystem * fix format * fix debug * fix run errors * Fix MutableForwardIterator not found issue * Fix editor runtime issues * Update 3d node API usage (need merge API in future) * Temporarily comment out rendering code (need revert) * add renderer to ccgame, add camera component * apply stash * fix predefine.js * add renderable and rendersystem * fix format * fix debug * fix run errors * renderer can clear now * misc fixes in vmath better vector random sampling custom w in vec3.transformMat4 * prepare geometry data in editor mode * per-primitive raycast for editor * fix dependencies * fix cctouch error * fix error, can not rendering * model can be rendered * fix for node api changing * class rename * clean up code * add name to ccclass decorators; temporarily comment out vb/ib buffer creation in gltf-loader;temporarily modification of base-node.js * Open commented vb/ib creation * make gltf-asset itself a variant of json * fix import bugs * update * import fix * node transform api * mesh renderer and skinning mesh renderer * bug fix * bug fix
158 lines
4.7 KiB
JavaScript
158 lines
4.7 KiB
JavaScript
/****************************************************************************
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
|
|
|
http://www.cocos.com
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
of this software and associated engine source code (the "Software"), a limited,
|
|
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
|
to use Cocos Creator solely to develop games on your target platforms. You shall
|
|
not use Cocos Creator software for developing other software or tools that's
|
|
used for developing games. You are not granted to publish, distribute,
|
|
sublicense, and/or sell copies of Cocos Creator.
|
|
|
|
The software or tools in this License Agreement are licensed, not sold.
|
|
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
|
|
|
|
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
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
THE SOFTWARE.
|
|
****************************************************************************/
|
|
|
|
const WrapMode = require('./types').WrapMode;
|
|
|
|
/**
|
|
* !#en Class for animation data handling.
|
|
* !#zh 动画剪辑,用于存储动画数据。
|
|
* @class AnimationClip
|
|
* @extends Asset
|
|
*/
|
|
var AnimationClip = cc.Class({
|
|
name: 'cc.AnimationClip2',
|
|
extends: cc.Asset,
|
|
|
|
properties: {
|
|
_duration: {
|
|
default: 0,
|
|
type: 'Float',
|
|
},
|
|
|
|
/**
|
|
* !#en Duration of this animation.
|
|
* !#zh 动画的持续时间。
|
|
* @property duration
|
|
* @type {Number}
|
|
*/
|
|
duration: {
|
|
get: function () { return this._duration; },
|
|
},
|
|
|
|
/**
|
|
* !#en FrameRate of this animation.
|
|
* !#zh 动画的帧速率。
|
|
* @property sample
|
|
* @type {Number}
|
|
*/
|
|
sample: {
|
|
default: 60,
|
|
},
|
|
|
|
/**
|
|
* !#en Speed of this animation.
|
|
* !#zh 动画的播放速度。
|
|
* @property speed
|
|
* @type {Number}
|
|
*/
|
|
speed: {
|
|
default: 1
|
|
},
|
|
|
|
/**
|
|
* !#en WrapMode of this animation.
|
|
* !#zh 动画的循环模式。
|
|
* @property wrapMode
|
|
* @type {WrapMode}
|
|
*/
|
|
wrapMode: {
|
|
default: WrapMode.Normal
|
|
},
|
|
|
|
/**
|
|
* !#en Curve data.
|
|
* !#zh 曲线数据。
|
|
* @property curveData
|
|
* @type {Object}
|
|
* @example {@link cocos2d/core/animation-clip/curve-data.js}
|
|
*/
|
|
curveData: {
|
|
default: {},
|
|
visible: false,
|
|
},
|
|
|
|
/**
|
|
* !#en Event data.
|
|
* !#zh 事件数据。
|
|
* @property events
|
|
* @type {Object[]}
|
|
* @example {@link cocos2d/core/animation-clip/event-data.js}
|
|
* @typescript events: {frame: number, func: string, params: string[]}[]
|
|
*/
|
|
events: {
|
|
default: [],
|
|
visible: false,
|
|
}
|
|
},
|
|
|
|
statics: {
|
|
/**
|
|
* !#en Crate clip with a set of sprite frames
|
|
* !#zh 使用一组序列帧图片来创建动画剪辑
|
|
* @method createWithSpriteFrames
|
|
* @param {[SpriteFrame]} spriteFrames
|
|
* @param {Number} sample
|
|
* @return {AnimationClip}
|
|
* @static
|
|
* @example
|
|
*
|
|
* var clip = cc.AnimationClip.createWithSpriteFrames(spriteFrames, 10);
|
|
*
|
|
*/
|
|
createWithSpriteFrames: function (spriteFrames, sample) {
|
|
if (!Array.isArray(spriteFrames)) {
|
|
cc.errorID(3905);
|
|
return null;
|
|
}
|
|
|
|
var clip = new AnimationClip();
|
|
clip.sample = sample || clip.sample;
|
|
|
|
clip._duration = spriteFrames.length / clip.sample;
|
|
|
|
var frames = [];
|
|
var step = 1 / clip.sample;
|
|
|
|
for (var i = 0, l = spriteFrames.length; i < l; i++) {
|
|
frames[i] = { frame: (i * step), value: spriteFrames[i] };
|
|
}
|
|
|
|
clip.curveData = {
|
|
comps: {
|
|
// component
|
|
'cc.Sprite': {
|
|
// component properties
|
|
'spriteFrame': frames
|
|
}
|
|
}
|
|
};
|
|
|
|
return clip;
|
|
}
|
|
}
|
|
});
|
|
|
|
cc.AnimationClip2 = module.exports = AnimationClip;
|