Merge pull request #3 from cocor-au-lait/feature/avoid-namespace

Avoiding needless namespace syntax to simplify imports
master
wada 2021-01-06 11:30:07 +09:00 committed by GitHub
commit c80e158a66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
45 changed files with 13534 additions and 13421 deletions

View File

@ -23,7 +23,6 @@ rules:
- error - error
- allow: - allow:
- constructors - constructors
'@typescript-eslint/no-namespace': warn
'no-fallthrough': warn 'no-fallthrough': warn
'@typescript-eslint/unbound-method': off '@typescript-eslint/unbound-method': off
'no-inner-declarations': off 'no-inner-declarations': off

1
.gitignore vendored
View File

@ -10,4 +10,5 @@ dist/
# Exclude some VSCode setting files. # Exclude some VSCode setting files.
.vscode/* .vscode/*
!/.vscode/extensions.json !/.vscode/extensions.json
!/.vscode/settings.json
!/.vscode/tasks.json !/.vscode/tasks.json

3
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"typescript.tsdk": "./node_modules/typescript/lib"
}

View File

@ -3,8 +3,8 @@
"scripts": { "scripts": {
"build": "tsc", "build": "tsc",
"test": "tsc --noEmit", "test": "tsc --noEmit",
"lint": "eslint src -f codeframe --ext .ts", "lint": "eslint src --ext .ts",
"lint:fix": "eslint src -f codeframe --ext .ts --fix", "lint:fix": "eslint src --ext .ts --fix",
"clean": "rimraf dist" "clean": "rimraf dist"
}, },
"devDependencies": { "devDependencies": {

View File

@ -10,56 +10,109 @@
* <br> * <br>
* https://docs.live2d.com/cubism-editor-manual/standard-parametor-list/ * https://docs.live2d.com/cubism-editor-manual/standard-parametor-list/
*/ */
export namespace Live2DCubismFramework { export const CubismDefaultParameterId = Object.freeze<Record<string, string>>({
// パーツID // パーツID
export const HitAreaPrefix = 'HitArea'; HitAreaPrefix: 'HitArea',
export const HitAreaHead = 'Head'; HitAreaHead: 'Head',
export const HitAreaBody = 'Body'; HitAreaBody: 'Body',
export const PartsIdCore = 'Parts01Core'; PartsIdCore: 'Parts01Core',
export const PartsArmPrefix = 'Parts01Arm_'; PartsArmPrefix: 'Parts01Arm_',
export const PartsArmLPrefix = 'Parts01ArmL_'; PartsArmLPrefix: 'Parts01ArmL_',
export const PartsArmRPrefix = 'Parts01ArmR_'; PartsArmRPrefix: 'Parts01ArmR_',
// パラメータID // パラメータID
export const ParamAngleX = 'ParamAngleX'; ParamAngleX: 'ParamAngleX',
export const ParamAngleY = 'ParamAngleY'; ParamAngleY: 'ParamAngleY',
export const ParamAngleZ = 'ParamAngleZ'; ParamAngleZ: 'ParamAngleZ',
export const ParamEyeLOpen = 'ParamEyeLOpen'; ParamEyeLOpen: 'ParamEyeLOpen',
export const ParamEyeLSmile = 'ParamEyeLSmile'; ParamEyeLSmile: 'ParamEyeLSmile',
export const ParamEyeROpen = 'ParamEyeROpen'; ParamEyeROpen: 'ParamEyeROpen',
export const ParamEyeRSmile = 'ParamEyeRSmile'; ParamEyeRSmile: 'ParamEyeRSmile',
export const ParamEyeBallX = 'ParamEyeBallX'; ParamEyeBallX: 'ParamEyeBallX',
export const ParamEyeBallY = 'ParamEyeBallY'; ParamEyeBallY: 'ParamEyeBallY',
export const ParamEyeBallForm = 'ParamEyeBallForm'; ParamEyeBallForm: 'ParamEyeBallForm',
export const ParamBrowLY = 'ParamBrowLY'; ParamBrowLY: 'ParamBrowLY',
export const ParamBrowRY = 'ParamBrowRY'; ParamBrowRY: 'ParamBrowRY',
export const ParamBrowLX = 'ParamBrowLX'; ParamBrowLX: 'ParamBrowLX',
export const ParamBrowRX = 'ParamBrowRX'; ParamBrowRX: 'ParamBrowRX',
export const ParamBrowLAngle = 'ParamBrowLAngle'; ParamBrowLAngle: 'ParamBrowLAngle',
export const ParamBrowRAngle = 'ParamBrowRAngle'; ParamBrowRAngle: 'ParamBrowRAngle',
export const ParamBrowLForm = 'ParamBrowLForm'; ParamBrowLForm: 'ParamBrowLForm',
export const ParamBrowRForm = 'ParamBrowRForm'; ParamBrowRForm: 'ParamBrowRForm',
export const ParamMouthForm = 'ParamMouthForm'; ParamMouthForm: 'ParamMouthForm',
export const ParamMouthOpenY = 'ParamMouthOpenY'; ParamMouthOpenY: 'ParamMouthOpenY',
export const ParamCheek = 'ParamCheek'; ParamCheek: 'ParamCheek',
export const ParamBodyAngleX = 'ParamBodyAngleX'; ParamBodyAngleX: 'ParamBodyAngleX',
export const ParamBodyAngleY = 'ParamBodyAngleY'; ParamBodyAngleY: 'ParamBodyAngleY',
export const ParamBodyAngleZ = 'ParamBodyAngleZ'; ParamBodyAngleZ: 'ParamBodyAngleZ',
export const ParamBreath = 'ParamBreath'; ParamBreath: 'ParamBreath',
export const ParamArmLA = 'ParamArmLA'; ParamArmLA: 'ParamArmLA',
export const ParamArmRA = 'ParamArmRA'; ParamArmRA: 'ParamArmRA',
export const ParamArmLB = 'ParamArmLB'; ParamArmLB: 'ParamArmLB',
export const ParamArmRB = 'ParamArmRB'; ParamArmRB: 'ParamArmRB',
export const ParamHandL = 'ParamHandL'; ParamHandL: 'ParamHandL',
export const ParamHandR = 'ParamHandR'; ParamHandR: 'ParamHandR',
export const ParamHairFront = 'ParamHairFront'; ParamHairFront: 'ParamHairFront',
export const ParamHairSide = 'ParamHairSide'; ParamHairSide: 'ParamHairSide',
export const ParamHairBack = 'ParamHairBack'; ParamHairBack: 'ParamHairBack',
export const ParamHairFluffy = 'ParamHairFluffy'; ParamHairFluffy: 'ParamHairFluffy',
export const ParamShoulderY = 'ParamShoulderY'; ParamShoulderY: 'ParamShoulderY',
export const ParamBustX = 'ParamBustX'; ParamBustX: 'ParamBustX',
export const ParamBustY = 'ParamBustY'; ParamBustY: 'ParamBustY',
export const ParamBaseX = 'ParamBaseX'; ParamBaseX: 'ParamBaseX',
export const ParamBaseY = 'ParamBaseY'; ParamBaseY: 'ParamBaseY',
export const ParamNONE = 'NONE:'; ParamNONE: 'NONE:'
});
// Namespace definition for compatibility.
import * as $ from './cubismdefaultparameterid';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Live2DCubismFramework {
export const HitAreaBody = $.CubismDefaultParameterId.HitAreaBody;
export const HitAreaHead = $.CubismDefaultParameterId.HitAreaHead;
export const HitAreaPrefix = $.CubismDefaultParameterId.HitAreaPrefix;
export const ParamAngleX = $.CubismDefaultParameterId.ParamAngleX;
export const ParamAngleY = $.CubismDefaultParameterId.ParamAngleY;
export const ParamAngleZ = $.CubismDefaultParameterId.ParamAngleZ;
export const ParamArmLA = $.CubismDefaultParameterId.ParamArmLA;
export const ParamArmLB = $.CubismDefaultParameterId.ParamArmLB;
export const ParamArmRA = $.CubismDefaultParameterId.ParamArmRA;
export const ParamArmRB = $.CubismDefaultParameterId.ParamArmRB;
export const ParamBaseX = $.CubismDefaultParameterId.ParamBaseX;
export const ParamBaseY = $.CubismDefaultParameterId.ParamBaseY;
export const ParamBodyAngleX = $.CubismDefaultParameterId.ParamBodyAngleX;
export const ParamBodyAngleY = $.CubismDefaultParameterId.ParamBodyAngleY;
export const ParamBodyAngleZ = $.CubismDefaultParameterId.ParamBodyAngleZ;
export const ParamBreath = $.CubismDefaultParameterId.ParamBreath;
export const ParamBrowLAngle = $.CubismDefaultParameterId.ParamBrowLAngle;
export const ParamBrowLForm = $.CubismDefaultParameterId.ParamBrowLForm;
export const ParamBrowLX = $.CubismDefaultParameterId.ParamBrowLX;
export const ParamBrowLY = $.CubismDefaultParameterId.ParamBrowLY;
export const ParamBrowRAngle = $.CubismDefaultParameterId.ParamBrowRAngle;
export const ParamBrowRForm = $.CubismDefaultParameterId.ParamBrowRForm;
export const ParamBrowRX = $.CubismDefaultParameterId.ParamBrowRX;
export const ParamBrowRY = $.CubismDefaultParameterId.ParamBrowRY;
export const ParamBustX = $.CubismDefaultParameterId.ParamBustX;
export const ParamBustY = $.CubismDefaultParameterId.ParamBustY;
export const ParamCheek = $.CubismDefaultParameterId.ParamCheek;
export const ParamEyeBallForm = $.CubismDefaultParameterId.ParamEyeBallForm;
export const ParamEyeBallX = $.CubismDefaultParameterId.ParamEyeBallX;
export const ParamEyeBallY = $.CubismDefaultParameterId.ParamEyeBallY;
export const ParamEyeLOpen = $.CubismDefaultParameterId.ParamEyeLOpen;
export const ParamEyeLSmile = $.CubismDefaultParameterId.ParamEyeLSmile;
export const ParamEyeROpen = $.CubismDefaultParameterId.ParamEyeROpen;
export const ParamEyeRSmile = $.CubismDefaultParameterId.ParamEyeRSmile;
export const ParamHairBack = $.CubismDefaultParameterId.ParamHairBack;
export const ParamHairFluffy = $.CubismDefaultParameterId.ParamHairFluffy;
export const ParamHairFront = $.CubismDefaultParameterId.ParamHairFront;
export const ParamHairSide = $.CubismDefaultParameterId.ParamHairSide;
export const ParamHandL = $.CubismDefaultParameterId.ParamHandL;
export const ParamHandR = $.CubismDefaultParameterId.ParamHandR;
export const ParamMouthForm = $.CubismDefaultParameterId.ParamMouthForm;
export const ParamMouthOpenY = $.CubismDefaultParameterId.ParamMouthOpenY;
export const ParamNONE = $.CubismDefaultParameterId.ParamNONE;
export const ParamShoulderY = $.CubismDefaultParameterId.ParamShoulderY;
export const PartsArmLPrefix = $.CubismDefaultParameterId.PartsArmLPrefix;
export const PartsArmPrefix = $.CubismDefaultParameterId.PartsArmPrefix;
export const PartsArmRPrefix = $.CubismDefaultParameterId.PartsArmRPrefix;
export const PartsIdCore = $.CubismDefaultParameterId.PartsIdCore;
} }

View File

