zoukankan      html  css  js  c++  java
  • LayaBox 3D 动画播放/倒放Bug问题解决

    LayaBox 动画可以直接使用Unity 导出的动画,但是奇怪的问题发生了,当我将动画倒放时,居然会出现无限循环播放。不知道是不是我调错接口了,跑进Laya的接口和文档中查了N久,无功而返。意识到可能又是源码bug了。

    跑进去调试一下果然发现了问题所在。

    直接修改 laya.d3.js 文件中  _updatePlayer 函数即可

    /**
     *@private
     */
    __proto._updatePlayer = function (animatorState, playState, elapsedTime, islooping) {
        var clipDuration = animatorState._clip._duration * (animatorState.clipEnd - animatorState.clipStart);
        var lastElapsedTime = playState._elapsedTime;
        var elapsedPlaybackTime = lastElapsedTime + elapsedTime;
        playState._lastElapsedTime = lastElapsedTime;
        playState._elapsedTime = elapsedPlaybackTime;
        var normalizedTime = elapsedPlaybackTime / clipDuration;
        playState._normalizedTime = normalizedTime;
        var playTime = normalizedTime % 1.0;
        playState._normalizedPlayTime = playTime < 0 ? playTime + 1.0 : playTime;
        playState._duration = clipDuration;
        var scripts = animatorState._scripts;
        // 修改后代码 [SixGod-Modify 2020年11月4日14:42:26]
        if ((!islooping && Math.abs(elapsedPlaybackTime) >= clipDuration)) {
            playState._finish = true;
            playState._elapsedTime = clipDuration;
            if (elapsedPlaybackTime > 0) {
                playState._normalizedPlayTime = 1.0;
            } else {
                playState._normalizedPlayTime = 0.0;
            }
            if (scripts) {
                for (var i = 0, n = scripts.length; i < n; i++)
                    scripts[i].onStateExit();
            }
            return;
        }
        // 源码
        // if ((!islooping && elapsedPlaybackTime >=clipDuration)){
        //     playState._finish=true;
        //     playState._elapsedTime=clipDuration;
        //     playState._normalizedPlayTime=1.0;
        //     if (scripts){
        //         for (var i=0,n=scripts.length;i < n;i++)
        //         scripts[i].onStateExit();
        //     }
        //     return;
        // }
        if (scripts) {
            for (i = 0, n = scripts.length; i < n; i++)
                scripts[i].onStateUpdate();
        }
    }
  • 相关阅读:
    BZOJ 3513: [MUTC2013]idiots(fft)
    BZOJ 2194: 快速傅立叶之二(fft)
    BZOJ 3779: 重组病毒(线段树+lct+树剖)
    LUOGU P3723 [AH2017/HNOI2017]礼物 (fft)
    CF 622F (拉格朗日插值)
    LUOGU P4781 【模板】拉格朗日插值
    bzoj 4184 shallot——线段树分治+线性基
    51nod 1673 树有几多愁——虚树+状压DP
    bzoj 3611(洛谷 4103) [Heoi2014]大工程——虚树
    bzoj 2286(洛谷 2495) [Sdoi2011]消耗战——虚树
  • 原文地址:https://www.cnblogs.com/huojiaoqingchun0123/p/13925844.html
Copyright © 2011-2022 走看看