@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/index.mjs 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.1
6
+ * Version: v2.10.0-alpha.2
7
7
  */
8
8
 
9
9
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
@@ -11647,10 +11647,11 @@ var GLSLVersion;
11647
11647
  })(GLSLVersion || (GLSLVersion = {}));
11648
11648
  var ShaderVariant = /*#__PURE__*/ function(EffectsObject) {
11649
11649
  _inherits(ShaderVariant, EffectsObject);
11650
- function ShaderVariant(engine, source) {
11650
+ function ShaderVariant(engine, source, key) {
11651
11651
  var _this;
11652
11652
  _this = EffectsObject.call(this, engine) || this;
11653
11653
  _this.source = source;
11654
+ _this.key = key;
11654
11655
  return _this;
11655
11656
  }
11656
11657
  var _proto = ShaderVariant.prototype;
@@ -12729,6 +12730,30 @@ var MAX_MASK_REFERENCE_COUNT = 254;
12729
12730
  /**
12730
12731
  * 期望的 stencil 值(等于正向蒙版的数量)
12731
12732
  */ this.expectedStencilValue = 0;
12733
+ this.prevStencilFunc = [
12734
+ 0,
12735
+ 0
12736
+ ];
12737
+ this.prevStencilOpFail = [
12738
+ 0,
12739
+ 0
12740
+ ];
12741
+ this.prevStencilOpZFail = [
12742
+ 0,
12743
+ 0
12744
+ ];
12745
+ this.prevStencilOpZPass = [
12746
+ 0,
12747
+ 0
12748
+ ];
12749
+ this.prevStencilRef = [
12750
+ 0,
12751
+ 0
12752
+ ];
12753
+ this.prevStencilMask = [
12754
+ 0,
12755
+ 0
12756
+ ];
12732
12757
  this.stencilClearAction = {
12733
12758
  stencilAction: TextureLoadAction.clear
12734
12759
  };
@@ -12886,22 +12911,22 @@ var MAX_MASK_REFERENCE_COUNT = 254;
12886
12911
  if (subMeshIndex === void 0) subMeshIndex = 0;
12887
12912
  var prevColorMask = material.colorMask;
12888
12913
  var prevStencilTest = material.stencilTest;
12889
- var prevStencilFunc = material.stencilFunc;
12890
- var prevStencilOpFail = material.stencilOpFail;
12891
- var prevStencilOpZFail = material.stencilOpZFail;
12892
- var prevStencilOpZPass = material.stencilOpZPass;
12893
- var prevStencilRef = material.stencilRef;
12894
- var prevStencilMask = material.stencilMask;
12914
+ this.copyStencilArrayValue(this.prevStencilFunc, material.stencilFunc);
12915
+ this.copyStencilArrayValue(this.prevStencilOpFail, material.stencilOpFail);
12916
+ this.copyStencilArrayValue(this.prevStencilOpZFail, material.stencilOpZFail);
12917
+ this.copyStencilArrayValue(this.prevStencilOpZPass, material.stencilOpZPass);
12918
+ this.copyStencilArrayValue(this.prevStencilRef, material.stencilRef);
12919
+ this.copyStencilArrayValue(this.prevStencilMask, material.stencilMask);
12895
12920
  this.setupMaskMaterial(material, maskRef);
12896
12921
  renderer.drawGeometry(geometry, worldMatrix, material, subMeshIndex);
12897
12922
  material.colorMask = prevColorMask;
12898
12923
  material.stencilTest = prevStencilTest;
12899
- material.stencilFunc = prevStencilFunc;
12900
- material.stencilOpFail = prevStencilOpFail;
12901
- material.stencilOpZFail = prevStencilOpZFail;
12902
- material.stencilOpZPass = prevStencilOpZPass;
12903
- material.stencilRef = prevStencilRef;
12904
- material.stencilMask = prevStencilMask;
12924
+ material.stencilFunc = this.prevStencilFunc;
12925
+ material.stencilOpFail = this.prevStencilOpFail;
12926
+ material.stencilOpZFail = this.prevStencilOpZFail;
12927
+ material.stencilOpZPass = this.prevStencilOpZPass;
12928
+ material.stencilRef = this.prevStencilRef;
12929
+ material.stencilMask = this.prevStencilMask;
12905
12930
  };
12906
12931
  /**
12907
12932
  * 设置蒙版材质的 stencil 属性(写入蒙版)
@@ -12975,6 +13000,13 @@ var MAX_MASK_REFERENCE_COUNT = 254;
12975
13000
  material.stencilTest = false;
12976
13001
  }
12977
13002
  };
13003
+ _proto.copyStencilArrayValue = function copyStencilArrayValue(target, source) {
13004
+ if (!source) {
13005
+ return;
13006
+ }
13007
+ target[0] = source[0];
13008
+ target[1] = source[1];
13009
+ };
12978
13010
  _create_class(MaskProcessor, [
12979
13011
  {
12980
13012
  key: "maskable",
@@ -12999,6 +13031,401 @@ var MAX_MASK_REFERENCE_COUNT = 254;
12999
13031
  return MaskProcessor;
13000
13032
  }();
13001
13033
 
13034
+ var BufferUsage;
13035
+ (function(BufferUsage) {
13036
+ BufferUsage[BufferUsage["Stream"] = 35040] = "Stream";
13037
+ BufferUsage[BufferUsage["Static"] = 35044] = "Static";
13038
+ BufferUsage[BufferUsage["Dynamic"] = 35048] = "Dynamic";
13039
+ })(BufferUsage || (BufferUsage = {}));
13040
+ var BufferDataType;
13041
+ (function(BufferDataType) {
13042
+ BufferDataType[BufferDataType["Byte"] = 5120] = "Byte";
13043
+ BufferDataType[BufferDataType["UnsignedByte"] = 5121] = "UnsignedByte";
13044
+ BufferDataType[BufferDataType["Short"] = 5122] = "Short";
13045
+ BufferDataType[BufferDataType["UnsignedShort"] = 5123] = "UnsignedShort";
13046
+ BufferDataType[BufferDataType["Int"] = 5124] = "Int";
13047
+ BufferDataType[BufferDataType["UnsignedInt"] = 5125] = "UnsignedInt";
13048
+ BufferDataType[BufferDataType["Float"] = 5126] = "Float";
13049
+ })(BufferDataType || (BufferDataType = {}));
13050
+ /**
13051
+ * 后端缓冲区的最小抽象,只保存资源状态。
13052
+ */ var DataBuffer = /*#__PURE__*/ function() {
13053
+ function DataBuffer() {
13054
+ this.references = 0;
13055
+ this.capacity = 0;
13056
+ this.is32Bits = false;
13057
+ }
13058
+ _create_class(DataBuffer, [
13059
+ {
13060
+ key: "underlyingResource",
13061
+ get: function get() {
13062
+ return null;
13063
+ }
13064
+ }
13065
+ ]);
13066
+ return DataBuffer;
13067
+ }();
13068
+ function getBytesPerElement(type) {
13069
+ switch(type){
13070
+ case 5120:
13071
+ case 5121:
13072
+ return 1;
13073
+ case 5122:
13074
+ case 5123:
13075
+ return 2;
13076
+ case 5124:
13077
+ case 5125:
13078
+ case 5126:
13079
+ return 4;
13080
+ default:
13081
+ return 0;
13082
+ }
13083
+ }
13084
+ function getDataType(data) {
13085
+ if (_instanceof1(data, Int8Array)) {
13086
+ return 5120;
13087
+ }
13088
+ if (_instanceof1(data, Uint8Array)) {
13089
+ return 5121;
13090
+ }
13091
+ if (_instanceof1(data, Int16Array)) {
13092
+ return 5122;
13093
+ }
13094
+ if (_instanceof1(data, Uint16Array)) {
13095
+ return 5123;
13096
+ }
13097
+ if (_instanceof1(data, Int32Array)) {
13098
+ return 5124;
13099
+ }
13100
+ if (_instanceof1(data, Uint32Array)) {
13101
+ return 5125;
13102
+ }
13103
+ return 5126;
13104
+ }
13105
+ function getDataByteLength(data) {
13106
+ if (Array.isArray(data)) {
13107
+ return data.length * Float32Array.BYTES_PER_ELEMENT;
13108
+ }
13109
+ return data.byteLength;
13110
+ }
13111
+ function toBufferView(data) {
13112
+ if (Array.isArray(data)) {
13113
+ return new Float32Array(data);
13114
+ }
13115
+ if (_instanceof1(data, ArrayBuffer)) {
13116
+ return new Uint8Array(data);
13117
+ }
13118
+ return data;
13119
+ }
13120
+ function createTypedArray(type, length) {
13121
+ switch(type){
13122
+ case 5120:
13123
+ return new Int8Array(length);
13124
+ case 5121:
13125
+ return new Uint8Array(length);
13126
+ case 5122:
13127
+ return new Int16Array(length);
13128
+ case 5123:
13129
+ return new Uint16Array(length);
13130
+ case 5124:
13131
+ return new Int32Array(length);
13132
+ case 5125:
13133
+ return new Uint32Array(length);
13134
+ default:
13135
+ return new Float32Array(length);
13136
+ }
13137
+ }
13138
+
13139
+ /**
13140
+ * 管理顶点数据及其对应的后端缓冲区。
13141
+ */ var Buffer = /*#__PURE__*/ function() {
13142
+ function Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes, divisor, label) {
13143
+ if (stride === void 0) stride = 0;
13144
+ if (postponeInternalCreation === void 0) postponeInternalCreation = false;
13145
+ if (instanced === void 0) instanced = false;
13146
+ if (useBytes === void 0) useBytes = false;
13147
+ this.engine = engine;
13148
+ this.isAlreadyOwned = false;
13149
+ this._isDisposed = false;
13150
+ this.updatable = updatable;
13151
+ this.instanced = instanced;
13152
+ this.divisor = divisor || 1;
13153
+ this.label = label;
13154
+ this.byteStride = useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT;
13155
+ if (_instanceof1(data, DataBuffer)) {
13156
+ this.buffer = data;
13157
+ } else {
13158
+ this.data = data;
13159
+ }
13160
+ if (!postponeInternalCreation) {
13161
+ this.create();
13162
+ }
13163
+ }
13164
+ var _proto = Buffer.prototype;
13165
+ _proto.isUpdatable = function isUpdatable() {
13166
+ return this.updatable;
13167
+ };
13168
+ _proto.getData = function getData() {
13169
+ return this.data;
13170
+ };
13171
+ _proto.getBuffer = function getBuffer() {
13172
+ return this.buffer;
13173
+ };
13174
+ _proto.getStrideSize = function getStrideSize() {
13175
+ return this.byteStride / Float32Array.BYTES_PER_ELEMENT;
13176
+ };
13177
+ _proto.createVertexBuffer = function createVertexBuffer(kind, offset, size, stride, instanced, useBytes, divisor) {
13178
+ if (useBytes === void 0) useBytes = false;
13179
+ var byteOffset = useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT;
13180
+ var byteStride = stride ? useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT : this.byteStride;
13181
+ return new VertexBuffer(this.engine, this, kind, {
13182
+ size: size,
13183
+ stride: byteStride,
13184
+ offset: byteOffset,
13185
+ instanced: instanced === undefined ? this.instanced : instanced,
13186
+ useBytes: true,
13187
+ divisor: divisor != null ? divisor : this.divisor
13188
+ });
13189
+ };
13190
+ _proto.create = function create(data) {
13191
+ if (!data && this.buffer) {
13192
+ return;
13193
+ }
13194
+ data = data != null ? data : this.data;
13195
+ if (!data) {
13196
+ return;
13197
+ }
13198
+ var options = this.getDataBufferOptions(data);
13199
+ if (!this.buffer) {
13200
+ this.buffer = this.updatable ? this.engine.createDynamicVertexBuffer(data, options) : this.engine.createVertexBuffer(data, options);
13201
+ if (this.updatable) {
13202
+ this.data = data;
13203
+ }
13204
+ } else if (this.updatable) {
13205
+ this.engine.updateDynamicVertexBuffer(this.buffer, data);
13206
+ this.data = data;
13207
+ }
13208
+ };
13209
+ _proto.update = function update(data) {
13210
+ this.create(data);
13211
+ };
13212
+ _proto.updateDirectly = function updateDirectly(data, offset, vertexCount, useBytes) {
13213
+ if (useBytes === void 0) useBytes = false;
13214
+ if (!this.buffer || !this.updatable) {
13215
+ return;
13216
+ }
13217
+ this.engine.updateDynamicVertexBuffer(this.buffer, data, useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT, vertexCount ? vertexCount * this.byteStride : undefined);
13218
+ if (offset === 0 && vertexCount === undefined) {
13219
+ this.data = data;
13220
+ } else {
13221
+ this.data = undefined;
13222
+ }
13223
+ };
13224
+ /**
13225
+ * @internal
13226
+ */ _proto.rebuild = function rebuild() {
13227
+ if (!this.data) {
13228
+ if (!this.buffer) {
13229
+ return;
13230
+ }
13231
+ var capacity = this.buffer.capacity;
13232
+ if (capacity > 0) {
13233
+ var options = this.getDataBufferOptions();
13234
+ this.buffer = this.updatable ? this.engine.createDynamicVertexBuffer(capacity, options) : this.engine.createVertexBuffer(capacity, options);
13235
+ } else {
13236
+ this.buffer = undefined;
13237
+ }
13238
+ return;
13239
+ }
13240
+ this.buffer = undefined;
13241
+ this.create(this.data);
13242
+ };
13243
+ /**
13244
+ * @internal
13245
+ */ _proto.increaseReferences = function increaseReferences() {
13246
+ if (!this.buffer) {
13247
+ return;
13248
+ }
13249
+ if (!this.isAlreadyOwned) {
13250
+ this.isAlreadyOwned = true;
13251
+ return;
13252
+ }
13253
+ this.buffer.references++;
13254
+ };
13255
+ _proto.dispose = function dispose() {
13256
+ if (!this.buffer) {
13257
+ return;
13258
+ }
13259
+ if (this.engine.releaseBuffer(this.buffer)) {
13260
+ this.data = undefined;
13261
+ this.buffer = undefined;
13262
+ this._isDisposed = true;
13263
+ }
13264
+ };
13265
+ _proto.getDataBufferOptions = function getDataBufferOptions(data) {
13266
+ return {
13267
+ usage: this.updatable ? BufferUsage.Dynamic : BufferUsage.Static,
13268
+ type: data ? getDataType(data) : BufferDataType.Float,
13269
+ byteStride: this.byteStride,
13270
+ instanceDivisor: this.instanced ? this.divisor : 0,
13271
+ label: this.label
13272
+ };
13273
+ };
13274
+ _create_class(Buffer, [
13275
+ {
13276
+ key: "isDisposed",
13277
+ get: function get() {
13278
+ return this._isDisposed;
13279
+ }
13280
+ },
13281
+ {
13282
+ key: "capacity",
13283
+ get: function get() {
13284
+ var _this_buffer;
13285
+ var _this_buffer_capacity;
13286
+ return (_this_buffer_capacity = (_this_buffer = this.buffer) == null ? void 0 : _this_buffer.capacity) != null ? _this_buffer_capacity : this.data ? getDataByteLength(this.data) : 0;
13287
+ }
13288
+ }
13289
+ ]);
13290
+ return Buffer;
13291
+ }();
13292
+
13293
+ /**
13294
+ * 描述一个顶点属性如何读取共享缓冲区。
13295
+ */ var VertexBuffer = /*#__PURE__*/ function() {
13296
+ function VertexBuffer(engine, data, kind, props) {
13297
+ if (props === void 0) props = {};
13298
+ this._isDisposed = false;
13299
+ this.engine = engine;
13300
+ this.kind = kind;
13301
+ if (_instanceof1(data, Buffer)) {
13302
+ this.buffer = data;
13303
+ var _props_takeBufferOwnership;
13304
+ this.ownsBuffer = (_props_takeBufferOwnership = props.takeBufferOwnership) != null ? _props_takeBufferOwnership : false;
13305
+ } else {
13306
+ var _props_updatable, _props_stride, _props_postponeInternalCreation, _props_instanced, _props_useBytes;
13307
+ 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);
13308
+ this.ownsBuffer = true;
13309
+ }
13310
+ var source = this.getData();
13311
+ var _props_type;
13312
+ this.type = (_props_type = props.type) != null ? _props_type : source ? getDataType(source) : VertexBuffer.FLOAT;
13313
+ var typeByteLength = getBytesPerElement(this.type);
13314
+ var _props_useBytes1;
13315
+ var useBytes = (_props_useBytes1 = props.useBytes) != null ? _props_useBytes1 : false;
13316
+ var _props_stride1;
13317
+ var stride = (_props_stride1 = props.stride) != null ? _props_stride1 : 0;
13318
+ var _props_offset;
13319
+ var offset = (_props_offset = props.offset) != null ? _props_offset : 0;
13320
+ if (useBytes) {
13321
+ this.size = props.size || (stride ? stride / typeByteLength : 0);
13322
+ this.byteStride = stride || this.buffer.byteStride || this.size * typeByteLength;
13323
+ this.byteOffset = offset;
13324
+ } else {
13325
+ this.size = props.size || stride;
13326
+ this.byteStride = stride ? stride * typeByteLength : this.buffer.byteStride || this.size * typeByteLength;
13327
+ this.byteOffset = offset * typeByteLength;
13328
+ }
13329
+ var _props_normalized;
13330
+ this.normalized = (_props_normalized = props.normalized) != null ? _props_normalized : false;
13331
+ var _props_instanced1;
13332
+ this.instanced = (_props_instanced1 = props.instanced) != null ? _props_instanced1 : false;
13333
+ var _props_divisor;
13334
+ this._instanceDivisor = this.instanced ? (_props_divisor = props.divisor) != null ? _props_divisor : 1 : 0;
13335
+ }
13336
+ var _proto = VertexBuffer.prototype;
13337
+ _proto.getKind = function getKind() {
13338
+ return this.kind;
13339
+ };
13340
+ _proto.isUpdatable = function isUpdatable() {
13341
+ return this.buffer.isUpdatable();
13342
+ };
13343
+ _proto.getData = function getData() {
13344
+ return this.buffer.getData();
13345
+ };
13346
+ _proto.getBuffer = function getBuffer() {
13347
+ return this.buffer.getBuffer();
13348
+ };
13349
+ _proto.getWrapperBuffer = function getWrapperBuffer() {
13350
+ return this.buffer;
13351
+ };
13352
+ _proto.getStrideSize = function getStrideSize() {
13353
+ return this.byteStride / getBytesPerElement(this.type);
13354
+ };
13355
+ _proto.getOffset = function getOffset() {
13356
+ return this.byteOffset / getBytesPerElement(this.type);
13357
+ };
13358
+ _proto.getSize = function getSize(sizeInBytes) {
13359
+ if (sizeInBytes === void 0) sizeInBytes = false;
13360
+ return sizeInBytes ? this.size * getBytesPerElement(this.type) : this.size;
13361
+ };
13362
+ _proto.getIsInstanced = function getIsInstanced() {
13363
+ return this.instanced;
13364
+ };
13365
+ _proto.getInstanceDivisor = function getInstanceDivisor() {
13366
+ return this._instanceDivisor;
13367
+ };
13368
+ _proto.create = function create(data) {
13369
+ this.buffer.create(data);
13370
+ };
13371
+ _proto.update = function update(data) {
13372
+ this.buffer.update(data);
13373
+ };
13374
+ _proto.updateDirectly = function updateDirectly(data, offset, useBytes) {
13375
+ if (useBytes === void 0) useBytes = false;
13376
+ this.buffer.updateDirectly(data, offset, undefined, useBytes);
13377
+ };
13378
+ /**
13379
+ * @internal
13380
+ */ _proto.rebuild = function rebuild() {
13381
+ this.buffer.rebuild();
13382
+ };
13383
+ _proto.dispose = function dispose() {
13384
+ if (this.ownsBuffer) {
13385
+ this.buffer.dispose();
13386
+ }
13387
+ this._isDisposed = true;
13388
+ };
13389
+ _create_class(VertexBuffer, [
13390
+ {
13391
+ key: "isDisposed",
13392
+ get: function get() {
13393
+ return this._isDisposed;
13394
+ }
13395
+ },
13396
+ {
13397
+ key: "instanceDivisor",
13398
+ get: function get() {
13399
+ return this._instanceDivisor;
13400
+ },
13401
+ set: function set(value) {
13402
+ this._instanceDivisor = value;
13403
+ this.instanced = value !== 0;
13404
+ }
13405
+ }
13406
+ ]);
13407
+ return VertexBuffer;
13408
+ }();
13409
+ VertexBuffer.PositionKind = "aPos";
13410
+ VertexBuffer.NormalKind = "aNormal";
13411
+ VertexBuffer.TangentKind = "aTangent";
13412
+ VertexBuffer.UVKind = "aUV";
13413
+ VertexBuffer.UV2Kind = "aUV2";
13414
+ VertexBuffer.UV3Kind = "aUV3";
13415
+ VertexBuffer.UV4Kind = "aUV4";
13416
+ VertexBuffer.UV5Kind = "aUV5";
13417
+ VertexBuffer.UV6Kind = "aUV6";
13418
+ VertexBuffer.ColorKind = "aColor";
13419
+ VertexBuffer.JointsKind = "aJoints";
13420
+ VertexBuffer.WeightsKind = "aWeights";
13421
+ VertexBuffer.BYTE = BufferDataType.Byte;
13422
+ VertexBuffer.UNSIGNED_BYTE = BufferDataType.UnsignedByte;
13423
+ VertexBuffer.SHORT = BufferDataType.Short;
13424
+ VertexBuffer.UNSIGNED_SHORT = BufferDataType.UnsignedShort;
13425
+ VertexBuffer.INT = BufferDataType.Int;
13426
+ VertexBuffer.UNSIGNED_INT = BufferDataType.UnsignedInt;
13427
+ VertexBuffer.FLOAT = BufferDataType.Float;
13428
+
13002
13429
  var HitTestType;
