Json parser refactor.

translate
cubism-dev 2018-12-20 11:51:34 +09:00
parent be4d450ae7
commit b5db751b2d
11 changed files with 290 additions and 165 deletions

View File

@ -9,7 +9,9 @@ import {Live2DCubismFramework as cubismframework} from "./live2dcubismframework"
import {Live2DCubismFramework as icubismmodelsetting} from "./icubismmodelsetting";
import {Live2DCubismFramework as cubismid} from "./id/cubismid";
import {Live2DCubismFramework as cubismjson} from "./utils/cubismjson";
import {Live2DCubismFramework as csmmap} from"./type/csmmap";
import {Live2DCubismFramework as csmmap} from "./type/csmmap";
import {Live2DCubismFramework as csmvector} from "./type/csmvector";
import csmVector = csmvector.csmVector;
import csmMap = csmmap.csmMap;
import iterator = csmmap.iterator;
import CubismFramework = cubismframework.CubismFramework;
@ -74,6 +76,18 @@ export namespace Live2DCubismFramework
const InitPartsVisible: string = "init_parts_visible";
const Val: string = "val";
enum FrequestNode
{
FrequestNode_Groups, // getRoot().getValueByString(Groups)
FrequestNode_Moc, // getRoot().getValueByString(FileReferences).getValueByString(Moc)
FrequestNode_Motions, // getRoot().getValueByString(FileReferences).getValueByString(Motions)
FrequestNode_Expressions, // getRoot().getValueByString(FileReferences).getValueByString(Expressions)
FrequestNode_Textures, // getRoot().getValueByString(FileReferences).getValueByString(Textures)
FrequestNode_Physics, // getRoot().getValueByString(FileReferences).getValueByString(Physics)
FrequestNode_Pose, // getRoot().getValueByString(FileReferences).getValueByString(Pose)
FrequestNode_HitAreas // getRoot().getValueByString(HitAreas)
};
/**
* Model3Json
@ -92,6 +106,21 @@ export namespace Live2DCubismFramework
{
super();
this._json = CubismJson.create(buffer, size);
if(this._json)
{
this._jsonValue = new csmVector<Value>();
// 順番はenum FrequestNodeと一致させる
this._jsonValue.pushBack(this._json.getRoot().getValueByString(Groups));
this._jsonValue.pushBack(this._json.getRoot().getValueByString(FileReferences).getValueByString(Moc));
this._jsonValue.pushBack(this._json.getRoot().getValueByString(FileReferences).getValueByString(Motions));
this._jsonValue.pushBack(this._json.getRoot().getValueByString(FileReferences).getValueByString(Expressions));
this._jsonValue.pushBack(this._json.getRoot().getValueByString(FileReferences).getValueByString(Textures));
this._jsonValue.pushBack(this._json.getRoot().getValueByString(FileReferences).getValueByString(Physics));
this._jsonValue.pushBack(this._json.getRoot().getValueByString(FileReferences).getValueByString(Pose));
this._jsonValue.pushBack(this._json.getRoot().getValueByString(HitAreas));
}
}
/**
@ -100,6 +129,8 @@ export namespace Live2DCubismFramework
public release(): void
{
CubismJson.delete(this._json);
this._jsonValue = null;
}
/**
@ -122,7 +153,7 @@ export namespace Live2DCubismFramework
{
return "";
}
return this._json.getRoot().getMap().getValue(FileReferences).getMap().getValue(Moc).getRawString();
return this._jsonValue.at(FrequestNode.FrequestNode_Moc).getRawString();
}
/**
@ -136,7 +167,7 @@ export namespace Live2DCubismFramework
return 0;
}
return this._json.getRoot().getMap().getValue(FileReferences).getMap().getValue(Textures).getSize();
return this._jsonValue.at(FrequestNode.FrequestNode_Textures).getSize();
}
/**
@ -145,7 +176,7 @@ export namespace Live2DCubismFramework
*/
public getTextureDirectory(): string
{
return this._json.getRoot().getMap().getValue(FileReferences).getMap().getValue(Textures).getRawString();
return this._jsonValue.at(FrequestNode.FrequestNode_Textures).getRawString();
}
/**
@ -155,7 +186,7 @@ export namespace Live2DCubismFramework
*/
public getTextureFileName(index: number): string
{
return this._json.getRoot().getMap().getValue(FileReferences).getMap().getValue(Textures).getVector().at(index).getRawString();
return this._jsonValue.at(FrequestNode.FrequestNode_Textures).getValueByIndex(index).getRawString();
}
/**
@ -169,7 +200,7 @@ export namespace Live2DCubismFramework
return 0;
}
return this._json.getRoot().getMap().getValue(HitAreas).getSize();
return this._jsonValue.at(FrequestNode.FrequestNode_HitAreas).getSize();
}
/**
@ -180,7 +211,7 @@ export namespace Live2DCubismFramework
*/
public getHitAreaId(index: number): CubismIdHandle
{
return CubismFramework.getIdManager().getId(this._json.getRoot().getMap().getValue(HitAreas).getVector().at(index).getMap().getValue(Id).getRawString());
return CubismFramework.getIdManager().getId(this._jsonValue.at(FrequestNode.FrequestNode_HitAreas).getValueByIndex(index).getValueByString(Id).getRawString());
}
/**
@ -190,7 +221,7 @@ export namespace Live2DCubismFramework
*/
public getHitAreaName(index: number): string
{
return this._json.getRoot().getMap().getValue(HitAreas).getVector().at(index).getMap().getValue(Name).getRawString();
return this._jsonValue.at(FrequestNode.FrequestNode_HitAreas).getValueByIndex(index).getValueByString(Name).getRawString();
}
/**
@ -204,7 +235,7 @@ export namespace Live2DCubismFramework
return "";
}
return this._json.getRoot().getMap().getValue(FileReferences).getMap().getValue(Physics).getRawString();
return this._jsonValue.at(FrequestNode.FrequestNode_Physics).getRawString();
}
/**
@ -218,7 +249,7 @@ export namespace Live2DCubismFramework
return "";
}
return this._json.getRoot().getMap().getValue(FileReferences).getMap().getValue(Pose).getRawString();
return this._jsonValue.at(FrequestNode.FrequestNode_Pose).getRawString();
}
/**
@ -232,7 +263,7 @@ export namespace Live2DCubismFramework
return 0;
}
return this._json.getRoot().getMap().getValue(FileReferences).getMap().getValue(Expressions).getSize();
return this._jsonValue.at(FrequestNode.FrequestNode_Expressions).getSize();
}
/**
@ -242,7 +273,7 @@ export namespace Live2DCubismFramework
*/
public getExpressionName(index: number): string
{
return this._json.getRoot().getMap().getValue(FileReferences).getMap().getValue(Expressions).getVector().at(index).getMap().getValue(Name).getRawString();
return this._jsonValue.at(FrequestNode.FrequestNode_Expressions).getValueByIndex(index).getValueByString(Name).getRawString();
}
/**
@ -252,7 +283,7 @@ export namespace Live2DCubismFramework
*/
public getExpressionFileName(index: number): string
{
return this._json.getRoot().getMap().getValue(FileReferences).getMap().getValue(Expressions).getVector().at(index).getMap().getValue(FilePath).getRawString();
return this._jsonValue.at(FrequestNode.FrequestNode_Expressions).getValueByIndex(index).getValueByString(FilePath).getRawString();
}
/**
@ -266,7 +297,7 @@ export namespace Live2DCubismFramework
return 0;
}
return this._json.getRoot().getMap().getValue(FileReferences).getMap().getValue(Motions).getMap().getSize();
return this._jsonValue.at(FrequestNode.FrequestNode_Motions).getKeys().getSize();
}
/**
@ -281,7 +312,7 @@ export namespace Live2DCubismFramework
return null;
}
return this._json.getRoot().getMap().getValue(FileReferences).getMap().getValue(Motions).getKeys().at(index);
return this._jsonValue.at(FrequestNode.FrequestNode_Motions).getKeys().at(index);
}
/**
@ -296,7 +327,7 @@ export namespace Live2DCubismFramework
return 0;
}
return this._json.getRoot().getMap().getValue(FileReferences).getMap().getValue(Motions).getMap().getValue(groupName).getSize();
return this._jsonValue.at(FrequestNode.FrequestNode_Motions).getValueByString(groupName).getSize();
}
/**
@ -312,7 +343,7 @@ export namespace Live2DCubismFramework
return "";
}
return this._json.getRoot().getMap().getValue(FileReferences).getMap().getValue(Motions).getMap().getValue(groupName).getVector().at(index).getMap().getValue(FilePath).getRawString();
return this._jsonValue.at(FrequestNode.FrequestNode_Motions).getValueByString(groupName).getValueByIndex(index).getValueByString(FilePath).getRawString();
}
/**
@ -328,7 +359,7 @@ export namespace Live2DCubismFramework
return "";
}
return this._json.getRoot().getMap().getValue(FileReferences).getMap().getValue(Motions).getMap().getValue(groupName).getVector().at(index).getMap().getValue(SoundPath).getRawString();
return this._jsonValue.at(FrequestNode.FrequestNode_Motions).getValueByString(groupName).getValueByIndex(index).getValueByString(SoundPath).getRawString();
}
/**
@ -344,7 +375,7 @@ export namespace Live2DCubismFramework
return -1.0;
}
return this._json.getRoot().getMap().getValue(FileReferences).getMap().getValue(Motions).getMap().getValue(groupName).getVector().at(index).getMap().getValue(FadeInTime).toFloat();
return this._jsonValue.at(FrequestNode.FrequestNode_Motions).getValueByString(groupName).getValueByIndex(index).getValueByString(FadeInTime).toFloat();
}
/**
@ -360,7 +391,7 @@ export namespace Live2DCubismFramework
return -1.0;
}
return this._json.getRoot().getMap().getValue(FileReferences).getMap().getValue(Motions).getMap().getValue(groupName).getVector().at(index).getMap().getValue(FadeOutTime).toFloat();
return this._jsonValue.at(FrequestNode.FrequestNode_Motions).getValueByString(groupName).getValueByIndex(index).getValueByString(FadeOutTime).toFloat();
}
/**
@ -374,7 +405,7 @@ export namespace Live2DCubismFramework
return "";
}
return this._json.getRoot().getMap().getValue(FileReferences).getMap().getValue(UserData).getRawString();
return this._json.getRoot().getValueByString(FileReferences).getValueByString(UserData).getRawString();
}
/**
@ -386,9 +417,7 @@ export namespace Live2DCubismFramework
public getLayoutMap(outLayoutMap: csmMap<string, number>): boolean
{
// 存在しない要素にアクセスするとエラーになるためValueがnullの場合はnullを代入する
let map: csmMap<string, Value> = (this._json.getRoot().getMap().isExist(Layout))
? this._json.getRoot().getMap().getValue(Layout).getMap()
: null;
let map: csmMap<string, Value> = this._json.getRoot().getValueByString(Layout).getMap();
if(map == null)
{
@ -418,11 +447,17 @@ export namespace Live2DCubismFramework
}
let num: number = 0;
for (let i = 0; i < this._json.getRoot().getMap().getValue(Groups).getSize(); i++)
for (let i = 0; i < this._jsonValue.at(FrequestNode.FrequestNode_Groups).getSize(); i++)
{
if (this._json.getRoot().getMap().getValue(Groups).getVector().at(i).getMap().getValue(Name).getRawString() == EyeBlink)
let refI: Value = this._jsonValue.at(FrequestNode.FrequestNode_Groups).getValueByIndex(i);
if(refI.isNull() || refI.isError())
{
num = this._json.getRoot().getMap().getValue(Groups).getVector().at(i).getMap().getValue(Ids).getVector().getSize();
continue;
}
if (refI.getValueByString(Name).getRawString() == EyeBlink)
{
num = refI.getValueByString(Ids).getVector().getSize();
break;
}
}
@ -442,11 +477,17 @@ export namespace Live2DCubismFramework
return null;
}
for (let i = 0; i < this._json.getRoot().getMap().getValue(Groups).getSize(); i++)
for (let i = 0; i < this._jsonValue.at(FrequestNode.FrequestNode_Groups).getSize(); i++)
{
if (this._json.getRoot().getMap().getValue(Groups).getVector().at(i).getMap().getValue(Name).getRawString() == EyeBlink)
let refI: Value = this._jsonValue.at(FrequestNode.FrequestNode_Groups).getValueByIndex(i);
if(refI.isNull() || refI.isError())
{
return CubismFramework.getIdManager().getId(this._json.getRoot().getMap().getValue(Groups).getVector().at(i).getMap().getValue(Ids).getVector().at(index).getRawString());
continue;
}
if (refI.getValueByString(Name).getRawString() == EyeBlink)
{
return CubismFramework.getIdManager().getId(refI.getValueByString(Ids).getValueByIndex(index).getRawString());
}
}
return null;
@ -464,11 +505,17 @@ export namespace Live2DCubismFramework
}
let num: number = 0;
for (let i: number = 0; i < this._json.getRoot().getMap().getValue(Groups).getSize(); i++)
for (let i: number = 0; i < this._jsonValue.at(FrequestNode.FrequestNode_Groups).getSize(); i++)
{
if (this._json.getRoot().getMap().getValue(Groups).getVector().at(i).getMap().getValue(Name).getRawString() == LipSync)
let refI: Value = this._jsonValue.at(FrequestNode.FrequestNode_Groups).getValueByIndex(i);
if(refI.isNull() || refI.isError())
{
num = this._json.getRoot().getMap().getValue(Groups).getVector().at(i).getMap().getValue(Ids).getVector().getSize();
continue;
}
if (refI.getValueByString(Name).getRawString() == LipSync)
{
num = refI.getValueByString(Ids).getVector().getSize();
break;
}
}
@ -488,11 +535,17 @@ export namespace Live2DCubismFramework
return null;
}
for (let i: number = 0; i < this._json.getRoot().getMap().getValue(Groups).getSize(); i++)
for (let i: number = 0; i < this._jsonValue.at(FrequestNode.FrequestNode_Groups).getSize(); i++)
{
if (this._json.getRoot().getMap().getValue(Groups).getVector().at(i).getMap().getValue(Name).getRawString() == LipSync)
let refI: Value = this._jsonValue.at(FrequestNode.FrequestNode_Groups).getValueByIndex(i);
if(refI.isNull() || refI.isError())
{
return CubismFramework.getIdManager().getId(this._json.getRoot().getMap().getValue(Groups).getVector().at(i).getMap().getValue(Ids).getVector().at(index).getRawString());
continue;
}
if (refI.getValueByString(Name).getRawString() == LipSync)
{
return CubismFramework.getIdManager().getId(refI.getValueByString(Ids).getValueByIndex(index).getRawString());
}
}
return null;
@ -505,7 +558,8 @@ export namespace Live2DCubismFramework
*/
private isExistModelFile(): boolean
{
return this._json.getRoot().getMap().getValue(FileReferences).getMap().isExist(Moc);
let node: Value = this._jsonValue.at(FrequestNode.FrequestNode_Moc);
return !node.isNull() && !node.isError();
}
/**
@ -515,7 +569,8 @@ export namespace Live2DCubismFramework
*/
private isExistTextureFiles(): boolean
{
return this._json.getRoot().getMap().getValue(FileReferences).getMap().isExist(Textures);
let node: Value = this._jsonValue.at(FrequestNode.FrequestNode_Textures);
return !node.isNull() && !node.isError();
}
/**
@ -525,7 +580,8 @@ export namespace Live2DCubismFramework
*/
private isExistHitAreas(): boolean
{
return this._json.getRoot().getMap().isExist(HitAreas);
let node: Value = this._jsonValue.at(FrequestNode.FrequestNode_HitAreas);
return !node.isNull() && !node.isError();
}
/**
@ -535,7 +591,8 @@ export namespace Live2DCubismFramework
*/
private isExistPhysicsFile(): boolean
{
return this._json.getRoot().getMap().getValue(FileReferences).getMap().isExist(Physics);
let node: Value = this._jsonValue.at(FrequestNode.FrequestNode_Physics);
return !node.isNull() && !node.isError();
}
/**
@ -545,7 +602,8 @@ export namespace Live2DCubismFramework
*/
private isExistPoseFile(): boolean
{
return this._json.getRoot().getMap().getValue(FileReferences).getMap().isExist(Pose);
let node: Value = this._jsonValue.at(FrequestNode.FrequestNode_Pose);
return !node.isNull() && !node.isError();
}
/**
@ -555,7 +613,8 @@ export namespace Live2DCubismFramework
*/
private isExistExpressionFile(): boolean
{
return this._json.getRoot().getMap().getValue(FileReferences).getMap().isExist(Expressions);
let node: Value = this._jsonValue.at(FrequestNode.FrequestNode_Expressions);
return !node.isNull() && !node.isError();
}
/**
@ -565,7 +624,8 @@ export namespace Live2DCubismFramework
*/
private isExistMotionGroups(): boolean
{
return this._json.getRoot().getMap().getValue(FileReferences).getMap().isExist(Motions);
let node: Value = this._jsonValue.at(FrequestNode.FrequestNode_Motions);
return !node.isNull() && !node.isError();
}
/**
@ -576,11 +636,8 @@ export namespace Live2DCubismFramework
*/
private isExistMotionGroupName(groupName: string): boolean
{
if(!this._json.getRoot().getMap().getValue(FileReferences).getMap().isExist(Motions))
{
return false;
}
return this._json.getRoot().getMap().getValue(FileReferences).getMap().getValue(Motions).getMap().isExist(groupName);
let node: Value = this._jsonValue.at(FrequestNode.FrequestNode_Motions).getValueByString(groupName);
return !node.isNull() && !node.isError();
}
/**
@ -592,7 +649,8 @@ export namespace Live2DCubismFramework
*/
private isExistMotionSoundFile(groupName: string, index: number): boolean
{
return this._json.getRoot().getMap().getValue(FileReferences).getMap().getValue(Motions).getMap().getValue(groupName).getVector().at(index).getMap().isExist(SoundPath);
let node: Value = this._jsonValue.at(FrequestNode.FrequestNode_Motions).getValueByString(groupName).getValueByIndex(index).getValueByString(SoundPath);
return !node.isNull() && !node.isError();
}
/**
@ -604,7 +662,8 @@ export namespace Live2DCubismFramework
*/
private isExistMotionFadeIn(groupName: string, index: number): boolean
{
return this._json.getRoot().getMap().getValue(FileReferences).getMap().getValue(Motions).getMap().getValue(groupName).getVector().at(index).getMap().isExist(FadeInTime);
let node: Value = this._jsonValue.at(FrequestNode.FrequestNode_Motions).getValueByString(groupName).getValueByIndex(index).getValueByString(FadeInTime);
return !node.isNull() && !node.isError();
}
/**
@ -616,7 +675,8 @@ export namespace Live2DCubismFramework
*/
private isExistMotionFadeOut(groupName: string, index: number): boolean
{
return this._json.getRoot().getMap().getValue(FileReferences).getMap().getValue(Motions).getMap().getValue(groupName).getVector().at(index).getMap().isExist(FadeOutTime);
let node: Value = this._jsonValue.at(FrequestNode.FrequestNode_Motions).getValueByString(groupName).getValueByIndex(index).getValueByString(FadeOutTime);
return !node.isNull() && !node.isError();
}
/**
@ -626,11 +686,8 @@ export namespace Live2DCubismFramework
*/
private isExistUserDataFile(): boolean
{
if(!this._json.getRoot().getMap().getValue(FileReferences).getMap().isExist(UserData))
{
return false;
}
return !this._json.getRoot().getMap().getValue(FileReferences).getMap().getValue(UserData).isNull();
let node: Value = this._json.getRoot().getValueByString(FileReferences).getValueByString(UserData);
return !node.isNull() && !node.isError();
}
/**
@ -640,13 +697,14 @@ export namespace Live2DCubismFramework
*/
private isExistEyeBlinkParameters(): boolean
{
if(!this._json.getRoot().getMap().isExist(Groups))
if(this._jsonValue.at(FrequestNode.FrequestNode_Groups).isNull() || this._jsonValue.at(FrequestNode.FrequestNode_Groups).isError())
{
return false;
}
for (let i: number = 0; i < this._json.getRoot().getMap().getValue(Groups).getSize(); ++i)
for (let i: number = 0; i < this._jsonValue.at(FrequestNode.FrequestNode_Groups).getSize(); ++i)
{
if (this._json.getRoot().getMap().getValue(Groups).getVector().at(i).getMap().getValue(Name).getRawString() == EyeBlink)
if (this._jsonValue.at(FrequestNode.FrequestNode_Groups).getValueByIndex(i).getValueByString(Name).getRawString() == EyeBlink)
{
return true;
}
@ -662,13 +720,13 @@ export namespace Live2DCubismFramework
*/
private isExistLipSyncParameters(): boolean
{
if(!this._json.getRoot().getMap().isExist(Groups))
if(this._jsonValue.at(FrequestNode.FrequestNode_Groups).isNull() || this._jsonValue.at(FrequestNode.FrequestNode_Groups).isError())
{
return false;
}
for (let i: number = 0; i < this._json.getRoot().getMap().getValue(Groups).getSize(); ++i)
for (let i: number = 0; i < this._jsonValue.at(FrequestNode.FrequestNode_Groups).getSize(); ++i)
{
if (this._json.getRoot().getMap().getValue(Groups).getVector().at(i).getMap().getValue(Name).getRawString() == LipSync)
if (this._jsonValue.at(FrequestNode.FrequestNode_Groups).getValueByIndex(i).getValueByString(Name).getRawString() == LipSync)
{
return true;
}
@ -678,5 +736,6 @@ export namespace Live2DCubismFramework
private _json: CubismJson;
private _jsonValue: csmVector<Value>;
}
}

View File

@ -51,9 +51,9 @@ export namespace Live2DCubismFramework
let root: Value = json.getRoot();
// フェード時間の指定
if(root.getMap().isExist(FadeIn))
if(!root.getValueByString(FadeIn).isNull())
{
ret._fadeTimeSeconds = root.getMap().getValue(FadeIn).toFloat(DefaultFadeInSeconds);
ret._fadeTimeSeconds = root.getValueByString(FadeIn).toFloat(DefaultFadeInSeconds);
if(ret._fadeTimeSeconds <= 0.0)
{
@ -62,33 +62,33 @@ export namespace Live2DCubismFramework
}
// パーツグループ
let poseListInfo: Value = root.getMap().getValue(Groups);
let poseListInfo: Value = root.getValueByString(Groups);
const poseCount: number = poseListInfo.getSize();
for(let poseIndex: number = 0; poseIndex < poseCount; ++poseIndex)
{
let idListInfo: Value = poseListInfo.getVector().at(poseIndex);
let idListInfo: Value = poseListInfo.getValueByIndex(poseIndex);
const idCount: number = idListInfo.getSize();
let groupCount: number = 0;
for(let groupIndex: number = 0; groupIndex < idCount; ++groupIndex)
{
let partInfo: Value = idListInfo.getVector().at(groupIndex);
let partInfo: Value = idListInfo.getValueByIndex(groupIndex);
let partData: PartData = new PartData();
const parameterId: CubismIdHandle = CubismFramework.getIdManager().getId(partInfo.getMap().getValue(Id).getRawString());
const parameterId: CubismIdHandle = CubismFramework.getIdManager().getId(partInfo.getValueByString(Id).getRawString());
partData.partId = parameterId;
// リンクするパーツの設定
if(partInfo.getMap().isExist(Link))
if(!partInfo.getValueByString(Link).isNull())
{
let linkListInfo: Value = partInfo.getMap().getValue(Link);
let linkListInfo: Value = partInfo.getValueByString(Link);
const linkCount: number = linkListInfo.getSize();
for(let linkIndex: number = 0; linkIndex < linkCount; ++linkIndex)
{
let linkPart: PartData = new PartData();
const linkId: CubismIdHandle = CubismFramework.getIdManager().getId(linkListInfo.getVector().at(linkIndex).getString());
const linkId: CubismIdHandle = CubismFramework.getIdManager().getId(linkListInfo.getValueByIndex(linkIndex).getString());
linkPart.partId = linkId;

View File

@ -86,12 +86,10 @@ export namespace Live2DCubismFramework
export class CubismFramework
{
/**
* @brief Cubism FrameworkAPI使<br>
* API<br>
* <br>
*
* Cubism FrameworkAPI使
* API
*
*
* @param allocator ICubismAllocator
* @param option Option
*
* @return true

View File

@ -5,6 +5,7 @@
* that can be found at http://live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/
/// <reference path="../../Core/live2dcubismcore.d.ts" />
import {Live2DCubismFramework as cubismmodel} from "./cubismmodel";
import CubismModel = cubismmodel.CubismModel;
import { CSM_ASSERT } from "../utils/cubismdebug";

View File

@ -5,7 +5,7 @@
* that can be found at http://live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/
/// <reference path="../../Core/live2dcubismcore" />
/// <reference path="../../Core/live2dcubismcore.d.ts" />
import {Live2DCubismFramework as cubismrenderer} from "../rendering/cubismrenderer";
import {Live2DCubismFramework as cubismid} from "../id/cubismid";
import {Live2DCubismFramework as cubismframework} from "../live2dcubismframework";
@ -722,6 +722,7 @@ export namespace Live2DCubismFramework
const parameterIds: string[] = this._model.parameters.ids;
const parameterCount: number = this._model.parameters.count;
this._parameterIds.prepareCapacity(parameterCount);
for(let i: number = 0; i < parameterCount; ++i)
{
this._parameterIds.pushBack(CubismFramework.getIdManager().getId(parameterIds[i]));
@ -732,6 +733,7 @@ export namespace Live2DCubismFramework
const partIds: string[] = this._model.parts.ids;
const partCount: number = this._model.parts.count;
this._partIds.prepareCapacity(partCount);
for(let i: number = 0; i < partCount; ++i)
{
this._partIds.pushBack(CubismFramework.getIdManager().getId(partIds[i]));
@ -742,6 +744,7 @@ export namespace Live2DCubismFramework
const drawableIds: string[] = this._model.drawables.ids;
const drawableCount: number = this._model.drawables.count;
this._drawableIds.prepareCapacity(drawableCount);
for(let i: number = 0; i < drawableCount; ++i)
{
this._drawableIds.pushBack(CubismFramework.getIdManager().getId(drawableIds[i]));

View File

@ -49,7 +49,7 @@ export namespace Live2DCubismFramework
*/
public getUserDataCount(): number
{
return this._json.getRoot().getMap().getValue(Meta).getMap().getValue(UserDataCount).toInt();
return this._json.getRoot().getValueByString(Meta).getValueByString(UserDataCount).toInt();
}
/**
@ -59,7 +59,7 @@ export namespace Live2DCubismFramework
*/
public getTotalUserDataSize(): number
{
return this._json.getRoot().getMap().getValue(Meta).getMap().getValue(TotalUserDataSize).toInt();
return this._json.getRoot().getValueByString(Meta).getValueByString(TotalUserDataSize).toInt();
}
/**
@ -69,7 +69,7 @@ export namespace Live2DCubismFramework
*/
public getUserDataTargetType(i: number): string
{
return this._json.getRoot().getMap().getValue(UserData).getVector().at(i).getMap().getValue(Target).getRawString();
return this._json.getRoot().getValueByString(UserData).getValueByIndex(i).getValueByString(Target).getRawString();
}
/**
@ -80,7 +80,7 @@ export namespace Live2DCubismFramework
*/
public getUserDataId(i: number): CubismIdHandle
{
return CubismFramework.getIdManager().getId(this._json.getRoot().getMap().getValue(UserData).getVector().at(i).getMap().getValue(Id).getRawString());
return CubismFramework.getIdManager().getId(this._json.getRoot().getValueByString(UserData).getValueByIndex(i).getValueByString(Id).getRawString());
}
/**
@ -91,7 +91,7 @@ export namespace Live2DCubismFramework
*/
public getUserDataValue(i: number): string
{
return this._json.getRoot().getMap().getValue(UserData).getVector().at(i).getMap().getValue(Value).getRawString();
return this._json.getRoot().getValueByString(UserData).getValueByIndex(i).getValueByString(Value).getRawString();
}
private _json: CubismJson;

View File

@ -55,42 +55,33 @@ export namespace Live2DCubismFramework
let json: CubismJson = CubismJson.create(buffer, size);
let root: Value = json.getRoot();
// typescriptではnullを許容していないため仮の値を入れる
if(root.getMap().getValue(ExpressionKeyFadeIn) == null)
{
root.getMap().setValue(ExpressionKeyFadeIn, new JsonFloat(DefaultFadeTime));
}
if(root.getMap().getValue(ExpressionKeyFadeOut) == null)
{
root.getMap().setValue(ExpressionKeyFadeOut, new JsonFloat(DefaultFadeTime));
}
expression.setFadeInTime(root.getMap().getValue(ExpressionKeyFadeIn).toFloat(DefaultFadeTime)); // フェードイン
expression.setFadeOutTime(root.getMap().getValue(ExpressionKeyFadeOut).toFloat(DefaultFadeTime)); // フェードアウト
expression.setFadeInTime(root.getValueByString(ExpressionKeyFadeIn).toFloat(DefaultFadeTime)); // フェードイン
expression.setFadeOutTime(root.getValueByString(ExpressionKeyFadeOut).toFloat(DefaultFadeTime)); // フェードアウト
// 各パラメータについて
const parameterCount = root.getMap().getValue(ExpressionKeyParameters).getSize();
const parameterCount = root.getValueByString(ExpressionKeyParameters).getSize();
expression._parameters.prepareCapacity(parameterCount);
for(let i: number = 0; i < parameterCount; ++i)
{
let param: Value = root.getMap().getValue(ExpressionKeyParameters).getVector().at(i);
const parameterId: CubismIdHandle = CubismFramework.getIdManager().getId(param.getMap().getValue(ExpressionKeyId).getRawString()); // パラメータID
let param: Value = root.getValueByString(ExpressionKeyParameters).getValueByIndex(i);
const parameterId: CubismIdHandle = CubismFramework.getIdManager().getId(param.getValueByString(ExpressionKeyId).getRawString()); // パラメータID
const value: number = param.getMap().getValue(ExpressionKeyValue).toFloat(); // 値
const value: number = param.getValueByString(ExpressionKeyValue).toFloat(); // 値
// 計算方法の設定
let blendType: ExpressionBlendType;
if(param.getMap().getValue(ExpressionKeyBlend).isNull() || param.getMap().getValue(ExpressionKeyBlend).getString() == BlendValueAdd)
if(param.getValueByString(ExpressionKeyBlend).isNull() || param.getValueByString(ExpressionKeyBlend).getString() == BlendValueAdd)
{
blendType = ExpressionBlendType.ExpressionBlendType_Add;
}
else if(param.getMap().getValue(ExpressionKeyBlend).getString() == BlendValueMultiply)
else if(param.getValueByString(ExpressionKeyBlend).getString() == BlendValueMultiply)
{
blendType = ExpressionBlendType.ExpressionBlendType_Multiply;
}
else if(param.getMap().getValue(ExpressionKeyBlend).getString() == BlendValueOverwrite)
else if(param.getValueByString(ExpressionKeyBlend).getString() == BlendValueOverwrite)
{
blendType = ExpressionBlendType.ExpressionBlendType_Overwrite;
}

View File

@ -65,7 +65,7 @@ export namespace Live2DCubismFramework
*/
public getMotionDuration(): number
{
return this._json.getRoot().getMap().getValue(Meta).getMap().getValue(Duration).toFloat();
return this._json.getRoot().getValueByString(Meta).getValueByString(Duration).toFloat();
}
/**
@ -75,7 +75,7 @@ export namespace Live2DCubismFramework
*/
public isMotionLoop(): boolean
{
return this._json.getRoot().getMap().getValue(Meta).getMap().getValue(Loop).toBoolean();
return this._json.getRoot().getValueByString(Meta).getValueByString(Loop).toBoolean();
}
/**
@ -84,7 +84,7 @@ export namespace Live2DCubismFramework
*/
public getMotionCurveCount(): number
{
return this._json.getRoot().getMap().getValue(Meta).getMap().getValue(CurveCount).toInt();
return this._json.getRoot().getValueByString(Meta).getValueByString(CurveCount).toInt();
}
/**
@ -93,7 +93,7 @@ export namespace Live2DCubismFramework
*/
public getMotionFps(): number
{
return this._json.getRoot().getMap().getValue(Meta).getMap().getValue(Fps).toFloat();
return this._json.getRoot().getValueByString(Meta).getValueByString(Fps).toFloat();
}
/**
@ -102,7 +102,7 @@ export namespace Live2DCubismFramework
*/
public getMotionTotalSegmentCount(): number
{
return this._json.getRoot().getMap().getValue(Meta).getMap().getValue(TotalSegmentCount).toInt();
return this._json.getRoot().getValueByString(Meta).getValueByString(TotalSegmentCount).toInt();
}
/**
@ -111,7 +111,7 @@ export namespace Live2DCubismFramework
*/
public getMotionTotalPointCount(): number
{
return this._json.getRoot().getMap().getValue(Meta).getMap().getValue(TotalPointCount).toInt();
return this._json.getRoot().getValueByString(Meta).getValueByString(TotalPointCount).toInt();
}
/**
@ -121,7 +121,7 @@ export namespace Live2DCubismFramework
*/
public isExistMotionFadeInTime(): boolean
{
return this._json.getRoot().getMap().getValue(Meta).getMap().isExist(FadeInTime);
return !this._json.getRoot().getValueByString(Meta).getValueByString(FadeInTime).isNull();
}
/**
@ -131,7 +131,7 @@ export namespace Live2DCubismFramework
*/
public isExistMotionFadeOutTime(): boolean
{
return this._json.getRoot().getMap().getValue(Meta).getMap().isExist(FadeOutTime);
return !this._json.getRoot().getValueByString(Meta).getValueByString(FadeOutTime).isNull();
}
/**
@ -140,7 +140,7 @@ export namespace Live2DCubismFramework
*/
public getMotionFadeInTime(): number
{
return this._json.getRoot().getMap().getValue(Meta).getMap().getValue(FadeInTime).toFloat();
return this._json.getRoot().getValueByString(Meta).getValueByString(FadeInTime).toFloat();
}
/**
@ -149,7 +149,7 @@ export namespace Live2DCubismFramework
*/
public getMotionFadeOutTime(): number
{
return this._json.getRoot().getMap().getValue(Meta).getMap().getValue(FadeOutTime).toFloat();
return this._json.getRoot().getValueByString(Meta).getValueByString(FadeOutTime).toFloat();
}
/**
@ -159,7 +159,7 @@ export namespace Live2DCubismFramework
*/
public getMotionCurveTarget(curveIndex: number): string
{
return this._json.getRoot().getMap().getValue(Curves).getVector().at(curveIndex).getMap().getValue(Target).getRawString();
return this._json.getRoot().getValueByString(Curves).getValueByIndex(curveIndex).getValueByString(Target).getRawString();
}
/**
@ -169,7 +169,7 @@ export namespace Live2DCubismFramework
*/
public getMotionCurveId(curveIndex: number): CubismIdHandle
{
return CubismFramework.getIdManager().getId(this._json.getRoot().getMap().getValue(Curves).getVector().at(curveIndex).getMap().getValue(Id).getRawString());
return CubismFramework.getIdManager().getId(this._json.getRoot().getValueByString(Curves).getValueByIndex(curveIndex).getValueByString(Id).getRawString());
}
/**
@ -180,7 +180,7 @@ export namespace Live2DCubismFramework
*/
public isExistMotionCurveFadeInTime(curveIndex: number): boolean
{
return this._json.getRoot().getMap().getValue(Curves).getVector().at(curveIndex).getMap().isExist(FadeInTime);
return !this._json.getRoot().getValueByString(Curves).getValueByIndex(curveIndex).getValueByString(FadeInTime).isNull();
}
/**
@ -191,7 +191,7 @@ export namespace Live2DCubismFramework
*/
public isExistMotionCurveFadeOutTime(curveIndex: number): boolean
{
return this._json.getRoot().getMap().getValue(Curves).getVector().at(curveIndex).getMap().isExist(FadeOutTime);
return !this._json.getRoot().getValueByString(Curves).getValueByIndex(curveIndex).getValueByString(FadeOutTime).isNull();
}
/**
@ -201,7 +201,7 @@ export namespace Live2DCubismFramework
*/
public getMotionCurveFadeInTime(curveIndex: number): number
{
return this._json.getRoot().getMap().getValue(Curves).getVector().at(curveIndex).getMap().getValue(FadeInTime).toFloat();
return this._json.getRoot().getValueByString(Curves).getValueByIndex(curveIndex).getValueByString(FadeInTime).toFloat();
}
/**
@ -211,7 +211,7 @@ export namespace Live2DCubismFramework
*/
public getMotionCurveFadeOutTime(curveIndex: number): number
{
return this._json.getRoot().getMap().getValue(Curves).getVector().at(curveIndex).getMap().getValue(FadeOutTime).toFloat();
return this._json.getRoot().getValueByString(Curves).getValueByIndex(curveIndex).getValueByString(FadeOutTime).toFloat();
}
/**
@ -221,7 +221,7 @@ export namespace Live2DCubismFramework
*/
public getMotionCurveSegmentCount(curveIndex: number): number
{
return this._json.getRoot().getMap().getValue(Curves).getVector().at(curveIndex).getMap().getValue(Segments).getVector().getSize();
return this._json.getRoot().getValueByString(Curves).getValueByIndex(curveIndex).getValueByString(Segments).getVector().getSize();
}
/**
@ -232,7 +232,7 @@ export namespace Live2DCubismFramework
*/
public getMotionCurveSegment(curveIndex: number, segmentIndex: number): number
{
return this._json.getRoot().getMap().getValue(Curves).getVector().at(curveIndex).getMap().getValue(Segments).getVector().at(segmentIndex).toFloat();
return this._json.getRoot().getValueByString(Curves).getValueByIndex(curveIndex).getValueByString(Segments).getValueByIndex(segmentIndex).toFloat();
}
/**
@ -241,11 +241,7 @@ export namespace Live2DCubismFramework
*/
public getEventCount(): number
{
if(!this._json.getRoot().getMap().getValue(Meta).getMap().isExist(UserDataCount))
{
return 0;
}
return this._json.getRoot().getMap().getValue(Meta).getMap().getValue(UserDataCount).toInt();
return this._json.getRoot().getValueByString(Meta).getValueByString(UserDataCount).toInt();
}
/**
@ -254,7 +250,7 @@ export namespace Live2DCubismFramework
*/
public getTotalEventValueSize(): number
{
return this._json.getRoot().getMap().getValue(Meta).getMap().getValue(TotalUserDataSize).toInt();
return this._json.getRoot().getValueByString(Meta).getValueByString(TotalUserDataSize).toInt();
}
/**
@ -264,7 +260,7 @@ export namespace Live2DCubismFramework
*/
public getEventTime(userDataIndex: number): number
{
return this._json.getRoot().getMap().getValue(UserData).getVector().at(userDataIndex).getMap().getValue(Time).toInt();
return this._json.getRoot().getValueByString(UserData).getValueByIndex(userDataIndex).getValueByString(Time).toInt();
}
/**
@ -274,7 +270,7 @@ export namespace Live2DCubismFramework
*/
public getEventValue(userDataIndex: number): csmString
{
return new csmString(this._json.getRoot().getMap().getValue(UserData).getVector().at(userDataIndex).getMap().getValue(Value).getRawString());
return new csmString(this._json.getRoot().getValueByString(UserData).getValueByIndex(userDataIndex).getValueByString(Value).getRawString());
}
_json: CubismJson; // motion3.jsonのデータ

View File

@ -90,8 +90,8 @@ export namespace Live2DCubismFramework
public getGravity(): CubismVector2
{
let ret: CubismVector2 = new CubismVector2(0, 0);
ret.x = this._json.getRoot().getMap().getValue(Meta).getMap().getValue(EffectiveForces).getMap().getValue(Gravity).getMap().getValue(X).toFloat();
ret.y = this._json.getRoot().getMap().getValue(Meta).getMap().getValue(EffectiveForces).getMap().getValue(Gravity).getMap().getValue(Y).toFloat();
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;
}
@ -102,8 +102,8 @@ export namespace Live2DCubismFramework
public getWind(): CubismVector2
{
let ret: CubismVector2 = new CubismVector2(0, 0);
ret.x = this._json.getRoot().getMap().getValue(Meta).getMap().getValue(EffectiveForces).getMap().getValue(Wind).getMap().getValue(X).toFloat();
ret.y = this._json.getRoot().getMap().getValue(Meta).getMap().getValue(EffectiveForces).getMap().getValue(Wind).getMap().getValue(Y).toFloat();
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;
}
@ -113,7 +113,7 @@ export namespace Live2DCubismFramework
*/
public getSubRigCount(): number
{
return this._json.getRoot().getMap().getValue(Meta).getMap().getValue(PhysicsSettingCount).toInt();
return this._json.getRoot().getValueByString(Meta).getValueByString(PhysicsSettingCount).toInt();
}
/**
@ -122,7 +122,7 @@ export namespace Live2DCubismFramework
*/
public getTotalInputCount(): number
{
return this._json.getRoot().getMap().getValue(Meta).getMap().getValue(TotalInputCount).toInt();
return this._json.getRoot().getValueByString(Meta).getValueByString(TotalInputCount).toInt();
}
/**
@ -131,7 +131,7 @@ export namespace Live2DCubismFramework
*/
public getTotalOutputCount(): number
{
return this._json.getRoot().getMap().getValue(Meta).getMap().getValue(TotalOutputCount).toInt();
return this._json.getRoot().getValueByString(Meta).getValueByString(TotalOutputCount).toInt();
}
/**
@ -140,7 +140,7 @@ export namespace Live2DCubismFramework
*/
public getVertexCount(): number
{
return this._json.getRoot().getMap().getValue(Meta).getMap().getValue(VertexCount).toInt();
return this._json.getRoot().getValueByString(Meta).getValueByString(VertexCount).toInt();
}
/**
@ -150,7 +150,7 @@ export namespace Live2DCubismFramework
*/
public getNormalizationPositionMinimumValue(physicsSettingIndex: number): number
{
return this._json.getRoot().getMap().getValue(PhysicsSettings).getVector().at(physicsSettingIndex).getMap().getValue(Normalization).getMap().getValue(Position).getMap().getValue(Minimum).toFloat();
return this._json.getRoot().getValueByString(PhysicsSettings).getValueByIndex(physicsSettingIndex).getValueByString(Normalization).getValueByString(Position).getValueByString(Minimum).toFloat();
}
/**
@ -160,7 +160,7 @@ export namespace Live2DCubismFramework
*/
public getNormalizationPositionMaximumValue(physicsSettingIndex: number): number
{
return this._json.getRoot().getMap().getValue(PhysicsSettings).getVector().at(physicsSettingIndex).getMap().getValue(Normalization).getMap().getValue(Position).getMap().getValue(Maximum).toFloat();
return this._json.getRoot().getValueByString(PhysicsSettings).getValueByIndex(physicsSettingIndex).getValueByString(Normalization).getValueByString(Position).getValueByString(Maximum).toFloat();
}
/**
@ -170,7 +170,7 @@ export namespace Live2DCubismFramework
*/
public getNormalizationPositionDefaultValue(physicsSettingIndex: number): number
{
return this._json.getRoot().getMap().getValue(PhysicsSettings).getVector().at(physicsSettingIndex).getMap().getValue(Normalization).getMap().getValue(Position).getMap().getValue(Default).toFloat();
return this._json.getRoot().getValueByString(PhysicsSettings).getValueByIndex(physicsSettingIndex).getValueByString(Normalization).getValueByString(Position).getValueByString(Default).toFloat();
}
/**
@ -180,7 +180,7 @@ export namespace Live2DCubismFramework
*/
public getNormalizationAngleMinimumValue(physicsSettingIndex: number): number
{
return this._json.getRoot().getMap().getValue(PhysicsSettings).getVector().at(physicsSettingIndex).getMap().getValue(Normalization).getMap().getValue(Angle).getMap().getValue(Minimum).toFloat();
return this._json.getRoot().getValueByString(PhysicsSettings).getValueByIndex(physicsSettingIndex).getValueByString(Normalization).getValueByString(Angle).getValueByString(Minimum).toFloat();
}
/**
@ -190,7 +190,7 @@ export namespace Live2DCubismFramework
*/
public getNormalizationAngleMaximumValue(physicsSettingIndex: number): number
{
return this._json.getRoot().getMap().getValue(PhysicsSettings).getVector().at(physicsSettingIndex).getMap().getValue(Normalization).getMap().getValue(Angle).getMap().getValue(Maximum).toFloat();
return this._json.getRoot().getValueByString(PhysicsSettings).getValueByIndex(physicsSettingIndex).getValueByString(Normalization).getValueByString(Angle).getValueByString(Maximum).toFloat();
}
/**
@ -200,7 +200,7 @@ export namespace Live2DCubismFramework
*/
public getNormalizationAngleDefaultValue(physicsSettingIndex: number): number
{
return this._json.getRoot().getMap().getValue(PhysicsSettings).getVector().at(physicsSettingIndex).getMap().getValue(Normalization).getMap().getValue(Angle).getMap().getValue(Default).toFloat();
return this._json.getRoot().getValueByString(PhysicsSettings).getValueByIndex(physicsSettingIndex).getValueByString(Normalization).getValueByString(Angle).getValueByString(Default).toFloat();
}
/**
@ -210,7 +210,7 @@ export namespace Live2DCubismFramework
*/
public getInputCount(physicsSettingIndex: number): number
{
return this._json.getRoot().getMap().getValue(PhysicsSettings).getVector().at(physicsSettingIndex).getMap().getValue(Input).getVector().getSize();
return this._json.getRoot().getValueByString(PhysicsSettings).getValueByIndex(physicsSettingIndex).getValueByString(Input).getVector().getSize();
}
/**
@ -221,7 +221,7 @@ export namespace Live2DCubismFramework
*/
public getInputWeight(physicsSettingIndex: number, inputIndex: number): number
{
return this._json.getRoot().getMap().getValue(PhysicsSettings).getVector().at(physicsSettingIndex).getMap().getValue(Input).getVector().at(inputIndex).getMap().getValue(Weight).toFloat();
return this._json.getRoot().getValueByString(PhysicsSettings).getValueByIndex(physicsSettingIndex).getValueByString(Input).getValueByIndex(inputIndex).getValueByString(Weight).toFloat();
}
/**
@ -232,7 +232,7 @@ export namespace Live2DCubismFramework
*/
public getInputReflect(physicsSettingIndex: number, inputIndex: number): boolean
{
return this._json.getRoot().getMap().getValue(PhysicsSettings).getVector().at(physicsSettingIndex).getMap().getValue(Input).getVector().at(inputIndex).getMap().getValue(Reflect).toBoolean();
return this._json.getRoot().getValueByString(PhysicsSettings).getValueByIndex(physicsSettingIndex).getValueByString(Input).getValueByIndex(inputIndex).getValueByString(Reflect).toBoolean();
}
/**
@ -243,7 +243,7 @@ export namespace Live2DCubismFramework
*/
public getInputType(physicsSettingIndex: number, inputIndex: number): string
{
return this._json.getRoot().getMap().getValue(PhysicsSettings).getVector().at(physicsSettingIndex).getMap().getValue(Input).getVector().at(inputIndex).getMap().getValue(Type).getRawString();
return this._json.getRoot().getValueByString(PhysicsSettings).getValueByIndex(physicsSettingIndex).getValueByString(Input).getValueByIndex(inputIndex).getValueByString(Type).getRawString();
}
/**
@ -254,7 +254,7 @@ export namespace Live2DCubismFramework
*/
public getInputSourceId(physicsSettingIndex: number, inputIndex: number): CubismIdHandle
{
return CubismFramework.getIdManager().getId(this._json.getRoot().getMap().getValue(PhysicsSettings).getVector().at(physicsSettingIndex).getMap().getValue(Input).getVector().at(inputIndex).getMap().getValue(Source).getMap().getValue(Id).getRawString());
return CubismFramework.getIdManager().getId(this._json.getRoot().getValueByString(PhysicsSettings).getValueByIndex(physicsSettingIndex).getValueByString(Input).getValueByIndex(inputIndex).getValueByString(Source).getValueByString(Id).getRawString());
}
/**
@ -264,7 +264,7 @@ export namespace Live2DCubismFramework
*/
public getOutputCount(physicsSettingIndex: number): number
{
return this._json.getRoot().getMap().getValue(PhysicsSettings).getVector().at(physicsSettingIndex).getMap().getValue(Output).getVector().getSize();
return this._json.getRoot().getValueByString(PhysicsSettings).getValueByIndex(physicsSettingIndex).getValueByString(Output).getVector().getSize();
}
/**
@ -275,7 +275,7 @@ export namespace Live2DCubismFramework
*/
public getOutputVertexIndex(physicsSettingIndex: number, outputIndex: number): number
{
return this._json.getRoot().getMap().getValue(PhysicsSettings).getVector().at(physicsSettingIndex).getMap().getValue(Output).getVector().at(outputIndex).getMap().getValue(VertexIndex).toInt();
return this._json.getRoot().getValueByString(PhysicsSettings).getValueByIndex(physicsSettingIndex).getValueByString(Output).getValueByIndex(outputIndex).getValueByString(VertexIndex).toInt();
}
/**
@ -286,7 +286,7 @@ export namespace Live2DCubismFramework
*/
public getOutputAngleScale(physicsSettingIndex: number, outputIndex: number): number
{
return this._json.getRoot().getMap().getValue(PhysicsSettings).getVector().at(physicsSettingIndex).getMap().getValue(Output).getVector().at(outputIndex).getMap().getValue(Scale).toFloat();
return this._json.getRoot().getValueByString(PhysicsSettings).getValueByIndex(physicsSettingIndex).getValueByString(Output).getValueByIndex(outputIndex).getValueByString(Scale).toFloat();
}
/**
@ -297,7 +297,7 @@ export namespace Live2DCubismFramework
*/
public getOutputWeight(physicsSettingIndex: number, outputIndex: number): number
{
return this._json.getRoot().getMap().getValue(PhysicsSettings).getVector().at(physicsSettingIndex).getMap().getValue(Output).getVector().at(outputIndex).getMap().getValue(Weight).toFloat();
return this._json.getRoot().getValueByString(PhysicsSettings).getValueByIndex(physicsSettingIndex).getValueByString(Output).getValueByIndex(outputIndex).getValueByString(Weight).toFloat();
}
/**
@ -308,7 +308,7 @@ export namespace Live2DCubismFramework
*/
public getOutputDestinationId(physicsSettingIndex: number, outputIndex: number): CubismIdHandle
{
return CubismFramework.getIdManager().getId(this._json.getRoot().getMap().getValue(PhysicsSettings).getVector().at(physicsSettingIndex).getMap().getValue(Output).getVector().at(outputIndex).getMap().getValue(Destination).getMap().getValue(Id).getRawString());
return CubismFramework.getIdManager().getId(this._json.getRoot().getValueByString(PhysicsSettings).getValueByIndex(physicsSettingIndex).getValueByString(Output).getValueByIndex(outputIndex).getValueByString(Destination).getValueByString(Id).getRawString());
}
/**
@ -319,7 +319,7 @@ export namespace Live2DCubismFramework
*/
public getOutputType(physicsSettingIndex: number, outputIndex: number): string
{
return this._json.getRoot().getMap().getValue(PhysicsSettings).getVector().at(physicsSettingIndex).getMap().getValue(Output).getVector().at(outputIndex).getMap().getValue(Type).getRawString();
return this._json.getRoot().getValueByString(PhysicsSettings).getValueByIndex(physicsSettingIndex).getValueByString(Output).getValueByIndex(outputIndex).getValueByString(Type).getRawString();
}
/**
@ -330,7 +330,7 @@ export namespace Live2DCubismFramework
*/
public getOutputReflect(physicsSettingIndex: number, outputIndex: number): boolean
{
return this._json.getRoot().getMap().getValue(PhysicsSettings).getVector().at(physicsSettingIndex).getMap().getValue(Output).getVector().at(outputIndex).getMap().getValue(Reflect).toBoolean();
return this._json.getRoot().getValueByString(PhysicsSettings).getValueByIndex(physicsSettingIndex).getValueByString(Output).getValueByIndex(outputIndex).getValueByString(Reflect).toBoolean();
}
/**
@ -340,7 +340,7 @@ export namespace Live2DCubismFramework
*/
public getParticleCount(physicsSettingIndex: number): number
{
return this._json.getRoot().getMap().getValue(PhysicsSettings).getVector().at(physicsSettingIndex).getMap().getValue(Vertices).getVector().getSize();
return this._json.getRoot().getValueByString(PhysicsSettings).getValueByIndex(physicsSettingIndex).getValueByString(Vertices).getVector().getSize();
}
/**
@ -351,7 +351,7 @@ export namespace Live2DCubismFramework
*/
public getParticleMobility(physicsSettingIndex: number, vertexIndex: number): number
{
return this._json.getRoot().getMap().getValue(PhysicsSettings).getVector().at(physicsSettingIndex).getMap().getValue(Vertices).getVector().at(vertexIndex).getMap().getValue(Mobility).toFloat();
return this._json.getRoot().getValueByString(PhysicsSettings).getValueByIndex(physicsSettingIndex).getValueByString(Vertices).getValueByIndex(vertexIndex).getValueByString(Mobility).toFloat();
}
/**
@ -362,7 +362,7 @@ export namespace Live2DCubismFramework
*/
public getParticleDelay(physicsSettingIndex: number, vertexIndex: number): number
{
return this._json.getRoot().getMap().getValue(PhysicsSettings).getVector().at(physicsSettingIndex).getMap().getValue(Vertices).getVector().at(vertexIndex).getMap().getValue(Delay).toFloat();
return this._json.getRoot().getValueByString(PhysicsSettings).getValueByIndex(physicsSettingIndex).getValueByString(Vertices).getValueByIndex(vertexIndex).getValueByString(Delay).toFloat();
}
/**
@ -373,7 +373,7 @@ export namespace Live2DCubismFramework
*/
public getParticleAcceleration(physicsSettingIndex: number, vertexIndex: number): number
{
return this._json.getRoot().getMap().getValue(PhysicsSettings).getVector().at(physicsSettingIndex).getMap().getValue(Vertices).getVector().at(vertexIndex).getMap().getValue(Acceleration).toFloat();
return this._json.getRoot().getValueByString(PhysicsSettings).getValueByIndex(physicsSettingIndex).getValueByString(Vertices).getValueByIndex(vertexIndex).getValueByString(Acceleration).toFloat();
}
/**
@ -384,7 +384,7 @@ export namespace Live2DCubismFramework
*/
public getParticleRadius(physicsSettingIndex: number, vertexIndex: number): number
{
return this._json.getRoot().getMap().getValue(PhysicsSettings).getVector().at(physicsSettingIndex).getMap().getValue(Vertices).getVector().at(vertexIndex).getMap().getValue(Radius).toInt();
return this._json.getRoot().getValueByString(PhysicsSettings).getValueByIndex(physicsSettingIndex).getValueByString(Vertices).getValueByIndex(vertexIndex).getValueByString(Radius).toInt();
}
/**
@ -396,8 +396,8 @@ export namespace Live2DCubismFramework
public getParticlePosition(physicsSettingIndex: number, vertexIndex: number): CubismVector2
{
let ret: CubismVector2 = new CubismVector2(0, 0);
ret.x = this._json.getRoot().getMap().getValue(PhysicsSettings).getVector().at(physicsSettingIndex).getMap().getValue(Vertices).getVector().at(vertexIndex).getMap().getValue(Position).getMap().getValue(X).toFloat();
ret.y = this._json.getRoot().getMap().getValue(PhysicsSettings).getVector().at(physicsSettingIndex).getMap().getValue(Vertices).getVector().at(vertexIndex).getMap().getValue(Position).getMap().getValue(Y).toFloat();
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;
}

View File

@ -1272,7 +1272,6 @@ export namespace Live2DCubismFramework
"varying vec2 v_texCoord;" +
"varying vec4 v_myPos;" +
"uniform mat4 u_clipMatrix;" +
"uniform sampler2D s_texture0;" +
"void main()" +
"{" +
" gl_Position = u_clipMatrix * a_position;" +
@ -1304,7 +1303,6 @@ export namespace Live2DCubismFramework
"attribute vec2 a_texCoord;" + //v.texcoord
"varying vec2 v_texCoord;" + //v2f.texcoord
"uniform mat4 u_matrix;" +
"uniform sampler2D s_texture0;" +
"void main()" +
"{" +
" gl_Position = u_matrix * a_position;" +
@ -1320,8 +1318,6 @@ export namespace Live2DCubismFramework
"varying vec4 v_clipPos;" +
"uniform mat4 u_matrix;" +
"uniform mat4 u_clipMatrix;" +
"uniform sampler2D s_texture0;" +
"uniform sampler2D s_texture1;" +
"void main()" +
"{" +
" gl_Position = u_matrix * a_position;" +

View File

@ -105,6 +105,22 @@ export namespace Live2DCubismFramework
return defaultValue;
}
/**
* [index]
*/
public getValueByIndex(index: number): Value
{
return Value.errorValue.setErrorNotForClientCall(CSM_JSON_ERROR_TYPE_MISMATCH);
}
/**
* [string | csmString]
*/
public getValueByString(s: string | csmString): Value
{
return Value.nullValue.setErrorNotForClientCall(CSM_JSON_ERROR_TYPE_MISMATCH);
}
/**
*
*
@ -1118,6 +1134,34 @@ export namespace Live2DCubismFramework
return true;
}
/**
* [index]
*/
public getValueByIndex(index: number): Value
{
if(index < 0 || this._array.getSize() <= index)
{
return Value.errorValue.setErrorNotForClientCall(CSM_JSON_ERROR_INDEX_OF_BOUNDS);
}
let v: Value = this._array.at(index);
if(v == null)
{
return Value.nullValue;
}
return v;
}
/**
* [string | csmString]
*/
public getValueByString(s: string | csmString): Value
{
return Value.errorValue.setErrorNotForClientCall(CSM_JSON_ERROR_TYPE_MISMATCH);
}
/**
* (csmString)
*/
@ -1175,7 +1219,6 @@ export namespace Live2DCubismFramework
public constructor()
{
super();
//this._keys = new csmVector<string>();
this._map = new csmMap<string, Value>();
}
@ -1208,6 +1251,44 @@ export namespace Live2DCubismFramework
return true;
}
/**
* [string | csmString]
*/
public getValueByString(s: string | csmString): Value
{
if(s instanceof csmString)
{
let ret: Value = this._map.getValue(s.s);
if(ret == null)
{
return Value.nullValue;
}
return ret;
}
for(let iter: csmMap_iterator<string, Value> = this._map.begin(); iter.notEqual(this._map.end()); iter.preIncrement())
{
if(iter.ptr().first == s)
{
if(iter.ptr().second == null)
{
return Value.nullValue;
}
return iter.ptr().second;
}
}
return Value.nullValue;
}
/**
* [index]
*/
public getValueByIndex(index: number): Value
{
return Value.errorValue.setErrorNotForClientCall(CSM_JSON_ERROR_TYPE_MISMATCH);
}
/**
* (csmString)
*/