@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.mjs
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
|
import * as THREE from 'three';
|
|
@@ -8226,7 +8226,7 @@ function _loadMipmapImage() {
|
|
|
8226
8226
|
return _loadMipmapImage.apply(this, arguments);
|
|
8227
8227
|
}
|
|
8228
8228
|
|
|
8229
|
-
var seed$
|
|
8229
|
+
var seed$9 = 1;
|
|
8230
8230
|
/**
|
|
8231
8231
|
* Texture 抽象类
|
|
8232
8232
|
*/ var Texture = /*#__PURE__*/ function(EffectsObject) {
|
|
@@ -8235,7 +8235,7 @@ var seed$a = 1;
|
|
|
8235
8235
|
var _this;
|
|
8236
8236
|
_this = EffectsObject.call(this, engine) || this;
|
|
8237
8237
|
_this.destroyed = false;
|
|
8238
|
-
_this.id = "Tex" + seed$
|
|
8238
|
+
_this.id = "Tex" + seed$9++;
|
|
8239
8239
|
return _this;
|
|
8240
8240
|
}
|
|
8241
8241
|
var _proto = Texture.prototype;
|
|
@@ -11654,10 +11654,11 @@ var GLSLVersion;
|
|
|
11654
11654
|
})(GLSLVersion || (GLSLVersion = {}));
|
|
11655
11655
|
var ShaderVariant = /*#__PURE__*/ function(EffectsObject) {
|
|
11656
11656
|
_inherits(ShaderVariant, EffectsObject);
|
|
11657
|
-
function ShaderVariant(engine, source) {
|
|
11657
|
+
function ShaderVariant(engine, source, key) {
|
|
11658
11658
|
var _this;
|
|
11659
11659
|
_this = EffectsObject.call(this, engine) || this;
|
|
11660
11660
|
_this.source = source;
|
|
11661
|
+
_this.key = key;
|
|
11661
11662
|
return _this;
|
|
11662
11663
|
}
|
|
11663
11664
|
var _proto = ShaderVariant.prototype;
|
|
@@ -11963,7 +11964,7 @@ var MaterialRenderType;
|
|
|
11963
11964
|
/**
|
|
11964
11965
|
* 用于设置材质默认名称的自增序号
|
|
11965
11966
|
* @internal
|
|
11966
|
-
*/ var seed$
|
|
11967
|
+
*/ var seed$8 = 1;
|
|
11967
11968
|
/**
|
|
11968
11969
|
* Material 类
|
|
11969
11970
|
*/ var Material = /*#__PURE__*/ function(EffectsObject) {
|
|
@@ -11995,7 +11996,7 @@ var MaterialRenderType;
|
|
|
11995
11996
|
_this.macrosDirty = true;
|
|
11996
11997
|
_this.materialState = new MaterialState();
|
|
11997
11998
|
if (props) {
|
|
11998
|
-
var _props_name = props.name, name = _props_name === void 0 ? "Material" + seed$
|
|
11999
|
+
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;
|
|
11999
12000
|
_this.name = name;
|
|
12000
12001
|
_this.renderType = renderType; // TODO 没有地方用到
|
|
12001
12002
|
_this.shaderSource = shader;
|
|
@@ -12006,7 +12007,7 @@ var MaterialRenderType;
|
|
|
12006
12007
|
dataType: DataType.Shader
|
|
12007
12008
|
});
|
|
12008
12009
|
} else {
|
|
12009
|
-
_this.name = "Material" + seed$
|
|
12010
|
+
_this.name = "Material" + seed$8++;
|
|
12010
12011
|
_this.renderType = 0;
|
|
12011
12012
|
}
|
|
12012
12013
|
return _this;
|
|
@@ -12736,6 +12737,30 @@ var MAX_MASK_REFERENCE_COUNT = 254;
|
|
|
12736
12737
|
/**
|
|
12737
12738
|
* 期望的 stencil 值(等于正向蒙版的数量)
|
|
12738
12739
|
*/ this.expectedStencilValue = 0;
|
|
12740
|
+
this.prevStencilFunc = [
|
|
12741
|
+
0,
|
|
12742
|
+
0
|
|
12743
|
+
];
|
|
12744
|
+
this.prevStencilOpFail = [
|
|
12745
|
+
0,
|
|
12746
|
+
0
|
|
12747
|
+
];
|
|
12748
|
+
this.prevStencilOpZFail = [
|
|
12749
|
+
0,
|
|
12750
|
+
0
|
|
12751
|
+
];
|
|
12752
|
+
this.prevStencilOpZPass = [
|
|
12753
|
+
0,
|
|
12754
|
+
0
|
|
12755
|
+
];
|
|
12756
|
+
this.prevStencilRef = [
|
|
12757
|
+
0,
|
|
12758
|
+
0
|
|
12759
|
+
];
|
|
12760
|
+
this.prevStencilMask = [
|
|
12761
|
+
0,
|
|
12762
|
+
0
|
|
12763
|
+
];
|
|
12739
12764
|
this.stencilClearAction = {
|
|
12740
12765
|
stencilAction: TextureLoadAction.clear
|
|
12741
12766
|
};
|
|
@@ -12893,22 +12918,22 @@ var MAX_MASK_REFERENCE_COUNT = 254;
|
|
|
12893
12918
|
if (subMeshIndex === void 0) subMeshIndex = 0;
|
|
12894
12919
|
var prevColorMask = material.colorMask;
|
|
12895
12920
|
var prevStencilTest = material.stencilTest;
|
|
12896
|
-
|
|
12897
|
-
|
|
12898
|
-
|
|
12899
|
-
|
|
12900
|
-
|
|
12901
|
-
|
|
12921
|
+
this.copyStencilArrayValue(this.prevStencilFunc, material.stencilFunc);
|
|
12922
|
+
this.copyStencilArrayValue(this.prevStencilOpFail, material.stencilOpFail);
|
|
12923
|
+
this.copyStencilArrayValue(this.prevStencilOpZFail, material.stencilOpZFail);
|
|
12924
|
+
this.copyStencilArrayValue(this.prevStencilOpZPass, material.stencilOpZPass);
|
|
12925
|
+
this.copyStencilArrayValue(this.prevStencilRef, material.stencilRef);
|
|
12926
|
+
this.copyStencilArrayValue(this.prevStencilMask, material.stencilMask);
|
|
12902
12927
|
this.setupMaskMaterial(material, maskRef);
|
|
12903
12928
|
renderer.drawGeometry(geometry, worldMatrix, material, subMeshIndex);
|
|
12904
12929
|
material.colorMask = prevColorMask;
|
|
12905
12930
|
material.stencilTest = prevStencilTest;
|
|
12906
|
-
material.stencilFunc = prevStencilFunc;
|
|
12907
|
-
material.stencilOpFail = prevStencilOpFail;
|
|
12908
|
-
material.stencilOpZFail = prevStencilOpZFail;
|
|
12909
|
-
material.stencilOpZPass = prevStencilOpZPass;
|
|
12910
|
-
material.stencilRef = prevStencilRef;
|
|
12911
|
-
material.stencilMask = prevStencilMask;
|
|
12931
|
+
material.stencilFunc = this.prevStencilFunc;
|
|
12932
|
+
material.stencilOpFail = this.prevStencilOpFail;
|
|
12933
|
+
material.stencilOpZFail = this.prevStencilOpZFail;
|
|
12934
|
+
material.stencilOpZPass = this.prevStencilOpZPass;
|
|
12935
|
+
material.stencilRef = this.prevStencilRef;
|
|
12936
|
+
material.stencilMask = this.prevStencilMask;
|
|
12912
12937
|
};
|
|
12913
12938
|
/**
|
|
12914
12939
|
* 设置蒙版材质的 stencil 属性(写入蒙版)
|
|
@@ -12982,6 +13007,13 @@ var MAX_MASK_REFERENCE_COUNT = 254;
|
|
|
12982
13007
|
material.stencilTest = false;
|
|
12983
13008
|
}
|
|
12984
13009
|
};
|
|
13010
|
+
_proto.copyStencilArrayValue = function copyStencilArrayValue(target, source) {
|
|
13011
|
+
if (!source) {
|
|
13012
|
+
return;
|
|
13013
|
+
}
|
|
13014
|
+
target[0] = source[0];
|
|
13015
|
+
target[1] = source[1];
|
|
13016
|
+
};
|
|
12985
13017
|
_create_class(MaskProcessor, [
|
|
12986
13018
|
{
|
|
12987
13019
|
key: "maskable",
|
|
@@ -13006,6 +13038,401 @@ var MAX_MASK_REFERENCE_COUNT = 254;
|
|
|
13006
13038
|
return MaskProcessor;
|
|
13007
13039
|
}();
|
|
13008
13040
|
|
|
13041
|
+
var BufferUsage;
|
|
13042
|
+
(function(BufferUsage) {
|
|
13043
|
+
BufferUsage[BufferUsage["Stream"] = 35040] = "Stream";
|
|
13044
|
+
BufferUsage[BufferUsage["Static"] = 35044] = "Static";
|
|
13045
|
+
BufferUsage[BufferUsage["Dynamic"] = 35048] = "Dynamic";
|
|
13046
|
+
})(BufferUsage || (BufferUsage = {}));
|
|
13047
|
+
var BufferDataType;
|
|
13048
|
+
(function(BufferDataType) {
|
|
13049
|
+
BufferDataType[BufferDataType["Byte"] = 5120] = "Byte";
|
|
13050
|
+
BufferDataType[BufferDataType["UnsignedByte"] = 5121] = "UnsignedByte";
|
|
13051
|
+
BufferDataType[BufferDataType["Short"] = 5122] = "Short";
|
|
13052
|
+
BufferDataType[BufferDataType["UnsignedShort"] = 5123] = "UnsignedShort";
|
|
13053
|
+
BufferDataType[BufferDataType["Int"] = 5124] = "Int";
|
|
13054
|
+
BufferDataType[BufferDataType["UnsignedInt"] = 5125] = "UnsignedInt";
|
|
13055
|
+
BufferDataType[BufferDataType["Float"] = 5126] = "Float";
|
|
13056
|
+
})(BufferDataType || (BufferDataType = {}));
|
|
13057
|
+
/**
|
|
13058
|
+
* 后端缓冲区的最小抽象,只保存资源状态。
|
|
13059
|
+
*/ var DataBuffer = /*#__PURE__*/ function() {
|
|
13060
|
+
function DataBuffer() {
|
|
13061
|
+
this.references = 0;
|
|
13062
|
+
this.capacity = 0;
|
|
13063
|
+
this.is32Bits = false;
|
|
13064
|
+
}
|
|
13065
|
+
_create_class(DataBuffer, [
|
|
13066
|
+
{
|
|
13067
|
+
key: "underlyingResource",
|
|
13068
|
+
get: function get() {
|
|
13069
|
+
return null;
|
|
13070
|
+
}
|
|
13071
|
+
}
|
|
13072
|
+
]);
|
|
13073
|
+
return DataBuffer;
|
|
13074
|
+
}();
|
|
13075
|
+
function getBytesPerElement(type) {
|
|
13076
|
+
switch(type){
|
|
13077
|
+
case 5120:
|
|
13078
|
+
case 5121:
|
|
13079
|
+
return 1;
|
|
13080
|
+
case 5122:
|
|
13081
|
+
case 5123:
|
|
13082
|
+
return 2;
|
|
13083
|
+
case 5124:
|
|
13084
|
+
case 5125:
|
|
13085
|
+
case 5126:
|
|
13086
|
+
return 4;
|
|
13087
|
+
default:
|
|
13088
|
+
return 0;
|
|
13089
|
+
}
|
|
13090
|
+
}
|
|
13091
|
+
function getDataType(data) {
|
|
13092
|
+
if (_instanceof1(data, Int8Array)) {
|
|
13093
|
+
return 5120;
|
|
13094
|
+
}
|
|
13095
|
+
if (_instanceof1(data, Uint8Array)) {
|
|
13096
|
+
return 5121;
|
|
13097
|
+
}
|
|
13098
|
+
if (_instanceof1(data, Int16Array)) {
|
|
13099
|
+
return 5122;
|
|
13100
|
+
}
|
|
13101
|
+
if (_instanceof1(data, Uint16Array)) {
|
|
13102
|
+
return 5123;
|
|
13103
|
+
}
|
|
13104
|
+
if (_instanceof1(data, Int32Array)) {
|
|
13105
|
+
return 5124;
|
|
13106
|
+
}
|
|
13107
|
+
if (_instanceof1(data, Uint32Array)) {
|
|
13108
|
+
return 5125;
|
|
13109
|
+
}
|
|
13110
|
+
return 5126;
|
|
13111
|
+
}
|
|
13112
|
+
function getDataByteLength(data) {
|
|
13113
|
+
if (Array.isArray(data)) {
|
|
13114
|
+
return data.length * Float32Array.BYTES_PER_ELEMENT;
|
|
13115
|
+
}
|
|
13116
|
+
return data.byteLength;
|
|
13117
|
+
}
|
|
13118
|
+
function toBufferView(data) {
|
|
13119
|
+
if (Array.isArray(data)) {
|
|
13120
|
+
return new Float32Array(data);
|
|
13121
|
+
}
|
|
13122
|
+
if (_instanceof1(data, ArrayBuffer)) {
|
|
13123
|
+
return new Uint8Array(data);
|
|
13124
|
+
}
|
|
13125
|
+
return data;
|
|
13126
|
+
}
|
|
13127
|
+
function createTypedArray(type, length) {
|
|
13128
|
+
switch(type){
|
|
13129
|
+
case 5120:
|
|
13130
|
+
return new Int8Array(length);
|
|
13131
|
+
case 5121:
|
|
13132
|
+
return new Uint8Array(length);
|
|
13133
|
+
case 5122:
|
|
13134
|
+
return new Int16Array(length);
|
|
13135
|
+
case 5123:
|
|
13136
|
+
return new Uint16Array(length);
|
|
13137
|
+
case 5124:
|
|
13138
|
+
return new Int32Array(length);
|
|
13139
|
+
case 5125:
|
|
13140
|
+
return new Uint32Array(length);
|
|
13141
|
+
default:
|
|
13142
|
+
return new Float32Array(length);
|
|
13143
|
+
}
|
|
13144
|
+
}
|
|
13145
|
+
|
|
13146
|
+
/**
|
|
13147
|
+
* 管理顶点数据及其对应的后端缓冲区。
|
|
13148
|
+
*/ var Buffer = /*#__PURE__*/ function() {
|
|
13149
|
+
function Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes, divisor, label) {
|
|
13150
|
+
if (stride === void 0) stride = 0;
|
|
13151
|
+
if (postponeInternalCreation === void 0) postponeInternalCreation = false;
|
|
13152
|
+
if (instanced === void 0) instanced = false;
|
|
13153
|
+
if (useBytes === void 0) useBytes = false;
|
|
13154
|
+
this.engine = engine;
|
|
13155
|
+
this.isAlreadyOwned = false;
|
|
13156
|
+
this._isDisposed = false;
|
|
13157
|
+
this.updatable = updatable;
|
|
13158
|
+
this.instanced = instanced;
|
|
13159
|
+
this.divisor = divisor || 1;
|
|
13160
|
+
this.label = label;
|
|
13161
|
+
this.byteStride = useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT;
|
|
13162
|
+
if (_instanceof1(data, DataBuffer)) {
|
|
13163
|
+
this.buffer = data;
|
|
13164
|
+
} else {
|
|
13165
|
+
this.data = data;
|
|
13166
|
+
}
|
|
13167
|
+
if (!postponeInternalCreation) {
|
|
13168
|
+
this.create();
|
|
13169
|
+
}
|
|
13170
|
+
}
|
|
13171
|
+
var _proto = Buffer.prototype;
|
|
13172
|
+
_proto.isUpdatable = function isUpdatable() {
|
|
13173
|
+
return this.updatable;
|
|
13174
|
+
};
|
|
13175
|
+
_proto.getData = function getData() {
|
|
13176
|
+
return this.data;
|
|
13177
|
+
};
|
|
13178
|
+
_proto.getBuffer = function getBuffer() {
|
|
13179
|
+
return this.buffer;
|
|
13180
|
+
};
|
|
13181
|
+
_proto.getStrideSize = function getStrideSize() {
|
|
13182
|
+
return this.byteStride / Float32Array.BYTES_PER_ELEMENT;
|
|
13183
|
+
};
|
|
13184
|
+
_proto.createVertexBuffer = function createVertexBuffer(kind, offset, size, stride, instanced, useBytes, divisor) {
|
|
13185
|
+
if (useBytes === void 0) useBytes = false;
|
|
13186
|
+
var byteOffset = useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT;
|
|
13187
|
+
var byteStride = stride ? useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT : this.byteStride;
|
|
13188
|
+
return new VertexBuffer(this.engine, this, kind, {
|
|
13189
|
+
size: size,
|
|
13190
|
+
stride: byteStride,
|
|
13191
|
+
offset: byteOffset,
|
|
13192
|
+
instanced: instanced === undefined ? this.instanced : instanced,
|
|
13193
|
+
useBytes: true,
|
|
13194
|
+
divisor: divisor != null ? divisor : this.divisor
|
|
13195
|
+
});
|
|
13196
|
+
};
|
|
13197
|
+
_proto.create = function create(data) {
|
|
13198
|
+
if (!data && this.buffer) {
|
|
13199
|
+
return;
|
|
13200
|
+
}
|
|
13201
|
+
data = data != null ? data : this.data;
|
|
13202
|
+
if (!data) {
|
|
13203
|
+
return;
|
|
13204
|
+
}
|
|
13205
|
+
var options = this.getDataBufferOptions(data);
|
|
13206
|
+
if (!this.buffer) {
|
|
13207
|
+
this.buffer = this.updatable ? this.engine.createDynamicVertexBuffer(data, options) : this.engine.createVertexBuffer(data, options);
|
|
13208
|
+
if (this.updatable) {
|
|
13209
|
+
this.data = data;
|
|
13210
|
+
}
|
|
13211
|
+
} else if (this.updatable) {
|
|
13212
|
+
this.engine.updateDynamicVertexBuffer(this.buffer, data);
|
|
13213
|
+
this.data = data;
|
|
13214
|
+
}
|
|
13215
|
+
};
|
|
13216
|
+
_proto.update = function update(data) {
|
|
13217
|
+
this.create(data);
|
|
13218
|
+
};
|
|
13219
|
+
_proto.updateDirectly = function updateDirectly(data, offset, vertexCount, useBytes) {
|
|
13220
|
+
if (useBytes === void 0) useBytes = false;
|
|
13221
|
+
if (!this.buffer || !this.updatable) {
|
|
13222
|
+
return;
|
|
13223
|
+
}
|
|
13224
|
+
this.engine.updateDynamicVertexBuffer(this.buffer, data, useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT, vertexCount ? vertexCount * this.byteStride : undefined);
|
|
13225
|
+
if (offset === 0 && vertexCount === undefined) {
|
|
13226
|
+
this.data = data;
|
|
13227
|
+
} else {
|
|
13228
|
+
this.data = undefined;
|
|
13229
|
+
}
|
|
13230
|
+
};
|
|
13231
|
+
/**
|
|
13232
|
+
* @internal
|
|
13233
|
+
*/ _proto.rebuild = function rebuild() {
|
|
13234
|
+
if (!this.data) {
|
|
13235
|
+
if (!this.buffer) {
|
|
13236
|
+
return;
|
|
13237
|
+
}
|
|
13238
|
+
var capacity = this.buffer.capacity;
|
|
13239
|
+
if (capacity > 0) {
|
|
13240
|
+
var options = this.getDataBufferOptions();
|
|
13241
|
+
this.buffer = this.updatable ? this.engine.createDynamicVertexBuffer(capacity, options) : this.engine.createVertexBuffer(capacity, options);
|
|
13242
|
+
} else {
|
|
13243
|
+
this.buffer = undefined;
|
|
13244
|
+
}
|
|
13245
|
+
return;
|
|
13246
|
+
}
|
|
13247
|
+
this.buffer = undefined;
|
|
13248
|
+
this.create(this.data);
|
|
13249
|
+
};
|
|
13250
|
+
/**
|
|
13251
|
+
* @internal
|
|
13252
|
+
*/ _proto.increaseReferences = function increaseReferences() {
|
|
13253
|
+
if (!this.buffer) {
|
|
13254
|
+
return;
|
|
13255
|
+
}
|
|
13256
|
+
if (!this.isAlreadyOwned) {
|
|
13257
|
+
this.isAlreadyOwned = true;
|
|
13258
|
+
return;
|
|
13259
|
+
}
|
|
13260
|
+
this.buffer.references++;
|
|
13261
|
+
};
|
|
13262
|
+
_proto.dispose = function dispose() {
|
|
13263
|
+
if (!this.buffer) {
|
|
13264
|
+
return;
|
|
13265
|
+
}
|
|
13266
|
+
if (this.engine.releaseBuffer(this.buffer)) {
|
|
13267
|
+
this.data = undefined;
|
|
13268
|
+
this.buffer = undefined;
|
|
13269
|
+
this._isDisposed = true;
|
|
13270
|
+
}
|
|
13271
|
+
};
|
|
13272
|
+
_proto.getDataBufferOptions = function getDataBufferOptions(data) {
|
|
13273
|
+
return {
|
|
13274
|
+
usage: this.updatable ? BufferUsage.Dynamic : BufferUsage.Static,
|
|
13275
|
+
type: data ? getDataType(data) : BufferDataType.Float,
|
|
13276
|
+
byteStride: this.byteStride,
|
|
13277
|
+
instanceDivisor: this.instanced ? this.divisor : 0,
|
|
13278
|
+
label: this.label
|
|
13279
|
+
};
|
|
13280
|
+
};
|
|
13281
|
+
_create_class(Buffer, [
|
|
13282
|
+
{
|
|
13283
|
+
key: "isDisposed",
|
|
13284
|
+
get: function get() {
|
|
13285
|
+
return this._isDisposed;
|
|
13286
|
+
}
|
|
13287
|
+
},
|
|
13288
|
+
{
|
|
13289
|
+
key: "capacity",
|
|
13290
|
+
get: function get() {
|
|
13291
|
+
var _this_buffer;
|
|
13292
|
+
var _this_buffer_capacity;
|
|
13293
|
+
return (_this_buffer_capacity = (_this_buffer = this.buffer) == null ? void 0 : _this_buffer.capacity) != null ? _this_buffer_capacity : this.data ? getDataByteLength(this.data) : 0;
|
|
13294
|
+
}
|
|
13295
|
+
}
|
|
13296
|
+
]);
|
|
13297
|
+
return Buffer;
|
|
13298
|
+
}();
|
|
13299
|
+
|
|
13300
|
+
/**
|
|
13301
|
+
* 描述一个顶点属性如何读取共享缓冲区。
|
|
13302
|
+
*/ var VertexBuffer = /*#__PURE__*/ function() {
|
|
13303
|
+
function VertexBuffer(engine, data, kind, props) {
|
|
13304
|
+
if (props === void 0) props = {};
|
|
13305
|
+
this._isDisposed = false;
|
|
13306
|
+
this.engine = engine;
|
|
13307
|
+
this.kind = kind;
|
|
13308
|
+
if (_instanceof1(data, Buffer)) {
|
|
13309
|
+
this.buffer = data;
|
|
13310
|
+
var _props_takeBufferOwnership;
|
|
13311
|
+
this.ownsBuffer = (_props_takeBufferOwnership = props.takeBufferOwnership) != null ? _props_takeBufferOwnership : false;
|
|
13312
|
+
} else {
|
|
13313
|
+
var _props_updatable, _props_stride, _props_postponeInternalCreation, _props_instanced, _props_useBytes;
|
|
13314
|
+
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);
|
|
13315
|
+
this.ownsBuffer = true;
|
|
13316
|
+
}
|
|
13317
|
+
var source = this.getData();
|
|
13318
|
+
var _props_type;
|
|
13319
|
+
this.type = (_props_type = props.type) != null ? _props_type : source ? getDataType(source) : VertexBuffer.FLOAT;
|
|
13320
|
+
var typeByteLength = getBytesPerElement(this.type);
|
|
13321
|
+
var _props_useBytes1;
|
|
13322
|
+
var useBytes = (_props_useBytes1 = props.useBytes) != null ? _props_useBytes1 : false;
|
|
13323
|
+
var _props_stride1;
|
|
13324
|
+
var stride = (_props_stride1 = props.stride) != null ? _props_stride1 : 0;
|
|
13325
|
+
var _props_offset;
|
|
13326
|
+
var offset = (_props_offset = props.offset) != null ? _props_offset : 0;
|
|
13327
|
+
if (useBytes) {
|
|
13328
|
+
this.size = props.size || (stride ? stride / typeByteLength : 0);
|
|
13329
|
+
this.byteStride = stride || this.buffer.byteStride || this.size * typeByteLength;
|
|
13330
|
+
this.byteOffset = offset;
|
|
13331
|
+
} else {
|
|
13332
|
+
this.size = props.size || stride;
|
|
13333
|
+
this.byteStride = stride ? stride * typeByteLength : this.buffer.byteStride || this.size * typeByteLength;
|
|
13334
|
+
this.byteOffset = offset * typeByteLength;
|
|
13335
|
+
}
|
|
13336
|
+
var _props_normalized;
|
|
13337
|
+
this.normalized = (_props_normalized = props.normalized) != null ? _props_normalized : false;
|
|
13338
|
+
var _props_instanced1;
|
|
13339
|
+
this.instanced = (_props_instanced1 = props.instanced) != null ? _props_instanced1 : false;
|
|
13340
|
+
var _props_divisor;
|
|
13341
|
+
this._instanceDivisor = this.instanced ? (_props_divisor = props.divisor) != null ? _props_divisor : 1 : 0;
|
|
13342
|
+
}
|
|
13343
|
+
var _proto = VertexBuffer.prototype;
|
|
13344
|
+
_proto.getKind = function getKind() {
|
|
13345
|
+
return this.kind;
|
|
13346
|
+
};
|
|
13347
|
+
_proto.isUpdatable = function isUpdatable() {
|
|
13348
|
+
return this.buffer.isUpdatable();
|
|
13349
|
+
};
|
|
13350
|
+
_proto.getData = function getData() {
|
|
13351
|
+
return this.buffer.getData();
|
|
13352
|
+
};
|
|
13353
|
+
_proto.getBuffer = function getBuffer() {
|
|
13354
|
+
return this.buffer.getBuffer();
|
|
13355
|
+
};
|
|
13356
|
+
_proto.getWrapperBuffer = function getWrapperBuffer() {
|
|
13357
|
+
return this.buffer;
|
|
13358
|
+
};
|
|
13359
|
+
_proto.getStrideSize = function getStrideSize() {
|
|
13360
|
+
return this.byteStride / getBytesPerElement(this.type);
|
|
13361
|
+
};
|
|
13362
|
+
_proto.getOffset = function getOffset() {
|
|
13363
|
+
return this.byteOffset / getBytesPerElement(this.type);
|
|
13364
|
+
};
|
|
13365
|
+
_proto.getSize = function getSize(sizeInBytes) {
|
|
13366
|
+
if (sizeInBytes === void 0) sizeInBytes = false;
|
|
13367
|
+
return sizeInBytes ? this.size * getBytesPerElement(this.type) : this.size;
|
|
13368
|
+
};
|
|
13369
|
+
_proto.getIsInstanced = function getIsInstanced() {
|
|
13370
|
+
return this.instanced;
|
|
13371
|
+
};
|
|
13372
|
+
_proto.getInstanceDivisor = function getInstanceDivisor() {
|
|
13373
|
+
return this._instanceDivisor;
|
|
13374
|
+
};
|
|
13375
|
+
_proto.create = function create(data) {
|
|
13376
|
+
this.buffer.create(data);
|
|
13377
|
+
};
|
|
13378
|
+
_proto.update = function update(data) {
|
|
13379
|
+
this.buffer.update(data);
|
|
13380
|
+
};
|
|
13381
|
+
_proto.updateDirectly = function updateDirectly(data, offset, useBytes) {
|
|
13382
|
+
if (useBytes === void 0) useBytes = false;
|
|
13383
|
+
this.buffer.updateDirectly(data, offset, undefined, useBytes);
|
|
13384
|
+
};
|
|
13385
|
+
/**
|
|
13386
|
+
* @internal
|
|
13387
|
+
*/ _proto.rebuild = function rebuild() {
|
|
13388
|
+
this.buffer.rebuild();
|
|
13389
|
+
};
|
|
13390
|
+
_proto.dispose = function dispose() {
|
|
13391
|
+
if (this.ownsBuffer) {
|
|
13392
|
+
this.buffer.dispose();
|
|
13393
|
+
}
|
|
13394
|
+
this._isDisposed = true;
|
|
13395
|
+
};
|
|
13396
|
+
_create_class(VertexBuffer, [
|
|
13397
|
+
{
|
|
13398
|
+
key: "isDisposed",
|
|
13399
|
+
get: function get() {
|
|
13400
|
+
return this._isDisposed;
|
|
13401
|
+
}
|
|
13402
|
+
},
|
|
13403
|
+
{
|
|
13404
|
+
key: "instanceDivisor",
|
|
13405
|
+
get: function get() {
|
|
13406
|
+
return this._instanceDivisor;
|
|
13407
|
+
},
|
|
13408
|
+
set: function set(value) {
|
|
13409
|
+
this._instanceDivisor = value;
|
|
13410
|
+
this.instanced = value !== 0;
|
|
13411
|
+
}
|
|
13412
|
+
}
|
|
13413
|
+
]);
|
|
13414
|
+
return VertexBuffer;
|
|
13415
|
+
}();
|
|
13416
|
+
VertexBuffer.PositionKind = "aPos";
|
|
13417
|
+
VertexBuffer.NormalKind = "aNormal";
|
|
13418
|
+
VertexBuffer.TangentKind = "aTangent";
|
|
13419
|
+
VertexBuffer.UVKind = "aUV";
|
|
13420
|
+
VertexBuffer.UV2Kind = "aUV2";
|
|
13421
|
+
VertexBuffer.UV3Kind = "aUV3";
|
|
13422
|
+
VertexBuffer.UV4Kind = "aUV4";
|
|
13423
|
+
VertexBuffer.UV5Kind = "aUV5";
|
|
13424
|
+
VertexBuffer.UV6Kind = "aUV6";
|
|
13425
|
+
VertexBuffer.ColorKind = "aColor";
|
|
13426
|
+
VertexBuffer.JointsKind = "aJoints";
|
|
13427
|
+
VertexBuffer.WeightsKind = "aWeights";
|
|
13428
|
+
VertexBuffer.BYTE = BufferDataType.Byte;
|
|
13429
|
+
VertexBuffer.UNSIGNED_BYTE = BufferDataType.UnsignedByte;
|
|
13430
|
+
VertexBuffer.SHORT = BufferDataType.Short;
|
|
13431
|
+
VertexBuffer.UNSIGNED_SHORT = BufferDataType.UnsignedShort;
|
|
13432
|
+
VertexBuffer.INT = BufferDataType.Int;
|
|
13433
|
+
VertexBuffer.UNSIGNED_INT = BufferDataType.UnsignedInt;
|
|
13434
|
+
VertexBuffer.FLOAT = BufferDataType.Float;
|
|
13435
|
+
|
|
13009
13436
|
var HitTestType;
|
|
13010
13437
|
(function(HitTestType) {
|
|
13011
13438
|
HitTestType[HitTestType["triangle"] = 1] = "triangle";
|
|
@@ -13328,7 +13755,7 @@ BoundingBox.tempVector2 = new Vector3();
|
|
|
13328
13755
|
};
|
|
13329
13756
|
_proto.geometryToTriangles = function geometryToTriangles(geometry) {
|
|
13330
13757
|
var indices = geometry.getIndexData();
|
|
13331
|
-
var vertices = geometry.getAttributeData(
|
|
13758
|
+
var vertices = geometry.getAttributeData(VertexBuffer.PositionKind);
|
|
13332
13759
|
var res = [];
|
|
13333
13760
|
if (!indices || !vertices) {
|
|
13334
13761
|
return res;
|
|
@@ -13534,7 +13961,7 @@ var HELP_LINK = {
|
|
|
13534
13961
|
var tempQuat$1 = new Quaternion();
|
|
13535
13962
|
var tempVector3$1 = new Vector3();
|
|
13536
13963
|
var tempVector3Second$1 = new Vector3();
|
|
13537
|
-
var seed$
|
|
13964
|
+
var seed$7 = 1;
|
|
13538
13965
|
/**
|
|
13539
13966
|
* 变换组件,用于描述元素的位置、旋转、缩放等信息
|
|
13540
13967
|
*/ var Transform = /*#__PURE__*/ function() {
|
|
@@ -13589,7 +14016,7 @@ var seed$8 = 1;
|
|
|
13589
14016
|
quat: new Quaternion(0, 0, 0, 1),
|
|
13590
14017
|
scale: new Vector3(1, 1, 1)
|
|
13591
14018
|
};
|
|
13592
|
-
this.name = "transform_" + seed$
|
|
14019
|
+
this.name = "transform_" + seed$7++;
|
|
13593
14020
|
if (props) {
|
|
13594
14021
|
this.setTransform(props);
|
|
13595
14022
|
}
|
|
@@ -20031,310 +20458,6 @@ CompositionComponent = __decorate([
|
|
|
20031
20458
|
effectsClass("CompositionComponent")
|
|
20032
20459
|
], CompositionComponent);
|
|
20033
20460
|
|
|
20034
|
-
/**
|
|
20035
|
-
* Mesh 组件
|
|
20036
|
-
*/ var MeshComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
20037
|
-
_inherits(MeshComponent, RendererComponent);
|
|
20038
|
-
function MeshComponent(engine) {
|
|
20039
|
-
var _this;
|
|
20040
|
-
_this = RendererComponent.call(this, engine) || this;
|
|
20041
|
-
// TODO 点击测试后续抽象一个 Collider 组件
|
|
20042
|
-
_this.getHitTestParams = function(force) {
|
|
20043
|
-
var worldMatrix = _this.transform.getWorldMatrix();
|
|
20044
|
-
_this.boundingBoxInfo.setGeometry(_this.geometry, worldMatrix);
|
|
20045
|
-
var area = _this.boundingBoxInfo.getRawBoundingBoxTriangle();
|
|
20046
|
-
if (area) {
|
|
20047
|
-
return {
|
|
20048
|
-
type: area.type,
|
|
20049
|
-
triangles: area.area,
|
|
20050
|
-
clipMasks: _this.frameClipMasks
|
|
20051
|
-
};
|
|
20052
|
-
}
|
|
20053
|
-
};
|
|
20054
|
-
return _this;
|
|
20055
|
-
}
|
|
20056
|
-
var _proto = MeshComponent.prototype;
|
|
20057
|
-
_proto.render = function render(renderer) {
|
|
20058
|
-
this.maskManager.drawStencilMask(renderer, this);
|
|
20059
|
-
for(var i = 0; i < this.materials.length; i++){
|
|
20060
|
-
var material = this.materials[i];
|
|
20061
|
-
renderer.drawGeometry(this.geometry, this.transform.getWorldMatrix(), material, i);
|
|
20062
|
-
}
|
|
20063
|
-
};
|
|
20064
|
-
_proto.drawStencilMask = function drawStencilMask(maskRef) {
|
|
20065
|
-
if (!this.isActiveAndEnabled) {
|
|
20066
|
-
return;
|
|
20067
|
-
}
|
|
20068
|
-
for(var i = 0; i < this.materials.length; i++){
|
|
20069
|
-
var material = this.materials[i];
|
|
20070
|
-
this.maskManager.drawGeometryMask(this.engine.renderer, this.geometry, this.transform.getWorldMatrix(), material, maskRef, i);
|
|
20071
|
-
}
|
|
20072
|
-
};
|
|
20073
|
-
_proto.getBoundingBox = function getBoundingBox() {
|
|
20074
|
-
var worldMatrix = this.transform.getWorldMatrix();
|
|
20075
|
-
this.boundingBoxInfo.setGeometry(this.geometry, worldMatrix);
|
|
20076
|
-
var boundingBox = this.boundingBoxInfo.getBoundingBoxTriangle();
|
|
20077
|
-
return boundingBox;
|
|
20078
|
-
};
|
|
20079
|
-
_proto.getBoundingBoxInfo = function getBoundingBoxInfo() {
|
|
20080
|
-
var positionArray = this.geometry.getAttributeData("aPos");
|
|
20081
|
-
if (positionArray) {
|
|
20082
|
-
var minMaxResult = extractMinAndMax(positionArray, 0, positionArray.length / 3);
|
|
20083
|
-
minMaxResult.minimum.x *= this.transform.size.x;
|
|
20084
|
-
minMaxResult.minimum.y *= this.transform.size.y;
|
|
20085
|
-
minMaxResult.maximum.x *= this.transform.size.x;
|
|
20086
|
-
minMaxResult.maximum.y *= this.transform.size.y;
|
|
20087
|
-
this.boundingBoxInfo.reConstruct(minMaxResult.minimum, minMaxResult.maximum, this.transform.getWorldMatrix());
|
|
20088
|
-
}
|
|
20089
|
-
return this.boundingBoxInfo;
|
|
20090
|
-
};
|
|
20091
|
-
_proto.fromData = function fromData(data) {
|
|
20092
|
-
RendererComponent.prototype.fromData.call(this, data);
|
|
20093
|
-
var maskOptions = data.mask;
|
|
20094
|
-
if (maskOptions) {
|
|
20095
|
-
this.maskManager.setMaskOptions(this.engine, maskOptions);
|
|
20096
|
-
}
|
|
20097
|
-
};
|
|
20098
|
-
return MeshComponent;
|
|
20099
|
-
}(RendererComponent);
|
|
20100
|
-
__decorate([
|
|
20101
|
-
serialize()
|
|
20102
|
-
], MeshComponent.prototype, "geometry", void 0);
|
|
20103
|
-
|
|
20104
|
-
var EffectComponent = /*#__PURE__*/ function(MeshComponent) {
|
|
20105
|
-
_inherits(EffectComponent, MeshComponent);
|
|
20106
|
-
function EffectComponent(engine) {
|
|
20107
|
-
var _this;
|
|
20108
|
-
_this = MeshComponent.call(this, engine) || this;
|
|
20109
|
-
_this.time = 0;
|
|
20110
|
-
_this.name = "EffectComponent";
|
|
20111
|
-
return _this;
|
|
20112
|
-
}
|
|
20113
|
-
var _proto = EffectComponent.prototype;
|
|
20114
|
-
_proto.onStart = function onStart() {
|
|
20115
|
-
this.item.getHitTestParams = this.getHitTestParams;
|
|
20116
|
-
};
|
|
20117
|
-
_proto.onUpdate = function onUpdate(dt) {
|
|
20118
|
-
var time = this.time;
|
|
20119
|
-
var _this_material_getVector4;
|
|
20120
|
-
var _Time = (_this_material_getVector4 = this.material.getVector4("_Time")) != null ? _this_material_getVector4 : new Vector4();
|
|
20121
|
-
this.material.setVector4("_Time", _Time.set(time / 20, time, time * 2, time * 3));
|
|
20122
|
-
this.time += dt / 1000;
|
|
20123
|
-
};
|
|
20124
|
-
_proto.fromData = function fromData(data) {
|
|
20125
|
-
MeshComponent.prototype.fromData.call(this, data);
|
|
20126
|
-
this.material = this.materials[0];
|
|
20127
|
-
};
|
|
20128
|
-
return EffectComponent;
|
|
20129
|
-
}(MeshComponent);
|
|
20130
|
-
EffectComponent = __decorate([
|
|
20131
|
-
effectsClass(DataType.EffectComponent)
|
|
20132
|
-
], EffectComponent);
|
|
20133
|
-
|
|
20134
|
-
var tempVector3 = new Vector3(0, 0, 0);
|
|
20135
|
-
var tempVector3Second = new Vector3(0, 0, 0);
|
|
20136
|
-
var ConstraintTarget = function ConstraintTarget() {
|
|
20137
|
-
this.target = null;
|
|
20138
|
-
this.weight = 1.0;
|
|
20139
|
-
};
|
|
20140
|
-
var PositionConstraint = /*#__PURE__*/ function(Component) {
|
|
20141
|
-
_inherits(PositionConstraint, Component);
|
|
20142
|
-
function PositionConstraint() {
|
|
20143
|
-
var _this;
|
|
20144
|
-
_this = Component.apply(this, arguments) || this;
|
|
20145
|
-
/**
|
|
20146
|
-
* 初始位置(当前元素的初始世界位置)
|
|
20147
|
-
*/ _this.positionAtRest = new Vector3(0, 0, 0);
|
|
20148
|
-
/**
|
|
20149
|
-
* 位置偏移
|
|
20150
|
-
*/ _this.positionOffset = new Vector3(0, 0, 0);
|
|
20151
|
-
/**
|
|
20152
|
-
* 约束权重 (0-1)
|
|
20153
|
-
*/ _this.weight = 1.0;
|
|
20154
|
-
/**
|
|
20155
|
-
* 是否约束 X 轴
|
|
20156
|
-
*/ _this.constrainX = true;
|
|
20157
|
-
/**
|
|
20158
|
-
* 是否约束 Y 轴
|
|
20159
|
-
*/ _this.constrainY = true;
|
|
20160
|
-
/**
|
|
20161
|
-
* 是否约束 Z 轴
|
|
20162
|
-
*/ _this.constrainZ = true;
|
|
20163
|
-
/**
|
|
20164
|
-
* 约束目标
|
|
20165
|
-
*/ _this.targets = [];
|
|
20166
|
-
return _this;
|
|
20167
|
-
}
|
|
20168
|
-
var _proto = PositionConstraint.prototype;
|
|
20169
|
-
_proto.onStart = function onStart() {
|
|
20170
|
-
// 保存当前元素的初始世界位置
|
|
20171
|
-
var pos = this.item.transform.getWorldPosition();
|
|
20172
|
-
this.positionAtRest.copyFrom(pos);
|
|
20173
|
-
};
|
|
20174
|
-
_proto.onUpdate = function onUpdate(dt) {
|
|
20175
|
-
if (this.targets.length === 0) {
|
|
20176
|
-
return;
|
|
20177
|
-
}
|
|
20178
|
-
// 重置 tempVector3 用于计算融合位置
|
|
20179
|
-
tempVector3.set(0, 0, 0);
|
|
20180
|
-
var totalWeight = 0;
|
|
20181
|
-
// 计算所有目标的加权平均位置
|
|
20182
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(this.targets), _step; !(_step = _iterator()).done;){
|
|
20183
|
-
var constraintTarget = _step.value;
|
|
20184
|
-
if (constraintTarget.target) {
|
|
20185
|
-
var targetPos = constraintTarget.target.transform.getWorldPosition();
|
|
20186
|
-
var weight = constraintTarget.weight;
|
|
20187
|
-
tempVector3.x += targetPos.x * weight;
|
|
20188
|
-
tempVector3.y += targetPos.y * weight;
|
|
20189
|
-
tempVector3.z += targetPos.z * weight;
|
|
20190
|
-
totalWeight += weight;
|
|
20191
|
-
}
|
|
20192
|
-
}
|
|
20193
|
-
// 归一化加权位置
|
|
20194
|
-
if (totalWeight > 0) {
|
|
20195
|
-
tempVector3.x /= totalWeight;
|
|
20196
|
-
tempVector3.y /= totalWeight;
|
|
20197
|
-
tempVector3.z /= totalWeight;
|
|
20198
|
-
}
|
|
20199
|
-
// 应用偏移
|
|
20200
|
-
tempVector3.x += this.positionOffset.x;
|
|
20201
|
-
tempVector3.y += this.positionOffset.y;
|
|
20202
|
-
tempVector3.z += this.positionOffset.z;
|
|
20203
|
-
// 根据全局权重在初始位置和融合位置之间插值,结果存入 tempVector3Second
|
|
20204
|
-
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));
|
|
20205
|
-
// 应用轴约束,复用 tempVector3 存储当前位置
|
|
20206
|
-
tempVector3.copyFrom(this.item.transform.getWorldPosition());
|
|
20207
|
-
var finalX = this.constrainX ? tempVector3Second.x : tempVector3.x;
|
|
20208
|
-
var finalY = this.constrainY ? tempVector3Second.y : tempVector3.y;
|
|
20209
|
-
var finalZ = this.constrainZ ? tempVector3Second.z : tempVector3.z;
|
|
20210
|
-
// 设置新的世界位置
|
|
20211
|
-
this.item.transform.setWorldPosition(finalX, finalY, finalZ);
|
|
20212
|
-
};
|
|
20213
|
-
/**
|
|
20214
|
-
* 添加约束目标
|
|
20215
|
-
* @param target - 目标元素
|
|
20216
|
-
* @param weight - 权重值 (0-1)
|
|
20217
|
-
*/ _proto.addTarget = function addTarget(target, weight) {
|
|
20218
|
-
if (weight === void 0) weight = 1.0;
|
|
20219
|
-
var constraintTarget = new ConstraintTarget();
|
|
20220
|
-
constraintTarget.target = target;
|
|
20221
|
-
constraintTarget.weight = Math.max(0, Math.min(1, weight));
|
|
20222
|
-
this.targets.push(constraintTarget);
|
|
20223
|
-
};
|
|
20224
|
-
/**
|
|
20225
|
-
* 移除约束目标
|
|
20226
|
-
* @param target - 要移除的目标元素
|
|
20227
|
-
*/ _proto.removeTarget = function removeTarget(target) {
|
|
20228
|
-
var index = this.targets.findIndex(function(ct) {
|
|
20229
|
-
return ct.target === target;
|
|
20230
|
-
});
|
|
20231
|
-
if (index !== -1) {
|
|
20232
|
-
this.targets.splice(index, 1);
|
|
20233
|
-
}
|
|
20234
|
-
};
|
|
20235
|
-
/**
|
|
20236
|
-
* 清除所有约束目标
|
|
20237
|
-
*/ _proto.clearTargets = function clearTargets() {
|
|
20238
|
-
this.targets = [];
|
|
20239
|
-
};
|
|
20240
|
-
/**
|
|
20241
|
-
* 设置位置偏移
|
|
20242
|
-
* @param x - X 轴偏移
|
|
20243
|
-
* @param y - Y 轴偏移
|
|
20244
|
-
* @param z - Z 轴偏移
|
|
20245
|
-
*/ _proto.setPositionOffset = function setPositionOffset(x, y, z) {
|
|
20246
|
-
this.positionOffset.set(x, y, z);
|
|
20247
|
-
};
|
|
20248
|
-
/**
|
|
20249
|
-
* 设置全局约束权重
|
|
20250
|
-
* @param weight - 权重值 (0-1),0 表示保持初始位置,1 表示完全跟随目标
|
|
20251
|
-
*/ _proto.setWeight = function setWeight(weight) {
|
|
20252
|
-
this.weight = Math.max(0, Math.min(1, weight));
|
|
20253
|
-
};
|
|
20254
|
-
/**
|
|
20255
|
-
* 线性插值
|
|
20256
|
-
* @param start - 起始值
|
|
20257
|
-
* @param end - 结束值
|
|
20258
|
-
* @param t - 插值因子 (0-1)
|
|
20259
|
-
*/ _proto.lerp = function lerp(start, end, t) {
|
|
20260
|
-
return start + (end - start) * t;
|
|
20261
|
-
};
|
|
20262
|
-
_proto.fromData = function fromData(data) {
|
|
20263
|
-
Component.prototype.fromData.call(this, data);
|
|
20264
|
-
// Deserialize all properties
|
|
20265
|
-
this.positionAtRest.copyFrom(data.positionAtRest);
|
|
20266
|
-
this.positionOffset.copyFrom(data.positionOffset);
|
|
20267
|
-
this.weight = data.weight;
|
|
20268
|
-
this.constrainX = data.constrainX;
|
|
20269
|
-
this.constrainY = data.constrainY;
|
|
20270
|
-
this.constrainZ = data.constrainZ;
|
|
20271
|
-
this.targets = [];
|
|
20272
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(data.targets), _step; !(_step = _iterator()).done;){
|
|
20273
|
-
var targetData = _step.value;
|
|
20274
|
-
var constraintTarget = new ConstraintTarget();
|
|
20275
|
-
constraintTarget.target = this.engine.findObject(targetData.target);
|
|
20276
|
-
constraintTarget.weight = targetData.weight;
|
|
20277
|
-
this.targets.push(constraintTarget);
|
|
20278
|
-
}
|
|
20279
|
-
};
|
|
20280
|
-
return PositionConstraint;
|
|
20281
|
-
}(Component);
|
|
20282
|
-
PositionConstraint = __decorate([
|
|
20283
|
-
effectsClass("PositionConstraint")
|
|
20284
|
-
], PositionConstraint);
|
|
20285
|
-
|
|
20286
|
-
var PostProcessVolume = /*#__PURE__*/ function(Component) {
|
|
20287
|
-
_inherits(PostProcessVolume, Component);
|
|
20288
|
-
function PostProcessVolume(engine) {
|
|
20289
|
-
var _this;
|
|
20290
|
-
_this = Component.call(this, engine) || this;
|
|
20291
|
-
_this.bloom = {
|
|
20292
|
-
threshold: 0,
|
|
20293
|
-
intensity: 0,
|
|
20294
|
-
active: false
|
|
20295
|
-
};
|
|
20296
|
-
_this.vignette = {
|
|
20297
|
-
intensity: 0,
|
|
20298
|
-
smoothness: 0,
|
|
20299
|
-
roundness: 0,
|
|
20300
|
-
active: false
|
|
20301
|
-
};
|
|
20302
|
-
_this.tonemapping = {
|
|
20303
|
-
active: false
|
|
20304
|
-
};
|
|
20305
|
-
_this.colorAdjustments = {
|
|
20306
|
-
brightness: 0,
|
|
20307
|
-
saturation: 0,
|
|
20308
|
-
contrast: 0,
|
|
20309
|
-
active: false
|
|
20310
|
-
};
|
|
20311
|
-
return _this;
|
|
20312
|
-
}
|
|
20313
|
-
var _proto = PostProcessVolume.prototype;
|
|
20314
|
-
_proto.onStart = function onStart() {
|
|
20315
|
-
var composition = this.item.composition;
|
|
20316
|
-
if (composition) {
|
|
20317
|
-
composition.renderFrame.globalVolume = this;
|
|
20318
|
-
}
|
|
20319
|
-
};
|
|
20320
|
-
return PostProcessVolume;
|
|
20321
|
-
}(Component);
|
|
20322
|
-
__decorate([
|
|
20323
|
-
serialize()
|
|
20324
|
-
], PostProcessVolume.prototype, "bloom", void 0);
|
|
20325
|
-
__decorate([
|
|
20326
|
-
serialize()
|
|
20327
|
-
], PostProcessVolume.prototype, "vignette", void 0);
|
|
20328
|
-
__decorate([
|
|
20329
|
-
serialize()
|
|
20330
|
-
], PostProcessVolume.prototype, "tonemapping", void 0);
|
|
20331
|
-
__decorate([
|
|
20332
|
-
serialize()
|
|
20333
|
-
], PostProcessVolume.prototype, "colorAdjustments", void 0);
|
|
20334
|
-
PostProcessVolume = __decorate([
|
|
20335
|
-
effectsClass(DataType.PostProcessVolume)
|
|
20336
|
-
], PostProcessVolume);
|
|
20337
|
-
|
|
20338
20461
|
var EFFECTS_COPY_MESH_NAME = "effects-internal-copy";
|
|
20339
20462
|
var COPY_MESH_SHADER_ID = "effects-internal-copy-mesh";
|
|
20340
20463
|
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}";
|
|
@@ -20525,7 +20648,7 @@ var RenderPassDestroyAttachmentType;
|
|
|
20525
20648
|
* 强制销毁
|
|
20526
20649
|
*/ RenderPassDestroyAttachmentType[RenderPassDestroyAttachmentType["destroy"] = 0] = "destroy";
|
|
20527
20650
|
})(RenderPassDestroyAttachmentType || (RenderPassDestroyAttachmentType = {}));
|
|
20528
|
-
var seed$
|
|
20651
|
+
var seed$6 = 1;
|
|
20529
20652
|
/**
|
|
20530
20653
|
* RenderPass 抽象类
|
|
20531
20654
|
*/ var RenderPass = /*#__PURE__*/ function() {
|
|
@@ -20535,7 +20658,7 @@ var seed$7 = 1;
|
|
|
20535
20658
|
*/ this.priority = 0;
|
|
20536
20659
|
/**
|
|
20537
20660
|
* 名称
|
|
20538
|
-
*/ this.name = "RenderPass" + seed$
|
|
20661
|
+
*/ this.name = "RenderPass" + seed$6++;
|
|
20539
20662
|
/**
|
|
20540
20663
|
* 包含的 Mesh 列表
|
|
20541
20664
|
*/ this.meshes = [];
|
|
@@ -20660,48 +20783,577 @@ var DrawObjectPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
20660
20783
|
return DrawObjectPass;
|
|
20661
20784
|
}(RenderPass);
|
|
20662
20785
|
|
|
20663
|
-
var
|
|
20664
|
-
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);
|
|
20786
|
+
var geometryId = 1;
|
|
20665
20787
|
/**
|
|
20666
|
-
*
|
|
20788
|
+
* 几何数据、属性布局和绘制范围的后端无关实现。
|
|
20667
20789
|
*/ var Geometry = /*#__PURE__*/ function(EffectsObject) {
|
|
20668
20790
|
_inherits(Geometry, EffectsObject);
|
|
20669
|
-
function Geometry() {
|
|
20791
|
+
function Geometry(engine, props) {
|
|
20670
20792
|
var _this;
|
|
20671
|
-
_this = EffectsObject.
|
|
20672
|
-
|
|
20673
|
-
|
|
20674
|
-
|
|
20675
|
-
/**
|
|
20676
|
-
|
|
20677
|
-
|
|
20793
|
+
_this = EffectsObject.call(this, engine) || this;
|
|
20794
|
+
_this.name = "";
|
|
20795
|
+
_this.subMeshes = [];
|
|
20796
|
+
/** @hide */ _this.mode = 4;
|
|
20797
|
+
/** @hide */ _this.instanceCount = 0;
|
|
20798
|
+
_this.vertexBuffers = {};
|
|
20799
|
+
_this.indices = new Uint16Array(0);
|
|
20800
|
+
_this.drawCount = 0;
|
|
20801
|
+
_this.drawStart = 0;
|
|
20802
|
+
_this.skin = {};
|
|
20803
|
+
_this.disposed = false;
|
|
20804
|
+
_this.initialized = false;
|
|
20805
|
+
_this.bufferUsage = BufferUsage.Static;
|
|
20806
|
+
if (supportsVertexArrayObjects(engine)) {
|
|
20807
|
+
_this.vertexArrayObjects = {};
|
|
20808
|
+
}
|
|
20809
|
+
if (props) {
|
|
20810
|
+
_this.processProps(props);
|
|
20811
|
+
}
|
|
20678
20812
|
return _this;
|
|
20679
20813
|
}
|
|
20680
20814
|
var _proto = Geometry.prototype;
|
|
20815
|
+
/** @hide */ _proto.isDisposed = function isDisposed() {
|
|
20816
|
+
return this.disposed;
|
|
20817
|
+
};
|
|
20681
20818
|
/**
|
|
20682
|
-
*
|
|
20683
|
-
|
|
20684
|
-
|
|
20685
|
-
|
|
20819
|
+
* @internal
|
|
20820
|
+
*/ _proto.getOptions = function getOptions() {
|
|
20821
|
+
return this.options ? _extends({}, this.options) : undefined;
|
|
20822
|
+
};
|
|
20823
|
+
/** @hide */ _proto.getVertexBuffer = function getVertexBuffer(name) {
|
|
20824
|
+
return this.vertexBuffers[name];
|
|
20686
20825
|
};
|
|
20687
20826
|
/**
|
|
20688
|
-
*
|
|
20689
|
-
*/ _proto.
|
|
20690
|
-
|
|
20827
|
+
* @internal
|
|
20828
|
+
*/ _proto.getVertexBuffers = function getVertexBuffers() {
|
|
20829
|
+
return this.vertexBuffers;
|
|
20830
|
+
};
|
|
20831
|
+
/** @hide */ _proto.setVerticesBuffer = function setVerticesBuffer(vertexBuffer, disposeExistingBuffer) {
|
|
20832
|
+
if (disposeExistingBuffer === void 0) disposeExistingBuffer = true;
|
|
20833
|
+
var kind = vertexBuffer.getKind();
|
|
20834
|
+
var current = this.vertexBuffers[kind];
|
|
20835
|
+
if (current && disposeExistingBuffer) {
|
|
20836
|
+
current.dispose();
|
|
20837
|
+
}
|
|
20838
|
+
if (vertexBuffer.ownsBuffer) {
|
|
20839
|
+
vertexBuffer.buffer.increaseReferences();
|
|
20840
|
+
}
|
|
20841
|
+
this.vertexBuffers[kind] = vertexBuffer;
|
|
20842
|
+
this.disposeVertexArrayObjects();
|
|
20843
|
+
};
|
|
20844
|
+
/** @hide */ _proto.getAttributeBuffer = function getAttributeBuffer(name) {
|
|
20845
|
+
var _this_vertexBuffers_name;
|
|
20846
|
+
return (_this_vertexBuffers_name = this.vertexBuffers[name]) == null ? void 0 : _this_vertexBuffers_name.getWrapperBuffer();
|
|
20847
|
+
};
|
|
20848
|
+
_proto.getAttributeData = function getAttributeData(name) {
|
|
20849
|
+
var _this_vertexBuffers_name;
|
|
20850
|
+
return (_this_vertexBuffers_name = this.vertexBuffers[name]) == null ? void 0 : _this_vertexBuffers_name.getData();
|
|
20851
|
+
};
|
|
20852
|
+
_proto.setAttributeData = function setAttributeData(name, data) {
|
|
20853
|
+
var vertexBuffer = this.vertexBuffers[name];
|
|
20854
|
+
if (!vertexBuffer) {
|
|
20855
|
+
return;
|
|
20856
|
+
}
|
|
20857
|
+
vertexBuffer.update(data);
|
|
20858
|
+
this.disposeVertexArrayObjects();
|
|
20859
|
+
};
|
|
20860
|
+
_proto.setAttributeSubData = function setAttributeSubData(name, offset, data) {
|
|
20861
|
+
var vertexBuffer = this.vertexBuffers[name];
|
|
20862
|
+
if (!vertexBuffer) {
|
|
20863
|
+
return;
|
|
20864
|
+
}
|
|
20865
|
+
var buffer = vertexBuffer.getWrapperBuffer();
|
|
20866
|
+
var vertexCount = buffer.byteStride > 0 ? Math.ceil(data.byteLength / buffer.byteStride) : 0;
|
|
20867
|
+
buffer.updateDirectly(data, offset, vertexCount);
|
|
20868
|
+
this.disposeVertexArrayObjects();
|
|
20869
|
+
};
|
|
20870
|
+
_proto.getAttributeStride = function getAttributeStride(name) {
|
|
20871
|
+
var _this_vertexBuffers_name;
|
|
20872
|
+
var _this_vertexBuffers_name_byteStride;
|
|
20873
|
+
return (_this_vertexBuffers_name_byteStride = (_this_vertexBuffers_name = this.vertexBuffers[name]) == null ? void 0 : _this_vertexBuffers_name.byteStride) != null ? _this_vertexBuffers_name_byteStride : 0;
|
|
20874
|
+
};
|
|
20875
|
+
_proto.getAttributeNames = function getAttributeNames() {
|
|
20876
|
+
return Object.keys(this.vertexBuffers);
|
|
20877
|
+
};
|
|
20878
|
+
/** @hide */ _proto.getIndexBuffer = function getIndexBuffer() {
|
|
20879
|
+
return this.indexBuffer;
|
|
20880
|
+
};
|
|
20881
|
+
_proto.getIndexData = function getIndexData() {
|
|
20882
|
+
return this.indices;
|
|
20883
|
+
};
|
|
20884
|
+
/** @hide */ _proto.getIndexType = function getIndexType() {
|
|
20885
|
+
var _this_indexBuffer;
|
|
20886
|
+
return ((_this_indexBuffer = this.indexBuffer) == null ? void 0 : _this_indexBuffer.is32Bits) || shouldUse32Bits(this.indices) ? BufferDataType.UnsignedInt : BufferDataType.UnsignedShort;
|
|
20887
|
+
};
|
|
20888
|
+
_proto.setIndexData = function setIndexData(data) {
|
|
20889
|
+
if (!isIndexData(data)) {
|
|
20890
|
+
throw new TypeError("Index data must use a supported integer array.");
|
|
20891
|
+
}
|
|
20892
|
+
this.indices = Array.isArray(data) ? shouldUse32Bits(data) ? new Uint32Array(data) : new Uint16Array(data) : data;
|
|
20893
|
+
this.releaseIndexBuffer();
|
|
20894
|
+
this.disposeVertexArrayObjects();
|
|
20895
|
+
if (this.initialized) {
|
|
20896
|
+
this.createIndexBuffer();
|
|
20897
|
+
}
|
|
20898
|
+
};
|
|
20899
|
+
_proto.setIndexSubData = function setIndexSubData(offset, data) {
|
|
20900
|
+
var indices = this.indices;
|
|
20901
|
+
if (offset < 0 || offset + data.length > indices.length) {
|
|
20902
|
+
throw new RangeError("Buffer '" + this.name + "##index' update is out of range.");
|
|
20903
|
+
}
|
|
20904
|
+
indices.set(data, offset);
|
|
20905
|
+
if (this.indexBuffer) {
|
|
20906
|
+
var updatedData = indices.slice(offset, offset + data.length);
|
|
20907
|
+
this.engine.updateDynamicIndexBuffer(this.indexBuffer, updatedData, offset * (this.indexBuffer.is32Bits ? Uint32Array.BYTES_PER_ELEMENT : Uint16Array.BYTES_PER_ELEMENT));
|
|
20908
|
+
this.disposeVertexArrayObjects();
|
|
20909
|
+
}
|
|
20910
|
+
};
|
|
20911
|
+
_proto.setDrawStart = function setDrawStart(start) {
|
|
20912
|
+
this.drawStart = start;
|
|
20913
|
+
};
|
|
20914
|
+
_proto.getDrawStart = function getDrawStart() {
|
|
20915
|
+
return this.drawStart;
|
|
20916
|
+
};
|
|
20917
|
+
_proto.setDrawCount = function setDrawCount(count) {
|
|
20918
|
+
this.drawCount = count;
|
|
20919
|
+
};
|
|
20920
|
+
_proto.getDrawCount = function getDrawCount() {
|
|
20921
|
+
return this.drawCount;
|
|
20922
|
+
};
|
|
20923
|
+
_proto.getSkinProps = function getSkinProps() {
|
|
20924
|
+
return this.skin;
|
|
20925
|
+
};
|
|
20926
|
+
/** @hide */ _proto.bind = function bind(shader) {
|
|
20927
|
+
var vertexArrayObjects = this.vertexArrayObjects;
|
|
20928
|
+
var engine = this.engine;
|
|
20929
|
+
if (!vertexArrayObjects || !supportsVertexArrayObjects(engine)) {
|
|
20930
|
+
engine.bindBuffers(this.vertexBuffers, this.indexBuffer, shader);
|
|
20931
|
+
return;
|
|
20932
|
+
}
|
|
20933
|
+
var vertexArrayObject = vertexArrayObjects[shader.key];
|
|
20934
|
+
if (!vertexArrayObject) {
|
|
20935
|
+
vertexArrayObject = engine.recordVertexArrayObject(this.vertexBuffers, this.indexBuffer, shader);
|
|
20936
|
+
if (vertexArrayObject) {
|
|
20937
|
+
vertexArrayObjects[shader.key] = vertexArrayObject;
|
|
20938
|
+
}
|
|
20939
|
+
}
|
|
20940
|
+
if (vertexArrayObject) {
|
|
20941
|
+
engine.bindVertexArrayObject(vertexArrayObject, this.indexBuffer);
|
|
20942
|
+
} else {
|
|
20943
|
+
engine.bindBuffers(this.vertexBuffers, this.indexBuffer, shader);
|
|
20944
|
+
}
|
|
20945
|
+
};
|
|
20946
|
+
_proto.releaseVertexArrayObject = function releaseVertexArrayObject(key) {
|
|
20947
|
+
var vertexArrayObjects = this.vertexArrayObjects;
|
|
20948
|
+
if (!vertexArrayObjects) {
|
|
20949
|
+
return;
|
|
20950
|
+
}
|
|
20951
|
+
var vertexArrayObject = vertexArrayObjects[key];
|
|
20952
|
+
if (vertexArrayObject && hasVertexArrayObjectMethods(this.engine)) {
|
|
20953
|
+
this.engine.releaseVertexArrayObject(vertexArrayObject);
|
|
20954
|
+
}
|
|
20955
|
+
delete vertexArrayObjects[key];
|
|
20956
|
+
};
|
|
20957
|
+
_proto.initialize = function initialize() {
|
|
20958
|
+
if (this.initialized || this.disposed) {
|
|
20959
|
+
return;
|
|
20960
|
+
}
|
|
20961
|
+
this.forEachVertexBuffer(function(buffer) {
|
|
20962
|
+
buffer.create();
|
|
20963
|
+
});
|
|
20964
|
+
this.createIndexBuffer();
|
|
20965
|
+
this.engine.addGeometry(this);
|
|
20966
|
+
this.initialized = true;
|
|
20967
|
+
this.options = undefined;
|
|
20968
|
+
};
|
|
20969
|
+
_proto.flush = function flush() {
|
|
20970
|
+
if (this.disposed) {
|
|
20971
|
+
return;
|
|
20972
|
+
}
|
|
20973
|
+
this.initialize();
|
|
20974
|
+
this.forEachVertexBuffer(function(buffer) {
|
|
20975
|
+
return buffer.create();
|
|
20976
|
+
});
|
|
20977
|
+
};
|
|
20978
|
+
/** @hide */ _proto.restore = function restore() {
|
|
20979
|
+
if (!this.initialized || this.disposed) {
|
|
20980
|
+
return;
|
|
20981
|
+
}
|
|
20982
|
+
if (this.vertexArrayObjects) {
|
|
20983
|
+
this.vertexArrayObjects = {};
|
|
20984
|
+
}
|
|
20985
|
+
this.forEachVertexBuffer(function(buffer) {
|
|
20986
|
+
return buffer.rebuild();
|
|
20987
|
+
});
|
|
20988
|
+
if (this.indices.length > 0) {
|
|
20989
|
+
this.indexBuffer = undefined;
|
|
20990
|
+
this.createIndexBuffer();
|
|
20991
|
+
}
|
|
20992
|
+
};
|
|
20993
|
+
_proto.fromData = function fromData(data) {
|
|
20994
|
+
EffectsObject.prototype.fromData.call(this, data);
|
|
20995
|
+
this.subMeshes = data.subMeshes;
|
|
20996
|
+
var buffer;
|
|
20997
|
+
if (data.buffer) {
|
|
20998
|
+
buffer = new Uint8Array(decodeBase64ToArrayBuffer(data.buffer));
|
|
20999
|
+
} else if (data.binaryData) {
|
|
21000
|
+
buffer = data.binaryData;
|
|
21001
|
+
}
|
|
21002
|
+
if (!buffer) {
|
|
21003
|
+
return;
|
|
21004
|
+
}
|
|
21005
|
+
var vertexCount = data.vertexData.vertexCount;
|
|
21006
|
+
var props = {
|
|
21007
|
+
name: data.name,
|
|
21008
|
+
mode: 4,
|
|
21009
|
+
attributes: {}
|
|
21010
|
+
};
|
|
21011
|
+
if (hasSemantic(data)) {
|
|
21012
|
+
data.vertexData.channels.forEach(function(channel) {
|
|
21013
|
+
var _vertexBufferSemanticMap_channel_semantic;
|
|
21014
|
+
var attributeName = (_vertexBufferSemanticMap_channel_semantic = vertexBufferSemanticMap[channel.semantic]) != null ? _vertexBufferSemanticMap_channel_semantic : channel.semantic;
|
|
21015
|
+
props.attributes[attributeName] = {
|
|
21016
|
+
type: vertexFormatToDataType(channel.format),
|
|
21017
|
+
size: channel.dimension,
|
|
21018
|
+
data: createVertexTypedArray(channel, buffer, vertexCount),
|
|
21019
|
+
normalize: channel.normalize
|
|
21020
|
+
};
|
|
21021
|
+
});
|
|
21022
|
+
} else {
|
|
21023
|
+
var positionChannel = data.vertexData.channels[0];
|
|
21024
|
+
var uvChannel = data.vertexData.channels[1];
|
|
21025
|
+
var normalChannel = data.vertexData.channels[2];
|
|
21026
|
+
var _obj;
|
|
21027
|
+
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);
|
|
21028
|
+
}
|
|
21029
|
+
if (data.indexFormat !== IndexFormatType.None) {
|
|
21030
|
+
var indices = createIndexTypedArray(data.indexFormat, buffer, data.indexOffset);
|
|
21031
|
+
props.indices = {
|
|
21032
|
+
data: indices
|
|
21033
|
+
};
|
|
21034
|
+
props.drawCount = indices.length;
|
|
21035
|
+
} else {
|
|
21036
|
+
props.drawCount = vertexCount;
|
|
21037
|
+
}
|
|
21038
|
+
this.processProps(props);
|
|
21039
|
+
this.skin = {
|
|
21040
|
+
boneNames: data.boneNames,
|
|
21041
|
+
rootBoneName: data.rootBoneName,
|
|
21042
|
+
inverseBindMatrices: data.inverseBindMatrices
|
|
21043
|
+
};
|
|
21044
|
+
};
|
|
21045
|
+
_proto.dispose = function dispose() {
|
|
21046
|
+
var _this = this;
|
|
21047
|
+
if (this.disposed) {
|
|
21048
|
+
return;
|
|
21049
|
+
}
|
|
21050
|
+
this.disposeVertexArrayObjects();
|
|
21051
|
+
Object.keys(this.vertexBuffers).forEach(function(name) {
|
|
21052
|
+
return _this.vertexBuffers[name].dispose();
|
|
21053
|
+
});
|
|
21054
|
+
this.releaseIndexBuffer();
|
|
21055
|
+
this.vertexBuffers = {};
|
|
21056
|
+
this.indices = new Uint16Array(0);
|
|
21057
|
+
this.options = undefined;
|
|
21058
|
+
this.drawStart = 0;
|
|
21059
|
+
this.drawCount = 0;
|
|
21060
|
+
if (this.initialized) {
|
|
21061
|
+
this.engine.removeGeometry(this);
|
|
21062
|
+
}
|
|
21063
|
+
this.initialized = false;
|
|
21064
|
+
this.disposed = true;
|
|
21065
|
+
EffectsObject.prototype.dispose.call(this);
|
|
20691
21066
|
};
|
|
21067
|
+
_proto.processProps = function processProps(props) {
|
|
21068
|
+
var _this = this;
|
|
21069
|
+
this.releaseCurrentBuffers();
|
|
21070
|
+
var _props_bufferUsage;
|
|
21071
|
+
var usage = (_props_bufferUsage = props.bufferUsage) != null ? _props_bufferUsage : BufferUsage.Static;
|
|
21072
|
+
var sourceBuffers = {};
|
|
21073
|
+
var sourceDivisors = {};
|
|
21074
|
+
var sourceTypes = {};
|
|
21075
|
+
Object.keys(props.attributes).forEach(function(name) {
|
|
21076
|
+
var attribute = props.attributes[name];
|
|
21077
|
+
var source = "dataSource" in attribute ? attribute.dataSource : name;
|
|
21078
|
+
var _sourceDivisors_source, _attribute_instanceDivisor;
|
|
21079
|
+
sourceDivisors[source] = Math.max((_sourceDivisors_source = sourceDivisors[source]) != null ? _sourceDivisors_source : 0, (_attribute_instanceDivisor = attribute.instanceDivisor) != null ? _attribute_instanceDivisor : 0);
|
|
21080
|
+
});
|
|
21081
|
+
Object.keys(props.attributes).forEach(function(name) {
|
|
21082
|
+
var attribute = props.attributes[name];
|
|
21083
|
+
if ("dataSource" in attribute) {
|
|
21084
|
+
return;
|
|
21085
|
+
}
|
|
21086
|
+
var typedData = isTypedArray(attribute.data) ? attribute.data : undefined;
|
|
21087
|
+
var _attribute_type;
|
|
21088
|
+
var type = (_attribute_type = attribute.type) != null ? _attribute_type : typedData ? getDataType(typedData) : BufferDataType.Float;
|
|
21089
|
+
var bytesPerElement = getBytesPerElement(type);
|
|
21090
|
+
var byteStride = attribute.stride || attribute.size * bytesPerElement;
|
|
21091
|
+
var data = typedData != null ? typedData : createTypedArray(type, 0);
|
|
21092
|
+
if (data.length === 0 && props.maxVertex && props.maxVertex > 0) {
|
|
21093
|
+
var elementStride = byteStride / bytesPerElement;
|
|
21094
|
+
data = createTypedArray(type, Math.ceil(props.maxVertex * elementStride));
|
|
21095
|
+
}
|
|
21096
|
+
var _sourceDivisors_name;
|
|
21097
|
+
var instanceDivisor = (_sourceDivisors_name = sourceDivisors[name]) != null ? _sourceDivisors_name : 0;
|
|
21098
|
+
sourceTypes[name] = type;
|
|
21099
|
+
sourceBuffers[name] = new Buffer(_this.engine, data, usage !== BufferUsage.Static, byteStride, false, instanceDivisor > 0, true, instanceDivisor, name);
|
|
21100
|
+
});
|
|
21101
|
+
Object.keys(props.attributes).forEach(function(name) {
|
|
21102
|
+
var attribute = props.attributes[name];
|
|
21103
|
+
var source = "dataSource" in attribute ? attribute.dataSource : name;
|
|
21104
|
+
var buffer = sourceBuffers[source];
|
|
21105
|
+
if (!buffer) {
|
|
21106
|
+
throw new Error("Attribute '" + name + "' references missing data source '" + source + "'.");
|
|
21107
|
+
}
|
|
21108
|
+
var _attribute_type, _ref;
|
|
21109
|
+
var type = (_ref = (_attribute_type = attribute.type) != null ? _attribute_type : sourceTypes[source]) != null ? _ref : BufferDataType.Float;
|
|
21110
|
+
var byteStride = attribute.stride || buffer.byteStride;
|
|
21111
|
+
var _attribute_instanceDivisor;
|
|
21112
|
+
var instanceDivisor = (_attribute_instanceDivisor = attribute.instanceDivisor) != null ? _attribute_instanceDivisor : 0;
|
|
21113
|
+
var _attribute_offset, _attribute_normalize;
|
|
21114
|
+
var vertexBuffer = new VertexBuffer(_this.engine, buffer, name, {
|
|
21115
|
+
size: attribute.size,
|
|
21116
|
+
type: type,
|
|
21117
|
+
stride: byteStride,
|
|
21118
|
+
offset: (_attribute_offset = attribute.offset) != null ? _attribute_offset : 0,
|
|
21119
|
+
normalized: (_attribute_normalize = attribute.normalize) != null ? _attribute_normalize : false,
|
|
21120
|
+
instanced: instanceDivisor > 0,
|
|
21121
|
+
divisor: instanceDivisor,
|
|
21122
|
+
useBytes: true,
|
|
21123
|
+
takeBufferOwnership: true
|
|
21124
|
+
});
|
|
21125
|
+
_this.setVerticesBuffer(vertexBuffer);
|
|
21126
|
+
});
|
|
21127
|
+
var _props_name;
|
|
21128
|
+
this.name = (_props_name = props.name) != null ? _props_name : "effectsGeometry:" + geometryId++;
|
|
21129
|
+
var _props_drawStart;
|
|
21130
|
+
this.drawStart = (_props_drawStart = props.drawStart) != null ? _props_drawStart : 0;
|
|
21131
|
+
var _props_drawCount;
|
|
21132
|
+
this.drawCount = (_props_drawCount = props.drawCount) != null ? _props_drawCount : 0;
|
|
21133
|
+
var _props_mode;
|
|
21134
|
+
this.mode = (_props_mode = props.mode) != null ? _props_mode : 4;
|
|
21135
|
+
var _props_instanceCount;
|
|
21136
|
+
this.instanceCount = (_props_instanceCount = props.instanceCount) != null ? _props_instanceCount : 0;
|
|
21137
|
+
this.bufferUsage = usage;
|
|
21138
|
+
this.options = props;
|
|
21139
|
+
if (props.indices) {
|
|
21140
|
+
var data = props.indices.data;
|
|
21141
|
+
if (!isIndexData(data)) {
|
|
21142
|
+
throw new TypeError("Index data must use a supported integer array.");
|
|
21143
|
+
}
|
|
21144
|
+
// 索引还会参与 CPU 侧的命中检测和几何查询,因此始终保留源数据。
|
|
21145
|
+
this.indices = Array.isArray(data) ? shouldUse32Bits(data) ? new Uint32Array(data) : new Uint16Array(data) : data;
|
|
21146
|
+
}
|
|
21147
|
+
this.disposeVertexArrayObjects();
|
|
21148
|
+
};
|
|
21149
|
+
_proto.releaseCurrentBuffers = function releaseCurrentBuffers() {
|
|
21150
|
+
var _this = this;
|
|
21151
|
+
var wasInitialized = this.initialized;
|
|
21152
|
+
this.disposeVertexArrayObjects();
|
|
21153
|
+
Object.keys(this.vertexBuffers).forEach(function(name) {
|
|
21154
|
+
return _this.vertexBuffers[name].dispose();
|
|
21155
|
+
});
|
|
21156
|
+
this.releaseIndexBuffer();
|
|
21157
|
+
this.vertexBuffers = {};
|
|
21158
|
+
this.indices = new Uint16Array(0);
|
|
21159
|
+
if (wasInitialized) {
|
|
21160
|
+
this.engine.removeGeometry(this);
|
|
21161
|
+
this.initialized = false;
|
|
21162
|
+
}
|
|
21163
|
+
};
|
|
21164
|
+
_proto.disposeVertexArrayObjects = function disposeVertexArrayObjects() {
|
|
21165
|
+
var _this = this;
|
|
21166
|
+
var vertexArrayObjects = this.vertexArrayObjects;
|
|
21167
|
+
if (!vertexArrayObjects) {
|
|
21168
|
+
return;
|
|
21169
|
+
}
|
|
21170
|
+
Object.keys(vertexArrayObjects).forEach(function(key) {
|
|
21171
|
+
var vertexArrayObject = vertexArrayObjects[key];
|
|
21172
|
+
if (vertexArrayObject && hasVertexArrayObjectMethods(_this.engine)) {
|
|
21173
|
+
_this.engine.releaseVertexArrayObject(vertexArrayObject);
|
|
21174
|
+
}
|
|
21175
|
+
});
|
|
21176
|
+
this.vertexArrayObjects = {};
|
|
21177
|
+
};
|
|
21178
|
+
_proto.createIndexBuffer = function createIndexBuffer() {
|
|
21179
|
+
var indices = this.indices;
|
|
21180
|
+
if (indices.length === 0 || this.indexBuffer) {
|
|
21181
|
+
return;
|
|
21182
|
+
}
|
|
21183
|
+
this.indexBuffer = this.engine.createIndexBuffer(indices, {
|
|
21184
|
+
usage: this.bufferUsage,
|
|
21185
|
+
type: this.getIndexType(),
|
|
21186
|
+
byteStride: 0,
|
|
21187
|
+
instanceDivisor: 0,
|
|
21188
|
+
label: "" + this.name + "##index"
|
|
21189
|
+
});
|
|
21190
|
+
};
|
|
21191
|
+
_proto.releaseIndexBuffer = function releaseIndexBuffer() {
|
|
21192
|
+
if (!this.indexBuffer) {
|
|
21193
|
+
return;
|
|
21194
|
+
}
|
|
21195
|
+
this.engine.releaseBuffer(this.indexBuffer);
|
|
21196
|
+
this.indexBuffer = undefined;
|
|
21197
|
+
};
|
|
21198
|
+
_proto.forEachVertexBuffer = function forEachVertexBuffer(callback) {
|
|
21199
|
+
var _this = this;
|
|
21200
|
+
var visited = new Set();
|
|
21201
|
+
Object.keys(this.vertexBuffers).forEach(function(name) {
|
|
21202
|
+
var buffer = _this.vertexBuffers[name].getWrapperBuffer();
|
|
21203
|
+
if (!visited.has(buffer)) {
|
|
21204
|
+
visited.add(buffer);
|
|
21205
|
+
callback(buffer);
|
|
21206
|
+
}
|
|
21207
|
+
});
|
|
21208
|
+
};
|
|
21209
|
+
_create_class(Geometry, [
|
|
21210
|
+
{
|
|
21211
|
+
key: "isInitialized",
|
|
21212
|
+
get: /**
|
|
21213
|
+
* @internal
|
|
21214
|
+
*/ function get() {
|
|
21215
|
+
return this.initialized;
|
|
21216
|
+
}
|
|
21217
|
+
}
|
|
21218
|
+
]);
|
|
20692
21219
|
return Geometry;
|
|
20693
21220
|
}(EffectsObject);
|
|
20694
|
-
function
|
|
20695
|
-
|
|
20696
|
-
|
|
21221
|
+
Geometry.create = function(engine, props) {
|
|
21222
|
+
return new Geometry(engine, props);
|
|
21223
|
+
};
|
|
21224
|
+
function isTypedArray(value) {
|
|
21225
|
+
return ArrayBuffer.isView(value) && !_instanceof1(value, DataView);
|
|
21226
|
+
}
|
|
21227
|
+
function hasVertexArrayObjectMethods(engine) {
|
|
21228
|
+
var candidate = engine;
|
|
21229
|
+
return typeof candidate.recordVertexArrayObject === "function" && typeof candidate.bindVertexArrayObject === "function" && typeof candidate.releaseVertexArrayObject === "function";
|
|
21230
|
+
}
|
|
21231
|
+
function supportsVertexArrayObjects(engine) {
|
|
21232
|
+
var _engine_gpuCapability;
|
|
21233
|
+
return ((_engine_gpuCapability = engine.gpuCapability) == null ? void 0 : _engine_gpuCapability.detail.vertexArrayObject) === true && hasVertexArrayObjectMethods(engine);
|
|
21234
|
+
}
|
|
21235
|
+
function isIndexData(data) {
|
|
21236
|
+
return Array.isArray(data) || _instanceof1(data, Int32Array) || _instanceof1(data, Uint16Array) || _instanceof1(data, Uint32Array);
|
|
21237
|
+
}
|
|
21238
|
+
function shouldUse32Bits(data) {
|
|
21239
|
+
if (_instanceof1(data, Uint32Array)) {
|
|
21240
|
+
return true;
|
|
21241
|
+
}
|
|
21242
|
+
if (_instanceof1(data, Uint16Array)) {
|
|
21243
|
+
return false;
|
|
20697
21244
|
}
|
|
20698
|
-
|
|
20699
|
-
|
|
21245
|
+
for(var i = 0; i < data.length; i++){
|
|
21246
|
+
if (data[i] >= 65535) {
|
|
21247
|
+
return true;
|
|
21248
|
+
}
|
|
20700
21249
|
}
|
|
20701
|
-
return
|
|
21250
|
+
return false;
|
|
21251
|
+
}
|
|
21252
|
+
function createAttributeFromChannel(channel, buffer, vertexCount, size) {
|
|
21253
|
+
return {
|
|
21254
|
+
type: vertexFormatToDataType(channel.format),
|
|
21255
|
+
size: size,
|
|
21256
|
+
data: createVertexTypedArray(channel, buffer, vertexCount),
|
|
21257
|
+
normalize: channel.normalize
|
|
21258
|
+
};
|
|
21259
|
+
}
|
|
21260
|
+
function createVertexTypedArray(channel, baseBuffer, vertexCount) {
|
|
21261
|
+
var arrayBuffer = baseBuffer.buffer;
|
|
21262
|
+
var byteOffset = baseBuffer.byteOffset + channel.offset;
|
|
21263
|
+
var length = channel.dimension * vertexCount;
|
|
21264
|
+
switch(channel.format){
|
|
21265
|
+
case VertexFormatType.Float32:
|
|
21266
|
+
return new Float32Array(arrayBuffer, byteOffset, length);
|
|
21267
|
+
case VertexFormatType.Int16:
|
|
21268
|
+
return new Int16Array(arrayBuffer, byteOffset, length);
|
|
21269
|
+
case VertexFormatType.Int8:
|
|
21270
|
+
return new Int8Array(arrayBuffer, byteOffset, length);
|
|
21271
|
+
case VertexFormatType.UInt16:
|
|
21272
|
+
return new Uint16Array(arrayBuffer, byteOffset, length);
|
|
21273
|
+
case VertexFormatType.UInt8:
|
|
21274
|
+
return new Uint8Array(arrayBuffer, byteOffset, length);
|
|
21275
|
+
default:
|
|
21276
|
+
throw new Error("Unsupported vertex format: " + channel.format + ".");
|
|
21277
|
+
}
|
|
21278
|
+
}
|
|
21279
|
+
function createIndexTypedArray(type, baseBuffer, offset) {
|
|
21280
|
+
var arrayBuffer = baseBuffer.buffer;
|
|
21281
|
+
var byteOffset = baseBuffer.byteOffset + offset;
|
|
21282
|
+
var byteLength = baseBuffer.byteLength - offset;
|
|
21283
|
+
switch(type){
|
|
21284
|
+
case IndexFormatType.UInt16:
|
|
21285
|
+
return new Uint16Array(arrayBuffer, byteOffset, byteLength / Uint16Array.BYTES_PER_ELEMENT);
|
|
21286
|
+
case IndexFormatType.UInt32:
|
|
21287
|
+
return new Uint32Array(arrayBuffer, byteOffset, byteLength / Uint32Array.BYTES_PER_ELEMENT);
|
|
21288
|
+
default:
|
|
21289
|
+
throw new Error("Unsupported index format: " + type + ".");
|
|
21290
|
+
}
|
|
21291
|
+
}
|
|
21292
|
+
function vertexFormatToDataType(format) {
|
|
21293
|
+
switch(format){
|
|
21294
|
+
case VertexFormatType.Float32:
|
|
21295
|
+
return BufferDataType.Float;
|
|
21296
|
+
case VertexFormatType.Int16:
|
|
21297
|
+
return BufferDataType.Short;
|
|
21298
|
+
case VertexFormatType.Int8:
|
|
21299
|
+
return BufferDataType.Byte;
|
|
21300
|
+
case VertexFormatType.UInt16:
|
|
21301
|
+
return BufferDataType.UnsignedShort;
|
|
21302
|
+
case VertexFormatType.UInt8:
|
|
21303
|
+
return BufferDataType.UnsignedByte;
|
|
21304
|
+
default:
|
|
21305
|
+
throw new Error("Unsupported vertex format: " + format + ".");
|
|
21306
|
+
}
|
|
21307
|
+
}
|
|
21308
|
+
function hasSemantic(data) {
|
|
21309
|
+
return data.vertexData.channels.some(function(channel) {
|
|
21310
|
+
return !!channel.semantic;
|
|
21311
|
+
});
|
|
21312
|
+
}
|
|
21313
|
+
function decodeBase64ToArrayBuffer(value) {
|
|
21314
|
+
var binary = atob(value);
|
|
21315
|
+
var bytes = new Uint8Array(binary.length);
|
|
21316
|
+
for(var i = 0; i < binary.length; i++){
|
|
21317
|
+
bytes[i] = binary.charCodeAt(i);
|
|
21318
|
+
}
|
|
21319
|
+
return bytes.buffer;
|
|
21320
|
+
}
|
|
21321
|
+
var vertexBufferSemanticMap = {
|
|
21322
|
+
POSITION: VertexBuffer.PositionKind,
|
|
21323
|
+
TEXCOORD0: VertexBuffer.UVKind,
|
|
21324
|
+
TEXCOORD_0: VertexBuffer.UVKind,
|
|
21325
|
+
TEXCOORD1: VertexBuffer.UV2Kind,
|
|
21326
|
+
NORMAL: VertexBuffer.NormalKind,
|
|
21327
|
+
TANGENT: VertexBuffer.TangentKind,
|
|
21328
|
+
COLOR: VertexBuffer.ColorKind,
|
|
21329
|
+
JOINTS: VertexBuffer.JointsKind,
|
|
21330
|
+
JOINTS_0: VertexBuffer.JointsKind,
|
|
21331
|
+
WEIGHTS: VertexBuffer.WeightsKind,
|
|
21332
|
+
WEIGHTS_0: VertexBuffer.WeightsKind,
|
|
21333
|
+
POSITION_BS0: "aTargetPosition0",
|
|
21334
|
+
POSITION_BS1: "aTargetPosition1",
|
|
21335
|
+
POSITION_BS2: "aTargetPosition2",
|
|
21336
|
+
POSITION_BS3: "aTargetPosition3",
|
|
21337
|
+
POSITION_BS4: "aTargetPosition4",
|
|
21338
|
+
POSITION_BS5: "aTargetPosition5",
|
|
21339
|
+
POSITION_BS6: "aTargetPosition6",
|
|
21340
|
+
POSITION_BS7: "aTargetPosition7",
|
|
21341
|
+
NORMAL_BS0: "aTargetNormal0",
|
|
21342
|
+
NORMAL_BS1: "aTargetNormal1",
|
|
21343
|
+
NORMAL_BS2: "aTargetNormal2",
|
|
21344
|
+
NORMAL_BS3: "aTargetNormal3",
|
|
21345
|
+
TANGENT_BS0: "aTargetTangent0",
|
|
21346
|
+
TANGENT_BS1: "aTargetTangent1",
|
|
21347
|
+
TANGENT_BS2: "aTargetTangent2",
|
|
21348
|
+
TANGENT_BS3: "aTargetTangent3"
|
|
21349
|
+
};
|
|
21350
|
+
var _obj$4;
|
|
21351
|
+
var BYTES_TYPE_MAP = (_obj$4 = {}, _obj$4[BufferDataType.Float] = 4, _obj$4[BufferDataType.Int] = 4, _obj$4[BufferDataType.UnsignedInt] = 4, _obj$4[BufferDataType.Short] = 2, _obj$4[BufferDataType.UnsignedShort] = 2, _obj$4[BufferDataType.Byte] = 1, _obj$4[BufferDataType.UnsignedByte] = 1, _obj$4);
|
|
21352
|
+
function generateEmptyTypedArray(type) {
|
|
21353
|
+
return createTypedArray(type, 0);
|
|
20702
21354
|
}
|
|
20703
21355
|
|
|
20704
|
-
var seed$
|
|
21356
|
+
var seed$5 = 1;
|
|
20705
21357
|
/**
|
|
20706
21358
|
* Mesh 抽象类
|
|
20707
21359
|
*/ var Mesh = /*#__PURE__*/ function(RendererComponent) {
|
|
@@ -20713,14 +21365,14 @@ var seed$6 = 1;
|
|
|
20713
21365
|
_this.visible = true;
|
|
20714
21366
|
if (props) {
|
|
20715
21367
|
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;
|
|
20716
|
-
_this.id = "Mesh" + seed$
|
|
21368
|
+
_this.id = "Mesh" + seed$5++;
|
|
20717
21369
|
_this.name = name;
|
|
20718
21370
|
_this.geometry = geometry;
|
|
20719
21371
|
_this.material = material;
|
|
20720
21372
|
_this.priority = priority;
|
|
20721
21373
|
_this.worldMatrix = worldMatrix;
|
|
20722
21374
|
} else {
|
|
20723
|
-
_this.id = "Mesh" + seed$
|
|
21375
|
+
_this.id = "Mesh" + seed$5++;
|
|
20724
21376
|
_this.name = "<unnamed>";
|
|
20725
21377
|
_this.worldMatrix = Matrix4.fromIdentity();
|
|
20726
21378
|
_this._priority = 0;
|
|
@@ -21113,25 +21765,24 @@ var ToneMappingPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
21113
21765
|
var name = "PostProcess";
|
|
21114
21766
|
var engine = _this.renderer.engine;
|
|
21115
21767
|
_this.sceneTextureHandle = sceneTextureHandle ? sceneTextureHandle : new RenderTargetHandle(engine);
|
|
21768
|
+
var _obj;
|
|
21116
21769
|
var geometry = Geometry.create(engine, {
|
|
21117
21770
|
name: name,
|
|
21118
21771
|
mode: glContext.TRIANGLE_STRIP,
|
|
21119
|
-
attributes: {
|
|
21120
|
-
|
|
21121
|
-
|
|
21122
|
-
|
|
21123
|
-
|
|
21124
|
-
|
|
21125
|
-
|
|
21126
|
-
|
|
21127
|
-
|
|
21128
|
-
|
|
21129
|
-
|
|
21130
|
-
|
|
21131
|
-
|
|
21132
|
-
|
|
21133
|
-
}
|
|
21134
|
-
},
|
|
21772
|
+
attributes: (_obj = {}, _obj[VertexBuffer.PositionKind] = {
|
|
21773
|
+
type: glContext.FLOAT,
|
|
21774
|
+
size: 2,
|
|
21775
|
+
data: new Float32Array([
|
|
21776
|
+
-1,
|
|
21777
|
+
1,
|
|
21778
|
+
-1,
|
|
21779
|
+
-1,
|
|
21780
|
+
1,
|
|
21781
|
+
1,
|
|
21782
|
+
1,
|
|
21783
|
+
-1
|
|
21784
|
+
])
|
|
21785
|
+
}, _obj),
|
|
21135
21786
|
drawCount: 4
|
|
21136
21787
|
});
|
|
21137
21788
|
var material = Material.create(engine, {
|
|
@@ -21214,7 +21865,7 @@ var ToneMappingPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
21214
21865
|
return ToneMappingPass;
|
|
21215
21866
|
}(RenderPass);
|
|
21216
21867
|
|
|
21217
|
-
var seed$
|
|
21868
|
+
var seed$4 = 1;
|
|
21218
21869
|
/**
|
|
21219
21870
|
* RenderFrame 抽象类
|
|
21220
21871
|
*/ var RenderFrame = /*#__PURE__*/ function() {
|
|
@@ -21254,7 +21905,7 @@ var seed$5 = 1;
|
|
|
21254
21905
|
var postProcessPass = new ToneMappingPass(renderer, sceneTextureHandle);
|
|
21255
21906
|
this.addRenderPass(postProcessPass);
|
|
21256
21907
|
}
|
|
21257
|
-
this.name = "RenderFrame" + seed$
|
|
21908
|
+
this.name = "RenderFrame" + seed$4++;
|
|
21258
21909
|
this.camera = camera;
|
|
21259
21910
|
this.editorTransform = Vector4.fromArray(editorTransform);
|
|
21260
21911
|
}
|
|
@@ -21561,6 +22212,7 @@ var GPUCapability = /*#__PURE__*/ function() {
|
|
|
21561
22212
|
maxTextureAnisotropy: textureAnisotropicExt ? gl.getParameter(textureAnisotropicExt.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : 0,
|
|
21562
22213
|
shaderTextureLod: level2 || !!gl.getExtension("EXT_shader_texture_lod"),
|
|
21563
22214
|
instanceDraw: level2 || !!gl.getExtension("ANGLE_instanced_arrays"),
|
|
22215
|
+
vertexArrayObject: level2 || !!this.vaoExt,
|
|
21564
22216
|
ktx2Support: detectKTX2Support(this.compressTextureCapabilityList),
|
|
21565
22217
|
drawBuffers: level2 || !!this.drawBufferExtension,
|
|
21566
22218
|
asyncShaderCompile: !!this.glAsyncCompileExt,
|
|
@@ -21785,24 +22437,23 @@ var Renderer = /*#__PURE__*/ function() {
|
|
|
21785
22437
|
*/ _proto.blit = function blit(source, destination, material) {
|
|
21786
22438
|
// 懒加载创建 blit geometry
|
|
21787
22439
|
if (!this.blitGeometry) {
|
|
22440
|
+
var _obj;
|
|
21788
22441
|
this.blitGeometry = Geometry.create(this.engine, {
|
|
21789
22442
|
mode: glContext.TRIANGLE_STRIP,
|
|
21790
|
-
attributes: {
|
|
21791
|
-
|
|
21792
|
-
|
|
21793
|
-
|
|
21794
|
-
|
|
21795
|
-
|
|
21796
|
-
|
|
21797
|
-
|
|
21798
|
-
|
|
21799
|
-
|
|
21800
|
-
|
|
21801
|
-
|
|
21802
|
-
|
|
21803
|
-
|
|
21804
|
-
}
|
|
21805
|
-
},
|
|
22443
|
+
attributes: (_obj = {}, _obj[VertexBuffer.PositionKind] = {
|
|
22444
|
+
type: glContext.FLOAT,
|
|
22445
|
+
size: 2,
|
|
22446
|
+
data: new Float32Array([
|
|
22447
|
+
-1,
|
|
22448
|
+
1,
|
|
22449
|
+
-1,
|
|
22450
|
+
-1,
|
|
22451
|
+
1,
|
|
22452
|
+
1,
|
|
22453
|
+
1,
|
|
22454
|
+
-1
|
|
22455
|
+
])
|
|
22456
|
+
}, _obj),
|
|
21806
22457
|
drawCount: 4
|
|
21807
22458
|
});
|
|
21808
22459
|
}
|
|
@@ -22274,61 +22925,57 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
22274
22925
|
this.currentBatchTexture = null;
|
|
22275
22926
|
this.transformStack = [];
|
|
22276
22927
|
this.currentTransform = Matrix3.fromIdentity();
|
|
22928
|
+
var _obj;
|
|
22277
22929
|
this.geometry = Geometry.create(this.engine, {
|
|
22278
|
-
attributes: {
|
|
22279
|
-
|
|
22280
|
-
|
|
22281
|
-
|
|
22282
|
-
|
|
22283
|
-
|
|
22284
|
-
|
|
22285
|
-
|
|
22286
|
-
|
|
22287
|
-
|
|
22288
|
-
|
|
22289
|
-
|
|
22290
|
-
|
|
22291
|
-
|
|
22292
|
-
|
|
22293
|
-
|
|
22294
|
-
|
|
22295
|
-
|
|
22296
|
-
|
|
22297
|
-
|
|
22298
|
-
|
|
22299
|
-
|
|
22300
|
-
|
|
22301
|
-
|
|
22302
|
-
|
|
22303
|
-
|
|
22304
|
-
|
|
22305
|
-
|
|
22306
|
-
|
|
22307
|
-
|
|
22308
|
-
|
|
22309
|
-
|
|
22310
|
-
|
|
22311
|
-
|
|
22312
|
-
|
|
22313
|
-
|
|
22314
|
-
|
|
22315
|
-
|
|
22316
|
-
|
|
22317
|
-
|
|
22318
|
-
|
|
22319
|
-
|
|
22320
|
-
|
|
22321
|
-
|
|
22322
|
-
|
|
22323
|
-
|
|
22324
|
-
|
|
22325
|
-
|
|
22326
|
-
|
|
22327
|
-
1,
|
|
22328
|
-
0
|
|
22329
|
-
])
|
|
22330
|
-
}
|
|
22331
|
-
},
|
|
22930
|
+
attributes: (_obj = {}, _obj[VertexBuffer.PositionKind] = {
|
|
22931
|
+
type: glContext.FLOAT,
|
|
22932
|
+
size: 2,
|
|
22933
|
+
data: new Float32Array([
|
|
22934
|
+
-0.5,
|
|
22935
|
+
0.5,
|
|
22936
|
+
-0.5,
|
|
22937
|
+
-0.5,
|
|
22938
|
+
0.5,
|
|
22939
|
+
0.5,
|
|
22940
|
+
0.5,
|
|
22941
|
+
-0.5
|
|
22942
|
+
])
|
|
22943
|
+
}, _obj[VertexBuffer.ColorKind] = {
|
|
22944
|
+
type: glContext.FLOAT,
|
|
22945
|
+
size: 4,
|
|
22946
|
+
data: new Float32Array([
|
|
22947
|
+
1,
|
|
22948
|
+
1,
|
|
22949
|
+
1,
|
|
22950
|
+
1,
|
|
22951
|
+
1,
|
|
22952
|
+
1,
|
|
22953
|
+
1,
|
|
22954
|
+
1,
|
|
22955
|
+
1,
|
|
22956
|
+
1,
|
|
22957
|
+
1,
|
|
22958
|
+
1,
|
|
22959
|
+
1,
|
|
22960
|
+
1,
|
|
22961
|
+
1,
|
|
22962
|
+
1
|
|
22963
|
+
])
|
|
22964
|
+
}, _obj[VertexBuffer.UVKind] = {
|
|
22965
|
+
size: 2,
|
|
22966
|
+
offset: 0,
|
|
22967
|
+
type: glContext.FLOAT,
|
|
22968
|
+
data: new Float32Array([
|
|
22969
|
+
0,
|
|
22970
|
+
1,
|
|
22971
|
+
0,
|
|
22972
|
+
0,
|
|
22973
|
+
1,
|
|
22974
|
+
1,
|
|
22975
|
+
1,
|
|
22976
|
+
0
|
|
22977
|
+
])
|
|
22978
|
+
}, _obj),
|
|
22332
22979
|
indices: {
|
|
22333
22980
|
data: new Uint16Array([
|
|
22334
22981
|
0,
|
|
@@ -22337,11 +22984,11 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
22337
22984
|
2,
|
|
22338
22985
|
1,
|
|
22339
22986
|
3
|
|
22340
|
-
])
|
|
22341
|
-
releasable: true
|
|
22987
|
+
])
|
|
22342
22988
|
},
|
|
22343
22989
|
mode: glContext.TRIANGLES,
|
|
22344
|
-
drawCount: 6
|
|
22990
|
+
drawCount: 6,
|
|
22991
|
+
bufferUsage: glContext.DYNAMIC_DRAW
|
|
22345
22992
|
});
|
|
22346
22993
|
this.coloredMaterial = Material.create(this.engine, {
|
|
22347
22994
|
shader: {
|
|
@@ -22429,9 +23076,9 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
22429
23076
|
var colorsArray = new Float32Array(this.colors);
|
|
22430
23077
|
var uvsArray = new Float32Array(this.uvs);
|
|
22431
23078
|
var indicesArray = new Uint16Array(this.indices);
|
|
22432
|
-
this.
|
|
22433
|
-
this.
|
|
22434
|
-
this.
|
|
23079
|
+
this.updateAttributeData(VertexBuffer.PositionKind, verticesArray, 2);
|
|
23080
|
+
this.updateAttributeData(VertexBuffer.ColorKind, colorsArray, 4);
|
|
23081
|
+
this.updateAttributeData(VertexBuffer.UVKind, uvsArray, 2);
|
|
22435
23082
|
this.geometry.setIndexData(indicesArray);
|
|
22436
23083
|
this.geometry.setDrawCount(this.currentIndexCount);
|
|
22437
23084
|
var material;
|
|
@@ -22449,6 +23096,18 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
22449
23096
|
this.colors.length = 0;
|
|
22450
23097
|
this.uvs.length = 0;
|
|
22451
23098
|
};
|
|
23099
|
+
_proto.updateAttributeData = function updateAttributeData(name, data, size) {
|
|
23100
|
+
var _this_geometry_getVertexBuffer;
|
|
23101
|
+
var dataBuffer = (_this_geometry_getVertexBuffer = this.geometry.getVertexBuffer(name)) == null ? void 0 : _this_geometry_getVertexBuffer.getBuffer();
|
|
23102
|
+
if (dataBuffer && data.byteLength > dataBuffer.capacity) {
|
|
23103
|
+
this.geometry.setVerticesBuffer(new VertexBuffer(this.engine, data, name, {
|
|
23104
|
+
updatable: true,
|
|
23105
|
+
size: size
|
|
23106
|
+
}));
|
|
23107
|
+
return;
|
|
23108
|
+
}
|
|
23109
|
+
this.geometry.setAttributeData(name, data);
|
|
23110
|
+
};
|
|
22452
23111
|
/**
|
|
22453
23112
|
* 线段顶点按顺序连接 (p0-p1, p1-p2, p2-p3, ...)
|
|
22454
23113
|
* @param points - 点数组,格式 [x1,y1,x2,y2,...],至少需要2个点(4个数值)
|
|
@@ -22818,6 +23477,310 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
22818
23477
|
return Graphics;
|
|
22819
23478
|
}();
|
|
22820
23479
|
|
|
23480
|
+
/**
|
|
23481
|
+
* Mesh 组件
|
|
23482
|
+
*/ var MeshComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
23483
|
+
_inherits(MeshComponent, RendererComponent);
|
|
23484
|
+
function MeshComponent(engine) {
|
|
23485
|
+
var _this;
|
|
23486
|
+
_this = RendererComponent.call(this, engine) || this;
|
|
23487
|
+
// TODO 点击测试后续抽象一个 Collider 组件
|
|
23488
|
+
_this.getHitTestParams = function(force) {
|
|
23489
|
+
var worldMatrix = _this.transform.getWorldMatrix();
|
|
23490
|
+
_this.boundingBoxInfo.setGeometry(_this.geometry, worldMatrix);
|
|
23491
|
+
var area = _this.boundingBoxInfo.getRawBoundingBoxTriangle();
|
|
23492
|
+
if (area) {
|
|
23493
|
+
return {
|
|
23494
|
+
type: area.type,
|
|
23495
|
+
triangles: area.area,
|
|
23496
|
+
clipMasks: _this.frameClipMasks
|
|
23497
|
+
};
|
|
23498
|
+
}
|
|
23499
|
+
};
|
|
23500
|
+
return _this;
|
|
23501
|
+
}
|
|
23502
|
+
var _proto = MeshComponent.prototype;
|
|
23503
|
+
_proto.render = function render(renderer) {
|
|
23504
|
+
this.maskManager.drawStencilMask(renderer, this);
|
|
23505
|
+
for(var i = 0; i < this.materials.length; i++){
|
|
23506
|
+
var material = this.materials[i];
|
|
23507
|
+
renderer.drawGeometry(this.geometry, this.transform.getWorldMatrix(), material, i);
|
|
23508
|
+
}
|
|
23509
|
+
};
|
|
23510
|
+
_proto.drawStencilMask = function drawStencilMask(maskRef) {
|
|
23511
|
+
if (!this.isActiveAndEnabled) {
|
|
23512
|
+
return;
|
|
23513
|
+
}
|
|
23514
|
+
for(var i = 0; i < this.materials.length; i++){
|
|
23515
|
+
var material = this.materials[i];
|
|
23516
|
+
this.maskManager.drawGeometryMask(this.engine.renderer, this.geometry, this.transform.getWorldMatrix(), material, maskRef, i);
|
|
23517
|
+
}
|
|
23518
|
+
};
|
|
23519
|
+
_proto.getBoundingBox = function getBoundingBox() {
|
|
23520
|
+
var worldMatrix = this.transform.getWorldMatrix();
|
|
23521
|
+
this.boundingBoxInfo.setGeometry(this.geometry, worldMatrix);
|
|
23522
|
+
var boundingBox = this.boundingBoxInfo.getBoundingBoxTriangle();
|
|
23523
|
+
return boundingBox;
|
|
23524
|
+
};
|
|
23525
|
+
_proto.getBoundingBoxInfo = function getBoundingBoxInfo() {
|
|
23526
|
+
var positionArray = this.geometry.getAttributeData(VertexBuffer.PositionKind);
|
|
23527
|
+
if (positionArray) {
|
|
23528
|
+
var minMaxResult = extractMinAndMax(positionArray, 0, positionArray.length / 3);
|
|
23529
|
+
minMaxResult.minimum.x *= this.transform.size.x;
|
|
23530
|
+
minMaxResult.minimum.y *= this.transform.size.y;
|
|
23531
|
+
minMaxResult.maximum.x *= this.transform.size.x;
|
|
23532
|
+
minMaxResult.maximum.y *= this.transform.size.y;
|
|
23533
|
+
this.boundingBoxInfo.reConstruct(minMaxResult.minimum, minMaxResult.maximum, this.transform.getWorldMatrix());
|
|
23534
|
+
}
|
|
23535
|
+
return this.boundingBoxInfo;
|
|
23536
|
+
};
|
|
23537
|
+
_proto.fromData = function fromData(data) {
|
|
23538
|
+
RendererComponent.prototype.fromData.call(this, data);
|
|
23539
|
+
var maskOptions = data.mask;
|
|
23540
|
+
if (maskOptions) {
|
|
23541
|
+
this.maskManager.setMaskOptions(this.engine, maskOptions);
|
|
23542
|
+
}
|
|
23543
|
+
};
|
|
23544
|
+
return MeshComponent;
|
|
23545
|
+
}(RendererComponent);
|
|
23546
|
+
__decorate([
|
|
23547
|
+
serialize()
|
|
23548
|
+
], MeshComponent.prototype, "geometry", void 0);
|
|
23549
|
+
|
|
23550
|
+
var EffectComponent = /*#__PURE__*/ function(MeshComponent) {
|
|
23551
|
+
_inherits(EffectComponent, MeshComponent);
|
|
23552
|
+
function EffectComponent(engine) {
|
|
23553
|
+
var _this;
|
|
23554
|
+
_this = MeshComponent.call(this, engine) || this;
|
|
23555
|
+
_this.time = 0;
|
|
23556
|
+
_this.name = "EffectComponent";
|
|
23557
|
+
return _this;
|
|
23558
|
+
}
|
|
23559
|
+
var _proto = EffectComponent.prototype;
|
|
23560
|
+
_proto.onStart = function onStart() {
|
|
23561
|
+
this.item.getHitTestParams = this.getHitTestParams;
|
|
23562
|
+
};
|
|
23563
|
+
_proto.onUpdate = function onUpdate(dt) {
|
|
23564
|
+
var time = this.time;
|
|
23565
|
+
var _this_material_getVector4;
|
|
23566
|
+
var _Time = (_this_material_getVector4 = this.material.getVector4("_Time")) != null ? _this_material_getVector4 : new Vector4();
|
|
23567
|
+
this.material.setVector4("_Time", _Time.set(time / 20, time, time * 2, time * 3));
|
|
23568
|
+
this.time += dt / 1000;
|
|
23569
|
+
};
|
|
23570
|
+
_proto.fromData = function fromData(data) {
|
|
23571
|
+
MeshComponent.prototype.fromData.call(this, data);
|
|
23572
|
+
this.material = this.materials[0];
|
|
23573
|
+
};
|
|
23574
|
+
return EffectComponent;
|
|
23575
|
+
}(MeshComponent);
|
|
23576
|
+
EffectComponent = __decorate([
|
|
23577
|
+
effectsClass(DataType.EffectComponent)
|
|
23578
|
+
], EffectComponent);
|
|
23579
|
+
|
|
23580
|
+
var tempVector3 = new Vector3(0, 0, 0);
|
|
23581
|
+
var tempVector3Second = new Vector3(0, 0, 0);
|
|
23582
|
+
var ConstraintTarget = function ConstraintTarget() {
|
|
23583
|
+
this.target = null;
|
|
23584
|
+
this.weight = 1.0;
|
|
23585
|
+
};
|
|
23586
|
+
var PositionConstraint = /*#__PURE__*/ function(Component) {
|
|
23587
|
+
_inherits(PositionConstraint, Component);
|
|
23588
|
+
function PositionConstraint() {
|
|
23589
|
+
var _this;
|
|
23590
|
+
_this = Component.apply(this, arguments) || this;
|
|
23591
|
+
/**
|
|
23592
|
+
* 初始位置(当前元素的初始世界位置)
|
|
23593
|
+
*/ _this.positionAtRest = new Vector3(0, 0, 0);
|
|
23594
|
+
/**
|
|
23595
|
+
* 位置偏移
|
|
23596
|
+
*/ _this.positionOffset = new Vector3(0, 0, 0);
|
|
23597
|
+
/**
|
|
23598
|
+
* 约束权重 (0-1)
|
|
23599
|
+
*/ _this.weight = 1.0;
|
|
23600
|
+
/**
|
|
23601
|
+
* 是否约束 X 轴
|
|
23602
|
+
*/ _this.constrainX = true;
|
|
23603
|
+
/**
|
|
23604
|
+
* 是否约束 Y 轴
|
|
23605
|
+
*/ _this.constrainY = true;
|
|
23606
|
+
/**
|
|
23607
|
+
* 是否约束 Z 轴
|
|
23608
|
+
*/ _this.constrainZ = true;
|
|
23609
|
+
/**
|
|
23610
|
+
* 约束目标
|
|
23611
|
+
*/ _this.targets = [];
|
|
23612
|
+
return _this;
|
|
23613
|
+
}
|
|
23614
|
+
var _proto = PositionConstraint.prototype;
|
|
23615
|
+
_proto.onStart = function onStart() {
|
|
23616
|
+
// 保存当前元素的初始世界位置
|
|
23617
|
+
var pos = this.item.transform.getWorldPosition();
|
|
23618
|
+
this.positionAtRest.copyFrom(pos);
|
|
23619
|
+
};
|
|
23620
|
+
_proto.onUpdate = function onUpdate(dt) {
|
|
23621
|
+
if (this.targets.length === 0) {
|
|
23622
|
+
return;
|
|
23623
|
+
}
|
|
23624
|
+
// 重置 tempVector3 用于计算融合位置
|
|
23625
|
+
tempVector3.set(0, 0, 0);
|
|
23626
|
+
var totalWeight = 0;
|
|
23627
|
+
// 计算所有目标的加权平均位置
|
|
23628
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(this.targets), _step; !(_step = _iterator()).done;){
|
|
23629
|
+
var constraintTarget = _step.value;
|
|
23630
|
+
if (constraintTarget.target) {
|
|
23631
|
+
var targetPos = constraintTarget.target.transform.getWorldPosition();
|
|
23632
|
+
var weight = constraintTarget.weight;
|
|
23633
|
+
tempVector3.x += targetPos.x * weight;
|
|
23634
|
+
tempVector3.y += targetPos.y * weight;
|
|
23635
|
+
tempVector3.z += targetPos.z * weight;
|
|
23636
|
+
totalWeight += weight;
|
|
23637
|
+
}
|
|
23638
|
+
}
|
|
23639
|
+
// 归一化加权位置
|
|
23640
|
+
if (totalWeight > 0) {
|
|
23641
|
+
tempVector3.x /= totalWeight;
|
|
23642
|
+
tempVector3.y /= totalWeight;
|
|
23643
|
+
tempVector3.z /= totalWeight;
|
|
23644
|
+
}
|
|
23645
|
+
// 应用偏移
|
|
23646
|
+
tempVector3.x += this.positionOffset.x;
|
|
23647
|
+
tempVector3.y += this.positionOffset.y;
|
|
23648
|
+
tempVector3.z += this.positionOffset.z;
|
|
23649
|
+
// 根据全局权重在初始位置和融合位置之间插值,结果存入 tempVector3Second
|
|
23650
|
+
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));
|
|
23651
|
+
// 应用轴约束,复用 tempVector3 存储当前位置
|
|
23652
|
+
tempVector3.copyFrom(this.item.transform.getWorldPosition());
|
|
23653
|
+
var finalX = this.constrainX ? tempVector3Second.x : tempVector3.x;
|
|
23654
|
+
var finalY = this.constrainY ? tempVector3Second.y : tempVector3.y;
|
|
23655
|
+
var finalZ = this.constrainZ ? tempVector3Second.z : tempVector3.z;
|
|
23656
|
+
// 设置新的世界位置
|
|
23657
|
+
this.item.transform.setWorldPosition(finalX, finalY, finalZ);
|
|
23658
|
+
};
|
|
23659
|
+
/**
|
|
23660
|
+
* 添加约束目标
|
|
23661
|
+
* @param target - 目标元素
|
|
23662
|
+
* @param weight - 权重值 (0-1)
|
|
23663
|
+
*/ _proto.addTarget = function addTarget(target, weight) {
|
|
23664
|
+
if (weight === void 0) weight = 1.0;
|
|
23665
|
+
var constraintTarget = new ConstraintTarget();
|
|
23666
|
+
constraintTarget.target = target;
|
|
23667
|
+
constraintTarget.weight = Math.max(0, Math.min(1, weight));
|
|
23668
|
+
this.targets.push(constraintTarget);
|
|
23669
|
+
};
|
|
23670
|
+
/**
|
|
23671
|
+
* 移除约束目标
|
|
23672
|
+
* @param target - 要移除的目标元素
|
|
23673
|
+
*/ _proto.removeTarget = function removeTarget(target) {
|
|
23674
|
+
var index = this.targets.findIndex(function(ct) {
|
|
23675
|
+
return ct.target === target;
|
|
23676
|
+
});
|
|
23677
|
+
if (index !== -1) {
|
|
23678
|
+
this.targets.splice(index, 1);
|
|
23679
|
+
}
|
|
23680
|
+
};
|
|
23681
|
+
/**
|
|
23682
|
+
* 清除所有约束目标
|
|
23683
|
+
*/ _proto.clearTargets = function clearTargets() {
|
|
23684
|
+
this.targets = [];
|
|
23685
|
+
};
|
|
23686
|
+
/**
|
|
23687
|
+
* 设置位置偏移
|
|
23688
|
+
* @param x - X 轴偏移
|
|
23689
|
+
* @param y - Y 轴偏移
|
|
23690
|
+
* @param z - Z 轴偏移
|
|
23691
|
+
*/ _proto.setPositionOffset = function setPositionOffset(x, y, z) {
|
|
23692
|
+
this.positionOffset.set(x, y, z);
|
|
23693
|
+
};
|
|
23694
|
+
/**
|
|
23695
|
+
* 设置全局约束权重
|
|
23696
|
+
* @param weight - 权重值 (0-1),0 表示保持初始位置,1 表示完全跟随目标
|
|
23697
|
+
*/ _proto.setWeight = function setWeight(weight) {
|
|
23698
|
+
this.weight = Math.max(0, Math.min(1, weight));
|
|
23699
|
+
};
|
|
23700
|
+
/**
|
|
23701
|
+
* 线性插值
|
|
23702
|
+
* @param start - 起始值
|
|
23703
|
+
* @param end - 结束值
|
|
23704
|
+
* @param t - 插值因子 (0-1)
|
|
23705
|
+
*/ _proto.lerp = function lerp(start, end, t) {
|
|
23706
|
+
return start + (end - start) * t;
|
|
23707
|
+
};
|
|
23708
|
+
_proto.fromData = function fromData(data) {
|
|
23709
|
+
Component.prototype.fromData.call(this, data);
|
|
23710
|
+
// Deserialize all properties
|
|
23711
|
+
this.positionAtRest.copyFrom(data.positionAtRest);
|
|
23712
|
+
this.positionOffset.copyFrom(data.positionOffset);
|
|
23713
|
+
this.weight = data.weight;
|
|
23714
|
+
this.constrainX = data.constrainX;
|
|
23715
|
+
this.constrainY = data.constrainY;
|
|
23716
|
+
this.constrainZ = data.constrainZ;
|
|
23717
|
+
this.targets = [];
|
|
23718
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(data.targets), _step; !(_step = _iterator()).done;){
|
|
23719
|
+
var targetData = _step.value;
|
|
23720
|
+
var constraintTarget = new ConstraintTarget();
|
|
23721
|
+
constraintTarget.target = this.engine.findObject(targetData.target);
|
|
23722
|
+
constraintTarget.weight = targetData.weight;
|
|
23723
|
+
this.targets.push(constraintTarget);
|
|
23724
|
+
}
|
|
23725
|
+
};
|
|
23726
|
+
return PositionConstraint;
|
|
23727
|
+
}(Component);
|
|
23728
|
+
PositionConstraint = __decorate([
|
|
23729
|
+
effectsClass("PositionConstraint")
|
|
23730
|
+
], PositionConstraint);
|
|
23731
|
+
|
|
23732
|
+
var PostProcessVolume = /*#__PURE__*/ function(Component) {
|
|
23733
|
+
_inherits(PostProcessVolume, Component);
|
|
23734
|
+
function PostProcessVolume(engine) {
|
|
23735
|
+
var _this;
|
|
23736
|
+
_this = Component.call(this, engine) || this;
|
|
23737
|
+
_this.bloom = {
|
|
23738
|
+
threshold: 0,
|
|
23739
|
+
intensity: 0,
|
|
23740
|
+
active: false
|
|
23741
|
+
};
|
|
23742
|
+
_this.vignette = {
|
|
23743
|
+
intensity: 0,
|
|
23744
|
+
smoothness: 0,
|
|
23745
|
+
roundness: 0,
|
|
23746
|
+
active: false
|
|
23747
|
+
};
|
|
23748
|
+
_this.tonemapping = {
|
|
23749
|
+
active: false
|
|
23750
|
+
};
|
|
23751
|
+
_this.colorAdjustments = {
|
|
23752
|
+
brightness: 0,
|
|
23753
|
+
saturation: 0,
|
|
23754
|
+
contrast: 0,
|
|
23755
|
+
active: false
|
|
23756
|
+
};
|
|
23757
|
+
return _this;
|
|
23758
|
+
}
|
|
23759
|
+
var _proto = PostProcessVolume.prototype;
|
|
23760
|
+
_proto.onStart = function onStart() {
|
|
23761
|
+
var composition = this.item.composition;
|
|
23762
|
+
if (composition) {
|
|
23763
|
+
composition.renderFrame.globalVolume = this;
|
|
23764
|
+
}
|
|
23765
|
+
};
|
|
23766
|
+
return PostProcessVolume;
|
|
23767
|
+
}(Component);
|
|
23768
|
+
__decorate([
|
|
23769
|
+
serialize()
|
|
23770
|
+
], PostProcessVolume.prototype, "bloom", void 0);
|
|
23771
|
+
__decorate([
|
|
23772
|
+
serialize()
|
|
23773
|
+
], PostProcessVolume.prototype, "vignette", void 0);
|
|
23774
|
+
__decorate([
|
|
23775
|
+
serialize()
|
|
23776
|
+
], PostProcessVolume.prototype, "tonemapping", void 0);
|
|
23777
|
+
__decorate([
|
|
23778
|
+
serialize()
|
|
23779
|
+
], PostProcessVolume.prototype, "colorAdjustments", void 0);
|
|
23780
|
+
PostProcessVolume = __decorate([
|
|
23781
|
+
effectsClass(DataType.PostProcessVolume)
|
|
23782
|
+
], PostProcessVolume);
|
|
23783
|
+
|
|
22821
23784
|
/**
|
|
22822
23785
|
* @since 2.7.0
|
|
22823
23786
|
*/ var MaskableGraphic = /*#__PURE__*/ function(RendererComponent) {
|
|
@@ -22856,42 +23819,40 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
22856
23819
|
side: SideMode.DOUBLE,
|
|
22857
23820
|
mask: 0
|
|
22858
23821
|
};
|
|
23822
|
+
var _obj;
|
|
22859
23823
|
_this.defaultGeometry = Geometry.create(_this.engine, {
|
|
22860
|
-
attributes: {
|
|
22861
|
-
|
|
22862
|
-
|
|
22863
|
-
|
|
22864
|
-
|
|
22865
|
-
|
|
22866
|
-
|
|
22867
|
-
|
|
22868
|
-
|
|
22869
|
-
|
|
22870
|
-
|
|
22871
|
-
|
|
22872
|
-
|
|
22873
|
-
|
|
22874
|
-
|
|
22875
|
-
|
|
22876
|
-
|
|
22877
|
-
|
|
22878
|
-
|
|
22879
|
-
|
|
22880
|
-
|
|
22881
|
-
|
|
22882
|
-
|
|
22883
|
-
|
|
22884
|
-
|
|
22885
|
-
|
|
22886
|
-
|
|
22887
|
-
|
|
22888
|
-
|
|
22889
|
-
|
|
22890
|
-
|
|
22891
|
-
|
|
22892
|
-
])
|
|
22893
|
-
}
|
|
22894
|
-
},
|
|
23824
|
+
attributes: (_obj = {}, _obj[VertexBuffer.PositionKind] = {
|
|
23825
|
+
type: glContext.FLOAT,
|
|
23826
|
+
size: 3,
|
|
23827
|
+
data: new Float32Array([
|
|
23828
|
+
-0.5,
|
|
23829
|
+
0.5,
|
|
23830
|
+
0,
|
|
23831
|
+
-0.5,
|
|
23832
|
+
-0.5,
|
|
23833
|
+
0,
|
|
23834
|
+
0.5,
|
|
23835
|
+
0.5,
|
|
23836
|
+
0,
|
|
23837
|
+
0.5,
|
|
23838
|
+
-0.5,
|
|
23839
|
+
0
|
|
23840
|
+
])
|
|
23841
|
+
}, _obj[VertexBuffer.UVKind] = {
|
|
23842
|
+
size: 2,
|
|
23843
|
+
offset: 0,
|
|
23844
|
+
type: glContext.FLOAT,
|
|
23845
|
+
data: new Float32Array([
|
|
23846
|
+
0,
|
|
23847
|
+
1,
|
|
23848
|
+
0,
|
|
23849
|
+
0,
|
|
23850
|
+
1,
|
|
23851
|
+
1,
|
|
23852
|
+
1,
|
|
23853
|
+
0
|
|
23854
|
+
])
|
|
23855
|
+
}, _obj),
|
|
22895
23856
|
indices: {
|
|
22896
23857
|
data: new Uint16Array([
|
|
22897
23858
|
0,
|
|
@@ -22900,11 +23861,11 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
22900
23861
|
2,
|
|
22901
23862
|
1,
|
|
22902
23863
|
3
|
|
22903
|
-
])
|
|
22904
|
-
releasable: true
|
|
23864
|
+
])
|
|
22905
23865
|
},
|
|
22906
23866
|
mode: glContext.TRIANGLES,
|
|
22907
|
-
drawCount: 6
|
|
23867
|
+
drawCount: 6,
|
|
23868
|
+
bufferUsage: glContext.DYNAMIC_DRAW
|
|
22908
23869
|
});
|
|
22909
23870
|
_this.geometry = _this.defaultGeometry;
|
|
22910
23871
|
var material = Material.create(_this.engine, {
|
|
@@ -23013,7 +23974,7 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
23013
23974
|
return boundingBox;
|
|
23014
23975
|
};
|
|
23015
23976
|
_proto.getBoundingBoxInfo = function getBoundingBoxInfo() {
|
|
23016
|
-
var positionArray = this.geometry.getAttributeData(
|
|
23977
|
+
var positionArray = this.geometry.getAttributeData(VertexBuffer.PositionKind);
|
|
23017
23978
|
if (positionArray) {
|
|
23018
23979
|
var minMaxResult = extractMinAndMax(positionArray, 0, positionArray.length / 3);
|
|
23019
23980
|
minMaxResult.minimum.x *= this.transform.size.x;
|
|
@@ -23227,61 +24188,66 @@ var FrameComponent = /*#__PURE__*/ function(RendererComponent1) {
|
|
|
23227
24188
|
_this.color = new Color(1, 1, 1, 1);
|
|
23228
24189
|
_this.worldMatrix = new Matrix4();
|
|
23229
24190
|
_this.getHitTestParams = function(force) {
|
|
24191
|
+
if (!force) {
|
|
24192
|
+
return;
|
|
24193
|
+
}
|
|
24194
|
+
// frame 边的四角(局部 [-0.5, 0.5] 经 size 与世界变换)
|
|
23230
24195
|
var sizeMatrix = Matrix4.fromScale(_this.transform.size.x, _this.transform.size.y, 1);
|
|
23231
24196
|
var worldMatrix = sizeMatrix.premultiply(_this.transform.getWorldMatrix());
|
|
23232
|
-
|
|
23233
|
-
|
|
23234
|
-
|
|
23235
|
-
|
|
23236
|
-
|
|
23237
|
-
|
|
23238
|
-
|
|
23239
|
-
|
|
23240
|
-
|
|
23241
|
-
|
|
23242
|
-
|
|
24197
|
+
var toWorld = function(x, y) {
|
|
24198
|
+
return worldMatrix.transformPoint(new Vector3(x, y, 0), new Vector3());
|
|
24199
|
+
};
|
|
24200
|
+
var TL = toWorld(-0.5, 0.5);
|
|
24201
|
+
var TR = toWorld(0.5, 0.5);
|
|
24202
|
+
var BR = toWorld(0.5, -0.5);
|
|
24203
|
+
var BL = toWorld(-0.5, -0.5);
|
|
24204
|
+
// 命中带为屏幕像素恒定的环带,中心落在 frame 边上,仅边缘可命中(内部镂空)
|
|
24205
|
+
var thickness = _this.getBorderWorldThickness(TL, TR);
|
|
24206
|
+
var triangles = _this.getBorderTriangles(TL, TR, BR, BL, thickness);
|
|
24207
|
+
return {
|
|
24208
|
+
type: HitTestType.triangle,
|
|
24209
|
+
triangles: triangles,
|
|
24210
|
+
clipMasks: _this.frameClipMasks
|
|
24211
|
+
};
|
|
23243
24212
|
};
|
|
23244
24213
|
return _this;
|
|
23245
24214
|
}
|
|
23246
24215
|
var _proto = FrameComponent.prototype;
|
|
23247
24216
|
_proto.onAwake = function onAwake() {
|
|
24217
|
+
var _obj;
|
|
23248
24218
|
this.clipGeometry = Geometry.create(this.engine, {
|
|
23249
|
-
attributes: {
|
|
23250
|
-
|
|
23251
|
-
|
|
23252
|
-
|
|
23253
|
-
|
|
23254
|
-
|
|
23255
|
-
|
|
23256
|
-
|
|
23257
|
-
|
|
23258
|
-
|
|
23259
|
-
|
|
23260
|
-
|
|
23261
|
-
|
|
23262
|
-
|
|
23263
|
-
|
|
23264
|
-
|
|
23265
|
-
|
|
23266
|
-
|
|
23267
|
-
|
|
23268
|
-
|
|
23269
|
-
|
|
23270
|
-
|
|
23271
|
-
|
|
23272
|
-
|
|
23273
|
-
|
|
23274
|
-
|
|
23275
|
-
|
|
23276
|
-
|
|
23277
|
-
|
|
23278
|
-
|
|
23279
|
-
|
|
23280
|
-
|
|
23281
|
-
0
|
|
23282
|
-
])
|
|
23283
|
-
}
|
|
23284
|
-
},
|
|
24219
|
+
attributes: (_obj = {}, _obj[VertexBuffer.PositionKind] = {
|
|
24220
|
+
type: glContext.FLOAT,
|
|
24221
|
+
size: 3,
|
|
24222
|
+
data: new Float32Array([
|
|
24223
|
+
-0.5,
|
|
24224
|
+
0.5,
|
|
24225
|
+
0,
|
|
24226
|
+
-0.5,
|
|
24227
|
+
-0.5,
|
|
24228
|
+
0,
|
|
24229
|
+
0.5,
|
|
24230
|
+
0.5,
|
|
24231
|
+
0,
|
|
24232
|
+
0.5,
|
|
24233
|
+
-0.5,
|
|
24234
|
+
0
|
|
24235
|
+
])
|
|
24236
|
+
}, _obj[VertexBuffer.UVKind] = {
|
|
24237
|
+
size: 2,
|
|
24238
|
+
offset: 0,
|
|
24239
|
+
type: glContext.FLOAT,
|
|
24240
|
+
data: new Float32Array([
|
|
24241
|
+
0,
|
|
24242
|
+
1,
|
|
24243
|
+
0,
|
|
24244
|
+
0,
|
|
24245
|
+
1,
|
|
24246
|
+
1,
|
|
24247
|
+
1,
|
|
24248
|
+
0
|
|
24249
|
+
])
|
|
24250
|
+
}, _obj),
|
|
23285
24251
|
indices: {
|
|
23286
24252
|
data: new Uint16Array([
|
|
23287
24253
|
0,
|
|
@@ -23290,8 +24256,7 @@ var FrameComponent = /*#__PURE__*/ function(RendererComponent1) {
|
|
|
23290
24256
|
2,
|
|
23291
24257
|
1,
|
|
23292
24258
|
3
|
|
23293
|
-
])
|
|
23294
|
-
releasable: true
|
|
24259
|
+
])
|
|
23295
24260
|
},
|
|
23296
24261
|
mode: glContext.TRIANGLES,
|
|
23297
24262
|
drawCount: 6
|
|
@@ -23341,6 +24306,62 @@ var FrameComponent = /*#__PURE__*/ function(RendererComponent1) {
|
|
|
23341
24306
|
this.color.copyFrom(data.color);
|
|
23342
24307
|
}
|
|
23343
24308
|
};
|
|
24309
|
+
/**
|
|
24310
|
+
* 由相机把命中带的屏幕像素厚度换算成世界厚度。对齐 Excalidraw frame 命中阈值:
|
|
24311
|
+
* 描边两侧各 0.85 × DEFAULT_COLLISION_THRESHOLD(≈8px),整条带 ≈13.6px,不受 size/scale/zoom 影响。
|
|
24312
|
+
*/ _proto.getBorderWorldThickness = function getBorderWorldThickness(topLeft, topRight) {
|
|
24313
|
+
var _this_item_composition;
|
|
24314
|
+
var fallbackThickness = 0.05; // 相机不可用时的兜底世界厚度
|
|
24315
|
+
var camera = (_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.camera;
|
|
24316
|
+
if (!camera) {
|
|
24317
|
+
return fallbackThickness;
|
|
24318
|
+
}
|
|
24319
|
+
var screenLeft = camera.worldToScreenPoint(topLeft);
|
|
24320
|
+
var screenRight = camera.worldToScreenPoint(topRight);
|
|
24321
|
+
var pixelDist = Math.hypot(screenRight.x - screenLeft.x, screenRight.y - screenLeft.y);
|
|
24322
|
+
var worldDist = Math.hypot(topRight.x - topLeft.x, topRight.y - topLeft.y) || 1;
|
|
24323
|
+
var pixelPerWorldUnit = pixelDist / worldDist;
|
|
24324
|
+
// 命中带整条宽度(像素):2 × 0.85 × DEFAULT_COLLISION_THRESHOLD,其中 DEFAULT_COLLISION_THRESHOLD ≈ 8
|
|
24325
|
+
var borderPixels = 2 * 0.85 * 8;
|
|
24326
|
+
return pixelPerWorldUnit > 0 ? borderPixels / pixelPerWorldUnit : fallbackThickness;
|
|
24327
|
+
};
|
|
24328
|
+
/**
|
|
24329
|
+
* 构造以 frame 边为中心、给定世界厚度的边框环带三角形(内部镂空)。
|
|
24330
|
+
* 带中心落在 frame 边上:half 向外、half 向内;沿 frame 局部坐标轴偏移以兼容旋转。
|
|
24331
|
+
*/ _proto.getBorderTriangles = function getBorderTriangles(TL, TR, BR, BL, thickness) {
|
|
24332
|
+
// frame 局部坐标轴在世界空间的方向
|
|
24333
|
+
var axisX = TR.clone().subtract(TL).normalize();
|
|
24334
|
+
var axisY = TL.clone().subtract(BL).normalize();
|
|
24335
|
+
var offset = function(corner, dx, dy) {
|
|
24336
|
+
return corner.clone().addScaledVector(axisX, dx).addScaledVector(axisY, dy);
|
|
24337
|
+
};
|
|
24338
|
+
// 外圈向外扩 half、内圈向内收 half,使带中心落在 frame 边上
|
|
24339
|
+
var half = thickness / 2;
|
|
24340
|
+
var outerTL = offset(TL, -half, half);
|
|
24341
|
+
var outerTR = offset(TR, half, half);
|
|
24342
|
+
var outerBR = offset(BR, half, -half);
|
|
24343
|
+
var outerBL = offset(BL, -half, -half);
|
|
24344
|
+
var innerTL = offset(TL, half, -half);
|
|
24345
|
+
var innerTR = offset(TR, -half, -half);
|
|
24346
|
+
var innerBR = offset(BR, -half, half);
|
|
24347
|
+
var innerBL = offset(BL, half, half);
|
|
24348
|
+
// 每条带是一个四边形,拆成 2 个三角形
|
|
24349
|
+
var quad = function(a, b, c, d) {
|
|
24350
|
+
return [
|
|
24351
|
+
{
|
|
24352
|
+
p0: a,
|
|
24353
|
+
p1: b,
|
|
24354
|
+
p2: c
|
|
24355
|
+
},
|
|
24356
|
+
{
|
|
24357
|
+
p0: a,
|
|
24358
|
+
p1: c,
|
|
24359
|
+
p2: d
|
|
24360
|
+
}
|
|
24361
|
+
];
|
|
24362
|
+
};
|
|
24363
|
+
return [].concat(quad(outerTL, outerTR, innerTR, innerTL), quad(outerTR, outerBR, innerBR, innerTR), quad(outerBR, outerBL, innerBL, innerBR), quad(outerBL, outerTL, innerTL, innerBL));
|
|
24364
|
+
};
|
|
23344
24365
|
_proto.setClipRectangle = function setClipRectangle() {
|
|
23345
24366
|
this.setClipRectangleRecursive(this.item);
|
|
23346
24367
|
};
|
|
@@ -24653,9 +25674,9 @@ var InteractLoader = /*#__PURE__*/ function(Plugin) {
|
|
|
24653
25674
|
return InteractLoader;
|
|
24654
25675
|
}(_wrap_native_super(Plugin));
|
|
24655
25676
|
|
|
24656
|
-
var vertex = "\nprecision highp float;\n\nattribute vec2
|
|
25677
|
+
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";
|
|
24657
25678
|
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";
|
|
24658
|
-
var seed$
|
|
25679
|
+
var seed$3 = 1;
|
|
24659
25680
|
var InteractMesh = /*#__PURE__*/ function() {
|
|
24660
25681
|
function InteractMesh(props, transform, engine) {
|
|
24661
25682
|
this.transform = transform;
|
|
@@ -24710,7 +25731,7 @@ var InteractMesh = /*#__PURE__*/ function() {
|
|
|
24710
25731
|
return material;
|
|
24711
25732
|
};
|
|
24712
25733
|
_proto.createGeometry = function createGeometry() {
|
|
24713
|
-
var indexData = new
|
|
25734
|
+
var indexData = new Uint16Array([
|
|
24714
25735
|
0,
|
|
24715
25736
|
1,
|
|
24716
25737
|
1,
|
|
@@ -24720,24 +25741,23 @@ var InteractMesh = /*#__PURE__*/ function() {
|
|
|
24720
25741
|
3,
|
|
24721
25742
|
0
|
|
24722
25743
|
]);
|
|
25744
|
+
var _obj;
|
|
24723
25745
|
return Geometry.create(this.engine, {
|
|
24724
|
-
attributes: {
|
|
24725
|
-
|
|
24726
|
-
|
|
24727
|
-
|
|
24728
|
-
|
|
24729
|
-
|
|
24730
|
-
|
|
24731
|
-
|
|
24732
|
-
|
|
24733
|
-
|
|
24734
|
-
|
|
24735
|
-
|
|
24736
|
-
|
|
24737
|
-
|
|
24738
|
-
|
|
24739
|
-
}
|
|
24740
|
-
},
|
|
25746
|
+
attributes: (_obj = {}, _obj[VertexBuffer.PositionKind] = {
|
|
25747
|
+
size: 2,
|
|
25748
|
+
offset: 0,
|
|
25749
|
+
stride: 2 * Float32Array.BYTES_PER_ELEMENT,
|
|
25750
|
+
data: new Float32Array([
|
|
25751
|
+
-0.5,
|
|
25752
|
+
0.5,
|
|
25753
|
+
0.5,
|
|
25754
|
+
0.5,
|
|
25755
|
+
0.5,
|
|
25756
|
+
-0.5,
|
|
25757
|
+
-0.5,
|
|
25758
|
+
-0.5
|
|
25759
|
+
])
|
|
25760
|
+
}, _obj),
|
|
24741
25761
|
drawCount: indexData.length,
|
|
24742
25762
|
indices: {
|
|
24743
25763
|
data: indexData
|
|
@@ -24748,7 +25768,7 @@ var InteractMesh = /*#__PURE__*/ function() {
|
|
|
24748
25768
|
};
|
|
24749
25769
|
_proto.createMesh = function createMesh(geometry, material) {
|
|
24750
25770
|
return Mesh.create(this.engine, {
|
|
24751
|
-
name: "Interact_preview" + seed$
|
|
25771
|
+
name: "Interact_preview" + seed$3++,
|
|
24752
25772
|
priority: 0,
|
|
24753
25773
|
worldMatrix: Matrix4.fromIdentity(),
|
|
24754
25774
|
geometry: geometry,
|
|
@@ -26664,6 +27684,11 @@ SpritePropertyTrack = __decorate([
|
|
|
26664
27684
|
effectsClass("SpritePropertyTrack")
|
|
26665
27685
|
], SpritePropertyTrack);
|
|
26666
27686
|
|
|
27687
|
+
function _assert_this_initialized(self) {
|
|
27688
|
+
if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
27689
|
+
return self;
|
|
27690
|
+
}
|
|
27691
|
+
|
|
26667
27692
|
var Cone = /*#__PURE__*/ function() {
|
|
26668
27693
|
function Cone(props) {
|
|
26669
27694
|
var _this = this;
|
|
@@ -27745,7 +28770,9 @@ var tmp0 = new Vector3();
|
|
|
27745
28770
|
var tmp1 = new Vector3();
|
|
27746
28771
|
var TrailMesh = /*#__PURE__*/ function() {
|
|
27747
28772
|
function TrailMesh(engine, props) {
|
|
28773
|
+
var _this = this;
|
|
27748
28774
|
this.pointStart = [];
|
|
28775
|
+
this.attributeData = new Map();
|
|
27749
28776
|
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;
|
|
27750
28777
|
var _engine_gpuCapability = engine.gpuCapability, detail = _engine_gpuCapability.detail, level = _engine_gpuCapability.level;
|
|
27751
28778
|
var pointCountPerTrail = Math.max(props.pointCountPerTrail, 2);
|
|
@@ -27828,42 +28855,36 @@ var TrailMesh = /*#__PURE__*/ function() {
|
|
|
27828
28855
|
var maxTriangleCount = (pointCountPerTrail - 1) * maxTrailCount;
|
|
27829
28856
|
var bpe = Float32Array.BYTES_PER_ELEMENT;
|
|
27830
28857
|
var v12 = 12 * bpe;
|
|
28858
|
+
var _obj;
|
|
27831
28859
|
var geometryOptions = {
|
|
27832
|
-
attributes: {
|
|
27833
|
-
|
|
27834
|
-
|
|
27835
|
-
|
|
27836
|
-
|
|
27837
|
-
|
|
27838
|
-
|
|
27839
|
-
|
|
27840
|
-
|
|
27841
|
-
|
|
27842
|
-
|
|
27843
|
-
|
|
27844
|
-
|
|
27845
|
-
|
|
27846
|
-
|
|
27847
|
-
|
|
27848
|
-
|
|
27849
|
-
|
|
27850
|
-
|
|
27851
|
-
|
|
27852
|
-
|
|
27853
|
-
|
|
27854
|
-
|
|
27855
|
-
|
|
27856
|
-
|
|
27857
|
-
|
|
27858
|
-
|
|
27859
|
-
|
|
27860
|
-
},
|
|
27861
|
-
//
|
|
27862
|
-
aDir: {
|
|
27863
|
-
size: 3,
|
|
27864
|
-
data: new Float32Array(maxVertexCount * 3)
|
|
27865
|
-
}
|
|
27866
|
-
},
|
|
28860
|
+
attributes: (_obj = {}, _obj[VertexBuffer.ColorKind] = {
|
|
28861
|
+
size: 4,
|
|
28862
|
+
stride: v12,
|
|
28863
|
+
data: new Float32Array(maxVertexCount * 12)
|
|
28864
|
+
}, _obj.aSeed = {
|
|
28865
|
+
size: 1,
|
|
28866
|
+
stride: v12,
|
|
28867
|
+
offset: 4 * bpe,
|
|
28868
|
+
dataSource: VertexBuffer.ColorKind
|
|
28869
|
+
}, _obj.aInfo = {
|
|
28870
|
+
size: 3,
|
|
28871
|
+
stride: v12,
|
|
28872
|
+
offset: 5 * bpe,
|
|
28873
|
+
dataSource: VertexBuffer.ColorKind
|
|
28874
|
+
}, _obj[VertexBuffer.PositionKind] = {
|
|
28875
|
+
size: 4,
|
|
28876
|
+
stride: v12,
|
|
28877
|
+
offset: 8 * bpe,
|
|
28878
|
+
dataSource: VertexBuffer.ColorKind
|
|
28879
|
+
}, //
|
|
28880
|
+
_obj.aTime = {
|
|
28881
|
+
size: 1,
|
|
28882
|
+
data: new Float32Array(maxVertexCount)
|
|
28883
|
+
}, //
|
|
28884
|
+
_obj.aDir = {
|
|
28885
|
+
size: 3,
|
|
28886
|
+
data: new Float32Array(maxVertexCount * 3)
|
|
28887
|
+
}, _obj),
|
|
27867
28888
|
indices: {
|
|
27868
28889
|
data: new Uint16Array(maxVertexCount * 6)
|
|
27869
28890
|
},
|
|
@@ -27937,6 +28958,13 @@ var TrailMesh = /*#__PURE__*/ function() {
|
|
|
27937
28958
|
this.mesh.worldMatrix = matrix;
|
|
27938
28959
|
}
|
|
27939
28960
|
this.geometry = mesh.firstGeometry();
|
|
28961
|
+
this.geometry.getAttributeNames().forEach(function(name) {
|
|
28962
|
+
var vertexBuffer = _this.geometry.getVertexBuffer(name);
|
|
28963
|
+
var data = _this.geometry.getAttributeData(name);
|
|
28964
|
+
if (vertexBuffer && _instanceof1(data, Float32Array)) {
|
|
28965
|
+
_this.attributeData.set(vertexBuffer.getWrapperBuffer(), data);
|
|
28966
|
+
}
|
|
28967
|
+
});
|
|
27940
28968
|
this.trailCursors = new Uint16Array(maxTrailCount);
|
|
27941
28969
|
}
|
|
27942
28970
|
var _proto = TrailMesh.prototype;
|
|
@@ -27967,8 +28995,8 @@ var TrailMesh = /*#__PURE__*/ function() {
|
|
|
27967
28995
|
var dirData = new Float32Array(6);
|
|
27968
28996
|
dirData.set(dir, 0);
|
|
27969
28997
|
dirData.set(dir, 3);
|
|
27970
|
-
|
|
27971
|
-
|
|
28998
|
+
this.setAttributeSubData("aDir", dirStartIndex, dirData);
|
|
28999
|
+
this.setAttributeSubData("aTime", pointStartIndex * 2, new Float32Array([
|
|
27972
29000
|
time,
|
|
27973
29001
|
time
|
|
27974
29002
|
]));
|
|
@@ -27990,13 +29018,13 @@ var TrailMesh = /*#__PURE__*/ function() {
|
|
|
27990
29018
|
colorData[19] = 1;
|
|
27991
29019
|
colorData.set(positionData, 20);
|
|
27992
29020
|
colorData[23] = -0.5 * size;
|
|
27993
|
-
|
|
29021
|
+
this.setAttributeSubData(VertexBuffer.ColorKind, pointStartIndex * 24, colorData);
|
|
27994
29022
|
if (previousIndex >= 0) {
|
|
27995
29023
|
var bPreviousPoint = this.getTrailPosition(trailIndex, bpreviousIndex, tmp1);
|
|
27996
29024
|
var previousDir = new Float32Array(calculateDirection(bPreviousPoint, previousPoint, position));
|
|
27997
29025
|
var previousDirStartIndex = (trailIndex * pointCountPerTrail + previousIndex) * 6;
|
|
27998
|
-
|
|
27999
|
-
|
|
29026
|
+
this.setAttributeSubData("aDir", previousDirStartIndex, previousDir);
|
|
29027
|
+
this.setAttributeSubData("aDir", previousDirStartIndex + 3, previousDir);
|
|
28000
29028
|
var indicesStart = trailIndex * pointCountPerTrail * 2;
|
|
28001
29029
|
var indicesData = new Uint16Array([
|
|
28002
29030
|
previousIndex * 2 + indicesStart,
|
|
@@ -28019,7 +29047,7 @@ var TrailMesh = /*#__PURE__*/ function() {
|
|
|
28019
29047
|
for(var i = 0; i < len; i++){
|
|
28020
29048
|
startData[i] = trailStart;
|
|
28021
29049
|
}
|
|
28022
|
-
|
|
29050
|
+
this.setAttributeSubData("aTrailStart", trailIndex * startData.length, startData);
|
|
28023
29051
|
} else {
|
|
28024
29052
|
var value = mtl.getFloats("uTrailStart");
|
|
28025
29053
|
if (value != undefined) {
|
|
@@ -28036,8 +29064,7 @@ var TrailMesh = /*#__PURE__*/ function() {
|
|
|
28036
29064
|
var pointCountPerTrail = this.pointCountPerTrail;
|
|
28037
29065
|
if (index >= 0 && index < pointCountPerTrail) {
|
|
28038
29066
|
var startIndex = (trail * pointCountPerTrail + index) * 24 + 8;
|
|
28039
|
-
var data = this.
|
|
28040
|
-
assertExist(data);
|
|
29067
|
+
var data = this.getAttributeData(VertexBuffer.ColorKind);
|
|
28041
29068
|
out.x = data[startIndex];
|
|
28042
29069
|
out.y = data[1 + startIndex];
|
|
28043
29070
|
out.z = data[2 + startIndex];
|
|
@@ -28051,12 +29078,11 @@ var TrailMesh = /*#__PURE__*/ function() {
|
|
|
28051
29078
|
this.geometry.setIndexData(new Uint16Array(indexData.length));
|
|
28052
29079
|
};
|
|
28053
29080
|
_proto.minusTime = function minusTime(time) {
|
|
28054
|
-
var data = this.
|
|
28055
|
-
assertExist(data);
|
|
29081
|
+
var data = this.getAttributeData("aTime");
|
|
28056
29082
|
for(var i = 0; i < data.length; i++){
|
|
28057
29083
|
data[i] -= time;
|
|
28058
29084
|
}
|
|
28059
|
-
this.
|
|
29085
|
+
this.setAttributeData("aTime", data);
|
|
28060
29086
|
this.time -= time;
|
|
28061
29087
|
};
|
|
28062
29088
|
_proto.clearTrail = function clearTrail(index) {
|
|
@@ -28077,6 +29103,35 @@ var TrailMesh = /*#__PURE__*/ function() {
|
|
|
28077
29103
|
this.pointStart[index] = pos;
|
|
28078
29104
|
};
|
|
28079
29105
|
_proto.onUpdate = function onUpdate(escapeTime) {};
|
|
29106
|
+
_proto.getAttributeData = function getAttributeData(name) {
|
|
29107
|
+
var vertexBuffer = this.geometry.getVertexBuffer(name);
|
|
29108
|
+
var data = vertexBuffer && this.attributeData.get(vertexBuffer.getWrapperBuffer());
|
|
29109
|
+
assertExist(data);
|
|
29110
|
+
return data;
|
|
29111
|
+
};
|
|
29112
|
+
_proto.setAttributeData = function setAttributeData(name, data) {
|
|
29113
|
+
var vertexBuffer = this.geometry.getVertexBuffer(name);
|
|
29114
|
+
assertExist(vertexBuffer);
|
|
29115
|
+
this.attributeData.set(vertexBuffer.getWrapperBuffer(), data);
|
|
29116
|
+
this.geometry.setAttributeData(name, data);
|
|
29117
|
+
};
|
|
29118
|
+
_proto.setAttributeSubData = function setAttributeSubData(name, offset, data) {
|
|
29119
|
+
var target = this.getAttributeData(name);
|
|
29120
|
+
target.set(data, offset);
|
|
29121
|
+
this.geometry.setAttributeSubData(name, offset, data);
|
|
29122
|
+
};
|
|
29123
|
+
/**
|
|
29124
|
+
* @internal
|
|
29125
|
+
*/ _proto.rebuild = function rebuild() {
|
|
29126
|
+
if (!this.geometry.isInitialized || this.geometry.isDisposed()) {
|
|
29127
|
+
return;
|
|
29128
|
+
}
|
|
29129
|
+
this.attributeData.forEach(function(data, buffer) {
|
|
29130
|
+
if (!buffer.getData()) {
|
|
29131
|
+
buffer.update(data);
|
|
29132
|
+
}
|
|
29133
|
+
});
|
|
29134
|
+
};
|
|
28080
29135
|
_create_class(TrailMesh, [
|
|
28081
29136
|
{
|
|
28082
29137
|
key: "time",
|
|
@@ -28200,11 +29255,13 @@ var particleUniformTypeMap = {
|
|
|
28200
29255
|
|
|
28201
29256
|
var ParticleMesh = /*#__PURE__*/ function() {
|
|
28202
29257
|
function ParticleMesh(engine, props) {
|
|
29258
|
+
var _this = this;
|
|
28203
29259
|
this.particleCount = 0;
|
|
28204
29260
|
this.cachedRotationVector3 = new Vector3();
|
|
28205
29261
|
this.cachedRotationMatrix = new Matrix3();
|
|
28206
29262
|
this.cachedLinearMove = new Vector3();
|
|
28207
29263
|
this.tempMatrix3 = new Matrix3();
|
|
29264
|
+
this.attributeData = new Map();
|
|
28208
29265
|
this.VERT_MAX_KEY_FRAME_COUNT = 0;
|
|
28209
29266
|
var env = (engine != null ? engine : {}).env;
|
|
28210
29267
|
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;
|
|
@@ -28503,6 +29560,13 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
28503
29560
|
this.anchor = anchor;
|
|
28504
29561
|
this.mesh = mesh;
|
|
28505
29562
|
this.geometry = mesh.firstGeometry();
|
|
29563
|
+
this.geometry.getAttributeNames().forEach(function(name) {
|
|
29564
|
+
var vertexBuffer = _this.geometry.getVertexBuffer(name);
|
|
29565
|
+
var data = _this.geometry.getAttributeData(name);
|
|
29566
|
+
if (vertexBuffer && _instanceof1(data, Float32Array)) {
|
|
29567
|
+
_this.attributeData.set(vertexBuffer.getWrapperBuffer(), data);
|
|
29568
|
+
}
|
|
29569
|
+
});
|
|
28506
29570
|
this.forceTarget = forceTarget;
|
|
28507
29571
|
this.sizeOverLifetime = sizeOverLifetime;
|
|
28508
29572
|
this.speedOverLifetime = speedOverLifetime;
|
|
@@ -28512,6 +29576,7 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
28512
29576
|
this.gravityModifier = gravityModifier;
|
|
28513
29577
|
this.rotationOverLifetime = rotationOverLifetime;
|
|
28514
29578
|
this.maxCount = maxCount;
|
|
29579
|
+
this.maxParticleBufferCount = maxCount;
|
|
28515
29580
|
// this.duration = duration;
|
|
28516
29581
|
this.textureOffsets = textureFlip ? [
|
|
28517
29582
|
0,
|
|
@@ -28545,9 +29610,8 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
28545
29610
|
// // this.mesh.material.setVector4('uParams', new Vector4(+v, this.duration, 0, 0));
|
|
28546
29611
|
// }
|
|
28547
29612
|
_proto.getPointColor = function getPointColor(index) {
|
|
28548
|
-
var data = this.
|
|
29613
|
+
var data = this.getAttributeData("aRot");
|
|
28549
29614
|
var i = index * 32 + 4;
|
|
28550
|
-
assertExist(data);
|
|
28551
29615
|
return [
|
|
28552
29616
|
data[i],
|
|
28553
29617
|
data[i + 1],
|
|
@@ -28556,46 +29620,31 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
28556
29620
|
];
|
|
28557
29621
|
};
|
|
28558
29622
|
_proto.clearPoints = function clearPoints() {
|
|
28559
|
-
this.resetGeometryData(this.geometry);
|
|
28560
29623
|
this.particleCount = 0;
|
|
28561
29624
|
this.geometry.setDrawCount(0);
|
|
28562
|
-
this.maxParticleBufferCount = 0;
|
|
28563
|
-
};
|
|
28564
|
-
_proto.resetGeometryData = function resetGeometryData(geometry) {
|
|
28565
|
-
var names = geometry.getAttributeNames();
|
|
28566
|
-
var index = geometry.getIndexData();
|
|
28567
|
-
for(var i = 0; i < names.length; i++){
|
|
28568
|
-
var name = names[i];
|
|
28569
|
-
var data = geometry.getAttributeData(name);
|
|
28570
|
-
if (data) {
|
|
28571
|
-
// @ts-expect-error
|
|
28572
|
-
geometry.setAttributeData(name, new data.constructor(0));
|
|
28573
|
-
}
|
|
28574
|
-
}
|
|
28575
|
-
// @ts-expect-error
|
|
28576
|
-
geometry.setIndexData(new index.constructor(0));
|
|
28577
29625
|
};
|
|
28578
29626
|
_proto.onUpdate = function onUpdate(dt) {
|
|
28579
|
-
var aPosArray = this.
|
|
29627
|
+
var aPosArray = this.getAttributeData(VertexBuffer.PositionKind); // vector3
|
|
28580
29628
|
var vertexCount = Math.ceil(aPosArray.length / 12);
|
|
28581
29629
|
this.applyTranslation(vertexCount, dt);
|
|
28582
29630
|
this.applyRotation(vertexCount, dt);
|
|
28583
29631
|
this.applyLinearMove(vertexCount, dt);
|
|
28584
29632
|
};
|
|
28585
29633
|
_proto.minusTime = function minusTime(time) {
|
|
28586
|
-
var aOffset = this.
|
|
29634
|
+
var aOffset = this.getAttributeData("aOffset");
|
|
28587
29635
|
for(var i = 0; i < aOffset.length; i += 4){
|
|
28588
29636
|
aOffset[i + 2] -= time;
|
|
28589
29637
|
}
|
|
28590
|
-
this.
|
|
29638
|
+
this.setAttributeData("aOffset", aOffset);
|
|
28591
29639
|
this.time -= time;
|
|
28592
29640
|
};
|
|
28593
29641
|
_proto.removePoint = function removePoint(index) {
|
|
28594
29642
|
if (index < this.particleCount) {
|
|
28595
|
-
this.
|
|
29643
|
+
this.setAttributeSubData("aOffset", index * 16, new Float32Array(16));
|
|
28596
29644
|
}
|
|
28597
29645
|
};
|
|
28598
29646
|
_proto.setPoint = function setPoint(index, point) {
|
|
29647
|
+
var _this = this;
|
|
28599
29648
|
var maxCount = this.maxCount;
|
|
28600
29649
|
if (index < maxCount) {
|
|
28601
29650
|
var particleCount = index + 1;
|
|
@@ -28712,13 +29761,12 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
28712
29761
|
var data = pointData[name];
|
|
28713
29762
|
var attrSize = geometry.getAttributeStride(name) / Float32Array.BYTES_PER_ELEMENT;
|
|
28714
29763
|
if (increaseBuffer) {
|
|
28715
|
-
var baseData =
|
|
28716
|
-
assertExist(baseData);
|
|
29764
|
+
var baseData = _this.getAttributeData(name);
|
|
28717
29765
|
var geoData = enlargeBuffer(baseData, vertexCount * attrSize, maxCount * 4 * attrSize, inc);
|
|
28718
29766
|
geoData.set(data, data.length * index);
|
|
28719
|
-
|
|
29767
|
+
_this.setAttributeData(name, geoData);
|
|
28720
29768
|
} else {
|
|
28721
|
-
|
|
29769
|
+
_this.setAttributeSubData(name, data.length * index, data);
|
|
28722
29770
|
}
|
|
28723
29771
|
});
|
|
28724
29772
|
this.particleCount = Math.max(particleCount, this.particleCount);
|
|
@@ -28727,9 +29775,9 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
28727
29775
|
};
|
|
28728
29776
|
_proto.applyTranslation = function applyTranslation(vertexCount, deltaTime) {
|
|
28729
29777
|
var localTime = this.time;
|
|
28730
|
-
var aTranslationArray = this.
|
|
28731
|
-
var aVelArray = this.
|
|
28732
|
-
var aOffsetArray = this.
|
|
29778
|
+
var aTranslationArray = this.getAttributeData("aTranslation");
|
|
29779
|
+
var aVelArray = this.getAttributeData("aVel"); // vector3
|
|
29780
|
+
var aOffsetArray = this.getAttributeData("aOffset");
|
|
28733
29781
|
if (aTranslationArray.length < vertexCount * 3) {
|
|
28734
29782
|
aTranslationArray = this.expandArray(aTranslationArray, vertexCount * 3);
|
|
28735
29783
|
}
|
|
@@ -28788,13 +29836,13 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
28788
29836
|
aTranslationArray[aTranslationOffset + 11] += aTranslationZ;
|
|
28789
29837
|
}
|
|
28790
29838
|
}
|
|
28791
|
-
this.
|
|
29839
|
+
this.setAttributeData("aTranslation", aTranslationArray);
|
|
28792
29840
|
};
|
|
28793
29841
|
_proto.applyRotation = function applyRotation(vertexCount, deltaTime) {
|
|
28794
|
-
var aRotationArray = this.
|
|
28795
|
-
var aOffsetArray = this.
|
|
28796
|
-
var aRotArray = this.
|
|
28797
|
-
var aSeedArray = this.
|
|
29842
|
+
var aRotationArray = this.getAttributeData("aRotation0");
|
|
29843
|
+
var aOffsetArray = this.getAttributeData("aOffset");
|
|
29844
|
+
var aRotArray = this.getAttributeData("aRot"); // vector3
|
|
29845
|
+
var aSeedArray = this.getAttributeData("aSeed"); // float
|
|
28798
29846
|
var localTime = this.time;
|
|
28799
29847
|
var aRotationMatrix = this.cachedRotationMatrix;
|
|
28800
29848
|
if (aRotationArray.length < vertexCount * 9) {
|
|
@@ -28885,12 +29933,12 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
28885
29933
|
aRotationArray.set(matrixArray, aRotationOffset + 27);
|
|
28886
29934
|
}
|
|
28887
29935
|
}
|
|
28888
|
-
this.
|
|
29936
|
+
this.setAttributeData("aRotation0", aRotationArray);
|
|
28889
29937
|
};
|
|
28890
29938
|
_proto.applyLinearMove = function applyLinearMove(vertexCount, deltaTime) {
|
|
28891
|
-
var aLinearMoveArray = this.
|
|
28892
|
-
var aOffsetArray = this.
|
|
28893
|
-
var aSeedArray = this.
|
|
29939
|
+
var aLinearMoveArray = this.getAttributeData("aLinearMove");
|
|
29940
|
+
var aOffsetArray = this.getAttributeData("aOffset");
|
|
29941
|
+
var aSeedArray = this.getAttributeData("aSeed"); // float
|
|
28894
29942
|
var localTime = this.time;
|
|
28895
29943
|
if (aLinearMoveArray.length < vertexCount * 3) {
|
|
28896
29944
|
aLinearMoveArray = this.expandArray(aLinearMoveArray, vertexCount * 3);
|
|
@@ -28965,7 +30013,36 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
28965
30013
|
aLinearMoveArray[aLinearMoveOffset + 11] = linearMove.z;
|
|
28966
30014
|
}
|
|
28967
30015
|
}
|
|
28968
|
-
this.
|
|
30016
|
+
this.setAttributeData("aLinearMove", aLinearMoveArray);
|
|
30017
|
+
};
|
|
30018
|
+
_proto.getAttributeData = function getAttributeData(name) {
|
|
30019
|
+
var vertexBuffer = this.geometry.getVertexBuffer(name);
|
|
30020
|
+
var data = vertexBuffer && this.attributeData.get(vertexBuffer.getWrapperBuffer());
|
|
30021
|
+
assertExist(data);
|
|
30022
|
+
return data;
|
|
30023
|
+
};
|
|
30024
|
+
_proto.setAttributeData = function setAttributeData(name, data) {
|
|
30025
|
+
var vertexBuffer = this.geometry.getVertexBuffer(name);
|
|
30026
|
+
assertExist(vertexBuffer);
|
|
30027
|
+
this.attributeData.set(vertexBuffer.getWrapperBuffer(), data);
|
|
30028
|
+
this.geometry.setAttributeData(name, data);
|
|
30029
|
+
};
|
|
30030
|
+
_proto.setAttributeSubData = function setAttributeSubData(name, offset, data) {
|
|
30031
|
+
var target = this.getAttributeData(name);
|
|
30032
|
+
target.set(data, offset);
|
|
30033
|
+
this.geometry.setAttributeSubData(name, offset, data);
|
|
30034
|
+
};
|
|
30035
|
+
/**
|
|
30036
|
+
* @internal
|
|
30037
|
+
*/ _proto.rebuild = function rebuild() {
|
|
30038
|
+
if (!this.geometry.isInitialized || this.geometry.isDisposed()) {
|
|
30039
|
+
return;
|
|
30040
|
+
}
|
|
30041
|
+
this.attributeData.forEach(function(data, buffer) {
|
|
30042
|
+
if (!buffer.getData()) {
|
|
30043
|
+
buffer.update(data);
|
|
30044
|
+
}
|
|
30045
|
+
});
|
|
28969
30046
|
};
|
|
28970
30047
|
_proto.expandArray = function expandArray(array, newSize) {
|
|
28971
30048
|
var newArr = new Float32Array(newSize);
|
|
@@ -28977,83 +30054,70 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
28977
30054
|
function generateGeometryProps(maxVertex, useSprite, name) {
|
|
28978
30055
|
var bpe = Float32Array.BYTES_PER_ELEMENT;
|
|
28979
30056
|
var j12 = bpe * 12;
|
|
28980
|
-
var
|
|
28981
|
-
|
|
28982
|
-
|
|
28983
|
-
|
|
28984
|
-
|
|
28985
|
-
|
|
28986
|
-
|
|
28987
|
-
|
|
28988
|
-
|
|
28989
|
-
|
|
28990
|
-
|
|
28991
|
-
|
|
28992
|
-
|
|
28993
|
-
|
|
28994
|
-
|
|
28995
|
-
|
|
28996
|
-
|
|
28997
|
-
|
|
28998
|
-
|
|
28999
|
-
|
|
29000
|
-
|
|
29001
|
-
|
|
29002
|
-
|
|
29003
|
-
|
|
29004
|
-
|
|
29005
|
-
|
|
29006
|
-
|
|
29007
|
-
|
|
29008
|
-
|
|
29009
|
-
|
|
29010
|
-
|
|
29011
|
-
|
|
29012
|
-
|
|
29013
|
-
|
|
29014
|
-
|
|
29015
|
-
|
|
29016
|
-
|
|
29017
|
-
|
|
29018
|
-
|
|
29019
|
-
|
|
29020
|
-
|
|
29021
|
-
|
|
29022
|
-
|
|
29023
|
-
|
|
29024
|
-
|
|
29025
|
-
|
|
29026
|
-
|
|
29027
|
-
|
|
29028
|
-
|
|
29029
|
-
|
|
29030
|
-
|
|
29031
|
-
|
|
29032
|
-
|
|
29033
|
-
|
|
29034
|
-
|
|
29035
|
-
|
|
29036
|
-
|
|
29037
|
-
|
|
29038
|
-
|
|
29039
|
-
|
|
29040
|
-
|
|
29041
|
-
|
|
29042
|
-
|
|
29043
|
-
|
|
29044
|
-
aRotation1: {
|
|
29045
|
-
size: 3,
|
|
29046
|
-
offset: 3 * bpe,
|
|
29047
|
-
stride: 9 * bpe,
|
|
29048
|
-
dataSource: "aRotation0"
|
|
29049
|
-
},
|
|
29050
|
-
aRotation2: {
|
|
29051
|
-
size: 3,
|
|
29052
|
-
offset: 6 * bpe,
|
|
29053
|
-
stride: 9 * bpe,
|
|
29054
|
-
dataSource: "aRotation0"
|
|
29055
|
-
}
|
|
29056
|
-
};
|
|
30057
|
+
var _obj;
|
|
30058
|
+
var attributes = (_obj = {}, _obj[VertexBuffer.PositionKind] = {
|
|
30059
|
+
size: 3,
|
|
30060
|
+
offset: 0,
|
|
30061
|
+
stride: j12,
|
|
30062
|
+
data: new Float32Array(0)
|
|
30063
|
+
}, _obj.aVel = {
|
|
30064
|
+
size: 3,
|
|
30065
|
+
offset: 3 * bpe,
|
|
30066
|
+
stride: j12,
|
|
30067
|
+
dataSource: VertexBuffer.PositionKind
|
|
30068
|
+
}, _obj.aDirX = {
|
|
30069
|
+
size: 3,
|
|
30070
|
+
offset: 6 * bpe,
|
|
30071
|
+
stride: j12,
|
|
30072
|
+
dataSource: VertexBuffer.PositionKind
|
|
30073
|
+
}, _obj.aDirY = {
|
|
30074
|
+
size: 3,
|
|
30075
|
+
offset: 9 * bpe,
|
|
30076
|
+
stride: j12,
|
|
30077
|
+
dataSource: VertexBuffer.PositionKind
|
|
30078
|
+
}, //
|
|
30079
|
+
_obj.aRot = {
|
|
30080
|
+
size: 3,
|
|
30081
|
+
offset: 0,
|
|
30082
|
+
stride: 8 * bpe,
|
|
30083
|
+
data: new Float32Array(0)
|
|
30084
|
+
}, _obj.aSeed = {
|
|
30085
|
+
size: 1,
|
|
30086
|
+
offset: 3 * bpe,
|
|
30087
|
+
stride: 8 * bpe,
|
|
30088
|
+
dataSource: "aRot"
|
|
30089
|
+
}, _obj[VertexBuffer.ColorKind] = {
|
|
30090
|
+
size: 4,
|
|
30091
|
+
offset: 4 * bpe,
|
|
30092
|
+
stride: 8 * bpe,
|
|
30093
|
+
dataSource: "aRot"
|
|
30094
|
+
}, //
|
|
30095
|
+
_obj.aOffset = {
|
|
30096
|
+
size: 4,
|
|
30097
|
+
stride: 4 * bpe,
|
|
30098
|
+
data: new Float32Array(0)
|
|
30099
|
+
}, _obj.aTranslation = {
|
|
30100
|
+
size: 3,
|
|
30101
|
+
data: new Float32Array(0)
|
|
30102
|
+
}, _obj.aLinearMove = {
|
|
30103
|
+
size: 3,
|
|
30104
|
+
data: new Float32Array(0)
|
|
30105
|
+
}, _obj.aRotation0 = {
|
|
30106
|
+
size: 3,
|
|
30107
|
+
offset: 0,
|
|
30108
|
+
stride: 9 * bpe,
|
|
30109
|
+
data: new Float32Array(0)
|
|
30110
|
+
}, _obj.aRotation1 = {
|
|
30111
|
+
size: 3,
|
|
30112
|
+
offset: 3 * bpe,
|
|
30113
|
+
stride: 9 * bpe,
|
|
30114
|
+
dataSource: "aRotation0"
|
|
30115
|
+
}, _obj.aRotation2 = {
|
|
30116
|
+
size: 3,
|
|
30117
|
+
offset: 6 * bpe,
|
|
30118
|
+
stride: 9 * bpe,
|
|
30119
|
+
dataSource: "aRotation0"
|
|
30120
|
+
}, _obj);
|
|
29057
30121
|
if (useSprite) {
|
|
29058
30122
|
attributes["aSprite"] = {
|
|
29059
30123
|
size: 3,
|
|
@@ -29064,10 +30128,11 @@ function generateGeometryProps(maxVertex, useSprite, name) {
|
|
|
29064
30128
|
return {
|
|
29065
30129
|
attributes: attributes,
|
|
29066
30130
|
indices: {
|
|
29067
|
-
data: new Uint16Array(
|
|
30131
|
+
data: new Uint16Array(maxVertex / 4 * 6)
|
|
29068
30132
|
},
|
|
29069
30133
|
name: name,
|
|
29070
|
-
maxVertex: maxVertex
|
|
30134
|
+
maxVertex: maxVertex,
|
|
30135
|
+
bufferUsage: BufferUsage.Dynamic
|
|
29071
30136
|
};
|
|
29072
30137
|
}
|
|
29073
30138
|
function getParticleMeshShader(item, gpuCapability, env) {
|
|
@@ -29347,6 +30412,13 @@ function modifyMaxKeyframeShader(shader, maxVertex, maxFrag) {
|
|
|
29347
30412
|
this.materials.push(this.trailMesh.mesh.material);
|
|
29348
30413
|
}
|
|
29349
30414
|
};
|
|
30415
|
+
/**
|
|
30416
|
+
* @internal
|
|
30417
|
+
*/ _proto.rebuild = function rebuild() {
|
|
30418
|
+
var _this_trailMesh;
|
|
30419
|
+
this.particleMesh.rebuild();
|
|
30420
|
+
(_this_trailMesh = this.trailMesh) == null ? void 0 : _this_trailMesh.rebuild();
|
|
30421
|
+
};
|
|
29350
30422
|
_proto.reset = function reset() {
|
|
29351
30423
|
var _this_trailMesh;
|
|
29352
30424
|
this.particleMesh.clearPoints();
|
|
@@ -29446,6 +30518,7 @@ var ParticleSystem = /*#__PURE__*/ function(Component) {
|
|
|
29446
30518
|
};
|
|
29447
30519
|
}
|
|
29448
30520
|
};
|
|
30521
|
+
engine.addParticleSystem(_assert_this_initialized(_this));
|
|
29449
30522
|
_this.maskManager = new MaskProcessor();
|
|
29450
30523
|
if (props) {
|
|
29451
30524
|
_this.fromData(props);
|
|
@@ -29717,6 +30790,18 @@ var ParticleSystem = /*#__PURE__*/ function(Component) {
|
|
|
29717
30790
|
});
|
|
29718
30791
|
}
|
|
29719
30792
|
};
|
|
30793
|
+
/**
|
|
30794
|
+
* @hidden
|
|
30795
|
+
* Internal utility.
|
|
30796
|
+
* Not part of the public API — do not rely on this in your code.
|
|
30797
|
+
*/ _proto.rebuild = function rebuild() {
|
|
30798
|
+
var _this_renderer;
|
|
30799
|
+
(_this_renderer = this.renderer) == null ? void 0 : _this_renderer.rebuild();
|
|
30800
|
+
};
|
|
30801
|
+
_proto.dispose = function dispose() {
|
|
30802
|
+
this.engine.removeParticleSystem(this);
|
|
30803
|
+
Component.prototype.dispose.call(this);
|
|
30804
|
+
};
|
|
29720
30805
|
_proto.getParticleBoxes = function getParticleBoxes() {
|
|
29721
30806
|
var link = this.particleLink;
|
|
29722
30807
|
var renderer = this.renderer;
|
|
@@ -30776,7 +31861,7 @@ var TimelineInstance = /*#__PURE__*/ function() {
|
|
|
30776
31861
|
return TimelineInstance;
|
|
30777
31862
|
}();
|
|
30778
31863
|
|
|
30779
|
-
var seed$
|
|
31864
|
+
var seed$2 = 0;
|
|
30780
31865
|
var SpriteColorPlayableAsset = /*#__PURE__*/ function(PlayableAsset) {
|
|
30781
31866
|
_inherits(SpriteColorPlayableAsset, PlayableAsset);
|
|
30782
31867
|
function SpriteColorPlayableAsset() {
|
|
@@ -30863,7 +31948,7 @@ var SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
30863
31948
|
_this = MaskableGraphic.call(this, engine) || this;
|
|
30864
31949
|
_this.time = 0;
|
|
30865
31950
|
_this.duration = 1;
|
|
30866
|
-
_this.name = "MSprite" + seed$
|
|
31951
|
+
_this.name = "MSprite" + seed$2++;
|
|
30867
31952
|
if (props) {
|
|
30868
31953
|
_this.fromData(props);
|
|
30869
31954
|
}
|
|
@@ -30984,8 +32069,8 @@ var SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
30984
32069
|
var width = isRotate90 ? h : w;
|
|
30985
32070
|
var height = isRotate90 ? w : h;
|
|
30986
32071
|
var angle = isRotate90 ? -Math.PI / 2 : 0;
|
|
30987
|
-
var aUV = geometry.getAttributeData(
|
|
30988
|
-
var aPos = geometry.getAttributeData(
|
|
32072
|
+
var aUV = geometry.getAttributeData(VertexBuffer.UVKind);
|
|
32073
|
+
var aPos = geometry.getAttributeData(VertexBuffer.PositionKind);
|
|
30989
32074
|
var indices = geometry.getIndexData();
|
|
30990
32075
|
var tempPosition = [
|
|
30991
32076
|
0,
|
|
@@ -31004,8 +32089,8 @@ var SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
31004
32089
|
aUV[uvOffset] = (tempPosition[0] + 0.5) * width + x;
|
|
31005
32090
|
aUV[uvOffset + 1] = (tempPosition[1] + 0.5) * height + y;
|
|
31006
32091
|
}
|
|
31007
|
-
this.
|
|
31008
|
-
this.
|
|
32092
|
+
this.updateAttributeData(VertexBuffer.PositionKind, aPos.slice(), 3);
|
|
32093
|
+
this.updateAttributeData(VertexBuffer.UVKind, aUV.slice(), 2);
|
|
31009
32094
|
this.geometry.setIndexData(indices.slice());
|
|
31010
32095
|
this.geometry.setDrawCount(indices.length);
|
|
31011
32096
|
}
|
|
@@ -31125,11 +32210,23 @@ var SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
31125
32210
|
index.push(base, 1 + base, 2 + base, 2 + base, 1 + base, 3 + base);
|
|
31126
32211
|
}
|
|
31127
32212
|
}
|
|
31128
|
-
|
|
32213
|
+
this.updateAttributeData(VertexBuffer.PositionKind, new Float32Array(position), 3);
|
|
31129
32214
|
geometry.setIndexData(new Uint16Array(index));
|
|
31130
|
-
|
|
32215
|
+
this.updateAttributeData(VertexBuffer.UVKind, new Float32Array(aUV), 2);
|
|
31131
32216
|
geometry.setDrawCount(index.length);
|
|
31132
32217
|
};
|
|
32218
|
+
_proto.updateAttributeData = function updateAttributeData(name, data, size) {
|
|
32219
|
+
var vertexBuffer = this.geometry.getVertexBuffer(name);
|
|
32220
|
+
var dataBuffer = vertexBuffer == null ? void 0 : vertexBuffer.getBuffer();
|
|
32221
|
+
if (!vertexBuffer || dataBuffer && data.byteLength > dataBuffer.capacity) {
|
|
32222
|
+
this.geometry.setVerticesBuffer(new VertexBuffer(this.engine, data, name, {
|
|
32223
|
+
updatable: true,
|
|
32224
|
+
size: size
|
|
32225
|
+
}));
|
|
32226
|
+
return;
|
|
32227
|
+
}
|
|
32228
|
+
this.geometry.setAttributeData(name, data);
|
|
32229
|
+
};
|
|
31133
32230
|
_create_class(SpriteComponent, [
|
|
31134
32231
|
{
|
|
31135
32232
|
key: "sprite",
|
|
@@ -31598,20 +32695,22 @@ var TextStyle = /*#__PURE__*/ function() {
|
|
|
31598
32695
|
return;
|
|
31599
32696
|
}
|
|
31600
32697
|
var context = this.context;
|
|
32698
|
+
var textureWidth = Math.max(1, width);
|
|
32699
|
+
var textureHeight = Math.max(1, height);
|
|
31601
32700
|
// 先保存状态
|
|
31602
32701
|
context.save();
|
|
31603
32702
|
// 设置canvas尺寸
|
|
31604
|
-
this.canvas.width =
|
|
31605
|
-
this.canvas.height =
|
|
32703
|
+
this.canvas.width = textureWidth;
|
|
32704
|
+
this.canvas.height = textureHeight;
|
|
31606
32705
|
//重置变换
|
|
31607
32706
|
context.setTransform(1, 0, 0, 1, 0, 0);
|
|
31608
32707
|
// 处理翻转
|
|
31609
32708
|
if (!flipY) {
|
|
31610
|
-
context.translate(0,
|
|
32709
|
+
context.translate(0, textureHeight);
|
|
31611
32710
|
context.scale(1, -1);
|
|
31612
32711
|
}
|
|
31613
32712
|
// 在翻转后清空画布
|
|
31614
|
-
context.clearRect(0, 0,
|
|
32713
|
+
context.clearRect(0, 0, textureWidth, textureHeight);
|
|
31615
32714
|
// 设置 alpha 修复用填充色(不实际输出像素)
|
|
31616
32715
|
context.fillStyle = "rgba(255, 255, 255, " + this.ALPHA_FIX_VALUE + ")";
|
|
31617
32716
|
// 执行绘制回调
|
|
@@ -31619,7 +32718,7 @@ var TextStyle = /*#__PURE__*/ function() {
|
|
|
31619
32718
|
// 创建纹理前恢复状态
|
|
31620
32719
|
context.restore();
|
|
31621
32720
|
// 创建新纹理
|
|
31622
|
-
var imageData = context.getImageData(0, 0,
|
|
32721
|
+
var imageData = context.getImageData(0, 0, textureWidth, textureHeight);
|
|
31623
32722
|
var texture = Texture.createWithData(this.engine, {
|
|
31624
32723
|
data: new Uint8Array(imageData.data),
|
|
31625
32724
|
width: imageData.width,
|
|
@@ -31655,7 +32754,7 @@ var DEFAULT_FONTS = [
|
|
|
31655
32754
|
"courier"
|
|
31656
32755
|
];
|
|
31657
32756
|
/** 检测字符串是否包含需要 RTL 和连写排版的字符(阿拉伯语等) */ var HAS_RTL_OR_JOINING = /[\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/;
|
|
31658
|
-
var seed$
|
|
32757
|
+
var seed$1 = 0;
|
|
31659
32758
|
var TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
31660
32759
|
_inherits(TextComponent, MaskableGraphic);
|
|
31661
32760
|
function TextComponent(engine) {
|
|
@@ -31672,7 +32771,7 @@ var TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
31672
32771
|
/**
|
|
31673
32772
|
* 每一行文本的最大宽度
|
|
31674
32773
|
*/ _this.maxLineWidth = 0;
|
|
31675
|
-
_this.name = "MText" + seed$
|
|
32774
|
+
_this.name = "MText" + seed$1++;
|
|
31676
32775
|
// 初始化canvas资源
|
|
31677
32776
|
var canvasAndContext = canvasPool.getCanvasAndContext(1, 1);
|
|
31678
32777
|
_this.canvas = canvasAndContext.canvas;
|
|
@@ -33588,45 +34687,42 @@ var ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
33588
34687
|
easingOuts: [],
|
|
33589
34688
|
shapes: []
|
|
33590
34689
|
};
|
|
34690
|
+
var _obj;
|
|
33591
34691
|
// Create Geometry
|
|
33592
34692
|
//-------------------------------------------------------------------------
|
|
33593
34693
|
_this.geometry = Geometry.create(_this.engine, {
|
|
33594
|
-
attributes: {
|
|
33595
|
-
|
|
33596
|
-
|
|
33597
|
-
|
|
33598
|
-
|
|
33599
|
-
|
|
33600
|
-
|
|
33601
|
-
|
|
33602
|
-
|
|
33603
|
-
|
|
33604
|
-
|
|
33605
|
-
|
|
33606
|
-
|
|
33607
|
-
|
|
33608
|
-
|
|
33609
|
-
|
|
33610
|
-
|
|
33611
|
-
|
|
33612
|
-
|
|
33613
|
-
|
|
33614
|
-
|
|
33615
|
-
|
|
33616
|
-
|
|
33617
|
-
|
|
33618
|
-
|
|
33619
|
-
|
|
33620
|
-
|
|
33621
|
-
|
|
33622
|
-
|
|
33623
|
-
|
|
33624
|
-
|
|
33625
|
-
|
|
33626
|
-
0
|
|
33627
|
-
])
|
|
33628
|
-
}
|
|
33629
|
-
},
|
|
34694
|
+
attributes: (_obj = {}, _obj[VertexBuffer.PositionKind] = {
|
|
34695
|
+
type: glContext.FLOAT,
|
|
34696
|
+
size: 3,
|
|
34697
|
+
data: new Float32Array([
|
|
34698
|
+
-0.5,
|
|
34699
|
+
0.5,
|
|
34700
|
+
0,
|
|
34701
|
+
-0.5,
|
|
34702
|
+
-0.5,
|
|
34703
|
+
0,
|
|
34704
|
+
0.5,
|
|
34705
|
+
0.5,
|
|
34706
|
+
0,
|
|
34707
|
+
0.5,
|
|
34708
|
+
-0.5,
|
|
34709
|
+
0
|
|
34710
|
+
])
|
|
34711
|
+
}, _obj[VertexBuffer.UVKind] = {
|
|
34712
|
+
size: 2,
|
|
34713
|
+
offset: 0,
|
|
34714
|
+
type: glContext.FLOAT,
|
|
34715
|
+
data: new Float32Array([
|
|
34716
|
+
0,
|
|
34717
|
+
1,
|
|
34718
|
+
0,
|
|
34719
|
+
0,
|
|
34720
|
+
1,
|
|
34721
|
+
1,
|
|
34722
|
+
1,
|
|
34723
|
+
0
|
|
34724
|
+
])
|
|
34725
|
+
}, _obj),
|
|
33630
34726
|
indices: {
|
|
33631
34727
|
data: new Uint16Array([
|
|
33632
34728
|
0,
|
|
@@ -33635,11 +34731,11 @@ var ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
33635
34731
|
2,
|
|
33636
34732
|
1,
|
|
33637
34733
|
3
|
|
33638
|
-
])
|
|
33639
|
-
releasable: true
|
|
34734
|
+
])
|
|
33640
34735
|
},
|
|
33641
34736
|
mode: glContext.TRIANGLES,
|
|
33642
|
-
drawCount: 6
|
|
34737
|
+
drawCount: 6,
|
|
34738
|
+
bufferUsage: glContext.DYNAMIC_DRAW
|
|
33643
34739
|
});
|
|
33644
34740
|
_this.geometry.subMeshes.push({
|
|
33645
34741
|
offset: 0,
|
|
@@ -33705,7 +34801,7 @@ var ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
33705
34801
|
return boundingBox;
|
|
33706
34802
|
};
|
|
33707
34803
|
_proto.getBoundingBoxInfo = function getBoundingBoxInfo() {
|
|
33708
|
-
var positionArray = this.geometry.getAttributeData(
|
|
34804
|
+
var positionArray = this.geometry.getAttributeData(VertexBuffer.PositionKind);
|
|
33709
34805
|
if (positionArray) {
|
|
33710
34806
|
var minMaxResult = extractMinAndMax(positionArray, 0, positionArray.length / 3);
|
|
33711
34807
|
minMaxResult.minimum.x *= this.transform.size.x;
|
|
@@ -33756,8 +34852,8 @@ var ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
33756
34852
|
var strokeIndexCount = indices.length - fillIndexCount;
|
|
33757
34853
|
var vertexCount = vertices.length / 2;
|
|
33758
34854
|
// Get the current attribute and index arrays from the geometry, avoiding re-creation
|
|
33759
|
-
var positionArray = this.geometry.getAttributeData(
|
|
33760
|
-
var uvArray = this.geometry.getAttributeData(
|
|
34855
|
+
var positionArray = this.geometry.getAttributeData(VertexBuffer.PositionKind);
|
|
34856
|
+
var uvArray = this.geometry.getAttributeData(VertexBuffer.UVKind);
|
|
33761
34857
|
var indexArray = this.geometry.getIndexData();
|
|
33762
34858
|
if (!positionArray || positionArray.length < vertexCount * 3) {
|
|
33763
34859
|
positionArray = new Float32Array(vertexCount * 3);
|
|
@@ -33798,8 +34894,8 @@ var ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
33798
34894
|
// Set index array
|
|
33799
34895
|
indexArray.set(indices);
|
|
33800
34896
|
// Rewrite to geometry
|
|
33801
|
-
this.
|
|
33802
|
-
this.
|
|
34897
|
+
this.updateAttributeData(VertexBuffer.PositionKind, positionArray, 3);
|
|
34898
|
+
this.updateAttributeData(VertexBuffer.UVKind, uvArray, 2);
|
|
33803
34899
|
this.geometry.setIndexData(indexArray);
|
|
33804
34900
|
this.geometry.setDrawCount(indices.length);
|
|
33805
34901
|
var u16Size = 2;
|
|
@@ -33809,6 +34905,18 @@ var ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
33809
34905
|
strokeSubMesh.offset = fillIndexCount * u16Size;
|
|
33810
34906
|
strokeSubMesh.indexCount = strokeIndexCount;
|
|
33811
34907
|
};
|
|
34908
|
+
_proto.updateAttributeData = function updateAttributeData(name, data, size) {
|
|
34909
|
+
var _this_geometry_getVertexBuffer;
|
|
34910
|
+
var dataBuffer = (_this_geometry_getVertexBuffer = this.geometry.getVertexBuffer(name)) == null ? void 0 : _this_geometry_getVertexBuffer.getBuffer();
|
|
34911
|
+
if (dataBuffer && data.byteLength > dataBuffer.capacity) {
|
|
34912
|
+
this.geometry.setVerticesBuffer(new VertexBuffer(this.engine, data, name, {
|
|
34913
|
+
updatable: true,
|
|
34914
|
+
size: size
|
|
34915
|
+
}));
|
|
34916
|
+
return;
|
|
34917
|
+
}
|
|
34918
|
+
this.geometry.setAttributeData(name, data);
|
|
34919
|
+
};
|
|
33812
34920
|
_proto.computeScreenScale = function computeScreenScale() {
|
|
33813
34921
|
var defaultPpu = 1;
|
|
33814
34922
|
var composition = this.item.composition;
|
|
@@ -36585,7 +37693,7 @@ function getStandardSpriteContent(sprite, transform) {
|
|
|
36585
37693
|
return ret;
|
|
36586
37694
|
}
|
|
36587
37695
|
|
|
36588
|
-
var version$2 = "2.10.0-alpha.
|
|
37696
|
+
var version$2 = "2.10.0-alpha.2";
|
|
36589
37697
|
var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
|
|
36590
37698
|
var standardVersion = /^(\d+)\.(\d+)$/;
|
|
36591
37699
|
var reverseParticle = false;
|
|
@@ -37082,7 +38190,7 @@ function _combineImageTemplate() {
|
|
|
37082
38190
|
this.options = options;
|
|
37083
38191
|
};
|
|
37084
38192
|
|
|
37085
|
-
var seed
|
|
38193
|
+
var seed = 1;
|
|
37086
38194
|
/**
|
|
37087
38195
|
* 资源管理器
|
|
37088
38196
|
* 用于加载和动效中所有的资源文件,包括图片、插件、图层粒子数据等
|
|
@@ -37094,7 +38202,7 @@ var seed$1 = 1;
|
|
|
37094
38202
|
this.downloader = downloader;
|
|
37095
38203
|
this.assets = {};
|
|
37096
38204
|
this.sourceFrom = {};
|
|
37097
|
-
this.id = seed
|
|
38205
|
+
this.id = seed++;
|
|
37098
38206
|
this.timers = [];
|
|
37099
38207
|
this.updateOptions(options);
|
|
37100
38208
|
}
|
|
@@ -38376,11 +39484,6 @@ var tmpScale = new Vector3(1, 1, 1);
|
|
|
38376
39484
|
return Camera;
|
|
38377
39485
|
}();
|
|
38378
39486
|
|
|
38379
|
-
function _assert_this_initialized(self) {
|
|
38380
|
-
if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
38381
|
-
return self;
|
|
38382
|
-
}
|
|
38383
|
-
|
|
38384
39487
|
/**
|
|
38385
39488
|
*
|
|
38386
39489
|
*/ var SceneTicking = /*#__PURE__*/ function() {
|
|
@@ -38547,7 +39650,7 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
|
|
|
38547
39650
|
_this.paused = true;
|
|
38548
39651
|
_this.isEndCalled = false;
|
|
38549
39652
|
_this._textures = [];
|
|
38550
|
-
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,
|
|
39653
|
+
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;
|
|
38551
39654
|
_this.engine.addComposition(_assert_this_initialized(_this));
|
|
38552
39655
|
var sourceContent = null;
|
|
38553
39656
|
if (scene) {
|
|
@@ -38605,7 +39708,7 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
|
|
|
38605
39708
|
_this.id = (_sourceContent_id = sourceContent == null ? void 0 : sourceContent.id) != null ? _sourceContent_id : generateGUID();
|
|
38606
39709
|
var _sourceContent_startTime;
|
|
38607
39710
|
_this.startTime = (_sourceContent_startTime = sourceContent == null ? void 0 : sourceContent.startTime) != null ? _sourceContent_startTime : 0;
|
|
38608
|
-
_this.event =
|
|
39711
|
+
_this.event = engine.eventSystem;
|
|
38609
39712
|
var _scene_startTime, _scene_totalTime;
|
|
38610
39713
|
_this.statistic = {
|
|
38611
39714
|
loadStart: (_scene_startTime = scene == null ? void 0 : scene.startTime) != null ? _scene_startTime : 0,
|
|
@@ -40951,6 +42054,7 @@ var DEFAULT_FPS = 60;
|
|
|
40951
42054
|
_this.renderPasses = [];
|
|
40952
42055
|
_this.framebuffers = [];
|
|
40953
42056
|
_this.renderbuffers = [];
|
|
42057
|
+
_this.particleSystems = [];
|
|
40954
42058
|
_this.clearAction = {
|
|
40955
42059
|
stencilAction: TextureLoadAction.clear,
|
|
40956
42060
|
clearStencil: 0,
|
|
@@ -40989,7 +42093,6 @@ var DEFAULT_FPS = 60;
|
|
|
40989
42093
|
_this.assetLoader = new AssetLoader(_assert_this_initialized(_this));
|
|
40990
42094
|
_this.assetService = new AssetService(_assert_this_initialized(_this));
|
|
40991
42095
|
_this.renderTargetPool = new RenderTargetPool(_assert_this_initialized(_this));
|
|
40992
|
-
_this.graphics = new Graphics(_assert_this_initialized(_this));
|
|
40993
42096
|
_this.renderingData = {
|
|
40994
42097
|
// @ts-expect-error
|
|
40995
42098
|
currentFrame: {}
|
|
@@ -41200,55 +42303,27 @@ var DEFAULT_FPS = 60;
|
|
|
41200
42303
|
});
|
|
41201
42304
|
this.emit("resize", this);
|
|
41202
42305
|
};
|
|
41203
|
-
_proto.
|
|
41204
|
-
|
|
41205
|
-
|
|
41206
|
-
|
|
41207
|
-
|
|
41208
|
-
|
|
41209
|
-
|
|
41210
|
-
|
|
41211
|
-
|
|
41212
|
-
|
|
41213
|
-
|
|
41214
|
-
|
|
41215
|
-
|
|
41216
|
-
|
|
41217
|
-
|
|
41218
|
-
|
|
41219
|
-
|
|
41220
|
-
|
|
41221
|
-
|
|
41222
|
-
|
|
41223
|
-
|
|
41224
|
-
targetHeight = finalHeight * this.displayScale;
|
|
41225
|
-
targetWidth = targetHeight * displayAspect;
|
|
41226
|
-
} else {
|
|
41227
|
-
targetWidth = finalWidth * this.displayScale;
|
|
41228
|
-
targetHeight = targetWidth / displayAspect;
|
|
41229
|
-
}
|
|
41230
|
-
} else {
|
|
41231
|
-
targetWidth = finalWidth;
|
|
41232
|
-
targetHeight = finalHeight;
|
|
41233
|
-
}
|
|
41234
|
-
var ratio = this.pixelRatio;
|
|
41235
|
-
var containerWidth = targetWidth;
|
|
41236
|
-
var containerHeight = targetHeight;
|
|
41237
|
-
targetWidth = Math.round(targetWidth * ratio);
|
|
41238
|
-
targetHeight = Math.round(targetHeight * ratio);
|
|
41239
|
-
if (targetWidth < 1 || targetHeight < 1) {
|
|
41240
|
-
if (this.offscreenMode) {
|
|
41241
|
-
targetWidth = targetHeight = containerWidth = containerHeight = 1;
|
|
41242
|
-
} else {
|
|
41243
|
-
throw new Error("Invalid container size " + targetWidth + "x" + targetHeight + ", see " + HELP_LINK["Invalid container size"] + ".");
|
|
41244
|
-
}
|
|
41245
|
-
}
|
|
41246
|
-
return [
|
|
41247
|
-
containerWidth,
|
|
41248
|
-
containerHeight,
|
|
41249
|
-
targetWidth,
|
|
41250
|
-
targetHeight
|
|
41251
|
-
];
|
|
42306
|
+
_proto.createVertexBuffer = function createVertexBuffer(data, options) {
|
|
42307
|
+
throw new Error("The active rendering backend does not provide vertex buffers.");
|
|
42308
|
+
};
|
|
42309
|
+
_proto.createDynamicVertexBuffer = function createDynamicVertexBuffer(data, options) {
|
|
42310
|
+
return this.createVertexBuffer(data, options);
|
|
42311
|
+
};
|
|
42312
|
+
_proto.createIndexBuffer = function createIndexBuffer(indices, options) {
|
|
42313
|
+
throw new Error("The active rendering backend does not provide index buffers.");
|
|
42314
|
+
};
|
|
42315
|
+
_proto.updateDynamicVertexBuffer = function updateDynamicVertexBuffer(vertexBuffer, data, byteOffset, byteLength) {
|
|
42316
|
+
throw new Error("The active rendering backend cannot update vertex buffers.");
|
|
42317
|
+
};
|
|
42318
|
+
_proto.updateDynamicIndexBuffer = function updateDynamicIndexBuffer(indexBuffer, indices, byteOffset) {
|
|
42319
|
+
throw new Error("The active rendering backend cannot update index buffers.");
|
|
42320
|
+
};
|
|
42321
|
+
/** @hide */ _proto.releaseBuffer = function releaseBuffer(buffer) {
|
|
42322
|
+
buffer.references--;
|
|
42323
|
+
return buffer.references === 0;
|
|
42324
|
+
};
|
|
42325
|
+
/** @hide */ _proto.bindBuffers = function bindBuffers(vertexBuffers, indexBuffer, effect) {
|
|
42326
|
+
throw new Error("The active rendering backend cannot bind geometry buffers.");
|
|
41252
42327
|
};
|
|
41253
42328
|
_proto.addTexture = function addTexture(tex) {
|
|
41254
42329
|
if (this.disposed) {
|
|
@@ -41286,6 +42361,18 @@ var DEFAULT_FPS = 60;
|
|
|
41286
42361
|
}
|
|
41287
42362
|
removeItem(this.geometries, geo);
|
|
41288
42363
|
};
|
|
42364
|
+
/** @internal */ _proto.addParticleSystem = function addParticleSystem(particleSystem) {
|
|
42365
|
+
if (this.disposed) {
|
|
42366
|
+
return;
|
|
42367
|
+
}
|
|
42368
|
+
addItem(this.particleSystems, particleSystem);
|
|
42369
|
+
};
|
|
42370
|
+
/** @internal */ _proto.removeParticleSystem = function removeParticleSystem(particleSystem) {
|
|
42371
|
+
if (this.disposed) {
|
|
42372
|
+
return;
|
|
42373
|
+
}
|
|
42374
|
+
removeItem(this.particleSystems, particleSystem);
|
|
42375
|
+
};
|
|
41289
42376
|
_proto.addMesh = function addMesh(mesh) {
|
|
41290
42377
|
if (this.disposed) {
|
|
41291
42378
|
return;
|
|
@@ -41438,7 +42525,7 @@ var DEFAULT_FPS = 60;
|
|
|
41438
42525
|
/**
|
|
41439
42526
|
* 销毁所有缓存的资源
|
|
41440
42527
|
*/ _proto.dispose = function dispose() {
|
|
41441
|
-
var _this_ticker, _this_eventSystem, _this_assetService;
|
|
42528
|
+
var _this_ticker, _this_eventSystem, _this_assetService, _this__graphics;
|
|
41442
42529
|
if (this.disposed) {
|
|
41443
42530
|
return;
|
|
41444
42531
|
}
|
|
@@ -41463,7 +42550,7 @@ var DEFAULT_FPS = 60;
|
|
|
41463
42550
|
(_this_ticker = this.ticker) == null ? void 0 : _this_ticker.stop();
|
|
41464
42551
|
(_this_eventSystem = this.eventSystem) == null ? void 0 : _this_eventSystem.dispose();
|
|
41465
42552
|
(_this_assetService = this.assetService) == null ? void 0 : _this_assetService.dispose();
|
|
41466
|
-
this.
|
|
42553
|
+
(_this__graphics = this._graphics) == null ? void 0 : _this__graphics.dispose();
|
|
41467
42554
|
this.renderPasses.forEach(function(pass) {
|
|
41468
42555
|
return pass.dispose();
|
|
41469
42556
|
});
|
|
@@ -41491,8 +42578,69 @@ var DEFAULT_FPS = 60;
|
|
|
41491
42578
|
this.meshes = [];
|
|
41492
42579
|
this.renderPasses = [];
|
|
41493
42580
|
this.compositions = [];
|
|
42581
|
+
this.particleSystems = [];
|
|
42582
|
+
};
|
|
42583
|
+
_proto.getTargetSize = function getTargetSize(parentEle) {
|
|
42584
|
+
if (parentEle === undefined || parentEle === null) {
|
|
42585
|
+
throw new Error("Container is not an HTMLElement, see " + HELP_LINK["Container is not an HTMLElement"] + ".");
|
|
42586
|
+
}
|
|
42587
|
+
var displayAspect = this.displayAspect;
|
|
42588
|
+
// 小程序环境没有 getComputedStyle
|
|
42589
|
+
var computedStyle = window.getComputedStyle == null ? void 0 : window.getComputedStyle.call(window, parentEle);
|
|
42590
|
+
var targetWidth;
|
|
42591
|
+
var targetHeight;
|
|
42592
|
+
var finalWidth = 0;
|
|
42593
|
+
var finalHeight = 0;
|
|
42594
|
+
if (computedStyle) {
|
|
42595
|
+
finalWidth = parseInt(computedStyle.width, 10);
|
|
42596
|
+
finalHeight = parseInt(computedStyle.height, 10);
|
|
42597
|
+
} else {
|
|
42598
|
+
finalWidth = parentEle.clientWidth;
|
|
42599
|
+
finalHeight = parentEle.clientHeight;
|
|
42600
|
+
}
|
|
42601
|
+
if (displayAspect) {
|
|
42602
|
+
var parentAspect = finalWidth / finalHeight;
|
|
42603
|
+
if (parentAspect > displayAspect) {
|
|
42604
|
+
targetHeight = finalHeight * this.displayScale;
|
|
42605
|
+
targetWidth = targetHeight * displayAspect;
|
|
42606
|
+
} else {
|
|
42607
|
+
targetWidth = finalWidth * this.displayScale;
|
|
42608
|
+
targetHeight = targetWidth / displayAspect;
|
|
42609
|
+
}
|
|
42610
|
+
} else {
|
|
42611
|
+
targetWidth = finalWidth;
|
|
42612
|
+
targetHeight = finalHeight;
|
|
42613
|
+
}
|
|
42614
|
+
var ratio = this.pixelRatio;
|
|
42615
|
+
var containerWidth = targetWidth;
|
|
42616
|
+
var containerHeight = targetHeight;
|
|
42617
|
+
targetWidth = Math.round(targetWidth * ratio);
|
|
42618
|
+
targetHeight = Math.round(targetHeight * ratio);
|
|
42619
|
+
if (targetWidth < 1 || targetHeight < 1) {
|
|
42620
|
+
if (this.offscreenMode) {
|
|
42621
|
+
targetWidth = targetHeight = containerWidth = containerHeight = 1;
|
|
42622
|
+
} else {
|
|
42623
|
+
throw new Error("Invalid container size " + targetWidth + "x" + targetHeight + ", see " + HELP_LINK["Invalid container size"] + ".");
|
|
42624
|
+
}
|
|
42625
|
+
}
|
|
42626
|
+
return [
|
|
42627
|
+
containerWidth,
|
|
42628
|
+
containerHeight,
|
|
42629
|
+
targetWidth,
|
|
42630
|
+
targetHeight
|
|
42631
|
+
];
|
|
41494
42632
|
};
|
|
41495
42633
|
_create_class(Engine, [
|
|
42634
|
+
{
|
|
42635
|
+
key: "graphics",
|
|
42636
|
+
get: function get() {
|
|
42637
|
+
if (this._graphics) {
|
|
42638
|
+
return this._graphics;
|
|
42639
|
+
}
|
|
42640
|
+
this._graphics = new Graphics(this);
|
|
42641
|
+
return this._graphics;
|
|
42642
|
+
}
|
|
42643
|
+
},
|
|
41496
42644
|
{
|
|
41497
42645
|
key: "disposed",
|
|
41498
42646
|
get: function get() {
|
|
@@ -41655,9 +42803,7 @@ var PassTextureCache = /*#__PURE__*/ function() {
|
|
|
41655
42803
|
};
|
|
41656
42804
|
SceneLoader.createComposition = function createComposition(scene, engine, options) {
|
|
41657
42805
|
if (options === void 0) options = {};
|
|
41658
|
-
var composition = new Composition(engine, _extends({}, options,
|
|
41659
|
-
event: engine.eventSystem
|
|
41660
|
-
}), scene);
|
|
42806
|
+
var composition = new Composition(engine, _extends({}, options), scene);
|
|
41661
42807
|
// TODO 目前编辑器会每帧调用 loadScene, 在这编译会导致闪帧,待编辑器渲染逻辑优化后移除。
|
|
41662
42808
|
if (engine.env !== PLAYER_OPTIONS_ENV_EDITOR) {
|
|
41663
42809
|
engine.assetService.createShaderVariant();
|
|
@@ -41710,7 +42856,7 @@ var PrecompositionManager = /*#__PURE__*/ function() {
|
|
|
41710
42856
|
rootItem.instantiatePreComposition(compositionData);
|
|
41711
42857
|
var _options_autoplay;
|
|
41712
42858
|
rootItem.getComponent(CompositionComponent).playOnStart = (_options_autoplay = options.autoplay) != null ? _options_autoplay : true;
|
|
41713
|
-
rootItem.getComponent(CompositionComponent).endBehavior =
|
|
42859
|
+
rootItem.getComponent(CompositionComponent).endBehavior = rootItem.endBehavior;
|
|
41714
42860
|
composition.addItem(rootItem);
|
|
41715
42861
|
return rootItem;
|
|
41716
42862
|
};
|
|
@@ -41722,7 +42868,7 @@ registerPlugin("text", TextLoader);
|
|
|
41722
42868
|
registerPlugin("sprite", SpriteLoader);
|
|
41723
42869
|
registerPlugin("particle", ParticleLoader);
|
|
41724
42870
|
registerPlugin("interact", InteractLoader);
|
|
41725
|
-
var version$1 = "2.10.0-alpha.
|
|
42871
|
+
var version$1 = "2.10.0-alpha.2";
|
|
41726
42872
|
logger.info("Core version: " + version$1 + ".");
|
|
41727
42873
|
|
|
41728
42874
|
var _obj;
|
|
@@ -42333,275 +43479,61 @@ function _possible_constructor_return(self, call) {
|
|
|
42333
43479
|
return _assert_this_initialized(self);
|
|
42334
43480
|
}
|
|
42335
43481
|
|
|
42336
|
-
var
|
|
42337
|
-
|
|
42338
|
-
|
|
42339
|
-
|
|
42340
|
-
|
|
42341
|
-
|
|
42342
|
-
|
|
42343
|
-
|
|
42344
|
-
|
|
42345
|
-
|
|
42346
|
-
|
|
42347
|
-
|
|
42348
|
-
|
|
42349
|
-
|
|
42350
|
-
|
|
42351
|
-
|
|
42352
|
-
|
|
42353
|
-
|
|
42354
|
-
_this.mode = mode != null ? mode : glContext.TRIANGLES;
|
|
42355
|
-
var attributesName = [];
|
|
42356
|
-
var attributes = {};
|
|
42357
|
-
var geometry = new THREE.BufferGeometry();
|
|
42358
|
-
Object.keys(props.attributes).forEach(function(name) {
|
|
42359
|
-
var attr = props.attributes[name];
|
|
42360
|
-
if (!("dataSource" in attr)) {
|
|
42361
|
-
_this.setAttributeType(name, attr, geometry, attributes, props.maxVertex);
|
|
42362
|
-
} else {
|
|
42363
|
-
// 使用AttributeWithType构造的attribute
|
|
42364
|
-
var dataSource = attr.dataSource;
|
|
42365
|
-
if (dataSource) {
|
|
42366
|
-
if (attributes[dataSource] === undefined) {
|
|
42367
|
-
_this.setAttributeType(dataSource, attr, geometry, attributes, props.maxVertex);
|
|
42368
|
-
}
|
|
42369
|
-
var size = attr.size, offset = attr.offset, normalize = attr.normalize;
|
|
42370
|
-
var dataSourceAttribute = attributes[dataSource];
|
|
42371
|
-
var buffer = dataSourceAttribute.buffer;
|
|
42372
|
-
var dataLength = dataSourceAttribute.dataLength;
|
|
42373
|
-
var attribute = new THREE.InterleavedBufferAttribute(buffer, size, (offset != null ? offset : 0) / dataLength, normalize);
|
|
42374
|
-
geometry.setAttribute(name, attribute);
|
|
42375
|
-
attributes[name] = {
|
|
42376
|
-
buffer: buffer,
|
|
42377
|
-
attribute: attribute,
|
|
42378
|
-
type: dataSourceAttribute.type,
|
|
42379
|
-
dataLength: dataLength
|
|
42380
|
-
};
|
|
42381
|
-
}
|
|
43482
|
+
var geometryCache = new WeakMap();
|
|
43483
|
+
function getThreeGeometry(source) {
|
|
43484
|
+
source.flush();
|
|
43485
|
+
var cache = geometryCache.get(source);
|
|
43486
|
+
var attributeNames = source.getAttributeNames();
|
|
43487
|
+
var indexBuffer = source.getIndexBuffer();
|
|
43488
|
+
var instanced = source.instanceCount > 0;
|
|
43489
|
+
if (!cache || !isCacheValid(source, cache, attributeNames, indexBuffer, instanced)) {
|
|
43490
|
+
cache == null ? void 0 : cache.resource.dispose();
|
|
43491
|
+
var geometry = instanced ? new THREE.InstancedBufferGeometry() : new THREE.BufferGeometry();
|
|
43492
|
+
var vertexBuffers = {};
|
|
43493
|
+
geometry.name = source.name;
|
|
43494
|
+
attributeNames.forEach(function(name) {
|
|
43495
|
+
var vertexBuffer = source.getVertexBuffer(name);
|
|
43496
|
+
var dataBuffer = vertexBuffer == null ? void 0 : vertexBuffer.getBuffer();
|
|
43497
|
+
var nativeBuffer = dataBuffer == null ? void 0 : dataBuffer.resource;
|
|
43498
|
+
if (!vertexBuffer || !_instanceof1(nativeBuffer, THREE.InterleavedBuffer)) {
|
|
43499
|
+
return;
|
|
42382
43500
|
}
|
|
42383
|
-
|
|
43501
|
+
vertexBuffers[name] = vertexBuffer;
|
|
43502
|
+
geometry.setAttribute(name, new THREE.InterleavedBufferAttribute(nativeBuffer, vertexBuffer.getSize(), vertexBuffer.byteOffset / nativeBuffer.array.BYTES_PER_ELEMENT, vertexBuffer.normalized));
|
|
42384
43503
|
});
|
|
42385
|
-
|
|
42386
|
-
|
|
42387
|
-
|
|
42388
|
-
|
|
42389
|
-
|
|
42390
|
-
|
|
42391
|
-
|
|
42392
|
-
|
|
42393
|
-
|
|
42394
|
-
|
|
42395
|
-
var _proto = ThreeGeometry.prototype;
|
|
42396
|
-
/**
|
|
42397
|
-
* 获取 attribute 数据
|
|
42398
|
-
*
|
|
42399
|
-
* @param name - attribute 名称
|
|
42400
|
-
* @returns 返回 attribute 数据,如果为空返回 undefined
|
|
42401
|
-
*/ _proto.getAttributeData = function getAttributeData(name) {
|
|
42402
|
-
if (this.attributes[name] == undefined) {
|
|
42403
|
-
return;
|
|
42404
|
-
}
|
|
42405
|
-
return this.attributes[name].buffer.array;
|
|
42406
|
-
};
|
|
42407
|
-
/**
|
|
42408
|
-
* 设置 attribute 数据
|
|
42409
|
-
*
|
|
42410
|
-
* @param name - attribute 名称
|
|
42411
|
-
* @param data - attribute 数据
|
|
42412
|
-
* @returns
|
|
42413
|
-
*/ _proto.setAttributeData = function setAttributeData(name, data) {
|
|
42414
|
-
if (this.attributes[name] == undefined) {
|
|
42415
|
-
return;
|
|
42416
|
-
}
|
|
42417
|
-
var attributeBuffer = this.attributes[name].buffer;
|
|
42418
|
-
if (data.length > attributeBuffer.array.length) {
|
|
42419
|
-
var buffer = new THREE.InterleavedBuffer(data, attributeBuffer.stride);
|
|
42420
|
-
attributeBuffer = this.attributes[name].attribute.data = buffer;
|
|
42421
|
-
this.attributes[name].buffer = buffer;
|
|
42422
|
-
this.geometry.setAttribute(name, this.attributes[name].attribute);
|
|
42423
|
-
} else {
|
|
42424
|
-
attributeBuffer.set(data, 0);
|
|
42425
|
-
attributeBuffer.updateRange.count = data.length;
|
|
42426
|
-
attributeBuffer.updateRange.offset = 0;
|
|
42427
|
-
}
|
|
42428
|
-
this.geometry.attributes[name].needsUpdate = true;
|
|
42429
|
-
};
|
|
42430
|
-
/**
|
|
42431
|
-
* 设置可变的 attribute 数据
|
|
42432
|
-
*
|
|
42433
|
-
* @param name - attribute 名称
|
|
42434
|
-
* @param dataOffset - 数据偏移
|
|
42435
|
-
* @param data - 数据内容
|
|
42436
|
-
* @returns
|
|
42437
|
-
*/ _proto.setAttributeSubData = function setAttributeSubData(name, dataOffset, data) {
|
|
42438
|
-
if (this.attributes[name] == undefined) {
|
|
42439
|
-
return;
|
|
42440
|
-
}
|
|
42441
|
-
var attributeBuffer = this.attributes[name].buffer;
|
|
42442
|
-
attributeBuffer.set(data, dataOffset);
|
|
42443
|
-
this.geometry.attributes[name].needsUpdate = true;
|
|
42444
|
-
};
|
|
42445
|
-
/**
|
|
42446
|
-
* 获取 attribute 数据步长
|
|
42447
|
-
*
|
|
42448
|
-
* @param name - attribute名称
|
|
42449
|
-
* @returns 返回步长值
|
|
42450
|
-
*/ _proto.getAttributeStride = function getAttributeStride(name) {
|
|
42451
|
-
var attribute = this.attributes[name];
|
|
42452
|
-
return attribute.buffer.stride * BYTES_TYPE_MAP[attribute.type];
|
|
42453
|
-
};
|
|
42454
|
-
/**
|
|
42455
|
-
* 获取用到的所有 attribute 名称
|
|
42456
|
-
* @returns 返回名称数组
|
|
42457
|
-
*/ _proto.getAttributeNames = function getAttributeNames() {
|
|
42458
|
-
return this.attributesName;
|
|
42459
|
-
};
|
|
42460
|
-
/**
|
|
42461
|
-
* 获取 index attribute 数据
|
|
42462
|
-
* @returns 返回数据,如果为空返回 undefined
|
|
42463
|
-
*/ _proto.getIndexData = function getIndexData() {
|
|
42464
|
-
var index = this.geometry.getIndex();
|
|
42465
|
-
return index === null ? undefined : index.array;
|
|
42466
|
-
};
|
|
42467
|
-
/**
|
|
42468
|
-
* 设置 index attribute 数据
|
|
42469
|
-
*
|
|
42470
|
-
* @param data - index 数据
|
|
42471
|
-
*/ _proto.setIndexData = function setIndexData(data) {
|
|
42472
|
-
if (data) {
|
|
42473
|
-
this.geometry.setIndex(new THREE.BufferAttribute(data, 1));
|
|
42474
|
-
this.geometry.index.needsUpdate = true;
|
|
42475
|
-
}
|
|
42476
|
-
};
|
|
42477
|
-
/**
|
|
42478
|
-
* 设置偏移 index 数据
|
|
42479
|
-
*
|
|
42480
|
-
* @param offset - 数据偏移量
|
|
42481
|
-
* @param data - 数据内容
|
|
42482
|
-
*/ _proto.setIndexSubData = function setIndexSubData(offset, data) {
|
|
42483
|
-
var index = this.geometry.getIndex();
|
|
42484
|
-
if (index !== null) {
|
|
42485
|
-
var start = offset;
|
|
42486
|
-
var length = offset + data.length;
|
|
42487
|
-
var array = index.count;
|
|
42488
|
-
if (array < length) {
|
|
42489
|
-
// @ts-expect-error safe to use
|
|
42490
|
-
var newData = new data.constructor(end);
|
|
42491
|
-
newData.set(index.array);
|
|
42492
|
-
index.array = newData;
|
|
42493
|
-
}
|
|
42494
|
-
//@ts-expect-error
|
|
42495
|
-
index.array.set(data, start);
|
|
42496
|
-
this.geometry.index.needsUpdate = true;
|
|
42497
|
-
}
|
|
42498
|
-
};
|
|
42499
|
-
/**
|
|
42500
|
-
* 设置绘制偏移
|
|
42501
|
-
*
|
|
42502
|
-
* @param start - 绘制偏移
|
|
42503
|
-
*/ _proto.setDrawStart = function setDrawStart(start) {
|
|
42504
|
-
this.drawStart = start;
|
|
42505
|
-
};
|
|
42506
|
-
/**
|
|
42507
|
-
* 获取绘制偏移
|
|
42508
|
-
*
|
|
42509
|
-
* @returns 返回绘制移
|
|
42510
|
-
*/ _proto.getDrawStart = function getDrawStart() {
|
|
42511
|
-
return this.drawStart;
|
|
42512
|
-
};
|
|
42513
|
-
/**
|
|
42514
|
-
* 设置绘制数量
|
|
42515
|
-
*
|
|
42516
|
-
* @param count - 绘制数量
|
|
42517
|
-
*/ _proto.setDrawCount = function setDrawCount(count) {
|
|
42518
|
-
this.drawCount = count;
|
|
42519
|
-
};
|
|
42520
|
-
/**
|
|
42521
|
-
* 获取绘制数量
|
|
42522
|
-
*
|
|
42523
|
-
* @returns 返回绘制数量
|
|
42524
|
-
*/ _proto.getDrawCount = function getDrawCount() {
|
|
42525
|
-
return this.drawCount;
|
|
42526
|
-
};
|
|
42527
|
-
/**
|
|
42528
|
-
* 获取蒙皮数据
|
|
42529
|
-
*
|
|
42530
|
-
* @returns 返回蒙皮数据
|
|
42531
|
-
*/ _proto.getSkinProps = function getSkinProps() {
|
|
42532
|
-
return {};
|
|
42533
|
-
};
|
|
42534
|
-
/**
|
|
42535
|
-
* 销毁方法
|
|
42536
|
-
*
|
|
42537
|
-
* @returns
|
|
42538
|
-
*/ _proto.dispose = function dispose() {
|
|
42539
|
-
if (this.destroyed) {
|
|
42540
|
-
return;
|
|
42541
|
-
}
|
|
42542
|
-
this.geometry.dispose();
|
|
42543
|
-
this.destroyed = true;
|
|
42544
|
-
Geometry.prototype.dispose.call(this);
|
|
42545
|
-
};
|
|
42546
|
-
_proto.setAttributeType = function setAttributeType(name, attr, geometry, attributes, maxCount) {
|
|
42547
|
-
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;
|
|
42548
|
-
var data = attr.data;
|
|
42549
|
-
if (type && !data) {
|
|
42550
|
-
data = generateEmptyTypedArray(type);
|
|
42551
|
-
}
|
|
42552
|
-
if (!data) {
|
|
42553
|
-
return;
|
|
42554
|
-
}
|
|
42555
|
-
var dataLength = _instanceof1(data, Float32Array) ? Float32Array.BYTES_PER_ELEMENT : Uint16Array.BYTES_PER_ELEMENT;
|
|
42556
|
-
var threeStride = stride / dataLength;
|
|
42557
|
-
maxCount = (maxCount != null ? maxCount : 0) * threeStride;
|
|
42558
|
-
var count = maxCount || size * dataLength;
|
|
42559
|
-
if (count) {
|
|
42560
|
-
// 如果传入了data且data.length不为0 使用传入的data 否则根据length新建数组
|
|
42561
|
-
if (data.length === 0) {
|
|
42562
|
-
data = _instanceof1(data, Float32Array) ? new Float32Array(count) : new Uint16Array(count);
|
|
42563
|
-
}
|
|
42564
|
-
}
|
|
42565
|
-
var buffer = new THREE.InterleavedBuffer(data, threeStride);
|
|
42566
|
-
var attribute = new THREE.InterleavedBufferAttribute(buffer, size, (offset != null ? offset : 0) / dataLength, normalize);
|
|
42567
|
-
geometry.setAttribute(name, attribute);
|
|
42568
|
-
attributes[name] = {
|
|
42569
|
-
buffer: buffer,
|
|
42570
|
-
attribute: attribute,
|
|
42571
|
-
type: type,
|
|
42572
|
-
dataLength: dataLength
|
|
43504
|
+
var indexDataBuffer = indexBuffer;
|
|
43505
|
+
var nativeIndex = indexDataBuffer == null ? void 0 : indexDataBuffer.resource;
|
|
43506
|
+
if (_instanceof1(nativeIndex, THREE.BufferAttribute)) {
|
|
43507
|
+
geometry.setIndex(nativeIndex);
|
|
43508
|
+
}
|
|
43509
|
+
cache = {
|
|
43510
|
+
vertexBuffers: vertexBuffers,
|
|
43511
|
+
indexBuffer: indexBuffer,
|
|
43512
|
+
instanced: instanced,
|
|
43513
|
+
resource: geometry
|
|
42573
43514
|
};
|
|
42574
|
-
|
|
42575
|
-
|
|
42576
|
-
|
|
42577
|
-
|
|
42578
|
-
|
|
42579
|
-
|
|
42580
|
-
|
|
42581
|
-
|
|
42582
|
-
|
|
42583
|
-
|
|
42584
|
-
|
|
42585
|
-
|
|
42586
|
-
|
|
42587
|
-
|
|
42588
|
-
|
|
42589
|
-
|
|
42590
|
-
|
|
42591
|
-
|
|
42592
|
-
|
|
42593
|
-
|
|
42594
|
-
|
|
42595
|
-
|
|
42596
|
-
set: /**
|
|
42597
|
-
* 设置绘制起点
|
|
42598
|
-
*/ function set(val) {
|
|
42599
|
-
this.geometry.drawRange.start = val;
|
|
42600
|
-
}
|
|
42601
|
-
}
|
|
42602
|
-
]);
|
|
42603
|
-
return ThreeGeometry;
|
|
42604
|
-
}(Geometry);
|
|
43515
|
+
geometryCache.set(source, cache);
|
|
43516
|
+
}
|
|
43517
|
+
if (_instanceof1(cache.resource, THREE.InstancedBufferGeometry)) {
|
|
43518
|
+
cache.resource.instanceCount = source.instanceCount;
|
|
43519
|
+
}
|
|
43520
|
+
var drawStart = source.getIndexBuffer() ? source.getDrawStart() / getBytesPerElement(source.getIndexType()) : source.getDrawStart();
|
|
43521
|
+
cache.resource.setDrawRange(drawStart, source.getDrawCount());
|
|
43522
|
+
return cache.resource;
|
|
43523
|
+
}
|
|
43524
|
+
function isCacheValid(source, cache, attributeNames, indexBuffer, instanced) {
|
|
43525
|
+
if (cache.indexBuffer !== indexBuffer || cache.instanced !== instanced || Object.keys(cache.vertexBuffers).length !== attributeNames.length) {
|
|
43526
|
+
return false;
|
|
43527
|
+
}
|
|
43528
|
+
return attributeNames.every(function(name) {
|
|
43529
|
+
return cache.vertexBuffers[name] === source.getVertexBuffer(name);
|
|
43530
|
+
});
|
|
43531
|
+
}
|
|
43532
|
+
function disposeThreeGeometry(source) {
|
|
43533
|
+
var cache = geometryCache.get(source);
|
|
43534
|
+
cache == null ? void 0 : cache.resource.dispose();
|
|
43535
|
+
geometryCache.delete(source);
|
|
43536
|
+
}
|
|
42605
43537
|
|
|
42606
43538
|
/**
|
|
42607
43539
|
* mesh 抽象类的 THREE 实现
|
|
@@ -42616,10 +43548,11 @@ var seed = 1;
|
|
|
42616
43548
|
_this = Mesh.call(this, engine, props) || this;
|
|
42617
43549
|
_this.geometry = geometry;
|
|
42618
43550
|
_this.material = material;
|
|
43551
|
+
var nativeGeometry = getThreeGeometry(geometry);
|
|
42619
43552
|
if (geometry.mode === glContext.LINES) {
|
|
42620
|
-
_this.mesh = new THREE.LineSegments(
|
|
43553
|
+
_this.mesh = new THREE.LineSegments(nativeGeometry, material.material);
|
|
42621
43554
|
} else {
|
|
42622
|
-
_this.mesh = new THREE.Mesh(
|
|
43555
|
+
_this.mesh = new THREE.Mesh(nativeGeometry, material.material);
|
|
42623
43556
|
}
|
|
42624
43557
|
// 在抽象Mesh设置priority时,THREE 的 Mesh 还未创建
|
|
42625
43558
|
_this.priority = priority;
|
|
@@ -42671,6 +43604,7 @@ var seed = 1;
|
|
|
42671
43604
|
if (!this.getVisible()) {
|
|
42672
43605
|
return;
|
|
42673
43606
|
}
|
|
43607
|
+
this.mesh.geometry = getThreeGeometry(this.geometry);
|
|
42674
43608
|
this.material.setMatrix("effects_ObjectToWorld", this.worldMatrix);
|
|
42675
43609
|
this.material.use(renderer, renderer.renderingData.currentFrame.globalUniforms);
|
|
42676
43610
|
};
|
|
@@ -42919,6 +43853,27 @@ var ThreeRenderer = /*#__PURE__*/ function(Renderer) {
|
|
|
42919
43853
|
return ThreeRenderer;
|
|
42920
43854
|
}(Renderer);
|
|
42921
43855
|
|
|
43856
|
+
/**
|
|
43857
|
+
* 保存渲染后端中的缓冲区资源。
|
|
43858
|
+
*/ var ThreeDataBuffer = /*#__PURE__*/ function(DataBuffer) {
|
|
43859
|
+
_inherits(ThreeDataBuffer, DataBuffer);
|
|
43860
|
+
function ThreeDataBuffer(resource) {
|
|
43861
|
+
var _this;
|
|
43862
|
+
_this = DataBuffer.call(this) || this;
|
|
43863
|
+
_this.resource = resource;
|
|
43864
|
+
return _this;
|
|
43865
|
+
}
|
|
43866
|
+
_create_class(ThreeDataBuffer, [
|
|
43867
|
+
{
|
|
43868
|
+
key: "underlyingResource",
|
|
43869
|
+
get: function get() {
|
|
43870
|
+
return this.resource;
|
|
43871
|
+
}
|
|
43872
|
+
}
|
|
43873
|
+
]);
|
|
43874
|
+
return ThreeDataBuffer;
|
|
43875
|
+
}(DataBuffer);
|
|
43876
|
+
|
|
42922
43877
|
/**
|
|
42923
43878
|
* 挂载着合成需要的全局对象等
|
|
42924
43879
|
*/ var ThreeEngine = /*#__PURE__*/ function(Engine) {
|
|
@@ -42937,8 +43892,116 @@ var ThreeRenderer = /*#__PURE__*/ function(Renderer) {
|
|
|
42937
43892
|
this.threeGroup = threeGroup;
|
|
42938
43893
|
this.composition = composition;
|
|
42939
43894
|
};
|
|
43895
|
+
_proto.createVertexBuffer = function createVertexBuffer(data, options) {
|
|
43896
|
+
var typedData = toTypedArray(data, options.type);
|
|
43897
|
+
var stride = options.byteStride > 0 ? options.byteStride / typedData.BYTES_PER_ELEMENT : 1;
|
|
43898
|
+
var resource = options.instanceDivisor > 0 ? new THREE.InstancedInterleavedBuffer(typedData, stride, options.instanceDivisor) : new THREE.InterleavedBuffer(typedData, stride);
|
|
43899
|
+
return createDataBuffer(resource, typedData.byteLength);
|
|
43900
|
+
};
|
|
43901
|
+
_proto.createDynamicVertexBuffer = function createDynamicVertexBuffer(data, options) {
|
|
43902
|
+
return this.createVertexBuffer(data, options);
|
|
43903
|
+
};
|
|
43904
|
+
_proto.createIndexBuffer = function createIndexBuffer(indices) {
|
|
43905
|
+
var data = normalizeIndexData(indices);
|
|
43906
|
+
var buffer = createDataBuffer(new THREE.BufferAttribute(data, 1), data.byteLength);
|
|
43907
|
+
buffer.is32Bits = _instanceof1(data, Uint32Array);
|
|
43908
|
+
return buffer;
|
|
43909
|
+
};
|
|
43910
|
+
_proto.updateDynamicVertexBuffer = function updateDynamicVertexBuffer(vertexBuffer, data, byteOffset, byteLength) {
|
|
43911
|
+
if (byteOffset === void 0) byteOffset = 0;
|
|
43912
|
+
var view = toTypedArray(data, BufferDataType.Float);
|
|
43913
|
+
if (byteLength !== undefined && byteLength < view.byteLength) {
|
|
43914
|
+
view = new Uint8Array(view.buffer, view.byteOffset, byteLength);
|
|
43915
|
+
}
|
|
43916
|
+
var resource = vertexBuffer.resource;
|
|
43917
|
+
if (!resource) {
|
|
43918
|
+
return;
|
|
43919
|
+
}
|
|
43920
|
+
if (byteOffset < 0 || byteOffset + view.byteLength > vertexBuffer.capacity) {
|
|
43921
|
+
throw new RangeError("Buffer update is out of range.");
|
|
43922
|
+
}
|
|
43923
|
+
var target = resource.array;
|
|
43924
|
+
var elementOffset = byteOffset / target.BYTES_PER_ELEMENT;
|
|
43925
|
+
if (!Number.isInteger(elementOffset)) {
|
|
43926
|
+
throw new RangeError("Buffer update is not aligned.");
|
|
43927
|
+
}
|
|
43928
|
+
target.set(view, elementOffset);
|
|
43929
|
+
resource.updateRange.offset = elementOffset;
|
|
43930
|
+
resource.updateRange.count = view.length;
|
|
43931
|
+
resource.needsUpdate = true;
|
|
43932
|
+
};
|
|
43933
|
+
_proto.updateDynamicIndexBuffer = function updateDynamicIndexBuffer(indexBuffer, indices, byteOffset) {
|
|
43934
|
+
if (byteOffset === void 0) byteOffset = 0;
|
|
43935
|
+
var data = indexBuffer.is32Bits ? _instanceof1(indices, Uint32Array) ? indices : new Uint32Array(indices) : _instanceof1(indices, Uint16Array) ? indices : new Uint16Array(indices);
|
|
43936
|
+
var resource = indexBuffer.resource;
|
|
43937
|
+
if (!resource) {
|
|
43938
|
+
return;
|
|
43939
|
+
}
|
|
43940
|
+
if (byteOffset < 0 || byteOffset + data.byteLength > indexBuffer.capacity) {
|
|
43941
|
+
throw new RangeError("Buffer update is out of range.");
|
|
43942
|
+
}
|
|
43943
|
+
var target = resource.array;
|
|
43944
|
+
var elementOffset = byteOffset / target.BYTES_PER_ELEMENT;
|
|
43945
|
+
if (!Number.isInteger(elementOffset)) {
|
|
43946
|
+
throw new RangeError("Buffer update is not aligned.");
|
|
43947
|
+
}
|
|
43948
|
+
target.set(data, elementOffset);
|
|
43949
|
+
resource.updateRange.offset = elementOffset;
|
|
43950
|
+
resource.updateRange.count = data.length;
|
|
43951
|
+
resource.needsUpdate = true;
|
|
43952
|
+
};
|
|
43953
|
+
/** @hide */ _proto.releaseBuffer = function releaseBuffer(buffer) {
|
|
43954
|
+
buffer.references--;
|
|
43955
|
+
if (buffer.references !== 0) {
|
|
43956
|
+
return false;
|
|
43957
|
+
}
|
|
43958
|
+
buffer.resource = undefined;
|
|
43959
|
+
buffer.capacity = 0;
|
|
43960
|
+
return true;
|
|
43961
|
+
};
|
|
43962
|
+
_proto.removeGeometry = function removeGeometry(geometry) {
|
|
43963
|
+
disposeThreeGeometry(geometry);
|
|
43964
|
+
Engine.prototype.removeGeometry.call(this, geometry);
|
|
43965
|
+
};
|
|
42940
43966
|
return ThreeEngine;
|
|
42941
43967
|
}(Engine);
|
|
43968
|
+
function toTypedArray(data, type) {
|
|
43969
|
+
if (typeof data === "number") {
|
|
43970
|
+
return createTypedArray(type, data / getBytesPerElement(type));
|
|
43971
|
+
}
|
|
43972
|
+
if (Array.isArray(data)) {
|
|
43973
|
+
var result = createTypedArray(type, data.length);
|
|
43974
|
+
result.set(data);
|
|
43975
|
+
return result;
|
|
43976
|
+
}
|
|
43977
|
+
if (_instanceof1(data, ArrayBuffer)) {
|
|
43978
|
+
var length = data.byteLength / getBytesPerElement(type);
|
|
43979
|
+
var result1 = createTypedArray(type, length);
|
|
43980
|
+
new Uint8Array(result1.buffer).set(new Uint8Array(data));
|
|
43981
|
+
return result1;
|
|
43982
|
+
}
|
|
43983
|
+
if (_instanceof1(data, DataView)) {
|
|
43984
|
+
return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
43985
|
+
}
|
|
43986
|
+
return data;
|
|
43987
|
+
}
|
|
43988
|
+
function normalizeIndexData(indices) {
|
|
43989
|
+
if (_instanceof1(indices, Uint16Array) || _instanceof1(indices, Uint32Array)) {
|
|
43990
|
+
return indices;
|
|
43991
|
+
}
|
|
43992
|
+
for(var i = 0; i < indices.length; i++){
|
|
43993
|
+
if (indices[i] >= 65535) {
|
|
43994
|
+
return new Uint32Array(indices);
|
|
43995
|
+
}
|
|
43996
|
+
}
|
|
43997
|
+
return new Uint16Array(indices);
|
|
43998
|
+
}
|
|
43999
|
+
function createDataBuffer(resource, capacity) {
|
|
44000
|
+
var buffer = new ThreeDataBuffer(resource);
|
|
44001
|
+
buffer.capacity = capacity;
|
|
44002
|
+
buffer.references = 1;
|
|
44003
|
+
return buffer;
|
|
44004
|
+
}
|
|
42942
44005
|
|
|
42943
44006
|
/**
|
|
42944
44007
|
*
|
|
@@ -43150,10 +44213,11 @@ var ThreeSpriteComponent = /*#__PURE__*/ function(SpriteComponent) {
|
|
|
43150
44213
|
_proto.fromData = function fromData(data) {
|
|
43151
44214
|
SpriteComponent.prototype.fromData.call(this, data);
|
|
43152
44215
|
if (!this.threeMesh) {
|
|
44216
|
+
var nativeGeometry = getThreeGeometry(this.geometry);
|
|
43153
44217
|
if (this.geometry.mode === glContext.LINES) {
|
|
43154
|
-
this.threeMesh = new THREE.LineSegments(
|
|
44218
|
+
this.threeMesh = new THREE.LineSegments(nativeGeometry, this.material.material);
|
|
43155
44219
|
} else {
|
|
43156
|
-
this.threeMesh = new THREE.Mesh(
|
|
44220
|
+
this.threeMesh = new THREE.Mesh(nativeGeometry, this.material.material);
|
|
43157
44221
|
}
|
|
43158
44222
|
}
|
|
43159
44223
|
};
|
|
@@ -43165,6 +44229,7 @@ var ThreeSpriteComponent = /*#__PURE__*/ function(SpriteComponent) {
|
|
|
43165
44229
|
if (!this.isActiveAndEnabled) {
|
|
43166
44230
|
return;
|
|
43167
44231
|
}
|
|
44232
|
+
this.threeMesh.geometry = getThreeGeometry(this.geometry);
|
|
43168
44233
|
this.material.setVector2("_Size", this.transform.size);
|
|
43169
44234
|
this.material.setMatrix("effects_ObjectToWorld", this.transform.getWorldMatrix());
|
|
43170
44235
|
this.material.use(renderer, renderer.renderingData.currentFrame.globalUniforms);
|
|
@@ -43286,14 +44351,6 @@ applyMixins(ThreeTextComponent, [
|
|
|
43286
44351
|
*/ Material.create = function(engine, props) {
|
|
43287
44352
|
return new ThreeMaterial(engine, props);
|
|
43288
44353
|
};
|
|
43289
|
-
/**
|
|
43290
|
-
* geometry 创建方法
|
|
43291
|
-
*
|
|
43292
|
-
* @param options - geometry 创建参数
|
|
43293
|
-
* @returns THREE 中的抽象 geometry 对象
|
|
43294
|
-
*/ Geometry.create = function(engine, options) {
|
|
43295
|
-
return new ThreeGeometry(engine, options);
|
|
43296
|
-
};
|
|
43297
44354
|
/**
|
|
43298
44355
|
* mesh 创建方法
|
|
43299
44356
|
*
|
|
@@ -43302,8 +44359,8 @@ applyMixins(ThreeTextComponent, [
|
|
|
43302
44359
|
*/ Mesh.create = function(engine, props) {
|
|
43303
44360
|
return new ThreeMesh(engine, props);
|
|
43304
44361
|
};
|
|
43305
|
-
var version = "2.10.0-alpha.
|
|
44362
|
+
var version = "2.10.0-alpha.2";
|
|
43306
44363
|
logger.info("THREEJS plugin version: " + version + ".");
|
|
43307
44364
|
|
|
43308
|
-
export { ATLAS_SIZE, ActivationMixerPlayable, ActivationPlayable, ActivationPlayableAsset, ActivationTrack, AndNode, AndNodeData, Animatable, AnimationClip, AnimationClipNode, AnimationClipNodeData, AnimationEvent, AnimationGraphAsset, Animator, ApplyAdditiveNode, ApplyAdditiveNodeData, Asset, AssetLoader, AssetManager, AssetService, BYTES_TYPE_MAP, Behaviour, BezierCurve, BezierCurvePath, BezierCurveQuat, BezierDataMap, BezierEasing, BezierLengthData, BezierMap, BezierPath, BezierQuat, BinaryAsset, BlendNode, BlendNodeData, BoolValueNode, BoundingBoxInfo, CONSTANT_MAP_BLEND, CONSTANT_MAP_DEPTH, CONSTANT_MAP_STENCIL_FUNC, CONSTANT_MAP_STENCIL_OP, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, Camera, CameraController, CameraVFXItemLoader, CanvasItem, CanvasLayer, Circle$1 as Circle, ColorCurve, ColorPlayable, ColorPropertyMixerPlayable, ColorPropertyPlayableAsset, ColorPropertyTrack, Component, ComponentTimePlayable, ComponentTimePlayableAsset, ComponentTimeTrack, Composition, CompositionComponent, CompressTextureCapabilityType, ConstBoolNode, ConstBoolNodeData, ConstFloatNode, ConstFloatNodeData, ConstraintTarget, Control, ControlParameterBoolNode, ControlParameterBoolNodeData, ControlParameterFloatNode, ControlParameterFloatNodeData, ControlParameterTriggerNode, ControlParameterTriggerNodeData, DEFAULT_FONTS, DEFAULT_FPS, Database, Deferred, DestroyOptions, Downloader, DrawObjectPass, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, EffectComponent, EffectComponentTimeTrack, EffectsObject, EffectsPackage, Ellipse, Engine, EqualNodeData, EventEmitter, EventSystem, FONT_SCALE, Fake3DAnimationMode, Fake3DComponent, FilterMode, Float16ArrayWrapper, FloatComparisonNode, FloatComparisonNodeData, FloatPropertyMixerPlayable, FloatPropertyPlayableAsset, FloatPropertyTrack, FloatValueNode, FrameComponent, Framebuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GlyphAtlas, GradientValue, GraphInstance, GraphNode, GraphNodeData, Graphics, GreaterNodeData, HELP_LINK, HitTestType, InteractComponent, InteractLoader, InteractMesh, InvalidIndex, Item, LayerBlendNode, LayerBlendNodeData, LessNodeData, LineSegments, LinearValue, MaskMode, MaskProcessor, MaskableGraphic, Material, MaterialDataBlock, MaterialRenderType, MaterialState, MaterialTrack, Mesh, NodeTransform, NotNode, NotNodeData, NotifyEvent, ObjectBindingTrack, OrNode, OrNodeData, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleBehaviourPlayable, ParticleBehaviourPlayableAsset, ParticleLoader, ParticleMesh, ParticleMixerPlayable, ParticleSystem, ParticleSystemRenderer, ParticleTrack, PassTextureCache, PathSegments, PlayState, Playable, PlayableAsset, PlayableOutput, Plugin, PluginSystem, PointerEventData, PointerEventType, PolyStar, Polygon, Pose, PoseNode, PositionConstraint, PostProcessVolume, Precomposition, PrecompositionManager, PropertyClipPlayable, PropertyTrack, REFERENCE_CURVE, RENDER_PREFER_LOOKUP_TEXTURE, RUNTIME_ENV, RandomSetValue, RandomValue, RandomVectorValue, RaycastResult, RectTransform, Rectangle$1 as Rectangle, ReferenceCurve, RenderFrame, RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, RenderTargetHandle, RenderTargetPool, RenderTextureFormat, Renderbuffer, Renderer, RendererComponent, RuntimeClip, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0, SEMANTIC_PRE_COLOR_ATTACHMENT_0, SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0, SPRITE_VERTEX_STRIDE, Scene, SceneLoader, SerializationHelper, Shader, ShaderCompileResultStatus, ShaderFactory, ShaderType, ShaderVariant, ShapeComponent, SourceType, Sprite, SpriteColorMixerPlayable, SpriteColorPlayableAsset, SpriteColorTrack, SpriteComponent, SpriteComponentTimeTrack, SpriteLoader, SpritePropertyMixerPlayable, SpritePropertyPlayableAsset, SpritePropertyTrack, SpriteRotation, StarType, StateMachineNode, StateMachineNodeData, StateNode, StateNodeData, StaticValue, SubCompositionClipPlayable, SubCompositionMixerPlayable, SubCompositionPlayableAsset, SubCompositionTrack, TEMPLATE_USE_OFFSCREEN_CANVAS, TEXTURE_UNIFORM_MAP, TangentMode, TextCache, TextComponent, TextComponentBase, TextLayout, TextLoader, TextStyle, Texture, TextureFactory, TextureLoadAction, TexturePaintScaleMode, TextureSourceType, TextureStoreAction, ThreeComposition, ThreeDisplayObject, ThreeEngine, ThreeMaterial, ThreeSpriteComponent, ThreeTextComponent, ThreeTexture, Ticker, TimelineAsset, TimelineClip, TimelineInstance, TrackAsset, TrackMixerPlayable, TrackType, Transform, TransformMixerPlayable, TransformPlayable, TransformPlayableAsset, TransformTrack, TransitionNode, TransitionNodeData, TransitionState, Triangle, TrimPath, TrimPathMode, UpdateModes, VFXItem, ValueGetter, ValueNode, Vector2Curve, Vector2PropertyMixerPlayable, Vector2PropertyPlayableAsset, Vector2PropertyTrack, Vector3Curve, Vector3PropertyMixerPlayable, Vector3PropertyTrack, Vector3ropertyPlayableAsset, Vector4Curve, Vector4PropertyMixerPlayable, Vector4PropertyPlayableAsset, Vector4PropertyTrack, WeightedMode, addByOrder, addItem, addItemWithOrder, applyMixins, assertExist, asserts, base64ToFile, breakOpportunityAfter, buildBezierData, buildEasingCurve, buildLine, calculateTranslation, canUseBOM, canvasPool, closePointEps, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, createGLContext, createKeyFrameMeta, createShape, createValueGetter, curveEps, decimalEqual, deserializeMipmapTexture, earcut, effectsClass, effectsClassStore, enlargeBuffer, ensureFixedNumber, ensureVec3, extractMinAndMax, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTexture, generateEmptyTypedArray, generateGUID, generateHalfFloatTexture, generateWhiteTexture, getBackgroundImage, getClass, getColorFromGradientStops, getConfig, getControlPoints, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, getKeyFrameMetaByRawValue, getMergedStore, getNodeDataClass, getParticleMeshShader, getPixelRatio, getPluginUsageInfo, getPreMultiAlpha, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, getTextureSize, glContext, glType2VertexFormatType, gpuTimer, imageDataFromColor, imageDataFromGradient, initErrors, initGLContext, integrate, interpolateColor, isAlipayMiniApp, isAndroid, isArray, isBreakChar, isCJKLike, isCanvas, isFunction, isIOS, isIOSByUA, isMiniProgram, isObject, isOpenHarmony, isPlainObject, isPowerOfTwo, isSafeFontFamily, isSimulatorCellPhone, isString, isUniformStruct, isUniformStructArray, isValidFontFamily, isWebGL2, isWechatMiniApp, itemFrag, itemVert, loadAVIFOptional, loadBinary, loadBlob, loadImage, loadMedia, loadVideo, loadWebPOptional, logger, index as math, modifyMaxKeyframeShader, nearestPowerOfTwo, nodeDataClass, noop, normalizeColor, numberToFix, oldBezierKeyFramesToNew, parsePercent$1 as parsePercent, particleFrag, particleOriginTranslateMap$1 as particleOriginTranslateMap, particleUniformTypeMap, particleVert, passRenderLevel, pluginLoaderMap, randomInRange, registerPlugin, removeItem, rotateVec2, screenMeshVert, serialize, setBlendMode, setConfig, setDefaultTextureFactory, setMaskMode, setRayFromCamera, setSideMode, setUniformValue, sortByOrder, index$1 as spec, textureLoaderRegistry, thresholdFrag, throwDestroyedError, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecFill, vecMulCombine, version, vertexFormatType2GLType };
|
|
44365
|
+
export { ATLAS_SIZE, ActivationMixerPlayable, ActivationPlayable, ActivationPlayableAsset, ActivationTrack, AndNode, AndNodeData, Animatable, AnimationClip, AnimationClipNode, AnimationClipNodeData, AnimationEvent, AnimationGraphAsset, Animator, ApplyAdditiveNode, ApplyAdditiveNodeData, Asset, AssetLoader, AssetManager, AssetService, BYTES_TYPE_MAP, Behaviour, BezierCurve, BezierCurvePath, BezierCurveQuat, BezierDataMap, BezierEasing, BezierLengthData, BezierMap, BezierPath, BezierQuat, BinaryAsset, BlendNode, BlendNodeData, BoolValueNode, BoundingBoxInfo, Buffer, BufferDataType, BufferUsage, CONSTANT_MAP_BLEND, CONSTANT_MAP_DEPTH, CONSTANT_MAP_STENCIL_FUNC, CONSTANT_MAP_STENCIL_OP, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, Camera, CameraController, CameraVFXItemLoader, CanvasItem, CanvasLayer, Circle$1 as Circle, ColorCurve, ColorPlayable, ColorPropertyMixerPlayable, ColorPropertyPlayableAsset, ColorPropertyTrack, Component, ComponentTimePlayable, ComponentTimePlayableAsset, ComponentTimeTrack, Composition, CompositionComponent, CompressTextureCapabilityType, ConstBoolNode, ConstBoolNodeData, ConstFloatNode, ConstFloatNodeData, ConstraintTarget, Control, ControlParameterBoolNode, ControlParameterBoolNodeData, ControlParameterFloatNode, ControlParameterFloatNodeData, ControlParameterTriggerNode, ControlParameterTriggerNodeData, DEFAULT_FONTS, DEFAULT_FPS, DataBuffer, Database, Deferred, DestroyOptions, Downloader, DrawObjectPass, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, EffectComponent, EffectComponentTimeTrack, EffectsObject, EffectsPackage, Ellipse, Engine, EqualNodeData, EventEmitter, EventSystem, FONT_SCALE, Fake3DAnimationMode, Fake3DComponent, FilterMode, Float16ArrayWrapper, FloatComparisonNode, FloatComparisonNodeData, FloatPropertyMixerPlayable, FloatPropertyPlayableAsset, FloatPropertyTrack, FloatValueNode, FrameComponent, Framebuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GlyphAtlas, GradientValue, GraphInstance, GraphNode, GraphNodeData, Graphics, GreaterNodeData, HELP_LINK, HitTestType, InteractComponent, InteractLoader, InteractMesh, InvalidIndex, Item, LayerBlendNode, LayerBlendNodeData, LessNodeData, LineSegments, LinearValue, MaskMode, MaskProcessor, MaskableGraphic, Material, MaterialDataBlock, MaterialRenderType, MaterialState, MaterialTrack, Mesh, NodeTransform, NotNode, NotNodeData, NotifyEvent, ObjectBindingTrack, OrNode, OrNodeData, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleBehaviourPlayable, ParticleBehaviourPlayableAsset, ParticleLoader, ParticleMesh, ParticleMixerPlayable, ParticleSystem, ParticleSystemRenderer, ParticleTrack, PassTextureCache, PathSegments, PlayState, Playable, PlayableAsset, PlayableOutput, Plugin, PluginSystem, PointerEventData, PointerEventType, PolyStar, Polygon, Pose, PoseNode, PositionConstraint, PostProcessVolume, Precomposition, PrecompositionManager, PropertyClipPlayable, PropertyTrack, REFERENCE_CURVE, RENDER_PREFER_LOOKUP_TEXTURE, RUNTIME_ENV, RandomSetValue, RandomValue, RandomVectorValue, RaycastResult, RectTransform, Rectangle$1 as Rectangle, ReferenceCurve, RenderFrame, RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, RenderTargetHandle, RenderTargetPool, RenderTextureFormat, Renderbuffer, Renderer, RendererComponent, RuntimeClip, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0, SEMANTIC_PRE_COLOR_ATTACHMENT_0, SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0, SPRITE_VERTEX_STRIDE, Scene, SceneLoader, SerializationHelper, Shader, ShaderCompileResultStatus, ShaderFactory, ShaderType, ShaderVariant, ShapeComponent, SourceType, Sprite, SpriteColorMixerPlayable, SpriteColorPlayableAsset, SpriteColorTrack, SpriteComponent, SpriteComponentTimeTrack, SpriteLoader, SpritePropertyMixerPlayable, SpritePropertyPlayableAsset, SpritePropertyTrack, SpriteRotation, StarType, StateMachineNode, StateMachineNodeData, StateNode, StateNodeData, StaticValue, SubCompositionClipPlayable, SubCompositionMixerPlayable, SubCompositionPlayableAsset, SubCompositionTrack, TEMPLATE_USE_OFFSCREEN_CANVAS, TEXTURE_UNIFORM_MAP, TangentMode, TextCache, TextComponent, TextComponentBase, TextLayout, TextLoader, TextStyle, Texture, TextureFactory, TextureLoadAction, TexturePaintScaleMode, TextureSourceType, TextureStoreAction, ThreeComposition, ThreeDisplayObject, ThreeEngine, ThreeMaterial, ThreeSpriteComponent, ThreeTextComponent, ThreeTexture, Ticker, TimelineAsset, TimelineClip, TimelineInstance, TrackAsset, TrackMixerPlayable, TrackType, Transform, TransformMixerPlayable, TransformPlayable, TransformPlayableAsset, TransformTrack, TransitionNode, TransitionNodeData, TransitionState, Triangle, TrimPath, TrimPathMode, UpdateModes, VFXItem, ValueGetter, ValueNode, Vector2Curve, Vector2PropertyMixerPlayable, Vector2PropertyPlayableAsset, Vector2PropertyTrack, Vector3Curve, Vector3PropertyMixerPlayable, Vector3PropertyTrack, Vector3ropertyPlayableAsset, Vector4Curve, Vector4PropertyMixerPlayable, Vector4PropertyPlayableAsset, Vector4PropertyTrack, VertexBuffer, WeightedMode, addByOrder, addItem, addItemWithOrder, applyMixins, assertExist, asserts, base64ToFile, breakOpportunityAfter, buildBezierData, buildEasingCurve, buildLine, calculateTranslation, canUseBOM, canvasPool, closePointEps, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, createGLContext, createKeyFrameMeta, createShape, createTypedArray, createValueGetter, curveEps, decimalEqual, deserializeMipmapTexture, earcut, effectsClass, effectsClassStore, enlargeBuffer, ensureFixedNumber, ensureVec3, extractMinAndMax, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTexture, generateEmptyTypedArray, generateGUID, generateHalfFloatTexture, generateWhiteTexture, getBackgroundImage, getBytesPerElement, getClass, getColorFromGradientStops, getConfig, getControlPoints, getDataByteLength, getDataType, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, getKeyFrameMetaByRawValue, getMergedStore, getNodeDataClass, getParticleMeshShader, getPixelRatio, getPluginUsageInfo, getPreMultiAlpha, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, getTextureSize, glContext, glType2VertexFormatType, gpuTimer, imageDataFromColor, imageDataFromGradient, initErrors, initGLContext, integrate, interpolateColor, isAlipayMiniApp, isAndroid, isArray, isBreakChar, isCJKLike, isCanvas, isFunction, isIOS, isIOSByUA, isMiniProgram, isObject, isOpenHarmony, isPlainObject, isPowerOfTwo, isSafeFontFamily, isSimulatorCellPhone, isString, isUniformStruct, isUniformStructArray, isValidFontFamily, isWebGL2, isWechatMiniApp, itemFrag, itemVert, loadAVIFOptional, loadBinary, loadBlob, loadImage, loadMedia, loadVideo, loadWebPOptional, logger, index as math, modifyMaxKeyframeShader, nearestPowerOfTwo, nodeDataClass, noop, normalizeColor, numberToFix, oldBezierKeyFramesToNew, parsePercent$1 as parsePercent, particleFrag, particleOriginTranslateMap$1 as particleOriginTranslateMap, particleUniformTypeMap, particleVert, passRenderLevel, pluginLoaderMap, randomInRange, registerPlugin, removeItem, rotateVec2, screenMeshVert, serialize, setBlendMode, setConfig, setDefaultTextureFactory, setMaskMode, setRayFromCamera, setSideMode, setUniformValue, sortByOrder, index$1 as spec, textureLoaderRegistry, thresholdFrag, throwDestroyedError, toBufferView, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecFill, vecMulCombine, version, vertexFormatType2GLType };
|
|
43309
44366
|
//# sourceMappingURL=index.mjs.map
|