Merge pull request #12 from Live2D/feature/improve_performance

Improve performance.
translate
Takuya Ito 2018-10-25 18:27:47 +09:00 committed by GitHub
commit bc9f30a86b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
56 changed files with 1457 additions and 1497 deletions

5
.gitattributes vendored Normal file
View File

@ -0,0 +1,5 @@
*.ts text
*.js text
*.json text
*.html text
*.md text

4
.gitignore vendored
View File

@ -1,6 +1,4 @@
.idea/
node_modules/
/Core/*
!Please copy cubism core for web
Sample/TypeScript/Demo/dist/

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license
@ -11,6 +11,7 @@ import {Live2DCubismFramework as cubismid} from "./id/cubismid";
import {Live2DCubismFramework as cubismjson} from "./utils/cubismjson";
import {Live2DCubismFramework as csmmap} from"./type/csmmap";
import csmMap = csmmap.csmMap;
import iterator = csmmap.iterator;
import CubismFramework = cubismframework.CubismFramework;
import CubismIdHandle = cubismid.CubismIdHandle;
import CubismJson = cubismjson.CubismJson;
@ -396,7 +397,7 @@ export namespace Live2DCubismFramework
let ret: boolean = false;
for(const ite: csmMap.iterator<string, Value> = map.begin(); ite.notEqual(map.end()); ite.preIncrement())
for(const ite: iterator<string, Value> = map.begin(); ite.notEqual(map.end()); ite.preIncrement())
{
outLayoutMap.setValue(ite.ptr().first, ite.ptr().second.toFloat());
ret = true;

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license
@ -37,15 +37,17 @@ export namespace Live2DCubismFramework
*/
public static delete(instance: CubismBreath): void
{
instance = void 0;
instance = null;
if(instance != null)
{
instance = null;
}
}
/**
*
* @param breathParameters
*/
public setParameters(breathParameters: csmVector<CubismBreath.BreathParameterData>): void
public setParameters(breathParameters: csmVector<BreathParameterData>): void
{
this._breathParameters = breathParameters;
}
@ -54,7 +56,7 @@ export namespace Live2DCubismFramework
*
* @return
*/
public getParameters(): csmVector<CubismBreath.BreathParameterData>
public getParameters(): csmVector<BreathParameterData>
{
return this._breathParameters;
}
@ -72,7 +74,7 @@ export namespace Live2DCubismFramework
for(let i: number = 0; i < this._breathParameters.getSize(); ++i)
{
let data: CubismBreath.BreathParameterData = this._breathParameters.at(i);
let data: BreathParameterData = this._breathParameters.at(i);
model.addParameterValueById(
data.parameterId,
@ -91,50 +93,46 @@ export namespace Live2DCubismFramework
this._currentTime = 0.0;
}
_breathParameters: csmVector<CubismBreath.BreathParameterData>; // 呼吸にひもづいているパラメータのリスト
_breathParameters: csmVector<BreathParameterData>; // 呼吸にひもづいているパラメータのリスト
_currentTime: number; // 積算時間[秒]
}
export namespace CubismBreath
/**
*
*/
export class BreathParameterData
{
/**
*
*
* @param parameterId ID
* @param offset
* @param peak
* @param cycle
* @param weight
*/
export class BreathParameterData
constructor(parameterId?: CubismIdHandle, offset?: number, peak?: number, cycle?: number, weight?: number)
{
/**
*
* @param parameterId ID
* @param offset
* @param peak
* @param cycle
* @param weight
*/
constructor(parameterId?: CubismIdHandle, offset?: number, peak?: number, cycle?: number, weight?: number)
{
this.parameterId = (parameterId == undefined)
? null
: parameterId;
this.offset = (offset == undefined)
? 0.0
: offset;
this.peak = (peak == undefined)
? 0.0
: peak;
this.cycle = (cycle == undefined)
? 0.0
: cycle;
this.weight = (weight == undefined)
? 0.0
: weight;
}
parameterId: CubismIdHandle; // 呼吸をひもづけるパラメータID\
offset: number; // 呼吸を正弦波としたときの、波のオフセット
peak: number; // 呼吸を正弦波としたときの、波の高さ
cycle: number; // 呼吸を正弦波としたときの、波の周期
weight: number; // パラメータへの重み
this.parameterId = (parameterId == undefined)
? null
: parameterId;
this.offset = (offset == undefined)
? 0.0
: offset;
this.peak = (peak == undefined)
? 0.0
: peak;
this.cycle = (cycle == undefined)
? 0.0
: cycle;
this.weight = (weight == undefined)
? 0.0
: weight;
}
parameterId: CubismIdHandle; // 呼吸をひもづけるパラメータID\
offset: number; // 呼吸を正弦波としたときの、波のオフセット
peak: number; // 呼吸を正弦波としたときの、波の高さ
cycle: number; // 呼吸を正弦波としたときの、波の周期
weight: number; // パラメータへの重み
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license
@ -40,8 +40,10 @@ export namespace Live2DCubismFramework
*/
public static delete(eyeBlink: CubismEyeBlink): void
{
eyeBlink = void 0;
eyeBlink = null;
if(eyeBlink != null)
{
eyeBlink = null;
}
}
/**
@ -97,57 +99,57 @@ export namespace Live2DCubismFramework
switch(this._blinkingState)
{
case CubismEyeBlink.EyeState.EyeState_Closing:
case EyeState.EyeState_Closing:
t = ((this._userTimeSeconds - this._stateStartTimeSeconds) / this._closingSeconds);
if(t >= 1.0)
{
t = 1.0;
this._blinkingState = CubismEyeBlink.EyeState.EyeState_Closed;
this._blinkingState = EyeState.EyeState_Closed;
this._stateStartTimeSeconds = this._userTimeSeconds;
}
parameterValue = 1.0 - t;
break;
case CubismEyeBlink.EyeState.EyeState_Closed:
case EyeState.EyeState_Closed:
t = ((this._userTimeSeconds - this._stateStartTimeSeconds) / this._closedSeconds);
if(t >= 1.0)
{
this._blinkingState = CubismEyeBlink.EyeState.EyeState_Opening;
this._blinkingState = EyeState.EyeState_Opening;
this._stateStartTimeSeconds = this._userTimeSeconds;
}
parameterValue = 0.0;
break;
case CubismEyeBlink.EyeState.EyeState_Opening:
case EyeState.EyeState_Opening:
t = ((this._userTimeSeconds - this._stateStartTimeSeconds) / this._openingSeconds);
if(t >= 1.0)
{
t = 1.0;
this._blinkingState = CubismEyeBlink.EyeState.EyeState_Interval;
this._blinkingState = EyeState.EyeState_Interval;
this._nextBlinkingTime = this.determinNextBlinkingTiming();
}
parameterValue = t;
break;
case CubismEyeBlink.EyeState.EyeState_Interval:
case EyeState.EyeState_Interval:
if(this._nextBlinkingTime < this._userTimeSeconds)
{
this._blinkingState = CubismEyeBlink.EyeState.EyeState_Closing;
this._blinkingState = EyeState.EyeState_Closing;
this._stateStartTimeSeconds = this._userTimeSeconds;
}
parameterValue = 1.0;
break;
case CubismEyeBlink.EyeState.EyeState_First:
case EyeState.EyeState_First:
default:
this._blinkingState = CubismEyeBlink.EyeState.EyeState_Interval;
this._blinkingState = EyeState.EyeState_Interval;
this._nextBlinkingTime = this.determinNextBlinkingTiming();
parameterValue = 1.0;
@ -171,7 +173,7 @@ export namespace Live2DCubismFramework
*/
public constructor(modelSetting: ICubismModelSetting)
{
this._blinkingState = CubismEyeBlink.EyeState.EyeState_First;
this._blinkingState = EyeState.EyeState_First;
this._nextBlinkingTime = 0.0;
this._stateStartTimeSeconds = 0.0;
this._blinkingIntervalSeconds = 4.0;
@ -212,27 +214,24 @@ export namespace Live2DCubismFramework
_closedSeconds: number; // まぶたを閉じている動作の所要時間[秒]
_openingSeconds: number; // まぶたを開く動作の所要時間[秒]
_userTimeSeconds: number; // デルタ時間の積算値[秒]
}
export namespace CubismEyeBlink
{
/**
*
*
*
*/
export enum EyeState
{
EyeState_First = 0, // 初期状態
EyeState_Interval, // まばたきしていない状態
EyeState_Closing, // まぶたが閉じていく途中の状態
EyeState_Closed, // まぶたが閉じている状態
EyeState_Opening // まぶたが開いていく途中の状態
}
/**
* ID0 true 1 false
*/
export const CloseIfZero = true;
static readonly CloseIfZero: boolean = true;
}
/**
*
*
*
*/
export enum EyeState
{
EyeState_First = 0, // 初期状態
EyeState_Interval, // まばたきしていない状態
EyeState_Closing, // まぶたが閉じていく途中の状態
EyeState_Closed, // まぶたが閉じている状態
EyeState_Opening // まぶたが開いていく途中の状態
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license
@ -12,6 +12,7 @@ import {Live2DCubismFramework as cubismframework} from "../live2dcubismframework
import {Live2DCubismFramework as cubismjson} 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;
@ -73,7 +74,7 @@ export namespace Live2DCubismFramework
for(let groupIndex: number = 0; groupIndex < idCount; ++groupIndex)
{
let partInfo: Value = idListInfo.getVector().at(groupIndex);
let partData: CubismPose.PartData = new CubismPose.PartData();
let partData: PartData = new PartData();
const parameterId: CubismIdHandle = CubismFramework.getIdManager().getId(partInfo.getMap().getValue(Id).getRawString());
partData.partId = parameterId;
@ -86,7 +87,7 @@ export namespace Live2DCubismFramework
for(let linkIndex: number = 0; linkIndex < linkCount; ++linkIndex)
{
let linkPart: CubismPose.PartData = new CubismPose.PartData();
let linkPart: PartData = new PartData();
const linkId: CubismIdHandle = CubismFramework.getIdManager().getId(linkListInfo.getVector().at(linkIndex).getString());
linkPart.partId = linkId;
@ -114,8 +115,10 @@ export namespace Live2DCubismFramework
*/
public static delete(pose: CubismPose): void
{
pose = void 0;
pose = null;
if(pose != null)
{
pose = null;
}
}
/**
@ -201,7 +204,7 @@ export namespace Live2DCubismFramework
{
for(let groupIndex: number = 0; groupIndex < this._partGroups.getSize(); ++groupIndex)
{
let partData: CubismPose.PartData = this._partGroups.at(groupIndex);
let partData: PartData = this._partGroups.at(groupIndex);
if(partData.link.getSize() == 0)
{
@ -213,7 +216,7 @@ export namespace Live2DCubismFramework
for(let linkIndex: number = 0; linkIndex < partData.link.getSize(); ++linkIndex)
{
let linkPart: CubismPose.PartData = partData.link.at(linkIndex);
let linkPart: PartData = partData.link.at(linkIndex);
const linkPartIndex: number = linkPart.partIndex;
if(linkPartIndex < 0)
@ -323,94 +326,91 @@ export namespace Live2DCubismFramework
{
this._fadeTimeSeconds = DefaultFadeInSeconds;
this._lastModel = null;
this._partGroups = new csmVector<CubismPose.PartData>();
this._partGroups = new csmVector<PartData>();
this._partGroupCounts = new csmVector<number>();
}
_partGroups: csmVector<CubismPose.PartData>; // パーツグループ
_partGroups: csmVector<PartData>; // パーツグループ
_partGroupCounts: csmVector<number>; // それぞれのパーツグループの個数
_fadeTimeSeconds: number; // フェード時間[秒]
_lastModel: CubismModel; // 前回操作したモデル
}
export namespace CubismPose
/**
*
*/
export class PartData
{
/**
*
*
*/
export class PartData
constructor(v?: PartData)
{
/**
*
*/
constructor(v?: PartData)
{
this.parameterIndex = 0;
this.partIndex = 0;
this.link = new csmVector<PartData>();
if(v != undefined)
{
this.partId = v.partId;
for(const ite: csmVector.iterator<PartData> = v.link.begin(); ite.notEqual(v.link.end()); ite.preIncrement())
{
this.link.pushBack(ite.ptr().clone());
}
}
}
/**
* =
*/
public assignment(v: PartData): PartData
this.parameterIndex = 0;
this.partIndex = 0;
this.link = new csmVector<PartData>();
if(v != undefined)
{
this.partId = v.partId;
for(const ite: csmVector.iterator<PartData> = v.link.begin(); ite.notEqual(v.link.end()); ite.preIncrement())
for(const ite: iterator<PartData> = v.link.begin(); ite.notEqual(v.link.end()); ite.preIncrement())
{
this.link.pushBack(ite.ptr().clone());
}
return this;
}
/**
*
* @param model 使
*/
public initialize(model: CubismModel): void
{
this.parameterIndex = model.getParameterIndex(this.partId);
this.partIndex = model.getPartIndex(this.partId);
model.setParameterValueByIndex(this.parameterIndex, 1);
}
/**
*
*/
public clone(): PartData
{
let clonePartData: PartData = new PartData();
clonePartData.partId = this.partId;
clonePartData.parameterIndex = this.parameterIndex;
clonePartData.partIndex = this.partIndex;
clonePartData.link = new csmVector<PartData>();
for(let ite: csmVector.iterator<PartData> = this.link.begin(); ite.notEqual(this.link.end()); ite.increment())
{
clonePartData.link.pushBack(ite.ptr().clone());
}
return clonePartData;
}
partId: CubismIdHandle; // パーツID
parameterIndex: number; // パラメータのインデックス
partIndex: number; // パーツのインデックス
link: csmVector<PartData>; // 連動するパラメータ
}
/**
* =
*/
public assignment(v: PartData): PartData
{
this.partId = v.partId;
for(const ite: iterator<PartData> = v.link.begin(); ite.notEqual(v.link.end()); ite.preIncrement())
{
this.link.pushBack(ite.ptr().clone());
}
return this;
}
/**
*
* @param model 使
*/
public initialize(model: CubismModel): void
{
this.parameterIndex = model.getParameterIndex(this.partId);
this.partIndex = model.getPartIndex(this.partId);
model.setParameterValueByIndex(this.parameterIndex, 1);
}
/**
*
*/
public clone(): PartData
{
let clonePartData: PartData = new PartData();
clonePartData.partId = this.partId;
clonePartData.parameterIndex = this.parameterIndex;
clonePartData.partIndex = this.partIndex;
clonePartData.link = new csmVector<PartData>();
for(let ite: iterator<PartData> = this.link.begin(); ite.notEqual(this.link.end()); ite.increment())
{
clonePartData.link.pushBack(ite.ptr().clone());
}
return clonePartData;
}
partId: CubismIdHandle; // パーツID
parameterIndex: number; // パラメータのインデックス
partIndex: number; // パーツのインデックス
link: csmVector<PartData>; // 連動するパラメータ
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license

View File

@ -1,283 +1,280 @@
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license
* that can be found at http://live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/
import {Live2DCubismFramework as cubismjson} from "./utils/cubismjson";
import {Live2DCubismFramework as cubismidmanager} from "./id/cubismidmanager";
import {Live2DCubismFramework as cubismrenderer} from "./rendering/cubismrenderer";
import {CubismLogInfo, CubismLogWarning, CSM_ASSERT} from "./utils/cubismdebug";
import Value = cubismjson.Value;
import CubismIdManager = cubismidmanager.CubismIdManager;
import CubismRenderer = cubismrenderer.CubismRenderer;
export function strtod(s: string, endPtr: string[]): number
{
let index: number = 0;
for(let i: number = 1; ; i++)
{
let testC: string = s.slice(i - 1, i);
// 指数・マイナスの可能性があるのでスキップする
if(testC=='e' || testC=='-' || testC == 'E')
{
continue;
}
    // 文字列の範囲を広げていく
let test: string = s.substring(0, i);
let number: number = Number(test);
if(isNaN(number))
{
     // 数値として認識できなくなったので終了
break;
}
    // 最後に数値としてできたindexを格納しておく
index = i;
}
let d = parseFloat(s); // パースした数値
if(isNaN(d))
{
     // 数値として認識できなくなったので終了
d = NaN;
}
endPtr[0] = s.slice(index); // 後続の文字列
return d;
}
export namespace Live2DCubismFramework
{
// ファイルスコープの変数を初期化
let s_isStarted: boolean = false;
let s_isInitialized: boolean = false;
let s_option: Option = null;
let s_cubismIdManager: CubismIdManager = null;
/**
* Framework使
*/
export namespace Constant
{
export const vertexOffset: number = 0; // メッシュ頂点のオフセット値
export const vertexStep: number = 2; // メッシュ頂点のステップ値
}
export function csmDelete<T>(address: T): void
{
if(!address)
{
return;
}
address = void 0;
}
/**
* Live2D Cubism3 Original Workflow SDK
* CubismFramework.initialize()CubismFramework.dispose()
*/
export class CubismFramework
{
/**
* @brief Cubism FrameworkAPI使<br>
* API<br>
* <br>
*
*
* @param allocator ICubismAllocator
* @param option Option
*
* @return true
*/
public static startUp(option: Option = null): boolean
{
if(s_isStarted)
{
CubismLogInfo("CubismFramework::StartUp() is already done.");
return s_isStarted;
}
s_option = option;
if(s_option != null)
{
// TODO Core::csmSetLogFunction(s_option->LogFunction);
}
s_isStarted = true;
// Live2D Cubism Coreバージョン情報を表示
if(s_isStarted)
{
const version: number = 1; // TODO Core::csmGetVersion()
const major: number = ((version & 0xFF000000) >> 24);
const minor: number = ((version & 0x00FF0000) >> 16);
const patch: number = ((version & 0x0000FFFF));
const versionNumber: number = version;
CubismLogInfo("Live2D Cubism Core version: %02d.%02d.%04d (%d)", major, minor, patch, versionNumber);
}
CubismLogInfo("CubismFramework::StartUp() is complete.");
return s_isStarted;
}
/**
* StartUp()CubismFramework
* Dispose()CubismFramework
*/
public static cleanUp(): void
{
s_isStarted = false;
s_isInitialized = false;
s_option = null;
s_cubismIdManager = null;
}
/**
* Cubism Framework<br>
* Initialize()Dispose()
*/
public static initialize(): void
{
CSM_ASSERT(s_isStarted);
if(!s_isStarted)
{
CubismLogWarning("CubismFramework is not started.");
return;
}
// --- s_isInitializedによる連続初期化ガード ---
// 連続してリソース確保が行われないようにする。
// 再度Initialize()するには先にDispose()を実行する必要がある。
if (s_isInitialized)
{
CubismLogWarning("CubismFramework::Initialize() skipped, already initialized.");
return;
}
//---- static 初期化 ----
Value.staticInitializeNotForClientCall();
s_cubismIdManager = new CubismIdManager();
s_isInitialized = true;
CubismLogInfo("CubismFramework::Initialize() is complete.");
}
/**
* Cubism Framework
*
*
*/
public static dispose(): void
{
CSM_ASSERT(s_isStarted);
if(!s_isStarted)
{
CubismLogWarning("CubismFramework is not started.");
return;
}
// --- s_isInitializedによる未初期化解放ガード ---
// dispose()するには先にinitialize()を実行する必要がある。
if(!s_isInitialized) // false...リソース未確保の場合
{
CubismLogWarning("CubismFramework::Dispose() skipped, not initialized.");
return;
}
Value.staticReleaseNotForClientCall();
s_cubismIdManager.release();
s_cubismIdManager = void 0;
// レンダラの静的リソース(シェーダプログラム他)を解放する
CubismRenderer.StaticRelease();
s_isInitialized = false;
CubismLogInfo("CubismFramework::Dispose() is complete.");
}
/**
*
*
* @return
*/
public static getLoggingLevel(): Option.LogLevel
{
if (s_option != null)
{
return s_option.loggingLevel;
}
return Option.LogLevel.LogLevel_Off;
}
/**
* Cubism FrameworkAPI使
* @return API使true
*/
public static isStarted(): boolean
{
return s_isStarted;
}
/**
* Cubism Framework
* @return true
*/
public static isInitialized(): boolean
{
return s_isInitialized;
}
/**
* ID
* @return CubismManager
*/
public static getIdManager(): CubismIdManager
{
return s_cubismIdManager;
}
/**
* 使
*
*/
private constructor()
{
}
}
}
export class Option
{
loggingLevel: Option.LogLevel; // ログ出力レベルの設定
}
/**
*
*/
export namespace Option
{
export enum LogLevel
{
LogLevel_Verbose = 0, // 詳細ログ
LogLevel_Debug, // デバッグログ
LogLevel_Info, // Infoログ
LogLevel_Warning, // 警告ログ
LogLevel_Error, // エラーログ
LogLevel_Off // ログ出力無効
}
}
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license
* that can be found at http://live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/
import {Live2DCubismFramework as cubismjson} from "./utils/cubismjson";
import {Live2DCubismFramework as cubismidmanager} from "./id/cubismidmanager";
import {Live2DCubismFramework as cubismrenderer} from "./rendering/cubismrenderer";
import {CubismLogInfo, CubismLogWarning, CSM_ASSERT} from "./utils/cubismdebug";
import Value = cubismjson.Value;
import CubismIdManager = cubismidmanager.CubismIdManager;
import CubismRenderer = cubismrenderer.CubismRenderer;
export function strtod(s: string, endPtr: string[]): number
{
let index: number = 0;
for(let i: number = 1; ; i++)
{
let testC: string = s.slice(i - 1, i);
// 指数・マイナスの可能性があるのでスキップする
if(testC=='e' || testC=='-' || testC == 'E')
{
continue;
}
    // 文字列の範囲を広げていく
let test: string = s.substring(0, i);
let number: number = Number(test);
if(isNaN(number))
{
     // 数値として認識できなくなったので終了
break;
}
    // 最後に数値としてできたindexを格納しておく
index = i;
}
let d = parseFloat(s); // パースした数値
if(isNaN(d))
{
     // 数値として認識できなくなったので終了
d = NaN;
}
endPtr[0] = s.slice(index); // 後続の文字列
return d;
}
export namespace Live2DCubismFramework
{
// ファイルスコープの変数を初期化
let s_isStarted: boolean = false;
let s_isInitialized: boolean = false;
let s_option: Option = null;
let s_cubismIdManager: CubismIdManager = null;
/**
* Framework使
*/
export namespace Constant
{
export const vertexOffset: number = 0; // メッシュ頂点のオフセット値
export const vertexStep: number = 2; // メッシュ頂点のステップ値
}
export function csmDelete<T>(address: T): void
{
if(!address)
{
return;
}
address = void 0;
}
/**
* Live2D Cubism3 Original Workflow SDK
* CubismFramework.initialize()CubismFramework.dispose()
*/
export class CubismFramework
{
/**
* @brief Cubism FrameworkAPI使<br>
* API<br>
* <br>
*
*
* @param allocator ICubismAllocator
* @param option Option
*
* @return true
*/
public static startUp(option: Option = null): boolean
{
if(s_isStarted)
{
CubismLogInfo("CubismFramework::StartUp() is already done.");
return s_isStarted;
}
s_option = option;
if(s_option != null)
{
// TODO Core::csmSetLogFunction(s_option->LogFunction);
}
s_isStarted = true;
// Live2D Cubism Coreバージョン情報を表示
if(s_isStarted)
{
const version: number = 1; // TODO Core::csmGetVersion()
const major: number = ((version & 0xFF000000) >> 24);
const minor: number = ((version & 0x00FF0000) >> 16);
const patch: number = ((version & 0x0000FFFF));
const versionNumber: number = version;
CubismLogInfo("Live2D Cubism Core version: %02d.%02d.%04d (%d)", major, minor, patch, versionNumber);
}
CubismLogInfo("CubismFramework::StartUp() is complete.");
return s_isStarted;
}
/**
* StartUp()CubismFramework
* Dispose()CubismFramework
*/
public static cleanUp(): void
{
s_isStarted = false;
s_isInitialized = false;
s_option = null;
s_cubismIdManager = null;
}
/**
* Cubism Framework<br>
* Initialize()Dispose()
*/
public static initialize(): void
{
CSM_ASSERT(s_isStarted);
if(!s_isStarted)
{
CubismLogWarning("CubismFramework is not started.");
return;
}
// --- s_isInitializedによる連続初期化ガード ---
// 連続してリソース確保が行われないようにする。
// 再度Initialize()するには先にDispose()を実行する必要がある。
if (s_isInitialized)
{
CubismLogWarning("CubismFramework::Initialize() skipped, already initialized.");
return;
}
//---- static 初期化 ----
Value.staticInitializeNotForClientCall();
s_cubismIdManager = new CubismIdManager();
s_isInitialized = true;
CubismLogInfo("CubismFramework::Initialize() is complete.");
}
/**
* Cubism Framework
*
*
*/
public static dispose(): void
{
CSM_ASSERT(s_isStarted);
if(!s_isStarted)
{
CubismLogWarning("CubismFramework is not started.");
return;
}
// --- s_isInitializedによる未初期化解放ガード ---
// dispose()するには先にinitialize()を実行する必要がある。
if(!s_isInitialized) // false...リソース未確保の場合
{
CubismLogWarning("CubismFramework::Dispose() skipped, not initialized.");
return;
}
Value.staticReleaseNotForClientCall();
s_cubismIdManager.release();
s_cubismIdManager = void 0;
// レンダラの静的リソース(シェーダプログラム他)を解放する
CubismRenderer.StaticRelease();
s_isInitialized = false;
CubismLogInfo("CubismFramework::Dispose() is complete.");
}
/**
*
*
* @return
*/
public static getLoggingLevel(): LogLevel
{
if (s_option != null)
{
return s_option.loggingLevel;
}
return LogLevel.LogLevel_Off;
}
/**
* Cubism FrameworkAPI使
* @return API使true
*/
public static isStarted(): boolean
{
return s_isStarted;
}
/**
* Cubism Framework
* @return true
*/
public static isInitialized(): boolean
{
return s_isInitialized;
}
/**
* ID
* @return CubismManager
*/
public static getIdManager(): CubismIdManager
{
return s_cubismIdManager;
}
/**
* 使
*
*/
private constructor()
{
}
}
}
export class Option
{
loggingLevel: LogLevel; // ログ出力レベルの設定
}
/**
*
*/
export enum LogLevel
{
LogLevel_Verbose = 0, // 詳細ログ
LogLevel_Debug, // デバッグログ
LogLevel_Info, // Infoログ
LogLevel_Warning, // 警告ログ
LogLevel_Error, // エラーログ
LogLevel_Off // ログ出力無効
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license
@ -274,6 +274,21 @@ export namespace Live2DCubismFramework
CubismMatrix44.multiply(m.getArray(), this._tr, this._tr);
}
/**
*
*/
public clone(): CubismMatrix44
{
let cloneMatrix: CubismMatrix44 = new CubismMatrix44();
for(let i: number = 0; i < this._tr.length; i++)
{
cloneMatrix._tr[i] = this._tr[i];
}
return cloneMatrix;
}
protected _tr: Float32Array; // 4x4行列データ
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license
@ -8,6 +8,7 @@
import {Live2DCubismFramework as csmmap} from "../type/csmmap";
import {Live2DCubismFramework as cubismmatrix44} from "./cubismmatrix44";
import csmMap = csmmap.csmMap;
import iterator = csmmap.iterator;
import CubismMatrix44 = cubismmatrix44.CubismMatrix44;
@ -202,7 +203,7 @@ export namespace Live2DCubismFramework
const keyLeft = "left";
const keyRight = "right";
for(const ite: csmMap.iterator<string, number> = layout.begin(); ite.notEqual(layout.end()); ite.preIncrement())
for(const ite: iterator<string, number> = layout.begin(); ite.notEqual(layout.end()); ite.preIncrement())
{
const key: string = ite.ptr().first;
const value: number = ite.ptr().second;
@ -217,7 +218,7 @@ export namespace Live2DCubismFramework
}
}
for(const ite: csmMap.iterator<string, number> = layout.begin(); ite.notEqual(layout.end()); ite.preIncrement())
for(const ite: iterator<string, number> = layout.begin(); ite.notEqual(layout.end()); ite.preIncrement())
{
const key: string = ite.ptr().first;
const value: number = ite.ptr().second;

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license
@ -73,10 +73,12 @@ export namespace Live2DCubismFramework
*/
deleteModel(model: CubismModel): void
{
model.release();
model = void 0;
--this._modelCount;
if(model != null)
{
model.release();
model = null;
--this._modelCount;
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license
@ -13,7 +13,7 @@ import {Live2DCubismFramework as csmmap} from "../type/csmmap";
import {Live2DCubismFramework as csmvector} from "../type/csmvector";
import {CSM_ASSERT} from "../utils/cubismdebug";
import CubismFramework = cubismframework.CubismFramework;
import CubismRenderer = cubismrenderer.CubismRenderer;
import CubismBlendMode = cubismrenderer.CubismBlendMode;
import csmVector = csmvector.csmVector;
import csmMap = csmmap.csmMap;
import CubismIdHandle = cubismid.CubismIdHandle;
@ -579,15 +579,15 @@ export namespace Live2DCubismFramework
* @param drawableIndex Drawable
* @return drawable
*/
public getDrawableBlendMode(drawableIndex: number): CubismRenderer.CubismBlendMode
public getDrawableBlendMode(drawableIndex: number): CubismBlendMode
{
const constantFlags = this._model.drawables.constantFlags;
return (Live2DCubismCore.Utils.hasBlendAdditiveBit(constantFlags[drawableIndex]))
? CubismRenderer.CubismBlendMode.CubismBlendMode_Additive
? CubismBlendMode.CubismBlendMode_Additive
: (Live2DCubismCore.Utils.hasBlendMultiplicativeBit(constantFlags[drawableIndex]))
? CubismRenderer.CubismBlendMode.CubismBlendMode_Multiplicative
: CubismRenderer.CubismBlendMode.CubismBlendMode_Normal;
? CubismBlendMode.CubismBlendMode_Multiplicative
: CubismBlendMode.CubismBlendMode_Normal;
}
/**

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license
@ -62,9 +62,11 @@ export namespace Live2DCubismFramework
*/
public static delete(modelUserData: CubismModelUserData): void
{
modelUserData.release();
modelUserData = void 0;
modelUserData = null;
if(modelUserData != null)
{
modelUserData.release();
modelUserData = null;
}
}
/**
@ -127,7 +129,7 @@ export namespace Live2DCubismFramework
{
for(let i: number = 0; i < this._userDataNodes.getSize(); ++i)
{
this._userDataNodes.set(i, void 0);
this._userDataNodes.set(i, null);
}
this._userDataNodes = null;

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license
@ -319,9 +319,9 @@ export namespace Live2DCubismFramework
*/
public deleteRenderer(): void
{
if(this._renderer)
if(this._renderer != null)
{
this._renderer = void 0;
this._renderer.release();
this._renderer = null;
}
}
@ -406,33 +406,37 @@ export namespace Live2DCubismFramework
*/
public release()
{
this._motionManager.release();
this._motionManager = void 0;
this._motionManager = null;
if(this._motionManager != null)
{
this._motionManager.release();
this._motionManager = null;
}
this._expressionManager.release();
this._expressionManager = void 0;
this._expressionManager = null;
if(this._expressionManager != null)
{
this._expressionManager.release();
this._expressionManager = null;
}
this._moc.deleteModel(this._model);
this._moc.release();
this._moc = void 0;
this._moc = null;
if(this._moc != null)
{
this._moc.deleteModel(this._model);
this._moc.release();
this._moc = null;
}
this._modelMatrix = void 0;
this._modelMatrix = null;
CubismPose.delete(this._pose);
CubismEyeBlink.delete(this._eyeBlink);
CubismBreath.delete(this._breath);
this._dragManager = void 0;
this._dragManager = null;
CubismPhysics.delete(this._physics);
CubismModelUserData.delete(this._modelUserData);
this.deleteRenderer();
this.deleteRenderer();
}
protected _moc: CubismMoc; // Mocデータ

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license
@ -80,28 +80,28 @@ export namespace Live2DCubismFramework
const value: number = param.getMap().getValue(ExpressionKeyValue).toFloat(); // 値
// 計算方法の設定
let blendType: CubismExpressionMotion.ExpressionBlendType;
let blendType: ExpressionBlendType;
if(param.getMap().getValue(ExpressionKeyBlend).isNull() || param.getMap().getValue(ExpressionKeyBlend).getString() == BlendValueAdd)
{
blendType = this.ExpressionBlendType.ExpressionBlendType_Add;
blendType = ExpressionBlendType.ExpressionBlendType_Add;
}
else if(param.getMap().getValue(ExpressionKeyBlend).getString() == BlendValueMultiply)
{
blendType = this.ExpressionBlendType.ExpressionBlendType_Multiply;
blendType = ExpressionBlendType.ExpressionBlendType_Multiply;
}
else if(param.getMap().getValue(ExpressionKeyBlend).getString() == BlendValueOverwrite)
{
blendType = this.ExpressionBlendType.ExpressionBlendType_Overwrite;
blendType = ExpressionBlendType.ExpressionBlendType_Overwrite;
}
else
{
// その他 仕様にない値を設定した時は加算モードにすることで復旧
blendType = this.ExpressionBlendType.ExpressionBlendType_Add;
blendType = ExpressionBlendType.ExpressionBlendType_Add;
}
// 設定オブジェクトを作成してリストに追加する
let item: CubismExpressionMotion.ExpressionParameter = new CubismExpressionMotion.ExpressionParameter();
let item: ExpressionParameter = new ExpressionParameter();
item.parameterId = parameterId;
item.blendType = blendType;
@ -125,21 +125,21 @@ export namespace Live2DCubismFramework
{
for(let i: number = 0; i < this._parameters.getSize(); ++i)
{
let parameter: CubismExpressionMotion.ExpressionParameter = this._parameters.at(i);
let parameter: ExpressionParameter = this._parameters.at(i);
switch(parameter.blendType)
{
case CubismExpressionMotion.ExpressionBlendType.ExpressionBlendType_Add:
case ExpressionBlendType.ExpressionBlendType_Add:
{
model.addParameterValueById(parameter.parameterId, parameter.value, weight);
break;
}
case CubismExpressionMotion.ExpressionBlendType.ExpressionBlendType_Multiply:
case ExpressionBlendType.ExpressionBlendType_Multiply:
{
model.multiplyParameterValueById(parameter.parameterId, parameter.value, weight);
break;
}
case CubismExpressionMotion.ExpressionBlendType.ExpressionBlendType_Overwrite:
case ExpressionBlendType.ExpressionBlendType_Overwrite:
{
model.setParameterValueById(parameter.parameterId, parameter.value, weight)
break;
@ -158,32 +158,29 @@ export namespace Live2DCubismFramework
{
super();
this._parameters = new csmVector<CubismExpressionMotion.ExpressionParameter>();
this._parameters = new csmVector<ExpressionParameter>();
}
_parameters: csmVector<CubismExpressionMotion.ExpressionParameter>; // 表情のパラメータ情報リスト
_parameters: csmVector<ExpressionParameter>; // 表情のパラメータ情報リスト
}
export namespace CubismExpressionMotion
/**
*
*/
export enum ExpressionBlendType
{
/**
*
*/
export enum ExpressionBlendType
{
ExpressionBlendType_Add = 0, // 加算
ExpressionBlendType_Multiply = 1, // 乗算
ExpressionBlendType_Overwrite = 2 // 上書き
}
ExpressionBlendType_Add = 0, // 加算
ExpressionBlendType_Multiply = 1, // 乗算
ExpressionBlendType_Overwrite = 2 // 上書き
}
/**
*
*/
export class ExpressionParameter
{
parameterId: CubismIdHandle; // パラメータID
blendType: ExpressionBlendType; // パラメータの演算種類
value: number; // 値
}
}
/**
*
*/
export class ExpressionParameter
{
parameterId: CubismIdHandle; // パラメータID
blendType: ExpressionBlendType; // パラメータの演算種類
value: number; // 値
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license
@ -13,6 +13,7 @@ import {Live2DCubismFramework as 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;
@ -108,7 +109,7 @@ export namespace Live2DCubismFramework
// ------- 処理を行う -------
// 既にモーションがあれば終了フラグを立てる
for(let ite: csmVector.iterator<CubismMotionQueueEntry> = this._motions.begin(); ite.notEqual(this._motions.end());)
for(let ite: iterator<CubismMotionQueueEntry> = this._motions.begin(); ite.notEqual(this._motions.end());)
{
let motionQueueEntry: CubismMotionQueueEntry = ite.ptr();
@ -152,7 +153,7 @@ export namespace Live2DCubismFramework
public isFinishedByHandle(motionQueueEntryNumber: CubismMotionQueueEntryHandle): boolean
{
// 既にモーションがあれば終了フラグを立てる
for(let ite: csmVector.iterator<CubismMotionQueueEntry> = this._motions.begin(); ite.notEqual(this._motions.end());ite.increment())
for(let ite: iterator<CubismMotionQueueEntry> = this._motions.begin(); ite.notEqual(this._motions.end());ite.increment())
{
let motionQueueEntry: CubismMotionQueueEntry = ite.ptr();
@ -177,7 +178,7 @@ export namespace Live2DCubismFramework
// ------- 処理を行う -------
// 既にモーションがあれば終了フラグを立てる
for(let ite: csmVector.iterator<CubismMotionQueueEntry> = this._motions.begin(); ite.notEqual(this._motions.end());)
for(let ite: iterator<CubismMotionQueueEntry> = this._motions.begin(); ite.notEqual(this._motions.end());)
{
let motionQueueEntry: CubismMotionQueueEntry = ite.ptr();
@ -207,7 +208,7 @@ export namespace Live2DCubismFramework
{
//------- 処理を行う -------
// 既にモーションがあれば終了フラグを立てる
for(let ite: csmVector.iterator<CubismMotionQueueEntry> = this._motions.begin(); ite.notEqual(this._motions.end()); ite.preIncrement())
for(let ite: iterator<CubismMotionQueueEntry> = this._motions.begin(); ite.notEqual(this._motions.end()); ite.preIncrement())
{
let motionQueueEntry: CubismMotionQueueEntry = ite.ptr();
@ -252,7 +253,7 @@ export namespace Live2DCubismFramework
// ------- 処理を行う --------
// 既にモーションがあれば終了フラグを立てる
for(let ite: csmVector.iterator<CubismMotionQueueEntry> = this._motions.begin(); ite.notEqual(this._motions.end());)
for(let ite: iterator<CubismMotionQueueEntry> = this._motions.begin(); ite.notEqual(this._motions.end());)
{
let motionQueueEntry: CubismMotionQueueEntry = ite.ptr();

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license
@ -67,9 +67,11 @@ export namespace Live2DCubismFramework
*/
public static delete(physics: CubismPhysics): void
{
physics.release();
physics = void 0;
physics = null;
if(physics != null)
{
physics.release();
physics = null;
}
}
/**
@ -201,7 +203,7 @@ export namespace Live2DCubismFramework
*
* @param options
*/
public setOptions(options: CubismPhysics.Options): void
public setOptions(options: Options): void
{
this._options = options;
}
@ -210,7 +212,7 @@ export namespace Live2DCubismFramework
*
* @return
*/
public getOption(): CubismPhysics.Options
public getOption(): Options
{
return this._options;
}
@ -223,7 +225,7 @@ export namespace Live2DCubismFramework
this._physicsRig = null;
// set default options
this._options = new CubismPhysics.Options();
this._options = new Options();
this._options.gravity.y = -1.0;
this._options.gravity.x = 0;
this._options.wind.x = 0;
@ -401,26 +403,22 @@ export namespace Live2DCubismFramework
}
_physicsRig: CubismPhysicsRig; // 物理演算のデータ
_options: CubismPhysics.Options; // オプション
_options: Options; // オプション
}
export namespace CubismPhysics
/**
*
*/
export class Options
{
/**
*
*/
export class Options
constructor()
{
constructor()
{
this.gravity = new CubismVector2(0, 0);
this.wind = new CubismVector2(0, 0);
}
gravity: CubismVector2; // 重力方向
wind: CubismVector2; // 風の方向
this.gravity = new CubismVector2(0, 0);
this.wind = new CubismVector2(0, 0);
}
gravity: CubismVector2; // 重力方向
wind: CubismVector2; // 風の方向
}
/**

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license
@ -62,17 +62,8 @@ export namespace Live2DCubismFramework
public drawModel(): void
{
if(this.getModel() == null) return;
/**
* doDrawModel
* saveProfile();
* restoreProfile();
*
*
*/
this.saveProfile();
this.doDrawModel();
this.restoreProfile();
}
/**
@ -152,7 +143,7 @@ export namespace Live2DCubismFramework
*
* @return RGBA
*/
public getModelColor(): CubismRenderer.CubismTextureColor
public getModelColor(): CubismTextureColor
{
return JSON.parse(JSON.stringify(this._modelColor));
}
@ -232,7 +223,7 @@ export namespace Live2DCubismFramework
this._isPremultipliedAlpha = false;
this._anisortopy = 0.0;
this._model = null;
this._modelColor = new CubismRenderer.CubismTextureColor();
this._modelColor = new CubismTextureColor();
// 単位行列に初期化
this._mvpMatrix4x4 = new CubismMatrix44();
@ -258,55 +249,42 @@ export namespace Live2DCubismFramework
*/
public abstract drawMesh(textureNo: number, indexCount: number, vertexCount: number,
indexArray: Uint16Array, vertexArray: Float32Array, uvArray: Float32Array,
opacity: number, colorBlendMode: CubismRenderer.CubismBlendMode): void;
/**
*
*/
public abstract saveProfile(): void;
/**
*
*/
public abstract restoreProfile(): void;
opacity: number, colorBlendMode: CubismBlendMode): void;
protected _mvpMatrix4x4: CubismMatrix44; // Model-View-Projection 行列
protected _modelColor: CubismRenderer.CubismTextureColor; // モデル自体のカラーRGBA
protected _modelColor: CubismTextureColor; // モデル自体のカラーRGBA
protected _isCulling: boolean; // カリングが有効ならtrue
protected _isPremultipliedAlpha: boolean; // 乗算済みαならtrue
protected _anisortopy: any; // テクスチャの異方性フィルタリングのパラメータ
protected _model: CubismModel; // レンダリング対象のモデル
}
export namespace CubismRenderer
export enum CubismBlendMode
{
export enum CubismBlendMode
{
CubismBlendMode_Normal = 0, // 通常
CubismBlendMode_Additive = 1, // 加算
CubismBlendMode_Multiplicative = 2, // 乗算
};
CubismBlendMode_Normal = 0, // 通常
CubismBlendMode_Additive = 1, // 加算
CubismBlendMode_Multiplicative = 2, // 乗算
};
/**
* RGBA
*/
export class CubismTextureColor
{
/**
* RGBA
*
*/
export class CubismTextureColor
constructor()
{
/**
*
*/
constructor()
{
this.R = 1.0;
this.G = 1.0;
this.B = 1.0;
this.A = 1.0;
}
R: number; // 赤チャンネル
G: number; // 緑チャンネル
B: number; // 青チャンネル
A: number; // αチャンネル
this.R = 1.0;
this.G = 1.0;
this.B = 1.0;
this.A = 1.0;
}
R: number; // 赤チャンネル
G: number; // 緑チャンネル
B: number; // 青チャンネル
A: number; // αチャンネル
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license
@ -212,18 +212,18 @@ export namespace Live2DCubismFramework
/**
*
*/
public begin(): csmMap.iterator<_KeyT, _ValT>
public begin(): iterator<_KeyT, _ValT>
{
let ite: csmMap.iterator<_KeyT, _ValT> = new csmMap.iterator<_KeyT, _ValT>(this, 0);
let ite: iterator<_KeyT, _ValT> = new iterator<_KeyT, _ValT>(this, 0);
return ite;
}
/**
*
*/
public end(): csmMap.iterator<_KeyT, _ValT>
public end(): iterator<_KeyT, _ValT>
{
let ite: csmMap.iterator<_KeyT, _ValT> = new csmMap.iterator<_KeyT, _ValT>(this, this._size); // 終了
let ite: iterator<_KeyT, _ValT> = new iterator<_KeyT, _ValT>(this, this._size); // 終了
return ite;
}
@ -232,7 +232,7 @@ export namespace Live2DCubismFramework
*
* @param ite
*/
public erase(ite: csmMap.iterator<_KeyT, _ValT>): csmMap.iterator<_KeyT, _ValT>
public erase(ite: iterator<_KeyT, _ValT>): iterator<_KeyT, _ValT>
{
let index: number = ite._index;
if(index < 0 || this._size <= index)
@ -244,7 +244,7 @@ export namespace Live2DCubismFramework
this._keyValues.splice(index, 1);
--this._size;
let ite2: csmMap.iterator<_KeyT, _ValT> = new csmMap.iterator<_KeyT, _ValT>(this, index); // 終了
let ite2: iterator<_KeyT, _ValT> = new iterator<_KeyT, _ValT>(this, index); // 終了
return ite2;
}
@ -266,95 +266,93 @@ export namespace Live2DCubismFramework
public _size: number; // コンテナの要素数
}
export namespace csmMap
/**
* csmMap<T>
*/
export class iterator<_KeyT, _ValT>
{
/**
* csmMap<T>
*
*/
export class iterator<_KeyT, _ValT>
constructor(v?: csmMap<_KeyT, _ValT>, idx?: number)
{
/**
*
*/
constructor(v?: csmMap<_KeyT, _ValT>, idx?: number)
{
this._map = (v != undefined)
? v
: new csmMap<_KeyT, _ValT>();
this._map = (v != undefined)
? v
: new csmMap<_KeyT, _ValT>();
this._index = (idx != undefined)
? idx
: 0;
}
/**
* =
*/
public set(ite: iterator<_KeyT, _ValT>): iterator<_KeyT, _ValT>
{
this._index = ite._index;
this._map = ite._map;
return this;
}
/**
* ++
*/
public preIncrement(): iterator<_KeyT, _ValT>
{
++this._index;
return this;
}
/**
* --
*/
public preDecrement(): iterator<_KeyT, _ValT>
{
--this._index;
return this;
}
/**
* ++
*/
public increment(): iterator<_KeyT, _ValT>
{
let iteold = new iterator<_KeyT, _ValT>(this._map, this._index++); // 古い値を保存
this._map = iteold._map;
this._index = iteold._index;
return this;
}
/**
* --
*/
public decrement(): iterator<_KeyT, _ValT>
{
let iteold = new iterator<_KeyT, _ValT>(this._map, this._index); // 古い値を保存
this._map = iteold._map;
this._index = iteold._index;
return this;
}
/**
* *
*/
public ptr(): csmPair<_KeyT, _ValT>
{
return this._map._keyValues[this._index];
}
/**
* !=
*/
public notEqual(ite: iterator<_KeyT, _ValT>): boolean
{
return (this._index != ite._index) || (this._map != ite._map);
}
_index: number; // コンテナのインデックス値
_map: csmMap<_KeyT, _ValT>; // コンテナ
this._index = (idx != undefined)
? idx
: 0;
}
/**
* =
*/
public set(ite: iterator<_KeyT, _ValT>): iterator<_KeyT, _ValT>
{
this._index = ite._index;
this._map = ite._map;
return this;
}
/**
* ++
*/
public preIncrement(): iterator<_KeyT, _ValT>
{
++this._index;
return this;
}
/**
* --
*/
public preDecrement(): iterator<_KeyT, _ValT>
{
--this._index;
return this;
}
/**
* ++
*/
public increment(): iterator<_KeyT, _ValT>
{
let iteold = new iterator<_KeyT, _ValT>(this._map, this._index++); // 古い値を保存
this._map = iteold._map;
this._index = iteold._index;
return this;
}
/**
* --
*/
public decrement(): iterator<_KeyT, _ValT>
{
let iteold = new iterator<_KeyT, _ValT>(this._map, this._index); // 古い値を保存
this._map = iteold._map;
this._index = iteold._index;
return this;
}
/**
* *
*/
public ptr(): csmPair<_KeyT, _ValT>
{
return this._map._keyValues[this._index];
}
/**
* !=
*/
public notEqual(ite: iterator<_KeyT, _ValT>): boolean
{
return (this._index != ite._index) || (this._map != ite._map);
}
_index: number; // コンテナのインデックス値
_map: csmMap<_KeyT, _ValT>; // コンテナ
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license
@ -175,7 +175,7 @@ export namespace Live2DCubismFramework
* @param begin 
* @param end
*/
public insert(position: csmVector.iterator<T>, begin: csmVector.iterator<T>, end: csmVector.iterator<T>): void
public insert(position: iterator<T>, begin: iterator<T>, end: iterator<T>): void
{
let dstSi: number = position._index;
let srcSi: number = begin._index;
@ -226,7 +226,7 @@ export namespace Live2DCubismFramework
*
* @param ite
*/
public erase(ite: csmVector.iterator<T>): csmVector.iterator<T>
public erase(ite: iterator<T>): iterator<T>
{
let index: number = ite._index;
if(index < 0 || this._size <= index)
@ -238,7 +238,7 @@ export namespace Live2DCubismFramework
this._ptr.splice(index, 1);
--this._size;
let ite2: csmVector.iterator<T> = new csmVector.iterator<T>(this, index); // 終了
let ite2: iterator<T> = new iterator<T>(this, index); // 終了
return ite2;
}
@ -266,20 +266,20 @@ export namespace Live2DCubismFramework
/**
*
*/
public begin(): csmVector.iterator<T>
public begin(): iterator<T>
{
let ite: csmVector.iterator<T> = (this._size == 0)
let ite: iterator<T> = (this._size == 0)
? this.end()
: new csmVector.iterator<T>(this, 0);
: new iterator<T>(this, 0);
return ite;
}
/**
*
*/
public end(): csmVector.iterator<T>
public end(): iterator<T>
{
let ite: csmVector.iterator<T> = new csmVector.iterator<T>(this, this._size);
let ite: iterator<T> = new iterator<T>(this, this._size);
return ite;
}
@ -300,97 +300,94 @@ export namespace Live2DCubismFramework
static readonly s_defaultSize = 10; // コンテナ初期化のデフォルトサイズ
}
export namespace csmVector
export class iterator<T>
{
export class iterator<T>
/**
*
*/
public constructor(v?: csmVector<T>, index?: number)
{
/**
*
*/
public constructor(v?: csmVector<T>, index?: number)
{
this._vector = (v != undefined) ? v : null;
this._index = (index != undefined) ? index : 0;
}
/**
*
*/
public set(ite: iterator<T>): iterator<T>
{
this._index = ite._index;
this._vector = ite._vector;
return this;
}
/**
* ++
*/
public preIncrement(): iterator<T>
{
++this._index;
return this;
}
/**
* --
*/
public preDecrement(): iterator<T>
{
--this._index;
return this;
}
/**
* ++
*/
public increment(): iterator<T>
{
let iteold = new iterator<T>(this._vector, this._index++);
this._vector = iteold._vector;
this._index = iteold._index;
return this;
}
/**
* --
*/
public decrement(): iterator<T>
{
let iteold = new iterator<T>(this._vector, this._index--); // 古い値を保存
this._vector = iteold._vector;
this._index = iteold._index;
return this;
}
/**
* ptr
*/
public ptr(): T
{
return this._vector._ptr[this._index];
}
/**
* =
*/
public substitution(ite: iterator<T>): iterator<T>
{
this._index = ite._index;
this._vector = ite._vector;
return this;
}
/**
* !=
*/
public notEqual(ite: iterator<T>): boolean
{
return (this._index != ite._index) || (this._vector != ite._vector);
}
_index: number; // コンテナのインデックス値
_vector: csmVector<T>; // コンテナ
this._vector = (v != undefined) ? v : null;
this._index = (index != undefined) ? index : 0;
}
/**
*
*/
public set(ite: iterator<T>): iterator<T>
{
this._index = ite._index;
this._vector = ite._vector;
return this;
}
/**
* ++
*/
public preIncrement(): iterator<T>
{
++this._index;
return this;
}
/**
* --
*/
public preDecrement(): iterator<T>
{
--this._index;
return this;
}
/**
* ++
*/
public increment(): iterator<T>
{
let iteold = new iterator<T>(this._vector, this._index++);
this._vector = iteold._vector;
this._index = iteold._index;
return this;
}
/**
* --
*/
public decrement(): iterator<T>
{
let iteold = new iterator<T>(this._vector, this._index--); // 古い値を保存
this._vector = iteold._vector;
this._index = iteold._index;
return this;
}
/**
* ptr
*/
public ptr(): T
{
return this._vector._ptr[this._index];
}
/**
* =
*/
public substitution(ite: iterator<T>): iterator<T>
{
this._index = ite._index;
this._vector = ite._vector;
return this;
}
/**
* !=
*/
public notEqual(ite: iterator<T>): boolean
{
return (this._index != ite._index) || (this._vector != ite._vector);
}
_index: number; // コンテナのインデックス値
_vector: csmVector<T>; // コンテナ
}
}

View File

@ -1,20 +1,20 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license
* that can be found at http://live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/
import {Live2DCubismFramework as live2dcubismframework, Option} from "../live2dcubismframework";
import {Live2DCubismFramework as live2dcubismframework, LogLevel} from "../live2dcubismframework";
import CubismFramework = live2dcubismframework.CubismFramework;
import { CSM_LOG_LEVEL, CSM_LOG_LEVEL_VERBOSE, CSM_LOG_LEVEL_DEBUG, CSM_LOG_LEVEL_INFO, CSM_LOG_LEVEL_WARNING, CSM_LOG_LEVEL_ERROR } from "../cubismframeworkconfig";
export const CubismLogPrint = (level: Option.LogLevel, fmt: string, ... args: any[]) =>
export const CubismLogPrint = (level: LogLevel, fmt: string, ... args: any[]) =>
{
Live2DCubismFramework.CubismDebug.print(level, "[CSM]" + fmt, args);
}
export const CubismLogPrintIn = (level: Option.LogLevel, fmt: string, ... args: any[]) =>
export const CubismLogPrintIn = (level: LogLevel, fmt: string, ... args: any[]) =>
{
CubismLogPrint(level, fmt + "\n", args);
}
@ -35,85 +35,85 @@ if(CSM_LOG_LEVEL <= CSM_LOG_LEVEL_VERBOSE)
{
CubismLogVerbose = (fmt: string, ... args: any[]) =>
{
CubismLogPrintIn(Option.LogLevel.LogLevel_Verbose, "[V]" + fmt, args);
CubismLogPrintIn(LogLevel.LogLevel_Verbose, "[V]" + fmt, args);
};
CubismLogDebug = (fmt: string, ... args: any[]) =>
{
CubismLogPrintIn(Option.LogLevel.LogLevel_Debug, "[D]" + fmt, args);
CubismLogPrintIn(LogLevel.LogLevel_Debug, "[D]" + fmt, args);
};
CubismLogInfo = (fmt: string, ... args: any[]) =>
{
CubismLogPrintIn(Option.LogLevel.LogLevel_Info, "[I]" + fmt, args);
CubismLogPrintIn(LogLevel.LogLevel_Info, "[I]" + fmt, args);
};
CubismLogWarning = (fmt: string, ... args: any[]) =>
{
CubismLogPrintIn(Option.LogLevel.LogLevel_Warning, "[W]" + fmt, args);
CubismLogPrintIn(LogLevel.LogLevel_Warning, "[W]" + fmt, args);
};
CubismLogError = (fmt: string, ... args: any[]) =>
{
CubismLogPrintIn(Option.LogLevel.LogLevel_Error, "[E]" + fmt, args);
CubismLogPrintIn(LogLevel.LogLevel_Error, "[E]" + fmt, args);
};
}
else if(CSM_LOG_LEVEL == CSM_LOG_LEVEL_DEBUG)
{
CubismLogDebug = (fmt: string, ... args: any[]) =>
{
CubismLogPrintIn(Option.LogLevel.LogLevel_Debug, "[D]" + fmt, args);
CubismLogPrintIn(LogLevel.LogLevel_Debug, "[D]" + fmt, args);
};
CubismLogInfo = (fmt: string, ... args: any[]) =>
{
CubismLogPrintIn(Option.LogLevel.LogLevel_Info, "[I]" + fmt, args);
CubismLogPrintIn(LogLevel.LogLevel_Info, "[I]" + fmt, args);
};
CubismLogWarning = (fmt: string, ... args: any[]) =>
{
CubismLogPrintIn(Option.LogLevel.LogLevel_Warning, "[W]" + fmt, args);
CubismLogPrintIn(LogLevel.LogLevel_Warning, "[W]" + fmt, args);
};
CubismLogError = (fmt: string, ... args: any[]) =>
{
CubismLogPrintIn(Option.LogLevel.LogLevel_Error, "[E]" + fmt, args);
CubismLogPrintIn(LogLevel.LogLevel_Error, "[E]" + fmt, args);
};
}
else if(CSM_LOG_LEVEL == CSM_LOG_LEVEL_INFO)
{
CubismLogInfo = (fmt: string, ... args: any[]) =>
{
CubismLogPrintIn(Option.LogLevel.LogLevel_Info, "[I]" + fmt, args);
CubismLogPrintIn(LogLevel.LogLevel_Info, "[I]" + fmt, args);
};
CubismLogWarning = (fmt: string, ... args: any[]) =>
{
CubismLogPrintIn(Option.LogLevel.LogLevel_Warning, "[W]" + fmt, args);
CubismLogPrintIn(LogLevel.LogLevel_Warning, "[W]" + fmt, args);
};
CubismLogError = (fmt: string, ... args: any[]) =>
{
CubismLogPrintIn(Option.LogLevel.LogLevel_Error, "[E]" + fmt, args);
CubismLogPrintIn(LogLevel.LogLevel_Error, "[E]" + fmt, args);
};
}
else if(CSM_LOG_LEVEL == CSM_LOG_LEVEL_WARNING)
{
CubismLogWarning = (fmt: string, ... args: any[]) =>
{
CubismLogPrintIn(Option.LogLevel.LogLevel_Warning, "[W]" + fmt, args);
CubismLogPrintIn(LogLevel.LogLevel_Warning, "[W]" + fmt, args);
};
CubismLogError = (fmt: string, ... args: any[]) =>
{
CubismLogPrintIn(Option.LogLevel.LogLevel_Error, "[E]" + fmt, args);
CubismLogPrintIn(LogLevel.LogLevel_Error, "[E]" + fmt, args);
};
}
else if(CSM_LOG_LEVEL == CSM_LOG_LEVEL_ERROR)
{
CubismLogError = (fmt: string, ... args: any[]) =>
{
CubismLogPrintIn(Option.LogLevel.LogLevel_Error, "[E]" + fmt, args);
CubismLogPrintIn(LogLevel.LogLevel_Error, "[E]" + fmt, args);
};
}
@ -135,7 +135,7 @@ export namespace Live2DCubismFramework
* @param format
* @param ... args
*/
public static print(logLevel: Option.LogLevel, format: string, ... args: any[]): void
public static print(logLevel: LogLevel, format: string, ... args: any[]): void
{
// オプションで設定されたログ出力レベルを下回る場合はログに出さない
// if(logLevel < CubismFramework.getLoggingLevel())
@ -169,7 +169,7 @@ export namespace Live2DCubismFramework
* @param data
* @param length
*/
public static dumpBytes(logLevel: Option.LogLevel, data: Uint8Array, length: number): void
public static dumpBytes(logLevel: LogLevel, data: Uint8Array, length: number): void
{
for (let i: number = 0; i < length; i++)
{

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license
@ -11,7 +11,9 @@ import {Live2DCubismFramework as csmvector} from "../type/csmvector";
import {CubismLogInfo} from "./cubismdebug";
import {strtod} from "../live2dcubismframework";
import csmVector = csmvector.csmVector;
import csmVector_iterator = csmvector.iterator;
import csmMap = csmmap.csmMap;
import csmMap_iterator = csmmap.iterator;
import csmString = csmstring.csmString;
export namespace Live2DCubismFramework
@ -305,6 +307,29 @@ export namespace Live2DCubismFramework
return this._root;
}
/**
* UnicodeString
*/
public LongArrayBufferToString(buffer: ArrayBuffer, len: number) : string
{
let tmp: string[] = [];
for (let p: number = 0; p < buffer.byteLength; p += len)
{
tmp.push(this.ArrayBufferToString(buffer.slice(p, p + len)));
}
return tmp.join("");
}
/**
* UnicodeString
*/
public ArrayBufferToString( buffer: ArrayBuffer ): string
{
// 8ビット変換
return String.fromCharCode.apply("", new Uint8Array(buffer));
}
/**
* JSON
* @param buffer
@ -315,7 +340,7 @@ export namespace Live2DCubismFramework
public parseBytes(buffer: ArrayBuffer, size: number): boolean
{
let endPos: number[] = new Array(1); // 参照渡しにするため配列
let decodeBuffer: string = new TextDecoder('utf-8').decode(buffer);
let decodeBuffer: string = this.LongArrayBufferToString(buffer, 1024);
this._root = this.parseValue(decodeBuffer, size, 0, endPos);
if(this._error)
@ -1065,7 +1090,7 @@ export namespace Live2DCubismFramework
*/
public release(): void
{
for(let ite: csmVector.iterator<Value> = this._array.begin(); ite.notEqual(this._array.end()); ite.preIncrement())
for(let ite: csmVector_iterator<Value> = this._array.begin(); ite.notEqual(this._array.end()); ite.preIncrement())
{
let v: Value = ite.ptr();
@ -1092,7 +1117,7 @@ export namespace Live2DCubismFramework
{
let stringBuffer: string = indent + "[\n";
for(let ite: csmVector.iterator<Value> = this._array.begin(); ite.notEqual(this._array.end()); ite.increment())
for(let ite: csmVector_iterator<Value> = this._array.begin(); ite.notEqual(this._array.end()); ite.increment())
{
let v: Value = ite.ptr();
this._stringBuffer += indent + "" + v.getString(indent + " ") + "\n";
@ -1151,7 +1176,7 @@ export namespace Live2DCubismFramework
*/
public release(): void
{
const ite: csmMap.iterator<string, Value> = this._map.begin();
const ite: csmMap_iterator<string, Value> = this._map.begin();
while(ite.notEqual(this._map.end()))
{
@ -1182,7 +1207,7 @@ export namespace Live2DCubismFramework
{
this._stringBuffer = indent + "{\n";
const ite: csmMap.iterator<string, Value> = this._map.begin();
const ite: csmMap_iterator<string, Value> = this._map.begin();
while(ite.notEqual(this._map.end()))
{
const key = ite.ptr().first;
@ -1222,7 +1247,7 @@ export namespace Live2DCubismFramework
{
this._keys = new csmVector<string>();
const ite: csmMap.iterator<string, Value> = this._map.begin();
const ite: csmMap_iterator<string, Value> = this._map.begin();
while(ite.notEqual(this._map.end()))
{

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license

View File

@ -96,6 +96,18 @@ F5で実行し、remote web site with sourcemapを選択します。
当リポジトリの変更履歴については[コミットログ](https://github.com/Live2D/CubismWebSamples/commits/master)を参照ください。
# 動作確認環境
- Windows Chrome 70.0.3538.67
- Windows Firefox 63.0
- Windows Edge 17.17134
- macOS Chrome 70.0.3538.77
- macOS Firefox 63.0
- macOS Safari 12.0
- iOS Safari 12.0
- Android Chrome 70.0.3538.64
# TODO
以下Core内関数の実装

View File

@ -1,12 +1,11 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license
* that can be found at http://live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/
import {Live2DCubismFramework as live2dcubismframework, Option} from "../../../../Framework/live2dcubismframework";
import Csm_CubismFramework_Option = Option;
import {LogLevel} from "../../../../Framework/live2dcubismframework";
/**
* Sample App使
@ -66,5 +65,5 @@ export namespace LAppDefine
export const DebugTouchLogEnable: boolean = false;
// Frameworkから出力するログのレベル設定
export const CubismLoggingLevel: Csm_CubismFramework_Option.LogLevel = Csm_CubismFramework_Option.LogLevel.LogLevel_Verbose;
export const CubismLoggingLevel: LogLevel = LogLevel.LogLevel_Verbose;
}

View File

@ -1,15 +1,14 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license
* that can be found at http://live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/
import {Live2DCubismFramework as live2dcubismframework, Option} from "../../../../Framework/live2dcubismframework";
import {Live2DCubismFramework as live2dcubismframework, Option as Csm_Option} from "../../../../Framework/live2dcubismframework";
import {Live2DCubismFramework as cubismmatrix44} from "../../../../Framework/math/cubismmatrix44";
import Csm_CubismMatrix44 = cubismmatrix44.CubismMatrix44;
import Csm_CubismFramework = live2dcubismframework.CubismFramework;
import Csm_Option = Option;
import { LAppView } from "./lappview";
import { LAppPal } from "./lapppal";
import { LAppTextureManager } from "./lapptexturemanager";
@ -18,6 +17,7 @@ import { LAppLive2DManager } from "./lapplive2dmanager";
export let canvas: HTMLCanvasElement = null;
export let s_instance: LAppDelegate = null;
export let gl: WebGLRenderingContext = null;
export let frameBuffer: WebGLFramebuffer = null;
/**
*
@ -48,7 +48,7 @@ export class LAppDelegate
{
if(s_instance != null)
{
s_instance = void 0;
s_instance.release();
}
s_instance = null;
@ -74,18 +74,36 @@ export class LAppDelegate
return false;
}
if (!frameBuffer)
{
frameBuffer = gl.getParameter(gl.FRAMEBUFFER_BINDING);
}
// 透過設定
gl.enable(gl.BLEND);
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
// マウス関連コールバック関数登録
canvas.onmousedown = onClickBegan;
canvas.onmousemove = onMouseMoved;
canvas.onmouseup = onClickEnded;
let supportTouch: boolean = 'ontouchend' in canvas;
if(supportTouch)
{
// タッチ関連コールバック関数登録
canvas.ontouchstart = onTouchBegan;
canvas.ontouchmove = onTouchMoved;
canvas.ontouchend = onTouchEnded;
canvas.ontouchcancel = onTouchCancel;
}
else
{
// マウス関連コールバック関数登録
canvas.onmousedown = onClickBegan;
canvas.onmousemove = onMouseMoved;
canvas.onmouseup = onClickEnded;
}
// AppViewの初期化
this._view.initialize();
// Cubism3の初期化
this.initializeCubism();
@ -97,8 +115,11 @@ export class LAppDelegate
*/
public release(): void
{
this._textureManager = void 0;
this._view = void 0;
this._textureManager.release();
this._textureManager = null;
this._view.release();
this._view = null;
// リソースを解放
LAppLive2DManager.releaseInstance();
@ -115,6 +136,12 @@ export class LAppDelegate
// メインループ
let loop = () =>
{
// インスタンスの有無の確認
if(s_instance == null)
{
return;
}
// 時間更新
LAppPal.updateTime();
@ -132,13 +159,15 @@ export class LAppDelegate
gl.clearDepth(1.0);
this._view.initializeSprite();
// 透過設定
gl.enable(gl.BLEND);
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
// 描画更新
this._view.render();
// ループのために再帰呼び出し
setTimeout(loop, 1000.0/60);
requestAnimationFrame(loop);
};
loop();
}
@ -153,7 +182,7 @@ export class LAppDelegate
if(vertexShaderId == null)
{
console.log("failed to create vertexShader");
LAppPal.printLog("failed to create vertexShader");
return null;
}
@ -176,7 +205,7 @@ export class LAppDelegate
if(fragmentShaderId == null)
{
console.log("failed to create fragmentShader");
LAppPal.printLog("failed to create fragmentShader");
return null;
}
@ -197,6 +226,9 @@ export class LAppDelegate
gl.attachShader(programId, vertexShaderId);
gl.attachShader(programId, fragmentShaderId);
gl.deleteShader(vertexShaderId);
gl.deleteShader(fragmentShaderId);
// リンク
gl.linkProgram(programId);
@ -213,22 +245,6 @@ export class LAppDelegate
return this._view;
}
/**
*
*/
public getIsEnd(): boolean
{
return this._isEnd;
}
/**
*
*/
public appEnd(): void
{
this._isEnd = true;
}
public getTextureManager(): LAppTextureManager
{
return this._textureManager;
@ -267,6 +283,8 @@ export class LAppDelegate
let projection: Csm_CubismMatrix44 = new Csm_CubismMatrix44();
LAppPal.updateTime();
this._view.initializeSprite();
}
_cubismOption: Csm_Option; // Cubism3 Option
@ -278,20 +296,18 @@ export class LAppDelegate
_textureManager: LAppTextureManager;// テクスチャマネージャー
}
/**
*
*/
function onClickBegan(e: MouseEvent): void
{
LAppDelegate.getInstance()._captured = true;
if(!LAppDelegate.getInstance()._view)
{
console.log("view notfound");
LAppPal.printLog("view notfound");
return;
}
LAppDelegate.getInstance()._captured = true;
let posX: number = e.pageX;
let posY: number = e.pageY;
@ -303,21 +319,21 @@ function onClickBegan(e: MouseEvent): void
*/
function onMouseMoved(e: MouseEvent): void
{
let rect = e.toElement.getBoundingClientRect();
let posX: number = e.clientX - rect.left;
let posY: number = e.clientY - rect.top;
if(!LAppDelegate.getInstance()._captured)
{
return;
}
if(!LAppDelegate.getInstance()._view)
{
console.log("view notfound");
LAppPal.printLog("view notfound");
return;
}
let rect = e.srcElement.getBoundingClientRect();
let posX: number = e.clientX - rect.left;
let posY: number = e.clientY - rect.top;
LAppDelegate.getInstance()._view.onTouchesMoved(posX, posY);
}
@ -327,14 +343,102 @@ function onMouseMoved(e: MouseEvent): void
function onClickEnded(e: MouseEvent): void
{
LAppDelegate.getInstance()._captured = false;
let rect = e.toElement.getBoundingClientRect();
if(!LAppDelegate.getInstance()._view)
{
LAppPal.printLog("view notfound");
return;
}
let rect = e.srcElement.getBoundingClientRect();
let posX: number = e.clientX - rect.left;
let posY: number = e.clientY - rect.top;
LAppDelegate.getInstance()._view.onTouchesEnded(posX, posY);
}
/**
*
*/
function onTouchBegan(e: TouchEvent): void
{
if(!LAppDelegate.getInstance()._view)
{
console.log("view notfound");
LAppPal.printLog("view notfound");
return;
}
LAppDelegate.getInstance()._captured = true;
let posX = e.changedTouches[0].pageX;
let posY = e.changedTouches[0].pageY;
LAppDelegate.getInstance()._view.onTouchesBegan(posX, posY);
}
/**
*
*/
function onTouchMoved(e: TouchEvent): void
{
if(!LAppDelegate.getInstance()._captured)
{
return;
}
if(!LAppDelegate.getInstance()._view)
{
LAppPal.printLog("view notfound");
return;
}
let rect = e.srcElement.getBoundingClientRect();
let posX = e.changedTouches[0].clientX - rect.left;
let posY = e.changedTouches[0].clientY - rect.top;
LAppDelegate.getInstance()._view.onTouchesMoved(posX, posY);
}
/**
*
*/
function onTouchEnded(e: TouchEvent): void
{
LAppDelegate.getInstance()._captured = false;
if(!LAppDelegate.getInstance()._view)
{
LAppPal.printLog("view notfound");
return;
}
let rect = e.srcElement.getBoundingClientRect();
let posX = e.changedTouches[0].clientX - rect.left;
let posY = e.changedTouches[0].clientY - rect.top;
LAppDelegate.getInstance()._view.onTouchesEnded(posX, posY);
}
}
/**
*
*/
function onTouchCancel(e: TouchEvent): void
{
LAppDelegate.getInstance()._captured = false;
if(!LAppDelegate.getInstance()._view)
{
LAppPal.printLog("view notfound");
return;
}
let rect = e.srcElement.getBoundingClientRect();
let posX = e.changedTouches[0].clientX - rect.left;
let posY = e.changedTouches[0].clientY - rect.top;
LAppDelegate.getInstance()._view.onTouchesEnded(posX, posY);
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license
@ -76,7 +76,8 @@ export class LAppLive2DManager
{
for(let i: number = 0; i < this._models.getSize(); i++)
{
this._models.set(i, void 0);
this._models.at(i).release();
this._models.set(i, null);
}
this._models.clear();
@ -153,13 +154,13 @@ export class LAppLive2DManager
projection.multiplyByMatrix(this._viewMatrix);
}
const saveProjection: Csm_CubismMatrix44 = projection;
const saveProjection: Csm_CubismMatrix44 = projection.clone();
let modelCount: number = this._models.getSize();
for(let i: number = 0; i < modelCount; ++i)
{
let model: LAppModel = this.getModel(i);
projection = saveProjection;
projection = saveProjection.clone();
model.update();
model.draw(projection); // 参照渡しなのでprojectionは変質する。

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license
@ -21,7 +21,8 @@ import {Live2DCubismFramework as cubismstring} from "../../../../Framework/utils
import {Live2DCubismFramework as cubismmotion} from "../../../../Framework/motion/cubismmotion";
import {Live2DCubismFramework as cubismmotionqueuemanager} from "../../../../Framework/motion/cubismmotionqueuemanager";
import {Live2DCubismFramework as csmstring} from "../../../../Framework/type/csmstring";
import {Live2DCubismFramework as csmrect} from "../../../../Framework/type/csmrectf";
import {Live2DCubismFramework as csmrect } from "../../../../Framework/type/csmrectf";
import { Live2DCubismFramework as CubismRenderer_WebGL } from "../../../../Framework/rendering/cubismrenderer_WebGL";
import {CubismLogInfo} from "../../../../Framework/utils/cubismdebug";
import csmRect = csmrect.csmRect;
import csmString = csmstring.csmString;
@ -33,6 +34,7 @@ import CubismMatrix44 = cubismmatrix44.CubismMatrix44;
import csmMap = csmmap.csmMap;
import csmVector = csmvector.csmVector;
import CubismBreath = cubismbreath.CubismBreath;
import BreathParameterData = cubismbreath.BreathParameterData;
import CubismEyeBlink = cubismeyeblink.CubismEyeBlink;
import ACubismMotion = acubismmotion.ACubismMotion;
import CubismFramework = live2dcubismframework.CubismFramework;
@ -44,7 +46,7 @@ import CubismDefaultParameterId = cubismdefaultparameterid;
import {LAppDefine} from "./lappdefine";
import {LAppPal} from "./lapppal";
import {gl} from "./lappdelegate";
import { gl, canvas, frameBuffer} from "./lappdelegate";
function createBuffer(path: string, callBack: any): void
{
@ -323,12 +325,12 @@ export class LAppModel extends CubismUserModel {
{
this._breath = CubismBreath.create();
let breathParameters: csmVector<CubismBreath.BreathParameterData> = new csmVector();
breathParameters.pushBack(new CubismBreath.BreathParameterData(this._idParamAngleX, 0.0, 15.0, 6.5345, 0.5));
breathParameters.pushBack(new CubismBreath.BreathParameterData(this._idParamAngleY, 0.0, 8.0, 3.5345, 0.5));
breathParameters.pushBack(new CubismBreath.BreathParameterData(this._idParamAngleZ, 0.0, 10.0, 5.5345, 0.5));
breathParameters.pushBack(new CubismBreath.BreathParameterData(this._idParamBodyAngleX, 0.0, 4.0, 15.5345, 0.5));
breathParameters.pushBack(new CubismBreath.BreathParameterData(CubismFramework.getIdManager().getId(CubismDefaultParameterId.ParamBreath), 0.0, 0.5, 3.2345, 0.5));
let breathParameters: csmVector<BreathParameterData> = new csmVector();
breathParameters.pushBack(new BreathParameterData(this._idParamAngleX, 0.0, 15.0, 6.5345, 0.5));
breathParameters.pushBack(new BreathParameterData(this._idParamAngleY, 0.0, 8.0, 3.5345, 0.5));
breathParameters.pushBack(new BreathParameterData(this._idParamAngleZ, 0.0, 10.0, 5.5345, 0.5));
breathParameters.pushBack(new BreathParameterData(this._idParamBodyAngleX, 0.0, 4.0, 15.5345, 0.5));
breathParameters.pushBack(new BreathParameterData(CubismFramework.getIdManager().getId(CubismDefaultParameterId.ParamBreath), 0.0, 0.5, 3.2345, 0.5));
this._breath.setParameters(breathParameters);
this._state = LoadStep.LoadUserData;
@ -467,6 +469,9 @@ export class LAppModel extends CubismUserModel {
*/
private setupTextures(): void
{
// iPhoneでのアルファ品質向上のためTypescriptではpremultipliedAlphaを採用
let usePremultiply: boolean = true;
if(this._state == LoadStep.LoadTexture)
{
// テクスチャ読み込み用
@ -500,6 +505,12 @@ export class LAppModel extends CubismUserModel {
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
// Premult処理を行わせる
if(usePremultiply)
{
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1);
}
// テクスチャにピクセルを書き込む
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, img[modelTextureNumber]);
@ -519,7 +530,7 @@ export class LAppModel extends CubismUserModel {
}
img[modelTextureNumber].src = texturePath;
this.getRenderer().setIsPremultipliedAlpha(false);
this.getRenderer().setIsPremultipliedAlpha(usePremultiply);
}
this._state = LoadStep.WaitLoadTexture;
@ -907,6 +918,15 @@ export class LAppModel extends CubismUserModel {
{
if(this._model == null) return;
// キャンバスサイズを渡す
let viewport: number[] = [
0,
0,
canvas.width,
canvas.height
];
this.getRenderer().setRenderState(frameBuffer, viewport);
this.getRenderer().drawModel();
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license
@ -30,6 +30,39 @@ import { gl, canvas } from "./lappdelegate";
this._rect.up = (y + height * 0.5);
this._rect.down = (y - height * 0.5);
this._texture = textureId;
this._vertexBuffer = null;
this._uvBuffer = null;
this._indexBuffer = null;
this._positionLocation = null;
this._uvLocation = null;
this._textureLocation = null;
this._positionArray = null;
this._uvArray = null;
this._indexArray = null;
this._firstDraw = true;
}
/**
*
*/
public release(): void
{
this._rect = null;
gl.deleteTexture(this._texture);
this._texture = null;
gl.deleteBuffer(this._uvBuffer);
this._uvBuffer = null;
gl.deleteBuffer(this._vertexBuffer);
this._vertexBuffer = null;
gl.deleteBuffer(this._indexBuffer);
this._indexBuffer = null;
}
/**
@ -47,62 +80,94 @@ import { gl, canvas } from "./lappdelegate";
*/
public render(programId: WebGLProgram): void
{
if(!this._texture)
if(this._texture == null)
{
// ロードが完了していない
return;
}
// 何番目のattribute変数か
let positionLocation = gl.getAttribLocation(programId, "position");
let uvLocation = gl.getAttribLocation(programId, "uv");
let textureLocation: WebGLUniformLocation = null;
textureLocation = gl.getUniformLocation(programId, "texture");
// attribute属性を有効にする
gl.enableVertexAttribArray(positionLocation);
gl.enableVertexAttribArray(uvLocation);
// uniform属性の登録
gl.uniform1i(textureLocation, 0);
const uvVertex: Float32Array = new Float32Array([
1.0, 0.0,
0.0, 0.0,
0.0, 1.0,
1.0, 1.0
]);
let vuv: WebGLBuffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, vuv);
gl.bufferData(gl.ARRAY_BUFFER, uvVertex, gl.STATIC_DRAW);
// 初回描画時
if(this._firstDraw)
{
// 何番目のattribute変数か取得
this._positionLocation = gl.getAttribLocation(programId, "position");
gl.enableVertexAttribArray(this._positionLocation);
this._uvLocation = gl.getAttribLocation(programId, "uv");
gl.enableVertexAttribArray(this._uvLocation);
// 何番目のuniform変数か取得
this._textureLocation = gl.getUniformLocation(programId, "texture");
// uniform属性の登録
gl.uniform1i(this._textureLocation, 0);
// uvバッファ、座標初期化
{
this._uvArray = [
1.0, 0.0,
0.0, 0.0,
0.0, 1.0,
1.0, 1.0
];
// uvバッファを作成
this._uvBuffer = gl.createBuffer();
}
// 頂点バッファ、座標初期化
{
let maxWidth = canvas.width;
let maxHeight = canvas.height;
// 頂点データ
this._positionArray = [
(this._rect.right - maxWidth * 0.5) / (maxWidth * 0.5), (this._rect.up - maxHeight * 0.5) / (maxHeight * 0.5),
(this._rect.left - maxWidth * 0.5) / (maxWidth * 0.5), (this._rect.up - maxHeight * 0.5) / (maxHeight * 0.5),
(this._rect.left - maxWidth * 0.5) / (maxWidth * 0.5), (this._rect.down - maxHeight * 0.5) / (maxHeight * 0.5),
(this._rect.right - maxWidth * 0.5) / (maxWidth * 0.5), (this._rect.down - maxHeight * 0.5) / (maxHeight * 0.5)
];
// 頂点バッファを作成
this._vertexBuffer = gl.createBuffer();
}
// 頂点インデックスバッファ、初期化
{
// インデックスデータ
this._indexArray = [
0, 1, 2,
3, 2, 0
];
// インデックスバッファを作成
this._indexBuffer = gl.createBuffer();
}
this._firstDraw = false;
}
// UV座標登録
gl.bindBuffer(gl.ARRAY_BUFFER, this._uvBuffer);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(this._uvArray), gl.STATIC_DRAW);
// attribute属性を登録
gl.vertexAttribPointer(uvLocation, 2, gl.FLOAT, false, 0, 0);
// 画面サイズを取得する。
let maxWidth, maxHeight;
maxWidth = canvas.width;
maxHeight = canvas.height;
// 頂点データ
let positionVertex: Float32Array = new Float32Array([
(this._rect.right - maxWidth * 0.5) / (maxWidth * 0.5), (this._rect.up - maxHeight * 0.5) / (maxHeight * 0.5),
(this._rect.left - maxWidth * 0.5) / (maxWidth * 0.5), (this._rect.up - maxHeight * 0.5) / (maxHeight * 0.5),
(this._rect.left - maxWidth * 0.5) / (maxWidth * 0.5), (this._rect.down - maxHeight * 0.5) / (maxHeight * 0.5),
(this._rect.right - maxWidth * 0.5) / (maxWidth * 0.5), (this._rect.down - maxHeight * 0.5) / (maxHeight * 0.5)
]);
let vposition: WebGLBuffer = gl.createBuffer();
gl.activeTexture(gl.TEXTURE0);
gl.bindBuffer(gl.ARRAY_BUFFER, vposition);
gl.bufferData(gl.ARRAY_BUFFER, positionVertex, gl.STATIC_DRAW);
gl.vertexAttribPointer(this._uvLocation, 2, gl.FLOAT, false, 0, 0);
// 頂点座標を登録
gl.bindBuffer(gl.ARRAY_BUFFER, this._vertexBuffer);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(this._positionArray), gl.STATIC_DRAW);
// attribute属性を登録
gl.vertexAttribPointer(positionLocation, 2, gl.FLOAT, false, 0, 0);
gl.vertexAttribPointer(this._positionLocation, 2, gl.FLOAT, false, 0, 0);
// 頂点インデックスを作成
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(this._indexArray), gl.DYNAMIC_DRAW);
// モデルの描画
gl.bindTexture(gl.TEXTURE_2D, this._texture);
gl.drawArrays(gl.TRIANGLE_FAN, 0, 4);
gl.drawElements(gl.TRIANGLES, this._indexArray.length, gl.UNSIGNED_SHORT, 0);
}
/**
@ -123,8 +188,21 @@ import { gl, canvas } from "./lappdelegate";
return (pointX >= this._rect.left && pointX <= this._rect.right && y <= this._rect.up && y >= this._rect.down);
}
_texture: WebGLTexture; // テクスチャ
_rect: Rect; // 矩形
_texture: WebGLTexture; // テクスチャ
_vertexBuffer: WebGLBuffer; // 頂点バッファ
_uvBuffer: WebGLBuffer; // uv頂点バッファ
_indexBuffer: WebGLBuffer; // 頂点インデックスバッファ
_rect: Rect; // 矩形
_positionLocation: number;
_uvLocation: number;
_textureLocation: WebGLUniformLocation;
_positionArray: number[];
_uvArray: number[];
_indexArray: number[];
_firstDraw: boolean;
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license
@ -23,6 +23,15 @@ export class LAppTextureManager
this._textures = new Csm_csmVector<TextureInfo>();
}
/**
*
*/
public release(): void
{
this._textures.clear();
this._textures = null;
}
/**
*
* @param red Red

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license
@ -12,19 +12,11 @@ import Csm_CubismMatrix44 = cubismMatrix44.CubismMatrix44;
import { TouchManager } from "./touchmanager";
import { LAppDefine } from "./lappdefine";
import { LAppLive2DManager } from "./lapplive2dmanager";
import { LAppDelegate, canvas} from "./lappdelegate";
import { LAppDelegate, canvas, gl} from "./lappdelegate";
import { LAppSprite } from "./lappsprite";
import { TextureInfo } from "./lapptexturemanager";
import { LAppPal } from "./lapppal";
enum LoadStep
{
BackImage,
GearImage,
PowerImage,
CompleteLoad
}
/**
*
*/
@ -35,8 +27,6 @@ export class LAppView
*/
constructor()
{
this._loadStep = LoadStep.BackImage;
this._programId = null;
this._back = null;
this._gear = null;
@ -85,15 +75,31 @@ export class LAppView
);
}
/**
*
*/
public release(): void
{
this._viewMatrix = null;
this._touchManager = null;
this._deviceToScreen = null;
this._gear.release();
this._gear = null;
this._back.release();
this._back = null;
gl.deleteProgram(this._programId);
this._programId = null;
}
/**
*
*/
public render(): void
{
if(this._loadStep != LoadStep.CompleteLoad)
{
return;
}
gl.useProgram(this._programId);
if(this._back)
{
@ -104,6 +110,8 @@ export class LAppView
this._gear.render(this._programId);
}
gl.flush();
let live2DManager: LAppLive2DManager = LAppLive2DManager.getInstance();
live2DManager.onUpdate();
@ -114,9 +122,8 @@ export class LAppView
*/
public initializeSprite(): void
{
let width: number, height: number;
width = canvas.width;
height = canvas.height;
let width: number = canvas.width;
let height: number = canvas.height;
let textureManager = LAppDelegate.getInstance().getTextureManager();
const resourcesPath = LAppDefine.ResourcesPath;
@ -124,54 +131,36 @@ export class LAppView
let imageName: string = "";
// 背景画像初期化
if(this._loadStep == LoadStep.BackImage)
imageName = LAppDefine.BackImageName;
// 非同期なのでコールバック関数を作成
let initBackGroundTexture = (textureInfo: TextureInfo): void =>
{
imageName = LAppDefine.BackImageName;
// 非同期なのでコールバック関数を作成
let initBackGroundTexture = (textureInfo: TextureInfo): void =>
{
let x: number = width * 0.5;
let y: number = height * 0.5;
let fwidth = textureInfo.width * 2.0;
let fheight = height * 0.95;
this._back = new LAppSprite(x, y, fwidth, fheight, textureInfo.id);
this._loadStep = LoadStep.GearImage;
}
let backGroundTexture: TextureInfo = textureManager.createTextureFromPngFile(resourcesPath + imageName, initBackGroundTexture);
// 既に画像があれば直接初期化
if(backGroundTexture != null)
{
initBackGroundTexture(backGroundTexture);
}
}
let x: number = width * 0.5;
let y: number = height * 0.5;
let fwidth = textureInfo.width * 2.0;
let fheight = height * 0.95;
this._back = new LAppSprite(x, y, fwidth, fheight, textureInfo.id);
};
textureManager.createTextureFromPngFile(resourcesPath + imageName, initBackGroundTexture);
// 歯車画像初期化
if(this._loadStep == LoadStep.GearImage)
imageName = LAppDefine.GearImageName;
let initGearTexture = (textureInfo: TextureInfo): void =>
{
imageName = LAppDefine.GearImageName;
let initGearTexture = (textureInfo: TextureInfo): void =>
{
let x = width - textureInfo.width * 0.5;
let y = height - textureInfo.height * 0.5;
let fwidth = textureInfo.width;
let fheight = textureInfo.height;
this._gear = new LAppSprite(x, y, fwidth, fheight, textureInfo.id);
let x = width - textureInfo.width * 0.5;
let y = height - textureInfo.height * 0.5;
let fwidth = textureInfo.width;
let fheight = textureInfo.height;
this._gear = new LAppSprite(x, y, fwidth, fheight, textureInfo.id);
};
this._loadStep = LoadStep.CompleteLoad;
}
let gearTexture: TextureInfo = textureManager.createTextureFromPngFile(resourcesPath + imageName, initGearTexture);
// 既に画像があれば直接初期化
if(gearTexture != null)
{
initGearTexture(gearTexture);
}
}
textureManager.createTextureFromPngFile(resourcesPath + imageName, initGearTexture);
if(this._loadStep == LoadStep.CompleteLoad)
// シェーダーを作成
if(this._programId == null)
{
this._programId = LAppDelegate.getInstance().createShader();
}
@ -285,6 +274,4 @@ export class LAppView
_gear: LAppSprite; // ギア画像
_changeModel: boolean; // モデル切り替えフラグ
_isClick: boolean; // クリック中
_loadStep: number;
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license
@ -12,7 +12,6 @@ let main: any = () =>
// create the application instance
if(LAppDelegate.getInstance().initialize() == false)
{
console.log("application iniitalize");
return;
}
@ -27,6 +26,5 @@ main();
*/
window.onbeforeunload = () =>
{
LAppDelegate.getInstance().release();
LAppDelegate.releaseInstance();
};

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license

View File

@ -1,9 +1,9 @@
{
"scripts": {
"build-framework": "npx webpack --config framework.webpack.config.js --mode development --module-bind 'ts=ts-loader' --resolve-extensions .ts,.js",
"watch-framework": "npx webpack --watch --config framework.webpack.config.js --mode development --module-bind 'ts=ts-loader' --resolve-extensions .ts,.js",
"build-sample": "npx webpack --config sample.webpack.config.js --mode development --module-bind 'ts=ts-loader' --resolve-extensions .ts,.js",
"watch-sample": "npx webpack --watch --config sample.webpack.config.js --mode development --module-bind 'ts=ts-loader' --resolve-extensions .ts,.js",
"build-framework": "npx webpack --config framework.webpack.config.js",
"watch-framework": "npx webpack --watch --config framework.webpack.config.js",
"build-sample": "npx webpack --config sample.webpack.config.js",
"watch-sample": "npx webpack --watch --config sample.webpack.config.js",
"build-all": "npm-run-all build-framework build-sample",
"watch-all": "npm-run-all watch-framework watch-sample"
},