@ -5,76 +5,67 @@
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/ */
import { Live2DCubismFramework as cubismframework } from './live2dcubismframework'; import { ICubismModelSetting } from './icubismmodelsetting';
import { Live2DCubismFramework as icubismmodelsetting } from './icubismmodelsetting'; import { CubismIdHandle } from './id/cubismid';
import { Live2DCubismFramework as cubismid } from './id/cubismid'; import { CubismFramework } from './live2dcubismframework';
import { Live2DCubismFramework as cubismjson } from './utils/cubismjson'; import { csmMap, iterator } from './type/csmmap';
import { Live2DCubismFramework as csmmap } from './type/csmmap'; import { csmVector } from './type/csmvector';
import { Live2DCubismFramework as csmvector } from './type/csmvector'; import { CubismJson, Value } from './utils/cubismjson';
import csmVector = csmvector.csmVector;
import csmMap = csmmap.csmMap;
import iterator = csmmap.iterator;
import CubismFramework = cubismframework.CubismFramework;
import CubismIdHandle = cubismid.CubismIdHandle;
import CubismJson = cubismjson.CubismJson;
import Value = cubismjson.Value;
import ICubismModelSetting = icubismmodelsetting.ICubismModelSetting;
export namespace Live2DCubismFramework { /**
/**
* Model3Json * Model3Json
*/ */
// JSON Keys // JSON Keys
const Version = 'Version'; const Version = 'Version';
const FileReferences = 'FileReferences'; const FileReferences = 'FileReferences';
const Groups = 'Groups'; const Groups = 'Groups';
const Layout = 'Layout'; const Layout = 'Layout';
const HitAreas = 'HitAreas'; const HitAreas = 'HitAreas';
const Moc = 'Moc'; const Moc = 'Moc';
const Textures = 'Textures'; const Textures = 'Textures';
const Physics = 'Physics'; const Physics = 'Physics';
const Pose = 'Pose'; const Pose = 'Pose';
const Expressions = 'Expressions'; const Expressions = 'Expressions';
const Motions = 'Motions'; const Motions = 'Motions';
const UserData = 'UserData'; const UserData = 'UserData';
const Name = 'Name'; const Name = 'Name';
const FilePath = 'File'; const FilePath = 'File';
const Id = 'Id'; const Id = 'Id';
const Ids = 'Ids'; const Ids = 'Ids';
const Target = 'Target'; const Target = 'Target';
// Motions // Motions
const Idle = 'Idle'; const Idle = 'Idle';
const TapBody = 'TapBody'; const TapBody = 'TapBody';
const PinchIn = 'PinchIn'; const PinchIn = 'PinchIn';
const PinchOut = 'PinchOut'; const PinchOut = 'PinchOut';
const Shake = 'Shake'; const Shake = 'Shake';
const FlickHead = 'FlickHead'; const FlickHead = 'FlickHead';
const Parameter = 'Parameter'; const Parameter = 'Parameter';
const SoundPath = 'Sound'; const SoundPath = 'Sound';
const FadeInTime = 'FadeInTime'; const FadeInTime = 'FadeInTime';
const FadeOutTime = 'FadeOutTime'; const FadeOutTime = 'FadeOutTime';
// Layout // Layout
const CenterX = 'CenterX'; const CenterX = 'CenterX';
const CenterY = 'CenterY'; const CenterY = 'CenterY';
const X = 'X'; const X = 'X';
const Y = 'Y'; const Y = 'Y';
const Width = 'Width'; const Width = 'Width';
const Height = 'Height'; const Height = 'Height';
const LipSync = 'LipSync'; const LipSync = 'LipSync';
const EyeBlink = 'EyeBlink'; const EyeBlink = 'EyeBlink';
const InitParameter = 'init_param'; const InitParameter = 'init_param';
const InitPartsVisible = 'init_parts_visible'; const InitPartsVisible = 'init_parts_visible';
const Val = 'val'; const Val = 'val';
enum FrequestNode { enum FrequestNode {
FrequestNode_Groups, // getRoot().getValueByString(Groups) FrequestNode_Groups, // getRoot().getValueByString(Groups)
FrequestNode_Moc, // getRoot().getValueByString(FileReferences).getValueByString(Moc) FrequestNode_Moc, // getRoot().getValueByString(FileReferences).getValueByString(Moc)
FrequestNode_Motions, // getRoot().getValueByString(FileReferences).getValueByString(Motions) FrequestNode_Motions, // getRoot().getValueByString(FileReferences).getValueByString(Motions)
@ -83,14 +74,14 @@ export namespace Live2DCubismFramework {
FrequestNode_Physics, // getRoot().getValueByString(FileReferences).getValueByString(Physics) FrequestNode_Physics, // getRoot().getValueByString(FileReferences).getValueByString(Physics)
FrequestNode_Pose, // getRoot().getValueByString(FileReferences).getValueByString(Pose) FrequestNode_Pose, // getRoot().getValueByString(FileReferences).getValueByString(Pose)
FrequestNode_HitAreas // getRoot().getValueByString(HitAreas) FrequestNode_HitAreas // getRoot().getValueByString(HitAreas)
} }
/** /**
* Model3Json * Model3Json
* *
* model3.json * model3.json
*/ */
export class CubismModelSettingJson extends ICubismModelSetting { export class CubismModelSettingJson extends ICubismModelSetting {
/** /**
* *
* *
@ -142,9 +133,7 @@ export namespace Live2DCubismFramework {
.getValueByString(FileReferences) .getValueByString(FileReferences)
.getValueByString(Pose) .getValueByString(Pose)
); );
this._jsonValue.pushBack( this._jsonValue.pushBack(this._json.getRoot().getValueByString(HitAreas));
this._json.getRoot().getValueByString(HitAreas)
);
} }
} }
@ -261,9 +250,7 @@ export namespace Live2DCubismFramework {
return ''; return '';
} }
return this._jsonValue return this._jsonValue.at(FrequestNode.FrequestNode_Physics).getRawString();
.at(FrequestNode.FrequestNode_Physics)
.getRawString();
} }
/** /**
@ -287,9 +274,7 @@ export namespace Live2DCubismFramework {
return 0; return 0;
} }
return this._jsonValue return this._jsonValue.at(FrequestNode.FrequestNode_Expressions).getSize();
.at(FrequestNode.FrequestNode_Expressions)
.getSize();
} }
/** /**
@ -640,9 +625,7 @@ export namespace Live2DCubismFramework {
* @return false * @return false
*/ */
private isExistTextureFiles(): boolean { private isExistTextureFiles(): boolean {
const node: Value = this._jsonValue.at( const node: Value = this._jsonValue.at(FrequestNode.FrequestNode_Textures);
FrequestNode.FrequestNode_Textures
);
return !node.isNull() && !node.isError(); return !node.isNull() && !node.isError();
} }
@ -652,9 +635,7 @@ export namespace Live2DCubismFramework {
* @return false * @return false
*/ */
private isExistHitAreas(): boolean { private isExistHitAreas(): boolean {
const node: Value = this._jsonValue.at( const node: Value = this._jsonValue.at(FrequestNode.FrequestNode_HitAreas);
FrequestNode.FrequestNode_HitAreas
);
return !node.isNull() && !node.isError(); return !node.isNull() && !node.isError();
} }
@ -838,5 +819,12 @@ export namespace Live2DCubismFramework {
private _json: CubismJson; private _json: CubismJson;
private _jsonValue: csmVector<Value>; private _jsonValue: csmVector<Value>;
} }
// Namespace definition for compatibility.
import * as $ from './cubismmodelsettingjson';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Live2DCubismFramework {
export const CubismModelSettingJson = $.CubismModelSettingJson;
export type CubismModelSettingJson = $.CubismModelSettingJson;
} }

View File

@ -5,20 +5,16 @@
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/ */
import { Live2DCubismFramework as csmvector } from '../type/csmvector'; import { CubismIdHandle } from '../id/cubismid';
import { Live2DCubismFramework as cubismmodel } from '../model/cubismmodel'; import { CubismModel } from '../model/cubismmodel';
import { Live2DCubismFramework as cubismid } from '../id/cubismid'; import { csmVector } from '../type/csmvector';
import CubismIdHandle = cubismid.CubismIdHandle;
import CubismModel = cubismmodel.CubismModel;
import csmVector = csmvector.csmVector;
export namespace Live2DCubismFramework { /**
/**
* *
* *
* *
*/ */
export class CubismBreath { export class CubismBreath {
/** /**
* *
*/ */
@ -40,9 +36,7 @@ export namespace Live2DCubismFramework {
* *
* @param breathParameters * @param breathParameters
*/ */
public setParameters( public setParameters(breathParameters: csmVector<BreathParameterData>): void {
breathParameters: csmVector<BreathParameterData>
): void {
this._breathParameters = breathParameters; this._breathParameters = breathParameters;
} }
@ -59,10 +53,7 @@ export namespace Live2DCubismFramework {
* @param model * @param model
* @param deltaTimeSeconds [] * @param deltaTimeSeconds []
*/ */
public updateParameters( public updateParameters(model: CubismModel, deltaTimeSeconds: number): void {
model: CubismModel,
deltaTimeSeconds: number
): void {
this._currentTime += deltaTimeSeconds; this._currentTime += deltaTimeSeconds;
const t: number = this._currentTime * 2.0 * 3.14159; const t: number = this._currentTime * 2.0 * 3.14159;
@ -87,12 +78,12 @@ export namespace Live2DCubismFramework {
_breathParameters: csmVector<BreathParameterData>; // 呼吸にひもづいているパラメータのリスト _breathParameters: csmVector<BreathParameterData>; // 呼吸にひもづいているパラメータのリスト
_currentTime: number; // 積算時間[秒] _currentTime: number; // 積算時間[秒]
} }
/** /**
* *
*/ */
export class BreathParameterData { export class BreathParameterData {
/** /**
* *
* @param parameterId ID * @param parameterId ID
@ -120,5 +111,14 @@ export namespace Live2DCubismFramework {
peak: number; // 呼吸を正弦波としたときの、波の高さ peak: number; // 呼吸を正弦波としたときの、波の高さ
cycle: number; // 呼吸を正弦波としたときの、波の周期 cycle: number; // 呼吸を正弦波としたときの、波の周期
weight: number; // パラメータへの重み weight: number; // パラメータへの重み
} }
// Namespace definition for compatibility.
import * as $ from './cubismbreath';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Live2DCubismFramework {
export const BreathParameterData = $.BreathParameterData;
export type BreathParameterData = $.BreathParameterData;
export const CubismBreath = $.CubismBreath;
export type CubismBreath = $.CubismBreath;
} }

View File

@ -5,22 +5,17 @@
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/ */
import { Live2DCubismFramework as csmvector } from '../type/csmvector'; import { ICubismModelSetting } from '../icubismmodelsetting';
import { Live2DCubismFramework as icubismmodelsetting } from '../icubismmodelsetting'; import { CubismIdHandle } from '../id/cubismid';
import { Live2DCubismFramework as cubismid } from '../id/cubismid'; import { CubismModel } from '../model/cubismmodel';
import { Live2DCubismFramework as cubismmodel } from '../model/cubismmodel'; import { csmVector } from '../type/csmvector';
import CubismModel = cubismmodel.CubismModel;
import CubismIdHandle = cubismid.CubismIdHandle;
import ICubismModelSetting = icubismmodelsetting.ICubismModelSetting;
import csmVector = csmvector.csmVector;
export namespace Live2DCubismFramework { /**
/**
* *
* *
* *
*/ */
export class CubismEyeBlink { export class CubismEyeBlink {
/** /**
* *
* @param modelSetting * @param modelSetting
@ -88,10 +83,7 @@ export namespace Live2DCubismFramework {
* @param model * @param model
* @param deltaTimeSeconds [] * @param deltaTimeSeconds []
*/ */
public updateParameters( public updateParameters(model: CubismModel, deltaTimeSeconds: number): void {
model: CubismModel,
deltaTimeSeconds: number
): void {
this._userTimeSeconds += deltaTimeSeconds; this._userTimeSeconds += deltaTimeSeconds;
let parameterValue: number; let parameterValue: number;
let t = 0.0; let t = 0.0;
@ -215,18 +207,27 @@ export namespace Live2DCubismFramework {
* ID0 true 1 false * ID0 true 1 false
*/ */
static readonly CloseIfZero: boolean = true; static readonly CloseIfZero: boolean = true;
} }
/** /**
* *
* *
* *
*/ */
export enum EyeState { export enum EyeState {
EyeState_First = 0, // 初期状態 EyeState_First = 0, // 初期状態
EyeState_Interval, // まばたきしていない状態 EyeState_Interval, // まばたきしていない状態
EyeState_Closing, // まぶたが閉じていく途中の状態 EyeState_Closing, // まぶたが閉じていく途中の状態
EyeState_Closed, // まぶたが閉じている状態 EyeState_Closed, // まぶたが閉じている状態
EyeState_Opening // まぶたが開いていく途中の状態 EyeState_Opening // まぶたが開いていく途中の状態
} }
// Namespace definition for compatibility.
import * as $ from './cubismeyeblink';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Live2DCubismFramework {
export const CubismEyeBlink = $.CubismEyeBlink;
export type CubismEyeBlink = $.CubismEyeBlink;
export const EyeState = $.EyeState;
export type EyeState = $.EyeState;
} }

View File

@ -5,35 +5,27 @@
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/ */
import { Live2DCubismFramework as cubismid } from '../id/cubismid'; import { CubismIdHandle } from '../id/cubismid';
import { Live2DCubismFramework as csmvector } from '../type/csmvector'; import { CubismFramework } from '../live2dcubismframework';
import { Live2DCubismFramework as cubismmodel } from '../model/cubismmodel'; import { CubismModel } from '../model/cubismmodel';
import { Live2DCubismFramework as cubismframework } from '../live2dcubismframework'; import { csmVector, iterator } from '../type/csmvector';
import { Live2DCubismFramework as cubismjson } from '../utils/cubismjson'; import { CubismJson, Value } from '../utils/cubismjson';
import CubismIdHandle = cubismid.CubismIdHandle;
import csmVector = csmvector.csmVector;
import iterator = csmvector.iterator;
import CubismModel = cubismmodel.CubismModel;
import CubismFramework = cubismframework.CubismFramework;
import CubismJson = cubismjson.CubismJson;
import Value = cubismjson.Value;
export namespace Live2DCubismFramework { const Epsilon = 0.001;
const Epsilon = 0.001; const DefaultFadeInSeconds = 0.5;
const DefaultFadeInSeconds = 0.5;
// Pose.jsonのタグ // Pose.jsonのタグ
const FadeIn = 'FadeInTime'; const FadeIn = 'FadeInTime';
const Link = 'Link'; const Link = 'Link';
const Groups = 'Groups'; const Groups = 'Groups';
const Id = 'Id'; const Id = 'Id';
/** /**
* *
* *
* *
*/ */
export class CubismPose { export class CubismPose {
/** /**
* *
* @param pose3json pose3.json * @param pose3json pose3.json
@ -119,10 +111,7 @@ export namespace Live2DCubismFramework {
* @param model * @param model
* @param deltaTimeSeconds [] * @param deltaTimeSeconds []
*/ */
public updateParameters( public updateParameters(model: CubismModel, deltaTimeSeconds: number): void {
model: CubismModel,
deltaTimeSeconds: number
): void {
// 前回のモデルと同じでない場合は初期化が必要 // 前回のモデルと同じでない場合は初期化が必要
if (model != this._lastModel) { if (model != this._lastModel) {
// パラメータインデックスの初期化 // パラメータインデックスの初期化
@ -171,10 +160,7 @@ export namespace Live2DCubismFramework {
} }
model.setPartOpacityByIndex(partsIndex, j == beginIndex ? 1.0 : 0.0); model.setPartOpacityByIndex(partsIndex, j == beginIndex ? 1.0 : 0.0);
model.setParameterValueByIndex( model.setParameterValueByIndex(paramIndex, j == beginIndex ? 1.0 : 0.0);
paramIndex,
j == beginIndex ? 1.0 : 0.0
);
for (let k = 0; k < this._partGroups.at(j).link.getSize(); ++k) { for (let k = 0; k < this._partGroups.at(j).link.getSize(); ++k) {
this._partGroups this._partGroups
@ -320,12 +306,12 @@ export namespace Live2DCubismFramework {
_partGroupCounts: csmVector<number>; // それぞれのパーツグループの個数 _partGroupCounts: csmVector<number>; // それぞれのパーツグループの個数
_fadeTimeSeconds: number; // フェード時間[秒] _fadeTimeSeconds: number; // フェード時間[秒]
_lastModel: CubismModel; // 前回操作したモデル _lastModel: CubismModel; // 前回操作したモデル
} }
/** /**
* *
*/ */
export class PartData { export class PartData {
/** /**
* *
*/ */
@ -401,5 +387,14 @@ export namespace Live2DCubismFramework {
parameterIndex: number; // パラメータのインデックス parameterIndex: number; // パラメータのインデックス
partIndex: number; // パーツのインデックス partIndex: number; // パーツのインデックス
link: csmVector<PartData>; // 連動するパラメータ link: csmVector<PartData>; // 連動するパラメータ
} }
// Namespace definition for compatibility.
import * as $ from './cubismpose';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Live2DCubismFramework {
export const CubismPose = $.CubismPose;
export type CubismPose = $.CubismPose;
export const PartData = $.PartData;
export type PartData = $.PartData;
} }

View File

@ -5,14 +5,13 @@
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/ */
export namespace Live2DCubismFramework { /**
/**
* *
* *
* *
* *
*/ */
export abstract class ICubismAllocator { export abstract class ICubismAllocator {
/** /**
* *
* *
@ -41,5 +40,12 @@ export namespace Live2DCubismFramework {
* @param alignedMemory * @param alignedMemory
*/ */
public abstract deallocateAligned(alignedMemory: any): void; public abstract deallocateAligned(alignedMemory: any): void;
} }
// Namespace definition for compatibility.
import * as $ from './icubismallcator';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Live2DCubismFramework {
export const ICubismAllocator = $.ICubismAllocator;
export type ICubismAllocator = $.ICubismAllocator;
} }

View File

@ -5,18 +5,15 @@
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/ */
import { Live2DCubismFramework as cubismid } from './id/cubismid'; import { CubismIdHandle } from './id/cubismid';
import { Live2DCubismFramework as csmmap } from './type/csmmap'; import { csmMap } from './type/csmmap';
import csmMap = csmmap.csmMap;
import CubismIdHandle = cubismid.CubismIdHandle;
export namespace Live2DCubismFramework { /**
/**
* *
* *
* *
*/ */
export abstract class ICubismModelSetting { export abstract class ICubismModelSetting {
/** /**
* Moc * Moc
* @return Moc * @return Moc
@ -195,5 +192,12 @@ export namespace Live2DCubismFramework {
* @return ID * @return ID
*/ */
public abstract getLipSyncParameterId(index: number): CubismIdHandle; public abstract getLipSyncParameterId(index: number): CubismIdHandle;
} }
// Namespace definition for compatibility.
import * as $ from './icubismmodelsetting';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Live2DCubismFramework {
export const ICubismModelSetting = $.ICubismModelSetting;
export type ICubismModelSetting = $.ICubismModelSetting;
} }

View File

@ -5,16 +5,14 @@
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/ */
import { Live2DCubismFramework as csmstring } from '../type/csmstring'; import { csmString } from '../type/csmstring';
import csmString = csmstring.csmString;
export namespace Live2DCubismFramework { /**
/**
* Drawable * Drawable
* *
* Drawable * Drawable
*/ */
export class CubismId { export class CubismId {
/** /**
* ID * ID
*/ */
@ -67,7 +65,15 @@ export namespace Live2DCubismFramework {
} }
private _id: csmString; // ID名 private _id: csmString; // ID名
} }
export declare type CubismIdHandle = CubismId; export declare type CubismIdHandle = CubismId;
// Namespace definition for compatibility.
import * as $ from './cubismid';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Live2DCubismFramework {
export const CubismId = $.CubismId;
export type CubismId = $.CubismId;
export type CubismIdHandle = $.CubismIdHandle;
} }

View File

@ -5,20 +5,16 @@
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/ */
import { Live2DCubismFramework as csmvector } from '../type/csmvector'; import { csmString } from '../type/csmstring';
import { Live2DCubismFramework as cubismid } from './cubismid'; import { csmVector } from '../type/csmvector';
import { Live2DCubismFramework as csmstring } from '../type/csmstring'; import { CubismId } from './cubismid';
import csmString = csmstring.csmString;
import CubismId = cubismid.CubismId;
import csmVector = csmvector.csmVector;
export namespace Live2DCubismFramework { /**
/**
* ID * ID
* *
* ID * ID
*/ */
export class CubismIdManager { export class CubismIdManager {
/** /**
* *
*/ */
@ -114,5 +110,12 @@ export namespace Live2DCubismFramework {
} }
private _ids: csmVector<CubismId>; // 登録されているIDのリスト private _ids: csmVector<CubismId>; // 登録されているIDのリスト
} }
// Namespace definition for compatibility.
import * as $ from './cubismidmanager';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Live2DCubismFramework {
export const CubismIdManager = $.CubismIdManager;
export type CubismIdManager = $.CubismIdManager;
} }

View File

@ -5,17 +5,14 @@
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/ */
import { Live2DCubismFramework as cubismjson } from './utils/cubismjson'; import { CubismIdManager } from './id/cubismidmanager';
import { Live2DCubismFramework as cubismidmanager } from './id/cubismidmanager'; import { CubismRenderer } from './rendering/cubismrenderer';
import { Live2DCubismFramework as cubismrenderer } from './rendering/cubismrenderer';
import { import {
CSM_ASSERT,
CubismLogInfo, CubismLogInfo,
CubismLogWarning, CubismLogWarning
CSM_ASSERT
} from './utils/cubismdebug'; } from './utils/cubismdebug';
import Value = cubismjson.Value; import { Value } from './utils/cubismjson';
import CubismIdManager = cubismidmanager.CubismIdManager;
import CubismRenderer = cubismrenderer.CubismRenderer;
export function strtod(s: string, endPtr: string[]): number { export function strtod(s: string, endPtr: string[]): number {
let index = 0; let index = 0;
@ -47,35 +44,34 @@ export function strtod(s: string, endPtr: string[]): number {
return d; return d;
} }
export namespace Live2DCubismFramework { // ファイルスコープの変数を初期化
// ファイルスコープの変数を初期化
let s_isStarted = false; let s_isStarted = false;
let s_isInitialized = false; let s_isInitialized = false;
let s_option: Option = null; let s_option: Option = null;
let s_cubismIdManager: CubismIdManager = null; let s_cubismIdManager: CubismIdManager = null;
/** /**
* Framework使 * Framework使
*/ */
export namespace Constant { export const Constant = Object.freeze<Record<string, number>>({
export const vertexOffset = 0; // メッシュ頂点のオフセット値 vertexOffset: 0, // メッシュ頂点のオフセット値
export const vertexStep = 2; // メッシュ頂点のステップ値 vertexStep: 2 // メッシュ頂点のステップ値
} });
export function csmDelete<T>(address: T): void { export function csmDelete<T>(address: T): void {
if (!address) { if (!address) {
return; return;
} }
address = void 0; address = void 0;
} }
/** /**
* Live2D Cubism SDK Original Workflow SDK * Live2D Cubism SDK Original Workflow SDK
* CubismFramework.initialize()CubismFramework.dispose() * CubismFramework.initialize()CubismFramework.dispose()
*/ */
export class CubismFramework { export class CubismFramework {
/** /**
* Cubism FrameworkAPI使 * Cubism FrameworkAPI使
* API * API
@ -251,7 +247,6 @@ export namespace Live2DCubismFramework {
* *
*/ */
private constructor() {} private constructor() {}
}
} }
export class Option { export class Option {
@ -270,3 +265,13 @@ export enum LogLevel {
LogLevel_Error, // エラーログ LogLevel_Error, // エラーログ
LogLevel_Off // ログ出力無効 LogLevel_Off // ログ出力無効
} }
// Namespace definition for compatibility.
import * as $ from './live2dcubismframework';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Live2DCubismFramework {
export const Constant = $.Constant;
export const csmDelete = $.csmDelete;
export const CubismFramework = $.CubismFramework;
export type CubismFramework = $.CubismFramework;
}

View File

@ -5,14 +5,12 @@
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/ */
import { Live2DCubismFramework as cubismvector2 } from './cubismvector2'; import { CubismVector2 } from './cubismvector2';
import CubismVector2 = cubismvector2.CubismVector2;
export namespace Live2DCubismFramework { /**
/**
* 使 * 使
*/ */
export class CubismMath { export class CubismMath {
/** /**
* *
* *
@ -191,5 +189,12 @@ export namespace Live2DCubismFramework {
* *
*/ */
private constructor() {} private constructor() {}
} }
// Namespace definition for compatibility.
import * as $ from './cubismmath';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Live2DCubismFramework {
export const CubismMath = $.CubismMath;
export type CubismMath = $.CubismMath;
} }

View File

@ -5,13 +5,12 @@
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/ */
export namespace Live2DCubismFramework { /**
/**
* 4x4 * 4x4
* *
* 4x4便 * 4x4便
*/ */
export class CubismMatrix44 { export class CubismMatrix44 {
/** /**
* *
*/ */
@ -304,5 +303,12 @@ export namespace Live2DCubismFramework {
} }
protected _tr: Float32Array; // 4x4行列データ protected _tr: Float32Array; // 4x4行列データ
} }
// Namespace definition for compatibility.
import * as $ from './cubismmatrix44';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Live2DCubismFramework {
export const CubismMatrix44 = $.CubismMatrix44;
export type CubismMatrix44 = $.CubismMatrix44;
} }

View File

@ -5,19 +5,15 @@
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/ */
import { Live2DCubismFramework as csmmap } from '../type/csmmap'; import { csmMap, iterator } from '../type/csmmap';
import { Live2DCubismFramework as cubismmatrix44 } from './cubismmatrix44'; import { CubismMatrix44 } from './cubismmatrix44';
import csmMap = csmmap.csmMap;
import iterator = csmmap.iterator;
import CubismMatrix44 = cubismmatrix44.CubismMatrix44;
export namespace Live2DCubismFramework { /**
/**
* 4x4 * 4x4
* *
* 4x4 * 4x4
*/ */
export class CubismModelMatrix extends CubismMatrix44 { export class CubismModelMatrix extends CubismMatrix44 {
/** /**
* *
* *
@ -219,5 +215,12 @@ export namespace Live2DCubismFramework {
private _width: number; // 横幅 private _width: number; // 横幅
private _height: number; // 縦幅 private _height: number; // 縦幅
} }
// Namespace definition for compatibility.
import * as $ from './cubismmodelmatrix';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Live2DCubismFramework {
export const CubismModelMatrix = $.CubismModelMatrix;
export type CubismModelMatrix = $.CubismModelMatrix;
} }

View File

@ -5,19 +5,17 @@
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/ */
import { Live2DCubismFramework as cubismmath } from './cubismmath'; import { CubismMath } from './cubismmath';
import CubismMath = cubismmath.CubismMath;
export namespace Live2DCubismFramework { const FrameRate = 30;
const FrameRate = 30; const Epsilon = 0.01;
const Epsilon = 0.01;
/** /**
* *
* *
* *
*/ */
export class CubismTargetPoint { export class CubismTargetPoint {
/** /**
* *
*/ */
@ -160,5 +158,12 @@ export namespace Live2DCubismFramework {
private _faceVY: number; // 顔の向きの変化速度Y private _faceVY: number; // 顔の向きの変化速度Y
private _lastTimeSeconds: number; // 最後の実行時間[秒] private _lastTimeSeconds: number; // 最後の実行時間[秒]
private _userTimeSeconds: number; // デルタ時間の積算値[秒] private _userTimeSeconds: number; // デルタ時間の積算値[秒]
} }
// Namespace definition for compatibility.
import * as $ from './cubismtargetpoint';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Live2DCubismFramework {
export const CubismTargetPoint = $.CubismTargetPoint;
export type CubismTargetPoint = $.CubismTargetPoint;
} }

View File

@ -5,13 +5,12 @@
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/ */
export namespace Live2DCubismFramework { /**
/**
* 2 * 2
* *
* 2 * 2
*/ */
export class CubismVector2 { export class CubismVector2 {
/** /**
* *
*/ */
@ -159,5 +158,12 @@ export namespace Live2DCubismFramework {
public isNotEqual(rhs: CubismVector2): boolean { public isNotEqual(rhs: CubismVector2): boolean {
return !this.isEqual(rhs); return !this.isEqual(rhs);
} }
} }
// Namespace definition for compatibility.
import * as $ from './cubismvector2';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Live2DCubismFramework {
export const CubismVector2 = $.CubismVector2;
export type CubismVector2 = $.CubismVector2;
} }

View File

@ -5,16 +5,14 @@
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/ */
import { Live2DCubismFramework as cubismmatrix44 } from './cubismmatrix44'; import { CubismMatrix44 } from './cubismmatrix44';
import CubismMatrix44 = cubismmatrix44.CubismMatrix44;
export namespace Live2DCubismFramework { /**
/**
* 使便4x4 * 使便4x4
* *
* 使便4x4 * 使便4x4
*/ */
export class CubismViewMatrix extends CubismMatrix44 { export class CubismViewMatrix extends CubismMatrix44 {
/** /**
* *
*/ */
@ -43,10 +41,7 @@ export namespace Live2DCubismFramework {
x = this._screenLeft - this._tr[0] * this._maxLeft - this._tr[12]; x = this._screenLeft - this._tr[0] * this._maxLeft - this._tr[12];
} }
if ( if (this._tr[0] * this._maxRight + (this._tr[12] + x) < this._screenRight) {
this._tr[0] * this._maxRight + (this._tr[12] + x) <
this._screenRight
) {
x = this._screenRight - this._tr[0] * this._maxRight - this._tr[12]; x = this._screenRight - this._tr[0] * this._maxRight - this._tr[12];
} }
@ -333,5 +328,12 @@ export namespace Live2DCubismFramework {
private _maxBottom: number; // 論理座標上の移動可能範囲下辺Y軸位置 private _maxBottom: number; // 論理座標上の移動可能範囲下辺Y軸位置
private _maxScale: number; // 拡大率の最大値 private _maxScale: number; // 拡大率の最大値
private _minScale: number; // 拡大率の最小値 private _minScale: number; // 拡大率の最小値
} }
// Namespace definition for compatibility.
import * as $ from './cubismviewmatrix';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Live2DCubismFramework {
export const CubismViewMatrix = $.CubismViewMatrix;
export type CubismViewMatrix = $.CubismViewMatrix;
} }

View File

@ -5,17 +5,15 @@
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/ */
import { Live2DCubismFramework as cubismmodel } from './cubismmodel';
import CubismModel = cubismmodel.CubismModel;
import { CSM_ASSERT } from '../utils/cubismdebug'; import { CSM_ASSERT } from '../utils/cubismdebug';
import { CubismModel } from './cubismmodel';
export namespace Live2DCubismFramework { /**
/**
* Moc * Moc
* *
* Moc * Moc
*/ */
export class CubismMoc { export class CubismMoc {
/** /**
* Moc * Moc
*/ */
@ -96,5 +94,12 @@ export namespace Live2DCubismFramework {
_moc: Live2DCubismCore.Moc; // Mocデータ _moc: Live2DCubismCore.Moc; // Mocデータ
_modelCount: number; // Mocデータから作られたモデルの個数 _modelCount: number; // Mocデータから作られたモデルの個数
} }
// Namespace definition for compatibility.
import * as $ from './cubismmoc';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Live2DCubismFramework {
export const CubismMoc = $.CubismMoc;
export type CubismMoc = $.CubismMoc;
} }

View File

@ -5,25 +5,19 @@
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/ */
import { Live2DCubismFramework as cubismrenderer } from '../rendering/cubismrenderer'; import { CubismIdHandle } from '../id/cubismid';
import { Live2DCubismFramework as cubismid } from '../id/cubismid'; import { CubismFramework } from '../live2dcubismframework';
import { Live2DCubismFramework as cubismframework } from '../live2dcubismframework'; import { CubismBlendMode } from '../rendering/cubismrenderer';
import { Live2DCubismFramework as csmmap } from '../type/csmmap'; import { csmMap } from '../type/csmmap';
import { Live2DCubismFramework as csmvector } from '../type/csmvector'; import { csmVector } from '../type/csmvector';
import { CSM_ASSERT } from '../utils/cubismdebug'; import { CSM_ASSERT } from '../utils/cubismdebug';
import CubismFramework = cubismframework.CubismFramework;
import CubismBlendMode = cubismrenderer.CubismBlendMode;
import csmVector = csmvector.csmVector;
import csmMap = csmmap.csmMap;
import CubismIdHandle = cubismid.CubismIdHandle;
export namespace Live2DCubismFramework { /**
/**
* *
* *
* Moc * Moc
*/ */
export class CubismModel { export class CubismModel {
/** /**
* *
*/ */
@ -43,8 +37,7 @@ export namespace Live2DCubismFramework {
} }
return ( return (
this._model.canvasinfo.CanvasWidth / this._model.canvasinfo.CanvasWidth / this._model.canvasinfo.PixelsPerUnit
this._model.canvasinfo.PixelsPerUnit
); );
} }
@ -57,8 +50,7 @@ export namespace Live2DCubismFramework {
} }
return ( return (
this._model.canvasinfo.CanvasHeight / this._model.canvasinfo.CanvasHeight / this._model.canvasinfo.PixelsPerUnit
this._model.canvasinfo.PixelsPerUnit
); );
} }
@ -530,8 +522,7 @@ export namespace Live2DCubismFramework {
* @return drawable * @return drawable
*/ */
public getDrawableVertexPositions(drawableIndex: number): Float32Array { public getDrawableVertexPositions(drawableIndex: number): Float32Array {
const verticesArray: Float32Array[] = this._model.drawables const verticesArray: Float32Array[] = this._model.drawables.vertexPositions;
.vertexPositions;
return verticesArray[drawableIndex]; return verticesArray[drawableIndex];
} }
@ -647,9 +638,7 @@ export namespace Live2DCubismFramework {
*/ */
public getDrawableDynamicFlagIsVisible(drawableIndex: number): boolean { public getDrawableDynamicFlagIsVisible(drawableIndex: number): boolean {
const dynamicFlags: Uint8Array = this._model.drawables.dynamicFlags; const dynamicFlags: Uint8Array = this._model.drawables.dynamicFlags;
return Live2DCubismCore.Utils.hasIsVisibleBit( return Live2DCubismCore.Utils.hasIsVisibleBit(dynamicFlags[drawableIndex]);
dynamicFlags[drawableIndex]
);
} }
/** /**
@ -818,5 +807,12 @@ export namespace Live2DCubismFramework {
private _parameterIds: csmVector<CubismIdHandle>; private _parameterIds: csmVector<CubismIdHandle>;
private _partIds: csmVector<CubismIdHandle>; private _partIds: csmVector<CubismIdHandle>;
private _drawableIds: csmVector<CubismIdHandle>; private _drawableIds: csmVector<CubismIdHandle>;
} }
// Namespace definition for compatibility.
import * as $ from './cubismmodel';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Live2DCubismFramework {
export const CubismModel = $.CubismModel;
export type CubismModel = $.CubismModel;
} }

View File

@ -5,37 +5,31 @@
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/ */
import { Live2DCubismFramework as cubismmodeluserdatajson } from './cubismmodeluserdatajson'; import { CubismIdHandle } from '../id/cubismid';
import { Live2DCubismFramework as cubismid } from '../id/cubismid'; import { CubismFramework } from '../live2dcubismframework';
import { Live2DCubismFramework as csmstring } from '../type/csmstring'; import { csmString } from '../type/csmstring';
import { Live2DCubismFramework as csmvector } from '../type/csmvector'; import { csmVector } from '../type/csmvector';
import { Live2DCubismFramework as cubismframework } from '../live2dcubismframework'; import { CubismModelUserDataJson } from './cubismmodeluserdatajson';
import CubismFramework = cubismframework.CubismFramework;
import csmVector = csmvector.csmVector;
import csmString = csmstring.csmString;
import CubismIdHandle = cubismid.CubismIdHandle;
import CubismModelUserDataJson = cubismmodeluserdatajson.CubismModelUserDataJson;
export namespace Live2DCubismFramework { const ArtMesh = 'ArtMesh';
const ArtMesh = 'ArtMesh';
/** /**
* *
* *
* Json * Json
*/ */
export class CubismModelUserDataNode { export class CubismModelUserDataNode {
targetType: CubismIdHandle; // ユーザーデータターゲットタイプ targetType: CubismIdHandle; // ユーザーデータターゲットタイプ
targetId: CubismIdHandle; // ユーザーデータターゲットのID targetId: CubismIdHandle; // ユーザーデータターゲットのID
value: csmString; // ユーザーデータ value: csmString; // ユーザーデータ
} }
/** /**
* *
* *
* *
*/ */
export class CubismModelUserData { export class CubismModelUserData {
/** /**
* *
* *
@ -43,10 +37,7 @@ export namespace Live2DCubismFramework {
* @param size * @param size
* @return * @return
*/ */
public static create( public static create(buffer: ArrayBuffer, size: number): CubismModelUserData {
buffer: ArrayBuffer,
size: number
): CubismModelUserData {
const ret: CubismModelUserData = new CubismModelUserData(); const ret: CubismModelUserData = new CubismModelUserData();
ret.parseUserData(buffer, size); ret.parseUserData(buffer, size);
@ -132,5 +123,14 @@ export namespace Live2DCubismFramework {
private _userDataNodes: csmVector<CubismModelUserDataNode>; // ユーザーデータ構造体配列 private _userDataNodes: csmVector<CubismModelUserDataNode>; // ユーザーデータ構造体配列
private _artMeshUserDataNode: csmVector<CubismModelUserDataNode>; // 閲覧リストの保持 private _artMeshUserDataNode: csmVector<CubismModelUserDataNode>; // 閲覧リストの保持
} }
// Namespace definition for compatibility.
import * as $ from './cubismmodeluserdata';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Live2DCubismFramework {
export const CubismModelUserData = $.CubismModelUserData;
export type CubismModelUserData = $.CubismModelUserData;
export const CubismModelUserDataNode = $.CubismModelUserDataNode;
export type CubismModelUserDataNode = $.CubismModelUserDataNode;
} }

View File

@ -5,23 +5,19 @@
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/ */
import { Live2DCubismFramework as cubismjson } from '../utils/cubismjson'; import { CubismIdHandle } from '../id/cubismid';
import { Live2DCubismFramework as cubismid } from '../id/cubismid'; import { CubismFramework } from '../live2dcubismframework';
import { Live2DCubismFramework as cubismframework } from '../live2dcubismframework'; import { CubismJson } from '../utils/cubismjson';
import CubismFramework = cubismframework.CubismFramework;
import CubismIdHandle = cubismid.CubismIdHandle;
import CubismJson = cubismjson.CubismJson;
export namespace Live2DCubismFramework { const Meta = 'Meta';
const Meta = 'Meta'; const UserDataCount = 'UserDataCount';
const UserDataCount = 'UserDataCount'; const TotalUserDataSize = 'TotalUserDataSize';
const TotalUserDataSize = 'TotalUserDataSize'; const UserData = 'UserData';
const UserData = 'UserData'; const Target = 'Target';
const Target = 'Target'; const Id = 'Id';
const Id = 'Id'; const Value = 'Value';
const Value = 'Value';
export class CubismModelUserDataJson { export class CubismModelUserDataJson {
/** /**
* *
* @param buffer userdata3.json * @param buffer userdata3.json
@ -110,5 +106,12 @@ export namespace Live2DCubismFramework {
} }
private _json: CubismJson; private _json: CubismJson;
} }
// Namespace definition for compatibility.
import * as $ from './cubismmodeluserdatajson';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Live2DCubismFramework {
export const CubismModelUserDataJson = $.CubismModelUserDataJson;
export type CubismModelUserDataJson = $.CubismModelUserDataJson;
} }

View File

@ -5,52 +5,32 @@
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/ */
import { Live2DCubismFramework as cubismframework } from '../live2dcubismframework'; import { CubismBreath } from '../effect/cubismbreath';
import { Live2DCubismFramework as cubismmotionmanager } from '../motion/cubismmotionmanager'; import { CubismEyeBlink } from '../effect/cubismeyeblink';
import { Live2DCubismFramework as cubismtargetpoint } from '../math/cubismtargetpoint'; import { CubismPose } from '../effect/cubismpose';
import { Live2DCubismFramework as cubismmodelmatrix } from '../math/cubismmodelmatrix'; import { CubismIdHandle } from '../id/cubismid';
import { Live2DCubismFramework as cubismmoc } from './cubismmoc'; import { Constant } from '../live2dcubismframework';
import { Live2DCubismFramework as cubismmodel } from './cubismmodel'; import { CubismModelMatrix } from '../math/cubismmodelmatrix';
import { Live2DCubismFramework as acubismmotion } from '../motion/acubismmotion'; import { CubismTargetPoint } from '../math/cubismtargetpoint';
import { Live2DCubismFramework as cubismmotion } from '../motion/cubismmotion'; import { ACubismMotion, FinishedMotionCallback } from '../motion/acubismmotion';
import { Live2DCubismFramework as cubismexpressionmotion } from '../motion/cubismexpressionmotion'; import { CubismExpressionMotion } from '../motion/cubismexpressionmotion';
import { Live2DCubismFramework as cubismpose } from '../effect/cubismpose'; import { CubismMotion } from '../motion/cubismmotion';
import { Live2DCubismFramework as cubismmodeluserdata } from './cubismmodeluserdata'; import { CubismMotionManager } from '../motion/cubismmotionmanager';
import { Live2DCubismFramework as cubismphysics } from '../physics/cubismphysics'; import { CubismMotionQueueManager } from '../motion/cubismmotionqueuemanager';
import { Live2DCubismFramework as cubismid } from '../id/cubismid'; import { CubismPhysics } from '../physics/cubismphysics';
import { Live2DCubismFramework as csmstring } from '../type/csmstring'; import { CubismRenderer_WebGL } from '../rendering/cubismrenderer_webgl';
import { Live2DCubismFramework as cubismmotionqueuemanager } from '../motion/cubismmotionqueuemanager'; import { csmString } from '../type/csmstring';
import { Live2DCubismFramework as cubismbreath } from '../effect/cubismbreath';
import { Live2DCubismFramework as cubismeyeblink } from '../effect/cubismeyeblink';
import { Live2DCubismFramework as cubismrenderer_webgl } from '../rendering/cubismrenderer_webgl';
import { CubismLogError, CubismLogInfo } from '../utils/cubismdebug'; import { CubismLogError, CubismLogInfo } from '../utils/cubismdebug';
import CubismRenderer_WebGL = cubismrenderer_webgl.CubismRenderer_WebGL; import { CubismMoc } from './cubismmoc';
import CubismEyeBlink = cubismeyeblink.CubismEyeBlink; import { CubismModel } from './cubismmodel';
import CubismBreath = cubismbreath.CubismBreath; import { CubismModelUserData } from './cubismmodeluserdata';
import CubismMotionQueueManager = cubismmotionqueuemanager.CubismMotionQueueManager;
import csmString = csmstring.csmString;
import Constant = cubismframework.Constant;
import CubismIdHandle = cubismid.CubismIdHandle;
import CubismPhysics = cubismphysics.CubismPhysics;
import CubismModelUserData = cubismmodeluserdata.CubismModelUserData;
import CubismPose = cubismpose.CubismPose;
import CubismExpressionMotion = cubismexpressionmotion.CubismExpressionMotion;
import CubismMotion = cubismmotion.CubismMotion;
import ACubismMotion = acubismmotion.ACubismMotion;
import FinishedMotionCallback = acubismmotion.FinishedMotionCallback;
import CubismModel = cubismmodel.CubismModel;
import CubismMoc = cubismmoc.CubismMoc;
import CubismModelMatrix = cubismmodelmatrix.CubismModelMatrix;
import CubismTargetPoint = cubismtargetpoint.CubismTargetPoint;
import CubismMotionManager = cubismmotionmanager.CubismMotionManager;
export namespace Live2DCubismFramework { /**
/**
* 使 * 使
* *
* 使 * 使
*/ */
export class CubismUserModel { export class CubismUserModel {
/** /**
* *
* *
@ -449,5 +429,12 @@ export namespace Live2DCubismFramework {
protected _debugMode: boolean; // デバッグモードかどうか protected _debugMode: boolean; // デバッグモードかどうか
private _renderer: CubismRenderer_WebGL; // レンダラ private _renderer: CubismRenderer_WebGL; // レンダラ
} }
// Namespace definition for compatibility.
import * as $ from './cubismusermodel';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Live2DCubismFramework {
export const CubismUserModel = $.CubismUserModel;
export type CubismUserModel = $.CubismUserModel;
} }

View File

@ -5,28 +5,22 @@
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/ */
import { Live2DCubismFramework as cubismmath } from '../math/cubismmath'; import { CubismMath } from '../math/cubismmath';
import { Live2DCubismFramework as cubismmodel } from '../model/cubismmodel'; import { CubismModel } from '../model/cubismmodel';
import { Live2DCubismFramework as cubismmotionqueueentry } from './cubismmotionqueueentry'; import { csmString } from '../type/csmstring';
import { Live2DCubismFramework as csmstring } from '../type/csmstring'; import { csmVector } from '../type/csmvector';
import { Live2DCubismFramework as csmvector } from '../type/csmvector';
import { CSM_ASSERT } from '../utils/cubismdebug'; import { CSM_ASSERT } from '../utils/cubismdebug';
import csmVector = csmvector.csmVector; import { CubismMotionQueueEntry } from './cubismmotionqueueentry';
import csmString = csmstring.csmString;
import CubismMotionQueueEntry = cubismmotionqueueentry.CubismMotionQueueEntry;
import CubismModel = cubismmodel.CubismModel;
import CubismMath = cubismmath.CubismMath;
export namespace Live2DCubismFramework { /** モーション再生終了コールバック関数定義 */
/** モーション再生終了コールバック関数定義 */ export type FinishedMotionCallback = (self: ACubismMotion) => void;
export type FinishedMotionCallback = (self: ACubismMotion) => void;
/** /**
* *
* *
* MotionQueueManager * MotionQueueManager
*/ */
export abstract class ACubismMotion { export abstract class ACubismMotion {
/** /**
* *
*/ */
@ -274,5 +268,13 @@ export namespace Live2DCubismFramework {
// モーション再生終了コールバック関数 // モーション再生終了コールバック関数
public _onFinishedMotion?: FinishedMotionCallback; public _onFinishedMotion?: FinishedMotionCallback;
} }
// Namespace definition for compatibility.
import * as $ from './acubismmotion';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Live2DCubismFramework {
export const ACubismMotion = $.ACubismMotion;
export type ACubismMotion = $.ACubismMotion;
export type FinishedMotionCallback = $.FinishedMotionCallback;
} }

View File

@ -5,42 +5,32 @@
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/ */
import { Live2DCubismFramework as acubismmotion } from './acubismmotion'; import { CubismIdHandle } from '../id/cubismid';
import { Live2DCubismFramework as cubismjson } from '../utils/cubismjson'; import { CubismFramework } from '../live2dcubismframework';
import { Live2DCubismFramework as cubismid } from '../id/cubismid'; import { CubismModel } from '../model/cubismmodel';
import { Live2DCubismFramework as cubismframework } from '../live2dcubismframework'; import { csmVector } from '../type/csmvector';
import { Live2DCubismFramework as cubismmodel } from '../model/cubismmodel'; import { CubismJson, Value } from '../utils/cubismjson';
import { Live2DCubismFramework as cubismmotionqueueentry } from './cubismmotionqueueentry'; import { ACubismMotion } from './acubismmotion';
import { Live2DCubismFramework as csmvector } from '../type/csmvector'; import { CubismMotionQueueEntry } from './cubismmotionqueueentry';
import JsonFloat = cubismjson.JsonFloat;
import csmVector = csmvector.csmVector;
import CubismMotionQueueEntry = cubismmotionqueueentry.CubismMotionQueueEntry;
import CubismModel = cubismmodel.CubismModel;
import CubismFramework = cubismframework.CubismFramework;
import CubismIdHandle = cubismid.CubismIdHandle;
import CubismJson = cubismjson.CubismJson;
import Value = cubismjson.Value;
import ACubismMotion = acubismmotion.ACubismMotion;
export namespace Live2DCubismFramework { // exp3.jsonのキーとデフォルト
// exp3.jsonのキーとデフォルト const ExpressionKeyFadeIn = 'FadeInTime';
const ExpressionKeyFadeIn = 'FadeInTime'; const ExpressionKeyFadeOut = 'FadeOutTime';
const ExpressionKeyFadeOut = 'FadeOutTime'; const ExpressionKeyParameters = 'Parameters';
const ExpressionKeyParameters = 'Parameters'; const ExpressionKeyId = 'Id';
const ExpressionKeyId = 'Id'; const ExpressionKeyValue = 'Value';
const ExpressionKeyValue = 'Value'; const ExpressionKeyBlend = 'Blend';
const ExpressionKeyBlend = 'Blend'; const BlendValueAdd = 'Add';
const BlendValueAdd = 'Add'; const BlendValueMultiply = 'Multiply';
const BlendValueMultiply = 'Multiply'; const BlendValueOverwrite = 'Overwrite';
const BlendValueOverwrite = 'Overwrite'; const DefaultFadeTime = 1.0;
const DefaultFadeTime = 1.0;
/** /**
* *
* *
* *
*/ */
export class CubismExpressionMotion extends ACubismMotion { export class CubismExpressionMotion extends ACubismMotion {
/** /**
* *
* @param buffer exp * @param buffer exp
@ -86,8 +76,7 @@ export namespace Live2DCubismFramework {
if ( if (
param.getValueByString(ExpressionKeyBlend).isNull() || param.getValueByString(ExpressionKeyBlend).isNull() ||
param.getValueByString(ExpressionKeyBlend).getString() == param.getValueByString(ExpressionKeyBlend).getString() == BlendValueAdd
BlendValueAdd
) { ) {
blendType = ExpressionBlendType.ExpressionBlendType_Add; blendType = ExpressionBlendType.ExpressionBlendType_Add;
} else if ( } else if (
@ -177,23 +166,34 @@ export namespace Live2DCubismFramework {
} }
_parameters: csmVector<ExpressionParameter>; // 表情のパラメータ情報リスト _parameters: csmVector<ExpressionParameter>; // 表情のパラメータ情報リスト
} }
/** /**
* *
*/ */
export enum ExpressionBlendType { export enum ExpressionBlendType {
ExpressionBlendType_Add = 0, // 加算 ExpressionBlendType_Add = 0, // 加算
ExpressionBlendType_Multiply = 1, // 乗算 ExpressionBlendType_Multiply = 1, // 乗算
ExpressionBlendType_Overwrite = 2 // 上書き ExpressionBlendType_Overwrite = 2 // 上書き
} }
/** /**
* *
*/ */
export class ExpressionParameter { export class ExpressionParameter {
parameterId: CubismIdHandle; // パラメータID parameterId: CubismIdHandle; // パラメータID
blendType: ExpressionBlendType; // パラメータの演算種類 blendType: ExpressionBlendType; // パラメータの演算種類
value: number; // 値 value: number; // 値
} }
// Namespace definition for compatibility.
import * as $ from './cubismexpressionmotion';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Live2DCubismFramework {
export const CubismExpressionMotion = $.CubismExpressionMotion;
export type CubismExpressionMotion = $.CubismExpressionMotion;
export const ExpressionBlendType = $.ExpressionBlendType;
export type ExpressionBlendType = $.ExpressionBlendType;
export const ExpressionParameter = $.ExpressionParameter;
export type ExpressionParameter = $.ExpressionParameter;
} }

View File

@ -5,56 +5,46 @@
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/ */
import { Live2DCubismFramework as cubismmotionjson } from './cubismmotionjson'; import { CubismIdHandle } from '../id/cubismid';
import { Live2DCubismFramework as cubismmotioninternal } from './cubismmotioninternal'; import { CubismFramework } from '../live2dcubismframework';
import { Live2DCubismFramework as acubismmotion } from './acubismmotion'; import { CubismMath } from '../math/cubismmath';
import { Live2DCubismFramework as cubismmodel } from '../model/cubismmodel'; import { CubismModel } from '../model/cubismmodel';
import { Live2DCubismFramework as cubismframework } from '../live2dcubismframework'; import { csmString } from '../type/csmstring';
import { Live2DCubismFramework as cubismmotionqueueentry } from './cubismmotionqueueentry'; import { csmVector } from '../type/csmvector';
import { Live2DCubismFramework as cubismmath } from '../math/cubismmath'; import { CSM_ASSERT, CubismLogDebug } from '../utils/cubismdebug';
import { Live2DCubismFramework as csmvector } from '../type/csmvector'; import { ACubismMotion, FinishedMotionCallback } from './acubismmotion';
import { Live2DCubismFramework as cubismid } from '../id/cubismid'; import {
import { Live2DCubismFramework as csmstring } from '../type/csmstring'; CubismMotionCurve,
import { CubismLogDebug, CSM_ASSERT } from '../utils/cubismdebug'; CubismMotionCurveTarget,
import csmString = csmstring.csmString; CubismMotionData,
import CubismMotionData = cubismmotioninternal.CubismMotionData; CubismMotionEvent,
import CubismMotionSegment = cubismmotioninternal.CubismMotionSegment; CubismMotionPoint,
import CubismMotionPoint = cubismmotioninternal.CubismMotionPoint; CubismMotionSegment,
import CubismMotionEvent = cubismmotioninternal.CubismMotionEvent; CubismMotionSegmentType
import CubismMotionSegmentType = cubismmotioninternal.CubismMotionSegmentType; } from './cubismmotioninternal';
import CubismIdHandle = cubismid.CubismIdHandle; import { CubismMotionJson } from './cubismmotionjson';
import CubismMotionCurve = cubismmotioninternal.CubismMotionCurve; import { CubismMotionQueueEntry } from './cubismmotionqueueentry';
import CubismMotionCurveTarget = cubismmotioninternal.CubismMotionCurveTarget;
import csmVector = csmvector.csmVector;
import CubismMath = cubismmath.CubismMath;
import CubismMotionQueueEntry = cubismmotionqueueentry.CubismMotionQueueEntry;
import CubismFramework = cubismframework.CubismFramework;
import CubismModel = cubismmodel.CubismModel;
import ACubismMotion = acubismmotion.ACubismMotion;
import FinishedMotionCallback = acubismmotion.FinishedMotionCallback;
import CubismMotionJson = cubismmotionjson.CubismMotionJson;
export namespace Live2DCubismFramework { const EffectNameEyeBlink = 'EyeBlink';
const EffectNameEyeBlink = 'EyeBlink'; const EffectNameLipSync = 'LipSync';
const EffectNameLipSync = 'LipSync'; const TargetNameModel = 'Model';
const TargetNameModel = 'Model'; const TargetNameParameter = 'Parameter';
const TargetNameParameter = 'Parameter'; const TargetNamePartOpacity = 'PartOpacity';
const TargetNamePartOpacity = 'PartOpacity';
function lerpPoints( function lerpPoints(
a: CubismMotionPoint, a: CubismMotionPoint,
b: CubismMotionPoint, b: CubismMotionPoint,
t: number t: number
): CubismMotionPoint { ): CubismMotionPoint {
const result: CubismMotionPoint = new CubismMotionPoint(); const result: CubismMotionPoint = new CubismMotionPoint();
result.time = a.time + (b.time - a.time) * t; result.time = a.time + (b.time - a.time) * t;
result.value = a.value + (b.value - a.value) * t; result.value = a.value + (b.value - a.value) * t;
return result; return result;
} }
function linearEvaluate(points: CubismMotionPoint[], time: number): number { function linearEvaluate(points: CubismMotionPoint[], time: number): number {
let t: number = (time - points[0].time) / (points[1].time - points[0].time); let t: number = (time - points[0].time) / (points[1].time - points[0].time);
if (t < 0.0) { if (t < 0.0) {
@ -62,9 +52,9 @@ export namespace Live2DCubismFramework {
} }
return points[0].value + (points[1].value - points[0].value) * t; return points[0].value + (points[1].value - points[0].value) * t;
} }
function bezierEvaluate(points: CubismMotionPoint[], time: number): number { function bezierEvaluate(points: CubismMotionPoint[], time: number): number {
let t: number = (time - points[0].time) / (points[3].time - points[0].time); let t: number = (time - points[0].time) / (points[3].time - points[0].time);
if (t < 0.0) { if (t < 0.0) {
@ -79,30 +69,29 @@ export namespace Live2DCubismFramework {
const p123: CubismMotionPoint = lerpPoints(p12, p23, t); const p123: CubismMotionPoint = lerpPoints(p12, p23, t);
return lerpPoints(p012, p123, t).value; return lerpPoints(p012, p123, t).value;
} }
function steppedEvaluate(points: CubismMotionPoint[], time: number): number { function steppedEvaluate(points: CubismMotionPoint[], time: number): number {
return points[0].value; return points[0].value;
} }
function inverseSteppedEvaluate( function inverseSteppedEvaluate(
points: CubismMotionPoint[], points: CubismMotionPoint[],
time: number time: number
): number { ): number {
return points[1].value; return points[1].value;
} }
function evaluateCurve( function evaluateCurve(
motionData: CubismMotionData, motionData: CubismMotionData,
index: number, index: number,
time: number time: number
): number { ): number {
// Find segment to evaluate. // Find segment to evaluate.
const curve: CubismMotionCurve = motionData.curves.at(index); const curve: CubismMotionCurve = motionData.curves.at(index);
let target = -1; let target = -1;
const totalSegmentCount: number = const totalSegmentCount: number = curve.baseSegmentIndex + curve.segmentCount;
curve.baseSegmentIndex + curve.segmentCount;
let pointPosition = 0; let pointPosition = 0;
for (let i: number = curve.baseSegmentIndex; i < totalSegmentCount; ++i) { for (let i: number = curve.baseSegmentIndex; i < totalSegmentCount; ++i) {
// Get first point of next segment. // Get first point of next segment.
@ -126,18 +115,15 @@ export namespace Live2DCubismFramework {
const segment: CubismMotionSegment = motionData.segments.at(target); const segment: CubismMotionSegment = motionData.segments.at(target);
return segment.evaluate( return segment.evaluate(motionData.points.get(segment.basePointIndex), time);
motionData.points.get(segment.basePointIndex), }
time
);
}
/** /**
* *
* *
* *
*/ */
export class CubismMotion extends ACubismMotion { export class CubismMotion extends ACubismMotion {
/** /**
* *
* *
@ -677,9 +663,7 @@ export namespace Live2DCubismFramework {
if (json.getMotionCurveTarget(curveCount) == TargetNameModel) { if (json.getMotionCurveTarget(curveCount) == TargetNameModel) {
this._motionData.curves.at(curveCount).type = this._motionData.curves.at(curveCount).type =
CubismMotionCurveTarget.CubismMotionCurveTarget_Model; CubismMotionCurveTarget.CubismMotionCurveTarget_Model;
} else if ( } else if (json.getMotionCurveTarget(curveCount) == TargetNameParameter) {
json.getMotionCurveTarget(curveCount) == TargetNameParameter
) {
this._motionData.curves.at(curveCount).type = this._motionData.curves.at(curveCount).type =
CubismMotionCurveTarget.CubismMotionCurveTarget_Parameter; CubismMotionCurveTarget.CubismMotionCurveTarget_Parameter;
} else if ( } else if (
@ -724,10 +708,7 @@ export namespace Live2DCubismFramework {
).time = json.getMotionCurveSegment(curveCount, segmentPosition); ).time = json.getMotionCurveSegment(curveCount, segmentPosition);
this._motionData.points.at( this._motionData.points.at(
totalPointCount totalPointCount
).value = json.getMotionCurveSegment( ).value = json.getMotionCurveSegment(curveCount, segmentPosition + 1);
curveCount,
segmentPosition + 1
);
totalPointCount += 1; totalPointCount += 1;
segmentPosition += 2; segmentPosition += 2;
@ -941,5 +922,12 @@ export namespace Live2DCubismFramework {
public _modelCurveIdEyeBlink: CubismIdHandle; // モデルが持つ自動まばたき用パラメータIDのハンドル。 モデルとモーションを対応付ける。 public _modelCurveIdEyeBlink: CubismIdHandle; // モデルが持つ自動まばたき用パラメータIDのハンドル。 モデルとモーションを対応付ける。
public _modelCurveIdLipSync: CubismIdHandle; // モデルが持つリップシンク用パラメータIDのハンドル。 モデルとモーションを対応付ける。 public _modelCurveIdLipSync: CubismIdHandle; // モデルが持つリップシンク用パラメータIDのハンドル。 モデルとモーションを対応付ける。
} }
// Namespace definition for compatibility.
import * as $ from './cubismmotion';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Live2DCubismFramework {
export const CubismMotion = $.CubismMotion;
export type CubismMotion = $.CubismMotion;
} }

View File

@ -5,63 +5,59 @@
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/ */
import { Live2DCubismFramework as cubismid } from '../id/cubismid'; import { CubismIdHandle } from '../id/cubismid';
import { Live2DCubismFramework as csmstring } from '../type/csmstring'; import { csmString } from '../type/csmstring';
import { Live2DCubismFramework as csmvector } from '../type/csmvector'; import { csmVector } from '../type/csmvector';
import csmVector = csmvector.csmVector;
import csmString = csmstring.csmString;
import CubismIdHandle = cubismid.CubismIdHandle;
export namespace Live2DCubismFramework { /**
/**
* @brief * @brief
* *
* *
*/ */
export enum CubismMotionCurveTarget { export enum CubismMotionCurveTarget {
CubismMotionCurveTarget_Model, // モデルに対して CubismMotionCurveTarget_Model, // モデルに対して
CubismMotionCurveTarget_Parameter, // パラメータに対して CubismMotionCurveTarget_Parameter, // パラメータに対して
CubismMotionCurveTarget_PartOpacity // パーツの不透明度に対して CubismMotionCurveTarget_PartOpacity // パーツの不透明度に対して
} }
/** /**
* @brief * @brief
* *
* *
*/ */
export enum CubismMotionSegmentType { export enum CubismMotionSegmentType {
CubismMotionSegmentType_Linear = 0, // リニア CubismMotionSegmentType_Linear = 0, // リニア
CubismMotionSegmentType_Bezier = 1, // ベジェ曲線 CubismMotionSegmentType_Bezier = 1, // ベジェ曲線
CubismMotionSegmentType_Stepped = 2, // ステップ CubismMotionSegmentType_Stepped = 2, // ステップ
CubismMotionSegmentType_InverseStepped = 3 // インバースステップ CubismMotionSegmentType_InverseStepped = 3 // インバースステップ
} }
/** /**
* @brief * @brief
* *
* *
*/ */
export class CubismMotionPoint { export class CubismMotionPoint {
time = 0.0; // 時間[秒] time = 0.0; // 時間[秒]
value = 0.0; // 値 value = 0.0; // 値
} }
/** /**
* *
* *
* @param points * @param points
* @param time [] * @param time []
*/ */
export interface csmMotionSegmentEvaluationFunction { export interface csmMotionSegmentEvaluationFunction {
(points: CubismMotionPoint[], time: number): number; (points: CubismMotionPoint[], time: number): number;
} }
/** /**
* @brief * @brief
* *
* *
*/ */
export class CubismMotionSegment { export class CubismMotionSegment {
/** /**
* @brief * @brief
* *
@ -76,14 +72,14 @@ export namespace Live2DCubismFramework {
evaluate: csmMotionSegmentEvaluationFunction; // 使用する評価関数 evaluate: csmMotionSegmentEvaluationFunction; // 使用する評価関数
basePointIndex: number; // 最初のセグメントへのインデックス basePointIndex: number; // 最初のセグメントへのインデックス
segmentType: number; // セグメントの種類 segmentType: number; // セグメントの種類
} }
/** /**
* @brief * @brief
* *
* *
*/ */
export class CubismMotionCurve { export class CubismMotionCurve {
public constructor() { public constructor() {
this.type = CubismMotionCurveTarget.CubismMotionCurveTarget_Model; this.type = CubismMotionCurveTarget.CubismMotionCurveTarget_Model;
this.segmentCount = 0; this.segmentCount = 0;
@ -98,22 +94,22 @@ export namespace Live2DCubismFramework {
baseSegmentIndex: number; // 最初のセグメントのインデックス baseSegmentIndex: number; // 最初のセグメントのインデックス
fadeInTime: number; // フェードインにかかる時間[秒] fadeInTime: number; // フェードインにかかる時間[秒]
fadeOutTime: number; // フェードアウトにかかる時間[秒] fadeOutTime: number; // フェードアウトにかかる時間[秒]
} }
/** /**
* *
*/ */
export class CubismMotionEvent { export class CubismMotionEvent {
fireTime = 0.0; fireTime = 0.0;
value: csmString; value: csmString;
} }
/** /**
* @brief * @brief
* *
* *
*/ */
export class CubismMotionData { export class CubismMotionData {
public constructor() { public constructor() {
this.duration = 0.0; this.duration = 0.0;
this.loop = false; this.loop = false;
@ -136,5 +132,25 @@ export namespace Live2DCubismFramework {
segments: csmVector<CubismMotionSegment>; // セグメントのリスト segments: csmVector<CubismMotionSegment>; // セグメントのリスト
points: csmVector<CubismMotionPoint>; // ポイントのリスト points: csmVector<CubismMotionPoint>; // ポイントのリスト
events: csmVector<CubismMotionEvent>; // イベントのリスト events: csmVector<CubismMotionEvent>; // イベントのリスト
} }
// Namespace definition for compatibility.
import * as $ from './cubismmotioninternal';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Live2DCubismFramework {
export const CubismMotionCurve = $.CubismMotionCurve;
export type CubismMotionCurve = $.CubismMotionCurve;
export const CubismMotionCurveTarget = $.CubismMotionCurveTarget;
export type CubismMotionCurveTarget = $.CubismMotionCurveTarget;
export const CubismMotionData = $.CubismMotionData;
export type CubismMotionData = $.CubismMotionData;
export const CubismMotionEvent = $.CubismMotionEvent;
export type CubismMotionEvent = $.CubismMotionEvent;
export const CubismMotionPoint = $.CubismMotionPoint;
export type CubismMotionPoint = $.CubismMotionPoint;
export const CubismMotionSegment = $.CubismMotionSegment;
export type CubismMotionSegment = $.CubismMotionSegment;
export const CubismMotionSegmentType = $.CubismMotionSegmentType;
export type CubismMotionSegmentType = $.CubismMotionSegmentType;
export type csmMotionSegmentEvaluationFunction = $.csmMotionSegmentEvaluationFunction;
} }

View File

@ -5,40 +5,35 @@
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/ */
import { Live2DCubismFramework as cubismjson } from '../utils/cubismjson'; import { CubismIdHandle } from '../id/cubismid';
import { Live2DCubismFramework as cubismid } from '../id/cubismid'; import { CubismFramework } from '../live2dcubismframework';
import { Live2DCubismFramework as cubismframework } from '../live2dcubismframework'; import { csmString } from '../type/csmstring';
import { Live2DCubismFramework as csmstring } from '../type/csmstring'; import { CubismJson } from '../utils/cubismjson';
import csmString = csmstring.csmString;
import CubismFramework = cubismframework.CubismFramework;
import CubismIdHandle = cubismid.CubismIdHandle;
import CubismJson = cubismjson.CubismJson;
export namespace Live2DCubismFramework { // JSON keys
// JSON keys const Meta = 'Meta';
const Meta = 'Meta'; const Duration = 'Duration';
const Duration = 'Duration'; const Loop = 'Loop';
const Loop = 'Loop'; const CurveCount = 'CurveCount';
const CurveCount = 'CurveCount'; const Fps = 'Fps';
const Fps = 'Fps'; const TotalSegmentCount = 'TotalSegmentCount';
const TotalSegmentCount = 'TotalSegmentCount'; const TotalPointCount = 'TotalPointCount';
const TotalPointCount = 'TotalPointCount'; const Curves = 'Curves';
const Curves = 'Curves'; const Target = 'Target';
const Target = 'Target'; const Id = 'Id';
const Id = 'Id'; const FadeInTime = 'FadeInTime';
const FadeInTime = 'FadeInTime'; const FadeOutTime = 'FadeOutTime';
const FadeOutTime = 'FadeOutTime'; const Segments = 'Segments';
const Segments = 'Segments'; const UserData = 'UserData';
const UserData = 'UserData'; const UserDataCount = 'UserDataCount';
const UserDataCount = 'UserDataCount'; const TotalUserDataSize = 'TotalUserDataSize';
const TotalUserDataSize = 'TotalUserDataSize'; const Time = 'Time';
const Time = 'Time'; const Value = 'Value';
const Value = 'Value';
/** /**
* motion3.json * motion3.json
*/ */
export class CubismMotionJson { export class CubismMotionJson {
/** /**
* *
* @param buffer motion3.json * @param buffer motion3.json
@ -355,5 +350,12 @@ export namespace Live2DCubismFramework {
} }
_json: CubismJson; // motion3.jsonのデータ _json: CubismJson; // motion3.jsonのデータ
} }
// Namespace definition for compatibility.
import * as $ from './cubismmotionjson';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Live2DCubismFramework {
export const CubismMotionJson = $.CubismMotionJson;
export type CubismMotionJson = $.CubismMotionJson;
} }

View File

@ -5,21 +5,19 @@
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/ */
import { Live2DCubismFramework as cubismmotionqueuemanager } from './cubismmotionqueuemanager'; import { CubismModel } from '../model/cubismmodel';
import { Live2DCubismFramework as acubismmotion } from './acubismmotion'; import { ACubismMotion } from './acubismmotion';
import { Live2DCubismFramework as cubismmodel } from '../model/cubismmodel'; import {
import CubismMotionQueueEntryHandle = cubismmotionqueuemanager.CubismMotionQueueEntryHandle; CubismMotionQueueEntryHandle,
import CubismModel = cubismmodel.CubismModel; CubismMotionQueueManager
import ACubismMotion = acubismmotion.ACubismMotion; } from './cubismmotionqueuemanager';
import CubismMotionQueueManager = cubismmotionqueuemanager.CubismMotionQueueManager;
export namespace Live2DCubismFramework { /**
/**
* *
* *
* *
*/ */
export class CubismMotionManager extends CubismMotionQueueManager { export class CubismMotionManager extends CubismMotionQueueManager {
/** /**
* *
*/ */
@ -86,10 +84,7 @@ export namespace Live2DCubismFramework {
public updateMotion(model: CubismModel, deltaTimeSeconds: number): boolean { public updateMotion(model: CubismModel, deltaTimeSeconds: number): boolean {
this._userTimeSeconds += deltaTimeSeconds; this._userTimeSeconds += deltaTimeSeconds;
const updated: boolean = super.doUpdateMotion( const updated: boolean = super.doUpdateMotion(model, this._userTimeSeconds);
model,
this._userTimeSeconds
);
if (this.isFinished()) { if (this.isFinished()) {
this._currentPriority = 0; // 再生中のモーションの優先度を解除 this._currentPriority = 0; // 再生中のモーションの優先度を解除
@ -120,5 +115,12 @@ export namespace Live2DCubismFramework {
_currentPriority: number; // 現在再生中のモーションの優先度 _currentPriority: number; // 現在再生中のモーションの優先度
_reservePriority: number; // 再生予定のモーションの優先度。再生中は0になる。モーションファイルを別スレッドで読み込むときの機能。 _reservePriority: number; // 再生予定のモーションの優先度。再生中は0になる。モーションファイルを別スレッドで読み込むときの機能。
} }
// Namespace definition for compatibility.
import * as $ from './cubismmotionmanager';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Live2DCubismFramework {
export const CubismMotionManager = $.CubismMotionManager;
export type CubismMotionManager = $.CubismMotionManager;
} }

View File

@ -5,16 +5,13 @@
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/ */
import { Live2DCubismFramework as acubismmotion } from './acubismmotion'; import { ACubismMotion } from './acubismmotion';
import { Live2DCubismFramework as cubismmotionqueuemanager } from './cubismmotionqueuemanager'; import { CubismMotionQueueEntryHandle } from './cubismmotionqueuemanager';
import CubismMotionQueueEntryHandle = cubismmotionqueuemanager.CubismMotionQueueEntryHandle;
import ACubismMotion = acubismmotion.ACubismMotion;
export namespace Live2DCubismFramework { /**
/**
* CubismMotionQueueManager * CubismMotionQueueManager
*/ */
export class CubismMotionQueueEntry { export class CubismMotionQueueEntry {
/** /**
* *
*/ */
@ -245,5 +242,12 @@ export namespace Live2DCubismFramework {
private _isTriggeredFadeOut: boolean; // フェードアウト開始フラグ private _isTriggeredFadeOut: boolean; // フェードアウト開始フラグ
_motionQueueEntryHandle: CubismMotionQueueEntryHandle; // インスタンスごとに一意の値を持つ識別番号 _motionQueueEntryHandle: CubismMotionQueueEntryHandle; // インスタンスごとに一意の値を持つ識別番号
} }
// Namespace definition for compatibility.
import * as $ from './cubismmotionqueueentry';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Live2DCubismFramework {
export const CubismMotionQueueEntry = $.CubismMotionQueueEntry;
export type CubismMotionQueueEntry = $.CubismMotionQueueEntry;
} }

View File

@ -5,20 +5,13 @@
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/ */
import { Live2DCubismFramework as acubismmotion } from './acubismmotion'; import { ACubismMotion } from './acubismmotion';
import { Live2DCubismFramework as cubismmotionqueueentry } from './cubismmotionqueueentry'; import { CubismMotionQueueEntry } from './cubismmotionqueueentry';
import { Live2DCubismFramework as csmvector } from '../type/csmvector'; import { csmVector, iterator } from '../type/csmvector';
import { Live2DCubismFramework as cubismmodel } from '../model/cubismmodel'; import { CubismModel } from '../model/cubismmodel';
import { Live2DCubismFramework as csmstring } from '../type/csmstring'; import { csmString } from '../type/csmstring';
import csmString = csmstring.csmString;
import CubismModel = cubismmodel.CubismModel;
import csmVector = csmvector.csmVector;
import iterator = csmvector.iterator;
import CubismMotionQueueEntry = cubismmotionqueueentry.CubismMotionQueueEntry;
import ACubismMotion = acubismmotion.ACubismMotion;
export namespace Live2DCubismFramework { /**
/**
* *
* *
* CubismMotionACubismMotion使 * CubismMotionACubismMotion使
@ -27,7 +20,7 @@ export namespace Live2DCubismFramework {
* *
* CubismMotionQueueManager使 * CubismMotionQueueManager使
*/ */
export class CubismMotionQueueManager { export class CubismMotionQueueManager {
/** /**
* *
*/ */
@ -217,9 +210,7 @@ export namespace Live2DCubismFramework {
continue; continue;
} }
if ( if (motionQueueEntry._motionQueueEntryHandle == motionQueueEntryNumber) {
motionQueueEntry._motionQueueEntryHandle == motionQueueEntryNumber
) {
return motionQueueEntry; return motionQueueEntry;
} }
} }
@ -249,10 +240,7 @@ export namespace Live2DCubismFramework {
* @return true * @return true
* @return false () * @return false ()
*/ */
public doUpdateMotion( public doUpdateMotion(model: CubismModel, userTimeSeconds: number): boolean {
model: CubismModel,
userTimeSeconds: number
): boolean {
let updated = false; let updated = false;
// ------- 処理を行う -------- // ------- 処理を行う --------
@ -322,9 +310,9 @@ export namespace Live2DCubismFramework {
_motions: csmVector<CubismMotionQueueEntry>; // モーション _motions: csmVector<CubismMotionQueueEntry>; // モーション
_eventCallBack: CubismMotionEventFunction; // コールバック関数 _eventCallBack: CubismMotionEventFunction; // コールバック関数
_eventCustomData: any; // コールバックに戻されるデータ _eventCustomData: any; // コールバックに戻されるデータ
} }
/** /**
* *
* *
* *
@ -332,19 +320,30 @@ export namespace Live2DCubismFramework {
* @param eventValue * @param eventValue
* @param customData * @param customData
*/ */
export interface CubismMotionEventFunction { export interface CubismMotionEventFunction {
( (
caller: CubismMotionQueueManager, caller: CubismMotionQueueManager,
eventValue: csmString, eventValue: csmString,
customData: any customData: any
): void; ): void;
} }
/** /**
* *
* *
* *
*/ */
export declare type CubismMotionQueueEntryHandle = any; export declare type CubismMotionQueueEntryHandle = any;
export const InvalidMotionQueueEntryHandleValue: CubismMotionQueueEntryHandle = -1; export const InvalidMotionQueueEntryHandleValue: CubismMotionQueueEntryHandle = -1;
// Namespace definition for compatibility.
import * as $ from './cubismmotionqueuemanager';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Live2DCubismFramework {
export const CubismMotionQueueManager = $.CubismMotionQueueManager;
export type CubismMotionQueueManager = $.CubismMotionQueueManager;
export const InvalidMotionQueueEntryHandleValue =
$.InvalidMotionQueueEntryHandleValue;
export type CubismMotionQueueEntryHandle = $.CubismMotionQueueEntryHandle;
export type CubismMotionEventFunction = $.CubismMotionEventFunction;
} }

View File

@ -5,43 +5,39 @@
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/ */
import { Live2DCubismFramework as cubismphysicsinternal } from './cubismphysicsinternal'; import { CubismMath } from '../math/cubismmath';
import { Live2DCubismFramework as cubismmodel } from '../model/cubismmodel'; import { CubismVector2 } from '../math/cubismvector2';
import { Live2DCubismFramework as cubismvector2 } from '../math/cubismvector2'; import { CubismModel } from '../model/cubismmodel';
import { Live2DCubismFramework as cubismmath } from '../math/cubismmath'; import {
import { Live2DCubismFramework as cubismphysicsjson } from './cubismphysicsjson'; CubismPhysicsInput,
import CubismPhysicsJson = cubismphysicsjson.CubismPhysicsJson; CubismPhysicsNormalization,
import CubismMath = cubismmath.CubismMath; CubismPhysicsOutput,
import CubismPhysicsRig = cubismphysicsinternal.CubismPhysicsRig; CubismPhysicsParticle,
import CubismPhysicsSubRig = cubismphysicsinternal.CubismPhysicsSubRig; CubismPhysicsRig,
import CubismPhysicsInput = cubismphysicsinternal.CubismPhysicsInput; CubismPhysicsSource,
import CubismPhysicsOutput = cubismphysicsinternal.CubismPhysicsOutput; CubismPhysicsSubRig,
import CubismPhysicsParticle = cubismphysicsinternal.CubismPhysicsParticle; CubismPhysicsTargetType
import CubismPhysicsSource = cubismphysicsinternal.CubismPhysicsSource; } from './cubismphysicsinternal';
import CubismPhysicsTargetType = cubismphysicsinternal.CubismPhysicsTargetType; import { CubismPhysicsJson } from './cubismphysicsjson';
import CubismPhysicsNormalization = cubismphysicsinternal.CubismPhysicsNormalization;
import CubismVector2 = cubismvector2.CubismVector2;
import CubismModel = cubismmodel.CubismModel;
export namespace Live2DCubismFramework { // physics types tags.
// physics types tags. const PhysicsTypeTagX = 'X';
const PhysicsTypeTagX = 'X'; const PhysicsTypeTagY = 'Y';
const PhysicsTypeTagY = 'Y'; const PhysicsTypeTagAngle = 'Angle';
const PhysicsTypeTagAngle = 'Angle';
// Constant of air resistance. // Constant of air resistance.
const AirResistance = 5.0; const AirResistance = 5.0;
// Constant of maximum weight of input and output ratio. // Constant of maximum weight of input and output ratio.
const MaximumWeight = 100.0; const MaximumWeight = 100.0;
// Constant of threshold of movement. // Constant of threshold of movement.
const MovementThreshold = 0.001; const MovementThreshold = 0.001;
/** /**
* *
*/ */
export class CubismPhysics { export class CubismPhysics {
/** /**
* *
* @param buffer physics3.json * @param buffer physics3.json
@ -103,9 +99,7 @@ export namespace Live2DCubismFramework {
totalTranslation.x = 0.0; totalTranslation.x = 0.0;
totalTranslation.y = 0.0; totalTranslation.y = 0.0;
currentSetting = this._physicsRig.settings.at(settingIndex); currentSetting = this._physicsRig.settings.at(settingIndex);
currentInput = this._physicsRig.inputs.get( currentInput = this._physicsRig.inputs.get(currentSetting.baseInputIndex);
currentSetting.baseInputIndex
);
currentOutput = this._physicsRig.outputs.get( currentOutput = this._physicsRig.outputs.get(
currentSetting.baseOutputIndex currentSetting.baseOutputIndex
); );
@ -170,9 +164,7 @@ export namespace Live2DCubismFramework {
} }
if (currentOutput[i].destinationParameterIndex == -1) { if (currentOutput[i].destinationParameterIndex == -1) {
currentOutput[ currentOutput[i].destinationParameterIndex = model.getParameterIndex(
i
].destinationParameterIndex = model.getParameterIndex(
currentOutput[i].destination.id currentOutput[i].destination.id
); );
} }
@ -196,8 +188,7 @@ export namespace Live2DCubismFramework {
const destinationParameterIndex: number = const destinationParameterIndex: number =
currentOutput[i].destinationParameterIndex; currentOutput[i].destinationParameterIndex;
const outParameterValue: Float32Array = const outParameterValue: Float32Array =
!Float32Array.prototype.slice && !Float32Array.prototype.slice && 'subarray' in Float32Array.prototype
'subarray' in Float32Array.prototype
? JSON.parse( ? JSON.parse(
JSON.stringify( JSON.stringify(
parameterValue.subarray(destinationParameterIndex) parameterValue.subarray(destinationParameterIndex)
@ -321,19 +312,13 @@ export namespace Live2DCubismFramework {
this._physicsRig.settings.at( this._physicsRig.settings.at(
i i
).normalizationAngle.minimum = json.getNormalizationAngleMinimumValue( ).normalizationAngle.minimum = json.getNormalizationAngleMinimumValue(i);
i
);
this._physicsRig.settings.at( this._physicsRig.settings.at(
i i
).normalizationAngle.maximum = json.getNormalizationAngleMaximumValue( ).normalizationAngle.maximum = json.getNormalizationAngleMaximumValue(i);
i
);
this._physicsRig.settings.at( this._physicsRig.settings.at(
i i
).normalizationAngle.defalut = json.getNormalizationAngleDefaultValue( ).normalizationAngle.defalut = json.getNormalizationAngleDefaultValue(i);
i
);
// Input // Input
this._physicsRig.settings.at(i).inputCount = json.getInputCount(i); this._physicsRig.settings.at(i).inputCount = json.getInputCount(i);
@ -341,9 +326,10 @@ export namespace Live2DCubismFramework {
for (let j = 0; j < this._physicsRig.settings.at(i).inputCount; ++j) { for (let j = 0; j < this._physicsRig.settings.at(i).inputCount; ++j) {
this._physicsRig.inputs.at(inputIndex + j).sourceParameterIndex = -1; this._physicsRig.inputs.at(inputIndex + j).sourceParameterIndex = -1;
this._physicsRig.inputs.at( this._physicsRig.inputs.at(inputIndex + j).weight = json.getInputWeight(
inputIndex + j i,
).weight = json.getInputWeight(i, j); j
);
this._physicsRig.inputs.at( this._physicsRig.inputs.at(
inputIndex + j inputIndex + j
).reflect = json.getInputReflect(i, j); ).reflect = json.getInputReflect(i, j);
@ -436,16 +422,10 @@ export namespace Live2DCubismFramework {
outputIndex += this._physicsRig.settings.at(i).outputCount; outputIndex += this._physicsRig.settings.at(i).outputCount;
// Particle // Particle
this._physicsRig.settings.at(i).particleCount = json.getParticleCount( this._physicsRig.settings.at(i).particleCount = json.getParticleCount(i);
i
);
this._physicsRig.settings.at(i).baseParticleIndex = particleIndex; this._physicsRig.settings.at(i).baseParticleIndex = particleIndex;
for ( for (let j = 0; j < this._physicsRig.settings.at(i).particleCount; ++j) {
let j = 0;
j < this._physicsRig.settings.at(i).particleCount;
++j
) {
this._physicsRig.particles.at( this._physicsRig.particles.at(
particleIndex + j particleIndex + j
).mobility = json.getParticleMobility(i, j); ).mobility = json.getParticleMobility(i, j);
@ -487,9 +467,7 @@ export namespace Live2DCubismFramework {
++settingIndex ++settingIndex
) { ) {
currentSetting = this._physicsRig.settings.at(settingIndex); currentSetting = this._physicsRig.settings.at(settingIndex);
strand = this._physicsRig.particles.get( strand = this._physicsRig.particles.get(currentSetting.baseParticleIndex);
currentSetting.baseParticleIndex
);
// Initialize the top of particle. // Initialize the top of particle.
strand[0].initialPosition = new CubismVector2(0.0, 0.0); strand[0].initialPosition = new CubismVector2(0.0, 0.0);
@ -528,12 +506,12 @@ export namespace Live2DCubismFramework {
_physicsRig: CubismPhysicsRig; // 物理演算のデータ _physicsRig: CubismPhysicsRig; // 物理演算のデータ
_options: Options; // オプション _options: Options; // オプション
} }
/** /**
* *
*/ */
export class Options { export class Options {
constructor() { constructor() {
this.gravity = new CubismVector2(0, 0); this.gravity = new CubismVector2(0, 0);
this.wind = new CubismVector2(0, 0); this.wind = new CubismVector2(0, 0);
@ -541,16 +519,16 @@ export namespace Live2DCubismFramework {
gravity: CubismVector2; // 重力方向 gravity: CubismVector2; // 重力方向
wind: CubismVector2; // 風の方向 wind: CubismVector2; // 風の方向
} }
/** /**
* Gets sign. * Gets sign.
* *
* @param value Evaluation target value. * @param value Evaluation target value.
* *
* @return Sign of value. * @return Sign of value.
*/ */
function sign(value: number): number { function sign(value: number): number {
let ret = 0; let ret = 0;
if (value > 0.0) { if (value > 0.0) {
@ -560,9 +538,9 @@ export namespace Live2DCubismFramework {
} }
return ret; return ret;
} }
function getInputTranslationXFromNormalizedParameterValue( function getInputTranslationXFromNormalizedParameterValue(
targetTranslation: CubismVector2, targetTranslation: CubismVector2,
targetAngle: { angle: number }, targetAngle: { angle: number },
value: number, value: number,
@ -573,7 +551,7 @@ export namespace Live2DCubismFramework {
normalizationAngle: CubismPhysicsNormalization, normalizationAngle: CubismPhysicsNormalization,
isInverted: boolean, isInverted: boolean,
weight: number weight: number
): void { ): void {
targetTranslation.x += targetTranslation.x +=
normalizeParameterValue( normalizeParameterValue(
value, value,
@ -585,9 +563,9 @@ export namespace Live2DCubismFramework {
normalizationPosition.defalut, normalizationPosition.defalut,
isInverted isInverted
) * weight; ) * weight;
} }
function getInputTranslationYFromNormalizedParamterValue( function getInputTranslationYFromNormalizedParamterValue(
targetTranslation: CubismVector2, targetTranslation: CubismVector2,
targetAngle: { angle: number }, targetAngle: { angle: number },
value: number, value: number,
@ -598,7 +576,7 @@ export namespace Live2DCubismFramework {
normalizationAngle: CubismPhysicsNormalization, normalizationAngle: CubismPhysicsNormalization,
isInverted: boolean, isInverted: boolean,
weight: number weight: number
): void { ): void {
targetTranslation.y += targetTranslation.y +=
normalizeParameterValue( normalizeParameterValue(
value, value,
@ -610,9 +588,9 @@ export namespace Live2DCubismFramework {
normalizationPosition.defalut, normalizationPosition.defalut,
isInverted isInverted
) * weight; ) * weight;
} }
function getInputAngleFromNormalizedParameterValue( function getInputAngleFromNormalizedParameterValue(
targetTranslation: CubismVector2, targetTranslation: CubismVector2,
targetAngle: { angle: number }, targetAngle: { angle: number },
value: number, value: number,
@ -623,7 +601,7 @@ export namespace Live2DCubismFramework {
normalizationAngle: CubismPhysicsNormalization, normalizationAngle: CubismPhysicsNormalization,
isInverted: boolean, isInverted: boolean,
weight: number weight: number
): void { ): void {
targetAngle.angle += targetAngle.angle +=
normalizeParameterValue( normalizeParameterValue(
value, value,
@ -635,15 +613,15 @@ export namespace Live2DCubismFramework {
normalizationAngle.defalut, normalizationAngle.defalut,
isInverted isInverted
) * weight; ) * weight;
} }
function getOutputTranslationX( function getOutputTranslationX(
translation: CubismVector2, translation: CubismVector2,
particles: CubismPhysicsParticle[], particles: CubismPhysicsParticle[],
particleIndex: number, particleIndex: number,
isInverted: boolean, isInverted: boolean,
parentGravity: CubismVector2 parentGravity: CubismVector2
): number { ): number {
let outputValue: number = translation.x; let outputValue: number = translation.x;
if (isInverted) { if (isInverted) {
@ -651,30 +629,30 @@ export namespace Live2DCubismFramework {
} }
return outputValue; return outputValue;
} }
function getOutputTranslationY( function getOutputTranslationY(
translation: CubismVector2, translation: CubismVector2,
particles: CubismPhysicsParticle[], particles: CubismPhysicsParticle[],
particleIndex: number, particleIndex: number,
isInverted: boolean, isInverted: boolean,
parentGravity: CubismVector2 parentGravity: CubismVector2
): number { ): number {
let outputValue: number = translation.y; let outputValue: number = translation.y;
if (isInverted) { if (isInverted) {
outputValue *= -1.0; outputValue *= -1.0;
} }
return outputValue; return outputValue;
} }
function getOutputAngle( function getOutputAngle(
translation: CubismVector2, translation: CubismVector2,
particles: CubismPhysicsParticle[], particles: CubismPhysicsParticle[],
particleIndex: number, particleIndex: number,
isInverted: boolean, isInverted: boolean,
parentGravity: CubismVector2 parentGravity: CubismVector2
): number { ): number {
let outputValue: number; let outputValue: number;
if (particleIndex >= 2) { if (particleIndex >= 2) {
@ -692,42 +670,42 @@ export namespace Live2DCubismFramework {
} }
return outputValue; return outputValue;
} }
function getRangeValue(min: number, max: number): number { function getRangeValue(min: number, max: number): number {
const maxValue: number = CubismMath.max(min, max); const maxValue: number = CubismMath.max(min, max);
const minValue: number = CubismMath.min(min, max); const minValue: number = CubismMath.min(min, max);
return CubismMath.abs(maxValue - minValue); return CubismMath.abs(maxValue - minValue);
} }
function getDefaultValue(min: number, max: number): number { function getDefaultValue(min: number, max: number): number {
const minValue: number = CubismMath.min(min, max); const minValue: number = CubismMath.min(min, max);
return minValue + getRangeValue(min, max) / 2.0; return minValue + getRangeValue(min, max) / 2.0;
} }
function getOutputScaleTranslationX( function getOutputScaleTranslationX(
translationScale: CubismVector2, translationScale: CubismVector2,
angleScale: number angleScale: number
): number { ): number {
return JSON.parse(JSON.stringify(translationScale.x)); return JSON.parse(JSON.stringify(translationScale.x));
} }
function getOutputScaleTranslationY( function getOutputScaleTranslationY(
translationScale: CubismVector2, translationScale: CubismVector2,
angleScale: number angleScale: number
): number { ): number {
return JSON.parse(JSON.stringify(translationScale.y)); return JSON.parse(JSON.stringify(translationScale.y));
} }
function getOutputScaleAngle( function getOutputScaleAngle(
translationScale: CubismVector2, translationScale: CubismVector2,
angleScale: number angleScale: number
): number { ): number {
return JSON.parse(JSON.stringify(angleScale)); return JSON.parse(JSON.stringify(angleScale));
} }
/** /**
* Updates particles. * Updates particles.
* *
* @param strand Target array of particle. * @param strand Target array of particle.
@ -739,7 +717,7 @@ export namespace Live2DCubismFramework {
* @param deltaTimeSeconds Delta time. * @param deltaTimeSeconds Delta time.
* @param airResistance Air resistance. * @param airResistance Air resistance.
*/ */
function updateParticles( function updateParticles(
strand: CubismPhysicsParticle[], strand: CubismPhysicsParticle[],
strandCount: number, strandCount: number,
totalTranslation: CubismVector2, totalTranslation: CubismVector2,
@ -748,7 +726,7 @@ export namespace Live2DCubismFramework {
thresholdValue: number, thresholdValue: number,
deltaTimeSeconds: number, deltaTimeSeconds: number,
airResistance: number airResistance: number
) { ) {
let totalRadian: number; let totalRadian: number;
let delay: number; let delay: number;
let radian: number; let radian: number;
@ -811,9 +789,7 @@ export namespace Live2DCubismFramework {
} }
if (delay != 0.0) { if (delay != 0.0) {
strand[i].velocity = strand[i].position.substract( strand[i].velocity = strand[i].position.substract(strand[i].lastPosition);
strand[i].lastPosition
);
strand[i].velocity = strand[i].velocity.divisionByScalar(delay); strand[i].velocity = strand[i].velocity.divisionByScalar(delay);
strand[i].velocity = strand[i].velocity.multiplyByScaler( strand[i].velocity = strand[i].velocity.multiplyByScaler(
strand[i].mobility strand[i].mobility
@ -826,22 +802,22 @@ export namespace Live2DCubismFramework {
currentGravity.y currentGravity.y
); );
} }
} }
/** /**
* Updates output parameter value. * Updates output parameter value.
* @param parameterValue Target parameter value. * @param parameterValue Target parameter value.
* @param parameterValueMinimum Minimum of parameter value. * @param parameterValueMinimum Minimum of parameter value.
* @param parameterValueMaximum Maximum of parameter value. * @param parameterValueMaximum Maximum of parameter value.
* @param translation Translation value. * @param translation Translation value.
*/ */
function updateOutputParameterValue( function updateOutputParameterValue(
parameterValue: Float32Array, parameterValue: Float32Array,
parameterValueMinimum: number, parameterValueMinimum: number,
parameterValueMaximum: number, parameterValueMaximum: number,
translation: number, translation: number,
output: CubismPhysicsOutput output: CubismPhysicsOutput
): void { ): void {
let outputScale: number; let outputScale: number;
let value: number; let value: number;
let weight: number; let weight: number;
@ -872,9 +848,9 @@ export namespace Live2DCubismFramework {
value = parameterValue[0] * (1.0 - weight) + value * weight; value = parameterValue[0] * (1.0 - weight) + value * weight;
parameterValue[0] = value; parameterValue[0] = value;
} }
} }
function normalizeParameterValue( function normalizeParameterValue(
value: number, value: number,
parameterMinimum: number, parameterMinimum: number,
parameterMaximum: number, parameterMaximum: number,
@ -883,7 +859,7 @@ export namespace Live2DCubismFramework {
normalizedMaximum: number, normalizedMaximum: number,
normalizedDefault: number, normalizedDefault: number,
isInverted: boolean isInverted: boolean
) { ) {
let result = 0.0; let result = 0.0;
const maxValue: number = CubismMath.max(parameterMaximum, parameterMinimum); const maxValue: number = CubismMath.max(parameterMaximum, parameterMinimum);
@ -945,5 +921,14 @@ export namespace Live2DCubismFramework {
} }
return isInverted ? result : result * -1.0; return isInverted ? result : result * -1.0;
} }
// Namespace definition for compatibility.
import * as $ from './cubismphysics';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Live2DCubismFramework {
export const CubismPhysics = $.CubismPhysics;
export type CubismPhysics = $.CubismPhysics;
export const Options = $.Options;
export type Options = $.Options;
} }

View File

@ -5,65 +5,61 @@
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/ */
import { Live2DCubismFramework as cubismvector2 } from '../math/cubismvector2'; import { CubismIdHandle } from '../id/cubismid';
import { Live2DCubismFramework as cubismid } from '../id/cubismid'; import { CubismVector2 } from '../math/cubismvector2';
import { Live2DCubismFramework as csmvector } from '../type/csmvector'; import { csmVector } from '../type/csmvector';
import csmVector = csmvector.csmVector;
import CubismIdHandle = cubismid.CubismIdHandle;
import CubismVector2 = cubismvector2.CubismVector2;
export namespace Live2DCubismFramework { /**
/**
* *
*/ */
export enum CubismPhysicsTargetType { export enum CubismPhysicsTargetType {
CubismPhysicsTargetType_Parameter // パラメータに対して適用 CubismPhysicsTargetType_Parameter // パラメータに対して適用
} }
/** /**
* *
*/ */
export enum CubismPhysicsSource { export enum CubismPhysicsSource {
CubismPhysicsSource_X, // X軸の位置から CubismPhysicsSource_X, // X軸の位置から
CubismPhysicsSource_Y, // Y軸の位置から CubismPhysicsSource_Y, // Y軸の位置から
CubismPhysicsSource_Angle // 角度から CubismPhysicsSource_Angle // 角度から
} }
/** /**
* @brief 使 * @brief 使
* *
* 使 * 使
*/ */
export class PhysicsJsonEffectiveForces { export class PhysicsJsonEffectiveForces {
constructor() { constructor() {
this.gravity = new CubismVector2(0, 0); this.gravity = new CubismVector2(0, 0);
this.wind = new CubismVector2(0, 0); this.wind = new CubismVector2(0, 0);
} }
gravity: CubismVector2; // 重力 gravity: CubismVector2; // 重力
wind: CubismVector2; // 風 wind: CubismVector2; // 風
} }
/** /**
* *
*/ */
export class CubismPhysicsParameter { export class CubismPhysicsParameter {
id: CubismIdHandle; // パラメータ id: CubismIdHandle; // パラメータ
targetType: CubismPhysicsTargetType; // 適用先の種類 targetType: CubismPhysicsTargetType; // 適用先の種類
} }
/** /**
* *
*/ */
export class CubismPhysicsNormalization { export class CubismPhysicsNormalization {
minimum: number; // 最大値 minimum: number; // 最大値
maximum: number; // 最小値 maximum: number; // 最小値
defalut: number; // デフォルト値 defalut: number; // デフォルト値
} }
/** /**
* 使 * 使
*/ */
export class CubismPhysicsParticle { export class CubismPhysicsParticle {
constructor() { constructor() {
this.initialPosition = new CubismVector2(0, 0); this.initialPosition = new CubismVector2(0, 0);
this.position = new CubismVector2(0, 0); this.position = new CubismVector2(0, 0);
@ -83,12 +79,12 @@ export namespace Live2DCubismFramework {
lastGravity: CubismVector2; // 最後の重力 lastGravity: CubismVector2; // 最後の重力
force: CubismVector2; // 現在かかっている力 force: CubismVector2; // 現在かかっている力
velocity: CubismVector2; // 現在の速度 velocity: CubismVector2; // 現在の速度
} }
/** /**
* *
*/ */
export class CubismPhysicsSubRig { export class CubismPhysicsSubRig {
constructor() { constructor() {
this.normalizationPosition = new CubismPhysicsNormalization(); this.normalizationPosition = new CubismPhysicsNormalization();
this.normalizationAngle = new CubismPhysicsNormalization(); this.normalizationAngle = new CubismPhysicsNormalization();
@ -101,9 +97,9 @@ export namespace Live2DCubismFramework {
baseParticleIndex: number; // 物理点の最初のインデックス baseParticleIndex: number; // 物理点の最初のインデックス
normalizationPosition: CubismPhysicsNormalization; // 正規化された位置 normalizationPosition: CubismPhysicsNormalization; // 正規化された位置
normalizationAngle: CubismPhysicsNormalization; // 正規化された角度 normalizationAngle: CubismPhysicsNormalization; // 正規化された角度
} }
/** /**
* *
* @param targetTranslation // 演算結果の移動値 * @param targetTranslation // 演算結果の移動値
* @param targetAngle // 演算結果の角度 * @param targetAngle // 演算結果の角度
@ -116,7 +112,7 @@ export namespace Live2DCubismFramework {
* @param isInverted // 値が反転されているか? * @param isInverted // 値が反転されているか?
* @param weight // 重み * @param weight // 重み
*/ */
export interface normalizedPhysicsParameterValueGetter { export interface normalizedPhysicsParameterValueGetter {
( (
targetTranslation: CubismVector2, targetTranslation: CubismVector2,
targetAngle: { angle: number }, targetAngle: { angle: number },
@ -129,9 +125,9 @@ export namespace Live2DCubismFramework {
isInverted: boolean, isInverted: boolean,
weight: number weight: number
): void; ): void;
} }
/** /**
* *
* @param translation * @param translation
* @param particles * @param particles
@ -139,7 +135,7 @@ export namespace Live2DCubismFramework {
* @param parentGravity * @param parentGravity
* @return * @return
*/ */
export interface physicsValueGetter { export interface physicsValueGetter {
( (
translation: CubismVector2, translation: CubismVector2,
particles: CubismPhysicsParticle[], particles: CubismPhysicsParticle[],
@ -147,22 +143,22 @@ export namespace Live2DCubismFramework {
isInverted: boolean, isInverted: boolean,
parentGravity: CubismVector2 parentGravity: CubismVector2
): number; ): number;
} }
/** /**
* *
* @param translationScale * @param translationScale
* @param angleScale * @param angleScale
* @return * @return
*/ */
export interface physicsScaleGetter { export interface physicsScaleGetter {
(translationScale: CubismVector2, angleScale: number): number; (translationScale: CubismVector2, angleScale: number): number;
} }
/** /**
* *
*/ */
export class CubismPhysicsInput { export class CubismPhysicsInput {
constructor() { constructor() {
this.source = new CubismPhysicsParameter(); this.source = new CubismPhysicsParameter();
} }
@ -172,14 +168,14 @@ export namespace Live2DCubismFramework {
type: number; // 入力の種類 type: number; // 入力の種類
reflect: boolean; // 値が反転されているかどうか reflect: boolean; // 値が反転されているかどうか
getNormalizedParameterValue: normalizedPhysicsParameterValueGetter; // 正規化されたパラメータ値の取得関数 getNormalizedParameterValue: normalizedPhysicsParameterValueGetter; // 正規化されたパラメータ値の取得関数
} }
/** /**
* @brief * @brief
* *
* *
*/ */
export class CubismPhysicsOutput { export class CubismPhysicsOutput {
constructor() { constructor() {
this.destination = new CubismPhysicsParameter(); this.destination = new CubismPhysicsParameter();
this.translationScale = new CubismVector2(0, 0); this.translationScale = new CubismVector2(0, 0);
@ -197,14 +193,14 @@ export namespace Live2DCubismFramework {
valueExceededMaximum: number; // 最大値をこえた時の値 valueExceededMaximum: number; // 最大値をこえた時の値
getValue: physicsValueGetter; // 物理演算の値の取得関数 getValue: physicsValueGetter; // 物理演算の値の取得関数
getScale: physicsScaleGetter; // 物理演算のスケール値の取得関数 getScale: physicsScaleGetter; // 物理演算のスケール値の取得関数
} }
/** /**
* @brief * @brief
* *
* *
*/ */
export class CubismPhysicsRig { export class CubismPhysicsRig {
constructor() { constructor() {
this.settings = new csmVector<CubismPhysicsSubRig>(); this.settings = new csmVector<CubismPhysicsSubRig>();
this.inputs = new csmVector<CubismPhysicsInput>(); this.inputs = new csmVector<CubismPhysicsInput>();
@ -221,5 +217,33 @@ export namespace Live2DCubismFramework {
particles: csmVector<CubismPhysicsParticle>; // 物理演算の物理点のリスト particles: csmVector<CubismPhysicsParticle>; // 物理演算の物理点のリスト
gravity: CubismVector2; // 重力 gravity: CubismVector2; // 重力
wind: CubismVector2; // 風 wind: CubismVector2; // 風
} }
// Namespace definition for compatibility.
import * as $ from './cubismphysicsinternal';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Live2DCubismFramework {
export const CubismPhysicsInput = $.CubismPhysicsInput;
export type CubismPhysicsInput = $.CubismPhysicsInput;
export const CubismPhysicsNormalization = $.CubismPhysicsNormalization;
export type CubismPhysicsNormalization = $.CubismPhysicsNormalization;
export const CubismPhysicsOutput = $.CubismPhysicsOutput;
export type CubismPhysicsOutput = $.CubismPhysicsOutput;
export const CubismPhysicsParameter = $.CubismPhysicsParameter;
export type CubismPhysicsParameter = $.CubismPhysicsParameter;
export const CubismPhysicsParticle = $.CubismPhysicsParticle;
export type CubismPhysicsParticle = $.CubismPhysicsParticle;
export const CubismPhysicsRig = $.CubismPhysicsRig;
export type CubismPhysicsRig = $.CubismPhysicsRig;
export const CubismPhysicsSource = $.CubismPhysicsSource;
export type CubismPhysicsSource = $.CubismPhysicsSource;
export const CubismPhysicsSubRig = $.CubismPhysicsSubRig;
export type CubismPhysicsSubRig = $.CubismPhysicsSubRig;
export const CubismPhysicsTargetType = $.CubismPhysicsTargetType;
export type CubismPhysicsTargetType = $.CubismPhysicsTargetType;
export const PhysicsJsonEffectiveForces = $.PhysicsJsonEffectiveForces;
export type PhysicsJsonEffectiveForces = $.PhysicsJsonEffectiveForces;
export type normalizedPhysicsParameterValueGetter = $.normalizedPhysicsParameterValueGetter;
export type physicsScaleGetter = $.physicsScaleGetter;
export type physicsValueGetter = $.physicsValueGetter;
} }

View File

@ -5,64 +5,59 @@
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/ */
import { Live2DCubismFramework as cubismjson } from '../utils/cubismjson'; import { CubismIdHandle } from '../id/cubismid';
import { Live2DCubismFramework as cubismvector2 } from '../math/cubismvector2'; import { CubismFramework } from '../live2dcubismframework';
import { Live2DCubismFramework as cubismid } from '../id/cubismid'; import { CubismVector2 } from '../math/cubismvector2';
import { Live2DCubismFramework as cubismframework } from '../live2dcubismframework'; import { CubismJson } from '../utils/cubismjson';
import CubismFramework = cubismframework.CubismFramework;
import CubismIdHandle = cubismid.CubismIdHandle;
import CubismVector2 = cubismvector2.CubismVector2;
import CubismJson = cubismjson.CubismJson;
export namespace Live2DCubismFramework { // JSON keys
// JSON keys const Position = 'Position';
const Position = 'Position'; const X = 'X';
const X = 'X'; const Y = 'Y';
const Y = 'Y'; const Angle = 'Angle';
const Angle = 'Angle'; const Type = 'Type';
const Type = 'Type'; const Id = 'Id';
const Id = 'Id';
// Meta // Meta
const Meta = 'Meta'; const Meta = 'Meta';
const EffectiveForces = 'EffectiveForces'; const EffectiveForces = 'EffectiveForces';
const TotalInputCount = 'TotalInputCount'; const TotalInputCount = 'TotalInputCount';
const TotalOutputCount = 'TotalOutputCount'; const TotalOutputCount = 'TotalOutputCount';
const PhysicsSettingCount = 'PhysicsSettingCount'; const PhysicsSettingCount = 'PhysicsSettingCount';
const Gravity = 'Gravity'; const Gravity = 'Gravity';
const Wind = 'Wind'; const Wind = 'Wind';
const VertexCount = 'VertexCount'; const VertexCount = 'VertexCount';
// PhysicsSettings // PhysicsSettings
const PhysicsSettings = 'PhysicsSettings'; const PhysicsSettings = 'PhysicsSettings';
const Normalization = 'Normalization'; const Normalization = 'Normalization';
const Minimum = 'Minimum'; const Minimum = 'Minimum';
const Maximum = 'Maximum'; const Maximum = 'Maximum';
const Default = 'Default'; const Default = 'Default';
const Reflect = 'Reflect'; const Reflect = 'Reflect';
const Weight = 'Weight'; const Weight = 'Weight';
// Input // Input
const Input = 'Input'; const Input = 'Input';
const Source = 'Source'; const Source = 'Source';
// Output // Output
const Output = 'Output'; const Output = 'Output';
const Scale = 'Scale'; const Scale = 'Scale';
const VertexIndex = 'VertexIndex'; const VertexIndex = 'VertexIndex';
const Destination = 'Destination'; const Destination = 'Destination';
// Particle // Particle
const Vertices = 'Vertices'; const Vertices = 'Vertices';
const Mobility = 'Mobility'; const Mobility = 'Mobility';
const Delay = 'Delay'; const Delay = 'Delay';
const Radius = 'Radius'; const Radius = 'Radius';
const Acceleration = 'Acceleration'; const Acceleration = 'Acceleration';
/** /**
* physics3.json * physics3.json
*/ */
export class CubismPhysicsJson { export class CubismPhysicsJson {
/** /**
* *
* @param buffer physics3.json * @param buffer physics3.json
@ -342,10 +337,7 @@ export namespace Live2DCubismFramework {
* @param inputIndex * @param inputIndex
* @return * @return
*/ */
public getInputType( public getInputType(physicsSettingIndex: number, inputIndex: number): string {
physicsSettingIndex: number,
inputIndex: number
): string {
return this._json return this._json
.getRoot() .getRoot()
.getValueByString(PhysicsSettings) .getValueByString(PhysicsSettings)
@ -645,5 +637,12 @@ export namespace Live2DCubismFramework {
} }
_json: CubismJson; // physics3.jsonデータ _json: CubismJson; // physics3.jsonデータ
} }
// Namespace definition for compatibility.
import * as $ from './cubismphysicsjson';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Live2DCubismFramework {
export const CubismPhysicsJson = $.CubismPhysicsJson;
export type CubismPhysicsJson = $.CubismPhysicsJson;
} }

View File

@ -5,18 +5,15 @@
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/ */
import { Live2DCubismFramework as cubismmatrix44 } from '../math/cubismmatrix44'; import { CubismMatrix44 } from '../math/cubismmatrix44';
import { Live2DCubismFramework as cubismmodel } from '../model/cubismmodel'; import { CubismModel } from '../model/cubismmodel';
import CubismModel = cubismmodel.CubismModel;
import CubismMatrix44 = cubismmatrix44.CubismMatrix44;
export namespace Live2DCubismFramework { /**
/**
* *
* *
* *
*/ */
export abstract class CubismRenderer { export abstract class CubismRenderer {
/** /**
* *
* *
@ -237,18 +234,18 @@ export namespace Live2DCubismFramework {
protected _isPremultipliedAlpha: boolean; // 乗算済みαならtrue protected _isPremultipliedAlpha: boolean; // 乗算済みαならtrue
protected _anisortopy: any; // テクスチャの異方性フィルタリングのパラメータ protected _anisortopy: any; // テクスチャの異方性フィルタリングのパラメータ
protected _model: CubismModel; // レンダリング対象のモデル protected _model: CubismModel; // レンダリング対象のモデル
} }
export enum CubismBlendMode { export enum CubismBlendMode {
CubismBlendMode_Normal = 0, // 通常 CubismBlendMode_Normal = 0, // 通常
CubismBlendMode_Additive = 1, // 加算 CubismBlendMode_Additive = 1, // 加算
CubismBlendMode_Multiplicative = 2 // 乗算 CubismBlendMode_Multiplicative = 2 // 乗算
} }
/** /**
* RGBA * RGBA
*/ */
export class CubismTextureColor { export class CubismTextureColor {
/** /**
* *
*/ */
@ -263,5 +260,16 @@ export namespace Live2DCubismFramework {
G: number; // 緑チャンネル G: number; // 緑チャンネル
B: number; // 青チャンネル B: number; // 青チャンネル
A: number; // αチャンネル A: number; // αチャンネル
} }
// Namespace definition for compatibility.
import * as $ from './cubismrenderer';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Live2DCubismFramework {
export const CubismBlendMode = $.CubismBlendMode;
export type CubismBlendMode = $.CubismBlendMode;
export const CubismRenderer = $.CubismRenderer;
export type CubismRenderer = $.CubismRenderer;
export const CubismTextureColor = $.CubismTextureColor;
export type CubismTextureColor = $.CubismTextureColor;
} }

View File

@ -5,36 +5,30 @@
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/ */
import { Live2DCubismFramework as cubismframework } from '../live2dcubismframework'; import { Constant } from '../live2dcubismframework';
import { Live2DCubismFramework as csmrect } from '../type/csmrectf'; import { CubismMatrix44 } from '../math/cubismmatrix44';
import { Live2DCubismFramework as cubismrenderer } from './cubismrenderer'; import { CubismModel } from '../model/cubismmodel';
import { Live2DCubismFramework as cubismmodel } from '../model/cubismmodel'; import { csmMap } from '../type/csmmap';
import { Live2DCubismFramework as cubsimmatrix44 } from '../math/cubismmatrix44'; import { csmRect } from '../type/csmrectf';
import { Live2DCubismFramework as csmmap } from '../type/csmmap'; import { csmVector } from '../type/csmvector';
import { Live2DCubismFramework as csmvector } from '../type/csmvector';
import { CubismLogError } from '../utils/cubismdebug'; import { CubismLogError } from '../utils/cubismdebug';
import Constant = cubismframework.Constant; import {
import CubismMatrix44 = cubsimmatrix44.CubismMatrix44; CubismBlendMode,
import csmRect = csmrect.csmRect; CubismRenderer,
import csmMap = csmmap.csmMap; CubismTextureColor
import csmVector = csmvector.csmVector; } from './cubismrenderer';
import CubismModel = cubismmodel.CubismModel;
import CubismRenderer = cubismrenderer.CubismRenderer;
import CubismBlendMode = cubismrenderer.CubismBlendMode;
import CubismTextureColor = cubismrenderer.CubismTextureColor;
export namespace Live2DCubismFramework { const ColorChannelCount = 4; // 実験時に1チャンネルの場合は1、RGBだけの場合は3、アルファも含める場合は4
const ColorChannelCount = 4; // 実験時に1チャンネルの場合は1、RGBだけの場合は3、アルファも含める場合は4
const shaderCount = 10; // シェーダーの数 = マスク生成用 + (通常用 + 加算 + 乗算) * (マスク無の乗算済アルファ対応版 + マスク有の乗算済アルファ対応版 + マスク有反転の乗算済アルファ対応版) const shaderCount = 10; // シェーダーの数 = マスク生成用 + (通常用 + 加算 + 乗算) * (マスク無の乗算済アルファ対応版 + マスク有の乗算済アルファ対応版 + マスク有反転の乗算済アルファ対応版)
let s_instance: CubismShader_WebGL; let s_instance: CubismShader_WebGL;
let s_viewport: number[]; let s_viewport: number[];
let s_fbo: WebGLFramebuffer; let s_fbo: WebGLFramebuffer;
/** /**
* *
*/ */
export class CubismClippingManager_WebGL { export class CubismClippingManager_WebGL {
/** /**
* RGBA * RGBA
* @param channelNo RGBA0:R, 1:G, 2:B, 3:A * @param channelNo RGBA0:R, 1:G, 2:B, 3:A
@ -490,12 +484,8 @@ export namespace Live2DCubismFramework {
} }
this._tmpMatrixForDraw.setMatrix(this._tmpMatrix.getArray()); this._tmpMatrixForDraw.setMatrix(this._tmpMatrix.getArray());
} }
clipContext._matrixForMask.setMatrix( clipContext._matrixForMask.setMatrix(this._tmpMatrixForMask.getArray());
this._tmpMatrixForMask.getArray() clipContext._matrixForDraw.setMatrix(this._tmpMatrixForDraw.getArray());
);
clipContext._matrixForDraw.setMatrix(
this._tmpMatrixForDraw.getArray()
);
const clipDrawCount: number = clipContext._clippingIdCount; const clipDrawCount: number = clipContext._clippingIdCount;
for (let i = 0; i < clipDrawCount; i++) { for (let i = 0; i < clipDrawCount; i++) {
@ -503,9 +493,7 @@ export namespace Live2DCubismFramework {
// 頂点情報が更新されておらず、信頼性がない場合は描画をパスする // 頂点情報が更新されておらず、信頼性がない場合は描画をパスする
if ( if (
!model.getDrawableDynamicFlagVertexPositionsDidChange( !model.getDrawableDynamicFlagVertexPositionsDidChange(clipDrawIndex)
clipDrawIndex
)
) { ) {
continue; continue;
} }
@ -739,13 +727,13 @@ export namespace Live2DCubismFramework {
private _tmpBoundsOnModel: csmRect; // マスク配置計算用の矩形 private _tmpBoundsOnModel: csmRect; // マスク配置計算用の矩形
gl: WebGLRenderingContext; // WebGLレンダリングコンテキスト gl: WebGLRenderingContext; // WebGLレンダリングコンテキスト
} }
/** /**
* *
* 使 * 使
*/ */
export class CubismRenderTextureResource { export class CubismRenderTextureResource {
/** /**
* *
* @param frameNo * @param frameNo
@ -758,12 +746,12 @@ export namespace Live2DCubismFramework {
public frameNo: number; // レンダラのフレーム番号 public frameNo: number; // レンダラのフレーム番号
public texture: WebGLFramebuffer; // テクスチャのアドレス public texture: WebGLFramebuffer; // テクスチャのアドレス
} }
/** /**
* *
*/ */
export class CubismClippingContext { export class CubismClippingContext {
/** /**
* *
*/ */
@ -838,13 +826,13 @@ export namespace Live2DCubismFramework {
public _clippedDrawableIndexList: number[]; // このマスクにクリップされる描画オブジェクトのリスト public _clippedDrawableIndexList: number[]; // このマスクにクリップされる描画オブジェクトのリスト
private _owner: CubismClippingManager_WebGL; // このマスクを管理しているマネージャのインスタンス private _owner: CubismClippingManager_WebGL; // このマスクを管理しているマネージャのインスタンス
} }
/** /**
* WebGL * WebGL
* CubismShader_WebGL.getInstance * CubismShader_WebGL.getInstance
*/ */
export class CubismShader_WebGL { export class CubismShader_WebGL {
/** /**
* *
* @return * @return
@ -1200,26 +1188,14 @@ export namespace Live2DCubismFramework {
); );
// 加算も通常と同じシェーダーを利用する // 加算も通常と同じシェーダーを利用する
this._shaderSets.at(4).shaderProgram = this._shaderSets.at( this._shaderSets.at(4).shaderProgram = this._shaderSets.at(1).shaderProgram;
1 this._shaderSets.at(5).shaderProgram = this._shaderSets.at(2).shaderProgram;
).shaderProgram; this._shaderSets.at(6).shaderProgram = this._shaderSets.at(3).shaderProgram;
this._shaderSets.at(5).shaderProgram = this._shaderSets.at(
2
).shaderProgram;
this._shaderSets.at(6).shaderProgram = this._shaderSets.at(
3
).shaderProgram;
// 乗算も通常と同じシェーダーを利用する // 乗算も通常と同じシェーダーを利用する
this._shaderSets.at(7).shaderProgram = this._shaderSets.at( this._shaderSets.at(7).shaderProgram = this._shaderSets.at(1).shaderProgram;
1 this._shaderSets.at(8).shaderProgram = this._shaderSets.at(2).shaderProgram;
).shaderProgram; this._shaderSets.at(9).shaderProgram = this._shaderSets.at(3).shaderProgram;
this._shaderSets.at(8).shaderProgram = this._shaderSets.at(
2
).shaderProgram;
this._shaderSets.at(9).shaderProgram = this._shaderSets.at(
3
).shaderProgram;
// SetupMask // SetupMask
this._shaderSets.at( this._shaderSets.at(
@ -1234,9 +1210,7 @@ export namespace Live2DCubismFramework {
this._shaderSets.at(0).shaderProgram, this._shaderSets.at(0).shaderProgram,
'a_texCoord' 'a_texCoord'
); );
this._shaderSets.at( this._shaderSets.at(0).samplerTexture0Location = this.gl.getUniformLocation(
0
).samplerTexture0Location = this.gl.getUniformLocation(
this._shaderSets.at(0).shaderProgram, this._shaderSets.at(0).shaderProgram,
's_texture0' 's_texture0'
); );
@ -1272,9 +1246,7 @@ export namespace Live2DCubismFramework {
this._shaderSets.at(1).shaderProgram, this._shaderSets.at(1).shaderProgram,
'a_texCoord' 'a_texCoord'
); );
this._shaderSets.at( this._shaderSets.at(1).samplerTexture0Location = this.gl.getUniformLocation(
1
).samplerTexture0Location = this.gl.getUniformLocation(
this._shaderSets.at(1).shaderProgram, this._shaderSets.at(1).shaderProgram,
's_texture0' 's_texture0'
); );
@ -1302,15 +1274,11 @@ export namespace Live2DCubismFramework {
this._shaderSets.at(2).shaderProgram, this._shaderSets.at(2).shaderProgram,
'a_texCoord' 'a_texCoord'
); );
this._shaderSets.at( this._shaderSets.at(2).samplerTexture0Location = this.gl.getUniformLocation(
2
).samplerTexture0Location = this.gl.getUniformLocation(
this._shaderSets.at(2).shaderProgram, this._shaderSets.at(2).shaderProgram,
's_texture0' 's_texture0'
); );
this._shaderSets.at( this._shaderSets.at(2).samplerTexture1Location = this.gl.getUniformLocation(
2
).samplerTexture1Location = this.gl.getUniformLocation(
this._shaderSets.at(2).shaderProgram, this._shaderSets.at(2).shaderProgram,
's_texture1' 's_texture1'
); );
@ -1350,15 +1318,11 @@ export namespace Live2DCubismFramework {
this._shaderSets.at(3).shaderProgram, this._shaderSets.at(3).shaderProgram,
'a_texCoord' 'a_texCoord'
); );
this._shaderSets.at( this._shaderSets.at(3).samplerTexture0Location = this.gl.getUniformLocation(
3
).samplerTexture0Location = this.gl.getUniformLocation(
this._shaderSets.at(3).shaderProgram, this._shaderSets.at(3).shaderProgram,
's_texture0' 's_texture0'
); );
this._shaderSets.at( this._shaderSets.at(3).samplerTexture1Location = this.gl.getUniformLocation(
3
).samplerTexture1Location = this.gl.getUniformLocation(
this._shaderSets.at(3).shaderProgram, this._shaderSets.at(3).shaderProgram,
's_texture1' 's_texture1'
); );
@ -1398,9 +1362,7 @@ export namespace Live2DCubismFramework {
this._shaderSets.at(4).shaderProgram, this._shaderSets.at(4).shaderProgram,
'a_texCoord' 'a_texCoord'
); );
this._shaderSets.at( this._shaderSets.at(4).samplerTexture0Location = this.gl.getUniformLocation(
4
).samplerTexture0Location = this.gl.getUniformLocation(
this._shaderSets.at(4).shaderProgram, this._shaderSets.at(4).shaderProgram,
's_texture0' 's_texture0'
); );
@ -1428,15 +1390,11 @@ export namespace Live2DCubismFramework {
this._shaderSets.at(5).shaderProgram, this._shaderSets.at(5).shaderProgram,
'a_texCoord' 'a_texCoord'
); );
this._shaderSets.at( this._shaderSets.at(5).samplerTexture0Location = this.gl.getUniformLocation(
5
).samplerTexture0Location = this.gl.getUniformLocation(
this._shaderSets.at(5).shaderProgram, this._shaderSets.at(5).shaderProgram,
's_texture0' 's_texture0'
); );
this._shaderSets.at( this._shaderSets.at(5).samplerTexture1Location = this.gl.getUniformLocation(
5
).samplerTexture1Location = this.gl.getUniformLocation(
this._shaderSets.at(5).shaderProgram, this._shaderSets.at(5).shaderProgram,
's_texture1' 's_texture1'
); );
@ -1476,15 +1434,11 @@ export namespace Live2DCubismFramework {
this._shaderSets.at(6).shaderProgram, this._shaderSets.at(6).shaderProgram,
'a_texCoord' 'a_texCoord'
); );
this._shaderSets.at( this._shaderSets.at(6).samplerTexture0Location = this.gl.getUniformLocation(
6
).samplerTexture0Location = this.gl.getUniformLocation(
this._shaderSets.at(6).shaderProgram, this._shaderSets.at(6).shaderProgram,
's_texture0' 's_texture0'
); );
this._shaderSets.at( this._shaderSets.at(6).samplerTexture1Location = this.gl.getUniformLocation(
6
).samplerTexture1Location = this.gl.getUniformLocation(
this._shaderSets.at(6).shaderProgram, this._shaderSets.at(6).shaderProgram,
's_texture1' 's_texture1'
); );
@ -1524,9 +1478,7 @@ export namespace Live2DCubismFramework {
this._shaderSets.at(7).shaderProgram, this._shaderSets.at(7).shaderProgram,
'a_texCoord' 'a_texCoord'
); );
this._shaderSets.at( this._shaderSets.at(7).samplerTexture0Location = this.gl.getUniformLocation(
7
).samplerTexture0Location = this.gl.getUniformLocation(
this._shaderSets.at(7).shaderProgram, this._shaderSets.at(7).shaderProgram,
's_texture0' 's_texture0'
); );
@ -1554,15 +1506,11 @@ export namespace Live2DCubismFramework {
this._shaderSets.at(8).shaderProgram, this._shaderSets.at(8).shaderProgram,
'a_texCoord' 'a_texCoord'
); );
this._shaderSets.at( this._shaderSets.at(8).samplerTexture0Location = this.gl.getUniformLocation(
8
).samplerTexture0Location = this.gl.getUniformLocation(
this._shaderSets.at(8).shaderProgram, this._shaderSets.at(8).shaderProgram,
's_texture0' 's_texture0'
); );
this._shaderSets.at( this._shaderSets.at(8).samplerTexture1Location = this.gl.getUniformLocation(
8
).samplerTexture1Location = this.gl.getUniformLocation(
this._shaderSets.at(8).shaderProgram, this._shaderSets.at(8).shaderProgram,
's_texture1' 's_texture1'
); );
@ -1602,15 +1550,11 @@ export namespace Live2DCubismFramework {
this._shaderSets.at(9).shaderProgram, this._shaderSets.at(9).shaderProgram,
'a_texCoord' 'a_texCoord'
); );
this._shaderSets.at( this._shaderSets.at(9).samplerTexture0Location = this.gl.getUniformLocation(
9
).samplerTexture0Location = this.gl.getUniformLocation(
this._shaderSets.at(9).shaderProgram, this._shaderSets.at(9).shaderProgram,
's_texture0' 's_texture0'
); );
this._shaderSets.at( this._shaderSets.at(9).samplerTexture1Location = this.gl.getUniformLocation(
9
).samplerTexture1Location = this.gl.getUniformLocation(
this._shaderSets.at(9).shaderProgram, this._shaderSets.at(9).shaderProgram,
's_texture1' 's_texture1'
); );
@ -1748,12 +1692,12 @@ export namespace Live2DCubismFramework {
_shaderSets: csmVector<CubismShaderSet>; // ロードしたシェーダープログラムを保持する変数 _shaderSets: csmVector<CubismShaderSet>; // ロードしたシェーダープログラムを保持する変数
gl: WebGLRenderingContext; // webglコンテキスト gl: WebGLRenderingContext; // webglコンテキスト
} }
/** /**
* CubismShader_WebGL * CubismShader_WebGL
*/ */
export class CubismShaderSet { export class CubismShaderSet {
shaderProgram: WebGLProgram; // シェーダープログラムのアドレス shaderProgram: WebGLProgram; // シェーダープログラムのアドレス
attributePositionLocation: GLuint; // シェーダープログラムに渡す変数のアドレスPosition attributePositionLocation: GLuint; // シェーダープログラムに渡す変数のアドレスPosition
attributeTexCoordLocation: GLuint; // シェーダープログラムに渡す変数のアドレスTexCoord attributeTexCoordLocation: GLuint; // シェーダープログラムに渡す変数のアドレスTexCoord
@ -1763,9 +1707,9 @@ export namespace Live2DCubismFramework {
samplerTexture1Location: WebGLUniformLocation; // シェーダープログラムに渡す変数のアドレスTexture1 samplerTexture1Location: WebGLUniformLocation; // シェーダープログラムに渡す変数のアドレスTexture1
uniformBaseColorLocation: WebGLUniformLocation; // シェーダープログラムに渡す変数のアドレスBaseColor uniformBaseColorLocation: WebGLUniformLocation; // シェーダープログラムに渡す変数のアドレスBaseColor
uniformChannelFlagLocation: WebGLUniformLocation; // シェーダープログラムに渡す変数のアドレスChannelFlag uniformChannelFlagLocation: WebGLUniformLocation; // シェーダープログラムに渡す変数のアドレスChannelFlag
} }
export enum ShaderNames { export enum ShaderNames {
// SetupMask // SetupMask
ShaderNames_SetupMask, ShaderNames_SetupMask,
@ -1783,9 +1727,9 @@ export namespace Live2DCubismFramework {
ShaderNames_MultPremultipliedAlpha, ShaderNames_MultPremultipliedAlpha,
ShaderNames_MultMaskedPremultipliedAlpha, ShaderNames_MultMaskedPremultipliedAlpha,
ShaderNames_MultMaskedPremultipliedAlphaInverted ShaderNames_MultMaskedPremultipliedAlphaInverted
} }
export const vertexShaderSrcSetupMask = export const vertexShaderSrcSetupMask =
'attribute vec4 a_position;' + 'attribute vec4 a_position;' +
'attribute vec2 a_texCoord;' + 'attribute vec2 a_texCoord;' +
'varying vec2 v_texCoord;' + 'varying vec2 v_texCoord;' +
@ -1798,7 +1742,7 @@ export namespace Live2DCubismFramework {
' v_texCoord = a_texCoord;' + ' v_texCoord = a_texCoord;' +
' v_texCoord.y = 1.0 - v_texCoord.y;' + ' v_texCoord.y = 1.0 - v_texCoord.y;' +
'}'; '}';
export const fragmentShaderSrcsetupMask = export const fragmentShaderSrcsetupMask =
'precision mediump float;' + 'precision mediump float;' +
'varying vec2 v_texCoord;' + 'varying vec2 v_texCoord;' +
'varying vec4 v_myPos;' + 'varying vec4 v_myPos;' +
@ -1815,9 +1759,9 @@ export namespace Live2DCubismFramework {
' gl_FragColor = u_channelFlag * texture2D(s_texture0, v_texCoord).a * isInside;' + ' gl_FragColor = u_channelFlag * texture2D(s_texture0, v_texCoord).a * isInside;' +
'}'; '}';
//----- バーテックスシェーダプログラム ----- //----- バーテックスシェーダプログラム -----
// Normal & Add & Mult 共通 // Normal & Add & Mult 共通
export const vertexShaderSrc = export const vertexShaderSrc =
'attribute vec4 a_position;' + //v.vertex 'attribute vec4 a_position;' + //v.vertex
'attribute vec2 a_texCoord;' + //v.texcoord 'attribute vec2 a_texCoord;' + //v.texcoord
'varying vec2 v_texCoord;' + //v2f.texcoord 'varying vec2 v_texCoord;' + //v2f.texcoord
@ -1829,8 +1773,8 @@ export namespace Live2DCubismFramework {
' v_texCoord.y = 1.0 - v_texCoord.y;' + ' v_texCoord.y = 1.0 - v_texCoord.y;' +
'}'; '}';
// Normal & Add & Mult 共通(クリッピングされたものの描画用) // Normal & Add & Mult 共通(クリッピングされたものの描画用)
export const vertexShaderSrcMasked = export const vertexShaderSrcMasked =
'attribute vec4 a_position;' + 'attribute vec4 a_position;' +
'attribute vec2 a_texCoord;' + 'attribute vec2 a_texCoord;' +
'varying vec2 v_texCoord;' + 'varying vec2 v_texCoord;' +
@ -1845,9 +1789,9 @@ export namespace Live2DCubismFramework {
' v_texCoord.y = 1.0 - v_texCoord.y;' + ' v_texCoord.y = 1.0 - v_texCoord.y;' +
'}'; '}';
//----- フラグメントシェーダプログラム ----- //----- フラグメントシェーダプログラム -----
// Normal & Add & Mult 共通 PremultipliedAlpha // Normal & Add & Mult 共通 PremultipliedAlpha
export const fragmentShaderSrcPremultipliedAlpha = export const fragmentShaderSrcPremultipliedAlpha =
'precision mediump float;' + 'precision mediump float;' +
'varying vec2 v_texCoord;' + //v2f.texcoord 'varying vec2 v_texCoord;' + //v2f.texcoord
'uniform vec4 u_baseColor;' + 'uniform vec4 u_baseColor;' +
@ -1857,8 +1801,8 @@ export namespace Live2DCubismFramework {
' gl_FragColor = texture2D(s_texture0 , v_texCoord) * u_baseColor;' + ' gl_FragColor = texture2D(s_texture0 , v_texCoord) * u_baseColor;' +
'}'; '}';
// Normal クリッピングされたものの描画用、PremultipliedAlpha兼用 // Normal クリッピングされたものの描画用、PremultipliedAlpha兼用
export const fragmentShaderSrcMaskPremultipliedAlpha = export const fragmentShaderSrcMaskPremultipliedAlpha =
'precision mediump float;' + 'precision mediump float;' +
'varying vec2 v_texCoord;' + 'varying vec2 v_texCoord;' +
'varying vec4 v_clipPos;' + 'varying vec4 v_clipPos;' +
@ -1875,8 +1819,8 @@ export namespace Live2DCubismFramework {
' gl_FragColor = col_formask;' + ' gl_FragColor = col_formask;' +
'}'; '}';
// Normal & Add & Mult 共通クリッピングされて反転使用の描画用、PremultipliedAlphaの場合 // Normal & Add & Mult 共通クリッピングされて反転使用の描画用、PremultipliedAlphaの場合
export const fragmentShaderSrcMaskInvertedPremultipliedAlpha = export const fragmentShaderSrcMaskInvertedPremultipliedAlpha =
'precision mediump float;' + 'precision mediump float;' +
'varying vec2 v_texCoord;' + 'varying vec2 v_texCoord;' +
'varying vec4 v_clipPos;' + 'varying vec4 v_clipPos;' +
@ -1893,10 +1837,10 @@ export namespace Live2DCubismFramework {
'gl_FragColor = col_formask;' + 'gl_FragColor = col_formask;' +
'}'; '}';
/** /**
* WebGL * WebGL
*/ */
export class CubismRenderer_WebGL extends CubismRenderer { export class CubismRenderer_WebGL extends CubismRenderer {
/** /**
* *
* *
@ -2248,12 +2192,31 @@ export namespace Live2DCubismFramework {
index: WebGLBuffer; index: WebGLBuffer;
}; // 頂点バッファデータ }; // 頂点バッファデータ
gl: WebGLRenderingContext; // webglコンテキスト gl: WebGLRenderingContext; // webglコンテキスト
} }
/** /**
* *
*/ */
CubismRenderer.staticRelease = (): void => { CubismRenderer.staticRelease = (): void => {
CubismRenderer_WebGL.doStaticRelease(); CubismRenderer_WebGL.doStaticRelease();
}; };
// Namespace definition for compatibility.
import * as $ from './cubismrenderer_webgl';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Live2DCubismFramework {
export const CubismClippingContext = $.CubismClippingContext;
export type CubismClippingContext = $.CubismClippingContext;
export const CubismClippingManager_WebGL = $.CubismClippingManager_WebGL;
export type CubismClippingManager_WebGL = $.CubismClippingManager_WebGL;
export const CubismRenderTextureResource = $.CubismRenderTextureResource;
export type CubismRenderTextureResource = $.CubismRenderTextureResource;
export const CubismRenderer_WebGL = $.CubismRenderer_WebGL;
export type CubismRenderer_WebGL = $.CubismRenderer_WebGL;
export const CubismShaderSet = $.CubismShaderSet;
export type CubismShaderSet = $.CubismShaderSet;
export const CubismShader_WebGL = $.CubismShader_WebGL;
export type CubismShader_WebGL = $.CubismShader_WebGL;
export const ShaderNames = $.ShaderNames;
export type ShaderNames = $.ShaderNames;
} }

View File

@ -7,12 +7,11 @@
import { CubismLogDebug } from '../utils/cubismdebug'; import { CubismLogDebug } from '../utils/cubismdebug';
export namespace Live2DCubismFramework { /**
/**
* Key-Value * Key-Value
* csmMap使 * csmMap使
*/ */
export class csmPair<_KeyT, _ValT> { export class csmPair<_KeyT, _ValT> {
/** /**
* *
* @param key Key * @param key Key
@ -26,12 +25,12 @@ export namespace Live2DCubismFramework {
public first: _KeyT; // keyとして用いる変数 public first: _KeyT; // keyとして用いる変数
public second: _ValT; // valueとして用いる変数 public second: _ValT; // valueとして用いる変数
} }
/** /**
* *
*/ */
export class csmMap<_KeyT, _ValT> { export class csmMap<_KeyT, _ValT> {
/** /**
* *
* @param size * @param size
@ -227,12 +226,12 @@ export namespace Live2DCubismFramework {
public _keyValues: csmPair<_KeyT, _ValT>[]; // key-valueペアの配列 public _keyValues: csmPair<_KeyT, _ValT>[]; // key-valueペアの配列
public _dummyValue: _ValT; // 空の値を返す為のダミー public _dummyValue: _ValT; // 空の値を返す為のダミー
public _size: number; // コンテナの要素数 public _size: number; // コンテナの要素数
} }
/** /**
* csmMap<T> * csmMap<T>
*/ */
export class iterator<_KeyT, _ValT> { export class iterator<_KeyT, _ValT> {
/** /**
* *
*/ */
@ -301,5 +300,16 @@ export namespace Live2DCubismFramework {
_index: number; // コンテナのインデックス値 _index: number; // コンテナのインデックス値
_map: csmMap<_KeyT, _ValT>; // コンテナ _map: csmMap<_KeyT, _ValT>; // コンテナ
} }
// Namespace definition for compatibility.
import * as $ from './csmmap';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Live2DCubismFramework {
export const csmMap = $.csmMap;
export type csmMap<K, V> = $.csmMap<K, V>;
export const csmPair = $.csmPair;
export type csmPair<K, V> = $.csmPair<K, V>;
export const iterator = $.iterator;
export type iterator<K, V> = $.iterator<K, V>;
} }

View File

@ -5,11 +5,10 @@
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/ */
export namespace Live2DCubismFramework { /**
/**
* float * float
*/ */
export class csmRect { export class csmRect {
/** /**
* *
* @param x X * @param x X
@ -79,5 +78,12 @@ export namespace Live2DCubismFramework {
public y: number; // 上端Y座標 public y: number; // 上端Y座標
public width: number; // 幅 public width: number; // 幅
public height: number; // 高さ public height: number; // 高さ
} }
// Namespace definition for compatibility.
import * as $ from './csmrectf';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Live2DCubismFramework {
export const csmRect = $.csmRect;
export type csmRect = $.csmRect;
} }

View File

@ -5,11 +5,10 @@
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/ */
export namespace Live2DCubismFramework { /**
/**
* *
*/ */
export class csmString { export class csmString {
/** /**
* *
* *
@ -97,5 +96,12 @@ export namespace Live2DCubismFramework {
} }
s: string; s: string;
} }
// Namespace definition for compatibility.
import * as $ from './csmstring';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Live2DCubismFramework {
export const csmString = $.csmString;
export type csmString = $.csmString;
} }

View File

@ -5,11 +5,10 @@
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/ */
export namespace Live2DCubismFramework { /**
/**
* *
*/ */
export class csmVector<T> { export class csmVector<T> {
/** /**
* *
* @param iniitalCapacity _capacity * sizeof(T) * @param iniitalCapacity _capacity * sizeof(T)
@ -263,9 +262,9 @@ export namespace Live2DCubismFramework {
_capacity: number; // コンテナのキャパシティ _capacity: number; // コンテナのキャパシティ
static readonly s_defaultSize = 10; // コンテナ初期化のデフォルトサイズ static readonly s_defaultSize = 10; // コンテナ初期化のデフォルトサイズ
} }
export class iterator<T> { export class iterator<T> {
/** /**
* *
*/ */
@ -340,5 +339,14 @@ export namespace Live2DCubismFramework {
_index: number; // コンテナのインデックス値 _index: number; // コンテナのインデックス値
_vector: csmVector<T>; // コンテナ _vector: csmVector<T>; // コンテナ
} }
// Namespace definition for compatibility.
import * as $ from './csmvector';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Live2DCubismFramework {
export const csmVector = $.csmVector;
export type csmVector<T> = $.csmVector<T>;
export const iterator = $.iterator;
export type iterator<T> = $.iterator<T>;
} }

View File

@ -5,21 +5,18 @@
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/ */
import {
Live2DCubismFramework as cubismframework,
LogLevel
} from '../live2dcubismframework';
import { import {
CSM_LOG_LEVEL, CSM_LOG_LEVEL,
CSM_LOG_LEVEL_VERBOSE,
CSM_LOG_LEVEL_DEBUG, CSM_LOG_LEVEL_DEBUG,
CSM_LOG_LEVEL_ERROR,
CSM_LOG_LEVEL_INFO, CSM_LOG_LEVEL_INFO,
CSM_LOG_LEVEL_WARNING, CSM_LOG_LEVEL_VERBOSE,
CSM_LOG_LEVEL_ERROR CSM_LOG_LEVEL_WARNING
} from '../cubismframeworkconfig'; } from '../cubismframeworkconfig';
import { CubismFramework, LogLevel } from '../live2dcubismframework';
export const CubismLogPrint = (level: LogLevel, fmt: string, args: any[]) => { export const CubismLogPrint = (level: LogLevel, fmt: string, args: any[]) => {
Live2DCubismFramework.CubismDebug.print(level, '[CSM]' + fmt, args); CubismDebug.print(level, '[CSM]' + fmt, args);
}; };
export const CubismLogPrintIn = (level: LogLevel, fmt: string, args: any[]) => { export const CubismLogPrintIn = (level: LogLevel, fmt: string, args: any[]) => {
@ -98,13 +95,11 @@ if (CSM_LOG_LEVEL <= CSM_LOG_LEVEL_VERBOSE) {
}; };
} }
//------------ LIVE2D NAMESPACE ------------ /**
export namespace Live2DCubismFramework {
/**
* *
* *
*/ */
export class CubismDebug { export class CubismDebug {
/** /**
* *
* CubismFramework.initialize() * CubismFramework.initialize()
@ -113,18 +108,14 @@ export namespace Live2DCubismFramework {
* @param format * @param format
* @param args * @param args
*/ */
public static print( public static print(logLevel: LogLevel, format: string, args?: any[]): void {
logLevel: LogLevel,
format: string,
args?: any[]
): void {
// オプションで設定されたログ出力レベルを下回る場合はログに出さない // オプションで設定されたログ出力レベルを下回る場合はログに出さない
if (logLevel < cubismframework.CubismFramework.getLoggingLevel()) { if (logLevel < CubismFramework.getLoggingLevel()) {
return; return;
} }
const logPrint: Live2DCubismCore.csmLogFunction = const logPrint: Live2DCubismCore.csmLogFunction =
cubismframework.CubismFramework.coreLogFunction; CubismFramework.coreLogFunction;
if (!logPrint) return; if (!logPrint) return;
@ -160,7 +151,12 @@ export namespace Live2DCubismFramework {
* private * private
*/ */
private constructor() {} private constructor() {}
}
} }
//------------ LIVE2D NAMESPACE ------------ // Namespace definition for compatibility.
import * as $ from './cubismdebug';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Live2DCubismFramework {
export const CubismDebug = $.CubismDebug;
export type CubismDebug = $.CubismDebug;
}

View File

@ -5,26 +5,20 @@
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/ */
import { Live2DCubismFramework as csmstring } from '../type/csmstring';
import { Live2DCubismFramework as csmmap } from '../type/csmmap';
import { Live2DCubismFramework as csmvector } from '../type/csmvector';
import { CubismLogInfo } from './cubismdebug';
import { strtod } from '../live2dcubismframework'; import { strtod } from '../live2dcubismframework';
import csmVector = csmvector.csmVector; import { csmMap, iterator as csmMap_iterator } from '../type/csmmap';
import csmVector_iterator = csmvector.iterator; import { csmString } from '../type/csmstring';
import csmMap = csmmap.csmMap; import { csmVector, iterator as csmVector_iterator } from '../type/csmvector';
import csmMap_iterator = csmmap.iterator; import { CubismLogInfo } from './cubismdebug';
import csmString = csmstring.csmString;
export namespace Live2DCubismFramework { // StaticInitializeNotForClientCall()で初期化する
// StaticInitializeNotForClientCall()で初期化する const CSM_JSON_ERROR_TYPE_MISMATCH = 'Error: type mismatch';
const CSM_JSON_ERROR_TYPE_MISMATCH = 'Error: type mismatch'; const CSM_JSON_ERROR_INDEX_OF_BOUNDS = 'Error: index out of bounds';
const CSM_JSON_ERROR_INDEX_OF_BOUNDS = 'Error: index out of bounds';
/** /**
* JSON * JSON
*/ */
export abstract class Value { export abstract class Value {
/** /**
* *
*/ */
@ -228,9 +222,9 @@ export namespace Live2DCubismFramework {
public static errorValue: Value; // 一時的な返り値として返すエラー。 CubismFramework::Disposeするまではdeleteしない public static errorValue: Value; // 一時的な返り値として返すエラー。 CubismFramework::Disposeするまではdeleteしない
public static nullValue: Value; // 一時的な返り値として返すNULL。 CubismFramework::Disposeするまではdeleteしない public static nullValue: Value; // 一時的な返り値として返すNULL。 CubismFramework::Disposeするまではdeleteしない
} }
/** /**
* AsciiJSON * AsciiJSON
* JSON * JSON
* (model3.json) * (model3.json)
@ -239,7 +233,7 @@ export namespace Live2DCubismFramework {
* ASCII * ASCII
* e * e
*/ */
export class CubismJson { export class CubismJson {
/** /**
* *
*/ */
@ -624,12 +618,7 @@ export namespace Live2DCubismFramework {
} }
// 値をチェック // 値をチェック
const value: Value = this.parseValue( const value: Value = this.parseValue(buffer, length, i, localRetEndPos2);
buffer,
length,
i,
localRetEndPos2
);
if (this._error) { if (this._error) {
return null; return null;
} }
@ -685,12 +674,7 @@ export namespace Live2DCubismFramework {
// , が続く限りループ // , が続く限りループ
for (; i < length; i++) { for (; i < length; i++) {
// : をチェック // : をチェック
const value: Value = this.parseValue( const value: Value = this.parseValue(buffer, length, i, localRetEndpos2);
buffer,
length,
i,
localRetEndpos2
);
if (this._error) { if (this._error) {
return null; return null;
@ -731,12 +715,12 @@ export namespace Live2DCubismFramework {
_error: string; // パース時のエラー _error: string; // パース時のエラー
_lineCount: number; // エラー報告に用いる行数カウント _lineCount: number; // エラー報告に用いる行数カウント
_root: Value; // パースされたルート要素 _root: Value; // パースされたルート要素
} }
/** /**
* JSONfloat * JSONfloat
*/ */
export class JsonFloat extends Value { export class JsonFloat extends Value {
/** /**
* *
*/ */
@ -800,12 +784,12 @@ export namespace Live2DCubismFramework {
} }
private _value: number; // JSON要素の値 private _value: number; // JSON要素の値
} }
/** /**
* JSON * JSON
*/ */
export class JsonBoolean extends Value { export class JsonBoolean extends Value {
/** /**
* Valuetrue * Valuetrue
*/ */
@ -863,12 +847,12 @@ export namespace Live2DCubismFramework {
static falseValue: JsonBoolean; // false static falseValue: JsonBoolean; // false
private _boolValue: boolean; // JSON要素の値 private _boolValue: boolean; // JSON要素の値
} }
/** /**
* JSON * JSON
*/ */
export class JsonString extends Value { export class JsonString extends Value {
/** /**
* *
*/ */
@ -918,12 +902,12 @@ export namespace Live2DCubismFramework {
return false; return false;
} }
} }
/** /**
* JSON * JSON
*/ */
export class JsonError extends JsonString { export class JsonError extends JsonString {
/** /**
* Valuetrue * Valuetrue
*/ */
@ -959,12 +943,12 @@ export namespace Live2DCubismFramework {
} }
protected _isStatic: boolean; // 静的なValueかどうか protected _isStatic: boolean; // 静的なValueかどうか
} }
/** /**
* JSONNULL * JSONNULL
*/ */
export class JsonNullvalue extends Value { export class JsonNullvalue extends Value {
/** /**
* ValueNULLtrue * ValueNULLtrue
*/ */
@ -994,12 +978,12 @@ export namespace Live2DCubismFramework {
this._stringBuffer = 'NullValue'; this._stringBuffer = 'NullValue';
} }
} }
/** /**
* JSON * JSON
*/ */
export class JsonArray extends Value { export class JsonArray extends Value {
/** /**
* *
*/ */
@ -1104,12 +1088,12 @@ export namespace Live2DCubismFramework {
} }
private _array: csmVector<Value>; // JSON要素の値 private _array: csmVector<Value>; // JSON要素の値
} }
/** /**
* JSON * JSON
*/ */
export class JsonMap extends Value { export class JsonMap extends Value {
/** /**
* *
*/ */
@ -1242,5 +1226,28 @@ export namespace Live2DCubismFramework {
private _map: csmMap<string, Value>; // JSON要素の値 private _map: csmMap<string, Value>; // JSON要素の値
private _keys: csmVector<string>; // JSON要素の値 private _keys: csmVector<string>; // JSON要素の値
} }
// Namespace definition for compatibility.
import * as $ from './cubismjson';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Live2DCubismFramework {
export const CubismJson = $.CubismJson;
export type CubismJson = $.CubismJson;
export const JsonArray = $.JsonArray;
export type JsonArray = $.JsonArray;
export const JsonBoolean = $.JsonBoolean;
export type JsonBoolean = $.JsonBoolean;
export const JsonError = $.JsonError;
export type JsonError = $.JsonError;
export const JsonFloat = $.JsonFloat;
export type JsonFloat = $.JsonFloat;
export const JsonMap = $.JsonMap;
export type JsonMap = $.JsonMap;
export const JsonNullvalue = $.JsonNullvalue;
export type JsonNullvalue = $.JsonNullvalue;
export const JsonString = $.JsonString;
export type JsonString = $.JsonString;
export const Value = $.Value;
export type Value = $.Value;
} }

View File

@ -5,8 +5,7 @@
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/ */
export namespace Live2DCubismFramework { export class CubismString {
export class CubismString {
/** /**
* *
* @param format * @param format
@ -119,5 +118,12 @@ export namespace Live2DCubismFramework {
* *
*/ */
private constructor() {} private constructor() {}
} }
// Namespace definition for compatibility.
import * as $ from './cubismstring';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Live2DCubismFramework {
export const CubismString = $.CubismString;
export type CubismString = $.CubismString;
} }