@galacean/engine-spine 4.2.2 → 4.2.4
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/browser.js +1 -1
- package/dist/main.js +677 -251
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +677 -251
- package/dist/module.js +678 -253
- package/dist/module.js.map +1 -1
- package/package.json +5 -4
- package/types/renderer/SpineAnimationRenderer.d.ts +18 -7
- package/types/renderer/SpineGenerator.d.ts +3 -4
- package/types/renderer/SpineMaterial.d.ts +23 -1
- package/types/SpineAnimation.d.ts +0 -48
- package/types/SpineLoader.d.ts +0 -32
- package/types/SpineMaterial.d.ts +0 -6
- package/types/SpineRenderer.d.ts +0 -38
- package/types/core/MeshGenerator.d.ts +0 -43
- package/types/core/SpineMesh.d.ts +0 -11
- package/types/spine-core/Animation.d.ts +0 -378
- package/types/spine-core/AnimationState.d.ts +0 -365
- package/types/spine-core/AnimationStateData.d.ts +0 -23
- package/types/spine-core/AssetManager.d.ts +0 -36
- package/types/spine-core/AtlasAttachmentLoader.d.ts +0 -23
- package/types/spine-core/BlendMode.d.ts +0 -7
- package/types/spine-core/Bone.d.ts +0 -110
- package/types/spine-core/BoneData.d.ts +0 -44
- package/types/spine-core/ConstraintData.d.ts +0 -7
- package/types/spine-core/Event.d.ts +0 -16
- package/types/spine-core/EventData.d.ts +0 -13
- package/types/spine-core/IkConstraint.d.ts +0 -38
- package/types/spine-core/IkConstraintData.d.ts +0 -26
- package/types/spine-core/PathConstraint.d.ts +0 -46
- package/types/spine-core/PathConstraintData.d.ts +0 -52
- package/types/spine-core/SharedAssetManager.d.ts +0 -19
- package/types/spine-core/Skeleton.d.ts +0 -134
- package/types/spine-core/SkeletonBinary.d.ts +0 -49
- package/types/spine-core/SkeletonBounds.d.ts +0 -48
- package/types/spine-core/SkeletonClipping.d.ts +0 -22
- package/types/spine-core/SkeletonData.d.ts +0 -89
- package/types/spine-core/SkeletonJson.d.ts +0 -34
- package/types/spine-core/Skin.d.ts +0 -43
- package/types/spine-core/Slot.d.ts +0 -42
- package/types/spine-core/SlotData.d.ts +0 -23
- package/types/spine-core/Texture.d.ts +0 -46
- package/types/spine-core/TextureAtlas.d.ts +0 -30
- package/types/spine-core/TransformConstraint.d.ts +0 -36
- package/types/spine-core/TransformConstraintData.d.ts +0 -34
- package/types/spine-core/Triangulator.d.ts +0 -14
- package/types/spine-core/Updatable.d.ts +0 -9
- package/types/spine-core/Utils.d.ts +0 -124
- package/types/spine-core/VertexEffect.d.ts +0 -7
- package/types/spine-core/attachments/Attachment.d.ts +0 -43
- package/types/spine-core/attachments/AttachmentLoader.d.ts +0 -25
- package/types/spine-core/attachments/AttachmentType.d.ts +0 -9
- package/types/spine-core/attachments/BoundingBoxAttachment.d.ts +0 -12
- package/types/spine-core/attachments/ClippingAttachment.d.ts +0 -14
- package/types/spine-core/attachments/MeshAttachment.d.ts +0 -46
- package/types/spine-core/attachments/PathAttachment.d.ts +0 -19
- package/types/spine-core/attachments/PointAttachment.d.ts +0 -20
- package/types/spine-core/attachments/RegionAttachment.d.ts +0 -88
- package/types/spine-core/polyfills.d.ts +0 -3
- package/types/spine-core/vertexeffects/JitterEffect.d.ts +0 -11
- package/types/spine-core/vertexeffects/SwirlEffect.d.ts +0 -16
- package/types/types.d.ts +0 -4
- package/types/util/BlendMode.d.ts +0 -4
package/dist/miniprogram.js
CHANGED
|
@@ -44,6 +44,97 @@ function __decorate(decorators, target, key, desc) {
|
|
|
44
44
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
45
45
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
46
46
|
}
|
|
47
|
+
function __generator(thisArg, body) {
|
|
48
|
+
var _ = {
|
|
49
|
+
label: 0,
|
|
50
|
+
sent: function sent() {
|
|
51
|
+
if (t[0] & 1) throw t[1];
|
|
52
|
+
return t[1];
|
|
53
|
+
},
|
|
54
|
+
trys: [],
|
|
55
|
+
ops: []
|
|
56
|
+
}, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
57
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
58
|
+
return this;
|
|
59
|
+
}), g;
|
|
60
|
+
function verb(n) {
|
|
61
|
+
return function(v) {
|
|
62
|
+
return step([
|
|
63
|
+
n,
|
|
64
|
+
v
|
|
65
|
+
]);
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function step(op) {
|
|
69
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
70
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
71
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
72
|
+
if (y = 0, t) op = [
|
|
73
|
+
op[0] & 2,
|
|
74
|
+
t.value
|
|
75
|
+
];
|
|
76
|
+
switch(op[0]){
|
|
77
|
+
case 0:
|
|
78
|
+
case 1:
|
|
79
|
+
t = op;
|
|
80
|
+
break;
|
|
81
|
+
case 4:
|
|
82
|
+
_.label++;
|
|
83
|
+
return {
|
|
84
|
+
value: op[1],
|
|
85
|
+
done: false
|
|
86
|
+
};
|
|
87
|
+
case 5:
|
|
88
|
+
_.label++;
|
|
89
|
+
y = op[1];
|
|
90
|
+
op = [
|
|
91
|
+
0
|
|
92
|
+
];
|
|
93
|
+
continue;
|
|
94
|
+
case 7:
|
|
95
|
+
op = _.ops.pop();
|
|
96
|
+
_.trys.pop();
|
|
97
|
+
continue;
|
|
98
|
+
default:
|
|
99
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
100
|
+
_ = 0;
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
104
|
+
_.label = op[1];
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
108
|
+
_.label = t[1];
|
|
109
|
+
t = op;
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
if (t && _.label < t[2]) {
|
|
113
|
+
_.label = t[2];
|
|
114
|
+
_.ops.push(op);
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
if (t[2]) _.ops.pop();
|
|
118
|
+
_.trys.pop();
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
op = body.call(thisArg, _);
|
|
122
|
+
} catch (e) {
|
|
123
|
+
op = [
|
|
124
|
+
6,
|
|
125
|
+
e
|
|
126
|
+
];
|
|
127
|
+
y = 0;
|
|
128
|
+
} finally{
|
|
129
|
+
f = t = 0;
|
|
130
|
+
}
|
|
131
|
+
if (op[0] & 5) throw op[1];
|
|
132
|
+
return {
|
|
133
|
+
value: op[0] ? op[1] : void 0,
|
|
134
|
+
done: true
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
}
|
|
47
138
|
typeof SuppressedError === "function" ? SuppressedError : function _SuppressedError(error, suppressed, message) {
|
|
48
139
|
var e = new Error(message);
|
|
49
140
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
@@ -203,8 +294,9 @@ var Color = /*#__PURE__*/ function() {
|
|
|
203
294
|
color.g = ((value & 0x0000ff00) >>> 8) / 255;
|
|
204
295
|
color.b = (value & 0x000000ff) / 255;
|
|
205
296
|
};
|
|
206
|
-
Color.fromString = function fromString(hex) {
|
|
207
|
-
|
|
297
|
+
Color.fromString = function fromString(hex, color) {
|
|
298
|
+
if (color === void 0) color = new Color();
|
|
299
|
+
return color.setFromString(hex);
|
|
208
300
|
};
|
|
209
301
|
return Color;
|
|
210
302
|
}();
|
|
@@ -2828,18 +2920,16 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
2828
2920
|
var finished = this.updateMixingFrom(from, delta);
|
|
2829
2921
|
from.animationLast = from.nextAnimationLast;
|
|
2830
2922
|
from.trackLast = from.nextTrackLast;
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
this.queue.end(from);
|
|
2840
|
-
}
|
|
2841
|
-
return finished;
|
|
2923
|
+
// The from entry was applied at least once and the mix is complete.
|
|
2924
|
+
if (to.nextTrackLast != -1 && to.mixTime >= to.mixDuration) {
|
|
2925
|
+
// Mixing is complete for all entries before the from entry or the mix is instantaneous.
|
|
2926
|
+
if (from.totalAlpha == 0 || to.mixDuration == 0) {
|
|
2927
|
+
to.mixingFrom = from.mixingFrom;
|
|
2928
|
+
if (from.mixingFrom != null) from.mixingFrom.mixingTo = to;
|
|
2929
|
+
to.interruptAlpha = from.interruptAlpha;
|
|
2930
|
+
this.queue.end(from);
|
|
2842
2931
|
}
|
|
2932
|
+
return finished;
|
|
2843
2933
|
}
|
|
2844
2934
|
from.trackTime += delta * from.timeScale;
|
|
2845
2935
|
to.mixTime += delta;
|
|
@@ -3204,10 +3294,11 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
3204
3294
|
if (!last) {
|
|
3205
3295
|
this.setCurrent(trackIndex, entry, true);
|
|
3206
3296
|
this.queue.drain();
|
|
3297
|
+
if (delay < 0) delay = 0;
|
|
3207
3298
|
} else {
|
|
3208
3299
|
last.next = entry;
|
|
3209
3300
|
entry.previous = last;
|
|
3210
|
-
if (delay <= 0) delay
|
|
3301
|
+
if (delay <= 0) delay = Math.max(delay + last.getTrackComplete() - entry.mixDuration, 0);
|
|
3211
3302
|
}
|
|
3212
3303
|
entry.delay = delay;
|
|
3213
3304
|
return entry;
|
|
@@ -3246,7 +3337,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
3246
3337
|
if (mixDuration === void 0) mixDuration = 0;
|
|
3247
3338
|
if (delay === void 0) delay = 0;
|
|
3248
3339
|
var entry = this.addAnimationWith(trackIndex, AnimationState.emptyAnimation(), false, delay);
|
|
3249
|
-
if (delay <= 0) entry.delay
|
|
3340
|
+
if (delay <= 0) entry.delay = Math.max(entry.delay + entry.mixDuration - mixDuration, 0);
|
|
3250
3341
|
entry.mixDuration = mixDuration;
|
|
3251
3342
|
entry.trackEnd = mixDuration;
|
|
3252
3343
|
return entry;
|
|
@@ -3500,7 +3591,10 @@ AnimationState._emptyAnimation = new Animation("<empty>", [], 0);
|
|
|
3500
3591
|
var _proto = TrackEntry.prototype;
|
|
3501
3592
|
_proto.setMixDurationWithDelay = function setMixDurationWithDelay(mixDuration, delay) {
|
|
3502
3593
|
this._mixDuration = mixDuration;
|
|
3503
|
-
if (
|
|
3594
|
+
if (delay <= 0) {
|
|
3595
|
+
if (this.previous != null) delay = Math.max(delay + this.previous.getTrackComplete() - mixDuration, 0);
|
|
3596
|
+
else delay = 0;
|
|
3597
|
+
}
|
|
3504
3598
|
this.delay = delay;
|
|
3505
3599
|
};
|
|
3506
3600
|
_proto.reset = function reset() {
|
|
@@ -3723,17 +3817,17 @@ var CURRENT = 2;
|
|
|
3723
3817
|
|
|
3724
3818
|
/******************************************************************************
|
|
3725
3819
|
* Spine Runtimes License Agreement
|
|
3726
|
-
* Last updated
|
|
3820
|
+
* Last updated April 5, 2025. Replaces all prior versions.
|
|
3727
3821
|
*
|
|
3728
|
-
* Copyright (c) 2013-
|
|
3822
|
+
* Copyright (c) 2013-2025, Esoteric Software LLC
|
|
3729
3823
|
*
|
|
3730
3824
|
* Integration of the Spine Runtimes into software or otherwise creating
|
|
3731
3825
|
* derivative works of the Spine Runtimes is permitted under the terms and
|
|
3732
3826
|
* conditions of Section 2 of the Spine Editor License Agreement:
|
|
3733
3827
|
* http://esotericsoftware.com/spine-editor-license
|
|
3734
3828
|
*
|
|
3735
|
-
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
|
3736
|
-
* otherwise create derivative works of the Spine Runtimes (collectively,
|
|
3829
|
+
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
|
3830
|
+
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
|
3737
3831
|
* "Products"), provided that each user of the Products must obtain their own
|
|
3738
3832
|
* Spine Editor license and redistribution of the Products in any form must
|
|
3739
3833
|
* include this license and copyright notice.
|
|
@@ -3746,8 +3840,8 @@ var CURRENT = 2;
|
|
|
3746
3840
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
|
3747
3841
|
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
|
3748
3842
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
3749
|
-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
3750
|
-
* SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
3843
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
3844
|
+
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
3751
3845
|
*****************************************************************************/ /** Stores mix (crossfade) durations to be applied when {@link AnimationState} animations are changed. */ var AnimationStateData = /*#__PURE__*/ function() {
|
|
3752
3846
|
function AnimationStateData(skeletonData) {
|
|
3753
3847
|
this.animationToMixTime = {};
|
|
@@ -4199,7 +4293,7 @@ var TextureAtlasRegion = /*#__PURE__*/ function(TextureRegion) {
|
|
|
4199
4293
|
this.copyTo(copy);
|
|
4200
4294
|
copy.regionUVs = new Array(this.regionUVs.length);
|
|
4201
4295
|
Utils.arrayCopy(this.regionUVs, 0, copy.regionUVs, 0, this.regionUVs.length);
|
|
4202
|
-
copy.uvs = new Array(this.uvs.length);
|
|
4296
|
+
copy.uvs = _instanceof1(this.uvs, Float32Array) ? Utils.newFloatArray(this.uvs.length) : new Array(this.uvs.length);
|
|
4203
4297
|
Utils.arrayCopy(this.uvs, 0, copy.uvs, 0, this.uvs.length);
|
|
4204
4298
|
copy.triangles = new Array(this.triangles.length);
|
|
4205
4299
|
Utils.arrayCopy(this.triangles, 0, copy.triangles, 0, this.triangles.length);
|
|
@@ -4863,17 +4957,17 @@ RegionAttachment.V4 = 31;
|
|
|
4863
4957
|
|
|
4864
4958
|
/******************************************************************************
|
|
4865
4959
|
* Spine Runtimes License Agreement
|
|
4866
|
-
* Last updated
|
|
4960
|
+
* Last updated April 5, 2025. Replaces all prior versions.
|
|
4867
4961
|
*
|
|
4868
|
-
* Copyright (c) 2013-
|
|
4962
|
+
* Copyright (c) 2013-2025, Esoteric Software LLC
|
|
4869
4963
|
*
|
|
4870
4964
|
* Integration of the Spine Runtimes into software or otherwise creating
|
|
4871
4965
|
* derivative works of the Spine Runtimes is permitted under the terms and
|
|
4872
4966
|
* conditions of Section 2 of the Spine Editor License Agreement:
|
|
4873
4967
|
* http://esotericsoftware.com/spine-editor-license
|
|
4874
4968
|
*
|
|
4875
|
-
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
|
4876
|
-
* otherwise create derivative works of the Spine Runtimes (collectively,
|
|
4969
|
+
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
|
4970
|
+
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
|
4877
4971
|
* "Products"), provided that each user of the Products must obtain their own
|
|
4878
4972
|
* Spine Editor license and redistribution of the Products in any form must
|
|
4879
4973
|
* include this license and copyright notice.
|
|
@@ -4886,8 +4980,8 @@ RegionAttachment.V4 = 31;
|
|
|
4886
4980
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
|
4887
4981
|
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
|
4888
4982
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
4889
|
-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
4890
|
-
* SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
4983
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
4984
|
+
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
4891
4985
|
*****************************************************************************/ /** The base class for all constraint datas. */ var ConstraintData = function ConstraintData(name, order, skinRequired) {
|
|
4892
4986
|
this.name = name;
|
|
4893
4987
|
this.order = order;
|
|
@@ -4895,18 +4989,46 @@ RegionAttachment.V4 = 31;
|
|
|
4895
4989
|
}
|
|
4896
4990
|
;
|
|
4897
4991
|
|
|
4992
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
4993
|
+
try {
|
|
4994
|
+
var info = gen[key](arg);
|
|
4995
|
+
var value = info.value;
|
|
4996
|
+
} catch (error) {
|
|
4997
|
+
reject(error);
|
|
4998
|
+
return;
|
|
4999
|
+
}
|
|
5000
|
+
if (info.done) resolve(value);
|
|
5001
|
+
else Promise.resolve(value).then(_next, _throw);
|
|
5002
|
+
}
|
|
5003
|
+
function _async_to_generator(fn) {
|
|
5004
|
+
return function() {
|
|
5005
|
+
var self = this, args = arguments;
|
|
5006
|
+
return new Promise(function(resolve, reject) {
|
|
5007
|
+
var gen = fn.apply(self, args);
|
|
5008
|
+
function _next(value) {
|
|
5009
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
5010
|
+
}
|
|
5011
|
+
function _throw(err) {
|
|
5012
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
5013
|
+
}
|
|
5014
|
+
_next(undefined);
|
|
5015
|
+
});
|
|
5016
|
+
};
|
|
5017
|
+
}
|
|
5018
|
+
|
|
4898
5019
|
var AssetManagerBase = /*#__PURE__*/ function() {
|
|
4899
|
-
function AssetManagerBase(textureLoader, pathPrefix, downloader) {
|
|
5020
|
+
function AssetManagerBase(textureLoader, pathPrefix, downloader, cache) {
|
|
4900
5021
|
if (pathPrefix === void 0) pathPrefix = "";
|
|
4901
5022
|
if (downloader === void 0) downloader = new Downloader();
|
|
5023
|
+
if (cache === void 0) cache = new AssetCache();
|
|
4902
5024
|
this.pathPrefix = "";
|
|
4903
|
-
this.assets = {};
|
|
4904
5025
|
this.errors = {};
|
|
4905
5026
|
this.toLoad = 0;
|
|
4906
5027
|
this.loaded = 0;
|
|
4907
5028
|
this.textureLoader = textureLoader;
|
|
4908
5029
|
this.pathPrefix = pathPrefix;
|
|
4909
5030
|
this.downloader = downloader;
|
|
5031
|
+
this.cache = cache;
|
|
4910
5032
|
}
|
|
4911
5033
|
var _proto = AssetManagerBase.prototype;
|
|
4912
5034
|
_proto.start = function start(path) {
|
|
@@ -4916,7 +5038,8 @@ var AssetManagerBase = /*#__PURE__*/ function() {
|
|
|
4916
5038
|
_proto.success = function success(callback, path, asset) {
|
|
4917
5039
|
this.toLoad--;
|
|
4918
5040
|
this.loaded++;
|
|
4919
|
-
this.assets[path] = asset;
|
|
5041
|
+
this.cache.assets[path] = asset;
|
|
5042
|
+
this.cache.assetsRefCount[path] = (this.cache.assetsRefCount[path] || 0) + 1;
|
|
4920
5043
|
if (callback) callback(path, asset);
|
|
4921
5044
|
};
|
|
4922
5045
|
_proto.error = function error(callback, path, message) {
|
|
@@ -4948,10 +5071,16 @@ var AssetManagerBase = /*#__PURE__*/ function() {
|
|
|
4948
5071
|
if (success === void 0) success = function() {};
|
|
4949
5072
|
if (error === void 0) error = function() {};
|
|
4950
5073
|
path = this.start(path);
|
|
4951
|
-
this.
|
|
4952
|
-
|
|
4953
|
-
|
|
4954
|
-
|
|
5074
|
+
if (this.reuseAssets(path, success, error)) return;
|
|
5075
|
+
this.cache.assetsLoaded[path] = new Promise(function(resolve, reject) {
|
|
5076
|
+
_this.downloader.downloadBinary(path, function(data) {
|
|
5077
|
+
_this.success(success, path, data);
|
|
5078
|
+
resolve(data);
|
|
5079
|
+
}, function(status, responseText) {
|
|
5080
|
+
var errorMsg = "Couldn't load binary " + path + ": status " + status + ", " + responseText;
|
|
5081
|
+
_this.error(error, path, errorMsg);
|
|
5082
|
+
reject(errorMsg);
|
|
5083
|
+
});
|
|
4955
5084
|
});
|
|
4956
5085
|
};
|
|
4957
5086
|
_proto.loadText = function loadText(path, success, error) {
|
|
@@ -4970,46 +5099,83 @@ var AssetManagerBase = /*#__PURE__*/ function() {
|
|
|
4970
5099
|
if (success === void 0) success = function() {};
|
|
4971
5100
|
if (error === void 0) error = function() {};
|
|
4972
5101
|
path = this.start(path);
|
|
4973
|
-
this.
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
5102
|
+
if (this.reuseAssets(path, success, error)) return;
|
|
5103
|
+
this.cache.assetsLoaded[path] = new Promise(function(resolve, reject) {
|
|
5104
|
+
_this.downloader.downloadJson(path, function(data) {
|
|
5105
|
+
_this.success(success, path, data);
|
|
5106
|
+
resolve(data);
|
|
5107
|
+
}, function(status, responseText) {
|
|
5108
|
+
var errorMsg = "Couldn't load JSON " + path + ": status " + status + ", " + responseText;
|
|
5109
|
+
_this.error(error, path, errorMsg);
|
|
5110
|
+
reject(errorMsg);
|
|
5111
|
+
});
|
|
4977
5112
|
});
|
|
4978
5113
|
};
|
|
4979
|
-
_proto.
|
|
5114
|
+
_proto.reuseAssets = function reuseAssets(path, success, error) {
|
|
4980
5115
|
var _this = this;
|
|
4981
5116
|
if (success === void 0) success = function() {};
|
|
4982
5117
|
if (error === void 0) error = function() {};
|
|
4983
|
-
|
|
4984
|
-
var
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
return blob ? createImageBitmap(blob, {
|
|
4995
|
-
premultiplyAlpha: "none",
|
|
4996
|
-
colorSpaceConversion: "none"
|
|
4997
|
-
}) : null;
|
|
4998
|
-
}).then(function(bitmap) {
|
|
4999
|
-
if (bitmap) _this.success(success, path, _this.textureLoader(bitmap));
|
|
5118
|
+
var loadedStatus = this.cache.assetsLoaded[path];
|
|
5119
|
+
var alreadyExistsOrLoading = loadedStatus !== undefined;
|
|
5120
|
+
if (alreadyExistsOrLoading) {
|
|
5121
|
+
this.cache.assetsLoaded[path] = loadedStatus.then(function(data) {
|
|
5122
|
+
// necessary when user preloads an image into the cache.
|
|
5123
|
+
// texture loader is not avaiable in the cache, so we transform in GLTexture at first use
|
|
5124
|
+
data = _instanceof1(data, engineMiniprogramAdapter.Image) || _instanceof1(data, ImageBitmap) ? _this.textureLoader(data) : data;
|
|
5125
|
+
_this.success(success, path, data);
|
|
5126
|
+
return data;
|
|
5127
|
+
}).catch(function(errorMsg) {
|
|
5128
|
+
return _this.error(error, path, errorMsg);
|
|
5000
5129
|
});
|
|
5001
|
-
} else {
|
|
5002
|
-
var image = new engineMiniprogramAdapter.Image();
|
|
5003
|
-
image.crossOrigin = "anonymous";
|
|
5004
|
-
image.onload = function() {
|
|
5005
|
-
_this.success(success, path, _this.textureLoader(image));
|
|
5006
|
-
};
|
|
5007
|
-
image.onerror = function() {
|
|
5008
|
-
_this.error(error, path, "Couldn't load image: " + path);
|
|
5009
|
-
};
|
|
5010
|
-
if (this.downloader.rawDataUris[path]) path = this.downloader.rawDataUris[path];
|
|
5011
|
-
image.src = path;
|
|
5012
5130
|
}
|
|
5131
|
+
return alreadyExistsOrLoading;
|
|
5132
|
+
};
|
|
5133
|
+
_proto.loadTexture = function loadTexture(path, success, error) {
|
|
5134
|
+
var _this = this;
|
|
5135
|
+
if (success === void 0) success = function() {};
|
|
5136
|
+
if (error === void 0) error = function() {};
|
|
5137
|
+
path = this.start(path);
|
|
5138
|
+
if (this.reuseAssets(path, success, error)) return;
|
|
5139
|
+
this.cache.assetsLoaded[path] = new Promise(function(resolve, reject) {
|
|
5140
|
+
var isBrowser = !!(typeof engineMiniprogramAdapter.window !== 'undefined' && typeof engineMiniprogramAdapter.navigator !== 'undefined' && engineMiniprogramAdapter.window.document);
|
|
5141
|
+
var isWebWorker = !isBrowser; // && typeof importScripts !== 'undefined';
|
|
5142
|
+
if (isWebWorker) {
|
|
5143
|
+
fetch(path, {
|
|
5144
|
+
mode: "cors"
|
|
5145
|
+
}).then(function(response) {
|
|
5146
|
+
if (response.ok) return response.blob();
|
|
5147
|
+
var errorMsg = "Couldn't load image: " + path;
|
|
5148
|
+
_this.error(error, path, "Couldn't load image: " + path);
|
|
5149
|
+
reject(errorMsg);
|
|
5150
|
+
}).then(function(blob) {
|
|
5151
|
+
return blob ? createImageBitmap(blob, {
|
|
5152
|
+
premultiplyAlpha: "none",
|
|
5153
|
+
colorSpaceConversion: "none"
|
|
5154
|
+
}) : null;
|
|
5155
|
+
}).then(function(bitmap) {
|
|
5156
|
+
if (bitmap) {
|
|
5157
|
+
var texture = _this.textureLoader(bitmap);
|
|
5158
|
+
_this.success(success, path, texture);
|
|
5159
|
+
resolve(texture);
|
|
5160
|
+
}
|
|
5161
|
+
});
|
|
5162
|
+
} else {
|
|
5163
|
+
var image = new engineMiniprogramAdapter.Image();
|
|
5164
|
+
image.crossOrigin = "anonymous";
|
|
5165
|
+
image.onload = function() {
|
|
5166
|
+
var texture = _this.textureLoader(image);
|
|
5167
|
+
_this.success(success, path, texture);
|
|
5168
|
+
resolve(texture);
|
|
5169
|
+
};
|
|
5170
|
+
image.onerror = function() {
|
|
5171
|
+
var errorMsg = "Couldn't load image: " + path;
|
|
5172
|
+
_this.error(error, path, errorMsg);
|
|
5173
|
+
reject(errorMsg);
|
|
5174
|
+
};
|
|
5175
|
+
if (_this.downloader.rawDataUris[path]) path = _this.downloader.rawDataUris[path];
|
|
5176
|
+
image.src = path;
|
|
5177
|
+
}
|
|
5178
|
+
});
|
|
5013
5179
|
};
|
|
5014
5180
|
_proto.loadTextureAtlas = function loadTextureAtlas(path, success, error, fileAlias) {
|
|
5015
5181
|
var _this = this;
|
|
@@ -5018,53 +5184,189 @@ var AssetManagerBase = /*#__PURE__*/ function() {
|
|
|
5018
5184
|
var index = path.lastIndexOf("/");
|
|
5019
5185
|
var parent = index >= 0 ? path.substring(0, index + 1) : "";
|
|
5020
5186
|
path = this.start(path);
|
|
5021
|
-
this.
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
if (
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5187
|
+
if (this.reuseAssets(path, success, error)) return;
|
|
5188
|
+
this.cache.assetsLoaded[path] = new Promise(function(resolve, reject) {
|
|
5189
|
+
_this.downloader.downloadText(path, function(atlasText) {
|
|
5190
|
+
try {
|
|
5191
|
+
var _loop = function() {
|
|
5192
|
+
var page = _step.value;
|
|
5193
|
+
_this.loadTexture(!fileAlias ? parent + page.name : fileAlias[page.name], function(imagePath, texture) {
|
|
5194
|
+
if (!abort) {
|
|
5195
|
+
page.setTexture(texture);
|
|
5196
|
+
if (--toLoad == 0) {
|
|
5197
|
+
_this.success(success, path, atlas);
|
|
5198
|
+
resolve(atlas);
|
|
5199
|
+
}
|
|
5200
|
+
}
|
|
5201
|
+
}, function(imagePath, message) {
|
|
5202
|
+
if (!abort) {
|
|
5203
|
+
var errorMsg = "Couldn't load texture " + path + " page image: " + imagePath;
|
|
5204
|
+
_this.error(error, path, errorMsg);
|
|
5205
|
+
reject(errorMsg);
|
|
5206
|
+
}
|
|
5207
|
+
abort = true;
|
|
5208
|
+
});
|
|
5209
|
+
};
|
|
5210
|
+
var atlas = new TextureAtlas(atlasText);
|
|
5211
|
+
var toLoad = atlas.pages.length, abort = false;
|
|
5212
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(atlas.pages), _step; !(_step = _iterator()).done;)_loop();
|
|
5213
|
+
} catch (e) {
|
|
5214
|
+
var errorMsg = "Couldn't parse texture atlas " + path + ": " + e.message;
|
|
5215
|
+
_this.error(error, path, errorMsg);
|
|
5216
|
+
reject(errorMsg);
|
|
5217
|
+
}
|
|
5218
|
+
}, function(status, responseText) {
|
|
5219
|
+
var errorMsg = "Couldn't load texture atlas " + path + ": status " + status + ", " + responseText;
|
|
5220
|
+
_this.error(error, path, errorMsg);
|
|
5221
|
+
reject(errorMsg);
|
|
5222
|
+
});
|
|
5043
5223
|
});
|
|
5044
5224
|
};
|
|
5225
|
+
_proto.loadTextureAtlasButNoTextures = function loadTextureAtlasButNoTextures(path, success, error, fileAlias) {
|
|
5226
|
+
var _this = this;
|
|
5227
|
+
if (success === void 0) success = function() {};
|
|
5228
|
+
if (error === void 0) error = function() {};
|
|
5229
|
+
path = this.start(path);
|
|
5230
|
+
if (this.reuseAssets(path, success, error)) return;
|
|
5231
|
+
this.cache.assetsLoaded[path] = new Promise(function(resolve, reject) {
|
|
5232
|
+
_this.downloader.downloadText(path, function(atlasText) {
|
|
5233
|
+
try {
|
|
5234
|
+
var atlas = new TextureAtlas(atlasText);
|
|
5235
|
+
_this.success(success, path, atlas);
|
|
5236
|
+
resolve(atlas);
|
|
5237
|
+
} catch (e) {
|
|
5238
|
+
var errorMsg = "Couldn't parse texture atlas " + path + ": " + e.message;
|
|
5239
|
+
_this.error(error, path, errorMsg);
|
|
5240
|
+
reject(errorMsg);
|
|
5241
|
+
}
|
|
5242
|
+
}, function(status, responseText) {
|
|
5243
|
+
var errorMsg = "Couldn't load texture atlas " + path + ": status " + status + ", " + responseText;
|
|
5244
|
+
_this.error(error, path, errorMsg);
|
|
5245
|
+
reject(errorMsg);
|
|
5246
|
+
});
|
|
5247
|
+
});
|
|
5248
|
+
};
|
|
5249
|
+
// Promisified versions of load function
|
|
5250
|
+
_proto.loadBinaryAsync = function loadBinaryAsync(path) {
|
|
5251
|
+
return _async_to_generator(function() {
|
|
5252
|
+
var _this;
|
|
5253
|
+
return __generator(this, function(_state) {
|
|
5254
|
+
_this = this;
|
|
5255
|
+
return [
|
|
5256
|
+
2,
|
|
5257
|
+
new Promise(function(resolve, reject) {
|
|
5258
|
+
_this.loadBinary(path, function(_, binary) {
|
|
5259
|
+
return resolve(binary);
|
|
5260
|
+
}, function(_, message) {
|
|
5261
|
+
return reject(message);
|
|
5262
|
+
});
|
|
5263
|
+
})
|
|
5264
|
+
];
|
|
5265
|
+
});
|
|
5266
|
+
}).call(this);
|
|
5267
|
+
};
|
|
5268
|
+
_proto.loadJsonAsync = function loadJsonAsync(path) {
|
|
5269
|
+
return _async_to_generator(function() {
|
|
5270
|
+
var _this;
|
|
5271
|
+
return __generator(this, function(_state) {
|
|
5272
|
+
_this = this;
|
|
5273
|
+
return [
|
|
5274
|
+
2,
|
|
5275
|
+
new Promise(function(resolve, reject) {
|
|
5276
|
+
_this.loadJson(path, function(_, object) {
|
|
5277
|
+
return resolve(object);
|
|
5278
|
+
}, function(_, message) {
|
|
5279
|
+
return reject(message);
|
|
5280
|
+
});
|
|
5281
|
+
})
|
|
5282
|
+
];
|
|
5283
|
+
});
|
|
5284
|
+
}).call(this);
|
|
5285
|
+
};
|
|
5286
|
+
_proto.loadTextureAsync = function loadTextureAsync(path) {
|
|
5287
|
+
return _async_to_generator(function() {
|
|
5288
|
+
var _this;
|
|
5289
|
+
return __generator(this, function(_state) {
|
|
5290
|
+
_this = this;
|
|
5291
|
+
return [
|
|
5292
|
+
2,
|
|
5293
|
+
new Promise(function(resolve, reject) {
|
|
5294
|
+
_this.loadTexture(path, function(_, texture) {
|
|
5295
|
+
return resolve(texture);
|
|
5296
|
+
}, function(_, message) {
|
|
5297
|
+
return reject(message);
|
|
5298
|
+
});
|
|
5299
|
+
})
|
|
5300
|
+
];
|
|
5301
|
+
});
|
|
5302
|
+
}).call(this);
|
|
5303
|
+
};
|
|
5304
|
+
_proto.loadTextureAtlasAsync = function loadTextureAtlasAsync(path) {
|
|
5305
|
+
return _async_to_generator(function() {
|
|
5306
|
+
var _this;
|
|
5307
|
+
return __generator(this, function(_state) {
|
|
5308
|
+
_this = this;
|
|
5309
|
+
return [
|
|
5310
|
+
2,
|
|
5311
|
+
new Promise(function(resolve, reject) {
|
|
5312
|
+
_this.loadTextureAtlas(path, function(_, atlas) {
|
|
5313
|
+
return resolve(atlas);
|
|
5314
|
+
}, function(_, message) {
|
|
5315
|
+
return reject(message);
|
|
5316
|
+
});
|
|
5317
|
+
})
|
|
5318
|
+
];
|
|
5319
|
+
});
|
|
5320
|
+
}).call(this);
|
|
5321
|
+
};
|
|
5322
|
+
_proto.loadTextureAtlasButNoTexturesAsync = function loadTextureAtlasButNoTexturesAsync(path) {
|
|
5323
|
+
return _async_to_generator(function() {
|
|
5324
|
+
var _this;
|
|
5325
|
+
return __generator(this, function(_state) {
|
|
5326
|
+
_this = this;
|
|
5327
|
+
return [
|
|
5328
|
+
2,
|
|
5329
|
+
new Promise(function(resolve, reject) {
|
|
5330
|
+
_this.loadTextureAtlasButNoTextures(path, function(_, atlas) {
|
|
5331
|
+
return resolve(atlas);
|
|
5332
|
+
}, function(_, message) {
|
|
5333
|
+
return reject(message);
|
|
5334
|
+
});
|
|
5335
|
+
})
|
|
5336
|
+
];
|
|
5337
|
+
});
|
|
5338
|
+
}).call(this);
|
|
5339
|
+
};
|
|
5340
|
+
_proto.setCache = function setCache(cache) {
|
|
5341
|
+
this.cache = cache;
|
|
5342
|
+
};
|
|
5045
5343
|
_proto.get = function get(path) {
|
|
5046
|
-
return this.assets[this.pathPrefix + path];
|
|
5344
|
+
return this.cache.assets[this.pathPrefix + path];
|
|
5047
5345
|
};
|
|
5048
5346
|
_proto.require = function require(path) {
|
|
5049
5347
|
path = this.pathPrefix + path;
|
|
5050
|
-
var asset = this.assets[path];
|
|
5348
|
+
var asset = this.cache.assets[path];
|
|
5051
5349
|
if (asset) return asset;
|
|
5052
5350
|
var error = this.errors[path];
|
|
5053
5351
|
throw Error("Asset not found: " + path + (error ? "\n" + error : ""));
|
|
5054
5352
|
};
|
|
5055
5353
|
_proto.remove = function remove(path) {
|
|
5056
5354
|
path = this.pathPrefix + path;
|
|
5057
|
-
var asset = this.assets[path];
|
|
5355
|
+
var asset = this.cache.assets[path];
|
|
5058
5356
|
if (asset.dispose) asset.dispose();
|
|
5059
|
-
delete this.assets[path];
|
|
5357
|
+
delete this.cache.assets[path];
|
|
5358
|
+
delete this.cache.assetsRefCount[path];
|
|
5359
|
+
delete this.cache.assetsLoaded[path];
|
|
5060
5360
|
return asset;
|
|
5061
5361
|
};
|
|
5062
5362
|
_proto.removeAll = function removeAll() {
|
|
5063
|
-
for(var
|
|
5064
|
-
var asset = this.assets[
|
|
5363
|
+
for(var path in this.cache.assets){
|
|
5364
|
+
var asset = this.cache.assets[path];
|
|
5065
5365
|
if (asset.dispose) asset.dispose();
|
|
5066
5366
|
}
|
|
5067
|
-
this.assets = {};
|
|
5367
|
+
this.cache.assets = {};
|
|
5368
|
+
this.cache.assetsLoaded = {};
|
|
5369
|
+
this.cache.assetsRefCount = {};
|
|
5068
5370
|
};
|
|
5069
5371
|
_proto.isLoadingComplete = function isLoadingComplete() {
|
|
5070
5372
|
return this.toLoad == 0;
|
|
@@ -5078,6 +5380,12 @@ var AssetManagerBase = /*#__PURE__*/ function() {
|
|
|
5078
5380
|
_proto.dispose = function dispose() {
|
|
5079
5381
|
this.removeAll();
|
|
5080
5382
|
};
|
|
5383
|
+
// dispose asset only if it's not used by others
|
|
5384
|
+
_proto.disposeAsset = function disposeAsset(path) {
|
|
5385
|
+
if (--this.cache.assetsRefCount[path] === 0) {
|
|
5386
|
+
this.remove(path);
|
|
5387
|
+
}
|
|
5388
|
+
};
|
|
5081
5389
|
_proto.hasErrors = function hasErrors() {
|
|
5082
5390
|
return Object.keys(this.errors).length > 0;
|
|
5083
5391
|
};
|
|
@@ -5086,6 +5394,44 @@ var AssetManagerBase = /*#__PURE__*/ function() {
|
|
|
5086
5394
|
};
|
|
5087
5395
|
return AssetManagerBase;
|
|
5088
5396
|
}();
|
|
5397
|
+
var AssetCache = /*#__PURE__*/ function() {
|
|
5398
|
+
function AssetCache() {
|
|
5399
|
+
this.assets = {};
|
|
5400
|
+
this.assetsRefCount = {};
|
|
5401
|
+
this.assetsLoaded = {};
|
|
5402
|
+
}
|
|
5403
|
+
var _proto = AssetCache.prototype;
|
|
5404
|
+
_proto.addAsset = function addAsset(path, asset) {
|
|
5405
|
+
return _async_to_generator(function() {
|
|
5406
|
+
var _;
|
|
5407
|
+
return __generator(this, function(_state) {
|
|
5408
|
+
switch(_state.label){
|
|
5409
|
+
case 0:
|
|
5410
|
+
this.assetsLoaded[path] = Promise.resolve(asset);
|
|
5411
|
+
_ = this.assets;
|
|
5412
|
+
return [
|
|
5413
|
+
4,
|
|
5414
|
+
asset
|
|
5415
|
+
];
|
|
5416
|
+
case 1:
|
|
5417
|
+
_[path] = _state.sent();
|
|
5418
|
+
return [
|
|
5419
|
+
2
|
|
5420
|
+
];
|
|
5421
|
+
}
|
|
5422
|
+
});
|
|
5423
|
+
}).call(this);
|
|
5424
|
+
};
|
|
5425
|
+
AssetCache.getCache = function getCache(id) {
|
|
5426
|
+
var cache = AssetCache.AVAILABLE_CACHES.get(id);
|
|
5427
|
+
if (cache) return cache;
|
|
5428
|
+
var newCache = new AssetCache();
|
|
5429
|
+
AssetCache.AVAILABLE_CACHES.set(id, newCache);
|
|
5430
|
+
return newCache;
|
|
5431
|
+
};
|
|
5432
|
+
return AssetCache;
|
|
5433
|
+
}();
|
|
5434
|
+
AssetCache.AVAILABLE_CACHES = new Map();
|
|
5089
5435
|
var Downloader = /*#__PURE__*/ function() {
|
|
5090
5436
|
function Downloader() {
|
|
5091
5437
|
this.callbacks = {};
|
|
@@ -5125,10 +5471,11 @@ var Downloader = /*#__PURE__*/ function() {
|
|
|
5125
5471
|
_proto.downloadText = function downloadText(url, success, error) {
|
|
5126
5472
|
var _this = this;
|
|
5127
5473
|
if (this.start(url, success, error)) return;
|
|
5128
|
-
|
|
5474
|
+
var rawDataUri = this.rawDataUris[url];
|
|
5475
|
+
// we assume if a "." is included in a raw data uri, it is used to rewrite an asset URL
|
|
5476
|
+
if (rawDataUri && !rawDataUri.includes(".")) {
|
|
5129
5477
|
try {
|
|
5130
|
-
|
|
5131
|
-
this.finish(url, 200, this.dataUriToString(dataUri));
|
|
5478
|
+
this.finish(url, 200, this.dataUriToString(rawDataUri));
|
|
5132
5479
|
} catch (e) {
|
|
5133
5480
|
this.finish(url, 400, JSON.stringify(e));
|
|
5134
5481
|
}
|
|
@@ -5136,7 +5483,7 @@ var Downloader = /*#__PURE__*/ function() {
|
|
|
5136
5483
|
}
|
|
5137
5484
|
var request = new engineMiniprogramAdapter.XMLHttpRequest();
|
|
5138
5485
|
request.overrideMimeType("text/html");
|
|
5139
|
-
request.open("GET", url, true);
|
|
5486
|
+
request.open("GET", rawDataUri ? rawDataUri : url, true);
|
|
5140
5487
|
var done = function() {
|
|
5141
5488
|
_this.finish(url, request.status, request.responseText);
|
|
5142
5489
|
};
|
|
@@ -5152,17 +5499,18 @@ var Downloader = /*#__PURE__*/ function() {
|
|
|
5152
5499
|
_proto.downloadBinary = function downloadBinary(url, success, error) {
|
|
5153
5500
|
var _this = this;
|
|
5154
5501
|
if (this.start(url, success, error)) return;
|
|
5155
|
-
|
|
5502
|
+
var rawDataUri = this.rawDataUris[url];
|
|
5503
|
+
// we assume if a "." is included in a raw data uri, it is used to rewrite an asset URL
|
|
5504
|
+
if (rawDataUri && !rawDataUri.includes(".")) {
|
|
5156
5505
|
try {
|
|
5157
|
-
|
|
5158
|
-
this.finish(url, 200, this.dataUriToUint8Array(dataUri));
|
|
5506
|
+
this.finish(url, 200, this.dataUriToUint8Array(rawDataUri));
|
|
5159
5507
|
} catch (e) {
|
|
5160
5508
|
this.finish(url, 400, JSON.stringify(e));
|
|
5161
5509
|
}
|
|
5162
5510
|
return;
|
|
5163
5511
|
}
|
|
5164
5512
|
var request = new engineMiniprogramAdapter.XMLHttpRequest();
|
|
5165
|
-
request.open("GET", url, true);
|
|
5513
|
+
request.open("GET", rawDataUri ? rawDataUri : url, true);
|
|
5166
5514
|
request.responseType = "arraybuffer";
|
|
5167
5515
|
var onerror = function() {
|
|
5168
5516
|
_this.finish(url, request.status, request.response);
|
|
@@ -5200,17 +5548,17 @@ var Downloader = /*#__PURE__*/ function() {
|
|
|
5200
5548
|
|
|
5201
5549
|
/******************************************************************************
|
|
5202
5550
|
* Spine Runtimes License Agreement
|
|
5203
|
-
* Last updated
|
|
5551
|
+
* Last updated April 5, 2025. Replaces all prior versions.
|
|
5204
5552
|
*
|
|
5205
|
-
* Copyright (c) 2013-
|
|
5553
|
+
* Copyright (c) 2013-2025, Esoteric Software LLC
|
|
5206
5554
|
*
|
|
5207
5555
|
* Integration of the Spine Runtimes into software or otherwise creating
|
|
5208
5556
|
* derivative works of the Spine Runtimes is permitted under the terms and
|
|
5209
5557
|
* conditions of Section 2 of the Spine Editor License Agreement:
|
|
5210
5558
|
* http://esotericsoftware.com/spine-editor-license
|
|
5211
5559
|
*
|
|
5212
|
-
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
|
5213
|
-
* otherwise create derivative works of the Spine Runtimes (collectively,
|
|
5560
|
+
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
|
5561
|
+
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
|
5214
5562
|
* "Products"), provided that each user of the Products must obtain their own
|
|
5215
5563
|
* Spine Editor license and redistribution of the Products in any form must
|
|
5216
5564
|
* include this license and copyright notice.
|
|
@@ -5223,8 +5571,8 @@ var Downloader = /*#__PURE__*/ function() {
|
|
|
5223
5571
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
|
5224
5572
|
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
|
5225
5573
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
5226
|
-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
5227
|
-
* SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
5574
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
5575
|
+
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
5228
5576
|
*****************************************************************************/ /** Stores the current pose values for an {@link Event}.
|
|
5229
5577
|
*
|
|
5230
5578
|
* See Timeline {@link Timeline#apply()},
|
|
@@ -5244,17 +5592,17 @@ var Downloader = /*#__PURE__*/ function() {
|
|
|
5244
5592
|
|
|
5245
5593
|
/******************************************************************************
|
|
5246
5594
|
* Spine Runtimes License Agreement
|
|
5247
|
-
* Last updated
|
|
5595
|
+
* Last updated April 5, 2025. Replaces all prior versions.
|
|
5248
5596
|
*
|
|
5249
|
-
* Copyright (c) 2013-
|
|
5597
|
+
* Copyright (c) 2013-2025, Esoteric Software LLC
|
|
5250
5598
|
*
|
|
5251
5599
|
* Integration of the Spine Runtimes into software or otherwise creating
|
|
5252
5600
|
* derivative works of the Spine Runtimes is permitted under the terms and
|
|
5253
5601
|
* conditions of Section 2 of the Spine Editor License Agreement:
|
|
5254
5602
|
* http://esotericsoftware.com/spine-editor-license
|
|
5255
5603
|
*
|
|
5256
|
-
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
|
5257
|
-
* otherwise create derivative works of the Spine Runtimes (collectively,
|
|
5604
|
+
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
|
5605
|
+
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
|
5258
5606
|
* "Products"), provided that each user of the Products must obtain their own
|
|
5259
5607
|
* Spine Editor license and redistribution of the Products in any form must
|
|
5260
5608
|
* include this license and copyright notice.
|
|
@@ -5267,8 +5615,8 @@ var Downloader = /*#__PURE__*/ function() {
|
|
|
5267
5615
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
|
5268
5616
|
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
|
5269
5617
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
5270
|
-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
5271
|
-
* SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
5618
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
5619
|
+
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
5272
5620
|
*****************************************************************************/ /** Stores the setup pose values for an {@link Event}.
|
|
5273
5621
|
*
|
|
5274
5622
|
* See [Events](http://esotericsoftware.com/spine-events) in the Spine User Guide. */ var EventData = function EventData(name) {
|
|
@@ -6128,7 +6476,7 @@ PathConstraint.epsilon = 0.00001;
|
|
|
6128
6476
|
}
|
|
6129
6477
|
if (a >= t) {
|
|
6130
6478
|
d = Math.pow(this.damping, 60 * t);
|
|
6131
|
-
var m = this.massInverse * t, e = this.strength, w = this.wind * f, g =
|
|
6479
|
+
var m = this.massInverse * t, e = this.strength, w = this.wind * f * skeleton.scaleX, g = this.gravity * f * skeleton.scaleY;
|
|
6132
6480
|
do {
|
|
6133
6481
|
if (x) {
|
|
6134
6482
|
this.xVelocity += (w - this.xOffset * e) * m;
|
|
@@ -6970,10 +7318,10 @@ PathConstraint.epsilon = 0.00001;
|
|
|
6970
7318
|
})) != null ? _this_physicsConstraints_find : null;
|
|
6971
7319
|
};
|
|
6972
7320
|
/** Returns the axis aligned bounding box (AABB) of the region and mesh attachments for the current pose as `{ x: number, y: number, width: number, height: number }`.
|
|
6973
|
-
* Note that this method will create temporary objects which can add to garbage collection pressure. Use `getBounds()` if garbage collection is a concern. */ _proto.getBoundsRect = function getBoundsRect() {
|
|
7321
|
+
* Note that this method will create temporary objects which can add to garbage collection pressure. Use `getBounds()` if garbage collection is a concern. */ _proto.getBoundsRect = function getBoundsRect(clipper) {
|
|
6974
7322
|
var offset = new Vector2();
|
|
6975
7323
|
var size = new Vector2();
|
|
6976
|
-
this.getBounds(offset, size);
|
|
7324
|
+
this.getBounds(offset, size, undefined, clipper);
|
|
6977
7325
|
return {
|
|
6978
7326
|
x: offset.x,
|
|
6979
7327
|
y: offset.y,
|
|
@@ -7102,17 +7450,17 @@ Skeleton.yDown = false;
|
|
|
7102
7450
|
|
|
7103
7451
|
/******************************************************************************
|
|
7104
7452
|
* Spine Runtimes License Agreement
|
|
7105
|
-
* Last updated
|
|
7453
|
+
* Last updated April 5, 2025. Replaces all prior versions.
|
|
7106
7454
|
*
|
|
7107
|
-
* Copyright (c) 2013-
|
|
7455
|
+
* Copyright (c) 2013-2025, Esoteric Software LLC
|
|
7108
7456
|
*
|
|
7109
7457
|
* Integration of the Spine Runtimes into software or otherwise creating
|
|
7110
7458
|
* derivative works of the Spine Runtimes is permitted under the terms and
|
|
7111
7459
|
* conditions of Section 2 of the Spine Editor License Agreement:
|
|
7112
7460
|
* http://esotericsoftware.com/spine-editor-license
|
|
7113
7461
|
*
|
|
7114
|
-
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
|
7115
|
-
* otherwise create derivative works of the Spine Runtimes (collectively,
|
|
7462
|
+
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
|
7463
|
+
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
|
7116
7464
|
* "Products"), provided that each user of the Products must obtain their own
|
|
7117
7465
|
* Spine Editor license and redistribution of the Products in any form must
|
|
7118
7466
|
* include this license and copyright notice.
|
|
@@ -7125,18 +7473,16 @@ Skeleton.yDown = false;
|
|
|
7125
7473
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
|
7126
7474
|
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
|
7127
7475
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
7128
|
-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
7129
|
-
* SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
7476
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
7477
|
+
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
7130
7478
|
*****************************************************************************/ /** Stores the setup pose and all of the stateless data for a skeleton.
|
|
7131
7479
|
*
|
|
7132
7480
|
* See [Data objects](http://esotericsoftware.com/spine-runtime-architecture#Data-objects) in the Spine Runtimes
|
|
7133
7481
|
* Guide. */ var SkeletonData = /*#__PURE__*/ function() {
|
|
7134
7482
|
function SkeletonData() {
|
|
7135
7483
|
/** The skeleton's name, which by default is the name of the skeleton data file, if possible. May be null. */ this.name = null;
|
|
7136
|
-
/** The skeleton's bones, sorted parent first. The root bone is always the first bone. */ this.bones = new Array() // Ordered parents first.
|
|
7137
|
-
;
|
|
7138
|
-
/** The skeleton's slots in the setup pose draw order. */ this.slots = new Array() // Setup pose draw order.
|
|
7139
|
-
;
|
|
7484
|
+
/** The skeleton's bones, sorted parent first. The root bone is always the first bone. */ this.bones = new Array(); // Ordered parents first.
|
|
7485
|
+
/** The skeleton's slots in the setup pose draw order. */ this.slots = new Array(); // Setup pose draw order.
|
|
7140
7486
|
this.skins = new Array();
|
|
7141
7487
|
/** The skeleton's default skin. By default this skin contains all attachments that were not in a skin in Spine.
|
|
7142
7488
|
*
|
|
@@ -7279,8 +7625,7 @@ Skeleton.yDown = false;
|
|
|
7279
7625
|
this.attachments = new Array();
|
|
7280
7626
|
this.bones = Array();
|
|
7281
7627
|
this.constraints = new Array();
|
|
7282
|
-
/** The color of the skin as it was in Spine, or a default color if nonessential data was not exported. */ this.color = new Color(0.99607843, 0.61960787, 0.30980393, 1) // fe9e4fff
|
|
7283
|
-
;
|
|
7628
|
+
/** The color of the skin as it was in Spine, or a default color if nonessential data was not exported. */ this.color = new Color(0.99607843, 0.61960787, 0.30980393, 1); // fe9e4fff
|
|
7284
7629
|
if (!name) throw new Error("name cannot be null.");
|
|
7285
7630
|
this.name = name;
|
|
7286
7631
|
}
|
|
@@ -10438,17 +10783,17 @@ function getValue(map, property, defaultValue) {
|
|
|
10438
10783
|
|
|
10439
10784
|
/******************************************************************************
|
|
10440
10785
|
* Spine Runtimes License Agreement
|
|
10441
|
-
* Last updated
|
|
10786
|
+
* Last updated April 5, 2025. Replaces all prior versions.
|
|
10442
10787
|
*
|
|
10443
|
-
* Copyright (c) 2013-
|
|
10788
|
+
* Copyright (c) 2013-2025, Esoteric Software LLC
|
|
10444
10789
|
*
|
|
10445
10790
|
* Integration of the Spine Runtimes into software or otherwise creating
|
|
10446
10791
|
* derivative works of the Spine Runtimes is permitted under the terms and
|
|
10447
10792
|
* conditions of Section 2 of the Spine Editor License Agreement:
|
|
10448
10793
|
* http://esotericsoftware.com/spine-editor-license
|
|
10449
10794
|
*
|
|
10450
|
-
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
|
10451
|
-
* otherwise create derivative works of the Spine Runtimes (collectively,
|
|
10795
|
+
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
|
10796
|
+
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
|
10452
10797
|
* "Products"), provided that each user of the Products must obtain their own
|
|
10453
10798
|
* Spine Editor license and redistribution of the Products in any form must
|
|
10454
10799
|
* include this license and copyright notice.
|
|
@@ -10461,8 +10806,8 @@ function getValue(map, property, defaultValue) {
|
|
|
10461
10806
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
|
10462
10807
|
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
|
10463
10808
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
10464
|
-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
10465
|
-
* SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
10809
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
10810
|
+
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
10466
10811
|
*****************************************************************************/ (function() {
|
|
10467
10812
|
if (typeof Math.fround === "undefined") {
|
|
10468
10813
|
Math.fround = function(array) {
|
|
@@ -10611,55 +10956,6 @@ function getValue(map, property, defaultValue) {
|
|
|
10611
10956
|
return LoaderUtils;
|
|
10612
10957
|
}();
|
|
10613
10958
|
|
|
10614
|
-
var SourceAlpha = miniprogram.BlendFactor.SourceAlpha, One = miniprogram.BlendFactor.One, DestinationColor = miniprogram.BlendFactor.DestinationColor, Zero = miniprogram.BlendFactor.Zero, OneMinusSourceColor = miniprogram.BlendFactor.OneMinusSourceColor, OneMinusSourceAlpha = miniprogram.BlendFactor.OneMinusSourceAlpha;
|
|
10615
|
-
var Add = miniprogram.BlendOperation.Add;
|
|
10616
|
-
function setBlendMode(material, blendMode, premultipliedAlpha) {
|
|
10617
|
-
var target = material.renderState.blendState.targetBlendState;
|
|
10618
|
-
switch(blendMode){
|
|
10619
|
-
case exports.BlendMode.Additive:
|
|
10620
|
-
target.sourceColorBlendFactor = premultipliedAlpha ? One : SourceAlpha;
|
|
10621
|
-
target.destinationColorBlendFactor = One;
|
|
10622
|
-
target.sourceAlphaBlendFactor = One;
|
|
10623
|
-
target.destinationAlphaBlendFactor = One;
|
|
10624
|
-
target.colorBlendOperation = target.alphaBlendOperation = Add;
|
|
10625
|
-
break;
|
|
10626
|
-
case exports.BlendMode.Multiply:
|
|
10627
|
-
target.sourceColorBlendFactor = DestinationColor;
|
|
10628
|
-
target.destinationColorBlendFactor = OneMinusSourceAlpha;
|
|
10629
|
-
target.sourceAlphaBlendFactor = One;
|
|
10630
|
-
target.destinationAlphaBlendFactor = OneMinusSourceAlpha;
|
|
10631
|
-
target.colorBlendOperation = target.alphaBlendOperation = Add;
|
|
10632
|
-
break;
|
|
10633
|
-
case exports.BlendMode.Screen:
|
|
10634
|
-
target.sourceColorBlendFactor = One;
|
|
10635
|
-
target.destinationColorBlendFactor = OneMinusSourceColor;
|
|
10636
|
-
target.sourceAlphaBlendFactor = One;
|
|
10637
|
-
target.destinationAlphaBlendFactor = OneMinusSourceColor;
|
|
10638
|
-
target.colorBlendOperation = target.alphaBlendOperation = Add;
|
|
10639
|
-
break;
|
|
10640
|
-
default:
|
|
10641
|
-
target.sourceColorBlendFactor = premultipliedAlpha ? One : SourceAlpha;
|
|
10642
|
-
target.destinationColorBlendFactor = OneMinusSourceAlpha;
|
|
10643
|
-
target.sourceAlphaBlendFactor = One;
|
|
10644
|
-
target.destinationAlphaBlendFactor = OneMinusSourceAlpha;
|
|
10645
|
-
target.colorBlendOperation = target.alphaBlendOperation = Add;
|
|
10646
|
-
break;
|
|
10647
|
-
}
|
|
10648
|
-
}
|
|
10649
|
-
function getBlendMode(material) {
|
|
10650
|
-
var target = material.renderState.blendState.targetBlendState;
|
|
10651
|
-
if (target.sourceColorBlendFactor === SourceAlpha && target.destinationColorBlendFactor === One && target.sourceAlphaBlendFactor === One && target.destinationAlphaBlendFactor === One && target.colorBlendOperation === Add && target.alphaBlendOperation === Add) {
|
|
10652
|
-
return exports.BlendMode.Additive;
|
|
10653
|
-
}
|
|
10654
|
-
if (target.sourceColorBlendFactor === DestinationColor && target.destinationColorBlendFactor === Zero && target.sourceAlphaBlendFactor === One && target.destinationAlphaBlendFactor === Zero && target.colorBlendOperation === Add && target.alphaBlendOperation === Add) {
|
|
10655
|
-
return exports.BlendMode.Multiply;
|
|
10656
|
-
}
|
|
10657
|
-
if (target.sourceColorBlendFactor === One && target.destinationColorBlendFactor === OneMinusSourceColor && target.sourceAlphaBlendFactor === One && target.destinationAlphaBlendFactor === OneMinusSourceColor && target.colorBlendOperation === Add && target.alphaBlendOperation === Add) {
|
|
10658
|
-
return exports.BlendMode.Screen;
|
|
10659
|
-
}
|
|
10660
|
-
return exports.BlendMode.Normal;
|
|
10661
|
-
}
|
|
10662
|
-
|
|
10663
10959
|
var ClearablePool = /*#__PURE__*/ function() {
|
|
10664
10960
|
function ClearablePool(type) {
|
|
10665
10961
|
this._usedElementCount = 0;
|
|
@@ -10720,11 +11016,11 @@ var SubRenderItem = function SubRenderItem() {
|
|
|
10720
11016
|
}
|
|
10721
11017
|
var _proto = SpineGenerator.prototype;
|
|
10722
11018
|
_proto.buildPrimitive = function buildPrimitive(skeleton, renderer) {
|
|
10723
|
-
var _indices = renderer._indices, _vertices = renderer._vertices, _localBounds = renderer._localBounds, _vertexCount = renderer._vertexCount, _subPrimitives = renderer._subPrimitives,
|
|
11019
|
+
var _indices = renderer._indices, _vertices = renderer._vertices, _localBounds = renderer._localBounds, _vertexCount = renderer._vertexCount, _subPrimitives = renderer._subPrimitives, zSpacing = renderer.zSpacing, premultipliedAlpha = renderer.premultipliedAlpha, tintBlack = renderer.tintBlack;
|
|
10724
11020
|
_localBounds.min.set(Infinity, Infinity, Infinity);
|
|
10725
11021
|
_localBounds.max.set(-Infinity, -Infinity, -Infinity);
|
|
10726
11022
|
var _this = this, _clipper = _this._clipper, _separateSlots = _this._separateSlots, _subRenderItems = _this._subRenderItems, _separateSlotTextureMap = _this._separateSlotTextureMap;
|
|
10727
|
-
var tempVerts = SpineGenerator.tempVerts, subRenderItemPool = SpineGenerator.subRenderItemPool, subPrimitivePool = SpineGenerator.subPrimitivePool,
|
|
11023
|
+
var tempVerts = SpineGenerator.tempVerts, subRenderItemPool = SpineGenerator.subRenderItemPool, subPrimitivePool = SpineGenerator.subPrimitivePool, vertexStrideWithTint = SpineGenerator.vertexStrideWithTint, vertexStrideWithoutTint = SpineGenerator.vertexStrideWithoutTint;
|
|
10728
11024
|
_subRenderItems.length = 0;
|
|
10729
11025
|
subRenderItemPool.clear();
|
|
10730
11026
|
var triangles;
|
|
@@ -10754,13 +11050,28 @@ var SubRenderItem = function SubRenderItem() {
|
|
|
10754
11050
|
var isClipping = _clipper.isClipping();
|
|
10755
11051
|
var numFloats = 0;
|
|
10756
11052
|
var attachmentColor = null;
|
|
10757
|
-
|
|
11053
|
+
// This vertexSize will be passed to spine-core's computeWorldVertices function.
|
|
11054
|
+
//
|
|
11055
|
+
// Expected format by computeWorldVertices:
|
|
11056
|
+
// - Without tintBlack: [x, y, u, v, r, g, b, a] = 8 components
|
|
11057
|
+
// - With tintBlack: [x, y, u, v, r, g, b, a, dr, dg, db, da] = 12 components
|
|
11058
|
+
//
|
|
11059
|
+
// Our actual vertex buffer format:
|
|
11060
|
+
// - vertexStrideWithoutTint: [x, y, z, u, v, r, g, b, a] = 9 components
|
|
11061
|
+
// - vertexStrideWithTint: [x, y, z, u, v, r, g, b, a, dr, dg, db] = 12 components
|
|
11062
|
+
// (Note: we optimized 'da' as uniform instead of buffer attribute)
|
|
11063
|
+
//
|
|
11064
|
+
// Calculation:
|
|
11065
|
+
// - Without tintBlack: 9 - 1 (remove z) = 8 ✓
|
|
11066
|
+
// - With tintBlack: 12 - 1 (remove z) + 1 (add back da) = 12 ✓
|
|
11067
|
+
var vertexSize = tintBlack ? vertexStrideWithTint : vertexStrideWithoutTint - 1;
|
|
11068
|
+
var clippedVertexSize = isClipping ? 2 : vertexSize;
|
|
10758
11069
|
switch(attachment.constructor){
|
|
10759
11070
|
case RegionAttachment:
|
|
10760
11071
|
var regionAttachment = attachment;
|
|
10761
11072
|
attachmentColor = regionAttachment.color;
|
|
10762
|
-
numFloats =
|
|
10763
|
-
regionAttachment.computeWorldVertices(slot, tempVerts, 0,
|
|
11073
|
+
numFloats = clippedVertexSize << 2;
|
|
11074
|
+
regionAttachment.computeWorldVertices(slot, tempVerts, 0, clippedVertexSize);
|
|
10764
11075
|
triangles = SpineGenerator.QUAD_TRIANGLES;
|
|
10765
11076
|
uvs = regionAttachment.uvs;
|
|
10766
11077
|
texture = regionAttachment.region.texture;
|
|
@@ -10768,11 +11079,11 @@ var SubRenderItem = function SubRenderItem() {
|
|
|
10768
11079
|
case MeshAttachment:
|
|
10769
11080
|
var meshAttachment = attachment;
|
|
10770
11081
|
attachmentColor = meshAttachment.color;
|
|
10771
|
-
numFloats = (meshAttachment.worldVerticesLength >> 1) *
|
|
11082
|
+
numFloats = (meshAttachment.worldVerticesLength >> 1) * clippedVertexSize;
|
|
10772
11083
|
if (numFloats > _vertices.length) {
|
|
10773
11084
|
SpineGenerator.tempVerts = new Array(numFloats);
|
|
10774
11085
|
}
|
|
10775
|
-
meshAttachment.computeWorldVertices(slot, 0, meshAttachment.worldVerticesLength, tempVerts, 0,
|
|
11086
|
+
meshAttachment.computeWorldVertices(slot, 0, meshAttachment.worldVerticesLength, tempVerts, 0, clippedVertexSize);
|
|
10776
11087
|
triangles = meshAttachment.triangles;
|
|
10777
11088
|
uvs = meshAttachment.uvs;
|
|
10778
11089
|
texture = meshAttachment.region.texture;
|
|
@@ -10804,8 +11115,21 @@ var SubRenderItem = function SubRenderItem() {
|
|
|
10804
11115
|
finalColor.g *= finalAlpha;
|
|
10805
11116
|
finalColor.b *= finalAlpha;
|
|
10806
11117
|
}
|
|
11118
|
+
var darkColor = SpineGenerator.tempDark;
|
|
11119
|
+
var slotDarkColor = slot.darkColor;
|
|
11120
|
+
if (!slotDarkColor) {
|
|
11121
|
+
darkColor.set(0, 0, 0, 1);
|
|
11122
|
+
} else {
|
|
11123
|
+
if (premultipliedAlpha) {
|
|
11124
|
+
darkColor.r = slotDarkColor.r * finalAlpha;
|
|
11125
|
+
darkColor.g = slotDarkColor.g * finalAlpha;
|
|
11126
|
+
darkColor.b = slotDarkColor.b * finalAlpha;
|
|
11127
|
+
} else {
|
|
11128
|
+
darkColor.setFromColor(slotDarkColor);
|
|
11129
|
+
}
|
|
11130
|
+
}
|
|
10807
11131
|
if (isClipping) {
|
|
10808
|
-
_clipper.clipTriangles(tempVerts, triangles, triangles.length, uvs, finalColor,
|
|
11132
|
+
_clipper.clipTriangles(tempVerts, triangles, triangles.length, uvs, finalColor, darkColor, tintBlack);
|
|
10809
11133
|
finalVertices = _clipper.clippedVertices;
|
|
10810
11134
|
finalVerticesLength = finalVertices.length;
|
|
10811
11135
|
finalIndices = _clipper.clippedTriangles;
|
|
@@ -10819,6 +11143,12 @@ var SubRenderItem = function SubRenderItem() {
|
|
|
10819
11143
|
tempVerts[v + 3] = a;
|
|
10820
11144
|
tempVerts[v + 4] = uvs[u];
|
|
10821
11145
|
tempVerts[v + 5] = uvs[u + 1];
|
|
11146
|
+
if (tintBlack) {
|
|
11147
|
+
tempVerts[v + 6] = darkColor.r;
|
|
11148
|
+
tempVerts[v + 7] = darkColor.g;
|
|
11149
|
+
tempVerts[v + 8] = darkColor.b;
|
|
11150
|
+
tempVerts[v + 9] = darkColor.a;
|
|
11151
|
+
}
|
|
10822
11152
|
}
|
|
10823
11153
|
finalVertices = tempVerts;
|
|
10824
11154
|
finalVerticesLength = numFloats;
|
|
@@ -10829,7 +11159,8 @@ var SubRenderItem = function SubRenderItem() {
|
|
|
10829
11159
|
_clipper.clipEndWithSlot(slot);
|
|
10830
11160
|
continue;
|
|
10831
11161
|
}
|
|
10832
|
-
var
|
|
11162
|
+
var stride = tintBlack ? vertexStrideWithTint : vertexStrideWithoutTint;
|
|
11163
|
+
var indexStart = verticesLength / stride;
|
|
10833
11164
|
var i = verticesLength;
|
|
10834
11165
|
var j = 0;
|
|
10835
11166
|
for(; j < finalVerticesLength;){
|
|
@@ -10838,12 +11169,18 @@ var SubRenderItem = function SubRenderItem() {
|
|
|
10838
11169
|
_vertices[i++] = x;
|
|
10839
11170
|
_vertices[i++] = y;
|
|
10840
11171
|
_vertices[i++] = z;
|
|
10841
|
-
_vertices[i++] = finalVertices[j++];
|
|
10842
|
-
_vertices[i++] = finalVertices[j++];
|
|
10843
|
-
_vertices[i++] = finalVertices[j++];
|
|
10844
|
-
_vertices[i++] = finalVertices[j++];
|
|
10845
|
-
_vertices[i++] = finalVertices[j++];
|
|
10846
|
-
_vertices[i++] = finalVertices[j++];
|
|
11172
|
+
_vertices[i++] = finalVertices[j++]; // u
|
|
11173
|
+
_vertices[i++] = finalVertices[j++]; // v
|
|
11174
|
+
_vertices[i++] = finalVertices[j++]; // r
|
|
11175
|
+
_vertices[i++] = finalVertices[j++]; // g
|
|
11176
|
+
_vertices[i++] = finalVertices[j++]; // b
|
|
11177
|
+
_vertices[i++] = finalVertices[j++]; // a
|
|
11178
|
+
if (tintBlack) {
|
|
11179
|
+
_vertices[i++] = finalVertices[j++]; // darkR
|
|
11180
|
+
_vertices[i++] = finalVertices[j++]; // darkG
|
|
11181
|
+
_vertices[i++] = finalVertices[j++]; // darkB
|
|
11182
|
+
j++; // darkA
|
|
11183
|
+
}
|
|
10847
11184
|
this._expandBounds(x, y, z, _localBounds);
|
|
10848
11185
|
}
|
|
10849
11186
|
verticesLength = i;
|
|
@@ -10900,22 +11237,17 @@ var SubRenderItem = function SubRenderItem() {
|
|
|
10900
11237
|
subPrimitivePool.return(item);
|
|
10901
11238
|
}
|
|
10902
11239
|
renderer._clearSubPrimitives();
|
|
10903
|
-
var materialCache = SpineAnimationRenderer._materialCache;
|
|
10904
11240
|
for(var i2 = 0, l = curLen; i2 < l; ++i2){
|
|
10905
11241
|
var item1 = _subRenderItems[i2];
|
|
10906
11242
|
var slotName1 = item1.slotName, blendMode = item1.blendMode, texture1 = item1.texture;
|
|
10907
11243
|
renderer._addSubPrimitive(item1.subPrimitive);
|
|
10908
11244
|
var subTexture = _separateSlotTextureMap.get(slotName1) || texture1.getImage();
|
|
10909
|
-
var
|
|
10910
|
-
var material = materialCache.get(key);
|
|
10911
|
-
if (!material) {
|
|
10912
|
-
material = this._createMaterialForTexture(subTexture, engine, blendMode, premultipliedAlpha);
|
|
10913
|
-
materialCache.set(key, material);
|
|
10914
|
-
}
|
|
11245
|
+
var material = renderer._getMaterial(subTexture, blendMode);
|
|
10915
11246
|
renderer.setMaterial(i2, material);
|
|
10916
11247
|
}
|
|
10917
|
-
if (indicesLength > _vertexCount) {
|
|
11248
|
+
if (indicesLength > _vertexCount || renderer._needResizeBuffer) {
|
|
10918
11249
|
renderer._createAndBindBuffer(indicesLength);
|
|
11250
|
+
renderer._needResizeBuffer = false;
|
|
10919
11251
|
this.buildPrimitive(skeleton, renderer);
|
|
10920
11252
|
return;
|
|
10921
11253
|
}
|
|
@@ -10930,12 +11262,6 @@ var SubRenderItem = function SubRenderItem() {
|
|
|
10930
11262
|
_proto.addSeparateSlotTexture = function addSeparateSlotTexture(slotName, texture) {
|
|
10931
11263
|
this._separateSlotTextureMap.set(slotName, texture);
|
|
10932
11264
|
};
|
|
10933
|
-
_proto._createMaterialForTexture = function _createMaterialForTexture(texture, engine, blendMode, premultipliedAlpha) {
|
|
10934
|
-
var material = SpineAnimationRenderer._getDefaultMaterial(engine);
|
|
10935
|
-
material.shaderData.setTexture("material_SpineTexture", texture);
|
|
10936
|
-
setBlendMode(material, blendMode, premultipliedAlpha);
|
|
10937
|
-
return material;
|
|
10938
|
-
};
|
|
10939
11265
|
_proto._createRenderItem = function _createRenderItem(subPrimitives, primitiveIndex, start, count, texture, blend, slotName) {
|
|
10940
11266
|
var subPrimitivePool = SpineGenerator.subPrimitivePool, subRenderItemPool = SpineGenerator.subRenderItemPool;
|
|
10941
11267
|
var origin = subPrimitives[primitiveIndex];
|
|
@@ -10960,8 +11286,8 @@ var SubRenderItem = function SubRenderItem() {
|
|
|
10960
11286
|
};
|
|
10961
11287
|
return SpineGenerator;
|
|
10962
11288
|
}();
|
|
10963
|
-
SpineGenerator.
|
|
10964
|
-
SpineGenerator.
|
|
11289
|
+
SpineGenerator.vertexStrideWithoutTint = 9;
|
|
11290
|
+
SpineGenerator.vertexStrideWithTint = 12;
|
|
10965
11291
|
SpineGenerator.tempDark = new Color();
|
|
10966
11292
|
SpineGenerator.tempColor = new Color();
|
|
10967
11293
|
SpineGenerator.tempVerts = new Array(8);
|
|
@@ -10976,25 +11302,92 @@ SpineGenerator.QUAD_TRIANGLES = [
|
|
|
10976
11302
|
SpineGenerator.subPrimitivePool = new ReturnablePool(miniprogram.SubPrimitive);
|
|
10977
11303
|
SpineGenerator.subRenderItemPool = new ClearablePool(SubRenderItem);
|
|
10978
11304
|
|
|
11305
|
+
var SourceAlpha = miniprogram.BlendFactor.SourceAlpha, One = miniprogram.BlendFactor.One, DestinationColor = miniprogram.BlendFactor.DestinationColor, OneMinusSourceColor = miniprogram.BlendFactor.OneMinusSourceColor, OneMinusSourceAlpha = miniprogram.BlendFactor.OneMinusSourceAlpha;
|
|
11306
|
+
var Add = miniprogram.BlendOperation.Add;
|
|
10979
11307
|
var SpineMaterial = /*#__PURE__*/ function(Material) {
|
|
10980
11308
|
_inherits(SpineMaterial, Material);
|
|
10981
11309
|
function SpineMaterial(engine) {
|
|
10982
11310
|
var _this;
|
|
10983
11311
|
var shader = miniprogram.Shader.find("galacean-spine-shader") || miniprogram.Shader.create("galacean-spine-shader", SpineMaterial._spineVS, SpineMaterial._spineFS);
|
|
10984
|
-
_this = Material.call(this, engine, shader) || this;
|
|
11312
|
+
_this = Material.call(this, engine, shader) || this, _this._blendMode = exports.BlendMode.Normal;
|
|
10985
11313
|
var renderState = _this.renderState;
|
|
10986
11314
|
var target = renderState.blendState.targetBlendState;
|
|
10987
11315
|
target.enabled = true;
|
|
10988
|
-
|
|
11316
|
+
_this._setBlendMode(exports.BlendMode.Normal, false);
|
|
10989
11317
|
renderState.depthState.writeEnabled = false;
|
|
10990
11318
|
renderState.rasterState.cullMode = miniprogram.CullMode.Off;
|
|
10991
11319
|
renderState.renderQueueType = miniprogram.RenderQueueType.Transparent;
|
|
10992
11320
|
return _this;
|
|
10993
11321
|
}
|
|
11322
|
+
var _proto = SpineMaterial.prototype;
|
|
11323
|
+
/**
|
|
11324
|
+
* @internal
|
|
11325
|
+
*/ _proto._setTintBlack = function _setTintBlack(enabled) {
|
|
11326
|
+
if (enabled) {
|
|
11327
|
+
this.shaderData.enableMacro("RENDERER_TINT_BLACK");
|
|
11328
|
+
} else {
|
|
11329
|
+
this.shaderData.disableMacro("RENDERER_TINT_BLACK");
|
|
11330
|
+
}
|
|
11331
|
+
};
|
|
11332
|
+
/**
|
|
11333
|
+
* @internal
|
|
11334
|
+
*/ _proto._setPremultipliedAlpha = function _setPremultipliedAlpha(enabled) {
|
|
11335
|
+
if (enabled) {
|
|
11336
|
+
this.shaderData.setFloat("renderer_PremultipliedAlpha", 1);
|
|
11337
|
+
} else {
|
|
11338
|
+
this.shaderData.setFloat("renderer_PremultipliedAlpha", 0);
|
|
11339
|
+
}
|
|
11340
|
+
};
|
|
11341
|
+
/**
|
|
11342
|
+
* @internal
|
|
11343
|
+
*/ _proto._setTexture = function _setTexture(value) {
|
|
11344
|
+
this.shaderData.setTexture("material_SpineTexture", value);
|
|
11345
|
+
};
|
|
11346
|
+
/**
|
|
11347
|
+
* @internal
|
|
11348
|
+
*/ _proto._setBlendMode = function _setBlendMode(blendMode, premultipliedAlpha) {
|
|
11349
|
+
var target = this.renderState.blendState.targetBlendState;
|
|
11350
|
+
this._blendMode = blendMode;
|
|
11351
|
+
switch(blendMode){
|
|
11352
|
+
case exports.BlendMode.Additive:
|
|
11353
|
+
target.sourceColorBlendFactor = premultipliedAlpha ? One : SourceAlpha;
|
|
11354
|
+
target.destinationColorBlendFactor = One;
|
|
11355
|
+
target.sourceAlphaBlendFactor = One;
|
|
11356
|
+
target.destinationAlphaBlendFactor = One;
|
|
11357
|
+
target.colorBlendOperation = target.alphaBlendOperation = Add;
|
|
11358
|
+
break;
|
|
11359
|
+
case exports.BlendMode.Multiply:
|
|
11360
|
+
target.sourceColorBlendFactor = DestinationColor;
|
|
11361
|
+
target.destinationColorBlendFactor = OneMinusSourceAlpha;
|
|
11362
|
+
target.sourceAlphaBlendFactor = One;
|
|
11363
|
+
target.destinationAlphaBlendFactor = OneMinusSourceAlpha;
|
|
11364
|
+
target.colorBlendOperation = target.alphaBlendOperation = Add;
|
|
11365
|
+
break;
|
|
11366
|
+
case exports.BlendMode.Screen:
|
|
11367
|
+
target.sourceColorBlendFactor = One;
|
|
11368
|
+
target.destinationColorBlendFactor = OneMinusSourceColor;
|
|
11369
|
+
target.sourceAlphaBlendFactor = One;
|
|
11370
|
+
target.destinationAlphaBlendFactor = OneMinusSourceColor;
|
|
11371
|
+
target.colorBlendOperation = target.alphaBlendOperation = Add;
|
|
11372
|
+
break;
|
|
11373
|
+
default:
|
|
11374
|
+
target.sourceColorBlendFactor = premultipliedAlpha ? One : SourceAlpha;
|
|
11375
|
+
target.destinationColorBlendFactor = OneMinusSourceAlpha;
|
|
11376
|
+
target.sourceAlphaBlendFactor = One;
|
|
11377
|
+
target.destinationAlphaBlendFactor = OneMinusSourceAlpha;
|
|
11378
|
+
target.colorBlendOperation = target.alphaBlendOperation = Add;
|
|
11379
|
+
break;
|
|
11380
|
+
}
|
|
11381
|
+
};
|
|
11382
|
+
/**
|
|
11383
|
+
* @internal
|
|
11384
|
+
*/ _proto._getBlendMode = function _getBlendMode() {
|
|
11385
|
+
return this._blendMode;
|
|
11386
|
+
};
|
|
10994
11387
|
return SpineMaterial;
|
|
10995
11388
|
}(miniprogram.Material);
|
|
10996
|
-
SpineMaterial._spineVS = "\n uniform mat4 renderer_MVPMat;\n\n attribute vec3 POSITION;\n attribute vec2 TEXCOORD_0;\n attribute vec4
|
|
10997
|
-
SpineMaterial._spineFS = "\n #include <common>\n uniform sampler2D material_SpineTexture;\n\n varying vec2 v_uv;\n varying vec4
|
|
11389
|
+
SpineMaterial._spineVS = "\n uniform mat4 renderer_MVPMat;\n\n attribute vec3 POSITION;\n attribute vec2 TEXCOORD_0;\n attribute vec4 LIGHT_COLOR;\n \n varying vec2 v_uv;\n varying vec4 v_lightColor;\n\n #ifdef RENDERER_TINT_BLACK\n attribute vec3 DARK_COLOR;\n varying vec3 v_darkColor;\n #endif\n \n void main()\n {\n gl_Position = renderer_MVPMat * vec4(POSITION, 1.0);\n \n v_uv = TEXCOORD_0;\n v_lightColor = LIGHT_COLOR;\n\n #ifdef RENDERER_TINT_BLACK\n v_darkColor = DARK_COLOR;\n #endif\n }\n ";
|
|
11390
|
+
SpineMaterial._spineFS = "\n #include <common>\n uniform sampler2D material_SpineTexture;\n uniform float renderer_PremultipliedAlpha;\n\n varying vec2 v_uv;\n varying vec4 v_lightColor;\n\n #ifdef RENDERER_TINT_BLACK\n varying vec3 v_darkColor;\n #endif\n \n void main()\n {\n vec4 texColor = texture2D(material_SpineTexture, v_uv);\n vec4 lightColor = sRGBToLinear(v_lightColor);\n #ifdef RENDERER_TINT_BLACK\n vec4 darkColor = sRGBToLinear(vec4(v_darkColor, 1.0));\n vec3 dark_premult = (texColor.a - texColor.rgb) * darkColor.rgb;\n vec3 dark_nonpremult = (1.0 - texColor.rgb) * darkColor.rgb;\n vec3 dark = mix(dark_nonpremult, dark_premult, renderer_PremultipliedAlpha);\n vec3 light = texColor.rgb * lightColor.rgb;\n gl_FragColor.rgb = dark + light;\n gl_FragColor.a = texColor.a * lightColor.a;\n #else\n gl_FragColor = texColor * lightColor;\n #endif\n }\n ";
|
|
10998
11391
|
|
|
10999
11392
|
/**
|
|
11000
11393
|
* Spine animation renderer, capable of rendering spine animations and providing functions for animation and skeleton manipulation.
|
|
@@ -11009,15 +11402,17 @@ SpineMaterial._spineFS = "\n #include <common>\n uniform sampler2D materia
|
|
|
11009
11402
|
* When enabled, vertex color values are multiplied by the alpha channel.
|
|
11010
11403
|
* @remarks
|
|
11011
11404
|
If this option is enabled, the Spine editor must export textures with "Premultiply Alpha" checked.
|
|
11012
|
-
*/ _this.premultipliedAlpha = false, /**
|
|
11405
|
+
*/ _this.premultipliedAlpha = false, _this._tintBlack = false, /**
|
|
11013
11406
|
* Default state for spine animation.
|
|
11014
11407
|
* Contains the default animation name to be played, whether this animation should loop, the default skin name.
|
|
11015
11408
|
*/ _this.defaultConfig = new SpineAnimationDefaultConfig(), /** @internal */ _this._subPrimitives = [], /** @internal */ _this._vertices = new Float32Array(), /** @internal */ _this._indices = new Uint16Array(), /** @internal */ _this._needResizeBuffer = false, /** @internal */ _this._vertexCount = 0, /** @internal */ _this._localBounds = new miniprogram.BoundingBox(new miniprogram.Vector3(Infinity, Infinity, Infinity), new miniprogram.Vector3(-Infinity, -Infinity, -Infinity));
|
|
11016
11409
|
var primitive = new miniprogram.Primitive(_this._engine);
|
|
11017
11410
|
_this._primitive = primitive;
|
|
11411
|
+
_this._primitive._addReferCount(1);
|
|
11018
11412
|
primitive.addVertexElement(SpineAnimationRenderer._positionVertexElement);
|
|
11019
|
-
primitive.addVertexElement(SpineAnimationRenderer.
|
|
11413
|
+
primitive.addVertexElement(SpineAnimationRenderer._lightColorVertexElement);
|
|
11020
11414
|
primitive.addVertexElement(SpineAnimationRenderer._uvVertexElement);
|
|
11415
|
+
primitive.addVertexElement(SpineAnimationRenderer._darkColorVertexElement);
|
|
11021
11416
|
return _this;
|
|
11022
11417
|
}
|
|
11023
11418
|
var _proto = SpineAnimationRenderer.prototype;
|
|
@@ -11099,8 +11494,12 @@ SpineMaterial._spineFS = "\n #include <common>\n uniform sampler2D materia
|
|
|
11099
11494
|
*/ _proto._onDestroy = function _onDestroy() {
|
|
11100
11495
|
this._clearMaterialCache();
|
|
11101
11496
|
this._subPrimitives.length = 0;
|
|
11102
|
-
|
|
11103
|
-
|
|
11497
|
+
var primitive = this._primitive;
|
|
11498
|
+
if (primitive) {
|
|
11499
|
+
primitive._addReferCount(-1);
|
|
11500
|
+
primitive._destroy();
|
|
11501
|
+
this._primitive = null;
|
|
11502
|
+
}
|
|
11104
11503
|
this._resource = null;
|
|
11105
11504
|
this._skeleton = null;
|
|
11106
11505
|
this._state = null;
|
|
@@ -11111,9 +11510,10 @@ SpineMaterial._spineFS = "\n #include <common>\n uniform sampler2D materia
|
|
|
11111
11510
|
*/ _proto._createAndBindBuffer = function _createAndBindBuffer(vertexCount) {
|
|
11112
11511
|
var _this = this, _engine = _this._engine, _primitive = _this._primitive;
|
|
11113
11512
|
this._vertexCount = vertexCount;
|
|
11114
|
-
this.
|
|
11513
|
+
var stride = this.tintBlack ? SpineGenerator.vertexStrideWithTint : SpineGenerator.vertexStrideWithoutTint;
|
|
11514
|
+
this._vertices = new Float32Array(vertexCount * stride);
|
|
11115
11515
|
this._indices = new Uint16Array(vertexCount);
|
|
11116
|
-
var vertexStride =
|
|
11516
|
+
var vertexStride = stride << 2;
|
|
11117
11517
|
var vertexBuffer = new miniprogram.Buffer(_engine, miniprogram.BufferBindFlag.VertexBuffer, this._vertices, miniprogram.BufferUsage.Dynamic);
|
|
11118
11518
|
var indexBuffer = new miniprogram.Buffer(_engine, miniprogram.BufferBindFlag.IndexBuffer, this._indices, miniprogram.BufferUsage.Dynamic);
|
|
11119
11519
|
this._indexBuffer = indexBuffer;
|
|
@@ -11133,14 +11533,34 @@ SpineMaterial._spineFS = "\n #include <common>\n uniform sampler2D materia
|
|
|
11133
11533
|
*/ _proto._clearSubPrimitives = function _clearSubPrimitives() {
|
|
11134
11534
|
this._subPrimitives.length = 0;
|
|
11135
11535
|
};
|
|
11536
|
+
/**
|
|
11537
|
+
* @internal
|
|
11538
|
+
*/ _proto._getMaterial = function _getMaterial(texture, blendMode) {
|
|
11539
|
+
var engine = this._engine;
|
|
11540
|
+
var premultipliedAlpha = this.premultipliedAlpha;
|
|
11541
|
+
var tintBlack = this.tintBlack;
|
|
11542
|
+
var key = texture.instanceId + "_" + blendMode + "_" + (premultipliedAlpha ? 1 : 0);
|
|
11543
|
+
var cached = SpineAnimationRenderer._materialCacheMap[key];
|
|
11544
|
+
if (!cached) {
|
|
11545
|
+
cached = new SpineMaterial(engine);
|
|
11546
|
+
cached.isGCIgnored = true;
|
|
11547
|
+
SpineAnimationRenderer._materialCacheMap.set(key, cached);
|
|
11548
|
+
}
|
|
11549
|
+
cached._setBlendMode(blendMode, premultipliedAlpha);
|
|
11550
|
+
cached._setTexture(texture);
|
|
11551
|
+
cached._setTintBlack(tintBlack);
|
|
11552
|
+
cached._setPremultipliedAlpha(premultipliedAlpha);
|
|
11553
|
+
return cached;
|
|
11554
|
+
};
|
|
11136
11555
|
_proto._clearMaterialCache = function _clearMaterialCache() {
|
|
11137
|
-
var materialCache = SpineAnimationRenderer.
|
|
11138
|
-
var
|
|
11556
|
+
var materialCache = SpineAnimationRenderer._materialCacheMap;
|
|
11557
|
+
var premultipliedAlpha = this.premultipliedAlpha;
|
|
11558
|
+
var materials = this._materials;
|
|
11139
11559
|
for(var i = 0, len = materials.length; i < len; i += 1){
|
|
11140
11560
|
var material = materials[i];
|
|
11141
11561
|
var texture = material.shaderData.getTexture("material_SpineTexture");
|
|
11142
|
-
var blendMode =
|
|
11143
|
-
var key = texture.instanceId + "_" + blendMode;
|
|
11562
|
+
var blendMode = material._getBlendMode();
|
|
11563
|
+
var key = texture.instanceId + "_" + blendMode + "_" + (premultipliedAlpha ? 1 : 0);
|
|
11144
11564
|
materialCache.delete(key);
|
|
11145
11565
|
}
|
|
11146
11566
|
};
|
|
@@ -11157,22 +11577,23 @@ SpineMaterial._spineFS = "\n #include <common>\n uniform sampler2D materia
|
|
|
11157
11577
|
}
|
|
11158
11578
|
}
|
|
11159
11579
|
};
|
|
11160
|
-
/** @internal */ SpineAnimationRenderer._getDefaultMaterial = function _getDefaultMaterial(engine) {
|
|
11161
|
-
var defaultMaterial = this._defaultMaterial;
|
|
11162
|
-
if (defaultMaterial) {
|
|
11163
|
-
if (defaultMaterial.engine === engine) {
|
|
11164
|
-
return defaultMaterial.clone();
|
|
11165
|
-
} else {
|
|
11166
|
-
defaultMaterial.destroy(true);
|
|
11167
|
-
defaultMaterial = null;
|
|
11168
|
-
}
|
|
11169
|
-
}
|
|
11170
|
-
defaultMaterial = new SpineMaterial(engine);
|
|
11171
|
-
defaultMaterial.isGCIgnored = true;
|
|
11172
|
-
this._defaultMaterial = defaultMaterial;
|
|
11173
|
-
return defaultMaterial.clone();
|
|
11174
|
-
};
|
|
11175
11580
|
_create_class(SpineAnimationRenderer, [
|
|
11581
|
+
{
|
|
11582
|
+
key: "tintBlack",
|
|
11583
|
+
get: /**
|
|
11584
|
+
* Whether to enable tint black feature for dark color tinting.
|
|
11585
|
+
*
|
|
11586
|
+
* @remarks Should be enabled when using "Tint Black" feature in Spine editor.
|
|
11587
|
+
*/ function get() {
|
|
11588
|
+
return this._tintBlack;
|
|
11589
|
+
},
|
|
11590
|
+
set: function set(value) {
|
|
11591
|
+
if (this._tintBlack !== value) {
|
|
11592
|
+
this._tintBlack = value;
|
|
11593
|
+
this._needResizeBuffer = true;
|
|
11594
|
+
}
|
|
11595
|
+
}
|
|
11596
|
+
},
|
|
11176
11597
|
{
|
|
11177
11598
|
key: "state",
|
|
11178
11599
|
get: /**
|
|
@@ -11226,15 +11647,19 @@ SpineMaterial._spineFS = "\n #include <common>\n uniform sampler2D materia
|
|
|
11226
11647
|
}(miniprogram.Renderer);
|
|
11227
11648
|
SpineAnimationRenderer._spineGenerator = new SpineGenerator();
|
|
11228
11649
|
SpineAnimationRenderer._positionVertexElement = new miniprogram.VertexElement("POSITION", 0, miniprogram.VertexElementFormat.Vector3, 0);
|
|
11229
|
-
SpineAnimationRenderer.
|
|
11650
|
+
SpineAnimationRenderer._lightColorVertexElement = new miniprogram.VertexElement("LIGHT_COLOR", 12, miniprogram.VertexElementFormat.Vector4, 0);
|
|
11230
11651
|
SpineAnimationRenderer._uvVertexElement = new miniprogram.VertexElement("TEXCOORD_0", 28, miniprogram.VertexElementFormat.Vector2, 0);
|
|
11231
|
-
|
|
11652
|
+
SpineAnimationRenderer._darkColorVertexElement = new miniprogram.VertexElement("DARK_COLOR", 36, miniprogram.VertexElementFormat.Vector3, 0);
|
|
11653
|
+
/** @internal */ SpineAnimationRenderer._materialCacheMap = new Map();
|
|
11232
11654
|
__decorate([
|
|
11233
11655
|
miniprogram.assignmentClone
|
|
11234
11656
|
], SpineAnimationRenderer.prototype, "zSpacing", void 0);
|
|
11235
11657
|
__decorate([
|
|
11236
11658
|
miniprogram.assignmentClone
|
|
11237
11659
|
], SpineAnimationRenderer.prototype, "premultipliedAlpha", void 0);
|
|
11660
|
+
__decorate([
|
|
11661
|
+
miniprogram.assignmentClone
|
|
11662
|
+
], SpineAnimationRenderer.prototype, "_tintBlack", void 0);
|
|
11238
11663
|
__decorate([
|
|
11239
11664
|
miniprogram.deepClone
|
|
11240
11665
|
], SpineAnimationRenderer.prototype, "defaultConfig", void 0);
|
|
@@ -11635,7 +12060,7 @@ for(var key in RendererObject){
|
|
|
11635
12060
|
for(var key1 in LoaderObject){
|
|
11636
12061
|
miniprogram.Loader.registerClass(key1, LoaderObject[key1]);
|
|
11637
12062
|
}
|
|
11638
|
-
var version = "4.2.
|
|
12063
|
+
var version = "4.2.4";
|
|
11639
12064
|
console.log("Galacean spine version: " + version);
|
|
11640
12065
|
|
|
11641
12066
|
exports.AlphaTimeline = AlphaTimeline;
|
|
@@ -11643,6 +12068,7 @@ exports.Animation = Animation;
|
|
|
11643
12068
|
exports.AnimationState = AnimationState;
|
|
11644
12069
|
exports.AnimationStateAdapter = AnimationStateAdapter;
|
|
11645
12070
|
exports.AnimationStateData = AnimationStateData;
|
|
12071
|
+
exports.AssetCache = AssetCache;
|
|
11646
12072
|
exports.AssetManagerBase = AssetManagerBase;
|
|
11647
12073
|
exports.AtlasAttachmentLoader = AtlasAttachmentLoader;
|
|
11648
12074
|
exports.Attachment = Attachment;
|