webgal-engine 4.6.3 → 4.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/index-CC7KTie-.js +4234 -0
- package/dist/assets/{index.es-CrZnCUfC.js → index.es-0XzJiDJZ.js} +3 -3
- package/dist/assets/{initRegister-BNakvGKk.js → initRegister-CUE0BQlV.js} +1 -1
- package/dist/assets/live2dAssets-DlXks16s.js +1 -0
- package/dist/assets/spineAssets-BFzEbEvC.js +2 -0
- package/dist/index.html +1 -1
- package/dist/webgal-engine.json +2 -2
- package/package.json +4 -3
- package/dist/assets/OPPOSans-R-tAcFw8I3.ttf.gz +0 -0
- package/dist/assets/ResourceHanRoundedCN-Regular-C1HdCLVq.ttf.gz +0 -0
- package/dist/assets/SourceHanSerifCN-Regular-B_f-kQ2u.ttf.gz +0 -0
- package/dist/assets/conentsCash-BBWvsVB4.js +0 -1
- package/dist/assets/index-Dch1g2w9.css.gz +0 -0
- package/dist/assets/index-EZxLQxgv.js +0 -4139
- package/dist/assets/index-EZxLQxgv.js.gz +0 -0
- package/dist/assets/index.es-CrZnCUfC.js.gz +0 -0
- package/dist/assets/initRegister-BNakvGKk.js.gz +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import{C as De,O as Ae,A as Be,P as ke,M as ft,T as Re,E as
|
|
1
|
+
import{u as kt,C as De,O as Ae,A as Be,P as ke,M as ft,T as Re,E as Rt,a as bt}from"./index-CC7KTie-.js";var W=Math.pow,I=(s,t,e)=>new Promise((i,r)=>{var a=l=>{try{o(e.next(l))}catch(h){r(h)}},n=l=>{try{o(e.throw(l))}catch(h){r(h)}},o=l=>l.done?i(l.value):Promise.resolve(l.value).then(a,n);o((e=e.apply(s,t)).next())});const Zt=2,Kt=2;var ct;(s=>{s.supportMoreMaskDivisions=!0,s.setOpacityFromMotion=!1})(ct||(ct={}));var w;(s=>{s.LOG_LEVEL_VERBOSE=0,s.LOG_LEVEL_WARNING=1,s.LOG_LEVEL_ERROR=2,s.LOG_LEVEL_NONE=999,s.logLevel=s.LOG_LEVEL_WARNING,s.sound=!0,s.motionSync=!0,s.motionFadingDuration=500,s.idleMotionFadingDuration=2e3,s.expressionFadingDuration=500,s.preserveExpressionOnMotion=!0,s.cubism4=ct,s.legacyExpressionBlendMode=!1})(w||(w={}));const C={log(s,...t){w.logLevel<=w.LOG_LEVEL_VERBOSE&&console.log(`[${s}]`,...t)},warn(s,...t){w.logLevel<=w.LOG_LEVEL_WARNING&&console.warn(`[${s}]`,...t)},error(s,...t){w.logLevel<=w.LOG_LEVEL_ERROR&&console.error(`[${s}]`,...t)}};function yt(s,t,e){return s<t?t:s>e?e:s}function Oe(s,t){return Math.random()*(t-s)+s}function rt(s,t,e,i,r){const a=t[i];a!==null&&typeof a===s&&(e[r]=a)}function at(s,t,e,i,r){const a=t[i];Array.isArray(a)&&(e[r]=a.filter(n=>n!==null&&typeof n===s))}function me(s,t){t.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(i=>{i!=="constructor"&&Object.defineProperty(s.prototype,i,Object.getOwnPropertyDescriptor(e.prototype,i))})})}function Ue(s){let t=s.lastIndexOf("/");return t!=-1&&(s=s.slice(0,t)),t=s.lastIndexOf("/"),t!==-1&&(s=s.slice(t+1)),s}function Ve(s,t){const e=s.indexOf(t);e!==-1&&s.splice(e,1)}class Ot extends Rt{constructor(t,e){super(),this.expressions=[],this.reserveExpressionIndex=-1,this.destroyed=!1,this.settings=t,this.tag=`ExpressionManager(${t.name})`}init(){this.defaultExpression=this.createExpression({},void 0),this.currentExpression=this.defaultExpression,this.stopAllExpressions()}loadExpression(t){return I(this,null,function*(){if(!this.definitions[t]){C.warn(this.tag,`Undefined expression at [${t}]`);return}if(this.expressions[t]===null){C.warn(this.tag,`Cannot set expression at [${t}] because it's already failed in loading.`);return}if(this.expressions[t])return this.expressions[t];const e=yield this._loadExpression(t);return this.expressions[t]=e,e})}_loadExpression(t){throw new Error("Not implemented.")}setRandomExpression(){return I(this,null,function*(){if(this.definitions.length){const t=[];for(let e=0;e<this.definitions.length;e++)this.expressions[e]!==null&&this.expressions[e]!==this.currentExpression&&e!==this.reserveExpressionIndex&&t.push(e);if(t.length){const e=Math.floor(Math.random()*t.length);return this.setExpression(e)}}return!1})}resetExpression(){this._setExpression(this.defaultExpression)}restoreExpression(){this._setExpression(this.currentExpression)}setExpression(t){return I(this,null,function*(){if(typeof t!="number"&&(t=this.getExpressionIndex(t)),!(t>-1&&t<this.definitions.length)||t===this.expressions.indexOf(this.currentExpression))return!1;this.reserveExpressionIndex=t;const e=yield this.loadExpression(t);return!e||this.reserveExpressionIndex!==t?!1:(this.reserveExpressionIndex=-1,this.currentExpression=e,this._setExpression(e),!0)})}update(t,e){return this.isFinished()?!1:this.updateParameters(t,e)}destroy(){this.destroyed=!0,this.emit("destroy");const t=this;t.definitions=void 0,t.expressions=void 0}}const Qt=.01,Ne=40/7.5,Ge=1/(.15*1e3);class ze{constructor(){this.targetX=0,this.targetY=0,this.x=0,this.y=0,this.vx=0,this.vy=0}focus(t,e,i=!1){this.targetX=yt(t,-1,1),this.targetY=yt(e,-1,1),i&&(this.x=this.targetX,this.y=this.targetY)}update(t){const e=this.targetX-this.x,i=this.targetY-this.y;if(Math.abs(e)<Qt&&Math.abs(i)<Qt)return;const r=Math.sqrt(W(e,2)+W(i,2)),a=Ne/(1e3/t);let n=a*(e/r)-this.vx,o=a*(i/r)-this.vy;const l=Math.sqrt(W(n,2)+W(o,2)),h=a*Ge*t;l>h&&(n*=h/l,o*=h/l),this.vx+=n,this.vy+=o;const u=Math.sqrt(W(this.vx,2)+W(this.vy,2)),c=.5*(Math.sqrt(W(h,2)+8*h*r)-h);u>c&&(this.vx*=c/u,this.vy*=c/u),this.x+=this.vx,this.y+=this.vy}}class vt{constructor(t){this.json=t;let e=t.url;if(typeof e!="string")throw new TypeError("The `url` field in settings JSON must be defined as a string.");this.url=e,this.name=Ue(this.url)}resolveURL(t){return kt.resolve(this.url,t)}replaceFiles(t){this.moc=t(this.moc,"moc"),this.pose!==void 0&&(this.pose=t(this.pose,"pose")),this.physics!==void 0&&(this.physics=t(this.physics,"physics"));for(let e=0;e<this.textures.length;e++)this.textures[e]=t(this.textures[e],`textures[${e}]`)}getDefinedFiles(){const t=[];return this.replaceFiles(e=>(t.push(e),e)),t}validateFiles(t){const e=(a,n)=>{const o=this.resolveURL(a);if(!t.includes(o)){if(n)throw new Error(`File "${a}" is defined in settings, but doesn't exist in given files`);return!1}return!0};return[this.moc,...this.textures].forEach(a=>e(a,!0)),this.getDefinedFiles().filter(a=>e(a,!1))}}var Et=(s=>(s[s.NONE=0]="NONE",s[s.IDLE=1]="IDLE",s[s.NORMAL=2]="NORMAL",s[s.FORCE=3]="FORCE",s))(Et||{});class Xe{constructor(){this.debug=!1,this.currentPriority=0,this.reservePriority=0}reserve(t,e,i){if(i<=0)return C.log(this.tag,"Cannot start a motion with MotionPriority.NONE."),!1;if(t===this.currentGroup&&e===this.currentIndex)return C.log(this.tag,"Motion is already playing.",this.dump(t,e)),!1;if(t===this.reservedGroup&&e===this.reservedIndex||t===this.reservedIdleGroup&&e===this.reservedIdleIndex)return C.log(this.tag,"Motion is already reserved.",this.dump(t,e)),!1;if(i===1){if(this.currentPriority!==0)return C.log(this.tag,"Cannot start idle motion because another motion is playing.",this.dump(t,e)),!1;if(this.reservedIdleGroup!==void 0)return C.log(this.tag,"Cannot start idle motion because another idle motion has reserved.",this.dump(t,e)),!1;this.setReservedIdle(t,e)}else{if(i<3){if(i<=this.currentPriority)return C.log(this.tag,"Cannot start motion because another motion is playing as an equivalent or higher priority.",this.dump(t,e)),!1;if(i<=this.reservePriority)return C.log(this.tag,"Cannot start motion because another motion has reserved as an equivalent or higher priority.",this.dump(t,e)),!1}this.setReserved(t,e,i)}return!0}start(t,e,i,r){if(r===1){if(this.setReservedIdle(void 0,void 0),this.currentPriority!==0)return C.log(this.tag,"Cannot start idle motion because another motion is playing.",this.dump(e,i)),!1}else{if(e!==this.reservedGroup||i!==this.reservedIndex)return C.log(this.tag,"Cannot start motion because another motion has taken the place.",this.dump(e,i)),!1;this.setReserved(void 0,void 0,0)}return t?(this.setCurrent(e,i,r),!0):!1}complete(){this.setCurrent(void 0,void 0,0)}setCurrent(t,e,i){this.currentPriority=i,this.currentGroup=t,this.currentIndex=e}setReserved(t,e,i){this.reservePriority=i,this.reservedGroup=t,this.reservedIndex=e}setReservedIdle(t,e){this.reservedIdleGroup=t,this.reservedIdleIndex=e}isActive(t,e){return t===this.currentGroup&&e===this.currentIndex||t===this.reservedGroup&&e===this.reservedIndex||t===this.reservedIdleGroup&&e===this.reservedIdleIndex}reset(){this.setCurrent(void 0,void 0,0),this.setReserved(void 0,void 0,0),this.setReservedIdle(void 0,void 0)}shouldRequestIdleMotion(){return this.currentGroup===void 0&&this.reservedIdleGroup===void 0}shouldOverrideExpression(){return!w.preserveExpressionOnMotion&&this.currentPriority>1}dump(t,e){if(this.debug){const i=["currentPriority","reservePriority","currentGroup","currentIndex","reservedGroup","reservedIndex","reservedIdleGroup","reservedIdleIndex"];return`
|
|
2
2
|
<Requested> group = "${t}", index = ${e}
|
|
3
3
|
`+i.map(r=>"["+r+"] "+this[r]).join(`
|
|
4
|
-
`)}return""}}const je="SoundManager",We=.5;class Z{static get volume(){return this._volume}static set volume(t){this._volume=(t>1?1:t<0?0:t)||0,this.audios.forEach(e=>e.volume=this._volume)}static add(t,e,i){const r=new Audio(t);return r.volume=this._volume,r.preload="auto",r.addEventListener("ended",()=>{this.dispose(r),e==null||e()}),r.addEventListener("error",a=>{this.dispose(r),C.warn(je,`Error occurred on "${t}"`,a.error),i==null||i(a.error)}),this.audios.push(r),r}static play(t){return new Promise((e,i)=>{var r;(r=t.play())==null||r.catch(a=>{t.dispatchEvent(new ErrorEvent("error",{error:a})),i(a)}),t.readyState===t.HAVE_ENOUGH_DATA?e():t.addEventListener("canplaythrough",e)})}static dispose(t){t.pause(),t.removeAttribute("src"),Ve(this.audios,t)}static destroy(){for(let t=this.audios.length-1;t>=0;t--)this.dispose(this.audios[t])}}Z.audios=[];Z._volume=We;class Mt extends kt{constructor(t,e){super(),this.motionGroups={},this.state=new Xe,this.playing=!1,this.destroyed=!1,this.settings=t,this.tag=`MotionManager(${t.name})`,this.state.tag=this.tag}init(t){t!=null&&t.idleMotionGroup&&(this.groups.idle=t.idleMotionGroup),this.setupMotions(t),this.stopAllMotions()}setupMotions(t){for(const i of Object.keys(this.definitions))this.motionGroups[i]=[];let e;switch(t==null?void 0:t.motionPreload){case"NONE":return;case"ALL":e=Object.keys(this.definitions);break;case"IDLE":default:e=[this.groups.idle];break}for(const i of e)if(this.definitions[i])for(let r=0;r<this.definitions[i].length;r++)this.loadMotion(i,r).then()}loadMotion(t,e){return I(this,null,function*(){var i;if(!((i=this.definitions[t])!=null&&i[e])){C.warn(this.tag,`Undefined motion at "${t}"[${e}]`);return}if(this.motionGroups[t][e]===null){C.warn(this.tag,`Cannot start motion at "${t}"[${e}] because it's already failed in loading.`);return}if(this.motionGroups[t][e])return this.motionGroups[t][e];const r=yield this._loadMotion(t,e);if(!this.destroyed)return this.motionGroups[t][e]=r??null,r})}_loadMotion(t,e){throw new Error("Not implemented.")}startMotion(t,e){return I(this,arguments,function*(i,r,a=Et.NORMAL){var n;if(!this.state.reserve(i,r,a))return!1;const o=(n=this.definitions[i])==null?void 0:n[r];if(!o)return!1;this.currentAudio&&Z.dispose(this.currentAudio);let l;if(w.sound){const u=this.getSoundFile(o);if(u)try{l=Z.add(this.settings.resolveURL(u),()=>this.currentAudio=void 0,()=>this.currentAudio=void 0),this.currentAudio=l}catch(c){C.warn(this.tag,"Failed to create audio",u,c)}}const h=yield this.loadMotion(i,r);if(l){const u=Z.play(l).catch(c=>C.warn(this.tag,"Failed to play audio",l.src,c));w.motionSync&&(yield u)}return this.state.start(h,i,r,a)?(C.log(this.tag,"Start motion:",this.getMotionName(o)),this.emit("motionStart",i,r,l),this.state.shouldOverrideExpression()&&this.expressionManager&&this.expressionManager.resetExpression(),this.playing=!0,this._startMotion(h),!0):(l&&(Z.dispose(l),this.currentAudio=void 0),!1)})}startRandomMotion(t,e){return I(this,null,function*(){const i=this.definitions[t];if(i!=null&&i.length){const r=[];for(let a=0;a<i.length;a++)this.motionGroups[t][a]!==null&&!this.state.isActive(t,a)&&r.push(a);if(r.length){const a=Math.floor(Math.random()*r.length);return this.startMotion(t,r[a],e)}}return!1})}stopAllMotions(){this._stopAllMotions(),this.state.reset(),this.currentAudio&&(Z.dispose(this.currentAudio),this.currentAudio=void 0)}update(t,e){var i;return this.isFinished()&&(this.playing&&(this.playing=!1,this.emit("motionFinish")),this.state.shouldOverrideExpression()&&((i=this.expressionManager)==null||i.restoreExpression()),this.state.complete(),this.state.shouldRequestIdleMotion()&&this.startRandomMotion(this.groups.idle,Et.IDLE)),this.updateParameters(t,e)}destroy(){var t;this.destroyed=!0,this.emit("destroy"),this.stopAllMotions(),(t=this.expressionManager)==null||t.destroy();const e=this;e.definitions=void 0,e.motionGroups=void 0}}const pe={blinkInterval:24*60*60*1e3,blinkIntervalRandom:1e3,closingDuration:100,closedDuration:50,openingDuration:150},Ye={x:0,y:0,width:0,height:0};class _e extends kt{constructor(){super(...arguments),this.focusController=new ze,this.originalWidth=0,this.originalHeight=0,this.width=0,this.height=0,this.localTransform=new ft,this.drawingMatrix=new ft,this.hitAreas={},this.textureFlipY=!1,this.viewport=[0,0,0,0],this.destroyed=!1}init(){this.setupLayout(),this.setupHitAreas()}setupLayout(){const t=this,e=this.getSize();t.originalWidth=e[0],t.originalHeight=e[1];const i=Object.assign({width:Zt,height:Kt},this.getLayout());this.localTransform.scale(i.width/Zt,i.height/Kt),t.width=this.originalWidth*this.localTransform.a,t.height=this.originalHeight*this.localTransform.d;const r=i.x!==void 0&&i.x-i.width/2||i.centerX!==void 0&&i.centerX||i.left!==void 0&&i.left-i.width/2||i.right!==void 0&&i.right+i.width/2||0,a=i.y!==void 0&&i.y-i.height/2||i.centerY!==void 0&&i.centerY||i.top!==void 0&&i.top-i.height/2||i.bottom!==void 0&&i.bottom+i.height/2||0;this.localTransform.translate(this.width*r,-this.height*a)}setupHitAreas(){const t=this.getHitAreaDefs().filter(e=>e.index>=0);for(const e of t)this.hitAreas[e.name]=e}hitTest(t,e){return Object.keys(this.hitAreas).filter(i=>this.isHit(i,t,e))}isHit(t,e,i){if(!this.hitAreas[t])return!1;const r=this.hitAreas[t].index,a=this.getDrawableBounds(r,Ye);return a.x<=e&&e<=a.x+a.width&&a.y<=i&&i<=a.y+a.height}getDrawableBounds(t,e){const i=this.getDrawableVertices(t);let r=i[0],a=i[0],n=i[1],o=i[1];for(let l=0;l<i.length;l+=2){const h=i[l],u=i[l+1];r=Math.min(h,r),a=Math.max(h,a),n=Math.min(u,n),o=Math.max(u,o)}return e??(e={}),e.x=r,e.y=n,e.width=a-r,e.height=o-n,e}updateTransform(t){this.drawingMatrix.copyFrom(t).append(this.localTransform)}update(t,e){this.focusController.update(t)}destroy(){this.destroyed=!0,this.emit("destroy"),this.motionManager.destroy(),this.motionManager=void 0}}const He="XHRLoader";class te extends Error{constructor(t,e,i,r=!1){super(t),this.url=e,this.status=i,this.aborted=r}}const E=class{static createXHR(s,t,e,i,r){const a=new XMLHttpRequest;if(E.allXhrSet.add(a),s){let n=E.xhrMap.get(s);n?n.add(a):(n=new Set([a]),E.xhrMap.set(s,n)),s.listeners("destroy").includes(E.cancelXHRs)||s.once("destroy",E.cancelXHRs)}return a.open("GET",t),a.responseType=e,a.onload=()=>{(a.status===200||a.status===0)&&a.response?i(a.response):a.onerror()},a.onerror=()=>{C.warn(He,`Failed to load resource as ${a.responseType} (Status ${a.status}): ${t}`),r(new te("Network error.",t,a.status))},a.onabort=()=>r(new te("Aborted.",t,a.status,!0)),a.onloadend=()=>{var n;E.allXhrSet.delete(a),s&&((n=E.xhrMap.get(s))==null||n.delete(a))},a}static cancelXHRs(){var s;(s=E.xhrMap.get(this))==null||s.forEach(t=>{t.abort(),E.allXhrSet.delete(t)}),E.xhrMap.delete(this)}static release(){E.allXhrSet.forEach(s=>s.abort()),E.allXhrSet.clear(),E.xhrMap=new WeakMap}};let Pt=E;Pt.xhrMap=new WeakMap;Pt.allXhrSet=new Set;Pt.loader=(s,t)=>new Promise((e,i)=>{E.createXHR(s.target,s.settings?s.settings.resolveURL(s.url):s.url,s.type,a=>{s.result=a,e()},i).send()});function fe(s,t){let e=-1;return i(0);function i(r,a){if(a)return Promise.reject(a);if(r<=e)return Promise.reject(new Error("next() called multiple times"));e=r;const n=s[r];if(!n)return Promise.resolve();try{return Promise.resolve(n(t,i.bind(null,r+1)))}catch(o){return Promise.reject(o)}}}class j{static load(t){return fe(this.middlewares,t).then(()=>t.result)}}j.middlewares=[Pt.loader];function qe(s,t={}){var e;const i={resourceOptions:{crossorigin:t.crossOrigin}};if(bt.fromURL)return bt.fromURL(s,i).catch(n=>{if(n instanceof Error)throw n;const o=new Error("Texture loading error");throw o.event=n,o});i.resourceOptions.autoLoad=!1;const r=bt.from(s,i);if(r.baseTexture.valid)return Promise.resolve(r);const a=r.baseTexture.resource;return(e=a._live2d_load)!=null||(a._live2d_load=new Promise((n,o)=>{const l=h=>{a.source.removeEventListener("error",l);const u=new Error("Texture loading error");u.event=h,o(u)};a.source.addEventListener("error",l),a.load().then(()=>n(r)).catch(l)})),a._live2d_load}const ee="Live2DFactory",ye=(s,t)=>I(void 0,null,function*(){if(typeof s.source=="string"){const e=yield j.load({url:s.source,type:"json",target:s.live2dModel});e.url=s.source,s.source=e,s.live2dModel.emit("settingsJSONLoaded",e)}return t()}),xe=(s,t)=>I(void 0,null,function*(){if(s.source instanceof vt)return s.settings=s.source,t();if(typeof s.source=="object"){const e=b.findRuntime(s.source);if(e){const i=e.createModelSettings(s.source);return s.settings=i,s.live2dModel.emit("settingsLoaded",i),t()}}throw new TypeError("Unknown settings format.")}),ve=(s,t)=>{if(s.settings){const e=b.findRuntime(s.settings);if(e)return e.ready().then(t)}return t()},Me=(s,t)=>I(void 0,null,function*(){yield t();const e=s.internalModel;if(e){const i=s.settings,r=b.findRuntime(i);if(r){const a=[];i.pose&&a.push(j.load({settings:i,url:i.pose,type:"json",target:e}).then(n=>{e.pose=r.createPose(e.coreModel,n),s.live2dModel.emit("poseLoaded",e.pose)}).catch(n=>{s.live2dModel.emit("poseLoadError",n),C.warn(ee,"Failed to load pose.",n)})),i.physics&&a.push(j.load({settings:i,url:i.physics,type:"json",target:e}).then(n=>{e.physics=r.createPhysics(e.coreModel,n),s.live2dModel.emit("physicsLoaded",e.physics)}).catch(n=>{s.live2dModel.emit("physicsLoadError",n),C.warn(ee,"Failed to load physics.",n)})),a.length&&(yield Promise.all(a))}}}),Pe=(s,t)=>I(void 0,null,function*(){if(s.settings){const e=s.live2dModel,i=s.settings.textures.map(r=>{const a=s.settings.resolveURL(r);return qe(a,{crossOrigin:s.options.crossOrigin})});if(yield t(),s.internalModel)e.internalModel=s.internalModel,e.emit("modelLoaded",s.internalModel);else throw new TypeError("Missing internal model.");e.textures=yield Promise.all(i),e.emit("textureLoaded",e.textures)}else throw new TypeError("Missing settings.")}),Ce=(s,t)=>I(void 0,null,function*(){const e=s.settings;if(e instanceof vt){const i=b.findRuntime(e);if(!i)throw new TypeError("Unknown model settings.");const r=yield j.load({settings:e,url:e.moc,type:"arraybuffer",target:s.live2dModel});if(!i.isValidMoc(r))throw new Error("Invalid moc data");const a=i.createCoreModel(r);return s.internalModel=i.createInternalModel(a,e,s.options),t()}throw new TypeError("Missing settings.")}),L=class{static registerRuntime(s){L.runtimes.push(s),L.runtimes.sort((t,e)=>e.version-t.version)}static findRuntime(s){for(const t of L.runtimes)if(t.test(s))return t}static setupLive2DModel(s,t,e){return I(this,null,function*(){const i=new Promise(n=>s.once("textureLoaded",n)),r=new Promise(n=>s.once("modelLoaded",n)),a=Promise.all([i,r]).then(()=>s.emit("ready"));yield fe(L.live2DModelMiddlewares,{live2dModel:s,source:t,options:e||{}}),yield a,s.emit("load")})}static loadMotion(s,t,e){var i,r;const a=n=>s.emit("motionLoadError",t,e,n);try{const n=(i=s.definitions[t])==null?void 0:i[e];if(!n)return Promise.resolve(void 0);s.listeners("destroy").includes(L.releaseTasks)||s.once("destroy",L.releaseTasks);let o=L.motionTasksMap.get(s);o||(o={},L.motionTasksMap.set(s,o));let l=o[t];l||(l=[],o[t]=l);const h=s.getMotionFile(n);return(r=l[e])!=null||(l[e]=j.load({url:h,settings:s.settings,type:s.motionDataType,target:s}).then(u=>{var c;const d=(c=L.motionTasksMap.get(s))==null?void 0:c[t];d&&delete d[e];const _=s.createMotion(u,t,n);return s.emit("motionLoaded",t,e,_),_}).catch(u=>{C.warn(s.tag,`Failed to load motion: ${h}
|
|
4
|
+
`)}return""}}const je="SoundManager",We=.5;class Z{static get volume(){return this._volume}static set volume(t){this._volume=(t>1?1:t<0?0:t)||0,this.audios.forEach(e=>e.volume=this._volume)}static add(t,e,i){const r=new Audio(t);return r.volume=this._volume,r.preload="auto",r.addEventListener("ended",()=>{this.dispose(r),e==null||e()}),r.addEventListener("error",a=>{this.dispose(r),C.warn(je,`Error occurred on "${t}"`,a.error),i==null||i(a.error)}),this.audios.push(r),r}static play(t){return new Promise((e,i)=>{var r;(r=t.play())==null||r.catch(a=>{t.dispatchEvent(new ErrorEvent("error",{error:a})),i(a)}),t.readyState===t.HAVE_ENOUGH_DATA?e():t.addEventListener("canplaythrough",e)})}static dispose(t){t.pause(),t.removeAttribute("src"),Ve(this.audios,t)}static destroy(){for(let t=this.audios.length-1;t>=0;t--)this.dispose(this.audios[t])}}Z.audios=[];Z._volume=We;class Mt extends Rt{constructor(t,e){super(),this.motionGroups={},this.state=new Xe,this.playing=!1,this.destroyed=!1,this.settings=t,this.tag=`MotionManager(${t.name})`,this.state.tag=this.tag}init(t){t!=null&&t.idleMotionGroup&&(this.groups.idle=t.idleMotionGroup),this.setupMotions(t),this.stopAllMotions()}setupMotions(t){for(const i of Object.keys(this.definitions))this.motionGroups[i]=[];let e;switch(t==null?void 0:t.motionPreload){case"NONE":return;case"ALL":e=Object.keys(this.definitions);break;case"IDLE":default:e=[this.groups.idle];break}for(const i of e)if(this.definitions[i])for(let r=0;r<this.definitions[i].length;r++)this.loadMotion(i,r).then()}loadMotion(t,e){return I(this,null,function*(){var i;if(!((i=this.definitions[t])!=null&&i[e])){C.warn(this.tag,`Undefined motion at "${t}"[${e}]`);return}if(this.motionGroups[t][e]===null){C.warn(this.tag,`Cannot start motion at "${t}"[${e}] because it's already failed in loading.`);return}if(this.motionGroups[t][e])return this.motionGroups[t][e];const r=yield this._loadMotion(t,e);if(!this.destroyed)return this.motionGroups[t][e]=r??null,r})}_loadMotion(t,e){throw new Error("Not implemented.")}startMotion(t,e){return I(this,arguments,function*(i,r,a=Et.NORMAL){var n;if(!this.state.reserve(i,r,a))return!1;const o=(n=this.definitions[i])==null?void 0:n[r];if(!o)return!1;this.currentAudio&&Z.dispose(this.currentAudio);let l;if(w.sound){const u=this.getSoundFile(o);if(u)try{l=Z.add(this.settings.resolveURL(u),()=>this.currentAudio=void 0,()=>this.currentAudio=void 0),this.currentAudio=l}catch(c){C.warn(this.tag,"Failed to create audio",u,c)}}const h=yield this.loadMotion(i,r);if(l){const u=Z.play(l).catch(c=>C.warn(this.tag,"Failed to play audio",l.src,c));w.motionSync&&(yield u)}return this.state.start(h,i,r,a)?(C.log(this.tag,"Start motion:",this.getMotionName(o)),this.emit("motionStart",i,r,l),this.state.shouldOverrideExpression()&&this.expressionManager&&this.expressionManager.resetExpression(),this.playing=!0,this._startMotion(h),!0):(l&&(Z.dispose(l),this.currentAudio=void 0),!1)})}startRandomMotion(t,e){return I(this,null,function*(){const i=this.definitions[t];if(i!=null&&i.length){const r=[];for(let a=0;a<i.length;a++)this.motionGroups[t][a]!==null&&!this.state.isActive(t,a)&&r.push(a);if(r.length){const a=Math.floor(Math.random()*r.length);return this.startMotion(t,r[a],e)}}return!1})}stopAllMotions(){this._stopAllMotions(),this.state.reset(),this.currentAudio&&(Z.dispose(this.currentAudio),this.currentAudio=void 0)}update(t,e){var i;return this.isFinished()&&(this.playing&&(this.playing=!1,this.emit("motionFinish")),this.state.shouldOverrideExpression()&&((i=this.expressionManager)==null||i.restoreExpression()),this.state.complete(),this.state.shouldRequestIdleMotion()&&this.startRandomMotion(this.groups.idle,Et.IDLE)),this.updateParameters(t,e)}destroy(){var t;this.destroyed=!0,this.emit("destroy"),this.stopAllMotions(),(t=this.expressionManager)==null||t.destroy();const e=this;e.definitions=void 0,e.motionGroups=void 0}}const pe={blinkInterval:24*60*60*1e3,blinkIntervalRandom:1e3,closingDuration:100,closedDuration:50,openingDuration:150},Ye={x:0,y:0,width:0,height:0};class _e extends Rt{constructor(){super(...arguments),this.focusController=new ze,this.originalWidth=0,this.originalHeight=0,this.width=0,this.height=0,this.localTransform=new ft,this.drawingMatrix=new ft,this.hitAreas={},this.textureFlipY=!1,this.viewport=[0,0,0,0],this.destroyed=!1}init(){this.setupLayout(),this.setupHitAreas()}setupLayout(){const t=this,e=this.getSize();t.originalWidth=e[0],t.originalHeight=e[1];const i=Object.assign({width:Zt,height:Kt},this.getLayout());this.localTransform.scale(i.width/Zt,i.height/Kt),t.width=this.originalWidth*this.localTransform.a,t.height=this.originalHeight*this.localTransform.d;const r=i.x!==void 0&&i.x-i.width/2||i.centerX!==void 0&&i.centerX||i.left!==void 0&&i.left-i.width/2||i.right!==void 0&&i.right+i.width/2||0,a=i.y!==void 0&&i.y-i.height/2||i.centerY!==void 0&&i.centerY||i.top!==void 0&&i.top-i.height/2||i.bottom!==void 0&&i.bottom+i.height/2||0;this.localTransform.translate(this.width*r,-this.height*a)}setupHitAreas(){const t=this.getHitAreaDefs().filter(e=>e.index>=0);for(const e of t)this.hitAreas[e.name]=e}hitTest(t,e){return Object.keys(this.hitAreas).filter(i=>this.isHit(i,t,e))}isHit(t,e,i){if(!this.hitAreas[t])return!1;const r=this.hitAreas[t].index,a=this.getDrawableBounds(r,Ye);return a.x<=e&&e<=a.x+a.width&&a.y<=i&&i<=a.y+a.height}getDrawableBounds(t,e){const i=this.getDrawableVertices(t);let r=i[0],a=i[0],n=i[1],o=i[1];for(let l=0;l<i.length;l+=2){const h=i[l],u=i[l+1];r=Math.min(h,r),a=Math.max(h,a),n=Math.min(u,n),o=Math.max(u,o)}return e??(e={}),e.x=r,e.y=n,e.width=a-r,e.height=o-n,e}updateTransform(t){this.drawingMatrix.copyFrom(t).append(this.localTransform)}update(t,e){this.focusController.update(t)}destroy(){this.destroyed=!0,this.emit("destroy"),this.motionManager.destroy(),this.motionManager=void 0}}const He="XHRLoader";class te extends Error{constructor(t,e,i,r=!1){super(t),this.url=e,this.status=i,this.aborted=r}}const E=class{static createXHR(s,t,e,i,r){const a=new XMLHttpRequest;if(E.allXhrSet.add(a),s){let n=E.xhrMap.get(s);n?n.add(a):(n=new Set([a]),E.xhrMap.set(s,n)),s.listeners("destroy").includes(E.cancelXHRs)||s.once("destroy",E.cancelXHRs)}return a.open("GET",t),a.responseType=e,a.onload=()=>{(a.status===200||a.status===0)&&a.response?i(a.response):a.onerror()},a.onerror=()=>{C.warn(He,`Failed to load resource as ${a.responseType} (Status ${a.status}): ${t}`),r(new te("Network error.",t,a.status))},a.onabort=()=>r(new te("Aborted.",t,a.status,!0)),a.onloadend=()=>{var n;E.allXhrSet.delete(a),s&&((n=E.xhrMap.get(s))==null||n.delete(a))},a}static cancelXHRs(){var s;(s=E.xhrMap.get(this))==null||s.forEach(t=>{t.abort(),E.allXhrSet.delete(t)}),E.xhrMap.delete(this)}static release(){E.allXhrSet.forEach(s=>s.abort()),E.allXhrSet.clear(),E.xhrMap=new WeakMap}};let Pt=E;Pt.xhrMap=new WeakMap;Pt.allXhrSet=new Set;Pt.loader=(s,t)=>new Promise((e,i)=>{E.createXHR(s.target,s.settings?s.settings.resolveURL(s.url):s.url,s.type,a=>{s.result=a,e()},i).send()});function fe(s,t){let e=-1;return i(0);function i(r,a){if(a)return Promise.reject(a);if(r<=e)return Promise.reject(new Error("next() called multiple times"));e=r;const n=s[r];if(!n)return Promise.resolve();try{return Promise.resolve(n(t,i.bind(null,r+1)))}catch(o){return Promise.reject(o)}}}class j{static load(t){return fe(this.middlewares,t).then(()=>t.result)}}j.middlewares=[Pt.loader];function qe(s,t={}){var e;const i={resourceOptions:{crossorigin:t.crossOrigin}};if(bt.fromURL)return bt.fromURL(s,i).catch(n=>{if(n instanceof Error)throw n;const o=new Error("Texture loading error");throw o.event=n,o});i.resourceOptions.autoLoad=!1;const r=bt.from(s,i);if(r.baseTexture.valid)return Promise.resolve(r);const a=r.baseTexture.resource;return(e=a._live2d_load)!=null||(a._live2d_load=new Promise((n,o)=>{const l=h=>{a.source.removeEventListener("error",l);const u=new Error("Texture loading error");u.event=h,o(u)};a.source.addEventListener("error",l),a.load().then(()=>n(r)).catch(l)})),a._live2d_load}const ee="Live2DFactory",ye=(s,t)=>I(void 0,null,function*(){if(typeof s.source=="string"){const e=yield j.load({url:s.source,type:"json",target:s.live2dModel});e.url=s.source,s.source=e,s.live2dModel.emit("settingsJSONLoaded",e)}return t()}),xe=(s,t)=>I(void 0,null,function*(){if(s.source instanceof vt)return s.settings=s.source,t();if(typeof s.source=="object"){const e=b.findRuntime(s.source);if(e){const i=e.createModelSettings(s.source);return s.settings=i,s.live2dModel.emit("settingsLoaded",i),t()}}throw new TypeError("Unknown settings format.")}),ve=(s,t)=>{if(s.settings){const e=b.findRuntime(s.settings);if(e)return e.ready().then(t)}return t()},Me=(s,t)=>I(void 0,null,function*(){yield t();const e=s.internalModel;if(e){const i=s.settings,r=b.findRuntime(i);if(r){const a=[];i.pose&&a.push(j.load({settings:i,url:i.pose,type:"json",target:e}).then(n=>{e.pose=r.createPose(e.coreModel,n),s.live2dModel.emit("poseLoaded",e.pose)}).catch(n=>{s.live2dModel.emit("poseLoadError",n),C.warn(ee,"Failed to load pose.",n)})),i.physics&&a.push(j.load({settings:i,url:i.physics,type:"json",target:e}).then(n=>{e.physics=r.createPhysics(e.coreModel,n),s.live2dModel.emit("physicsLoaded",e.physics)}).catch(n=>{s.live2dModel.emit("physicsLoadError",n),C.warn(ee,"Failed to load physics.",n)})),a.length&&(yield Promise.all(a))}}}),Pe=(s,t)=>I(void 0,null,function*(){if(s.settings){const e=s.live2dModel,i=s.settings.textures.map(r=>{const a=s.settings.resolveURL(r);return qe(a,{crossOrigin:s.options.crossOrigin})});if(yield t(),s.internalModel)e.internalModel=s.internalModel,e.emit("modelLoaded",s.internalModel);else throw new TypeError("Missing internal model.");e.textures=yield Promise.all(i),e.emit("textureLoaded",e.textures)}else throw new TypeError("Missing settings.")}),Ce=(s,t)=>I(void 0,null,function*(){const e=s.settings;if(e instanceof vt){const i=b.findRuntime(e);if(!i)throw new TypeError("Unknown model settings.");const r=yield j.load({settings:e,url:e.moc,type:"arraybuffer",target:s.live2dModel});if(!i.isValidMoc(r))throw new Error("Invalid moc data");const a=i.createCoreModel(r);return s.internalModel=i.createInternalModel(a,e,s.options),t()}throw new TypeError("Missing settings.")}),L=class{static registerRuntime(s){L.runtimes.push(s),L.runtimes.sort((t,e)=>e.version-t.version)}static findRuntime(s){for(const t of L.runtimes)if(t.test(s))return t}static setupLive2DModel(s,t,e){return I(this,null,function*(){const i=new Promise(n=>s.once("textureLoaded",n)),r=new Promise(n=>s.once("modelLoaded",n)),a=Promise.all([i,r]).then(()=>s.emit("ready"));yield fe(L.live2DModelMiddlewares,{live2dModel:s,source:t,options:e||{}}),yield a,s.emit("load")})}static loadMotion(s,t,e){var i,r;const a=n=>s.emit("motionLoadError",t,e,n);try{const n=(i=s.definitions[t])==null?void 0:i[e];if(!n)return Promise.resolve(void 0);s.listeners("destroy").includes(L.releaseTasks)||s.once("destroy",L.releaseTasks);let o=L.motionTasksMap.get(s);o||(o={},L.motionTasksMap.set(s,o));let l=o[t];l||(l=[],o[t]=l);const h=s.getMotionFile(n);return(r=l[e])!=null||(l[e]=j.load({url:h,settings:s.settings,type:s.motionDataType,target:s}).then(u=>{var c;const d=(c=L.motionTasksMap.get(s))==null?void 0:c[t];d&&delete d[e];const _=s.createMotion(u,t,n);return s.emit("motionLoaded",t,e,_),_}).catch(u=>{C.warn(s.tag,`Failed to load motion: ${h}
|
|
5
5
|
`,u),a(u)})),l[e]}catch(n){C.warn(s.tag,`Failed to load motion at "${t}"[${e}]
|
|
6
6
|
`,n),a(n)}return Promise.resolve(void 0)}static loadExpression(s,t){var e;const i=r=>s.emit("expressionLoadError",t,r);try{const r=s.definitions[t];if(!r)return Promise.resolve(void 0);s.listeners("destroy").includes(L.releaseTasks)||s.once("destroy",L.releaseTasks);let a=L.expressionTasksMap.get(s);a||(a=[],L.expressionTasksMap.set(s,a));const n=s.getExpressionFile(r);return(e=a[t])!=null||(a[t]=j.load({url:n,settings:s.settings,type:"json",target:s}).then(o=>{const l=L.expressionTasksMap.get(s);l&&delete l[t];const h=s.createExpression(o,r);return s.emit("expressionLoaded",t,h),h}).catch(o=>{C.warn(s.tag,`Failed to load expression: ${n}
|
|
7
7
|
`,o),i(o)})),a[t]}catch(r){C.warn(s.tag,`Failed to load expression at [${t}]
|
|
8
|
-
`,r),i(r)}return Promise.resolve(void 0)}static releaseTasks(){this instanceof Mt?L.motionTasksMap.delete(this):L.expressionTasksMap.delete(this)}};let b=L;b.runtimes=[];b.urlToJSON=ye;b.jsonToSettings=xe;b.waitUntilReady=ve;b.setupOptionals=Me;b.setupEssentials=Pe;b.createInternalModel=Ce;b.live2DModelMiddlewares=[ye,xe,ve,Me,Pe,Ce];b.motionTasksMap=new WeakMap;b.expressionTasksMap=new WeakMap;Mt.prototype._loadMotion=function(s,t){return b.loadMotion(this,s,t)};Ot.prototype._loadExpression=function(s){return b.loadExpression(this,s)};class $e{constructor(){this._autoInteract=!1}get autoInteract(){return this._autoInteract}set autoInteract(t){t!==this._autoInteract&&(t?this.on("pointertap",ie,this):this.off("pointertap",ie,this),this._autoInteract=t)}registerInteraction(t){t!==this.interactionManager&&(this.unregisterInteraction(),this._autoInteract&&t&&(this.interactionManager=t,t.on("pointermove",se,this)))}unregisterInteraction(){var t;this.interactionManager&&((t=this.interactionManager)==null||t.off("pointermove",se,this),this.interactionManager=void 0)}}function ie(s){this.tap(s.data.global.x,s.data.global.y)}function se(s){this.focus(s.data.global.x,s.data.global.y)}class Je extends Re{}const D=new ke,Ze=new ft;let G;class Ke extends De{constructor(t){super(),this.tag="Live2DModel(uninitialized)",this.textures=[],this.transform=new Je,this.anchor=new Ae(this.onAnchorChange,this,0,0),this.glContextID=-1,this.elapsedTime=performance.now(),this.deltaTime=0,this.overrideBounds={x0:0,y0:0,x1:0,y1:0},this._autoUpdate=!1,this._alphaFilter=new Be(1),this._lastWorldAlpha=1,this.filters=this.filters?[...this.filters,this._alphaFilter]:[this._alphaFilter],this.once("modelLoaded",()=>this.init(t))}static from(t,e){const i=new this(e);return b.setupLive2DModel(i,t,e).then(()=>i)}static fromSync(t,e){const i=new this(e);return b.setupLive2DModel(i,t,e).then(e==null?void 0:e.onLoad).catch(e==null?void 0:e.onError),i}static registerTicker(t){G=t}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){var e;G||(G=(e=window.PIXI)==null?void 0:e.Ticker),t?this._destroyed||(G?(G.shared.add(this.onTickerUpdate,this),this._autoUpdate=!0):C.warn(this.tag,"No Ticker registered, please call Live2DModel.registerTicker(Ticker).")):(G==null||G.shared.remove(this.onTickerUpdate,this),this._autoUpdate=!1)}updateAlphaFilter(){const t=this.worldAlpha;this._alphaFilter.alpha=t,this._lastWorldAlpha=t}checkAlphaChange(){this.worldAlpha!==this._lastWorldAlpha&&this.updateAlphaFilter()}init(t){this.tag=`Live2DModel(${this.internalModel.settings.name})`;const e=Object.assign({autoUpdate:!0,autoInteract:!0},t);e.autoInteract&&(this.interactive=!0),e.overWriteBounds&&(this.overrideBounds=e.overWriteBounds),this.autoInteract=e.autoInteract,this.autoUpdate=e.autoUpdate}onAnchorChange(){this.pivot.set(this.anchor.x*this.internalModel.width,this.anchor.y*this.internalModel.height)}motion(t,e,i){return e===void 0?this.internalModel.motionManager.startRandomMotion(t,i):this.internalModel.motionManager.startMotion(t,e,i)}expression(t){return this.internalModel.motionManager.expressionManager?t===void 0?this.internalModel.motionManager.expressionManager.setRandomExpression():this.internalModel.motionManager.expressionManager.setExpression(t):Promise.resolve(!1)}focus(t,e,i=!1){D.x=t,D.y=e,this.toModelPosition(D,D,!0);let r=D.x/this.internalModel.originalWidth*2-1,a=D.y/this.internalModel.originalHeight*2-1,n=Math.atan2(a,r);this.internalModel.focusController.focus(Math.cos(n),-Math.sin(n),i)}tap(t,e){const i=this.hitTest(t,e);i.length&&(C.log(this.tag,"Hit",i),this.emit("hit",i))}hitTest(t,e){return D.x=t,D.y=e,this.toModelPosition(D,D),this.internalModel.hitTest(D.x,D.y)}toModelPosition(t,e=t.clone(),i){return i||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.transform.worldTransform.applyInverse(t,e),this.internalModel.localTransform.applyInverse(e,e),e}containsPoint(t){return this.getBounds(!0).contains(t.x,t.y)}_calculateBounds(){this._bounds.addFrame(this.transform,this.overrideBounds.x0,this.overrideBounds.y0,this.internalModel.width+this.overrideBounds.x1,this.internalModel.height+this.overrideBounds.y1)}onTickerUpdate(){this.update(G.shared.deltaMS)}update(t){this.deltaTime+=t,this.elapsedTime+=t}_render(t){this.checkAlphaChange(),this.registerInteraction(t.plugins.interaction),t.batch.reset(),t.geometry.reset(),t.shader.reset(),t.state.reset();let e=!1;this.glContextID!==t.CONTEXT_UID&&(this.glContextID=t.CONTEXT_UID,this.internalModel.updateWebGLContext(t.gl,this.glContextID),e=!0);for(let a=0;a<this.textures.length;a++){const n=this.textures[a];n.valid&&((e||!n.baseTexture._glTextures[this.glContextID])&&(t.gl.pixelStorei(WebGLRenderingContext.UNPACK_FLIP_Y_WEBGL,this.internalModel.textureFlipY),t.texture.bind(n.baseTexture,0)),this.internalModel.bindTexture(a,n.baseTexture._glTextures[this.glContextID].texture),n.baseTexture.touched=t.textureGC.count)}const i=t.framebuffer.viewport;this.internalModel.viewport=[i.x,i.y,i.width,i.height],this.deltaTime&&(this.internalModel.update(this.deltaTime,this.elapsedTime),this.deltaTime=0);const r=Ze.copyFrom(t.globalUniforms.uniforms.projectionMatrix).append(this.worldTransform);this.internalModel.updateTransform(r),this.internalModel.draw(t.gl),t.state.reset(),t.texture.reset()}destroy(t){this.emit("destroy"),this.autoUpdate=!1,this.unregisterInteraction(),t!=null&&t.texture&&this.textures.forEach(e=>e.destroy(t.baseTexture)),this.internalModel.destroy(),super.destroy(t)}}me(Ke,[$e]);const U=class{static resolveURL(s,t){var e;const i=(e=U.filesMap[s])==null?void 0:e[t];if(i===void 0)throw new Error("Cannot find this file from uploaded files: "+t);return i}static upload(s,t){return I(this,null,function*(){const e={};for(const i of t.getDefinedFiles()){const r=decodeURI(Rt.resolve(t.url,i)),a=s.find(n=>n.webkitRelativePath===r);a&&(e[i]=URL.createObjectURL(a))}U.filesMap[t._objectURL]=e})}static createSettings(s){return I(this,null,function*(){const t=s.find(n=>n.name.endsWith("model.json")||n.name.endsWith("model3.json"));if(!t)throw new TypeError("Settings file not found");const e=yield U.readText(t),i=JSON.parse(e);i.url=t.webkitRelativePath;const r=b.findRuntime(i);if(!r)throw new Error("Unknown settings JSON");const a=r.createModelSettings(i);return a._objectURL=URL.createObjectURL(t),a})}static readText(s){return I(this,null,function*(){return new Promise((t,e)=>{const i=new FileReader;i.onload=()=>t(i.result),i.onerror=e,i.readAsText(s,"utf8")})})}};let Ut=U;Ut.filesMap={};Ut.factory=(s,t)=>I(void 0,null,function*(){if(Array.isArray(s.source)&&s.source[0]instanceof File){const e=s.source;let i=e.settings;if(!i)i=yield U.createSettings(e);else if(!i._objectURL)throw new Error('"_objectURL" must be specified in ModelSettings');i.validateFiles(e.map(r=>encodeURI(r.webkitRelativePath))),yield U.upload(e,i),i.resolveURL=function(r){return U.resolveURL(this._objectURL,r)},s.source=i,s.live2dModel.once("modelLoaded",r=>{r.once("destroy",function(){const a=this.settings._objectURL;if(URL.revokeObjectURL(a),U.filesMap[a])for(const n of Object.values(U.filesMap[a]))URL.revokeObjectURL(n);delete U.filesMap[a]})})}return t()});b.live2DModelMiddlewares.unshift(Ut.factory);const F=class{static unzip(s,t){return I(this,null,function*(){const e=yield F.getFilePaths(s),i=[];for(const a of t.getDefinedFiles()){const n=decodeURI(Rt.resolve(t.url,a));e.includes(n)&&i.push(n)}const r=yield F.getFiles(s,i);for(let a=0;a<r.length;a++){const n=i[a],o=r[a];Object.defineProperty(o,"webkitRelativePath",{value:n})}return r})}static createSettings(s){return I(this,null,function*(){const e=(yield F.getFilePaths(s)).find(n=>n.endsWith("model.json")||n.endsWith("model3.json"));if(!e)throw new Error("Settings file not found");const i=yield F.readText(s,e);if(!i)throw new Error("Empty settings file: "+e);const r=JSON.parse(i);r.url=e;const a=b.findRuntime(r);if(!a)throw new Error("Unknown settings JSON");return a.createModelSettings(r)})}static zipReader(s,t){return I(this,null,function*(){throw new Error("Not implemented")})}static getFilePaths(s){return I(this,null,function*(){throw new Error("Not implemented")})}static getFiles(s,t){return I(this,null,function*(){throw new Error("Not implemented")})}static readText(s,t){return I(this,null,function*(){throw new Error("Not implemented")})}static releaseReader(s){}};let Ct=F;Ct.ZIP_PROTOCOL="zip://";Ct.uid=0;Ct.factory=(s,t)=>I(void 0,null,function*(){const e=s.source;let i,r,a;if(typeof e=="string"&&(e.endsWith(".zip")||e.startsWith(F.ZIP_PROTOCOL))?(e.startsWith(F.ZIP_PROTOCOL)?i=e.slice(F.ZIP_PROTOCOL.length):i=e,r=yield j.load({url:i,type:"blob",target:s.live2dModel})):Array.isArray(e)&&e.length===1&&e[0]instanceof File&&e[0].name.endsWith(".zip")&&(r=e[0],i=URL.createObjectURL(r),a=e.settings),r){if(!r.size)throw new Error("Empty zip file");const n=yield F.zipReader(r,i);a||(a=yield F.createSettings(n)),a._objectURL=F.ZIP_PROTOCOL+F.uid+"/"+a.url;const o=yield F.unzip(n,a);o.settings=a,s.source=o,i.startsWith("blob:")&&s.live2dModel.once("modelLoaded",l=>{l.once("destroy",function(){URL.revokeObjectURL(i)})}),F.releaseReader(n)}return t()});b.live2DModelMiddlewares.unshift(Ct.factory);if(!window.Live2D)throw new Error("Could not find Cubism 2 runtime. This plugin requires live2d.min.js to be loaded.");const Qe=Live2DMotion.prototype.updateParam;Live2DMotion.prototype.updateParam=function(s,t){Qe.call(this,s,t),t.isFinished()&&this.onFinishHandler&&(this.onFinishHandler(this),delete this.onFinishHandler)};class ti extends AMotion{constructor(t){super(),this.params=[],this.setFadeIn(t.fade_in>0?t.fade_in:w.expressionFadingDuration),this.setFadeOut(t.fade_out>0?t.fade_out:w.expressionFadingDuration),Array.isArray(t.params)&&t.params.forEach(e=>{const i=e.calc||"add";if(i==="add"){const r=e.def||0;e.val-=r}else if(i==="mult"){const r=e.def||1;e.val/=r}this.params.push({calc:i,val:e.val,id:e.id})})}updateParamExe(t,e,i,r){this.params.forEach(a=>{if(w.legacyExpressionBlendMode){let n=t.getParamFloat(a.id);t.setParamFloat(a.id,a.val*i+n*(1-i))}else switch(a.calc){case"set":t.setParamFloat(a.id,a.val,i);break;case"add":t.addToParamFloat(a.id,a.val*i);break;case"mult":t.multParamFloat(a.id,a.val,i);break}})}}class ei extends Ot{constructor(t,e){var i;super(t,e),this.queueManager=new MotionQueueManager,this.definitions=(i=this.settings.expressions)!=null?i:[],this.init()}isFinished(){return this.queueManager.isFinished()}getExpressionIndex(t){return this.definitions.findIndex(e=>e.name===t)}getExpressionFile(t){return t.file}createExpression(t,e){return new ti(t)}_setExpression(t){return this.queueManager.startMotion(t)}stopAllExpressions(){this.queueManager.stopAllMotions()}updateParameters(t,e){return this.queueManager.updateParam(t)}}class ii extends Mt{constructor(t,e){super(t,e),this.groups={idle:"idle"},this.motionDataType="arraybuffer",this.queueManager=new MotionQueueManager,this.definitions=this.settings.motions,this.init(e)}init(t){super.init(t),this.settings.expressions&&(this.expressionManager=new ei(this.settings,t))}isFinished(){return this.queueManager.isFinished()}createMotion(t,e,i){const r=Live2DMotion.loadMotion(t),a=e===this.groups.idle?w.idleMotionFadingDuration:w.motionFadingDuration;return r.setFadeIn(i.fade_in>0?i.fade_in:a),r.setFadeOut(i.fade_out>0?i.fade_out:a),r}getMotionFile(t){return t.file}getMotionName(t){return t.file}getSoundFile(t){return t.sound}_startMotion(t,e){return t.onFinishHandler=e,this.queueManager.stopAllMotions(),this.queueManager.startMotion(t)}_stopAllMotions(){this.queueManager.stopAllMotions()}updateParameters(t,e){return this.queueManager.updateParam(t)}destroy(){super.destroy(),this.queueManager=void 0}}class si{constructor(t){this.coreModel=t,this.blinkInterval=4e3,this.blinkIntervalRandom=1e3,this.closingDuration=100,this.closedDuration=50,this.openingDuration=150,this.eyeState=0,this.eyeParamValue=1,this.closedTimer=0,this.nextBlinkTimeLeft=this.blinkInterval,this.leftParam=t.getParamIndex("PARAM_EYE_L_OPEN"),this.rightParam=t.getParamIndex("PARAM_EYE_R_OPEN"),this.recalculateBlinkInterval()}setEyeParams(t){this.eyeParamValue=yt(t,0,1),this.coreModel.multParamFloat(this.leftParam,this.eyeParamValue),this.coreModel.multParamFloat(this.rightParam,this.eyeParamValue)}recalculateBlinkInterval(){let t=this.blinkInterval;t+=Oe(-1,1)*this.blinkIntervalRandom,t=Math.max(t,0),this.nextBlinkTimeLeft=t}update(t){switch(this.eyeState){case 0:this.nextBlinkTimeLeft-=t,this.nextBlinkTimeLeft<0&&(this.eyeState=1,this.recalculateBlinkInterval());break;case 1:this.eyeParamValue=this.eyeParamValue-t/this.closingDuration,this.setEyeParams(Math.max(this.eyeParamValue,0)),this.eyeParamValue<=0&&(this.eyeState=2,this.closedTimer=0,this.eyeParamValue=0);break;case 2:this.closedTimer+=t,this.setEyeParams(this.eyeParamValue),this.closedTimer>=this.closedDuration&&(this.eyeState=3);break;case 3:this.eyeParamValue=this.eyeParamValue+t/this.openingDuration,this.setEyeParams(Math.min(this.eyeParamValue,1)),this.eyeParamValue>=1&&(this.eyeState=0,this.eyeParamValue=1);break}}}const Y=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);class ri extends _e{constructor(t,e,i){super(),this.textureFlipY=!0,this.drawDataCount=0,this.disableCulling=!1,this.coreModel=t,this.settings=e,this.motionManager=new ii(e,i),this.eyeBlink=new si(t),this.eyeballXParamIndex=t.getParamIndex("PARAM_EYE_BALL_X"),this.eyeballYParamIndex=t.getParamIndex("PARAM_EYE_BALL_Y"),this.angleXParamIndex=t.getParamIndex("PARAM_ANGLE_X"),this.angleYParamIndex=t.getParamIndex("PARAM_ANGLE_Y"),this.angleZParamIndex=t.getParamIndex("PARAM_ANGLE_Z"),this.bodyAngleXParamIndex=t.getParamIndex("PARAM_BODY_ANGLE_X"),this.breathParamIndex=t.getParamIndex("PARAM_BREATH"),this.init()}init(){super.init(),this.settings.initParams&&this.settings.initParams.forEach(({id:a,value:n})=>this.coreModel.setParamFloat(a,n)),this.settings.initOpacities&&this.settings.initOpacities.forEach(({id:a,value:n})=>this.coreModel.setPartsOpacity(a,n)),this.coreModel.saveParam();const t=this.coreModel.getModelContext()._$aS;t!=null&&t.length&&(this.drawDataCount=t.length);let e=this.coreModel.drawParamWebGL.culling;Object.defineProperty(this.coreModel.drawParamWebGL,"culling",{set:a=>e=a,get:()=>this.disableCulling?!1:e});const i=this.coreModel.getModelContext().clipManager,r=i.setupClip;i.setupClip=(a,n)=>{r.call(i,a,n),n.gl.viewport(...this.viewport)},this.setBlinkParam(pe)}getSize(){return[this.coreModel.getCanvasWidth(),this.coreModel.getCanvasHeight()]}getLayout(){const t={};if(this.settings.layout)for(const e of Object.keys(this.settings.layout)){let i=e;e==="center_x"?i="centerX":e==="center_y"&&(i="centerY"),t[i]=this.settings.layout[e]}return t}updateWebGLContext(t,e){const i=this.coreModel.drawParamWebGL;i.firstDraw=!0,i.setGL(t),i.glno=e;for(const n in i)i.hasOwnProperty(n)&&i[n]instanceof WebGLBuffer&&(i[n]=null);const r=this.coreModel.getModelContext().clipManager;r.curFrameNo=e;const a=t.getParameter(t.FRAMEBUFFER_BINDING);r.getMaskRenderTexture(),t.bindFramebuffer(t.FRAMEBUFFER,a)}bindTexture(t,e){this.coreModel.setTexture(t,e)}getHitAreaDefs(){var t;return((t=this.settings.hitAreas)==null?void 0:t.map(e=>({id:e.id,name:e.name,index:this.coreModel.getDrawDataIndex(e.id)})))||[]}getDrawableIDs(){const t=this.coreModel.getModelContext(),e=[];for(let i=0;i<this.drawDataCount;i++){const r=t.getDrawData(i);r&&e.push(r.getDrawDataID().id)}return e}getDrawableIndex(t){return this.coreModel.getDrawDataIndex(t)}getDrawableVertices(t){if(typeof t=="string"&&(t=this.coreModel.getDrawDataIndex(t),t===-1))throw new TypeError("Unable to find drawable ID: "+t);return this.coreModel.getTransformedPoints(t).slice()}update(t,e){var i,r,a,n;super.update(t,e);const o=this.coreModel;this.emit("beforeMotionUpdate");const l=this.motionManager.update(this.coreModel,e);this.emit("afterMotionUpdate"),o.saveParam(),(i=this.motionManager.expressionManager)==null||i.update(o,e),l||(r=this.eyeBlink)==null||r.update(t),this.updateFocus(),this.updateNaturalMovements(t,e),(a=this.physics)==null||a.update(e),(n=this.pose)==null||n.update(t),this.emit("beforeModelUpdate"),o.update(),o.loadParam()}updateFocus(){this.coreModel.addToParamFloat(this.eyeballXParamIndex,this.focusController.x),this.coreModel.addToParamFloat(this.eyeballYParamIndex,this.focusController.y),this.coreModel.addToParamFloat(this.angleXParamIndex,this.focusController.x*30),this.coreModel.addToParamFloat(this.angleYParamIndex,this.focusController.y*30),this.coreModel.addToParamFloat(this.angleZParamIndex,this.focusController.x*this.focusController.y*-30),this.coreModel.addToParamFloat(this.bodyAngleXParamIndex,this.focusController.x*10)}updateNaturalMovements(t,e){const i=e/1e3*2*Math.PI;this.coreModel.setParamFloat(this.breathParamIndex,.5+.5*Math.sin(i/3.2345))}draw(t){const e=this.disableCulling;t.getParameter(t.FRAMEBUFFER_BINDING)&&(this.disableCulling=!0);const i=this.drawingMatrix;Y[0]=i.a,Y[1]=i.b,Y[4]=i.c,Y[5]=i.d,Y[12]=i.tx,Y[13]=i.ty,this.coreModel.setMatrix(Y),this.coreModel.draw(),this.disableCulling=e}destroy(){super.destroy(),this.coreModel=void 0}setBlinkParam(t){if(this.eyeBlink)try{this.eyeBlink.blinkInterval=t.blinkInterval,this.eyeBlink.blinkIntervalRandom=t.blinkIntervalRandom,this.eyeBlink.closingDuration=t.closingDuration,this.eyeBlink.closedDuration=t.closedDuration,this.eyeBlink.openingDuration=t.openingDuration,this.eyeBlink.recalculateBlinkInterval()}catch(e){console.error("Failed to set blink parameters:",e)}}}class dt extends vt{constructor(t){if(super(t),this.motions={},!dt.isValidJSON(t))throw new TypeError("Invalid JSON.");this.moc=t.model,at("string",t,this,"textures","textures"),this.copy(t)}static isValidJSON(t){var e;return!!t&&typeof t.model=="string"&&((e=t.textures)==null?void 0:e.length)>0&&t.textures.every(i=>typeof i=="string")}copy(t){rt("string",t,this,"name","name"),rt("string",t,this,"pose","pose"),rt("string",t,this,"physics","physics"),rt("object",t,this,"layout","layout"),rt("object",t,this,"motions","motions"),at("object",t,this,"hit_areas","hitAreas"),at("object",t,this,"expressions","expressions"),at("object",t,this,"init_params","initParams"),at("object",t,this,"init_opacities","initOpacities")}replaceFiles(t){super.replaceFiles(t);for(const[e,i]of Object.entries(this.motions))for(let r=0;r<i.length;r++)i[r].file=t(i[r].file,`motions.${e}[${r}].file`),i[r].sound!==void 0&&(i[r].sound=t(i[r].sound,`motions.${e}[${r}].sound`));if(this.expressions)for(let e=0;e<this.expressions.length;e++)this.expressions[e].file=t(this.expressions[e].file,`expressions[${e}].file`)}}const ai={x:PhysicsHair.Src.SRC_TO_X,y:PhysicsHair.Src.SRC_TO_Y,angle:PhysicsHair.Src.SRC_TO_G_ANGLE},ni={x:PhysicsHair.Src.SRC_TO_X,y:PhysicsHair.Src.SRC_TO_Y,angle:PhysicsHair.Src.SRC_TO_G_ANGLE};class oi{constructor(t,e){this.coreModel=t,this.physicsHairs=[],e.physics_hair&&(this.physicsHairs=e.physics_hair.map(i=>{const r=new PhysicsHair;return r.setup(i.setup.length,i.setup.regist,i.setup.mass),i.src.forEach(({id:a,ptype:n,scale:o,weight:l})=>{const h=ai[n];h&&r.addSrcParam(h,a,o,l)}),i.targets.forEach(({id:a,ptype:n,scale:o,weight:l})=>{const h=ni[n];h&&r.addTargetParam(h,a,o,l)}),r}))}update(t){this.physicsHairs.forEach(e=>e.update(this.coreModel,t))}}class re{constructor(t){this.id=t,this.paramIndex=-1,this.partsIndex=-1,this.link=[]}initIndex(t){this.paramIndex=t.getParamIndex("VISIBLE:"+this.id),this.partsIndex=t.getPartsDataIndex(PartsDataID.getID(this.id)),t.setParamFloat(this.paramIndex,1)}}class li{constructor(t,e){this.coreModel=t,this.opacityAnimDuration=500,this.partsGroups=[],e.parts_visible&&(this.partsGroups=e.parts_visible.map(({group:i})=>i.map(({id:r,link:a})=>{const n=new re(r);return a&&(n.link=a.map(o=>new re(o))),n})),this.init())}init(){this.partsGroups.forEach(t=>{t.forEach(e=>{if(e.initIndex(this.coreModel),e.paramIndex>=0){const i=this.coreModel.getParamFloat(e.paramIndex)!==0;this.coreModel.setPartsOpacity(e.partsIndex,i?1:0),this.coreModel.setParamFloat(e.paramIndex,i?1:0),e.link.length>0&&e.link.forEach(r=>r.initIndex(this.coreModel))}})})}normalizePartsOpacityGroup(t,e){const i=this.coreModel,r=.5,a=.15;let n=1,o=t.findIndex(({paramIndex:l,partsIndex:h})=>h>=0&&i.getParamFloat(l)!==0);if(o>=0){const l=i.getPartsOpacity(t[o].partsIndex);n=yt(l+e/this.opacityAnimDuration,0,1)}else o=0,n=1;t.forEach(({partsIndex:l},h)=>{if(l>=0)if(o==h)i.setPartsOpacity(l,n);else{let u=i.getPartsOpacity(l),c;n<r?c=n*(r-1)/r+1:c=(1-n)*r/(1-r),(1-c)*(1-n)>a&&(c=1-a/(1-n)),u>c&&(u=c),i.setPartsOpacity(l,u)}})}copyOpacity(t){const e=this.coreModel;t.forEach(({partsIndex:i,link:r})=>{if(i>=0&&r){const a=e.getPartsOpacity(i);r.forEach(({partsIndex:n})=>{n>=0&&e.setPartsOpacity(n,a)})}})}update(t){this.partsGroups.forEach(e=>{this.normalizePartsOpacityGroup(e,t),this.copyOpacity(e)})}}b.registerRuntime({version:2,test(s){return s instanceof dt||dt.isValidJSON(s)},ready(){return Promise.resolve()},isValidMoc(s){if(s.byteLength<3)return!1;const t=new Int8Array(s,0,3);return String.fromCharCode(...t)==="moc"},createModelSettings(s){return new dt(s)},createCoreModel(s){const t=Live2DModelWebGL.loadModel(s),e=Live2D.getError();if(e)throw e;return t},createInternalModel(s,t,e){return new ri(s,t,e)},createPose(s,t){return new li(s,t)},createPhysics(s,t){return new oi(s,t)}});if(!window.Live2DCubismCore)throw new Error("Could not find Cubism 4 runtime. This plugin requires live2dcubismcore.js to be loaded.");class y{constructor(t,e){this.x=t||0,this.y=e||0}add(t){const e=new y(0,0);return e.x=this.x+t.x,e.y=this.y+t.y,e}substract(t){const e=new y(0,0);return e.x=this.x-t.x,e.y=this.y-t.y,e}multiply(t){const e=new y(0,0);return e.x=this.x*t.x,e.y=this.y*t.y,e}multiplyByScaler(t){return this.multiply(new y(t,t))}division(t){const e=new y(0,0);return e.x=this.x/t.x,e.y=this.y/t.y,e}divisionByScalar(t){return this.division(new y(t,t))}getLength(){return Math.sqrt(this.x*this.x+this.y*this.y)}getDistanceWith(t){return Math.sqrt((this.x-t.x)*(this.x-t.x)+(this.y-t.y)*(this.y-t.y))}dot(t){return this.x*t.x+this.y*t.y}normalize(){const t=Math.pow(this.x*this.x+this.y*this.y,.5);this.x=this.x/t,this.y=this.y/t}isEqual(t){return this.x==t.x&&this.y==t.y}isNotEqual(t){return!this.isEqual(t)}}const _t=class{static range(s,t,e){return s<t?s=t:s>e&&(s=e),s}static sin(s){return Math.sin(s)}static cos(s){return Math.cos(s)}static abs(s){return Math.abs(s)}static sqrt(s){return Math.sqrt(s)}static cbrt(s){if(s===0)return s;let t=s;const e=t<0;e&&(t=-t);let i;return t===1/0?i=1/0:(i=Math.exp(Math.log(t)/3),i=(t/(i*i)+2*i)/3),e?-i:i}static getEasingSine(s){return s<0?0:s>1?1:.5-.5*this.cos(s*Math.PI)}static max(s,t){return s>t?s:t}static min(s,t){return s>t?t:s}static degreesToRadian(s){return s/180*Math.PI}static radianToDegrees(s){return s*180/Math.PI}static directionToRadian(s,t){const e=Math.atan2(t.y,t.x),i=Math.atan2(s.y,s.x);let r=e-i;for(;r<-Math.PI;)r+=Math.PI*2;for(;r>Math.PI;)r-=Math.PI*2;return r}static directionToDegrees(s,t){const e=this.directionToRadian(s,t);let i=this.radianToDegrees(e);return t.x-s.x>0&&(i=-i),i}static radianToDirection(s){const t=new y;return t.x=this.sin(s),t.y=this.cos(s),t}static quadraticEquation(s,t,e){return this.abs(s)<_t.Epsilon?this.abs(t)<_t.Epsilon?-e:-e/t:-(t+this.sqrt(t*t-4*s*e))/(2*s)}static cardanoAlgorithmForBezier(s,t,e,i){if(this.sqrt(s)<_t.Epsilon)return this.range(this.quadraticEquation(t,e,i),0,1);const r=t/s,a=e/s,n=i/s,o=(3*a-r*r)/3,l=o/3,h=(2*r*r*r-9*r*a+27*n)/27,u=h/2,c=u*u+l*l*l,d=.5,_=d+.01;if(c<0){const f=-o/3,x=f*f*f,M=this.sqrt(x),T=-h/(2*M),P=this.range(T,-1,1),V=Math.acos(P),N=2*this.cbrt(M),$t=N*this.cos(V/3)-r/3;if(this.abs($t-d)<_)return this.range($t,0,1);const Jt=N*this.cos((V+2*Math.PI)/3)-r/3;if(this.abs(Jt-d)<_)return this.range(Jt,0,1);const Fe=N*this.cos((V+4*Math.PI)/3)-r/3;return this.range(Fe,0,1)}if(c==0){let f;u<0?f=this.cbrt(-u):f=-this.cbrt(u);const x=2*f-r/3;if(this.abs(x-d)<_)return this.range(x,0,1);const M=-f-r/3;return this.range(M,0,1)}const p=this.sqrt(c),v=this.cbrt(p-u),m=this.cbrt(p+u),g=v-m-r/3;return this.range(g,0,1)}constructor(){}};let S=_t;S.Epsilon=1e-5;class k{constructor(){this._tr=new Float32Array(16),this.loadIdentity()}static multiply(t,e,i){const r=new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),a=4;for(let n=0;n<a;++n)for(let o=0;o<a;++o)for(let l=0;l<a;++l)r[o+n*4]+=t[l+n*4]*e[o+l*4];for(let n=0;n<16;++n)i[n]=r[n]}loadIdentity(){const t=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);this.setMatrix(t)}setMatrix(t){for(let e=0;e<16;++e)this._tr[e]=t[e]}getArray(){return this._tr}getScaleX(){return this._tr[0]}getScaleY(){return this._tr[5]}getTranslateX(){return this._tr[12]}getTranslateY(){return this._tr[13]}transformX(t){return this._tr[0]*t+this._tr[12]}transformY(t){return this._tr[5]*t+this._tr[13]}invertTransformX(t){return(t-this._tr[12])/this._tr[0]}invertTransformY(t){return(t-this._tr[13])/this._tr[5]}translateRelative(t,e){const i=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,t,e,0,1]);k.multiply(i,this._tr,this._tr)}translate(t,e){this._tr[12]=t,this._tr[13]=e}translateX(t){this._tr[12]=t}translateY(t){this._tr[13]=t}scaleRelative(t,e){const i=new Float32Array([t,0,0,0,0,e,0,0,0,0,1,0,0,0,0,1]);k.multiply(i,this._tr,this._tr)}scale(t,e){this._tr[0]=t,this._tr[5]=e}multiplyByMatrix(t){k.multiply(t.getArray(),this._tr,this._tr)}clone(){const t=new k;for(let e=0;e<this._tr.length;e++)t._tr[e]=this._tr[e];return t}}class Vt{initialize(t){this._model=t}drawModel(){this.getModel()!=null&&this.doDrawModel()}setMvpMatrix(t){this._mvpMatrix4x4.setMatrix(t.getArray())}getMvpMatrix(){return this._mvpMatrix4x4}setModelColor(t,e,i,r){t<0?t=0:t>1&&(t=1),e<0?e=0:e>1&&(e=1),i<0?i=0:i>1&&(i=1),r<0?r=0:r>1&&(r=1),this._modelColor.R=t,this._modelColor.G=e,this._modelColor.B=i,this._modelColor.A=r}getModelColor(){return Object.assign({},this._modelColor)}setIsPremultipliedAlpha(t){this._isPremultipliedAlpha=t}isPremultipliedAlpha(){return this._isPremultipliedAlpha}setIsCulling(t){this._isCulling=t}isCulling(){return this._isCulling}setAnisotropy(t){this._anisortopy=t}getAnisotropy(){return this._anisortopy}getModel(){return this._model}constructor(){this._isCulling=!1,this._isPremultipliedAlpha=!1,this._anisortopy=0,this._modelColor=new ot,this._mvpMatrix4x4=new k,this._mvpMatrix4x4.loadIdentity()}}var X=(s=>(s[s.CubismBlendMode_Normal=0]="CubismBlendMode_Normal",s[s.CubismBlendMode_Additive=1]="CubismBlendMode_Additive",s[s.CubismBlendMode_Multiplicative=2]="CubismBlendMode_Multiplicative",s))(X||{});class ot{constructor(){this.R=1,this.G=1,this.B=1,this.A=1}}let R=!1,Q=!1,tt;const It={vertexOffset:0,vertexStep:2};class gt{static startUp(t){if(R)return nt("CubismFramework.startUp() is already done."),R;if(Live2DCubismCore._isStarted)return R=!0,!0;if(Live2DCubismCore._isStarted=!0,tt=t,tt&&Live2DCubismCore.Logging.csmSetLogFunction(tt.logFunction),R=!0,R){const e=Live2DCubismCore.Version.csmGetVersion(),i=(e&4278190080)>>24,r=(e&16711680)>>16,a=e&65535,n=e;nt("Live2D Cubism Core version: {0}.{1}.{2} ({3})",("00"+i).slice(-2),("00"+r).slice(-2),("0000"+a).slice(-4),n)}return nt("CubismFramework.startUp() is complete."),R}static cleanUp(){R=!1,Q=!1,tt=void 0}static initialize(){if(!R){lt("CubismFramework is not started.");return}if(Q){lt("CubismFramework.initialize() skipped, already initialized.");return}Q=!0,nt("CubismFramework.initialize() is complete.")}static dispose(){if(!R){lt("CubismFramework is not started.");return}if(!Q){lt("CubismFramework.dispose() skipped, not initialized.");return}Vt.staticRelease(),Q=!1,nt("CubismFramework.dispose() is complete.")}static isStarted(){return R}static isInitialized(){return Q}static coreLogFunction(t){Live2DCubismCore.Logging.csmGetLogFunction()&&Live2DCubismCore.Logging.csmGetLogFunction()(t)}static getLoggingLevel(){return tt!=null?tt.loggingLevel:K.LogLevel_Off}constructor(){}}var K=(s=>(s[s.LogLevel_Verbose=0]="LogLevel_Verbose",s[s.LogLevel_Debug=1]="LogLevel_Debug",s[s.LogLevel_Info=2]="LogLevel_Info",s[s.LogLevel_Warning=3]="LogLevel_Warning",s[s.LogLevel_Error=4]="LogLevel_Error",s[s.LogLevel_Off=5]="LogLevel_Off",s))(K||{});const mt=()=>{};function ae(s,...t){St.print(K.LogLevel_Debug,"[CSM][D]"+s+`
|
|
8
|
+
`,r),i(r)}return Promise.resolve(void 0)}static releaseTasks(){this instanceof Mt?L.motionTasksMap.delete(this):L.expressionTasksMap.delete(this)}};let b=L;b.runtimes=[];b.urlToJSON=ye;b.jsonToSettings=xe;b.waitUntilReady=ve;b.setupOptionals=Me;b.setupEssentials=Pe;b.createInternalModel=Ce;b.live2DModelMiddlewares=[ye,xe,ve,Me,Pe,Ce];b.motionTasksMap=new WeakMap;b.expressionTasksMap=new WeakMap;Mt.prototype._loadMotion=function(s,t){return b.loadMotion(this,s,t)};Ot.prototype._loadExpression=function(s){return b.loadExpression(this,s)};class $e{constructor(){this._autoInteract=!1}get autoInteract(){return this._autoInteract}set autoInteract(t){t!==this._autoInteract&&(t?this.on("pointertap",ie,this):this.off("pointertap",ie,this),this._autoInteract=t)}registerInteraction(t){t!==this.interactionManager&&(this.unregisterInteraction(),this._autoInteract&&t&&(this.interactionManager=t,t.on("pointermove",se,this)))}unregisterInteraction(){var t;this.interactionManager&&((t=this.interactionManager)==null||t.off("pointermove",se,this),this.interactionManager=void 0)}}function ie(s){this.tap(s.data.global.x,s.data.global.y)}function se(s){this.focus(s.data.global.x,s.data.global.y)}class Je extends Re{}const D=new ke,Ze=new ft;let G;class Ke extends De{constructor(t){super(),this.tag="Live2DModel(uninitialized)",this.textures=[],this.transform=new Je,this.anchor=new Ae(this.onAnchorChange,this,0,0),this.glContextID=-1,this.elapsedTime=performance.now(),this.deltaTime=0,this.overrideBounds={x0:0,y0:0,x1:0,y1:0},this._autoUpdate=!1,this._alphaFilter=new Be(1),this._lastWorldAlpha=1,this.filters=this.filters?[...this.filters,this._alphaFilter]:[this._alphaFilter],this.once("modelLoaded",()=>this.init(t))}static from(t,e){const i=new this(e);return b.setupLive2DModel(i,t,e).then(()=>i)}static fromSync(t,e){const i=new this(e);return b.setupLive2DModel(i,t,e).then(e==null?void 0:e.onLoad).catch(e==null?void 0:e.onError),i}static registerTicker(t){G=t}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){var e;G||(G=(e=window.PIXI)==null?void 0:e.Ticker),t?this._destroyed||(G?(G.shared.add(this.onTickerUpdate,this),this._autoUpdate=!0):C.warn(this.tag,"No Ticker registered, please call Live2DModel.registerTicker(Ticker).")):(G==null||G.shared.remove(this.onTickerUpdate,this),this._autoUpdate=!1)}updateAlphaFilter(){const t=this.worldAlpha;this._alphaFilter.alpha=t,this._lastWorldAlpha=t}checkAlphaChange(){this.worldAlpha!==this._lastWorldAlpha&&this.updateAlphaFilter()}init(t){this.tag=`Live2DModel(${this.internalModel.settings.name})`;const e=Object.assign({autoUpdate:!0,autoInteract:!0},t);e.autoInteract&&(this.interactive=!0),e.overWriteBounds&&(this.overrideBounds=e.overWriteBounds),this.autoInteract=e.autoInteract,this.autoUpdate=e.autoUpdate}onAnchorChange(){this.pivot.set(this.anchor.x*this.internalModel.width,this.anchor.y*this.internalModel.height)}motion(t,e,i){return e===void 0?this.internalModel.motionManager.startRandomMotion(t,i):this.internalModel.motionManager.startMotion(t,e,i)}expression(t){return this.internalModel.motionManager.expressionManager?t===void 0?this.internalModel.motionManager.expressionManager.setRandomExpression():this.internalModel.motionManager.expressionManager.setExpression(t):Promise.resolve(!1)}focus(t,e,i=!1){D.x=t,D.y=e,this.toModelPosition(D,D,!0);let r=D.x/this.internalModel.originalWidth*2-1,a=D.y/this.internalModel.originalHeight*2-1,n=Math.atan2(a,r);this.internalModel.focusController.focus(Math.cos(n),-Math.sin(n),i)}tap(t,e){const i=this.hitTest(t,e);i.length&&(C.log(this.tag,"Hit",i),this.emit("hit",i))}hitTest(t,e){return D.x=t,D.y=e,this.toModelPosition(D,D),this.internalModel.hitTest(D.x,D.y)}toModelPosition(t,e=t.clone(),i){return i||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.transform.worldTransform.applyInverse(t,e),this.internalModel.localTransform.applyInverse(e,e),e}containsPoint(t){return this.getBounds(!0).contains(t.x,t.y)}_calculateBounds(){this._bounds.addFrame(this.transform,this.overrideBounds.x0,this.overrideBounds.y0,this.internalModel.width+this.overrideBounds.x1,this.internalModel.height+this.overrideBounds.y1)}onTickerUpdate(){this.update(G.shared.deltaMS)}update(t){this.deltaTime+=t,this.elapsedTime+=t}_render(t){this.checkAlphaChange(),this.registerInteraction(t.plugins.interaction),t.batch.reset(),t.geometry.reset(),t.shader.reset(),t.state.reset();let e=!1;this.glContextID!==t.CONTEXT_UID&&(this.glContextID=t.CONTEXT_UID,this.internalModel.updateWebGLContext(t.gl,this.glContextID),e=!0);for(let a=0;a<this.textures.length;a++){const n=this.textures[a];n.valid&&((e||!n.baseTexture._glTextures[this.glContextID])&&(t.gl.pixelStorei(WebGLRenderingContext.UNPACK_FLIP_Y_WEBGL,this.internalModel.textureFlipY),t.texture.bind(n.baseTexture,0)),this.internalModel.bindTexture(a,n.baseTexture._glTextures[this.glContextID].texture),n.baseTexture.touched=t.textureGC.count)}const i=t.framebuffer.viewport;this.internalModel.viewport=[i.x,i.y,i.width,i.height],this.deltaTime&&(this.internalModel.update(this.deltaTime,this.elapsedTime),this.deltaTime=0);const r=Ze.copyFrom(t.globalUniforms.uniforms.projectionMatrix).append(this.worldTransform);this.internalModel.updateTransform(r),this.internalModel.draw(t.gl),t.state.reset(),t.texture.reset()}destroy(t){this.emit("destroy"),this.autoUpdate=!1,this.unregisterInteraction(),t!=null&&t.texture&&this.textures.forEach(e=>e.destroy(t.baseTexture)),this.internalModel.destroy(),super.destroy(t)}}me(Ke,[$e]);const U=class{static resolveURL(s,t){var e;const i=(e=U.filesMap[s])==null?void 0:e[t];if(i===void 0)throw new Error("Cannot find this file from uploaded files: "+t);return i}static upload(s,t){return I(this,null,function*(){const e={};for(const i of t.getDefinedFiles()){const r=decodeURI(kt.resolve(t.url,i)),a=s.find(n=>n.webkitRelativePath===r);a&&(e[i]=URL.createObjectURL(a))}U.filesMap[t._objectURL]=e})}static createSettings(s){return I(this,null,function*(){const t=s.find(n=>n.name.endsWith("model.json")||n.name.endsWith("model3.json"));if(!t)throw new TypeError("Settings file not found");const e=yield U.readText(t),i=JSON.parse(e);i.url=t.webkitRelativePath;const r=b.findRuntime(i);if(!r)throw new Error("Unknown settings JSON");const a=r.createModelSettings(i);return a._objectURL=URL.createObjectURL(t),a})}static readText(s){return I(this,null,function*(){return new Promise((t,e)=>{const i=new FileReader;i.onload=()=>t(i.result),i.onerror=e,i.readAsText(s,"utf8")})})}};let Ut=U;Ut.filesMap={};Ut.factory=(s,t)=>I(void 0,null,function*(){if(Array.isArray(s.source)&&s.source[0]instanceof File){const e=s.source;let i=e.settings;if(!i)i=yield U.createSettings(e);else if(!i._objectURL)throw new Error('"_objectURL" must be specified in ModelSettings');i.validateFiles(e.map(r=>encodeURI(r.webkitRelativePath))),yield U.upload(e,i),i.resolveURL=function(r){return U.resolveURL(this._objectURL,r)},s.source=i,s.live2dModel.once("modelLoaded",r=>{r.once("destroy",function(){const a=this.settings._objectURL;if(URL.revokeObjectURL(a),U.filesMap[a])for(const n of Object.values(U.filesMap[a]))URL.revokeObjectURL(n);delete U.filesMap[a]})})}return t()});b.live2DModelMiddlewares.unshift(Ut.factory);const F=class{static unzip(s,t){return I(this,null,function*(){const e=yield F.getFilePaths(s),i=[];for(const a of t.getDefinedFiles()){const n=decodeURI(kt.resolve(t.url,a));e.includes(n)&&i.push(n)}const r=yield F.getFiles(s,i);for(let a=0;a<r.length;a++){const n=i[a],o=r[a];Object.defineProperty(o,"webkitRelativePath",{value:n})}return r})}static createSettings(s){return I(this,null,function*(){const e=(yield F.getFilePaths(s)).find(n=>n.endsWith("model.json")||n.endsWith("model3.json"));if(!e)throw new Error("Settings file not found");const i=yield F.readText(s,e);if(!i)throw new Error("Empty settings file: "+e);const r=JSON.parse(i);r.url=e;const a=b.findRuntime(r);if(!a)throw new Error("Unknown settings JSON");return a.createModelSettings(r)})}static zipReader(s,t){return I(this,null,function*(){throw new Error("Not implemented")})}static getFilePaths(s){return I(this,null,function*(){throw new Error("Not implemented")})}static getFiles(s,t){return I(this,null,function*(){throw new Error("Not implemented")})}static readText(s,t){return I(this,null,function*(){throw new Error("Not implemented")})}static releaseReader(s){}};let Ct=F;Ct.ZIP_PROTOCOL="zip://";Ct.uid=0;Ct.factory=(s,t)=>I(void 0,null,function*(){const e=s.source;let i,r,a;if(typeof e=="string"&&(e.endsWith(".zip")||e.startsWith(F.ZIP_PROTOCOL))?(e.startsWith(F.ZIP_PROTOCOL)?i=e.slice(F.ZIP_PROTOCOL.length):i=e,r=yield j.load({url:i,type:"blob",target:s.live2dModel})):Array.isArray(e)&&e.length===1&&e[0]instanceof File&&e[0].name.endsWith(".zip")&&(r=e[0],i=URL.createObjectURL(r),a=e.settings),r){if(!r.size)throw new Error("Empty zip file");const n=yield F.zipReader(r,i);a||(a=yield F.createSettings(n)),a._objectURL=F.ZIP_PROTOCOL+F.uid+"/"+a.url;const o=yield F.unzip(n,a);o.settings=a,s.source=o,i.startsWith("blob:")&&s.live2dModel.once("modelLoaded",l=>{l.once("destroy",function(){URL.revokeObjectURL(i)})}),F.releaseReader(n)}return t()});b.live2DModelMiddlewares.unshift(Ct.factory);if(!window.Live2D)throw new Error("Could not find Cubism 2 runtime. This plugin requires live2d.min.js to be loaded.");const Qe=Live2DMotion.prototype.updateParam;Live2DMotion.prototype.updateParam=function(s,t){Qe.call(this,s,t),t.isFinished()&&this.onFinishHandler&&(this.onFinishHandler(this),delete this.onFinishHandler)};class ti extends AMotion{constructor(t){super(),this.params=[],this.setFadeIn(t.fade_in>0?t.fade_in:w.expressionFadingDuration),this.setFadeOut(t.fade_out>0?t.fade_out:w.expressionFadingDuration),Array.isArray(t.params)&&t.params.forEach(e=>{const i=e.calc||"add";if(i==="add"){const r=e.def||0;e.val-=r}else if(i==="mult"){const r=e.def||1;e.val/=r}this.params.push({calc:i,val:e.val,id:e.id})})}updateParamExe(t,e,i,r){this.params.forEach(a=>{if(w.legacyExpressionBlendMode){let n=t.getParamFloat(a.id);t.setParamFloat(a.id,a.val*i+n*(1-i))}else switch(a.calc){case"set":t.setParamFloat(a.id,a.val,i);break;case"add":t.addToParamFloat(a.id,a.val*i);break;case"mult":t.multParamFloat(a.id,a.val,i);break}})}}class ei extends Ot{constructor(t,e){var i;super(t,e),this.queueManager=new MotionQueueManager,this.definitions=(i=this.settings.expressions)!=null?i:[],this.init()}isFinished(){return this.queueManager.isFinished()}getExpressionIndex(t){return this.definitions.findIndex(e=>e.name===t)}getExpressionFile(t){return t.file}createExpression(t,e){return new ti(t)}_setExpression(t){return this.queueManager.startMotion(t)}stopAllExpressions(){this.queueManager.stopAllMotions()}updateParameters(t,e){return this.queueManager.updateParam(t)}}class ii extends Mt{constructor(t,e){super(t,e),this.groups={idle:"idle"},this.motionDataType="arraybuffer",this.queueManager=new MotionQueueManager,this.definitions=this.settings.motions,this.init(e)}init(t){super.init(t),this.settings.expressions&&(this.expressionManager=new ei(this.settings,t))}isFinished(){return this.queueManager.isFinished()}createMotion(t,e,i){const r=Live2DMotion.loadMotion(t),a=e===this.groups.idle?w.idleMotionFadingDuration:w.motionFadingDuration;return r.setFadeIn(i.fade_in>0?i.fade_in:a),r.setFadeOut(i.fade_out>0?i.fade_out:a),r}getMotionFile(t){return t.file}getMotionName(t){return t.file}getSoundFile(t){return t.sound}_startMotion(t,e){return t.onFinishHandler=e,this.queueManager.stopAllMotions(),this.queueManager.startMotion(t)}_stopAllMotions(){this.queueManager.stopAllMotions()}updateParameters(t,e){return this.queueManager.updateParam(t)}destroy(){super.destroy(),this.queueManager=void 0}}class si{constructor(t){this.coreModel=t,this.blinkInterval=4e3,this.blinkIntervalRandom=1e3,this.closingDuration=100,this.closedDuration=50,this.openingDuration=150,this.eyeState=0,this.eyeParamValue=1,this.closedTimer=0,this.nextBlinkTimeLeft=this.blinkInterval,this.leftParam=t.getParamIndex("PARAM_EYE_L_OPEN"),this.rightParam=t.getParamIndex("PARAM_EYE_R_OPEN"),this.recalculateBlinkInterval()}setEyeParams(t){this.eyeParamValue=yt(t,0,1),this.coreModel.multParamFloat(this.leftParam,this.eyeParamValue),this.coreModel.multParamFloat(this.rightParam,this.eyeParamValue)}recalculateBlinkInterval(){let t=this.blinkInterval;t+=Oe(-1,1)*this.blinkIntervalRandom,t=Math.max(t,0),this.nextBlinkTimeLeft=t}update(t){switch(this.eyeState){case 0:this.nextBlinkTimeLeft-=t,this.nextBlinkTimeLeft<0&&(this.eyeState=1,this.recalculateBlinkInterval());break;case 1:this.eyeParamValue=this.eyeParamValue-t/this.closingDuration,this.setEyeParams(Math.max(this.eyeParamValue,0)),this.eyeParamValue<=0&&(this.eyeState=2,this.closedTimer=0,this.eyeParamValue=0);break;case 2:this.closedTimer+=t,this.setEyeParams(this.eyeParamValue),this.closedTimer>=this.closedDuration&&(this.eyeState=3);break;case 3:this.eyeParamValue=this.eyeParamValue+t/this.openingDuration,this.setEyeParams(Math.min(this.eyeParamValue,1)),this.eyeParamValue>=1&&(this.eyeState=0,this.eyeParamValue=1);break}}}const Y=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);class ri extends _e{constructor(t,e,i){super(),this.textureFlipY=!0,this.drawDataCount=0,this.disableCulling=!1,this.coreModel=t,this.settings=e,this.motionManager=new ii(e,i),this.eyeBlink=new si(t),this.eyeballXParamIndex=t.getParamIndex("PARAM_EYE_BALL_X"),this.eyeballYParamIndex=t.getParamIndex("PARAM_EYE_BALL_Y"),this.angleXParamIndex=t.getParamIndex("PARAM_ANGLE_X"),this.angleYParamIndex=t.getParamIndex("PARAM_ANGLE_Y"),this.angleZParamIndex=t.getParamIndex("PARAM_ANGLE_Z"),this.bodyAngleXParamIndex=t.getParamIndex("PARAM_BODY_ANGLE_X"),this.breathParamIndex=t.getParamIndex("PARAM_BREATH"),this.init()}init(){super.init(),this.settings.initParams&&this.settings.initParams.forEach(({id:a,value:n})=>this.coreModel.setParamFloat(a,n)),this.settings.initOpacities&&this.settings.initOpacities.forEach(({id:a,value:n})=>this.coreModel.setPartsOpacity(a,n)),this.coreModel.saveParam();const t=this.coreModel.getModelContext()._$aS;t!=null&&t.length&&(this.drawDataCount=t.length);let e=this.coreModel.drawParamWebGL.culling;Object.defineProperty(this.coreModel.drawParamWebGL,"culling",{set:a=>e=a,get:()=>this.disableCulling?!1:e});const i=this.coreModel.getModelContext().clipManager,r=i.setupClip;i.setupClip=(a,n)=>{r.call(i,a,n),n.gl.viewport(...this.viewport)},this.setBlinkParam(pe)}getSize(){return[this.coreModel.getCanvasWidth(),this.coreModel.getCanvasHeight()]}getLayout(){const t={};if(this.settings.layout)for(const e of Object.keys(this.settings.layout)){let i=e;e==="center_x"?i="centerX":e==="center_y"&&(i="centerY"),t[i]=this.settings.layout[e]}return t}updateWebGLContext(t,e){const i=this.coreModel.drawParamWebGL;i.firstDraw=!0,i.setGL(t),i.glno=e;for(const n in i)i.hasOwnProperty(n)&&i[n]instanceof WebGLBuffer&&(i[n]=null);const r=this.coreModel.getModelContext().clipManager;r.curFrameNo=e;const a=t.getParameter(t.FRAMEBUFFER_BINDING);r.getMaskRenderTexture(),t.bindFramebuffer(t.FRAMEBUFFER,a)}bindTexture(t,e){this.coreModel.setTexture(t,e)}getHitAreaDefs(){var t;return((t=this.settings.hitAreas)==null?void 0:t.map(e=>({id:e.id,name:e.name,index:this.coreModel.getDrawDataIndex(e.id)})))||[]}getDrawableIDs(){const t=this.coreModel.getModelContext(),e=[];for(let i=0;i<this.drawDataCount;i++){const r=t.getDrawData(i);r&&e.push(r.getDrawDataID().id)}return e}getDrawableIndex(t){return this.coreModel.getDrawDataIndex(t)}getDrawableVertices(t){if(typeof t=="string"&&(t=this.coreModel.getDrawDataIndex(t),t===-1))throw new TypeError("Unable to find drawable ID: "+t);return this.coreModel.getTransformedPoints(t).slice()}update(t,e){var i,r,a,n;super.update(t,e);const o=this.coreModel;this.emit("beforeMotionUpdate");const l=this.motionManager.update(this.coreModel,e);this.emit("afterMotionUpdate"),o.saveParam(),(i=this.motionManager.expressionManager)==null||i.update(o,e),l||(r=this.eyeBlink)==null||r.update(t),this.updateFocus(),this.updateNaturalMovements(t,e),(a=this.physics)==null||a.update(e),(n=this.pose)==null||n.update(t),this.emit("beforeModelUpdate"),o.update(),o.loadParam()}updateFocus(){this.coreModel.addToParamFloat(this.eyeballXParamIndex,this.focusController.x),this.coreModel.addToParamFloat(this.eyeballYParamIndex,this.focusController.y),this.coreModel.addToParamFloat(this.angleXParamIndex,this.focusController.x*30),this.coreModel.addToParamFloat(this.angleYParamIndex,this.focusController.y*30),this.coreModel.addToParamFloat(this.angleZParamIndex,this.focusController.x*this.focusController.y*-30),this.coreModel.addToParamFloat(this.bodyAngleXParamIndex,this.focusController.x*10)}updateNaturalMovements(t,e){const i=e/1e3*2*Math.PI;this.coreModel.setParamFloat(this.breathParamIndex,.5+.5*Math.sin(i/3.2345))}draw(t){const e=this.disableCulling;t.getParameter(t.FRAMEBUFFER_BINDING)&&(this.disableCulling=!0);const i=this.drawingMatrix;Y[0]=i.a,Y[1]=i.b,Y[4]=i.c,Y[5]=i.d,Y[12]=i.tx,Y[13]=i.ty,this.coreModel.setMatrix(Y),this.coreModel.draw(),this.disableCulling=e}destroy(){super.destroy(),this.coreModel=void 0}setBlinkParam(t){if(this.eyeBlink)try{this.eyeBlink.blinkInterval=t.blinkInterval,this.eyeBlink.blinkIntervalRandom=t.blinkIntervalRandom,this.eyeBlink.closingDuration=t.closingDuration,this.eyeBlink.closedDuration=t.closedDuration,this.eyeBlink.openingDuration=t.openingDuration,this.eyeBlink.recalculateBlinkInterval()}catch(e){console.error("Failed to set blink parameters:",e)}}}class dt extends vt{constructor(t){if(super(t),this.motions={},!dt.isValidJSON(t))throw new TypeError("Invalid JSON.");this.moc=t.model,at("string",t,this,"textures","textures"),this.copy(t)}static isValidJSON(t){var e;return!!t&&typeof t.model=="string"&&((e=t.textures)==null?void 0:e.length)>0&&t.textures.every(i=>typeof i=="string")}copy(t){rt("string",t,this,"name","name"),rt("string",t,this,"pose","pose"),rt("string",t,this,"physics","physics"),rt("object",t,this,"layout","layout"),rt("object",t,this,"motions","motions"),at("object",t,this,"hit_areas","hitAreas"),at("object",t,this,"expressions","expressions"),at("object",t,this,"init_params","initParams"),at("object",t,this,"init_opacities","initOpacities")}replaceFiles(t){super.replaceFiles(t);for(const[e,i]of Object.entries(this.motions))for(let r=0;r<i.length;r++)i[r].file=t(i[r].file,`motions.${e}[${r}].file`),i[r].sound!==void 0&&(i[r].sound=t(i[r].sound,`motions.${e}[${r}].sound`));if(this.expressions)for(let e=0;e<this.expressions.length;e++)this.expressions[e].file=t(this.expressions[e].file,`expressions[${e}].file`)}}const ai={x:PhysicsHair.Src.SRC_TO_X,y:PhysicsHair.Src.SRC_TO_Y,angle:PhysicsHair.Src.SRC_TO_G_ANGLE},ni={x:PhysicsHair.Src.SRC_TO_X,y:PhysicsHair.Src.SRC_TO_Y,angle:PhysicsHair.Src.SRC_TO_G_ANGLE};class oi{constructor(t,e){this.coreModel=t,this.physicsHairs=[],e.physics_hair&&(this.physicsHairs=e.physics_hair.map(i=>{const r=new PhysicsHair;return r.setup(i.setup.length,i.setup.regist,i.setup.mass),i.src.forEach(({id:a,ptype:n,scale:o,weight:l})=>{const h=ai[n];h&&r.addSrcParam(h,a,o,l)}),i.targets.forEach(({id:a,ptype:n,scale:o,weight:l})=>{const h=ni[n];h&&r.addTargetParam(h,a,o,l)}),r}))}update(t){this.physicsHairs.forEach(e=>e.update(this.coreModel,t))}}class re{constructor(t){this.id=t,this.paramIndex=-1,this.partsIndex=-1,this.link=[]}initIndex(t){this.paramIndex=t.getParamIndex("VISIBLE:"+this.id),this.partsIndex=t.getPartsDataIndex(PartsDataID.getID(this.id)),t.setParamFloat(this.paramIndex,1)}}class li{constructor(t,e){this.coreModel=t,this.opacityAnimDuration=500,this.partsGroups=[],e.parts_visible&&(this.partsGroups=e.parts_visible.map(({group:i})=>i.map(({id:r,link:a})=>{const n=new re(r);return a&&(n.link=a.map(o=>new re(o))),n})),this.init())}init(){this.partsGroups.forEach(t=>{t.forEach(e=>{if(e.initIndex(this.coreModel),e.paramIndex>=0){const i=this.coreModel.getParamFloat(e.paramIndex)!==0;this.coreModel.setPartsOpacity(e.partsIndex,i?1:0),this.coreModel.setParamFloat(e.paramIndex,i?1:0),e.link.length>0&&e.link.forEach(r=>r.initIndex(this.coreModel))}})})}normalizePartsOpacityGroup(t,e){const i=this.coreModel,r=.5,a=.15;let n=1,o=t.findIndex(({paramIndex:l,partsIndex:h})=>h>=0&&i.getParamFloat(l)!==0);if(o>=0){const l=i.getPartsOpacity(t[o].partsIndex);n=yt(l+e/this.opacityAnimDuration,0,1)}else o=0,n=1;t.forEach(({partsIndex:l},h)=>{if(l>=0)if(o==h)i.setPartsOpacity(l,n);else{let u=i.getPartsOpacity(l),c;n<r?c=n*(r-1)/r+1:c=(1-n)*r/(1-r),(1-c)*(1-n)>a&&(c=1-a/(1-n)),u>c&&(u=c),i.setPartsOpacity(l,u)}})}copyOpacity(t){const e=this.coreModel;t.forEach(({partsIndex:i,link:r})=>{if(i>=0&&r){const a=e.getPartsOpacity(i);r.forEach(({partsIndex:n})=>{n>=0&&e.setPartsOpacity(n,a)})}})}update(t){this.partsGroups.forEach(e=>{this.normalizePartsOpacityGroup(e,t),this.copyOpacity(e)})}}b.registerRuntime({version:2,test(s){return s instanceof dt||dt.isValidJSON(s)},ready(){return Promise.resolve()},isValidMoc(s){if(s.byteLength<3)return!1;const t=new Int8Array(s,0,3);return String.fromCharCode(...t)==="moc"},createModelSettings(s){return new dt(s)},createCoreModel(s){const t=Live2DModelWebGL.loadModel(s),e=Live2D.getError();if(e)throw e;return t},createInternalModel(s,t,e){return new ri(s,t,e)},createPose(s,t){return new li(s,t)},createPhysics(s,t){return new oi(s,t)}});if(!window.Live2DCubismCore)throw new Error("Could not find Cubism 4 runtime. This plugin requires live2dcubismcore.js to be loaded.");class y{constructor(t,e){this.x=t||0,this.y=e||0}add(t){const e=new y(0,0);return e.x=this.x+t.x,e.y=this.y+t.y,e}substract(t){const e=new y(0,0);return e.x=this.x-t.x,e.y=this.y-t.y,e}multiply(t){const e=new y(0,0);return e.x=this.x*t.x,e.y=this.y*t.y,e}multiplyByScaler(t){return this.multiply(new y(t,t))}division(t){const e=new y(0,0);return e.x=this.x/t.x,e.y=this.y/t.y,e}divisionByScalar(t){return this.division(new y(t,t))}getLength(){return Math.sqrt(this.x*this.x+this.y*this.y)}getDistanceWith(t){return Math.sqrt((this.x-t.x)*(this.x-t.x)+(this.y-t.y)*(this.y-t.y))}dot(t){return this.x*t.x+this.y*t.y}normalize(){const t=Math.pow(this.x*this.x+this.y*this.y,.5);this.x=this.x/t,this.y=this.y/t}isEqual(t){return this.x==t.x&&this.y==t.y}isNotEqual(t){return!this.isEqual(t)}}const _t=class{static range(s,t,e){return s<t?s=t:s>e&&(s=e),s}static sin(s){return Math.sin(s)}static cos(s){return Math.cos(s)}static abs(s){return Math.abs(s)}static sqrt(s){return Math.sqrt(s)}static cbrt(s){if(s===0)return s;let t=s;const e=t<0;e&&(t=-t);let i;return t===1/0?i=1/0:(i=Math.exp(Math.log(t)/3),i=(t/(i*i)+2*i)/3),e?-i:i}static getEasingSine(s){return s<0?0:s>1?1:.5-.5*this.cos(s*Math.PI)}static max(s,t){return s>t?s:t}static min(s,t){return s>t?t:s}static degreesToRadian(s){return s/180*Math.PI}static radianToDegrees(s){return s*180/Math.PI}static directionToRadian(s,t){const e=Math.atan2(t.y,t.x),i=Math.atan2(s.y,s.x);let r=e-i;for(;r<-Math.PI;)r+=Math.PI*2;for(;r>Math.PI;)r-=Math.PI*2;return r}static directionToDegrees(s,t){const e=this.directionToRadian(s,t);let i=this.radianToDegrees(e);return t.x-s.x>0&&(i=-i),i}static radianToDirection(s){const t=new y;return t.x=this.sin(s),t.y=this.cos(s),t}static quadraticEquation(s,t,e){return this.abs(s)<_t.Epsilon?this.abs(t)<_t.Epsilon?-e:-e/t:-(t+this.sqrt(t*t-4*s*e))/(2*s)}static cardanoAlgorithmForBezier(s,t,e,i){if(this.sqrt(s)<_t.Epsilon)return this.range(this.quadraticEquation(t,e,i),0,1);const r=t/s,a=e/s,n=i/s,o=(3*a-r*r)/3,l=o/3,h=(2*r*r*r-9*r*a+27*n)/27,u=h/2,c=u*u+l*l*l,d=.5,_=d+.01;if(c<0){const f=-o/3,x=f*f*f,M=this.sqrt(x),T=-h/(2*M),P=this.range(T,-1,1),V=Math.acos(P),N=2*this.cbrt(M),$t=N*this.cos(V/3)-r/3;if(this.abs($t-d)<_)return this.range($t,0,1);const Jt=N*this.cos((V+2*Math.PI)/3)-r/3;if(this.abs(Jt-d)<_)return this.range(Jt,0,1);const Fe=N*this.cos((V+4*Math.PI)/3)-r/3;return this.range(Fe,0,1)}if(c==0){let f;u<0?f=this.cbrt(-u):f=-this.cbrt(u);const x=2*f-r/3;if(this.abs(x-d)<_)return this.range(x,0,1);const M=-f-r/3;return this.range(M,0,1)}const p=this.sqrt(c),v=this.cbrt(p-u),m=this.cbrt(p+u),g=v-m-r/3;return this.range(g,0,1)}constructor(){}};let S=_t;S.Epsilon=1e-5;class k{constructor(){this._tr=new Float32Array(16),this.loadIdentity()}static multiply(t,e,i){const r=new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),a=4;for(let n=0;n<a;++n)for(let o=0;o<a;++o)for(let l=0;l<a;++l)r[o+n*4]+=t[l+n*4]*e[o+l*4];for(let n=0;n<16;++n)i[n]=r[n]}loadIdentity(){const t=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);this.setMatrix(t)}setMatrix(t){for(let e=0;e<16;++e)this._tr[e]=t[e]}getArray(){return this._tr}getScaleX(){return this._tr[0]}getScaleY(){return this._tr[5]}getTranslateX(){return this._tr[12]}getTranslateY(){return this._tr[13]}transformX(t){return this._tr[0]*t+this._tr[12]}transformY(t){return this._tr[5]*t+this._tr[13]}invertTransformX(t){return(t-this._tr[12])/this._tr[0]}invertTransformY(t){return(t-this._tr[13])/this._tr[5]}translateRelative(t,e){const i=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,t,e,0,1]);k.multiply(i,this._tr,this._tr)}translate(t,e){this._tr[12]=t,this._tr[13]=e}translateX(t){this._tr[12]=t}translateY(t){this._tr[13]=t}scaleRelative(t,e){const i=new Float32Array([t,0,0,0,0,e,0,0,0,0,1,0,0,0,0,1]);k.multiply(i,this._tr,this._tr)}scale(t,e){this._tr[0]=t,this._tr[5]=e}multiplyByMatrix(t){k.multiply(t.getArray(),this._tr,this._tr)}clone(){const t=new k;for(let e=0;e<this._tr.length;e++)t._tr[e]=this._tr[e];return t}}class Vt{initialize(t){this._model=t}drawModel(){this.getModel()!=null&&this.doDrawModel()}setMvpMatrix(t){this._mvpMatrix4x4.setMatrix(t.getArray())}getMvpMatrix(){return this._mvpMatrix4x4}setModelColor(t,e,i,r){t<0?t=0:t>1&&(t=1),e<0?e=0:e>1&&(e=1),i<0?i=0:i>1&&(i=1),r<0?r=0:r>1&&(r=1),this._modelColor.R=t,this._modelColor.G=e,this._modelColor.B=i,this._modelColor.A=r}getModelColor(){return Object.assign({},this._modelColor)}setIsPremultipliedAlpha(t){this._isPremultipliedAlpha=t}isPremultipliedAlpha(){return this._isPremultipliedAlpha}setIsCulling(t){this._isCulling=t}isCulling(){return this._isCulling}setAnisotropy(t){this._anisortopy=t}getAnisotropy(){return this._anisortopy}getModel(){return this._model}constructor(){this._isCulling=!1,this._isPremultipliedAlpha=!1,this._anisortopy=0,this._modelColor=new ot,this._mvpMatrix4x4=new k,this._mvpMatrix4x4.loadIdentity()}}var X=(s=>(s[s.CubismBlendMode_Normal=0]="CubismBlendMode_Normal",s[s.CubismBlendMode_Additive=1]="CubismBlendMode_Additive",s[s.CubismBlendMode_Multiplicative=2]="CubismBlendMode_Multiplicative",s))(X||{});class ot{constructor(){this.R=1,this.G=1,this.B=1,this.A=1}}let R=!1,Q=!1,tt;const It={vertexOffset:0,vertexStep:2};class gt{static startUp(t){if(R)return nt("CubismFramework.startUp() is already done."),R;if(Live2DCubismCore._isStarted)return R=!0,!0;if(Live2DCubismCore._isStarted=!0,tt=t,tt&&Live2DCubismCore.Logging.csmSetLogFunction(tt.logFunction),R=!0,R){const e=Live2DCubismCore.Version.csmGetVersion(),i=(e&4278190080)>>24,r=(e&16711680)>>16,a=e&65535,n=e;nt("Live2D Cubism Core version: {0}.{1}.{2} ({3})",("00"+i).slice(-2),("00"+r).slice(-2),("0000"+a).slice(-4),n)}return nt("CubismFramework.startUp() is complete."),R}static cleanUp(){R=!1,Q=!1,tt=void 0}static initialize(){if(!R){lt("CubismFramework is not started.");return}if(Q){lt("CubismFramework.initialize() skipped, already initialized.");return}Q=!0,nt("CubismFramework.initialize() is complete.")}static dispose(){if(!R){lt("CubismFramework is not started.");return}if(!Q){lt("CubismFramework.dispose() skipped, not initialized.");return}Vt.staticRelease(),Q=!1,nt("CubismFramework.dispose() is complete.")}static isStarted(){return R}static isInitialized(){return Q}static coreLogFunction(t){Live2DCubismCore.Logging.csmGetLogFunction()&&Live2DCubismCore.Logging.csmGetLogFunction()(t)}static getLoggingLevel(){return tt!=null?tt.loggingLevel:K.LogLevel_Off}constructor(){}}var K=(s=>(s[s.LogLevel_Verbose=0]="LogLevel_Verbose",s[s.LogLevel_Debug=1]="LogLevel_Debug",s[s.LogLevel_Info=2]="LogLevel_Info",s[s.LogLevel_Warning=3]="LogLevel_Warning",s[s.LogLevel_Error=4]="LogLevel_Error",s[s.LogLevel_Off=5]="LogLevel_Off",s))(K||{});const mt=()=>{};function ae(s,...t){St.print(K.LogLevel_Debug,"[CSM][D]"+s+`
|
|
9
9
|
`,t)}function nt(s,...t){St.print(K.LogLevel_Info,"[CSM][I]"+s+`
|
|
10
10
|
`,t)}function lt(s,...t){St.print(K.LogLevel_Warning,"[CSM][W]"+s+`
|
|
11
11
|
`,t)}function et(s,...t){St.print(K.LogLevel_Error,"[CSM][E]"+s+`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as F,W as U,C as _,b as z,a as D,S as L,c as E,B as J,R as Q}from"./index-
|
|
1
|
+
import{r as F,W as U,C as _,b as z,a as D,S as L,c as E,B as J,R as Q}from"./index-CC7KTie-.js";const X=""+new URL("cherryBlossoms-DzBBkOW8.webp",import.meta.url).href,G=(x,P,w,k,T,M,m)=>{const v=U.gameplay.pixiStage,S=P==="foreground"?v.foregroundEffectsContainer:v.backgroundEffectsContainer,p=E.width,a=E.height,c=new _;c.angle=m;const b=c.rotation,C=Math.abs(Math.cos(b)),h=Math.abs(Math.sin(b)),i=p*C+a*h,u=p*h+a*C;c.width=i,c.height=u,c.pivot.set(i/2,u/2),c.position.set(p/2,a/2),S.addChild(c);const r=new z(T,{scale:!0,position:!0,rotation:!0,uvs:!1,alpha:!0});c.addChild(r);const g=[],R=D.from(X),y=(d,l)=>d+Math.random()*(l-d);for(let d=0;d<T;d++){const l=Math.random()*Math.PI*2,n=L.from(R);n.anchor.set(.5),n.x=Math.random()*i,n.y=Math.random()*u,n.rotation=Math.random()*Math.PI*2,n.scale.set(Math.cos(l)*M,Math.sin(l)*M),n.speed=(y(.5,2)+y(.1,1))*w,n.rotationSpeed=Math.random()*.015*(Math.random()<.5?1:-1),n.positionPhase=Math.random()*Math.PI*2,n.scalePhase=l,g.push(n),r.addChild(n)}function I(d){const l=Date.now()/1e3;for(const n of g){const W=Math.sin(l+n.positionPhase)*k;n.x+=W*d,n.y+=n.speed*d,n.rotation+=n.rotationSpeed*d;const A=Math.cos(l+n.scalePhase)*M,B=Math.sin(l+n.scalePhase)*M;n.scale.set(A,B);const t=Math.abs(n.width*M),e=Math.abs(n.height*M);n.x+t/2<-i?n.x=i+t/2:n.x-t/2>i&&(n.x=-i-t/2),n.y-e/2>u&&(n.x=Math.random()*i,n.y=-Math.random()*50-e,n.positionPhase=Math.random()*Math.PI*2,n.scalePhase=Math.random()*Math.PI*2,n.speed=(y(.5,2)+y(.1,1))*w,n.rotationSpeed=Math.random()*.015*(Math.random()<.5?1:-1))}}return v.registerAnimation({setStartState:()=>{},setEndState:()=>{},tickerFunc:I},x),{container:c,tickerKey:x}};F("cherryBlossoms",{fg:()=>G("cherry-blossoms-foreground-ticker","foreground",2,3,100,.05,0),bg:()=>G("cherry-blossoms-background-ticker","background",1,2,300,.025,0)});const N=""+new URL("rain-Bd8ZRQ7x.png",import.meta.url).href,O=(x,P,w,k,T,M)=>{const m=U.gameplay.pixiStage;m.currentApp;const v=P==="foreground"?m.foregroundEffectsContainer:m.backgroundEffectsContainer,S=E.width,p=E.height,a=new _;a.angle=M;const c=a.rotation,b=Math.abs(Math.cos(c)),C=Math.abs(Math.sin(c)),h=S*b+p*C,i=S*C+p*b;a.width=h,a.height=i,a.pivot.set(h/2,i/2),a.position.set(S/2,p/2),v.addChild(a);const u=new z(k,{scale:!0,position:!0,rotation:!0,alpha:!0,uvs:!1});a.addChild(u);const r=[],g=[],R=128,y=640,I=5,d=[10,5,2,2,1],l=t=>{if(!t||t.length===0)return 0;const e=t.reduce((o,f)=>o+f,0);if(e<=0)return Math.floor(Math.random()*t.length);let s=Math.random()*e;for(let o=0;o<t.length;o++){if(s<t[o])return o;s-=t[o]}return t.length-1},n=(t,e=!1)=>{const s=Math.random()*.5+.5;t.scale.set(T*s),t.anchor.set(.5),e?(t.x=Math.random()*h,t.y=Math.random()*i):(t.x=Math.random()*h,t.y=-Math.random()*50-t.height),t.alpha=Math.random()*.5+.5,t.vy=(Math.random()*.4+.8)*w},W=()=>{let t;r.length===I?t=l(d):t=Math.floor(Math.random()*r.length),t=Math.max(0,Math.min(t,r.length-1));const e=new L(r[t]);return n(e,!0),e},A=t=>{for(const e of g)e.y+=e.vy*t,(e.y-e.height/2>i||e.x<-e.width||e.x>h+e.width)&&n(e,!1)};return(()=>{for(r.length=0;g.length>0;)g.pop();u.removeChildren();const t=J.from(N),e=()=>{var s;if(t.valid)for(let o=0;o<I;o++){const f=new Q(o*R,0,R,y);r.push(new D(t,f))}if(r.length===0){console.error("Failed to create any raindrop textures. Cannot create sprites.");return}(s=r[0])!=null&&s.valid||console.warn("First raindrop texture is invalid after creation. Sprites might not render correctly.");for(let o=0;o<k;o++){const f=W();u.addChild(f),g.push(f)}m.registerAnimation({setStartState:()=>{},setEndState:()=>{},tickerFunc:A},x)};t.valid?e():(t.once("loaded",()=>{e()}),t.once("error",s=>{console.error(`Error loading base texture ${N}:`,s),e()}))})(),{container:a,tickerKey:x}};F("rain",{fg:()=>O("rain-foreground-ticker","foreground",30,50,.4,1),bg:()=>O("rain-background-ticker","background",20,150,.3,1)});const $=""+new URL("snow-CJh9m2KR.png",import.meta.url).href,H=(x,P,w,k,T,M)=>{const m=U.gameplay.pixiStage;m.currentApp;const v=P==="foreground"?m.foregroundEffectsContainer:m.backgroundEffectsContainer,S=E.width,p=E.height,a=new _;a.angle=M;const c=a.rotation,b=Math.abs(Math.cos(c)),C=Math.abs(Math.sin(c)),h=S*b+p*C,i=S*C+p*b;a.width=h,a.height=i,a.pivot.set(h/2,i/2),a.position.set(S/2,p/2),v.addChild(a);const u=new z(k,{scale:!0,position:!0,rotation:!0,alpha:!0,uvs:!1});a.addChild(u);const r=[],g=[],R=128,y=128,I=10,d=[10,2,2,2,1,1,1,2,2,2],l=t=>{if(!t||t.length===0)return 0;const e=t.reduce((o,f)=>o+f,0);if(e<=0)return Math.floor(Math.random()*t.length);let s=Math.random()*e;for(let o=0;o<t.length;o++){if(s<t[o])return o;s-=t[o]}return t.length-1},n=(t,e=!1)=>{const s=Math.random()*.5+.5;t.scale.set(T*s),t.anchor.set(.5),e?(t.x=Math.random()*h,t.y=Math.random()*i):(t.x=Math.random()*h,t.y=-Math.random()*50-t.height),t.alpha=Math.random()*.2+.8,t.vy=(Math.random()*.4+.8)*w,t.vx=(Math.random()-.5)*.25*w,t.rotationSpeed=(Math.random()-.5)*.005},W=()=>{let t;r.length===I?t=l(d):t=Math.floor(Math.random()*r.length),t=Math.max(0,Math.min(t,r.length-1));const e=new L(r[t]);return n(e,!0),e},A=t=>{for(const e of g)e.y+=e.vy*t,e.x+=e.vx*t,e.rotation+=e.rotationSpeed*t,(e.y-e.height/2>i||e.x<-e.width||e.x>h+e.width)&&n(e,!1)};return(()=>{for(r.length=0;g.length>0;)g.pop();u.removeChildren();const t=J.from($),e=()=>{var s;if(t.valid)for(let o=0;o<I;o++){const f=new Q(o*R,0,R,y);r.push(new D(t,f))}if(r.length===0){console.error("Failed to create any snowflake textures. Cannot create sprites.");return}(s=r[0])!=null&&s.valid||console.warn("First snowflake texture is invalid after creation. Sprites might not render correctly.");for(let o=0;o<k;o++){const f=W();u.addChild(f),g.push(f)}m.registerAnimation({setStartState:()=>{},setEndState:()=>{},tickerFunc:A},x)};t.valid?e():(t.once("loaded",()=>{e()}),t.once("error",s=>{console.error(`Error loading base texture ${$}:`,s),e()}))})(),{container:a,tickerKey:x}};F("snow",{fg:()=>H("snow-foreground-ticker","foreground",3,250,.4,0),bg:()=>H("snow-background-ticker","background",1,750,.2,0)});F("heavySnow",{fg:()=>H("heavy-snow-foreground-ticker","foreground",20,1e3,.6,-75),bg:()=>H("heavy-snow-background-ticker","background",10,2e3,.3,-80)});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{L as r}from"./index-CC7KTie-.js";async function u(a,o){if(await r.ready,!r.isAvailable)return{value:void 0};const t=await o(a,"json"),s=t.FileReferences,i=e=>new URL(e,a).href,l=await Promise.all(((s==null?void 0:s.Textures)??t.textures??[]).map(e=>o(i(e),"texture"))),n=(s==null?void 0:s.Moc)??t.model;n&&await o(i(n),"binary");const c=s?[s.Physics,s.Pose,...(s.Expressions??[]).map(e=>e.File)]:[t.physics,t.pose,...(t.expressions??[]).map(e=>e.file)],m=s?Object.values(s.Motions??{}).flat().map(e=>e.File):Object.values(t.motions??{}).flat().map(e=>e.file);return Promise.allSettled([...c.filter(e=>!!e).map(e=>o(i(e),"json")),...m.map(e=>o(i(e),s?"json":"binary"))]),{value:t,textures:l}}export{u as loadLive2dResources};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-CC7KTie-.js","./index-Dch1g2w9.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{_,d as A,e as d,f as b}from"./index-CC7KTie-.js";async function S(a,t){const{loadPixiSpine:l}=await _(async()=>{const{loadPixiSpine:i}=await import("./index-CC7KTie-.js").then(c=>c.s);return{loadPixiSpine:i}},__vite__mapDeps([0,1]),import.meta.url),n=await l();if(!n)throw new Error("Spine 未启用,请按 WebGAL Spine 文档安装并启用运行时");const r=A(a)==="skel",p=await t(a,r?"binary":"json"),e=new URL(a);e.pathname=e.pathname.replace(/\.[^.]+$/,".atlas"),e.search="",e.hash="";const P=await t(e.href,"text"),w=[],m=await new Promise((i,c)=>{new n.TextureAtlas(P,(u,x)=>{t(new URL(u,e).href,"texture").then(s=>{u.includes("-pma.")&&s.baseTexture.alphaMode!==d.PMA&&(s.baseTexture.alphaMode=d.PMA,s.baseTexture.dispose()),w.push(s),x(s.baseTexture)}).catch(c)},i)}),o=new n.SpineParser,h=new b(a,a);return o.parseData(h,r?o.createBinaryParser():o.createJsonParser(),m,r?new Uint8Array(p):p),{value:h,textures:w}}export{S as loadSpineResources};
|
package/dist/index.html
CHANGED
|
@@ -136,7 +136,7 @@
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
</style>
|
|
139
|
-
<script type="module" crossorigin src="./assets/index-
|
|
139
|
+
<script type="module" crossorigin src="./assets/index-CC7KTie-.js"></script>
|
|
140
140
|
<link rel="stylesheet" crossorigin href="./assets/index-Dch1g2w9.css">
|
|
141
141
|
</head>
|
|
142
142
|
<body>
|
package/dist/webgal-engine.json
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"schemaVersion": "1.0.0",
|
|
3
3
|
"id": "open-webgal.webgal",
|
|
4
4
|
"name": "WebGAL",
|
|
5
|
-
"version": "4.6.
|
|
5
|
+
"version": "4.6.5",
|
|
6
6
|
"type": "official",
|
|
7
|
-
"webgalVersion": "4.6.
|
|
7
|
+
"webgalVersion": "4.6.5",
|
|
8
8
|
"description": "界面美观、功能强大、易于开发的全新网页端视觉小说引擎",
|
|
9
9
|
"descriptions": {
|
|
10
10
|
"en": "A brand new web Visual Novel engine with a beautiful interface, powerful features, and easy development",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webgal-engine",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.5",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "vite --host --port 3000",
|
|
6
6
|
"build": "node scripts/update-engine-version.js && cross-env NODE_ENV=production tsc && vite build --base=./",
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@emotion/css": "^11.11.2",
|
|
13
13
|
"@icon-park/react": "^1.4.2",
|
|
14
|
+
"@pixi/assets": "6.5.10",
|
|
15
|
+
"@pixi/basis": "6.5.10",
|
|
14
16
|
"@reduxjs/toolkit": "^1.8.1",
|
|
15
17
|
"angular-expressions": "^1.4.3",
|
|
16
18
|
"axios": "^1.13.5",
|
|
@@ -53,7 +55,6 @@
|
|
|
53
55
|
"typescript": "^4.9.5",
|
|
54
56
|
"typescript-eslint": "^8.65.0",
|
|
55
57
|
"unplugin-info": "^1.2.2",
|
|
56
|
-
"vite": "^5.4.21"
|
|
57
|
-
"vite-plugin-compression": "^0.5.1"
|
|
58
|
+
"vite": "^5.4.21"
|
|
58
59
|
}
|
|
59
60
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e=Object.defineProperty;var c=(n,t,s)=>t in n?e(n,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[t]=s;var o=(n,t,s)=>c(n,typeof t!="symbol"?t+"":t,s);class h{constructor(){o(this,"_content","")}push(t){this._content=t}pop(){const t=this._content;return this._content="",t}}class i{constructor(){o(this,"_content","")}push(t){this._content=t}pop(){const t=this._content;return this._content="",t}}const _=new h,p=new i;export{h as FigureConentsCash,i as VoiceConentsCash,_ as figureCash,p as voiceCash};
|
|
Binary file
|