13003
13430
  (function(HitTestType) {
13004
13431
  HitTestType[HitTestType["triangle"] = 1] = "triangle";
@@ -13321,7 +13748,7 @@ BoundingBox.tempVector2 = new Vector3();
13321
13748
  };
13322
13749
  _proto.geometryToTriangles = function geometryToTriangles(geometry) {
13323
13750
  var indices = geometry.getIndexData();
13324
- var vertices = geometry.getAttributeData("aPos");
13751
+ var vertices = geometry.getAttributeData(VertexBuffer.PositionKind);
13325
13752
  var res = [];
13326
13753
  if (!indices || !vertices) {
13327
13754
  return res;
@@ -20024,310 +20451,6 @@ CompositionComponent = __decorate([
20024
20451
  effectsClass("CompositionComponent")
20025
20452
  ], CompositionComponent);
20026
20453
 
20027
- /**
20028
- * Mesh 组件
20029
- */ var MeshComponent = /*#__PURE__*/ function(RendererComponent) {
20030
- _inherits(MeshComponent, RendererComponent);
20031
- function MeshComponent(engine) {
20032
- var _this;
20033
- _this = RendererComponent.call(this, engine) || this;
20034
- // TODO 点击测试后续抽象一个 Collider 组件
20035
- _this.getHitTestParams = function(force) {
20036
- var worldMatrix = _this.transform.getWorldMatrix();
20037
- _this.boundingBoxInfo.setGeometry(_this.geometry, worldMatrix);
20038
- var area = _this.boundingBoxInfo.getRawBoundingBoxTriangle();
20039
- if (area) {
20040
- return {
20041
- type: area.type,
20042
- triangles: area.area,
20043
- clipMasks: _this.frameClipMasks
20044
- };
20045
- }
20046
- };
20047
- return _this;
20048
- }
20049
- var _proto = MeshComponent.prototype;
20050
- _proto.render = function render(renderer) {
20051
- this.maskManager.drawStencilMask(renderer, this);
20052
- for(var i = 0; i < this.materials.length; i++){
20053
- var material = this.materials[i];
20054
- renderer.drawGeometry(this.geometry, this.transform.getWorldMatrix(), material, i);
20055
- }
20056
- };
20057
- _proto.drawStencilMask = function drawStencilMask(maskRef) {
20058
- if (!this.isActiveAndEnabled) {
20059
- return;
20060
- }
20061
- for(var i = 0; i < this.materials.length; i++){
20062
- var material = this.materials[i];
20063
- this.maskManager.drawGeometryMask(this.engine.renderer, this.geometry, this.transform.getWorldMatrix(), material, maskRef, i);
20064
- }
20065
- };
20066
- _proto.getBoundingBox = function getBoundingBox() {
20067
- var worldMatrix = this.transform.getWorldMatrix();
20068
- this.boundingBoxInfo.setGeometry(this.geometry, worldMatrix);
20069
- var boundingBox = this.boundingBoxInfo.getBoundingBoxTriangle();
20070
- return boundingBox;
20071
- };
20072
- _proto.getBoundingBoxInfo = function getBoundingBoxInfo() {
20073
- var positionArray = this.geometry.getAttributeData("aPos");
20074
- if (positionArray) {
20075
- var minMaxResult = extractMinAndMax(positionArray, 0, positionArray.length / 3);
20076
- minMaxResult.minimum.x *= this.transform.size.x;
20077
- minMaxResult.minimum.y *= this.transform.size.y;
20078
- minMaxResult.maximum.x *= this.transform.size.x;
20079
- minMaxResult.maximum.y *= this.transform.size.y;
20080
- this.boundingBoxInfo.reConstruct(minMaxResult.minimum, minMaxResult.maximum, this.transform.getWorldMatrix());
20081
- }
20082
- return this.boundingBoxInfo;
20083
- };
20084
- _proto.fromData = function fromData(data) {
20085
- RendererComponent.prototype.fromData.call(this, data);
20086
- var maskOptions = data.mask;
20087
- if (maskOptions) {
20088
- this.maskManager.setMaskOptions(this.engine, maskOptions);
20089
- }
20090
- };
20091
- return MeshComponent;
20092
- }(RendererComponent);
20093
- __decorate([
20094
- serialize()
20095
- ], MeshComponent.prototype, "geometry", void 0);
20096
-
20097
- var EffectComponent = /*#__PURE__*/ function(MeshComponent) {
20098
- _inherits(EffectComponent, MeshComponent);
20099
- function EffectComponent(engine) {
20100
- var _this;
20101
- _this = MeshComponent.call(this, engine) || this;
20102
- _this.time = 0;
20103
- _this.name = "EffectComponent";
20104
- return _this;
20105
- }
20106
- var _proto = EffectComponent.prototype;
20107
- _proto.onStart = function onStart() {
20108
- this.item.getHitTestParams = this.getHitTestParams;
20109
- };
20110
- _proto.onUpdate = function onUpdate(dt) {
20111
- var time = this.time;
20112
- var _this_material_getVector4;
20113
- var _Time = (_this_material_getVector4 = this.material.getVector4("_Time")) != null ? _this_material_getVector4 : new Vector4();
20114
- this.material.setVector4("_Time", _Time.set(time / 20, time, time * 2, time * 3));
20115
- this.time += dt / 1000;
20116
- };
20117
- _proto.fromData = function fromData(data) {
20118
- MeshComponent.prototype.fromData.call(this, data);
20119
- this.material = this.materials[0];
20120
- };
20121
- return EffectComponent;
20122
- }(MeshComponent);
20123
- EffectComponent = __decorate([
20124
- effectsClass(DataType.EffectComponent)
20125
- ], EffectComponent);
20126
-
20127
- var tempVector3 = new Vector3(0, 0, 0);
20128
- var tempVector3Second = new Vector3(0, 0, 0);
20129
- var ConstraintTarget = function ConstraintTarget() {
20130
- this.target = null;
20131
- this.weight = 1.0;
20132
- };
20133
- var PositionConstraint = /*#__PURE__*/ function(Component) {
20134
- _inherits(PositionConstraint, Component);
20135
- function PositionConstraint() {
20136
- var _this;
20137
- _this = Component.apply(this, arguments) || this;
20138
- /**
20139
- * 初始位置(当前元素的初始世界位置)
20140
- */ _this.positionAtRest = new Vector3(0, 0, 0);
20141
- /**
20142
- * 位置偏移
20143
- */ _this.positionOffset = new Vector3(0, 0, 0);
20144
- /**
20145
- * 约束权重 (0-1)
20146
- */ _this.weight = 1.0;
20147
- /**
20148
- * 是否约束 X 轴
20149
- */ _this.constrainX = true;
20150
- /**
20151
- * 是否约束 Y 轴
20152
- */ _this.constrainY = true;
20153
- /**
20154
- * 是否约束 Z 轴
20155
- */ _this.constrainZ = true;
20156
- /**
20157
- * 约束目标
20158
- */ _this.targets = [];
20159
- return _this;
20160
- }
20161
- var _proto = PositionConstraint.prototype;
20162
- _proto.onStart = function onStart() {
20163
- // 保存当前元素的初始世界位置
20164
- var pos = this.item.transform.getWorldPosition();
20165
- this.positionAtRest.copyFrom(pos);
20166
- };
20167
- _proto.onUpdate = function onUpdate(dt) {
20168
- if (this.targets.length === 0) {
20169
- return;
20170
- }
20171
- // 重置 tempVector3 用于计算融合位置
20172
- tempVector3.set(0, 0, 0);
20173
- var totalWeight = 0;
20174
- // 计算所有目标的加权平均位置
20175
- for(var _iterator = _create_for_of_iterator_helper_loose(this.targets), _step; !(_step = _iterator()).done;){
20176
- var constraintTarget = _step.value;
20177
- if (constraintTarget.target) {
20178
- var targetPos = constraintTarget.target.transform.getWorldPosition();
20179
- var weight = constraintTarget.weight;
20180
- tempVector3.x += targetPos.x * weight;
20181
- tempVector3.y += targetPos.y * weight;
20182
- tempVector3.z += targetPos.z * weight;
20183
- totalWeight += weight;
20184
- }
20185
- }
20186
- // 归一化加权位置
20187
- if (totalWeight > 0) {
20188
- tempVector3.x /= totalWeight;
20189
- tempVector3.y /= totalWeight;
20190
- tempVector3.z /= totalWeight;
20191
- }
20192
- // 应用偏移
20193
- tempVector3.x += this.positionOffset.x;
20194
- tempVector3.y += this.positionOffset.y;
20195
- tempVector3.z += this.positionOffset.z;
20196
- // 根据全局权重在初始位置和融合位置之间插值,结果存入 tempVector3Second
20197
- 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));
20198
- // 应用轴约束,复用 tempVector3 存储当前位置
20199
- tempVector3.copyFrom(this.item.transform.getWorldPosition());
20200
- var finalX = this.constrainX ? tempVector3Second.x : tempVector3.x;
20201
- var finalY = this.constrainY ? tempVector3Second.y : tempVector3.y;
20202
- var finalZ = this.constrainZ ? tempVector3Second.z : tempVector3.z;
20203
- // 设置新的世界位置
20204
- this.item.transform.setWorldPosition(finalX, finalY, finalZ);
20205
- };
20206
- /**
20207
- * 添加约束目标
20208
- * @param target - 目标元素
20209
- * @param weight - 权重值 (0-1)
20210
- */ _proto.addTarget = function addTarget(target, weight) {
20211
- if (weight === void 0) weight = 1.0;
20212
- var constraintTarget = new ConstraintTarget();
20213
- constraintTarget.target = target;
20214
- constraintTarget.weight = Math.max(0, Math.min(1, weight));
20215
- this.targets.push(constraintTarget);
20216
- };
20217
- /**
20218
- * 移除约束目标
20219
- * @param target - 要移除的目标元素
20220
- */ _proto.removeTarget = function removeTarget(target) {
20221
- var index = this.targets.findIndex(function(ct) {
20222
- return ct.target === target;
20223
- });
20224
- if (index !== -1) {
20225
- this.targets.splice(index, 1);
20226
- }
20227
- };
20228
- /**
20229
- * 清除所有约束目标
20230
- */ _proto.clearTargets = function clearTargets() {
20231
- this.targets = [];
20232
- };
20233
- /**
20234
- * 设置位置偏移
20235
- * @param x - X 轴偏移
20236
- * @param y - Y 轴偏移
20237
- * @param z - Z 轴偏移
20238
- */ _proto.setPositionOffset = function setPositionOffset(x, y, z) {
20239
- this.positionOffset.set(x, y, z);
20240
- };
20241
- /**
20242
- * 设置全局约束权重
20243
- * @param weight - 权重值 (0-1),0 表示保持初始位置,1 表示完全跟随目标
20244
- */ _proto.setWeight = function setWeight(weight) {
20245
- this.weight = Math.max(0, Math.min(1, weight));
20246
- };
20247
- /**
20248
- * 线性插值
20249
- * @param start - 起始值
20250
- * @param end - 结束值
20251
- * @param t - 插值因子 (0-1)
20252
- */ _proto.lerp = function lerp(start, end, t) {
20253
- return start + (end - start) * t;
20254
- };
20255
- _proto.fromData = function fromData(data) {
20256
- Component.prototype.fromData.call(this, data);
20257
- // Deserialize all properties
20258
- this.positionAtRest.copyFrom(data.positionAtRest);
20259
- this.positionOffset.copyFrom(data.positionOffset);
20260
- this.weight = data.weight;
20261
- this.constrainX = data.constrainX;
20262
- this.constrainY = data.constrainY;
20263
- this.constrainZ = data.constrainZ;
20264
- this.targets = [];
20265
- for(var _iterator = _create_for_of_iterator_helper_loose(data.targets), _step; !(_step = _iterator()).done;){
20266
- var targetData = _step.value;
20267
- var constraintTarget = new ConstraintTarget();
20268
- constraintTarget.target = this.engine.findObject(targetData.target);
20269
- constraintTarget.weight = targetData.weight;
20270
- this.targets.push(constraintTarget);
20271
- }
20272
- };
20273
- return PositionConstraint;
20274
- }(Component);
20275
- PositionConstraint = __decorate([
20276
- effectsClass("PositionConstraint")
20277
- ], PositionConstraint);
20278
-
20279
- var PostProcessVolume = /*#__PURE__*/ function(Component) {
20280
- _inherits(PostProcessVolume, Component);
20281
- function PostProcessVolume(engine) {
20282
- var _this;
20283
- _this = Component.call(this, engine) || this;
20284
- _this.bloom = {
20285
- threshold: 0,
20286
- intensity: 0,
20287
- active: false
20288
- };
20289
- _this.vignette = {
20290
- intensity: 0,
20291
- smoothness: 0,
20292
- roundness: 0,
20293
- active: false
20294
- };
20295
- _this.tonemapping = {
20296
- active: false
20297
- };
20298
- _this.colorAdjustments = {
20299
- brightness: 0,
20300
- saturation: 0,
20301
- contrast: 0,
20302
- active: false
20303
- };
20304
- return _this;
20305
- }
20306
- var _proto = PostProcessVolume.prototype;
20307
- _proto.onStart = function onStart() {
20308
- var composition = this.item.composition;
20309
- if (composition) {
20310
- composition.renderFrame.globalVolume = this;
20311
- }
20312
- };
20313
- return PostProcessVolume;
20314
- }(Component);
20315
- __decorate([
20316
- serialize()
20317
- ], PostProcessVolume.prototype, "bloom", void 0);
20318
- __decorate([
20319
- serialize()
20320
- ], PostProcessVolume.prototype, "vignette", void 0);
20321
- __decorate([
20322
- serialize()
20323
- ], PostProcessVolume.prototype, "tonemapping", void 0);
20324
- __decorate([
20325
- serialize()
20326
- ], PostProcessVolume.prototype, "colorAdjustments", void 0);
20327
- PostProcessVolume = __decorate([
20328
- effectsClass(DataType.PostProcessVolume)
20329
- ], PostProcessVolume);
20330
-
20331
20454
  var EFFECTS_COPY_MESH_NAME = "effects-internal-copy";
20332
20455
  var COPY_MESH_SHADER_ID = "effects-internal-copy-mesh";
20333
20456
  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}";
@@ -20653,45 +20776,574 @@ var DrawObjectPass = /*#__PURE__*/ function(RenderPass) {
20653
20776
  return DrawObjectPass;
20654
20777
  }(RenderPass);
20655
20778
 
