/**
 * Copyright(c) Live2D Inc. All rights reserved.
 *
 * Use of this source code is governed by the Live2D Open Software license
 * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
 */ import { CubismIdManager } from './id/cubismidmanager' ; import { CubismRenderer } from './rendering/cubismrenderer' ; import { CSM_ASSERT , CubismLogInfo , CubismLogWarning } from './utils/cubismdebug' ; import { Value } from './utils/cubismjson' ; export function strtod ( s , endPtr ) { let index = 0 ; for ( let i = 1 ; ; i ++ ) { const testC = s . slice ( i - 1 , i ) ; if ( testC == 'e' || testC == '-' || testC == 'E' ) { continue ; } const test = s . substring ( 0 , i ) ; const number = Number ( test ) ; if ( isNaN ( number ) ) { break ; } index = i ; } let d = parseFloat ( s ) ; if ( isNaN ( d ) ) { d = NaN ; } endPtr [ 0 ] = s . slice ( index ) ; return d ; } let s_isStarted = false ; let s_isInitialized = false ; let s_option = null ; let s_cubismIdManager = null ; /**
 * Framework内で使う定数の宣言
 */ export const Constant = Object . freeze < Record < string , number > > ( { vertexOffset : 0 , vertexStep : 2 } ) ; export function csmDelete < T > ( address ) { if ( ! address ) { return ; } address = void 0 ; } /**
 * Live2D Cubism SDK Original Workflow SDKのエントリポイント
 * 利用開始時はCubismFramework.initialize()を呼び、CubismFramework.dispose()で終了する。
 */ export class CubismFramework { param option return public static startUp ( option = null ) { if ( s_isStarted ) { CubismLogInfo ( 'CubismFramework.startUp() is already done.' ) ; return s_isStarted ; } s_option = option ; if ( s_option != null ) { Live2DCubismCore . Logging . csmSetLogFunction ( s_option . logFunction ) ; } s_isStarted = true ; if ( s_isStarted ) { const version = Live2DCubismCore . Version . csmGetVersion ( ) ; const major = ( version & 0xff000000 ) >> 24 ; const minor = ( version & 0x00ff0000 ) >> 16 ; const patch = version & 0x0000ffff ; const versionNumber = version ; CubismLogInfo ( `Live2D Cubism Core version: {0}.{1}.{2} ({3})` , ( '00' + major ) . slice ( - 2 ) , ( '00' + minor ) . slice ( - 2 ) , ( '0000' + patch ) . slice ( - 4 ) , versionNumber ) ; } CubismLogInfo ( 'CubismFramework.startUp() is complete.' ) ; return s_isStarted ; } /**
     * StartUp()で初期化したCubismFrameworkの各パラメータをクリアします。
     * Dispose()したCubismFrameworkを再利用する際に利用してください。
     */ public static cleanUp ( ) { s_isStarted = false ; s_isInitialized = false ; s_option = null ; s_cubismIdManager = null ; } /**
     * Cubism Framework内のリソースを初期化してモデルを表示可能な状態にします。<br>
     *     再度Initialize()するには先にDispose()を実行する必要があります。
     */ public static initialize ( ) { CSM_ASSERT ( s_isStarted ) ; if ( ! s_isStarted ) { CubismLogWarning ( 'CubismFramework is not started.' ) ; return ; } if ( s_isInitialized ) { CubismLogWarning ( 'CubismFramework.initialize() skipped, already initialized.' ) ; return ; } Value . staticInitializeNotForClientCall ( ) ; s_cubismIdManager = new CubismIdManager ( ) ; s_isInitialized = true ; CubismLogInfo ( 'CubismFramework.initialize() is complete.' ) ; } /**
     * Cubism Framework内の全てのリソースを解放します。
     *      ただし、外部で確保されたリソースについては解放しません。
     *      外部で適切に破棄する必要があります。
     */ public static dispose ( ) { CSM_ASSERT ( s_isStarted ) ; if ( ! s_isStarted ) { CubismLogWarning ( 'CubismFramework is not started.' ) ; return ; } if ( ! s_isInitialized ) { CubismLogWarning ( 'CubismFramework.dispose() skipped, not initialized.' ) ; return ; } Value . staticReleaseNotForClientCall ( ) ; s_cubismIdManager . release ( ) ; s_cubismIdManager = null ; CubismRenderer . staticRelease ( ) ; s_isInitialized = false ; CubismLogInfo ( 'CubismFramework.dispose() is complete.' ) ; } return public static isStarted ( ) { return s_isStarted ; } return public static isInitialized ( ) { return s_isInitialized ; } praram public static coreLogFunction ( message ) { if ( ! Live2DCubismCore . Logging . csmGetLogFunction ( ) ) { return ; } Live2DCubismCore . Logging . csmGetLogFunction ( ) ( message ) ; } return public static getLoggingLevel ( ) { if ( s_option != null ) { return s_option . loggingLevel ; } return LogLevel . LogLevel_Off ; } return public static getIdManager ( ) { return s_cubismIdManager ; } /**
     * 静的クラスとして使用する
     * インスタンス化させない
     */ private constructor ( ) { } } export class Option { logFunction : Live2DCubismCore . csmLogFunction ; loggingLevel : LogLevel ; } /**
 * ログ出力のレベル
 */ export enum LogLevel { LogLevel_Verbose = 0 , LogLevel_Debug , LogLevel_Info , LogLevel_Warning , LogLevel_Error , LogLevel_Off } import * as $ from './live2dcubismframework' ; export namespace Live2DCubismFramework { export const Constant = $ . Constant ; export const csmDelete = $ . csmDelete ; export const CubismFramework = $ . CubismFramework ; export type CubismFramework = $ . CubismFramework ; }