Files
EzVibe/assets/live2d/march7/live2dcubismpixi.js
e2hang 798e5c2f7d checkpoint: segfault root cause analysis + Live2D stability fixes
- _refresh_messages: widget pool reuse to avoid layout cascade → QWebEngineView crash
- viewer.html: QWebChannel bridge, texture resize, burst render, gl.finish
- live2d_view.py: debug checkpoints, playMotion/setExpression render-on-demand
- main.py: Chromium flags --no-sandbox --in-process-gpu --disable-gpu-rasterization --ignore-gpu-blocklist
- scheduler.py: test_reminder re-enabled
- docs: complete root cause analysis
2026-05-23 13:33:58 +08:00

2 lines
19 KiB
JavaScript

var LIVE2DCUBISMFRAMEWORK;!function(t){var e=function(){return function(t,e){this.time=t,this.value=e}}();t.AnimationPoint=e;var i=function(){return function(t,e){this.time=t,this.value=e}}();t.AnimationUserDataBody=i;var n=function(){function t(){}return t.lerp=function(t,i,n){return new e(t.time+(i.time-t.time)*n,t.value+(i.value-t.value)*n)},t.LINEAR=function(t,e,i){var n=t[e+0],a=t[e+1],r=(i-n.time)/(a.time-n.time);return n.value+(a.value-n.value)*r},t.BEZIER=function(e,i,n){var a=(n-e[i+0].time)/(e[i+3].time-e[i].time),r=t.lerp(e[i+0],e[i+1],a),s=t.lerp(e[i+1],e[i+2],a),o=t.lerp(e[i+2],e[i+3],a),u=t.lerp(r,s,a),l=t.lerp(s,o,a);return t.lerp(u,l,a).value},t.STEPPED=function(t,e,i){return t[e+0].value},t.INVERSE_STEPPED=function(t,e,i){return t[e+1].value},t}();t.BuiltinAnimationSegmentEvaluators=n;var a=function(){return function(t,e){this.offset=t,this.evaluate=e}}();t.AnimationSegment=a;var r=function(){function t(t,e,i){this.targetId=t,this.points=e,this.segments=i}return t.prototype.evaluate=function(t){for(var e=0,i=this.segments.length-1;e<i&&this.points[this.segments[e+1].offset].time<t;++e);return this.segments[e].evaluate(this.points,this.segments[e].offset,t)},t}();t.AnimationTrack=r;var s=function(){function t(t){var s=this;this.modelTracks=new Array,this.parameterTracks=new Array,this.partOpacityTracks=new Array,this.userDataBodys=new Array,this.duration=t.Meta.Duration,this.fps=t.Meta.Fps,this.loop=t.Meta.Loop,this.userDataCount=t.Meta.UserDataCount,this.totalUserDataSize=t.Meta.TotalUserDataSize,null!=t.UserData&&(t.UserData.forEach(function(t){s.userDataBodys.push(new i(t.Time,t.Value))}),console.assert(this.userDataBodys.length===this.userDataCount)),t.Curves.forEach(function(t){var i=t.Segments,o=new Array,u=new Array;o.push(new e(i[0],i[1]));for(var l=2;l<i.length;l+=3){var c=o.length-1,h=n.LINEAR,f=i[l];1==f?(h=n.BEZIER,o.push(new e(i[l+1],i[l+2])),o.push(new e(i[l+3],i[l+4])),l+=4):2==f?h=n.STEPPED:3==f&&(h=n.INVERSE_STEPPED),o.push(new e(i[l+1],i[l+2])),u.push(new a(c,h))}var p=new r(t.Id,o,u);"Model"==t.Target?s.modelTracks.push(p):"Parameter"==t.Target?s.parameterTracks.push(p):"PartOpacity"==t.Target&&s.partOpacityTracks.push(p)})}return t.fromMotion3Json=function(e){if(null==e)return null;var i=new t(e);return i.isValid?i:null},t.prototype.addAnimationCallback=function(t){null==this._callbackFunctions&&(this._callbackFunctions=new Array),this._callbackFunctions.push(t)},t.prototype.removeAnimationCallback=function(t){if(null!=this._callbackFunctions){for(var e=-1,i=0;i<this._callbackFunctions.length;i++)if(this._callbackFunctions[i]===t){e=i;break}e>=0&&this._callbackFunctions.splice(e,1)}},t.prototype.clearAnimationCallback=function(){this._callbackFunctions=[]},t.prototype.callAnimationCallback=function(t){this._callbackFunctions.length>0&&this._callbackFunctions.forEach(function(e){e(t)})},t.prototype.evaluate=function(t,e,i,n,a,r){if(void 0===r&&(r=null),!(e<=.01)){if(this.loop)for(;t>this.duration;)t-=this.duration;if(this.parameterTracks.forEach(function(r){var s=n.parameters.ids.indexOf(r.targetId);if(s>=0){var o=r.evaluate(t);1!=a[0][s]&&(n.parameters.values[s]=n.parameters.defaultValues[s],a[0][s]=!0),n.parameters.values[s]=i(n.parameters.values[s],o,r.evaluate(0),e)}}),this.partOpacityTracks.forEach(function(r){var s=n.parts.ids.indexOf(r.targetId);if(s>=0){var o=r.evaluate(t);1!=a[1][s]&&(n.parts.opacities[s]=1,a[1][s]=!0),n.parts.opacities[s]=i(n.parts.opacities[s],o,r.evaluate(0),e)}}),this.modelTracks.forEach(function(s){if(null!=r){var o=r.getGroupById(s.targetId);if(null!=o&&"Parameter"===o.target)for(var u=0,l=o.ids;u<l.length;u++){var c=l[u],h=n.parameters.ids.indexOf(c);if(h>=0){var f=s.evaluate(t);1!=a[0][h]&&(n.parameters.values[h]=n.parameters.defaultValues[h],a[0][h]=!0),n.parameters.values[h]=i(n.parameters.values[h],f,s.evaluate(0),e)}}}}),null!=this._callbackFunctions)for(var s=0,o=this.userDataBodys;s<o.length;s++){var u=o[s];this.isEventTriggered(u.time,t,this._lastTime,this.duration)&&this.callAnimationCallback(u.value)}this._lastTime=t}},t.prototype.isEventTriggered=function(t,e,i,n){if(e>i){if(t>i&&t<e)return!0}else if(t>0&&t<e||t>i&&t<n)return!0;return!1},Object.defineProperty(t.prototype,"isValid",{get:function(){return!0},enumerable:!0,configurable:!0}),t}();t.Animation=s;var o=function(){function t(){}return t.LINEAR=function(t,e){return t/e},t}();t.BuiltinCrossfadeWeighters=o;var u=function(){return function(){}}();t.AnimationState=u;var l=function(){function t(){}return t.OVERRIDE=function(t,e,i,n){return e*n+t*(1-n)},t.ADD=function(t,e,i,n){return t+(e-i)*n},t.MULTIPLY=function(t,e,i){return t*(1+(e-1)*i)},t}();t.BuiltinAnimationBlenders=l;var c=function(){function t(){this.weight=1}return Object.defineProperty(t.prototype,"currentAnimation",{get:function(){return this._animation},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"currentTime",{get:function(){return this._time},set:function(t){this._time=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isPlaying",{get:function(){return this._play},enumerable:!0,configurable:!0}),t.prototype.play=function(t,e){void 0===e&&(e=0),this._animation&&e>0?(this._goalAnimation=t,this._goalTime=0,this._fadeTime=0,this._fadeDuration=e):(this._animation=t,this.currentTime=0,this._play=!0)},t.prototype.resume=function(){this._play=!0},t.prototype.pause=function(){this._play=!1},t.prototype.stop=function(){this._play=!1,this.currentTime=0},t.prototype._update=function(t){this._play&&(this._time+=t,this._goalTime+=t,this._fadeTime+=t,(null==this._animation||!this._animation.loop&&this._time>this._animation.duration)&&(this.stop(),this._animation=null))},t.prototype._evaluate=function(t,e){if(null!=this._animation){var i=this.weight<1?this.weight:1,n=null!=this._goalAnimation?i*this.weightCrossfade(this._fadeTime,this._fadeDuration):i;this._animation.evaluate(this._time,n,this.blend,t,e,this.groups),null!=this._goalAnimation&&(n=1-i*this.weightCrossfade(this._fadeTime,this._fadeDuration),this._goalAnimation.evaluate(this._goalTime,n,this.blend,t,e,this.groups),this._fadeTime>this._fadeDuration&&(this._animation=this._goalAnimation,this._time=this._goalTime,this._goalAnimation=null))}},t}();t.AnimationLayer=c;var h=function(){function t(t,e,i){this._target=t,this.timeScale=e,this._layers=i}return Object.defineProperty(t.prototype,"target",{get:function(){return this._target},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isPlaying",{get:function(){var t=!1;return this._layers.forEach(function(e){e.isPlaying&&(t=!0)}),t},enumerable:!0,configurable:!0}),t.prototype.addLayer=function(t,e,i){void 0===e&&(e=l.OVERRIDE),void 0===i&&(i=1);var n=new c;n.blend=e,n.weightCrossfade=o.LINEAR,n.weight=i,n.groups=this.groups,this._layers.set(t,n)},t.prototype.getLayer=function(t){return this._layers.has(t)?this._layers.get(t):null},t.prototype.removeLayer=function(t){return this._layers.has(t)?this._layers.delete(t):null},t.prototype.clearLayers=function(){this._layers.clear()},t.prototype.updateAndEvaluate=function(t){var e=this;(t*=this.timeScale>0?this.timeScale:0)>.001&&this._layers.forEach(function(e){e._update(t)});var i=new Array(this._target.parameters.count).fill(!1),n=new Array(this._target.parts.count).fill(!1),a=new Array(i,n);this._layers.forEach(function(t){t._evaluate(e._target,a)})},t._create=function(e,i,n){var a=new t(e,i,n);return a.isValid?a:null},Object.defineProperty(t.prototype,"isValid",{get:function(){return null!=this._target},enumerable:!0,configurable:!0}),t}();t.Animator=h;var f=function(){function t(){this._timeScale=1,this._layerNames=new Array,this._layerBlenders=new Array,this._layerCrossfadeWeighters=new Array,this._layerWeights=new Array}return t.prototype.setTarget=function(t){return this._target=t,this},t.prototype.setTimeScale=function(t){return this._timeScale=t,this},t.prototype.addLayer=function(t,e,i){return void 0===e&&(e=l.OVERRIDE),void 0===i&&(i=1),this._layerNames.push(t),this._layerBlenders.push(e),this._layerCrossfadeWeighters.push(o.LINEAR),this._layerWeights.push(i),this},t.prototype.build=function(){for(var t=new Map,e=0;e<this._layerNames.length;++e){var i=new c;i.blend=this._layerBlenders[e],i.weightCrossfade=this._layerCrossfadeWeighters[e],i.weight=this._layerWeights[e],t.set(this._layerNames[e],i)}return h._create(this._target,this._timeScale,t)},t}();t.AnimatorBuilder=f;var p=function(){function t(t,e){this.x=t,this.y=e}return t.distance=function(t,e){return Math.abs(t.substract(e).length)},t.dot=function(t,e){return t.x*e.x+t.y*e.y},Object.defineProperty(t.prototype,"length",{get:function(){return Math.sqrt(t.dot(this,this))},enumerable:!0,configurable:!0}),t.prototype.add=function(e){return new t(this.x+e.x,this.y+e.y)},t.prototype.substract=function(e){return new t(this.x-e.x,this.y-e.y)},t.prototype.multiply=function(e){return new t(this.x*e.x,this.y*e.y)},t.prototype.multiplyByScalar=function(e){return this.multiply(new t(e,e))},t.prototype.divide=function(e){return new t(this.x/e.x,this.y/e.y)},t.prototype.divideByScalar=function(e){return this.divide(new t(e,e))},t.prototype.rotateByRadians=function(e){return new t(this.x*Math.cos(e)-this.y*Math.sin(e),this.x*Math.sin(e)+this.y*Math.cos(e))},t.prototype.normalize=function(){var e=this.length;return new t(this.x/e,this.y/e)},t.zero=new t(0,0),t}();t.PhysicsVector2=p;var y=function(){function t(){}return t.clampScalar=function(t,e,i){return t<e?e:t>i?i:t},t.directionToDegrees=function(e,i){var n=t.directionToRadians(e,i),a=t.radiansToDegrees(n);return i.x-e.x>0?-a:a},t.radiansToDegrees=function(t){return 180*t/Math.PI},t.radiansToDirection=function(t){return new p(Math.sin(t),Math.cos(t))},t.degreesToRadians=function(t){return t/180*Math.PI},t.directionToRadians=function(t,e){var i=p.dot(t,e),n=t.length*e.length;if(0==n)return 0;var a=i/n;return Math.abs(a)<=1?Math.acos(a):0},t.gravity=new p(0,-1),t.wind=new p(0,0),t.maximumWeight=100,t.airResistance=5,t.movementThreshold=.001,t.correctAngles=!0,t}();t.Physics=y;var d=function(){return function(t,e,i,n,a){this.initialPosition=t,this.mobility=e,this.delay=i,this.acceleration=n,this.radius=a,this.position=t,this.lastPosition=this.position,this.lastGravity=new p(0,-1),this.force=new p(0,0),this.velocity=new p(0,0)}}();t.PhysicsParticle=d;var m=function(){function t(t,e,i){this.x=t,this.y=e,this.angle=i}return t.prototype.add=function(e){return new t(this.x+e.x,this.y+e.y,this.angle+e.angle)},t}();t.PhysicsFactorTuple=m;var g=function(){return function(t,e,i){this.minimum=t,this.maximum=e,this.def=i}}();t.PhysicsNormalizationTuple=g;var v=function(){return function(t,e){this.position=t,this.angle=e}}();t.PhysicsNormalizationOptions=v;var _=function(){function t(t,e,i,n){this.targetId=t,this.weight=e,this.factor=i,this.invert=n}return Object.defineProperty(t.prototype,"normalizedWeight",{get:function(){return y.clampScalar(this.weight/y.maximumWeight,0,1)},enumerable:!0,configurable:!0}),t.prototype.evaluateFactor=function(t,e,i,n,a){console.assert(i>e);var r=this.getMiddleValue(e,i),s=t-r;switch(Math.sign(s)){case 1:if(0==(o=i-r))s=a.angle.def;else 0==(u=a.angle.maximum-a.angle.def)?s=a.angle.maximum:(s*=Math.abs(u/o),s+=a.angle.def);break;case-1:var o,u;if(0==(o=r-e))s=a.angle.def;else 0==(u=a.angle.def-a.angle.minimum)?s=a.angle.minimum:(s*=Math.abs(u/o),s+=a.angle.def);break;case 0:s=a.angle.def}var l=this.weight/y.maximumWeight;return s*=this.invert?1:-1,new m(s*this.factor.x*l,s*this.factor.y*l,s*this.factor.angle*l)},t.prototype.getRangeValue=function(t,e){var i=Math.max(t,e),n=Math.min(t,e);return Math.abs(i-n)},t.prototype.getMiddleValue=function(t,e){return Math.min(t,e)+this.getRangeValue(t,e)/2},t}();t.PhysicsInput=_;var b=function(){function t(t,e,i,n,a,r){this.targetId=t,this.particleIndex=e,this.weight=i,this.factor=a,this.invert=r,this.factor.angle*=n}return Object.defineProperty(t.prototype,"normalizedWeight",{get:function(){return y.clampScalar(this.weight/y.maximumWeight,0,1)},enumerable:!0,configurable:!0}),t.prototype.evaluateValue=function(t,e){var i=t.x*this.factor.x+t.y*this.factor.y;if(this.factor.angle>0){var n=y.gravity;y.correctAngles&&this.particleIndex>1&&(n=e[this.particleIndex-2].position.substract(e[this.particleIndex-1].position));var a=y.directionToRadians(n,t);i+=(t.x-n.x>0?-a:a)*this.factor.angle}return i*=this.invert?-1:1},t}();t.PhysicsOutput=b;var w=function(){function t(t,e,i,n){this.input=t,this.output=e,this.particles=i,this.normalization=n}return t.prototype._update=function(t,e){var i=this,n=e.parameters,a=new m(0,0,0);this.input.forEach(function(t){var e=n.ids.indexOf(t.targetId);-1!=e&&(a=a.add(t.evaluateFactor(n.values[e],n.minimumValues[e],n.maximumValues[e],n.defaultValues[e],i.normalization)))});var r=y.degreesToRadians(-a.angle),s=new p(a.x,a.y).rotateByRadians(r);a.x=s.x,a.y=s.y;var o=r,u=y.radiansToDirection(o).normalize();this.particles.forEach(function(e,n){if(0!=n){e.force=u.multiplyByScalar(e.acceleration).add(y.wind),e.lastPosition=e.position;var r=e.delay*t*30,s=e.position.substract(i.particles[n-1].position),o=p.distance(p.zero,s),l=y.directionToDegrees(e.lastGravity,u),c=y.degreesToRadians(l)/y.airResistance;s=s.rotateByRadians(c).normalize(),e.position=i.particles[n-1].position.add(s.multiplyByScalar(o));var h=e.velocity.multiplyByScalar(r),f=e.force.multiplyByScalar(r).multiplyByScalar(r);e.position=e.position.add(h).add(f);var d=e.position.substract(i.particles[n-1].position).normalize();e.position=i.particles[n-1].position.add(d.multiplyByScalar(e.radius)),Math.abs(e.position.x)<y.movementThreshold&&(e.position.x=0),e.velocity=0!=r?e.position.substract(e.lastPosition).divideByScalar(r).multiplyByScalar(e.mobility):p.zero,e.force=p.zero,e.lastGravity=u}else e.position=new p(a.x,a.y)})},t.prototype._evaluate=function(t){var e=this,i=t.parameters;this.output.forEach(function(t){if(!(t.particleIndex<1||t.particleIndex>=e.particles.length)){var n=i.ids.indexOf(t.targetId);if(-1!=n){var a=e.particles[t.particleIndex-1].position.substract(e.particles[t.particleIndex].position),r=y.clampScalar(t.evaluateValue(a,e.particles),i.minimumValues[n],i.maximumValues[n]),s=i.values[n]*(1-t.normalizedWeight)+r*t.normalizedWeight;i.values[n]=y.clampScalar(s,i.minimumValues[n],i.maximumValues[n])}}})},t}();t.PhysicsSubRig=w;var D=function(){function t(t,e,i){var n=this;this.timeScale=1,this.timeScale=e,this._target=t,t&&(this._subRigs=new Array,i.PhysicsSettings.forEach(function(t){var e=new Array;t.Input.forEach(function(t){var i=new m(1,0,0);"Y"==t.Type?(i.x=0,i.y=1):"Angle"==t.Type&&(i.x=0,i.angle=1),e.push(new _(t.Source.Id,t.Weight,i,t.Reflect))});var i=new Array;t.Output.forEach(function(t){var e=new m(1,0,0);"Y"==t.Type?(e.x=0,e.y=1):"Angle"==t.Type&&(e.x=0,e.angle=1),i.push(new b(t.Destination.Id,t.VertexIndex,t.Weight,t.Scale,e,t.Reflect))});var a=new Array;t.Vertices.forEach(function(t){var e=new p(t.Position.X,t.Position.Y);a.push(new d(e,t.Mobility,t.Delay,t.Acceleration,t.Radius))});var r=t.Normalization,s=new g(r.Position.Minimum,r.Position.Maximum,r.Position.Default),o=new g(r.Angle.Minimum,r.Angle.Maximum,r.Angle.Default),u=new v(s,o);n._subRigs.push(new w(e,i,a,u))}))}return t.prototype.updateAndEvaluate=function(t){var e=this;(t*=this.timeScale>0?this.timeScale:0)>.01&&this._subRigs.forEach(function(i){i._update(t,e._target)}),this._subRigs.forEach(function(t){t._evaluate(e._target)})},t._fromPhysics3Json=function(e,i,n){var a=new t(e,i,n);return a._isValid?a:null},Object.defineProperty(t.prototype,"_isValid",{get:function(){return null!=this._target},enumerable:!0,configurable:!0}),t}();t.PhysicsRig=D;var B=function(){function t(){this._timeScale=1}return t.prototype.setTarget=function(t){return this._target=t,this},t.prototype.setTimeScale=function(t){return this._timeScale=t,this},t.prototype.setPhysics3Json=function(t){return this._physics3Json=t,this},t.prototype.build=function(){return D._fromPhysics3Json(this._target,this._timeScale,this._physics3Json)},t}();t.PhysicsRigBuilder=B;var T=function(){function t(t,e){var i=this;this._target=t,t&&(this._version=e.Version,this._userDataCount=e.Meta.UserDataCount,this._totalUserDataSize=e.Meta.TotalUserDataSize,null!=e.UserData&&(this._userDataBodys=new Array,e.UserData.forEach(function(t){i._userDataBodys.push(new E(t.Target,t.Id,t.Value))}),console.assert(this._userDataBodys.length===this._userDataCount)))}return t._fromUserData3Json=function(e,i){var n=new t(e,i);return n._isValid?n:null},Object.defineProperty(t.prototype,"_isValid",{get:function(){return null!=this._target},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"userDataCount",{get:function(){return null==this._userDataBodys?0:this._userDataCount},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"totalUserDataSize",{get:function(){return null==this._userDataBodys?0:this._totalUserDataSize},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"userDataBodys",{get:function(){return null==this._userDataBodys?null:this._userDataBodys},enumerable:!0,configurable:!0}),t.prototype.isExistUserDataById=function(t){if(null==this._userDataBodys)return!1;for(var e=0,i=this._userDataBodys;e<i.length;e++){if(i[e].id===t)return!0}return!1},t.prototype.getUserDataValueById=function(t){if(null==this._userDataBodys)return null;for(var e=0,i=this._userDataBodys;e<i.length;e++){var n=i[e];if(n.id===t)return n.value}return null},t.prototype.getUserDataTargetById=function(t){if(null==this._userDataBodys)return null;for(var e=0,i=this._userDataBodys;e<i.length;e++){var n=i[e];if(n.id===t)return n.target}return null},t.prototype.getUserDataBodyById=function(t){if(null==this._userDataBodys)return null;for(var e=0,i=this._userDataBodys;e<i.length;e++){var n=i[e];if(n.id===t)return n}return null},t}();t.UserData=T;var A=function(){function t(){}return t.prototype.setTarget=function(t){return this._target=t,this},t.prototype.setUserData3Json=function(t){return this._userData3Json=t},t.prototype.build=function(){return T._fromUserData3Json(this._target,this._userData3Json)},t}();t.UserDataBuilder=A;var x,E=function(){return function(t,e,i){this.target=t,this.id=e,this.value=i}}();t.UserDataBody=E,function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.ArtMesh=1]="ArtMesh"}(x||(x={}));var P=function(){function t(t){var e=this;void 0!==t.Groups?(this._groupBodys=new Array,t.Groups.forEach(function(t){e._groupBodys.push(new S(t.Target,t.Name,t.Ids))})):this._groupBodys=null}return Object.defineProperty(t.prototype,"data",{get:function(){return null==this._groupBodys?null:this._groupBodys},enumerable:!0,configurable:!0}),t.fromModel3Json=function(e){return new t(e)},t.prototype.getGroupById=function(t){if(null!=this._groupBodys)for(var e=0,i=this._groupBodys;e<i.length;e++){var n=i[e];if(n.name===t)return n}return null},t}();t.Groups=P;var S=function(){return function(t,e,i){this.target=t,this.name=e,this.ids=i}}();t.GroupBody=S}(LIVE2DCUBISMFRAMEWORK||(LIVE2DCUBISMFRAMEWORK={}));