20656
- var _obj$3;
20657
- 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);
20779
+ var geometryId = 1;
20658
20780
  /**
20659
- * Geometry 抽象类
20781
+ * 几何数据、属性布局和绘制范围的后端无关实现。
20660
20782
  */ var Geometry = /*#__PURE__*/ function(EffectsObject) {
20661
20783
  _inherits(Geometry, EffectsObject);
20662
- function Geometry() {
20784
+ function Geometry(engine, props) {
20663
20785
  var _this;
20664
- _this = EffectsObject.apply(this, arguments) || this;
20665
- /**
20666
- * Geometry 的名称
20667
- */ _this.name = "";
20668
- /**
20669
- * 子网格数据
20670
- */ _this.subMeshes = [];
20786
+ _this = EffectsObject.call(this, engine) || this;
20787
+ _this.name = "";
20788
+ _this.subMeshes = [];
20789
+ /** @hide */ _this.mode = 4;
20790
+ /** @hide */ _this.instanceCount = 0;
20791
+ _this.vertexBuffers = {};
20792
+ _this.indices = new Uint16Array(0);
20793
+ _this.drawCount = 0;
20794
+ _this.drawStart = 0;
20795
+ _this.skin = {};
20796
+ _this.disposed = false;
20797
+ _this.initialized = false;
20798
+ _this.bufferUsage = BufferUsage.Static;
20799
+ if (supportsVertexArrayObjects(engine)) {
20800
+ _this.vertexArrayObjects = {};
20801
+ }
20802
+ if (props) {
20803
+ _this.processProps(props);
20804
+ }
20671
20805
  return _this;
20672
20806
  }
20673
20807
  var _proto = Geometry.prototype;
20808
+ /** @hide */ _proto.isDisposed = function isDisposed() {
20809
+ return this.disposed;
20810
+ };
20674
20811
  /**
20675
- * 初始化 GPU 资源
20676
- * @override
20677
- */ _proto.initialize = function initialize() {
20678
- // OVERRIDE
20812
+ * @internal
20813
+ */ _proto.getOptions = function getOptions() {
20814
+ return this.options ? _extends({}, this.options) : undefined;
20815
+ };
20816
+ /** @hide */ _proto.getVertexBuffer = function getVertexBuffer(name) {
20817
+ return this.vertexBuffers[name];
20679
20818
  };
20680
20819
  /**
20681
- * 几何数据刷新
20682
- */ _proto.flush = function flush() {
20683
- // OVERRIDE
20820
+ * @internal
20821
+ */ _proto.getVertexBuffers = function getVertexBuffers() {
20822
+ return this.vertexBuffers;
20823
+ };
20824
+ /** @hide */ _proto.setVerticesBuffer = function setVerticesBuffer(vertexBuffer, disposeExistingBuffer) {
20825
+ if (disposeExistingBuffer === void 0) disposeExistingBuffer = true;
20826
+ var kind = vertexBuffer.getKind();
20827
+ var current = this.vertexBuffers[kind];
20828
+ if (current && disposeExistingBuffer) {
20829
+ current.dispose();
20830
+ }
20831
+ if (vertexBuffer.ownsBuffer) {
20832
+ vertexBuffer.buffer.increaseReferences();
20833
+ }
20834
+ this.vertexBuffers[kind] = vertexBuffer;
20835
+ this.disposeVertexArrayObjects();
20836
+ };
20837
+ /** @hide */ _proto.getAttributeBuffer = function getAttributeBuffer(name) {
20838
+ var _this_vertexBuffers_name;
20839
+ return (_this_vertexBuffers_name = this.vertexBuffers[name]) == null ? void 0 : _this_vertexBuffers_name.getWrapperBuffer();
20840
+ };
20841
+ _proto.getAttributeData = function getAttributeData(name) {
20842
+ var _this_vertexBuffers_name;
20843
+ return (_this_vertexBuffers_name = this.vertexBuffers[name]) == null ? void 0 : _this_vertexBuffers_name.getData();
20844
+ };
20845
+ _proto.setAttributeData = function setAttributeData(name, data) {
20846
+ var vertexBuffer = this.vertexBuffers[name];
20847
+ if (!vertexBuffer) {
20848
+ return;
20849
+ }
20850
+ vertexBuffer.update(data);
20851
+ this.disposeVertexArrayObjects();
20852
+ };
20853
+ _proto.setAttributeSubData = function setAttributeSubData(name, offset, data) {
20854
+ var vertexBuffer = this.vertexBuffers[name];
20855
+ if (!vertexBuffer) {
20856
+ return;
20857
+ }
20858
+ var buffer = vertexBuffer.getWrapperBuffer();
20859
+ var vertexCount = buffer.byteStride > 0 ? Math.ceil(data.byteLength / buffer.byteStride) : 0;
20860
+ buffer.updateDirectly(data, offset, vertexCount);
20861
+ this.disposeVertexArrayObjects();
20862
+ };
20863
+ _proto.getAttributeStride = function getAttributeStride(name) {
20864
+ var _this_vertexBuffers_name;
20865
+ var _this_vertexBuffers_name_byteStride;
20866
+ return (_this_vertexBuffers_name_byteStride = (_this_vertexBuffers_name = this.vertexBuffers[name]) == null ? void 0 : _this_vertexBuffers_name.byteStride) != null ? _this_vertexBuffers_name_byteStride : 0;
20867
+ };
20868
+ _proto.getAttributeNames = function getAttributeNames() {
20869
+ return Object.keys(this.vertexBuffers);
20870
+ };
20871
+ /** @hide */ _proto.getIndexBuffer = function getIndexBuffer() {
20872
+ return this.indexBuffer;
20873
+ };
20874
+ _proto.getIndexData = function getIndexData() {
20875
+ return this.indices;
20876
+ };
20877
+ /** @hide */ _proto.getIndexType = function getIndexType() {
20878
+ var _this_indexBuffer;
20879
+ return ((_this_indexBuffer = this.indexBuffer) == null ? void 0 : _this_indexBuffer.is32Bits) || shouldUse32Bits(this.indices) ? BufferDataType.UnsignedInt : BufferDataType.UnsignedShort;
20880
+ };
20881
+ _proto.setIndexData = function setIndexData(data) {
20882
+ if (!isIndexData(data)) {
20883
+ throw new TypeError("Index data must use a supported integer array.");
20884
+ }
20885
+ this.indices = Array.isArray(data) ? shouldUse32Bits(data) ? new Uint32Array(data) : new Uint16Array(data) : data;
20886
+ this.releaseIndexBuffer();
20887
+ this.disposeVertexArrayObjects();
20888
+ if (this.initialized) {
20889
+ this.createIndexBuffer();
20890
+ }
20891
+ };
20892
+ _proto.setIndexSubData = function setIndexSubData(offset, data) {
20893
+ var indices = this.indices;
20894
+ if (offset < 0 || offset + data.length > indices.length) {
20895
+ throw new RangeError("Buffer '" + this.name + "##index' update is out of range.");
20896
+ }
20897
+ indices.set(data, offset);
20898
+ if (this.indexBuffer) {
20899
+ var updatedData = indices.slice(offset, offset + data.length);
20900
+ this.engine.updateDynamicIndexBuffer(this.indexBuffer, updatedData, offset * (this.indexBuffer.is32Bits ? Uint32Array.BYTES_PER_ELEMENT : Uint16Array.BYTES_PER_ELEMENT));
20901
+ this.disposeVertexArrayObjects();
20902
+ }
20903
+ };
20904
+ _proto.setDrawStart = function setDrawStart(start) {
20905
+ this.drawStart = start;
20906
+ };
20907
+ _proto.getDrawStart = function getDrawStart() {
20908
+ return this.drawStart;
20909
+ };
20910
+ _proto.setDrawCount = function setDrawCount(count) {
20911
+ this.drawCount = count;
20912
+ };
20913
+ _proto.getDrawCount = function getDrawCount() {
20914
+ return this.drawCount;
20915
+ };
20916
+ _proto.getSkinProps = function getSkinProps() {
20917
+ return this.skin;
20918
+ };
20919
+ /** @hide */ _proto.bind = function bind(shader) {
20920
+ var vertexArrayObjects = this.vertexArrayObjects;
20921
+ var engine = this.engine;
20922
+ if (!vertexArrayObjects || !supportsVertexArrayObjects(engine)) {
20923
+ engine.bindBuffers(this.vertexBuffers, this.indexBuffer, shader);
20924
+ return;
20925
+ }
20926
+ var vertexArrayObject = vertexArrayObjects[shader.key];
20927
+ if (!vertexArrayObject) {
20928
+ vertexArrayObject = engine.recordVertexArrayObject(this.vertexBuffers, this.indexBuffer, shader);
20929
+ if (vertexArrayObject) {
20930
+ vertexArrayObjects[shader.key] = vertexArrayObject;
20931
+ }
20932
+ }
20933
+ if (vertexArrayObject) {
20934
+ engine.bindVertexArrayObject(vertexArrayObject, this.indexBuffer);
20935
+ } else {
20936
+ engine.bindBuffers(this.vertexBuffers, this.indexBuffer, shader);
20937
+ }
20938
+ };
20939
+ _proto.releaseVertexArrayObject = function releaseVertexArrayObject(key) {
20940
+ var vertexArrayObjects = this.vertexArrayObjects;
20941
+ if (!vertexArrayObjects) {
20942
+ return;
20943
+ }
20944
+ var vertexArrayObject = vertexArrayObjects[key];
20945
+ if (vertexArrayObject && hasVertexArrayObjectMethods(this.engine)) {
20946
+ this.engine.releaseVertexArrayObject(vertexArrayObject);
20947
+ }
20948
+ delete vertexArrayObjects[key];
20949
+ };
20950
+ _proto.initialize = function initialize() {
20951
+ if (this.initialized || this.disposed) {
20952
+ return;
20953
+ }
20954
+ this.forEachVertexBuffer(function(buffer) {
20955
+ buffer.create();
20956
+ });
20957
+ this.createIndexBuffer();
20958
+ this.engine.addGeometry(this);
20959
+ this.initialized = true;
20960
+ this.options = undefined;
20961
+ };
20962
+ _proto.flush = function flush() {
20963
+ if (this.disposed) {
20964
+ return;
20965
+ }
20966
+ this.initialize();
20967
+ this.forEachVertexBuffer(function(buffer) {
20968
+ return buffer.create();
20969
+ });
20970
+ };
20971
+ /** @hide */ _proto.restore = function restore() {
20972
+ if (!this.initialized || this.disposed) {
20973
+ return;
20974
+ }
20975
+ if (this.vertexArrayObjects) {
20976
+ this.vertexArrayObjects = {};
20977
+ }
20978
+ this.forEachVertexBuffer(function(buffer) {
20979
+ return buffer.rebuild();
20980
+ });
20981
+ if (this.indices.length > 0) {
20982
+ this.indexBuffer = undefined;
20983
+ this.createIndexBuffer();
20984
+ }
20985
+ };
20986
+ _proto.fromData = function fromData(data) {
20987
+ EffectsObject.prototype.fromData.call(this, data);
20988
+ this.subMeshes = data.subMeshes;
20989
+ var buffer;
20990
+ if (data.buffer) {
20991
+ buffer = new Uint8Array(decodeBase64ToArrayBuffer(data.buffer));
20992
+ } else if (data.binaryData) {
20993
+ buffer = data.binaryData;
20994
+ }
20995
+ if (!buffer) {
20996
+ return;
20997
+ }
20998
+ var vertexCount = data.vertexData.vertexCount;
20999
+ var props = {
21000
+ name: data.name,
21001
+ mode: 4,
21002
+ attributes: {}
21003
+ };
21004
+ if (hasSemantic(data)) {
21005
+ data.vertexData.channels.forEach(function(channel) {
21006
+ var _vertexBufferSemanticMap_channel_semantic;
21007
+ var attributeName = (_vertexBufferSemanticMap_channel_semantic = vertexBufferSemanticMap[channel.semantic]) != null ? _vertexBufferSemanticMap_channel_semantic : channel.semantic;
21008
+ props.attributes[attributeName] = {
21009
+ type: vertexFormatToDataType(channel.format),
21010
+ size: channel.dimension,
21011
+ data: createVertexTypedArray(channel, buffer, vertexCount),
21012
+ normalize: channel.normalize
21013
+ };
21014
+ });
21015
+ } else {
21016
+ var positionChannel = data.vertexData.channels[0];
21017
+ var uvChannel = data.vertexData.channels[1];
21018
+ var normalChannel = data.vertexData.channels[2];
21019
+ var _obj;
21020
+ 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);
21021
+ }
21022
+ if (data.indexFormat !== IndexFormatType.None) {
21023
+ var indices = createIndexTypedArray(data.indexFormat, buffer, data.indexOffset);
21024
+ props.indices = {
21025
+ data: indices
21026
+ };
21027
+ props.drawCount = indices.length;
21028
+ } else {
21029
+ props.drawCount = vertexCount;
21030
+ }
21031
+ this.processProps(props);
21032
+ this.skin = {
21033
+ boneNames: data.boneNames,
21034
+ rootBoneName: data.rootBoneName,
21035
+ inverseBindMatrices: data.inverseBindMatrices
21036
+ };
21037
+ };
21038
+ _proto.dispose = function dispose() {
21039
+ var _this = this;
21040
+ if (this.disposed) {
21041
+ return;
21042
+ }
21043
+ this.disposeVertexArrayObjects();
21044
+ Object.keys(this.vertexBuffers).forEach(function(name) {
21045
+ return _this.vertexBuffers[name].dispose();
21046
+ });
21047
+ this.releaseIndexBuffer();
21048
+ this.vertexBuffers = {};
21049
+ this.indices = new Uint16Array(0);
21050
+ this.options = undefined;
21051
+ this.drawStart = 0;
21052
+ this.drawCount = 0;
21053
+ if (this.initialized) {
21054
+ this.engine.removeGeometry(this);
21055
+ }
21056
+ this.initialized = false;
21057
+ this.disposed = true;
21058
+ EffectsObject.prototype.dispose.call(this);
21059
+ };
21060
+ _proto.processProps = function processProps(props) {
21061
+ var _this = this;
21062
+ this.releaseCurrentBuffers();
21063
+ var _props_bufferUsage;
21064
+ var usage = (_props_bufferUsage = props.bufferUsage) != null ? _props_bufferUsage : BufferUsage.Static;
21065
+ var sourceBuffers = {};
21066
+ var sourceDivisors = {};
21067
+ var sourceTypes = {};
21068
+ Object.keys(props.attributes).forEach(function(name) {
21069
+ var attribute = props.attributes[name];
21070
+ var source = "dataSource" in attribute ? attribute.dataSource : name;
21071
+ var _sourceDivisors_source, _attribute_instanceDivisor;
21072
+ sourceDivisors[source] = Math.max((_sourceDivisors_source = sourceDivisors[source]) != null ? _sourceDivisors_source : 0, (_attribute_instanceDivisor = attribute.instanceDivisor) != null ? _attribute_instanceDivisor : 0);
21073
+ });
21074
+ Object.keys(props.attributes).forEach(function(name) {
21075
+ var attribute = props.attributes[name];
21076
+ if ("dataSource" in attribute) {
21077
+ return;
21078
+ }
21079
+ var typedData = isTypedArray(attribute.data) ? attribute.data : undefined;
21080
+ var _attribute_type;
21081
+ var type = (_attribute_type = attribute.type) != null ? _attribute_type : typedData ? getDataType(typedData) : BufferDataType.Float;
21082
+ var bytesPerElement = getBytesPerElement(type);
21083
+ var byteStride = attribute.stride || attribute.size * bytesPerElement;
21084
+ var data = typedData != null ? typedData : createTypedArray(type, 0);
21085
+ if (data.length === 0 && props.maxVertex && props.maxVertex > 0) {
21086
+ var elementStride = byteStride / bytesPerElement;
21087
+ data = createTypedArray(type, Math.ceil(props.maxVertex * elementStride));
21088
+ }
21089
+ var _sourceDivisors_name;
21090
+ var instanceDivisor = (_sourceDivisors_name = sourceDivisors[name]) != null ? _sourceDivisors_name : 0;
21091
+ sourceTypes[name] = type;
21092
+ sourceBuffers[name] = new Buffer(_this.engine, data, usage !== BufferUsage.Static, byteStride, false, instanceDivisor > 0, true, instanceDivisor, name);
21093
+ });
21094
+ Object.keys(props.attributes).forEach(function(name) {
21095
+ var attribute = props.attributes[name];
21096
+ var source = "dataSource" in attribute ? attribute.dataSource : name;
21097
+ var buffer = sourceBuffers[source];
21098
+ if (!buffer) {
21099
+ throw new Error("Attribute '" + name + "' references missing data source '" + source + "'.");
21100
+ }
21101
+ var _attribute_type, _ref;
21102
+ var type = (_ref = (_attribute_type = attribute.type) != null ? _attribute_type : sourceTypes[source]) != null ? _ref : BufferDataType.Float;
21103
+ var byteStride = attribute.stride || buffer.byteStride;
21104
+ var _attribute_instanceDivisor;
21105
+ var instanceDivisor = (_attribute_instanceDivisor = attribute.instanceDivisor) != null ? _attribute_instanceDivisor : 0;
21106
+ var _attribute_offset, _attribute_normalize;
21107
+ var vertexBuffer = new VertexBuffer(_this.engine, buffer, name, {
21108
+ size: attribute.size,
21109
+ type: type,
21110
+ stride: byteStride,
21111
+ offset: (_attribute_offset = attribute.offset) != null ? _attribute_offset : 0,
21112
+ normalized: (_attribute_normalize = attribute.normalize) != null ? _attribute_normalize : false,
21113
+ instanced: instanceDivisor > 0,
21114
+ divisor: instanceDivisor,
21115
+ useBytes: true,
21116
+ takeBufferOwnership: true
21117
+ });
21118
+ _this.setVerticesBuffer(vertexBuffer);
21119
+ });
21120
+ var _props_name;
21121
+ this.name = (_props_name = props.name) != null ? _props_name : "effectsGeometry:" + geometryId++;
21122
+ var _props_drawStart;
21123
+ this.drawStart = (_props_drawStart = props.drawStart) != null ? _props_drawStart : 0;
21124
+ var _props_drawCount;
21125
+ this.drawCount = (_props_drawCount = props.drawCount) != null ? _props_drawCount : 0;
21126
+ var _props_mode;
21127
+ this.mode = (_props_mode = props.mode) != null ? _props_mode : 4;
21128
+ var _props_instanceCount;
21129
+ this.instanceCount = (_props_instanceCount = props.instanceCount) != null ? _props_instanceCount : 0;
21130
+ this.bufferUsage = usage;
21131
+ this.options = props;
21132
+ if (props.indices) {
21133
+ var data = props.indices.data;
21134
+ if (!isIndexData(data)) {
21135
+ throw new TypeError("Index data must use a supported integer array.");
21136
+ }
21137
+ // 索引还会参与 CPU 侧的命中检测和几何查询,因此始终保留源数据。
21138
+ this.indices = Array.isArray(data) ? shouldUse32Bits(data) ? new Uint32Array(data) : new Uint16Array(data) : data;
21139
+ }
21140
+ this.disposeVertexArrayObjects();
21141
+ };
21142
+ _proto.releaseCurrentBuffers = function releaseCurrentBuffers() {
21143
+ var _this = this;
21144
+ var wasInitialized = this.initialized;
21145
+ this.disposeVertexArrayObjects();
21146
+ Object.keys(this.vertexBuffers).forEach(function(name) {
21147
+ return _this.vertexBuffers[name].dispose();
21148
+ });
21149
+ this.releaseIndexBuffer();
21150
+ this.vertexBuffers = {};
21151
+ this.indices = new Uint16Array(0);
21152
+ if (wasInitialized) {
21153
+ this.engine.removeGeometry(this);
21154
+ this.initialized = false;
21155
+ }
21156
+ };
21157
+ _proto.disposeVertexArrayObjects = function disposeVertexArrayObjects() {
21158
+ var _this = this;
21159
+ var vertexArrayObjects = this.vertexArrayObjects;
21160
+ if (!vertexArrayObjects) {
21161
+ return;
21162
+ }
21163
+ Object.keys(vertexArrayObjects).forEach(function(key) {
21164
+ var vertexArrayObject = vertexArrayObjects[key];
21165
+ if (vertexArrayObject && hasVertexArrayObjectMethods(_this.engine)) {
21166
+ _this.engine.releaseVertexArrayObject(vertexArrayObject);
21167
+ }
21168
+ });
21169
+ this.vertexArrayObjects = {};
21170
+ };
21171
+ _proto.createIndexBuffer = function createIndexBuffer() {
21172
+ var indices = this.indices;
21173
+ if (indices.length === 0 || this.indexBuffer) {
21174
+ return;
21175
+ }
21176
+ this.indexBuffer = this.engine.createIndexBuffer(indices, {
21177
+ usage: this.bufferUsage,
21178
+ type: this.getIndexType(),
21179
+ byteStride: 0,
21180
+ instanceDivisor: 0,
21181
+ label: "" + this.name + "##index"
21182
+ });
21183
+ };
21184
+ _proto.releaseIndexBuffer = function releaseIndexBuffer() {
21185
+ if (!this.indexBuffer) {
21186
+ return;
21187
+ }
21188
+ this.engine.releaseBuffer(this.indexBuffer);
21189
+ this.indexBuffer = undefined;
20684
21190
  };
21191
+ _proto.forEachVertexBuffer = function forEachVertexBuffer(callback) {
21192
+ var _this = this;
21193
+ var visited = new Set();
21194
+ Object.keys(this.vertexBuffers).forEach(function(name) {
21195
+ var buffer = _this.vertexBuffers[name].getWrapperBuffer();
21196
+ if (!visited.has(buffer)) {
21197
+ visited.add(buffer);
21198
+ callback(buffer);
21199
+ }
21200
+ });
21201
+ };
21202
+ _create_class(Geometry, [
21203
+ {
21204
+ key: "isInitialized",
21205
+ get: /**
21206
+ * @internal
21207
+ */ function get() {
21208
+ return this.initialized;
21209
+ }
21210
+ }
21211
+ ]);
20685
21212
  return Geometry;
20686
21213
  }(EffectsObject);
20687
- function generateEmptyTypedArray(type) {
20688
- if (type === glContext.INT) {
20689
- return new Int32Array(0);
21214
+ Geometry.create = function(engine, props) {
21215
+ return new Geometry(engine, props);
21216
+ };
21217
+ function isTypedArray(value) {
21218
+ return ArrayBuffer.isView(value) && !_instanceof1(value, DataView);
21219
+ }
21220
+ function hasVertexArrayObjectMethods(engine) {
21221
+ var candidate = engine;
21222
+ return typeof candidate.recordVertexArrayObject === "function" && typeof candidate.bindVertexArrayObject === "function" && typeof candidate.releaseVertexArrayObject === "function";
21223
+ }
21224
+ function supportsVertexArrayObjects(engine) {
21225
+ var _engine_gpuCapability;
21226
+ return ((_engine_gpuCapability = engine.gpuCapability) == null ? void 0 : _engine_gpuCapability.detail.vertexArrayObject) === true && hasVertexArrayObjectMethods(engine);
21227
+ }
21228
+ function isIndexData(data) {
21229
+ return Array.isArray(data) || _instanceof1(data, Int32Array) || _instanceof1(data, Uint16Array) || _instanceof1(data, Uint32Array);
21230
+ }
21231
+ function shouldUse32Bits(data) {
21232
+ if (_instanceof1(data, Uint32Array)) {
21233
+ return true;
20690
21234
  }
20691
- if (type === glContext.SHORT) {
20692
- return new Int16Array(0);
21235
+ if (_instanceof1(data, Uint16Array)) {
21236
+ return false;
21237
+ }
21238
+ for(var i = 0; i < data.length; i++){
21239
+ if (data[i] >= 65535) {
21240
+ return true;
21241
+ }
21242
+ }
21243
+ return false;
21244
+ }
21245
+ function createAttributeFromChannel(channel, buffer, vertexCount, size) {
21246
+ return {
21247
+ type: vertexFormatToDataType(channel.format),
21248
+ size: size,
21249
+ data: createVertexTypedArray(channel, buffer, vertexCount),
21250
+ normalize: channel.normalize
21251
+ };
21252
+ }
21253
+ function createVertexTypedArray(channel, baseBuffer, vertexCount) {
21254
+ var arrayBuffer = baseBuffer.buffer;
21255
+ var byteOffset = baseBuffer.byteOffset + channel.offset;
21256
+ var length = channel.dimension * vertexCount;
21257
+ switch(channel.format){
21258
+ case VertexFormatType.Float32:
21259
+ return new Float32Array(arrayBuffer, byteOffset, length);
21260
+ case VertexFormatType.Int16:
21261
+ return new Int16Array(arrayBuffer, byteOffset, length);
21262
+ case VertexFormatType.Int8:
21263
+ return new Int8Array(arrayBuffer, byteOffset, length);
21264
+ case VertexFormatType.UInt16:
21265
+ return new Uint16Array(arrayBuffer, byteOffset, length);
21266
+ case VertexFormatType.UInt8:
21267
+ return new Uint8Array(arrayBuffer, byteOffset, length);
21268
+ default:
21269
+ throw new Error("Unsupported vertex format: " + channel.format + ".");
21270
+ }
21271
+ }
21272
+ function createIndexTypedArray(type, baseBuffer, offset) {
21273
+ var arrayBuffer = baseBuffer.buffer;
21274
+ var byteOffset = baseBuffer.byteOffset + offset;
21275
+ var byteLength = baseBuffer.byteLength - offset;
21276
+ switch(type){
21277
+ case IndexFormatType.UInt16:
21278
+ return new Uint16Array(arrayBuffer, byteOffset, byteLength / Uint16Array.BYTES_PER_ELEMENT);
21279
+ case IndexFormatType.UInt32:
21280
+ return new Uint32Array(arrayBuffer, byteOffset, byteLength / Uint32Array.BYTES_PER_ELEMENT);
21281
+ default:
21282
+ throw new Error("Unsupported index format: " + type + ".");
21283
+ }
21284
+ }
21285
+ function vertexFormatToDataType(format) {
21286
+ switch(format){
21287
+ case VertexFormatType.Float32:
21288
+ return BufferDataType.Float;
21289
+ case VertexFormatType.Int16:
21290
+ return BufferDataType.Short;
21291
+ case VertexFormatType.Int8:
21292
+ return BufferDataType.Byte;
21293
+ case VertexFormatType.UInt16:
21294
+ return BufferDataType.UnsignedShort;
21295
+ case VertexFormatType.UInt8:
21296
+ return BufferDataType.UnsignedByte;
21297
+ default:
21298
+ throw new Error("Unsupported vertex format: " + format + ".");
20693
21299
  }
20694
- return new Float32Array(0);
21300
+ }
21301
+ function hasSemantic(data) {
21302
+ return data.vertexData.channels.some(function(channel) {
21303
+ return !!channel.semantic;
21304
+ });
21305
+ }
21306
+ function decodeBase64ToArrayBuffer(value) {
21307
+ var binary = atob(value);
21308
+ var bytes = new Uint8Array(binary.length);
21309
+ for(var i = 0; i < binary.length; i++){
21310
+ bytes[i] = binary.charCodeAt(i);
21311
+ }
21312
+ return bytes.buffer;
21313
+ }
21314
+ var vertexBufferSemanticMap = {
21315
+ POSITION: VertexBuffer.PositionKind,
21316
+ TEXCOORD0: VertexBuffer.UVKind,
21317
+ TEXCOORD_0: VertexBuffer.UVKind,
21318
+ TEXCOORD1: VertexBuffer.UV2Kind,
21319
+ NORMAL: VertexBuffer.NormalKind,
21320
+ TANGENT: VertexBuffer.TangentKind,
21321
+ COLOR: VertexBuffer.ColorKind,
21322
+ JOINTS: VertexBuffer.JointsKind,
21323
+ JOINTS_0: VertexBuffer.JointsKind,
21324
+ WEIGHTS: VertexBuffer.WeightsKind,
21325
+ WEIGHTS_0: VertexBuffer.WeightsKind,
21326
+ POSITION_BS0: "aTargetPosition0",
21327
+ POSITION_BS1: "aTargetPosition1",
21328
+ POSITION_BS2: "aTargetPosition2",
21329
+ POSITION_BS3: "aTargetPosition3",
21330
+ POSITION_BS4: "aTargetPosition4",
21331
+ POSITION_BS5: "aTargetPosition5",
21332
+ POSITION_BS6: "aTargetPosition6",
21333
+ POSITION_BS7: "aTargetPosition7",
21334
+ NORMAL_BS0: "aTargetNormal0",
21335
+ NORMAL_BS1: "aTargetNormal1",
21336
+ NORMAL_BS2: "aTargetNormal2",
21337
+ NORMAL_BS3: "aTargetNormal3",
21338
+ TANGENT_BS0: "aTargetTangent0",
21339
+ TANGENT_BS1: "aTargetTangent1",
21340
+ TANGENT_BS2: "aTargetTangent2",
21341
+ TANGENT_BS3: "aTargetTangent3"
21342
+ };
21343
+ var _obj$3;
21344
+ var BYTES_TYPE_MAP = (_obj$3 = {}, _obj$3[BufferDataType.Float] = 4, _obj$3[BufferDataType.Int] = 4, _obj$3[BufferDataType.UnsignedInt] = 4, _obj$3[BufferDataType.Short] = 2, _obj$3[BufferDataType.UnsignedShort] = 2, _obj$3[BufferDataType.Byte] = 1, _obj$3[BufferDataType.UnsignedByte] = 1, _obj$3);
21345
+ function generateEmptyTypedArray(type) {
21346
+ return createTypedArray(type, 0);
20695
21347
  }
20696
21348
 
20697
21349
  var seed$5 = 1;
@@ -21106,25 +21758,24 @@ var ToneMappingPass = /*#__PURE__*/ function(RenderPass) {
21106
21758
  var name = "PostProcess";
21107
21759
  var engine = _this.renderer.engine;
21108
21760
  _this.sceneTextureHandle = sceneTextureHandle ? sceneTextureHandle : new RenderTargetHandle(engine);
21761
+ var _obj;
21109
21762
  var geometry = Geometry.create(engine, {
21110
21763
  name: name,
21111
21764
  mode: glContext.TRIANGLE_STRIP,
21112
- attributes: {
21113
- aPos: {
21114
- type: glContext.FLOAT,
21115
- size: 2,
21116
- data: new Float32Array([
21117
- -1,
21118
- 1,
21119
- -1,
21120
- -1,
21121
- 1,
21122
- 1,
21123
- 1,
21124
- -1
21125
- ])
21126
- }
21127
- },
21765
+ attributes: (_obj = {}, _obj[VertexBuffer.PositionKind] = {
21766
+ type: glContext.FLOAT,
21767
+ size: 2,
21768
+ data: new Float32Array([
21769
+ -1,
21770
+ 1,
21771
+ -1,
21772
+ -1,
21773
+ 1,
21774
+ 1,
21775
+ 1,
21776
+ -1
21777
+ ])
21778
+ }, _obj),
21128
21779
  drawCount: 4
21129
21780
  });
21130
21781
  var material = Material.create(engine, {
@@ -21554,6 +22205,7 @@ var GPUCapability = /*#__PURE__*/ function() {
21554
22205
  maxTextureAnisotropy: textureAnisotropicExt ? gl.getParameter(textureAnisotropicExt.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : 0,
21555
22206
  shaderTextureLod: level2 || !!gl.getExtension("EXT_shader_texture_lod"),
21556
22207
  instanceDraw: level2 || !!gl.getExtension("ANGLE_instanced_arrays"),
22208
+ vertexArrayObject: level2 || !!this.vaoExt,
21557
22209
  ktx2Support: detectKTX2Support(this.compressTextureCapabilityList),
21558
22210
  drawBuffers: level2 || !!this.drawBufferExtension,
21559
22211
  asyncShaderCompile: !!this.glAsyncCompileExt,
@@ -21778,24 +22430,23 @@ var Renderer = /*#__PURE__*/ function() {
21778
22430
  */ _proto.blit = function blit(source, destination, material) {
21779
22431
  // 懒加载创建 blit geometry
21780
22432
  if (!this.blitGeometry) {
22433
+ var _obj;
21781
22434
  this.blitGeometry = Geometry.create(this.engine, {
21782
22435
  mode: glContext.TRIANGLE_STRIP,
21783
- attributes: {
21784
- aPos: {
21785
- type: glContext.FLOAT,
21786
- size: 2,
21787
- data: new Float32Array([
21788
- -1,
21789
- 1,
21790
- -1,
21791
- -1,
21792
- 1,
21793
- 1,
21794
- 1,
21795
- -1
21796
- ])
21797
- }
21798
- },
22436
+ attributes: (_obj = {}, _obj[VertexBuffer.PositionKind] = {
22437
+ type: glContext.FLOAT,
22438
+ size: 2,
22439
+ data: new Float32Array([
22440
+ -1,
22441
+ 1,
22442
+ -1,
22443
+ -1,
22444
+ 1,
22445
+ 1,
22446
+ 1,
22447
+ -1
22448
+ ])
22449
+ }, _obj),
21799
22450
  drawCount: 4
21800
22451
  });
21801
22452
  }
@@ -22267,61 +22918,57 @@ var Graphics = /*#__PURE__*/ function() {
22267
22918
  this.currentBatchTexture = null;
22268
22919
  this.transformStack = [];
22269
22920
  this.currentTransform = Matrix3.fromIdentity();
22921
+ var _obj;
22270
22922
  this.geometry = Geometry.create(this.engine, {
22271
- attributes: {
22272
- aPos: {
22273
- type: glContext.FLOAT,
22274
- size: 2,
22275
- data: new Float32Array([
22276
- -0.5,
22277
- 0.5,
22278
- -0.5,
22279
- -0.5,
22280
- 0.5,
22281
- 0.5,
22282
- 0.5,
22283
- -0.5
22284
- ])
22285
- },
22286
- aColor: {
22287
- type: glContext.FLOAT,
22288
- size: 4,
22289
- data: new Float32Array([
22290
- 1,
22291
- 1,
22292
- 1,
22293
- 1,
22294
- 1,
22295
- 1,
22296
- 1,
22297
- 1,
22298
- 1,
22299
- 1,
22300
- 1,
22301
- 1,
22302
- 1,
22303
- 1,
22304
- 1,
22305
- 1
22306
- ])
22307
- },
22308
- aUV: {
22309
- size: 2,
22310
- offset: 0,
22311
- releasable: true,
22312
- type: glContext.FLOAT,
22313
- data: new Float32Array([
22314
- 0,
22315
- 1,
22316
- 0,
22317
- 0,
22318
- 1,
22319
- 1,
22320
- 1,
22321
- 0
22322
- ])
22323
- }
22324
- },
22923
+ attributes: (_obj = {}, _obj[VertexBuffer.PositionKind] = {
22924
+ type: glContext.FLOAT,
22925
+ size: 2,
22926
+ data: new Float32Array([
22927
+ -0.5,
22928
+ 0.5,
22929
+ -0.5,
22930
+ -0.5,
22931
+ 0.5,
22932
+ 0.5,
22933
+ 0.5,
22934
+ -0.5
22935
+ ])
22936
+ }, _obj[VertexBuffer.ColorKind] = {
22937
+ type: glContext.FLOAT,
22938
+ size: 4,
22939
+ data: new Float32Array([
22940
+ 1,
22941
+ 1,
22942
+ 1,
22943
+ 1,
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
+ ])
22957
+ }, _obj[VertexBuffer.UVKind] = {
22958
+ size: 2,
22959
+ offset: 0,
22960
+ type: glContext.FLOAT,
22961
+ data: new Float32Array([
22962
+ 0,
22963
+ 1,
22964
+ 0,
22965
+ 0,
22966
+ 1,
22967
+ 1,
22968
+ 1,
22969
+ 0
22970
+ ])
22971
+ }, _obj),
22325
22972
  indices: {
22326
22973
  data: new Uint16Array([
22327
22974
  0,
@@ -22330,11 +22977,11 @@ var Graphics = /*#__PURE__*/ function() {
22330
22977
  2,
22331
22978
  1,
22332
22979
  3
22333
- ]),
22334
- releasable: true
22980
+ ])
22335
22981
  },
22336
22982
  mode: glContext.TRIANGLES,
22337
- drawCount: 6
22983
+ drawCount: 6,
22984
+ bufferUsage: glContext.DYNAMIC_DRAW
22338
22985
  });
22339
22986
  this.coloredMaterial = Material.create(this.engine, {
22340
22987
  shader: {
@@ -22422,9 +23069,9 @@ var Graphics = /*#__PURE__*/ function() {
22422
23069
  var colorsArray = new Float32Array(this.colors);
22423
23070
  var uvsArray = new Float32Array(this.uvs);
22424
23071
  var indicesArray = new Uint16Array(this.indices);
22425
- this.geometry.setAttributeData("aPos", verticesArray);
22426
- this.geometry.setAttributeData("aColor", colorsArray);
22427
- this.geometry.setAttributeData("aUV", uvsArray);
23072
+ this.updateAttributeData(VertexBuffer.PositionKind, verticesArray, 2);
23073
+ this.updateAttributeData(VertexBuffer.ColorKind, colorsArray, 4);
23074
+ this.updateAttributeData(VertexBuffer.UVKind, uvsArray, 2);
22428
23075
  this.geometry.setIndexData(indicesArray);
22429
23076
  this.geometry.setDrawCount(this.currentIndexCount);
22430
23077
  var material;
@@ -22442,6 +23089,18 @@ var Graphics = /*#__PURE__*/ function() {
22442
23089
  this.colors.length = 0;
22443
23090
  this.uvs.length = 0;
22444
23091
  };
23092
+ _proto.updateAttributeData = function updateAttributeData(name, data, size) {
23093
+ var _this_geometry_getVertexBuffer;
23094
+ var dataBuffer = (_this_geometry_getVertexBuffer = this.geometry.getVertexBuffer(name)) == null ? void 0 : _this_geometry_getVertexBuffer.getBuffer();
23095
+ if (dataBuffer && data.byteLength > dataBuffer.capacity) {
23096
+ this.geometry.setVerticesBuffer(new VertexBuffer(this.engine, data, name, {
23097
+ updatable: true,
23098
+ size: size
23099
+ }));
23100
+ return;
23101
+ }
23102
+ this.geometry.setAttributeData(name, data);
23103
+ };
22445
23104
  /**
22446
23105
  * 线段顶点按顺序连接 (p0-p1, p1-p2, p2-p3, ...)
22447
23106
  * @param points - 点数组,格式 [x1,y1,x2,y2,...],至少需要2个点(4个数值)
@@ -22811,6 +23470,310 @@ var Graphics = /*#__PURE__*/ function() {
22811
23470
  return Graphics;
22812
23471
  }();
22813
23472
 
23473
+ /**
23474
+ * Mesh 组件
23475
+ */ var MeshComponent = /*#__PURE__*/ function(RendererComponent) {
23476
+ _inherits(MeshComponent, RendererComponent);
23477
+ function MeshComponent(engine) {
23478
+ var _this;
23479
+ _this = RendererComponent.call(this, engine) || this;
23480
+ // TODO 点击测试后续抽象一个 Collider 组件
23481
+ _this.getHitTestParams = function(force) {
23482
+ var worldMatrix = _this.transform.getWorldMatrix();
23483
+ _this.boundingBoxInfo.setGeometry(_this.geometry, worldMatrix);
23484
+ var area = _this.boundingBoxInfo.getRawBoundingBoxTriangle();
23485
+ if (area) {
23486
+ return {
23487
+ type: area.type,
23488
+ triangles: area.area,
23489
+ clipMasks: _this.frameClipMasks
23490
+ };
23491
+ }
23492
+ };
23493
+ return _this;
23494
+ }
23495
+ var _proto = MeshComponent.prototype;
23496
+ _proto.render = function render(renderer) {
23497
+ this.maskManager.drawStencilMask(renderer, this);
23498
+ for(var i = 0; i < this.materials.length; i++){
23499
+ var material = this.materials[i];
23500
+ renderer.drawGeometry(this.geometry, this.transform.getWorldMatrix(), material, i);
23501
+ }
23502
+ };
23503
+ _proto.drawStencilMask = function drawStencilMask(maskRef) {
23504
+ if (!this.isActiveAndEnabled) {
23505
+ return;
23506
+ }
23507
+ for(var i = 0; i < this.materials.length; i++){
23508
+ var material = this.materials[i];
23509
+ this.maskManager.drawGeometryMask(this.engine.renderer, this.geometry, this.transform.getWorldMatrix(), material, maskRef, i);
23510
+ }
23511
+ };
23512
+ _proto.getBoundingBox = function getBoundingBox() {
23513
+ var worldMatrix = this.transform.getWorldMatrix();
23514
+ this.boundingBoxInfo.setGeometry(this.geometry, worldMatrix);
23515
+ var boundingBox = this.boundingBoxInfo.getBoundingBoxTriangle();
23516
+ return boundingBox;
23517
+ };
23518
+ _proto.getBoundingBoxInfo = function getBoundingBoxInfo() {
23519
+ var positionArray = this.geometry.getAttributeData(VertexBuffer.PositionKind);
23520
+ if (positionArray) {
23521
+ var minMaxResult = extractMinAndMax(positionArray, 0, positionArray.length / 3);
23522
+ minMaxResult.minimum.x *= this.transform.size.x;
23523
+ minMaxResult.minimum.y *= this.transform.size.y;
23524
+ minMaxResult.maximum.x *= this.transform.size.x;
23525
+ minMaxResult.maximum.y *= this.transform.size.y;
23526
+ this.boundingBoxInfo.reConstruct(minMaxResult.minimum, minMaxResult.maximum, this.transform.getWorldMatrix());
23527
+ }
23528
+ return this.boundingBoxInfo;
23529
+ };
23530
+ _proto.fromData = function fromData(data) {
23531
+ RendererComponent.prototype.fromData.call(this, data);
23532
+ var maskOptions = data.mask;
23533
+ if (maskOptions) {
23534
+ this.maskManager.setMaskOptions(this.engine, maskOptions);
23535
+ }
23536
+ };
23537
+ return MeshComponent;
23538
+ }(RendererComponent);
23539
+ __decorate([
23540
+ serialize()
23541
+ ], MeshComponent.prototype, "geometry", void 0);
23542
+
23543
+ var EffectComponent = /*#__PURE__*/ function(MeshComponent) {
23544
+ _inherits(EffectComponent, MeshComponent);
23545
+ function EffectComponent(engine) {
23546
+ var _this;
23547
+ _this = MeshComponent.call(this, engine) || this;
23548
+ _this.time = 0;
23549
+ _this.name = "EffectComponent";
23550
+ return _this;
23551
+ }
23552
+ var _proto = EffectComponent.prototype;
23553
+ _proto.onStart = function onStart() {
23554
+ this.item.getHitTestParams = this.getHitTestParams;
23555
+ };
23556
+ _proto.onUpdate = function onUpdate(dt) {
23557
+ var time = this.time;
23558
+ var _this_material_getVector4;
23559
+ var _Time = (_this_material_getVector4 = this.material.getVector4("_Time")) != null ? _this_material_getVector4 : new Vector4();
23560
+ this.material.setVector4("_Time", _Time.set(time / 20, time, time * 2, time * 3));
23561
+ this.time += dt / 1000;
23562
+ };
23563
+ _proto.fromData = function fromData(data) {
23564
+ MeshComponent.prototype.fromData.call(this, data);
23565
+ this.material = this.materials[0];
23566
+ };
23567
+ return EffectComponent;
23568
+ }(MeshComponent);
23569
+ EffectComponent = __decorate([
23570
+ effectsClass(DataType.EffectComponent)
23571
+ ], EffectComponent);
23572
+
23573
+ var tempVector3 = new Vector3(0, 0, 0);
23574
+ var tempVector3Second = new Vector3(0, 0, 0);
23575
+ var ConstraintTarget = function ConstraintTarget() {
23576
+ this.target = null;
23577
+ this.weight = 1.0;
23578
+ };
23579
+ var PositionConstraint = /*#__PURE__*/ function(Component) {
23580
+ _inherits(PositionConstraint, Component);
23581
+ function PositionConstraint() {
23582
+ var _this;
23583
+ _this = Component.apply(this, arguments) || this;
23584
+ /**
23585
+ * 初始位置(当前元素的初始世界位置)
23586
+ */ _this.positionAtRest = new Vector3(0, 0, 0);
23587
+ /**
23588
+ * 位置偏移
23589
+ */ _this.positionOffset = new Vector3(0, 0, 0);
23590
+ /**
23591
+ * 约束权重 (0-1)
23592
+ */ _this.weight = 1.0;
23593
+ /**
23594
+ * 是否约束 X 轴
23595
+ */ _this.constrainX = true;
23596
+ /**
23597
+ * 是否约束 Y 轴
23598
+ */ _this.constrainY = true;
23599
+ /**
23600
+ * 是否约束 Z 轴
23601
+ */ _this.constrainZ = true;
23602
+ /**
23603
+ * 约束目标
23604
+ */ _this.targets = [];
23605
+ return _this;
23606
+ }
23607
+ var _proto = PositionConstraint.prototype;
23608
+ _proto.onStart = function onStart() {
23609
+ // 保存当前元素的初始世界位置
23610
+ var pos = this.item.transform.getWorldPosition();
23611
+ this.positionAtRest.copyFrom(pos);
23612
+ };
23613
+ _proto.onUpdate = function onUpdate(dt) {
23614
+ if (this.targets.length === 0) {
23615
+ return;
23616
+ }
23617
+ // 重置 tempVector3 用于计算融合位置
23618
+ tempVector3.set(0, 0, 0);
23619
+ var totalWeight = 0;
23620
+ // 计算所有目标的加权平均位置
23621
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.targets), _step; !(_step = _iterator()).done;){
23622
+ var constraintTarget = _step.value;
23623
+ if (constraintTarget.target) {
23624
+ var targetPos = constraintTarget.target.transform.getWorldPosition();
23625
+ var weight = constraintTarget.weight;
23626
+ tempVector3.x += targetPos.x * weight;
23627
+ tempVector3.y += targetPos.y * weight;
23628
+ tempVector3.z += targetPos.z * weight;
23629
+ totalWeight += weight;
23630
+ }
23631
+ }
23632
+ // 归一化加权位置
23633
+ if (totalWeight > 0) {
23634
+ tempVector3.x /= totalWeight;
23635
+ tempVector3.y /= totalWeight;
23636
+ tempVector3.z /= totalWeight;
23637
+ }
23638
+ // 应用偏移
23639
+ tempVector3.x += this.positionOffset.x;
23640
+ tempVector3.y += this.positionOffset.y;
23641
+ tempVector3.z += this.positionOffset.z;
23642
+ // 根据全局权重在初始位置和融合位置之间插值,结果存入 tempVector3Second
23643
+ 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));
23644
+ // 应用轴约束,复用 tempVector3 存储当前位置
23645
+ tempVector3.copyFrom(this.item.transform.getWorldPosition());
23646
+ var finalX = this.constrainX ? tempVector3Second.x : tempVector3.x;
23647
+ var finalY = this.constrainY ? tempVector3Second.y : tempVector3.y;
23648
+ var finalZ = this.constrainZ ? tempVector3Second.z : tempVector3.z;
23649
+ // 设置新的世界位置
23650
+ this.item.transform.setWorldPosition(finalX, finalY, finalZ);
23651
+ };
23652
+ /**
23653
+ * 添加约束目标
23654
+ * @param target - 目标元素
23655
+ * @param weight - 权重值 (0-1)
23656
+ */ _proto.addTarget = function addTarget(target, weight) {
23657
+ if (weight === void 0) weight = 1.0;
23658
+ var constraintTarget = new ConstraintTarget();
23659
+ constraintTarget.target = target;
23660
+ constraintTarget.weight = Math.max(0, Math.min(1, weight));
23661
+ this.targets.push(constraintTarget);
23662
+ };
23663
+ /**
23664
+ * 移除约束目标
23665
+ * @param target - 要移除的目标元素
23666
+ */ _proto.removeTarget = function removeTarget(target) {
23667
+ var index = this.targets.findIndex(function(ct) {
23668
+ return ct.target === target;
23669
+ });
23670
+ if (index !== -1) {
23671
+ this.targets.splice(index, 1);
23672
+ }
23673
+ };
23674
+ /**
23675
+ * 清除所有约束目标
23676
+ */ _proto.clearTargets = function clearTargets() {
23677
+ this.targets = [];
23678
+ };
23679
+ /**
23680
+ * 设置位置偏移
23681
+ * @param x - X 轴偏移
23682
+ * @param y - Y 轴偏移
23683
+ * @param z - Z 轴偏移
23684
+ */ _proto.setPositionOffset = function setPositionOffset(x, y, z) {
23685
+ this.positionOffset.set(x, y, z);
23686
+ };
23687
+ /**
23688
+ * 设置全局约束权重
23689
+ * @param weight - 权重值 (0-1),0 表示保持初始位置,1 表示完全跟随目标
23690
+ */ _proto.setWeight = function setWeight(weight) {
23691
+ this.weight = Math.max(0, Math.min(1, weight));
23692
+ };
23693
+ /**
23694
+ * 线性插值
23695
+ * @param start - 起始值
23696
+ * @param end - 结束值
23697
+ * @param t - 插值因子 (0-1)
23698
+ */ _proto.lerp = function lerp(start, end, t) {
23699
+ return start + (end - start) * t;
23700
+ };
23701
+ _proto.fromData = function fromData(data) {
23702
+ Component.prototype.fromData.call(this, data);
23703
+ // Deserialize all properties
23704
+ this.positionAtRest.copyFrom(data.positionAtRest);
23705
+ this.positionOffset.copyFrom(data.positionOffset);
23706
+ this.weight = data.weight;
23707
+ this.constrainX = data.constrainX;
23708
+ this.constrainY = data.constrainY;
23709
+ this.constrainZ = data.constrainZ;
23710
+ this.targets = [];
23711
+ for(var _iterator = _create_for_of_iterator_helper_loose(data.targets), _step; !(_step = _iterator()).done;){
23712
+ var targetData = _step.value;
23713
+ var constraintTarget = new ConstraintTarget();
23714
+ constraintTarget.target = this.engine.findObject(targetData.target);
23715
+ constraintTarget.weight = targetData.weight;
23716
+ this.targets.push(constraintTarget);
23717
+ }
23718
+ };
23719
+ return PositionConstraint;
23720
+ }(Component);
23721
+ PositionConstraint = __decorate([
23722
+ effectsClass("PositionConstraint")
23723
+ ], PositionConstraint);
23724
+
23725
+ var PostProcessVolume = /*#__PURE__*/ function(Component) {
23726
+ _inherits(PostProcessVolume, Component);
23727
+ function PostProcessVolume(engine) {
23728
+ var _this;
23729
+ _this = Component.call(this, engine) || this;
23730
+ _this.bloom = {
23731
+ threshold: 0,
23732
+ intensity: 0,
23733
+ active: false
23734
+ };
23735
+ _this.vignette = {
23736
+ intensity: 0,
23737
+ smoothness: 0,
23738
+ roundness: 0,
23739
+ active: false
23740
+ };
23741
+ _this.tonemapping = {
23742
+ active: false
23743
+ };
23744
+ _this.colorAdjustments = {
23745
+ brightness: 0,
23746
+ saturation: 0,
23747
+ contrast: 0,
23748
+ active: false
23749
+ };
23750
+ return _this;
23751
+ }
23752
+ var _proto = PostProcessVolume.prototype;
23753
+ _proto.onStart = function onStart() {
23754
+ var composition = this.item.composition;
23755
+ if (composition) {
23756
+ composition.renderFrame.globalVolume = this;
23757
+ }
23758
+ };
23759
+ return PostProcessVolume;
23760
+ }(Component);
23761
+ __decorate([
23762
+ serialize()
23763
+ ], PostProcessVolume.prototype, "bloom", void 0);
23764
+ __decorate([
23765
+ serialize()
23766
+ ], PostProcessVolume.prototype, "vignette", void 0);
23767
+ __decorate([
23768
+ serialize()
23769
+ ], PostProcessVolume.prototype, "tonemapping", void 0);
23770
+ __decorate([
23771
+ serialize()
23772
+ ], PostProcessVolume.prototype, "colorAdjustments", void 0);
23773
+ PostProcessVolume = __decorate([
23774
+ effectsClass(DataType.PostProcessVolume)
23775
+ ], PostProcessVolume);
23776
+
22814
23777
  /**
22815
23778
  * @since 2.7.0
22816
23779
  */ var MaskableGraphic = /*#__PURE__*/ function(RendererComponent) {
@@ -22849,42 +23812,40 @@ var Graphics = /*#__PURE__*/ function() {
22849
23812
  side: SideMode.DOUBLE,
22850
23813
  mask: 0
22851
23814
  };
23815
+ var _obj;
22852
23816
  _this.defaultGeometry = Geometry.create(_this.engine, {
22853
- attributes: {
22854
- aPos: {
22855
- type: glContext.FLOAT,
22856
- size: 3,
22857
- data: new Float32Array([
22858
- -0.5,
22859
- 0.5,
22860
- 0,
22861
- -0.5,
22862
- -0.5,
22863
- 0,
22864
- 0.5,
22865
- 0.5,
22866
- 0,
22867
- 0.5,
22868
- -0.5,
22869
- 0
22870
- ])
22871
- },
22872
- aUV: {
22873
- size: 2,
22874
- offset: 0,
22875
- type: glContext.FLOAT,
22876
- data: new Float32Array([
22877
- 0,
22878
- 1,
22879
- 0,
22880
- 0,
22881
- 1,
22882
- 1,
22883
- 1,
22884
- 0
22885
- ])
22886
- }
22887
- },
23817
+ attributes: (_obj = {}, _obj[VertexBuffer.PositionKind] = {
23818
+ type: glContext.FLOAT,
23819
+ size: 3,
23820
+ data: new Float32Array([
23821
+ -0.5,
23822
+ 0.5,
23823
+ 0,
23824
+ -0.5,
23825
+ -0.5,
23826
+ 0,
23827
+ 0.5,
23828
+ 0.5,
23829
+ 0,
23830
+ 0.5,
23831
+ -0.5,
23832
+ 0
23833
+ ])
23834
+ }, _obj[VertexBuffer.UVKind] = {
23835
+ size: 2,
23836
+ offset: 0,
23837
+ type: glContext.FLOAT,
23838
+ data: new Float32Array([
23839
+ 0,
23840
+ 1,
23841
+ 0,
23842
+ 0,
23843
+ 1,
23844
+ 1,
23845
+ 1,
23846
+ 0
23847
+ ])
23848
+ }, _obj),
22888
23849
  indices: {
22889
23850
  data: new Uint16Array([
22890
23851
  0,
@@ -22893,11 +23854,11 @@ var Graphics = /*#__PURE__*/ function() {
22893
23854
  2,
22894
23855
  1,
22895
23856
  3
22896
- ]),
22897
- releasable: true
23857
+ ])
22898
23858
  },
22899
23859
  mode: glContext.TRIANGLES,
22900
- drawCount: 6
23860
+ drawCount: 6,
23861
+ bufferUsage: glContext.DYNAMIC_DRAW
22901
23862
  });
22902
23863
  _this.geometry = _this.defaultGeometry;
22903
23864
  var material = Material.create(_this.engine, {
@@ -23006,7 +23967,7 @@ var Graphics = /*#__PURE__*/ function() {
23006
23967
  return boundingBox;
23007
23968
  };
23008
23969
  _proto.getBoundingBoxInfo = function getBoundingBoxInfo() {
23009
- var positionArray = this.geometry.getAttributeData("aPos");
23970
+ var positionArray = this.geometry.getAttributeData(VertexBuffer.PositionKind);
23010
23971
  if (positionArray) {
23011
23972
  var minMaxResult = extractMinAndMax(positionArray, 0, positionArray.length / 3);
23012
23973
  minMaxResult.minimum.x *= this.transform.size.x;
@@ -23220,61 +24181,66 @@ var FrameComponent = /*#__PURE__*/ function(RendererComponent1) {
23220
24181
  _this.color = new Color(1, 1, 1, 1);
23221
24182
  _this.worldMatrix = new Matrix4();
23222
24183
  _this.getHitTestParams = function(force) {
24184
+ if (!force) {
24185
+ return;
24186
+ }
24187
+ // frame 边的四角(局部 [-0.5, 0.5] 经 size 与世界变换)
23223
24188
  var sizeMatrix = Matrix4.fromScale(_this.transform.size.x, _this.transform.size.y, 1);
23224
24189
  var worldMatrix = sizeMatrix.premultiply(_this.transform.getWorldMatrix());
23225
- if (force) {
23226
- _this.boundingBoxInfo.setGeometry(_this.clipGeometry, worldMatrix);
23227
- var area = _this.boundingBoxInfo.getRawBoundingBoxTriangle();
23228
- if (area) {
23229
- return {
23230
- type: area.type,
23231
- triangles: area.area,
23232
- clipMasks: _this.frameClipMasks
23233
- };
23234
- }
23235
- }
24190
+ var toWorld = function(x, y) {
24191
+ return worldMatrix.transformPoint(new Vector3(x, y, 0), new Vector3());
24192
+ };
24193
+ var TL = toWorld(-0.5, 0.5);
24194
+ var TR = toWorld(0.5, 0.5);
24195
+ var BR = toWorld(0.5, -0.5);
24196
+ var BL = toWorld(-0.5, -0.5);
24197
+ // 命中带为屏幕像素恒定的环带,中心落在 frame 边上,仅边缘可命中(内部镂空)
24198
+ var thickness = _this.getBorderWorldThickness(TL, TR);
24199
+ var triangles = _this.getBorderTriangles(TL, TR, BR, BL, thickness);
24200
+ return {
24201
+ type: HitTestType.triangle,
24202
+ triangles: triangles,
24203
+ clipMasks: _this.frameClipMasks
24204
+ };
23236
24205
  };
23237
24206
  return _this;
23238
24207
  }
23239
24208
  var _proto = FrameComponent.prototype;
23240
24209
  _proto.onAwake = function onAwake() {
24210
+ var _obj;
23241
24211
  this.clipGeometry = Geometry.create(this.engine, {
23242
- attributes: {
23243
- aPos: {
23244
- type: glContext.FLOAT,
23245
- size: 3,
23246
- data: new Float32Array([
23247
- -0.5,
23248
- 0.5,
23249
- 0,
23250
- -0.5,
23251
- -0.5,
23252
- 0,
23253
- 0.5,
23254
- 0.5,
23255
- 0,
23256
- 0.5,
23257
- -0.5,
23258
- 0
23259
- ])
23260
- },
23261
- aUV: {
23262
- size: 2,
23263
- offset: 0,
23264
- releasable: true,
23265
- type: glContext.FLOAT,
23266
- data: new Float32Array([
23267
- 0,
23268
- 1,
23269
- 0,
23270
- 0,
23271
- 1,
23272
- 1,
23273
- 1,
23274
- 0
23275
- ])
23276
- }
23277
- },
24212
+ attributes: (_obj = {}, _obj[VertexBuffer.PositionKind] = {
24213
+ type: glContext.FLOAT,
24214
+ size: 3,
24215
+ data: new Float32Array([
24216
+ -0.5,
24217
+ 0.5,
24218
+ 0,
24219
+ -0.5,
24220
+ -0.5,
24221
+ 0,
24222
+ 0.5,
24223
+ 0.5,
24224
+ 0,
24225
+ 0.5,
24226
+ -0.5,
24227
+ 0
24228
+ ])
24229
+ }, _obj[VertexBuffer.UVKind] = {
24230
+ size: 2,
24231
+ offset: 0,
24232
+ type: glContext.FLOAT,
24233
+ data: new Float32Array([
24234
+ 0,
24235
+ 1,
24236
+ 0,
24237
+ 0,
24238
+ 1,
24239
+ 1,
24240
+ 1,
24241
+ 0
24242
+ ])
24243
+ }, _obj),
23278
24244
  indices: {
23279
24245
  data: new Uint16Array([
23280
24246
  0,
@@ -23283,8 +24249,7 @@ var FrameComponent = /*#__PURE__*/ function(RendererComponent1) {
23283
24249
  2,
23284
24250
  1,
23285
24251
  3
23286
- ]),
23287
- releasable: true
24252
+ ])
23288
24253
  },
23289
24254
  mode: glContext.TRIANGLES,
23290
24255
  drawCount: 6
@@ -23334,6 +24299,62 @@ var FrameComponent = /*#__PURE__*/ function(RendererComponent1) {
23334
24299
  this.color.copyFrom(data.color);
23335
24300
  }
23336
24301
  };
24302
+ /**
24303
+ * 由相机把命中带的屏幕像素厚度换算成世界厚度。对齐 Excalidraw frame 命中阈值:
24304
+ * 描边两侧各 0.85 × DEFAULT_COLLISION_THRESHOLD(≈8px),整条带 ≈13.6px,不受 size/scale/zoom 影响。
24305
+ */ _proto.getBorderWorldThickness = function getBorderWorldThickness(topLeft, topRight) {
24306
+ var _this_item_composition;
24307
+ var fallbackThickness = 0.05; // 相机不可用时的兜底世界厚度
24308
+ var camera = (_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.camera;
24309
+ if (!camera) {
24310
+ return fallbackThickness;
24311
+ }
24312
+ var screenLeft = camera.worldToScreenPoint(topLeft);
24313
+ var screenRight = camera.worldToScreenPoint(topRight);
24314
+ var pixelDist = Math.hypot(screenRight.x - screenLeft.x, screenRight.y - screenLeft.y);
24315
+ var worldDist = Math.hypot(topRight.x - topLeft.x, topRight.y - topLeft.y) || 1;
24316
+ var pixelPerWorldUnit = pixelDist / worldDist;
24317
+ // 命中带整条宽度(像素):2 × 0.85 × DEFAULT_COLLISION_THRESHOLD,其中 DEFAULT_COLLISION_THRESHOLD ≈ 8
24318
+ var borderPixels = 2 * 0.85 * 8;
24319
+ return pixelPerWorldUnit > 0 ? borderPixels / pixelPerWorldUnit : fallbackThickness;
24320
+ };
24321
+ /**
24322
+ * 构造以 frame 边为中心、给定世界厚度的边框环带三角形(内部镂空)。
24323
+ * 带中心落在 frame 边上:half 向外、half 向内;沿 frame 局部坐标轴偏移以兼容旋转。
24324
+ */ _proto.getBorderTriangles = function getBorderTriangles(TL, TR, BR, BL, thickness) {
24325
+ // frame 局部坐标轴在世界空间的方向
24326
+ var axisX = TR.clone().subtract(TL).normalize();
24327
+ var axisY = TL.clone().subtract(BL).normalize();
24328
+ var offset = function(corner, dx, dy) {
24329
+ return corner.clone().addScaledVector(axisX, dx).addScaledVector(axisY, dy);
24330
+ };
24331
+ // 外圈向外扩 half、内圈向内收 half,使带中心落在 frame 边上
24332
+ var half = thickness / 2;
24333
+ var outerTL = offset(TL, -half, half);
24334
+ var outerTR = offset(TR, half, half);
24335
+ var outerBR = offset(BR, half, -half);
24336
+ var outerBL = offset(BL, -half, -half);
24337
+ var innerTL = offset(TL, half, -half);
24338
+ var innerTR = offset(TR, -half, -half);
24339
+ var innerBR = offset(BR, -half, half);
24340
+ var innerBL = offset(BL, half, half);
24341
+ // 每条带是一个四边形,拆成 2 个三角形
24342
+ var quad = function(a, b, c, d) {
24343
+ return [
24344
+ {
24345
+ p0: a,
24346
+ p1: b,
24347
+ p2: c
24348
+ },
24349
+ {
24350
+ p0: a,
24351
+ p1: c,
24352
+ p2: d
24353
+ }
24354
+ ];
24355
+ };
24356
+ return [].concat(quad(outerTL, outerTR, innerTR, innerTL), quad(outerTR, outerBR, innerBR, innerTR), quad(outerBR, outerBL, innerBL, innerBR), quad(outerBL, outerTL, innerTL, innerBL));
24357
+ };
23337
24358
  _proto.setClipRectangle = function setClipRectangle() {
23338
24359
  this.setClipRectangleRecursive(this.item);
23339
24360
  };
@@ -24646,7 +25667,7 @@ var InteractLoader = /*#__PURE__*/ function(Plugin) {
24646
25667
  return InteractLoader;
24647
25668
  }(_wrap_native_super(Plugin));
24648
25669
 
24649
- var vertex = "\nprecision highp float;\n\nattribute vec2 aPoint;\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(aPoint.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";
25670
+ 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";
24650
25671
  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";
24651
25672
  var seed$3 = 1;
24652
25673
  var InteractMesh = /*#__PURE__*/ function() {
@@ -24703,7 +25724,7 @@ var InteractMesh = /*#__PURE__*/ function() {
24703
25724
  return material;
24704
25725
  };
24705
25726
  _proto.createGeometry = function createGeometry() {
24706
- var indexData = new Uint8Array([
25727
+ var indexData = new Uint16Array([
24707
25728
  0,
24708
25729
  1,
24709
25730
  1,
@@ -24713,24 +25734,23 @@ var InteractMesh = /*#__PURE__*/ function() {
24713
25734
  3,
24714
25735
  0
24715
25736
  ]);
25737
+ var _obj;
24716
25738
  return Geometry.create(this.engine, {
24717
- attributes: {
24718
- aPoint: {
24719
- size: 2,
24720
- offset: 0,
24721
- stride: 2 * Float32Array.BYTES_PER_ELEMENT,
24722
- data: new Float32Array([
24723
- -0.5,
24724
- 0.5,
24725
- 0.5,
24726
- 0.5,
24727
- 0.5,
24728
- -0.5,
24729
- -0.5,
24730
- -0.5
24731
- ])
24732
- }
24733
- },
25739
+ attributes: (_obj = {}, _obj[VertexBuffer.PositionKind] = {
25740
+ size: 2,
25741
+ offset: 0,
25742
+ stride: 2 * Float32Array.BYTES_PER_ELEMENT,
25743
+ data: new Float32Array([
25744
+ -0.5,
25745
+ 0.5,
25746
+ 0.5,
25747
+ 0.5,
25748
+ 0.5,
25749
+ -0.5,
25750
+ -0.5,
25751
+ -0.5
25752
+ ])
25753
+ }, _obj),
24734
25754
  drawCount: indexData.length,
24735
25755
  indices: {
24736
25756
  data: indexData
@@ -26657,6 +27677,11 @@ SpritePropertyTrack = __decorate([
26657
27677
  effectsClass("SpritePropertyTrack")
26658
27678
  ], SpritePropertyTrack);
26659
27679
 
27680
+ function _assert_this_initialized(self) {
27681
+ if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
27682
+ return self;
27683
+ }
27684
+
26660
27685
  var Cone = /*#__PURE__*/ function() {
26661
27686
  function Cone(props) {
26662
27687
  var _this = this;
@@ -27738,7 +28763,9 @@ var tmp0 = new Vector3();
27738
28763
  var tmp1 = new Vector3();
27739
28764
  var TrailMesh = /*#__PURE__*/ function() {
27740
28765
  function TrailMesh(engine, props) {
28766
+ var _this = this;
27741
28767
  this.pointStart = [];
28768
+ this.attributeData = new Map();
27742
28769
  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;
27743
28770
  var _engine_gpuCapability = engine.gpuCapability, detail = _engine_gpuCapability.detail, level = _engine_gpuCapability.level;
27744
28771
  var pointCountPerTrail = Math.max(props.pointCountPerTrail, 2);
@@ -27821,42 +28848,36 @@ var TrailMesh = /*#__PURE__*/ function() {
27821
28848
  var maxTriangleCount = (pointCountPerTrail - 1) * maxTrailCount;
27822
28849
  var bpe = Float32Array.BYTES_PER_ELEMENT;
27823
28850
  var v12 = 12 * bpe;
28851
+ var _obj;
27824
28852
  var geometryOptions = {
27825
- attributes: {
27826
- aColor: {
27827
- size: 4,
27828
- stride: v12,
27829
- data: new Float32Array(maxVertexCount * 12)
27830
- },
27831
- aSeed: {
27832
- size: 1,
27833
- stride: v12,
27834
- offset: 4 * bpe,
27835
- dataSource: "aColor"
27836
- },
27837
- aInfo: {
27838
- size: 3,
27839
- stride: v12,
27840
- offset: 5 * bpe,
27841
- dataSource: "aColor"
27842
- },
27843
- aPos: {
27844
- size: 4,
27845
- stride: v12,
27846
- offset: 8 * bpe,
27847
- dataSource: "aColor"
27848
- },
27849
- //
27850
- aTime: {
27851
- size: 1,
27852
- data: new Float32Array(maxVertexCount)
27853
- },
27854
- //
27855
- aDir: {
27856
- size: 3,
27857
- data: new Float32Array(maxVertexCount * 3)
27858
- }
27859
- },
28853
+ attributes: (_obj = {}, _obj[VertexBuffer.ColorKind] = {
28854
+ size: 4,
28855
+ stride: v12,
28856
+ data: new Float32Array(maxVertexCount * 12)
28857
+ }, _obj.aSeed = {
28858
+ size: 1,
28859
+ stride: v12,
28860
+ offset: 4 * bpe,
28861
+ dataSource: VertexBuffer.ColorKind
28862
+ }, _obj.aInfo = {
28863
+ size: 3,
28864
+ stride: v12,
28865
+ offset: 5 * bpe,
28866
+ dataSource: VertexBuffer.ColorKind
28867
+ }, _obj[VertexBuffer.PositionKind] = {
28868
+ size: 4,
28869
+ stride: v12,
28870
+ offset: 8 * bpe,
28871
+ dataSource: VertexBuffer.ColorKind
28872
+ }, //
28873
+ _obj.aTime = {
28874
+ size: 1,
28875
+ data: new Float32Array(maxVertexCount)
28876
+ }, //
28877
+ _obj.aDir = {
28878
+ size: 3,
28879
+ data: new Float32Array(maxVertexCount * 3)
28880
+ }, _obj),
27860
28881
  indices: {
27861
28882
  data: new Uint16Array(maxVertexCount * 6)
27862
28883
  },
@@ -27930,6 +28951,13 @@ var TrailMesh = /*#__PURE__*/ function() {
27930
28951
  this.mesh.worldMatrix = matrix;
27931
28952
  }
27932
28953
  this.geometry = mesh.firstGeometry();
28954
+ this.geometry.getAttributeNames().forEach(function(name) {
28955
+ var vertexBuffer = _this.geometry.getVertexBuffer(name);
28956
+ var data = _this.geometry.getAttributeData(name);
28957
+ if (vertexBuffer && _instanceof1(data, Float32Array)) {
28958
+ _this.attributeData.set(vertexBuffer.getWrapperBuffer(), data);
28959
+ }
28960
+ });
27933
28961
  this.trailCursors = new Uint16Array(maxTrailCount);
27934
28962
  }
27935
28963
  var _proto = TrailMesh.prototype;
@@ -27960,8 +28988,8 @@ var TrailMesh = /*#__PURE__*/ function() {
27960
28988
  var dirData = new Float32Array(6);
27961
28989
  dirData.set(dir, 0);
27962
28990
  dirData.set(dir, 3);
27963
- geometry.setAttributeSubData("aDir", dirStartIndex, dirData);
27964
- geometry.setAttributeSubData("aTime", pointStartIndex * 2, new Float32Array([
28991
+ this.setAttributeSubData("aDir", dirStartIndex, dirData);
28992
+ this.setAttributeSubData("aTime", pointStartIndex * 2, new Float32Array([
27965
28993
  time,
27966
28994
  time
27967
28995
  ]));
@@ -27983,13 +29011,13 @@ var TrailMesh = /*#__PURE__*/ function() {
27983
29011
  colorData[19] = 1;
27984
29012
  colorData.set(positionData, 20);
27985
29013
  colorData[23] = -0.5 * size;
27986
- geometry.setAttributeSubData("aColor", pointStartIndex * 24, colorData);
29014
+ this.setAttributeSubData(VertexBuffer.ColorKind, pointStartIndex * 24, colorData);
27987
29015
  if (previousIndex >= 0) {
27988
29016
  var bPreviousPoint = this.getTrailPosition(trailIndex, bpreviousIndex, tmp1);
27989
29017
  var previousDir = new Float32Array(calculateDirection(bPreviousPoint, previousPoint, position));
27990
29018
  var previousDirStartIndex = (trailIndex * pointCountPerTrail + previousIndex) * 6;
27991
- geometry.setAttributeSubData("aDir", previousDirStartIndex, previousDir);
27992
- geometry.setAttributeSubData("aDir", previousDirStartIndex + 3, previousDir);
29019
+ this.setAttributeSubData("aDir", previousDirStartIndex, previousDir);
29020
+ this.setAttributeSubData("aDir", previousDirStartIndex + 3, previousDir);
27993
29021
  var indicesStart = trailIndex * pointCountPerTrail * 2;
27994
29022
  var indicesData = new Uint16Array([
27995
29023
  previousIndex * 2 + indicesStart,
@@ -28012,7 +29040,7 @@ var TrailMesh = /*#__PURE__*/ function() {
28012
29040
  for(var i = 0; i < len; i++){
28013
29041
  startData[i] = trailStart;
28014
29042
  }
28015
- geometry.setAttributeSubData("aTrailStart", trailIndex * startData.length, startData);
29043
+ this.setAttributeSubData("aTrailStart", trailIndex * startData.length, startData);
28016
29044
  } else {
28017
29045
  var value = mtl.getFloats("uTrailStart");
28018
29046
  if (value != undefined) {
@@ -28029,8 +29057,7 @@ var TrailMesh = /*#__PURE__*/ function() {
28029
29057
  var pointCountPerTrail = this.pointCountPerTrail;
28030
29058
  if (index >= 0 && index < pointCountPerTrail) {
28031
29059
  var startIndex = (trail * pointCountPerTrail + index) * 24 + 8;
28032
- var data = this.geometry.getAttributeData("aColor");
28033
- assertExist(data);
29060
+ var data = this.getAttributeData(VertexBuffer.ColorKind);
28034
29061
  out.x = data[startIndex];
28035
29062
  out.y = data[1 + startIndex];
28036
29063
  out.z = data[2 + startIndex];
@@ -28044,12 +29071,11 @@ var TrailMesh = /*#__PURE__*/ function() {
28044
29071
  this.geometry.setIndexData(new Uint16Array(indexData.length));
28045
29072
  };
28046
29073
  _proto.minusTime = function minusTime(time) {
28047
- var data = this.geometry.getAttributeData("aTime");
28048
- assertExist(data);
29074
+ var data = this.getAttributeData("aTime");
28049
29075
  for(var i = 0; i < data.length; i++){
28050
29076
  data[i] -= time;
28051
29077
  }
28052
- this.geometry.setAttributeData("aTime", data);
29078
+ this.setAttributeData("aTime", data);
28053
29079
  this.time -= time;
28054
29080
  };
28055
29081
  _proto.clearTrail = function clearTrail(index) {
@@ -28070,6 +29096,35 @@ var TrailMesh = /*#__PURE__*/ function() {
28070
29096
  this.pointStart[index] = pos;
28071
29097
  };
28072
29098
  _proto.onUpdate = function onUpdate(escapeTime) {};
29099
+ _proto.getAttributeData = function getAttributeData(name) {
29100
+ var vertexBuffer = this.geometry.getVertexBuffer(name);
29101
+ var data = vertexBuffer && this.attributeData.get(vertexBuffer.getWrapperBuffer());
29102
+ assertExist(data);
29103
+ return data;
29104
+ };
29105
+ _proto.setAttributeData = function setAttributeData(name, data) {
29106
+ var vertexBuffer = this.geometry.getVertexBuffer(name);
29107
+ assertExist(vertexBuffer);
29108
+ this.attributeData.set(vertexBuffer.getWrapperBuffer(), data);
29109
+ this.geometry.setAttributeData(name, data);
29110
+ };
29111
+ _proto.setAttributeSubData = function setAttributeSubData(name, offset, data) {
29112
+ var target = this.getAttributeData(name);
29113
+ target.set(data, offset);
29114
+ this.geometry.setAttributeSubData(name, offset, data);
29115
+ };
29116
+ /**
29117
+ * @internal
29118
+ */ _proto.rebuild = function rebuild() {
29119
+ if (!this.geometry.isInitialized || this.geometry.isDisposed()) {
29120
+ return;
29121
+ }
29122
+ this.attributeData.forEach(function(data, buffer) {
29123
+ if (!buffer.getData()) {
29124
+ buffer.update(data);
29125
+ }
29126
+ });
29127
+ };
28073
29128
  _create_class(TrailMesh, [
28074
29129
  {
28075
29130
  key: "time",
@@ -28193,11 +29248,13 @@ var particleUniformTypeMap = {
28193
29248
 
28194
29249
  var ParticleMesh = /*#__PURE__*/ function() {
28195
29250
  function ParticleMesh(engine, props) {
29251
+ var _this = this;
28196
29252
  this.particleCount = 0;
28197
29253
  this.cachedRotationVector3 = new Vector3();
28198
29254
  this.cachedRotationMatrix = new Matrix3();
28199
29255
  this.cachedLinearMove = new Vector3();
28200
29256
  this.tempMatrix3 = new Matrix3();
29257
+ this.attributeData = new Map();
28201
29258
  this.VERT_MAX_KEY_FRAME_COUNT = 0;
28202
29259
  var env = (engine != null ? engine : {}).env;
28203
29260
  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;
@@ -28496,6 +29553,13 @@ var ParticleMesh = /*#__PURE__*/ function() {
28496
29553
  this.anchor = anchor;
28497
29554
  this.mesh = mesh;
28498
29555
  this.geometry = mesh.firstGeometry();
29556
+ this.geometry.getAttributeNames().forEach(function(name) {
29557
+ var vertexBuffer = _this.geometry.getVertexBuffer(name);
29558
+ var data = _this.geometry.getAttributeData(name);
29559
+ if (vertexBuffer && _instanceof1(data, Float32Array)) {
29560
+ _this.attributeData.set(vertexBuffer.getWrapperBuffer(), data);
29561
+ }
29562
+ });
28499
29563
  this.forceTarget = forceTarget;
28500
29564
  this.sizeOverLifetime = sizeOverLifetime;
28501
29565
  this.speedOverLifetime = speedOverLifetime;
@@ -28505,6 +29569,7 @@ var ParticleMesh = /*#__PURE__*/ function() {
28505
29569
  this.gravityModifier = gravityModifier;
28506
29570
  this.rotationOverLifetime = rotationOverLifetime;
28507
29571
  this.maxCount = maxCount;
29572
+ this.maxParticleBufferCount = maxCount;
28508
29573
  // this.duration = duration;
28509
29574
  this.textureOffsets = textureFlip ? [
28510
29575
  0,
@@ -28538,9 +29603,8 @@ var ParticleMesh = /*#__PURE__*/ function() {
28538
29603
  // // this.mesh.material.setVector4('uParams', new Vector4(+v, this.duration, 0, 0));
28539
29604
  // }
28540
29605
  _proto.getPointColor = function getPointColor(index) {
28541
- var data = this.geometry.getAttributeData("aRot");
29606
+ var data = this.getAttributeData("aRot");
28542
29607
  var i = index * 32 + 4;
28543
- assertExist(data);
28544
29608
  return [
28545
29609
  data[i],
28546
29610
  data[i + 1],
@@ -28549,46 +29613,31 @@ var ParticleMesh = /*#__PURE__*/ function() {
28549
29613
  ];
28550
29614
  };
28551
29615
  _proto.clearPoints = function clearPoints() {
28552
- this.resetGeometryData(this.geometry);
28553
29616
  this.particleCount = 0;
28554
29617
  this.geometry.setDrawCount(0);
28555
- this.maxParticleBufferCount = 0;
28556
- };
28557
- _proto.resetGeometryData = function resetGeometryData(geometry) {
28558
- var names = geometry.getAttributeNames();
28559
- var index = geometry.getIndexData();
28560
- for(var i = 0; i < names.length; i++){
28561
- var name = names[i];
28562
- var data = geometry.getAttributeData(name);
28563
- if (data) {
28564
- // @ts-expect-error
28565
- geometry.setAttributeData(name, new data.constructor(0));
28566
- }
28567
- }
28568
- // @ts-expect-error
28569
- geometry.setIndexData(new index.constructor(0));
28570
29618
  };
28571
29619
  _proto.onUpdate = function onUpdate(dt) {
28572
- var aPosArray = this.geometry.getAttributeData("aPos"); // vector3
29620
+ var aPosArray = this.getAttributeData(VertexBuffer.PositionKind); // vector3
28573
29621
  var vertexCount = Math.ceil(aPosArray.length / 12);
28574
29622
  this.applyTranslation(vertexCount, dt);
28575
29623
  this.applyRotation(vertexCount, dt);
28576
29624
  this.applyLinearMove(vertexCount, dt);
28577
29625
  };
28578
29626
  _proto.minusTime = function minusTime(time) {
28579
- var aOffset = this.geometry.getAttributeData("aOffset");
29627
+ var aOffset = this.getAttributeData("aOffset");
28580
29628
  for(var i = 0; i < aOffset.length; i += 4){
28581
29629
  aOffset[i + 2] -= time;
28582
29630
  }
28583
- this.geometry.setAttributeData("aOffset", aOffset);
29631
+ this.setAttributeData("aOffset", aOffset);
28584
29632
  this.time -= time;
28585
29633
  };
28586
29634
  _proto.removePoint = function removePoint(index) {
28587
29635
  if (index < this.particleCount) {
28588
- this.geometry.setAttributeSubData("aOffset", index * 16, new Float32Array(16));
29636
+ this.setAttributeSubData("aOffset", index * 16, new Float32Array(16));
28589
29637
  }
28590
29638
  };
28591
29639
  _proto.setPoint = function setPoint(index, point) {
29640
+ var _this = this;
28592
29641
  var maxCount = this.maxCount;
28593
29642
  if (index < maxCount) {
28594
29643
  var particleCount = index + 1;
@@ -28705,13 +29754,12 @@ var ParticleMesh = /*#__PURE__*/ function() {
28705
29754
  var data = pointData[name];
28706
29755
  var attrSize = geometry.getAttributeStride(name) / Float32Array.BYTES_PER_ELEMENT;
28707
29756
  if (increaseBuffer) {
28708
- var baseData = geometry.getAttributeData(name);
28709
- assertExist(baseData);
29757
+ var baseData = _this.getAttributeData(name);
28710
29758
  var geoData = enlargeBuffer(baseData, vertexCount * attrSize, maxCount * 4 * attrSize, inc);
28711
29759
  geoData.set(data, data.length * index);
28712
- geometry.setAttributeData(name, geoData);
29760
+ _this.setAttributeData(name, geoData);
28713
29761
  } else {
28714
- geometry.setAttributeSubData(name, data.length * index, data);
29762
+ _this.setAttributeSubData(name, data.length * index, data);
28715
29763
  }
28716
29764
  });
28717
29765
  this.particleCount = Math.max(particleCount, this.particleCount);
@@ -28720,9 +29768,9 @@ var ParticleMesh = /*#__PURE__*/ function() {
28720
29768
  };
28721
29769
  _proto.applyTranslation = function applyTranslation(vertexCount, deltaTime) {
28722
29770
  var localTime = this.time;
28723
- var aTranslationArray = this.geometry.getAttributeData("aTranslation");
28724
- var aVelArray = this.geometry.getAttributeData("aVel"); // vector3
28725
- var aOffsetArray = this.geometry.getAttributeData("aOffset");
29771
+ var aTranslationArray = this.getAttributeData("aTranslation");
29772
+ var aVelArray = this.getAttributeData("aVel"); // vector3
29773
+ var aOffsetArray = this.getAttributeData("aOffset");
28726
29774
  if (aTranslationArray.length < vertexCount * 3) {
28727
29775
  aTranslationArray = this.expandArray(aTranslationArray, vertexCount * 3);
28728
29776
  }
@@ -28781,13 +29829,13 @@ var ParticleMesh = /*#__PURE__*/ function() {
28781
29829
  aTranslationArray[aTranslationOffset + 11] += aTranslationZ;
28782
29830
  }
28783
29831
  }
28784
- this.geometry.setAttributeData("aTranslation", aTranslationArray);
29832
+ this.setAttributeData("aTranslation", aTranslationArray);
28785
29833
  };
28786
29834
  _proto.applyRotation = function applyRotation(vertexCount, deltaTime) {
28787
- var aRotationArray = this.geometry.getAttributeData("aRotation0");
28788
- var aOffsetArray = this.geometry.getAttributeData("aOffset");
28789
- var aRotArray = this.geometry.getAttributeData("aRot"); // vector3
28790
- var aSeedArray = this.geometry.getAttributeData("aSeed"); // float
29835
+ var aRotationArray = this.getAttributeData("aRotation0");
29836
+ var aOffsetArray = this.getAttributeData("aOffset");
29837
+ var aRotArray = this.getAttributeData("aRot"); // vector3
29838
+ var aSeedArray = this.getAttributeData("aSeed"); // float
28791
29839
  var localTime = this.time;
28792
29840
  var aRotationMatrix = this.cachedRotationMatrix;
28793
29841
  if (aRotationArray.length < vertexCount * 9) {
@@ -28878,12 +29926,12 @@ var ParticleMesh = /*#__PURE__*/ function() {
28878
29926
  aRotationArray.set(matrixArray, aRotationOffset + 27);
28879
29927
  }
28880
29928
  }
28881
- this.geometry.setAttributeData("aRotation0", aRotationArray);
29929
+ this.setAttributeData("aRotation0", aRotationArray);
28882
29930
  };
28883
29931
  _proto.applyLinearMove = function applyLinearMove(vertexCount, deltaTime) {
28884
- var aLinearMoveArray = this.geometry.getAttributeData("aLinearMove");
28885
- var aOffsetArray = this.geometry.getAttributeData("aOffset");
28886
- var aSeedArray = this.geometry.getAttributeData("aSeed"); // float
29932
+ var aLinearMoveArray = this.getAttributeData("aLinearMove");
29933
+ var aOffsetArray = this.getAttributeData("aOffset");
29934
+ var aSeedArray = this.getAttributeData("aSeed"); // float
28887
29935
  var localTime = this.time;
28888
29936
  if (aLinearMoveArray.length < vertexCount * 3) {
28889
29937
  aLinearMoveArray = this.expandArray(aLinearMoveArray, vertexCount * 3);
@@ -28958,7 +30006,36 @@ var ParticleMesh = /*#__PURE__*/ function() {
28958
30006
  aLinearMoveArray[aLinearMoveOffset + 11] = linearMove.z;
28959
30007
  }
28960
30008
  }
28961
- this.geometry.setAttributeData("aLinearMove", aLinearMoveArray);
30009
+ this.setAttributeData("aLinearMove", aLinearMoveArray);
30010
+ };
30011
+ _proto.getAttributeData = function getAttributeData(name) {
30012
+ var vertexBuffer = this.geometry.getVertexBuffer(name);
30013
+ var data = vertexBuffer && this.attributeData.get(vertexBuffer.getWrapperBuffer());
30014
+ assertExist(data);
30015
+ return data;
30016
+ };
30017
+ _proto.setAttributeData = function setAttributeData(name, data) {
30018
+ var vertexBuffer = this.geometry.getVertexBuffer(name);
30019
+ assertExist(vertexBuffer);
30020
+ this.attributeData.set(vertexBuffer.getWrapperBuffer(), data);
30021
+ this.geometry.setAttributeData(name, data);
30022
+ };
30023
+ _proto.setAttributeSubData = function setAttributeSubData(name, offset, data) {
30024
+ var target = this.getAttributeData(name);
30025
+ target.set(data, offset);
30026
+ this.geometry.setAttributeSubData(name, offset, data);
30027
+ };
30028
+ /**
30029
+ * @internal
30030
+ */ _proto.rebuild = function rebuild() {
30031
+ if (!this.geometry.isInitialized || this.geometry.isDisposed()) {
30032
+ return;
30033
+ }
30034
+ this.attributeData.forEach(function(data, buffer) {
30035
+ if (!buffer.getData()) {
30036
+ buffer.update(data);
30037
+ }
30038
+ });
28962
30039
  };
28963
30040
  _proto.expandArray = function expandArray(array, newSize) {
28964
30041
  var newArr = new Float32Array(newSize);
@@ -28970,83 +30047,70 @@ var ParticleMesh = /*#__PURE__*/ function() {
28970
30047
  function generateGeometryProps(maxVertex, useSprite, name) {
28971
30048
  var bpe = Float32Array.BYTES_PER_ELEMENT;
28972
30049
  var j12 = bpe * 12;
28973
- var attributes = {
28974
- aPos: {
28975
- size: 3,
28976
- offset: 0,
28977
- stride: j12,
28978
- data: new Float32Array(0)
28979
- },
28980
- aVel: {
28981
- size: 3,
28982
- offset: 3 * bpe,
28983
- stride: j12,
28984
- dataSource: "aPos"
28985
- },
28986
- aDirX: {
28987
- size: 3,
28988
- offset: 6 * bpe,
28989
- stride: j12,
28990
- dataSource: "aPos"
28991
- },
28992
- aDirY: {
28993
- size: 3,
28994
- offset: 9 * bpe,
28995
- stride: j12,
28996
- dataSource: "aPos"
28997
- },
28998
- //
28999
- aRot: {
29000
- size: 3,
29001
- offset: 0,
29002
- stride: 8 * bpe,
29003
- data: new Float32Array(0)
29004
- },
29005
- aSeed: {
29006
- size: 1,
29007
- offset: 3 * bpe,
29008
- stride: 8 * bpe,
29009
- dataSource: "aRot"
29010
- },
29011
- aColor: {
29012
- size: 4,
29013
- offset: 4 * bpe,
29014
- stride: 8 * bpe,
29015
- dataSource: "aRot"
29016
- },
29017
- //
29018
- aOffset: {
29019
- size: 4,
29020
- stride: 4 * bpe,
29021
- data: new Float32Array(0)
29022
- },
29023
- aTranslation: {
29024
- size: 3,
29025
- data: new Float32Array(0)
29026
- },
29027
- aLinearMove: {
29028
- size: 3,
29029
- data: new Float32Array(0)
29030
- },
29031
- aRotation0: {
29032
- size: 3,
29033
- offset: 0,
29034
- stride: 9 * bpe,
29035
- data: new Float32Array(0)
29036
- },
29037
- aRotation1: {
29038
- size: 3,
29039
- offset: 3 * bpe,
29040
- stride: 9 * bpe,
29041
- dataSource: "aRotation0"
29042
- },
29043
- aRotation2: {
29044
- size: 3,
29045
- offset: 6 * bpe,
29046
- stride: 9 * bpe,
29047
- dataSource: "aRotation0"
29048
- }
29049
- };
30050
+ var _obj;
30051
+ var attributes = (_obj = {}, _obj[VertexBuffer.PositionKind] = {
30052
+ size: 3,
30053
+ offset: 0,
30054
+ stride: j12,
30055
+ data: new Float32Array(0)
30056
+ }, _obj.aVel = {
30057
+ size: 3,
30058
+ offset: 3 * bpe,
30059
+ stride: j12,
30060
+ dataSource: VertexBuffer.PositionKind
30061
+ }, _obj.aDirX = {
30062
+ size: 3,
30063
+ offset: 6 * bpe,
30064
+ stride: j12,
30065
+ dataSource: VertexBuffer.PositionKind
30066
+ }, _obj.aDirY = {
30067
+ size: 3,
30068
+ offset: 9 * bpe,
30069
+ stride: j12,
30070
+ dataSource: VertexBuffer.PositionKind
30071
+ }, //
30072
+ _obj.aRot = {
30073
+ size: 3,
30074
+ offset: 0,
30075
+ stride: 8 * bpe,
30076
+ data: new Float32Array(0)
30077
+ }, _obj.aSeed = {
30078
+ size: 1,
30079
+ offset: 3 * bpe,
30080
+ stride: 8 * bpe,
30081
+ dataSource: "aRot"
30082
+ }, _obj[VertexBuffer.ColorKind] = {
30083
+ size: 4,
30084
+ offset: 4 * bpe,
30085
+ stride: 8 * bpe,
30086
+ dataSource: "aRot"
30087
+ }, //
30088
+ _obj.aOffset = {
30089
+ size: 4,
30090
+ stride: 4 * bpe,
30091
+ data: new Float32Array(0)
30092
+ }, _obj.aTranslation = {
30093
+ size: 3,
30094
+ data: new Float32Array(0)
30095
+ }, _obj.aLinearMove = {
30096
+ size: 3,
30097
+ data: new Float32Array(0)
30098
+ }, _obj.aRotation0 = {
30099
+ size: 3,
30100
+ offset: 0,
30101
+ stride: 9 * bpe,
30102
+ data: new Float32Array(0)
30103
+ }, _obj.aRotation1 = {
30104
+ size: 3,
30105
+ offset: 3 * bpe,
30106
+ stride: 9 * bpe,
30107
+ dataSource: "aRotation0"
30108
+ }, _obj.aRotation2 = {
30109
+ size: 3,
30110
+ offset: 6 * bpe,
30111
+ stride: 9 * bpe,
30112
+ dataSource: "aRotation0"
30113
+ }, _obj);
29050
30114
  if (useSprite) {
29051
30115
  attributes["aSprite"] = {
29052
30116
  size: 3,
@@ -29057,10 +30121,11 @@ function generateGeometryProps(maxVertex, useSprite, name) {
29057
30121
  return {
29058
30122
  attributes: attributes,
29059
30123
  indices: {
29060
- data: new Uint16Array(0)
30124
+ data: new Uint16Array(maxVertex / 4 * 6)
29061
30125
  },
29062
30126
  name: name,
29063
- maxVertex: maxVertex
30127
+ maxVertex: maxVertex,
30128
+ bufferUsage: BufferUsage.Dynamic
29064
30129
  };
29065
30130
  }
29066
30131
  function getParticleMeshShader(item, gpuCapability, env) {
@@ -29340,6 +30405,13 @@ function modifyMaxKeyframeShader(shader, maxVertex, maxFrag) {
29340
30405
  this.materials.push(this.trailMesh.mesh.material);
29341
30406
  }
29342
30407
  };
30408
+ /**
30409
+ * @internal
30410
+ */ _proto.rebuild = function rebuild() {
30411
+ var _this_trailMesh;
30412
+ this.particleMesh.rebuild();
30413
+ (_this_trailMesh = this.trailMesh) == null ? void 0 : _this_trailMesh.rebuild();
30414
+ };
29343
30415
  _proto.reset = function reset() {
29344
30416
  var _this_trailMesh;
29345
30417
  this.particleMesh.clearPoints();
@@ -29439,6 +30511,7 @@ var ParticleSystem = /*#__PURE__*/ function(Component) {
29439
30511
  };
29440
30512
  }
29441
30513
  };
30514
+ engine.addParticleSystem(_assert_this_initialized(_this));
29442
30515
  _this.maskManager = new MaskProcessor();
29443
30516
  if (props) {
29444
30517
  _this.fromData(props);
@@ -29710,6 +30783,18 @@ var ParticleSystem = /*#__PURE__*/ function(Component) {
29710
30783
  });
29711
30784
  }
29712
30785
  };
30786
+ /**
30787
+ * @hidden
30788
+ * Internal utility.
30789
+ * Not part of the public API — do not rely on this in your code.
30790
+ */ _proto.rebuild = function rebuild() {
30791
+ var _this_renderer;
30792
+ (_this_renderer = this.renderer) == null ? void 0 : _this_renderer.rebuild();
30793
+ };
30794
+ _proto.dispose = function dispose() {
30795
+ this.engine.removeParticleSystem(this);
30796
+ Component.prototype.dispose.call(this);
30797
+ };
29713
30798
  _proto.getParticleBoxes = function getParticleBoxes() {
29714
30799
  var link = this.particleLink;
29715
30800
  var renderer = this.renderer;
@@ -30977,8 +32062,8 @@ var SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
30977
32062
  var width = isRotate90 ? h : w;
30978
32063
  var height = isRotate90 ? w : h;
30979
32064
  var angle = isRotate90 ? -Math.PI / 2 : 0;
30980
- var aUV = geometry.getAttributeData("aUV");
30981
- var aPos = geometry.getAttributeData("aPos");
32065
+ var aUV = geometry.getAttributeData(VertexBuffer.UVKind);
32066
+ var aPos = geometry.getAttributeData(VertexBuffer.PositionKind);
30982
32067
  var indices = geometry.getIndexData();
30983
32068
  var tempPosition = [
30984
32069
  0,
@@ -30997,8 +32082,8 @@ var SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
30997
32082
  aUV[uvOffset] = (tempPosition[0] + 0.5) * width + x;
30998
32083
  aUV[uvOffset + 1] = (tempPosition[1] + 0.5) * height + y;
30999
32084
  }
31000
- this.geometry.setAttributeData("aPos", aPos.slice());
31001
- this.geometry.setAttributeData("aUV", aUV.slice());
32085
+ this.updateAttributeData(VertexBuffer.PositionKind, aPos.slice(), 3);
32086
+ this.updateAttributeData(VertexBuffer.UVKind, aUV.slice(), 2);
31002
32087
  this.geometry.setIndexData(indices.slice());
31003
32088
  this.geometry.setDrawCount(indices.length);
31004
32089
  }
@@ -31118,11 +32203,23 @@ var SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
31118
32203
  index.push(base, 1 + base, 2 + base, 2 + base, 1 + base, 3 + base);
31119
32204
  }
31120
32205
  }
31121
- geometry.setAttributeData("aPos", new Float32Array(position));
32206
+ this.updateAttributeData(VertexBuffer.PositionKind, new Float32Array(position), 3);
31122
32207
  geometry.setIndexData(new Uint16Array(index));
31123
- geometry.setAttributeData("aUV", new Float32Array(aUV));
32208
+ this.updateAttributeData(VertexBuffer.UVKind, new Float32Array(aUV), 2);
31124
32209
  geometry.setDrawCount(index.length);
31125
32210
  };
32211
+ _proto.updateAttributeData = function updateAttributeData(name, data, size) {
32212
+ var vertexBuffer = this.geometry.getVertexBuffer(name);
32213
+ var dataBuffer = vertexBuffer == null ? void 0 : vertexBuffer.getBuffer();
32214
+ if (!vertexBuffer || dataBuffer && data.byteLength > dataBuffer.capacity) {
32215
+ this.geometry.setVerticesBuffer(new VertexBuffer(this.engine, data, name, {
32216
+ updatable: true,
32217
+ size: size
32218
+ }));
32219
+ return;
32220
+ }
32221
+ this.geometry.setAttributeData(name, data);
32222
+ };
31126
32223
  _create_class(SpriteComponent, [
31127
32224
  {
31128
32225
  key: "sprite",
@@ -31591,20 +32688,22 @@ var TextStyle = /*#__PURE__*/ function() {
31591
32688
  return;
31592
32689
  }
31593
32690
  var context = this.context;
32691
+ var textureWidth = Math.max(1, width);
32692
+ var textureHeight = Math.max(1, height);
31594
32693
  // 先保存状态
31595
32694
  context.save();
31596
32695
  // 设置canvas尺寸
31597
- this.canvas.width = width;
31598
- this.canvas.height = height;
32696
+ this.canvas.width = textureWidth;
32697
+ this.canvas.height = textureHeight;
31599
32698
  //重置变换
31600
32699
  context.setTransform(1, 0, 0, 1, 0, 0);
31601
32700
  // 处理翻转
31602
32701
  if (!flipY) {
31603
- context.translate(0, height);
32702
+ context.translate(0, textureHeight);
31604
32703
  context.scale(1, -1);
31605
32704
  }
31606
32705
  // 在翻转后清空画布
31607
- context.clearRect(0, 0, width, height);
32706
+ context.clearRect(0, 0, textureWidth, textureHeight);
31608
32707
  // 设置 alpha 修复用填充色(不实际输出像素)
31609
32708
  context.fillStyle = "rgba(255, 255, 255, " + this.ALPHA_FIX_VALUE + ")";
31610
32709
  // 执行绘制回调
@@ -31612,7 +32711,7 @@ var TextStyle = /*#__PURE__*/ function() {
31612
32711
  // 创建纹理前恢复状态
31613
32712
  context.restore();
31614
32713
  // 创建新纹理
31615
- var imageData = context.getImageData(0, 0, width, height);
32714
+ var imageData = context.getImageData(0, 0, textureWidth, textureHeight);
31616
32715
  var texture = Texture.createWithData(this.engine, {
31617
32716
  data: new Uint8Array(imageData.data),
31618
32717
  width: imageData.width,
@@ -33581,45 +34680,42 @@ var ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
33581
34680
  easingOuts: [],
33582
34681
  shapes: []
33583
34682
  };
34683
+ var _obj;
33584
34684
  // Create Geometry
33585
34685
  //-------------------------------------------------------------------------
33586
34686
  _this.geometry = Geometry.create(_this.engine, {
33587
- attributes: {
33588
- aPos: {
33589
- type: glContext.FLOAT,
33590
- size: 3,
33591
- data: new Float32Array([
33592
- -0.5,
33593
- 0.5,
33594
- 0,
33595
- -0.5,
33596
- -0.5,
33597
- 0,
33598
- 0.5,
33599
- 0.5,
33600
- 0,
33601
- 0.5,
33602
- -0.5,
33603
- 0
33604
- ])
33605
- },
33606
- aUV: {
33607
- size: 2,
33608
- offset: 0,
33609
- releasable: true,
33610
- type: glContext.FLOAT,
33611
- data: new Float32Array([
33612
- 0,
33613
- 1,
33614
- 0,
33615
- 0,
33616
- 1,
33617
- 1,
33618
- 1,
33619
- 0
33620
- ])
33621
- }
33622
- },
34687
+ attributes: (_obj = {}, _obj[VertexBuffer.PositionKind] = {
34688
+ type: glContext.FLOAT,
34689
+ size: 3,
34690
+ data: new Float32Array([
34691
+ -0.5,
34692
+ 0.5,
34693
+ 0,
34694
+ -0.5,
34695
+ -0.5,
34696
+ 0,
34697
+ 0.5,
34698
+ 0.5,
34699
+ 0,
34700
+ 0.5,
34701
+ -0.5,
34702
+ 0
34703
+ ])
34704
+ }, _obj[VertexBuffer.UVKind] = {
34705
+ size: 2,
34706
+ offset: 0,
34707
+ type: glContext.FLOAT,
34708
+ data: new Float32Array([
34709
+ 0,
34710
+ 1,
34711
+ 0,
34712
+ 0,
34713
+ 1,
34714
+ 1,
34715
+ 1,
34716
+ 0
34717
+ ])
34718
+ }, _obj),
33623
34719
  indices: {
33624
34720
  data: new Uint16Array([
33625
34721
  0,
@@ -33628,11 +34724,11 @@ var ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
33628
34724
  2,
33629
34725
  1,
33630
34726
  3
33631
- ]),
33632
- releasable: true
34727
+ ])
33633
34728
  },
33634
34729
  mode: glContext.TRIANGLES,
33635
- drawCount: 6
34730
+ drawCount: 6,
34731
+ bufferUsage: glContext.DYNAMIC_DRAW
33636
34732
  });
33637
34733
  _this.geometry.subMeshes.push({
33638
34734
  offset: 0,
@@ -33698,7 +34794,7 @@ var ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
33698
34794
  return boundingBox;
33699
34795
  };
33700
34796
  _proto.getBoundingBoxInfo = function getBoundingBoxInfo() {
33701
- var positionArray = this.geometry.getAttributeData("aPos");
34797
+ var positionArray = this.geometry.getAttributeData(VertexBuffer.PositionKind);
33702
34798
  if (positionArray) {
33703
34799
  var minMaxResult = extractMinAndMax(positionArray, 0, positionArray.length / 3);
33704
34800
  minMaxResult.minimum.x *= this.transform.size.x;
@@ -33749,8 +34845,8 @@ var ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
33749
34845
  var strokeIndexCount = indices.length - fillIndexCount;
33750
34846
  var vertexCount = vertices.length / 2;
33751
34847
  // Get the current attribute and index arrays from the geometry, avoiding re-creation
33752
- var positionArray = this.geometry.getAttributeData("aPos");
33753
- var uvArray = this.geometry.getAttributeData("aUV");
34848
+ var positionArray = this.geometry.getAttributeData(VertexBuffer.PositionKind);
34849
+ var uvArray = this.geometry.getAttributeData(VertexBuffer.UVKind);
33754
34850
  var indexArray = this.geometry.getIndexData();
33755
34851
  if (!positionArray || positionArray.length < vertexCount * 3) {
33756
34852
  positionArray = new Float32Array(vertexCount * 3);
@@ -33791,8 +34887,8 @@ var ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
33791
34887
  // Set index array
33792
34888
  indexArray.set(indices);
33793
34889
  // Rewrite to geometry
33794
- this.geometry.setAttributeData("aPos", positionArray);
33795
- this.geometry.setAttributeData("aUV", uvArray);
34890
+ this.updateAttributeData(VertexBuffer.PositionKind, positionArray, 3);
34891
+ this.updateAttributeData(VertexBuffer.UVKind, uvArray, 2);
33796
34892
  this.geometry.setIndexData(indexArray);
33797
34893
  this.geometry.setDrawCount(indices.length);
33798
34894
  var u16Size = 2;
@@ -33802,6 +34898,18 @@ var ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
33802
34898
  strokeSubMesh.offset = fillIndexCount * u16Size;
33803
34899
  strokeSubMesh.indexCount = strokeIndexCount;
33804
34900
  };
34901
+ _proto.updateAttributeData = function updateAttributeData(name, data, size) {
34902
+ var _this_geometry_getVertexBuffer;
34903
+ var dataBuffer = (_this_geometry_getVertexBuffer = this.geometry.getVertexBuffer(name)) == null ? void 0 : _this_geometry_getVertexBuffer.getBuffer();
34904
+ if (dataBuffer && data.byteLength > dataBuffer.capacity) {
34905
+ this.geometry.setVerticesBuffer(new VertexBuffer(this.engine, data, name, {
34906
+ updatable: true,
34907
+ size: size
34908
+ }));
34909
+ return;
34910
+ }
34911
+ this.geometry.setAttributeData(name, data);
34912
+ };
33805
34913
  _proto.computeScreenScale = function computeScreenScale() {
33806
34914
  var defaultPpu = 1;
33807
34915
  var composition = this.item.composition;
@@ -36578,7 +37686,7 @@ function getStandardSpriteContent(sprite, transform) {
36578
37686
  return ret;
36579
37687
  }
36580
37688
 
36581
- var version$1 = "2.10.0-alpha.1";
37689
+ var version$1 = "2.10.0-alpha.2";
36582
37690
  var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
36583
37691
  var standardVersion = /^(\d+)\.(\d+)$/;
36584
37692
  var reverseParticle = false;
@@ -38369,11 +39477,6 @@ var tmpScale = new Vector3(1, 1, 1);
38369
39477
  return Camera;
38370
39478
  }();
38371
39479
 
38372
- function _assert_this_initialized(self) {
38373
- if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
38374
- return self;
38375
- }
38376
-
38377
39480
  /**
38378
39481
  *
38379
39482
  */ var SceneTicking = /*#__PURE__*/ function() {
@@ -38540,7 +39643,7 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
38540
39643
  _this.paused = true;
38541
39644
  _this.isEndCalled = false;
38542
39645
  _this._textures = [];
38543
- 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, event = _ref.event, onItemMessage = _ref.onItemMessage;
39646
+ 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;
38544
39647
  _this.engine.addComposition(_assert_this_initialized(_this));
38545
39648
  var sourceContent = null;
38546
39649
  if (scene) {
@@ -38598,7 +39701,7 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
38598
39701
  _this.id = (_sourceContent_id = sourceContent == null ? void 0 : sourceContent.id) != null ? _sourceContent_id : generateGUID();
38599
39702
  var _sourceContent_startTime;
38600
39703
  _this.startTime = (_sourceContent_startTime = sourceContent == null ? void 0 : sourceContent.startTime) != null ? _sourceContent_startTime : 0;
38601
- _this.event = event;
39704
+ _this.event = engine.eventSystem;
38602
39705
  var _scene_startTime, _scene_totalTime;
38603
39706
  _this.statistic = {
38604
39707
  loadStart: (_scene_startTime = scene == null ? void 0 : scene.startTime) != null ? _scene_startTime : 0,
@@ -40944,6 +42047,7 @@ var DEFAULT_FPS = 60;
40944
42047
  _this.renderPasses = [];
40945
42048
  _this.framebuffers = [];
40946
42049
  _this.renderbuffers = [];
42050
+ _this.particleSystems = [];
40947
42051
  _this.clearAction = {
40948
42052
  stencilAction: TextureLoadAction.clear,
40949
42053
  clearStencil: 0,
@@ -40982,7 +42086,6 @@ var DEFAULT_FPS = 60;
40982
42086
  _this.assetLoader = new AssetLoader(_assert_this_initialized(_this));
40983
42087
  _this.assetService = new AssetService(_assert_this_initialized(_this));
40984
42088
  _this.renderTargetPool = new RenderTargetPool(_assert_this_initialized(_this));
40985
- _this.graphics = new Graphics(_assert_this_initialized(_this));
40986
42089
  _this.renderingData = {
40987
42090
  // @ts-expect-error
40988
42091
  currentFrame: {}
@@ -41193,55 +42296,27 @@ var DEFAULT_FPS = 60;
41193
42296
  });
41194
42297
  this.emit("resize", this);
41195
42298
  };
41196
- _proto.getTargetSize = function getTargetSize(parentEle) {
41197
- if (parentEle === undefined || parentEle === null) {
41198
- throw new Error("Container is not an HTMLElement, see " + HELP_LINK["Container is not an HTMLElement"] + ".");
41199
- }
41200
- var displayAspect = this.displayAspect;
41201
- // 小程序环境没有 getComputedStyle
41202
- var computedStyle = window.getComputedStyle == null ? void 0 : window.getComputedStyle.call(window, parentEle);
41203
- var targetWidth;
41204
- var targetHeight;
41205
- var finalWidth = 0;
41206
- var finalHeight = 0;
41207
- if (computedStyle) {
41208
- finalWidth = parseInt(computedStyle.width, 10);
41209
- finalHeight = parseInt(computedStyle.height, 10);
41210
- } else {
41211
- finalWidth = parentEle.clientWidth;
41212
- finalHeight = parentEle.clientHeight;
41213
- }
41214
- if (displayAspect) {
41215
- var parentAspect = finalWidth / finalHeight;
41216
- if (parentAspect > displayAspect) {
41217
- targetHeight = finalHeight * this.displayScale;
41218
- targetWidth = targetHeight * displayAspect;
41219
- } else {
41220
- targetWidth = finalWidth * this.displayScale;
41221
- targetHeight = targetWidth / displayAspect;
41222
- }
41223
- } else {
41224
- targetWidth = finalWidth;
41225
- targetHeight = finalHeight;
41226
- }
41227
- var ratio = this.pixelRatio;
41228
- var containerWidth = targetWidth;
41229
- var containerHeight = targetHeight;
41230
- targetWidth = Math.round(targetWidth * ratio);
41231
- targetHeight = Math.round(targetHeight * ratio);
41232
- if (targetWidth < 1 || targetHeight < 1) {
41233
- if (this.offscreenMode) {
41234
- targetWidth = targetHeight = containerWidth = containerHeight = 1;
41235
- } else {
41236
- throw new Error("Invalid container size " + targetWidth + "x" + targetHeight + ", see " + HELP_LINK["Invalid container size"] + ".");
41237
- }
41238
- }
41239
- return [
41240
- containerWidth,
41241
- containerHeight,
41242
- targetWidth,
41243
- targetHeight
41244
- ];
42299
+ _proto.createVertexBuffer = function createVertexBuffer(data, options) {
42300
+ throw new Error("The active rendering backend does not provide vertex buffers.");
42301
+ };
42302
+ _proto.createDynamicVertexBuffer = function createDynamicVertexBuffer(data, options) {
42303
+ return this.createVertexBuffer(data, options);
42304
+ };
42305
+ _proto.createIndexBuffer = function createIndexBuffer(indices, options) {
42306
+ throw new Error("The active rendering backend does not provide index buffers.");
42307
+ };
42308
+ _proto.updateDynamicVertexBuffer = function updateDynamicVertexBuffer(vertexBuffer, data, byteOffset, byteLength) {
42309
+ throw new Error("The active rendering backend cannot update vertex buffers.");
42310
+ };
42311
+ _proto.updateDynamicIndexBuffer = function updateDynamicIndexBuffer(indexBuffer, indices, byteOffset) {
42312
+ throw new Error("The active rendering backend cannot update index buffers.");
42313
+ };
42314
+ /** @hide */ _proto.releaseBuffer = function releaseBuffer(buffer) {
42315
+ buffer.references--;
42316
+ return buffer.references === 0;
42317
+ };
42318
+ /** @hide */ _proto.bindBuffers = function bindBuffers(vertexBuffers, indexBuffer, effect) {
42319
+ throw new Error("The active rendering backend cannot bind geometry buffers.");
41245
42320
  };
41246
42321
  _proto.addTexture = function addTexture(tex) {
41247
42322
  if (this.disposed) {
@@ -41279,6 +42354,18 @@ var DEFAULT_FPS = 60;
41279
42354
  }
41280
42355
  removeItem(this.geometries, geo);
41281
42356
  };
42357
+ /** @internal */ _proto.addParticleSystem = function addParticleSystem(particleSystem) {
42358
+ if (this.disposed) {
42359
+ return;
42360
+ }
42361
+ addItem(this.particleSystems, particleSystem);
42362
+ };
42363
+ /** @internal */ _proto.removeParticleSystem = function removeParticleSystem(particleSystem) {
42364
+ if (this.disposed) {
42365
+ return;
42366
+ }
42367
+ removeItem(this.particleSystems, particleSystem);
42368
+ };
41282
42369
  _proto.addMesh = function addMesh(mesh) {
41283
42370
  if (this.disposed) {
41284
42371
  return;
@@ -41431,7 +42518,7 @@ var DEFAULT_FPS = 60;
41431
42518
  /**
41432
42519
  * 销毁所有缓存的资源
41433
42520
  */ _proto.dispose = function dispose() {
41434
- var _this_ticker, _this_eventSystem, _this_assetService;
42521
+ var _this_ticker, _this_eventSystem, _this_assetService, _this__graphics;
41435
42522
  if (this.disposed) {
41436
42523
  return;
41437
42524
  }
@@ -41456,7 +42543,7 @@ var DEFAULT_FPS = 60;
41456
42543
  (_this_ticker = this.ticker) == null ? void 0 : _this_ticker.stop();
41457
42544
  (_this_eventSystem = this.eventSystem) == null ? void 0 : _this_eventSystem.dispose();
41458
42545
  (_this_assetService = this.assetService) == null ? void 0 : _this_assetService.dispose();
41459
- this.graphics.dispose();
42546
+ (_this__graphics = this._graphics) == null ? void 0 : _this__graphics.dispose();
41460
42547
  this.renderPasses.forEach(function(pass) {
41461
42548
  return pass.dispose();
41462
42549
  });
@@ -41484,8 +42571,69 @@ var DEFAULT_FPS = 60;
41484
42571
  this.meshes = [];
41485
42572
  this.renderPasses = [];
41486
42573
  this.compositions = [];
42574
+ this.particleSystems = [];
42575
+ };
42576
+ _proto.getTargetSize = function getTargetSize(parentEle) {
42577
+ if (parentEle === undefined || parentEle === null) {
42578
+ throw new Error("Container is not an HTMLElement, see " + HELP_LINK["Container is not an HTMLElement"] + ".");
42579
+ }
42580
+ var displayAspect = this.displayAspect;
42581
+ // 小程序环境没有 getComputedStyle
42582
+ var computedStyle = window.getComputedStyle == null ? void 0 : window.getComputedStyle.call(window, parentEle);
42583
+ var targetWidth;
42584
+ var targetHeight;
42585
+ var finalWidth = 0;
42586
+ var finalHeight = 0;
42587
+ if (computedStyle) {
42588
+ finalWidth = parseInt(computedStyle.width, 10);
42589
+ finalHeight = parseInt(computedStyle.height, 10);
42590
+ } else {
42591
+ finalWidth = parentEle.clientWidth;
42592
+ finalHeight = parentEle.clientHeight;
42593
+ }
42594
+ if (displayAspect) {
42595
+ var parentAspect = finalWidth / finalHeight;
42596
+ if (parentAspect > displayAspect) {
42597
+ targetHeight = finalHeight * this.displayScale;
42598
+ targetWidth = targetHeight * displayAspect;
42599
+ } else {
42600
+ targetWidth = finalWidth * this.displayScale;
42601
+ targetHeight = targetWidth / displayAspect;
42602
+ }
42603
+ } else {
42604
+ targetWidth = finalWidth;
42605
+ targetHeight = finalHeight;
42606
+ }
42607
+ var ratio = this.pixelRatio;
42608
+ var containerWidth = targetWidth;
42609
+ var containerHeight = targetHeight;
42610
+ targetWidth = Math.round(targetWidth * ratio);
42611
+ targetHeight = Math.round(targetHeight * ratio);
42612
+ if (targetWidth < 1 || targetHeight < 1) {
42613
+ if (this.offscreenMode) {
42614
+ targetWidth = targetHeight = containerWidth = containerHeight = 1;
42615
+ } else {
42616
+ throw new Error("Invalid container size " + targetWidth + "x" + targetHeight + ", see " + HELP_LINK["Invalid container size"] + ".");
42617
+ }
42618
+ }
42619
+ return [
42620
+ containerWidth,
42621
+ containerHeight,
42622
+ targetWidth,
42623
+ targetHeight
42624
+ ];
41487
42625
  };
41488
42626
  _create_class(Engine, [
42627
+ {
42628
+ key: "graphics",
42629
+ get: function get() {
42630
+ if (this._graphics) {
42631
+ return this._graphics;
42632
+ }
42633
+ this._graphics = new Graphics(this);
42634
+ return this._graphics;
42635
+ }
42636
+ },
41489
42637
  {
41490
42638
  key: "disposed",
41491
42639
  get: function get() {
@@ -41648,9 +42796,7 @@ var PassTextureCache = /*#__PURE__*/ function() {
41648
42796
  };
41649
42797
  SceneLoader.createComposition = function createComposition(scene, engine, options) {
41650
42798
  if (options === void 0) options = {};
41651
- var composition = new Composition(engine, _extends({}, options, {
41652
- event: engine.eventSystem
41653
- }), scene);
42799
+ var composition = new Composition(engine, _extends({}, options), scene);
41654
42800
  // TODO 目前编辑器会每帧调用 loadScene, 在这编译会导致闪帧,待编辑器渲染逻辑优化后移除。
41655
42801
  if (engine.env !== PLAYER_OPTIONS_ENV_EDITOR) {
41656
42802
  engine.assetService.createShaderVariant();
@@ -41703,7 +42849,7 @@ var PrecompositionManager = /*#__PURE__*/ function() {
41703
42849
  rootItem.instantiatePreComposition(compositionData);
41704
42850
  var _options_autoplay;
41705
42851
  rootItem.getComponent(CompositionComponent).playOnStart = (_options_autoplay = options.autoplay) != null ? _options_autoplay : true;
41706
- rootItem.getComponent(CompositionComponent).endBehavior = 0;
42852
+ rootItem.getComponent(CompositionComponent).endBehavior = rootItem.endBehavior;
41707
42853
  composition.addItem(rootItem);
41708
42854
  return rootItem;
41709
42855
  };
@@ -41715,8 +42861,8 @@ registerPlugin("text", TextLoader);
41715
42861
  registerPlugin("sprite", SpriteLoader);
41716
42862
  registerPlugin("particle", ParticleLoader);
41717
42863
  registerPlugin("interact", InteractLoader);
41718
- var version = "2.10.0-alpha.1";
42864
+ var version = "2.10.0-alpha.2";
41719
42865
  logger.info("Core version: " + version + ".");
41720
42866
 
41721
- export { ATLAS_SIZE, ActivationMixerPlayable, ActivationPlayable, ActivationPlayableAsset, ActivationTrack, AndNode, AndNodeData, Animatable, AnimationClip, AnimationClipNode, AnimationClipNodeData, AnimationEvent, AnimationGraphAsset, Animator, ApplyAdditiveNode, ApplyAdditiveNodeData, Asset, AssetLoader, AssetManager, AssetService, BYTES_TYPE_MAP, Behaviour, BezierCurve, BezierCurvePath, BezierCurveQuat, BezierDataMap, BezierEasing, BezierLengthData, BezierMap, BezierPath, BezierQuat, BinaryAsset, BlendNode, BlendNodeData, BoolValueNode, BoundingBoxInfo, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, Camera, CameraController, CameraVFXItemLoader, CanvasItem, CanvasLayer, Circle$1 as Circle, ColorCurve, ColorPlayable, ColorPropertyMixerPlayable, ColorPropertyPlayableAsset, ColorPropertyTrack, Component, ComponentTimePlayable, ComponentTimePlayableAsset, ComponentTimeTrack, Composition, CompositionComponent, CompressTextureCapabilityType, ConstBoolNode, ConstBoolNodeData, ConstFloatNode, ConstFloatNodeData, ConstraintTarget, Control, ControlParameterBoolNode, ControlParameterBoolNodeData, ControlParameterFloatNode, ControlParameterFloatNodeData, ControlParameterTriggerNode, ControlParameterTriggerNodeData, DEFAULT_FONTS, DEFAULT_FPS, Database, Deferred, DestroyOptions, Downloader, DrawObjectPass, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, EffectComponent, EffectComponentTimeTrack, EffectsObject, EffectsPackage, Ellipse, Engine, EqualNodeData, EventEmitter, EventSystem, FONT_SCALE, Fake3DAnimationMode, Fake3DComponent, FilterMode, Float16ArrayWrapper, FloatComparisonNode, FloatComparisonNodeData, FloatPropertyMixerPlayable, FloatPropertyPlayableAsset, FloatPropertyTrack, FloatValueNode, FrameComponent, Framebuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GlyphAtlas, GradientValue, GraphInstance, GraphNode, GraphNodeData, Graphics, GreaterNodeData, HELP_LINK, HitTestType, InteractComponent, InteractLoader, InteractMesh, InvalidIndex, Item, LayerBlendNode, LayerBlendNodeData, LessNodeData, LineSegments, LinearValue, MaskMode, MaskProcessor, MaskableGraphic, Material, MaterialDataBlock, MaterialRenderType, MaterialState, MaterialTrack, Mesh, NodeTransform, NotNode, NotNodeData, NotifyEvent, ObjectBindingTrack, OrNode, OrNodeData, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleBehaviourPlayable, ParticleBehaviourPlayableAsset, ParticleLoader, ParticleMesh, ParticleMixerPlayable, ParticleSystem, ParticleSystemRenderer, ParticleTrack, PassTextureCache, PathSegments, PlayState, Playable, PlayableAsset, PlayableOutput, Plugin, PluginSystem, PointerEventData, PointerEventType, PolyStar, Polygon, Pose, PoseNode, PositionConstraint, PostProcessVolume, Precomposition, PrecompositionManager, PropertyClipPlayable, PropertyTrack, REFERENCE_CURVE, RENDER_PREFER_LOOKUP_TEXTURE, RUNTIME_ENV, RandomSetValue, RandomValue, RandomVectorValue, RaycastResult, RectTransform, Rectangle$1 as Rectangle, ReferenceCurve, RenderFrame, RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, RenderTargetHandle, RenderTargetPool, RenderTextureFormat, Renderbuffer, Renderer, RendererComponent, RuntimeClip, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0, SEMANTIC_PRE_COLOR_ATTACHMENT_0, SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0, SPRITE_VERTEX_STRIDE, Scene, SceneLoader, SerializationHelper, Shader, ShaderCompileResultStatus, ShaderFactory, ShaderType, ShaderVariant, ShapeComponent, SourceType, Sprite, SpriteColorMixerPlayable, SpriteColorPlayableAsset, SpriteColorTrack, SpriteComponent, SpriteComponentTimeTrack, SpriteLoader, SpritePropertyMixerPlayable, SpritePropertyPlayableAsset, SpritePropertyTrack, SpriteRotation, StarType, StateMachineNode, StateMachineNodeData, StateNode, StateNodeData, StaticValue, SubCompositionClipPlayable, SubCompositionMixerPlayable, SubCompositionPlayableAsset, SubCompositionTrack, TEMPLATE_USE_OFFSCREEN_CANVAS, TangentMode, TextCache, TextComponent, TextComponentBase, TextLayout, TextLoader, TextStyle, Texture, TextureFactory, TextureLoadAction, TexturePaintScaleMode, TextureSourceType, TextureStoreAction, Ticker, TimelineAsset, TimelineClip, TimelineInstance, TrackAsset, TrackMixerPlayable, TrackType, Transform, TransformMixerPlayable, TransformPlayable, TransformPlayableAsset, TransformTrack, TransitionNode, TransitionNodeData, TransitionState, Triangle, TrimPath, TrimPathMode, UpdateModes, VFXItem, ValueGetter, ValueNode, Vector2Curve, Vector2PropertyMixerPlayable, Vector2PropertyPlayableAsset, Vector2PropertyTrack, Vector3Curve, Vector3PropertyMixerPlayable, Vector3PropertyTrack, Vector3ropertyPlayableAsset, Vector4Curve, Vector4PropertyMixerPlayable, Vector4PropertyPlayableAsset, Vector4PropertyTrack, WeightedMode, addByOrder, addItem, addItemWithOrder, applyMixins, assertExist, asserts, base64ToFile, breakOpportunityAfter, buildBezierData, buildEasingCurve, buildLine, calculateTranslation, canUseBOM, canvasPool, closePointEps, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, createGLContext, createKeyFrameMeta, createShape, createValueGetter, curveEps, decimalEqual, deserializeMipmapTexture, earcut, effectsClass, effectsClassStore, enlargeBuffer, ensureFixedNumber, ensureVec3, extractMinAndMax, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTexture, generateEmptyTypedArray, generateGUID, generateHalfFloatTexture, generateWhiteTexture, getBackgroundImage, getClass, getColorFromGradientStops, getConfig, getControlPoints, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, getKeyFrameMetaByRawValue, getMergedStore, getNodeDataClass, getParticleMeshShader, getPixelRatio, getPluginUsageInfo, getPreMultiAlpha, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, getTextureSize, glContext, glType2VertexFormatType, gpuTimer, imageDataFromColor, imageDataFromGradient, initErrors, initGLContext, integrate, interpolateColor, isAlipayMiniApp, isAndroid, isArray, isBreakChar, isCJKLike, isCanvas, isFunction, isIOS, isIOSByUA, isMiniProgram, isObject, isOpenHarmony, isPlainObject, isPowerOfTwo, isSafeFontFamily, isSimulatorCellPhone, isString, isUniformStruct, isUniformStructArray, isValidFontFamily, isWebGL2, isWechatMiniApp, itemFrag, itemVert, loadAVIFOptional, loadBinary, loadBlob, loadImage, loadMedia, loadVideo, loadWebPOptional, logger, index as math, modifyMaxKeyframeShader, nearestPowerOfTwo, nodeDataClass, noop, normalizeColor, numberToFix, oldBezierKeyFramesToNew, parsePercent$1 as parsePercent, particleFrag, particleOriginTranslateMap$1 as particleOriginTranslateMap, particleUniformTypeMap, particleVert, passRenderLevel, pluginLoaderMap, randomInRange, registerPlugin, removeItem, rotateVec2, screenMeshVert, serialize, setBlendMode, setConfig, setDefaultTextureFactory, setMaskMode, setRayFromCamera, setSideMode, sortByOrder, index$1 as spec, textureLoaderRegistry, thresholdFrag, throwDestroyedError, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecFill, vecMulCombine, version, vertexFormatType2GLType };
42867
+ export { ATLAS_SIZE, ActivationMixerPlayable, ActivationPlayable, ActivationPlayableAsset, ActivationTrack, AndNode, AndNodeData, Animatable, AnimationClip, AnimationClipNode, AnimationClipNodeData, AnimationEvent, AnimationGraphAsset, Animator, ApplyAdditiveNode, ApplyAdditiveNodeData, Asset, AssetLoader, AssetManager, AssetService, BYTES_TYPE_MAP, Behaviour, BezierCurve, BezierCurvePath, BezierCurveQuat, BezierDataMap, BezierEasing, BezierLengthData, BezierMap, BezierPath, BezierQuat, BinaryAsset, BlendNode, BlendNodeData, BoolValueNode, BoundingBoxInfo, Buffer, BufferDataType, BufferUsage, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, Camera, CameraController, CameraVFXItemLoader, CanvasItem, CanvasLayer, Circle$1 as Circle, ColorCurve, ColorPlayable, ColorPropertyMixerPlayable, ColorPropertyPlayableAsset, ColorPropertyTrack, Component, ComponentTimePlayable, ComponentTimePlayableAsset, ComponentTimeTrack, Composition, CompositionComponent, CompressTextureCapabilityType, ConstBoolNode, ConstBoolNodeData, ConstFloatNode, ConstFloatNodeData, ConstraintTarget, Control, ControlParameterBoolNode, ControlParameterBoolNodeData, ControlParameterFloatNode, ControlParameterFloatNodeData, ControlParameterTriggerNode, ControlParameterTriggerNodeData, DEFAULT_FONTS, DEFAULT_FPS, DataBuffer, Database, Deferred, DestroyOptions, Downloader, DrawObjectPass, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, EffectComponent, EffectComponentTimeTrack, EffectsObject, EffectsPackage, Ellipse, Engine, EqualNodeData, EventEmitter, EventSystem, FONT_SCALE, Fake3DAnimationMode, Fake3DComponent, FilterMode, Float16ArrayWrapper, FloatComparisonNode, FloatComparisonNodeData, FloatPropertyMixerPlayable, FloatPropertyPlayableAsset, FloatPropertyTrack, FloatValueNode, FrameComponent, Framebuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GlyphAtlas, GradientValue, GraphInstance, GraphNode, GraphNodeData, Graphics, GreaterNodeData, HELP_LINK, HitTestType, InteractComponent, InteractLoader, InteractMesh, InvalidIndex, Item, LayerBlendNode, LayerBlendNodeData, LessNodeData, LineSegments, LinearValue, MaskMode, MaskProcessor, MaskableGraphic, Material, MaterialDataBlock, MaterialRenderType, MaterialState, MaterialTrack, Mesh, NodeTransform, NotNode, NotNodeData, NotifyEvent, ObjectBindingTrack, OrNode, OrNodeData, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleBehaviourPlayable, ParticleBehaviourPlayableAsset, ParticleLoader, ParticleMesh, ParticleMixerPlayable, ParticleSystem, ParticleSystemRenderer, ParticleTrack, PassTextureCache, PathSegments, PlayState, Playable, PlayableAsset, PlayableOutput, Plugin, PluginSystem, PointerEventData, PointerEventType, PolyStar, Polygon, Pose, PoseNode, PositionConstraint, PostProcessVolume, Precomposition, PrecompositionManager, PropertyClipPlayable, PropertyTrack, REFERENCE_CURVE, RENDER_PREFER_LOOKUP_TEXTURE, RUNTIME_ENV, RandomSetValue, RandomValue, RandomVectorValue, RaycastResult, RectTransform, Rectangle$1 as Rectangle, ReferenceCurve, RenderFrame, RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, RenderTargetHandle, RenderTargetPool, RenderTextureFormat, Renderbuffer, Renderer, RendererComponent, RuntimeClip, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0, SEMANTIC_PRE_COLOR_ATTACHMENT_0, SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0, SPRITE_VERTEX_STRIDE, Scene, SceneLoader, SerializationHelper, Shader, ShaderCompileResultStatus, ShaderFactory, ShaderType, ShaderVariant, ShapeComponent, SourceType, Sprite, SpriteColorMixerPlayable, SpriteColorPlayableAsset, SpriteColorTrack, SpriteComponent, SpriteComponentTimeTrack, SpriteLoader, SpritePropertyMixerPlayable, SpritePropertyPlayableAsset, SpritePropertyTrack, SpriteRotation, StarType, StateMachineNode, StateMachineNodeData, StateNode, StateNodeData, StaticValue, SubCompositionClipPlayable, SubCompositionMixerPlayable, SubCompositionPlayableAsset, SubCompositionTrack, TEMPLATE_USE_OFFSCREEN_CANVAS, TangentMode, TextCache, TextComponent, TextComponentBase, TextLayout, TextLoader, TextStyle, Texture, TextureFactory, TextureLoadAction, TexturePaintScaleMode, TextureSourceType, TextureStoreAction, Ticker, TimelineAsset, TimelineClip, TimelineInstance, TrackAsset, TrackMixerPlayable, TrackType, Transform, TransformMixerPlayable, TransformPlayable, TransformPlayableAsset, TransformTrack, TransitionNode, TransitionNodeData, TransitionState, Triangle, TrimPath, TrimPathMode, UpdateModes, VFXItem, ValueGetter, ValueNode, Vector2Curve, Vector2PropertyMixerPlayable, Vector2PropertyPlayableAsset, Vector2PropertyTrack, Vector3Curve, Vector3PropertyMixerPlayable, Vector3PropertyTrack, Vector3ropertyPlayableAsset, Vector4Curve, Vector4PropertyMixerPlayable, Vector4PropertyPlayableAsset, Vector4PropertyTrack, VertexBuffer, WeightedMode, addByOrder, addItem, addItemWithOrder, applyMixins, assertExist, asserts, base64ToFile, breakOpportunityAfter, buildBezierData, buildEasingCurve, buildLine, calculateTranslation, canUseBOM, canvasPool, closePointEps, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, createGLContext, createKeyFrameMeta, createShape, createTypedArray, createValueGetter, curveEps, decimalEqual, deserializeMipmapTexture, earcut, effectsClass, effectsClassStore, enlargeBuffer, ensureFixedNumber, ensureVec3, extractMinAndMax, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTexture, generateEmptyTypedArray, generateGUID, generateHalfFloatTexture, generateWhiteTexture, getBackgroundImage, getBytesPerElement, getClass, getColorFromGradientStops, getConfig, getControlPoints, getDataByteLength, getDataType, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, getKeyFrameMetaByRawValue, getMergedStore, getNodeDataClass, getParticleMeshShader, getPixelRatio, getPluginUsageInfo, getPreMultiAlpha, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, getTextureSize, glContext, glType2VertexFormatType, gpuTimer, imageDataFromColor, imageDataFromGradient, initErrors, initGLContext, integrate, interpolateColor, isAlipayMiniApp, isAndroid, isArray, isBreakChar, isCJKLike, isCanvas, isFunction, isIOS, isIOSByUA, isMiniProgram, isObject, isOpenHarmony, isPlainObject, isPowerOfTwo, isSafeFontFamily, isSimulatorCellPhone, isString, isUniformStruct, isUniformStructArray, isValidFontFamily, isWebGL2, isWechatMiniApp, itemFrag, itemVert, loadAVIFOptional, loadBinary, loadBlob, loadImage, loadMedia, loadVideo, loadWebPOptional, logger, index as math, modifyMaxKeyframeShader, nearestPowerOfTwo, nodeDataClass, noop, normalizeColor, numberToFix, oldBezierKeyFramesToNew, parsePercent$1 as parsePercent, particleFrag, particleOriginTranslateMap$1 as particleOriginTranslateMap, particleUniformTypeMap, particleVert, passRenderLevel, pluginLoaderMap, randomInRange, registerPlugin, removeItem, rotateVec2, screenMeshVert, serialize, setBlendMode, setConfig, setDefaultTextureFactory, setMaskMode, setRayFromCamera, setSideMode, sortByOrder, index$1 as spec, textureLoaderRegistry, thresholdFrag, throwDestroyedError, toBufferView, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecFill, vecMulCombine, version, vertexFormatType2GLType };
41722
42868
  //# sourceMappingURL=index.mjs.map