/**
 * 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.
 */ import { CubismIdHandle } from '../id/cubismid' ; import { CubismFramework } from '../live2dcubismframework' ; import { csmString } from '../type/csmstring' ; import { CubismJson } from '../utils/cubismjson' ; const Meta = 'Meta' ; const Duration = 'Duration' ; const Loop = 'Loop' ; const AreBeziersRestricted = 'AreBeziersRestricted' ; const CurveCount = 'CurveCount' ; const Fps = 'Fps' ; const TotalSegmentCount = 'TotalSegmentCount' ; const TotalPointCount = 'TotalPointCount' ; const Curves = 'Curves' ; const Target = 'Target' ; const Id = 'Id' ; const FadeInTime = 'FadeInTime' ; const FadeOutTime = 'FadeOutTime' ; const Segments = 'Segments' ; const UserData = 'UserData' ; const UserDataCount = 'UserDataCount' ; const TotalUserDataSize = 'TotalUserDataSize' ; const Time = 'Time' ; const Value = 'Value' ; /**
 * motion3.jsonのコンテナ。
 */ export class CubismMotionJson { param buffer param size public constructor ( buffer , size ) { this . _json = CubismJson . create ( buffer , size ) ; } /**
     * デストラクタ相当の処理
     */ public release ( ) { CubismJson . delete ( this . _json ) ; } return public getMotionDuration ( ) { return this . _json . getRoot ( ) . getValueByString ( Meta ) . getValueByString ( Duration ) . toFloat ( ) ; } return return public isMotionLoop ( ) { return this . _json . getRoot ( ) . getValueByString ( Meta ) . getValueByString ( Loop ) . toBoolean ( ) ; } public getEvaluationOptionFlag ( flagType ) { if ( EvaluationOptionFlag . EvaluationOptionFlag_AreBeziersRistricted == flagType ) { return this . _json . getRoot ( ) . getValueByString ( Meta ) . getValueByString ( AreBeziersRestricted ) . toBoolean ( ) ; } return false ; } return public getMotionCurveCount ( ) { return this . _json . getRoot ( ) . getValueByString ( Meta ) . getValueByString ( CurveCount ) . toInt ( ) ; } return public getMotionFps ( ) { return this . _json . getRoot ( ) . getValueByString ( Meta ) . getValueByString ( Fps ) . toFloat ( ) ; } return public getMotionTotalSegmentCount ( ) { return this . _json . getRoot ( ) . getValueByString ( Meta ) . getValueByString ( TotalSegmentCount ) . toInt ( ) ; } return public getMotionTotalPointCount ( ) { return this . _json . getRoot ( ) . getValueByString ( Meta ) . getValueByString ( TotalPointCount ) . toInt ( ) ; } return return public isExistMotionFadeInTime ( ) { return ! this . _json . getRoot ( ) . getValueByString ( Meta ) . getValueByString ( FadeInTime ) . isNull ( ) ; } return return public isExistMotionFadeOutTime ( ) { return ! this . _json . getRoot ( ) . getValueByString ( Meta ) . getValueByString ( FadeOutTime ) . isNull ( ) ; } return public getMotionFadeInTime ( ) { return this . _json . getRoot ( ) . getValueByString ( Meta ) . getValueByString ( FadeInTime ) . toFloat ( ) ; } return public getMotionFadeOutTime ( ) { return this . _json . getRoot ( ) . getValueByString ( Meta ) . getValueByString ( FadeOutTime ) . toFloat ( ) ; } param curveIndex return public getMotionCurveTarget ( curveIndex ) { return this . _json . getRoot ( ) . getValueByString ( Curves ) . getValueByIndex ( curveIndex ) . getValueByString ( Target ) . getRawString ( ) ; } param curveIndex return public getMotionCurveId ( curveIndex ) { return CubismFramework . getIdManager ( ) . getId ( this . _json . getRoot ( ) . getValueByString ( Curves ) . getValueByIndex ( curveIndex ) . getValueByString ( Id ) . getRawString ( ) ) ; } param curveIndex return return public isExistMotionCurveFadeInTime ( curveIndex ) { return ! this . _json . getRoot ( ) . getValueByString ( Curves ) . getValueByIndex ( curveIndex ) . getValueByString ( FadeInTime ) . isNull ( ) ; } param curveIndex return return public isExistMotionCurveFadeOutTime ( curveIndex ) { return ! this . _json . getRoot ( ) . getValueByString ( Curves ) . getValueByIndex ( curveIndex ) . getValueByString ( FadeOutTime ) . isNull ( ) ; } param curveIndex return public getMotionCurveFadeInTime ( curveIndex ) { return this . _json . getRoot ( ) . getValueByString ( Curves ) . getValueByIndex ( curveIndex ) . getValueByString ( FadeInTime ) . toFloat ( ) ; } param curveIndex return public getMotionCurveFadeOutTime ( curveIndex ) { return this . _json . getRoot ( ) . getValueByString ( Curves ) . getValueByIndex ( curveIndex ) . getValueByString ( FadeOutTime ) . toFloat ( ) ; } param curveIndex return public getMotionCurveSegmentCount ( curveIndex ) { return this . _json . getRoot ( ) . getValueByString ( Curves ) . getValueByIndex ( curveIndex ) . getValueByString ( Segments ) . getVector ( ) . getSize ( ) ; } param curveIndex param segmentIndex return public getMotionCurveSegment ( curveIndex , segmentIndex ) { return this . _json . getRoot ( ) . getValueByString ( Curves ) . getValueByIndex ( curveIndex ) . getValueByString ( Segments ) . getValueByIndex ( segmentIndex ) . toFloat ( ) ; } return public getEventCount ( ) { return this . _json . getRoot ( ) . getValueByString ( Meta ) . getValueByString ( UserDataCount ) . toInt ( ) ; } return public getTotalEventValueSize ( ) { return this . _json . getRoot ( ) . getValueByString ( Meta ) . getValueByString ( TotalUserDataSize ) . toInt ( ) ; } param userDataIndex return public getEventTime ( userDataIndex ) { return this . _json . getRoot ( ) . getValueByString ( UserData ) . getValueByIndex ( userDataIndex ) . getValueByString ( Time ) . toFloat ( ) ; } param userDataIndex return public getEventValue ( userDataIndex ) { return new csmString ( this . _json . getRoot ( ) . getValueByString ( UserData ) . getValueByIndex ( userDataIndex ) . getValueByString ( Value ) . getRawString ( ) ) ; } _json : CubismJson ; } brief export enum EvaluationOptionFlag { EvaluationOptionFlag_AreBeziersRistricted = 0 } import * as $ from './cubismmotionjson' ; export namespace Live2DCubismFramework { export const CubismMotionJson = $ . CubismMotionJson ; export type CubismMotionJson = $ . CubismMotionJson ; }