diff --git a/cocos/core/director.ts b/cocos/core/director.ts index cecb20b5ec..412199b1f9 100644 --- a/cocos/core/director.ts +++ b/cocos/core/director.ts @@ -922,16 +922,22 @@ class Director extends EventTarget { /** * @en Returns the delta time since last frame. * @zh 获取上一帧的增量时间。 - * @return {Number} */ public getDeltaTime () { return this._deltaTime; } + /** + * @en Returns the current time. + * @zh 获取当前帧的时间。 + */ + public getCurrentTime () { + return this._lastUpdate; + } + /** * @en Returns how many frames were called since the director started. * @zh 获取 director 启动以来游戏运行的总帧数。 - * @return {Number} */ public getTotalFrames () { return this._totalFrames; @@ -940,7 +946,6 @@ class Director extends EventTarget { /** * @en Returns whether or not the Director is paused. * @zh 是否处于暂停状态。 - * @return {Boolean} */ public isPaused () { return this._paused; @@ -949,7 +954,6 @@ class Director extends EventTarget { /** * @en Returns the cc.Scheduler associated with this director. * @zh 获取和 director 相关联的 cc.Scheduler。 - * @return {Scheduler} */ public getScheduler () { return this._scheduler; @@ -958,9 +962,8 @@ class Director extends EventTarget { /** * @en Sets the cc.Scheduler associated with this director. * @zh 设置和 director 相关联的 cc.Scheduler。 - * @param {Scheduler} scheduler */ - public setScheduler (scheduler) { + public setScheduler (scheduler: Scheduler) { if (this._scheduler !== scheduler) { this._scheduler = scheduler; } @@ -969,11 +972,6 @@ class Director extends EventTarget { /** * @en register a system. * @zh 注册一个 system。 - * @param {string} name - * @param {function} cls - * @param {Array} compClsNames - * @param {number} priority - * @return {System} */ public registerSystem (name, cls, compClsNames, priority) { const sys = new cls(); @@ -991,8 +989,6 @@ class Director extends EventTarget { /** * @en get a system. * @zh 获取一个 system。 - * @param {string} name - * @return {System} */ public getSystem (name) { return this._systems.find((sys) => { diff --git a/cocos/renderer/models/skinning-model.ts b/cocos/renderer/models/skinning-model.ts index f196fdb568..8b51d9cfa3 100644 --- a/cocos/renderer/models/skinning-model.ts +++ b/cocos/renderer/models/skinning-model.ts @@ -51,9 +51,9 @@ export enum JointsMediumType { } export function selectJointsMediumType (device: GFXDevice, jointCount: number): JointsMediumType { - if (jointCount <= JointUniformCapacity) { + /*if (jointCount <= JointUniformCapacity) { return JointsMediumType.UNIFORM; - } else if (device.hasFeature(GFXFeature.TEXTURE_FLOAT)) { + } else */if (device.hasFeature(GFXFeature.TEXTURE_FLOAT)) { return JointsMediumType.RGBA32F; } else { return JointsMediumType.RGBA8; @@ -81,6 +81,7 @@ const qt_1 = new Quat(); const qt_2 = new Quat(); const m4_1 = new Mat4(); const f4_1 = new Float32Array(4); +const SKINNING_INTERVAL = 1000 / 30; export class Joint { public node: Node; @@ -130,6 +131,7 @@ export class SkinningModel extends Model { private _skeleton: Skeleton | null = null; private _joints: Joint[] = []; private _jointsMedium: IJointsInfo | null = null; + private _lastUpdate = 0; constructor (scene: RenderScene, node: Node) { super(scene, node); @@ -186,6 +188,10 @@ export class SkinningModel extends Model { public updateUBOs () { if (!super.updateUBOs() || !this._skeleton) { return false; } + const now = cc.director.getCurrentTime(); + if (now - this._lastUpdate < SKINNING_INTERVAL) { return true; } + this._lastUpdate = now; + const len = this._joints.length; if (this._skeleton.bindTRS.length) { // TODO: pre-apply this into animation clip for (let i = 0; i < len; ++i) {