UNPKG

phaser4-rex-plugins

Version:
700 lines 32.9 kB
"use strict"; /** * Copyright(c) Live2D Inc. All rights reserved. * * Use of this source code is governed by the Live2D Open Software license * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. */ var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; result["default"] = mod; return result; }; Object.defineProperty(exports, "__esModule", { value: true }); var live2dcubismframework_1 = require("../live2dcubismframework"); var cubismmath_1 = require("../math/cubismmath"); var csmstring_1 = require("../type/csmstring"); var cubismdebug_1 = require("../utils/cubismdebug"); var acubismmotion_1 = require("./acubismmotion"); var cubismmotioninternal_1 = require("./cubismmotioninternal"); var cubismmotionjson_1 = require("./cubismmotionjson"); var EffectNameEyeBlink = 'EyeBlink'; var EffectNameLipSync = 'LipSync'; var TargetNameModel = 'Model'; var TargetNameParameter = 'Parameter'; var TargetNamePartOpacity = 'PartOpacity'; /** * Cubism SDK R2 以前のモーションを再現させるなら true 、アニメータのモーションを正しく再現するなら false 。 */ var UseOldBeziersCurveMotion = false; function lerpPoints(a, b, t) { var result = new cubismmotioninternal_1.CubismMotionPoint(); result.time = a.time + (b.time - a.time) * t; result.value = a.value + (b.value - a.value) * t; return result; } function linearEvaluate(points, time) { var t = (time - points[0].time) / (points[1].time - points[0].time); if (t < 0.0) { t = 0.0; } return points[0].value + (points[1].value - points[0].value) * t; } function bezierEvaluate(points, time) { var t = (time - points[0].time) / (points[3].time - points[0].time); if (t < 0.0) { t = 0.0; } var p01 = lerpPoints(points[0], points[1], t); var p12 = lerpPoints(points[1], points[2], t); var p23 = lerpPoints(points[2], points[3], t); var p012 = lerpPoints(p01, p12, t); var p123 = lerpPoints(p12, p23, t); return lerpPoints(p012, p123, t).value; } function bezierEvaluateBinarySearch(points, time) { var x_error = 0.01; var x = time; var x1 = points[0].time; var x2 = points[3].time; var cx1 = points[1].time; var cx2 = points[2].time; var ta = 0.0; var tb = 1.0; var t = 0.0; var i = 0; for (var var33 = true; i < 20; ++i) { if (x < x1 + x_error) { t = ta; break; } if (x2 - x_error < x) { t = tb; break; } var centerx = (cx1 + cx2) * 0.5; cx1 = (x1 + cx1) * 0.5; cx2 = (x2 + cx2) * 0.5; var ctrlx12 = (cx1 + centerx) * 0.5; var ctrlx21 = (cx2 + centerx) * 0.5; centerx = (ctrlx12 + ctrlx21) * 0.5; if (x < centerx) { tb = (ta + tb) * 0.5; if (centerx - x_error < x) { t = tb; break; } x2 = centerx; cx2 = ctrlx12; } else { ta = (ta + tb) * 0.5; if (x < centerx + x_error) { t = ta; break; } x1 = centerx; cx1 = ctrlx21; } } if (i == 20) { t = (ta + tb) * 0.5; } if (t < 0.0) { t = 0.0; } if (t > 1.0) { t = 1.0; } var p01 = lerpPoints(points[0], points[1], t); var p12 = lerpPoints(points[1], points[2], t); var p23 = lerpPoints(points[2], points[3], t); var p012 = lerpPoints(p01, p12, t); var p123 = lerpPoints(p12, p23, t); return lerpPoints(p012, p123, t).value; } function bezierEvaluateCardanoInterpretation(points, time) { var x = time; var x1 = points[0].time; var x2 = points[3].time; var cx1 = points[1].time; var cx2 = points[2].time; var a = x2 - 3.0 * cx2 + 3.0 * cx1 - x1; var b = 3.0 * cx2 - 6.0 * cx1 + 3.0 * x1; var c = 3.0 * cx1 - 3.0 * x1; var d = x1 - x; var t = cubismmath_1.CubismMath.cardanoAlgorithmForBezier(a, b, c, d); var p01 = lerpPoints(points[0], points[1], t); var p12 = lerpPoints(points[1], points[2], t); var p23 = lerpPoints(points[2], points[3], t); var p012 = lerpPoints(p01, p12, t); var p123 = lerpPoints(p12, p23, t); return lerpPoints(p012, p123, t).value; } function steppedEvaluate(points, time) { return points[0].value; } function inverseSteppedEvaluate(points, time) { return points[1].value; } function evaluateCurve(motionData, index, time) { // Find segment to evaluate. var curve = motionData.curves.at(index); var target = -1; var totalSegmentCount = curve.baseSegmentIndex + curve.segmentCount; var pointPosition = 0; for (var i = curve.baseSegmentIndex; i < totalSegmentCount; ++i) { // Get first point of next segment. pointPosition = motionData.segments.at(i).basePointIndex + (motionData.segments.at(i).segmentType == cubismmotioninternal_1.CubismMotionSegmentType.CubismMotionSegmentType_Bezier ? 3 : 1); // Break if time lies within current segment. if (motionData.points.at(pointPosition).time > time) { target = i; break; } } if (target == -1) { return motionData.points.at(pointPosition).value; } var segment = motionData.segments.at(target); return segment.evaluate(motionData.points.get(segment.basePointIndex), time); } /** * モーションクラス * * モーションのクラス。 */ var CubismMotion = /** @class */ (function (_super) { __extends(CubismMotion, _super); /** * コンストラクタ */ function CubismMotion() { var _this = _super.call(this) || this; _this._sourceFrameRate = 30.0; _this._loopDurationSeconds = -1.0; _this._isLoop = false; // trueから false へデフォルトを変更 _this._isLoopFadeIn = true; // ループ時にフェードインが有効かどうかのフラグ _this._lastWeight = 0.0; _this._motionData = null; _this._modelCurveIdEyeBlink = null; _this._modelCurveIdLipSync = null; _this._eyeBlinkParameterIds = null; _this._lipSyncParameterIds = null; return _this; } /** * インスタンスを作成する * * @param buffer motion3.jsonが読み込まれているバッファ * @param size バッファのサイズ * @param onFinishedMotionHandler モーション再生終了時に呼び出されるコールバック関数 * @return 作成されたインスタンス */ CubismMotion.create = function (buffer, size, onFinishedMotionHandler) { var ret = new CubismMotion(); ret.parse(buffer, size); ret._sourceFrameRate = ret._motionData.fps; ret._loopDurationSeconds = ret._motionData.duration; ret._onFinishedMotion = onFinishedMotionHandler; // NOTE: Editorではループありのモーション書き出しは非対応 // ret->_loop = (ret->_motionData->Loop > 0); return ret; }; /** * モデルのパラメータの更新の実行 * @param model 対象のモデル * @param userTimeSeconds 現在の時刻[秒] * @param fadeWeight モーションの重み * @param motionQueueEntry CubismMotionQueueManagerで管理されているモーション */ CubismMotion.prototype.doUpdateParameters = function (model, userTimeSeconds, fadeWeight, motionQueueEntry) { if (this._modelCurveIdEyeBlink == null) { this._modelCurveIdEyeBlink = live2dcubismframework_1.CubismFramework.getIdManager().getId(EffectNameEyeBlink); } if (this._modelCurveIdLipSync == null) { this._modelCurveIdLipSync = live2dcubismframework_1.CubismFramework.getIdManager().getId(EffectNameLipSync); } var timeOffsetSeconds = userTimeSeconds - motionQueueEntry.getStartTime(); if (timeOffsetSeconds < 0.0) { timeOffsetSeconds = 0.0; // エラー回避 } var lipSyncValue = Number.MAX_VALUE; var eyeBlinkValue = Number.MAX_VALUE; //まばたき、リップシンクのうちモーションの適用を検出するためのビット(maxFlagCount個まで var MaxTargetSize = 64; var lipSyncFlags = 0; var eyeBlinkFlags = 0; //瞬き、リップシンクのターゲット数が上限を超えている場合 if (this._eyeBlinkParameterIds.getSize() > MaxTargetSize) { cubismdebug_1.CubismLogDebug('too many eye blink targets : {0}', this._eyeBlinkParameterIds.getSize()); } if (this._lipSyncParameterIds.getSize() > MaxTargetSize) { cubismdebug_1.CubismLogDebug('too many lip sync targets : {0}', this._lipSyncParameterIds.getSize()); } var tmpFadeIn = this._fadeInSeconds <= 0.0 ? 1.0 : cubismmath_1.CubismMath.getEasingSine((userTimeSeconds - motionQueueEntry.getFadeInStartTime()) / this._fadeInSeconds); var tmpFadeOut = this._fadeOutSeconds <= 0.0 || motionQueueEntry.getEndTime() < 0.0 ? 1.0 : cubismmath_1.CubismMath.getEasingSine((motionQueueEntry.getEndTime() - userTimeSeconds) / this._fadeOutSeconds); var value; var c, parameterIndex; // 'Repeat' time as necessary. var time = timeOffsetSeconds; if (this._isLoop) { while (time > this._motionData.duration) { time -= this._motionData.duration; } } var curves = this._motionData.curves; // Evaluate model curves. for (c = 0; c < this._motionData.curveCount && curves.at(c).type == cubismmotioninternal_1.CubismMotionCurveTarget.CubismMotionCurveTarget_Model; ++c) { // Evaluate curve and call handler. value = evaluateCurve(this._motionData, c, time); if (curves.at(c).id == this._modelCurveIdEyeBlink) { eyeBlinkValue = value; } else if (curves.at(c).id == this._modelCurveIdLipSync) { lipSyncValue = value; } } var parameterMotionCurveCount = 0; for (; c < this._motionData.curveCount && curves.at(c).type == cubismmotioninternal_1.CubismMotionCurveTarget.CubismMotionCurveTarget_Parameter; ++c) { parameterMotionCurveCount++; // Find parameter index. parameterIndex = model.getParameterIndex(curves.at(c).id); // Skip curve evaluation if no value in sink. if (parameterIndex == -1) { continue; } var sourceValue = model.getParameterValueByIndex(parameterIndex); // Evaluate curve and apply value. value = evaluateCurve(this._motionData, c, time); if (eyeBlinkValue != Number.MAX_VALUE) { for (var i = 0; i < this._eyeBlinkParameterIds.getSize() && i < MaxTargetSize; ++i) { if (this._eyeBlinkParameterIds.at(i) == curves.at(c).id) { value *= eyeBlinkValue; eyeBlinkFlags |= 1 << i; break; } } } if (lipSyncValue != Number.MAX_VALUE) { for (var i = 0; i < this._lipSyncParameterIds.getSize() && i < MaxTargetSize; ++i) { if (this._lipSyncParameterIds.at(i) == curves.at(c).id) { value += lipSyncValue; lipSyncFlags |= 1 << i; break; } } } var v = void 0; // パラメータごとのフェード if (curves.at(c).fadeInTime < 0.0 && curves.at(c).fadeOutTime < 0.0) { // モーションのフェードを適用 v = sourceValue + (value - sourceValue) * fadeWeight; } else { // パラメータに対してフェードインかフェードアウトが設定してある場合はそちらを適用 var fin = void 0; var fout = void 0; if (curves.at(c).fadeInTime < 0.0) { fin = tmpFadeIn; } else { fin = curves.at(c).fadeInTime == 0.0 ? 1.0 : cubismmath_1.CubismMath.getEasingSine((userTimeSeconds - motionQueueEntry.getFadeInStartTime()) / curves.at(c).fadeInTime); } if (curves.at(c).fadeOutTime < 0.0) { fout = tmpFadeOut; } else { fout = curves.at(c).fadeOutTime == 0.0 || motionQueueEntry.getEndTime() < 0.0 ? 1.0 : cubismmath_1.CubismMath.getEasingSine((motionQueueEntry.getEndTime() - userTimeSeconds) / curves.at(c).fadeOutTime); } var paramWeight = this._weight * fin * fout; // パラメータごとのフェードを適用 v = sourceValue + (value - sourceValue) * paramWeight; } model.setParameterValueByIndex(parameterIndex, v, 1.0); } { if (eyeBlinkValue != Number.MAX_VALUE) { for (var i = 0; i < this._eyeBlinkParameterIds.getSize() && i < MaxTargetSize; ++i) { var sourceValue = model.getParameterValueById(this._eyeBlinkParameterIds.at(i)); // モーションでの上書きがあった時にはまばたきは適用しない if ((eyeBlinkFlags >> i) & 0x01) { continue; } var v = sourceValue + (eyeBlinkValue - sourceValue) * fadeWeight; model.setParameterValueById(this._eyeBlinkParameterIds.at(i), v); } } if (lipSyncValue != Number.MAX_VALUE) { for (var i = 0; i < this._lipSyncParameterIds.getSize() && i < MaxTargetSize; ++i) { var sourceValue = model.getParameterValueById(this._lipSyncParameterIds.at(i)); // モーションでの上書きがあった時にはリップシンクは適用しない if ((lipSyncFlags >> i) & 0x01) { continue; } var v = sourceValue + (lipSyncValue - sourceValue) * fadeWeight; model.setParameterValueById(this._lipSyncParameterIds.at(i), v); } } } for (; c < this._motionData.curveCount && curves.at(c).type == cubismmotioninternal_1.CubismMotionCurveTarget.CubismMotionCurveTarget_PartOpacity; ++c) { // Find parameter index. parameterIndex = model.getParameterIndex(curves.at(c).id); // Skip curve evaluation if no value in sink. if (parameterIndex == -1) { continue; } // Evaluate curve and apply value. value = evaluateCurve(this._motionData, c, time); model.setParameterValueByIndex(parameterIndex, value); } if (timeOffsetSeconds >= this._motionData.duration) { if (this._isLoop) { motionQueueEntry.setStartTime(userTimeSeconds); // 最初の状態へ if (this._isLoopFadeIn) { // ループ内でループ用フェードインが有効の時は、フェードイン設定し直し motionQueueEntry.setFadeInStartTime(userTimeSeconds); } } else { if (this._onFinishedMotion) { this._onFinishedMotion(this); } motionQueueEntry.setIsFinished(true); } } this._lastWeight = fadeWeight; }; /** * ループ情報の設定 * @param loop ループ情報 */ CubismMotion.prototype.setIsLoop = function (loop) { this._isLoop = loop; }; /** * ループ情報の取得 * @return true ループする * @return false ループしない */ CubismMotion.prototype.isLoop = function () { return this._isLoop; }; /** * ループ時のフェードイン情報の設定 * @param loopFadeIn ループ時のフェードイン情報 */ CubismMotion.prototype.setIsLoopFadeIn = function (loopFadeIn) { this._isLoopFadeIn = loopFadeIn; }; /** * ループ時のフェードイン情報の取得 * * @return true する * @return false しない */ CubismMotion.prototype.isLoopFadeIn = function () { return this._isLoopFadeIn; }; /** * モーションの長さを取得する。 * * @return モーションの長さ[秒] */ CubismMotion.prototype.getDuration = function () { return this._isLoop ? -1.0 : this._loopDurationSeconds; }; /** * モーションのループ時の長さを取得する。 * * @return モーションのループ時の長さ[秒] */ CubismMotion.prototype.getLoopDuration = function () { return this._loopDurationSeconds; }; /** * パラメータに対するフェードインの時間を設定する。 * * @param parameterId パラメータID * @param value フェードインにかかる時間[秒] */ CubismMotion.prototype.setParameterFadeInTime = function (parameterId, value) { var curves = this._motionData.curves; for (var i = 0; i < this._motionData.curveCount; ++i) { if (parameterId == curves.at(i).id) { curves.at(i).fadeInTime = value; return; } } }; /** * パラメータに対するフェードアウトの時間の設定 * @param parameterId パラメータID * @param value フェードアウトにかかる時間[秒] */ CubismMotion.prototype.setParameterFadeOutTime = function (parameterId, value) { var curves = this._motionData.curves; for (var i = 0; i < this._motionData.curveCount; ++i) { if (parameterId == curves.at(i).id) { curves.at(i).fadeOutTime = value; return; } } }; /** * パラメータに対するフェードインの時間の取得 * @param parameterId パラメータID * @return フェードインにかかる時間[秒] */ CubismMotion.prototype.getParameterFadeInTime = function (parameterId) { var curves = this._motionData.curves; for (var i = 0; i < this._motionData.curveCount; ++i) { if (parameterId == curves.at(i).id) { return curves.at(i).fadeInTime; } } return -1; }; /** * パラメータに対するフェードアウトの時間を取得 * * @param parameterId パラメータID * @return フェードアウトにかかる時間[秒] */ CubismMotion.prototype.getParameterFadeOutTime = function (parameterId) { var curves = this._motionData.curves; for (var i = 0; i < this._motionData.curveCount; ++i) { if (parameterId == curves.at(i).id) { return curves.at(i).fadeOutTime; } } return -1; }; /** * 自動エフェクトがかかっているパラメータIDリストの設定 * @param eyeBlinkParameterIds 自動まばたきがかかっているパラメータIDのリスト * @param lipSyncParameterIds リップシンクがかかっているパラメータIDのリスト */ CubismMotion.prototype.setEffectIds = function (eyeBlinkParameterIds, lipSyncParameterIds) { this._eyeBlinkParameterIds = eyeBlinkParameterIds; this._lipSyncParameterIds = lipSyncParameterIds; }; /** * デストラクタ相当の処理 */ CubismMotion.prototype.release = function () { this._motionData = void 0; this._motionData = null; }; /** * motion3.jsonをパースする。 * * @param motionJson motion3.jsonが読み込まれているバッファ * @param size バッファのサイズ */ CubismMotion.prototype.parse = function (motionJson, size) { this._motionData = new cubismmotioninternal_1.CubismMotionData(); var json = new cubismmotionjson_1.CubismMotionJson(motionJson, size); this._motionData.duration = json.getMotionDuration(); this._motionData.loop = json.isMotionLoop(); this._motionData.curveCount = json.getMotionCurveCount(); this._motionData.fps = json.getMotionFps(); this._motionData.eventCount = json.getEventCount(); var areBeziersRestructed = json.getEvaluationOptionFlag(cubismmotionjson_1.EvaluationOptionFlag.EvaluationOptionFlag_AreBeziersRistricted); if (json.isExistMotionFadeInTime()) { this._fadeInSeconds = json.getMotionFadeInTime() < 0.0 ? 1.0 : json.getMotionFadeInTime(); } else { this._fadeInSeconds = 1.0; } if (json.isExistMotionFadeOutTime()) { this._fadeOutSeconds = json.getMotionFadeOutTime() < 0.0 ? 1.0 : json.getMotionFadeOutTime(); } else { this._fadeOutSeconds = 1.0; } this._motionData.curves.updateSize(this._motionData.curveCount, cubismmotioninternal_1.CubismMotionCurve, true); this._motionData.segments.updateSize(json.getMotionTotalSegmentCount(), cubismmotioninternal_1.CubismMotionSegment, true); this._motionData.points.updateSize(json.getMotionTotalPointCount(), cubismmotioninternal_1.CubismMotionPoint, true); this._motionData.events.updateSize(this._motionData.eventCount, cubismmotioninternal_1.CubismMotionEvent, true); var totalPointCount = 0; var totalSegmentCount = 0; // Curves for (var curveCount = 0; curveCount < this._motionData.curveCount; ++curveCount) { if (json.getMotionCurveTarget(curveCount) == TargetNameModel) { this._motionData.curves.at(curveCount).type = cubismmotioninternal_1.CubismMotionCurveTarget.CubismMotionCurveTarget_Model; } else if (json.getMotionCurveTarget(curveCount) == TargetNameParameter) { this._motionData.curves.at(curveCount).type = cubismmotioninternal_1.CubismMotionCurveTarget.CubismMotionCurveTarget_Parameter; } else if (json.getMotionCurveTarget(curveCount) == TargetNamePartOpacity) { this._motionData.curves.at(curveCount).type = cubismmotioninternal_1.CubismMotionCurveTarget.CubismMotionCurveTarget_PartOpacity; } else { cubismdebug_1.CubismLogWarning('Warning : Unable to get segment type from Curve! The number of "CurveCount" may be incorrect!'); } this._motionData.curves.at(curveCount).id = json.getMotionCurveId(curveCount); this._motionData.curves.at(curveCount).baseSegmentIndex = totalSegmentCount; this._motionData.curves.at(curveCount).fadeInTime = json.isExistMotionCurveFadeInTime(curveCount) ? json.getMotionCurveFadeInTime(curveCount) : -1.0; this._motionData.curves.at(curveCount).fadeOutTime = json.isExistMotionCurveFadeOutTime(curveCount) ? json.getMotionCurveFadeOutTime(curveCount) : -1.0; // Segments for (var segmentPosition = 0; segmentPosition < json.getMotionCurveSegmentCount(curveCount);) { if (segmentPosition == 0) { this._motionData.segments.at(totalSegmentCount).basePointIndex = totalPointCount; this._motionData.points.at(totalPointCount).time = json.getMotionCurveSegment(curveCount, segmentPosition); this._motionData.points.at(totalPointCount).value = json.getMotionCurveSegment(curveCount, segmentPosition + 1); totalPointCount += 1; segmentPosition += 2; } else { this._motionData.segments.at(totalSegmentCount).basePointIndex = totalPointCount - 1; } var segment = json.getMotionCurveSegment(curveCount, segmentPosition); switch (segment) { case cubismmotioninternal_1.CubismMotionSegmentType.CubismMotionSegmentType_Linear: { this._motionData.segments.at(totalSegmentCount).segmentType = cubismmotioninternal_1.CubismMotionSegmentType.CubismMotionSegmentType_Linear; this._motionData.segments.at(totalSegmentCount).evaluate = linearEvaluate; this._motionData.points.at(totalPointCount).time = json.getMotionCurveSegment(curveCount, segmentPosition + 1); this._motionData.points.at(totalPointCount).value = json.getMotionCurveSegment(curveCount, segmentPosition + 2); totalPointCount += 1; segmentPosition += 3; break; } case cubismmotioninternal_1.CubismMotionSegmentType.CubismMotionSegmentType_Bezier: { this._motionData.segments.at(totalSegmentCount).segmentType = cubismmotioninternal_1.CubismMotionSegmentType.CubismMotionSegmentType_Bezier; if (areBeziersRestructed || UseOldBeziersCurveMotion) { this._motionData.segments.at(totalSegmentCount).evaluate = bezierEvaluate; } else { this._motionData.segments.at(totalSegmentCount).evaluate = bezierEvaluateCardanoInterpretation; } this._motionData.points.at(totalPointCount).time = json.getMotionCurveSegment(curveCount, segmentPosition + 1); this._motionData.points.at(totalPointCount).value = json.getMotionCurveSegment(curveCount, segmentPosition + 2); this._motionData.points.at(totalPointCount + 1).time = json.getMotionCurveSegment(curveCount, segmentPosition + 3); this._motionData.points.at(totalPointCount + 1).value = json.getMotionCurveSegment(curveCount, segmentPosition + 4); this._motionData.points.at(totalPointCount + 2).time = json.getMotionCurveSegment(curveCount, segmentPosition + 5); this._motionData.points.at(totalPointCount + 2).value = json.getMotionCurveSegment(curveCount, segmentPosition + 6); totalPointCount += 3; segmentPosition += 7; break; } case cubismmotioninternal_1.CubismMotionSegmentType.CubismMotionSegmentType_Stepped: { this._motionData.segments.at(totalSegmentCount).segmentType = cubismmotioninternal_1.CubismMotionSegmentType.CubismMotionSegmentType_Stepped; this._motionData.segments.at(totalSegmentCount).evaluate = steppedEvaluate; this._motionData.points.at(totalPointCount).time = json.getMotionCurveSegment(curveCount, segmentPosition + 1); this._motionData.points.at(totalPointCount).value = json.getMotionCurveSegment(curveCount, segmentPosition + 2); totalPointCount += 1; segmentPosition += 3; break; } case cubismmotioninternal_1.CubismMotionSegmentType.CubismMotionSegmentType_InverseStepped: { this._motionData.segments.at(totalSegmentCount).segmentType = cubismmotioninternal_1.CubismMotionSegmentType.CubismMotionSegmentType_InverseStepped; this._motionData.segments.at(totalSegmentCount).evaluate = inverseSteppedEvaluate; this._motionData.points.at(totalPointCount).time = json.getMotionCurveSegment(curveCount, segmentPosition + 1); this._motionData.points.at(totalPointCount).value = json.getMotionCurveSegment(curveCount, segmentPosition + 2); totalPointCount += 1; segmentPosition += 3; break; } default: { cubismdebug_1.CSM_ASSERT(0); break; } } ++this._motionData.curves.at(curveCount).segmentCount; ++totalSegmentCount; } } for (var userdatacount = 0; userdatacount < json.getEventCount(); ++userdatacount) { this._motionData.events.at(userdatacount).fireTime = json.getEventTime(userdatacount); this._motionData.events.at(userdatacount).value = json.getEventValue(userdatacount); } json.release(); json = void 0; json = null; }; /** * モデルのパラメータ更新 * * イベント発火のチェック。 * 入力する時間は呼ばれるモーションタイミングを0とした秒数で行う。 * * @param beforeCheckTimeSeconds 前回のイベントチェック時間[秒] * @param motionTimeSeconds 今回の再生時間[秒] */ CubismMotion.prototype.getFiredEvent = function (beforeCheckTimeSeconds, motionTimeSeconds) { this._firedEventValues.updateSize(0); // イベントの発火チェック for (var u = 0; u < this._motionData.eventCount; ++u) { if (this._motionData.events.at(u).fireTime > beforeCheckTimeSeconds && this._motionData.events.at(u).fireTime <= motionTimeSeconds) { this._firedEventValues.pushBack(new csmstring_1.csmString(this._motionData.events.at(u).value.s)); } } return this._firedEventValues; }; return CubismMotion; }(acubismmotion_1.ACubismMotion)); exports.CubismMotion = CubismMotion; // Namespace definition for compatibility. var $ = __importStar(require("./cubismmotion")); // eslint-disable-next-line @typescript-eslint/no-namespace var Live2DCubismFramework; (function (Live2DCubismFramework) { Live2DCubismFramework.CubismMotion = $.CubismMotion; })(Live2DCubismFramework = exports.Live2DCubismFramework || (exports.Live2DCubismFramework = {})); //# sourceMappingURL=cubismmotion.js.map