@galacean/effects-threejs 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.js +2192 -1127
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +2185 -1128
- package/dist/index.mjs.map +1 -1
- package/dist/three-data-buffer.d.ts +11 -0
- package/dist/three-engine.d.ts +13 -2
- package/dist/three-geometry.d.ts +3 -155
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects runtime threejs plugin for the web
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
|
|
6
|
-
* Version: v2.10.0-alpha.
|
|
6
|
+
* Version: v2.10.0-alpha.2
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -8250,7 +8250,7 @@ function _loadMipmapImage() {
|
|
|
8250
8250
|
return _loadMipmapImage.apply(this, arguments);
|
|
8251
8251
|
}
|
|
8252
8252
|
|
|
8253
|
-
var seed$
|
|
8253
|
+
var seed$9 = 1;
|
|
8254
8254
|
/**
|
|
8255
8255
|
* Texture 抽象类
|
|
8256
8256
|
*/ var Texture = /*#__PURE__*/ function(EffectsObject) {
|
|
@@ -8259,7 +8259,7 @@ var seed$a = 1;
|
|
|
8259
8259
|
var _this;
|
|
8260
8260
|
_this = EffectsObject.call(this, engine) || this;
|
|
8261
8261
|
_this.destroyed = false;
|
|
8262
|
-
_this.id = "Tex" + seed$
|
|
8262
|
+
_this.id = "Tex" + seed$9++;
|
|
8263
8263
|
return _this;
|
|
8264
8264
|
}
|
|
8265
8265
|
var _proto = Texture.prototype;
|
|
@@ -11678,10 +11678,11 @@ exports.GLSLVersion = void 0;
|
|
|
11678
11678
|
})(exports.GLSLVersion || (exports.GLSLVersion = {}));
|
|
11679
11679
|
var ShaderVariant = /*#__PURE__*/ function(EffectsObject) {
|
|
11680
11680
|
_inherits(ShaderVariant, EffectsObject);
|
|
11681
|
-
function ShaderVariant(engine, source) {
|
|
11681
|
+
function ShaderVariant(engine, source, key) {
|
|
11682
11682
|
var _this;
|
|
11683
11683
|
_this = EffectsObject.call(this, engine) || this;
|
|
11684
11684
|
_this.source = source;
|
|
11685
|
+
_this.key = key;
|
|
11685
11686
|
return _this;
|
|
11686
11687
|
}
|
|
11687
11688
|
var _proto = ShaderVariant.prototype;
|
|
@@ -11987,7 +11988,7 @@ exports.MaterialRenderType = void 0;
|
|
|
11987
11988
|
/**
|
|
11988
11989
|
* 用于设置材质默认名称的自增序号
|
|
11989
11990
|
* @internal
|
|
11990
|
-
*/ var seed$
|
|
11991
|
+
*/ var seed$8 = 1;
|
|
11991
11992
|
/**
|
|
11992
11993
|
* Material 类
|
|
11993
11994
|
*/ var Material = /*#__PURE__*/ function(EffectsObject) {
|
|
@@ -12019,7 +12020,7 @@ exports.MaterialRenderType = void 0;
|
|
|
12019
12020
|
_this.macrosDirty = true;
|
|
12020
12021
|
_this.materialState = new MaterialState();
|
|
12021
12022
|
if (props) {
|
|
12022
|
-
var _props_name = props.name, name = _props_name === void 0 ? "Material" + seed$
|
|
12023
|
+
var _props_name = props.name, name = _props_name === void 0 ? "Material" + seed$8++ : _props_name, _props_renderType = props.renderType, renderType = _props_renderType === void 0 ? 0 : _props_renderType, shader = props.shader;
|
|
12023
12024
|
_this.name = name;
|
|
12024
12025
|
_this.renderType = renderType; // TODO 没有地方用到
|
|
12025
12026
|
_this.shaderSource = shader;
|
|
@@ -12030,7 +12031,7 @@ exports.MaterialRenderType = void 0;
|
|
|
12030
12031
|
dataType: DataType.Shader
|
|
12031
12032
|
});
|
|
12032
12033
|
} else {
|
|
12033
|
-
_this.name = "Material" + seed$
|
|
12034
|
+
_this.name = "Material" + seed$8++;
|
|
12034
12035
|
_this.renderType = 0;
|
|
12035
12036
|
}
|
|
12036
12037
|
return _this;
|
|
@@ -12760,6 +12761,30 @@ var MAX_MASK_REFERENCE_COUNT = 254;
|
|
|
12760
12761
|
/**
|
|
12761
12762
|
* 期望的 stencil 值(等于正向蒙版的数量)
|
|
12762
12763
|
*/ this.expectedStencilValue = 0;
|
|
12764
|
+
this.prevStencilFunc = [
|
|
12765
|
+
0,
|
|
12766
|
+
0
|
|
12767
|
+
];
|
|
12768
|
+
this.prevStencilOpFail = [
|
|
12769
|
+
0,
|
|
12770
|
+
0
|
|
12771
|
+
];
|
|
12772
|
+
this.prevStencilOpZFail = [
|
|
12773
|
+
0,
|
|
12774
|
+
0
|
|
12775
|
+
];
|
|
12776
|
+
this.prevStencilOpZPass = [
|
|
12777
|
+
0,
|
|
12778
|
+
0
|
|
12779
|
+
];
|
|
12780
|
+
this.prevStencilRef = [
|
|
12781
|
+
0,
|
|
12782
|
+
0
|
|
12783
|
+
];
|
|
12784
|
+
this.prevStencilMask = [
|
|
12785
|
+
0,
|
|
12786
|
+
0
|
|
12787
|
+
];
|
|
12763
12788
|
this.stencilClearAction = {
|
|
12764
12789
|
stencilAction: exports.TextureLoadAction.clear
|
|
12765
12790
|
};
|
|
@@ -12917,22 +12942,22 @@ var MAX_MASK_REFERENCE_COUNT = 254;
|
|
|
12917
12942
|
if (subMeshIndex === void 0) subMeshIndex = 0;
|
|
12918
12943
|
var prevColorMask = material.colorMask;
|
|
12919
12944
|
var prevStencilTest = material.stencilTest;
|
|
12920
|
-
|
|
12921
|
-
|
|
12922
|
-
|
|
12923
|
-
|
|
12924
|
-
|
|
12925
|
-
|
|
12945
|
+
this.copyStencilArrayValue(this.prevStencilFunc, material.stencilFunc);
|
|
12946
|
+
this.copyStencilArrayValue(this.prevStencilOpFail, material.stencilOpFail);
|
|
12947
|
+
this.copyStencilArrayValue(this.prevStencilOpZFail, material.stencilOpZFail);
|
|
12948
|
+
this.copyStencilArrayValue(this.prevStencilOpZPass, material.stencilOpZPass);
|
|
12949
|
+
this.copyStencilArrayValue(this.prevStencilRef, material.stencilRef);
|
|
12950
|
+
this.copyStencilArrayValue(this.prevStencilMask, material.stencilMask);
|
|
12926
12951
|
this.setupMaskMaterial(material, maskRef);
|
|
12927
12952
|
renderer.drawGeometry(geometry, worldMatrix, material, subMeshIndex);
|
|
12928
12953
|
material.colorMask = prevColorMask;
|
|
12929
12954
|
material.stencilTest = prevStencilTest;
|
|
12930
|
-
material.stencilFunc = prevStencilFunc;
|
|
12931
|
-
material.stencilOpFail = prevStencilOpFail;
|
|
12932
|
-
material.stencilOpZFail = prevStencilOpZFail;
|
|
12933
|
-
material.stencilOpZPass = prevStencilOpZPass;
|
|
12934
|
-
material.stencilRef = prevStencilRef;
|
|
12935
|
-
material.stencilMask = prevStencilMask;
|
|
12955
|
+
material.stencilFunc = this.prevStencilFunc;
|
|
12956
|
+
material.stencilOpFail = this.prevStencilOpFail;
|
|
12957
|
+
material.stencilOpZFail = this.prevStencilOpZFail;
|
|
12958
|
+
material.stencilOpZPass = this.prevStencilOpZPass;
|
|
12959
|
+
material.stencilRef = this.prevStencilRef;
|
|
12960
|
+
material.stencilMask = this.prevStencilMask;
|
|
12936
12961
|
};
|
|
12937
12962
|
/**
|
|
12938
12963
|
* 设置蒙版材质的 stencil 属性(写入蒙版)
|
|
@@ -13006,6 +13031,13 @@ var MAX_MASK_REFERENCE_COUNT = 254;
|
|
|
13006
13031
|
material.stencilTest = false;
|
|
13007
13032
|
}
|
|
13008
13033
|
};
|
|
13034
|
+
_proto.copyStencilArrayValue = function copyStencilArrayValue(target, source) {
|
|
13035
|
+
if (!source) {
|
|
13036
|
+
return;
|
|
13037
|
+
}
|
|
13038
|
+
target[0] = source[0];
|
|
13039
|
+
target[1] = source[1];
|
|
13040
|
+
};
|
|
13009
13041
|
_create_class(MaskProcessor, [
|
|
13010
13042
|
{
|
|
13011
13043
|
key: "maskable",
|
|
@@ -13030,6 +13062,401 @@ var MAX_MASK_REFERENCE_COUNT = 254;
|
|
|
13030
13062
|
return MaskProcessor;
|
|
13031
13063
|
}();
|
|
13032
13064
|
|
|
13065
|
+
exports.BufferUsage = void 0;
|
|
13066
|
+
(function(BufferUsage) {
|
|
13067
|
+
BufferUsage[BufferUsage["Stream"] = 35040] = "Stream";
|
|
13068
|
+
BufferUsage[BufferUsage["Static"] = 35044] = "Static";
|
|
13069
|
+
BufferUsage[BufferUsage["Dynamic"] = 35048] = "Dynamic";
|
|
13070
|
+
})(exports.BufferUsage || (exports.BufferUsage = {}));
|
|
13071
|
+
exports.BufferDataType = void 0;
|
|
13072
|
+
(function(BufferDataType) {
|
|
13073
|
+
BufferDataType[BufferDataType["Byte"] = 5120] = "Byte";
|
|
13074
|
+
BufferDataType[BufferDataType["UnsignedByte"] = 5121] = "UnsignedByte";
|
|
13075
|
+
BufferDataType[BufferDataType["Short"] = 5122] = "Short";
|
|
13076
|
+
BufferDataType[BufferDataType["UnsignedShort"] = 5123] = "UnsignedShort";
|
|
13077
|
+
BufferDataType[BufferDataType["Int"] = 5124] = "Int";
|
|
13078
|
+
BufferDataType[BufferDataType["UnsignedInt"] = 5125] = "UnsignedInt";
|
|
13079
|
+
BufferDataType[BufferDataType["Float"] = 5126] = "Float";
|
|
13080
|
+
})(exports.BufferDataType || (exports.BufferDataType = {}));
|
|
13081
|
+
/**
|
|
13082
|
+
* 后端缓冲区的最小抽象,只保存资源状态。
|
|
13083
|
+
*/ var DataBuffer = /*#__PURE__*/ function() {
|
|
13084
|
+
function DataBuffer() {
|
|
13085
|
+
this.references = 0;
|
|
13086
|
+
this.capacity = 0;
|
|
13087
|
+
this.is32Bits = false;
|
|
13088
|
+
}
|
|
13089
|
+
_create_class(DataBuffer, [
|
|
13090
|
+
{
|
|
13091
|
+
key: "underlyingResource",
|
|
13092
|
+
get: function get() {
|
|
13093
|
+
return null;
|
|
13094
|
+
}
|
|
13095
|
+
}
|
|
13096
|
+
]);
|
|
13097
|
+
return DataBuffer;
|
|
13098
|
+
}();
|
|
13099
|
+
function getBytesPerElement(type) {
|
|
13100
|
+
switch(type){
|
|
13101
|
+
case 5120:
|
|
13102
|
+
case 5121:
|
|
13103
|
+
return 1;
|
|
13104
|
+
case 5122:
|
|
13105
|
+
case 5123:
|
|
13106
|
+
return 2;
|
|
13107
|
+
case 5124:
|
|
13108
|
+
case 5125:
|
|
13109
|
+
case 5126:
|
|
13110
|
+
return 4;
|
|
13111
|
+
default:
|
|
13112
|
+
return 0;
|
|
13113
|
+
}
|
|
13114
|
+
}
|
|
13115
|
+
function getDataType(data) {
|
|
13116
|
+
if (_instanceof1(data, Int8Array)) {
|
|
13117
|
+
return 5120;
|
|
13118
|
+
}
|
|
13119
|
+
if (_instanceof1(data, Uint8Array)) {
|
|
13120
|
+
return 5121;
|
|
13121
|
+
}
|
|
13122
|
+
if (_instanceof1(data, Int16Array)) {
|
|
13123
|
+
return 5122;
|
|
13124
|
+
}
|
|
13125
|
+
if (_instanceof1(data, Uint16Array)) {
|
|
13126
|
+
return 5123;
|
|
13127
|
+
}
|
|
13128
|
+
if (_instanceof1(data, Int32Array)) {
|
|
13129
|
+
return 5124;
|
|
13130
|
+
}
|
|
13131
|
+
if (_instanceof1(data, Uint32Array)) {
|
|
13132
|
+
return 5125;
|
|
13133
|
+
}
|
|
13134
|
+
return 5126;
|
|
13135
|
+
}
|
|
13136
|
+
function getDataByteLength(data) {
|
|
13137
|
+
if (Array.isArray(data)) {
|
|
13138
|
+
return data.length * Float32Array.BYTES_PER_ELEMENT;
|
|
13139
|
+
}
|
|
13140
|
+
return data.byteLength;
|
|
13141
|
+
}
|
|
13142
|
+
function toBufferView(data) {
|
|
13143
|
+
if (Array.isArray(data)) {
|
|
13144
|
+
return new Float32Array(data);
|
|
13145
|
+
}
|
|
13146
|
+
if (_instanceof1(data, ArrayBuffer)) {
|
|
13147
|
+
return new Uint8Array(data);
|
|
13148
|
+
}
|
|
13149
|
+
return data;
|
|
13150
|
+
}
|
|
13151
|
+
function createTypedArray(type, length) {
|
|
13152
|
+
switch(type){
|
|
13153
|
+
case 5120:
|
|
13154
|
+
return new Int8Array(length);
|
|
13155
|
+
case 5121:
|
|
13156
|
+
return new Uint8Array(length);
|
|
13157
|
+
case 5122:
|
|
13158
|
+
return new Int16Array(length);
|
|
13159
|
+
case 5123:
|
|
13160
|
+
return new Uint16Array(length);
|
|
13161
|
+
case 5124:
|
|
13162
|
+
return new Int32Array(length);
|
|
13163
|
+
case 5125:
|
|
13164
|
+
return new Uint32Array(length);
|
|
13165
|
+
default:
|
|
13166
|
+
return new Float32Array(length);
|
|
13167
|
+
}
|
|
13168
|
+
}
|
|
13169
|
+
|
|
13170
|
+
/**
|
|
13171
|
+
* 管理顶点数据及其对应的后端缓冲区。
|
|
13172
|
+
*/ var Buffer = /*#__PURE__*/ function() {
|
|
13173
|
+
function Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes, divisor, label) {
|
|
13174
|
+
if (stride === void 0) stride = 0;
|
|
13175
|
+
if (postponeInternalCreation === void 0) postponeInternalCreation = false;
|
|
13176
|
+
if (instanced === void 0) instanced = false;
|
|
13177
|
+
if (useBytes === void 0) useBytes = false;
|
|
13178
|
+
this.engine = engine;
|
|
13179
|
+
this.isAlreadyOwned = false;
|
|
13180
|
+
this._isDisposed = false;
|
|
13181
|
+
this.updatable = updatable;
|
|
13182
|
+
this.instanced = instanced;
|
|
13183
|
+
this.divisor = divisor || 1;
|
|
13184
|
+
this.label = label;
|
|
13185
|
+
this.byteStride = useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT;
|
|
13186
|
+
if (_instanceof1(data, DataBuffer)) {
|
|
13187
|
+
this.buffer = data;
|
|
13188
|
+
} else {
|
|
13189
|
+
this.data = data;
|
|
13190
|
+
}
|
|
13191
|
+
if (!postponeInternalCreation) {
|
|
13192
|
+
this.create();
|
|
13193
|
+
}
|
|
13194
|
+
}
|
|
13195
|
+
var _proto = Buffer.prototype;
|
|
13196
|
+
_proto.isUpdatable = function isUpdatable() {
|
|
13197
|
+
return this.updatable;
|
|
13198
|
+
};
|
|
13199
|
+
_proto.getData = function getData() {
|
|
13200
|
+
return this.data;
|
|
13201
|
+
};
|
|
13202
|
+
_proto.getBuffer = function getBuffer() {
|
|
13203
|
+
return this.buffer;
|
|
13204
|
+
};
|
|
13205
|
+
_proto.getStrideSize = function getStrideSize() {
|
|
13206
|
+
return this.byteStride / Float32Array.BYTES_PER_ELEMENT;
|
|
13207
|
+
};
|
|
13208
|
+
_proto.createVertexBuffer = function createVertexBuffer(kind, offset, size, stride, instanced, useBytes, divisor) {
|
|
13209
|
+
if (useBytes === void 0) useBytes = false;
|
|
13210
|
+
var byteOffset = useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT;
|
|
13211
|
+
var byteStride = stride ? useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT : this.byteStride;
|
|
13212
|
+
return new VertexBuffer(this.engine, this, kind, {
|
|
13213
|
+
size: size,
|
|
13214
|
+
stride: byteStride,
|
|
13215
|
+
offset: byteOffset,
|
|
13216
|
+
instanced: instanced === undefined ? this.instanced : instanced,
|
|
13217
|
+
useBytes: true,
|
|
13218
|
+
divisor: divisor != null ? divisor : this.divisor
|
|
13219
|
+
});
|
|
13220
|
+
};
|
|
13221
|
+
_proto.create = function create(data) {
|
|
13222
|
+
if (!data && this.buffer) {
|
|
13223
|
+
return;
|
|
13224
|
+
}
|
|
13225
|
+
data = data != null ? data : this.data;
|
|
13226
|
+
if (!data) {
|
|
13227
|
+
return;
|
|
13228
|
+
}
|
|
13229
|
+
var options = this.getDataBufferOptions(data);
|
|
13230
|
+
if (!this.buffer) {
|
|
13231
|
+
this.buffer = this.updatable ? this.engine.createDynamicVertexBuffer(data, options) : this.engine.createVertexBuffer(data, options);
|
|
13232
|
+
if (this.updatable) {
|
|
13233
|
+
this.data = data;
|
|
13234
|
+
}
|
|
13235
|
+
} else if (this.updatable) {
|
|
13236
|
+
this.engine.updateDynamicVertexBuffer(this.buffer, data);
|
|
13237
|
+
this.data = data;
|
|
13238
|
+
}
|
|
13239
|
+
};
|
|
13240
|
+
_proto.update = function update(data) {
|
|
13241
|
+
this.create(data);
|
|
13242
|
+
};
|
|
13243
|
+
_proto.updateDirectly = function updateDirectly(data, offset, vertexCount, useBytes) {
|
|
13244
|
+
if (useBytes === void 0) useBytes = false;
|
|
13245
|
+
if (!this.buffer || !this.updatable) {
|
|
13246
|
+
return;
|
|
13247
|
+
}
|
|
13248
|
+
this.engine.updateDynamicVertexBuffer(this.buffer, data, useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT, vertexCount ? vertexCount * this.byteStride : undefined);
|
|
13249
|
+
if (offset === 0 && vertexCount === undefined) {
|
|
13250
|
+
this.data = data;
|
|
13251
|
+
} else {
|
|
13252
|
+
this.data = undefined;
|
|
13253
|
+
}
|
|
13254
|
+
};
|
|
13255
|
+
/**
|
|
13256
|
+
* @internal
|
|
13257
|
+
*/ _proto.rebuild = function rebuild() {
|
|
13258
|
+
if (!this.data) {
|
|
13259
|
+
if (!this.buffer) {
|
|
13260
|
+
return;
|
|
13261
|
+
}
|
|
13262
|
+
var capacity = this.buffer.capacity;
|
|
13263
|
+
if (capacity > 0) {
|
|
13264
|
+
var options = this.getDataBufferOptions();
|
|
13265
|
+
this.buffer = this.updatable ? this.engine.createDynamicVertexBuffer(capacity, options) : this.engine.createVertexBuffer(capacity, options);
|
|
13266
|
+
} else {
|
|
13267
|
+
this.buffer = undefined;
|
|
13268
|
+
}
|
|
13269
|
+
return;
|
|
13270
|
+
}
|
|
13271
|
+
this.buffer = undefined;
|
|
13272
|
+
this.create(this.data);
|
|
13273
|
+
};
|
|
13274
|
+
/**
|
|
13275
|
+
* @internal
|
|
13276
|
+
*/ _proto.increaseReferences = function increaseReferences() {
|
|
13277
|
+
if (!this.buffer) {
|
|
13278
|
+
return;
|
|
13279
|
+
}
|
|
13280
|
+
if (!this.isAlreadyOwned) {
|
|
13281
|
+
this.isAlreadyOwned = true;
|
|
13282
|
+
return;
|
|
13283
|
+
}
|
|
13284
|
+
this.buffer.references++;
|
|
13285
|
+
};
|
|
13286
|
+
_proto.dispose = function dispose() {
|
|
13287
|
+
if (!this.buffer) {
|
|
13288
|
+
return;
|
|
13289
|
+
}
|
|
13290
|
+
if (this.engine.releaseBuffer(this.buffer)) {
|
|
13291
|
+
this.data = undefined;
|
|
13292
|
+
this.buffer = undefined;
|
|
13293
|
+
this._isDisposed = true;
|
|
13294
|
+
}
|
|
13295
|
+
};
|
|
13296
|
+
_proto.getDataBufferOptions = function getDataBufferOptions(data) {
|
|
13297
|
+
return {
|
|
13298
|
+
usage: this.updatable ? exports.BufferUsage.Dynamic : exports.BufferUsage.Static,
|
|
13299
|
+
type: data ? getDataType(data) : exports.BufferDataType.Float,
|
|
13300
|
+
byteStride: this.byteStride,
|
|
13301
|
+
instanceDivisor: this.instanced ? this.divisor : 0,
|
|
13302
|
+
label: this.label
|
|
13303
|
+
};
|
|
13304
|
+
};
|
|
13305
|
+
_create_class(Buffer, [
|
|
13306
|
+
{
|
|
13307
|
+
key: "isDisposed",
|
|
13308
|
+
get: function get() {
|
|
13309
|
+
return this._isDisposed;
|
|
13310
|
+
}
|
|
13311
|
+
},
|
|
13312
|
+
{
|
|
13313
|
+
key: "capacity",
|
|
13314
|
+
get: function get() {
|
|
13315
|
+
var _this_buffer;
|
|
13316
|
+
var _this_buffer_capacity;
|
|
13317
|
+
return (_this_buffer_capacity = (_this_buffer = this.buffer) == null ? void 0 : _this_buffer.capacity) != null ? _this_buffer_capacity : this.data ? getDataByteLength(this.data) : 0;
|
|
13318
|
+
}
|
|
13319
|
+
}
|
|
13320
|
+
]);
|
|
13321
|
+
return Buffer;
|
|
13322
|
+
}();
|
|
13323
|
+
|
|
13324
|
+
/**
|
|
13325
|
+
* 描述一个顶点属性如何读取共享缓冲区。
|
|
13326
|
+
*/ var VertexBuffer = /*#__PURE__*/ function() {
|
|
13327
|
+
function VertexBuffer(engine, data, kind, props) {
|
|
13328
|
+
if (props === void 0) props = {};
|
|
13329
|
+
this._isDisposed = false;
|
|
13330
|
+
this.engine = engine;
|
|
13331
|
+
this.kind = kind;
|
|
13332
|
+
if (_instanceof1(data, Buffer)) {
|
|
13333
|
+
this.buffer = data;
|
|
13334
|
+
var _props_takeBufferOwnership;
|
|
13335
|
+
this.ownsBuffer = (_props_takeBufferOwnership = props.takeBufferOwnership) != null ? _props_takeBufferOwnership : false;
|
|
13336
|
+
} else {
|
|
13337
|
+
var _props_updatable, _props_stride, _props_postponeInternalCreation, _props_instanced, _props_useBytes;
|
|
13338
|
+
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);
|
|
13339
|
+
this.ownsBuffer = true;
|
|
13340
|
+
}
|
|
13341
|
+
var source = this.getData();
|
|
13342
|
+
var _props_type;
|
|
13343
|
+
this.type = (_props_type = props.type) != null ? _props_type : source ? getDataType(source) : VertexBuffer.FLOAT;
|
|
13344
|
+
var typeByteLength = getBytesPerElement(this.type);
|
|
13345
|
+
var _props_useBytes1;
|
|
13346
|
+
var useBytes = (_props_useBytes1 = props.useBytes) != null ? _props_useBytes1 : false;
|
|
13347
|
+
var _props_stride1;
|
|
13348
|
+
var stride = (_props_stride1 = props.stride) != null ? _props_stride1 : 0;
|
|
13349
|
+
var _props_offset;
|
|
13350
|
+
var offset = (_props_offset = props.offset) != null ? _props_offset : 0;
|
|
13351
|
+
if (useBytes) {
|
|
13352
|
+
this.size = props.size || (stride ? stride / typeByteLength : 0);
|
|
13353
|
+
this.byteStride = stride || this.buffer.byteStride || this.size * typeByteLength;
|
|
13354
|
+
this.byteOffset = offset;
|
|
13355
|
+
} else {
|
|
13356
|
+
this.size = props.size || stride;
|
|
13357
|
+
this.byteStride = stride ? stride * typeByteLength : this.buffer.byteStride || this.size * typeByteLength;
|
|
13358
|
+
this.byteOffset = offset * typeByteLength;
|
|
13359
|
+
}
|
|
13360
|
+
var _props_normalized;
|
|
13361
|
+
this.normalized = (_props_normalized = props.normalized) != null ? _props_normalized : false;
|
|
13362
|
+
var _props_instanced1;
|
|
13363
|
+
this.instanced = (_props_instanced1 = props.instanced) != null ? _props_instanced1 : false;
|
|
13364
|
+
var _props_divisor;
|
|
13365
|
+
this._instanceDivisor = this.instanced ? (_props_divisor = props.divisor) != null ? _props_divisor : 1 : 0;
|
|
13366
|
+
}
|
|
13367
|
+
var _proto = VertexBuffer.prototype;
|
|
13368
|
+
_proto.getKind = function getKind() {
|
|
13369
|
+
return this.kind;
|
|
13370
|
+
};
|
|
13371
|
+
_proto.isUpdatable = function isUpdatable() {
|
|
13372
|
+
return this.buffer.isUpdatable();
|
|
13373
|
+
};
|
|
13374
|
+
_proto.getData = function getData() {
|
|
13375
|
+
return this.buffer.getData();
|
|
13376
|
+
};
|
|
13377
|
+
_proto.getBuffer = function getBuffer() {
|
|
13378
|
+
return this.buffer.getBuffer();
|
|
13379
|
+
};
|
|
13380
|
+
_proto.getWrapperBuffer = function getWrapperBuffer() {
|
|
13381
|
+
return this.buffer;
|
|
13382
|
+
};
|
|
13383
|
+
_proto.getStrideSize = function getStrideSize() {
|
|
13384
|
+
return this.byteStride / getBytesPerElement(this.type);
|
|
13385
|
+
};
|
|
13386
|
+
_proto.getOffset = function getOffset() {
|
|
13387
|
+
return this.byteOffset / getBytesPerElement(this.type);
|
|
13388
|
+
};
|
|
13389
|
+
_proto.getSize = function getSize(sizeInBytes) {
|
|
13390
|
+
if (sizeInBytes === void 0) sizeInBytes = false;
|
|
13391
|
+
return sizeInBytes ? this.size * getBytesPerElement(this.type) : this.size;
|
|
13392
|
+
};
|
|
13393
|
+
_proto.getIsInstanced = function getIsInstanced() {
|
|
13394
|
+
return this.instanced;
|
|
13395
|
+
};
|
|
13396
|
+
_proto.getInstanceDivisor = function getInstanceDivisor() {
|
|
13397
|
+
return this._instanceDivisor;
|
|
13398
|
+
};
|
|
13399
|
+
_proto.create = function create(data) {
|
|
13400
|
+
this.buffer.create(data);
|
|
13401
|
+
};
|
|
13402
|
+
_proto.update = function update(data) {
|
|
13403
|
+
this.buffer.update(data);
|
|
13404
|
+
};
|
|
13405
|
+
_proto.updateDirectly = function updateDirectly(data, offset, useBytes) {
|
|
13406
|
+
if (useBytes === void 0) useBytes = false;
|
|
13407
|
+
this.buffer.updateDirectly(data, offset, undefined, useBytes);
|
|
13408
|
+
};
|
|
13409
|
+
/**
|
|
13410
|
+
* @internal
|
|
13411
|
+
*/ _proto.rebuild = function rebuild() {
|
|
13412
|
+
this.buffer.rebuild();
|
|
13413
|
+
};
|
|
13414
|
+
_proto.dispose = function dispose() {
|
|
13415
|
+
if (this.ownsBuffer) {
|
|
13416
|
+
this.buffer.dispose();
|
|
13417
|
+
}
|
|
13418
|
+
this._isDisposed = true;
|
|
13419
|
+
};
|
|
13420
|
+
_create_class(VertexBuffer, [
|
|
13421
|
+
{
|
|
13422
|
+
key: "isDisposed",
|
|
13423
|
+
get: function get() {
|
|
13424
|
+
return this._isDisposed;
|
|
13425
|
+
}
|
|
13426
|
+
},
|
|
13427
|
+
{
|
|
13428
|
+
key: "instanceDivisor",
|
|
13429
|
+
get: function get() {
|
|
13430
|
+
return this._instanceDivisor;
|
|
13431
|
+
},
|
|
13432
|
+
set: function set(value) {
|
|
13433
|
+
this._instanceDivisor = value;
|
|
13434
|
+
this.instanced = value !== 0;
|
|
13435
|
+
}
|
|
13436
|
+
}
|
|
13437
|
+
]);
|
|
13438
|
+
return VertexBuffer;
|
|
13439
|
+
}();
|
|
13440
|
+
VertexBuffer.PositionKind = "aPos";
|
|
13441
|
+
VertexBuffer.NormalKind = "aNormal";
|
|
13442
|
+
VertexBuffer.TangentKind = "aTangent";
|
|
13443
|
+
VertexBuffer.UVKind = "aUV";
|
|
13444
|
+
VertexBuffer.UV2Kind = "aUV2";
|
|
13445
|
+
VertexBuffer.UV3Kind = "aUV3";
|
|
13446
|
+
VertexBuffer.UV4Kind = "aUV4";
|
|
13447
|
+
VertexBuffer.UV5Kind = "aUV5";
|
|
13448
|
+
VertexBuffer.UV6Kind = "aUV6";
|
|
13449
|
+
VertexBuffer.ColorKind = "aColor";
|
|
13450
|
+
VertexBuffer.JointsKind = "aJoints";
|
|
13451
|
+
VertexBuffer.WeightsKind = "aWeights";
|
|
13452
|
+
VertexBuffer.BYTE = exports.BufferDataType.Byte;
|
|
13453
|
+
VertexBuffer.UNSIGNED_BYTE = exports.BufferDataType.UnsignedByte;
|
|
13454
|
+
VertexBuffer.SHORT = exports.BufferDataType.Short;
|
|
13455
|
+
VertexBuffer.UNSIGNED_SHORT = exports.BufferDataType.UnsignedShort;
|
|
13456
|
+
VertexBuffer.INT = exports.BufferDataType.Int;
|
|
13457
|
+
VertexBuffer.UNSIGNED_INT = exports.BufferDataType.UnsignedInt;
|
|
13458
|
+
VertexBuffer.FLOAT = exports.BufferDataType.Float;
|
|
13459
|
+
|
|
13033
13460
|
exports.HitTestType = void 0;
|
|
13034
13461
|
(function(HitTestType) {
|
|
13035
13462
|
HitTestType[HitTestType["triangle"] = 1] = "triangle";
|
|
@@ -13352,7 +13779,7 @@ BoundingBox.tempVector2 = new Vector3();
|
|
|
13352
13779
|
};
|
|
13353
13780
|
_proto.geometryToTriangles = function geometryToTriangles(geometry) {
|
|
13354
13781
|
var indices = geometry.getIndexData();
|
|
13355
|
-
var vertices = geometry.getAttributeData(
|
|
13782
|
+
var vertices = geometry.getAttributeData(VertexBuffer.PositionKind);
|
|
13356
13783
|
var res = [];
|
|
13357
13784
|
if (!indices || !vertices) {
|
|
13358
13785
|
return res;
|
|
@@ -13558,7 +13985,7 @@ var HELP_LINK = {
|
|
|
13558
13985
|
var tempQuat$1 = new Quaternion();
|
|
13559
13986
|
var tempVector3$1 = new Vector3();
|
|
13560
13987
|
var tempVector3Second$1 = new Vector3();
|
|
13561
|
-
var seed$
|
|
13988
|
+
var seed$7 = 1;
|
|
13562
13989
|
/**
|
|
13563
13990
|
* 变换组件,用于描述元素的位置、旋转、缩放等信息
|
|
13564
13991
|
*/ var Transform = /*#__PURE__*/ function() {
|
|
@@ -13613,7 +14040,7 @@ var seed$8 = 1;
|
|
|
13613
14040
|
quat: new Quaternion(0, 0, 0, 1),
|
|
13614
14041
|
scale: new Vector3(1, 1, 1)
|
|
13615
14042
|
};
|
|
13616
|
-
this.name = "transform_" + seed$
|
|
14043
|
+
this.name = "transform_" + seed$7++;
|
|
13617
14044
|
if (props) {
|
|
13618
14045
|
this.setTransform(props);
|
|
13619
14046
|
}
|
|
@@ -20055,310 +20482,6 @@ exports.CompositionComponent = __decorate([
|
|
|
20055
20482
|
effectsClass("CompositionComponent")
|
|
20056
20483
|
], exports.CompositionComponent);
|
|
20057
20484
|
|
|
20058
|
-
/**
|
|
20059
|
-
* Mesh 组件
|
|
20060
|
-
*/ var MeshComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
20061
|
-
_inherits(MeshComponent, RendererComponent);
|
|
20062
|
-
function MeshComponent(engine) {
|
|
20063
|
-
var _this;
|
|
20064
|
-
_this = RendererComponent.call(this, engine) || this;
|
|
20065
|
-
// TODO 点击测试后续抽象一个 Collider 组件
|
|
20066
|
-
_this.getHitTestParams = function(force) {
|
|
20067
|
-
var worldMatrix = _this.transform.getWorldMatrix();
|
|
20068
|
-
_this.boundingBoxInfo.setGeometry(_this.geometry, worldMatrix);
|
|
20069
|
-
var area = _this.boundingBoxInfo.getRawBoundingBoxTriangle();
|
|
20070
|
-
if (area) {
|
|
20071
|
-
return {
|
|
20072
|
-
type: area.type,
|
|
20073
|
-
triangles: area.area,
|
|
20074
|
-
clipMasks: _this.frameClipMasks
|
|
20075
|
-
};
|
|
20076
|
-
}
|
|
20077
|
-
};
|
|
20078
|
-
return _this;
|
|
20079
|
-
}
|
|
20080
|
-
var _proto = MeshComponent.prototype;
|
|
20081
|
-
_proto.render = function render(renderer) {
|
|
20082
|
-
this.maskManager.drawStencilMask(renderer, this);
|
|
20083
|
-
for(var i = 0; i < this.materials.length; i++){
|
|
20084
|
-
var material = this.materials[i];
|
|
20085
|
-
renderer.drawGeometry(this.geometry, this.transform.getWorldMatrix(), material, i);
|
|
20086
|
-
}
|
|
20087
|
-
};
|
|
20088
|
-
_proto.drawStencilMask = function drawStencilMask(maskRef) {
|
|
20089
|
-
if (!this.isActiveAndEnabled) {
|
|
20090
|
-
return;
|
|
20091
|
-
}
|
|
20092
|
-
for(var i = 0; i < this.materials.length; i++){
|
|
20093
|
-
var material = this.materials[i];
|
|
20094
|
-
this.maskManager.drawGeometryMask(this.engine.renderer, this.geometry, this.transform.getWorldMatrix(), material, maskRef, i);
|
|
20095
|
-
}
|
|
20096
|
-
};
|
|
20097
|
-
_proto.getBoundingBox = function getBoundingBox() {
|
|
20098
|
-
var worldMatrix = this.transform.getWorldMatrix();
|
|
20099
|
-
this.boundingBoxInfo.setGeometry(this.geometry, worldMatrix);
|
|
20100
|
-
var boundingBox = this.boundingBoxInfo.getBoundingBoxTriangle();
|
|
20101
|
-
return boundingBox;
|
|
20102
|
-
};
|
|
20103
|
-
_proto.getBoundingBoxInfo = function getBoundingBoxInfo() {
|
|
20104
|
-
var positionArray = this.geometry.getAttributeData("aPos");
|
|
20105
|
-
if (positionArray) {
|
|
20106
|
-
var minMaxResult = extractMinAndMax(positionArray, 0, positionArray.length / 3);
|
|
20107
|
-
minMaxResult.minimum.x *= this.transform.size.x;
|
|
20108
|
-
minMaxResult.minimum.y *= this.transform.size.y;
|
|
20109
|
-
minMaxResult.maximum.x *= this.transform.size.x;
|
|
20110
|
-
minMaxResult.maximum.y *= this.transform.size.y;
|
|
20111
|
-
this.boundingBoxInfo.reConstruct(minMaxResult.minimum, minMaxResult.maximum, this.transform.getWorldMatrix());
|
|
20112
|
-
}
|
|
20113
|
-
return this.boundingBoxInfo;
|
|
20114
|
-
};
|
|
20115
|
-
_proto.fromData = function fromData(data) {
|
|
20116
|
-
RendererComponent.prototype.fromData.call(this, data);
|
|
20117
|
-
var maskOptions = data.mask;
|
|
20118
|
-
if (maskOptions) {
|
|
20119
|
-
this.maskManager.setMaskOptions(this.engine, maskOptions);
|
|
20120
|
-
}
|
|
20121
|
-
};
|
|
20122
|
-
return MeshComponent;
|
|
20123
|
-
}(RendererComponent);
|
|
20124
|
-
__decorate([
|
|
20125
|
-
serialize()
|
|
20126
|
-
], MeshComponent.prototype, "geometry", void 0);
|
|
20127
|
-
|
|
20128
|
-
exports.EffectComponent = /*#__PURE__*/ function(MeshComponent) {
|
|
20129
|
-
_inherits(EffectComponent, MeshComponent);
|
|
20130
|
-
function EffectComponent(engine) {
|
|
20131
|
-
var _this;
|
|
20132
|
-
_this = MeshComponent.call(this, engine) || this;
|
|
20133
|
-
_this.time = 0;
|
|
20134
|
-
_this.name = "EffectComponent";
|
|
20135
|
-
return _this;
|
|
20136
|
-
}
|
|
20137
|
-
var _proto = EffectComponent.prototype;
|
|
20138
|
-
_proto.onStart = function onStart() {
|
|
20139
|
-
this.item.getHitTestParams = this.getHitTestParams;
|
|
20140
|
-
};
|
|
20141
|
-
_proto.onUpdate = function onUpdate(dt) {
|
|
20142
|
-
var time = this.time;
|
|
20143
|
-
var _this_material_getVector4;
|
|
20144
|
-
var _Time = (_this_material_getVector4 = this.material.getVector4("_Time")) != null ? _this_material_getVector4 : new Vector4();
|
|
20145
|
-
this.material.setVector4("_Time", _Time.set(time / 20, time, time * 2, time * 3));
|
|
20146
|
-
this.time += dt / 1000;
|
|
20147
|
-
};
|
|
20148
|
-
_proto.fromData = function fromData(data) {
|
|
20149
|
-
MeshComponent.prototype.fromData.call(this, data);
|
|
20150
|
-
this.material = this.materials[0];
|
|
20151
|
-
};
|
|
20152
|
-
return EffectComponent;
|
|
20153
|
-
}(MeshComponent);
|
|
20154
|
-
exports.EffectComponent = __decorate([
|
|
20155
|
-
effectsClass(DataType.EffectComponent)
|
|
20156
|
-
], exports.EffectComponent);
|
|
20157
|
-
|
|
20158
|
-
var tempVector3 = new Vector3(0, 0, 0);
|
|
20159
|
-
var tempVector3Second = new Vector3(0, 0, 0);
|
|
20160
|
-
var ConstraintTarget = function ConstraintTarget() {
|
|
20161
|
-
this.target = null;
|
|
20162
|
-
this.weight = 1.0;
|
|
20163
|
-
};
|
|
20164
|
-
exports.PositionConstraint = /*#__PURE__*/ function(Component) {
|
|
20165
|
-
_inherits(PositionConstraint, Component);
|
|
20166
|
-
function PositionConstraint() {
|
|
20167
|
-
var _this;
|
|
20168
|
-
_this = Component.apply(this, arguments) || this;
|
|
20169
|
-
/**
|
|
20170
|
-
* 初始位置(当前元素的初始世界位置)
|
|
20171
|
-
*/ _this.positionAtRest = new Vector3(0, 0, 0);
|
|
20172
|
-
/**
|
|
20173
|
-
* 位置偏移
|
|
20174
|
-
*/ _this.positionOffset = new Vector3(0, 0, 0);
|
|
20175
|
-
/**
|
|
20176
|
-
* 约束权重 (0-1)
|
|
20177
|
-
*/ _this.weight = 1.0;
|
|
20178
|
-
/**
|
|
20179
|
-
* 是否约束 X 轴
|
|
20180
|
-
*/ _this.constrainX = true;
|
|
20181
|
-
/**
|
|
20182
|
-
* 是否约束 Y 轴
|
|
20183
|
-
*/ _this.constrainY = true;
|
|
20184
|
-
/**
|
|
20185
|
-
* 是否约束 Z 轴
|
|
20186
|
-
*/ _this.constrainZ = true;
|
|
20187
|
-
/**
|
|
20188
|
-
* 约束目标
|
|
20189
|
-
*/ _this.targets = [];
|
|
20190
|
-
return _this;
|
|
20191
|
-
}
|
|
20192
|
-
var _proto = PositionConstraint.prototype;
|
|
20193
|
-
_proto.onStart = function onStart() {
|
|
20194
|
-
// 保存当前元素的初始世界位置
|
|
20195
|
-
var pos = this.item.transform.getWorldPosition();
|
|
20196
|
-
this.positionAtRest.copyFrom(pos);
|
|
20197
|
-
};
|
|
20198
|
-
_proto.onUpdate = function onUpdate(dt) {
|
|
20199
|
-
if (this.targets.length === 0) {
|
|
20200
|
-
return;
|
|
20201
|
-
}
|
|
20202
|
-
// 重置 tempVector3 用于计算融合位置
|
|
20203
|
-
tempVector3.set(0, 0, 0);
|
|
20204
|
-
var totalWeight = 0;
|
|
20205
|
-
// 计算所有目标的加权平均位置
|
|
20206
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(this.targets), _step; !(_step = _iterator()).done;){
|
|
20207
|
-
var constraintTarget = _step.value;
|
|
20208
|
-
if (constraintTarget.target) {
|
|
20209
|
-
var targetPos = constraintTarget.target.transform.getWorldPosition();
|
|
20210
|
-
var weight = constraintTarget.weight;
|
|
20211
|
-
tempVector3.x += targetPos.x * weight;
|
|
20212
|
-
tempVector3.y += targetPos.y * weight;
|
|
20213
|
-
tempVector3.z += targetPos.z * weight;
|
|
20214
|
-
totalWeight += weight;
|
|
20215
|
-
}
|
|
20216
|
-
}
|
|
20217
|
-
// 归一化加权位置
|
|
20218
|
-
if (totalWeight > 0) {
|
|
20219
|
-
tempVector3.x /= totalWeight;
|
|
20220
|
-
tempVector3.y /= totalWeight;
|
|
20221
|
-
tempVector3.z /= totalWeight;
|
|
20222
|
-
}
|
|
20223
|
-
// 应用偏移
|
|
20224
|
-
tempVector3.x += this.positionOffset.x;
|
|
20225
|
-
tempVector3.y += this.positionOffset.y;
|
|
20226
|
-
tempVector3.z += this.positionOffset.z;
|
|
20227
|
-
// 根据全局权重在初始位置和融合位置之间插值,结果存入 tempVector3Second
|
|
20228
|
-
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));
|
|
20229
|
-
// 应用轴约束,复用 tempVector3 存储当前位置
|
|
20230
|
-
tempVector3.copyFrom(this.item.transform.getWorldPosition());
|
|
20231
|
-
var finalX = this.constrainX ? tempVector3Second.x : tempVector3.x;
|
|
20232
|
-
var finalY = this.constrainY ? tempVector3Second.y : tempVector3.y;
|
|
20233
|
-
var finalZ = this.constrainZ ? tempVector3Second.z : tempVector3.z;
|
|
20234
|
-
// 设置新的世界位置
|
|
20235
|
-
this.item.transform.setWorldPosition(finalX, finalY, finalZ);
|
|
20236
|
-
};
|
|
20237
|
-
/**
|
|
20238
|
-
* 添加约束目标
|
|
20239
|
-
* @param target - 目标元素
|
|
20240
|
-
* @param weight - 权重值 (0-1)
|
|
20241
|
-
*/ _proto.addTarget = function addTarget(target, weight) {
|
|
20242
|
-
if (weight === void 0) weight = 1.0;
|
|
20243
|
-
var constraintTarget = new ConstraintTarget();
|
|
20244
|
-
constraintTarget.target = target;
|
|
20245
|
-
constraintTarget.weight = Math.max(0, Math.min(1, weight));
|
|
20246
|
-
this.targets.push(constraintTarget);
|
|
20247
|
-
};
|
|
20248
|
-
/**
|
|
20249
|
-
* 移除约束目标
|
|
20250
|
-
* @param target - 要移除的目标元素
|
|
20251
|
-
*/ _proto.removeTarget = function removeTarget(target) {
|
|
20252
|
-
var index = this.targets.findIndex(function(ct) {
|
|
20253
|
-
return ct.target === target;
|
|
20254
|
-
});
|
|
20255
|
-
if (index !== -1) {
|
|
20256
|
-
this.targets.splice(index, 1);
|
|
20257
|
-
}
|
|
20258
|
-
};
|
|
20259
|
-
/**
|
|
20260
|
-
* 清除所有约束目标
|
|
20261
|
-
*/ _proto.clearTargets = function clearTargets() {
|
|
20262
|
-
this.targets = [];
|
|
20263
|
-
};
|
|
20264
|
-
/**
|
|
20265
|
-
* 设置位置偏移
|
|
20266
|
-
* @param x - X 轴偏移
|
|
20267
|
-
* @param y - Y 轴偏移
|
|
20268
|
-
* @param z - Z 轴偏移
|
|
20269
|
-
*/ _proto.setPositionOffset = function setPositionOffset(x, y, z) {
|
|
20270
|
-
this.positionOffset.set(x, y, z);
|
|
20271
|
-
};
|
|
20272
|
-
/**
|
|
20273
|
-
* 设置全局约束权重
|
|
20274
|
-
* @param weight - 权重值 (0-1),0 表示保持初始位置,1 表示完全跟随目标
|
|
20275
|
-
*/ _proto.setWeight = function setWeight(weight) {
|
|
20276
|
-
this.weight = Math.max(0, Math.min(1, weight));
|
|
20277
|
-
};
|
|
20278
|
-
/**
|
|
20279
|
-
* 线性插值
|
|
20280
|
-
* @param start - 起始值
|
|
20281
|
-
* @param end - 结束值
|
|
20282
|
-
* @param t - 插值因子 (0-1)
|
|
20283
|
-
*/ _proto.lerp = function lerp(start, end, t) {
|
|
20284
|
-
return start + (end - start) * t;
|
|
20285
|
-
};
|
|
20286
|
-
_proto.fromData = function fromData(data) {
|
|
20287
|
-
Component.prototype.fromData.call(this, data);
|
|
20288
|
-
// Deserialize all properties
|
|
20289
|
-
this.positionAtRest.copyFrom(data.positionAtRest);
|
|
20290
|
-
this.positionOffset.copyFrom(data.positionOffset);
|
|
20291
|
-
this.weight = data.weight;
|
|
20292
|
-
this.constrainX = data.constrainX;
|
|
20293
|
-
this.constrainY = data.constrainY;
|
|
20294
|
-
this.constrainZ = data.constrainZ;
|
|
20295
|
-
this.targets = [];
|
|
20296
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(data.targets), _step; !(_step = _iterator()).done;){
|
|
20297
|
-
var targetData = _step.value;
|
|
20298
|
-
var constraintTarget = new ConstraintTarget();
|
|
20299
|
-
constraintTarget.target = this.engine.findObject(targetData.target);
|
|
20300
|
-
constraintTarget.weight = targetData.weight;
|
|
20301
|
-
this.targets.push(constraintTarget);
|
|
20302
|
-
}
|
|
20303
|
-
};
|
|
20304
|
-
return PositionConstraint;
|
|
20305
|
-
}(Component);
|
|
20306
|
-
exports.PositionConstraint = __decorate([
|
|
20307
|
-
effectsClass("PositionConstraint")
|
|
20308
|
-
], exports.PositionConstraint);
|
|
20309
|
-
|
|
20310
|
-
exports.PostProcessVolume = /*#__PURE__*/ function(Component) {
|
|
20311
|
-
_inherits(PostProcessVolume, Component);
|
|
20312
|
-
function PostProcessVolume(engine) {
|
|
20313
|
-
var _this;
|
|
20314
|
-
_this = Component.call(this, engine) || this;
|
|
20315
|
-
_this.bloom = {
|
|
20316
|
-
threshold: 0,
|
|
20317
|
-
intensity: 0,
|
|
20318
|
-
active: false
|
|
20319
|
-
};
|
|
20320
|
-
_this.vignette = {
|
|
20321
|
-
intensity: 0,
|
|
20322
|
-
smoothness: 0,
|
|
20323
|
-
roundness: 0,
|
|
20324
|
-
active: false
|
|
20325
|
-
};
|
|
20326
|
-
_this.tonemapping = {
|
|
20327
|
-
active: false
|
|
20328
|
-
};
|
|
20329
|
-
_this.colorAdjustments = {
|
|
20330
|
-
brightness: 0,
|
|
20331
|
-
saturation: 0,
|
|
20332
|
-
contrast: 0,
|
|
20333
|
-
active: false
|
|
20334
|
-
};
|
|
20335
|
-
return _this;
|
|
20336
|
-
}
|
|
20337
|
-
var _proto = PostProcessVolume.prototype;
|
|
20338
|
-
_proto.onStart = function onStart() {
|
|
20339
|
-
var composition = this.item.composition;
|
|
20340
|
-
if (composition) {
|
|
20341
|
-
composition.renderFrame.globalVolume = this;
|
|
20342
|
-
}
|
|
20343
|
-
};
|
|
20344
|
-
return PostProcessVolume;
|
|
20345
|
-
}(Component);
|
|
20346
|
-
__decorate([
|
|
20347
|
-
serialize()
|
|
20348
|
-
], exports.PostProcessVolume.prototype, "bloom", void 0);
|
|
20349
|
-
__decorate([
|
|
20350
|
-
serialize()
|
|
20351
|
-
], exports.PostProcessVolume.prototype, "vignette", void 0);
|
|
20352
|
-
__decorate([
|
|
20353
|
-
serialize()
|
|
20354
|
-
], exports.PostProcessVolume.prototype, "tonemapping", void 0);
|
|
20355
|
-
__decorate([
|
|
20356
|
-
serialize()
|
|
20357
|
-
], exports.PostProcessVolume.prototype, "colorAdjustments", void 0);
|
|
20358
|
-
exports.PostProcessVolume = __decorate([
|
|
20359
|
-
effectsClass(DataType.PostProcessVolume)
|
|
20360
|
-
], exports.PostProcessVolume);
|
|
20361
|
-
|
|
20362
20485
|
var EFFECTS_COPY_MESH_NAME = "effects-internal-copy";
|
|
20363
20486
|
var COPY_MESH_SHADER_ID = "effects-internal-copy-mesh";
|
|
20364
20487
|
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}";
|
|
@@ -20549,7 +20672,7 @@ exports.RenderPassDestroyAttachmentType = void 0;
|
|
|
20549
20672
|
* 强制销毁
|
|
20550
20673
|
*/ RenderPassDestroyAttachmentType[RenderPassDestroyAttachmentType["destroy"] = 0] = "destroy";
|
|
20551
20674
|
})(exports.RenderPassDestroyAttachmentType || (exports.RenderPassDestroyAttachmentType = {}));
|
|
20552
|
-
var seed$
|
|
20675
|
+
var seed$6 = 1;
|
|
20553
20676
|
/**
|
|
20554
20677
|
* RenderPass 抽象类
|
|
20555
20678
|
*/ var RenderPass = /*#__PURE__*/ function() {
|
|
@@ -20559,7 +20682,7 @@ var seed$7 = 1;
|
|
|
20559
20682
|
*/ this.priority = 0;
|
|
20560
20683
|
/**
|
|
20561
20684
|
* 名称
|
|
20562
|
-
*/ this.name = "RenderPass" + seed$
|
|
20685
|
+
*/ this.name = "RenderPass" + seed$6++;
|
|
20563
20686
|
/**
|
|
20564
20687
|
* 包含的 Mesh 列表
|
|
20565
20688
|
*/ this.meshes = [];
|
|
@@ -20684,48 +20807,577 @@ var DrawObjectPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
20684
20807
|
return DrawObjectPass;
|
|
20685
20808
|
}(RenderPass);
|
|
20686
20809
|
|
|
20687
|
-
var
|
|
20688
|
-
var BYTES_TYPE_MAP = (_obj$4 = {}, _obj$4[glContext.FLOAT] = Float32Array.BYTES_PER_ELEMENT, _obj$4[glContext.INT] = Int32Array.BYTES_PER_ELEMENT, _obj$4[glContext.SHORT] = Int16Array.BYTES_PER_ELEMENT, _obj$4[glContext.BYTE] = Int8Array.BYTES_PER_ELEMENT, _obj$4);
|
|
20810
|
+
var geometryId = 1;
|
|
20689
20811
|
/**
|
|
20690
|
-
*
|
|
20812
|
+
* 几何数据、属性布局和绘制范围的后端无关实现。
|
|
20691
20813
|
*/ var Geometry = /*#__PURE__*/ function(EffectsObject) {
|
|
20692
20814
|
_inherits(Geometry, EffectsObject);
|
|
20693
|
-
function Geometry() {
|
|
20815
|
+
function Geometry(engine, props) {
|
|
20694
20816
|
var _this;
|
|
20695
|
-
_this = EffectsObject.
|
|
20696
|
-
|
|
20697
|
-
|
|
20698
|
-
|
|
20699
|
-
/**
|
|
20700
|
-
|
|
20701
|
-
|
|
20817
|
+
_this = EffectsObject.call(this, engine) || this;
|
|
20818
|
+
_this.name = "";
|
|
20819
|
+
_this.subMeshes = [];
|
|
20820
|
+
/** @hide */ _this.mode = 4;
|
|
20821
|
+
/** @hide */ _this.instanceCount = 0;
|
|
20822
|
+
_this.vertexBuffers = {};
|
|
20823
|
+
_this.indices = new Uint16Array(0);
|
|
20824
|
+
_this.drawCount = 0;
|
|
20825
|
+
_this.drawStart = 0;
|
|
20826
|
+
_this.skin = {};
|
|
20827
|
+
_this.disposed = false;
|
|
20828
|
+
_this.initialized = false;
|
|
20829
|
+
_this.bufferUsage = exports.BufferUsage.Static;
|
|
20830
|
+
if (supportsVertexArrayObjects(engine)) {
|
|
20831
|
+
_this.vertexArrayObjects = {};
|
|
20832
|
+
}
|
|
20833
|
+
if (props) {
|
|
20834
|
+
_this.processProps(props);
|
|
20835
|
+
}
|
|
20702
20836
|
return _this;
|
|
20703
20837
|
}
|
|
20704
20838
|
var _proto = Geometry.prototype;
|
|
20839
|
+
/** @hide */ _proto.isDisposed = function isDisposed() {
|
|
20840
|
+
return this.disposed;
|
|
20841
|
+
};
|
|
20705
20842
|
/**
|
|
20706
|
-
*
|
|
20707
|
-
|
|
20708
|
-
|
|
20709
|
-
|
|
20843
|
+
* @internal
|
|
20844
|
+
*/ _proto.getOptions = function getOptions() {
|
|
20845
|
+
return this.options ? _extends({}, this.options) : undefined;
|
|
20846
|
+
};
|
|
20847
|
+
/** @hide */ _proto.getVertexBuffer = function getVertexBuffer(name) {
|
|
20848
|
+
return this.vertexBuffers[name];
|
|
20710
20849
|
};
|
|
20711
20850
|
/**
|
|
20712
|
-
*
|
|
20713
|
-
*/ _proto.
|
|
20714
|
-
|
|
20851
|
+
* @internal
|
|
20852
|
+
*/ _proto.getVertexBuffers = function getVertexBuffers() {
|
|
20853
|
+
return this.vertexBuffers;
|
|
20854
|
+
};
|
|
20855
|
+
/** @hide */ _proto.setVerticesBuffer = function setVerticesBuffer(vertexBuffer, disposeExistingBuffer) {
|
|
20856
|
+
if (disposeExistingBuffer === void 0) disposeExistingBuffer = true;
|
|
20857
|
+
var kind = vertexBuffer.getKind();
|
|
20858
|
+
var current = this.vertexBuffers[kind];
|
|
20859
|
+
if (current && disposeExistingBuffer) {
|
|
20860
|
+
current.dispose();
|
|
20861
|
+
}
|
|
20862
|
+
if (vertexBuffer.ownsBuffer) {
|
|
20863
|
+
vertexBuffer.buffer.increaseReferences();
|
|
20864
|
+
}
|
|
20865
|
+
this.vertexBuffers[kind] = vertexBuffer;
|
|
20866
|
+
this.disposeVertexArrayObjects();
|
|
20867
|
+
};
|
|
20868
|
+
/** @hide */ _proto.getAttributeBuffer = function getAttributeBuffer(name) {
|
|
20869
|
+
var _this_vertexBuffers_name;
|
|
20870
|
+
return (_this_vertexBuffers_name = this.vertexBuffers[name]) == null ? void 0 : _this_vertexBuffers_name.getWrapperBuffer();
|
|
20871
|
+
};
|
|
20872
|
+
_proto.getAttributeData = function getAttributeData(name) {
|
|
20873
|
+
var _this_vertexBuffers_name;
|
|
20874
|
+
return (_this_vertexBuffers_name = this.vertexBuffers[name]) == null ? void 0 : _this_vertexBuffers_name.getData();
|
|
20875
|
+
};
|
|
20876
|
+
_proto.setAttributeData = function setAttributeData(name, data) {
|
|
20877
|
+
var vertexBuffer = this.vertexBuffers[name];
|
|
20878
|
+
if (!vertexBuffer) {
|
|
20879
|
+
return;
|
|
20880
|
+
}
|
|
20881
|
+
vertexBuffer.update(data);
|
|
20882
|
+
this.disposeVertexArrayObjects();
|
|
20883
|
+
};
|
|
20884
|
+
_proto.setAttributeSubData = function setAttributeSubData(name, offset, data) {
|
|
20885
|
+
var vertexBuffer = this.vertexBuffers[name];
|
|
20886
|
+
if (!vertexBuffer) {
|
|
20887
|
+
return;
|
|
20888
|
+
}
|
|
20889
|
+
var buffer = vertexBuffer.getWrapperBuffer();
|
|
20890
|
+
var vertexCount = buffer.byteStride > 0 ? Math.ceil(data.byteLength / buffer.byteStride) : 0;
|
|
20891
|
+
buffer.updateDirectly(data, offset, vertexCount);
|
|
20892
|
+
this.disposeVertexArrayObjects();
|
|
20893
|
+
};
|
|
20894
|
+
_proto.getAttributeStride = function getAttributeStride(name) {
|
|
20895
|
+
var _this_vertexBuffers_name;
|
|
20896
|
+
var _this_vertexBuffers_name_byteStride;
|
|
20897
|
+
return (_this_vertexBuffers_name_byteStride = (_this_vertexBuffers_name = this.vertexBuffers[name]) == null ? void 0 : _this_vertexBuffers_name.byteStride) != null ? _this_vertexBuffers_name_byteStride : 0;
|
|
20898
|
+
};
|
|
20899
|
+
_proto.getAttributeNames = function getAttributeNames() {
|
|
20900
|
+
return Object.keys(this.vertexBuffers);
|
|
20901
|
+
};
|
|
20902
|
+
/** @hide */ _proto.getIndexBuffer = function getIndexBuffer() {
|
|
20903
|
+
return this.indexBuffer;
|
|
20904
|
+
};
|
|
20905
|
+
_proto.getIndexData = function getIndexData() {
|
|
20906
|
+
return this.indices;
|
|
20907
|
+
};
|
|
20908
|
+
/** @hide */ _proto.getIndexType = function getIndexType() {
|
|
20909
|
+
var _this_indexBuffer;
|
|
20910
|
+
return ((_this_indexBuffer = this.indexBuffer) == null ? void 0 : _this_indexBuffer.is32Bits) || shouldUse32Bits(this.indices) ? exports.BufferDataType.UnsignedInt : exports.BufferDataType.UnsignedShort;
|
|
20911
|
+
};
|
|
20912
|
+
_proto.setIndexData = function setIndexData(data) {
|
|
20913
|
+
if (!isIndexData(data)) {
|
|
20914
|
+
throw new TypeError("Index data must use a supported integer array.");
|
|
20915
|
+
}
|
|
20916
|
+
this.indices = Array.isArray(data) ? shouldUse32Bits(data) ? new Uint32Array(data) : new Uint16Array(data) : data;
|
|
20917
|
+
this.releaseIndexBuffer();
|
|
20918
|
+
this.disposeVertexArrayObjects();
|
|
20919
|
+
if (this.initialized) {
|
|
20920
|
+
this.createIndexBuffer();
|
|
20921
|
+
}
|
|
20922
|
+
};
|
|
20923
|
+
_proto.setIndexSubData = function setIndexSubData(offset, data) {
|
|
20924
|
+
var indices = this.indices;
|
|
20925
|
+
if (offset < 0 || offset + data.length > indices.length) {
|
|
20926
|
+
throw new RangeError("Buffer '" + this.name + "##index' update is out of range.");
|
|
20927
|
+
}
|
|
20928
|
+
indices.set(data, offset);
|
|
20929
|
+
if (this.indexBuffer) {
|
|
20930
|
+
var updatedData = indices.slice(offset, offset + data.length);
|
|
20931
|
+
this.engine.updateDynamicIndexBuffer(this.indexBuffer, updatedData, offset * (this.indexBuffer.is32Bits ? Uint32Array.BYTES_PER_ELEMENT : Uint16Array.BYTES_PER_ELEMENT));
|
|
20932
|
+
this.disposeVertexArrayObjects();
|
|
20933
|
+
}
|
|
20934
|
+
};
|
|
20935
|
+
_proto.setDrawStart = function setDrawStart(start) {
|
|
20936
|
+
this.drawStart = start;
|
|
20937
|
+
};
|
|
20938
|
+
_proto.getDrawStart = function getDrawStart() {
|
|
20939
|
+
return this.drawStart;
|
|
20940
|
+
};
|
|
20941
|
+
_proto.setDrawCount = function setDrawCount(count) {
|
|
20942
|
+
this.drawCount = count;
|
|
20943
|
+
};
|
|
20944
|
+
_proto.getDrawCount = function getDrawCount() {
|
|
20945
|
+
return this.drawCount;
|
|
20946
|
+
};
|
|
20947
|
+
_proto.getSkinProps = function getSkinProps() {
|
|
20948
|
+
return this.skin;
|
|
20949
|
+
};
|
|
20950
|
+
/** @hide */ _proto.bind = function bind(shader) {
|
|
20951
|
+
var vertexArrayObjects = this.vertexArrayObjects;
|
|
20952
|
+
var engine = this.engine;
|
|
20953
|
+
if (!vertexArrayObjects || !supportsVertexArrayObjects(engine)) {
|
|
20954
|
+
engine.bindBuffers(this.vertexBuffers, this.indexBuffer, shader);
|
|
20955
|
+
return;
|
|
20956
|
+
}
|
|
20957
|
+
var vertexArrayObject = vertexArrayObjects[shader.key];
|
|
20958
|
+
if (!vertexArrayObject) {
|
|
20959
|
+
vertexArrayObject = engine.recordVertexArrayObject(this.vertexBuffers, this.indexBuffer, shader);
|
|
20960
|
+
if (vertexArrayObject) {
|
|
20961
|
+
vertexArrayObjects[shader.key] = vertexArrayObject;
|
|
20962
|
+
}
|
|
20963
|
+
}
|
|
20964
|
+
if (vertexArrayObject) {
|
|
20965
|
+
engine.bindVertexArrayObject(vertexArrayObject, this.indexBuffer);
|
|
20966
|
+
} else {
|
|
20967
|
+
engine.bindBuffers(this.vertexBuffers, this.indexBuffer, shader);
|
|
20968
|
+
}
|
|
20969
|
+
};
|
|
20970
|
+
_proto.releaseVertexArrayObject = function releaseVertexArrayObject(key) {
|
|
20971
|
+
var vertexArrayObjects = this.vertexArrayObjects;
|
|
20972
|
+
if (!vertexArrayObjects) {
|
|
20973
|
+
return;
|
|
20974
|
+
}
|
|
20975
|
+
var vertexArrayObject = vertexArrayObjects[key];
|
|
20976
|
+
if (vertexArrayObject && hasVertexArrayObjectMethods(this.engine)) {
|
|
20977
|
+
this.engine.releaseVertexArrayObject(vertexArrayObject);
|
|
20978
|
+
}
|
|
20979
|
+
delete vertexArrayObjects[key];
|
|
20980
|
+
};
|
|
20981
|
+
_proto.initialize = function initialize() {
|
|
20982
|
+
if (this.initialized || this.disposed) {
|
|
20983
|
+
return;
|
|
20984
|
+
}
|
|
20985
|
+
this.forEachVertexBuffer(function(buffer) {
|
|
20986
|
+
buffer.create();
|
|
20987
|
+
});
|
|
20988
|
+
this.createIndexBuffer();
|
|
20989
|
+
this.engine.addGeometry(this);
|
|
20990
|
+
this.initialized = true;
|
|
20991
|
+
this.options = undefined;
|
|
20992
|
+
};
|
|
20993
|
+
_proto.flush = function flush() {
|
|
20994
|
+
if (this.disposed) {
|
|
20995
|
+
return;
|
|
20996
|
+
}
|
|
20997
|
+
this.initialize();
|
|
20998
|
+
this.forEachVertexBuffer(function(buffer) {
|
|
20999
|
+
return buffer.create();
|
|
21000
|
+
});
|
|
21001
|
+
};
|
|
21002
|
+
/** @hide */ _proto.restore = function restore() {
|
|
21003
|
+
if (!this.initialized || this.disposed) {
|
|
21004
|
+
return;
|
|
21005
|
+
}
|
|
21006
|
+
if (this.vertexArrayObjects) {
|
|
21007
|
+
this.vertexArrayObjects = {};
|
|
21008
|
+
}
|
|
21009
|
+
this.forEachVertexBuffer(function(buffer) {
|
|
21010
|
+
return buffer.rebuild();
|
|
21011
|
+
});
|
|
21012
|
+
if (this.indices.length > 0) {
|
|
21013
|
+
this.indexBuffer = undefined;
|
|
21014
|
+
this.createIndexBuffer();
|
|
21015
|
+
}
|
|
21016
|
+
};
|
|
21017
|
+
_proto.fromData = function fromData(data) {
|
|
21018
|
+
EffectsObject.prototype.fromData.call(this, data);
|
|
21019
|
+
this.subMeshes = data.subMeshes;
|
|
21020
|
+
var buffer;
|
|
21021
|
+
if (data.buffer) {
|
|
21022
|
+
buffer = new Uint8Array(decodeBase64ToArrayBuffer(data.buffer));
|
|
21023
|
+
} else if (data.binaryData) {
|
|
21024
|
+
buffer = data.binaryData;
|
|
21025
|
+
}
|
|
21026
|
+
if (!buffer) {
|
|
21027
|
+
return;
|
|
21028
|
+
}
|
|
21029
|
+
var vertexCount = data.vertexData.vertexCount;
|
|
21030
|
+
var props = {
|
|
21031
|
+
name: data.name,
|
|
21032
|
+
mode: 4,
|
|
21033
|
+
attributes: {}
|
|
21034
|
+
};
|
|
21035
|
+
if (hasSemantic(data)) {
|
|
21036
|
+
data.vertexData.channels.forEach(function(channel) {
|
|
21037
|
+
var _vertexBufferSemanticMap_channel_semantic;
|
|
21038
|
+
var attributeName = (_vertexBufferSemanticMap_channel_semantic = vertexBufferSemanticMap[channel.semantic]) != null ? _vertexBufferSemanticMap_channel_semantic : channel.semantic;
|
|
21039
|
+
props.attributes[attributeName] = {
|
|
21040
|
+
type: vertexFormatToDataType(channel.format),
|
|
21041
|
+
size: channel.dimension,
|
|
21042
|
+
data: createVertexTypedArray(channel, buffer, vertexCount),
|
|
21043
|
+
normalize: channel.normalize
|
|
21044
|
+
};
|
|
21045
|
+
});
|
|
21046
|
+
} else {
|
|
21047
|
+
var positionChannel = data.vertexData.channels[0];
|
|
21048
|
+
var uvChannel = data.vertexData.channels[1];
|
|
21049
|
+
var normalChannel = data.vertexData.channels[2];
|
|
21050
|
+
var _obj;
|
|
21051
|
+
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);
|
|
21052
|
+
}
|
|
21053
|
+
if (data.indexFormat !== IndexFormatType.None) {
|
|
21054
|
+
var indices = createIndexTypedArray(data.indexFormat, buffer, data.indexOffset);
|
|
21055
|
+
props.indices = {
|
|
21056
|
+
data: indices
|
|
21057
|
+
};
|
|
21058
|
+
props.drawCount = indices.length;
|
|
21059
|
+
} else {
|
|
21060
|
+
props.drawCount = vertexCount;
|
|
21061
|
+
}
|
|
21062
|
+
this.processProps(props);
|
|
21063
|
+
this.skin = {
|
|
21064
|
+
boneNames: data.boneNames,
|
|
21065
|
+
rootBoneName: data.rootBoneName,
|
|
21066
|
+
inverseBindMatrices: data.inverseBindMatrices
|
|
21067
|
+
};
|
|
21068
|
+
};
|
|
21069
|
+
_proto.dispose = function dispose() {
|
|
21070
|
+
var _this = this;
|
|
21071
|
+
if (this.disposed) {
|
|
21072
|
+
return;
|
|
21073
|
+
}
|
|
21074
|
+
this.disposeVertexArrayObjects();
|
|
21075
|
+
Object.keys(this.vertexBuffers).forEach(function(name) {
|
|
21076
|
+
return _this.vertexBuffers[name].dispose();
|
|
21077
|
+
});
|
|
21078
|
+
this.releaseIndexBuffer();
|
|
21079
|
+
this.vertexBuffers = {};
|
|
21080
|
+
this.indices = new Uint16Array(0);
|
|
21081
|
+
this.options = undefined;
|
|
21082
|
+
this.drawStart = 0;
|
|
21083
|
+
this.drawCount = 0;
|
|
21084
|
+
if (this.initialized) {
|
|
21085
|
+
this.engine.removeGeometry(this);
|
|
21086
|
+
}
|
|
21087
|
+
this.initialized = false;
|
|
21088
|
+
this.disposed = true;
|
|
21089
|
+
EffectsObject.prototype.dispose.call(this);
|
|
20715
21090
|
};
|
|
21091
|
+
_proto.processProps = function processProps(props) {
|
|
21092
|
+
var _this = this;
|
|
21093
|
+
this.releaseCurrentBuffers();
|
|
21094
|
+
var _props_bufferUsage;
|
|
21095
|
+
var usage = (_props_bufferUsage = props.bufferUsage) != null ? _props_bufferUsage : exports.BufferUsage.Static;
|
|
21096
|
+
var sourceBuffers = {};
|
|
21097
|
+
var sourceDivisors = {};
|
|
21098
|
+
var sourceTypes = {};
|
|
21099
|
+
Object.keys(props.attributes).forEach(function(name) {
|
|
21100
|
+
var attribute = props.attributes[name];
|
|
21101
|
+
var source = "dataSource" in attribute ? attribute.dataSource : name;
|
|
21102
|
+
var _sourceDivisors_source, _attribute_instanceDivisor;
|
|
21103
|
+
sourceDivisors[source] = Math.max((_sourceDivisors_source = sourceDivisors[source]) != null ? _sourceDivisors_source : 0, (_attribute_instanceDivisor = attribute.instanceDivisor) != null ? _attribute_instanceDivisor : 0);
|
|
21104
|
+
});
|
|
21105
|
+
Object.keys(props.attributes).forEach(function(name) {
|
|
21106
|
+
var attribute = props.attributes[name];
|
|
21107
|
+
if ("dataSource" in attribute) {
|
|
21108
|
+
return;
|
|
21109
|
+
}
|
|
21110
|
+
var typedData = isTypedArray(attribute.data) ? attribute.data : undefined;
|
|
21111
|
+
var _attribute_type;
|
|
21112
|
+
var type = (_attribute_type = attribute.type) != null ? _attribute_type : typedData ? getDataType(typedData) : exports.BufferDataType.Float;
|
|
21113
|
+
var bytesPerElement = getBytesPerElement(type);
|
|
21114
|
+
var byteStride = attribute.stride || attribute.size * bytesPerElement;
|
|
21115
|
+
var data = typedData != null ? typedData : createTypedArray(type, 0);
|
|
21116
|
+
if (data.length === 0 && props.maxVertex && props.maxVertex > 0) {
|
|
21117
|
+
var elementStride = byteStride / bytesPerElement;
|
|
21118
|
+
data = createTypedArray(type, Math.ceil(props.maxVertex * elementStride));
|
|
21119
|
+
}
|
|
21120
|
+
var _sourceDivisors_name;
|
|
21121
|
+
var instanceDivisor = (_sourceDivisors_name = sourceDivisors[name]) != null ? _sourceDivisors_name : 0;
|
|
21122
|
+
sourceTypes[name] = type;
|
|
21123
|
+
sourceBuffers[name] = new Buffer(_this.engine, data, usage !== exports.BufferUsage.Static, byteStride, false, instanceDivisor > 0, true, instanceDivisor, name);
|
|
21124
|
+
});
|
|
21125
|
+
Object.keys(props.attributes).forEach(function(name) {
|
|
21126
|
+
var attribute = props.attributes[name];
|
|
21127
|
+
var source = "dataSource" in attribute ? attribute.dataSource : name;
|
|
21128
|
+
var buffer = sourceBuffers[source];
|
|
21129
|
+
if (!buffer) {
|
|
21130
|
+
throw new Error("Attribute '" + name + "' references missing data source '" + source + "'.");
|
|
21131
|
+
}
|
|
21132
|
+
var _attribute_type, _ref;
|
|
21133
|
+
var type = (_ref = (_attribute_type = attribute.type) != null ? _attribute_type : sourceTypes[source]) != null ? _ref : exports.BufferDataType.Float;
|
|
21134
|
+
var byteStride = attribute.stride || buffer.byteStride;
|
|
21135
|
+
var _attribute_instanceDivisor;
|
|
21136
|
+
var instanceDivisor = (_attribute_instanceDivisor = attribute.instanceDivisor) != null ? _attribute_instanceDivisor : 0;
|
|
21137
|
+
var _attribute_offset, _attribute_normalize;
|
|
21138
|
+
var vertexBuffer = new VertexBuffer(_this.engine, buffer, name, {
|
|
21139
|
+
size: attribute.size,
|
|
21140
|
+
type: type,
|
|
21141
|
+
stride: byteStride,
|
|
21142
|
+
offset: (_attribute_offset = attribute.offset) != null ? _attribute_offset : 0,
|
|
21143
|
+
normalized: (_attribute_normalize = attribute.normalize) != null ? _attribute_normalize : false,
|
|
21144
|
+
instanced: instanceDivisor > 0,
|
|
21145
|
+
divisor: instanceDivisor,
|
|
21146
|
+
useBytes: true,
|
|
21147
|
+
takeBufferOwnership: true
|
|
21148
|
+
});
|
|
21149
|
+
_this.setVerticesBuffer(vertexBuffer);
|
|
21150
|
+
});
|
|
21151
|
+
var _props_name;
|
|
21152
|
+
this.name = (_props_name = props.name) != null ? _props_name : "effectsGeometry:" + geometryId++;
|
|
21153
|
+
var _props_drawStart;
|
|
21154
|
+
this.drawStart = (_props_drawStart = props.drawStart) != null ? _props_drawStart : 0;
|
|
21155
|
+
var _props_drawCount;
|
|
21156
|
+
this.drawCount = (_props_drawCount = props.drawCount) != null ? _props_drawCount : 0;
|
|
21157
|
+
var _props_mode;
|
|
21158
|
+
this.mode = (_props_mode = props.mode) != null ? _props_mode : 4;
|
|
21159
|
+
var _props_instanceCount;
|
|
21160
|
+
this.instanceCount = (_props_instanceCount = props.instanceCount) != null ? _props_instanceCount : 0;
|
|
21161
|
+
this.bufferUsage = usage;
|
|
21162
|
+
this.options = props;
|
|
21163
|
+
if (props.indices) {
|
|
21164
|
+
var data = props.indices.data;
|
|
21165
|
+
if (!isIndexData(data)) {
|
|
21166
|
+
throw new TypeError("Index data must use a supported integer array.");
|
|
21167
|
+
}
|
|
21168
|
+
// 索引还会参与 CPU 侧的命中检测和几何查询,因此始终保留源数据。
|
|
21169
|
+
this.indices = Array.isArray(data) ? shouldUse32Bits(data) ? new Uint32Array(data) : new Uint16Array(data) : data;
|
|
21170
|
+
}
|
|
21171
|
+
this.disposeVertexArrayObjects();
|
|
21172
|
+
};
|
|
21173
|
+
_proto.releaseCurrentBuffers = function releaseCurrentBuffers() {
|
|
21174
|
+
var _this = this;
|
|
21175
|
+
var wasInitialized = this.initialized;
|
|
21176
|
+
this.disposeVertexArrayObjects();
|
|
21177
|
+
Object.keys(this.vertexBuffers).forEach(function(name) {
|
|
21178
|
+
return _this.vertexBuffers[name].dispose();
|
|
21179
|
+
});
|
|
21180
|
+
this.releaseIndexBuffer();
|
|
21181
|
+
this.vertexBuffers = {};
|
|
21182
|
+
this.indices = new Uint16Array(0);
|
|
21183
|
+
if (wasInitialized) {
|
|
21184
|
+
this.engine.removeGeometry(this);
|
|
21185
|
+
this.initialized = false;
|
|
21186
|
+
}
|
|
21187
|
+
};
|
|
21188
|
+
_proto.disposeVertexArrayObjects = function disposeVertexArrayObjects() {
|
|
21189
|
+
var _this = this;
|
|
21190
|
+
var vertexArrayObjects = this.vertexArrayObjects;
|
|
21191
|
+
if (!vertexArrayObjects) {
|
|
21192
|
+
return;
|
|
21193
|
+
}
|
|
21194
|
+
Object.keys(vertexArrayObjects).forEach(function(key) {
|
|
21195
|
+
var vertexArrayObject = vertexArrayObjects[key];
|
|
21196
|
+
if (vertexArrayObject && hasVertexArrayObjectMethods(_this.engine)) {
|
|
21197
|
+
_this.engine.releaseVertexArrayObject(vertexArrayObject);
|
|
21198
|
+
}
|
|
21199
|
+
});
|
|
21200
|
+
this.vertexArrayObjects = {};
|
|
21201
|
+
};
|
|
21202
|
+
_proto.createIndexBuffer = function createIndexBuffer() {
|
|
21203
|
+
var indices = this.indices;
|
|
21204
|
+
if (indices.length === 0 || this.indexBuffer) {
|
|
21205
|
+
return;
|
|
21206
|
+
}
|
|
21207
|
+
this.indexBuffer = this.engine.createIndexBuffer(indices, {
|
|
21208
|
+
usage: this.bufferUsage,
|
|
21209
|
+
type: this.getIndexType(),
|
|
21210
|
+
byteStride: 0,
|
|
21211
|
+
instanceDivisor: 0,
|
|
21212
|
+
label: "" + this.name + "##index"
|
|
21213
|
+
});
|
|
21214
|
+
};
|
|
21215
|
+
_proto.releaseIndexBuffer = function releaseIndexBuffer() {
|
|
21216
|
+
if (!this.indexBuffer) {
|
|
21217
|
+
return;
|
|
21218
|
+
}
|
|
21219
|
+
this.engine.releaseBuffer(this.indexBuffer);
|
|
21220
|
+
this.indexBuffer = undefined;
|
|
21221
|
+
};
|
|
21222
|
+
_proto.forEachVertexBuffer = function forEachVertexBuffer(callback) {
|
|
21223
|
+
var _this = this;
|
|
21224
|
+
var visited = new Set();
|
|
21225
|
+
Object.keys(this.vertexBuffers).forEach(function(name) {
|
|
21226
|
+
var buffer = _this.vertexBuffers[name].getWrapperBuffer();
|
|
21227
|
+
if (!visited.has(buffer)) {
|
|
21228
|
+
visited.add(buffer);
|
|
21229
|
+
callback(buffer);
|
|
21230
|
+
}
|
|
21231
|
+
});
|
|
21232
|
+
};
|
|
21233
|
+
_create_class(Geometry, [
|
|
21234
|
+
{
|
|
21235
|
+
key: "isInitialized",
|
|
21236
|
+
get: /**
|
|
21237
|
+
* @internal
|
|
21238
|
+
*/ function get() {
|
|
21239
|
+
return this.initialized;
|
|
21240
|
+
}
|
|
21241
|
+
}
|
|
21242
|
+
]);
|
|
20716
21243
|
return Geometry;
|
|
20717
21244
|
}(EffectsObject);
|
|
20718
|
-
function
|
|
20719
|
-
|
|
20720
|
-
|
|
21245
|
+
Geometry.create = function(engine, props) {
|
|
21246
|
+
return new Geometry(engine, props);
|
|
21247
|
+
};
|
|
21248
|
+
function isTypedArray(value) {
|
|
21249
|
+
return ArrayBuffer.isView(value) && !_instanceof1(value, DataView);
|
|
21250
|
+
}
|
|
21251
|
+
function hasVertexArrayObjectMethods(engine) {
|
|
21252
|
+
var candidate = engine;
|
|
21253
|
+
return typeof candidate.recordVertexArrayObject === "function" && typeof candidate.bindVertexArrayObject === "function" && typeof candidate.releaseVertexArrayObject === "function";
|
|
21254
|
+
}
|
|
21255
|
+
function supportsVertexArrayObjects(engine) {
|
|
21256
|
+
var _engine_gpuCapability;
|
|
21257
|
+
return ((_engine_gpuCapability = engine.gpuCapability) == null ? void 0 : _engine_gpuCapability.detail.vertexArrayObject) === true && hasVertexArrayObjectMethods(engine);
|
|
21258
|
+
}
|
|
21259
|
+
function isIndexData(data) {
|
|
21260
|
+
return Array.isArray(data) || _instanceof1(data, Int32Array) || _instanceof1(data, Uint16Array) || _instanceof1(data, Uint32Array);
|
|
21261
|
+
}
|
|
21262
|
+
function shouldUse32Bits(data) {
|
|
21263
|
+
if (_instanceof1(data, Uint32Array)) {
|
|
21264
|
+
return true;
|
|
21265
|
+
}
|
|
21266
|
+
if (_instanceof1(data, Uint16Array)) {
|
|
21267
|
+
return false;
|
|
20721
21268
|
}
|
|
20722
|
-
|
|
20723
|
-
|
|
21269
|
+
for(var i = 0; i < data.length; i++){
|
|
21270
|
+
if (data[i] >= 65535) {
|
|
21271
|
+
return true;
|
|
21272
|
+
}
|
|
20724
21273
|
}
|
|
20725
|
-
return
|
|
21274
|
+
return false;
|
|
21275
|
+
}
|
|
21276
|
+
function createAttributeFromChannel(channel, buffer, vertexCount, size) {
|
|
21277
|
+
return {
|
|
21278
|
+
type: vertexFormatToDataType(channel.format),
|
|
21279
|
+
size: size,
|
|
21280
|
+
data: createVertexTypedArray(channel, buffer, vertexCount),
|
|
21281
|
+
normalize: channel.normalize
|
|
21282
|
+
};
|
|
21283
|
+
}
|
|
21284
|
+
function createVertexTypedArray(channel, baseBuffer, vertexCount) {
|
|
21285
|
+
var arrayBuffer = baseBuffer.buffer;
|
|
21286
|
+
var byteOffset = baseBuffer.byteOffset + channel.offset;
|
|
21287
|
+
var length = channel.dimension * vertexCount;
|
|
21288
|
+
switch(channel.format){
|
|
21289
|
+
case VertexFormatType.Float32:
|
|
21290
|
+
return new Float32Array(arrayBuffer, byteOffset, length);
|
|
21291
|
+
case VertexFormatType.Int16:
|
|
21292
|
+
return new Int16Array(arrayBuffer, byteOffset, length);
|
|
21293
|
+
case VertexFormatType.Int8:
|
|
21294
|
+
return new Int8Array(arrayBuffer, byteOffset, length);
|
|
21295
|
+
case VertexFormatType.UInt16:
|
|
21296
|
+
return new Uint16Array(arrayBuffer, byteOffset, length);
|
|
21297
|
+
case VertexFormatType.UInt8:
|
|
21298
|
+
return new Uint8Array(arrayBuffer, byteOffset, length);
|
|
21299
|
+
default:
|
|
21300
|
+
throw new Error("Unsupported vertex format: " + channel.format + ".");
|
|
21301
|
+
}
|
|
21302
|
+
}
|
|
21303
|
+
function createIndexTypedArray(type, baseBuffer, offset) {
|
|
21304
|
+
var arrayBuffer = baseBuffer.buffer;
|
|
21305
|
+
var byteOffset = baseBuffer.byteOffset + offset;
|
|
21306
|
+
var byteLength = baseBuffer.byteLength - offset;
|
|
21307
|
+
switch(type){
|
|
21308
|
+
case IndexFormatType.UInt16:
|
|
21309
|
+
return new Uint16Array(arrayBuffer, byteOffset, byteLength / Uint16Array.BYTES_PER_ELEMENT);
|
|
21310
|
+
case IndexFormatType.UInt32:
|
|
21311
|
+
return new Uint32Array(arrayBuffer, byteOffset, byteLength / Uint32Array.BYTES_PER_ELEMENT);
|
|
21312
|
+
default:
|
|
21313
|
+
throw new Error("Unsupported index format: " + type + ".");
|
|
21314
|
+
}
|
|
21315
|
+
}
|
|
21316
|
+
function vertexFormatToDataType(format) {
|
|
21317
|
+
switch(format){
|
|
21318
|
+
case VertexFormatType.Float32:
|
|
21319
|
+
return exports.BufferDataType.Float;
|
|
21320
|
+
case VertexFormatType.Int16:
|
|
21321
|
+
return exports.BufferDataType.Short;
|
|
21322
|
+
case VertexFormatType.Int8:
|
|
21323
|
+
return exports.BufferDataType.Byte;
|
|
21324
|
+
case VertexFormatType.UInt16:
|
|
21325
|
+
return exports.BufferDataType.UnsignedShort;
|
|
21326
|
+
case VertexFormatType.UInt8:
|
|
21327
|
+
return exports.BufferDataType.UnsignedByte;
|
|
21328
|
+
default:
|
|
21329
|
+
throw new Error("Unsupported vertex format: " + format + ".");
|
|
21330
|
+
}
|
|
21331
|
+
}
|
|
21332
|
+
function hasSemantic(data) {
|
|
21333
|
+
return data.vertexData.channels.some(function(channel) {
|
|
21334
|
+
return !!channel.semantic;
|
|
21335
|
+
});
|
|
21336
|
+
}
|
|
21337
|
+
function decodeBase64ToArrayBuffer(value) {
|
|
21338
|
+
var binary = atob(value);
|
|
21339
|
+
var bytes = new Uint8Array(binary.length);
|
|
21340
|
+
for(var i = 0; i < binary.length; i++){
|
|
21341
|
+
bytes[i] = binary.charCodeAt(i);
|
|
21342
|
+
}
|
|
21343
|
+
return bytes.buffer;
|
|
21344
|
+
}
|
|
21345
|
+
var vertexBufferSemanticMap = {
|
|
21346
|
+
POSITION: VertexBuffer.PositionKind,
|
|
21347
|
+
TEXCOORD0: VertexBuffer.UVKind,
|
|
21348
|
+
TEXCOORD_0: VertexBuffer.UVKind,
|
|
21349
|
+
TEXCOORD1: VertexBuffer.UV2Kind,
|
|
21350
|
+
NORMAL: VertexBuffer.NormalKind,
|
|
21351
|
+
TANGENT: VertexBuffer.TangentKind,
|
|
21352
|
+
COLOR: VertexBuffer.ColorKind,
|
|
21353
|
+
JOINTS: VertexBuffer.JointsKind,
|
|
21354
|
+
JOINTS_0: VertexBuffer.JointsKind,
|
|
21355
|
+
WEIGHTS: VertexBuffer.WeightsKind,
|
|
21356
|
+
WEIGHTS_0: VertexBuffer.WeightsKind,
|
|
21357
|
+
POSITION_BS0: "aTargetPosition0",
|
|
21358
|
+
POSITION_BS1: "aTargetPosition1",
|
|
21359
|
+
POSITION_BS2: "aTargetPosition2",
|
|
21360
|
+
POSITION_BS3: "aTargetPosition3",
|
|
21361
|
+
POSITION_BS4: "aTargetPosition4",
|
|
21362
|
+
POSITION_BS5: "aTargetPosition5",
|
|
21363
|
+
POSITION_BS6: "aTargetPosition6",
|
|
21364
|
+
POSITION_BS7: "aTargetPosition7",
|
|
21365
|
+
NORMAL_BS0: "aTargetNormal0",
|
|
21366
|
+
NORMAL_BS1: "aTargetNormal1",
|
|
21367
|
+
NORMAL_BS2: "aTargetNormal2",
|
|
21368
|
+
NORMAL_BS3: "aTargetNormal3",
|
|
21369
|
+
TANGENT_BS0: "aTargetTangent0",
|
|
21370
|
+
TANGENT_BS1: "aTargetTangent1",
|
|
21371
|
+
TANGENT_BS2: "aTargetTangent2",
|
|
21372
|
+
TANGENT_BS3: "aTargetTangent3"
|
|
21373
|
+
};
|
|
21374
|
+
var _obj$4;
|
|
21375
|
+
var BYTES_TYPE_MAP = (_obj$4 = {}, _obj$4[exports.BufferDataType.Float] = 4, _obj$4[exports.BufferDataType.Int] = 4, _obj$4[exports.BufferDataType.UnsignedInt] = 4, _obj$4[exports.BufferDataType.Short] = 2, _obj$4[exports.BufferDataType.UnsignedShort] = 2, _obj$4[exports.BufferDataType.Byte] = 1, _obj$4[exports.BufferDataType.UnsignedByte] = 1, _obj$4);
|
|
21376
|
+
function generateEmptyTypedArray(type) {
|
|
21377
|
+
return createTypedArray(type, 0);
|
|
20726
21378
|
}
|
|
20727
21379
|
|
|
20728
|
-
var seed$
|
|
21380
|
+
var seed$5 = 1;
|
|
20729
21381
|
/**
|
|
20730
21382
|
* Mesh 抽象类
|
|
20731
21383
|
*/ var Mesh = /*#__PURE__*/ function(RendererComponent) {
|
|
@@ -20737,14 +21389,14 @@ var seed$6 = 1;
|
|
|
20737
21389
|
_this.visible = true;
|
|
20738
21390
|
if (props) {
|
|
20739
21391
|
var material = props.material, geometry = props.geometry, _props_name = props.name, name = _props_name === void 0 ? "<unnamed>" : _props_name, _props_priority = props.priority, priority = _props_priority === void 0 ? 0 : _props_priority, _props_worldMatrix = props.worldMatrix, worldMatrix = _props_worldMatrix === void 0 ? Matrix4.fromIdentity() : _props_worldMatrix;
|
|
20740
|
-
_this.id = "Mesh" + seed$
|
|
21392
|
+
_this.id = "Mesh" + seed$5++;
|
|
20741
21393
|
_this.name = name;
|
|
20742
21394
|
_this.geometry = geometry;
|
|
20743
21395
|
_this.material = material;
|
|
20744
21396
|
_this.priority = priority;
|
|
20745
21397
|
_this.worldMatrix = worldMatrix;
|
|
20746
21398
|
} else {
|
|
20747
|
-
_this.id = "Mesh" + seed$
|
|
21399
|
+
_this.id = "Mesh" + seed$5++;
|
|
20748
21400
|
_this.name = "<unnamed>";
|
|
20749
21401
|
_this.worldMatrix = Matrix4.fromIdentity();
|
|
20750
21402
|
_this._priority = 0;
|
|
@@ -21137,25 +21789,24 @@ var ToneMappingPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
21137
21789
|
var name = "PostProcess";
|
|
21138
21790
|
var engine = _this.renderer.engine;
|
|
21139
21791
|
_this.sceneTextureHandle = sceneTextureHandle ? sceneTextureHandle : new RenderTargetHandle(engine);
|
|
21792
|
+
var _obj;
|
|
21140
21793
|
var geometry = Geometry.create(engine, {
|
|
21141
21794
|
name: name,
|
|
21142
21795
|
mode: glContext.TRIANGLE_STRIP,
|
|
21143
|
-
attributes: {
|
|
21144
|
-
|
|
21145
|
-
|
|
21146
|
-
|
|
21147
|
-
|
|
21148
|
-
|
|
21149
|
-
|
|
21150
|
-
|
|
21151
|
-
|
|
21152
|
-
|
|
21153
|
-
|
|
21154
|
-
|
|
21155
|
-
|
|
21156
|
-
|
|
21157
|
-
}
|
|
21158
|
-
},
|
|
21796
|
+
attributes: (_obj = {}, _obj[VertexBuffer.PositionKind] = {
|
|
21797
|
+
type: glContext.FLOAT,
|
|
21798
|
+
size: 2,
|
|
21799
|
+
data: new Float32Array([
|
|
21800
|
+
-1,
|
|
21801
|
+
1,
|
|
21802
|
+
-1,
|
|
21803
|
+
-1,
|
|
21804
|
+
1,
|
|
21805
|
+
1,
|
|
21806
|
+
1,
|
|
21807
|
+
-1
|
|
21808
|
+
])
|
|
21809
|
+
}, _obj),
|
|
21159
21810
|
drawCount: 4
|
|
21160
21811
|
});
|
|
21161
21812
|
var material = Material.create(engine, {
|
|
@@ -21238,7 +21889,7 @@ var ToneMappingPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
21238
21889
|
return ToneMappingPass;
|
|
21239
21890
|
}(RenderPass);
|
|
21240
21891
|
|
|
21241
|
-
var seed$
|
|
21892
|
+
var seed$4 = 1;
|
|
21242
21893
|
/**
|
|
21243
21894
|
* RenderFrame 抽象类
|
|
21244
21895
|
*/ var RenderFrame = /*#__PURE__*/ function() {
|
|
@@ -21278,7 +21929,7 @@ var seed$5 = 1;
|
|
|
21278
21929
|
var postProcessPass = new ToneMappingPass(renderer, sceneTextureHandle);
|
|
21279
21930
|
this.addRenderPass(postProcessPass);
|
|
21280
21931
|
}
|
|
21281
|
-
this.name = "RenderFrame" + seed$
|
|
21932
|
+
this.name = "RenderFrame" + seed$4++;
|
|
21282
21933
|
this.camera = camera;
|
|
21283
21934
|
this.editorTransform = Vector4.fromArray(editorTransform);
|
|
21284
21935
|
}
|
|
@@ -21585,6 +22236,7 @@ var GPUCapability = /*#__PURE__*/ function() {
|
|
|
21585
22236
|
maxTextureAnisotropy: textureAnisotropicExt ? gl.getParameter(textureAnisotropicExt.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : 0,
|
|
21586
22237
|
shaderTextureLod: level2 || !!gl.getExtension("EXT_shader_texture_lod"),
|
|
21587
22238
|
instanceDraw: level2 || !!gl.getExtension("ANGLE_instanced_arrays"),
|
|
22239
|
+
vertexArrayObject: level2 || !!this.vaoExt,
|
|
21588
22240
|
ktx2Support: detectKTX2Support(this.compressTextureCapabilityList),
|
|
21589
22241
|
drawBuffers: level2 || !!this.drawBufferExtension,
|
|
21590
22242
|
asyncShaderCompile: !!this.glAsyncCompileExt,
|
|
@@ -21809,24 +22461,23 @@ var Renderer = /*#__PURE__*/ function() {
|
|
|
21809
22461
|
*/ _proto.blit = function blit(source, destination, material) {
|
|
21810
22462
|
// 懒加载创建 blit geometry
|
|
21811
22463
|
if (!this.blitGeometry) {
|
|
22464
|
+
var _obj;
|
|
21812
22465
|
this.blitGeometry = Geometry.create(this.engine, {
|
|
21813
22466
|
mode: glContext.TRIANGLE_STRIP,
|
|
21814
|
-
attributes: {
|
|
21815
|
-
|
|
21816
|
-
|
|
21817
|
-
|
|
21818
|
-
|
|
21819
|
-
|
|
21820
|
-
|
|
21821
|
-
|
|
21822
|
-
|
|
21823
|
-
|
|
21824
|
-
|
|
21825
|
-
|
|
21826
|
-
|
|
21827
|
-
|
|
21828
|
-
}
|
|
21829
|
-
},
|
|
22467
|
+
attributes: (_obj = {}, _obj[VertexBuffer.PositionKind] = {
|
|
22468
|
+
type: glContext.FLOAT,
|
|
22469
|
+
size: 2,
|
|
22470
|
+
data: new Float32Array([
|
|
22471
|
+
-1,
|
|
22472
|
+
1,
|
|
22473
|
+
-1,
|
|
22474
|
+
-1,
|
|
22475
|
+
1,
|
|
22476
|
+
1,
|
|
22477
|
+
1,
|
|
22478
|
+
-1
|
|
22479
|
+
])
|
|
22480
|
+
}, _obj),
|
|
21830
22481
|
drawCount: 4
|
|
21831
22482
|
});
|
|
21832
22483
|
}
|
|
@@ -22298,61 +22949,57 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
22298
22949
|
this.currentBatchTexture = null;
|
|
22299
22950
|
this.transformStack = [];
|
|
22300
22951
|
this.currentTransform = Matrix3.fromIdentity();
|
|
22952
|
+
var _obj;
|
|
22301
22953
|
this.geometry = Geometry.create(this.engine, {
|
|
22302
|
-
attributes: {
|
|
22303
|
-
|
|
22304
|
-
|
|
22305
|
-
|
|
22306
|
-
|
|
22307
|
-
|
|
22308
|
-
|
|
22309
|
-
|
|
22310
|
-
|
|
22311
|
-
|
|
22312
|
-
|
|
22313
|
-
|
|
22314
|
-
|
|
22315
|
-
|
|
22316
|
-
|
|
22317
|
-
|
|
22318
|
-
|
|
22319
|
-
|
|
22320
|
-
|
|
22321
|
-
|
|
22322
|
-
|
|
22323
|
-
|
|
22324
|
-
|
|
22325
|
-
|
|
22326
|
-
|
|
22327
|
-
|
|
22328
|
-
|
|
22329
|
-
|
|
22330
|
-
|
|
22331
|
-
|
|
22332
|
-
|
|
22333
|
-
|
|
22334
|
-
|
|
22335
|
-
|
|
22336
|
-
|
|
22337
|
-
|
|
22338
|
-
|
|
22339
|
-
|
|
22340
|
-
|
|
22341
|
-
|
|
22342
|
-
|
|
22343
|
-
|
|
22344
|
-
|
|
22345
|
-
|
|
22346
|
-
|
|
22347
|
-
|
|
22348
|
-
|
|
22349
|
-
|
|
22350
|
-
|
|
22351
|
-
1,
|
|
22352
|
-
0
|
|
22353
|
-
])
|
|
22354
|
-
}
|
|
22355
|
-
},
|
|
22954
|
+
attributes: (_obj = {}, _obj[VertexBuffer.PositionKind] = {
|
|
22955
|
+
type: glContext.FLOAT,
|
|
22956
|
+
size: 2,
|
|
22957
|
+
data: new Float32Array([
|
|
22958
|
+
-0.5,
|
|
22959
|
+
0.5,
|
|
22960
|
+
-0.5,
|
|
22961
|
+
-0.5,
|
|
22962
|
+
0.5,
|
|
22963
|
+
0.5,
|
|
22964
|
+
0.5,
|
|
22965
|
+
-0.5
|
|
22966
|
+
])
|
|
22967
|
+
}, _obj[VertexBuffer.ColorKind] = {
|
|
22968
|
+
type: glContext.FLOAT,
|
|
22969
|
+
size: 4,
|
|
22970
|
+
data: new Float32Array([
|
|
22971
|
+
1,
|
|
22972
|
+
1,
|
|
22973
|
+
1,
|
|
22974
|
+
1,
|
|
22975
|
+
1,
|
|
22976
|
+
1,
|
|
22977
|
+
1,
|
|
22978
|
+
1,
|
|
22979
|
+
1,
|
|
22980
|
+
1,
|
|
22981
|
+
1,
|
|
22982
|
+
1,
|
|
22983
|
+
1,
|
|
22984
|
+
1,
|
|
22985
|
+
1,
|
|
22986
|
+
1
|
|
22987
|
+
])
|
|
22988
|
+
}, _obj[VertexBuffer.UVKind] = {
|
|
22989
|
+
size: 2,
|
|
22990
|
+
offset: 0,
|
|
22991
|
+
type: glContext.FLOAT,
|
|
22992
|
+
data: new Float32Array([
|
|
22993
|
+
0,
|
|
22994
|
+
1,
|
|
22995
|
+
0,
|
|
22996
|
+
0,
|
|
22997
|
+
1,
|
|
22998
|
+
1,
|
|
22999
|
+
1,
|
|
23000
|
+
0
|
|
23001
|
+
])
|
|
23002
|
+
}, _obj),
|
|
22356
23003
|
indices: {
|
|
22357
23004
|
data: new Uint16Array([
|
|
22358
23005
|
0,
|
|
@@ -22361,11 +23008,11 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
22361
23008
|
2,
|
|
22362
23009
|
1,
|
|
22363
23010
|
3
|
|
22364
|
-
])
|
|
22365
|
-
releasable: true
|
|
23011
|
+
])
|
|
22366
23012
|
},
|
|
22367
23013
|
mode: glContext.TRIANGLES,
|
|
22368
|
-
drawCount: 6
|
|
23014
|
+
drawCount: 6,
|
|
23015
|
+
bufferUsage: glContext.DYNAMIC_DRAW
|
|
22369
23016
|
});
|
|
22370
23017
|
this.coloredMaterial = Material.create(this.engine, {
|
|
22371
23018
|
shader: {
|
|
@@ -22453,9 +23100,9 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
22453
23100
|
var colorsArray = new Float32Array(this.colors);
|
|
22454
23101
|
var uvsArray = new Float32Array(this.uvs);
|
|
22455
23102
|
var indicesArray = new Uint16Array(this.indices);
|
|
22456
|
-
this.
|
|
22457
|
-
this.
|
|
22458
|
-
this.
|
|
23103
|
+
this.updateAttributeData(VertexBuffer.PositionKind, verticesArray, 2);
|
|
23104
|
+
this.updateAttributeData(VertexBuffer.ColorKind, colorsArray, 4);
|
|
23105
|
+
this.updateAttributeData(VertexBuffer.UVKind, uvsArray, 2);
|
|
22459
23106
|
this.geometry.setIndexData(indicesArray);
|
|
22460
23107
|
this.geometry.setDrawCount(this.currentIndexCount);
|
|
22461
23108
|
var material;
|
|
@@ -22473,6 +23120,18 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
22473
23120
|
this.colors.length = 0;
|
|
22474
23121
|
this.uvs.length = 0;
|
|
22475
23122
|
};
|
|
23123
|
+
_proto.updateAttributeData = function updateAttributeData(name, data, size) {
|
|
23124
|
+
var _this_geometry_getVertexBuffer;
|
|
23125
|
+
var dataBuffer = (_this_geometry_getVertexBuffer = this.geometry.getVertexBuffer(name)) == null ? void 0 : _this_geometry_getVertexBuffer.getBuffer();
|
|
23126
|
+
if (dataBuffer && data.byteLength > dataBuffer.capacity) {
|
|
23127
|
+
this.geometry.setVerticesBuffer(new VertexBuffer(this.engine, data, name, {
|
|
23128
|
+
updatable: true,
|
|
23129
|
+
size: size
|
|
23130
|
+
}));
|
|
23131
|
+
return;
|
|
23132
|
+
}
|
|
23133
|
+
this.geometry.setAttributeData(name, data);
|
|
23134
|
+
};
|
|
22476
23135
|
/**
|
|
22477
23136
|
* 线段顶点按顺序连接 (p0-p1, p1-p2, p2-p3, ...)
|
|
22478
23137
|
* @param points - 点数组,格式 [x1,y1,x2,y2,...],至少需要2个点(4个数值)
|
|
@@ -22842,6 +23501,310 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
22842
23501
|
return Graphics;
|
|
22843
23502
|
}();
|
|
22844
23503
|
|
|
23504
|
+
/**
|
|
23505
|
+
* Mesh 组件
|
|
23506
|
+
*/ var MeshComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
23507
|
+
_inherits(MeshComponent, RendererComponent);
|
|
23508
|
+
function MeshComponent(engine) {
|
|
23509
|
+
var _this;
|
|
23510
|
+
_this = RendererComponent.call(this, engine) || this;
|
|
23511
|
+
// TODO 点击测试后续抽象一个 Collider 组件
|
|
23512
|
+
_this.getHitTestParams = function(force) {
|
|
23513
|
+
var worldMatrix = _this.transform.getWorldMatrix();
|
|
23514
|
+
_this.boundingBoxInfo.setGeometry(_this.geometry, worldMatrix);
|
|
23515
|
+
var area = _this.boundingBoxInfo.getRawBoundingBoxTriangle();
|
|
23516
|
+
if (area) {
|
|
23517
|
+
return {
|
|
23518
|
+
type: area.type,
|
|
23519
|
+
triangles: area.area,
|
|
23520
|
+
clipMasks: _this.frameClipMasks
|
|
23521
|
+
};
|
|
23522
|
+
}
|
|
23523
|
+
};
|
|
23524
|
+
return _this;
|
|
23525
|
+
}
|
|
23526
|
+
var _proto = MeshComponent.prototype;
|
|
23527
|
+
_proto.render = function render(renderer) {
|
|
23528
|
+
this.maskManager.drawStencilMask(renderer, this);
|
|
23529
|
+
for(var i = 0; i < this.materials.length; i++){
|
|
23530
|
+
var material = this.materials[i];
|
|
23531
|
+
renderer.drawGeometry(this.geometry, this.transform.getWorldMatrix(), material, i);
|
|
23532
|
+
}
|
|
23533
|
+
};
|
|
23534
|
+
_proto.drawStencilMask = function drawStencilMask(maskRef) {
|
|
23535
|
+
if (!this.isActiveAndEnabled) {
|
|
23536
|
+
return;
|
|
23537
|
+
}
|
|
23538
|
+
for(var i = 0; i < this.materials.length; i++){
|
|
23539
|
+
var material = this.materials[i];
|
|
23540
|
+
this.maskManager.drawGeometryMask(this.engine.renderer, this.geometry, this.transform.getWorldMatrix(), material, maskRef, i);
|
|
23541
|
+
}
|
|
23542
|
+
};
|
|
23543
|
+
_proto.getBoundingBox = function getBoundingBox() {
|
|
23544
|
+
var worldMatrix = this.transform.getWorldMatrix();
|
|
23545
|
+
this.boundingBoxInfo.setGeometry(this.geometry, worldMatrix);
|
|
23546
|
+
var boundingBox = this.boundingBoxInfo.getBoundingBoxTriangle();
|
|
23547
|
+
return boundingBox;
|
|
23548
|
+
};
|
|
23549
|
+
_proto.getBoundingBoxInfo = function getBoundingBoxInfo() {
|
|
23550
|
+
var positionArray = this.geometry.getAttributeData(VertexBuffer.PositionKind);
|
|
23551
|
+
if (positionArray) {
|
|
23552
|
+
var minMaxResult = extractMinAndMax(positionArray, 0, positionArray.length / 3);
|
|
23553
|
+
minMaxResult.minimum.x *= this.transform.size.x;
|
|
23554
|
+
minMaxResult.minimum.y *= this.transform.size.y;
|
|
23555
|
+
minMaxResult.maximum.x *= this.transform.size.x;
|
|
23556
|
+
minMaxResult.maximum.y *= this.transform.size.y;
|
|
23557
|
+
this.boundingBoxInfo.reConstruct(minMaxResult.minimum, minMaxResult.maximum, this.transform.getWorldMatrix());
|
|
23558
|
+
}
|
|
23559
|
+
return this.boundingBoxInfo;
|
|
23560
|
+
};
|
|
23561
|
+
_proto.fromData = function fromData(data) {
|
|
23562
|
+
RendererComponent.prototype.fromData.call(this, data);
|
|
23563
|
+
var maskOptions = data.mask;
|
|
23564
|
+
if (maskOptions) {
|
|
23565
|
+
this.maskManager.setMaskOptions(this.engine, maskOptions);
|
|
23566
|
+
}
|
|
23567
|
+
};
|
|
23568
|
+
return MeshComponent;
|
|
23569
|
+
}(RendererComponent);
|
|
23570
|
+
__decorate([
|
|
23571
|
+
serialize()
|
|
23572
|
+
], MeshComponent.prototype, "geometry", void 0);
|
|
23573
|
+
|
|
23574
|
+
exports.EffectComponent = /*#__PURE__*/ function(MeshComponent) {
|
|
23575
|
+
_inherits(EffectComponent, MeshComponent);
|
|
23576
|
+
function EffectComponent(engine) {
|
|
23577
|
+
var _this;
|
|
23578
|
+
_this = MeshComponent.call(this, engine) || this;
|
|
23579
|
+
_this.time = 0;
|
|
23580
|
+
_this.name = "EffectComponent";
|
|
23581
|
+
return _this;
|
|
23582
|
+
}
|
|
23583
|
+
var _proto = EffectComponent.prototype;
|
|
23584
|
+
_proto.onStart = function onStart() {
|
|
23585
|
+
this.item.getHitTestParams = this.getHitTestParams;
|
|
23586
|
+
};
|
|
23587
|
+
_proto.onUpdate = function onUpdate(dt) {
|
|
23588
|
+
var time = this.time;
|
|
23589
|
+
var _this_material_getVector4;
|
|
23590
|
+
var _Time = (_this_material_getVector4 = this.material.getVector4("_Time")) != null ? _this_material_getVector4 : new Vector4();
|
|
23591
|
+
this.material.setVector4("_Time", _Time.set(time / 20, time, time * 2, time * 3));
|
|
23592
|
+
this.time += dt / 1000;
|
|
23593
|
+
};
|
|
23594
|
+
_proto.fromData = function fromData(data) {
|
|
23595
|
+
MeshComponent.prototype.fromData.call(this, data);
|
|
23596
|
+
this.material = this.materials[0];
|
|
23597
|
+
};
|
|
23598
|
+
return EffectComponent;
|
|
23599
|
+
}(MeshComponent);
|
|
23600
|
+
exports.EffectComponent = __decorate([
|
|
23601
|
+
effectsClass(DataType.EffectComponent)
|
|
23602
|
+
], exports.EffectComponent);
|
|
23603
|
+
|
|
23604
|
+
var tempVector3 = new Vector3(0, 0, 0);
|
|
23605
|
+
var tempVector3Second = new Vector3(0, 0, 0);
|
|
23606
|
+
var ConstraintTarget = function ConstraintTarget() {
|
|
23607
|
+
this.target = null;
|
|
23608
|
+
this.weight = 1.0;
|
|
23609
|
+
};
|
|
23610
|
+
exports.PositionConstraint = /*#__PURE__*/ function(Component) {
|
|
23611
|
+
_inherits(PositionConstraint, Component);
|
|
23612
|
+
function PositionConstraint() {
|
|
23613
|
+
var _this;
|
|
23614
|
+
_this = Component.apply(this, arguments) || this;
|
|
23615
|
+
/**
|
|
23616
|
+
* 初始位置(当前元素的初始世界位置)
|
|
23617
|
+
*/ _this.positionAtRest = new Vector3(0, 0, 0);
|
|
23618
|
+
/**
|
|
23619
|
+
* 位置偏移
|
|
23620
|
+
*/ _this.positionOffset = new Vector3(0, 0, 0);
|
|
23621
|
+
/**
|
|
23622
|
+
* 约束权重 (0-1)
|
|
23623
|
+
*/ _this.weight = 1.0;
|
|
23624
|
+
/**
|
|
23625
|
+
* 是否约束 X 轴
|
|
23626
|
+
*/ _this.constrainX = true;
|
|
23627
|
+
/**
|
|
23628
|
+
* 是否约束 Y 轴
|
|
23629
|
+
*/ _this.constrainY = true;
|
|
23630
|
+
/**
|
|
23631
|
+
* 是否约束 Z 轴
|
|
23632
|
+
*/ _this.constrainZ = true;
|
|
23633
|
+
/**
|
|
23634
|
+
* 约束目标
|
|
23635
|
+
*/ _this.targets = [];
|
|
23636
|
+
return _this;
|
|
23637
|
+
}
|
|
23638
|
+
var _proto = PositionConstraint.prototype;
|
|
23639
|
+
_proto.onStart = function onStart() {
|
|
23640
|
+
// 保存当前元素的初始世界位置
|
|
23641
|
+
var pos = this.item.transform.getWorldPosition();
|
|
23642
|
+
this.positionAtRest.copyFrom(pos);
|
|
23643
|
+
};
|
|
23644
|
+
_proto.onUpdate = function onUpdate(dt) {
|
|
23645
|
+
if (this.targets.length === 0) {
|
|
23646
|
+
return;
|
|
23647
|
+
}
|
|
23648
|
+
// 重置 tempVector3 用于计算融合位置
|
|
23649
|
+
tempVector3.set(0, 0, 0);
|
|
23650
|
+
var totalWeight = 0;
|
|
23651
|
+
// 计算所有目标的加权平均位置
|
|
23652
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(this.targets), _step; !(_step = _iterator()).done;){
|
|
23653
|
+
var constraintTarget = _step.value;
|
|
23654
|
+
if (constraintTarget.target) {
|
|
23655
|
+
var targetPos = constraintTarget.target.transform.getWorldPosition();
|
|
23656
|
+
var weight = constraintTarget.weight;
|
|
23657
|
+
tempVector3.x += targetPos.x * weight;
|
|
23658
|
+
tempVector3.y += targetPos.y * weight;
|
|
23659
|
+
tempVector3.z += targetPos.z * weight;
|
|
23660
|
+
totalWeight += weight;
|
|
23661
|
+
}
|
|
23662
|
+
}
|
|
23663
|
+
// 归一化加权位置
|
|
23664
|
+
if (totalWeight > 0) {
|
|
23665
|
+
tempVector3.x /= totalWeight;
|
|
23666
|
+
tempVector3.y /= totalWeight;
|
|
23667
|
+
tempVector3.z /= totalWeight;
|
|
23668
|
+
}
|
|
23669
|
+
// 应用偏移
|
|
23670
|
+
tempVector3.x += this.positionOffset.x;
|
|
23671
|
+
tempVector3.y += this.positionOffset.y;
|
|
23672
|
+
tempVector3.z += this.positionOffset.z;
|
|
23673
|
+
// 根据全局权重在初始位置和融合位置之间插值,结果存入 tempVector3Second
|
|
23674
|
+
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));
|
|
23675
|
+
// 应用轴约束,复用 tempVector3 存储当前位置
|
|
23676
|
+
tempVector3.copyFrom(this.item.transform.getWorldPosition());
|
|
23677
|
+
var finalX = this.constrainX ? tempVector3Second.x : tempVector3.x;
|
|
23678
|
+
var finalY = this.constrainY ? tempVector3Second.y : tempVector3.y;
|
|
23679
|
+
var finalZ = this.constrainZ ? tempVector3Second.z : tempVector3.z;
|
|
23680
|
+
// 设置新的世界位置
|
|
23681
|
+
this.item.transform.setWorldPosition(finalX, finalY, finalZ);
|
|
23682
|
+
};
|
|
23683
|
+
/**
|
|
23684
|
+
* 添加约束目标
|
|
23685
|
+
* @param target - 目标元素
|
|
23686
|
+
* @param weight - 权重值 (0-1)
|
|
23687
|
+
*/ _proto.addTarget = function addTarget(target, weight) {
|
|
23688
|
+
if (weight === void 0) weight = 1.0;
|
|
23689
|
+
var constraintTarget = new ConstraintTarget();
|
|
23690
|
+
constraintTarget.target = target;
|
|
23691
|
+
constraintTarget.weight = Math.max(0, Math.min(1, weight));
|
|
23692
|
+
this.targets.push(constraintTarget);
|
|
23693
|
+
};
|
|
23694
|
+
/**
|
|
23695
|
+
* 移除约束目标
|
|
23696
|
+
* @param target - 要移除的目标元素
|
|
23697
|
+
*/ _proto.removeTarget = function removeTarget(target) {
|
|
23698
|
+
var index = this.targets.findIndex(function(ct) {
|
|
23699
|
+
return ct.target === target;
|
|
23700
|
+
});
|
|
23701
|
+
if (index !== -1) {
|
|
23702
|
+
this.targets.splice(index, 1);
|
|
23703
|
+
}
|
|
23704
|
+
};
|
|
23705
|
+
/**
|
|
23706
|
+
* 清除所有约束目标
|
|
23707
|
+
*/ _proto.clearTargets = function clearTargets() {
|
|
23708
|
+
this.targets = [];
|
|
23709
|
+
};
|
|
23710
|
+
/**
|
|
23711
|
+
* 设置位置偏移
|
|
23712
|
+
* @param x - X 轴偏移
|
|
23713
|
+
* @param y - Y 轴偏移
|
|
23714
|
+
* @param z - Z 轴偏移
|
|
23715
|
+
*/ _proto.setPositionOffset = function setPositionOffset(x, y, z) {
|
|
23716
|
+
this.positionOffset.set(x, y, z);
|
|
23717
|
+
};
|
|
23718
|
+
/**
|
|
23719
|
+
* 设置全局约束权重
|
|
23720
|
+
* @param weight - 权重值 (0-1),0 表示保持初始位置,1 表示完全跟随目标
|
|
23721
|
+
*/ _proto.setWeight = function setWeight(weight) {
|
|
23722
|
+
this.weight = Math.max(0, Math.min(1, weight));
|
|
23723
|
+
};
|
|
23724
|
+
/**
|
|
23725
|
+
* 线性插值
|
|
23726
|
+
* @param start - 起始值
|
|
23727
|
+
* @param end - 结束值
|
|
23728
|
+
* @param t - 插值因子 (0-1)
|
|
23729
|
+
*/ _proto.lerp = function lerp(start, end, t) {
|
|
23730
|
+
return start + (end - start) * t;
|
|
23731
|
+
};
|
|
23732
|
+
_proto.fromData = function fromData(data) {
|
|
23733
|
+
Component.prototype.fromData.call(this, data);
|
|
23734
|
+
// Deserialize all properties
|
|
23735
|
+
this.positionAtRest.copyFrom(data.positionAtRest);
|
|
23736
|
+
this.positionOffset.copyFrom(data.positionOffset);
|
|
23737
|
+
this.weight = data.weight;
|
|
23738
|
+
this.constrainX = data.constrainX;
|
|
23739
|
+
this.constrainY = data.constrainY;
|
|
23740
|
+
this.constrainZ = data.constrainZ;
|
|
23741
|
+
this.targets = [];
|
|
23742
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(data.targets), _step; !(_step = _iterator()).done;){
|
|
23743
|
+
var targetData = _step.value;
|
|
23744
|
+
var constraintTarget = new ConstraintTarget();
|
|
23745
|
+
constraintTarget.target = this.engine.findObject(targetData.target);
|
|
23746
|
+
constraintTarget.weight = targetData.weight;
|
|
23747
|
+
this.targets.push(constraintTarget);
|
|
23748
|
+
}
|
|
23749
|
+
};
|
|
23750
|
+
return PositionConstraint;
|
|
23751
|
+
}(Component);
|
|
23752
|
+
exports.PositionConstraint = __decorate([
|
|
23753
|
+
effectsClass("PositionConstraint")
|
|
23754
|
+
], exports.PositionConstraint);
|
|
23755
|
+
|
|
23756
|
+
exports.PostProcessVolume = /*#__PURE__*/ function(Component) {
|
|
23757
|
+
_inherits(PostProcessVolume, Component);
|
|
23758
|
+
function PostProcessVolume(engine) {
|
|
23759
|
+
var _this;
|
|
23760
|
+
_this = Component.call(this, engine) || this;
|
|
23761
|
+
_this.bloom = {
|
|
23762
|
+
threshold: 0,
|
|
23763
|
+
intensity: 0,
|
|
23764
|
+
active: false
|
|
23765
|
+
};
|
|
23766
|
+
_this.vignette = {
|
|
23767
|
+
intensity: 0,
|
|
23768
|
+
smoothness: 0,
|
|
23769
|
+
roundness: 0,
|
|
23770
|
+
active: false
|
|
23771
|
+
};
|
|
23772
|
+
_this.tonemapping = {
|
|
23773
|
+
active: false
|
|
23774
|
+
};
|
|
23775
|
+
_this.colorAdjustments = {
|
|
23776
|
+
brightness: 0,
|
|
23777
|
+
saturation: 0,
|
|
23778
|
+
contrast: 0,
|
|
23779
|
+
active: false
|
|
23780
|
+
};
|
|
23781
|
+
return _this;
|
|
23782
|
+
}
|
|
23783
|
+
var _proto = PostProcessVolume.prototype;
|
|
23784
|
+
_proto.onStart = function onStart() {
|
|
23785
|
+
var composition = this.item.composition;
|
|
23786
|
+
if (composition) {
|
|
23787
|
+
composition.renderFrame.globalVolume = this;
|
|
23788
|
+
}
|
|
23789
|
+
};
|
|
23790
|
+
return PostProcessVolume;
|
|
23791
|
+
}(Component);
|
|
23792
|
+
__decorate([
|
|
23793
|
+
serialize()
|
|
23794
|
+
], exports.PostProcessVolume.prototype, "bloom", void 0);
|
|
23795
|
+
__decorate([
|
|
23796
|
+
serialize()
|
|
23797
|
+
], exports.PostProcessVolume.prototype, "vignette", void 0);
|
|
23798
|
+
__decorate([
|
|
23799
|
+
serialize()
|
|
23800
|
+
], exports.PostProcessVolume.prototype, "tonemapping", void 0);
|
|
23801
|
+
__decorate([
|
|
23802
|
+
serialize()
|
|
23803
|
+
], exports.PostProcessVolume.prototype, "colorAdjustments", void 0);
|
|
23804
|
+
exports.PostProcessVolume = __decorate([
|
|
23805
|
+
effectsClass(DataType.PostProcessVolume)
|
|
23806
|
+
], exports.PostProcessVolume);
|
|
23807
|
+
|
|
22845
23808
|
/**
|
|
22846
23809
|
* @since 2.7.0
|
|
22847
23810
|
*/ var MaskableGraphic = /*#__PURE__*/ function(RendererComponent) {
|
|
@@ -22880,42 +23843,40 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
22880
23843
|
side: SideMode.DOUBLE,
|
|
22881
23844
|
mask: 0
|
|
22882
23845
|
};
|
|
23846
|
+
var _obj;
|
|
22883
23847
|
_this.defaultGeometry = Geometry.create(_this.engine, {
|
|
22884
|
-
attributes: {
|
|
22885
|
-
|
|
22886
|
-
|
|
22887
|
-
|
|
22888
|
-
|
|
22889
|
-
|
|
22890
|
-
|
|
22891
|
-
|
|
22892
|
-
|
|
22893
|
-
|
|
22894
|
-
|
|
22895
|
-
|
|
22896
|
-
|
|
22897
|
-
|
|
22898
|
-
|
|
22899
|
-
|
|
22900
|
-
|
|
22901
|
-
|
|
22902
|
-
|
|
22903
|
-
|
|
22904
|
-
|
|
22905
|
-
|
|
22906
|
-
|
|
22907
|
-
|
|
22908
|
-
|
|
22909
|
-
|
|
22910
|
-
|
|
22911
|
-
|
|
22912
|
-
|
|
22913
|
-
|
|
22914
|
-
|
|
22915
|
-
|
|
22916
|
-
])
|
|
22917
|
-
}
|
|
22918
|
-
},
|
|
23848
|
+
attributes: (_obj = {}, _obj[VertexBuffer.PositionKind] = {
|
|
23849
|
+
type: glContext.FLOAT,
|
|
23850
|
+
size: 3,
|
|
23851
|
+
data: new Float32Array([
|
|
23852
|
+
-0.5,
|
|
23853
|
+
0.5,
|
|
23854
|
+
0,
|
|
23855
|
+
-0.5,
|
|
23856
|
+
-0.5,
|
|
23857
|
+
0,
|
|
23858
|
+
0.5,
|
|
23859
|
+
0.5,
|
|
23860
|
+
0,
|
|
23861
|
+
0.5,
|
|
23862
|
+
-0.5,
|
|
23863
|
+
0
|
|
23864
|
+
])
|
|
23865
|
+
}, _obj[VertexBuffer.UVKind] = {
|
|
23866
|
+
size: 2,
|
|
23867
|
+
offset: 0,
|
|
23868
|
+
type: glContext.FLOAT,
|
|
23869
|
+
data: new Float32Array([
|
|
23870
|
+
0,
|
|
23871
|
+
1,
|
|
23872
|
+
0,
|
|
23873
|
+
0,
|
|
23874
|
+
1,
|
|
23875
|
+
1,
|
|
23876
|
+
1,
|
|
23877
|
+
0
|
|
23878
|
+
])
|
|
23879
|
+
}, _obj),
|
|
22919
23880
|
indices: {
|
|
22920
23881
|
data: new Uint16Array([
|
|
22921
23882
|
0,
|
|
@@ -22924,11 +23885,11 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
22924
23885
|
2,
|
|
22925
23886
|
1,
|
|
22926
23887
|
3
|
|
22927
|
-
])
|
|
22928
|
-
releasable: true
|
|
23888
|
+
])
|
|
22929
23889
|
},
|
|
22930
23890
|
mode: glContext.TRIANGLES,
|
|
22931
|
-
drawCount: 6
|
|
23891
|
+
drawCount: 6,
|
|
23892
|
+
bufferUsage: glContext.DYNAMIC_DRAW
|
|
22932
23893
|
});
|
|
22933
23894
|
_this.geometry = _this.defaultGeometry;
|
|
22934
23895
|
var material = Material.create(_this.engine, {
|
|
@@ -23037,7 +23998,7 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
23037
23998
|
return boundingBox;
|
|
23038
23999
|
};
|
|
23039
24000
|
_proto.getBoundingBoxInfo = function getBoundingBoxInfo() {
|
|
23040
|
-
var positionArray = this.geometry.getAttributeData(
|
|
24001
|
+
var positionArray = this.geometry.getAttributeData(VertexBuffer.PositionKind);
|
|
23041
24002
|
if (positionArray) {
|
|
23042
24003
|
var minMaxResult = extractMinAndMax(positionArray, 0, positionArray.length / 3);
|
|
23043
24004
|
minMaxResult.minimum.x *= this.transform.size.x;
|
|
@@ -23251,61 +24212,66 @@ exports.FrameComponent = /*#__PURE__*/ function(RendererComponent1) {
|
|
|
23251
24212
|
_this.color = new Color(1, 1, 1, 1);
|
|
23252
24213
|
_this.worldMatrix = new Matrix4();
|
|
23253
24214
|
_this.getHitTestParams = function(force) {
|
|
24215
|
+
if (!force) {
|
|
24216
|
+
return;
|
|
24217
|
+
}
|
|
24218
|
+
// frame 边的四角(局部 [-0.5, 0.5] 经 size 与世界变换)
|
|
23254
24219
|
var sizeMatrix = Matrix4.fromScale(_this.transform.size.x, _this.transform.size.y, 1);
|
|
23255
24220
|
var worldMatrix = sizeMatrix.premultiply(_this.transform.getWorldMatrix());
|
|
23256
|
-
|
|
23257
|
-
|
|
23258
|
-
|
|
23259
|
-
|
|
23260
|
-
|
|
23261
|
-
|
|
23262
|
-
|
|
23263
|
-
|
|
23264
|
-
|
|
23265
|
-
|
|
23266
|
-
|
|
24221
|
+
var toWorld = function(x, y) {
|
|
24222
|
+
return worldMatrix.transformPoint(new Vector3(x, y, 0), new Vector3());
|
|
24223
|
+
};
|
|
24224
|
+
var TL = toWorld(-0.5, 0.5);
|
|
24225
|
+
var TR = toWorld(0.5, 0.5);
|
|
24226
|
+
var BR = toWorld(0.5, -0.5);
|
|
24227
|
+
var BL = toWorld(-0.5, -0.5);
|
|
24228
|
+
// 命中带为屏幕像素恒定的环带,中心落在 frame 边上,仅边缘可命中(内部镂空)
|
|
24229
|
+
var thickness = _this.getBorderWorldThickness(TL, TR);
|
|
24230
|
+
var triangles = _this.getBorderTriangles(TL, TR, BR, BL, thickness);
|
|
24231
|
+
return {
|
|
24232
|
+
type: exports.HitTestType.triangle,
|
|
24233
|
+
triangles: triangles,
|
|
24234
|
+
clipMasks: _this.frameClipMasks
|
|
24235
|
+
};
|
|
23267
24236
|
};
|
|
23268
24237
|
return _this;
|
|
23269
24238
|
}
|
|
23270
24239
|
var _proto = FrameComponent.prototype;
|
|
23271
24240
|
_proto.onAwake = function onAwake() {
|
|
24241
|
+
var _obj;
|
|
23272
24242
|
this.clipGeometry = Geometry.create(this.engine, {
|
|
23273
|
-
attributes: {
|
|
23274
|
-
|
|
23275
|
-
|
|
23276
|
-
|
|
23277
|
-
|
|
23278
|
-
|
|
23279
|
-
|
|
23280
|
-
|
|
23281
|
-
|
|
23282
|
-
|
|
23283
|
-
|
|
23284
|
-
|
|
23285
|
-
|
|
23286
|
-
|
|
23287
|
-
|
|
23288
|
-
|
|
23289
|
-
|
|
23290
|
-
|
|
23291
|
-
|
|
23292
|
-
|
|
23293
|
-
|
|
23294
|
-
|
|
23295
|
-
|
|
23296
|
-
|
|
23297
|
-
|
|
23298
|
-
|
|
23299
|
-
|
|
23300
|
-
|
|
23301
|
-
|
|
23302
|
-
|
|
23303
|
-
|
|
23304
|
-
|
|
23305
|
-
0
|
|
23306
|
-
])
|
|
23307
|
-
}
|
|
23308
|
-
},
|
|
24243
|
+
attributes: (_obj = {}, _obj[VertexBuffer.PositionKind] = {
|
|
24244
|
+
type: glContext.FLOAT,
|
|
24245
|
+
size: 3,
|
|
24246
|
+
data: new Float32Array([
|
|
24247
|
+
-0.5,
|
|
24248
|
+
0.5,
|
|
24249
|
+
0,
|
|
24250
|
+
-0.5,
|
|
24251
|
+
-0.5,
|
|
24252
|
+
0,
|
|
24253
|
+
0.5,
|
|
24254
|
+
0.5,
|
|
24255
|
+
0,
|
|
24256
|
+
0.5,
|
|
24257
|
+
-0.5,
|
|
24258
|
+
0
|
|
24259
|
+
])
|
|
24260
|
+
}, _obj[VertexBuffer.UVKind] = {
|
|
24261
|
+
size: 2,
|
|
24262
|
+
offset: 0,
|
|
24263
|
+
type: glContext.FLOAT,
|
|
24264
|
+
data: new Float32Array([
|
|
24265
|
+
0,
|
|
24266
|
+
1,
|
|
24267
|
+
0,
|
|
24268
|
+
0,
|
|
24269
|
+
1,
|
|
24270
|
+
1,
|
|
24271
|
+
1,
|
|
24272
|
+
0
|
|
24273
|
+
])
|
|
24274
|
+
}, _obj),
|
|
23309
24275
|
indices: {
|
|
23310
24276
|
data: new Uint16Array([
|
|
23311
24277
|
0,
|
|
@@ -23314,8 +24280,7 @@ exports.FrameComponent = /*#__PURE__*/ function(RendererComponent1) {
|
|
|
23314
24280
|
2,
|
|
23315
24281
|
1,
|
|
23316
24282
|
3
|
|
23317
|
-
])
|
|
23318
|
-
releasable: true
|
|
24283
|
+
])
|
|
23319
24284
|
},
|
|
23320
24285
|
mode: glContext.TRIANGLES,
|
|
23321
24286
|
drawCount: 6
|
|
@@ -23365,6 +24330,62 @@ exports.FrameComponent = /*#__PURE__*/ function(RendererComponent1) {
|
|
|
23365
24330
|
this.color.copyFrom(data.color);
|
|
23366
24331
|
}
|
|
23367
24332
|
};
|
|
24333
|
+
/**
|
|
24334
|
+
* 由相机把命中带的屏幕像素厚度换算成世界厚度。对齐 Excalidraw frame 命中阈值:
|
|
24335
|
+
* 描边两侧各 0.85 × DEFAULT_COLLISION_THRESHOLD(≈8px),整条带 ≈13.6px,不受 size/scale/zoom 影响。
|
|
24336
|
+
*/ _proto.getBorderWorldThickness = function getBorderWorldThickness(topLeft, topRight) {
|
|
24337
|
+
var _this_item_composition;
|
|
24338
|
+
var fallbackThickness = 0.05; // 相机不可用时的兜底世界厚度
|
|
24339
|
+
var camera = (_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.camera;
|
|
24340
|
+
if (!camera) {
|
|
24341
|
+
return fallbackThickness;
|
|
24342
|
+
}
|
|
24343
|
+
var screenLeft = camera.worldToScreenPoint(topLeft);
|
|
24344
|
+
var screenRight = camera.worldToScreenPoint(topRight);
|
|
24345
|
+
var pixelDist = Math.hypot(screenRight.x - screenLeft.x, screenRight.y - screenLeft.y);
|
|
24346
|
+
var worldDist = Math.hypot(topRight.x - topLeft.x, topRight.y - topLeft.y) || 1;
|
|
24347
|
+
var pixelPerWorldUnit = pixelDist / worldDist;
|
|
24348
|
+
// 命中带整条宽度(像素):2 × 0.85 × DEFAULT_COLLISION_THRESHOLD,其中 DEFAULT_COLLISION_THRESHOLD ≈ 8
|
|
24349
|
+
var borderPixels = 2 * 0.85 * 8;
|
|
24350
|
+
return pixelPerWorldUnit > 0 ? borderPixels / pixelPerWorldUnit : fallbackThickness;
|
|
24351
|
+
};
|
|
24352
|
+
/**
|
|
24353
|
+
* 构造以 frame 边为中心、给定世界厚度的边框环带三角形(内部镂空)。
|
|
24354
|
+
* 带中心落在 frame 边上:half 向外、half 向内;沿 frame 局部坐标轴偏移以兼容旋转。
|
|
24355
|
+
*/ _proto.getBorderTriangles = function getBorderTriangles(TL, TR, BR, BL, thickness) {
|
|
24356
|
+
// frame 局部坐标轴在世界空间的方向
|
|
24357
|
+
var axisX = TR.clone().subtract(TL).normalize();
|
|
24358
|
+
var axisY = TL.clone().subtract(BL).normalize();
|
|
24359
|
+
var offset = function(corner, dx, dy) {
|
|
24360
|
+
return corner.clone().addScaledVector(axisX, dx).addScaledVector(axisY, dy);
|
|
24361
|
+
};
|
|
24362
|
+
// 外圈向外扩 half、内圈向内收 half,使带中心落在 frame 边上
|
|
24363
|
+
var half = thickness / 2;
|
|
24364
|
+
var outerTL = offset(TL, -half, half);
|
|
24365
|
+
var outerTR = offset(TR, half, half);
|
|
24366
|
+
var outerBR = offset(BR, half, -half);
|
|
24367
|
+
var outerBL = offset(BL, -half, -half);
|
|
24368
|
+
var innerTL = offset(TL, half, -half);
|
|
24369
|
+
var innerTR = offset(TR, -half, -half);
|
|
24370
|
+
var innerBR = offset(BR, -half, half);
|
|
24371
|
+
var innerBL = offset(BL, half, half);
|
|
24372
|
+
// 每条带是一个四边形,拆成 2 个三角形
|
|
24373
|
+
var quad = function(a, b, c, d) {
|
|
24374
|
+
return [
|
|
24375
|
+
{
|
|
24376
|
+
p0: a,
|
|
24377
|
+
p1: b,
|
|
24378
|
+
p2: c
|
|
24379
|
+
},
|
|
24380
|
+
{
|
|
24381
|
+
p0: a,
|
|
24382
|
+
p1: c,
|
|
24383
|
+
p2: d
|
|
24384
|
+
}
|
|
24385
|
+
];
|
|
24386
|
+
};
|
|
24387
|
+
return [].concat(quad(outerTL, outerTR, innerTR, innerTL), quad(outerTR, outerBR, innerBR, innerTR), quad(outerBR, outerBL, innerBL, innerBR), quad(outerBL, outerTL, innerTL, innerBL));
|
|
24388
|
+
};
|
|
23368
24389
|
_proto.setClipRectangle = function setClipRectangle() {
|
|
23369
24390
|
this.setClipRectangleRecursive(this.item);
|
|
23370
24391
|
};
|
|
@@ -24677,9 +25698,9 @@ var InteractLoader = /*#__PURE__*/ function(Plugin) {
|
|
|
24677
25698
|
return InteractLoader;
|
|
24678
25699
|
}(_wrap_native_super(Plugin));
|
|
24679
25700
|
|
|
24680
|
-
var vertex = "\nprecision highp float;\n\nattribute vec2
|
|
25701
|
+
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";
|
|
24681
25702
|
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";
|
|
24682
|
-
var seed$
|
|
25703
|
+
var seed$3 = 1;
|
|
24683
25704
|
var InteractMesh = /*#__PURE__*/ function() {
|
|
24684
25705
|
function InteractMesh(props, transform, engine) {
|
|
24685
25706
|
this.transform = transform;
|
|
@@ -24734,7 +25755,7 @@ var InteractMesh = /*#__PURE__*/ function() {
|
|
|
24734
25755
|
return material;
|
|
24735
25756
|
};
|
|
24736
25757
|
_proto.createGeometry = function createGeometry() {
|
|
24737
|
-
var indexData = new
|
|
25758
|
+
var indexData = new Uint16Array([
|
|
24738
25759
|
0,
|
|
24739
25760
|
1,
|
|
24740
25761
|
1,
|
|
@@ -24744,24 +25765,23 @@ var InteractMesh = /*#__PURE__*/ function() {
|
|
|
24744
25765
|
3,
|
|
24745
25766
|
0
|
|
24746
25767
|
]);
|
|
25768
|
+
var _obj;
|
|
24747
25769
|
return Geometry.create(this.engine, {
|
|
24748
|
-
attributes: {
|
|
24749
|
-
|
|
24750
|
-
|
|
24751
|
-
|
|
24752
|
-
|
|
24753
|
-
|
|
24754
|
-
|
|
24755
|
-
|
|
24756
|
-
|
|
24757
|
-
|
|
24758
|
-
|
|
24759
|
-
|
|
24760
|
-
|
|
24761
|
-
|
|
24762
|
-
|
|
24763
|
-
}
|
|
24764
|
-
},
|
|
25770
|
+
attributes: (_obj = {}, _obj[VertexBuffer.PositionKind] = {
|
|
25771
|
+
size: 2,
|
|
25772
|
+
offset: 0,
|
|
25773
|
+
stride: 2 * Float32Array.BYTES_PER_ELEMENT,
|
|
25774
|
+
data: new Float32Array([
|
|
25775
|
+
-0.5,
|
|
25776
|
+
0.5,
|
|
25777
|
+
0.5,
|
|
25778
|
+
0.5,
|
|
25779
|
+
0.5,
|
|
25780
|
+
-0.5,
|
|
25781
|
+
-0.5,
|
|
25782
|
+
-0.5
|
|
25783
|
+
])
|
|
25784
|
+
}, _obj),
|
|
24765
25785
|
drawCount: indexData.length,
|
|
24766
25786
|
indices: {
|
|
24767
25787
|
data: indexData
|
|
@@ -24772,7 +25792,7 @@ var InteractMesh = /*#__PURE__*/ function() {
|
|
|
24772
25792
|
};
|
|
24773
25793
|
_proto.createMesh = function createMesh(geometry, material) {
|
|
24774
25794
|
return Mesh.create(this.engine, {
|
|
24775
|
-
name: "Interact_preview" + seed$
|
|
25795
|
+
name: "Interact_preview" + seed$3++,
|
|
24776
25796
|
priority: 0,
|
|
24777
25797
|
worldMatrix: Matrix4.fromIdentity(),
|
|
24778
25798
|
geometry: geometry,
|
|
@@ -26688,6 +27708,11 @@ exports.SpritePropertyTrack = __decorate([
|
|
|
26688
27708
|
effectsClass("SpritePropertyTrack")
|
|
26689
27709
|
], exports.SpritePropertyTrack);
|
|
26690
27710
|
|
|
27711
|
+
function _assert_this_initialized(self) {
|
|
27712
|
+
if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
27713
|
+
return self;
|
|
27714
|
+
}
|
|
27715
|
+
|
|
26691
27716
|
var Cone = /*#__PURE__*/ function() {
|
|
26692
27717
|
function Cone(props) {
|
|
26693
27718
|
var _this = this;
|
|
@@ -27769,7 +28794,9 @@ var tmp0 = new Vector3();
|
|
|
27769
28794
|
var tmp1 = new Vector3();
|
|
27770
28795
|
var TrailMesh = /*#__PURE__*/ function() {
|
|
27771
28796
|
function TrailMesh(engine, props) {
|
|
28797
|
+
var _this = this;
|
|
27772
28798
|
this.pointStart = [];
|
|
28799
|
+
this.attributeData = new Map();
|
|
27773
28800
|
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;
|
|
27774
28801
|
var _engine_gpuCapability = engine.gpuCapability, detail = _engine_gpuCapability.detail, level = _engine_gpuCapability.level;
|
|
27775
28802
|
var pointCountPerTrail = Math.max(props.pointCountPerTrail, 2);
|
|
@@ -27852,42 +28879,36 @@ var TrailMesh = /*#__PURE__*/ function() {
|
|
|
27852
28879
|
var maxTriangleCount = (pointCountPerTrail - 1) * maxTrailCount;
|
|
27853
28880
|
var bpe = Float32Array.BYTES_PER_ELEMENT;
|
|
27854
28881
|
var v12 = 12 * bpe;
|
|
28882
|
+
var _obj;
|
|
27855
28883
|
var geometryOptions = {
|
|
27856
|
-
attributes: {
|
|
27857
|
-
|
|
27858
|
-
|
|
27859
|
-
|
|
27860
|
-
|
|
27861
|
-
|
|
27862
|
-
|
|
27863
|
-
|
|
27864
|
-
|
|
27865
|
-
|
|
27866
|
-
|
|
27867
|
-
|
|
27868
|
-
|
|
27869
|
-
|
|
27870
|
-
|
|
27871
|
-
|
|
27872
|
-
|
|
27873
|
-
|
|
27874
|
-
|
|
27875
|
-
|
|
27876
|
-
|
|
27877
|
-
|
|
27878
|
-
|
|
27879
|
-
|
|
27880
|
-
|
|
27881
|
-
|
|
27882
|
-
|
|
27883
|
-
|
|
27884
|
-
},
|
|
27885
|
-
//
|
|
27886
|
-
aDir: {
|
|
27887
|
-
size: 3,
|
|
27888
|
-
data: new Float32Array(maxVertexCount * 3)
|
|
27889
|
-
}
|
|
27890
|
-
},
|
|
28884
|
+
attributes: (_obj = {}, _obj[VertexBuffer.ColorKind] = {
|
|
28885
|
+
size: 4,
|
|
28886
|
+
stride: v12,
|
|
28887
|
+
data: new Float32Array(maxVertexCount * 12)
|
|
28888
|
+
}, _obj.aSeed = {
|
|
28889
|
+
size: 1,
|
|
28890
|
+
stride: v12,
|
|
28891
|
+
offset: 4 * bpe,
|
|
28892
|
+
dataSource: VertexBuffer.ColorKind
|
|
28893
|
+
}, _obj.aInfo = {
|
|
28894
|
+
size: 3,
|
|
28895
|
+
stride: v12,
|
|
28896
|
+
offset: 5 * bpe,
|
|
28897
|
+
dataSource: VertexBuffer.ColorKind
|
|
28898
|
+
}, _obj[VertexBuffer.PositionKind] = {
|
|
28899
|
+
size: 4,
|
|
28900
|
+
stride: v12,
|
|
28901
|
+
offset: 8 * bpe,
|
|
28902
|
+
dataSource: VertexBuffer.ColorKind
|
|
28903
|
+
}, //
|
|
28904
|
+
_obj.aTime = {
|
|
28905
|
+
size: 1,
|
|
28906
|
+
data: new Float32Array(maxVertexCount)
|
|
28907
|
+
}, //
|
|
28908
|
+
_obj.aDir = {
|
|
28909
|
+
size: 3,
|
|
28910
|
+
data: new Float32Array(maxVertexCount * 3)
|
|
28911
|
+
}, _obj),
|
|
27891
28912
|
indices: {
|
|
27892
28913
|
data: new Uint16Array(maxVertexCount * 6)
|
|
27893
28914
|
},
|
|
@@ -27961,6 +28982,13 @@ var TrailMesh = /*#__PURE__*/ function() {
|
|
|
27961
28982
|
this.mesh.worldMatrix = matrix;
|
|
27962
28983
|
}
|
|
27963
28984
|
this.geometry = mesh.firstGeometry();
|
|
28985
|
+
this.geometry.getAttributeNames().forEach(function(name) {
|
|
28986
|
+
var vertexBuffer = _this.geometry.getVertexBuffer(name);
|
|
28987
|
+
var data = _this.geometry.getAttributeData(name);
|
|
28988
|
+
if (vertexBuffer && _instanceof1(data, Float32Array)) {
|
|
28989
|
+
_this.attributeData.set(vertexBuffer.getWrapperBuffer(), data);
|
|
28990
|
+
}
|
|
28991
|
+
});
|
|
27964
28992
|
this.trailCursors = new Uint16Array(maxTrailCount);
|
|
27965
28993
|
}
|
|
27966
28994
|
var _proto = TrailMesh.prototype;
|
|
@@ -27991,8 +29019,8 @@ var TrailMesh = /*#__PURE__*/ function() {
|
|
|
27991
29019
|
var dirData = new Float32Array(6);
|
|
27992
29020
|
dirData.set(dir, 0);
|
|
27993
29021
|
dirData.set(dir, 3);
|
|
27994
|
-
|
|
27995
|
-
|
|
29022
|
+
this.setAttributeSubData("aDir", dirStartIndex, dirData);
|
|
29023
|
+
this.setAttributeSubData("aTime", pointStartIndex * 2, new Float32Array([
|
|
27996
29024
|
time,
|
|
27997
29025
|
time
|
|
27998
29026
|
]));
|
|
@@ -28014,13 +29042,13 @@ var TrailMesh = /*#__PURE__*/ function() {
|
|
|
28014
29042
|
colorData[19] = 1;
|
|
28015
29043
|
colorData.set(positionData, 20);
|
|
28016
29044
|
colorData[23] = -0.5 * size;
|
|
28017
|
-
|
|
29045
|
+
this.setAttributeSubData(VertexBuffer.ColorKind, pointStartIndex * 24, colorData);
|
|
28018
29046
|
if (previousIndex >= 0) {
|
|
28019
29047
|
var bPreviousPoint = this.getTrailPosition(trailIndex, bpreviousIndex, tmp1);
|
|
28020
29048
|
var previousDir = new Float32Array(calculateDirection(bPreviousPoint, previousPoint, position));
|
|
28021
29049
|
var previousDirStartIndex = (trailIndex * pointCountPerTrail + previousIndex) * 6;
|
|
28022
|
-
|
|
28023
|
-
|
|
29050
|
+
this.setAttributeSubData("aDir", previousDirStartIndex, previousDir);
|
|
29051
|
+
this.setAttributeSubData("aDir", previousDirStartIndex + 3, previousDir);
|
|
28024
29052
|
var indicesStart = trailIndex * pointCountPerTrail * 2;
|
|
28025
29053
|
var indicesData = new Uint16Array([
|
|
28026
29054
|
previousIndex * 2 + indicesStart,
|
|
@@ -28043,7 +29071,7 @@ var TrailMesh = /*#__PURE__*/ function() {
|
|
|
28043
29071
|
for(var i = 0; i < len; i++){
|
|
28044
29072
|
startData[i] = trailStart;
|
|
28045
29073
|
}
|
|
28046
|
-
|
|
29074
|
+
this.setAttributeSubData("aTrailStart", trailIndex * startData.length, startData);
|
|
28047
29075
|
} else {
|
|
28048
29076
|
var value = mtl.getFloats("uTrailStart");
|
|
28049
29077
|
if (value != undefined) {
|
|
@@ -28060,8 +29088,7 @@ var TrailMesh = /*#__PURE__*/ function() {
|
|
|
28060
29088
|
var pointCountPerTrail = this.pointCountPerTrail;
|
|
28061
29089
|
if (index >= 0 && index < pointCountPerTrail) {
|
|
28062
29090
|
var startIndex = (trail * pointCountPerTrail + index) * 24 + 8;
|
|
28063
|
-
var data = this.
|
|
28064
|
-
assertExist(data);
|
|
29091
|
+
var data = this.getAttributeData(VertexBuffer.ColorKind);
|
|
28065
29092
|
out.x = data[startIndex];
|
|
28066
29093
|
out.y = data[1 + startIndex];
|
|
28067
29094
|
out.z = data[2 + startIndex];
|
|
@@ -28075,12 +29102,11 @@ var TrailMesh = /*#__PURE__*/ function() {
|
|
|
28075
29102
|
this.geometry.setIndexData(new Uint16Array(indexData.length));
|
|
28076
29103
|
};
|
|
28077
29104
|
_proto.minusTime = function minusTime(time) {
|
|
28078
|
-
var data = this.
|
|
28079
|
-
assertExist(data);
|
|
29105
|
+
var data = this.getAttributeData("aTime");
|
|
28080
29106
|
for(var i = 0; i < data.length; i++){
|
|
28081
29107
|
data[i] -= time;
|
|
28082
29108
|
}
|
|
28083
|
-
this.
|
|
29109
|
+
this.setAttributeData("aTime", data);
|
|
28084
29110
|
this.time -= time;
|
|
28085
29111
|
};
|
|
28086
29112
|
_proto.clearTrail = function clearTrail(index) {
|
|
@@ -28101,6 +29127,35 @@ var TrailMesh = /*#__PURE__*/ function() {
|
|
|
28101
29127
|
this.pointStart[index] = pos;
|
|
28102
29128
|
};
|
|
28103
29129
|
_proto.onUpdate = function onUpdate(escapeTime) {};
|
|
29130
|
+
_proto.getAttributeData = function getAttributeData(name) {
|
|
29131
|
+
var vertexBuffer = this.geometry.getVertexBuffer(name);
|
|
29132
|
+
var data = vertexBuffer && this.attributeData.get(vertexBuffer.getWrapperBuffer());
|
|
29133
|
+
assertExist(data);
|
|
29134
|
+
return data;
|
|
29135
|
+
};
|
|
29136
|
+
_proto.setAttributeData = function setAttributeData(name, data) {
|
|
29137
|
+
var vertexBuffer = this.geometry.getVertexBuffer(name);
|
|
29138
|
+
assertExist(vertexBuffer);
|
|
29139
|
+
this.attributeData.set(vertexBuffer.getWrapperBuffer(), data);
|
|
29140
|
+
this.geometry.setAttributeData(name, data);
|
|
29141
|
+
};
|
|
29142
|
+
_proto.setAttributeSubData = function setAttributeSubData(name, offset, data) {
|
|
29143
|
+
var target = this.getAttributeData(name);
|
|
29144
|
+
target.set(data, offset);
|
|
29145
|
+
this.geometry.setAttributeSubData(name, offset, data);
|
|
29146
|
+
};
|
|
29147
|
+
/**
|
|
29148
|
+
* @internal
|
|
29149
|
+
*/ _proto.rebuild = function rebuild() {
|
|
29150
|
+
if (!this.geometry.isInitialized || this.geometry.isDisposed()) {
|
|
29151
|
+
return;
|
|
29152
|
+
}
|
|
29153
|
+
this.attributeData.forEach(function(data, buffer) {
|
|
29154
|
+
if (!buffer.getData()) {
|
|
29155
|
+
buffer.update(data);
|
|
29156
|
+
}
|
|
29157
|
+
});
|
|
29158
|
+
};
|
|
28104
29159
|
_create_class(TrailMesh, [
|
|
28105
29160
|
{
|
|
28106
29161
|
key: "time",
|
|
@@ -28224,11 +29279,13 @@ var particleUniformTypeMap = {
|
|
|
28224
29279
|
|
|
28225
29280
|
var ParticleMesh = /*#__PURE__*/ function() {
|
|
28226
29281
|
function ParticleMesh(engine, props) {
|
|
29282
|
+
var _this = this;
|
|
28227
29283
|
this.particleCount = 0;
|
|
28228
29284
|
this.cachedRotationVector3 = new Vector3();
|
|
28229
29285
|
this.cachedRotationMatrix = new Matrix3();
|
|
28230
29286
|
this.cachedLinearMove = new Vector3();
|
|
28231
29287
|
this.tempMatrix3 = new Matrix3();
|
|
29288
|
+
this.attributeData = new Map();
|
|
28232
29289
|
this.VERT_MAX_KEY_FRAME_COUNT = 0;
|
|
28233
29290
|
var env = (engine != null ? engine : {}).env;
|
|
28234
29291
|
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;
|
|
@@ -28527,6 +29584,13 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
28527
29584
|
this.anchor = anchor;
|
|
28528
29585
|
this.mesh = mesh;
|
|
28529
29586
|
this.geometry = mesh.firstGeometry();
|
|
29587
|
+
this.geometry.getAttributeNames().forEach(function(name) {
|
|
29588
|
+
var vertexBuffer = _this.geometry.getVertexBuffer(name);
|
|
29589
|
+
var data = _this.geometry.getAttributeData(name);
|
|
29590
|
+
if (vertexBuffer && _instanceof1(data, Float32Array)) {
|
|
29591
|
+
_this.attributeData.set(vertexBuffer.getWrapperBuffer(), data);
|
|
29592
|
+
}
|
|
29593
|
+
});
|
|
28530
29594
|
this.forceTarget = forceTarget;
|
|
28531
29595
|
this.sizeOverLifetime = sizeOverLifetime;
|
|
28532
29596
|
this.speedOverLifetime = speedOverLifetime;
|
|
@@ -28536,6 +29600,7 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
28536
29600
|
this.gravityModifier = gravityModifier;
|
|
28537
29601
|
this.rotationOverLifetime = rotationOverLifetime;
|
|
28538
29602
|
this.maxCount = maxCount;
|
|
29603
|
+
this.maxParticleBufferCount = maxCount;
|
|
28539
29604
|
// this.duration = duration;
|
|
28540
29605
|
this.textureOffsets = textureFlip ? [
|
|
28541
29606
|
0,
|
|
@@ -28569,9 +29634,8 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
28569
29634
|
// // this.mesh.material.setVector4('uParams', new Vector4(+v, this.duration, 0, 0));
|
|
28570
29635
|
// }
|
|
28571
29636
|
_proto.getPointColor = function getPointColor(index) {
|
|
28572
|
-
var data = this.
|
|
29637
|
+
var data = this.getAttributeData("aRot");
|
|
28573
29638
|
var i = index * 32 + 4;
|
|
28574
|
-
assertExist(data);
|
|
28575
29639
|
return [
|
|
28576
29640
|
data[i],
|
|
28577
29641
|
data[i + 1],
|
|
@@ -28580,46 +29644,31 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
28580
29644
|
];
|
|
28581
29645
|
};
|
|
28582
29646
|
_proto.clearPoints = function clearPoints() {
|
|
28583
|
-
this.resetGeometryData(this.geometry);
|
|
28584
29647
|
this.particleCount = 0;
|
|
28585
29648
|
this.geometry.setDrawCount(0);
|
|
28586
|
-
this.maxParticleBufferCount = 0;
|
|
28587
|
-
};
|
|
28588
|
-
_proto.resetGeometryData = function resetGeometryData(geometry) {
|
|
28589
|
-
var names = geometry.getAttributeNames();
|
|
28590
|
-
var index = geometry.getIndexData();
|
|
28591
|
-
for(var i = 0; i < names.length; i++){
|
|
28592
|
-
var name = names[i];
|
|
28593
|
-
var data = geometry.getAttributeData(name);
|
|
28594
|
-
if (data) {
|
|
28595
|
-
// @ts-expect-error
|
|
28596
|
-
geometry.setAttributeData(name, new data.constructor(0));
|
|
28597
|
-
}
|
|
28598
|
-
}
|
|
28599
|
-
// @ts-expect-error
|
|
28600
|
-
geometry.setIndexData(new index.constructor(0));
|
|
28601
29649
|
};
|
|
28602
29650
|
_proto.onUpdate = function onUpdate(dt) {
|
|
28603
|
-
var aPosArray = this.
|
|
29651
|
+
var aPosArray = this.getAttributeData(VertexBuffer.PositionKind); // vector3
|
|
28604
29652
|
var vertexCount = Math.ceil(aPosArray.length / 12);
|
|
28605
29653
|
this.applyTranslation(vertexCount, dt);
|
|
28606
29654
|
this.applyRotation(vertexCount, dt);
|
|
28607
29655
|
this.applyLinearMove(vertexCount, dt);
|
|
28608
29656
|
};
|
|
28609
29657
|
_proto.minusTime = function minusTime(time) {
|
|
28610
|
-
var aOffset = this.
|
|
29658
|
+
var aOffset = this.getAttributeData("aOffset");
|
|
28611
29659
|
for(var i = 0; i < aOffset.length; i += 4){
|
|
28612
29660
|
aOffset[i + 2] -= time;
|
|
28613
29661
|
}
|
|
28614
|
-
this.
|
|
29662
|
+
this.setAttributeData("aOffset", aOffset);
|
|
28615
29663
|
this.time -= time;
|
|
28616
29664
|
};
|
|
28617
29665
|
_proto.removePoint = function removePoint(index) {
|
|
28618
29666
|
if (index < this.particleCount) {
|
|
28619
|
-
this.
|
|
29667
|
+
this.setAttributeSubData("aOffset", index * 16, new Float32Array(16));
|
|
28620
29668
|
}
|
|
28621
29669
|
};
|
|
28622
29670
|
_proto.setPoint = function setPoint(index, point) {
|
|
29671
|
+
var _this = this;
|
|
28623
29672
|
var maxCount = this.maxCount;
|
|
28624
29673
|
if (index < maxCount) {
|
|
28625
29674
|
var particleCount = index + 1;
|
|
@@ -28736,13 +29785,12 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
28736
29785
|
var data = pointData[name];
|
|
28737
29786
|
var attrSize = geometry.getAttributeStride(name) / Float32Array.BYTES_PER_ELEMENT;
|
|
28738
29787
|
if (increaseBuffer) {
|
|
28739
|
-
var baseData =
|
|
28740
|
-
assertExist(baseData);
|
|
29788
|
+
var baseData = _this.getAttributeData(name);
|
|
28741
29789
|
var geoData = enlargeBuffer(baseData, vertexCount * attrSize, maxCount * 4 * attrSize, inc);
|
|
28742
29790
|
geoData.set(data, data.length * index);
|
|
28743
|
-
|
|
29791
|
+
_this.setAttributeData(name, geoData);
|
|
28744
29792
|
} else {
|
|
28745
|
-
|
|
29793
|
+
_this.setAttributeSubData(name, data.length * index, data);
|
|
28746
29794
|
}
|
|
28747
29795
|
});
|
|
28748
29796
|
this.particleCount = Math.max(particleCount, this.particleCount);
|
|
@@ -28751,9 +29799,9 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
28751
29799
|
};
|
|
28752
29800
|
_proto.applyTranslation = function applyTranslation(vertexCount, deltaTime) {
|
|
28753
29801
|
var localTime = this.time;
|
|
28754
|
-
var aTranslationArray = this.
|
|
28755
|
-
var aVelArray = this.
|
|
28756
|
-
var aOffsetArray = this.
|
|
29802
|
+
var aTranslationArray = this.getAttributeData("aTranslation");
|
|
29803
|
+
var aVelArray = this.getAttributeData("aVel"); // vector3
|
|
29804
|
+
var aOffsetArray = this.getAttributeData("aOffset");
|
|
28757
29805
|
if (aTranslationArray.length < vertexCount * 3) {
|
|
28758
29806
|
aTranslationArray = this.expandArray(aTranslationArray, vertexCount * 3);
|
|
28759
29807
|
}
|
|
@@ -28812,13 +29860,13 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
28812
29860
|
aTranslationArray[aTranslationOffset + 11] += aTranslationZ;
|
|
28813
29861
|
}
|
|
28814
29862
|
}
|
|
28815
|
-
this.
|
|
29863
|
+
this.setAttributeData("aTranslation", aTranslationArray);
|
|
28816
29864
|
};
|
|
28817
29865
|
_proto.applyRotation = function applyRotation(vertexCount, deltaTime) {
|
|
28818
|
-
var aRotationArray = this.
|
|
28819
|
-
var aOffsetArray = this.
|
|
28820
|
-
var aRotArray = this.
|
|
28821
|
-
var aSeedArray = this.
|
|
29866
|
+
var aRotationArray = this.getAttributeData("aRotation0");
|
|
29867
|
+
var aOffsetArray = this.getAttributeData("aOffset");
|
|
29868
|
+
var aRotArray = this.getAttributeData("aRot"); // vector3
|
|
29869
|
+
var aSeedArray = this.getAttributeData("aSeed"); // float
|
|
28822
29870
|
var localTime = this.time;
|
|
28823
29871
|
var aRotationMatrix = this.cachedRotationMatrix;
|
|
28824
29872
|
if (aRotationArray.length < vertexCount * 9) {
|
|
@@ -28909,12 +29957,12 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
28909
29957
|
aRotationArray.set(matrixArray, aRotationOffset + 27);
|
|
28910
29958
|
}
|
|
28911
29959
|
}
|
|
28912
|
-
this.
|
|
29960
|
+
this.setAttributeData("aRotation0", aRotationArray);
|
|
28913
29961
|
};
|
|
28914
29962
|
_proto.applyLinearMove = function applyLinearMove(vertexCount, deltaTime) {
|
|
28915
|
-
var aLinearMoveArray = this.
|
|
28916
|
-
var aOffsetArray = this.
|
|
28917
|
-
var aSeedArray = this.
|
|
29963
|
+
var aLinearMoveArray = this.getAttributeData("aLinearMove");
|
|
29964
|
+
var aOffsetArray = this.getAttributeData("aOffset");
|
|
29965
|
+
var aSeedArray = this.getAttributeData("aSeed"); // float
|
|
28918
29966
|
var localTime = this.time;
|
|
28919
29967
|
if (aLinearMoveArray.length < vertexCount * 3) {
|
|
28920
29968
|
aLinearMoveArray = this.expandArray(aLinearMoveArray, vertexCount * 3);
|
|
@@ -28989,7 +30037,36 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
28989
30037
|
aLinearMoveArray[aLinearMoveOffset + 11] = linearMove.z;
|
|
28990
30038
|
}
|
|
28991
30039
|
}
|
|
28992
|
-
this.
|
|
30040
|
+
this.setAttributeData("aLinearMove", aLinearMoveArray);
|
|
30041
|
+
};
|
|
30042
|
+
_proto.getAttributeData = function getAttributeData(name) {
|
|
30043
|
+
var vertexBuffer = this.geometry.getVertexBuffer(name);
|
|
30044
|
+
var data = vertexBuffer && this.attributeData.get(vertexBuffer.getWrapperBuffer());
|
|
30045
|
+
assertExist(data);
|
|
30046
|
+
return data;
|
|
30047
|
+
};
|
|
30048
|
+
_proto.setAttributeData = function setAttributeData(name, data) {
|
|
30049
|
+
var vertexBuffer = this.geometry.getVertexBuffer(name);
|
|
30050
|
+
assertExist(vertexBuffer);
|
|
30051
|
+
this.attributeData.set(vertexBuffer.getWrapperBuffer(), data);
|
|
30052
|
+
this.geometry.setAttributeData(name, data);
|
|
30053
|
+
};
|
|
30054
|
+
_proto.setAttributeSubData = function setAttributeSubData(name, offset, data) {
|
|
30055
|
+
var target = this.getAttributeData(name);
|
|
30056
|
+
target.set(data, offset);
|
|
30057
|
+
this.geometry.setAttributeSubData(name, offset, data);
|
|
30058
|
+
};
|
|
30059
|
+
/**
|
|
30060
|
+
* @internal
|
|
30061
|
+
*/ _proto.rebuild = function rebuild() {
|
|
30062
|
+
if (!this.geometry.isInitialized || this.geometry.isDisposed()) {
|
|
30063
|
+
return;
|
|
30064
|
+
}
|
|
30065
|
+
this.attributeData.forEach(function(data, buffer) {
|
|
30066
|
+
if (!buffer.getData()) {
|
|
30067
|
+
buffer.update(data);
|
|
30068
|
+
}
|
|
30069
|
+
});
|
|
28993
30070
|
};
|
|
28994
30071
|
_proto.expandArray = function expandArray(array, newSize) {
|
|
28995
30072
|
var newArr = new Float32Array(newSize);
|
|
@@ -29001,83 +30078,70 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
29001
30078
|
function generateGeometryProps(maxVertex, useSprite, name) {
|
|
29002
30079
|
var bpe = Float32Array.BYTES_PER_ELEMENT;
|
|
29003
30080
|
var j12 = bpe * 12;
|
|
29004
|
-
var
|
|
29005
|
-
|
|
29006
|
-
|
|
29007
|
-
|
|
29008
|
-
|
|
29009
|
-
|
|
29010
|
-
|
|
29011
|
-
|
|
29012
|
-
|
|
29013
|
-
|
|
29014
|
-
|
|
29015
|
-
|
|
29016
|
-
|
|
29017
|
-
|
|
29018
|
-
|
|
29019
|
-
|
|
29020
|
-
|
|
29021
|
-
|
|
29022
|
-
|
|
29023
|
-
|
|
29024
|
-
|
|
29025
|
-
|
|
29026
|
-
|
|
29027
|
-
|
|
29028
|
-
|
|
29029
|
-
|
|
29030
|
-
|
|
29031
|
-
|
|
29032
|
-
|
|
29033
|
-
|
|
29034
|
-
|
|
29035
|
-
|
|
29036
|
-
|
|
29037
|
-
|
|
29038
|
-
|
|
29039
|
-
|
|
29040
|
-
|
|
29041
|
-
|
|
29042
|
-
|
|
29043
|
-
|
|
29044
|
-
|
|
29045
|
-
|
|
29046
|
-
|
|
29047
|
-
|
|
29048
|
-
|
|
29049
|
-
|
|
29050
|
-
|
|
29051
|
-
|
|
29052
|
-
|
|
29053
|
-
|
|
29054
|
-
|
|
29055
|
-
|
|
29056
|
-
|
|
29057
|
-
|
|
29058
|
-
|
|
29059
|
-
|
|
29060
|
-
|
|
29061
|
-
|
|
29062
|
-
|
|
29063
|
-
|
|
29064
|
-
|
|
29065
|
-
|
|
29066
|
-
|
|
29067
|
-
|
|
29068
|
-
aRotation1: {
|
|
29069
|
-
size: 3,
|
|
29070
|
-
offset: 3 * bpe,
|
|
29071
|
-
stride: 9 * bpe,
|
|
29072
|
-
dataSource: "aRotation0"
|
|
29073
|
-
},
|
|
29074
|
-
aRotation2: {
|
|
29075
|
-
size: 3,
|
|
29076
|
-
offset: 6 * bpe,
|
|
29077
|
-
stride: 9 * bpe,
|
|
29078
|
-
dataSource: "aRotation0"
|
|
29079
|
-
}
|
|
29080
|
-
};
|
|
30081
|
+
var _obj;
|
|
30082
|
+
var attributes = (_obj = {}, _obj[VertexBuffer.PositionKind] = {
|
|
30083
|
+
size: 3,
|
|
30084
|
+
offset: 0,
|
|
30085
|
+
stride: j12,
|
|
30086
|
+
data: new Float32Array(0)
|
|
30087
|
+
}, _obj.aVel = {
|
|
30088
|
+
size: 3,
|
|
30089
|
+
offset: 3 * bpe,
|
|
30090
|
+
stride: j12,
|
|
30091
|
+
dataSource: VertexBuffer.PositionKind
|
|
30092
|
+
}, _obj.aDirX = {
|
|
30093
|
+
size: 3,
|
|
30094
|
+
offset: 6 * bpe,
|
|
30095
|
+
stride: j12,
|
|
30096
|
+
dataSource: VertexBuffer.PositionKind
|
|
30097
|
+
}, _obj.aDirY = {
|
|
30098
|
+
size: 3,
|
|
30099
|
+
offset: 9 * bpe,
|
|
30100
|
+
stride: j12,
|
|
30101
|
+
dataSource: VertexBuffer.PositionKind
|
|
30102
|
+
}, //
|
|
30103
|
+
_obj.aRot = {
|
|
30104
|
+
size: 3,
|
|
30105
|
+
offset: 0,
|
|
30106
|
+
stride: 8 * bpe,
|
|
30107
|
+
data: new Float32Array(0)
|
|
30108
|
+
}, _obj.aSeed = {
|
|
30109
|
+
size: 1,
|
|
30110
|
+
offset: 3 * bpe,
|
|
30111
|
+
stride: 8 * bpe,
|
|
30112
|
+
dataSource: "aRot"
|
|
30113
|
+
}, _obj[VertexBuffer.ColorKind] = {
|
|
30114
|
+
size: 4,
|
|
30115
|
+
offset: 4 * bpe,
|
|
30116
|
+
stride: 8 * bpe,
|
|
30117
|
+
dataSource: "aRot"
|
|
30118
|
+
}, //
|
|
30119
|
+
_obj.aOffset = {
|
|
30120
|
+
size: 4,
|
|
30121
|
+
stride: 4 * bpe,
|
|
30122
|
+
data: new Float32Array(0)
|
|
30123
|
+
}, _obj.aTranslation = {
|
|
30124
|
+
size: 3,
|
|
30125
|
+
data: new Float32Array(0)
|
|
30126
|
+
}, _obj.aLinearMove = {
|
|
30127
|
+
size: 3,
|
|
30128
|
+
data: new Float32Array(0)
|
|
30129
|
+
}, _obj.aRotation0 = {
|
|
30130
|
+
size: 3,
|
|
30131
|
+
offset: 0,
|
|
30132
|
+
stride: 9 * bpe,
|
|
30133
|
+
data: new Float32Array(0)
|
|
30134
|
+
}, _obj.aRotation1 = {
|
|
30135
|
+
size: 3,
|
|
30136
|
+
offset: 3 * bpe,
|
|
30137
|
+
stride: 9 * bpe,
|
|
30138
|
+
dataSource: "aRotation0"
|
|
30139
|
+
}, _obj.aRotation2 = {
|
|
30140
|
+
size: 3,
|
|
30141
|
+
offset: 6 * bpe,
|
|
30142
|
+
stride: 9 * bpe,
|
|
30143
|
+
dataSource: "aRotation0"
|
|
30144
|
+
}, _obj);
|
|
29081
30145
|
if (useSprite) {
|
|
29082
30146
|
attributes["aSprite"] = {
|
|
29083
30147
|
size: 3,
|
|
@@ -29088,10 +30152,11 @@ function generateGeometryProps(maxVertex, useSprite, name) {
|
|
|
29088
30152
|
return {
|
|
29089
30153
|
attributes: attributes,
|
|
29090
30154
|
indices: {
|
|
29091
|
-
data: new Uint16Array(
|
|
30155
|
+
data: new Uint16Array(maxVertex / 4 * 6)
|
|
29092
30156
|
},
|
|
29093
30157
|
name: name,
|
|
29094
|
-
maxVertex: maxVertex
|
|
30158
|
+
maxVertex: maxVertex,
|
|
30159
|
+
bufferUsage: exports.BufferUsage.Dynamic
|
|
29095
30160
|
};
|
|
29096
30161
|
}
|
|
29097
30162
|
function getParticleMeshShader(item, gpuCapability, env) {
|
|
@@ -29371,6 +30436,13 @@ function modifyMaxKeyframeShader(shader, maxVertex, maxFrag) {
|
|
|
29371
30436
|
this.materials.push(this.trailMesh.mesh.material);
|
|
29372
30437
|
}
|
|
29373
30438
|
};
|
|
30439
|
+
/**
|
|
30440
|
+
* @internal
|
|
30441
|
+
*/ _proto.rebuild = function rebuild() {
|
|
30442
|
+
var _this_trailMesh;
|
|
30443
|
+
this.particleMesh.rebuild();
|
|
30444
|
+
(_this_trailMesh = this.trailMesh) == null ? void 0 : _this_trailMesh.rebuild();
|
|
30445
|
+
};
|
|
29374
30446
|
_proto.reset = function reset() {
|
|
29375
30447
|
var _this_trailMesh;
|
|
29376
30448
|
this.particleMesh.clearPoints();
|
|
@@ -29470,6 +30542,7 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
|
|
|
29470
30542
|
};
|
|
29471
30543
|
}
|
|
29472
30544
|
};
|
|
30545
|
+
engine.addParticleSystem(_assert_this_initialized(_this));
|
|
29473
30546
|
_this.maskManager = new MaskProcessor();
|
|
29474
30547
|
if (props) {
|
|
29475
30548
|
_this.fromData(props);
|
|
@@ -29741,6 +30814,18 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
|
|
|
29741
30814
|
});
|
|
29742
30815
|
}
|
|
29743
30816
|
};
|
|
30817
|
+
/**
|
|
30818
|
+
* @hidden
|
|
30819
|
+
* Internal utility.
|
|
30820
|
+
* Not part of the public API — do not rely on this in your code.
|
|
30821
|
+
*/ _proto.rebuild = function rebuild() {
|
|
30822
|
+
var _this_renderer;
|
|
30823
|
+
(_this_renderer = this.renderer) == null ? void 0 : _this_renderer.rebuild();
|
|
30824
|
+
};
|
|
30825
|
+
_proto.dispose = function dispose() {
|
|
30826
|
+
this.engine.removeParticleSystem(this);
|
|
30827
|
+
Component.prototype.dispose.call(this);
|
|
30828
|
+
};
|
|
29744
30829
|
_proto.getParticleBoxes = function getParticleBoxes() {
|
|
29745
30830
|
var link = this.particleLink;
|
|
29746
30831
|
var renderer = this.renderer;
|
|
@@ -30800,7 +31885,7 @@ var TimelineInstance = /*#__PURE__*/ function() {
|
|
|
30800
31885
|
return TimelineInstance;
|
|
30801
31886
|
}();
|
|
30802
31887
|
|
|
30803
|
-
var seed$
|
|
31888
|
+
var seed$2 = 0;
|
|
30804
31889
|
exports.SpriteColorPlayableAsset = /*#__PURE__*/ function(PlayableAsset) {
|
|
30805
31890
|
_inherits(SpriteColorPlayableAsset, PlayableAsset);
|
|
30806
31891
|
function SpriteColorPlayableAsset() {
|
|
@@ -30887,7 +31972,7 @@ exports.SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
30887
31972
|
_this = MaskableGraphic.call(this, engine) || this;
|
|
30888
31973
|
_this.time = 0;
|
|
30889
31974
|
_this.duration = 1;
|
|
30890
|
-
_this.name = "MSprite" + seed$
|
|
31975
|
+
_this.name = "MSprite" + seed$2++;
|
|
30891
31976
|
if (props) {
|
|
30892
31977
|
_this.fromData(props);
|
|
30893
31978
|
}
|
|
@@ -31008,8 +32093,8 @@ exports.SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
31008
32093
|
var width = isRotate90 ? h : w;
|
|
31009
32094
|
var height = isRotate90 ? w : h;
|
|
31010
32095
|
var angle = isRotate90 ? -Math.PI / 2 : 0;
|
|
31011
|
-
var aUV = geometry.getAttributeData(
|
|
31012
|
-
var aPos = geometry.getAttributeData(
|
|
32096
|
+
var aUV = geometry.getAttributeData(VertexBuffer.UVKind);
|
|
32097
|
+
var aPos = geometry.getAttributeData(VertexBuffer.PositionKind);
|
|
31013
32098
|
var indices = geometry.getIndexData();
|
|
31014
32099
|
var tempPosition = [
|
|
31015
32100
|
0,
|
|
@@ -31028,8 +32113,8 @@ exports.SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
31028
32113
|
aUV[uvOffset] = (tempPosition[0] + 0.5) * width + x;
|
|
31029
32114
|
aUV[uvOffset + 1] = (tempPosition[1] + 0.5) * height + y;
|
|
31030
32115
|
}
|
|
31031
|
-
this.
|
|
31032
|
-
this.
|
|
32116
|
+
this.updateAttributeData(VertexBuffer.PositionKind, aPos.slice(), 3);
|
|
32117
|
+
this.updateAttributeData(VertexBuffer.UVKind, aUV.slice(), 2);
|
|
31033
32118
|
this.geometry.setIndexData(indices.slice());
|
|
31034
32119
|
this.geometry.setDrawCount(indices.length);
|
|
31035
32120
|
}
|
|
@@ -31149,11 +32234,23 @@ exports.SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
31149
32234
|
index.push(base, 1 + base, 2 + base, 2 + base, 1 + base, 3 + base);
|
|
31150
32235
|
}
|
|
31151
32236
|
}
|
|
31152
|
-
|
|
32237
|
+
this.updateAttributeData(VertexBuffer.PositionKind, new Float32Array(position), 3);
|
|
31153
32238
|
geometry.setIndexData(new Uint16Array(index));
|
|
31154
|
-
|
|
32239
|
+
this.updateAttributeData(VertexBuffer.UVKind, new Float32Array(aUV), 2);
|
|
31155
32240
|
geometry.setDrawCount(index.length);
|
|
31156
32241
|
};
|
|
32242
|
+
_proto.updateAttributeData = function updateAttributeData(name, data, size) {
|
|
32243
|
+
var vertexBuffer = this.geometry.getVertexBuffer(name);
|
|
32244
|
+
var dataBuffer = vertexBuffer == null ? void 0 : vertexBuffer.getBuffer();
|
|
32245
|
+
if (!vertexBuffer || dataBuffer && data.byteLength > dataBuffer.capacity) {
|
|
32246
|
+
this.geometry.setVerticesBuffer(new VertexBuffer(this.engine, data, name, {
|
|
32247
|
+
updatable: true,
|
|
32248
|
+
size: size
|
|
32249
|
+
}));
|
|
32250
|
+
return;
|
|
32251
|
+
}
|
|
32252
|
+
this.geometry.setAttributeData(name, data);
|
|
32253
|
+
};
|
|
31157
32254
|
_create_class(SpriteComponent, [
|
|
31158
32255
|
{
|
|
31159
32256
|
key: "sprite",
|
|
@@ -31622,20 +32719,22 @@ var TextStyle = /*#__PURE__*/ function() {
|
|
|
31622
32719
|
return;
|
|
31623
32720
|
}
|
|
31624
32721
|
var context = this.context;
|
|
32722
|
+
var textureWidth = Math.max(1, width);
|
|
32723
|
+
var textureHeight = Math.max(1, height);
|
|
31625
32724
|
// 先保存状态
|
|
31626
32725
|
context.save();
|
|
31627
32726
|
// 设置canvas尺寸
|
|
31628
|
-
this.canvas.width =
|
|
31629
|
-
this.canvas.height =
|
|
32727
|
+
this.canvas.width = textureWidth;
|
|
32728
|
+
this.canvas.height = textureHeight;
|
|
31630
32729
|
//重置变换
|
|
31631
32730
|
context.setTransform(1, 0, 0, 1, 0, 0);
|
|
31632
32731
|
// 处理翻转
|
|
31633
32732
|
if (!flipY) {
|
|
31634
|
-
context.translate(0,
|
|
32733
|
+
context.translate(0, textureHeight);
|
|
31635
32734
|
context.scale(1, -1);
|
|
31636
32735
|
}
|
|
31637
32736
|
// 在翻转后清空画布
|
|
31638
|
-
context.clearRect(0, 0,
|
|
32737
|
+
context.clearRect(0, 0, textureWidth, textureHeight);
|
|
31639
32738
|
// 设置 alpha 修复用填充色(不实际输出像素)
|
|
31640
32739
|
context.fillStyle = "rgba(255, 255, 255, " + this.ALPHA_FIX_VALUE + ")";
|
|
31641
32740
|
// 执行绘制回调
|
|
@@ -31643,7 +32742,7 @@ var TextStyle = /*#__PURE__*/ function() {
|
|
|
31643
32742
|
// 创建纹理前恢复状态
|
|
31644
32743
|
context.restore();
|
|
31645
32744
|
// 创建新纹理
|
|
31646
|
-
var imageData = context.getImageData(0, 0,
|
|
32745
|
+
var imageData = context.getImageData(0, 0, textureWidth, textureHeight);
|
|
31647
32746
|
var texture = Texture.createWithData(this.engine, {
|
|
31648
32747
|
data: new Uint8Array(imageData.data),
|
|
31649
32748
|
width: imageData.width,
|
|
@@ -31679,7 +32778,7 @@ var DEFAULT_FONTS = [
|
|
|
31679
32778
|
"courier"
|
|
31680
32779
|
];
|
|
31681
32780
|
/** 检测字符串是否包含需要 RTL 和连写排版的字符(阿拉伯语等) */ var HAS_RTL_OR_JOINING = /[\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/;
|
|
31682
|
-
var seed$
|
|
32781
|
+
var seed$1 = 0;
|
|
31683
32782
|
exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
31684
32783
|
_inherits(TextComponent, MaskableGraphic);
|
|
31685
32784
|
function TextComponent(engine) {
|
|
@@ -31696,7 +32795,7 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
31696
32795
|
/**
|
|
31697
32796
|
* 每一行文本的最大宽度
|
|
31698
32797
|
*/ _this.maxLineWidth = 0;
|
|
31699
|
-
_this.name = "MText" + seed$
|
|
32798
|
+
_this.name = "MText" + seed$1++;
|
|
31700
32799
|
// 初始化canvas资源
|
|
31701
32800
|
var canvasAndContext = canvasPool.getCanvasAndContext(1, 1);
|
|
31702
32801
|
_this.canvas = canvasAndContext.canvas;
|
|
@@ -33612,45 +34711,42 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
33612
34711
|
easingOuts: [],
|
|
33613
34712
|
shapes: []
|
|
33614
34713
|
};
|
|
34714
|
+
var _obj;
|
|
33615
34715
|
// Create Geometry
|
|
33616
34716
|
//-------------------------------------------------------------------------
|
|
33617
34717
|
_this.geometry = Geometry.create(_this.engine, {
|
|
33618
|
-
attributes: {
|
|
33619
|
-
|
|
33620
|
-
|
|
33621
|
-
|
|
33622
|
-
|
|
33623
|
-
|
|
33624
|
-
|
|
33625
|
-
|
|
33626
|
-
|
|
33627
|
-
|
|
33628
|
-
|
|
33629
|
-
|
|
33630
|
-
|
|
33631
|
-
|
|
33632
|
-
|
|
33633
|
-
|
|
33634
|
-
|
|
33635
|
-
|
|
33636
|
-
|
|
33637
|
-
|
|
33638
|
-
|
|
33639
|
-
|
|
33640
|
-
|
|
33641
|
-
|
|
33642
|
-
|
|
33643
|
-
|
|
33644
|
-
|
|
33645
|
-
|
|
33646
|
-
|
|
33647
|
-
|
|
33648
|
-
|
|
33649
|
-
|
|
33650
|
-
0
|
|
33651
|
-
])
|
|
33652
|
-
}
|
|
33653
|
-
},
|
|
34718
|
+
attributes: (_obj = {}, _obj[VertexBuffer.PositionKind] = {
|
|
34719
|
+
type: glContext.FLOAT,
|
|
34720
|
+
size: 3,
|
|
34721
|
+
data: new Float32Array([
|
|
34722
|
+
-0.5,
|
|
34723
|
+
0.5,
|
|
34724
|
+
0,
|
|
34725
|
+
-0.5,
|
|
34726
|
+
-0.5,
|
|
34727
|
+
0,
|
|
34728
|
+
0.5,
|
|
34729
|
+
0.5,
|
|
34730
|
+
0,
|
|
34731
|
+
0.5,
|
|
34732
|
+
-0.5,
|
|
34733
|
+
0
|
|
34734
|
+
])
|
|
34735
|
+
}, _obj[VertexBuffer.UVKind] = {
|
|
34736
|
+
size: 2,
|
|
34737
|
+
offset: 0,
|
|
34738
|
+
type: glContext.FLOAT,
|
|
34739
|
+
data: new Float32Array([
|
|
34740
|
+
0,
|
|
34741
|
+
1,
|
|
34742
|
+
0,
|
|
34743
|
+
0,
|
|
34744
|
+
1,
|
|
34745
|
+
1,
|
|
34746
|
+
1,
|
|
34747
|
+
0
|
|
34748
|
+
])
|
|
34749
|
+
}, _obj),
|
|
33654
34750
|
indices: {
|
|
33655
34751
|
data: new Uint16Array([
|
|
33656
34752
|
0,
|
|
@@ -33659,11 +34755,11 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
33659
34755
|
2,
|
|
33660
34756
|
1,
|
|
33661
34757
|
3
|
|
33662
|
-
])
|
|
33663
|
-
releasable: true
|
|
34758
|
+
])
|
|
33664
34759
|
},
|
|
33665
34760
|
mode: glContext.TRIANGLES,
|
|
33666
|
-
drawCount: 6
|
|
34761
|
+
drawCount: 6,
|
|
34762
|
+
bufferUsage: glContext.DYNAMIC_DRAW
|
|
33667
34763
|
});
|
|
33668
34764
|
_this.geometry.subMeshes.push({
|
|
33669
34765
|
offset: 0,
|
|
@@ -33729,7 +34825,7 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
33729
34825
|
return boundingBox;
|
|
33730
34826
|
};
|
|
33731
34827
|
_proto.getBoundingBoxInfo = function getBoundingBoxInfo() {
|
|
33732
|
-
var positionArray = this.geometry.getAttributeData(
|
|
34828
|
+
var positionArray = this.geometry.getAttributeData(VertexBuffer.PositionKind);
|
|
33733
34829
|
if (positionArray) {
|
|
33734
34830
|
var minMaxResult = extractMinAndMax(positionArray, 0, positionArray.length / 3);
|
|
33735
34831
|
minMaxResult.minimum.x *= this.transform.size.x;
|
|
@@ -33780,8 +34876,8 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
33780
34876
|
var strokeIndexCount = indices.length - fillIndexCount;
|
|
33781
34877
|
var vertexCount = vertices.length / 2;
|
|
33782
34878
|
// Get the current attribute and index arrays from the geometry, avoiding re-creation
|
|
33783
|
-
var positionArray = this.geometry.getAttributeData(
|
|
33784
|
-
var uvArray = this.geometry.getAttributeData(
|
|
34879
|
+
var positionArray = this.geometry.getAttributeData(VertexBuffer.PositionKind);
|
|
34880
|
+
var uvArray = this.geometry.getAttributeData(VertexBuffer.UVKind);
|
|
33785
34881
|
var indexArray = this.geometry.getIndexData();
|
|
33786
34882
|
if (!positionArray || positionArray.length < vertexCount * 3) {
|
|
33787
34883
|
positionArray = new Float32Array(vertexCount * 3);
|
|
@@ -33822,8 +34918,8 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
33822
34918
|
// Set index array
|
|
33823
34919
|
indexArray.set(indices);
|
|
33824
34920
|
// Rewrite to geometry
|
|
33825
|
-
this.
|
|
33826
|
-
this.
|
|
34921
|
+
this.updateAttributeData(VertexBuffer.PositionKind, positionArray, 3);
|
|
34922
|
+
this.updateAttributeData(VertexBuffer.UVKind, uvArray, 2);
|
|
33827
34923
|
this.geometry.setIndexData(indexArray);
|
|
33828
34924
|
this.geometry.setDrawCount(indices.length);
|
|
33829
34925
|
var u16Size = 2;
|
|
@@ -33833,6 +34929,18 @@ exports.ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
33833
34929
|
strokeSubMesh.offset = fillIndexCount * u16Size;
|
|
33834
34930
|
strokeSubMesh.indexCount = strokeIndexCount;
|
|
33835
34931
|
};
|
|
34932
|
+
_proto.updateAttributeData = function updateAttributeData(name, data, size) {
|
|
34933
|
+
var _this_geometry_getVertexBuffer;
|
|
34934
|
+
var dataBuffer = (_this_geometry_getVertexBuffer = this.geometry.getVertexBuffer(name)) == null ? void 0 : _this_geometry_getVertexBuffer.getBuffer();
|
|
34935
|
+
if (dataBuffer && data.byteLength > dataBuffer.capacity) {
|
|
34936
|
+
this.geometry.setVerticesBuffer(new VertexBuffer(this.engine, data, name, {
|
|
34937
|
+
updatable: true,
|
|
34938
|
+
size: size
|
|
34939
|
+
}));
|
|
34940
|
+
return;
|
|
34941
|
+
}
|
|
34942
|
+
this.geometry.setAttributeData(name, data);
|
|
34943
|
+
};
|
|
33836
34944
|
_proto.computeScreenScale = function computeScreenScale() {
|
|
33837
34945
|
var defaultPpu = 1;
|
|
33838
34946
|
var composition = this.item.composition;
|
|
@@ -36609,7 +37717,7 @@ function getStandardSpriteContent(sprite, transform) {
|
|
|
36609
37717
|
return ret;
|
|
36610
37718
|
}
|
|
36611
37719
|
|
|
36612
|
-
var version$2 = "2.10.0-alpha.
|
|
37720
|
+
var version$2 = "2.10.0-alpha.2";
|
|
36613
37721
|
var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
|
|
36614
37722
|
var standardVersion = /^(\d+)\.(\d+)$/;
|
|
36615
37723
|
var reverseParticle = false;
|
|
@@ -37106,7 +38214,7 @@ function _combineImageTemplate() {
|
|
|
37106
38214
|
this.options = options;
|
|
37107
38215
|
};
|
|
37108
38216
|
|
|
37109
|
-
var seed
|
|
38217
|
+
var seed = 1;
|
|
37110
38218
|
/**
|
|
37111
38219
|
* 资源管理器
|
|
37112
38220
|
* 用于加载和动效中所有的资源文件,包括图片、插件、图层粒子数据等
|
|
@@ -37118,7 +38226,7 @@ var seed$1 = 1;
|
|
|
37118
38226
|
this.downloader = downloader;
|
|
37119
38227
|
this.assets = {};
|
|
37120
38228
|
this.sourceFrom = {};
|
|
37121
|
-
this.id = seed
|
|
38229
|
+
this.id = seed++;
|
|
37122
38230
|
this.timers = [];
|
|
37123
38231
|
this.updateOptions(options);
|
|
37124
38232
|
}
|
|
@@ -38400,11 +39508,6 @@ var tmpScale = new Vector3(1, 1, 1);
|
|
|
38400
39508
|
return Camera;
|
|
38401
39509
|
}();
|
|
38402
39510
|
|
|
38403
|
-
function _assert_this_initialized(self) {
|
|
38404
|
-
if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
38405
|
-
return self;
|
|
38406
|
-
}
|
|
38407
|
-
|
|
38408
39511
|
/**
|
|
38409
39512
|
*
|
|
38410
39513
|
*/ var SceneTicking = /*#__PURE__*/ function() {
|
|
@@ -38571,7 +39674,7 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
|
|
|
38571
39674
|
_this.paused = true;
|
|
38572
39675
|
_this.isEndCalled = false;
|
|
38573
39676
|
_this._textures = [];
|
|
38574
|
-
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,
|
|
39677
|
+
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;
|
|
38575
39678
|
_this.engine.addComposition(_assert_this_initialized(_this));
|
|
38576
39679
|
var sourceContent = null;
|
|
38577
39680
|
if (scene) {
|
|
@@ -38629,7 +39732,7 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
|
|
|
38629
39732
|
_this.id = (_sourceContent_id = sourceContent == null ? void 0 : sourceContent.id) != null ? _sourceContent_id : generateGUID();
|
|
38630
39733
|
var _sourceContent_startTime;
|
|
38631
39734
|
_this.startTime = (_sourceContent_startTime = sourceContent == null ? void 0 : sourceContent.startTime) != null ? _sourceContent_startTime : 0;
|
|
38632
|
-
_this.event =
|
|
39735
|
+
_this.event = engine.eventSystem;
|
|
38633
39736
|
var _scene_startTime, _scene_totalTime;
|
|
38634
39737
|
_this.statistic = {
|
|
38635
39738
|
loadStart: (_scene_startTime = scene == null ? void 0 : scene.startTime) != null ? _scene_startTime : 0,
|
|
@@ -40975,6 +42078,7 @@ var DEFAULT_FPS = 60;
|
|
|
40975
42078
|
_this.renderPasses = [];
|
|
40976
42079
|
_this.framebuffers = [];
|
|
40977
42080
|
_this.renderbuffers = [];
|
|
42081
|
+
_this.particleSystems = [];
|
|
40978
42082
|
_this.clearAction = {
|
|
40979
42083
|
stencilAction: exports.TextureLoadAction.clear,
|
|
40980
42084
|
clearStencil: 0,
|
|
@@ -41013,7 +42117,6 @@ var DEFAULT_FPS = 60;
|
|
|
41013
42117
|
_this.assetLoader = new AssetLoader(_assert_this_initialized(_this));
|
|
41014
42118
|
_this.assetService = new AssetService(_assert_this_initialized(_this));
|
|
41015
42119
|
_this.renderTargetPool = new RenderTargetPool(_assert_this_initialized(_this));
|
|
41016
|
-
_this.graphics = new Graphics(_assert_this_initialized(_this));
|
|
41017
42120
|
_this.renderingData = {
|
|
41018
42121
|
// @ts-expect-error
|
|
41019
42122
|
currentFrame: {}
|
|
@@ -41224,55 +42327,27 @@ var DEFAULT_FPS = 60;
|
|
|
41224
42327
|
});
|
|
41225
42328
|
this.emit("resize", this);
|
|
41226
42329
|
};
|
|
41227
|
-
_proto.
|
|
41228
|
-
|
|
41229
|
-
|
|
41230
|
-
|
|
41231
|
-
|
|
41232
|
-
|
|
41233
|
-
|
|
41234
|
-
|
|
41235
|
-
|
|
41236
|
-
|
|
41237
|
-
|
|
41238
|
-
|
|
41239
|
-
|
|
41240
|
-
|
|
41241
|
-
|
|
41242
|
-
|
|
41243
|
-
|
|
41244
|
-
|
|
41245
|
-
|
|
41246
|
-
|
|
41247
|
-
|
|
41248
|
-
targetHeight = finalHeight * this.displayScale;
|
|
41249
|
-
targetWidth = targetHeight * displayAspect;
|
|
41250
|
-
} else {
|
|
41251
|
-
targetWidth = finalWidth * this.displayScale;
|
|
41252
|
-
targetHeight = targetWidth / displayAspect;
|
|
41253
|
-
}
|
|
41254
|
-
} else {
|
|
41255
|
-
targetWidth = finalWidth;
|
|
41256
|
-
targetHeight = finalHeight;
|
|
41257
|
-
}
|
|
41258
|
-
var ratio = this.pixelRatio;
|
|
41259
|
-
var containerWidth = targetWidth;
|
|
41260
|
-
var containerHeight = targetHeight;
|
|
41261
|
-
targetWidth = Math.round(targetWidth * ratio);
|
|
41262
|
-
targetHeight = Math.round(targetHeight * ratio);
|
|
41263
|
-
if (targetWidth < 1 || targetHeight < 1) {
|
|
41264
|
-
if (this.offscreenMode) {
|
|
41265
|
-
targetWidth = targetHeight = containerWidth = containerHeight = 1;
|
|
41266
|
-
} else {
|
|
41267
|
-
throw new Error("Invalid container size " + targetWidth + "x" + targetHeight + ", see " + HELP_LINK["Invalid container size"] + ".");
|
|
41268
|
-
}
|
|
41269
|
-
}
|
|
41270
|
-
return [
|
|
41271
|
-
containerWidth,
|
|
41272
|
-
containerHeight,
|
|
41273
|
-
targetWidth,
|
|
41274
|
-
targetHeight
|
|
41275
|
-
];
|
|
42330
|
+
_proto.createVertexBuffer = function createVertexBuffer(data, options) {
|
|
42331
|
+
throw new Error("The active rendering backend does not provide vertex buffers.");
|
|
42332
|
+
};
|
|
42333
|
+
_proto.createDynamicVertexBuffer = function createDynamicVertexBuffer(data, options) {
|
|
42334
|
+
return this.createVertexBuffer(data, options);
|
|
42335
|
+
};
|
|
42336
|
+
_proto.createIndexBuffer = function createIndexBuffer(indices, options) {
|
|
42337
|
+
throw new Error("The active rendering backend does not provide index buffers.");
|
|
42338
|
+
};
|
|
42339
|
+
_proto.updateDynamicVertexBuffer = function updateDynamicVertexBuffer(vertexBuffer, data, byteOffset, byteLength) {
|
|
42340
|
+
throw new Error("The active rendering backend cannot update vertex buffers.");
|
|
42341
|
+
};
|
|
42342
|
+
_proto.updateDynamicIndexBuffer = function updateDynamicIndexBuffer(indexBuffer, indices, byteOffset) {
|
|
42343
|
+
throw new Error("The active rendering backend cannot update index buffers.");
|
|
42344
|
+
};
|
|
42345
|
+
/** @hide */ _proto.releaseBuffer = function releaseBuffer(buffer) {
|
|
42346
|
+
buffer.references--;
|
|
42347
|
+
return buffer.references === 0;
|
|
42348
|
+
};
|
|
42349
|
+
/** @hide */ _proto.bindBuffers = function bindBuffers(vertexBuffers, indexBuffer, effect) {
|
|
42350
|
+
throw new Error("The active rendering backend cannot bind geometry buffers.");
|
|
41276
42351
|
};
|
|
41277
42352
|
_proto.addTexture = function addTexture(tex) {
|
|
41278
42353
|
if (this.disposed) {
|
|
@@ -41310,6 +42385,18 @@ var DEFAULT_FPS = 60;
|
|
|
41310
42385
|
}
|
|
41311
42386
|
removeItem(this.geometries, geo);
|
|
41312
42387
|
};
|
|
42388
|
+
/** @internal */ _proto.addParticleSystem = function addParticleSystem(particleSystem) {
|
|
42389
|
+
if (this.disposed) {
|
|
42390
|
+
return;
|
|
42391
|
+
}
|
|
42392
|
+
addItem(this.particleSystems, particleSystem);
|
|
42393
|
+
};
|
|
42394
|
+
/** @internal */ _proto.removeParticleSystem = function removeParticleSystem(particleSystem) {
|
|
42395
|
+
if (this.disposed) {
|
|
42396
|
+
return;
|
|
42397
|
+
}
|
|
42398
|
+
removeItem(this.particleSystems, particleSystem);
|
|
42399
|
+
};
|
|
41313
42400
|
_proto.addMesh = function addMesh(mesh) {
|
|
41314
42401
|
if (this.disposed) {
|
|
41315
42402
|
return;
|
|
@@ -41462,7 +42549,7 @@ var DEFAULT_FPS = 60;
|
|
|
41462
42549
|
/**
|
|
41463
42550
|
* 销毁所有缓存的资源
|
|
41464
42551
|
*/ _proto.dispose = function dispose() {
|
|
41465
|
-
var _this_ticker, _this_eventSystem, _this_assetService;
|
|
42552
|
+
var _this_ticker, _this_eventSystem, _this_assetService, _this__graphics;
|
|
41466
42553
|
if (this.disposed) {
|
|
41467
42554
|
return;
|
|
41468
42555
|
}
|
|
@@ -41487,7 +42574,7 @@ var DEFAULT_FPS = 60;
|
|
|
41487
42574
|
(_this_ticker = this.ticker) == null ? void 0 : _this_ticker.stop();
|
|
41488
42575
|
(_this_eventSystem = this.eventSystem) == null ? void 0 : _this_eventSystem.dispose();
|
|
41489
42576
|
(_this_assetService = this.assetService) == null ? void 0 : _this_assetService.dispose();
|
|
41490
|
-
this.
|
|
42577
|
+
(_this__graphics = this._graphics) == null ? void 0 : _this__graphics.dispose();
|
|
41491
42578
|
this.renderPasses.forEach(function(pass) {
|
|
41492
42579
|
return pass.dispose();
|
|
41493
42580
|
});
|
|
@@ -41515,8 +42602,69 @@ var DEFAULT_FPS = 60;
|
|
|
41515
42602
|
this.meshes = [];
|
|
41516
42603
|
this.renderPasses = [];
|
|
41517
42604
|
this.compositions = [];
|
|
42605
|
+
this.particleSystems = [];
|
|
42606
|
+
};
|
|
42607
|
+
_proto.getTargetSize = function getTargetSize(parentEle) {
|
|
42608
|
+
if (parentEle === undefined || parentEle === null) {
|
|
42609
|
+
throw new Error("Container is not an HTMLElement, see " + HELP_LINK["Container is not an HTMLElement"] + ".");
|
|
42610
|
+
}
|
|
42611
|
+
var displayAspect = this.displayAspect;
|
|
42612
|
+
// 小程序环境没有 getComputedStyle
|
|
42613
|
+
var computedStyle = window.getComputedStyle == null ? void 0 : window.getComputedStyle.call(window, parentEle);
|
|
42614
|
+
var targetWidth;
|
|
42615
|
+
var targetHeight;
|
|
42616
|
+
var finalWidth = 0;
|
|
42617
|
+
var finalHeight = 0;
|
|
42618
|
+
if (computedStyle) {
|
|
42619
|
+
finalWidth = parseInt(computedStyle.width, 10);
|
|
42620
|
+
finalHeight = parseInt(computedStyle.height, 10);
|
|
42621
|
+
} else {
|
|
42622
|
+
finalWidth = parentEle.clientWidth;
|
|
42623
|
+
finalHeight = parentEle.clientHeight;
|
|
42624
|
+
}
|
|
42625
|
+
if (displayAspect) {
|
|
42626
|
+
var parentAspect = finalWidth / finalHeight;
|
|
42627
|
+
if (parentAspect > displayAspect) {
|
|
42628
|
+
targetHeight = finalHeight * this.displayScale;
|
|
42629
|
+
targetWidth = targetHeight * displayAspect;
|
|
42630
|
+
} else {
|
|
42631
|
+
targetWidth = finalWidth * this.displayScale;
|
|
42632
|
+
targetHeight = targetWidth / displayAspect;
|
|
42633
|
+
}
|
|
42634
|
+
} else {
|
|
42635
|
+
targetWidth = finalWidth;
|
|
42636
|
+
targetHeight = finalHeight;
|
|
42637
|
+
}
|
|
42638
|
+
var ratio = this.pixelRatio;
|
|
42639
|
+
var containerWidth = targetWidth;
|
|
42640
|
+
var containerHeight = targetHeight;
|
|
42641
|
+
targetWidth = Math.round(targetWidth * ratio);
|
|
42642
|
+
targetHeight = Math.round(targetHeight * ratio);
|
|
42643
|
+
if (targetWidth < 1 || targetHeight < 1) {
|
|
42644
|
+
if (this.offscreenMode) {
|
|
42645
|
+
targetWidth = targetHeight = containerWidth = containerHeight = 1;
|
|
42646
|
+
} else {
|
|
42647
|
+
throw new Error("Invalid container size " + targetWidth + "x" + targetHeight + ", see " + HELP_LINK["Invalid container size"] + ".");
|
|
42648
|
+
}
|
|
42649
|
+
}
|
|
42650
|
+
return [
|
|
42651
|
+
containerWidth,
|
|
42652
|
+
containerHeight,
|
|
42653
|
+
targetWidth,
|
|
42654
|
+
targetHeight
|
|
42655
|
+
];
|
|
41518
42656
|
};
|
|
41519
42657
|
_create_class(Engine, [
|
|
42658
|
+
{
|
|
42659
|
+
key: "graphics",
|
|
42660
|
+
get: function get() {
|
|
42661
|
+
if (this._graphics) {
|
|
42662
|
+
return this._graphics;
|
|
42663
|
+
}
|
|
42664
|
+
this._graphics = new Graphics(this);
|
|
42665
|
+
return this._graphics;
|
|
42666
|
+
}
|
|
42667
|
+
},
|
|
41520
42668
|
{
|
|
41521
42669
|
key: "disposed",
|
|
41522
42670
|
get: function get() {
|
|
@@ -41679,9 +42827,7 @@ var PassTextureCache = /*#__PURE__*/ function() {
|
|
|
41679
42827
|
};
|
|
41680
42828
|
SceneLoader.createComposition = function createComposition(scene, engine, options) {
|
|
41681
42829
|
if (options === void 0) options = {};
|
|
41682
|
-
var composition = new Composition(engine, _extends({}, options,
|
|
41683
|
-
event: engine.eventSystem
|
|
41684
|
-
}), scene);
|
|
42830
|
+
var composition = new Composition(engine, _extends({}, options), scene);
|
|
41685
42831
|
// TODO 目前编辑器会每帧调用 loadScene, 在这编译会导致闪帧,待编辑器渲染逻辑优化后移除。
|
|
41686
42832
|
if (engine.env !== PLAYER_OPTIONS_ENV_EDITOR) {
|
|
41687
42833
|
engine.assetService.createShaderVariant();
|
|
@@ -41734,7 +42880,7 @@ var PrecompositionManager = /*#__PURE__*/ function() {
|
|
|
41734
42880
|
rootItem.instantiatePreComposition(compositionData);
|
|
41735
42881
|
var _options_autoplay;
|
|
41736
42882
|
rootItem.getComponent(exports.CompositionComponent).playOnStart = (_options_autoplay = options.autoplay) != null ? _options_autoplay : true;
|
|
41737
|
-
rootItem.getComponent(exports.CompositionComponent).endBehavior =
|
|
42883
|
+
rootItem.getComponent(exports.CompositionComponent).endBehavior = rootItem.endBehavior;
|
|
41738
42884
|
composition.addItem(rootItem);
|
|
41739
42885
|
return rootItem;
|
|
41740
42886
|
};
|
|
@@ -41746,7 +42892,7 @@ registerPlugin("text", TextLoader);
|
|
|
41746
42892
|
registerPlugin("sprite", SpriteLoader);
|
|
41747
42893
|
registerPlugin("particle", ParticleLoader);
|
|
41748
42894
|
registerPlugin("interact", InteractLoader);
|
|
41749
|
-
var version$1 = "2.10.0-alpha.
|
|
42895
|
+
var version$1 = "2.10.0-alpha.2";
|
|
41750
42896
|
logger.info("Core version: " + version$1 + ".");
|
|
41751
42897
|
|
|
41752
42898
|
var _obj;
|
|
@@ -42357,275 +43503,61 @@ function _possible_constructor_return(self, call) {
|
|
|
42357
43503
|
return _assert_this_initialized(self);
|
|
42358
43504
|
}
|
|
42359
43505
|
|
|
42360
|
-
var
|
|
42361
|
-
|
|
42362
|
-
|
|
42363
|
-
|
|
42364
|
-
|
|
42365
|
-
|
|
42366
|
-
|
|
42367
|
-
|
|
42368
|
-
|
|
42369
|
-
|
|
42370
|
-
|
|
42371
|
-
|
|
42372
|
-
|
|
42373
|
-
|
|
42374
|
-
|
|
42375
|
-
|
|
42376
|
-
|
|
42377
|
-
|
|
42378
|
-
_this.mode = mode != null ? mode : glContext.TRIANGLES;
|
|
42379
|
-
var attributesName = [];
|
|
42380
|
-
var attributes = {};
|
|
42381
|
-
var geometry = new THREE__namespace.BufferGeometry();
|
|
42382
|
-
Object.keys(props.attributes).forEach(function(name) {
|
|
42383
|
-
var attr = props.attributes[name];
|
|
42384
|
-
if (!("dataSource" in attr)) {
|
|
42385
|
-
_this.setAttributeType(name, attr, geometry, attributes, props.maxVertex);
|
|
42386
|
-
} else {
|
|
42387
|
-
// 使用AttributeWithType构造的attribute
|
|
42388
|
-
var dataSource = attr.dataSource;
|
|
42389
|
-
if (dataSource) {
|
|
42390
|
-
if (attributes[dataSource] === undefined) {
|
|
42391
|
-
_this.setAttributeType(dataSource, attr, geometry, attributes, props.maxVertex);
|
|
42392
|
-
}
|
|
42393
|
-
var size = attr.size, offset = attr.offset, normalize = attr.normalize;
|
|
42394
|
-
var dataSourceAttribute = attributes[dataSource];
|
|
42395
|
-
var buffer = dataSourceAttribute.buffer;
|
|
42396
|
-
var dataLength = dataSourceAttribute.dataLength;
|
|
42397
|
-
var attribute = new THREE__namespace.InterleavedBufferAttribute(buffer, size, (offset != null ? offset : 0) / dataLength, normalize);
|
|
42398
|
-
geometry.setAttribute(name, attribute);
|
|
42399
|
-
attributes[name] = {
|
|
42400
|
-
buffer: buffer,
|
|
42401
|
-
attribute: attribute,
|
|
42402
|
-
type: dataSourceAttribute.type,
|
|
42403
|
-
dataLength: dataLength
|
|
42404
|
-
};
|
|
42405
|
-
}
|
|
43506
|
+
var geometryCache = new WeakMap();
|
|
43507
|
+
function getThreeGeometry(source) {
|
|
43508
|
+
source.flush();
|
|
43509
|
+
var cache = geometryCache.get(source);
|
|
43510
|
+
var attributeNames = source.getAttributeNames();
|
|
43511
|
+
var indexBuffer = source.getIndexBuffer();
|
|
43512
|
+
var instanced = source.instanceCount > 0;
|
|
43513
|
+
if (!cache || !isCacheValid(source, cache, attributeNames, indexBuffer, instanced)) {
|
|
43514
|
+
cache == null ? void 0 : cache.resource.dispose();
|
|
43515
|
+
var geometry = instanced ? new THREE__namespace.InstancedBufferGeometry() : new THREE__namespace.BufferGeometry();
|
|
43516
|
+
var vertexBuffers = {};
|
|
43517
|
+
geometry.name = source.name;
|
|
43518
|
+
attributeNames.forEach(function(name) {
|
|
43519
|
+
var vertexBuffer = source.getVertexBuffer(name);
|
|
43520
|
+
var dataBuffer = vertexBuffer == null ? void 0 : vertexBuffer.getBuffer();
|
|
43521
|
+
var nativeBuffer = dataBuffer == null ? void 0 : dataBuffer.resource;
|
|
43522
|
+
if (!vertexBuffer || !_instanceof1(nativeBuffer, THREE__namespace.InterleavedBuffer)) {
|
|
43523
|
+
return;
|
|
42406
43524
|
}
|
|
42407
|
-
|
|
43525
|
+
vertexBuffers[name] = vertexBuffer;
|
|
43526
|
+
geometry.setAttribute(name, new THREE__namespace.InterleavedBufferAttribute(nativeBuffer, vertexBuffer.getSize(), vertexBuffer.byteOffset / nativeBuffer.array.BYTES_PER_ELEMENT, vertexBuffer.normalized));
|
|
42408
43527
|
});
|
|
42409
|
-
|
|
42410
|
-
|
|
42411
|
-
|
|
42412
|
-
|
|
42413
|
-
|
|
42414
|
-
|
|
42415
|
-
|
|
42416
|
-
|
|
42417
|
-
|
|
42418
|
-
|
|
42419
|
-
var _proto = ThreeGeometry.prototype;
|
|
42420
|
-
/**
|
|
42421
|
-
* 获取 attribute 数据
|
|
42422
|
-
*
|
|
42423
|
-
* @param name - attribute 名称
|
|
42424
|
-
* @returns 返回 attribute 数据,如果为空返回 undefined
|
|
42425
|
-
*/ _proto.getAttributeData = function getAttributeData(name) {
|
|
42426
|
-
if (this.attributes[name] == undefined) {
|
|
42427
|
-
return;
|
|
42428
|
-
}
|
|
42429
|
-
return this.attributes[name].buffer.array;
|
|
42430
|
-
};
|
|
42431
|
-
/**
|
|
42432
|
-
* 设置 attribute 数据
|
|
42433
|
-
*
|
|
42434
|
-
* @param name - attribute 名称
|
|
42435
|
-
* @param data - attribute 数据
|
|
42436
|
-
* @returns
|
|
42437
|
-
*/ _proto.setAttributeData = function setAttributeData(name, data) {
|
|
42438
|
-
if (this.attributes[name] == undefined) {
|
|
42439
|
-
return;
|
|
42440
|
-
}
|
|
42441
|
-
var attributeBuffer = this.attributes[name].buffer;
|
|
42442
|
-
if (data.length > attributeBuffer.array.length) {
|
|
42443
|
-
var buffer = new THREE__namespace.InterleavedBuffer(data, attributeBuffer.stride);
|
|
42444
|
-
attributeBuffer = this.attributes[name].attribute.data = buffer;
|
|
42445
|
-
this.attributes[name].buffer = buffer;
|
|
42446
|
-
this.geometry.setAttribute(name, this.attributes[name].attribute);
|
|
42447
|
-
} else {
|
|
42448
|
-
attributeBuffer.set(data, 0);
|
|
42449
|
-
attributeBuffer.updateRange.count = data.length;
|
|
42450
|
-
attributeBuffer.updateRange.offset = 0;
|
|
42451
|
-
}
|
|
42452
|
-
this.geometry.attributes[name].needsUpdate = true;
|
|
42453
|
-
};
|
|
42454
|
-
/**
|
|
42455
|
-
* 设置可变的 attribute 数据
|
|
42456
|
-
*
|
|
42457
|
-
* @param name - attribute 名称
|
|
42458
|
-
* @param dataOffset - 数据偏移
|
|
42459
|
-
* @param data - 数据内容
|
|
42460
|
-
* @returns
|
|
42461
|
-
*/ _proto.setAttributeSubData = function setAttributeSubData(name, dataOffset, data) {
|
|
42462
|
-
if (this.attributes[name] == undefined) {
|
|
42463
|
-
return;
|
|
42464
|
-
}
|
|
42465
|
-
var attributeBuffer = this.attributes[name].buffer;
|
|
42466
|
-
attributeBuffer.set(data, dataOffset);
|
|
42467
|
-
this.geometry.attributes[name].needsUpdate = true;
|
|
42468
|
-
};
|
|
42469
|
-
/**
|
|
42470
|
-
* 获取 attribute 数据步长
|
|
42471
|
-
*
|
|
42472
|
-
* @param name - attribute名称
|
|
42473
|
-
* @returns 返回步长值
|
|
42474
|
-
*/ _proto.getAttributeStride = function getAttributeStride(name) {
|
|
42475
|
-
var attribute = this.attributes[name];
|
|
42476
|
-
return attribute.buffer.stride * BYTES_TYPE_MAP[attribute.type];
|
|
42477
|
-
};
|
|
42478
|
-
/**
|
|
42479
|
-
* 获取用到的所有 attribute 名称
|
|
42480
|
-
* @returns 返回名称数组
|
|
42481
|
-
*/ _proto.getAttributeNames = function getAttributeNames() {
|
|
42482
|
-
return this.attributesName;
|
|
42483
|
-
};
|
|
42484
|
-
/**
|
|
42485
|
-
* 获取 index attribute 数据
|
|
42486
|
-
* @returns 返回数据,如果为空返回 undefined
|
|
42487
|
-
*/ _proto.getIndexData = function getIndexData() {
|
|
42488
|
-
var index = this.geometry.getIndex();
|
|
42489
|
-
return index === null ? undefined : index.array;
|
|
42490
|
-
};
|
|
42491
|
-
/**
|
|
42492
|
-
* 设置 index attribute 数据
|
|
42493
|
-
*
|
|
42494
|
-
* @param data - index 数据
|
|
42495
|
-
*/ _proto.setIndexData = function setIndexData(data) {
|
|
42496
|
-
if (data) {
|
|
42497
|
-
this.geometry.setIndex(new THREE__namespace.BufferAttribute(data, 1));
|
|
42498
|
-
this.geometry.index.needsUpdate = true;
|
|
42499
|
-
}
|
|
42500
|
-
};
|
|
42501
|
-
/**
|
|
42502
|
-
* 设置偏移 index 数据
|
|
42503
|
-
*
|
|
42504
|
-
* @param offset - 数据偏移量
|
|
42505
|
-
* @param data - 数据内容
|
|
42506
|
-
*/ _proto.setIndexSubData = function setIndexSubData(offset, data) {
|
|
42507
|
-
var index = this.geometry.getIndex();
|
|
42508
|
-
if (index !== null) {
|
|
42509
|
-
var start = offset;
|
|
42510
|
-
var length = offset + data.length;
|
|
42511
|
-
var array = index.count;
|
|
42512
|
-
if (array < length) {
|
|
42513
|
-
// @ts-expect-error safe to use
|
|
42514
|
-
var newData = new data.constructor(end);
|
|
42515
|
-
newData.set(index.array);
|
|
42516
|
-
index.array = newData;
|
|
42517
|
-
}
|
|
42518
|
-
//@ts-expect-error
|
|
42519
|
-
index.array.set(data, start);
|
|
42520
|
-
this.geometry.index.needsUpdate = true;
|
|
42521
|
-
}
|
|
42522
|
-
};
|
|
42523
|
-
/**
|
|
42524
|
-
* 设置绘制偏移
|
|
42525
|
-
*
|
|
42526
|
-
* @param start - 绘制偏移
|
|
42527
|
-
*/ _proto.setDrawStart = function setDrawStart(start) {
|
|
42528
|
-
this.drawStart = start;
|
|
42529
|
-
};
|
|
42530
|
-
/**
|
|
42531
|
-
* 获取绘制偏移
|
|
42532
|
-
*
|
|
42533
|
-
* @returns 返回绘制移
|
|
42534
|
-
*/ _proto.getDrawStart = function getDrawStart() {
|
|
42535
|
-
return this.drawStart;
|
|
42536
|
-
};
|
|
42537
|
-
/**
|
|
42538
|
-
* 设置绘制数量
|
|
42539
|
-
*
|
|
42540
|
-
* @param count - 绘制数量
|
|
42541
|
-
*/ _proto.setDrawCount = function setDrawCount(count) {
|
|
42542
|
-
this.drawCount = count;
|
|
42543
|
-
};
|
|
42544
|
-
/**
|
|
42545
|
-
* 获取绘制数量
|
|
42546
|
-
*
|
|
42547
|
-
* @returns 返回绘制数量
|
|
42548
|
-
*/ _proto.getDrawCount = function getDrawCount() {
|
|
42549
|
-
return this.drawCount;
|
|
42550
|
-
};
|
|
42551
|
-
/**
|
|
42552
|
-
* 获取蒙皮数据
|
|
42553
|
-
*
|
|
42554
|
-
* @returns 返回蒙皮数据
|
|
42555
|
-
*/ _proto.getSkinProps = function getSkinProps() {
|
|
42556
|
-
return {};
|
|
42557
|
-
};
|
|
42558
|
-
/**
|
|
42559
|
-
* 销毁方法
|
|
42560
|
-
*
|
|
42561
|
-
* @returns
|
|
42562
|
-
*/ _proto.dispose = function dispose() {
|
|
42563
|
-
if (this.destroyed) {
|
|
42564
|
-
return;
|
|
42565
|
-
}
|
|
42566
|
-
this.geometry.dispose();
|
|
42567
|
-
this.destroyed = true;
|
|
42568
|
-
Geometry.prototype.dispose.call(this);
|
|
42569
|
-
};
|
|
42570
|
-
_proto.setAttributeType = function setAttributeType(name, attr, geometry, attributes, maxCount) {
|
|
42571
|
-
var _attr_stride = attr.stride, stride = _attr_stride === void 0 ? 0 : _attr_stride, size = attr.size, offset = attr.offset, normalize = attr.normalize, _attr_type = attr.type, type = _attr_type === void 0 ? glContext.FLOAT : _attr_type;
|
|
42572
|
-
var data = attr.data;
|
|
42573
|
-
if (type && !data) {
|
|
42574
|
-
data = generateEmptyTypedArray(type);
|
|
42575
|
-
}
|
|
42576
|
-
if (!data) {
|
|
42577
|
-
return;
|
|
42578
|
-
}
|
|
42579
|
-
var dataLength = _instanceof1(data, Float32Array) ? Float32Array.BYTES_PER_ELEMENT : Uint16Array.BYTES_PER_ELEMENT;
|
|
42580
|
-
var threeStride = stride / dataLength;
|
|
42581
|
-
maxCount = (maxCount != null ? maxCount : 0) * threeStride;
|
|
42582
|
-
var count = maxCount || size * dataLength;
|
|
42583
|
-
if (count) {
|
|
42584
|
-
// 如果传入了data且data.length不为0 使用传入的data 否则根据length新建数组
|
|
42585
|
-
if (data.length === 0) {
|
|
42586
|
-
data = _instanceof1(data, Float32Array) ? new Float32Array(count) : new Uint16Array(count);
|
|
42587
|
-
}
|
|
42588
|
-
}
|
|
42589
|
-
var buffer = new THREE__namespace.InterleavedBuffer(data, threeStride);
|
|
42590
|
-
var attribute = new THREE__namespace.InterleavedBufferAttribute(buffer, size, (offset != null ? offset : 0) / dataLength, normalize);
|
|
42591
|
-
geometry.setAttribute(name, attribute);
|
|
42592
|
-
attributes[name] = {
|
|
42593
|
-
buffer: buffer,
|
|
42594
|
-
attribute: attribute,
|
|
42595
|
-
type: type,
|
|
42596
|
-
dataLength: dataLength
|
|
43528
|
+
var indexDataBuffer = indexBuffer;
|
|
43529
|
+
var nativeIndex = indexDataBuffer == null ? void 0 : indexDataBuffer.resource;
|
|
43530
|
+
if (_instanceof1(nativeIndex, THREE__namespace.BufferAttribute)) {
|
|
43531
|
+
geometry.setIndex(nativeIndex);
|
|
43532
|
+
}
|
|
43533
|
+
cache = {
|
|
43534
|
+
vertexBuffers: vertexBuffers,
|
|
43535
|
+
indexBuffer: indexBuffer,
|
|
43536
|
+
instanced: instanced,
|
|
43537
|
+
resource: geometry
|
|
42597
43538
|
};
|
|
42598
|
-
|
|
42599
|
-
|
|
42600
|
-
|
|
42601
|
-
|
|
42602
|
-
|
|
42603
|
-
|
|
42604
|
-
|
|
42605
|
-
|
|
42606
|
-
|
|
42607
|
-
|
|
42608
|
-
|
|
42609
|
-
|
|
42610
|
-
|
|
42611
|
-
|
|
42612
|
-
|
|
42613
|
-
|
|
42614
|
-
|
|
42615
|
-
|
|
42616
|
-
|
|
42617
|
-
|
|
42618
|
-
|
|
42619
|
-
|
|
42620
|
-
set: /**
|
|
42621
|
-
* 设置绘制起点
|
|
42622
|
-
*/ function set(val) {
|
|
42623
|
-
this.geometry.drawRange.start = val;
|
|
42624
|
-
}
|
|
42625
|
-
}
|
|
42626
|
-
]);
|
|
42627
|
-
return ThreeGeometry;
|
|
42628
|
-
}(Geometry);
|
|
43539
|
+
geometryCache.set(source, cache);
|
|
43540
|
+
}
|
|
43541
|
+
if (_instanceof1(cache.resource, THREE__namespace.InstancedBufferGeometry)) {
|
|
43542
|
+
cache.resource.instanceCount = source.instanceCount;
|
|
43543
|
+
}
|
|
43544
|
+
var drawStart = source.getIndexBuffer() ? source.getDrawStart() / getBytesPerElement(source.getIndexType()) : source.getDrawStart();
|
|
43545
|
+
cache.resource.setDrawRange(drawStart, source.getDrawCount());
|
|
43546
|
+
return cache.resource;
|
|
43547
|
+
}
|
|
43548
|
+
function isCacheValid(source, cache, attributeNames, indexBuffer, instanced) {
|
|
43549
|
+
if (cache.indexBuffer !== indexBuffer || cache.instanced !== instanced || Object.keys(cache.vertexBuffers).length !== attributeNames.length) {
|
|
43550
|
+
return false;
|
|
43551
|
+
}
|
|
43552
|
+
return attributeNames.every(function(name) {
|
|
43553
|
+
return cache.vertexBuffers[name] === source.getVertexBuffer(name);
|
|
43554
|
+
});
|
|
43555
|
+
}
|
|
43556
|
+
function disposeThreeGeometry(source) {
|
|
43557
|
+
var cache = geometryCache.get(source);
|
|
43558
|
+
cache == null ? void 0 : cache.resource.dispose();
|
|
43559
|
+
geometryCache.delete(source);
|
|
43560
|
+
}
|
|
42629
43561
|
|
|
42630
43562
|
/**
|
|
42631
43563
|
* mesh 抽象类的 THREE 实现
|
|
@@ -42640,10 +43572,11 @@ var seed = 1;
|
|
|
42640
43572
|
_this = Mesh.call(this, engine, props) || this;
|
|
42641
43573
|
_this.geometry = geometry;
|
|
42642
43574
|
_this.material = material;
|
|
43575
|
+
var nativeGeometry = getThreeGeometry(geometry);
|
|
42643
43576
|
if (geometry.mode === glContext.LINES) {
|
|
42644
|
-
_this.mesh = new THREE__namespace.LineSegments(
|
|
43577
|
+
_this.mesh = new THREE__namespace.LineSegments(nativeGeometry, material.material);
|
|
42645
43578
|
} else {
|
|
42646
|
-
_this.mesh = new THREE__namespace.Mesh(
|
|
43579
|
+
_this.mesh = new THREE__namespace.Mesh(nativeGeometry, material.material);
|
|
42647
43580
|
}
|
|
42648
43581
|
// 在抽象Mesh设置priority时,THREE 的 Mesh 还未创建
|
|
42649
43582
|
_this.priority = priority;
|
|
@@ -42695,6 +43628,7 @@ var seed = 1;
|
|
|
42695
43628
|
if (!this.getVisible()) {
|
|
42696
43629
|
return;
|
|
42697
43630
|
}
|
|
43631
|
+
this.mesh.geometry = getThreeGeometry(this.geometry);
|
|
42698
43632
|
this.material.setMatrix("effects_ObjectToWorld", this.worldMatrix);
|
|
42699
43633
|
this.material.use(renderer, renderer.renderingData.currentFrame.globalUniforms);
|
|
42700
43634
|
};
|
|
@@ -42943,6 +43877,27 @@ var ThreeRenderer = /*#__PURE__*/ function(Renderer) {
|
|
|
42943
43877
|
return ThreeRenderer;
|
|
42944
43878
|
}(Renderer);
|
|
42945
43879
|
|
|
43880
|
+
/**
|
|
43881
|
+
* 保存渲染后端中的缓冲区资源。
|
|
43882
|
+
*/ var ThreeDataBuffer = /*#__PURE__*/ function(DataBuffer) {
|
|
43883
|
+
_inherits(ThreeDataBuffer, DataBuffer);
|
|
43884
|
+
function ThreeDataBuffer(resource) {
|
|
43885
|
+
var _this;
|
|
43886
|
+
_this = DataBuffer.call(this) || this;
|
|
43887
|
+
_this.resource = resource;
|
|
43888
|
+
return _this;
|
|
43889
|
+
}
|
|
43890
|
+
_create_class(ThreeDataBuffer, [
|
|
43891
|
+
{
|
|
43892
|
+
key: "underlyingResource",
|
|
43893
|
+
get: function get() {
|
|
43894
|
+
return this.resource;
|
|
43895
|
+
}
|
|
43896
|
+
}
|
|
43897
|
+
]);
|
|
43898
|
+
return ThreeDataBuffer;
|
|
43899
|
+
}(DataBuffer);
|
|
43900
|
+
|
|
42946
43901
|
/**
|
|
42947
43902
|
* 挂载着合成需要的全局对象等
|
|
42948
43903
|
*/ var ThreeEngine = /*#__PURE__*/ function(Engine) {
|
|
@@ -42961,8 +43916,116 @@ var ThreeRenderer = /*#__PURE__*/ function(Renderer) {
|
|
|
42961
43916
|
this.threeGroup = threeGroup;
|
|
42962
43917
|
this.composition = composition;
|
|
42963
43918
|
};
|
|
43919
|
+
_proto.createVertexBuffer = function createVertexBuffer(data, options) {
|
|
43920
|
+
var typedData = toTypedArray(data, options.type);
|
|
43921
|
+
var stride = options.byteStride > 0 ? options.byteStride / typedData.BYTES_PER_ELEMENT : 1;
|
|
43922
|
+
var resource = options.instanceDivisor > 0 ? new THREE__namespace.InstancedInterleavedBuffer(typedData, stride, options.instanceDivisor) : new THREE__namespace.InterleavedBuffer(typedData, stride);
|
|
43923
|
+
return createDataBuffer(resource, typedData.byteLength);
|
|
43924
|
+
};
|
|
43925
|
+
_proto.createDynamicVertexBuffer = function createDynamicVertexBuffer(data, options) {
|
|
43926
|
+
return this.createVertexBuffer(data, options);
|
|
43927
|
+
};
|
|
43928
|
+
_proto.createIndexBuffer = function createIndexBuffer(indices) {
|
|
43929
|
+
var data = normalizeIndexData(indices);
|
|
43930
|
+
var buffer = createDataBuffer(new THREE__namespace.BufferAttribute(data, 1), data.byteLength);
|
|
43931
|
+
buffer.is32Bits = _instanceof1(data, Uint32Array);
|
|
43932
|
+
return buffer;
|
|
43933
|
+
};
|
|
43934
|
+
_proto.updateDynamicVertexBuffer = function updateDynamicVertexBuffer(vertexBuffer, data, byteOffset, byteLength) {
|
|
43935
|
+
if (byteOffset === void 0) byteOffset = 0;
|
|
43936
|
+
var view = toTypedArray(data, exports.BufferDataType.Float);
|
|
43937
|
+
if (byteLength !== undefined && byteLength < view.byteLength) {
|
|
43938
|
+
view = new Uint8Array(view.buffer, view.byteOffset, byteLength);
|
|
43939
|
+
}
|
|
43940
|
+
var resource = vertexBuffer.resource;
|
|
43941
|
+
if (!resource) {
|
|
43942
|
+
return;
|
|
43943
|
+
}
|
|
43944
|
+
if (byteOffset < 0 || byteOffset + view.byteLength > vertexBuffer.capacity) {
|
|
43945
|
+
throw new RangeError("Buffer update is out of range.");
|
|
43946
|
+
}
|
|
43947
|
+
var target = resource.array;
|
|
43948
|
+
var elementOffset = byteOffset / target.BYTES_PER_ELEMENT;
|
|
43949
|
+
if (!Number.isInteger(elementOffset)) {
|
|
43950
|
+
throw new RangeError("Buffer update is not aligned.");
|
|
43951
|
+
}
|
|
43952
|
+
target.set(view, elementOffset);
|
|
43953
|
+
resource.updateRange.offset = elementOffset;
|
|
43954
|
+
resource.updateRange.count = view.length;
|
|
43955
|
+
resource.needsUpdate = true;
|
|
43956
|
+
};
|
|
43957
|
+
_proto.updateDynamicIndexBuffer = function updateDynamicIndexBuffer(indexBuffer, indices, byteOffset) {
|
|
43958
|
+
if (byteOffset === void 0) byteOffset = 0;
|
|
43959
|
+
var data = indexBuffer.is32Bits ? _instanceof1(indices, Uint32Array) ? indices : new Uint32Array(indices) : _instanceof1(indices, Uint16Array) ? indices : new Uint16Array(indices);
|
|
43960
|
+
var resource = indexBuffer.resource;
|
|
43961
|
+
if (!resource) {
|
|
43962
|
+
return;
|
|
43963
|
+
}
|
|
43964
|
+
if (byteOffset < 0 || byteOffset + data.byteLength > indexBuffer.capacity) {
|
|
43965
|
+
throw new RangeError("Buffer update is out of range.");
|
|
43966
|
+
}
|
|
43967
|
+
var target = resource.array;
|
|
43968
|
+
var elementOffset = byteOffset / target.BYTES_PER_ELEMENT;
|
|
43969
|
+
if (!Number.isInteger(elementOffset)) {
|
|
43970
|
+
throw new RangeError("Buffer update is not aligned.");
|
|
43971
|
+
}
|
|
43972
|
+
target.set(data, elementOffset);
|
|
43973
|
+
resource.updateRange.offset = elementOffset;
|
|
43974
|
+
resource.updateRange.count = data.length;
|
|
43975
|
+
resource.needsUpdate = true;
|
|
43976
|
+
};
|
|
43977
|
+
/** @hide */ _proto.releaseBuffer = function releaseBuffer(buffer) {
|
|
43978
|
+
buffer.references--;
|
|
43979
|
+
if (buffer.references !== 0) {
|
|
43980
|
+
return false;
|
|
43981
|
+
}
|
|
43982
|
+
buffer.resource = undefined;
|
|
43983
|
+
buffer.capacity = 0;
|
|
43984
|
+
return true;
|
|
43985
|
+
};
|
|
43986
|
+
_proto.removeGeometry = function removeGeometry(geometry) {
|
|
43987
|
+
disposeThreeGeometry(geometry);
|
|
43988
|
+
Engine.prototype.removeGeometry.call(this, geometry);
|
|
43989
|
+
};
|
|
42964
43990
|
return ThreeEngine;
|
|
42965
43991
|
}(Engine);
|
|
43992
|
+
function toTypedArray(data, type) {
|
|
43993
|
+
if (typeof data === "number") {
|
|
43994
|
+
return createTypedArray(type, data / getBytesPerElement(type));
|
|
43995
|
+
}
|
|
43996
|
+
if (Array.isArray(data)) {
|
|
43997
|
+
var result = createTypedArray(type, data.length);
|
|
43998
|
+
result.set(data);
|
|
43999
|
+
return result;
|
|
44000
|
+
}
|
|
44001
|
+
if (_instanceof1(data, ArrayBuffer)) {
|
|
44002
|
+
var length = data.byteLength / getBytesPerElement(type);
|
|
44003
|
+
var result1 = createTypedArray(type, length);
|
|
44004
|
+
new Uint8Array(result1.buffer).set(new Uint8Array(data));
|
|
44005
|
+
return result1;
|
|
44006
|
+
}
|
|
44007
|
+
if (_instanceof1(data, DataView)) {
|
|
44008
|
+
return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
44009
|
+
}
|
|
44010
|
+
return data;
|
|
44011
|
+
}
|
|
44012
|
+
function normalizeIndexData(indices) {
|
|
44013
|
+
if (_instanceof1(indices, Uint16Array) || _instanceof1(indices, Uint32Array)) {
|
|
44014
|
+
return indices;
|
|
44015
|
+
}
|
|
44016
|
+
for(var i = 0; i < indices.length; i++){
|
|
44017
|
+
if (indices[i] >= 65535) {
|
|
44018
|
+
return new Uint32Array(indices);
|
|
44019
|
+
}
|
|
44020
|
+
}
|
|
44021
|
+
return new Uint16Array(indices);
|
|
44022
|
+
}
|
|
44023
|
+
function createDataBuffer(resource, capacity) {
|
|
44024
|
+
var buffer = new ThreeDataBuffer(resource);
|
|
44025
|
+
buffer.capacity = capacity;
|
|
44026
|
+
buffer.references = 1;
|
|
44027
|
+
return buffer;
|
|
44028
|
+
}
|
|
42966
44029
|
|
|
42967
44030
|
/**
|
|
42968
44031
|
*
|
|
@@ -43174,10 +44237,11 @@ exports.ThreeSpriteComponent = /*#__PURE__*/ function(SpriteComponent) {
|
|
|
43174
44237
|
_proto.fromData = function fromData(data) {
|
|
43175
44238
|
SpriteComponent.prototype.fromData.call(this, data);
|
|
43176
44239
|
if (!this.threeMesh) {
|
|
44240
|
+
var nativeGeometry = getThreeGeometry(this.geometry);
|
|
43177
44241
|
if (this.geometry.mode === glContext.LINES) {
|
|
43178
|
-
this.threeMesh = new THREE__namespace.LineSegments(
|
|
44242
|
+
this.threeMesh = new THREE__namespace.LineSegments(nativeGeometry, this.material.material);
|
|
43179
44243
|
} else {
|
|
43180
|
-
this.threeMesh = new THREE__namespace.Mesh(
|
|
44244
|
+
this.threeMesh = new THREE__namespace.Mesh(nativeGeometry, this.material.material);
|
|
43181
44245
|
}
|
|
43182
44246
|
}
|
|
43183
44247
|
};
|
|
@@ -43189,6 +44253,7 @@ exports.ThreeSpriteComponent = /*#__PURE__*/ function(SpriteComponent) {
|
|
|
43189
44253
|
if (!this.isActiveAndEnabled) {
|
|
43190
44254
|
return;
|
|
43191
44255
|
}
|
|
44256
|
+
this.threeMesh.geometry = getThreeGeometry(this.geometry);
|
|
43192
44257
|
this.material.setVector2("_Size", this.transform.size);
|
|
43193
44258
|
this.material.setMatrix("effects_ObjectToWorld", this.transform.getWorldMatrix());
|
|
43194
44259
|
this.material.use(renderer, renderer.renderingData.currentFrame.globalUniforms);
|
|
@@ -43310,14 +44375,6 @@ applyMixins(exports.ThreeTextComponent, [
|
|
|
43310
44375
|
*/ Material.create = function(engine, props) {
|
|
43311
44376
|
return new ThreeMaterial(engine, props);
|
|
43312
44377
|
};
|
|
43313
|
-
/**
|
|
43314
|
-
* geometry 创建方法
|
|
43315
|
-
*
|
|
43316
|
-
* @param options - geometry 创建参数
|
|
43317
|
-
* @returns THREE 中的抽象 geometry 对象
|
|
43318
|
-
*/ Geometry.create = function(engine, options) {
|
|
43319
|
-
return new ThreeGeometry(engine, options);
|
|
43320
|
-
};
|
|
43321
44378
|
/**
|
|
43322
44379
|
* mesh 创建方法
|
|
43323
44380
|
*
|
|
@@ -43326,7 +44383,7 @@ applyMixins(exports.ThreeTextComponent, [
|
|
|
43326
44383
|
*/ Mesh.create = function(engine, props) {
|
|
43327
44384
|
return new ThreeMesh(engine, props);
|
|
43328
44385
|
};
|
|
43329
|
-
var version = "2.10.0-alpha.
|
|
44386
|
+
var version = "2.10.0-alpha.2";
|
|
43330
44387
|
logger.info("THREEJS plugin version: " + version + ".");
|
|
43331
44388
|
|
|
43332
44389
|
exports.ATLAS_SIZE = ATLAS_SIZE;
|
|
@@ -43355,6 +44412,7 @@ exports.BezierQuat = BezierQuat;
|
|
|
43355
44412
|
exports.BlendNode = BlendNode;
|
|
43356
44413
|
exports.BoolValueNode = BoolValueNode;
|
|
43357
44414
|
exports.BoundingBoxInfo = BoundingBoxInfo;
|
|
44415
|
+
exports.Buffer = Buffer;
|
|
43358
44416
|
exports.CONSTANT_MAP_BLEND = CONSTANT_MAP_BLEND;
|
|
43359
44417
|
exports.CONSTANT_MAP_DEPTH = CONSTANT_MAP_DEPTH;
|
|
43360
44418
|
exports.CONSTANT_MAP_STENCIL_FUNC = CONSTANT_MAP_STENCIL_FUNC;
|
|
@@ -43384,6 +44442,7 @@ exports.ControlParameterFloatNode = ControlParameterFloatNode;
|
|
|
43384
44442
|
exports.ControlParameterTriggerNode = ControlParameterTriggerNode;
|
|
43385
44443
|
exports.DEFAULT_FONTS = DEFAULT_FONTS;
|
|
43386
44444
|
exports.DEFAULT_FPS = DEFAULT_FPS;
|
|
44445
|
+
exports.DataBuffer = DataBuffer;
|
|
43387
44446
|
exports.Database = Database;
|
|
43388
44447
|
exports.Deferred = Deferred;
|
|
43389
44448
|
exports.Downloader = Downloader;
|
|
@@ -43529,6 +44588,7 @@ exports.Vector3Curve = Vector3Curve;
|
|
|
43529
44588
|
exports.Vector3PropertyMixerPlayable = Vector3PropertyMixerPlayable;
|
|
43530
44589
|
exports.Vector4Curve = Vector4Curve;
|
|
43531
44590
|
exports.Vector4PropertyMixerPlayable = Vector4PropertyMixerPlayable;
|
|
44591
|
+
exports.VertexBuffer = VertexBuffer;
|
|
43532
44592
|
exports.addByOrder = addByOrder;
|
|
43533
44593
|
exports.addItem = addItem;
|
|
43534
44594
|
exports.addItemWithOrder = addItemWithOrder;
|
|
@@ -43551,6 +44611,7 @@ exports.combineImageTemplate = combineImageTemplate;
|
|
|
43551
44611
|
exports.createGLContext = createGLContext;
|
|
43552
44612
|
exports.createKeyFrameMeta = createKeyFrameMeta;
|
|
43553
44613
|
exports.createShape = createShape;
|
|
44614
|
+
exports.createTypedArray = createTypedArray;
|
|
43554
44615
|
exports.createValueGetter = createValueGetter;
|
|
43555
44616
|
exports.curveEps = curveEps;
|
|
43556
44617
|
exports.decimalEqual = decimalEqual;
|
|
@@ -43571,10 +44632,13 @@ exports.generateGUID = generateGUID;
|
|
|
43571
44632
|
exports.generateHalfFloatTexture = generateHalfFloatTexture;
|
|
43572
44633
|
exports.generateWhiteTexture = generateWhiteTexture;
|
|
43573
44634
|
exports.getBackgroundImage = getBackgroundImage;
|
|
44635
|
+
exports.getBytesPerElement = getBytesPerElement;
|
|
43574
44636
|
exports.getClass = getClass;
|
|
43575
44637
|
exports.getColorFromGradientStops = getColorFromGradientStops;
|
|
43576
44638
|
exports.getConfig = getConfig;
|
|
43577
44639
|
exports.getControlPoints = getControlPoints;
|
|
44640
|
+
exports.getDataByteLength = getDataByteLength;
|
|
44641
|
+
exports.getDataType = getDataType;
|
|
43578
44642
|
exports.getDefaultTextureFactory = getDefaultTextureFactory;
|
|
43579
44643
|
exports.getGeometryByShape = getGeometryByShape;
|
|
43580
44644
|
exports.getGeometryTriangles = getGeometryTriangles;
|
|
@@ -43664,6 +44728,7 @@ exports.spec = index$1;
|
|
|
43664
44728
|
exports.textureLoaderRegistry = textureLoaderRegistry;
|
|
43665
44729
|
exports.thresholdFrag = thresholdFrag;
|
|
43666
44730
|
exports.throwDestroyedError = throwDestroyedError;
|
|
44731
|
+
exports.toBufferView = toBufferView;
|
|
43667
44732
|
exports.trailVert = trailVert;
|
|
43668
44733
|
exports.translatePoint = translatePoint;
|
|
43669
44734
|
exports.trianglesFromRect = trianglesFromRect;
|