/**
 * 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 { CubismVector2 } from '../math/cubismvector2' ; import { CubismJson } from '../utils/cubismjson' ; const Position = 'Position' ; const X = 'X' ; const Y = 'Y' ; const Angle = 'Angle' ; const Type = 'Type' ; const Id = 'Id' ; const Meta = 'Meta' ; const EffectiveForces = 'EffectiveForces' ; const TotalInputCount = 'TotalInputCount' ; const TotalOutputCount = 'TotalOutputCount' ; const PhysicsSettingCount = 'PhysicsSettingCount' ; const Gravity = 'Gravity' ; const Wind = 'Wind' ; const VertexCount = 'VertexCount' ; const PhysicsSettings = 'PhysicsSettings' ; const Normalization = 'Normalization' ; const Minimum = 'Minimum' ; const Maximum = 'Maximum' ; const Default = 'Default' ; const Reflect = 'Reflect' ; const Weight = 'Weight' ; const Input = 'Input' ; const Source = 'Source' ; const Output = 'Output' ; const Scale = 'Scale' ; const VertexIndex = 'VertexIndex' ; const Destination = 'Destination' ; const Vertices = 'Vertices' ; const Mobility = 'Mobility' ; const Delay = 'Delay' ; const Radius = 'Radius' ; const Acceleration = 'Acceleration' ; /**
 * physics3.jsonのコンテナ。
 */ export class CubismPhysicsJson { param buffer param size public constructor ( buffer , size ) { this . _json = CubismJson . create ( buffer , size ) ; } /**
     * デストラクタ相当の処理
     */ public release ( ) { CubismJson . delete ( this . _json ) ; } return public getGravity ( ) { const ret = new CubismVector2 ( 0 , 0 ) ; ret . x = this . _json . getRoot ( ) . getValueByString ( Meta ) . getValueByString ( EffectiveForces ) . getValueByString ( Gravity ) . getValueByString ( X ) . toFloat ( ) ; ret . y = this . _json . getRoot ( ) . getValueByString ( Meta ) . getValueByString ( EffectiveForces ) . getValueByString ( Gravity ) . getValueByString ( Y ) . toFloat ( ) ; return ret ; } return public getWind ( ) { const ret = new CubismVector2 ( 0 , 0 ) ; ret . x = this . _json . getRoot ( ) . getValueByString ( Meta ) . getValueByString ( EffectiveForces ) . getValueByString ( Wind ) . getValueByString ( X ) . toFloat ( ) ; ret . y = this . _json . getRoot ( ) . getValueByString ( Meta ) . getValueByString ( EffectiveForces ) . getValueByString ( Wind ) . getValueByString ( Y ) . toFloat ( ) ; return ret ; } return public getSubRigCount ( ) { return this . _json . getRoot ( ) . getValueByString ( Meta ) . getValueByString ( PhysicsSettingCount ) . toInt ( ) ; } return public getTotalInputCount ( ) { return this . _json . getRoot ( ) . getValueByString ( Meta ) . getValueByString ( TotalInputCount ) . toInt ( ) ; } return public getTotalOutputCount ( ) { return this . _json . getRoot ( ) . getValueByString ( Meta ) . getValueByString ( TotalOutputCount ) . toInt ( ) ; } return public getVertexCount ( ) { return this . _json . getRoot ( ) . getValueByString ( Meta ) . getValueByString ( VertexCount ) . toInt ( ) ; } param physicsSettingIndex return public getNormalizationPositionMinimumValue ( physicsSettingIndex ) { return this . _json . getRoot ( ) . getValueByString ( PhysicsSettings ) . getValueByIndex ( physicsSettingIndex ) . getValueByString ( Normalization ) . getValueByString ( Position ) . getValueByString ( Minimum ) . toFloat ( ) ; } param physicsSettingIndex return public getNormalizationPositionMaximumValue ( physicsSettingIndex ) { return this . _json . getRoot ( ) . getValueByString ( PhysicsSettings ) . getValueByIndex ( physicsSettingIndex ) . getValueByString ( Normalization ) . getValueByString ( Position ) . getValueByString ( Maximum ) . toFloat ( ) ; } param physicsSettingIndex return public getNormalizationPositionDefaultValue ( physicsSettingIndex ) { return this . _json . getRoot ( ) . getValueByString ( PhysicsSettings ) . getValueByIndex ( physicsSettingIndex ) . getValueByString ( Normalization ) . getValueByString ( Position ) . getValueByString ( Default ) . toFloat ( ) ; } param physicsSettingIndex return public getNormalizationAngleMinimumValue ( physicsSettingIndex ) { return this . _json . getRoot ( ) . getValueByString ( PhysicsSettings ) . getValueByIndex ( physicsSettingIndex ) . getValueByString ( Normalization ) . getValueByString ( Angle ) . getValueByString ( Minimum ) . toFloat ( ) ; } param physicsSettingIndex return public getNormalizationAngleMaximumValue ( physicsSettingIndex ) { return this . _json . getRoot ( ) . getValueByString ( PhysicsSettings ) . getValueByIndex ( physicsSettingIndex ) . getValueByString ( Normalization ) . getValueByString ( Angle ) . getValueByString ( Maximum ) . toFloat ( ) ; } param physicsSettingIndex return public getNormalizationAngleDefaultValue ( physicsSettingIndex ) { return this . _json . getRoot ( ) . getValueByString ( PhysicsSettings ) . getValueByIndex ( physicsSettingIndex ) . getValueByString ( Normalization ) . getValueByString ( Angle ) . getValueByString ( Default ) . toFloat ( ) ; } param physicsSettingIndex return public getInputCount ( physicsSettingIndex ) { return this . _json . getRoot ( ) . getValueByString ( PhysicsSettings ) . getValueByIndex ( physicsSettingIndex ) . getValueByString ( Input ) . getVector ( ) . getSize ( ) ; } param physicsSettingIndex param inputIndex return public getInputWeight ( physicsSettingIndex , inputIndex ) { return this . _json . getRoot ( ) . getValueByString ( PhysicsSettings ) . getValueByIndex ( physicsSettingIndex ) . getValueByString ( Input ) . getValueByIndex ( inputIndex ) . getValueByString ( Weight ) . toFloat ( ) ; } param physicsSettingIndex param inputIndex return public getInputReflect ( physicsSettingIndex , inputIndex ) { return this . _json . getRoot ( ) . getValueByString ( PhysicsSettings ) . getValueByIndex ( physicsSettingIndex ) . getValueByString ( Input ) . getValueByIndex ( inputIndex ) . getValueByString ( Reflect ) . toBoolean ( ) ; } param physicsSettingIndex param inputIndex return public getInputType ( physicsSettingIndex , inputIndex ) { return this . _json . getRoot ( ) . getValueByString ( PhysicsSettings ) . getValueByIndex ( physicsSettingIndex ) . getValueByString ( Input ) . getValueByIndex ( inputIndex ) . getValueByString ( Type ) . getRawString ( ) ; } param physicsSettingIndex param inputIndex return public getInputSourceId ( physicsSettingIndex , inputIndex ) { return CubismFramework . getIdManager ( ) . getId ( this . _json . getRoot ( ) . getValueByString ( PhysicsSettings ) . getValueByIndex ( physicsSettingIndex ) . getValueByString ( Input ) . getValueByIndex ( inputIndex ) . getValueByString ( Source ) . getValueByString ( Id ) . getRawString ( ) ) ; } param physicsSettingIndex return public getOutputCount ( physicsSettingIndex ) { return this . _json . getRoot ( ) . getValueByString ( PhysicsSettings ) . getValueByIndex ( physicsSettingIndex ) . getValueByString ( Output ) . getVector ( ) . getSize ( ) ; } param physicsSettingIndex param outputIndex return public getOutputVertexIndex ( physicsSettingIndex , outputIndex ) { return this . _json . getRoot ( ) . getValueByString ( PhysicsSettings ) . getValueByIndex ( physicsSettingIndex ) . getValueByString ( Output ) . getValueByIndex ( outputIndex ) . getValueByString ( VertexIndex ) . toInt ( ) ; } param physicsSettingIndex param outputIndex return public getOutputAngleScale ( physicsSettingIndex , outputIndex ) { return this . _json . getRoot ( ) . getValueByString ( PhysicsSettings ) . getValueByIndex ( physicsSettingIndex ) . getValueByString ( Output ) . getValueByIndex ( outputIndex ) . getValueByString ( Scale ) . toFloat ( ) ; } param physicsSettingIndex param outputIndex return public getOutputWeight ( physicsSettingIndex , outputIndex ) { return this . _json . getRoot ( ) . getValueByString ( PhysicsSettings ) . getValueByIndex ( physicsSettingIndex ) . getValueByString ( Output ) . getValueByIndex ( outputIndex ) . getValueByString ( Weight ) . toFloat ( ) ; } param physicsSettingIndex param outputIndex return public getOutputDestinationId ( physicsSettingIndex , outputIndex ) { return CubismFramework . getIdManager ( ) . getId ( this . _json . getRoot ( ) . getValueByString ( PhysicsSettings ) . getValueByIndex ( physicsSettingIndex ) . getValueByString ( Output ) . getValueByIndex ( outputIndex ) . getValueByString ( Destination ) . getValueByString ( Id ) . getRawString ( ) ) ; } param physicsSettingIndex param outputIndex return public getOutputType ( physicsSettingIndex , outputIndex ) { return this . _json . getRoot ( ) . getValueByString ( PhysicsSettings ) . getValueByIndex ( physicsSettingIndex ) . getValueByString ( Output ) . getValueByIndex ( outputIndex ) . getValueByString ( Type ) . getRawString ( ) ; } param physicsSettingIndex param outputIndex return public getOutputReflect ( physicsSettingIndex , outputIndex ) { return this . _json . getRoot ( ) . getValueByString ( PhysicsSettings ) . getValueByIndex ( physicsSettingIndex ) . getValueByString ( Output ) . getValueByIndex ( outputIndex ) . getValueByString ( Reflect ) . toBoolean ( ) ; } param physicsSettingIndex return public getParticleCount ( physicsSettingIndex ) { return this . _json . getRoot ( ) . getValueByString ( PhysicsSettings ) . getValueByIndex ( physicsSettingIndex ) . getValueByString ( Vertices ) . getVector ( ) . getSize ( ) ; } param physicsSettingIndex param vertexIndex return public getParticleMobility ( physicsSettingIndex , vertexIndex ) { return this . _json . getRoot ( ) . getValueByString ( PhysicsSettings ) . getValueByIndex ( physicsSettingIndex ) . getValueByString ( Vertices ) . getValueByIndex ( vertexIndex ) . getValueByString ( Mobility ) . toFloat ( ) ; } param physicsSettingIndex param vertexIndex return public getParticleDelay ( physicsSettingIndex , vertexIndex ) { return this . _json . getRoot ( ) . getValueByString ( PhysicsSettings ) . getValueByIndex ( physicsSettingIndex ) . getValueByString ( Vertices ) . getValueByIndex ( vertexIndex ) . getValueByString ( Delay ) . toFloat ( ) ; } param physicsSettingIndex param vertexIndex return public getParticleAcceleration ( physicsSettingIndex , vertexIndex ) { return this . _json . getRoot ( ) . getValueByString ( PhysicsSettings ) . getValueByIndex ( physicsSettingIndex ) . getValueByString ( Vertices ) . getValueByIndex ( vertexIndex ) . getValueByString ( Acceleration ) . toFloat ( ) ; } param physicsSettingIndex param vertexIndex return public getParticleRadius ( physicsSettingIndex , vertexIndex ) { return this . _json . getRoot ( ) . getValueByString ( PhysicsSettings ) . getValueByIndex ( physicsSettingIndex ) . getValueByString ( Vertices ) . getValueByIndex ( vertexIndex ) . getValueByString ( Radius ) . toFloat ( ) ; } param physicsSettingIndex param vertexInde return public getParticlePosition ( physicsSettingIndex , vertexIndex ) { const ret = new CubismVector2 ( 0 , 0 ) ; ret . x = this . _json . getRoot ( ) . getValueByString ( PhysicsSettings ) . getValueByIndex ( physicsSettingIndex ) . getValueByString ( Vertices ) . getValueByIndex ( vertexIndex ) . getValueByString ( Position ) . getValueByString ( X ) . toFloat ( ) ; ret . y = this . _json . getRoot ( ) . getValueByString ( PhysicsSettings ) . getValueByIndex ( physicsSettingIndex ) . getValueByString ( Vertices ) . getValueByIndex ( vertexIndex ) . getValueByString ( Position ) . getValueByString ( Y ) . toFloat ( ) ; return ret ; } _json : CubismJson ; } import * as $ from './cubismphysicsjson' ; export namespace Live2DCubismFramework { export const CubismPhysicsJson = $ . CubismPhysicsJson ; export type CubismPhysicsJson = $ . CubismPhysicsJson ; }