From 4e14ef622de211092a4d096375024ac1b20c780a Mon Sep 17 00:00:00 2001 From: wada Date: Thu, 7 Jul 2022 11:30:03 +0900 Subject: [PATCH] Update to Cubism 4 SDK for Web R5 beta4 --- CHANGELOG.md | 10 ++++++++++ README.md | 7 +++---- src/model/cubismmoc.ts | 17 +++++++++++++++++ src/model/cubismmodel.ts | 21 +++++++++++++++++++++ 4 files changed, 51 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24eaccb..25fb8a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## [4-r.5-beta.4] - 2022-07-07 + +### Added + +* Add a function to get the latest .moc3 Version and the .moc3 Version of the loaded model. +* Add a function to get the type of parameters of the model. +* Add a function to get the parent part of the model's Drawable. + + ## [4-r.5-beta.3] - 2022-06-16 ### Fixed @@ -97,6 +106,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). * Reformat code using Prettier and ESLint. +[4-r.5-beta.4]: https://github.com/Live2D/CubismWebFramework/compare/4-r.5-beta.3...4-r.5-beta.4 [4-r.5-beta.3]: https://github.com/Live2D/CubismWebFramework/compare/4-r.5-beta.2...4-r.5-beta.3 [4-r.5-beta.2]: https://github.com/Live2D/CubismWebFramework/compare/4-r.5-beta.1...4-r.5-beta.2 [4-r.5-beta.1]: https://github.com/Live2D/CubismWebFramework/compare/4-r.4...4-r.5-beta.1 diff --git a/README.md b/README.md index 6ab0bdb..ff0fbfb 100644 --- a/README.md +++ b/README.md @@ -17,10 +17,9 @@ Live2D Cubism 4 Editor で出力したモデルをアプリケーションで利 ### Node.js -* 18.1.0 -* 17.9.0 -* 16.15.0 -* 14.19.2 +* 18.4.0 +* 16.15.1 +* 14.19.3 ### TypeScript diff --git a/src/model/cubismmoc.ts b/src/model/cubismmoc.ts index 212dc80..afe388a 100644 --- a/src/model/cubismmoc.ts +++ b/src/model/cubismmoc.ts @@ -24,6 +24,7 @@ export class CubismMoc { if (moc) { cubismMoc = new CubismMoc(moc); + cubismMoc._mocVersion = Live2DCubismCore.Version.csmGetMocVersion(moc); } return cubismMoc; @@ -79,6 +80,7 @@ export class CubismMoc { private constructor(moc: Live2DCubismCore.Moc) { this._moc = moc; this._modelCount = 0; + this._mocVersion = 0; } /** @@ -91,8 +93,23 @@ export class CubismMoc { this._moc = null; } + /** + * 最新の.moc3 Versionを取得 + */ + public getLatestMocVersion(): number { + return Live2DCubismCore.Version.csmGetLatestMocVersion(); + } + + /** + * 読み込んだモデルの.moc3 Versionを取得 + */ + public getMocVersion(): number { + return this._mocVersion; + } + _moc: Live2DCubismCore.Moc; // Mocデータ _modelCount: number; // Mocデータから作られたモデルの個数 + _mocVersion: number; // 読み込んだモデルの.moc3 Version } // Namespace definition for compatibility. diff --git a/src/model/cubismmodel.ts b/src/model/cubismmodel.ts index f03d280..46ea035 100644 --- a/src/model/cubismmodel.ts +++ b/src/model/cubismmodel.ts @@ -416,6 +416,18 @@ export class CubismModel { return this._model.parameters.count; } + /** + * パラメータの種類の取得 + * @param parameterIndex パラメータのインデックス + * @return csmParameterType_Normal -> 通常のパラメータ + * csmParameterType_BlendShape -> ブレンドシェイプパラメータ + */ + public getParameterType( + parameterIndex: number + ): Live2DCubismCore.csmParameterType { + return this._model.parameters.types[parameterIndex]; + } + /** * パラメータの最大値の取得 * @param parameterIndex パラメータのインデックス @@ -788,6 +800,15 @@ export class CubismModel { return screenColor; } + /** + * Drawableの親パーツのインデックスの取得 + * @param drawableIndex Drawableのインデックス + * @return drawableの親パーツのインデックス + */ + public getDrawableParentPartIndex(drawableIndex: number): number { + return this._model.drawables.parentPartIndices[drawableIndex]; + } + /** * Drawableのカリング情報の取得 * @param drawableIndex Drawableのインデックス