live2dapi-noa 2.0.0 → 2.1.0
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/autoload.js +1 -1
- package/css/left.css +54 -72
- package/css/left.min.css +1 -1
- package/css/right.css +54 -72
- package/css/right.min.css +1 -1
- package/jsdelivr/random/autoload.js +1 -1
- package/jsdelivr/random/autoload.min.js +1 -1
- package/jsdelivr/random/waifu-tips.js +3 -2
- package/jsdelivr/sequential/autoload.js +1 -1
- package/jsdelivr/sequential/autoload.min.js +1 -1
- package/jsdelivr/sequential/waifu-tips.js +3 -2
- package/library/catalog.d.ts +29 -0
- package/live2d.min.js +12 -2
- package/modern/renderer.mjs +18 -18
- package/npm/random/autoload.js +1 -1
- package/npm/random/waifu-tips.js +3 -2
- package/npm/sequential/autoload.js +1 -1
- package/npm/sequential/waifu-tips.js +3 -2
- package/package.json +2 -1
- package/readme.md +56 -16
- package/widget.d.mts +5 -1
- package/widget.mjs +56 -8
package/live2d.min.js
CHANGED
|
@@ -81,6 +81,7 @@ function resetGaze() {
|
|
|
81
81
|
function n(t){var i=C.width,e=C.height;var r=e/i,o=w.default.VIEW_LOGICAL_LEFT,n=w.default.VIEW_LOGICAL_RIGHT,_=-r,h=r;if(window.Live2D.captureFrame=!1,B=new M.L2DViewMatrix,B.setScreenRect(o,n,_,h),B.setMaxScreenRect(w.default.VIEW_LOGICAL_MAX_LEFT,w.default.VIEW_LOGICAL_MAX_RIGHT,w.default.VIEW_LOGICAL_MAX_BOTTOM,w.default.VIEW_LOGICAL_MAX_TOP),B.setMaxScale(w.default.VIEW_MAX_SCALE),B.setMinScale(w.default.VIEW_MIN_SCALE),U=new M.L2DMatrix44,U.multScale(1,i/e),F=v(),(0,D.setContext)(F),!F)return console.error("Failed to create WebGL context."),void(window.WebGLRenderingContext&&console.error("Your browser don't support WebGL, check https://get.webgl.org/ for futher information."));window.Live2D.setGL(F),F.clearColor(0,0,0,0),a(t),s()}function s(){b||(b=!0,function t(){_();var i=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame;if(window.Live2D.captureFrame){window.Live2D.captureFrame=!1;var e=document.createElement("a");document.body.appendChild(e),e.setAttribute("type","hidden"),e.href=C.toDataURL(),e.download=window.Live2D.captureName||"live2d.png",e.click()}i(t,C)}())}function _(){if(R.getModel(0)&&R.getModel(0).hidden)return;gaze.update();O.default.reset(),O.default.loadIdentity(),F.clear(F.COLOR_BUFFER_BIT),O.default.multMatrix(U.getArray()),O.default.multMatrix(B.getArray()),O.default.push();for(var t=0;t<R.numModels();t++){var i=R.getModel(t);if(null==i)return;i.initialized&&!i.updating&&(i.setDrag(gaze.getX(),gaze.getY()),i.update(),i.draw(F))}O.default.pop()}function a(t){resetGaze();R.reloadFlg=!0,R.count++,R.changeModel(F,t)}function v(){for(var t=["webgl","experimental-webgl","webkit-3d","moz-webgl"],i=0;i<t.length;i++)try{var e=C.getContext(t[i],{premultipliedAlpha:!0});if(e)return e}catch(t){}return null}function L(canvas,url,options) {
|
|
82
82
|
o(canvas); n(url);
|
|
83
83
|
var model = R.getModel(0);
|
|
84
|
+
if (model) model.soundAliases = options && options.soundAliases;
|
|
84
85
|
if (model) model.startPending = !!(options && options.start && !document.hidden);
|
|
85
86
|
}
|
|
86
87
|
L.prepareInteraction = function () { return e(10).default.prepareInteraction(); };
|
|
@@ -169,7 +170,16 @@ function resumeAudio() {
|
|
|
169
170
|
o.prepareInteraction = function () {
|
|
170
171
|
try { resumeAudio().catch(function(){}); return true; } catch (_) { return false; }
|
|
171
172
|
};
|
|
172
|
-
function o(){n.L2DBaseModel.prototype.constructor.call(this),this.eyeBlink=new n.L2DEyeBlink,this.motionRequest=0,this.modelHomeDir="",this.modelSetting=null,this.tmpMatrix=[]}Object.defineProperty(i,"__esModule",{value:!0}),i.default=o;var n=e(0),s=e(11),_=r(s),a=e(1),h=r(a),l=e(3),$=r(l);o.prototype=new n.L2DBaseModel,o.prototype.load=function(t,i,e){this.setUpdating(!0),this.setInitialized(!1),this.modelHomeDir=i.substring(0,i.lastIndexOf("/")+1),this.modelSetting=new _.default;var r=this;this.modelSetting.loadModelSetting(i,function(){
|
|
173
|
+
function o(){n.L2DBaseModel.prototype.constructor.call(this),this.eyeBlink=new n.L2DEyeBlink,this.motionRequest=0,this.modelHomeDir="",this.modelSetting=null,this.tmpMatrix=[]}Object.defineProperty(i,"__esModule",{value:!0}),i.default=o;var n=e(0),s=e(11),_=r(s),a=e(1),h=r(a),l=e(3),$=r(l);o.prototype=new n.L2DBaseModel,o.prototype.load=function(t,i,e){this.setUpdating(!0),this.setInitialized(!1),this.modelHomeDir=i.substring(0,i.lastIndexOf("/")+1),this.modelSetting=new _.default;var r=this;this.modelSetting.loadModelSetting(i,function(){
|
|
174
|
+
if (r.soundAliases) {
|
|
175
|
+
var motions = r.modelSetting.json.motions || {};
|
|
176
|
+
Object.keys(motions).forEach(function(group) {
|
|
177
|
+
motions[group].forEach(function(motion) {
|
|
178
|
+
if (Object.prototype.hasOwnProperty.call(r.soundAliases, motion.sound)) motion.sound = r.soundAliases[motion.sound];
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
var t=r.modelHomeDir+r.modelSetting.getModelFile();r.loadModelData(t,function(t){for(var i=0;i<r.modelSetting.getTextureNum();i++){if(/^https?:\/\/|^\/\//i.test(r.modelSetting.getTextureFile(i)))var o=r.modelSetting.getTextureFile(i);else var o=r.modelHomeDir+r.modelSetting.getTextureFile(i);r.loadTexture(i,o,function(){if(r.isTexLoaded&&!r.released){if(r.modelSetting.getExpressionNum()>0){r.expressions={};for(var t=0;t<r.modelSetting.getExpressionNum();t++){var i=r.modelSetting.getExpressionName(t),o=r.modelHomeDir+r.modelSetting.getExpressionFile(t);r.loadExpression(i,o)}}else r.expressionManager=null,r.expressions={};if(r.eyeBlink,null!=r.modelSetting.getPhysicsFile()?r.loadPhysics(r.modelHomeDir+r.modelSetting.getPhysicsFile()):r.physics=null,null!=r.modelSetting.getPoseFile()?r.loadPose(r.modelHomeDir+r.modelSetting.getPoseFile(),function(){r.pose.updateParam(r.live2DModel)}):r.pose=null,null!=r.modelSetting.getLayout()){var n=r.modelSetting.getLayout();null!=n.width&&r.modelMatrix.setWidth(n.width),null!=n.height&&r.modelMatrix.setHeight(n.height),null!=n.x&&r.modelMatrix.setX(n.x),null!=n.y&&r.modelMatrix.setY(n.y),null!=n.center_x&&r.modelMatrix.centerX(n.center_x),null!=n.center_y&&r.modelMatrix.centerY(n.center_y),null!=n.top&&r.modelMatrix.top(n.top),null!=n.bottom&&r.modelMatrix.bottom(n.bottom),null!=n.left&&r.modelMatrix.left(n.left),null!=n.right&&r.modelMatrix.right(n.right)}for(var t=0;t<r.modelSetting.getInitParamNum();t++)r.live2DModel.setParamFloat(r.modelSetting.getInitParamID(t),r.modelSetting.getInitParamValue(t));for(var t=0;t<r.modelSetting.getInitPartsVisibleNum();t++)r.live2DModel.setPartsOpacity(r.modelSetting.getInitPartsVisibleID(t),r.modelSetting.getInitPartsVisibleValue(t));r.live2DModel.saveParam(),r.mainMotionManager.stopAllMotions(),r.setUpdating(!1),r.setInitialized(!0),"function"==typeof e&&e()}})}})})},
|
|
173
183
|
o.prototype.release = function (gl) {
|
|
174
184
|
this.released = true;
|
|
175
185
|
this.endDialogue(true);
|
|
@@ -426,4 +436,4 @@ o.prototype.hitTestCustom = function (name, x, y) {
|
|
|
426
436
|
return this.hitTestSimpleCustom(areas[name + "_x"], areas[name + "_y"], x, y);
|
|
427
437
|
}
|
|
428
438
|
},function(t,i,e){"use strict";function r(){this.NAME="name",this.ID="id",this.MODEL="model",this.TEXTURES="textures",this.HIT_AREAS="hit_areas",this.PHYSICS="physics",this.POSE="pose",this.EXPRESSIONS="expressions",this.MOTION_GROUPS="motions",this.SOUND="sound",this.FADE_IN="fade_in",this.FADE_OUT="fade_out",this.LAYOUT="layout",this.HIT_AREAS_CUSTOM="hit_areas_custom",this.INIT_PARAM="init_param",this.INIT_PARTS_VISIBLE="init_parts_visible",this.VALUE="val",this.FILE="file",this.json={}}Object.defineProperty(i,"__esModule",{value:!0}),i.default=r;var o=e(0);r.prototype.loadModelSetting=function(t,i){var e=this;o.Live2DFramework.getPlatformManager().loadBytes(t,function(t){var r=new TextDecoder().decode(t);e.json=JSON.parse(r),i()})},r.prototype.getTextureFile=function(t){return null==this.json[this.TEXTURES]||null==this.json[this.TEXTURES][t]?null:this.json[this.TEXTURES][t]},r.prototype.getModelFile=function(){return this.json[this.MODEL]},r.prototype.getTextureNum=function(){return null==this.json[this.TEXTURES]?0:this.json[this.TEXTURES].length},r.prototype.getHitAreaNum=function(){return null==this.json[this.HIT_AREAS]?0:this.json[this.HIT_AREAS].length},r.prototype.getHitAreaID=function(t){return null==this.json[this.HIT_AREAS]||null==this.json[this.HIT_AREAS][t]?null:this.json[this.HIT_AREAS][t][this.ID]},r.prototype.getHitAreaName=function(t){return null==this.json[this.HIT_AREAS]||null==this.json[this.HIT_AREAS][t]?null:this.json[this.HIT_AREAS][t][this.NAME]},r.prototype.getPhysicsFile=function(){return this.json[this.PHYSICS]},r.prototype.getPoseFile=function(){return this.json[this.POSE]},r.prototype.getExpressionNum=function(){return null==this.json[this.EXPRESSIONS]?0:this.json[this.EXPRESSIONS].length},r.prototype.getExpressionFile=function(t){return null==this.json[this.EXPRESSIONS]?null:this.json[this.EXPRESSIONS][t][this.FILE]},r.prototype.getExpressionName=function(t){return null==this.json[this.EXPRESSIONS]?null:this.json[this.EXPRESSIONS][t][this.NAME]},r.prototype.getLayout=function(){return this.json[this.LAYOUT]},r.prototype.getHitAreasCustom=function(){return this.json[this.HIT_AREAS_CUSTOM]},r.prototype.getInitParamNum=function(){return null==this.json[this.INIT_PARAM]?0:this.json[this.INIT_PARAM].length},r.prototype.getMotionNum=function(t){return null==this.json[this.MOTION_GROUPS]||null==this.json[this.MOTION_GROUPS][t]?0:this.json[this.MOTION_GROUPS][t].length},r.prototype.getMotionFile=function(t,i){return null==this.json[this.MOTION_GROUPS]||null==this.json[this.MOTION_GROUPS][t]||null==this.json[this.MOTION_GROUPS][t][i]?null:this.json[this.MOTION_GROUPS][t][i][this.FILE]},r.prototype.getMotionSound=function(t,i){return null==this.json[this.MOTION_GROUPS]||null==this.json[this.MOTION_GROUPS][t]||null==this.json[this.MOTION_GROUPS][t][i]||null==this.json[this.MOTION_GROUPS][t][i][this.SOUND]?null:this.json[this.MOTION_GROUPS][t][i][this.SOUND]},r.prototype.getMotionFadeIn=function(t,i){return null==this.json[this.MOTION_GROUPS]||null==this.json[this.MOTION_GROUPS][t]||null==this.json[this.MOTION_GROUPS][t][i]||null==this.json[this.MOTION_GROUPS][t][i][this.FADE_IN]?1e3:this.json[this.MOTION_GROUPS][t][i][this.FADE_IN]},r.prototype.getMotionFadeOut=function(t,i){return null==this.json[this.MOTION_GROUPS]||null==this.json[this.MOTION_GROUPS][t]||null==this.json[this.MOTION_GROUPS][t][i]||null==this.json[this.MOTION_GROUPS][t][i][this.FADE_OUT]?1e3:this.json[this.MOTION_GROUPS][t][i][this.FADE_OUT]},r.prototype.getInitParamID=function(t){return null==this.json[this.INIT_PARAM]||null==this.json[this.INIT_PARAM][t]?null:this.json[this.INIT_PARAM][t][this.ID]},r.prototype.getInitParamValue=function(t){return null==this.json[this.INIT_PARAM]||null==this.json[this.INIT_PARAM][t]?NaN:this.json[this.INIT_PARAM][t][this.VALUE]},r.prototype.getInitPartsVisibleNum=function(){return null==this.json[this.INIT_PARTS_VISIBLE]?0:this.json[this.INIT_PARTS_VISIBLE].length},r.prototype.getInitPartsVisibleID=function(t){return null==this.json[this.INIT_PARTS_VISIBLE]||null==this.json[this.INIT_PARTS_VISIBLE][t]?null:this.json[this.INIT_PARTS_VISIBLE][t][this.ID]},r.prototype.getInitPartsVisibleValue=function(t){return null==this.json[this.INIT_PARTS_VISIBLE]||null==this.json[this.INIT_PARTS_VISIBLE][t]?NaN:this.json[this.INIT_PARTS_VISIBLE][t][this.VALUE]}}]);;
|
|
429
|
-
"use strict";(()=>{function L(
|
|
439
|
+
"use strict";(()=>{function L(d){return d.pathname.toLowerCase().endsWith(".model3.json")}function w(d,n){let l,e,o,m=0,c=!1;function b(){return l??(l=new Promise((t,u)=>{let r=document.createElement("script");r.src=d+"live2d.min.js",r.acceptCubism2=s=>{n=s,t(s)},r.onerror=()=>u(new Error("Failed to load "+r.src)),document.head.appendChild(r)}).catch(t=>{throw l=void 0,t}))}let a=(t,u,r)=>{let s=++m;e?.abort(),e=void 0,o=void 0,c=!1;let h=new URL(u,document.baseURI);if(!L(h))return n?n(t,u,r):b().then(i=>{if(m!==s)return;let f=i(t,u,r);return c&&i.hide?.(),f});n?.hide?.(),e=new AbortController;let{signal:p}=e;return import(d+"modern/renderer.mjs").then(async i=>{if(p.aborted)return;let f=await i.mountModern(document.getElementById(t),h.href,r?.coreUrl,p,r?.dialogue);p.aborted||(o=f,c&&o.pause())}).catch(i=>{if(!p.aborted)throw e=void 0,i})};return a.hide=()=>{c=!0,e?o?.pause():n?.hide?.()},a.show=t=>{c=!1,e?o?.resume():n?.show?.(t)},a.prepareInteraction=()=>!e&&!!n?.prepareInteraction?.(),a.capture=()=>(e&&o?.capture(),!!e),a}var R=document.currentScript;if(!R?.acceptCubism2){let d=new URL(".",R?.src||document.baseURI).href;window.loadlive2d=w(d,window.loadlive2d)}})();
|