@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/module.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TextureFilterMode, TextureWrapMode, AssetType, BlendFactor, BlendOperation,
|
|
1
|
+
import { TextureFilterMode, TextureWrapMode, AssetType, SubPrimitive, BlendFactor, BlendOperation, Shader, CullMode, RenderQueueType, Material, VertexElement, VertexElementFormat, BoundingBox, Buffer, BufferBindFlag, BufferUsage, VertexBufferBinding, IndexBufferBinding, IndexFormat, Renderer, assignmentClone, deepClone, ignoreClone, Vector3, Primitive, Entity, ReferResource, resourceLoader, AssetPromise, Loader } from '@galacean/engine';
|
|
2
2
|
|
|
3
3
|
function _set_prototype_of(o, p) {
|
|
4
4
|
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
@@ -39,6 +39,97 @@ function __decorate(decorators, target, key, desc) {
|
|
|
39
39
|
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;
|
|
40
40
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
41
41
|
}
|
|
42
|
+
function __generator(thisArg, body) {
|
|
43
|
+
var _ = {
|
|
44
|
+
label: 0,
|
|
45
|
+
sent: function sent() {
|
|
46
|
+
if (t[0] & 1) throw t[1];
|
|
47
|
+
return t[1];
|
|
48
|
+
},
|
|
49
|
+
trys: [],
|
|
50
|
+
ops: []
|
|
51
|
+
}, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
52
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
53
|
+
return this;
|
|
54
|
+
}), g;
|
|
55
|
+
function verb(n) {
|
|
56
|
+
return function(v) {
|
|
57
|
+
return step([
|
|
58
|
+
n,
|
|
59
|
+
v
|
|
60
|
+
]);
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function step(op) {
|
|
64
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
65
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
66
|
+
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;
|
|
67
|
+
if (y = 0, t) op = [
|
|
68
|
+
op[0] & 2,
|
|
69
|
+
t.value
|
|
70
|
+
];
|
|
71
|
+
switch(op[0]){
|
|
72
|
+
case 0:
|
|
73
|
+
case 1:
|
|
74
|
+
t = op;
|
|
75
|
+
break;
|
|
76
|
+
case 4:
|
|
77
|
+
_.label++;
|
|
78
|
+
return {
|
|
79
|
+
value: op[1],
|
|
80
|
+
done: false
|
|
81
|
+
};
|
|
82
|
+
case 5:
|
|
83
|
+
_.label++;
|
|
84
|
+
y = op[1];
|
|
85
|
+
op = [
|
|
86
|
+
0
|
|
87
|
+
];
|
|
88
|
+
continue;
|
|
89
|
+
case 7:
|
|
90
|
+
op = _.ops.pop();
|
|
91
|
+
_.trys.pop();
|
|
92
|
+
continue;
|
|
93
|
+
default:
|
|
94
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
95
|
+
_ = 0;
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
99
|
+
_.label = op[1];
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
103
|
+
_.label = t[1];
|
|
104
|
+
t = op;
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
if (t && _.label < t[2]) {
|
|
108
|
+
_.label = t[2];
|
|
109
|
+
_.ops.push(op);
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
if (t[2]) _.ops.pop();
|
|
113
|
+
_.trys.pop();
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
op = body.call(thisArg, _);
|
|
117
|
+
} catch (e) {
|
|
118
|
+
op = [
|
|
119
|
+
6,
|
|
120
|
+
e
|
|
121
|
+
];
|
|
122
|
+
y = 0;
|
|
123
|
+
} finally{
|
|
124
|
+
f = t = 0;
|
|
125
|
+
}
|
|
126
|
+
if (op[0] & 5) throw op[1];
|
|
127
|
+
return {
|
|
128
|
+
value: op[0] ? op[1] : void 0,
|
|
129
|
+
done: true
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
}
|
|
42
133
|
typeof SuppressedError === "function" ? SuppressedError : function _SuppressedError(error, suppressed, message) {
|
|
43
134
|
var e = new Error(message);
|
|
44
135
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
@@ -198,8 +289,9 @@ var Color = /*#__PURE__*/ function() {
|
|
|
198
289
|
color.g = ((value & 0x0000ff00) >>> 8) / 255;
|
|
199
290
|
color.b = (value & 0x000000ff) / 255;
|
|
200
291
|
};
|
|
201
|
-
Color.fromString = function fromString(hex) {
|
|
202
|
-
|
|
292
|
+
Color.fromString = function fromString(hex, color) {
|
|
293
|
+
if (color === void 0) color = new Color();
|
|
294
|
+
return color.setFromString(hex);
|
|
203
295
|
};
|
|
204
296
|
return Color;
|
|
205
297
|
}();
|
|
@@ -2823,18 +2915,16 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
2823
2915
|
var finished = this.updateMixingFrom(from, delta);
|
|
2824
2916
|
from.animationLast = from.nextAnimationLast;
|
|
2825
2917
|
from.trackLast = from.nextTrackLast;
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
this.queue.end(from);
|
|
2835
|
-
}
|
|
2836
|
-
return finished;
|
|
2918
|
+
// The from entry was applied at least once and the mix is complete.
|
|
2919
|
+
if (to.nextTrackLast != -1 && to.mixTime >= to.mixDuration) {
|
|
2920
|
+
// Mixing is complete for all entries before the from entry or the mix is instantaneous.
|
|
2921
|
+
if (from.totalAlpha == 0 || to.mixDuration == 0) {
|
|
2922
|
+
to.mixingFrom = from.mixingFrom;
|
|
2923
|
+
if (from.mixingFrom != null) from.mixingFrom.mixingTo = to;
|
|
2924
|
+
to.interruptAlpha = from.interruptAlpha;
|
|
2925
|
+
this.queue.end(from);
|
|
2837
2926
|
}
|
|
2927
|
+
return finished;
|
|
2838
2928
|
}
|
|
2839
2929
|
from.trackTime += delta * from.timeScale;
|
|
2840
2930
|
to.mixTime += delta;
|
|
@@ -3199,10 +3289,11 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
3199
3289
|
if (!last) {
|
|
3200
3290
|
this.setCurrent(trackIndex, entry, true);
|
|
3201
3291
|
this.queue.drain();
|
|
3292
|
+
if (delay < 0) delay = 0;
|
|
3202
3293
|
} else {
|
|
3203
3294
|
last.next = entry;
|
|
3204
3295
|
entry.previous = last;
|
|
3205
|
-
if (delay <= 0) delay
|
|
3296
|
+
if (delay <= 0) delay = Math.max(delay + last.getTrackComplete() - entry.mixDuration, 0);
|
|
3206
3297
|
}
|
|
3207
3298
|
entry.delay = delay;
|
|
3208
3299
|
return entry;
|
|
@@ -3241,7 +3332,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
3241
3332
|
if (mixDuration === void 0) mixDuration = 0;
|
|
3242
3333
|
if (delay === void 0) delay = 0;
|
|
3243
3334
|
var entry = this.addAnimationWith(trackIndex, AnimationState.emptyAnimation(), false, delay);
|
|
3244
|
-
if (delay <= 0) entry.delay
|
|
3335
|
+
if (delay <= 0) entry.delay = Math.max(entry.delay + entry.mixDuration - mixDuration, 0);
|
|
3245
3336
|
entry.mixDuration = mixDuration;
|
|
3246
3337
|
entry.trackEnd = mixDuration;
|
|
3247
3338
|
return entry;
|
|
@@ -3495,7 +3586,10 @@ AnimationState._emptyAnimation = new Animation("<empty>", [], 0);
|
|
|
3495
3586
|
var _proto = TrackEntry.prototype;
|
|
3496
3587
|
_proto.setMixDurationWithDelay = function setMixDurationWithDelay(mixDuration, delay) {
|
|
3497
3588
|
this._mixDuration = mixDuration;
|
|
3498
|
-
if (
|
|
3589
|
+
if (delay <= 0) {
|
|
3590
|
+
if (this.previous != null) delay = Math.max(delay + this.previous.getTrackComplete() - mixDuration, 0);
|
|
3591
|
+
else delay = 0;
|
|
3592
|
+
}
|
|
3499
3593
|
this.delay = delay;
|
|
3500
3594
|
};
|
|
3501
3595
|
_proto.reset = function reset() {
|
|
@@ -3718,17 +3812,17 @@ var CURRENT = 2;
|
|
|
3718
3812
|
|
|
3719
3813
|
/******************************************************************************
|
|
3720
3814
|
* Spine Runtimes License Agreement
|
|
3721
|
-
* Last updated
|
|
3815
|
+
* Last updated April 5, 2025. Replaces all prior versions.
|
|
3722
3816
|
*
|
|
3723
|
-
* Copyright (c) 2013-
|
|
3817
|
+
* Copyright (c) 2013-2025, Esoteric Software LLC
|
|
3724
3818
|
*
|
|
3725
3819
|
* Integration of the Spine Runtimes into software or otherwise creating
|
|
3726
3820
|
* derivative works of the Spine Runtimes is permitted under the terms and
|
|
3727
3821
|
* conditions of Section 2 of the Spine Editor License Agreement:
|
|
3728
3822
|
* http://esotericsoftware.com/spine-editor-license
|
|
3729
3823
|
*
|
|
3730
|
-
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
|
3731
|
-
* otherwise create derivative works of the Spine Runtimes (collectively,
|
|
3824
|
+
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
|
3825
|
+
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
|
3732
3826
|
* "Products"), provided that each user of the Products must obtain their own
|
|
3733
3827
|
* Spine Editor license and redistribution of the Products in any form must
|
|
3734
3828
|
* include this license and copyright notice.
|
|
@@ -3741,8 +3835,8 @@ var CURRENT = 2;
|
|
|
3741
3835
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
|
3742
3836
|
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
|
3743
3837
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
3744
|
-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
3745
|
-
* SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
3838
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
3839
|
+
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
3746
3840
|
*****************************************************************************/ /** Stores mix (crossfade) durations to be applied when {@link AnimationState} animations are changed. */ var AnimationStateData = /*#__PURE__*/ function() {
|
|
3747
3841
|
function AnimationStateData(skeletonData) {
|
|
3748
3842
|
this.animationToMixTime = {};
|
|
@@ -4194,7 +4288,7 @@ var TextureAtlasRegion = /*#__PURE__*/ function(TextureRegion) {
|
|
|
4194
4288
|
this.copyTo(copy);
|
|
4195
4289
|
copy.regionUVs = new Array(this.regionUVs.length);
|
|
4196
4290
|
Utils.arrayCopy(this.regionUVs, 0, copy.regionUVs, 0, this.regionUVs.length);
|
|
4197
|
-
copy.uvs = new Array(this.uvs.length);
|
|
4291
|
+
copy.uvs = _instanceof1(this.uvs, Float32Array) ? Utils.newFloatArray(this.uvs.length) : new Array(this.uvs.length);
|
|
4198
4292
|
Utils.arrayCopy(this.uvs, 0, copy.uvs, 0, this.uvs.length);
|
|
4199
4293
|
copy.triangles = new Array(this.triangles.length);
|
|
4200
4294
|
Utils.arrayCopy(this.triangles, 0, copy.triangles, 0, this.triangles.length);
|
|
@@ -4858,17 +4952,17 @@ RegionAttachment.V4 = 31;
|
|
|
4858
4952
|
|
|
4859
4953
|
/******************************************************************************
|
|
4860
4954
|
* Spine Runtimes License Agreement
|
|
4861
|
-
* Last updated
|
|
4955
|
+
* Last updated April 5, 2025. Replaces all prior versions.
|
|
4862
4956
|
*
|
|
4863
|
-
* Copyright (c) 2013-
|
|
4957
|
+
* Copyright (c) 2013-2025, Esoteric Software LLC
|
|
4864
4958
|
*
|
|
4865
4959
|
* Integration of the Spine Runtimes into software or otherwise creating
|
|
4866
4960
|
* derivative works of the Spine Runtimes is permitted under the terms and
|
|
4867
4961
|
* conditions of Section 2 of the Spine Editor License Agreement:
|
|
4868
4962
|
* http://esotericsoftware.com/spine-editor-license
|
|
4869
4963
|
*
|
|
4870
|
-
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
|
4871
|
-
* otherwise create derivative works of the Spine Runtimes (collectively,
|
|
4964
|
+
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
|
4965
|
+
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
|
4872
4966
|
* "Products"), provided that each user of the Products must obtain their own
|
|
4873
4967
|
* Spine Editor license and redistribution of the Products in any form must
|
|
4874
4968
|
* include this license and copyright notice.
|
|
@@ -4881,8 +4975,8 @@ RegionAttachment.V4 = 31;
|
|
|
4881
4975
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
|
4882
4976
|
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
|
4883
4977
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
4884
|
-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
4885
|
-
* SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
4978
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
4979
|
+
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
4886
4980
|
*****************************************************************************/ /** The base class for all constraint datas. */ var ConstraintData = function ConstraintData(name, order, skinRequired) {
|
|
4887
4981
|
this.name = name;
|
|
4888
4982
|
this.order = order;
|
|
@@ -4890,18 +4984,46 @@ RegionAttachment.V4 = 31;
|
|
|
4890
4984
|
}
|
|
4891
4985
|
;
|
|
4892
4986
|
|
|
4987
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
4988
|
+
try {
|
|
4989
|
+
var info = gen[key](arg);
|
|
4990
|
+
var value = info.value;
|
|
4991
|
+
} catch (error) {
|
|
4992
|
+
reject(error);
|
|
4993
|
+
return;
|
|
4994
|
+
}
|
|
4995
|
+
if (info.done) resolve(value);
|
|
4996
|
+
else Promise.resolve(value).then(_next, _throw);
|
|
4997
|
+
}
|
|
4998
|
+
function _async_to_generator(fn) {
|
|
4999
|
+
return function() {
|
|
5000
|
+
var self = this, args = arguments;
|
|
5001
|
+
return new Promise(function(resolve, reject) {
|
|
5002
|
+
var gen = fn.apply(self, args);
|
|
5003
|
+
function _next(value) {
|
|
5004
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
5005
|
+
}
|
|
5006
|
+
function _throw(err) {
|
|
5007
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
5008
|
+
}
|
|
5009
|
+
_next(undefined);
|
|
5010
|
+
});
|
|
5011
|
+
};
|
|
5012
|
+
}
|
|
5013
|
+
|
|
4893
5014
|
var AssetManagerBase = /*#__PURE__*/ function() {
|
|
4894
|
-
function AssetManagerBase(textureLoader, pathPrefix, downloader) {
|
|
5015
|
+
function AssetManagerBase(textureLoader, pathPrefix, downloader, cache) {
|
|
4895
5016
|
if (pathPrefix === void 0) pathPrefix = "";
|
|
4896
5017
|
if (downloader === void 0) downloader = new Downloader();
|
|
5018
|
+
if (cache === void 0) cache = new AssetCache();
|
|
4897
5019
|
this.pathPrefix = "";
|
|
4898
|
-
this.assets = {};
|
|
4899
5020
|
this.errors = {};
|
|
4900
5021
|
this.toLoad = 0;
|
|
4901
5022
|
this.loaded = 0;
|
|
4902
5023
|
this.textureLoader = textureLoader;
|
|
4903
5024
|
this.pathPrefix = pathPrefix;
|
|
4904
5025
|
this.downloader = downloader;
|
|
5026
|
+
this.cache = cache;
|
|
4905
5027
|
}
|
|
4906
5028
|
var _proto = AssetManagerBase.prototype;
|
|
4907
5029
|
_proto.start = function start(path) {
|
|
@@ -4911,7 +5033,8 @@ var AssetManagerBase = /*#__PURE__*/ function() {
|
|
|
4911
5033
|
_proto.success = function success(callback, path, asset) {
|
|
4912
5034
|
this.toLoad--;
|
|
4913
5035
|
this.loaded++;
|
|
4914
|
-
this.assets[path] = asset;
|
|
5036
|
+
this.cache.assets[path] = asset;
|
|
5037
|
+
this.cache.assetsRefCount[path] = (this.cache.assetsRefCount[path] || 0) + 1;
|
|
4915
5038
|
if (callback) callback(path, asset);
|
|
4916
5039
|
};
|
|
4917
5040
|
_proto.error = function error(callback, path, message) {
|
|
@@ -4943,10 +5066,16 @@ var AssetManagerBase = /*#__PURE__*/ function() {
|
|
|
4943
5066
|
if (success === void 0) success = function() {};
|
|
4944
5067
|
if (error === void 0) error = function() {};
|
|
4945
5068
|
path = this.start(path);
|
|
4946
|
-
this.
|
|
4947
|
-
|
|
4948
|
-
|
|
4949
|
-
|
|
5069
|
+
if (this.reuseAssets(path, success, error)) return;
|
|
5070
|
+
this.cache.assetsLoaded[path] = new Promise(function(resolve, reject) {
|
|
5071
|
+
_this.downloader.downloadBinary(path, function(data) {
|
|
5072
|
+
_this.success(success, path, data);
|
|
5073
|
+
resolve(data);
|
|
5074
|
+
}, function(status, responseText) {
|
|
5075
|
+
var errorMsg = "Couldn't load binary " + path + ": status " + status + ", " + responseText;
|
|
5076
|
+
_this.error(error, path, errorMsg);
|
|
5077
|
+
reject(errorMsg);
|
|
5078
|
+
});
|
|
4950
5079
|
});
|
|
4951
5080
|
};
|
|
4952
5081
|
_proto.loadText = function loadText(path, success, error) {
|
|
@@ -4965,46 +5094,83 @@ var AssetManagerBase = /*#__PURE__*/ function() {
|
|
|
4965
5094
|
if (success === void 0) success = function() {};
|
|
4966
5095
|
if (error === void 0) error = function() {};
|
|
4967
5096
|
path = this.start(path);
|
|
4968
|
-
this.
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
5097
|
+
if (this.reuseAssets(path, success, error)) return;
|
|
5098
|
+
this.cache.assetsLoaded[path] = new Promise(function(resolve, reject) {
|
|
5099
|
+
_this.downloader.downloadJson(path, function(data) {
|
|
5100
|
+
_this.success(success, path, data);
|
|
5101
|
+
resolve(data);
|
|
5102
|
+
}, function(status, responseText) {
|
|
5103
|
+
var errorMsg = "Couldn't load JSON " + path + ": status " + status + ", " + responseText;
|
|
5104
|
+
_this.error(error, path, errorMsg);
|
|
5105
|
+
reject(errorMsg);
|
|
5106
|
+
});
|
|
4972
5107
|
});
|
|
4973
5108
|
};
|
|
4974
|
-
_proto.
|
|
5109
|
+
_proto.reuseAssets = function reuseAssets(path, success, error) {
|
|
4975
5110
|
var _this = this;
|
|
4976
5111
|
if (success === void 0) success = function() {};
|
|
4977
5112
|
if (error === void 0) error = function() {};
|
|
4978
|
-
|
|
4979
|
-
var
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
return blob ? createImageBitmap(blob, {
|
|
4990
|
-
premultiplyAlpha: "none",
|
|
4991
|
-
colorSpaceConversion: "none"
|
|
4992
|
-
}) : null;
|
|
4993
|
-
}).then(function(bitmap) {
|
|
4994
|
-
if (bitmap) _this.success(success, path, _this.textureLoader(bitmap));
|
|
5113
|
+
var loadedStatus = this.cache.assetsLoaded[path];
|
|
5114
|
+
var alreadyExistsOrLoading = loadedStatus !== undefined;
|
|
5115
|
+
if (alreadyExistsOrLoading) {
|
|
5116
|
+
this.cache.assetsLoaded[path] = loadedStatus.then(function(data) {
|
|
5117
|
+
// necessary when user preloads an image into the cache.
|
|
5118
|
+
// texture loader is not avaiable in the cache, so we transform in GLTexture at first use
|
|
5119
|
+
data = _instanceof1(data, Image) || _instanceof1(data, ImageBitmap) ? _this.textureLoader(data) : data;
|
|
5120
|
+
_this.success(success, path, data);
|
|
5121
|
+
return data;
|
|
5122
|
+
}).catch(function(errorMsg) {
|
|
5123
|
+
return _this.error(error, path, errorMsg);
|
|
4995
5124
|
});
|
|
4996
|
-
} else {
|
|
4997
|
-
var image = new Image();
|
|
4998
|
-
image.crossOrigin = "anonymous";
|
|
4999
|
-
image.onload = function() {
|
|
5000
|
-
_this.success(success, path, _this.textureLoader(image));
|
|
5001
|
-
};
|
|
5002
|
-
image.onerror = function() {
|
|
5003
|
-
_this.error(error, path, "Couldn't load image: " + path);
|
|
5004
|
-
};
|
|
5005
|
-
if (this.downloader.rawDataUris[path]) path = this.downloader.rawDataUris[path];
|
|
5006
|
-
image.src = path;
|
|
5007
5125
|
}
|
|
5126
|
+
return alreadyExistsOrLoading;
|
|
5127
|
+
};
|
|
5128
|
+
_proto.loadTexture = function loadTexture(path, success, error) {
|
|
5129
|
+
var _this = this;
|
|
5130
|
+
if (success === void 0) success = function() {};
|
|
5131
|
+
if (error === void 0) error = function() {};
|
|
5132
|
+
path = this.start(path);
|
|
5133
|
+
if (this.reuseAssets(path, success, error)) return;
|
|
5134
|
+
this.cache.assetsLoaded[path] = new Promise(function(resolve, reject) {
|
|
5135
|
+
var isBrowser = !!(typeof window !== 'undefined' && typeof navigator !== 'undefined' && window.document);
|
|
5136
|
+
var isWebWorker = !isBrowser; // && typeof importScripts !== 'undefined';
|
|
5137
|
+
if (isWebWorker) {
|
|
5138
|
+
fetch(path, {
|
|
5139
|
+
mode: "cors"
|
|
5140
|
+
}).then(function(response) {
|
|
5141
|
+
if (response.ok) return response.blob();
|
|
5142
|
+
var errorMsg = "Couldn't load image: " + path;
|
|
5143
|
+
_this.error(error, path, "Couldn't load image: " + path);
|
|
5144
|
+
reject(errorMsg);
|
|
5145
|
+
}).then(function(blob) {
|
|
5146
|
+
return blob ? createImageBitmap(blob, {
|
|
5147
|
+
premultiplyAlpha: "none",
|
|
5148
|
+
colorSpaceConversion: "none"
|
|
5149
|
+
}) : null;
|
|
5150
|
+
}).then(function(bitmap) {
|
|
5151
|
+
if (bitmap) {
|
|
5152
|
+
var texture = _this.textureLoader(bitmap);
|
|
5153
|
+
_this.success(success, path, texture);
|
|
5154
|
+
resolve(texture);
|
|
5155
|
+
}
|
|
5156
|
+
});
|
|
5157
|
+
} else {
|
|
5158
|
+
var image = new Image();
|
|
5159
|
+
image.crossOrigin = "anonymous";
|
|
5160
|
+
image.onload = function() {
|
|
5161
|
+
var texture = _this.textureLoader(image);
|
|
5162
|
+
_this.success(success, path, texture);
|
|
5163
|
+
resolve(texture);
|
|
5164
|
+
};
|
|
5165
|
+
image.onerror = function() {
|
|
5166
|
+
var errorMsg = "Couldn't load image: " + path;
|
|
5167
|
+
_this.error(error, path, errorMsg);
|
|
5168
|
+
reject(errorMsg);
|
|
5169
|
+
};
|
|
5170
|
+
if (_this.downloader.rawDataUris[path]) path = _this.downloader.rawDataUris[path];
|
|
5171
|
+
image.src = path;
|
|
5172
|
+
}
|
|
5173
|
+
});
|
|
5008
5174
|
};
|
|
5009
5175
|
_proto.loadTextureAtlas = function loadTextureAtlas(path, success, error, fileAlias) {
|
|
5010
5176
|
var _this = this;
|
|
@@ -5013,53 +5179,189 @@ var AssetManagerBase = /*#__PURE__*/ function() {
|
|
|
5013
5179
|
var index = path.lastIndexOf("/");
|
|
5014
5180
|
var parent = index >= 0 ? path.substring(0, index + 1) : "";
|
|
5015
5181
|
path = this.start(path);
|
|
5016
|
-
this.
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
if (
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5182
|
+
if (this.reuseAssets(path, success, error)) return;
|
|
5183
|
+
this.cache.assetsLoaded[path] = new Promise(function(resolve, reject) {
|
|
5184
|
+
_this.downloader.downloadText(path, function(atlasText) {
|
|
5185
|
+
try {
|
|
5186
|
+
var _loop = function() {
|
|
5187
|
+
var page = _step.value;
|
|
5188
|
+
_this.loadTexture(!fileAlias ? parent + page.name : fileAlias[page.name], function(imagePath, texture) {
|
|
5189
|
+
if (!abort) {
|
|
5190
|
+
page.setTexture(texture);
|
|
5191
|
+
if (--toLoad == 0) {
|
|
5192
|
+
_this.success(success, path, atlas);
|
|
5193
|
+
resolve(atlas);
|
|
5194
|
+
}
|
|
5195
|
+
}
|
|
5196
|
+
}, function(imagePath, message) {
|
|
5197
|
+
if (!abort) {
|
|
5198
|
+
var errorMsg = "Couldn't load texture " + path + " page image: " + imagePath;
|
|
5199
|
+
_this.error(error, path, errorMsg);
|
|
5200
|
+
reject(errorMsg);
|
|
5201
|
+
}
|
|
5202
|
+
abort = true;
|
|
5203
|
+
});
|
|
5204
|
+
};
|
|
5205
|
+
var atlas = new TextureAtlas(atlasText);
|
|
5206
|
+
var toLoad = atlas.pages.length, abort = false;
|
|
5207
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(atlas.pages), _step; !(_step = _iterator()).done;)_loop();
|
|
5208
|
+
} catch (e) {
|
|
5209
|
+
var errorMsg = "Couldn't parse texture atlas " + path + ": " + e.message;
|
|
5210
|
+
_this.error(error, path, errorMsg);
|
|
5211
|
+
reject(errorMsg);
|
|
5212
|
+
}
|
|
5213
|
+
}, function(status, responseText) {
|
|
5214
|
+
var errorMsg = "Couldn't load texture atlas " + path + ": status " + status + ", " + responseText;
|
|
5215
|
+
_this.error(error, path, errorMsg);
|
|
5216
|
+
reject(errorMsg);
|
|
5217
|
+
});
|
|
5038
5218
|
});
|
|
5039
5219
|
};
|
|
5220
|
+
_proto.loadTextureAtlasButNoTextures = function loadTextureAtlasButNoTextures(path, success, error, fileAlias) {
|
|
5221
|
+
var _this = this;
|
|
5222
|
+
if (success === void 0) success = function() {};
|
|
5223
|
+
if (error === void 0) error = function() {};
|
|
5224
|
+
path = this.start(path);
|
|
5225
|
+
if (this.reuseAssets(path, success, error)) return;
|
|
5226
|
+
this.cache.assetsLoaded[path] = new Promise(function(resolve, reject) {
|
|
5227
|
+
_this.downloader.downloadText(path, function(atlasText) {
|
|
5228
|
+
try {
|
|
5229
|
+
var atlas = new TextureAtlas(atlasText);
|
|
5230
|
+
_this.success(success, path, atlas);
|
|
5231
|
+
resolve(atlas);
|
|
5232
|
+
} catch (e) {
|
|
5233
|
+
var errorMsg = "Couldn't parse texture atlas " + path + ": " + e.message;
|
|
5234
|
+
_this.error(error, path, errorMsg);
|
|
5235
|
+
reject(errorMsg);
|
|
5236
|
+
}
|
|
5237
|
+
}, function(status, responseText) {
|
|
5238
|
+
var errorMsg = "Couldn't load texture atlas " + path + ": status " + status + ", " + responseText;
|
|
5239
|
+
_this.error(error, path, errorMsg);
|
|
5240
|
+
reject(errorMsg);
|
|
5241
|
+
});
|
|
5242
|
+
});
|
|
5243
|
+
};
|
|
5244
|
+
// Promisified versions of load function
|
|
5245
|
+
_proto.loadBinaryAsync = function loadBinaryAsync(path) {
|
|
5246
|
+
return _async_to_generator(function() {
|
|
5247
|
+
var _this;
|
|
5248
|
+
return __generator(this, function(_state) {
|
|
5249
|
+
_this = this;
|
|
5250
|
+
return [
|
|
5251
|
+
2,
|
|
5252
|
+
new Promise(function(resolve, reject) {
|
|
5253
|
+
_this.loadBinary(path, function(_, binary) {
|
|
5254
|
+
return resolve(binary);
|
|
5255
|
+
}, function(_, message) {
|
|
5256
|
+
return reject(message);
|
|
5257
|
+
});
|
|
5258
|
+
})
|
|
5259
|
+
];
|
|
5260
|
+
});
|
|
5261
|
+
}).call(this);
|
|
5262
|
+
};
|
|
5263
|
+
_proto.loadJsonAsync = function loadJsonAsync(path) {
|
|
5264
|
+
return _async_to_generator(function() {
|
|
5265
|
+
var _this;
|
|
5266
|
+
return __generator(this, function(_state) {
|
|
5267
|
+
_this = this;
|
|
5268
|
+
return [
|
|
5269
|
+
2,
|
|
5270
|
+
new Promise(function(resolve, reject) {
|
|
5271
|
+
_this.loadJson(path, function(_, object) {
|
|
5272
|
+
return resolve(object);
|
|
5273
|
+
}, function(_, message) {
|
|
5274
|
+
return reject(message);
|
|
5275
|
+
});
|
|
5276
|
+
})
|
|
5277
|
+
];
|
|
5278
|
+
});
|
|
5279
|
+
}).call(this);
|
|
5280
|
+
};
|
|
5281
|
+
_proto.loadTextureAsync = function loadTextureAsync(path) {
|
|
5282
|
+
return _async_to_generator(function() {
|
|
5283
|
+
var _this;
|
|
5284
|
+
return __generator(this, function(_state) {
|
|
5285
|
+
_this = this;
|
|
5286
|
+
return [
|
|
5287
|
+
2,
|
|
5288
|
+
new Promise(function(resolve, reject) {
|
|
5289
|
+
_this.loadTexture(path, function(_, texture) {
|
|
5290
|
+
return resolve(texture);
|
|
5291
|
+
}, function(_, message) {
|
|
5292
|
+
return reject(message);
|
|
5293
|
+
});
|
|
5294
|
+
})
|
|
5295
|
+
];
|
|
5296
|
+
});
|
|
5297
|
+
}).call(this);
|
|
5298
|
+
};
|
|
5299
|
+
_proto.loadTextureAtlasAsync = function loadTextureAtlasAsync(path) {
|
|
5300
|
+
return _async_to_generator(function() {
|
|
5301
|
+
var _this;
|
|
5302
|
+
return __generator(this, function(_state) {
|
|
5303
|
+
_this = this;
|
|
5304
|
+
return [
|
|
5305
|
+
2,
|
|
5306
|
+
new Promise(function(resolve, reject) {
|
|
5307
|
+
_this.loadTextureAtlas(path, function(_, atlas) {
|
|
5308
|
+
return resolve(atlas);
|
|
5309
|
+
}, function(_, message) {
|
|
5310
|
+
return reject(message);
|
|
5311
|
+
});
|
|
5312
|
+
})
|
|
5313
|
+
];
|
|
5314
|
+
});
|
|
5315
|
+
}).call(this);
|
|
5316
|
+
};
|
|
5317
|
+
_proto.loadTextureAtlasButNoTexturesAsync = function loadTextureAtlasButNoTexturesAsync(path) {
|
|
5318
|
+
return _async_to_generator(function() {
|
|
5319
|
+
var _this;
|
|
5320
|
+
return __generator(this, function(_state) {
|
|
5321
|
+
_this = this;
|
|
5322
|
+
return [
|
|
5323
|
+
2,
|
|
5324
|
+
new Promise(function(resolve, reject) {
|
|
5325
|
+
_this.loadTextureAtlasButNoTextures(path, function(_, atlas) {
|
|
5326
|
+
return resolve(atlas);
|
|
5327
|
+
}, function(_, message) {
|
|
5328
|
+
return reject(message);
|
|
5329
|
+
});
|
|
5330
|
+
})
|
|
5331
|
+
];
|
|
5332
|
+
});
|
|
5333
|
+
}).call(this);
|
|
5334
|
+
};
|
|
5335
|
+
_proto.setCache = function setCache(cache) {
|
|
5336
|
+
this.cache = cache;
|
|
5337
|
+
};
|
|
5040
5338
|
_proto.get = function get(path) {
|
|
5041
|
-
return this.assets[this.pathPrefix + path];
|
|
5339
|
+
return this.cache.assets[this.pathPrefix + path];
|
|
5042
5340
|
};
|
|
5043
5341
|
_proto.require = function require(path) {
|
|
5044
5342
|
path = this.pathPrefix + path;
|
|
5045
|
-
var asset = this.assets[path];
|
|
5343
|
+
var asset = this.cache.assets[path];
|
|
5046
5344
|
if (asset) return asset;
|
|
5047
5345
|
var error = this.errors[path];
|
|
5048
5346
|
throw Error("Asset not found: " + path + (error ? "\n" + error : ""));
|
|
5049
5347
|
};
|
|
5050
5348
|
_proto.remove = function remove(path) {
|
|
5051
5349
|
path = this.pathPrefix + path;
|
|
5052
|
-
var asset = this.assets[path];
|
|
5350
|
+
var asset = this.cache.assets[path];
|
|
5053
5351
|
if (asset.dispose) asset.dispose();
|
|
5054
|
-
delete this.assets[path];
|
|
5352
|
+
delete this.cache.assets[path];
|
|
5353
|
+
delete this.cache.assetsRefCount[path];
|
|
5354
|
+
delete this.cache.assetsLoaded[path];
|
|
5055
5355
|
return asset;
|
|
5056
5356
|
};
|
|
5057
5357
|
_proto.removeAll = function removeAll() {
|
|
5058
|
-
for(var
|
|
5059
|
-
var asset = this.assets[
|
|
5358
|
+
for(var path in this.cache.assets){
|
|
5359
|
+
var asset = this.cache.assets[path];
|
|
5060
5360
|
if (asset.dispose) asset.dispose();
|
|
5061
5361
|
}
|
|
5062
|
-
this.assets = {};
|
|
5362
|
+
this.cache.assets = {};
|
|
5363
|
+
this.cache.assetsLoaded = {};
|
|
5364
|
+
this.cache.assetsRefCount = {};
|
|
5063
5365
|
};
|
|
5064
5366
|
_proto.isLoadingComplete = function isLoadingComplete() {
|
|
5065
5367
|
return this.toLoad == 0;
|
|
@@ -5073,6 +5375,12 @@ var AssetManagerBase = /*#__PURE__*/ function() {
|
|
|
5073
5375
|
_proto.dispose = function dispose() {
|
|
5074
5376
|
this.removeAll();
|
|
5075
5377
|
};
|
|
5378
|
+
// dispose asset only if it's not used by others
|
|
5379
|
+
_proto.disposeAsset = function disposeAsset(path) {
|
|
5380
|
+
if (--this.cache.assetsRefCount[path] === 0) {
|
|
5381
|
+
this.remove(path);
|
|
5382
|
+
}
|
|
5383
|
+
};
|
|
5076
5384
|
_proto.hasErrors = function hasErrors() {
|
|
5077
5385
|
return Object.keys(this.errors).length > 0;
|
|
5078
5386
|
};
|
|
@@ -5081,6 +5389,44 @@ var AssetManagerBase = /*#__PURE__*/ function() {
|
|
|
5081
5389
|
};
|
|
5082
5390
|
return AssetManagerBase;
|
|
5083
5391
|
}();
|
|
5392
|
+
var AssetCache = /*#__PURE__*/ function() {
|
|
5393
|
+
function AssetCache() {
|
|
5394
|
+
this.assets = {};
|
|
5395
|
+
this.assetsRefCount = {};
|
|
5396
|
+
this.assetsLoaded = {};
|
|
5397
|
+
}
|
|
5398
|
+
var _proto = AssetCache.prototype;
|
|
5399
|
+
_proto.addAsset = function addAsset(path, asset) {
|
|
5400
|
+
return _async_to_generator(function() {
|
|
5401
|
+
var _;
|
|
5402
|
+
return __generator(this, function(_state) {
|
|
5403
|
+
switch(_state.label){
|
|
5404
|
+
case 0:
|
|
5405
|
+
this.assetsLoaded[path] = Promise.resolve(asset);
|
|
5406
|
+
_ = this.assets;
|
|
5407
|
+
return [
|
|
5408
|
+
4,
|
|
5409
|
+
asset
|
|
5410
|
+
];
|
|
5411
|
+
case 1:
|
|
5412
|
+
_[path] = _state.sent();
|
|
5413
|
+
return [
|
|
5414
|
+
2
|
|
5415
|
+
];
|
|
5416
|
+
}
|
|
5417
|
+
});
|
|
5418
|
+
}).call(this);
|
|
5419
|
+
};
|
|
5420
|
+
AssetCache.getCache = function getCache(id) {
|
|
5421
|
+
var cache = AssetCache.AVAILABLE_CACHES.get(id);
|
|
5422
|
+
if (cache) return cache;
|
|
5423
|
+
var newCache = new AssetCache();
|
|
5424
|
+
AssetCache.AVAILABLE_CACHES.set(id, newCache);
|
|
5425
|
+
return newCache;
|
|
5426
|
+
};
|
|
5427
|
+
return AssetCache;
|
|
5428
|
+
}();
|
|
5429
|
+
AssetCache.AVAILABLE_CACHES = new Map();
|
|
5084
5430
|
var Downloader = /*#__PURE__*/ function() {
|
|
5085
5431
|
function Downloader() {
|
|
5086
5432
|
this.callbacks = {};
|
|
@@ -5120,10 +5466,11 @@ var Downloader = /*#__PURE__*/ function() {
|
|
|
5120
5466
|
_proto.downloadText = function downloadText(url, success, error) {
|
|
5121
5467
|
var _this = this;
|
|
5122
5468
|
if (this.start(url, success, error)) return;
|
|
5123
|
-
|
|
5469
|
+
var rawDataUri = this.rawDataUris[url];
|
|
5470
|
+
// we assume if a "." is included in a raw data uri, it is used to rewrite an asset URL
|
|
5471
|
+
if (rawDataUri && !rawDataUri.includes(".")) {
|
|
5124
5472
|
try {
|
|
5125
|
-
|
|
5126
|
-
this.finish(url, 200, this.dataUriToString(dataUri));
|
|
5473
|
+
this.finish(url, 200, this.dataUriToString(rawDataUri));
|
|
5127
5474
|
} catch (e) {
|
|
5128
5475
|
this.finish(url, 400, JSON.stringify(e));
|
|
5129
5476
|
}
|
|
@@ -5131,7 +5478,7 @@ var Downloader = /*#__PURE__*/ function() {
|
|
|
5131
5478
|
}
|
|
5132
5479
|
var request = new XMLHttpRequest();
|
|
5133
5480
|
request.overrideMimeType("text/html");
|
|
5134
|
-
request.open("GET", url, true);
|
|
5481
|
+
request.open("GET", rawDataUri ? rawDataUri : url, true);
|
|
5135
5482
|
var done = function() {
|
|
5136
5483
|
_this.finish(url, request.status, request.responseText);
|
|
5137
5484
|
};
|
|
@@ -5147,17 +5494,18 @@ var Downloader = /*#__PURE__*/ function() {
|
|
|
5147
5494
|
_proto.downloadBinary = function downloadBinary(url, success, error) {
|
|
5148
5495
|
var _this = this;
|
|
5149
5496
|
if (this.start(url, success, error)) return;
|
|
5150
|
-
|
|
5497
|
+
var rawDataUri = this.rawDataUris[url];
|
|
5498
|
+
// we assume if a "." is included in a raw data uri, it is used to rewrite an asset URL
|
|
5499
|
+
if (rawDataUri && !rawDataUri.includes(".")) {
|
|
5151
5500
|
try {
|
|
5152
|
-
|
|
5153
|
-
this.finish(url, 200, this.dataUriToUint8Array(dataUri));
|
|
5501
|
+
this.finish(url, 200, this.dataUriToUint8Array(rawDataUri));
|
|
5154
5502
|
} catch (e) {
|
|
5155
5503
|
this.finish(url, 400, JSON.stringify(e));
|
|
5156
5504
|
}
|
|
5157
5505
|
return;
|
|
5158
5506
|
}
|
|
5159
5507
|
var request = new XMLHttpRequest();
|
|
5160
|
-
request.open("GET", url, true);
|
|
5508
|
+
request.open("GET", rawDataUri ? rawDataUri : url, true);
|
|
5161
5509
|
request.responseType = "arraybuffer";
|
|
5162
5510
|
var onerror = function() {
|
|
5163
5511
|
_this.finish(url, request.status, request.response);
|
|
@@ -5195,17 +5543,17 @@ var Downloader = /*#__PURE__*/ function() {
|
|
|
5195
5543
|
|
|
5196
5544
|
/******************************************************************************
|
|
5197
5545
|
* Spine Runtimes License Agreement
|
|
5198
|
-
* Last updated
|
|
5546
|
+
* Last updated April 5, 2025. Replaces all prior versions.
|
|
5199
5547
|
*
|
|
5200
|
-
* Copyright (c) 2013-
|
|
5548
|
+
* Copyright (c) 2013-2025, Esoteric Software LLC
|
|
5201
5549
|
*
|
|
5202
5550
|
* Integration of the Spine Runtimes into software or otherwise creating
|
|
5203
5551
|
* derivative works of the Spine Runtimes is permitted under the terms and
|
|
5204
5552
|
* conditions of Section 2 of the Spine Editor License Agreement:
|
|
5205
5553
|
* http://esotericsoftware.com/spine-editor-license
|
|
5206
5554
|
*
|
|
5207
|
-
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
|
5208
|
-
* otherwise create derivative works of the Spine Runtimes (collectively,
|
|
5555
|
+
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
|
5556
|
+
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
|
5209
5557
|
* "Products"), provided that each user of the Products must obtain their own
|
|
5210
5558
|
* Spine Editor license and redistribution of the Products in any form must
|
|
5211
5559
|
* include this license and copyright notice.
|
|
@@ -5218,8 +5566,8 @@ var Downloader = /*#__PURE__*/ function() {
|
|
|
5218
5566
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
|
5219
5567
|
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
|
5220
5568
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
5221
|
-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
5222
|
-
* SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
5569
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
5570
|
+
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
5223
5571
|
*****************************************************************************/ /** Stores the current pose values for an {@link Event}.
|
|
5224
5572
|
*
|
|
5225
5573
|
* See Timeline {@link Timeline#apply()},
|
|
@@ -5239,17 +5587,17 @@ var Downloader = /*#__PURE__*/ function() {
|
|
|
5239
5587
|
|
|
5240
5588
|
/******************************************************************************
|
|
5241
5589
|
* Spine Runtimes License Agreement
|
|
5242
|
-
* Last updated
|
|
5590
|
+
* Last updated April 5, 2025. Replaces all prior versions.
|
|
5243
5591
|
*
|
|
5244
|
-
* Copyright (c) 2013-
|
|
5592
|
+
* Copyright (c) 2013-2025, Esoteric Software LLC
|
|
5245
5593
|
*
|
|
5246
5594
|
* Integration of the Spine Runtimes into software or otherwise creating
|
|
5247
5595
|
* derivative works of the Spine Runtimes is permitted under the terms and
|
|
5248
5596
|
* conditions of Section 2 of the Spine Editor License Agreement:
|
|
5249
5597
|
* http://esotericsoftware.com/spine-editor-license
|
|
5250
5598
|
*
|
|
5251
|
-
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
|
5252
|
-
* otherwise create derivative works of the Spine Runtimes (collectively,
|
|
5599
|
+
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
|
5600
|
+
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
|
5253
5601
|
* "Products"), provided that each user of the Products must obtain their own
|
|
5254
5602
|
* Spine Editor license and redistribution of the Products in any form must
|
|
5255
5603
|
* include this license and copyright notice.
|
|
@@ -5262,8 +5610,8 @@ var Downloader = /*#__PURE__*/ function() {
|
|
|
5262
5610
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
|
5263
5611
|
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
|
5264
5612
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
5265
|
-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
5266
|
-
* SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
5613
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
5614
|
+
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
5267
5615
|
*****************************************************************************/ /** Stores the setup pose values for an {@link Event}.
|
|
5268
5616
|
*
|
|
5269
5617
|
* See [Events](http://esotericsoftware.com/spine-events) in the Spine User Guide. */ var EventData = function EventData(name) {
|
|
@@ -6123,7 +6471,7 @@ PathConstraint.epsilon = 0.00001;
|
|
|
6123
6471
|
}
|
|
6124
6472
|
if (a >= t) {
|
|
6125
6473
|
d = Math.pow(this.damping, 60 * t);
|
|
6126
|
-
var m = this.massInverse * t, e = this.strength, w = this.wind * f, g =
|
|
6474
|
+
var m = this.massInverse * t, e = this.strength, w = this.wind * f * skeleton.scaleX, g = this.gravity * f * skeleton.scaleY;
|
|
6127
6475
|
do {
|
|
6128
6476
|
if (x) {
|
|
6129
6477
|
this.xVelocity += (w - this.xOffset * e) * m;
|
|
@@ -6965,10 +7313,10 @@ PathConstraint.epsilon = 0.00001;
|
|
|
6965
7313
|
})) != null ? _this_physicsConstraints_find : null;
|
|
6966
7314
|
};
|
|
6967
7315
|
/** 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 }`.
|
|
6968
|
-
* 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() {
|
|
7316
|
+
* 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) {
|
|
6969
7317
|
var offset = new Vector2();
|
|
6970
7318
|
var size = new Vector2();
|
|
6971
|
-
this.getBounds(offset, size);
|
|
7319
|
+
this.getBounds(offset, size, undefined, clipper);
|
|
6972
7320
|
return {
|
|
6973
7321
|
x: offset.x,
|
|
6974
7322
|
y: offset.y,
|
|
@@ -7097,17 +7445,17 @@ Skeleton.yDown = false;
|
|
|
7097
7445
|
|
|
7098
7446
|
/******************************************************************************
|
|
7099
7447
|
* Spine Runtimes License Agreement
|
|
7100
|
-
* Last updated
|
|
7448
|
+
* Last updated April 5, 2025. Replaces all prior versions.
|
|
7101
7449
|
*
|
|
7102
|
-
* Copyright (c) 2013-
|
|
7450
|
+
* Copyright (c) 2013-2025, Esoteric Software LLC
|
|
7103
7451
|
*
|
|
7104
7452
|
* Integration of the Spine Runtimes into software or otherwise creating
|
|
7105
7453
|
* derivative works of the Spine Runtimes is permitted under the terms and
|
|
7106
7454
|
* conditions of Section 2 of the Spine Editor License Agreement:
|
|
7107
7455
|
* http://esotericsoftware.com/spine-editor-license
|
|
7108
7456
|
*
|
|
7109
|
-
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
|
7110
|
-
* otherwise create derivative works of the Spine Runtimes (collectively,
|
|
7457
|
+
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
|
7458
|
+
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
|
7111
7459
|
* "Products"), provided that each user of the Products must obtain their own
|
|
7112
7460
|
* Spine Editor license and redistribution of the Products in any form must
|
|
7113
7461
|
* include this license and copyright notice.
|
|
@@ -7120,18 +7468,16 @@ Skeleton.yDown = false;
|
|
|
7120
7468
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
|
7121
7469
|
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
|
7122
7470
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
7123
|
-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
7124
|
-
* SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
7471
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
7472
|
+
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
7125
7473
|
*****************************************************************************/ /** Stores the setup pose and all of the stateless data for a skeleton.
|
|
7126
7474
|
*
|
|
7127
7475
|
* See [Data objects](http://esotericsoftware.com/spine-runtime-architecture#Data-objects) in the Spine Runtimes
|
|
7128
7476
|
* Guide. */ var SkeletonData = /*#__PURE__*/ function() {
|
|
7129
7477
|
function SkeletonData() {
|
|
7130
7478
|
/** The skeleton's name, which by default is the name of the skeleton data file, if possible. May be null. */ this.name = null;
|
|
7131
|
-
/** The skeleton's bones, sorted parent first. The root bone is always the first bone. */ this.bones = new Array() // Ordered parents first.
|
|
7132
|
-
;
|
|
7133
|
-
/** The skeleton's slots in the setup pose draw order. */ this.slots = new Array() // Setup pose draw order.
|
|
7134
|
-
;
|
|
7479
|
+
/** The skeleton's bones, sorted parent first. The root bone is always the first bone. */ this.bones = new Array(); // Ordered parents first.
|
|
7480
|
+
/** The skeleton's slots in the setup pose draw order. */ this.slots = new Array(); // Setup pose draw order.
|
|
7135
7481
|
this.skins = new Array();
|
|
7136
7482
|
/** The skeleton's default skin. By default this skin contains all attachments that were not in a skin in Spine.
|
|
7137
7483
|
*
|
|
@@ -7274,8 +7620,7 @@ Skeleton.yDown = false;
|
|
|
7274
7620
|
this.attachments = new Array();
|
|
7275
7621
|
this.bones = Array();
|
|
7276
7622
|
this.constraints = new Array();
|
|
7277
|
-
/** 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
|
|
7278
|
-
;
|
|
7623
|
+
/** 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
|
|
7279
7624
|
if (!name) throw new Error("name cannot be null.");
|
|
7280
7625
|
this.name = name;
|
|
7281
7626
|
}
|
|
@@ -10433,17 +10778,17 @@ function getValue(map, property, defaultValue) {
|
|
|
10433
10778
|
|
|
10434
10779
|
/******************************************************************************
|
|
10435
10780
|
* Spine Runtimes License Agreement
|
|
10436
|
-
* Last updated
|
|
10781
|
+
* Last updated April 5, 2025. Replaces all prior versions.
|
|
10437
10782
|
*
|
|
10438
|
-
* Copyright (c) 2013-
|
|
10783
|
+
* Copyright (c) 2013-2025, Esoteric Software LLC
|
|
10439
10784
|
*
|
|
10440
10785
|
* Integration of the Spine Runtimes into software or otherwise creating
|
|
10441
10786
|
* derivative works of the Spine Runtimes is permitted under the terms and
|
|
10442
10787
|
* conditions of Section 2 of the Spine Editor License Agreement:
|
|
10443
10788
|
* http://esotericsoftware.com/spine-editor-license
|
|
10444
10789
|
*
|
|
10445
|
-
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
|
10446
|
-
* otherwise create derivative works of the Spine Runtimes (collectively,
|
|
10790
|
+
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
|
10791
|
+
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
|
10447
10792
|
* "Products"), provided that each user of the Products must obtain their own
|
|
10448
10793
|
* Spine Editor license and redistribution of the Products in any form must
|
|
10449
10794
|
* include this license and copyright notice.
|
|
@@ -10456,8 +10801,8 @@ function getValue(map, property, defaultValue) {
|
|
|
10456
10801
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
|
10457
10802
|
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
|
10458
10803
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
10459
|
-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
10460
|
-
* SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
10804
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
10805
|
+
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
10461
10806
|
*****************************************************************************/ (function() {
|
|
10462
10807
|
if (typeof Math.fround === "undefined") {
|
|
10463
10808
|
Math.fround = function(array) {
|
|
@@ -10606,55 +10951,6 @@ function getValue(map, property, defaultValue) {
|
|
|
10606
10951
|
return LoaderUtils;
|
|
10607
10952
|
}();
|
|
10608
10953
|
|
|
10609
|
-
var SourceAlpha = BlendFactor.SourceAlpha, One = BlendFactor.One, DestinationColor = BlendFactor.DestinationColor, Zero = BlendFactor.Zero, OneMinusSourceColor = BlendFactor.OneMinusSourceColor, OneMinusSourceAlpha = BlendFactor.OneMinusSourceAlpha;
|
|
10610
|
-
var Add = BlendOperation.Add;
|
|
10611
|
-
function setBlendMode(material, blendMode, premultipliedAlpha) {
|
|
10612
|
-
var target = material.renderState.blendState.targetBlendState;
|
|
10613
|
-
switch(blendMode){
|
|
10614
|
-
case BlendMode.Additive:
|
|
10615
|
-
target.sourceColorBlendFactor = premultipliedAlpha ? One : SourceAlpha;
|
|
10616
|
-
target.destinationColorBlendFactor = One;
|
|
10617
|
-
target.sourceAlphaBlendFactor = One;
|
|
10618
|
-
target.destinationAlphaBlendFactor = One;
|
|
10619
|
-
target.colorBlendOperation = target.alphaBlendOperation = Add;
|
|
10620
|
-
break;
|
|
10621
|
-
case BlendMode.Multiply:
|
|
10622
|
-
target.sourceColorBlendFactor = DestinationColor;
|
|
10623
|
-
target.destinationColorBlendFactor = OneMinusSourceAlpha;
|
|
10624
|
-
target.sourceAlphaBlendFactor = One;
|
|
10625
|
-
target.destinationAlphaBlendFactor = OneMinusSourceAlpha;
|
|
10626
|
-
target.colorBlendOperation = target.alphaBlendOperation = Add;
|
|
10627
|
-
break;
|
|
10628
|
-
case BlendMode.Screen:
|
|
10629
|
-
target.sourceColorBlendFactor = One;
|
|
10630
|
-
target.destinationColorBlendFactor = OneMinusSourceColor;
|
|
10631
|
-
target.sourceAlphaBlendFactor = One;
|
|
10632
|
-
target.destinationAlphaBlendFactor = OneMinusSourceColor;
|
|
10633
|
-
target.colorBlendOperation = target.alphaBlendOperation = Add;
|
|
10634
|
-
break;
|
|
10635
|
-
default:
|
|
10636
|
-
target.sourceColorBlendFactor = premultipliedAlpha ? One : SourceAlpha;
|
|
10637
|
-
target.destinationColorBlendFactor = OneMinusSourceAlpha;
|
|
10638
|
-
target.sourceAlphaBlendFactor = One;
|
|
10639
|
-
target.destinationAlphaBlendFactor = OneMinusSourceAlpha;
|
|
10640
|
-
target.colorBlendOperation = target.alphaBlendOperation = Add;
|
|
10641
|
-
break;
|
|
10642
|
-
}
|
|
10643
|
-
}
|
|
10644
|
-
function getBlendMode(material) {
|
|
10645
|
-
var target = material.renderState.blendState.targetBlendState;
|
|
10646
|
-
if (target.sourceColorBlendFactor === SourceAlpha && target.destinationColorBlendFactor === One && target.sourceAlphaBlendFactor === One && target.destinationAlphaBlendFactor === One && target.colorBlendOperation === Add && target.alphaBlendOperation === Add) {
|
|
10647
|
-
return BlendMode.Additive;
|
|
10648
|
-
}
|
|
10649
|
-
if (target.sourceColorBlendFactor === DestinationColor && target.destinationColorBlendFactor === Zero && target.sourceAlphaBlendFactor === One && target.destinationAlphaBlendFactor === Zero && target.colorBlendOperation === Add && target.alphaBlendOperation === Add) {
|
|
10650
|
-
return BlendMode.Multiply;
|
|
10651
|
-
}
|
|
10652
|
-
if (target.sourceColorBlendFactor === One && target.destinationColorBlendFactor === OneMinusSourceColor && target.sourceAlphaBlendFactor === One && target.destinationAlphaBlendFactor === OneMinusSourceColor && target.colorBlendOperation === Add && target.alphaBlendOperation === Add) {
|
|
10653
|
-
return BlendMode.Screen;
|
|
10654
|
-
}
|
|
10655
|
-
return BlendMode.Normal;
|
|
10656
|
-
}
|
|
10657
|
-
|
|
10658
10954
|
var ClearablePool = /*#__PURE__*/ function() {
|
|
10659
10955
|
function ClearablePool(type) {
|
|
10660
10956
|
this._usedElementCount = 0;
|
|
@@ -10715,11 +11011,11 @@ var SubRenderItem = function SubRenderItem() {
|
|
|
10715
11011
|
}
|
|
10716
11012
|
var _proto = SpineGenerator.prototype;
|
|
10717
11013
|
_proto.buildPrimitive = function buildPrimitive(skeleton, renderer) {
|
|
10718
|
-
var _indices = renderer._indices, _vertices = renderer._vertices, _localBounds = renderer._localBounds, _vertexCount = renderer._vertexCount, _subPrimitives = renderer._subPrimitives,
|
|
11014
|
+
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;
|
|
10719
11015
|
_localBounds.min.set(Infinity, Infinity, Infinity);
|
|
10720
11016
|
_localBounds.max.set(-Infinity, -Infinity, -Infinity);
|
|
10721
11017
|
var _this = this, _clipper = _this._clipper, _separateSlots = _this._separateSlots, _subRenderItems = _this._subRenderItems, _separateSlotTextureMap = _this._separateSlotTextureMap;
|
|
10722
|
-
var tempVerts = SpineGenerator.tempVerts, subRenderItemPool = SpineGenerator.subRenderItemPool, subPrimitivePool = SpineGenerator.subPrimitivePool,
|
|
11018
|
+
var tempVerts = SpineGenerator.tempVerts, subRenderItemPool = SpineGenerator.subRenderItemPool, subPrimitivePool = SpineGenerator.subPrimitivePool, vertexStrideWithTint = SpineGenerator.vertexStrideWithTint, vertexStrideWithoutTint = SpineGenerator.vertexStrideWithoutTint;
|
|
10723
11019
|
_subRenderItems.length = 0;
|
|
10724
11020
|
subRenderItemPool.clear();
|
|
10725
11021
|
var triangles;
|
|
@@ -10749,13 +11045,28 @@ var SubRenderItem = function SubRenderItem() {
|
|
|
10749
11045
|
var isClipping = _clipper.isClipping();
|
|
10750
11046
|
var numFloats = 0;
|
|
10751
11047
|
var attachmentColor = null;
|
|
10752
|
-
|
|
11048
|
+
// This vertexSize will be passed to spine-core's computeWorldVertices function.
|
|
11049
|
+
//
|
|
11050
|
+
// Expected format by computeWorldVertices:
|
|
11051
|
+
// - Without tintBlack: [x, y, u, v, r, g, b, a] = 8 components
|
|
11052
|
+
// - With tintBlack: [x, y, u, v, r, g, b, a, dr, dg, db, da] = 12 components
|
|
11053
|
+
//
|
|
11054
|
+
// Our actual vertex buffer format:
|
|
11055
|
+
// - vertexStrideWithoutTint: [x, y, z, u, v, r, g, b, a] = 9 components
|
|
11056
|
+
// - vertexStrideWithTint: [x, y, z, u, v, r, g, b, a, dr, dg, db] = 12 components
|
|
11057
|
+
// (Note: we optimized 'da' as uniform instead of buffer attribute)
|
|
11058
|
+
//
|
|
11059
|
+
// Calculation:
|
|
11060
|
+
// - Without tintBlack: 9 - 1 (remove z) = 8 ✓
|
|
11061
|
+
// - With tintBlack: 12 - 1 (remove z) + 1 (add back da) = 12 ✓
|
|
11062
|
+
var vertexSize = tintBlack ? vertexStrideWithTint : vertexStrideWithoutTint - 1;
|
|
11063
|
+
var clippedVertexSize = isClipping ? 2 : vertexSize;
|
|
10753
11064
|
switch(attachment.constructor){
|
|
10754
11065
|
case RegionAttachment:
|
|
10755
11066
|
var regionAttachment = attachment;
|
|
10756
11067
|
attachmentColor = regionAttachment.color;
|
|
10757
|
-
numFloats =
|
|
10758
|
-
regionAttachment.computeWorldVertices(slot, tempVerts, 0,
|
|
11068
|
+
numFloats = clippedVertexSize << 2;
|
|
11069
|
+
regionAttachment.computeWorldVertices(slot, tempVerts, 0, clippedVertexSize);
|
|
10759
11070
|
triangles = SpineGenerator.QUAD_TRIANGLES;
|
|
10760
11071
|
uvs = regionAttachment.uvs;
|
|
10761
11072
|
texture = regionAttachment.region.texture;
|
|
@@ -10763,11 +11074,11 @@ var SubRenderItem = function SubRenderItem() {
|
|
|
10763
11074
|
case MeshAttachment:
|
|
10764
11075
|
var meshAttachment = attachment;
|
|
10765
11076
|
attachmentColor = meshAttachment.color;
|
|
10766
|
-
numFloats = (meshAttachment.worldVerticesLength >> 1) *
|
|
11077
|
+
numFloats = (meshAttachment.worldVerticesLength >> 1) * clippedVertexSize;
|
|
10767
11078
|
if (numFloats > _vertices.length) {
|
|
10768
11079
|
SpineGenerator.tempVerts = new Array(numFloats);
|
|
10769
11080
|
}
|
|
10770
|
-
meshAttachment.computeWorldVertices(slot, 0, meshAttachment.worldVerticesLength, tempVerts, 0,
|
|
11081
|
+
meshAttachment.computeWorldVertices(slot, 0, meshAttachment.worldVerticesLength, tempVerts, 0, clippedVertexSize);
|
|
10771
11082
|
triangles = meshAttachment.triangles;
|
|
10772
11083
|
uvs = meshAttachment.uvs;
|
|
10773
11084
|
texture = meshAttachment.region.texture;
|
|
@@ -10799,8 +11110,21 @@ var SubRenderItem = function SubRenderItem() {
|
|
|
10799
11110
|
finalColor.g *= finalAlpha;
|
|
10800
11111
|
finalColor.b *= finalAlpha;
|
|
10801
11112
|
}
|
|
11113
|
+
var darkColor = SpineGenerator.tempDark;
|
|
11114
|
+
var slotDarkColor = slot.darkColor;
|
|
11115
|
+
if (!slotDarkColor) {
|
|
11116
|
+
darkColor.set(0, 0, 0, 1);
|
|
11117
|
+
} else {
|
|
11118
|
+
if (premultipliedAlpha) {
|
|
11119
|
+
darkColor.r = slotDarkColor.r * finalAlpha;
|
|
11120
|
+
darkColor.g = slotDarkColor.g * finalAlpha;
|
|
11121
|
+
darkColor.b = slotDarkColor.b * finalAlpha;
|
|
11122
|
+
} else {
|
|
11123
|
+
darkColor.setFromColor(slotDarkColor);
|
|
11124
|
+
}
|
|
11125
|
+
}
|
|
10802
11126
|
if (isClipping) {
|
|
10803
|
-
_clipper.clipTriangles(tempVerts, triangles, triangles.length, uvs, finalColor,
|
|
11127
|
+
_clipper.clipTriangles(tempVerts, triangles, triangles.length, uvs, finalColor, darkColor, tintBlack);
|
|
10804
11128
|
finalVertices = _clipper.clippedVertices;
|
|
10805
11129
|
finalVerticesLength = finalVertices.length;
|
|
10806
11130
|
finalIndices = _clipper.clippedTriangles;
|
|
@@ -10814,6 +11138,12 @@ var SubRenderItem = function SubRenderItem() {
|
|
|
10814
11138
|
tempVerts[v + 3] = a;
|
|
10815
11139
|
tempVerts[v + 4] = uvs[u];
|
|
10816
11140
|
tempVerts[v + 5] = uvs[u + 1];
|
|
11141
|
+
if (tintBlack) {
|
|
11142
|
+
tempVerts[v + 6] = darkColor.r;
|
|
11143
|
+
tempVerts[v + 7] = darkColor.g;
|
|
11144
|
+
tempVerts[v + 8] = darkColor.b;
|
|
11145
|
+
tempVerts[v + 9] = darkColor.a;
|
|
11146
|
+
}
|
|
10817
11147
|
}
|
|
10818
11148
|
finalVertices = tempVerts;
|
|
10819
11149
|
finalVerticesLength = numFloats;
|
|
@@ -10824,7 +11154,8 @@ var SubRenderItem = function SubRenderItem() {
|
|
|
10824
11154
|
_clipper.clipEndWithSlot(slot);
|
|
10825
11155
|
continue;
|
|
10826
11156
|
}
|
|
10827
|
-
var
|
|
11157
|
+
var stride = tintBlack ? vertexStrideWithTint : vertexStrideWithoutTint;
|
|
11158
|
+
var indexStart = verticesLength / stride;
|
|
10828
11159
|
var i = verticesLength;
|
|
10829
11160
|
var j = 0;
|
|
10830
11161
|
for(; j < finalVerticesLength;){
|
|
@@ -10833,12 +11164,18 @@ var SubRenderItem = function SubRenderItem() {
|
|
|
10833
11164
|
_vertices[i++] = x;
|
|
10834
11165
|
_vertices[i++] = y;
|
|
10835
11166
|
_vertices[i++] = z;
|
|
10836
|
-
_vertices[i++] = finalVertices[j++];
|
|
10837
|
-
_vertices[i++] = finalVertices[j++];
|
|
10838
|
-
_vertices[i++] = finalVertices[j++];
|
|
10839
|
-
_vertices[i++] = finalVertices[j++];
|
|
10840
|
-
_vertices[i++] = finalVertices[j++];
|
|
10841
|
-
_vertices[i++] = finalVertices[j++];
|
|
11167
|
+
_vertices[i++] = finalVertices[j++]; // u
|
|
11168
|
+
_vertices[i++] = finalVertices[j++]; // v
|
|
11169
|
+
_vertices[i++] = finalVertices[j++]; // r
|
|
11170
|
+
_vertices[i++] = finalVertices[j++]; // g
|
|
11171
|
+
_vertices[i++] = finalVertices[j++]; // b
|
|
11172
|
+
_vertices[i++] = finalVertices[j++]; // a
|
|
11173
|
+
if (tintBlack) {
|
|
11174
|
+
_vertices[i++] = finalVertices[j++]; // darkR
|
|
11175
|
+
_vertices[i++] = finalVertices[j++]; // darkG
|
|
11176
|
+
_vertices[i++] = finalVertices[j++]; // darkB
|
|
11177
|
+
j++; // darkA
|
|
11178
|
+
}
|
|
10842
11179
|
this._expandBounds(x, y, z, _localBounds);
|
|
10843
11180
|
}
|
|
10844
11181
|
verticesLength = i;
|
|
@@ -10895,22 +11232,17 @@ var SubRenderItem = function SubRenderItem() {
|
|
|
10895
11232
|
subPrimitivePool.return(item);
|
|
10896
11233
|
}
|
|
10897
11234
|
renderer._clearSubPrimitives();
|
|
10898
|
-
var materialCache = SpineAnimationRenderer._materialCache;
|
|
10899
11235
|
for(var i2 = 0, l = curLen; i2 < l; ++i2){
|
|
10900
11236
|
var item1 = _subRenderItems[i2];
|
|
10901
11237
|
var slotName1 = item1.slotName, blendMode = item1.blendMode, texture1 = item1.texture;
|
|
10902
11238
|
renderer._addSubPrimitive(item1.subPrimitive);
|
|
10903
11239
|
var subTexture = _separateSlotTextureMap.get(slotName1) || texture1.getImage();
|
|
10904
|
-
var
|
|
10905
|
-
var material = materialCache.get(key);
|
|
10906
|
-
if (!material) {
|
|
10907
|
-
material = this._createMaterialForTexture(subTexture, engine, blendMode, premultipliedAlpha);
|
|
10908
|
-
materialCache.set(key, material);
|
|
10909
|
-
}
|
|
11240
|
+
var material = renderer._getMaterial(subTexture, blendMode);
|
|
10910
11241
|
renderer.setMaterial(i2, material);
|
|
10911
11242
|
}
|
|
10912
|
-
if (indicesLength > _vertexCount) {
|
|
11243
|
+
if (indicesLength > _vertexCount || renderer._needResizeBuffer) {
|
|
10913
11244
|
renderer._createAndBindBuffer(indicesLength);
|
|
11245
|
+
renderer._needResizeBuffer = false;
|
|
10914
11246
|
this.buildPrimitive(skeleton, renderer);
|
|
10915
11247
|
return;
|
|
10916
11248
|
}
|
|
@@ -10925,12 +11257,6 @@ var SubRenderItem = function SubRenderItem() {
|
|
|
10925
11257
|
_proto.addSeparateSlotTexture = function addSeparateSlotTexture(slotName, texture) {
|
|
10926
11258
|
this._separateSlotTextureMap.set(slotName, texture);
|
|
10927
11259
|
};
|
|
10928
|
-
_proto._createMaterialForTexture = function _createMaterialForTexture(texture, engine, blendMode, premultipliedAlpha) {
|
|
10929
|
-
var material = SpineAnimationRenderer._getDefaultMaterial(engine);
|
|
10930
|
-
material.shaderData.setTexture("material_SpineTexture", texture);
|
|
10931
|
-
setBlendMode(material, blendMode, premultipliedAlpha);
|
|
10932
|
-
return material;
|
|
10933
|
-
};
|
|
10934
11260
|
_proto._createRenderItem = function _createRenderItem(subPrimitives, primitiveIndex, start, count, texture, blend, slotName) {
|
|
10935
11261
|
var subPrimitivePool = SpineGenerator.subPrimitivePool, subRenderItemPool = SpineGenerator.subRenderItemPool;
|
|
10936
11262
|
var origin = subPrimitives[primitiveIndex];
|
|
@@ -10955,8 +11281,8 @@ var SubRenderItem = function SubRenderItem() {
|
|
|
10955
11281
|
};
|
|
10956
11282
|
return SpineGenerator;
|
|
10957
11283
|
}();
|
|
10958
|
-
SpineGenerator.
|
|
10959
|
-
SpineGenerator.
|
|
11284
|
+
SpineGenerator.vertexStrideWithoutTint = 9;
|
|
11285
|
+
SpineGenerator.vertexStrideWithTint = 12;
|
|
10960
11286
|
SpineGenerator.tempDark = new Color();
|
|
10961
11287
|
SpineGenerator.tempColor = new Color();
|
|
10962
11288
|
SpineGenerator.tempVerts = new Array(8);
|
|
@@ -10971,25 +11297,92 @@ SpineGenerator.QUAD_TRIANGLES = [
|
|
|
10971
11297
|
SpineGenerator.subPrimitivePool = new ReturnablePool(SubPrimitive);
|
|
10972
11298
|
SpineGenerator.subRenderItemPool = new ClearablePool(SubRenderItem);
|
|
10973
11299
|
|
|
11300
|
+
var SourceAlpha = BlendFactor.SourceAlpha, One = BlendFactor.One, DestinationColor = BlendFactor.DestinationColor, OneMinusSourceColor = BlendFactor.OneMinusSourceColor, OneMinusSourceAlpha = BlendFactor.OneMinusSourceAlpha;
|
|
11301
|
+
var Add = BlendOperation.Add;
|
|
10974
11302
|
var SpineMaterial = /*#__PURE__*/ function(Material) {
|
|
10975
11303
|
_inherits(SpineMaterial, Material);
|
|
10976
11304
|
function SpineMaterial(engine) {
|
|
10977
11305
|
var _this;
|
|
10978
11306
|
var shader = Shader.find("galacean-spine-shader") || Shader.create("galacean-spine-shader", SpineMaterial._spineVS, SpineMaterial._spineFS);
|
|
10979
|
-
_this = Material.call(this, engine, shader) || this;
|
|
11307
|
+
_this = Material.call(this, engine, shader) || this, _this._blendMode = BlendMode.Normal;
|
|
10980
11308
|
var renderState = _this.renderState;
|
|
10981
11309
|
var target = renderState.blendState.targetBlendState;
|
|
10982
11310
|
target.enabled = true;
|
|
10983
|
-
|
|
11311
|
+
_this._setBlendMode(BlendMode.Normal, false);
|
|
10984
11312
|
renderState.depthState.writeEnabled = false;
|
|
10985
11313
|
renderState.rasterState.cullMode = CullMode.Off;
|
|
10986
11314
|
renderState.renderQueueType = RenderQueueType.Transparent;
|
|
10987
11315
|
return _this;
|
|
10988
11316
|
}
|
|
11317
|
+
var _proto = SpineMaterial.prototype;
|
|
11318
|
+
/**
|
|
11319
|
+
* @internal
|
|
11320
|
+
*/ _proto._setTintBlack = function _setTintBlack(enabled) {
|
|
11321
|
+
if (enabled) {
|
|
11322
|
+
this.shaderData.enableMacro("RENDERER_TINT_BLACK");
|
|
11323
|
+
} else {
|
|
11324
|
+
this.shaderData.disableMacro("RENDERER_TINT_BLACK");
|
|
11325
|
+
}
|
|
11326
|
+
};
|
|
11327
|
+
/**
|
|
11328
|
+
* @internal
|
|
11329
|
+
*/ _proto._setPremultipliedAlpha = function _setPremultipliedAlpha(enabled) {
|
|
11330
|
+
if (enabled) {
|
|
11331
|
+
this.shaderData.setFloat("renderer_PremultipliedAlpha", 1);
|
|
11332
|
+
} else {
|
|
11333
|
+
this.shaderData.setFloat("renderer_PremultipliedAlpha", 0);
|
|
11334
|
+
}
|
|
11335
|
+
};
|
|
11336
|
+
/**
|
|
11337
|
+
* @internal
|
|
11338
|
+
*/ _proto._setTexture = function _setTexture(value) {
|
|
11339
|
+
this.shaderData.setTexture("material_SpineTexture", value);
|
|
11340
|
+
};
|
|
11341
|
+
/**
|
|
11342
|
+
* @internal
|
|
11343
|
+
*/ _proto._setBlendMode = function _setBlendMode(blendMode, premultipliedAlpha) {
|
|
11344
|
+
var target = this.renderState.blendState.targetBlendState;
|
|
11345
|
+
this._blendMode = blendMode;
|
|
11346
|
+
switch(blendMode){
|
|
11347
|
+
case BlendMode.Additive:
|
|
11348
|
+
target.sourceColorBlendFactor = premultipliedAlpha ? One : SourceAlpha;
|
|
11349
|
+
target.destinationColorBlendFactor = One;
|
|
11350
|
+
target.sourceAlphaBlendFactor = One;
|
|
11351
|
+
target.destinationAlphaBlendFactor = One;
|
|
11352
|
+
target.colorBlendOperation = target.alphaBlendOperation = Add;
|
|
11353
|
+
break;
|
|
11354
|
+
case BlendMode.Multiply:
|
|
11355
|
+
target.sourceColorBlendFactor = DestinationColor;
|
|
11356
|
+
target.destinationColorBlendFactor = OneMinusSourceAlpha;
|
|
11357
|
+
target.sourceAlphaBlendFactor = One;
|
|
11358
|
+
target.destinationAlphaBlendFactor = OneMinusSourceAlpha;
|
|
11359
|
+
target.colorBlendOperation = target.alphaBlendOperation = Add;
|
|
11360
|
+
break;
|
|
11361
|
+
case BlendMode.Screen:
|
|
11362
|
+
target.sourceColorBlendFactor = One;
|
|
11363
|
+
target.destinationColorBlendFactor = OneMinusSourceColor;
|
|
11364
|
+
target.sourceAlphaBlendFactor = One;
|
|
11365
|
+
target.destinationAlphaBlendFactor = OneMinusSourceColor;
|
|
11366
|
+
target.colorBlendOperation = target.alphaBlendOperation = Add;
|
|
11367
|
+
break;
|
|
11368
|
+
default:
|
|
11369
|
+
target.sourceColorBlendFactor = premultipliedAlpha ? One : SourceAlpha;
|
|
11370
|
+
target.destinationColorBlendFactor = OneMinusSourceAlpha;
|
|
11371
|
+
target.sourceAlphaBlendFactor = One;
|
|
11372
|
+
target.destinationAlphaBlendFactor = OneMinusSourceAlpha;
|
|
11373
|
+
target.colorBlendOperation = target.alphaBlendOperation = Add;
|
|
11374
|
+
break;
|
|
11375
|
+
}
|
|
11376
|
+
};
|
|
11377
|
+
/**
|
|
11378
|
+
* @internal
|
|
11379
|
+
*/ _proto._getBlendMode = function _getBlendMode() {
|
|
11380
|
+
return this._blendMode;
|
|
11381
|
+
};
|
|
10989
11382
|
return SpineMaterial;
|
|
10990
11383
|
}(Material);
|
|
10991
|
-
SpineMaterial._spineVS = "\n uniform mat4 renderer_MVPMat;\n\n attribute vec3 POSITION;\n attribute vec2 TEXCOORD_0;\n attribute vec4
|
|
10992
|
-
SpineMaterial._spineFS = "\n #include <common>\n uniform sampler2D material_SpineTexture;\n\n varying vec2 v_uv;\n varying vec4
|
|
11384
|
+
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 ";
|
|
11385
|
+
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 ";
|
|
10993
11386
|
|
|
10994
11387
|
/**
|
|
10995
11388
|
* Spine animation renderer, capable of rendering spine animations and providing functions for animation and skeleton manipulation.
|
|
@@ -11004,15 +11397,17 @@ SpineMaterial._spineFS = "\n #include <common>\n uniform sampler2D materia
|
|
|
11004
11397
|
* When enabled, vertex color values are multiplied by the alpha channel.
|
|
11005
11398
|
* @remarks
|
|
11006
11399
|
If this option is enabled, the Spine editor must export textures with "Premultiply Alpha" checked.
|
|
11007
|
-
*/ _this.premultipliedAlpha = false, /**
|
|
11400
|
+
*/ _this.premultipliedAlpha = false, _this._tintBlack = false, /**
|
|
11008
11401
|
* Default state for spine animation.
|
|
11009
11402
|
* Contains the default animation name to be played, whether this animation should loop, the default skin name.
|
|
11010
11403
|
*/ _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 BoundingBox(new Vector3(Infinity, Infinity, Infinity), new Vector3(-Infinity, -Infinity, -Infinity));
|
|
11011
11404
|
var primitive = new Primitive(_this._engine);
|
|
11012
11405
|
_this._primitive = primitive;
|
|
11406
|
+
_this._primitive._addReferCount(1);
|
|
11013
11407
|
primitive.addVertexElement(SpineAnimationRenderer._positionVertexElement);
|
|
11014
|
-
primitive.addVertexElement(SpineAnimationRenderer.
|
|
11408
|
+
primitive.addVertexElement(SpineAnimationRenderer._lightColorVertexElement);
|
|
11015
11409
|
primitive.addVertexElement(SpineAnimationRenderer._uvVertexElement);
|
|
11410
|
+
primitive.addVertexElement(SpineAnimationRenderer._darkColorVertexElement);
|
|
11016
11411
|
return _this;
|
|
11017
11412
|
}
|
|
11018
11413
|
var _proto = SpineAnimationRenderer.prototype;
|
|
@@ -11094,8 +11489,12 @@ SpineMaterial._spineFS = "\n #include <common>\n uniform sampler2D materia
|
|
|
11094
11489
|
*/ _proto._onDestroy = function _onDestroy() {
|
|
11095
11490
|
this._clearMaterialCache();
|
|
11096
11491
|
this._subPrimitives.length = 0;
|
|
11097
|
-
|
|
11098
|
-
|
|
11492
|
+
var primitive = this._primitive;
|
|
11493
|
+
if (primitive) {
|
|
11494
|
+
primitive._addReferCount(-1);
|
|
11495
|
+
primitive._destroy();
|
|
11496
|
+
this._primitive = null;
|
|
11497
|
+
}
|
|
11099
11498
|
this._resource = null;
|
|
11100
11499
|
this._skeleton = null;
|
|
11101
11500
|
this._state = null;
|
|
@@ -11106,9 +11505,10 @@ SpineMaterial._spineFS = "\n #include <common>\n uniform sampler2D materia
|
|
|
11106
11505
|
*/ _proto._createAndBindBuffer = function _createAndBindBuffer(vertexCount) {
|
|
11107
11506
|
var _this = this, _engine = _this._engine, _primitive = _this._primitive;
|
|
11108
11507
|
this._vertexCount = vertexCount;
|
|
11109
|
-
this.
|
|
11508
|
+
var stride = this.tintBlack ? SpineGenerator.vertexStrideWithTint : SpineGenerator.vertexStrideWithoutTint;
|
|
11509
|
+
this._vertices = new Float32Array(vertexCount * stride);
|
|
11110
11510
|
this._indices = new Uint16Array(vertexCount);
|
|
11111
|
-
var vertexStride =
|
|
11511
|
+
var vertexStride = stride << 2;
|
|
11112
11512
|
var vertexBuffer = new Buffer(_engine, BufferBindFlag.VertexBuffer, this._vertices, BufferUsage.Dynamic);
|
|
11113
11513
|
var indexBuffer = new Buffer(_engine, BufferBindFlag.IndexBuffer, this._indices, BufferUsage.Dynamic);
|
|
11114
11514
|
this._indexBuffer = indexBuffer;
|
|
@@ -11128,14 +11528,34 @@ SpineMaterial._spineFS = "\n #include <common>\n uniform sampler2D materia
|
|
|
11128
11528
|
*/ _proto._clearSubPrimitives = function _clearSubPrimitives() {
|
|
11129
11529
|
this._subPrimitives.length = 0;
|
|
11130
11530
|
};
|
|
11531
|
+
/**
|
|
11532
|
+
* @internal
|
|
11533
|
+
*/ _proto._getMaterial = function _getMaterial(texture, blendMode) {
|
|
11534
|
+
var engine = this._engine;
|
|
11535
|
+
var premultipliedAlpha = this.premultipliedAlpha;
|
|
11536
|
+
var tintBlack = this.tintBlack;
|
|
11537
|
+
var key = texture.instanceId + "_" + blendMode + "_" + (premultipliedAlpha ? 1 : 0);
|
|
11538
|
+
var cached = SpineAnimationRenderer._materialCacheMap[key];
|
|
11539
|
+
if (!cached) {
|
|
11540
|
+
cached = new SpineMaterial(engine);
|
|
11541
|
+
cached.isGCIgnored = true;
|
|
11542
|
+
SpineAnimationRenderer._materialCacheMap.set(key, cached);
|
|
11543
|
+
}
|
|
11544
|
+
cached._setBlendMode(blendMode, premultipliedAlpha);
|
|
11545
|
+
cached._setTexture(texture);
|
|
11546
|
+
cached._setTintBlack(tintBlack);
|
|
11547
|
+
cached._setPremultipliedAlpha(premultipliedAlpha);
|
|
11548
|
+
return cached;
|
|
11549
|
+
};
|
|
11131
11550
|
_proto._clearMaterialCache = function _clearMaterialCache() {
|
|
11132
|
-
var materialCache = SpineAnimationRenderer.
|
|
11133
|
-
var
|
|
11551
|
+
var materialCache = SpineAnimationRenderer._materialCacheMap;
|
|
11552
|
+
var premultipliedAlpha = this.premultipliedAlpha;
|
|
11553
|
+
var materials = this._materials;
|
|
11134
11554
|
for(var i = 0, len = materials.length; i < len; i += 1){
|
|
11135
11555
|
var material = materials[i];
|
|
11136
11556
|
var texture = material.shaderData.getTexture("material_SpineTexture");
|
|
11137
|
-
var blendMode =
|
|
11138
|
-
var key = texture.instanceId + "_" + blendMode;
|
|
11557
|
+
var blendMode = material._getBlendMode();
|
|
11558
|
+
var key = texture.instanceId + "_" + blendMode + "_" + (premultipliedAlpha ? 1 : 0);
|
|
11139
11559
|
materialCache.delete(key);
|
|
11140
11560
|
}
|
|
11141
11561
|
};
|
|
@@ -11152,22 +11572,23 @@ SpineMaterial._spineFS = "\n #include <common>\n uniform sampler2D materia
|
|
|
11152
11572
|
}
|
|
11153
11573
|
}
|
|
11154
11574
|
};
|
|
11155
|
-
/** @internal */ SpineAnimationRenderer._getDefaultMaterial = function _getDefaultMaterial(engine) {
|
|
11156
|
-
var defaultMaterial = this._defaultMaterial;
|
|
11157
|
-
if (defaultMaterial) {
|
|
11158
|
-
if (defaultMaterial.engine === engine) {
|
|
11159
|
-
return defaultMaterial.clone();
|
|
11160
|
-
} else {
|
|
11161
|
-
defaultMaterial.destroy(true);
|
|
11162
|
-
defaultMaterial = null;
|
|
11163
|
-
}
|
|
11164
|
-
}
|
|
11165
|
-
defaultMaterial = new SpineMaterial(engine);
|
|
11166
|
-
defaultMaterial.isGCIgnored = true;
|
|
11167
|
-
this._defaultMaterial = defaultMaterial;
|
|
11168
|
-
return defaultMaterial.clone();
|
|
11169
|
-
};
|
|
11170
11575
|
_create_class(SpineAnimationRenderer, [
|
|
11576
|
+
{
|
|
11577
|
+
key: "tintBlack",
|
|
11578
|
+
get: /**
|
|
11579
|
+
* Whether to enable tint black feature for dark color tinting.
|
|
11580
|
+
*
|
|
11581
|
+
* @remarks Should be enabled when using "Tint Black" feature in Spine editor.
|
|
11582
|
+
*/ function get() {
|
|
11583
|
+
return this._tintBlack;
|
|
11584
|
+
},
|
|
11585
|
+
set: function set(value) {
|
|
11586
|
+
if (this._tintBlack !== value) {
|
|
11587
|
+
this._tintBlack = value;
|
|
11588
|
+
this._needResizeBuffer = true;
|
|
11589
|
+
}
|
|
11590
|
+
}
|
|
11591
|
+
},
|
|
11171
11592
|
{
|
|
11172
11593
|
key: "state",
|
|
11173
11594
|
get: /**
|
|
@@ -11221,15 +11642,19 @@ SpineMaterial._spineFS = "\n #include <common>\n uniform sampler2D materia
|
|
|
11221
11642
|
}(Renderer);
|
|
11222
11643
|
SpineAnimationRenderer._spineGenerator = new SpineGenerator();
|
|
11223
11644
|
SpineAnimationRenderer._positionVertexElement = new VertexElement("POSITION", 0, VertexElementFormat.Vector3, 0);
|
|
11224
|
-
SpineAnimationRenderer.
|
|
11645
|
+
SpineAnimationRenderer._lightColorVertexElement = new VertexElement("LIGHT_COLOR", 12, VertexElementFormat.Vector4, 0);
|
|
11225
11646
|
SpineAnimationRenderer._uvVertexElement = new VertexElement("TEXCOORD_0", 28, VertexElementFormat.Vector2, 0);
|
|
11226
|
-
|
|
11647
|
+
SpineAnimationRenderer._darkColorVertexElement = new VertexElement("DARK_COLOR", 36, VertexElementFormat.Vector3, 0);
|
|
11648
|
+
/** @internal */ SpineAnimationRenderer._materialCacheMap = new Map();
|
|
11227
11649
|
__decorate([
|
|
11228
11650
|
assignmentClone
|
|
11229
11651
|
], SpineAnimationRenderer.prototype, "zSpacing", void 0);
|
|
11230
11652
|
__decorate([
|
|
11231
11653
|
assignmentClone
|
|
11232
11654
|
], SpineAnimationRenderer.prototype, "premultipliedAlpha", void 0);
|
|
11655
|
+
__decorate([
|
|
11656
|
+
assignmentClone
|
|
11657
|
+
], SpineAnimationRenderer.prototype, "_tintBlack", void 0);
|
|
11233
11658
|
__decorate([
|
|
11234
11659
|
deepClone
|
|
11235
11660
|
], SpineAnimationRenderer.prototype, "defaultConfig", void 0);
|
|
@@ -11630,8 +12055,8 @@ for(var key in RendererObject){
|
|
|
11630
12055
|
for(var key1 in LoaderObject){
|
|
11631
12056
|
Loader.registerClass(key1, LoaderObject[key1]);
|
|
11632
12057
|
}
|
|
11633
|
-
var version = "4.2.
|
|
12058
|
+
var version = "4.2.4";
|
|
11634
12059
|
console.log("Galacean spine version: " + version);
|
|
11635
12060
|
|
|
11636
|
-
export { AlphaTimeline, Animation, AnimationState, AnimationStateAdapter, AnimationStateData, AssetManagerBase, AtlasAttachmentLoader, Attachment, AttachmentTimeline, BinaryInput, BlendMode, Bone, BoneData, BoundingBoxAttachment, CURRENT, ClippingAttachment, Color, ConstraintData, CurveTimeline, CurveTimeline1, CurveTimeline2, DebugUtils, DeformTimeline, Downloader, DrawOrderTimeline, Event, EventData, EventQueue, EventTimeline, EventType, FIRST, FakeTexture, HOLD_FIRST, HOLD_MIX, HOLD_SUBSEQUENT, IkConstraint, IkConstraintData, IkConstraintTimeline, Inherit, InheritTimeline, IntSet, Interpolation, LoaderUtils, MathUtils, MeshAttachment, MixBlend, MixDirection, PathAttachment, PathConstraint, PathConstraintData, PathConstraintMixTimeline, PathConstraintPositionTimeline, PathConstraintSpacingTimeline, Physics, PhysicsConstraintDampingTimeline, PhysicsConstraintGravityTimeline, PhysicsConstraintInertiaTimeline, PhysicsConstraintMassTimeline, PhysicsConstraintMixTimeline, PhysicsConstraintResetTimeline, PhysicsConstraintStrengthTimeline, PhysicsConstraintTimeline, PhysicsConstraintWindTimeline, PointAttachment, Pool, PositionMode, Pow, PowOut, RGB2Timeline, RGBA2Timeline, RGBATimeline, RGBTimeline, RegionAttachment, RotateMode, RotateTimeline, SETUP, SUBSEQUENT, ScaleTimeline, ScaleXTimeline, ScaleYTimeline, SequenceTimeline, ShearTimeline, ShearXTimeline, ShearYTimeline, Skeleton, SkeletonBinary, SkeletonBounds, SkeletonClipping, SkeletonData, SkeletonJson, Skin, SkinEntry, Slot, SlotData, SpacingMode, SpineAnimationRenderer, SpineMaterial, SpineResource, StringSet, Texture, TextureAtlas, TextureAtlasPage, TextureAtlasRegion, TextureFilter, TextureRegion, TextureWrap, TimeKeeper, Timeline, TrackEntry, TransformConstraint, TransformConstraintData, TransformConstraintTimeline, TranslateTimeline, TranslateXTimeline, TranslateYTimeline, Triangulator, Utils, Vector2, VertexAttachment, WindowedMean, version };
|
|
12061
|
+
export { AlphaTimeline, Animation, AnimationState, AnimationStateAdapter, AnimationStateData, AssetCache, AssetManagerBase, AtlasAttachmentLoader, Attachment, AttachmentTimeline, BinaryInput, BlendMode, Bone, BoneData, BoundingBoxAttachment, CURRENT, ClippingAttachment, Color, ConstraintData, CurveTimeline, CurveTimeline1, CurveTimeline2, DebugUtils, DeformTimeline, Downloader, DrawOrderTimeline, Event, EventData, EventQueue, EventTimeline, EventType, FIRST, FakeTexture, HOLD_FIRST, HOLD_MIX, HOLD_SUBSEQUENT, IkConstraint, IkConstraintData, IkConstraintTimeline, Inherit, InheritTimeline, IntSet, Interpolation, LoaderUtils, MathUtils, MeshAttachment, MixBlend, MixDirection, PathAttachment, PathConstraint, PathConstraintData, PathConstraintMixTimeline, PathConstraintPositionTimeline, PathConstraintSpacingTimeline, Physics, PhysicsConstraintDampingTimeline, PhysicsConstraintGravityTimeline, PhysicsConstraintInertiaTimeline, PhysicsConstraintMassTimeline, PhysicsConstraintMixTimeline, PhysicsConstraintResetTimeline, PhysicsConstraintStrengthTimeline, PhysicsConstraintTimeline, PhysicsConstraintWindTimeline, PointAttachment, Pool, PositionMode, Pow, PowOut, RGB2Timeline, RGBA2Timeline, RGBATimeline, RGBTimeline, RegionAttachment, RotateMode, RotateTimeline, SETUP, SUBSEQUENT, ScaleTimeline, ScaleXTimeline, ScaleYTimeline, SequenceTimeline, ShearTimeline, ShearXTimeline, ShearYTimeline, Skeleton, SkeletonBinary, SkeletonBounds, SkeletonClipping, SkeletonData, SkeletonJson, Skin, SkinEntry, Slot, SlotData, SpacingMode, SpineAnimationRenderer, SpineMaterial, SpineResource, StringSet, Texture, TextureAtlas, TextureAtlasPage, TextureAtlasRegion, TextureFilter, TextureRegion, TextureWrap, TimeKeeper, Timeline, TrackEntry, TransformConstraint, TransformConstraintData, TransformConstraintTimeline, TranslateTimeline, TranslateXTimeline, TranslateYTimeline, Triangulator, Utils, Vector2, VertexAttachment, WindowedMean, version };
|
|
11637
12062
|
//# sourceMappingURL=module.js.map
|