@galacean/effects-core 2.10.0-alpha.1 → 2.10.0-alpha.2
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/components/frame-component.d.ts +10 -0
- package/dist/components/mesh-component.d.ts +1 -1
- package/dist/composition.d.ts +4 -8
- package/dist/engine.d.ts +20 -8
- package/dist/index.js +1980 -826
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1973 -827
- package/dist/index.mjs.map +1 -1
- package/dist/plugins/particle/particle-mesh.d.ts +4 -1
- package/dist/plugins/particle/particle-system.d.ts +7 -0
- package/dist/plugins/particle/trail-mesh.d.ts +4 -0
- package/dist/plugins/shape/shape-component.d.ts +1 -0
- package/dist/plugins/sprite/sprite-item.d.ts +1 -0
- package/dist/render/buffer.d.ts +33 -0
- package/dist/render/data-buffer.d.ts +39 -0
- package/dist/render/geometry.d.ts +72 -94
- package/dist/render/gpu-capability.d.ts +2 -0
- package/dist/render/graphics.d.ts +1 -0
- package/dist/render/index.d.ts +3 -0
- package/dist/render/shader.d.ts +2 -1
- package/dist/render/vertex-buffer.d.ts +72 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects runtime core for the web
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
|
|
6
|
-
* Version: v2.10.0-alpha.
|
|
6
|
+
* Version: v2.10.0-alpha.2
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -11651,10 +11651,11 @@ exports.GLSLVersion = void 0;
|
|
|
11651
11651
|
})(exports.GLSLVersion || (exports.GLSLVersion = {}));
|
|
11652
11652
|
var ShaderVariant = /*#__PURE__*/ function(EffectsObject) {
|
|
11653
11653
|
_inherits(ShaderVariant, EffectsObject);
|
|
11654
|
-
function ShaderVariant(engine, source) {
|
|
11654
|
+
function ShaderVariant(engine, source, key) {
|
|
11655
11655
|
var _this;
|
|
11656
11656
|
_this = EffectsObject.call(this, engine) || this;
|
|
11657
11657
|
_this.source = source;
|
|
11658
|
+
_this.key = key;
|
|
11658
11659
|
return _this;
|
|
11659
11660
|
}
|
|
11660
11661
|
var _proto = ShaderVariant.prototype;
|
|
@@ -12733,6 +12734,30 @@ var MAX_MASK_REFERENCE_COUNT = 254;
|
|
|
12733
12734
|
/**
|
|
12734
12735
|
* 期望的 stencil 值(等于正向蒙版的数量)
|
|
12735
12736
|
*/ this.expectedStencilValue = 0;
|
|
12737
|
+
this.prevStencilFunc = [
|
|
12738
|
+
0,
|
|
12739
|
+
0
|
|
12740
|
+
];
|
|
12741
|
+
this.prevStencilOpFail = [
|
|
12742
|
+
0,
|
|
12743
|
+
0
|
|
12744
|
+
];
|
|
12745
|
+
this.prevStencilOpZFail = [
|
|
12746
|
+
0,
|
|
12747
|
+
0
|
|
12748
|
+
];
|
|
12749
|
+
this.prevStencilOpZPass = [
|
|
12750
|
+
0,
|
|
12751
|
+
0
|
|
12752
|
+
];
|
|
12753
|
+
this.prevStencilRef = [
|
|
12754
|
+
0,
|
|
12755
|
+
0
|
|
12756
|
+
];
|
|
12757
|
+
this.prevStencilMask = [
|
|
12758
|
+
0,
|
|
12759
|
+
0
|
|
12760
|
+
];
|
|
12736
12761
|
this.stencilClearAction = {
|
|
12737
12762
|
stencilAction: exports.TextureLoadAction.clear
|
|
12738
12763
|
};
|
|
@@ -12890,22 +12915,22 @@ var MAX_MASK_REFERENCE_COUNT = 254;
|
|
|
12890
12915
|
if (subMeshIndex === void 0) subMeshIndex = 0;
|
|
12891
12916
|
var prevColorMask = material.colorMask;
|
|
12892
12917
|
var prevStencilTest = material.stencilTest;
|
|
12893
|
-
|
|
12894
|
-
|
|
12895
|
-
|
|
12896
|
-
|
|
12897
|
-
|
|
12898
|
-
|
|
12918
|
+
this.copyStencilArrayValue(this.prevStencilFunc, material.stencilFunc);
|
|
12919
|
+
this.copyStencilArrayValue(this.prevStencilOpFail, material.stencilOpFail);
|
|
12920
|
+
this.copyStencilArrayValue(this.prevStencilOpZFail, material.stencilOpZFail);
|
|
12921
|
+
this.copyStencilArrayValue(this.prevStencilOpZPass, material.stencilOpZPass);
|
|
12922
|
+
this.copyStencilArrayValue(this.prevStencilRef, material.stencilRef);
|
|
12923
|
+
this.copyStencilArrayValue(this.prevStencilMask, material.stencilMask);
|
|
12899
12924
|
this.setupMaskMaterial(material, maskRef);
|
|
12900
12925
|
renderer.drawGeometry(geometry, worldMatrix, material, subMeshIndex);
|
|
12901
12926
|
material.colorMask = prevColorMask;
|
|
12902
12927
|
material.stencilTest = prevStencilTest;
|
|
12903
|
-
material.stencilFunc = prevStencilFunc;
|
|
12904
|
-
material.stencilOpFail = prevStencilOpFail;
|
|
12905
|
-
material.stencilOpZFail = prevStencilOpZFail;
|
|
12906
|
-
material.stencilOpZPass = prevStencilOpZPass;
|
|
12907
|
-
material.stencilRef = prevStencilRef;
|
|
12908
|
-
material.stencilMask = prevStencilMask;
|
|
12928
|
+
material.stencilFunc = this.prevStencilFunc;
|
|
12929
|
+
material.stencilOpFail = this.prevStencilOpFail;
|
|
12930
|
+
material.stencilOpZFail = this.prevStencilOpZFail;
|
|
12931
|
+
material.stencilOpZPass = this.prevStencilOpZPass;
|
|
12932
|
+
material.stencilRef = this.prevStencilRef;
|
|
12933
|
+
material.stencilMask = this.prevStencilMask;
|
|
12909
12934
|
};
|
|
12910
12935
|
/**
|
|
12911
12936
|
* 设置蒙版材质的 stencil 属性(写入蒙版)
|
|
@@ -12979,6 +13004,13 @@ var MAX_MASK_REFERENCE_COUNT = 254;
|
|
|
12979
13004
|
material.stencilTest = false;
|
|
12980
13005
|
}
|
|
12981
13006
|
};
|
|
13007
|
+
_proto.copyStencilArrayValue = function copyStencilArrayValue(target, source) {
|
|
13008
|
+
if (!source) {
|
|
13009
|
+
return;
|
|
13010
|
+
}
|
|
13011
|
+
target[0] = source[0];
|
|
13012
|
+
target[1] = source[1];
|
|
13013
|
+
};
|
|
12982
13014
|
_create_class(MaskProcessor, [
|
|
12983
13015
|
{
|
|
12984
13016
|
key: "maskable",
|
|
@@ -13003,6 +13035,401 @@ var MAX_MASK_REFERENCE_COUNT = 254;
|
|
|
13003
13035
|
return MaskProcessor;
|
|
13004
13036
|
}();
|
|
13005
13037
|
|
|
13038
|
+
exports.BufferUsage = void 0;
|
|
13039
|
+
(function(BufferUsage) {
|
|
13040
|
+
BufferUsage[BufferUsage["Stream"] = 35040] = "Stream";
|
|
13041
|
+
BufferUsage[BufferUsage["Static"] = 35044] = "Static";
|
|
13042
|
+
BufferUsage[BufferUsage["Dynamic"] = 35048] = "Dynamic";
|
|
13043
|
+
})(exports.BufferUsage || (exports.BufferUsage = {}));
|
|
13044
|
+
exports.BufferDataType = void 0;
|
|
13045
|
+
(function(BufferDataType) {
|
|
13046
|
+
BufferDataType[BufferDataType["Byte"] = 5120] = "Byte";
|
|
13047
|
+
BufferDataType[BufferDataType["UnsignedByte"] = 5121] = "UnsignedByte";
|
|
13048
|
+
BufferDataType[BufferDataType["Short"] = 5122] = "Short";
|
|
13049
|
+
BufferDataType[BufferDataType["UnsignedShort"] = 5123] = "UnsignedShort";
|
|
13050
|
+
BufferDataType[BufferDataType["Int"] = 5124] = "Int";
|
|
13051
|
+
BufferDataType[BufferDataType["UnsignedInt"] = 5125] = "UnsignedInt";
|
|
13052
|
+
BufferDataType[BufferDataType["Float"] = 5126] = "Float";
|
|
13053
|
+
})(exports.BufferDataType || (exports.BufferDataType = {}));
|
|
13054
|
+
/**
|
|
13055
|
+
* 后端缓冲区的最小抽象,只保存资源状态。
|
|
13056
|
+
*/ var DataBuffer = /*#__PURE__*/ function() {
|
|
13057
|
+
function DataBuffer() {
|
|
13058
|
+
this.references = 0;
|
|
13059
|
+
this.capacity = 0;
|
|
13060
|
+
this.is32Bits = false;
|
|
13061
|
+
}
|
|
13062
|
+
_create_class(DataBuffer, [
|
|
13063
|
+
{
|
|
13064
|
+
key: "underlyingResource",
|
|
13065
|
+
get: function get() {
|
|
13066
|
+
return null;
|
|
13067
|
+
}
|
|
13068
|
+
}
|
|
13069
|
+
]);
|
|
13070
|
+
return DataBuffer;
|
|
13071
|
+
}();
|
|
13072
|
+
function getBytesPerElement(type) {
|
|
13073
|
+
switch(type){
|
|
13074
|
+
case 5120:
|
|
13075
|
+
case 5121:
|
|
13076
|
+
return 1;
|
|
13077
|
+
case 5122:
|
|
13078
|
+
case 5123:
|
|
13079
|
+
return 2;
|
|
13080
|
+
case 5124:
|
|
13081
|
+
case 5125:
|
|
13082
|
+
case 5126:
|
|
13083
|
+
return 4;
|
|
13084
|
+
default:
|
|
13085
|
+
return 0;
|
|
13086
|
+
}
|
|
13087
|
+
}
|
|
13088
|
+
function getDataType(data) {
|
|
13089
|
+
if (_instanceof1(data, Int8Array)) {
|
|
13090
|
+
return 5120;
|
|
13091
|
+
}
|
|
13092
|
+
if (_instanceof1(data, Uint8Array)) {
|
|
13093
|
+
return 5121;
|
|
13094
|
+
}
|
|
13095
|
+
if (_instanceof1(data, Int16Array)) {
|
|
13096
|
+
return 5122;
|
|
13097
|
+
}
|
|
13098
|
+
if (_instanceof1(data, Uint16Array)) {
|
|
13099
|
+
return 5123;
|
|
13100
|
+
}
|
|
13101
|
+
if (_instanceof1(data, Int32Array)) {
|
|
13102
|
+
return 5124;
|
|
13103
|
+
}
|
|
13104
|
+
if (_instanceof1(data, Uint32Array)) {
|
|
13105
|
+
return 5125;
|
|
13106
|
+
}
|
|
13107
|
+
return 5126;
|
|
13108
|
+
}
|
|
13109
|
+
function getDataByteLength(data) {
|
|
13110
|
+
if (Array.isArray(data)) {
|
|
13111
|
+
return data.length * Float32Array.BYTES_PER_ELEMENT;
|
|
13112
|
+
}
|
|
13113
|
+
return data.byteLength;
|
|
13114
|
+
}
|
|
13115
|
+
function toBufferView(data) {
|
|
13116
|
+
if (Array.isArray(data)) {
|
|
13117
|
+
return new Float32Array(data);
|
|
13118
|
+
}
|
|
13119
|
+
if (_instanceof1(data, ArrayBuffer)) {
|
|
13120
|
+
return new Uint8Array(data);
|
|
13121
|
+
}
|
|
13122
|
+
return data;
|
|
13123
|
+
}
|
|
13124
|
+
function createTypedArray(type, length) {
|
|
13125
|
+
switch(type){
|
|
13126
|
+
case 5120:
|
|
13127
|
+
return new Int8Array(length);
|
|
13128
|
+
case 5121:
|
|
13129
|
+
return new Uint8Array(length);
|
|
13130
|
+
case 5122:
|
|
13131
|
+
return new Int16Array(length);
|
|
13132
|
+
case 5123:
|
|
13133
|
+
return new Uint16Array(length);
|
|
13134
|
+
case 5124:
|
|
13135
|
+
return new Int32Array(length);
|
|
13136
|
+
case 5125:
|
|
13137
|
+
return new Uint32Array(length);
|
|
13138
|
+
default:
|
|
13139
|
+
return new Float32Array(length);
|
|
13140
|
+
}
|
|
13141
|
+
}
|
|
13142
|
+
|
|
13143
|
+
/**
|
|
13144
|
+
* 管理顶点数据及其对应的后端缓冲区。
|
|
13145
|
+
*/ var Buffer = /*#__PURE__*/ function() {
|
|
13146
|
+
function Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes, divisor, label) {
|
|
13147
|
+
if (stride === void 0) stride = 0;
|
|
13148
|
+
if (postponeInternalCreation === void 0) postponeInternalCreation = false;
|
|
13149
|
+
if (instanced === void 0) instanced = false;
|
|
13150
|
+
if (useBytes === void 0) useBytes = false;
|
|
13151
|
+
this.engine = engine;
|
|
13152
|
+
this.isAlreadyOwned = false;
|
|
13153
|
+
this._isDisposed = false;
|
|
13154
|
+
this.updatable = updatable;
|
|
13155
|
+
this.instanced = instanced;
|
|
13156
|
+
this.divisor = divisor || 1;
|
|
13157
|
+
this.label = label;
|
|
13158
|
+
this.byteStride = useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT;
|
|
13159
|
+
if (_instanceof1(data, DataBuffer)) {
|
|
13160
|
+
this.buffer = data;
|
|
13161
|
+
} else {
|
|
13162
|
+
this.data = data;
|
|
13163
|
+
}
|
|
13164
|
+
if (!postponeInternalCreation) {
|
|
13165
|
+
this.create();
|
|
13166
|
+
}
|
|
13167
|
+
}
|
|
13168
|
+
var _proto = Buffer.prototype;
|
|
13169
|
+
_proto.isUpdatable = function isUpdatable() {
|
|
13170
|
+
return this.updatable;
|
|
13171
|
+
};
|
|
13172
|
+
_proto.getData = function getData() {
|
|
13173
|
+
return this.data;
|
|
13174
|
+
};
|
|
13175
|
+
_proto.getBuffer = function getBuffer() {
|
|
13176
|
+
return this.buffer;
|
|
13177
|
+
};
|
|
13178
|
+
_proto.getStrideSize = function getStrideSize() {
|
|
13179
|
+
return this.byteStride / Float32Array.BYTES_PER_ELEMENT;
|
|
13180
|
+
};
|
|
13181
|
+
_proto.createVertexBuffer = function createVertexBuffer(kind, offset, size, stride, instanced, useBytes, divisor) {
|
|
13182
|
+
if (useBytes === void 0) useBytes = false;
|
|
13183
|
+
var byteOffset = useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT;
|
|
13184
|
+
var byteStride = stride ? useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT : this.byteStride;
|
|
13185
|
+
return new VertexBuffer(this.engine, this, kind, {
|
|
13186
|
+
size: size,
|
|
13187
|
+
stride: byteStride,
|
|
13188
|
+
offset: byteOffset,
|
|
13189
|
+
instanced: instanced === undefined ? this.instanced : instanced,
|
|
13190
|
+
useBytes: true,
|
|
13191
|
+
divisor: divisor != null ? divisor : this.divisor
|
|
13192
|
+
});
|
|
13193
|
+
};
|
|
13194
|
+
_proto.create = function create(data) {
|
|
13195
|
+
if (!data && this.buffer) {
|
|
13196
|
+
return;
|
|
13197
|
+
}
|
|
13198
|
+
data = data != null ? data : this.data;
|
|
13199
|
+
if (!data) {
|
|
13200
|
+
return;
|
|
13201
|
+
}
|
|
13202
|
+
var options = this.getDataBufferOptions(data);
|
|
13203
|
+
if (!this.buffer) {
|
|
13204
|
+
this.buffer = this.updatable ? this.engine.createDynamicVertexBuffer(data, options) : this.engine.createVertexBuffer(data, options);
|
|
13205
|
+
if (this.updatable) {
|
|
13206
|
+
this.data = data;
|
|
13207
|
+
}
|
|
13208
|
+
} else if (this.updatable) {
|
|
13209
|
+
this.engine.updateDynamicVertexBuffer(this.buffer, data);
|
|
13210
|
+
this.data = data;
|
|
13211
|
+
}
|
|
13212
|
+
};
|
|
13213
|
+
_proto.update = function update(data) {
|
|
13214
|
+
this.create(data);
|
|
13215
|
+
};
|
|
13216
|
+
_proto.updateDirectly = function updateDirectly(data, offset, vertexCount, useBytes) {
|
|
13217
|
+
if (useBytes === void 0) useBytes = false;
|
|
13218
|
+
if (!this.buffer || !this.updatable) {
|
|
13219
|
+
return;
|
|
13220
|
+
}
|
|
13221
|
+
this.engine.updateDynamicVertexBuffer(this.buffer, data, useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT, vertexCount ? vertexCount * this.byteStride : undefined);
|
|
13222
|
+
if (offset === 0 && vertexCount === undefined) {
|
|
13223
|
+
this.data = data;
|
|
13224
|
+
} else {
|
|
13225
|
+
this.data = undefined;
|
|
13226
|
+
}
|
|
13227
|
+
};
|
|
13228
|
+
/**
|
|
13229
|
+
* @internal
|
|
13230
|
+
*/ _proto.rebuild = function rebuild() {
|
|
13231
|
+
if (!this.data) {
|
|
13232
|
+
if (!this.buffer) {
|
|
13233
|
+
return;
|
|
13234
|
+
}
|
|
13235
|
+
var capacity = this.buffer.capacity;
|
|
13236
|
+
if (capacity > 0) {
|
|
13237
|
+
var options = this.getDataBufferOptions();
|
|
13238
|
+
this.buffer = this.updatable ? this.engine.createDynamicVertexBuffer(capacity, options) : this.engine.createVertexBuffer(capacity, options);
|
|
13239
|
+
} else {
|
|
13240
|
+
this.buffer = undefined;
|
|
13241
|
+
}
|
|
13242
|
+
return;
|
|
13243
|
+
}
|
|
13244
|
+
this.buffer = undefined;
|
|
13245
|
+
this.create(this.data);
|
|
13246
|
+
};
|
|
13247
|
+
/**
|
|
13248
|
+
* @internal
|
|
13249
|
+
*/ _proto.increaseReferences = function increaseReferences() {
|
|
13250
|
+
if (!this.buffer) {
|
|
13251
|
+
return;
|
|
13252
|
+
}
|
|
13253
|
+
if (!this.isAlreadyOwned) {
|
|
13254
|
+
this.isAlreadyOwned = true;
|
|
13255
|
+
return;
|
|
13256
|
+
}
|
|
13257
|
+
this.buffer.references++;
|
|
13258
|
+
};
|
|
13259
|
+
_proto.dispose = function dispose() {
|
|
13260
|
+
if (!this.buffer) {
|
|
13261
|
+
return;
|
|
13262
|
+
}
|
|
13263
|
+
if (this.engine.releaseBuffer(this.buffer)) {
|
|
13264
|
+
this.data = undefined;
|
|
13265
|
+
this.buffer = undefined;
|
|
13266
|
+
this._isDisposed = true;
|
|
13267
|
+
}
|
|
13268
|
+
};
|
|
13269
|
+
_proto.getDataBufferOptions = function getDataBufferOptions(data) {
|
|
13270
|
+
return {
|
|
13271
|
+
usage: this.updatable ? exports.BufferUsage.Dynamic : exports.BufferUsage.Static,
|
|
13272
|
+
type: data ? getDataType(data) : exports.BufferDataType.Float,
|
|
13273
|
+
byteStride: this.byteStride,
|
|
13274
|
+
instanceDivisor: this.instanced ? this.divisor : 0,
|
|
13275
|
+
label: this.label
|
|
13276
|
+
};
|
|
13277
|
+
};
|
|
13278
|
+
_create_class(Buffer, [
|
|
13279
|
+
{
|
|
13280
|
+
key: "isDisposed",
|
|
13281
|
+
get: function get() {
|
|
13282
|
+
return this._isDisposed;
|
|
13283
|
+
}
|
|
13284
|
+
},
|
|
13285
|
+
{
|
|
13286
|
+
key: "capacity",
|
|
13287
|
+
get: function get() {
|
|
13288
|
+
var _this_buffer;
|
|
13289
|
+
var _this_buffer_capacity;
|
|
13290
|
+
return (_this_buffer_capacity = (_this_buffer = this.buffer) == null ? void 0 : _this_buffer.capacity) != null ? _this_buffer_capacity : this.data ? getDataByteLength(this.data) : 0;
|
|
13291
|
+
}
|
|
13292
|
+
}
|
|
13293
|
+
]);
|
|
13294
|
+
return Buffer;
|
|
13295
|
+
}();
|
|
13296
|
+
|
|
13297
|
+
/**
|
|
13298
|
+
* 描述一个顶点属性如何读取共享缓冲区。
|
|
13299
|
+
*/ var VertexBuffer = /*#__PURE__*/ function() {
|
|
13300
|
+
function VertexBuffer(engine, data, kind, props) {
|
|
13301
|
+
if (props === void 0) props = {};
|
|
13302
|
+
this._isDisposed = false;
|
|
13303
|
+
this.engine = engine;
|
|
13304
|
+
this.kind = kind;
|
|
13305
|
+
if (_instanceof1(data, Buffer)) {
|
|
13306
|
+
this.buffer = data;
|
|
13307
|
+
var _props_takeBufferOwnership;
|
|
13308
|
+
this.ownsBuffer = (_props_takeBufferOwnership = props.takeBufferOwnership) != null ? _props_takeBufferOwnership : false;
|
|
13309
|
+
} else {
|
|
13310
|
+
var _props_updatable, _props_stride, _props_postponeInternalCreation, _props_instanced, _props_useBytes;
|
|
13311
|
+
this.buffer = new Buffer(engine, data, (_props_updatable = props.updatable) != null ? _props_updatable : false, (_props_stride = props.stride) != null ? _props_stride : 0, (_props_postponeInternalCreation = props.postponeInternalCreation) != null ? _props_postponeInternalCreation : false, (_props_instanced = props.instanced) != null ? _props_instanced : false, (_props_useBytes = props.useBytes) != null ? _props_useBytes : false, props.divisor, props.label);
|
|
13312
|
+
this.ownsBuffer = true;
|
|
13313
|
+
}
|
|
13314
|
+
var source = this.getData();
|
|
13315
|
+
var _props_type;
|
|
13316
|
+
this.type = (_props_type = props.type) != null ? _props_type : source ? getDataType(source) : VertexBuffer.FLOAT;
|
|
13317
|
+
var typeByteLength = getBytesPerElement(this.type);
|
|
13318
|
+
var _props_useBytes1;
|
|
13319
|
+
var useBytes = (_props_useBytes1 = props.useBytes) != null ? _props_useBytes1 : false;
|
|
13320
|
+
var _props_stride1;
|
|
13321
|
+
var stride = (_props_stride1 = props.stride) != null ? _props_stride1 : 0;
|
|
13322
|
+
var _props_offset;
|
|
13323
|
+
var offset = (_props_offset = props.offset) != null ? _props_offset : 0;
|
|
13324
|
+
if (useBytes) {
|
|
13325
|
+
this.size = props.size || (stride ? stride / typeByteLength : 0);
|
|
13326
|
+
this.byteStride = stride || this.buffer.byteStride || this.size * typeByteLength;
|
|
13327
|
+
this.byteOffset = offset;
|
|
13328
|
+
} else {
|
|
13329
|
+
this.size = props.size || stride;
|
|
13330
|
+
this.byteStride = stride ? stride * typeByteLength : this.buffer.byteStride || this.size * typeByteLength;
|
|
13331
|
+
this.byteOffset = offset * typeByteLength;
|
|
13332
|
+
}
|
|
13333
|
+
var _props_normalized;
|
|
13334
|
+
this.normalized = (_props_normalized = props.normalized) != null ? _props_normalized : false;
|
|
13335
|
+
var _props_instanced1;
|
|
13336
|
+
this.instanced = (_props_instanced1 = props.instanced) != null ? _props_instanced1 : false;
|
|
13337
|
+
var _props_divisor;
|
|
13338
|
+
this._instanceDivisor = this.instanced ? (_props_divisor = props.divisor) != null ? _props_divisor : 1 : 0;
|
|
13339
|
+
}
|
|
13340
|
+
var _proto = VertexBuffer.prototype;
|
|
13341
|
+
_proto.getKind = function getKind() {
|
|
13342
|
+
return this.kind;
|
|
13343
|
+
};
|
|
13344
|
+
_proto.isUpdatable = function isUpdatable() {
|
|
13345
|
+
return this.buffer.isUpdatable();
|
|
13346
|
+
};
|
|
13347
|
+
_proto.getData = function getData() {
|
|
13348
|
+
return this.buffer.getData();
|
|
13349
|
+
};
|
|
13350
|
+
_proto.getBuffer = function getBuffer() {
|
|
13351
|
+
return this.buffer.getBuffer();
|
|
13352
|
+
};
|
|
13353
|
+
_proto.getWrapperBuffer = function getWrapperBuffer() {
|
|
13354
|
+
return this.buffer;
|
|
13355
|
+
};
|
|
13356
|
+
_proto.getStrideSize = function getStrideSize() {
|
|
13357
|
+
return this.byteStride / getBytesPerElement(this.type);
|
|
13358
|
+
};
|
|
13359
|
+
_proto.getOffset = function getOffset() {
|
|
13360
|
+
return this.byteOffset / getBytesPerElement(this.type);
|
|
13361
|
+
};
|
|
13362
|
+
_proto.getSize = function getSize(sizeInBytes) {
|
|
13363
|
+
if (sizeInBytes === void 0) sizeInBytes = false;
|
|
13364
|
+
return sizeInBytes ? this.size * getBytesPerElement(this.type) : this.size;
|
|
13365
|
+
};
|
|
13366
|
+
_proto.getIsInstanced = function getIsInstanced() {
|
|
13367
|
+
return this.instanced;
|
|
13368
|
+
};
|
|
13369
|
+
_proto.getInstanceDivisor = function getInstanceDivisor() {
|
|
13370
|
+
return this._instanceDivisor;
|
|
13371
|
+
};
|
|
13372
|
+
_proto.create = function create(data) {
|
|
13373
|
+
this.buffer.create(data);
|
|
13374
|
+
};
|
|
13375
|
+
_proto.update = function update(data) {
|
|
13376
|
+
this.buffer.update(data);
|
|
13377
|
+
};
|
|
13378
|
+
_proto.updateDirectly = function updateDirectly(data, offset, useBytes) {
|
|
13379
|
+
if (useBytes === void 0) useBytes = false;
|
|
13380
|
+
this.buffer.updateDirectly(data, offset, undefined, useBytes);
|
|
13381
|
+
};
|
|
13382
|
+
/**
|
|
13383
|
+
* @internal
|
|
13384
|
+
*/ _proto.rebuild = function rebuild() {
|
|
13385
|
+
this.buffer.rebuild();
|
|
13386
|
+
};
|
|
13387
|
+
_proto.dispose = function dispose() {
|
|
13388
|
+
if (this.ownsBuffer) {
|
|
13389
|
+
this.buffer.dispose();
|
|
13390
|
+
}
|
|
13391
|
+
this._isDisposed = true;
|
|
13392
|
+
};
|
|
13393
|
+
_create_class(VertexBuffer, [
|
|
13394
|
+
{
|
|
13395
|
+
key: "isDisposed",
|
|
13396
|
+
get: function get() {
|
|
13397
|
+
return this._isDisposed;
|
|
13398
|
+
}
|
|
13399
|
+
},
|
|
13400
|
+
{
|
|
13401
|
+
key: "instanceDivisor",
|
|
13402
|
+
get: function get() {
|
|
13403
|
+
return this._instanceDivisor;
|
|
13404
|
+
},
|
|
13405
|
+
set: function set(value) {
|
|
13406
|
+
this._instanceDivisor = value;
|
|
13407
|
+
this.instanced = value !== 0;
|
|
13408
|
+
}
|
|
13409
|
+
}
|
|
13410
|
+
]);
|
|
13411
|
+
return VertexBuffer;
|
|
13412
|
+
}();
|
|
13413
|
+
VertexBuffer.PositionKind = "aPos";
|
|
13414
|
+
VertexBuffer.NormalKind = "aNormal";
|
|
13415
|
+
VertexBuffer.TangentKind = "aTangent";
|
|
13416
|
+
VertexBuffer.UVKind = "aUV";
|
|
13417
|
+
VertexBuffer.UV2Kind = "aUV2";
|
|
13418
|
+
VertexBuffer.UV3Kind = "aUV3";
|
|
13419
|
+
VertexBuffer.UV4Kind = "aUV4";
|
|
13420
|
+
VertexBuffer.UV5Kind = "aUV5";
|
|
13421
|
+
VertexBuffer.UV6Kind = "aUV6";
|
|
13422
|
+
VertexBuffer.ColorKind = "aColor";
|
|
13423
|
+
VertexBuffer.JointsKind = "aJoints";
|
|
13424
|
+
VertexBuffer.WeightsKind = "aWeights";
|
|
13425
|
+
VertexBuffer.BYTE = exports.BufferDataType.Byte;
|
|
13426
|
+
VertexBuffer.UNSIGNED_BYTE = exports.BufferDataType.UnsignedByte;
|
|
13427
|
+
VertexBuffer.SHORT = exports.BufferDataType.Short;
|
|
13428
|
+
VertexBuffer.UNSIGNED_SHORT = exports.BufferDataType.UnsignedShort;
|
|
13429
|
+
VertexBuffer.INT = exports.BufferDataType.Int;
|
|
13430
|
+
VertexBuffer.UNSIGNED_INT = exports.BufferDataType.UnsignedInt;
|
|
13431
|
+
VertexBuffer.FLOAT = exports.BufferDataType.Float;
|
|
13432
|
+
|
|
13006
13433
|
exports.HitTestType = void 0;
|
|
13007
13434
|
(function(HitTestType) {
|
|
13008
13435
|
HitTestType[HitTestType["triangle"] = 1] = "triangle";
|
|
@@ -13325,7 +13752,7 @@ BoundingBox.tempVector2 = new Vector3();
|
|
|
13325
13752
|
};
|
|
13326
13753
|
_proto.geometryToTriangles = function geometryToTriangles(geometry) {
|
|
13327
13754
|
var indices = geometry.getIndexData();
|
|
13328
|
-
var vertices = geometry.getAttributeData(
|
|
13755
|
+
var vertices = geometry.getAttributeData(VertexBuffer.PositionKind);
|
|
13329
13756
|
var res = [];
|
|
13330
13757
|
if (!indices || !vertices) {
|
|
13331
13758
|
return res;
|
|
@@ -20028,310 +20455,6 @@ exports.CompositionComponent = __decorate([
|
|
|
20028
20455
|
effectsClass("CompositionComponent")
|
|
20029
20456
|
], exports.CompositionComponent);
|
|
20030
20457
|
|
|
20031
|
-
/**
|
|
20032
|
-
* Mesh 组件
|
|
20033
|
-
*/ var MeshComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
20034
|
-
_inherits(MeshComponent, RendererComponent);
|
|
20035
|
-
function MeshComponent(engine) {
|
|
20036
|
-
var _this;
|
|
20037
|
-
_this = RendererComponent.call(this, engine) || this;
|
|
20038
|
-
// TODO 点击测试后续抽象一个 Collider 组件
|
|
20039
|
-
_this.getHitTestParams = function(force) {
|
|
20040
|
-
var worldMatrix = _this.transform.getWorldMatrix();
|
|
20041
|
-
_this.boundingBoxInfo.setGeometry(_this.geometry, worldMatrix);
|
|
20042
|
-
var area = _this.boundingBoxInfo.getRawBoundingBoxTriangle();
|
|
20043
|
-
if (area) {
|
|
20044
|
-
return {
|
|
20045
|
-
type: area.type,
|
|
20046
|
-
triangles: area.area,
|
|
20047
|
-
clipMasks: _this.frameClipMasks
|
|
20048
|
-
};
|
|
20049
|
-
}
|
|
20050
|
-
};
|
|
20051
|
-
return _this;
|
|
20052
|
-
}
|
|
20053
|
-
var _proto = MeshComponent.prototype;
|
|
20054
|
-
_proto.render = function render(renderer) {
|
|
20055
|
-
this.maskManager.drawStencilMask(renderer, this);
|
|
20056
|
-
for(var i = 0; i < this.materials.length; i++){
|
|
20057
|
-
var material = this.materials[i];
|
|
20058
|
-
renderer.drawGeometry(this.geometry, this.transform.getWorldMatrix(), material, i);
|
|
20059
|
-
}
|
|
20060
|
-
};
|
|
20061
|
-
_proto.drawStencilMask = function drawStencilMask(maskRef) {
|
|
20062
|
-
if (!this.isActiveAndEnabled) {
|
|
20063
|
-
return;
|
|
20064
|
-
}
|
|
20065
|
-
for(var i = 0; i < this.materials.length; i++){
|
|
20066
|
-
var material = this.materials[i];
|
|
20067
|
-
this.maskManager.drawGeometryMask(this.engine.renderer, this.geometry, this.transform.getWorldMatrix(), material, maskRef, i);
|
|
20068
|
-
}
|
|
20069
|
-
};
|
|
20070
|
-
_proto.getBoundingBox = function getBoundingBox() {
|
|
20071
|
-
var worldMatrix = this.transform.getWorldMatrix();
|
|
20072
|
-
this.boundingBoxInfo.setGeometry(this.geometry, worldMatrix);
|
|
20073
|
-
var boundingBox = this.boundingBoxInfo.getBoundingBoxTriangle();
|
|
20074
|
-
return boundingBox;
|
|
20075
|
-
};
|
|
20076
|
-
_proto.getBoundingBoxInfo = function getBoundingBoxInfo() {
|
|
20077
|
-
var positionArray = this.geometry.getAttributeData("aPos");
|
|
20078
|
-
if (positionArray) {
|
|
20079
|
-
var minMaxResult = extractMinAndMax(positionArray, 0, positionArray.length / 3);
|
|
20080
|
-
minMaxResult.minimum.x *= this.transform.size.x;
|
|
20081
|
-
minMaxResult.minimum.y *= this.transform.size.y;
|
|
20082
|
-
minMaxResult.maximum.x *= this.transform.size.x;
|
|
20083
|
-
minMaxResult.maximum.y *= this.transform.size.y;
|
|
20084
|
-
this.boundingBoxInfo.reConstruct(minMaxResult.minimum, minMaxResult.maximum, this.transform.getWorldMatrix());
|
|
20085
|
-
}
|
|
20086
|
-
return this.boundingBoxInfo;
|
|
20087
|
-
};
|
|
20088
|
-
_proto.fromData = function fromData(data) {
|
|
20089
|
-
RendererComponent.prototype.fromData.call(this, data);
|
|
20090
|
-
var maskOptions = data.mask;
|
|
20091
|
-
if (maskOptions) {
|
|
20092
|
-
this.maskManager.setMaskOptions(this.engine, maskOptions);
|
|
20093
|
-
}
|
|
20094
|
-
};
|
|
20095
|
-
return MeshComponent;
|
|
20096
|
-
}(RendererComponent);
|
|
20097
|
-
__decorate([
|
|
20098
|
-
serialize()
|
|
20099
|
-
], MeshComponent.prototype, "geometry", void 0);
|
|
20100
|
-
|
|
20101
|
-
exports.EffectComponent = /*#__PURE__*/ function(MeshComponent) {
|
|
20102
|
-
_inherits(EffectComponent, MeshComponent);
|
|
20103
|
-
function EffectComponent(engine) {
|
|
20104
|
-
var _this;
|
|
20105
|
-
_this = MeshComponent.call(this, engine) || this;
|
|
20106
|
-
_this.time = 0;
|
|
20107
|
-
_this.name = "EffectComponent";
|
|
20108
|
-
return _this;
|
|
20109
|
-
}
|
|
20110
|
-
var _proto = EffectComponent.prototype;
|
|
20111
|
-
_proto.onStart = function onStart() {
|
|
20112
|
-
this.item.getHitTestParams = this.getHitTestParams;
|
|
20113
|
-
};
|
|
20114
|
-
_proto.onUpdate = function onUpdate(dt) {
|
|
20115
|
-
var time = this.time;
|
|
20116
|
-
var _this_material_getVector4;
|
|
20117
|
-
var _Time = (_this_material_getVector4 = this.material.getVector4("_Time")) != null ? _this_material_getVector4 : new Vector4();
|
|
20118
|
-
this.material.setVector4("_Time", _Time.set(time / 20, time, time * 2, time * 3));
|
|
20119
|
-
this.time += dt / 1000;
|
|
20120
|
-
};
|
|
20121
|
-
_proto.fromData = function fromData(data) {
|
|
20122
|
-
MeshComponent.prototype.fromData.call(this, data);
|
|
20123
|
-
this.material = this.materials[0];
|
|
20124
|
-
};
|
|
20125
|
-
return EffectComponent;
|
|
20126
|
-
}(MeshComponent);
|
|
20127
|
-
exports.EffectComponent = __decorate([
|
|
20128
|
-
effectsClass(DataType.EffectComponent)
|
|
20129
|
-
], exports.EffectComponent);
|
|
20130
|
-
|
|
20131
|
-
var tempVector3 = new Vector3(0, 0, 0);
|
|
20132
|
-
var tempVector3Second = new Vector3(0, 0, 0);
|
|
20133
|
-
var ConstraintTarget = function ConstraintTarget() {
|
|
20134
|
-
this.target = null;
|
|
20135
|
-
this.weight = 1.0;
|
|
20136
|
-
};
|
|
20137
|
-
exports.PositionConstraint = /*#__PURE__*/ function(Component) {
|
|
20138
|
-
_inherits(PositionConstraint, Component);
|
|
20139
|
-
function PositionConstraint() {
|
|
20140
|
-
var _this;
|
|
20141
|
-
_this = Component.apply(this, arguments) || this;
|
|
20142
|
-
/**
|
|
20143
|
-
* 初始位置(当前元素的初始世界位置)
|
|
20144
|
-
*/ _this.positionAtRest = new Vector3(0, 0, 0);
|
|
20145
|
-
/**
|
|
20146
|
-
* 位置偏移
|
|
20147
|
-
*/ _this.positionOffset = new Vector3(0, 0, 0);
|
|
20148
|
-
/**
|
|
20149
|
-
* 约束权重 (0-1)
|
|
20150
|
-
*/ _this.weight = 1.0;
|
|
20151
|
-
/**
|
|
20152
|
-
* 是否约束 X 轴
|
|
20153
|
-
*/ _this.constrainX = true;
|
|
20154
|
-
/**
|
|
20155
|
-
* 是否约束 Y 轴
|
|
20156
|
-
*/ _this.constrainY = true;
|
|
20157
|
-
/**
|
|
20158
|
-
* 是否约束 Z 轴
|
|
20159
|
-
*/ _this.constrainZ = true;
|
|
20160
|
-
/**
|
|
20161
|
-
* 约束目标
|
|
20162
|
-
*/ _this.targets = [];
|
|
20163
|
-
return _this;
|
|
20164
|
-
}
|
|
20165
|
-
var _proto = PositionConstraint.prototype;
|
|
20166
|
-
_proto.onStart = function onStart() {
|
|
20167
|
-
// 保存当前元素的初始世界位置
|
|
20168
|
-
var pos = this.item.transform.getWorldPosition();
|
|
20169
|
-
this.positionAtRest.copyFrom(pos);
|
|
20170
|
-
};
|
|
20171
|
-
_proto.onUpdate = function onUpdate(dt) {
|
|
20172
|
-
if (this.targets.length === 0) {
|
|
20173
|
-
return;
|
|
20174
|
-
}
|
|
20175
|
-
// 重置 tempVector3 用于计算融合位置
|
|
20176
|
-
tempVector3.set(0, 0, 0);
|
|
20177
|
-
var totalWeight = 0;
|
|
20178
|
-
// 计算所有目标的加权平均位置
|
|
20179
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(this.targets), _step; !(_step = _iterator()).done;){
|
|
20180
|
-
var constraintTarget = _step.value;
|
|
20181
|
-
if (constraintTarget.target) {
|
|
20182
|
-
var targetPos = constraintTarget.target.transform.getWorldPosition();
|
|
20183
|
-
var weight = constraintTarget.weight;
|
|
20184
|
-
tempVector3.x += targetPos.x * weight;
|
|
20185
|
-
tempVector3.y += targetPos.y * weight;
|
|
20186
|
-
tempVector3.z += targetPos.z * weight;
|
|
20187
|
-
totalWeight += weight;
|
|
20188
|
-
}
|
|
20189
|
-
}
|
|
20190
|
-
// 归一化加权位置
|
|
20191
|
-
if (totalWeight > 0) {
|
|
20192
|
-
tempVector3.x /= totalWeight;
|
|
20193
|
-
tempVector3.y /= totalWeight;
|
|
20194
|
-
tempVector3.z /= totalWeight;
|
|
20195
|
-
}
|
|
20196
|
-
// 应用偏移
|
|
20197
|
-
tempVector3.x += this.positionOffset.x;
|
|
20198
|
-
tempVector3.y += this.positionOffset.y;
|
|
20199
|
-
tempVector3.z += this.positionOffset.z;
|
|
20200
|
-
// 根据全局权重在初始位置和融合位置之间插值,结果存入 tempVector3Second
|
|
20201
|
-
tempVector3Second.set(this.lerp(this.positionAtRest.x, tempVector3.x, this.weight), this.lerp(this.positionAtRest.y, tempVector3.y, this.weight), this.lerp(this.positionAtRest.z, tempVector3.z, this.weight));
|
|
20202
|
-
// 应用轴约束,复用 tempVector3 存储当前位置
|
|
20203
|
-
tempVector3.copyFrom(this.item.transform.getWorldPosition());
|
|
20204
|
-
var finalX = this.constrainX ? tempVector3Second.x : tempVector3.x;
|
|
20205
|
-
var finalY = this.constrainY ? tempVector3Second.y : tempVector3.y;
|
|
20206
|
-
var finalZ = this.constrainZ ? tempVector3Second.z : tempVector3.z;
|
|
20207
|
-
// 设置新的世界位置
|
|
20208
|
-
this.item.transform.setWorldPosition(finalX, finalY, finalZ);
|
|
20209
|
-
};
|
|
20210
|
-
/**
|
|
20211
|
-
* 添加约束目标
|
|
20212
|
-
* @param target - 目标元素
|
|
20213
|
-
* @param weight - 权重值 (0-1)
|
|
20214
|
-
*/ _proto.addTarget = function addTarget(target, weight) {
|
|
20215
|
-
if (weight === void 0) weight = 1.0;
|
|
20216
|
-
var constraintTarget = new ConstraintTarget();
|
|
20217
|
-
constraintTarget.target = target;
|
|
20218
|
-
constraintTarget.weight = Math.max(0, Math.min(1, weight));
|
|
20219
|
-
this.targets.push(constraintTarget);
|
|
20220
|
-
};
|
|
20221
|
-
/**
|
|
20222
|
-
* 移除约束目标
|
|
20223
|
-
* @param target - 要移除的目标元素
|
|
20224
|
-
*/ _proto.removeTarget = function removeTarget(target) {
|
|
20225
|
-
var index = this.targets.findIndex(function(ct) {
|
|
20226
|
-
return ct.target === target;
|
|
20227
|
-
});
|
|
20228
|
-
if (index !== -1) {
|
|
20229
|
-
this.targets.splice(index, 1);
|
|
20230
|
-
}
|
|
20231
|
-
};
|
|
20232
|
-
/**
|
|
20233
|
-
* 清除所有约束目标
|
|
20234
|
-
*/ _proto.clearTargets = function clearTargets() {
|
|
20235
|
-
this.targets = [];
|
|
20236
|
-
};
|
|
20237
|
-
/**
|
|
20238
|
-
* 设置位置偏移
|
|
20239
|
-
* @param x - X 轴偏移
|
|
20240
|
-
* @param y - Y 轴偏移
|
|
20241
|
-
* @param z - Z 轴偏移
|
|
20242
|
-
*/ _proto.setPositionOffset = function setPositionOffset(x, y, z) {
|
|
20243
|
-
this.positionOffset.set(x, y, z);
|
|
20244
|
-
};
|
|
20245
|
-
/**
|
|
20246
|
-
* 设置全局约束权重
|
|
20247
|
-
* @param weight - 权重值 (0-1),0 表示保持初始位置,1 表示完全跟随目标
|
|
20248
|
-
*/ _proto.setWeight = function setWeight(weight) {
|
|
20249
|
-
this.weight = Math.max(0, Math.min(1, weight));
|
|
20250
|
-
};
|
|
20251
|
-
/**
|
|
20252
|
-
* 线性插值
|
|
20253
|
-
* @param start - 起始值
|
|
20254
|
-
* @param end - 结束值
|
|
20255
|
-
* @param t - 插值因子 (0-1)
|
|
20256
|
-
*/ _proto.lerp = function lerp(start, end, t) {
|
|
20257
|
-
return start + (end - start) * t;
|
|
20258
|
-
};
|
|
20259
|
-
_proto.fromData = function fromData(data) {
|
|
20260
|
-
Component.prototype.fromData.call(this, data);
|
|
20261
|
-
// Deserialize all properties
|
|
20262
|
-
this.positionAtRest.copyFrom(data.positionAtRest);
|
|
20263
|
-
this.positionOffset.copyFrom(data.positionOffset);
|
|
20264
|
-
this.weight = data.weight;
|
|
20265
|
-
this.constrainX = data.constrainX;
|
|
20266
|
-
this.constrainY = data.constrainY;
|
|
20267
|
-
this.constrainZ = data.constrainZ;
|
|
20268
|
-
this.targets = [];
|
|
20269
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(data.targets), _step; !(_step = _iterator()).done;){
|
|
20270
|
-
var targetData = _step.value;
|
|
20271
|
-
var constraintTarget = new ConstraintTarget();
|
|
20272
|
-
constraintTarget.target = this.engine.findObject(targetData.target);
|
|
20273
|
-
constraintTarget.weight = targetData.weight;
|
|
20274
|
-
this.targets.push(constraintTarget);
|
|
20275
|
-
}
|
|
20276
|
-
};
|
|
20277
|
-
return PositionConstraint;
|
|
20278
|
-
}(Component);
|
|
20279
|
-
exports.PositionConstraint = __decorate([
|
|
20280
|
-
effectsClass("PositionConstraint")
|
|
20281
|
-
], exports.PositionConstraint);
|
|
20282
|
-
|
|
20283
|
-
exports.PostProcessVolume = /*#__PURE__*/ function(Component) {
|
|
20284
|
-
_inherits(PostProcessVolume, Component);
|
|
20285
|
-
function PostProcessVolume(engine) {
|
|
20286
|
-
var _this;
|
|
20287
|
-
_this = Component.call(this, engine) || this;
|
|
20288
|
-
_this.bloom = {
|
|
20289
|
-
threshold: 0,
|
|
20290
|
-
intensity: 0,
|
|
20291
|
-
active: false
|
|
20292
|
-
};
|
|
20293
|
-
_this.vignette = {
|
|
20294
|
-
intensity: 0,
|
|
20295
|
-
smoothness: 0,
|
|
20296
|
-
roundness: 0,
|
|
20297
|
-
active: false
|
|
20298
|
-
};
|
|
20299
|
-
_this.tonemapping = {
|
|
20300
|
-
active: false
|
|
20301
|
-
};
|
|
20302
|
-
_this.colorAdjustments = {
|
|
20303
|
-
brightness: 0,
|
|
20304
|
-
saturation: 0,
|
|
20305
|
-
contrast: 0,
|
|
20306
|
-
active: false
|
|
20307
|
-
};
|
|
20308
|
-
return _this;
|
|
20309
|
-
}
|
|
20310
|
-
var _proto = PostProcessVolume.prototype;
|
|
20311
|
-
_proto.onStart = function onStart() {
|
|
20312
|
-
var composition = this.item.composition;
|
|
20313
|
-
if (composition) {
|
|
20314
|
-
composition.renderFrame.globalVolume = this;
|
|
20315
|
-
}
|
|
20316
|
-
};
|
|
20317
|
-
return PostProcessVolume;
|
|
20318
|
-
}(Component);
|
|
20319
|
-
__decorate([
|
|
20320
|
-
serialize()
|
|
20321
|
-
], exports.PostProcessVolume.prototype, "bloom", void 0);
|
|
20322
|
-
__decorate([
|
|
20323
|
-
serialize()
|
|
20324
|
-
], exports.PostProcessVolume.prototype, "vignette", void 0);
|
|
20325
|
-
__decorate([
|
|
20326
|
-
serialize()
|
|
20327
|
-
], exports.PostProcessVolume.prototype, "tonemapping", void 0);
|
|
20328
|
-
__decorate([
|
|
20329
|
-
serialize()
|
|
20330
|
-
], exports.PostProcessVolume.prototype, "colorAdjustments", void 0);
|
|
20331
|
-
exports.PostProcessVolume = __decorate([
|
|
20332
|
-
effectsClass(DataType.PostProcessVolume)
|
|
20333
|
-
], exports.PostProcessVolume);
|
|
20334
|
-
|
|
20335
20458
|
var EFFECTS_COPY_MESH_NAME = "effects-internal-copy";
|
|
20336
20459
|
var COPY_MESH_SHADER_ID = "effects-internal-copy-mesh";
|
|
20337
20460
|
var COPY_VERTEX_SHADER = "\nprecision highp float;\nattribute vec2 aPos;\nvarying vec2 vTex;\nvoid main(){\n gl_Position = vec4(aPos,0.,1.0);\n vTex = (aPos + vec2(1.0))/2.;\n}";
|
|
@@ -20657,45 +20780,574 @@ var DrawObjectPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
20657
20780
|
return DrawObjectPass;
|
|
20658
20781
|
}(RenderPass);
|
|
20659
20782
|
|
|
20660
|
-
var
|
|
20661
|
-
var BYTES_TYPE_MAP = (_obj$3 = {}, _obj$3[glContext.FLOAT] = Float32Array.BYTES_PER_ELEMENT, _obj$3[glContext.INT] = Int32Array.BYTES_PER_ELEMENT, _obj$3[glContext.SHORT] = Int16Array.BYTES_PER_ELEMENT, _obj$3[glContext.BYTE] = Int8Array.BYTES_PER_ELEMENT, _obj$3);
|
|
20783
|
+
var geometryId = 1;
|
|
20662
20784
|
/**
|
|
20663
|
-
*
|
|
20785
|
+
* 几何数据、属性布局和绘制范围的后端无关实现。
|
|
20664
20786
|
*/ var Geometry = /*#__PURE__*/ function(EffectsObject) {
|
|
20665
20787
|
_inherits(Geometry, EffectsObject);
|
|
20666
|
-
function Geometry() {
|
|
20788
|
+
function Geometry(engine, props) {
|
|
20667
20789
|
var _this;
|
|
20668
|
-
_this = EffectsObject.
|
|
20669
|
-
|
|
20670
|
-
|
|
20671
|
-
|
|
20672
|
-
/**
|
|
20673
|
-
|
|
20674
|
-
|
|
20790
|
+
_this = EffectsObject.call(this, engine) || this;
|
|
20791
|
+
_this.name = "";
|
|
20792
|
+
_this.subMeshes = [];
|
|
20793
|
+
/** @hide */ _this.mode = 4;
|
|
20794
|
+
/** @hide */ _this.instanceCount = 0;
|
|
20795
|
+
_this.vertexBuffers = {};
|
|
20796
|
+
_this.indices = new Uint16Array(0);
|
|
20797
|
+
_this.drawCount = 0;
|
|
20798
|
+
_this.drawStart = 0;
|
|
20799
|
+
_this.skin = {};
|
|
20800
|
+
_this.disposed = false;
|
|
20801
|
+
_this.initialized = false;
|
|
20802
|
+
_this.bufferUsage = exports.BufferUsage.Static;
|
|
20803
|
+
if (supportsVertexArrayObjects(engine)) {
|
|
20804
|
+
_this.vertexArrayObjects = {};
|
|
20805
|
+
}
|
|
20806
|
+
if (props) {
|
|
20807
|
+
_this.processProps(props);
|
|
20808
|
+
}
|
|
20675
20809
|
return _this;
|
|
20676
20810
|
}
|
|
20677
20811
|
var _proto = Geometry.prototype;
|
|
20812
|
+
/** @hide */ _proto.isDisposed = function isDisposed() {
|
|
20813
|
+
return this.disposed;
|
|
20814
|
+
};
|
|
20678
20815
|
/**
|
|
20679
|
-
*
|
|
20680
|
-
|
|
20681
|
-
|
|
20682
|
-
|
|
20816
|
+
* @internal
|
|
20817
|
+
*/ _proto.getOptions = function getOptions() {
|
|
20818
|
+
return this.options ? _extends({}, this.options) : undefined;
|
|
20819
|
+
};
|
|
20820
|
+
/** @hide */ _proto.getVertexBuffer = function getVertexBuffer(name) {
|
|
20821
|
+
return this.vertexBuffers[name];
|
|
20683
20822
|
};
|
|
20684
20823
|
/**
|
|
20685
|
-
*
|
|
20686
|
-
*/ _proto.
|
|
20687
|
-
|
|
20824
|
+
* @internal
|
|
20825
|
+
*/ _proto.getVertexBuffers = function getVertexBuffers() {
|
|
20826
|
+
return this.vertexBuffers;
|
|
20827
|
+
};
|
|
20828
|
+
/** @hide */ _proto.setVerticesBuffer = function setVerticesBuffer(vertexBuffer, disposeExistingBuffer) {
|
|
20829
|
+
if (disposeExistingBuffer === void 0) disposeExistingBuffer = true;
|
|
20830
|
+
var kind = vertexBuffer.getKind();
|
|
20831
|
+
var current = this.vertexBuffers[kind];
|
|
20832
|
+
if (current && disposeExistingBuffer) {
|
|
20833
|
+
current.dispose();
|
|
20834
|
+
}
|
|
20835
|
+
if (vertexBuffer.ownsBuffer) {
|
|
20836
|
+
vertexBuffer.buffer.increaseReferences();
|
|
20837
|
+
}
|
|
20838
|
+
this.vertexBuffers[kind] = vertexBuffer;
|
|
20839
|
+
this.disposeVertexArrayObjects();
|
|
20840
|
+
};
|
|
20841
|
+
/** @hide */ _proto.getAttributeBuffer = function getAttributeBuffer(name) {
|
|
20842
|
+
var _this_vertexBuffers_name;
|
|
20843
|
+
return (_this_vertexBuffers_name = this.vertexBuffers[name]) == null ? void 0 : _this_vertexBuffers_name.getWrapperBuffer();
|
|
20844
|
+
};
|
|
20845
|
+
_proto.getAttributeData = function getAttributeData(name) {
|
|
20846
|
+
var _this_vertexBuffers_name;
|
|
20847
|
+
return (_this_vertexBuffers_name = this.vertexBuffers[name]) == null ? void 0 : _this_vertexBuffers_name.getData();
|
|
20848
|
+
};
|
|
20849
|
+
_proto.setAttributeData = function setAttributeData(name, data) {
|
|
20850
|
+
var vertexBuffer = this.vertexBuffers[name];
|
|
20851
|
+
if (!vertexBuffer) {
|
|
20852
|
+
return;
|
|
20853
|
+
}
|
|
20854
|
+
vertexBuffer.update(data);
|
|
20855
|
+
this.disposeVertexArrayObjects();
|
|
20856
|
+
};
|
|
20857
|
+
_proto.setAttributeSubData = function setAttributeSubData(name, offset, data) {
|
|
20858
|
+
var vertexBuffer = this.vertexBuffers[name];
|
|
20859
|
+
if (!vertexBuffer) {
|
|
20860
|
+
return;
|
|
20861
|
+
}
|
|
20862
|
+
var buffer = vertexBuffer.getWrapperBuffer();
|
|
20863
|
+
var vertexCount = buffer.byteStride > 0 ? Math.ceil(data.byteLength / buffer.byteStride) : 0;
|
|
20864
|
+
buffer.updateDirectly(data, offset, vertexCount);
|
|
20865
|
+
this.disposeVertexArrayObjects();
|
|
20866
|
+
};
|
|
20867
|
+
_proto.getAttributeStride = function getAttributeStride(name) {
|
|
20868
|
+
var _this_vertexBuffers_name;
|
|
20869
|
+
var _this_vertexBuffers_name_byteStride;
|
|
20870
|
+
return (_this_vertexBuffers_name_byteStride = (_this_vertexBuffers_name = this.vertexBuffers[name]) == null ? void 0 : _this_vertexBuffers_name.byteStride) != null ? _this_vertexBuffers_name_byteStride : 0;
|
|
20871
|
+
};
|
|
20872
|
+
_proto.getAttributeNames = function getAttributeNames() {
|
|
20873
|
+
return Object.keys(this.vertexBuffers);
|
|
20874
|
+
};
|
|
20875
|
+
/** @hide */ _proto.getIndexBuffer = function getIndexBuffer() {
|
|
20876
|
+
return this.indexBuffer;
|
|
20877
|
+
};
|
|
20878
|
+
_proto.getIndexData = function getIndexData() {
|
|
20879
|
+
return this.indices;
|
|
20880
|
+
};
|
|
20881
|
+
/** @hide */ _proto.getIndexType = function getIndexType() {
|
|
20882
|
+
var _this_indexBuffer;
|
|
20883
|
+
return ((_this_indexBuffer = this.indexBuffer) == null ? void 0 : _this_indexBuffer.is32Bits) || shouldUse32Bits(this.indices) ? exports.BufferDataType.UnsignedInt : exports.BufferDataType.UnsignedShort;
|
|
20884
|
+
};
|
|
20885
|
+
_proto.setIndexData = function setIndexData(data) {
|
|
20886
|
+
if (!isIndexData(data)) {
|
|
20887
|
+
throw new TypeError("Index data must use a supported integer array.");
|
|
20888
|
+
}
|
|
20889
|
+
this.indices = Array.isArray(data) ? shouldUse32Bits(data) ? new Uint32Array(data) : new Uint16Array(data) : data;
|
|
20890
|
+
this.releaseIndexBuffer();
|
|
20891
|
+
this.disposeVertexArrayObjects();
|
|
20892
|
+
if (this.initialized) {
|
|
20893
|
+
this.createIndexBuffer();
|
|
20894
|
+
}
|
|
20895
|
+
};
|
|
20896
|
+
_proto.setIndexSubData = function setIndexSubData(offset, data) {
|
|
20897
|
+
var indices = this.indices;
|
|
20898
|
+
if (offset < 0 || offset + data.length > indices.length) {
|
|
20899
|
+
throw new RangeError("Buffer '" + this.name + "##index' update is out of range.");
|
|
20900
|
+
}
|
|
20901
|
+
indices.set(data, offset);
|
|
20902
|
+
if (this.indexBuffer) {
|
|
20903
|
+
var updatedData = indices.slice(offset, offset + data.length);
|
|
20904
|
+
this.engine.updateDynamicIndexBuffer(this.indexBuffer, updatedData, offset * (this.indexBuffer.is32Bits ? Uint32Array.BYTES_PER_ELEMENT : Uint16Array.BYTES_PER_ELEMENT));
|
|
20905
|
+
this.disposeVertexArrayObjects();
|
|
20906
|
+
}
|
|
20907
|
+
};
|
|
20908
|
+
_proto.setDrawStart = function setDrawStart(start) {
|
|
20909
|
+
this.drawStart = start;
|
|
20910
|
+
};
|
|
20911
|
+
_proto.getDrawStart = function getDrawStart() {
|
|
20912
|
+
return this.drawStart;
|
|
20913
|
+
};
|
|
20914
|
+
_proto.setDrawCount = function setDrawCount(count) {
|
|
20915
|
+
this.drawCount = count;
|
|
20916
|
+
};
|
|
20917
|
+
_proto.getDrawCount = function getDrawCount() {
|
|
20918
|
+
return this.drawCount;
|
|
20919
|
+
};
|
|
20920
|
+
_proto.getSkinProps = function getSkinProps() {
|
|
20921
|
+
return this.skin;
|
|
20922
|
+
};
|
|
20923
|
+
/** @hide */ _proto.bind = function bind(shader) {
|
|
20924
|
+
var vertexArrayObjects = this.vertexArrayObjects;
|
|
20925
|
+
var engine = this.engine;
|
|
20926
|
+
if (!vertexArrayObjects || !supportsVertexArrayObjects(engine)) {
|
|
20927
|
+
engine.bindBuffers(this.vertexBuffers, this.indexBuffer, shader);
|
|
20928
|
+
return;
|
|
20929
|
+
}
|
|
20930
|
+
var vertexArrayObject = vertexArrayObjects[shader.key];
|
|
20931
|
+
if (!vertexArrayObject) {
|
|
20932
|
+
vertexArrayObject = engine.recordVertexArrayObject(this.vertexBuffers, this.indexBuffer, shader);
|
|
20933
|
+
if (vertexArrayObject) {
|
|
20934
|
+
vertexArrayObjects[shader.key] = vertexArrayObject;
|
|
20935
|
+
}
|
|
20936
|
+
}
|
|
20937
|
+
if (vertexArrayObject) {
|
|
20938
|
+
engine.bindVertexArrayObject(vertexArrayObject, this.indexBuffer);
|
|
20939
|
+
} else {
|
|
20940
|
+
engine.bindBuffers(this.vertexBuffers, this.indexBuffer, shader);
|
|
20941
|
+
}
|
|
20942
|
+
};
|
|
20943
|
+
_proto.releaseVertexArrayObject = function releaseVertexArrayObject(key) {
|
|
20944
|
+
var vertexArrayObjects = this.vertexArrayObjects;
|
|
20945
|
+
if (!vertexArrayObjects) {
|
|
20946
|
+
return;
|
|
20947
|
+
}
|
|
20948
|
+
var vertexArrayObject = vertexArrayObjects[key];
|
|
20949
|
+
if (vertexArrayObject && hasVertexArrayObjectMethods(this.engine)) {
|
|
20950
|
+
this.engine.releaseVertexArrayObject(vertexArrayObject);
|
|
20951
|
+
}
|
|
20952
|
+
delete vertexArrayObjects[key];
|
|
20953
|
+
};
|
|
20954
|
+
_proto.initialize = function initialize() {
|
|
20955
|
+
if (this.initialized || this.disposed) {
|
|
20956
|
+
return;
|
|
20957
|
+
}
|
|
20958
|
+
this.forEachVertexBuffer(function(buffer) {
|
|
20959
|
+
buffer.create();
|
|
20960
|
+
});
|
|
20961
|
+
this.createIndexBuffer();
|
|
20962
|
+
this.engine.addGeometry(this);
|
|
20963
|
+
this.initialized = true;
|
|
20964
|
+
this.options = undefined;
|
|
20965
|
+
};
|
|
20966
|
+
_proto.flush = function flush() {
|
|
20967
|
+
if (this.disposed) {
|
|
20968
|
+
return;
|
|
20969
|
+
}
|
|
20970
|
+
this.initialize();
|
|
20971
|
+
this.forEachVertexBuffer(function(buffer) {
|
|
20972
|
+
return buffer.create();
|
|
20973
|
+
});
|
|
20974
|
+
};
|
|
20975
|
+
/** @hide */ _proto.restore = function restore() {
|
|
20976
|
+
if (!this.initialized || this.disposed) {
|
|
20977
|
+
return;
|
|
20978
|
+
}
|
|
20979
|
+
if (this.vertexArrayObjects) {
|
|
20980
|
+
this.vertexArrayObjects = {};
|
|
20981
|
+
}
|
|
20982
|
+
this.forEachVertexBuffer(function(buffer) {
|
|
20983
|
+
return buffer.rebuild();
|
|
20984
|
+
});
|
|
20985
|
+
if (this.indices.length > 0) {
|
|
20986
|
+
this.indexBuffer = undefined;
|
|
20987
|
+
this.createIndexBuffer();
|
|
20988
|
+
}
|
|
20989
|
+
};
|
|
20990
|
+
_proto.fromData = function fromData(data) {
|
|
20991
|
+
EffectsObject.prototype.fromData.call(this, data);
|
|
20992
|
+
this.subMeshes = data.subMeshes;
|
|
20993
|
+
var buffer;
|
|
20994
|
+
if (data.buffer) {
|
|
20995
|
+
buffer = new Uint8Array(decodeBase64ToArrayBuffer(data.buffer));
|
|
20996
|
+
} else if (data.binaryData) {
|
|
20997
|
+
buffer = data.binaryData;
|
|
20998
|
+
}
|
|
20999
|
+
if (!buffer) {
|
|
21000
|
+
return;
|
|
21001
|
+
}
|
|
21002
|
+
var vertexCount = data.vertexData.vertexCount;
|
|
21003
|
+
var props = {
|
|
21004
|
+
name: data.name,
|
|
21005
|
+
mode: 4,
|
|
21006
|
+
attributes: {}
|
|
21007
|
+
};
|
|
21008
|
+
if (hasSemantic(data)) {
|
|
21009
|
+
data.vertexData.channels.forEach(function(channel) {
|
|
21010
|
+
var _vertexBufferSemanticMap_channel_semantic;
|
|
21011
|
+
var attributeName = (_vertexBufferSemanticMap_channel_semantic = vertexBufferSemanticMap[channel.semantic]) != null ? _vertexBufferSemanticMap_channel_semantic : channel.semantic;
|
|
21012
|
+
props.attributes[attributeName] = {
|
|
21013
|
+
type: vertexFormatToDataType(channel.format),
|
|
21014
|
+
size: channel.dimension,
|
|
21015
|
+
data: createVertexTypedArray(channel, buffer, vertexCount),
|
|
21016
|
+
normalize: channel.normalize
|
|
21017
|
+
};
|
|
21018
|
+
});
|
|
21019
|
+
} else {
|
|
21020
|
+
var positionChannel = data.vertexData.channels[0];
|
|
21021
|
+
var uvChannel = data.vertexData.channels[1];
|
|
21022
|
+
var normalChannel = data.vertexData.channels[2];
|
|
21023
|
+
var _obj;
|
|
21024
|
+
props.attributes = (_obj = {}, _obj[VertexBuffer.PositionKind] = createAttributeFromChannel(positionChannel, buffer, vertexCount, 3), _obj[VertexBuffer.UVKind] = createAttributeFromChannel(uvChannel, buffer, vertexCount, 2), _obj[VertexBuffer.NormalKind] = createAttributeFromChannel(normalChannel, buffer, vertexCount, 3), _obj);
|
|
21025
|
+
}
|
|
21026
|
+
if (data.indexFormat !== IndexFormatType.None) {
|
|
21027
|
+
var indices = createIndexTypedArray(data.indexFormat, buffer, data.indexOffset);
|
|
21028
|
+
props.indices = {
|
|
21029
|
+
data: indices
|
|
21030
|
+
};
|
|
21031
|
+
props.drawCount = indices.length;
|
|
21032
|
+
} else {
|
|
21033
|
+
props.drawCount = vertexCount;
|
|
21034
|
+
}
|
|
21035
|
+
this.processProps(props);
|
|
21036
|
+
this.skin = {
|
|
21037
|
+
boneNames: data.boneNames,
|
|
21038
|
+
rootBoneName: data.rootBoneName,
|
|
21039
|
+
inverseBindMatrices: data.inverseBindMatrices
|
|
21040
|
+
};
|
|
21041
|
+
};
|
|
21042
|
+
_proto.dispose = function dispose() {
|
|
21043
|
+
var _this = this;
|
|
21044
|
+
if (this.disposed) {
|
|
21045
|
+
return;
|
|
21046
|
+
}
|
|
21047
|
+
this.disposeVertexArrayObjects();
|
|
21048
|
+
Object.keys(this.vertexBuffers).forEach(function(name) {
|
|
21049
|
+
return _this.vertexBuffers[name].dispose();
|
|
21050
|
+
});
|
|
21051
|
+
this.releaseIndexBuffer();
|
|
21052
|
+
this.vertexBuffers = {};
|
|
21053
|
+
this.indices = new Uint16Array(0);
|
|
21054
|
+
this.options = undefined;
|
|
21055
|
+
this.drawStart = 0;
|
|
21056
|
+
this.drawCount = 0;
|
|
21057
|
+
if (this.initialized) {
|
|
21058
|
+
this.engine.removeGeometry(this);
|
|
21059
|
+
}
|
|
21060
|
+
this.initialized = false;
|
|
21061
|
+
this.disposed = true;
|
|
21062
|
+
EffectsObject.prototype.dispose.call(this);
|
|
21063
|
+
};
|
|
21064
|
+
_proto.processProps = function processProps(props) {
|
|
21065
|
+
var _this = this;
|
|
21066
|
+
this.releaseCurrentBuffers();
|
|
21067
|
+
var _props_bufferUsage;
|
|
21068
|
+
var usage = (_props_bufferUsage = props.bufferUsage) != null ? _props_bufferUsage : exports.BufferUsage.Static;
|
|
21069
|
+
var sourceBuffers = {};
|
|
21070
|
+
var sourceDivisors = {};
|
|
21071
|
+
var sourceTypes = {};
|
|
21072
|
+
Object.keys(props.attributes).forEach(function(name) {
|
|
21073
|
+
var attribute = props.attributes[name];
|
|
21074
|
+
var source = "dataSource" in attribute ? attribute.dataSource : name;
|
|
21075
|
+
var _sourceDivisors_source, _attribute_instanceDivisor;
|
|
21076
|
+
sourceDivisors[source] = Math.max((_sourceDivisors_source = sourceDivisors[source]) != null ? _sourceDivisors_source : 0, (_attribute_instanceDivisor = attribute.instanceDivisor) != null ? _attribute_instanceDivisor : 0);
|
|
21077
|
+
});
|
|
21078
|
+
Object.keys(props.attributes).forEach(function(name) {
|
|
21079
|
+
var attribute = props.attributes[name];
|
|
21080
|
+
if ("dataSource" in attribute) {
|
|
21081
|
+
return;
|
|
21082
|
+
}
|
|
21083
|
+
var typedData = isTypedArray(attribute.data) ? attribute.data : undefined;
|
|
21084
|
+
var _attribute_type;
|
|
21085
|
+
var type = (_attribute_type = attribute.type) != null ? _attribute_type : typedData ? getDataType(typedData) : exports.BufferDataType.Float;
|
|
21086
|
+
var bytesPerElement = getBytesPerElement(type);
|
|
21087
|
+
var byteStride = attribute.stride || attribute.size * bytesPerElement;
|
|
21088
|
+
var data = typedData != null ? typedData : createTypedArray(type, 0);
|
|
21089
|
+
if (data.length === 0 && props.maxVertex && props.maxVertex > 0) {
|
|
21090
|
+
var elementStride = byteStride / bytesPerElement;
|
|
21091
|
+
data = createTypedArray(type, Math.ceil(props.maxVertex * elementStride));
|
|
21092
|
+
}
|
|
21093
|
+
var _sourceDivisors_name;
|
|
21094
|
+
var instanceDivisor = (_sourceDivisors_name = sourceDivisors[name]) != null ? _sourceDivisors_name : 0;
|
|
21095
|
+
sourceTypes[name] = type;
|
|
21096
|
+
sourceBuffers[name] = new Buffer(_this.engine, data, usage !== exports.BufferUsage.Static, byteStride, false, instanceDivisor > 0, true, instanceDivisor, name);
|
|
21097
|
+
});
|
|
21098
|
+
Object.keys(props.attributes).forEach(function(name) {
|
|
21099
|
+
var attribute = props.attributes[name];
|
|
21100
|
+
var source = "dataSource" in attribute ? attribute.dataSource : name;
|
|
21101
|
+
var buffer = sourceBuffers[source];
|
|
21102
|
+
if (!buffer) {
|
|
21103
|
+
throw new Error("Attribute '" + name + "' references missing data source '" + source + "'.");
|
|
21104
|
+
}
|
|
21105
|
+
var _attribute_type, _ref;
|
|
21106
|
+
var type = (_ref = (_attribute_type = attribute.type) != null ? _attribute_type : sourceTypes[source]) != null ? _ref : exports.BufferDataType.Float;
|
|
21107
|
+
var byteStride = attribute.stride || buffer.byteStride;
|
|
21108
|
+
var _attribute_instanceDivisor;
|
|
21109
|
+
var instanceDivisor = (_attribute_instanceDivisor = attribute.instanceDivisor) != null ? _attribute_instanceDivisor : 0;
|
|
21110
|
+
var _attribute_offset, _attribute_normalize;
|
|
21111
|
+
var vertexBuffer = new VertexBuffer(_this.engine, buffer, name, {
|
|
21112
|
+
size: attribute.size,
|
|
21113
|
+
type: type,
|
|
21114
|
+
stride: byteStride,
|
|
21115
|
+
offset: (_attribute_offset = attribute.offset) != null ? _attribute_offset : 0,
|
|
21116
|
+
normalized: (_attribute_normalize = attribute.normalize) != null ? _attribute_normalize : false,
|
|
21117
|
+
instanced: instanceDivisor > 0,
|
|
21118
|
+
divisor: instanceDivisor,
|
|
21119
|
+
useBytes: true,
|
|
21120
|
+
takeBufferOwnership: true
|
|
21121
|
+
});
|
|
21122
|
+
_this.setVerticesBuffer(vertexBuffer);
|
|
21123
|
+
});
|
|
21124
|
+
var _props_name;
|
|
21125
|
+
this.name = (_props_name = props.name) != null ? _props_name : "effectsGeometry:" + geometryId++;
|
|
21126
|
+
var _props_drawStart;
|
|
21127
|
+
this.drawStart = (_props_drawStart = props.drawStart) != null ? _props_drawStart : 0;
|
|
21128
|
+
var _props_drawCount;
|
|
21129
|
+
this.drawCount = (_props_drawCount = props.drawCount) != null ? _props_drawCount : 0;
|
|
21130
|
+
var _props_mode;
|
|
21131
|
+
this.mode = (_props_mode = props.mode) != null ? _props_mode : 4;
|
|
21132
|
+
var _props_instanceCount;
|
|
21133
|
+
this.instanceCount = (_props_instanceCount = props.instanceCount) != null ? _props_instanceCount : 0;
|
|
21134
|
+
this.bufferUsage = usage;
|
|
21135
|
+
this.options = props;
|
|
21136
|
+
if (props.indices) {
|
|
21137
|
+
var data = props.indices.data;
|
|
21138
|
+
if (!isIndexData(data)) {
|
|
21139
|
+
throw new TypeError("Index data must use a supported integer array.");
|
|
21140
|
+
}
|
|
21141
|
+
// 索引还会参与 CPU 侧的命中检测和几何查询,因此始终保留源数据。
|
|
21142
|
+
this.indices = Array.isArray(data) ? shouldUse32Bits(data) ? new Uint32Array(data) : new Uint16Array(data) : data;
|
|
21143
|
+
}
|
|
21144
|
+
this.disposeVertexArrayObjects();
|
|
21145
|
+
};
|
|
21146
|
+
_proto.releaseCurrentBuffers = function releaseCurrentBuffers() {
|
|
21147
|
+
var _this = this;
|
|
21148
|
+
var wasInitialized = this.initialized;
|
|
21149
|
+
this.disposeVertexArrayObjects();
|
|
21150
|
+
Object.keys(this.vertexBuffers).forEach(function(name) {
|
|
21151
|
+
return _this.vertexBuffers[name].dispose();
|
|
21152
|
+
});
|
|
21153
|
+
this.releaseIndexBuffer();
|
|
21154
|
+
this.vertexBuffers = {};
|
|
21155
|
+
this.indices = new Uint16Array(0);
|
|
21156
|
+
if (wasInitialized) {
|
|
21157
|
+
this.engine.removeGeometry(this);
|
|
21158
|
+
this.initialized = false;
|
|
21159
|
+
}
|
|
21160
|
+
};
|
|
21161
|
+
_proto.disposeVertexArrayObjects = function disposeVertexArrayObjects() {
|
|
21162
|
+
var _this = this;
|
|
21163
|
+
var vertexArrayObjects = this.vertexArrayObjects;
|
|
21164
|
+
if (!vertexArrayObjects) {
|
|
21165
|
+
return;
|
|
21166
|
+
}
|
|
21167
|
+
Object.keys(vertexArrayObjects).forEach(function(key) {
|
|
21168
|
+
var vertexArrayObject = vertexArrayObjects[key];
|
|
21169
|
+
if (vertexArrayObject && hasVertexArrayObjectMethods(_this.engine)) {
|
|
21170
|
+
_this.engine.releaseVertexArrayObject(vertexArrayObject);
|
|
21171
|
+
}
|
|
21172
|
+
});
|
|
21173
|
+
this.vertexArrayObjects = {};
|
|
21174
|
+
};
|
|
21175
|
+
_proto.createIndexBuffer = function createIndexBuffer() {
|
|
21176
|
+
var indices = this.indices;
|
|
21177
|
+
if (indices.length === 0 || this.indexBuffer) {
|
|
21178
|
+
return;
|
|
21179
|
+
}
|
|
21180
|
+
this.indexBuffer = this.engine.createIndexBuffer(indices, {
|
|
21181
|
+
usage: this.bufferUsage,
|
|
21182
|
+
type: this.getIndexType(),
|
|
21183
|
+
byteStride: 0,
|
|
21184
|
+
instanceDivisor: 0,
|
|
21185
|
+
label: "" + this.name + "##index"
|
|
21186
|
+
});
|
|
21187
|
+
};
|
|
21188
|
+
_proto.releaseIndexBuffer = function releaseIndexBuffer() {
|
|
21189
|
+
if (!this.indexBuffer) {
|
|
21190
|
+
return;
|
|
21191
|
+
}
|
|
21192
|
+
this.engine.releaseBuffer(this.indexBuffer);
|
|
21193
|
+
this.indexBuffer = undefined;
|
|
20688
21194
|
};
|
|
21195
|
+
_proto.forEachVertexBuffer = function forEachVertexBuffer(callback) {
|
|
21196
|
+
var _this = this;
|
|
21197
|
+
var visited = new Set();
|
|
21198
|
+
Object.keys(this.vertexBuffers).forEach(function(name) {
|
|
21199
|
+
var buffer = _this.vertexBuffers[name].getWrapperBuffer();
|
|
21200
|
+
if (!visited.has(buffer)) {
|
|
21201
|
+
visited.add(buffer);
|
|
21202
|
+
callback(buffer);
|
|
21203
|
+
}
|
|
21204
|
+
});
|
|
21205
|
+
};
|
|
21206
|
+
_create_class(Geometry, [
|
|
21207
|
+
{
|
|
21208
|
+
key: "isInitialized",
|
|
21209
|
+
get: /**
|
|
21210
|
+
* @internal
|
|
21211
|
+
*/ function get() {
|
|
21212
|
+
return this.initialized;
|
|
21213
|
+
}
|
|
21214
|
+
}
|
|
21215
|
+
]);
|
|
20689
21216
|
return Geometry;
|
|
20690
21217
|
}(EffectsObject);
|
|
20691
|
-
function
|
|
20692
|
-
|
|
20693
|
-
|
|
21218
|
+
Geometry.create = function(engine, props) {
|
|
21219
|
+
return new Geometry(engine, props);
|
|
21220
|
+
};
|
|
21221
|
+
function isTypedArray(value) {
|
|
21222
|
+
return ArrayBuffer.isView(value) && !_instanceof1(value, DataView);
|
|
21223
|
+
}
|
|
21224
|
+
function hasVertexArrayObjectMethods(engine) {
|
|
21225
|
+
var candidate = engine;
|
|
21226
|
+
return typeof candidate.recordVertexArrayObject === "function" && typeof candidate.bindVertexArrayObject === "function" && typeof candidate.releaseVertexArrayObject === "function";
|
|
21227
|
+
}
|
|
21228
|
+
function supportsVertexArrayObjects(engine) {
|
|
21229
|
+
var _engine_gpuCapability;
|
|
21230
|
+
return ((_engine_gpuCapability = engine.gpuCapability) == null ? void 0 : _engine_gpuCapability.detail.vertexArrayObject) === true && hasVertexArrayObjectMethods(engine);
|
|
21231
|
+
}
|
|
21232
|
+
function isIndexData(data) {
|
|
21233
|
+
return Array.isArray(data) || _instanceof1(data, Int32Array) || _instanceof1(data, Uint16Array) || _instanceof1(data, Uint32Array);
|
|
21234
|
+
}
|
|
21235
|
+
function shouldUse32Bits(data) {
|
|
21236
|
+
if (_instanceof1(data, Uint32Array)) {
|
|
21237
|
+
return true;
|
|
20694
21238
|
}
|
|
20695
|
-
if (
|
|
20696
|
-
return
|
|
21239
|
+
if (_instanceof1(data, Uint16Array)) {
|
|
21240
|
+
return false;
|
|
21241
|
+
}
|
|
21242
|
+
for(var i = 0; i < data.length; i++){
|
|
21243
|
+
if (data[i] >= 65535) {
|
|
21244
|
+
return true;
|
|
21245
|
+
}
|
|
21246
|
+
}
|
|
21247
|
+
return false;
|
|
21248
|
+
}
|
|
21249
|
+
function createAttributeFromChannel(channel, buffer, vertexCount, size) {
|
|
21250
|
+
return {
|
|
21251
|
+
type: vertexFormatToDataType(channel.format),
|
|
21252
|
+
size: size,
|
|
21253
|
+
data: createVertexTypedArray(channel, buffer, vertexCount),
|
|
21254
|
+
normalize: channel.normalize
|
|
21255
|
+
};
|
|
21256
|
+
}
|
|
21257
|
+
function createVertexTypedArray(channel, baseBuffer, vertexCount) {
|
|
21258
|
+
var arrayBuffer = baseBuffer.buffer;
|
|
21259
|
+
var byteOffset = baseBuffer.byteOffset + channel.offset;
|
|
21260
|
+
var length = channel.dimension * vertexCount;
|
|
21261
|
+
switch(channel.format){
|
|
21262
|
+
case VertexFormatType.Float32:
|
|
21263
|
+
return new Float32Array(arrayBuffer, byteOffset, length);
|
|
21264
|
+
case VertexFormatType.Int16:
|
|
21265
|
+
return new Int16Array(arrayBuffer, byteOffset, length);
|
|
21266
|
+
case VertexFormatType.Int8:
|
|
21267
|
+
return new Int8Array(arrayBuffer, byteOffset, length);
|
|
21268
|
+
case VertexFormatType.UInt16:
|
|
21269
|
+
return new Uint16Array(arrayBuffer, byteOffset, length);
|
|
21270
|
+
case VertexFormatType.UInt8:
|
|
21271
|
+
return new Uint8Array(arrayBuffer, byteOffset, length);
|
|
21272
|
+
default:
|
|
21273
|
+
throw new Error("Unsupported vertex format: " + channel.format + ".");
|
|
21274
|
+
}
|
|
21275
|
+
}
|
|
21276
|
+
function createIndexTypedArray(type, baseBuffer, offset) {
|
|
21277
|
+
var arrayBuffer = baseBuffer.buffer;
|
|
21278
|
+
var byteOffset = baseBuffer.byteOffset + offset;
|
|
21279
|
+
var byteLength = baseBuffer.byteLength - offset;
|
|
21280
|
+
switch(type){
|
|
21281
|
+
case IndexFormatType.UInt16:
|
|
21282
|
+
return new Uint16Array(arrayBuffer, byteOffset, byteLength / Uint16Array.BYTES_PER_ELEMENT);
|
|
21283
|
+
case IndexFormatType.UInt32:
|
|
21284
|
+
return new Uint32Array(arrayBuffer, byteOffset, byteLength / Uint32Array.BYTES_PER_ELEMENT);
|
|
21285
|
+
default:
|
|
21286
|
+
throw new Error("Unsupported index format: " + type + ".");
|
|
21287
|
+
}
|
|
21288
|
+
}
|
|
21289
|
+
function vertexFormatToDataType(format) {
|
|
21290
|
+
switch(format){
|
|
21291
|
+
case VertexFormatType.Float32:
|
|
21292
|
+
return exports.BufferDataType.Float;
|
|
21293
|
+
case VertexFormatType.Int16:
|
|
21294
|
+
return exports.BufferDataType.Short;
|
|
21295
|
+
case VertexFormatType.Int8:
|
|
21296
|
+
return exports.BufferDataType.Byte;
|
|
21297
|
+
case VertexFormatType.UInt16:
|
|
21298
|
+
return exports.BufferDataType.UnsignedShort;
|
|
21299
|
+
case VertexFormatType.UInt8:
|
|
21300
|
+
return exports.BufferDataType.UnsignedByte;
|
|
21301
|
+
default:
|
|
21302
|
+
throw new Error("Unsupported vertex format: " + format + ".");
|
|
20697
21303
|
}
|
|
20698
|
-
|
|
21304
|
+
}
|
|
21305
|
+
function hasSemantic(data) {
|
|
21306
|
+
return data.vertexData.channels.some(function(channel) {
|
|
21307
|
+
return !!channel.semantic;
|
|
21308
|
+
});
|
|
21309
|
+
}
|
|
21310
|
+
function decodeBase64ToArrayBuffer(value) {
|
|
21311
|
+
var binary = atob(value);
|
|
21312
|
+
var bytes = new Uint8Array(binary.length);
|
|
21313
|
+
for(var i = 0; i < binary.length; i++){
|
|
21314
|
+
bytes[i] = binary.charCodeAt(i);
|
|
21315
|
+
}
|
|
21316
|
+
return bytes.buffer;
|
|
21317
|
+
}
|
|
21318
|
+
var vertexBufferSemanticMap = {
|
|
21319
|
+
POSITION: VertexBuffer.PositionKind,
|
|
21320
|
+
TEXCOORD0: VertexBuffer.UVKind,
|
|
21321
|
+
TEXCOORD_0: VertexBuffer.UVKind,
|
|
21322
|
+
TEXCOORD1: VertexBuffer.UV2Kind,
|
|
21323
|
+
NORMAL: VertexBuffer.NormalKind,
|
|
21324
|
+
TANGENT: VertexBuffer.TangentKind,
|
|
21325
|
+
COLOR: VertexBuffer.ColorKind,
|
|
21326
|
+
JOINTS: VertexBuffer.JointsKind,
|
|
21327
|
+
JOINTS_0: VertexBuffer.JointsKind,
|
|
21328
|
+
WEIGHTS: VertexBuffer.WeightsKind,
|
|
21329
|
+
WEIGHTS_0: VertexBuffer.WeightsKind,
|
|
21330
|
+
POSITION_BS0: "aTargetPosition0",
|
|
21331
|
+
POSITION_BS1: "aTargetPosition1",
|
|
21332
|
+
POSITION_BS2: "aTargetPosition2",
|
|
21333
|
+
POSITION_BS3: "aTargetPosition3",
|
|
21334
|
+
POSITION_BS4: "aTargetPosition4",
|
|
21335
|
+
POSITION_BS5: "aTargetPosition5",
|
|
21336
|
+
POSITION_BS6: "aTargetPosition6",
|
|
21337
|
+
POSITION_BS7: "aTargetPosition7",
|
|
21338
|
+
NORMAL_BS0: "aTargetNormal0",
|
|
21339
|
+
NORMAL_BS1: "aTargetNormal1",
|
|
21340
|
+
NORMAL_BS2: "aTargetNormal2",
|
|
21341
|
+
NORMAL_BS3: "aTargetNormal3",
|
|
21342
|
+
TANGENT_BS0: "aTargetTangent0",
|
|
21343
|
+
TANGENT_BS1: "aTargetTangent1",
|
|
21344
|
+
TANGENT_BS2: "aTargetTangent2",
|
|
21345
|
+
TANGENT_BS3: "aTargetTangent3"
|
|
21346
|
+
};
|
|
21347
|
+
var _obj$3;
|
|
21348
|
+
var BYTES_TYPE_MAP = (_obj$3 = {}, _obj$3[exports.BufferDataType.Float] = 4, _obj$3[exports.BufferDataType.Int] = 4, _obj$3[exports.BufferDataType.UnsignedInt] = 4, _obj$3[exports.BufferDataType.Short] = 2, _obj$3[exports.BufferDataType.UnsignedShort] = 2, _obj$3[exports.BufferDataType.Byte] = 1, _obj$3[exports.BufferDataType.UnsignedByte] = 1, _obj$3);
|
|
21349
|
+
function generateEmptyTypedArray(type) {
|
|
21350
|
+
return createTypedArray(type, 0);
|
|
20699
21351
|
}
|
|
20700
21352
|
|
|
20701
21353
|
var seed$5 = 1;
|
|
@@ -21110,25 +21762,24 @@ var ToneMappingPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
21110
21762
|
var name = "PostProcess";
|
|
21111
21763
|
var engine = _this.renderer.engine;
|
|
21112
21764
|
_this.sceneTextureHandle = sceneTextureHandle ? sceneTextureHandle : new RenderTargetHandle(engine);
|
|
21765
|
+
var _obj;
|
|
21113
21766
|
var geometry = Geometry.create(engine, {
|
|
21114
21767
|
name: name,
|
|
21115
21768
|
mode: glContext.TRIANGLE_STRIP,
|
|
21116
|
-
attributes: {
|
|
21117
|
-
|
|
21118
|
-
|
|
21119
|
-
|
|
21120
|
-
|
|
21121
|
-
|
|
21122
|
-
|
|
21123
|
-
|
|
21124
|
-
|
|
21125
|
-
|
|
21126
|
-
|
|
21127
|
-
|
|
21128
|
-
|
|
21129
|
-
|
|
21130
|
-
}
|
|
21131
|
-
},
|
|
21769
|
+
attributes: (_obj = {}, _obj[VertexBuffer.PositionKind] = {
|
|
21770
|
+
type: glContext.FLOAT,
|
|
21771
|
+
size: 2,
|
|
21772
|
+
data: new Float32Array([
|
|
21773
|
+
-1,
|
|
21774
|
+
1,
|
|
21775
|
+
-1,
|
|
21776
|
+
-1,
|
|
21777
|
+
1,
|
|
21778
|
+
1,
|
|
21779
|
+
1,
|
|
21780
|
+
-1
|
|
21781
|
+
])
|
|
21782
|
+
}, _obj),
|
|
21132
21783
|
drawCount: 4
|
|
21133
21784
|
});
|
|
21134
21785
|
var material = Material.create(engine, {
|
|
@@ -21558,6 +22209,7 @@ var GPUCapability = /*#__PURE__*/ function() {
|
|
|
21558
22209
|
maxTextureAnisotropy: textureAnisotropicExt ? gl.getParameter(textureAnisotropicExt.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : 0,
|
|
21559
22210
|
shaderTextureLod: level2 || !!gl.getExtension("EXT_shader_texture_lod"),
|
|
21560
22211
|
instanceDraw: level2 || !!gl.getExtension("ANGLE_instanced_arrays"),
|
|
22212
|
+
vertexArrayObject: level2 || !!this.vaoExt,
|
|
21561
22213
|
ktx2Support: detectKTX2Support(this.compressTextureCapabilityList),
|
|
21562
22214
|
drawBuffers: level2 || !!this.drawBufferExtension,
|
|
21563
22215
|
asyncShaderCompile: !!this.glAsyncCompileExt,
|
|
@@ -21782,24 +22434,23 @@ var Renderer = /*#__PURE__*/ function() {
|
|
|
21782
22434
|
*/ _proto.blit = function blit(source, destination, material) {
|
|
21783
22435
|
// 懒加载创建 blit geometry
|
|
21784
22436
|
if (!this.blitGeometry) {
|
|
22437
|
+
var _obj;
|
|
21785
22438
|
this.blitGeometry = Geometry.create(this.engine, {
|
|
21786
22439
|
mode: glContext.TRIANGLE_STRIP,
|
|
21787
|
-
attributes: {
|
|
21788
|
-
|
|
21789
|
-
|
|
21790
|
-
|
|
21791
|
-
|
|
21792
|
-
|
|
21793
|
-
|
|
21794
|
-
|
|
21795
|
-
|
|
21796
|
-
|
|
21797
|
-
|
|
21798
|
-
|
|
21799
|
-
|
|
21800
|
-
|
|
21801
|
-
}
|
|
21802
|
-
},
|
|
22440
|
+
attributes: (_obj = {}, _obj[VertexBuffer.PositionKind] = {
|
|
22441
|
+
type: glContext.FLOAT,
|
|
22442
|
+
size: 2,
|
|
22443
|
+
data: new Float32Array([
|
|
22444
|
+
-1,
|
|
22445
|
+
1,
|
|
22446
|
+
-1,
|
|
22447
|
+
-1,
|
|
22448
|
+
1,
|
|
22449
|
+
1,
|
|
22450
|
+
1,
|
|
22451
|
+
-1
|
|
22452
|
+
])
|
|
22453
|
+
}, _obj),
|
|
21803
22454
|
drawCount: 4
|
|
21804
22455
|
});
|
|
21805
22456
|
}
|
|
@@ -22271,61 +22922,57 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
22271
22922
|
this.currentBatchTexture = null;
|
|
22272
22923
|
this.transformStack = [];
|
|
22273
22924
|
this.currentTransform = Matrix3.fromIdentity();
|
|
22925
|
+
var _obj;
|
|
22274
22926
|
this.geometry = Geometry.create(this.engine, {
|
|
22275
|
-
attributes: {
|
|
22276
|
-
|
|
22277
|
-
|
|
22278
|
-
|
|
22279
|
-
|
|
22280
|
-
|
|
22281
|
-
|
|
22282
|
-
|
|
22283
|
-
|
|
22284
|
-
|
|
22285
|
-
|
|
22286
|
-
|
|
22287
|
-
|
|
22288
|
-
|
|
22289
|
-
|
|
22290
|
-
|
|
22291
|
-
|
|
22292
|
-
|
|
22293
|
-
|
|
22294
|
-
|
|
22295
|
-
|
|
22296
|
-
|
|
22297
|
-
|
|
22298
|
-
|
|
22299
|
-
|
|
22300
|
-
|
|
22301
|
-
|
|
22302
|
-
|
|
22303
|
-
|
|
22304
|
-
|
|
22305
|
-
|
|
22306
|
-
|
|
22307
|
-
|
|
22308
|
-
|
|
22309
|
-
|
|
22310
|
-
|
|
22311
|
-
|
|
22312
|
-
|
|
22313
|
-
|
|
22314
|
-
|
|
22315
|
-
|
|
22316
|
-
|
|
22317
|
-
|
|
22318
|
-
|
|
22319
|
-
|
|
22320
|
-
|
|
22321
|
-
|
|
22322
|
-
|
|
22323
|
-
|
|
22324
|
-
1,
|
|
22325
|
-
0
|
|
22326
|
-
])
|
|
22327
|
-
}
|
|
22328
|
-
},
|
|
22927
|
+
attributes: (_obj = {}, _obj[VertexBuffer.PositionKind] = {
|
|
22928
|
+
type: glContext.FLOAT,
|
|
22929
|
+
size: 2,
|
|
22930
|
+
data: new Float32Array([
|
|
22931
|
+
-0.5,
|
|
22932
|
+
0.5,
|
|
22933
|
+
-0.5,
|
|
22934
|
+
-0.5,
|
|
22935
|
+
0.5,
|
|
22936
|
+
0.5,
|
|
22937
|
+
0.5,
|
|
22938
|
+
-0.5
|
|
22939
|
+
])
|
|
22940
|
+
}, _obj[VertexBuffer.ColorKind] = {
|
|
22941
|
+
type: glContext.FLOAT,
|
|
22942
|
+
size: 4,
|
|
22943
|
+
data: new Float32Array([
|
|
22944
|
+
1,
|
|
22945
|
+
1,
|
|
22946
|
+
1,
|
|
22947
|
+
1,
|
|
22948
|
+
1,
|
|
22949
|
+
1,
|
|
22950
|
+
1,
|
|
22951
|
+
1,
|
|
22952
|
+
1,
|
|
22953
|
+
1,
|
|
22954
|
+
1,
|
|
22955
|
+
1,
|
|
22956
|
+
1,
|
|
22957
|
+
1,
|
|
22958
|
+
1,
|
|
22959
|
+
1
|
|
22960
|
+
])
|
|
22961
|
+
}, _obj[VertexBuffer.UVKind] = {
|
|
22962
|
+
size: 2,
|
|
22963
|
+
offset: 0,
|
|
22964
|
+
type: glContext.FLOAT,
|
|
22965
|
+
data: new Float32Array([
|
|
22966
|
+
0,
|
|
22967
|
+
1,
|
|
22968
|
+
0,
|
|
22969
|
+
0,
|
|
22970
|
+
1,
|
|
22971
|
+
1,
|
|
22972
|
+
1,
|
|
22973
|
+
0
|
|
22974
|
+
])
|
|
22975
|
+
}, _obj),
|
|
22329
22976
|
indices: {
|
|
22330
22977
|
data: new Uint16Array([
|
|
22331
22978
|
0,
|
|
@@ -22334,11 +22981,11 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
22334
22981
|
2,
|
|
22335
22982
|
1,
|
|
22336
22983
|
3
|
|
22337
|
-
])
|
|
22338
|
-
releasable: true
|
|
22984
|
+
])
|
|
22339
22985
|
},
|
|
22340
22986
|
mode: glContext.TRIANGLES,
|
|
22341
|
-
drawCount: 6
|
|
22987
|
+
drawCount: 6,
|
|
22988
|
+
bufferUsage: glContext.DYNAMIC_DRAW
|
|
22342
22989
|
});
|
|
22343
22990
|
this.coloredMaterial = Material.create(this.engine, {
|
|
22344
22991
|
shader: {
|
|
@@ -22426,9 +23073,9 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
22426
23073
|
var colorsArray = new Float32Array(this.colors);
|
|
22427
23074
|
var uvsArray = new Float32Array(this.uvs);
|
|
22428
23075
|
var indicesArray = new Uint16Array(this.indices);
|
|
22429
|
-
this.
|
|
22430
|
-
this.
|
|
22431
|
-
this.
|
|
23076
|
+
this.updateAttributeData(VertexBuffer.PositionKind, verticesArray, 2);
|
|
23077
|
+
this.updateAttributeData(VertexBuffer.ColorKind, colorsArray, 4);
|
|
23078
|
+
this.updateAttributeData(VertexBuffer.UVKind, uvsArray, 2);
|
|
22432
23079
|
this.geometry.setIndexData(indicesArray);
|
|
22433
23080
|
this.geometry.setDrawCount(this.currentIndexCount);
|
|
22434
23081
|
var material;
|
|
@@ -22446,6 +23093,18 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
22446
23093
|
this.colors.length = 0;
|
|
22447
23094
|
this.uvs.length = 0;
|
|
22448
23095
|
};
|
|
23096
|
+
_proto.updateAttributeData = function updateAttributeData(name, data, size) {
|
|
23097
|
+
var _this_geometry_getVertexBuffer;
|
|
23098
|
+
var dataBuffer = (_this_geometry_getVertexBuffer = this.geometry.getVertexBuffer(name)) == null ? void 0 : _this_geometry_getVertexBuffer.getBuffer();
|
|
23099
|
+
if (dataBuffer && data.byteLength > dataBuffer.capacity) {
|
|
23100
|
+
this.geometry.setVerticesBuffer(new VertexBuffer(this.engine, data, name, {
|
|
23101
|
+
updatable: true,
|
|
23102
|
+
size: size
|
|
23103
|
+
}));
|
|
23104
|
+
return;
|
|
23105
|
+
}
|
|
23106
|
+
this.geometry.setAttributeData(name, data);
|
|
23107
|
+
};
|
|
22449
23108
|
/**
|
|
22450
23109
|
* 线段顶点按顺序连接 (p0-p1, p1-p2, p2-p3, ...)
|
|
22451
23110
|
* @param points - 点数组,格式 [x1,y1,x2,y2,...],至少需要2个点(4个数值)
|
|
@@ -22815,6 +23474,310 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
22815
23474
|
return Graphics;
|
|
22816
23475
|
}();
|
|
22817
23476
|
|
|
23477
|
+
/**
|
|
23478
|
+
* Mesh 组件
|
|
23479
|
+
*/ var MeshComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
23480
|
+
_inherits(MeshComponent, RendererComponent);
|
|
23481
|
+
function MeshComponent(engine) {
|
|
23482
|
+
var _this;
|
|
23483
|
+
_this = RendererComponent.call(this, engine) || this;
|
|
23484
|
+
// TODO 点击测试后续抽象一个 Collider 组件
|
|
23485
|
+
_this.getHitTestParams = function(force) {
|
|
23486
|
+
var worldMatrix = _this.transform.getWorldMatrix();
|
|
23487
|
+
_this.boundingBoxInfo.setGeometry(_this.geometry, worldMatrix);
|
|
23488
|
+
var area = _this.boundingBoxInfo.getRawBoundingBoxTriangle();
|
|
23489
|
+
if (area) {
|
|
23490
|
+
return {
|
|
23491
|
+
type: area.type,
|
|
23492
|
+
triangles: area.area,
|
|
23493
|
+
clipMasks: _this.frameClipMasks
|
|
23494
|
+
};
|
|
23495
|
+
}
|
|
23496
|
+
};
|
|
23497
|
+
return _this;
|
|
23498
|
+
}
|
|
23499
|
+
var _proto = MeshComponent.prototype;
|
|
23500
|
+
_proto.render = function render(renderer) {
|
|
23501
|
+
this.maskManager.drawStencilMask(renderer, this);
|
|
23502
|
+
for(var i = 0; i < this.materials.length; i++){
|
|
23503
|
+
var material = this.materials[i];
|
|
23504
|
+
renderer.drawGeometry(this.geometry, this.transform.getWorldMatrix(), material, i);
|
|
23505
|
+
}
|
|
23506
|
+
};
|
|
23507
|
+
_proto.drawStencilMask = function drawStencilMask(maskRef) {
|
|
23508
|
+
if (!this.isActiveAndEnabled) {
|
|
23509
|
+
return;
|
|
23510
|
+
}
|
|
23511
|
+
for(var i = 0; i < this.materials.length; i++){
|
|
23512
|
+
var material = this.materials[i];
|
|
23513
|
+
this.maskManager.drawGeometryMask(this.engine.renderer, this.geometry, this.transform.getWorldMatrix(), material, maskRef, i);
|
|
23514
|
+
}
|
|
23515
|
+
};
|
|
23516
|
+
_proto.getBoundingBox = function getBoundingBox() {
|
|
23517
|
+
var worldMatrix = this.transform.getWorldMatrix();
|
|
23518
|
+
this.boundingBoxInfo.setGeometry(this.geometry, worldMatrix);
|
|
23519
|
+
var boundingBox = this.boundingBoxInfo.getBoundingBoxTriangle();
|
|
23520
|
+
return boundingBox;
|
|
23521
|
+
};
|
|
23522
|
+
_proto.getBoundingBoxInfo = function getBoundingBoxInfo() {
|
|
23523
|
+
var positionArray = this.geometry.getAttributeData(VertexBuffer.PositionKind);
|
|
23524
|
+
if (positionArray) {
|
|
23525
|
+
var minMaxResult = extractMinAndMax(positionArray, 0, positionArray.length / 3);
|
|
23526
|
+
minMaxResult.minimum.x *= this.transform.size.x;
|
|
23527
|
+
minMaxResult.minimum.y *= this.transform.size.y;
|
|
23528
|
+
minMaxResult.maximum.x *= this.transform.size.x;
|
|
23529
|
+
minMaxResult.maximum.y *= this.transform.size.y;
|
|
23530
|
+
this.boundingBoxInfo.reConstruct(minMaxResult.minimum, minMaxResult.maximum, this.transform.getWorldMatrix());
|
|
23531
|
+
}
|
|
23532
|
+
return this.boundingBoxInfo;
|
|
23533
|
+
};
|
|
23534
|
+
_proto.fromData = function fromData(data) {
|
|
23535
|
+
RendererComponent.prototype.fromData.call(this, data);
|
|
23536
|
+
var maskOptions = data.mask;
|
|
23537
|
+
if (maskOptions) {
|
|
23538
|
+
this.maskManager.setMaskOptions(this.engine, maskOptions);
|
|
23539
|
+
}
|
|
23540
|
+
};
|
|
23541
|
+
return MeshComponent;
|
|
23542
|
+
}(RendererComponent);
|
|
23543
|
+
__decorate([
|
|
23544
|
+
serialize()
|
|
23545
|
+
], MeshComponent.prototype, "geometry", void 0);
|
|
23546
|
+
|
|
23547
|
+
exports.EffectComponent = /*#__PURE__*/ function(MeshComponent) {
|
|
23548
|
+
_inherits(EffectComponent, MeshComponent);
|
|
23549
|
+
function EffectComponent(engine) {
|
|
23550
|
+
var _this;
|
|
23551
|
+
_this = MeshComponent.call(this, engine) || this;
|
|
23552
|
+
_this.time = 0;
|
|
23553
|
+
_this.name = "EffectComponent";
|
|
23554
|
+
return _this;
|
|
23555
|
+
}
|
|
23556
|
+
var _proto = EffectComponent.prototype;
|
|
23557
|
+
_proto.onStart = function onStart() {
|
|
23558
|
+
this.item.getHitTestParams = this.getHitTestParams;
|
|
23559
|
+
};
|
|
23560
|
+
_proto.onUpdate = function onUpdate(dt) {
|
|
23561
|
+
var time = this.time;
|
|
23562
|
+
var _this_material_getVector4;
|
|
23563
|
+
var _Time = (_this_material_getVector4 = this.material.getVector4("_Time")) != null ? _this_material_getVector4 : new Vector4();
|
|
23564
|
+
this.material.setVector4("_Time", _Time.set(time / 20, time, time * 2, time * 3));
|
|
23565
|
+
this.time += dt / 1000;
|
|
23566
|
+
};
|
|
23567
|
+
_proto.fromData = function fromData(data) {
|
|
23568
|
+
MeshComponent.prototype.fromData.call(this, data);
|
|
23569
|
+
this.material = this.materials[0];
|
|
23570
|
+
};
|
|
23571
|
+
return EffectComponent;
|
|
23572
|
+
}(MeshComponent);
|
|
23573
|
+
exports.EffectComponent = __decorate([
|
|
23574
|
+
effectsClass(DataType.EffectComponent)
|
|
23575
|
+
], exports.EffectComponent);
|
|
23576
|
+
|
|
23577
|
+
var tempVector3 = new Vector3(0, 0, 0);
|
|
23578
|
+
var tempVector3Second = new Vector3(0, 0, 0);
|
|
23579
|
+
var ConstraintTarget = function ConstraintTarget() {
|
|
23580
|
+
this.target = null;
|
|
23581
|
+
this.weight = 1.0;
|
|
23582
|
+
};
|
|
23583
|
+
exports.PositionConstraint = /*#__PURE__*/ function(Component) {
|
|
23584
|
+
_inherits(PositionConstraint, Component);
|
|
23585
|
+
function PositionConstraint() {
|
|
23586
|
+
var _this;
|
|
23587
|
+
_this = Component.apply(this, arguments) || this;
|
|
23588
|
+
/**
|
|
23589
|
+
* 初始位置(当前元素的初始世界位置)
|
|
23590
|
+
*/ _this.positionAtRest = new Vector3(0, 0, 0);
|
|
23591
|
+
/**
|
|
23592
|
+
* 位置偏移
|
|
23593
|
+
*/ _this.positionOffset = new Vector3(0, 0, 0);
|
|
23594
|
+
/**
|
|
23595
|
+
* 约束权重 (0-1)
|
|
23596
|
+
*/ _this.weight = 1.0;
|
|
23597
|
+
/**
|
|
23598
|
+
* 是否约束 X 轴
|
|
23599
|
+
*/ _this.constrainX = true;
|
|
23600
|
+
/**
|
|
23601
|
+
* 是否约束 Y 轴
|
|
23602
|
+
*/ _this.constrainY = true;
|
|
23603
|
+
/**
|
|
23604
|
+
* 是否约束 Z 轴
|
|
23605
|
+
*/ _this.constrainZ = true;
|
|
23606
|
+
/**
|
|
23607
|
+
* 约束目标
|
|
23608
|
+
*/ _this.targets = [];
|
|
23609
|
+
return _this;
|
|
23610
|
+
}
|
|
23611
|
+
var _proto = PositionConstraint.prototype;
|
|
23612
|
+
_proto.onStart = function onStart() {
|
|
23613
|
+
// 保存当前元素的初始世界位置
|
|
23614
|
+
var pos = this.item.transform.getWorldPosition();
|
|
23615
|
+
this.positionAtRest.copyFrom(pos);
|
|
23616
|
+
};
|
|
23617
|
+
_proto.onUpdate = function onUpdate(dt) {
|
|
23618
|
+
if (this.targets.length === 0) {
|
|
23619
|
+
return;
|
|
23620
|
+
}
|
|
23621
|
+
// 重置 tempVector3 用于计算融合位置
|
|
23622
|
+
tempVector3.set(0, 0, 0);
|
|
23623
|
+
var totalWeight = 0;
|
|
23624
|
+
// 计算所有目标的加权平均位置
|
|
23625
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(this.targets), _step; !(_step = _iterator()).done;){
|
|
23626
|
+
var constraintTarget = _step.value;
|
|
23627
|
+
if (constraintTarget.target) {
|
|
23628
|
+
var targetPos = constraintTarget.target.transform.getWorldPosition();
|
|
23629
|
+
var weight = constraintTarget.weight;
|
|
23630
|
+
tempVector3.x += targetPos.x * weight;
|
|
23631
|
+
tempVector3.y += targetPos.y * weight;
|
|
23632
|
+
tempVector3.z += targetPos.z * weight;
|
|
23633
|
+
totalWeight += weight;
|
|
23634
|
+
}
|
|
23635
|
+
}
|
|
23636
|
+
// 归一化加权位置
|
|
23637
|
+
if (totalWeight > 0) {
|
|
23638
|
+
tempVector3.x /= totalWeight;
|
|
23639
|
+
tempVector3.y /= totalWeight;
|
|
23640
|
+
tempVector3.z /= totalWeight;
|
|
23641
|
+
}
|
|
23642
|
+
// 应用偏移
|
|
23643
|
+
tempVector3.x += this.positionOffset.x;
|
|
23644
|
+
tempVector3.y += this.positionOffset.y;
|
|
23645
|
+
tempVector3.z += this.positionOffset.z;
|
|
23646
|
+
// 根据全局权重在初始位置和融合位置之间插值,结果存入 tempVector3Second
|
|
23647
|
+
tempVector3Second.set(this.lerp(this.positionAtRest.x, tempVector3.x, this.weight), this.lerp(this.positionAtRest.y, tempVector3.y, this.weight), this.lerp(this.positionAtRest.z, tempVector3.z, this.weight));
|
|
23648
|
+
// 应用轴约束,复用 tempVector3 存储当前位置
|
|
23649
|
+
tempVector3.copyFrom(this.item.transform.getWorldPosition());
|
|
23650
|
+
var finalX = this.constrainX ? tempVector3Second.x : tempVector3.x;
|
|
23651
|
+
var finalY = this.constrainY ? tempVector3Second.y : tempVector3.y;
|
|
23652
|
+
var finalZ = this.constrainZ ? tempVector3Second.z : tempVector3.z;
|
|
23653
|
+
// 设置新的世界位置
|
|
23654
|
+
this.item.transform.setWorldPosition(finalX, finalY, finalZ);
|
|
23655
|
+
};
|
|
23656
|
+
/**
|
|
23657
|
+
* 添加约束目标
|
|
23658
|
+
* @param target - 目标元素
|
|
23659
|
+
* @param weight - 权重值 (0-1)
|
|
23660
|
+
*/ _proto.addTarget = function addTarget(target, weight) {
|
|
23661
|
+
if (weight === void 0) weight = 1.0;
|
|
23662
|
+
var constraintTarget = new ConstraintTarget();
|
|
23663
|
+
constraintTarget.target = target;
|
|
23664
|
+
constraintTarget.weight = Math.max(0, Math.min(1, weight));
|
|
23665
|
+
this.targets.push(constraintTarget);
|
|
23666
|
+
};
|
|
23667
|
+
/**
|
|
23668
|
+
* 移除约束目标
|
|
23669
|
+
* @param target - 要移除的目标元素
|
|
23670
|
+
*/ _proto.removeTarget = function removeTarget(target) {
|
|
23671
|
+
var index = this.targets.findIndex(function(ct) {
|
|
23672
|
+
return ct.target === target;
|
|
23673
|
+
});
|
|
23674
|
+
if (index !== -1) {
|
|
23675
|
+
this.targets.splice(index, 1);
|
|
23676
|
+
}
|
|
23677
|
+
};
|
|
23678
|
+
/**
|
|
23679
|
+
* 清除所有约束目标
|
|
23680
|
+
*/ _proto.clearTargets = function clearTargets() {
|
|
23681
|
+
this.targets = [];
|
|
23682
|
+
};
|
|
23683
|
+
/**
|
|
23684
|
+
* 设置位置偏移
|
|
23685
|
+
* @param x - X 轴偏移
|
|
23686
|
+
* @param y - Y 轴偏移
|
|
23687
|
+
* @param z - Z 轴偏移
|
|
23688
|
+
*/ _proto.setPositionOffset = function setPositionOffset(x, y, z) {
|
|
23689
|
+
this.positionOffset.set(x, y, z);
|
|
23690
|
+
};
|
|
23691
|
+
/**
|
|
23692
|
+
* 设置全局约束权重
|
|
23693
|
+
* @param weight - 权重值 (0-1),0 表示保持初始位置,1 表示完全跟随目标
|
|
23694
|
+
*/ _proto.setWeight = function setWeight(weight) {
|
|
23695
|
+
this.weight = Math.max(0, Math.min(1, weight));
|
|
23696
|
+
};
|
|
23697
|
+
/**
|
|
23698
|
+
* 线性插值
|
|
23699
|
+
* @param start - 起始值
|
|
23700
|
+
* @param end - 结束值
|
|
23701
|
+
* @param t - 插值因子 (0-1)
|
|
23702
|
+
*/ _proto.lerp = function lerp(start, end, t) {
|
|
23703
|
+
return start + (end - start) * t;
|
|
23704
|
+
};
|
|
23705
|
+
_proto.fromData = function fromData(data) {
|
|
23706
|
+
Component.prototype.fromData.call(this, data);
|
|
23707
|
+
// Deserialize all properties
|
|
23708
|
+
this.positionAtRest.copyFrom(data.positionAtRest);
|
|
23709
|
+
this.positionOffset.copyFrom(data.positionOffset);
|
|
23710
|
+
this.weight = data.weight;
|
|
23711
|
+
this.constrainX = data.constrainX;
|
|
23712
|
+
this.constrainY = data.constrainY;
|
|
23713
|
+
this.constrainZ = data.constrainZ;
|
|
23714
|
+
this.targets = [];
|
|
23715
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(data.targets), _step; !(_step = _iterator()).done;){
|
|
23716
|
+
var targetData = _step.value;
|
|
23717
|
+
var constraintTarget = new ConstraintTarget();
|
|
23718
|
+
constraintTarget.target = this.engine.findObject(targetData.target);
|
|
23719
|
+
constraintTarget.weight = targetData.weight;
|
|
23720
|
+
this.targets.push(constraintTarget);
|
|
23721
|
+
}
|
|
23722
|
+
};
|
|
23723
|
+
return PositionConstraint;
|
|
23724
|
+
}(Component);
|
|
23725
|
+
exports.PositionConstraint = __decorate([
|
|
23726
|
+
effectsClass("PositionConstraint")
|
|
23727
|
+
], exports.PositionConstraint);
|
|
23728
|
+
|
|
23729
|
+
exports.PostProcessVolume = /*#__PURE__*/ function(Component) {
|
|
23730
|
+
_inherits(PostProcessVolume, Component);
|
|
23731
|
+
function PostProcessVolume(engine) {
|
|
23732
|
+
var _this;
|
|
23733
|
+
_this = Component.call(this, engine) || this;
|
|
23734
|
+
_this.bloom = {
|
|
23735
|
+
threshold: 0,
|
|
23736
|
+
intensity: 0,
|
|
23737
|
+
active: false
|
|
23738
|
+
};
|
|
23739
|
+
_this.vignette = {
|
|
23740
|
+
intensity: 0,
|
|
23741
|
+
smoothness: 0,
|
|
23742
|
+
roundness: 0,
|
|
23743
|
+
active: false
|
|
23744
|
+
};
|
|
23745
|
+
_this.tonemapping = {
|
|
23746
|
+
active: false
|
|
23747
|
+
};
|
|
23748
|
+
_this.colorAdjustments = {
|
|
23749
|
+
brightness: 0,
|
|
23750
|
+
saturation: 0,
|
|
23751
|
+
contrast: 0,
|
|
23752
|
+
active: false
|
|
23753
|
+
};
|
|
23754
|
+
return _this;
|
|
23755
|
+
}
|
|
23756
|
+
var _proto = PostProcessVolume.prototype;
|
|
23757
|
+
_proto.onStart = function onStart() {
|
|
23758
|
+
var composition = this.item.composition;
|
|
23759
|
+
if (composition) {
|
|
23760
|
+
composition.renderFrame.globalVolume = this;
|
|
23761
|
+
}
|
|
23762
|
+
};
|
|
23763
|
+
return PostProcessVolume;
|
|
23764
|
+
}(Component);
|
|
23765
|
+
__decorate([
|
|
23766
|
+
serialize()
|
|
23767
|
+
], exports.PostProcessVolume.prototype, "bloom", void 0);
|
|
23768
|
+
__decorate([
|
|
23769
|
+
serialize()
|
|
23770
|
+
], exports.PostProcessVolume.prototype, "vignette", void 0);
|
|
23771
|
+
__decorate([
|
|
23772
|
+
serialize()
|
|
23773
|
+
], exports.PostProcessVolume.prototype, "tonemapping", void 0);
|
|
23774
|
+
__decorate([
|
|
23775
|
+
serialize()
|
|
23776
|
+
], exports.PostProcessVolume.prototype, "colorAdjustments", void 0);
|
|
23777
|
+
exports.PostProcessVolume = __decorate([
|
|
23778
|
+
effectsClass(DataType.PostProcessVolume)
|
|
23779
|
+
], exports.PostProcessVolume);
|
|
23780
|
+
|
|
22818
23781
|
/**
|
|
22819
23782
|
* @since 2.7.0
|
|
22820
23783
|
*/ var MaskableGraphic = /*#__PURE__*/ function(RendererComponent) {
|
|
@@ -22853,42 +23816,40 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
22853
23816
|
side: SideMode.DOUBLE,
|
|
22854
23817
|
mask: 0
|
|
22855
23818
|
};
|
|
23819
|
+
var _obj;
|
|
22856
23820
|
_this.defaultGeometry = Geometry.create(_this.engine, {
|
|
22857
|
-
attributes: {
|
|
22858
|
-
|
|
22859
|
-
|
|
22860
|
-
|
|
22861
|
-
|
|
22862
|
-
|
|
22863
|
-
|
|
22864
|
-
|
|
22865
|
-
|
|
22866
|
-
|
|
22867
|
-
|
|
22868
|
-
|
|
22869
|
-
|
|
22870
|
-
|
|
22871
|
-
|
|
22872
|
-
|
|
22873
|
-
|
|
22874
|
-
|
|
22875
|
-
|
|
22876
|
-
|
|
22877
|
-
|
|
22878
|
-
|
|
22879
|
-
|
|
22880
|
-
|
|
22881
|
-
|
|
22882
|
-
|
|
22883
|
-
|
|
22884
|
-
|
|
22885
|
-
|
|
22886
|
-
|
|
22887
|
-
|
|
22888
|
-
|
|
22889
|
-
])
|
|
22890
|
-
}
|
|
22891
|
-
},
|
|
23821
|
+
attributes: (_obj = {}, _obj[VertexBuffer.PositionKind] = {
|
|
23822
|
+
type: glContext.FLOAT,
|
|
23823
|
+
size: 3,
|
|
23824
|
+
data: new Float32Array([
|
|
23825
|
+
-0.5,
|
|
23826
|
+
0.5,
|
|
23827
|
+
0,
|
|
23828
|
+
-0.5,
|
|
23829
|
+
-0.5,
|
|
23830
|
+
0,
|
|
23831
|
+
0.5,
|
|
23832
|
+
0.5,
|
|
23833
|
+
0,
|
|
23834
|
+
0.5,
|
|
23835
|
+
-0.5,
|
|
23836
|
+
0
|
|
23837
|
+
])
|
|
23838
|
+
}, _obj[VertexBuffer.UVKind] = {
|
|
23839
|
+
size: 2,
|
|
23840
|
+
offset: 0,
|
|
23841
|
+
type: glContext.FLOAT,
|
|
23842
|
+
data: new Float32Array([
|
|
23843
|
+
0,
|
|
23844
|
+
1,
|
|
23845
|
+
0,
|
|
23846
|
+
0,
|
|
23847
|
+
1,
|
|
23848
|
+
1,
|
|
23849
|
+
1,
|
|
23850
|
+
0
|
|
23851
|
+
])
|
|
23852
|
+
}, _obj),
|
|
22892
23853
|
indices: {
|
|
22893
23854
|
data: new Uint16Array([
|
|
22894
23855
|
0,
|
|
@@ -22897,11 +23858,11 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
22897
23858
|
2,
|
|
22898
23859
|
1,
|
|
22899
23860
|
3
|
|
22900
|
-
])
|
|
22901
|
-
releasable: true
|
|
23861
|
+
])
|
|
22902
23862
|
},
|
|
22903
23863
|
mode: glContext.TRIANGLES,
|
|
22904
|
-
drawCount: 6
|
|
23864
|
+
drawCount: 6,
|
|
23865
|
+
bufferUsage: glContext.DYNAMIC_DRAW
|
|
22905
23866
|
});
|
|
22906
23867
|
_this.geometry = _this.defaultGeometry;
|
|
22907
23868
|
var material = Material.create(_this.engine, {
|
|
@@ -23010,7 +23971,7 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
23010
23971
|
return boundingBox;
|
|
23011
23972
|
};
|
|
23012
23973
|
_proto.getBoundingBoxInfo = function getBoundingBoxInfo() {
|
|
23013
|
-
var positionArray = this.geometry.getAttributeData(
|
|
23974
|
+
var positionArray = this.geometry.getAttributeData(VertexBuffer.PositionKind);
|
|
23014
23975
|
if (positionArray) {
|
|
23015
23976
|
var minMaxResult = extractMinAndMax(positionArray, 0, positionArray.length / 3);
|
|
23016
23977
|
minMaxResult.minimum.x *= this.transform.size.x;
|
|
@@ -23224,61 +24185,66 @@ exports.FrameComponent = /*#__PURE__*/ function(RendererComponent1) {
|
|
|
23224
24185
|
_this.color = new Color(1, 1, 1, 1);
|
|
23225
24186
|
_this.worldMatrix = new Matrix4();
|
|
23226
24187
|
_this.getHitTestParams = function(force) {
|
|
24188
|
+
if (!force) {
|
|
24189
|
+
return;
|
|
24190
|
+
}
|
|
24191
|
+
// frame 边的四角(局部 [-0.5, 0.5] 经 size 与世界变换)
|
|
23227
24192
|
var sizeMatrix = Matrix4.fromScale(_this.transform.size.x, _this.transform.size.y, 1);
|
|
23228
24193
|
var worldMatrix = sizeMatrix.premultiply(_this.transform.getWorldMatrix());
|
|
23229
|
-
|
|
23230
|
-
|
|
23231
|
-
|
|
23232
|
-
|
|
23233
|
-
|
|
23234
|
-
|
|
23235
|
-
|
|
23236
|
-
|
|
23237
|
-
|
|
23238
|
-
|
|
23239
|
-
|
|
24194
|
+
var toWorld = function(x, y) {
|
|
24195
|
+
return worldMatrix.transformPoint(new Vector3(x, y, 0), new Vector3());
|
|
24196
|
+
};
|
|
24197
|
+
var TL = toWorld(-0.5, 0.5);
|
|
24198
|
+
var TR = toWorld(0.5, 0.5);
|
|
24199
|
+
var BR = toWorld(0.5, -0.5);
|
|
24200
|
+
var BL = toWorld(-0.5, -0.5);
|
|
24201
|
+
// 命中带为屏幕像素恒定的环带,中心落在 frame 边上,仅边缘可命中(内部镂空)
|
|
24202
|
+
var thickness = _this.getBorderWorldThickness(TL, TR);
|
|
24203
|
+
var triangles = _this.getBorderTriangles(TL, TR, BR, BL, thickness);
|
|
24204
|
+
return {
|
|
24205
|
+
type: exports.HitTestType.triangle,
|
|
24206
|
+
triangles: triangles,
|
|
24207
|
+
clipMasks: _this.frameClipMasks
|
|
24208
|
+
};
|
|
23240
24209
|
};
|
|
23241
24210
|
return _this;
|
|
23242
24211
|
}
|
|
23243
24212
|
var _proto = FrameComponent.prototype;
|
|
23244
24213
|
_proto.onAwake = function onAwake() {
|
|
24214
|
+
var _obj;
|
|
23245
24215
|
this.clipGeometry = Geometry.create(this.engine, {
|
|
23246
|
-
attributes: {
|
|
23247
|
-
|
|
23248
|
-
|
|
23249
|
-
|
|
23250
|
-
|
|
23251
|
-
|
|
23252
|
-
|
|
23253
|
-
|
|
23254
|
-
|
|
23255
|
-
|
|
23256
|
-
|
|
23257
|
-
|
|
23258
|
-
|
|
23259
|
-
|
|
23260
|
-
|
|
23261
|
-
|
|
23262
|
-
|
|
23263
|
-
|
|
23264
|
-
|
|
23265
|
-
|
|
23266
|
-
|
|
23267
|
-
|
|
23268
|
-
|
|
23269
|
-
|
|
23270
|
-
|
|
23271
|
-
|
|
23272
|
-
|
|
23273
|
-
|
|
23274
|
-
|
|
23275
|
-
|
|
23276
|
-
|
|
23277
|
-
|
|
23278
|
-
0
|
|
23279
|
-
])
|
|
23280
|
-
}
|
|
23281
|
-
},
|
|
24216
|
+
attributes: (_obj = {}, _obj[VertexBuffer.PositionKind] = {
|
|
24217
|
+
type: glContext.FLOAT,
|
|
24218
|
+
size: 3,
|
|
24219
|
+
data: new Float32Array([
|
|
24220
|
+
-0.5,
|
|
24221
|
+
0.5,
|
|
24222
|
+
0,
|
|
24223
|
+
-0.5,
|
|
24224
|
+
-0.5,
|
|
24225
|
+
0,
|
|
24226
|
+
0.5,
|
|
24227
|
+
0.5,
|
|
24228
|
+
0,
|
|
24229
|
+
0.5,
|
|
24230
|
+
-0.5,
|
|
24231
|
+
0
|
|
24232
|
+
])
|
|
24233
|
+
}, _obj[VertexBuffer.UVKind] = {
|
|
24234
|
+
size: 2,
|
|
24235
|
+
offset: 0,
|
|
24236
|
+
type: glContext.FLOAT,
|
|
24237
|
+
data: new Float32Array([
|
|
24238
|
+
0,
|
|
24239
|
+
1,
|
|
24240
|
+
0,
|
|
24241
|
+
0,
|
|
24242
|
+
1,
|
|
24243
|
+
1,
|
|
24244
|
+
1,
|
|
24245
|
+
0
|
|
24246
|
+
])
|
|
24247
|
+
}, _obj),
|
|
23282
24248
|
indices: {
|
|
23283
24249
|
data: new Uint16Array([
|
|
23284
24250
|
0,
|
|
@@ -23287,8 +24253,7 @@ exports.FrameComponent = /*#__PURE__*/ function(RendererComponent1) {
|
|
|
23287
24253
|
2,
|
|
23288
24254
|
1,
|
|
23289
24255
|
3
|
|
23290
|
-
])
|
|
23291
|
-
releasable: true
|
|
24256
|
+
])
|
|
23292
24257
|
},
|
|
23293
24258
|
mode: glContext.TRIANGLES,
|
|
23294
24259
|
drawCount: 6
|
|
@@ -23338,6 +24303,62 @@ exports.FrameComponent = /*#__PURE__*/ function(RendererComponent1) {
|
|
|
23338
24303
|
this.color.copyFrom(data.color);
|
|
23339
24304
|
}
|
|
23340
24305
|
};
|
|
24306
|
+
/**
|
|
24307
|
+
* 由相机把命中带的屏幕像素厚度换算成世界厚度。对齐 Excalidraw frame 命中阈值:
|
|
24308
|
+
* 描边两侧各 0.85 × DEFAULT_COLLISION_THRESHOLD(≈8px),整条带 ≈13.6px,不受 size/scale/zoom 影响。
|
|
24309
|
+
*/ _proto.getBorderWorldThickness = function getBorderWorldThickness(topLeft, topRight) {
|
|
24310
|
+
var _this_item_composition;
|
|
24311
|
+
var fallbackThickness = 0.05; // 相机不可用时的兜底世界厚度
|
|
24312
|
+
var camera = (_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.camera;
|
|
24313
|
+
if (!camera) {
|
|
24314
|
+
return fallbackThickness;
|
|
24315
|
+
}
|
|
24316
|
+
var screenLeft = camera.worldToScreenPoint(topLeft);
|
|
24317
|
+
var screenRight = camera.worldToScreenPoint(topRight);
|
|
24318
|
+
var pixelDist = Math.hypot(screenRight.x - screenLeft.x, screenRight.y - screenLeft.y);
|
|
24319
|
+
var worldDist = Math.hypot(topRight.x - topLeft.x, topRight.y - topLeft.y) || 1;
|
|
24320
|
+
var pixelPerWorldUnit = pixelDist / worldDist;
|
|
24321
|
+
// 命中带整条宽度(像素):2 × 0.85 × DEFAULT_COLLISION_THRESHOLD,其中 DEFAULT_COLLISION_THRESHOLD ≈ 8
|
|
24322
|
+
var borderPixels = 2 * 0.85 * 8;
|
|
24323
|
+
return pixelPerWorldUnit > 0 ? borderPixels / pixelPerWorldUnit : fallbackThickness;
|
|
24324
|
+
};
|
|
24325
|
+
/**
|
|
24326
|
+
* 构造以 frame 边为中心、给定世界厚度的边框环带三角形(内部镂空)。
|
|
24327
|
+
* 带中心落在 frame 边上:half 向外、half 向内;沿 frame 局部坐标轴偏移以兼容旋转。
|
|
24328
|
+
*/ _proto.getBorderTriangles = function getBorderTriangles(TL, TR, BR, BL, thickness) {
|
|
24329
|
+
// frame 局部坐标轴在世界空间的方向
|
|
24330
|
+
var axisX = TR.clone().subtract(TL).normalize();
|
|
24331
|
+
var axisY = TL.clone().subtract(BL).normalize();
|
|
24332
|
+
var offset = function(corner, dx, dy) {
|
|
24333
|
+
return corner.clone().addScaledVector(axisX, dx).addScaledVector(axisY, dy);
|
|
24334
|
+
};
|
|
24335
|
+
// 外圈向外扩 half、内圈向内收 half,使带中心落在 frame 边上
|
|
24336
|
+
var half = thickness / 2;
|
|
24337
|
+
var outerTL = offset(TL, -half, half);
|
|
24338
|
+
var outerTR = offset(TR, half, half);
|
|
24339
|
+
var outerBR = offset(BR, half, -half);
|
|
24340
|
+
var outerBL = offset(BL, -half, -half);
|
|
24341
|
+
var innerTL = offset(TL, half, -half);
|
|
24342
|
+
var innerTR = offset(TR, -half, -half);
|
|
24343
|
+
var innerBR = offset(BR, -half, half);
|
|
24344
|
+
var innerBL = offset(BL, half, half);
|
|
24345
|
+
// 每条带是一个四边形,拆成 2 个三角形
|
|
24346
|
+
var quad = function(a, b, c, d) {
|
|
24347
|
+
return [
|
|
24348
|
+
{
|
|
24349
|
+
p0: a,
|
|
24350
|
+
p1: b,
|
|
24351
|
+
p2: c
|
|
24352
|
+
},
|
|
24353
|
+
{
|
|
24354
|
+
p0: a,
|
|
24355
|
+
p1: c,
|
|
24356
|
+
p2: d
|
|
24357
|
+
}
|
|
24358
|
+
];
|
|
24359
|
+
};
|
|
24360
|
+
return [].concat(quad(outerTL, outerTR, innerTR, innerTL), quad(outerTR, outerBR, innerBR, innerTR), quad(outerBR, outerBL, innerBL, innerBR), quad(outerBL, outerTL, innerTL, innerBL));
|
|
24361
|
+
};
|
|
23341
24362
|
_proto.setClipRectangle = function setClipRectangle() {
|
|
23342
24363
|
this.setClipRectangleRecursive(this.item);
|
|
23343
24364
|
};
|
|
@@ -24650,7 +25671,7 @@ var InteractLoader = /*#__PURE__*/ function(Plugin) {
|
|
|
24650
25671
|
return InteractLoader;
|
|
24651
25672
|
}(_wrap_native_super(Plugin));
|
|
24652
25673
|
|
|
24653
|
-
var vertex = "\nprecision highp float;\n\nattribute vec2
|
|
25674
|
+
var vertex = "\nprecision highp float;\n\nattribute vec2 aPos;\nuniform vec4 uPos;\nuniform vec2 uSize;\nuniform vec4 uQuat;\nuniform vec4 uColor;\nuniform mat4 effects_ObjectToWorld;\nuniform mat4 effects_MatrixInvV;\nuniform mat4 effects_MatrixVP;\nvarying vec4 vColor;\n\nvec3 rotateByQuat(vec3 a, vec4 quat){\n vec3 qvec = quat.xyz;\n vec3 uv = cross(qvec, a);\n vec3 uuv = cross(qvec, uv) * 2.;\n return a +(uv * 2. * quat.w + uuv);\n}\n\nvoid main() {\n vec4 _pos = uPos;\n vec3 point = rotateByQuat(vec3(aPos.xy * uSize, 0.),uQuat);\n vec4 pos = vec4(_pos.xyz, 1.0);\n pos = effects_ObjectToWorld * pos;\n pos.xyz += effects_MatrixInvV[0].xyz * point.x+ effects_MatrixInvV[1].xyz * point.y;\n gl_Position = effects_MatrixVP * pos;\n vColor = uColor;\n}\n";
|
|
24654
25675
|
var fragment = "\nprecision highp float;\n\n#define fragColor gl_FragColor\n\nvarying vec4 vColor;\nvoid main() {\n gl_FragColor = vColor*vColor.a;\n}\n";
|
|
24655
25676
|
var seed$3 = 1;
|
|
24656
25677
|
var InteractMesh = /*#__PURE__*/ function() {
|
|
@@ -24707,7 +25728,7 @@ var InteractMesh = /*#__PURE__*/ function() {
|
|
|
24707
25728
|
return material;
|
|
24708
25729
|
};
|
|
24709
25730
|
_proto.createGeometry = function createGeometry() {
|
|
24710
|
-
var indexData = new
|
|
25731
|
+
var indexData = new Uint16Array([
|
|
24711
25732
|
0,
|
|
24712
25733
|
1,
|
|
24713
25734
|
1,
|
|
@@ -24717,24 +25738,23 @@ var InteractMesh = /*#__PURE__*/ function() {
|
|
|
24717
25738
|
3,
|
|
24718
25739
|
0
|
|
24719
25740
|
]);
|
|
25741
|
+
var _obj;
|
|
24720
25742
|
return Geometry.create(this.engine, {
|
|
24721
|
-
attributes: {
|
|
24722
|
-
|
|
24723
|
-
|
|
24724
|
-
|
|
24725
|
-
|
|
24726
|
-
|
|
24727
|
-
|
|
24728
|
-
|
|
24729
|
-
|
|
24730
|
-
|
|
24731
|
-
|
|
24732
|
-
|
|
24733
|
-
|
|
24734
|
-
|
|
24735
|
-
|
|
24736
|
-
}
|
|
24737
|
-
},
|
|
25743
|
+
attributes: (_obj = {}, _obj[VertexBuffer.PositionKind] = {
|
|
25744
|
+
size: 2,
|
|
25745
|
+
offset: 0,
|
|
25746
|
+
stride: 2 * Float32Array.BYTES_PER_ELEMENT,
|
|
25747
|
+
data: new Float32Array([
|
|
25748
|
+
-0.5,
|
|
25749
|
+
0.5,
|
|
25750
|
+
0.5,
|
|
25751
|
+
0.5,
|
|
25752
|
+
0.5,
|
|
25753
|
+
-0.5,
|
|
25754
|
+
-0.5,
|
|
25755
|
+
-0.5
|
|
25756
|
+
])
|
|
25757
|
+
}, _obj),
|
|
24738
25758
|
drawCount: indexData.length,
|
|
24739
25759
|
indices: {
|
|
24740
25760
|
data: indexData
|
|
@@ -26661,6 +27681,11 @@ exports.SpritePropertyTrack = __decorate([
|
|
|
26661
27681
|
effectsClass("SpritePropertyTrack")
|
|
26662
27682
|
], exports.SpritePropertyTrack);
|
|
26663
27683
|
|
|
27684
|
+
function _assert_this_initialized(self) {
|
|
27685
|
+
if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
27686
|
+
return self;
|
|
27687
|
+
}
|
|
27688
|
+
|
|
26664
27689
|
var Cone = /*#__PURE__*/ function() {
|
|
26665
27690
|
function Cone(props) {
|
|
26666
27691
|
var _this = this;
|
|
@@ -27742,7 +28767,9 @@ var tmp0 = new Vector3();
|
|
|
27742
28767
|
var tmp1 = new Vector3();
|
|
27743
28768
|
var TrailMesh = /*#__PURE__*/ function() {
|
|
27744
28769
|
function TrailMesh(engine, props) {
|
|
28770
|
+
var _this = this;
|
|
27745
28771
|
this.pointStart = [];
|
|
28772
|
+
this.attributeData = new Map();
|
|
27746
28773
|
var colorOverLifetime = props.colorOverLifetime, colorOverTrail = props.colorOverTrail, maxTrailCount = props.maxTrailCount, _props_opacityOverLifetime = props.opacityOverLifetime, opacityOverLifetime = _props_opacityOverLifetime === void 0 ? createValueGetter(1) : _props_opacityOverLifetime, widthOverTrail = props.widthOverTrail, name = props.name, occlusion = props.occlusion, blending = props.blending, texture = props.texture, transparentOcclusion = props.transparentOcclusion, minimumVertexDistance = props.minimumVertexDistance, lifetime = props.lifetime, matrix = props.matrix;
|
|
27747
28774
|
var _engine_gpuCapability = engine.gpuCapability, detail = _engine_gpuCapability.detail, level = _engine_gpuCapability.level;
|
|
27748
28775
|
var pointCountPerTrail = Math.max(props.pointCountPerTrail, 2);
|
|
@@ -27825,42 +28852,36 @@ var TrailMesh = /*#__PURE__*/ function() {
|
|
|
27825
28852
|
var maxTriangleCount = (pointCountPerTrail - 1) * maxTrailCount;
|
|
27826
28853
|
var bpe = Float32Array.BYTES_PER_ELEMENT;
|
|
27827
28854
|
var v12 = 12 * bpe;
|
|
28855
|
+
var _obj;
|
|
27828
28856
|
var geometryOptions = {
|
|
27829
|
-
attributes: {
|
|
27830
|
-
|
|
27831
|
-
|
|
27832
|
-
|
|
27833
|
-
|
|
27834
|
-
|
|
27835
|
-
|
|
27836
|
-
|
|
27837
|
-
|
|
27838
|
-
|
|
27839
|
-
|
|
27840
|
-
|
|
27841
|
-
|
|
27842
|
-
|
|
27843
|
-
|
|
27844
|
-
|
|
27845
|
-
|
|
27846
|
-
|
|
27847
|
-
|
|
27848
|
-
|
|
27849
|
-
|
|
27850
|
-
|
|
27851
|
-
|
|
27852
|
-
|
|
27853
|
-
|
|
27854
|
-
|
|
27855
|
-
|
|
27856
|
-
|
|
27857
|
-
},
|
|
27858
|
-
//
|
|
27859
|
-
aDir: {
|
|
27860
|
-
size: 3,
|
|
27861
|
-
data: new Float32Array(maxVertexCount * 3)
|
|
27862
|
-
}
|
|
27863
|
-
},
|
|
28857
|
+
attributes: (_obj = {}, _obj[VertexBuffer.ColorKind] = {
|
|
28858
|
+
size: 4,
|
|
28859
|
+
stride: v12,
|
|
28860
|
+
data: new Float32Array(maxVertexCount * 12)
|
|
28861
|
+
}, _obj.aSeed = {
|
|
28862
|
+
size: 1,
|
|
28863
|
+
stride: v12,
|
|
28864
|
+
offset: 4 * bpe,
|
|
28865
|
+
dataSource: VertexBuffer.ColorKind
|
|
28866
|
+
}, _obj.aInfo = {
|
|
28867
|
+
size: 3,
|
|
28868
|
+
stride: v12,
|
|
28869
|
+
offset: 5 * bpe,
|
|
28870
|
+
dataSource: VertexBuffer.ColorKind
|
|
28871
|
+
}, _obj[VertexBuffer.PositionKind] = {
|
|
28872
|
+
size: 4,
|
|
28873
|
+
stride: v12,
|
|
28874
|
+
offset: 8 * bpe,
|
|
28875
|
+
dataSource: VertexBuffer.ColorKind
|
|
28876
|
+
}, //
|
|
28877
|
+
_obj.aTime = {
|
|
28878
|
+
size: 1,
|
|
28879
|
+
data: new Float32Array(maxVertexCount)
|
|
28880
|
+
}, //
|
|
28881
|
+
_obj.aDir = {
|
|
28882
|
+
size: 3,
|
|
28883
|
+
data: new Float32Array(maxVertexCount * 3)
|
|
28884
|
+
}, _obj),
|
|
27864
28885
|
indices: {
|
|
27865
28886
|
data: new Uint16Array(maxVertexCount * 6)
|
|
27866
28887
|
},
|
|
@@ -27934,6 +28955,13 @@ var TrailMesh = /*#__PURE__*/ function() {
|
|
|
27934
28955
|
this.mesh.worldMatrix = matrix;
|
|
27935
28956
|
}
|
|
27936
28957
|
this.geometry = mesh.firstGeometry();
|
|
28958
|
+
this.geometry.getAttributeNames().forEach(function(name) {
|
|
28959
|
+
var vertexBuffer = _this.geometry.getVertexBuffer(name);
|
|
28960
|
+
var data = _this.geometry.getAttributeData(name);
|
|
28961
|
+
if (vertexBuffer && _instanceof1(data, Float32Array)) {
|
|
28962
|
+
_this.attributeData.set(vertexBuffer.getWrapperBuffer(), data);
|
|
28963
|
+
}
|
|
28964
|
+
});
|
|
27937
28965
|
this.trailCursors = new Uint16Array(maxTrailCount);
|
|
27938
28966
|
}
|
|
27939
28967
|
var _proto = TrailMesh.prototype;
|
|
@@ -27964,8 +28992,8 @@ var TrailMesh = /*#__PURE__*/ function() {
|
|
|
27964
28992
|
var dirData = new Float32Array(6);
|
|
27965
28993
|
dirData.set(dir, 0);
|
|
27966
28994
|
dirData.set(dir, 3);
|
|
27967
|
-
|
|
27968
|
-
|
|
28995
|
+
this.setAttributeSubData("aDir", dirStartIndex, dirData);
|
|
28996
|
+
this.setAttributeSubData("aTime", pointStartIndex * 2, new Float32Array([
|
|
27969
28997
|
time,
|
|
27970
28998
|
time
|
|
27971
28999
|
]));
|
|
@@ -27987,13 +29015,13 @@ var TrailMesh = /*#__PURE__*/ function() {
|
|
|
27987
29015
|
colorData[19] = 1;
|
|
27988
29016
|
colorData.set(positionData, 20);
|
|
27989
29017
|
colorData[23] = -0.5 * size;
|
|
27990
|
-
|
|
29018
|
+
this.setAttributeSubData(VertexBuffer.ColorKind, pointStartIndex * 24, colorData);
|
|
27991
29019
|
if (previousIndex >= 0) {
|
|
27992
29020
|
var bPreviousPoint = this.getTrailPosition(trailIndex, bpreviousIndex, tmp1);
|
|
27993
29021
|
var previousDir = new Float32Array(calculateDirection(bPreviousPoint, previousPoint, position));
|
|
27994
29022
|
var previousDirStartIndex = (trailIndex * pointCountPerTrail + previousIndex) * 6;
|
|
27995
|
-
|
|
27996
|
-
|
|
29023
|
+
this.setAttributeSubData("aDir", previousDirStartIndex, previousDir);
|
|
29024
|
+
this.setAttributeSubData("aDir", previousDirStartIndex + 3, previousDir);
|
|
27997
29025
|
var indicesStart = trailIndex * pointCountPerTrail * 2;
|
|
27998
29026
|
var indicesData = new Uint16Array([
|
|
27999
29027
|
previousIndex * 2 + indicesStart,
|
|
@@ -28016,7 +29044,7 @@ var TrailMesh = /*#__PURE__*/ function() {
|
|
|
28016
29044
|
for(var i = 0; i < len; i++){
|
|
28017
29045
|
startData[i] = trailStart;
|
|
28018
29046
|
}
|
|
28019
|
-
|
|
29047
|
+
this.setAttributeSubData("aTrailStart", trailIndex * startData.length, startData);
|
|
28020
29048
|
} else {
|
|
28021
29049
|
var value = mtl.getFloats("uTrailStart");
|
|
28022
29050
|
if (value != undefined) {
|
|
@@ -28033,8 +29061,7 @@ var TrailMesh = /*#__PURE__*/ function() {
|
|
|
28033
29061
|
var pointCountPerTrail = this.pointCountPerTrail;
|
|
28034
29062
|
if (index >= 0 && index < pointCountPerTrail) {
|
|
28035
29063
|
var startIndex = (trail * pointCountPerTrail + index) * 24 + 8;
|
|
28036
|
-
var data = this.
|
|
28037
|
-
assertExist(data);
|
|
29064
|
+
var data = this.getAttributeData(VertexBuffer.ColorKind);
|
|
28038
29065
|
out.x = data[startIndex];
|
|
28039
29066
|
out.y = data[1 + startIndex];
|
|
28040
29067
|
out.z = data[2 + startIndex];
|
|
@@ -28048,12 +29075,11 @@ var TrailMesh = /*#__PURE__*/ function() {
|
|
|
28048
29075
|
this.geometry.setIndexData(new Uint16Array(indexData.length));
|
|
28049
29076
|
};
|
|
28050
29077
|
_proto.minusTime = function minusTime(time) {
|
|
28051
|
-
var data = this.
|
|
28052
|
-
assertExist(data);
|
|
29078
|
+
var data = this.getAttributeData("aTime");
|
|
28053
29079
|
for(var i = 0; i < data.length; i++){
|
|
28054
29080
|
data[i] -= time;
|
|
28055
29081
|
}
|
|
28056
|
-
this.
|
|
29082
|
+
this.setAttributeData("aTime", data);
|
|
28057
29083
|
this.time -= time;
|
|
28058
29084
|
};
|
|
28059
29085
|
_proto.clearTrail = function clearTrail(index) {
|
|
@@ -28074,6 +29100,35 @@ var TrailMesh = /*#__PURE__*/ function() {
|
|
|
28074
29100
|
this.pointStart[index] = pos;
|
|
28075
29101
|
};
|
|
28076
29102
|
_proto.onUpdate = function onUpdate(escapeTime) {};
|
|
29103
|
+
_proto.getAttributeData = function getAttributeData(name) {
|
|
29104
|
+
var vertexBuffer = this.geometry.getVertexBuffer(name);
|
|
29105
|
+
var data = vertexBuffer && this.attributeData.get(vertexBuffer.getWrapperBuffer());
|
|
29106
|
+
assertExist(data);
|
|
29107
|
+
return data;
|
|
29108
|
+
};
|
|
29109
|
+
_proto.setAttributeData = function setAttributeData(name, data) {
|
|
29110
|
+
var vertexBuffer = this.geometry.getVertexBuffer(name);
|
|
29111
|
+
assertExist(vertexBuffer);
|
|
29112
|
+
this.attributeData.set(vertexBuffer.getWrapperBuffer(), data);
|
|
29113
|
+
this.geometry.setAttributeData(name, data);
|
|
29114
|
+
};
|
|
29115
|
+
_proto.setAttributeSubData = function setAttributeSubData(name, offset, data) {
|
|
29116
|
+
var target = this.getAttributeData(name);
|
|
29117
|
+
target.set(data, offset);
|
|
29118
|
+
this.geometry.setAttributeSubData(name, offset, data);
|
|
29119
|
+
};
|
|
29120
|
+
/**
|
|
29121
|
+
* @internal
|
|
29122
|
+
*/ _proto.rebuild = function rebuild() {
|
|
29123
|
+
if (!this.geometry.isInitialized || this.geometry.isDisposed()) {
|
|
29124
|
+
return;
|
|
29125
|
+
}
|
|
29126
|
+
this.attributeData.forEach(function(data, buffer) {
|
|
29127
|
+
if (!buffer.getData()) {
|
|
29128
|
+
buffer.update(data);
|
|
29129
|
+
}
|
|
29130
|
+
});
|
|
29131
|
+
};
|
|
28077
29132
|
_create_class(TrailMesh, [
|
|
28078
29133
|
{
|
|
28079
29134
|
key: "time",
|
|
@@ -28197,11 +29252,13 @@ var particleUniformTypeMap = {
|
|
|
28197
29252
|
|
|
28198
29253
|
var ParticleMesh = /*#__PURE__*/ function() {
|
|
28199
29254
|
function ParticleMesh(engine, props) {
|
|
29255
|
+
var _this = this;
|
|
28200
29256
|
this.particleCount = 0;
|
|
28201
29257
|
this.cachedRotationVector3 = new Vector3();
|
|
28202
29258
|
this.cachedRotationMatrix = new Matrix3();
|
|
28203
29259
|
this.cachedLinearMove = new Vector3();
|
|
28204
29260
|
this.tempMatrix3 = new Matrix3();
|
|
29261
|
+
this.attributeData = new Map();
|
|
28205
29262
|
this.VERT_MAX_KEY_FRAME_COUNT = 0;
|
|
28206
29263
|
var env = (engine != null ? engine : {}).env;
|
|
28207
29264
|
var speedOverLifetime = props.speedOverLifetime, colorOverLifetime = props.colorOverLifetime, linearVelOverLifetime = props.linearVelOverLifetime, orbitalVelOverLifetime = props.orbitalVelOverLifetime, sizeOverLifetime = props.sizeOverLifetime, rotationOverLifetime = props.rotationOverLifetime, sprite = props.sprite, gravityModifier = props.gravityModifier, maxCount = props.maxCount, textureFlip = props.textureFlip, useSprite = props.useSprite, name = props.name, gravity = props.gravity, forceTarget = props.forceTarget, side = props.side, occlusion = props.occlusion, anchor = props.anchor, blending = props.blending, transparentOcclusion = props.transparentOcclusion, _props_renderMode = props.renderMode, renderMode = _props_renderMode === void 0 ? 0 : _props_renderMode, _props_diffuse = props.diffuse, diffuse = _props_diffuse === void 0 ? Texture.createWithData(engine) : _props_diffuse;
|
|
@@ -28500,6 +29557,13 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
28500
29557
|
this.anchor = anchor;
|
|
28501
29558
|
this.mesh = mesh;
|
|
28502
29559
|
this.geometry = mesh.firstGeometry();
|
|
29560
|
+
this.geometry.getAttributeNames().forEach(function(name) {
|
|
29561
|
+
var vertexBuffer = _this.geometry.getVertexBuffer(name);
|
|
29562
|
+
var data = _this.geometry.getAttributeData(name);
|
|
29563
|
+
if (vertexBuffer && _instanceof1(data, Float32Array)) {
|
|
29564
|
+
_this.attributeData.set(vertexBuffer.getWrapperBuffer(), data);
|
|
29565
|
+
}
|
|
29566
|
+
});
|
|
28503
29567
|
this.forceTarget = forceTarget;
|
|
28504
29568
|
this.sizeOverLifetime = sizeOverLifetime;
|
|
28505
29569
|
this.speedOverLifetime = speedOverLifetime;
|
|
@@ -28509,6 +29573,7 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
28509
29573
|
this.gravityModifier = gravityModifier;
|
|
28510
29574
|
this.rotationOverLifetime = rotationOverLifetime;
|
|
28511
29575
|
this.maxCount = maxCount;
|
|
29576
|
+
this.maxParticleBufferCount = maxCount;
|
|
28512
29577
|
// this.duration = duration;
|
|
28513
29578
|
this.textureOffsets = textureFlip ? [
|
|
28514
29579
|
0,
|
|
@@ -28542,9 +29607,8 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
28542
29607
|
// // this.mesh.material.setVector4('uParams', new Vector4(+v, this.duration, 0, 0));
|
|
28543
29608
|
// }
|
|
28544
29609
|
_proto.getPointColor = function getPointColor(index) {
|
|
28545
|
-
var data = this.
|
|
29610
|
+
var data = this.getAttributeData("aRot");
|
|
28546
29611
|
var i = index * 32 + 4;
|
|
28547
|
-
assertExist(data);
|
|
28548
29612
|
return [
|
|
28549
29613
|
data[i],
|
|
28550
29614
|
data[i + 1],
|
|
@@ -28553,46 +29617,31 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
28553
29617
|
];
|
|
28554
29618
|
};
|
|
28555
29619
|
_proto.clearPoints = function clearPoints() {
|
|
28556
|
-
this.resetGeometryData(this.geometry);
|
|
28557
29620
|
this.particleCount = 0;
|
|
28558
29621
|
this.geometry.setDrawCount(0);
|
|
28559
|
-
this.maxParticleBufferCount = 0;
|
|
28560
|
-
};
|
|
28561
|
-
_proto.resetGeometryData = function resetGeometryData(geometry) {
|
|
28562
|
-
var names = geometry.getAttributeNames();
|
|
28563
|
-
var index = geometry.getIndexData();
|
|
28564
|
-
for(var i = 0; i < names.length; i++){
|
|
28565
|
-
var name = names[i];
|
|
28566
|
-
var data = geometry.getAttributeData(name);
|
|
28567
|
-
if (data) {
|
|
28568
|
-
// @ts-expect-error
|
|
28569
|
-
geometry.setAttributeData(name, new data.constructor(0));
|
|
28570
|
-
}
|
|
28571
|
-
}
|
|
28572
|
-
// @ts-expect-error
|
|
28573
|
-
geometry.setIndexData(new index.constructor(0));
|
|
28574
29622
|
};
|
|
28575
29623
|
_proto.onUpdate = function onUpdate(dt) {
|
|
28576
|
-
var aPosArray = this.
|
|
29624
|
+
var aPosArray = this.getAttributeData(VertexBuffer.PositionKind); // vector3
|
|
28577
29625
|
var vertexCount = Math.ceil(aPosArray.length / 12);
|
|
28578
29626
|
this.applyTranslation(vertexCount, dt);
|
|
28579
29627
|
this.applyRotation(vertexCount, dt);
|
|
28580
29628
|
this.applyLinearMove(vertexCount, dt);
|
|
28581
29629
|
};
|
|
28582
29630
|
_proto.minusTime = function minusTime(time) {
|
|
28583
|
-
var aOffset = this.
|
|
29631
|
+
var aOffset = this.getAttributeData("aOffset");
|
|
28584
29632
|
for(var i = 0; i < aOffset.length; i += 4){
|
|
28585
29633
|
aOffset[i + 2] -= time;
|
|
28586
29634
|
}
|
|
28587
|
-
this.
|
|
29635
|
+
this.setAttributeData("aOffset", aOffset);
|
|
28588
29636
|
this.time -= time;
|
|
28589
29637
|
};
|
|
28590
29638
|
_proto.removePoint = function removePoint(index) {
|
|
28591
29639
|
if (index < this.particleCount) {
|
|
28592
|
-
this.
|
|
29640
|
+
this.setAttributeSubData("aOffset", index * 16, new Float32Array(16));
|
|
28593
29641
|
}
|
|
28594
29642
|
};
|
|
28595
29643
|
_proto.setPoint = function setPoint(index, point) {
|
|
29644
|
+
var _this = this;
|
|
28596
29645
|
var maxCount = this.maxCount;
|
|
28597
29646
|
if (index < maxCount) {
|
|
28598
29647
|
var particleCount = index + 1;
|
|
@@ -28709,13 +29758,12 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
28709
29758
|
var data = pointData[name];
|
|
28710
29759
|
var attrSize = geometry.getAttributeStride(name) / Float32Array.BYTES_PER_ELEMENT;
|
|
28711
29760
|
if (increaseBuffer) {
|
|
28712
|
-
var baseData =
|
|
28713
|
-
assertExist(baseData);
|
|
29761
|
+
var baseData = _this.getAttributeData(name);
|
|
28714
29762
|
var geoData = enlargeBuffer(baseData, vertexCount * attrSize, maxCount * 4 * attrSize, inc);
|
|
28715
29763
|
geoData.set(data, data.length * index);
|
|
28716
|
-
|
|
29764
|
+
_this.setAttributeData(name, geoData);
|
|
28717
29765
|
} else {
|
|
28718
|
-
|
|
29766
|
+
_this.setAttributeSubData(name, data.length * index, data);
|
|
28719
29767
|
}
|
|
28720
29768
|
});
|
|
28721
29769
|
this.particleCount = Math.max(particleCount, this.particleCount);
|
|
@@ -28724,9 +29772,9 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
28724
29772
|
};
|
|
28725
29773
|
_proto.applyTranslation = function applyTranslation(vertexCount, deltaTime) {
|
|
28726
29774
|
var localTime = this.time;
|
|
28727
|
-
var aTranslationArray = this.
|
|
28728
|
-
var aVelArray = this.
|
|
28729
|
-
var aOffsetArray = this.
|
|
29775
|
+
var aTranslationArray = this.getAttributeData("aTranslation");
|
|
29776
|
+
var aVelArray = this.getAttributeData("aVel"); // vector3
|
|
29777
|
+
var aOffsetArray = this.getAttributeData("aOffset");
|
|
28730
29778
|
if (aTranslationArray.length < vertexCount * 3) {
|
|
28731
29779
|
aTranslationArray = this.expandArray(aTranslationArray, vertexCount * 3);
|
|
28732
29780
|
}
|
|
@@ -28785,13 +29833,13 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
28785
29833
|
aTranslationArray[aTranslationOffset + 11] += aTranslationZ;
|
|
28786
29834
|
}
|
|
28787
29835
|
}
|
|
28788
|
-
this.
|
|
29836
|
+
this.setAttributeData("aTranslation", aTranslationArray);
|
|
28789
29837
|
};
|
|
28790
29838
|
_proto.applyRotation = function applyRotation(vertexCount, deltaTime) {
|
|
28791
|
-
var aRotationArray = this.
|
|
28792
|
-
var aOffsetArray = this.
|
|
28793
|
-
var aRotArray = this.
|
|
28794
|
-
var aSeedArray = this.
|
|
29839
|
+
var aRotationArray = this.getAttributeData("aRotation0");
|
|
29840
|
+
var aOffsetArray = this.getAttributeData("aOffset");
|
|
29841
|
+
var aRotArray = this.getAttributeData("aRot"); // vector3
|
|
29842
|
+
var aSeedArray = this.getAttributeData("aSeed"); // float
|
|
28795
29843
|
var localTime = this.time;
|
|
28796
29844
|
var aRotationMatrix = this.cachedRotationMatrix;
|
|
28797
29845
|
if (aRotationArray.length < vertexCount * 9) {
|
|
@@ -28882,12 +29930,12 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
28882
29930
|
aRotationArray.set(matrixArray, aRotationOffset + 27);
|
|
28883
29931
|
}
|
|
28884
29932
|
}
|
|
28885
|
-
this.
|
|
29933
|
+
this.setAttributeData("aRotation0", aRotationArray);
|
|
28886
29934
|
};
|
|
28887
29935
|
_proto.applyLinearMove = function applyLinearMove(vertexCount, deltaTime) {
|
|
28888
|
-
var aLinearMoveArray = this.
|
|
28889
|
-
var aOffsetArray = this.
|
|
28890
|
-
var aSeedArray = this.
|
|
29936
|
+
var aLinearMoveArray = this.getAttributeData("aLinearMove");
|
|
29937
|
+
var aOffsetArray = this.getAttributeData("aOffset");
|
|
29938
|
+
var aSeedArray = this.getAttributeData("aSeed"); // float
|
|
28891
29939
|
var localTime = this.time;
|
|
28892
29940
|
if (aLinearMoveArray.length < vertexCount * 3) {
|
|
28893
29941
|
aLinearMoveArray = this.expandArray(aLinearMoveArray, vertexCount * 3);
|
|
@@ -28962,7 +30010,36 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
28962
30010
|
aLinearMoveArray[aLinearMoveOffset + 11] = linearMove.z;
|
|
28963
30011
|
}
|
|
28964
30012
|
}
|
|
28965
|
-
this.
|
|
30013
|
+
this.setAttributeData("aLinearMove", aLinearMoveArray);
|
|
30014
|
+
};
|
|
30015
|
+
_proto.getAttributeData = function getAttributeData(name) {
|
|
30016
|
+
var vertexBuffer = this.geometry.getVertexBuffer(name);
|
|
30017
|
+
var data = vertexBuffer && this.attributeData.get(vertexBuffer.getWrapperBuffer());
|
|
30018
|
+
assertExist(data);
|
|
30019
|
+
return data;
|
|
30020
|
+
};
|
|
30021
|
+
_proto.setAttributeData = function setAttributeData(name, data) {
|
|
30022
|
+
var vertexBuffer = this.geometry.getVertexBuffer(name);
|
|
30023
|
+
assertExist(vertexBuffer);
|
|
30024
|
+
this.attributeData.set(vertexBuffer.getWrapperBuffer(), data);
|
|
30025
|
+
this.geometry.setAttributeData(name, data);
|
|
30026
|
+
};
|
|
30027
|
+
_proto.setAttributeSubData = function setAttributeSubData(name, offset, data) {
|
|
30028
|
+
var target = this.getAttributeData(name);
|
|
30029
|
+
target.set(data, offset);
|
|
30030
|
+
this.geometry.setAttributeSubData(name, offset, data);
|
|
30031
|
+
};
|
|
30032
|
+
/**
|
|
30033
|
+
* @internal
|
|
30034
|
+
*/ _proto.rebuild = function rebuild() {
|
|
30035
|
+
if (!this.geometry.isInitialized || this.geometry.isDisposed()) {
|
|
30036
|
+
return;
|
|
30037
|
+
}
|
|
30038
|
+
this.attributeData.forEach(function(data, buffer) {
|
|
30039
|
+
if (!buffer.getData()) {
|
|
30040
|
+
buffer.update(data);
|
|
30041
|
+
}
|
|
30042
|
+
});
|
|
28966
30043
|
};
|
|
28967
30044
|
_proto.expandArray = function expandArray(array, newSize) {
|
|
28968
30045
|
var newArr = new Float32Array(newSize);
|
|
@@ -28974,83 +30051,70 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
28974
30051
|
function generateGeometryProps(maxVertex, useSprite, name) {
|
|
28975
30052
|
var bpe = Float32Array.BYTES_PER_ELEMENT;
|
|
28976
30053
|
var j12 = bpe * 12;
|
|
28977
|
-
var
|
|
28978
|
-
|
|
28979
|
-
|
|
28980
|
-
|
|
28981
|
-
|
|
28982
|
-
|
|
28983
|
-
|
|
28984
|
-
|
|
28985
|
-
|
|
28986
|
-
|
|
28987
|
-
|
|
28988
|
-
|
|
28989
|
-
|
|
28990
|
-
|
|
28991
|
-
|
|
28992
|
-
|
|
28993
|
-
|
|
28994
|
-
|
|
28995
|
-
|
|
28996
|
-
|
|
28997
|
-
|
|
28998
|
-
|
|
28999
|
-
|
|
29000
|
-
|
|
29001
|
-
|
|
29002
|
-
|
|
29003
|
-
|
|
29004
|
-
|
|
29005
|
-
|
|
29006
|
-
|
|
29007
|
-
|
|
29008
|
-
|
|
29009
|
-
|
|
29010
|
-
|
|
29011
|
-
|
|
29012
|
-
|
|
29013
|
-
|
|
29014
|
-
|
|
29015
|
-
|
|
29016
|
-
|
|
29017
|
-
|
|
29018
|
-
|
|
29019
|
-
|
|
29020
|
-
|
|
29021
|
-
|
|
29022
|
-
|
|
29023
|
-
|
|
29024
|
-
|
|
29025
|
-
|
|
29026
|
-
|
|
29027
|
-
|
|
29028
|
-
|
|
29029
|
-
|
|
29030
|
-
|
|
29031
|
-
|
|
29032
|
-
|
|
29033
|
-
|
|
29034
|
-
|
|
29035
|
-
|
|
29036
|
-
|
|
29037
|
-
|
|
29038
|
-
|
|
29039
|
-
|
|
29040
|
-
|
|
29041
|
-
aRotation1: {
|
|
29042
|
-
size: 3,
|
|
29043
|
-
offset: 3 * bpe,
|
|
29044
|
-
stride: 9 * bpe,
|
|
29045
|
-
dataSource: "aRotation0"
|
|
29046
|
-
},
|
|
29047
|
-
aRotation2: {
|
|
29048
|
-
size: 3,
|
|
29049
|
-
offset: 6 * bpe,
|
|
29050
|
-
stride: 9 * bpe,
|
|
29051
|
-
dataSource: "aRotation0"
|
|
29052
|
-
}
|
|
29053
|
-
};
|
|
30054
|
+
var _obj;
|
|
30055
|
+
var attributes = (_obj = {}, _obj[VertexBuffer.PositionKind] = {
|
|
30056
|
+
size: 3,
|
|
30057
|
+
offset: 0,
|
|
30058
|
+
stride: j12,
|
|
30059
|
+
data: new Float32Array(0)
|
|
30060
|
+
}, _obj.aVel = {
|
|
30061
|
+
size: 3,
|
|
30062
|
+
offset: 3 * bpe,
|
|
30063
|
+
stride: j12,
|
|
30064
|
+
dataSource: VertexBuffer.PositionKind
|
|
30065
|
+
}, _obj.aDirX = {
|
|
30066
|
+
size: 3,
|
|
30067
|
+
offset: 6 * bpe,
|
|
30068
|
+
stride: j12,
|
|
30069
|
+
dataSource: VertexBuffer.PositionKind
|
|
30070
|
+
}, _obj.aDirY = {
|
|
30071
|
+
size: 3,
|
|
30072
|
+
offset: 9 * bpe,
|
|
30073
|
+
stride: j12,
|
|
30074
|
+
dataSource: VertexBuffer.PositionKind
|
|
30075
|
+
}, //
|
|
30076
|
+
_obj.aRot = {
|
|
30077
|
+
size: 3,
|
|
30078
|
+
offset: 0,
|
|
30079
|
+
stride: 8 * bpe,
|
|
30080
|
+
data: new Float32Array(0)
|
|
30081
|
+
}, _obj.aSeed = {
|
|
30082
|
+
size: 1,
|
|
30083
|
+
offset: 3 * bpe,
|
|
30084
|
+
stride: 8 * bpe,
|
|
30085
|
+
dataSource: "aRot"
|
|
30086
|
+
}, _obj[VertexBuffer.ColorKind] = {
|
|
30087
|
+
size: 4,
|
|
30088
|
+
offset: 4 * bpe,
|
|
30089
|
+
stride: 8 * bpe,
|
|
30090
|
+
dataSource: "aRot"
|
|
30091
|
+
}, //
|
|
30092
|
+
_obj.aOffset = {
|
|
30093
|
+
size: 4,
|
|
30094
|
+
stride: 4 * bpe,
|
|
30095
|
+
data: new Float32Array(0)
|
|
30096
|
+
}, _obj.aTranslation = {
|
|
30097
|
+
size: 3,
|
|
30098
|
+
data: new Float32Array(0)
|
|
30099
|
+
}, _obj.aLinearMove = {
|
|
30100
|
+
size: 3,
|
|
30101
|
+
data: new Float32Array(0)
|
|
30102
|
+
}, _obj.aRotation0 = {
|
|
30103
|
+
size: 3,
|
|
30104
|
+
offset: 0,
|
|
30105
|
+
stride: 9 * bpe,
|
|
30106
|
+
data: new Float32Array(0)
|
|
30107
|
+
}, _obj.aRotation1 = {
|
|
30108
|
+
size: 3,
|
|
30109
|
+
offset: 3 * bpe,
|
|
30110
|
+
stride: 9 * bpe,
|
|
30111
|
+
dataSource: "aRotation0"
|
|
30112
|
+
}, _obj.aRotation2 = {
|
|
30113
|
+
size: 3,
|
|
30114
|
+
offset: 6 * bpe,
|
|
30115
|
+
stride: 9 * bpe,
|
|
30116
|
+
dataSource: "aRotation0"
|
|
30117
|
+
}, _obj);
|
|
29054
30118
|
if (useSprite) {
|
|
29055
30119
|
attributes["aSprite"] = {
|
|
29056
30120
|
size: 3,
|
|
@@ -29061,10 +30125,11 @@ function generateGeometryProps(maxVertex, useSprite, name) {
|
|
|
29061
30125
|
return {
|
|
29062
30126
|
attributes: attributes,
|
|
29063
30127
|
indices: {
|
|
29064
|
-
data: new Uint16Array(
|
|
30128
|
+
data: new Uint16Array(maxVertex / 4 * 6)
|
|
29065
30129
|
},
|
|
29066
30130
|
name: name,
|
|
29067
|
-
maxVertex: maxVertex
|
|
30131
|
+
maxVertex: maxVertex,
|
|
30132
|
+
bufferUsage: exports.BufferUsage.Dynamic
|
|
29068
30133
|
};
|
|
29069
30134
|
}
|
|
29070
30135
|
function getParticleMeshShader(item, gpuCapability, env) {
|
|
@@ -29344,6 +30409,13 @@ function modifyMaxKeyframeShader(shader, maxVertex, maxFrag) {
|
|
|
29344
30409
|
this.materials.push(this.trailMesh.mesh.material);
|
|
29345
30410
|
}
|
|
29346
30411
|
};
|
|
30412
|
+
/**
|
|
30413
|
+
* @internal
|
|
30414
|
+
*/ _proto.rebuild = function rebuild() {
|
|
30415
|
+
var _this_trailMesh;
|
|
30416
|
+
this.particleMesh.rebuild();
|
|
30417
|
+
(_this_trailMesh = this.trailMesh) == null ? void 0 : _this_trailMesh.rebuild();
|
|
30418
|
+
};
|
|
29347
30419
|
_proto.reset = function reset() {
|
|
29348
30420
|
var _this_trailMesh;
|
|
29349
30421
|
this.particleMesh.clearPoints();
|
|
@@ -29443,6 +30515,7 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
|
|
|
29443
30515
|
};
|
|
29444
30516
|
}
|
|
29445
30517
|
};
|
|
30518
|
+
engine.addParticleSystem(_assert_this_initialized(_this));
|
|
29446
30519
|
_this.maskManager = new MaskProcessor();
|
|
29447
30520
|
if (props) {
|
|
29448
30521
|
_this.fromData(props);
|
|
@@ -29714,6 +30787,18 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
|
|
|
29714
30787
|
});
|
|
29715
30788
|
}
|
|
29716
30789
|
};
|
|
30790
|
+
/**
|
|
30791
|
+
* @hidden
|
|
30792
|
+
* Internal utility.
|
|
30793
|
+
* Not part of the public API — do not rely on this in your code.
|
|
30794
|
+
*/ _proto.rebuild = function rebuild() {
|
|
30795
|
+
var _this_renderer;
|
|
30796
|
+
(_this_renderer = this.renderer) == null ? void 0 : _this_renderer.rebuild();
|
|
30797
|
+
};
|
|
30798
|
+
_proto.dispose = function dispose() {
|
|
30799
|
+
this.engine.removeParticleSystem(this);
|
|
30800
|
+
Component.prototype.dispose.call(this);
|
|
30801
|
+
};
|
|
29717
30802
|
_proto.getParticleBoxes = function getParticleBoxes() {
|
|
29718
30803
|
var link = this.particleLink;
|
|
29719
30804
|
var renderer = this.renderer;
|
|
@@ -30981,8 +32066,8 @@ exports.SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
30981
32066
|
var width = isRotate90 ? h : w;
|
|
30982
32067
|
var height = isRotate90 ? w : h;
|
|
30983
32068
|
var angle = isRotate90 ? -Math.PI / 2 : 0;
|
|
30984
|
-
var aUV = geometry.getAttributeData(
|
|
30985
|
-
var aPos = geometry.getAttributeData(
|
|
32069
|
+
var aUV = geometry.getAttributeData(VertexBuffer.UVKind);
|
|
32070
|
+
var aPos = geometry.getAttributeData(VertexBuffer.PositionKind);
|
|
30986
32071
|
var indices = geometry.getIndexData();
|
|
30987
32072
|
var tempPosition = [
|
|
30988
32073
|
0,
|
|
@@ -31001,8 +32086,8 @@ exports.SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
31001
32086
|
aUV[uvOffset] = (tempPosition[0] + 0.5) * width + x;
|
|
31002
32087
|
aUV[uvOffset + 1] = (tempPosition[1] + 0.5) * height + y;
|
|
31003
32088
|
}
|
|
31004
|
-
this.
|
|
31005
|
-
this.
|
|
32089
|
+
this.updateAttributeData(VertexBuffer.PositionKind, aPos.slice(), 3);
|
|
32090
|
+
this.updateAttributeData(VertexBuffer.UVKind, aUV.slice(), 2);
|
|
31006
32091
|
this.geometry.setIndexData(indices.slice());
|
|
31007
32092
|
this.geometry.setDrawCount(indices.length);
|
|
31008
32093
|
}
|
|
@@ -31122,11 +32207,23 @@ exports.SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
31122
32207
|
index.push(base, 1 + base, 2 + base, 2 + base, 1 + base, 3 + base);
|
|
31123
32208
|
}
|
|
31124
32209
|
}
|
|
31125
|
-
|
|
32210
|
+
this.updateAttributeData(VertexBuffer.PositionKind, new Float32Array(position), 3);
|
|
31126
32211
|
geometry.setIndexData(new Uint16Array(index));
|
|
31127
|
-
|
|
32212
|
+
this.updateAttributeData(VertexBuffer.UVKind, new Float32Array(aUV), 2);
|
|
31128
32213
|
geometry.setDrawCount(index.length);
|
|
31129
32214
|
};
|
|
32215
|
+
_proto.updateAttributeData = function updateAttributeData(name, data, size) {
|
|
32216
|
+
var vertexBuffer = this.geometry.getVertexBuffer(name);
|
|
32217
|
+
var dataBuffer = vertexBuffer == null ? void 0 : vertexBuffer.getBuffer();
|
|
32218
|
+
if (!vertexBuffer || dataBuffer && data.byteLength > dataBuffer.capacity) {
|
|
32219
|
+
this.geometry.setVerticesBuffer(new VertexBuffer(this.engine, data, name, {
|
|
32220
|
+
updatable: true,
|
|
32221
|
+
size: size
|
|
32222
|
+
}));
|
|
32223
|
+
return;
|
|
32224
|
+
}
|
|
32225
|
+
this.geometry.setAttributeData(name, data);
|
|
32226
|
+
};
|
|
31130
32227
|
_create_class(SpriteComponent, [
|
|
31131
32228
|
{
|
|
31132
32229
|
key: "sprite",
|
|
@@ -31595,20 +32692,22 @@ var TextStyle = /*#__PURE__*/ function() {
|
|
|
31595
32692
|
return;
|
|
31596
32693
|
}
|
|
31597
32694
|
var context = this.context;
|
|
32695
|
+
var textureWidth = Math.max(1, width);
|
|
32696
|
+
var textureHeight = Math.max(1, height);
|
|
31598
32697
|
// 先保存状态
|
|
31599
32698
|
context.save();
|
|
31600
32699
|
// 设置canvas尺寸
|
|
31601
|
-
this.canvas.width =
|
|
31602
|
-
this.canvas.height =
|
|
32700
|
+
this.canvas.width = textureWidth;
|
|
32701
|
+
this.canvas.height = textureHeight;
|
|
31603
32702
|
//重置变换
|
|
31604
32703
|
context.setTransform(1, 0, 0, 1, 0, 0);
|
|
31605
32704
|
// 处理翻转
|
|
31606
32705
|
if (!flipY) {
|
|
31607
|
-
context.translate(0,
|
|
32706
|
+
context.translate(0, textureHeight);
|
|
31608
32707
|
context.scale(1, -1);
|
|
31609
32708
|
}
|
|
31610
32709
|
// 在翻转后清空画布
|
|
31611
|
-
context.clearRect(0, 0,
|
|
32710
|
+
context.clearRect(0, 0, textureWidth, textureHeight);
|
|
31612
32711
|
// 设置 alpha 修复用填充色(不实际输出像素)
|
|
31613
32712
|
context.fillStyle = "rgba(255, 255, 255, " + this.ALPHA_FIX_VALUE + ")";
|
|
31614
32713
|
// 执行绘制回调
|
|
@@ -31616,7 +32715,7 @@ var TextStyle = /*#__PURE__*/ function() {
|
|
|
31616
32715
|
// 创建纹理前恢复状态
|
|
31617
32716
|
context.restore();
|
|
31618
32717
|
// 创建新纹理
|
|
31619
|
-
var imageData = context.getImageData(0, 0,
|
|
32718
|
+
var imageData = context.getImageData(0, 0, textureWidth, textureHeight);
|
|
31620
32719
|
var texture = Texture.createWithData(this.engine, {
|
|
31621
32720
|
data: new Uint8Array(imageData.data),
|
|
31622
32721
|
width: imageData.width,
|
|
@@ -33585,45 +34684,42 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
33585
34684
|
easingOuts: [],
|
|
33586
34685
|
shapes: []
|
|
33587
34686
|
};
|
|
34687
|
+
var _obj;
|
|
33588
34688
|
// Create Geometry
|
|
33589
34689
|
//-------------------------------------------------------------------------
|
|
33590
34690
|
_this.geometry = Geometry.create(_this.engine, {
|
|
33591
|
-
attributes: {
|
|
33592
|
-
|
|
33593
|
-
|
|
33594
|
-
|
|
33595
|
-
|
|
33596
|
-
|
|
33597
|
-
|
|
33598
|
-
|
|
33599
|
-
|
|
33600
|
-
|
|
33601
|
-
|
|
33602
|
-
|
|
33603
|
-
|
|
33604
|
-
|
|
33605
|
-
|
|
33606
|
-
|
|
33607
|
-
|
|
33608
|
-
|
|
33609
|
-
|
|
33610
|
-
|
|
33611
|
-
|
|
33612
|
-
|
|
33613
|
-
|
|
33614
|
-
|
|
33615
|
-
|
|
33616
|
-
|
|
33617
|
-
|
|
33618
|
-
|
|
33619
|
-
|
|
33620
|
-
|
|
33621
|
-
|
|
33622
|
-
|
|
33623
|
-
0
|
|
33624
|
-
])
|
|
33625
|
-
}
|
|
33626
|
-
},
|
|
34691
|
+
attributes: (_obj = {}, _obj[VertexBuffer.PositionKind] = {
|
|
34692
|
+
type: glContext.FLOAT,
|
|
34693
|
+
size: 3,
|
|
34694
|
+
data: new Float32Array([
|
|
34695
|
+
-0.5,
|
|
34696
|
+
0.5,
|
|
34697
|
+
0,
|
|
34698
|
+
-0.5,
|
|
34699
|
+
-0.5,
|
|
34700
|
+
0,
|
|
34701
|
+
0.5,
|
|
34702
|
+
0.5,
|
|
34703
|
+
0,
|
|
34704
|
+
0.5,
|
|
34705
|
+
-0.5,
|
|
34706
|
+
0
|
|
34707
|
+
])
|
|
34708
|
+
}, _obj[VertexBuffer.UVKind] = {
|
|
34709
|
+
size: 2,
|
|
34710
|
+
offset: 0,
|
|
34711
|
+
type: glContext.FLOAT,
|
|
34712
|
+
data: new Float32Array([
|
|
34713
|
+
0,
|
|
34714
|
+
1,
|
|
34715
|
+
0,
|
|
34716
|
+
0,
|
|
34717
|
+
1,
|
|
34718
|
+
1,
|
|
34719
|
+
1,
|
|
34720
|
+
0
|
|
34721
|
+
])
|
|
34722
|
+
}, _obj),
|
|
33627
34723
|
indices: {
|
|
33628
34724
|
data: new Uint16Array([
|
|
33629
34725
|
0,
|
|
@@ -33632,11 +34728,11 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
33632
34728
|
2,
|
|
33633
34729
|
1,
|
|
33634
34730
|
3
|
|
33635
|
-
])
|
|
33636
|
-
releasable: true
|
|
34731
|
+
])
|
|
33637
34732
|
},
|
|
33638
34733
|
mode: glContext.TRIANGLES,
|
|
33639
|
-
drawCount: 6
|
|
34734
|
+
drawCount: 6,
|
|
34735
|
+
bufferUsage: glContext.DYNAMIC_DRAW
|
|
33640
34736
|
});
|
|
33641
34737
|
_this.geometry.subMeshes.push({
|
|
33642
34738
|
offset: 0,
|
|
@@ -33702,7 +34798,7 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
33702
34798
|
return boundingBox;
|
|
33703
34799
|
};
|
|
33704
34800
|
_proto.getBoundingBoxInfo = function getBoundingBoxInfo() {
|
|
33705
|
-
var positionArray = this.geometry.getAttributeData(
|
|
34801
|
+
var positionArray = this.geometry.getAttributeData(VertexBuffer.PositionKind);
|
|
33706
34802
|
if (positionArray) {
|
|
33707
34803
|
var minMaxResult = extractMinAndMax(positionArray, 0, positionArray.length / 3);
|
|
33708
34804
|
minMaxResult.minimum.x *= this.transform.size.x;
|
|
@@ -33753,8 +34849,8 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
33753
34849
|
var strokeIndexCount = indices.length - fillIndexCount;
|
|
33754
34850
|
var vertexCount = vertices.length / 2;
|
|
33755
34851
|
// Get the current attribute and index arrays from the geometry, avoiding re-creation
|
|
33756
|
-
var positionArray = this.geometry.getAttributeData(
|
|
33757
|
-
var uvArray = this.geometry.getAttributeData(
|
|
34852
|
+
var positionArray = this.geometry.getAttributeData(VertexBuffer.PositionKind);
|
|
34853
|
+
var uvArray = this.geometry.getAttributeData(VertexBuffer.UVKind);
|
|
33758
34854
|
var indexArray = this.geometry.getIndexData();
|
|
33759
34855
|
if (!positionArray || positionArray.length < vertexCount * 3) {
|
|
33760
34856
|
positionArray = new Float32Array(vertexCount * 3);
|
|
@@ -33795,8 +34891,8 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
33795
34891
|
// Set index array
|
|
33796
34892
|
indexArray.set(indices);
|
|
33797
34893
|
// Rewrite to geometry
|
|
33798
|
-
this.
|
|
33799
|
-
this.
|
|
34894
|
+
this.updateAttributeData(VertexBuffer.PositionKind, positionArray, 3);
|
|
34895
|
+
this.updateAttributeData(VertexBuffer.UVKind, uvArray, 2);
|
|
33800
34896
|
this.geometry.setIndexData(indexArray);
|
|
33801
34897
|
this.geometry.setDrawCount(indices.length);
|
|
33802
34898
|
var u16Size = 2;
|
|
@@ -33806,6 +34902,18 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
33806
34902
|
strokeSubMesh.offset = fillIndexCount * u16Size;
|
|
33807
34903
|
strokeSubMesh.indexCount = strokeIndexCount;
|
|
33808
34904
|
};
|
|
34905
|
+
_proto.updateAttributeData = function updateAttributeData(name, data, size) {
|
|
34906
|
+
var _this_geometry_getVertexBuffer;
|
|
34907
|
+
var dataBuffer = (_this_geometry_getVertexBuffer = this.geometry.getVertexBuffer(name)) == null ? void 0 : _this_geometry_getVertexBuffer.getBuffer();
|
|
34908
|
+
if (dataBuffer && data.byteLength > dataBuffer.capacity) {
|
|
34909
|
+
this.geometry.setVerticesBuffer(new VertexBuffer(this.engine, data, name, {
|
|
34910
|
+
updatable: true,
|
|
34911
|
+
size: size
|
|
34912
|
+
}));
|
|
34913
|
+
return;
|
|
34914
|
+
}
|
|
34915
|
+
this.geometry.setAttributeData(name, data);
|
|
34916
|
+
};
|
|
33809
34917
|
_proto.computeScreenScale = function computeScreenScale() {
|
|
33810
34918
|
var defaultPpu = 1;
|
|
33811
34919
|
var composition = this.item.composition;
|
|
@@ -36582,7 +37690,7 @@ function getStandardSpriteContent(sprite, transform) {
|
|
|
36582
37690
|
return ret;
|
|
36583
37691
|
}
|
|
36584
37692
|
|
|
36585
|
-
var version$1 = "2.10.0-alpha.
|
|
37693
|
+
var version$1 = "2.10.0-alpha.2";
|
|
36586
37694
|
var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
|
|
36587
37695
|
var standardVersion = /^(\d+)\.(\d+)$/;
|
|
36588
37696
|
var reverseParticle = false;
|
|
@@ -38373,11 +39481,6 @@ var tmpScale = new Vector3(1, 1, 1);
|
|
|
38373
39481
|
return Camera;
|
|
38374
39482
|
}();
|
|
38375
39483
|
|
|
38376
|
-
function _assert_this_initialized(self) {
|
|
38377
|
-
if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
38378
|
-
return self;
|
|
38379
|
-
}
|
|
38380
|
-
|
|
38381
39484
|
/**
|
|
38382
39485
|
*
|
|
38383
39486
|
*/ var SceneTicking = /*#__PURE__*/ function() {
|
|
@@ -38544,7 +39647,7 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
|
|
|
38544
39647
|
_this.paused = true;
|
|
38545
39648
|
_this.isEndCalled = false;
|
|
38546
39649
|
_this._textures = [];
|
|
38547
|
-
var _ref = props != null ? props : {}, _ref_reusable = _ref.reusable, reusable = _ref_reusable === void 0 ? false : _ref_reusable, _ref_speed = _ref.speed, speed = _ref_speed === void 0 ? 1 : _ref_speed, _ref_baseRenderOrder = _ref.baseRenderOrder, baseRenderOrder = _ref_baseRenderOrder === void 0 ? 0 : _ref_baseRenderOrder,
|
|
39650
|
+
var _ref = props != null ? props : {}, _ref_reusable = _ref.reusable, reusable = _ref_reusable === void 0 ? false : _ref_reusable, _ref_speed = _ref.speed, speed = _ref_speed === void 0 ? 1 : _ref_speed, _ref_baseRenderOrder = _ref.baseRenderOrder, baseRenderOrder = _ref_baseRenderOrder === void 0 ? 0 : _ref_baseRenderOrder, onItemMessage = _ref.onItemMessage;
|
|
38548
39651
|
_this.engine.addComposition(_assert_this_initialized(_this));
|
|
38549
39652
|
var sourceContent = null;
|
|
38550
39653
|
if (scene) {
|
|
@@ -38602,7 +39705,7 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
|
|
|
38602
39705
|
_this.id = (_sourceContent_id = sourceContent == null ? void 0 : sourceContent.id) != null ? _sourceContent_id : generateGUID();
|
|
38603
39706
|
var _sourceContent_startTime;
|
|
38604
39707
|
_this.startTime = (_sourceContent_startTime = sourceContent == null ? void 0 : sourceContent.startTime) != null ? _sourceContent_startTime : 0;
|
|
38605
|
-
_this.event =
|
|
39708
|
+
_this.event = engine.eventSystem;
|
|
38606
39709
|
var _scene_startTime, _scene_totalTime;
|
|
38607
39710
|
_this.statistic = {
|
|
38608
39711
|
loadStart: (_scene_startTime = scene == null ? void 0 : scene.startTime) != null ? _scene_startTime : 0,
|
|
@@ -40948,6 +42051,7 @@ var DEFAULT_FPS = 60;
|
|
|
40948
42051
|
_this.renderPasses = [];
|
|
40949
42052
|
_this.framebuffers = [];
|
|
40950
42053
|
_this.renderbuffers = [];
|
|
42054
|
+
_this.particleSystems = [];
|
|
40951
42055
|
_this.clearAction = {
|
|
40952
42056
|
stencilAction: exports.TextureLoadAction.clear,
|
|
40953
42057
|
clearStencil: 0,
|
|
@@ -40986,7 +42090,6 @@ var DEFAULT_FPS = 60;
|
|
|
40986
42090
|
_this.assetLoader = new AssetLoader(_assert_this_initialized(_this));
|
|
40987
42091
|
_this.assetService = new AssetService(_assert_this_initialized(_this));
|
|
40988
42092
|
_this.renderTargetPool = new RenderTargetPool(_assert_this_initialized(_this));
|
|
40989
|
-
_this.graphics = new Graphics(_assert_this_initialized(_this));
|
|
40990
42093
|
_this.renderingData = {
|
|
40991
42094
|
// @ts-expect-error
|
|
40992
42095
|
currentFrame: {}
|
|
@@ -41197,55 +42300,27 @@ var DEFAULT_FPS = 60;
|
|
|
41197
42300
|
});
|
|
41198
42301
|
this.emit("resize", this);
|
|
41199
42302
|
};
|
|
41200
|
-
_proto.
|
|
41201
|
-
|
|
41202
|
-
|
|
41203
|
-
|
|
41204
|
-
|
|
41205
|
-
|
|
41206
|
-
|
|
41207
|
-
|
|
41208
|
-
|
|
41209
|
-
|
|
41210
|
-
|
|
41211
|
-
|
|
41212
|
-
|
|
41213
|
-
|
|
41214
|
-
|
|
41215
|
-
|
|
41216
|
-
|
|
41217
|
-
|
|
41218
|
-
|
|
41219
|
-
|
|
41220
|
-
|
|
41221
|
-
targetHeight = finalHeight * this.displayScale;
|
|
41222
|
-
targetWidth = targetHeight * displayAspect;
|
|
41223
|
-
} else {
|
|
41224
|
-
targetWidth = finalWidth * this.displayScale;
|
|
41225
|
-
targetHeight = targetWidth / displayAspect;
|
|
41226
|
-
}
|
|
41227
|
-
} else {
|
|
41228
|
-
targetWidth = finalWidth;
|
|
41229
|
-
targetHeight = finalHeight;
|
|
41230
|
-
}
|
|
41231
|
-
var ratio = this.pixelRatio;
|
|
41232
|
-
var containerWidth = targetWidth;
|
|
41233
|
-
var containerHeight = targetHeight;
|
|
41234
|
-
targetWidth = Math.round(targetWidth * ratio);
|
|
41235
|
-
targetHeight = Math.round(targetHeight * ratio);
|
|
41236
|
-
if (targetWidth < 1 || targetHeight < 1) {
|
|
41237
|
-
if (this.offscreenMode) {
|
|
41238
|
-
targetWidth = targetHeight = containerWidth = containerHeight = 1;
|
|
41239
|
-
} else {
|
|
41240
|
-
throw new Error("Invalid container size " + targetWidth + "x" + targetHeight + ", see " + HELP_LINK["Invalid container size"] + ".");
|
|
41241
|
-
}
|
|
41242
|
-
}
|
|
41243
|
-
return [
|
|
41244
|
-
containerWidth,
|
|
41245
|
-
containerHeight,
|
|
41246
|
-
targetWidth,
|
|
41247
|
-
targetHeight
|
|
41248
|
-
];
|
|
42303
|
+
_proto.createVertexBuffer = function createVertexBuffer(data, options) {
|
|
42304
|
+
throw new Error("The active rendering backend does not provide vertex buffers.");
|
|
42305
|
+
};
|
|
42306
|
+
_proto.createDynamicVertexBuffer = function createDynamicVertexBuffer(data, options) {
|
|
42307
|
+
return this.createVertexBuffer(data, options);
|
|
42308
|
+
};
|
|
42309
|
+
_proto.createIndexBuffer = function createIndexBuffer(indices, options) {
|
|
42310
|
+
throw new Error("The active rendering backend does not provide index buffers.");
|
|
42311
|
+
};
|
|
42312
|
+
_proto.updateDynamicVertexBuffer = function updateDynamicVertexBuffer(vertexBuffer, data, byteOffset, byteLength) {
|
|
42313
|
+
throw new Error("The active rendering backend cannot update vertex buffers.");
|
|
42314
|
+
};
|
|
42315
|
+
_proto.updateDynamicIndexBuffer = function updateDynamicIndexBuffer(indexBuffer, indices, byteOffset) {
|
|
42316
|
+
throw new Error("The active rendering backend cannot update index buffers.");
|
|
42317
|
+
};
|
|
42318
|
+
/** @hide */ _proto.releaseBuffer = function releaseBuffer(buffer) {
|
|
42319
|
+
buffer.references--;
|
|
42320
|
+
return buffer.references === 0;
|
|
42321
|
+
};
|
|
42322
|
+
/** @hide */ _proto.bindBuffers = function bindBuffers(vertexBuffers, indexBuffer, effect) {
|
|
42323
|
+
throw new Error("The active rendering backend cannot bind geometry buffers.");
|
|
41249
42324
|
};
|
|
41250
42325
|
_proto.addTexture = function addTexture(tex) {
|
|
41251
42326
|
if (this.disposed) {
|
|
@@ -41283,6 +42358,18 @@ var DEFAULT_FPS = 60;
|
|
|
41283
42358
|
}
|
|
41284
42359
|
removeItem(this.geometries, geo);
|
|
41285
42360
|
};
|
|
42361
|
+
/** @internal */ _proto.addParticleSystem = function addParticleSystem(particleSystem) {
|
|
42362
|
+
if (this.disposed) {
|
|
42363
|
+
return;
|
|
42364
|
+
}
|
|
42365
|
+
addItem(this.particleSystems, particleSystem);
|
|
42366
|
+
};
|
|
42367
|
+
/** @internal */ _proto.removeParticleSystem = function removeParticleSystem(particleSystem) {
|
|
42368
|
+
if (this.disposed) {
|
|
42369
|
+
return;
|
|
42370
|
+
}
|
|
42371
|
+
removeItem(this.particleSystems, particleSystem);
|
|
42372
|
+
};
|
|
41286
42373
|
_proto.addMesh = function addMesh(mesh) {
|
|
41287
42374
|
if (this.disposed) {
|
|
41288
42375
|
return;
|
|
@@ -41435,7 +42522,7 @@ var DEFAULT_FPS = 60;
|
|
|
41435
42522
|
/**
|
|
41436
42523
|
* 销毁所有缓存的资源
|
|
41437
42524
|
*/ _proto.dispose = function dispose() {
|
|
41438
|
-
var _this_ticker, _this_eventSystem, _this_assetService;
|
|
42525
|
+
var _this_ticker, _this_eventSystem, _this_assetService, _this__graphics;
|
|
41439
42526
|
if (this.disposed) {
|
|
41440
42527
|
return;
|
|
41441
42528
|
}
|
|
@@ -41460,7 +42547,7 @@ var DEFAULT_FPS = 60;
|
|
|
41460
42547
|
(_this_ticker = this.ticker) == null ? void 0 : _this_ticker.stop();
|
|
41461
42548
|
(_this_eventSystem = this.eventSystem) == null ? void 0 : _this_eventSystem.dispose();
|
|
41462
42549
|
(_this_assetService = this.assetService) == null ? void 0 : _this_assetService.dispose();
|
|
41463
|
-
this.
|
|
42550
|
+
(_this__graphics = this._graphics) == null ? void 0 : _this__graphics.dispose();
|
|
41464
42551
|
this.renderPasses.forEach(function(pass) {
|
|
41465
42552
|
return pass.dispose();
|
|
41466
42553
|
});
|
|
@@ -41488,8 +42575,69 @@ var DEFAULT_FPS = 60;
|
|
|
41488
42575
|
this.meshes = [];
|
|
41489
42576
|
this.renderPasses = [];
|
|
41490
42577
|
this.compositions = [];
|
|
42578
|
+
this.particleSystems = [];
|
|
42579
|
+
};
|
|
42580
|
+
_proto.getTargetSize = function getTargetSize(parentEle) {
|
|
42581
|
+
if (parentEle === undefined || parentEle === null) {
|
|
42582
|
+
throw new Error("Container is not an HTMLElement, see " + HELP_LINK["Container is not an HTMLElement"] + ".");
|
|
42583
|
+
}
|
|
42584
|
+
var displayAspect = this.displayAspect;
|
|
42585
|
+
// 小程序环境没有 getComputedStyle
|
|
42586
|
+
var computedStyle = window.getComputedStyle == null ? void 0 : window.getComputedStyle.call(window, parentEle);
|
|
42587
|
+
var targetWidth;
|
|
42588
|
+
var targetHeight;
|
|
42589
|
+
var finalWidth = 0;
|
|
42590
|
+
var finalHeight = 0;
|
|
42591
|
+
if (computedStyle) {
|
|
42592
|
+
finalWidth = parseInt(computedStyle.width, 10);
|
|
42593
|
+
finalHeight = parseInt(computedStyle.height, 10);
|
|
42594
|
+
} else {
|
|
42595
|
+
finalWidth = parentEle.clientWidth;
|
|
42596
|
+
finalHeight = parentEle.clientHeight;
|
|
42597
|
+
}
|
|
42598
|
+
if (displayAspect) {
|
|
42599
|
+
var parentAspect = finalWidth / finalHeight;
|
|
42600
|
+
if (parentAspect > displayAspect) {
|
|
42601
|
+
targetHeight = finalHeight * this.displayScale;
|
|
42602
|
+
targetWidth = targetHeight * displayAspect;
|
|
42603
|
+
} else {
|
|
42604
|
+
targetWidth = finalWidth * this.displayScale;
|
|
42605
|
+
targetHeight = targetWidth / displayAspect;
|
|
42606
|
+
}
|
|
42607
|
+
} else {
|
|
42608
|
+
targetWidth = finalWidth;
|
|
42609
|
+
targetHeight = finalHeight;
|
|
42610
|
+
}
|
|
42611
|
+
var ratio = this.pixelRatio;
|
|
42612
|
+
var containerWidth = targetWidth;
|
|
42613
|
+
var containerHeight = targetHeight;
|
|
42614
|
+
targetWidth = Math.round(targetWidth * ratio);
|
|
42615
|
+
targetHeight = Math.round(targetHeight * ratio);
|
|
42616
|
+
if (targetWidth < 1 || targetHeight < 1) {
|
|
42617
|
+
if (this.offscreenMode) {
|
|
42618
|
+
targetWidth = targetHeight = containerWidth = containerHeight = 1;
|
|
42619
|
+
} else {
|
|
42620
|
+
throw new Error("Invalid container size " + targetWidth + "x" + targetHeight + ", see " + HELP_LINK["Invalid container size"] + ".");
|
|
42621
|
+
}
|
|
42622
|
+
}
|
|
42623
|
+
return [
|
|
42624
|
+
containerWidth,
|
|
42625
|
+
containerHeight,
|
|
42626
|
+
targetWidth,
|
|
42627
|
+
targetHeight
|
|
42628
|
+
];
|
|
41491
42629
|
};
|
|
41492
42630
|
_create_class(Engine, [
|
|
42631
|
+
{
|
|
42632
|
+
key: "graphics",
|
|
42633
|
+
get: function get() {
|
|
42634
|
+
if (this._graphics) {
|
|
42635
|
+
return this._graphics;
|
|
42636
|
+
}
|
|
42637
|
+
this._graphics = new Graphics(this);
|
|
42638
|
+
return this._graphics;
|
|
42639
|
+
}
|
|
42640
|
+
},
|
|
41493
42641
|
{
|
|
41494
42642
|
key: "disposed",
|
|
41495
42643
|
get: function get() {
|
|
@@ -41652,9 +42800,7 @@ var PassTextureCache = /*#__PURE__*/ function() {
|
|
|
41652
42800
|
};
|
|
41653
42801
|
SceneLoader.createComposition = function createComposition(scene, engine, options) {
|
|
41654
42802
|
if (options === void 0) options = {};
|
|
41655
|
-
var composition = new Composition(engine, _extends({}, options,
|
|
41656
|
-
event: engine.eventSystem
|
|
41657
|
-
}), scene);
|
|
42803
|
+
var composition = new Composition(engine, _extends({}, options), scene);
|
|
41658
42804
|
// TODO 目前编辑器会每帧调用 loadScene, 在这编译会导致闪帧,待编辑器渲染逻辑优化后移除。
|
|
41659
42805
|
if (engine.env !== PLAYER_OPTIONS_ENV_EDITOR) {
|
|
41660
42806
|
engine.assetService.createShaderVariant();
|
|
@@ -41707,7 +42853,7 @@ var PrecompositionManager = /*#__PURE__*/ function() {
|
|
|
41707
42853
|
rootItem.instantiatePreComposition(compositionData);
|
|
41708
42854
|
var _options_autoplay;
|
|
41709
42855
|
rootItem.getComponent(exports.CompositionComponent).playOnStart = (_options_autoplay = options.autoplay) != null ? _options_autoplay : true;
|
|
41710
|
-
rootItem.getComponent(exports.CompositionComponent).endBehavior =
|
|
42856
|
+
rootItem.getComponent(exports.CompositionComponent).endBehavior = rootItem.endBehavior;
|
|
41711
42857
|
composition.addItem(rootItem);
|
|
41712
42858
|
return rootItem;
|
|
41713
42859
|
};
|
|
@@ -41719,7 +42865,7 @@ registerPlugin("text", TextLoader);
|
|
|
41719
42865
|
registerPlugin("sprite", SpriteLoader);
|
|
41720
42866
|
registerPlugin("particle", ParticleLoader);
|
|
41721
42867
|
registerPlugin("interact", InteractLoader);
|
|
41722
|
-
var version = "2.10.0-alpha.
|
|
42868
|
+
var version = "2.10.0-alpha.2";
|
|
41723
42869
|
logger.info("Core version: " + version + ".");
|
|
41724
42870
|
|
|
41725
42871
|
exports.ATLAS_SIZE = ATLAS_SIZE;
|
|
@@ -41748,6 +42894,7 @@ exports.BezierQuat = BezierQuat;
|
|
|
41748
42894
|
exports.BlendNode = BlendNode;
|
|
41749
42895
|
exports.BoolValueNode = BoolValueNode;
|
|
41750
42896
|
exports.BoundingBoxInfo = BoundingBoxInfo;
|
|
42897
|
+
exports.Buffer = Buffer;
|
|
41751
42898
|
exports.COPY_FRAGMENT_SHADER = COPY_FRAGMENT_SHADER;
|
|
41752
42899
|
exports.COPY_MESH_SHADER_ID = COPY_MESH_SHADER_ID;
|
|
41753
42900
|
exports.COPY_VERTEX_SHADER = COPY_VERTEX_SHADER;
|
|
@@ -41773,6 +42920,7 @@ exports.ControlParameterFloatNode = ControlParameterFloatNode;
|
|
|
41773
42920
|
exports.ControlParameterTriggerNode = ControlParameterTriggerNode;
|
|
41774
42921
|
exports.DEFAULT_FONTS = DEFAULT_FONTS;
|
|
41775
42922
|
exports.DEFAULT_FPS = DEFAULT_FPS;
|
|
42923
|
+
exports.DataBuffer = DataBuffer;
|
|
41776
42924
|
exports.Database = Database;
|
|
41777
42925
|
exports.Deferred = Deferred;
|
|
41778
42926
|
exports.Downloader = Downloader;
|
|
@@ -41912,6 +43060,7 @@ exports.Vector3Curve = Vector3Curve;
|
|
|
41912
43060
|
exports.Vector3PropertyMixerPlayable = Vector3PropertyMixerPlayable;
|
|
41913
43061
|
exports.Vector4Curve = Vector4Curve;
|
|
41914
43062
|
exports.Vector4PropertyMixerPlayable = Vector4PropertyMixerPlayable;
|
|
43063
|
+
exports.VertexBuffer = VertexBuffer;
|
|
41915
43064
|
exports.addByOrder = addByOrder;
|
|
41916
43065
|
exports.addItem = addItem;
|
|
41917
43066
|
exports.addItemWithOrder = addItemWithOrder;
|
|
@@ -41934,6 +43083,7 @@ exports.combineImageTemplate = combineImageTemplate;
|
|
|
41934
43083
|
exports.createGLContext = createGLContext;
|
|
41935
43084
|
exports.createKeyFrameMeta = createKeyFrameMeta;
|
|
41936
43085
|
exports.createShape = createShape;
|
|
43086
|
+
exports.createTypedArray = createTypedArray;
|
|
41937
43087
|
exports.createValueGetter = createValueGetter;
|
|
41938
43088
|
exports.curveEps = curveEps;
|
|
41939
43089
|
exports.decimalEqual = decimalEqual;
|
|
@@ -41954,10 +43104,13 @@ exports.generateGUID = generateGUID;
|
|
|
41954
43104
|
exports.generateHalfFloatTexture = generateHalfFloatTexture;
|
|
41955
43105
|
exports.generateWhiteTexture = generateWhiteTexture;
|
|
41956
43106
|
exports.getBackgroundImage = getBackgroundImage;
|
|
43107
|
+
exports.getBytesPerElement = getBytesPerElement;
|
|
41957
43108
|
exports.getClass = getClass;
|
|
41958
43109
|
exports.getColorFromGradientStops = getColorFromGradientStops;
|
|
41959
43110
|
exports.getConfig = getConfig;
|
|
41960
43111
|
exports.getControlPoints = getControlPoints;
|
|
43112
|
+
exports.getDataByteLength = getDataByteLength;
|
|
43113
|
+
exports.getDataType = getDataType;
|
|
41961
43114
|
exports.getDefaultTextureFactory = getDefaultTextureFactory;
|
|
41962
43115
|
exports.getGeometryByShape = getGeometryByShape;
|
|
41963
43116
|
exports.getGeometryTriangles = getGeometryTriangles;
|
|
@@ -42046,6 +43199,7 @@ exports.spec = index$1;
|
|
|
42046
43199
|
exports.textureLoaderRegistry = textureLoaderRegistry;
|
|
42047
43200
|
exports.thresholdFrag = thresholdFrag;
|
|
42048
43201
|
exports.throwDestroyedError = throwDestroyedError;
|
|
43202
|
+
exports.toBufferView = toBufferView;
|
|
42049
43203
|
exports.trailVert = trailVert;
|
|
42050
43204
|
exports.translatePoint = translatePoint;
|
|
42051
43205
|
exports.trianglesFromRect = trianglesFromRect;
|