@galacean/engine-loader 1.1.0-beta.9 → 1.2.0-alpha.0
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/main.js +495 -245
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +495 -245
- package/dist/module.js +497 -247
- package/dist/module.js.map +1 -1
- package/package.json +5 -5
- package/types/GLTFLoader.d.ts +1 -0
- package/types/Texture2DLoader.d.ts +9 -1
- package/types/gltf/GLTFResource.d.ts +50 -16
- package/types/gltf/extensions/GLTFExtensionSchema.d.ts +9 -1
- package/types/gltf/extensions/KHR_materials_anisotropy.d.ts +1 -0
- package/types/gltf/extensions/index.d.ts +1 -0
- package/types/gltf/parser/GLTFJSONParser.d.ts +7 -0
- package/types/gltf/parser/GLTFParserContext.d.ts +17 -2
- package/types/gltf/parser/GLTFSceneParser.d.ts +0 -1
- package/types/index.d.ts +1 -1
- package/types/ktx2/KTX2Loader.d.ts +16 -5
- package/types/resource-deserialize/resources/parser/ReflectionParser.d.ts +1 -1
- package/types/resource-deserialize/resources/schema/MaterialSchema.d.ts +1 -1
- package/types/resource-deserialize/resources/schema/SceneSchema.d.ts +3 -1
- package/types/resource-deserialize/utils/BufferReader.d.ts +1 -1
- package/types/ktx2/BinomialLLCTranscoder/BinomialLLCTranscoder.d.ts +0 -13
- package/types/ktx2/BinomialLLCTranscoder/TranscodeWorkerCode.d.ts +0 -33
- package/types/ktx2/KhronosTranscoder/KhronosTranscoder.d.ts +0 -17
- package/types/ktx2/KhronosTranscoder/TranscoderWorkerCode.d.ts +0 -34
- package/types/ktx2/TranscodeResult.d.ts +0 -10
- package/types/ktx2/constants.d.ts +0 -7
- package/types/ktx2/zstddec.d.ts +0 -62
package/dist/miniprogram.js
CHANGED
|
@@ -121,116 +121,116 @@ var BufferReader = /*#__PURE__*/ function() {
|
|
|
121
121
|
this.data = data;
|
|
122
122
|
this._dataView = new DataView(data.buffer, data.byteOffset + byteOffset, byteLength != null ? byteLength : data.byteLength - byteOffset);
|
|
123
123
|
this._littleEndian = littleEndian;
|
|
124
|
-
this.
|
|
124
|
+
this._position = 0;
|
|
125
125
|
this._baseOffset = byteOffset;
|
|
126
126
|
}
|
|
127
127
|
var _proto = BufferReader.prototype;
|
|
128
128
|
_proto.nextUint8 = function nextUint8() {
|
|
129
|
-
var value = this._dataView.getUint8(this.
|
|
130
|
-
this.
|
|
129
|
+
var value = this._dataView.getUint8(this._position);
|
|
130
|
+
this._position += 1;
|
|
131
131
|
return value;
|
|
132
132
|
};
|
|
133
133
|
_proto.nextUint16 = function nextUint16() {
|
|
134
|
-
var value = this._dataView.getUint16(this.
|
|
135
|
-
this.
|
|
134
|
+
var value = this._dataView.getUint16(this._position, this._littleEndian);
|
|
135
|
+
this._position += 2;
|
|
136
136
|
return value;
|
|
137
137
|
};
|
|
138
138
|
_proto.nextUint32 = function nextUint32() {
|
|
139
|
-
var value = this._dataView.getUint32(this.
|
|
140
|
-
this.
|
|
139
|
+
var value = this._dataView.getUint32(this._position, this._littleEndian);
|
|
140
|
+
this._position += 4;
|
|
141
141
|
return value;
|
|
142
142
|
};
|
|
143
143
|
_proto.nextInt32 = function nextInt32() {
|
|
144
|
-
var value = this._dataView.getInt32(this.
|
|
145
|
-
this.
|
|
144
|
+
var value = this._dataView.getInt32(this._position, this._littleEndian);
|
|
145
|
+
this._position += 4;
|
|
146
146
|
return value;
|
|
147
147
|
};
|
|
148
148
|
_proto.nextInt32Array = function nextInt32Array(len) {
|
|
149
|
-
var value = new Int32Array(this.data.buffer, this.
|
|
150
|
-
this.
|
|
149
|
+
var value = new Int32Array(this.data.buffer, this._position + this._dataView.byteOffset, len);
|
|
150
|
+
this._position += 4 * len;
|
|
151
151
|
return value;
|
|
152
152
|
};
|
|
153
153
|
_proto.nextFloat32 = function nextFloat32() {
|
|
154
|
-
var value = this._dataView.getFloat32(this.
|
|
155
|
-
this.
|
|
154
|
+
var value = this._dataView.getFloat32(this._position, this._littleEndian);
|
|
155
|
+
this._position += 4;
|
|
156
156
|
return value;
|
|
157
157
|
};
|
|
158
158
|
_proto.nextFloat32Array = function nextFloat32Array(len) {
|
|
159
|
-
var value = new Float32Array(this.data.buffer, this.
|
|
160
|
-
this.
|
|
159
|
+
var value = new Float32Array(this.data.buffer, this._position + this._dataView.byteOffset, len);
|
|
160
|
+
this._position += 4 * len;
|
|
161
161
|
return value;
|
|
162
162
|
};
|
|
163
163
|
_proto.nextUint32Array = function nextUint32Array(len) {
|
|
164
|
-
var value = new Uint32Array(this.data.buffer, this.
|
|
165
|
-
this.
|
|
164
|
+
var value = new Uint32Array(this.data.buffer, this._position + this._dataView.byteOffset, len);
|
|
165
|
+
this._position += 4 * len;
|
|
166
166
|
return value;
|
|
167
167
|
};
|
|
168
168
|
_proto.nextUint8Array = function nextUint8Array(len) {
|
|
169
|
-
var value = new Uint8Array(this.data.buffer, this.
|
|
170
|
-
this.
|
|
169
|
+
var value = new Uint8Array(this.data.buffer, this._position + this._dataView.byteOffset, len);
|
|
170
|
+
this._position += len;
|
|
171
171
|
return value;
|
|
172
172
|
};
|
|
173
173
|
_proto.nextUint64 = function nextUint64() {
|
|
174
|
-
var left = this._dataView.getUint32(this.
|
|
175
|
-
var right = this._dataView.getUint32(this.
|
|
174
|
+
var left = this._dataView.getUint32(this._position, this._littleEndian);
|
|
175
|
+
var right = this._dataView.getUint32(this._position + 4, this._littleEndian);
|
|
176
176
|
var value = left + Math.pow(2, 32) * right;
|
|
177
|
-
this.
|
|
177
|
+
this._position += 8;
|
|
178
178
|
return value;
|
|
179
179
|
};
|
|
180
180
|
_proto.nextStr = function nextStr() {
|
|
181
181
|
var strByteLength = this.nextUint16();
|
|
182
|
-
var uint8Array = new Uint8Array(this.data.buffer, this.
|
|
183
|
-
this.
|
|
182
|
+
var uint8Array = new Uint8Array(this.data.buffer, this._position + this._dataView.byteOffset, strByteLength);
|
|
183
|
+
this._position += strByteLength;
|
|
184
184
|
return miniprogram.Utils.decodeText(uint8Array);
|
|
185
185
|
};
|
|
186
186
|
/**
|
|
187
187
|
* image data 放在最后
|
|
188
188
|
*/ _proto.nextImageData = function nextImageData(count) {
|
|
189
|
-
return new Uint8Array(this.data.buffer, this.data.byteOffset + this.
|
|
189
|
+
return new Uint8Array(this.data.buffer, this.data.byteOffset + this._position);
|
|
190
190
|
};
|
|
191
191
|
_proto.nextImagesData = function nextImagesData(count) {
|
|
192
192
|
var imagesLen = new Array(count);
|
|
193
193
|
// Start offset of Uint32Array should be a multiple of 4. ref: https://stackoverflow.com/questions/15417310/why-typed-array-constructors-require-offset-to-be-multiple-of-underlying-type-si
|
|
194
194
|
for(var i = 0; i < count; i++){
|
|
195
|
-
var len = this._dataView.getUint32(this.
|
|
195
|
+
var len = this._dataView.getUint32(this._position, this._littleEndian);
|
|
196
196
|
imagesLen[i] = len;
|
|
197
|
-
this.
|
|
197
|
+
this._position += 4;
|
|
198
198
|
}
|
|
199
199
|
var imagesData = [];
|
|
200
200
|
for(var i1 = 0; i1 < count; i1++){
|
|
201
201
|
var len1 = imagesLen[i1];
|
|
202
|
-
var buffer = new Uint8Array(this.data.buffer, this._dataView.byteOffset + this.
|
|
203
|
-
this.
|
|
202
|
+
var buffer = new Uint8Array(this.data.buffer, this._dataView.byteOffset + this._position, len1);
|
|
203
|
+
this._position += len1;
|
|
204
204
|
imagesData.push(buffer);
|
|
205
205
|
}
|
|
206
206
|
return imagesData;
|
|
207
207
|
};
|
|
208
208
|
_proto.skip = function skip(bytes) {
|
|
209
|
-
this.
|
|
209
|
+
this._position += bytes;
|
|
210
210
|
return this;
|
|
211
211
|
};
|
|
212
212
|
_proto.scan = function scan(maxByteLength, term) {
|
|
213
213
|
if (term === void 0) term = 0x00;
|
|
214
|
-
var byteOffset = this.
|
|
214
|
+
var byteOffset = this._position;
|
|
215
215
|
var byteLength = 0;
|
|
216
|
-
while(this._dataView.getUint8(this.
|
|
216
|
+
while(this._dataView.getUint8(this._position) !== term && byteLength < maxByteLength){
|
|
217
217
|
byteLength++;
|
|
218
|
-
this.
|
|
218
|
+
this._position++;
|
|
219
219
|
}
|
|
220
|
-
if (byteLength < maxByteLength) this.
|
|
220
|
+
if (byteLength < maxByteLength) this._position++;
|
|
221
221
|
return new Uint8Array(this._dataView.buffer, this._dataView.byteOffset + byteOffset, byteLength);
|
|
222
222
|
};
|
|
223
223
|
_create_class(BufferReader, [
|
|
224
224
|
{
|
|
225
225
|
key: "position",
|
|
226
226
|
get: function get() {
|
|
227
|
-
return this.
|
|
227
|
+
return this._position;
|
|
228
228
|
}
|
|
229
229
|
},
|
|
230
230
|
{
|
|
231
231
|
key: "offset",
|
|
232
232
|
get: function get() {
|
|
233
|
-
return this.
|
|
233
|
+
return this._position + this._baseOffset;
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
236
|
]);
|
|
@@ -294,75 +294,74 @@ exports.MeshDecoder = /*#__PURE__*/ function() {
|
|
|
294
294
|
var encodedMeshData = JSON.parse(jsonDataString);
|
|
295
295
|
// @ts-ignore Vector3 is not compatible with {x: number, y: number, z: number}.
|
|
296
296
|
encodedMeshData.bounds && modelMesh.bounds.copyFrom(encodedMeshData.bounds);
|
|
297
|
-
var offset = Math.ceil(bufferReader.offset / 4) * 4;
|
|
297
|
+
var offset = Math.ceil(bufferReader.offset / 4) * 4 + bufferReader.data.byteOffset;
|
|
298
298
|
var buffer = bufferReader.data.buffer;
|
|
299
|
-
var
|
|
300
|
-
var float32Array = new Float32Array(buffer, encodedMeshData.positions.start + offset + byteOffset, (encodedMeshData.positions.end - encodedMeshData.positions.start) / 4);
|
|
299
|
+
var float32Array = new Float32Array(buffer, encodedMeshData.positions.start + offset, (encodedMeshData.positions.end - encodedMeshData.positions.start) / 4);
|
|
301
300
|
var vertexCount = float32Array.length / 3;
|
|
302
301
|
var positions = float32ArrayToVector3(float32Array, vertexCount);
|
|
303
302
|
modelMesh.setPositions(positions);
|
|
304
303
|
if (encodedMeshData.normals) {
|
|
305
|
-
var float32Array1 = new Float32Array(buffer, encodedMeshData.normals.start + offset
|
|
304
|
+
var float32Array1 = new Float32Array(buffer, encodedMeshData.normals.start + offset, (encodedMeshData.normals.end - encodedMeshData.normals.start) / 4);
|
|
306
305
|
var normals = float32ArrayToVector3(float32Array1, vertexCount);
|
|
307
306
|
modelMesh.setNormals(normals);
|
|
308
307
|
}
|
|
309
308
|
if (encodedMeshData.uvs) {
|
|
310
|
-
var float32Array2 = new Float32Array(buffer, encodedMeshData.uvs.start + offset
|
|
309
|
+
var float32Array2 = new Float32Array(buffer, encodedMeshData.uvs.start + offset, (encodedMeshData.uvs.end - encodedMeshData.uvs.start) / 4);
|
|
311
310
|
modelMesh.setUVs(float32ArrayToVector2(float32Array2, vertexCount));
|
|
312
311
|
}
|
|
313
312
|
if (encodedMeshData.uv1) {
|
|
314
|
-
var float32Array3 = new Float32Array(buffer, encodedMeshData.uv1.start + offset
|
|
313
|
+
var float32Array3 = new Float32Array(buffer, encodedMeshData.uv1.start + offset, (encodedMeshData.uv1.end - encodedMeshData.uv1.start) / 4);
|
|
315
314
|
modelMesh.setUVs(float32ArrayToVector2(float32Array3, vertexCount), 1);
|
|
316
315
|
}
|
|
317
316
|
if (encodedMeshData.uv2) {
|
|
318
|
-
var float32Array4 = new Float32Array(buffer, encodedMeshData.uv2.start + offset
|
|
317
|
+
var float32Array4 = new Float32Array(buffer, encodedMeshData.uv2.start + offset, (encodedMeshData.uv2.end - encodedMeshData.uv2.start) / 4);
|
|
319
318
|
modelMesh.setUVs(float32ArrayToVector2(float32Array4, vertexCount), 2);
|
|
320
319
|
}
|
|
321
320
|
if (encodedMeshData.uv3) {
|
|
322
|
-
var float32Array5 = new Float32Array(buffer, encodedMeshData.uv3.start + offset
|
|
321
|
+
var float32Array5 = new Float32Array(buffer, encodedMeshData.uv3.start + offset, (encodedMeshData.uv3.end - encodedMeshData.uv3.start) / 4);
|
|
323
322
|
modelMesh.setUVs(float32ArrayToVector2(float32Array5, vertexCount), 3);
|
|
324
323
|
}
|
|
325
324
|
if (encodedMeshData.uv4) {
|
|
326
|
-
var float32Array6 = new Float32Array(buffer, encodedMeshData.uv4.start + offset
|
|
325
|
+
var float32Array6 = new Float32Array(buffer, encodedMeshData.uv4.start + offset, (encodedMeshData.uv4.end - encodedMeshData.uv4.start) / 4);
|
|
327
326
|
modelMesh.setUVs(float32ArrayToVector2(float32Array6, vertexCount), 4);
|
|
328
327
|
}
|
|
329
328
|
if (encodedMeshData.uv5) {
|
|
330
|
-
var float32Array7 = new Float32Array(buffer, encodedMeshData.uv5.start + offset
|
|
329
|
+
var float32Array7 = new Float32Array(buffer, encodedMeshData.uv5.start + offset, (encodedMeshData.uv5.end - encodedMeshData.uv5.start) / 4);
|
|
331
330
|
modelMesh.setUVs(float32ArrayToVector2(float32Array7, vertexCount), 5);
|
|
332
331
|
}
|
|
333
332
|
if (encodedMeshData.uv6) {
|
|
334
|
-
var float32Array8 = new Float32Array(buffer, encodedMeshData.uv6.start + offset
|
|
333
|
+
var float32Array8 = new Float32Array(buffer, encodedMeshData.uv6.start + offset, (encodedMeshData.uv6.end - encodedMeshData.uv6.start) / 4);
|
|
335
334
|
modelMesh.setUVs(float32ArrayToVector2(float32Array8, vertexCount), 6);
|
|
336
335
|
}
|
|
337
336
|
if (encodedMeshData.uv7) {
|
|
338
|
-
var float32Array9 = new Float32Array(buffer, encodedMeshData.uv7.start + offset
|
|
337
|
+
var float32Array9 = new Float32Array(buffer, encodedMeshData.uv7.start + offset, (encodedMeshData.uv7.end - encodedMeshData.uv7.start) / 4);
|
|
339
338
|
modelMesh.setUVs(float32ArrayToVector2(float32Array9, vertexCount), 7);
|
|
340
339
|
}
|
|
341
340
|
if (encodedMeshData.colors) {
|
|
342
|
-
var float32Array10 = new Float32Array(buffer, encodedMeshData.colors.start + offset
|
|
341
|
+
var float32Array10 = new Float32Array(buffer, encodedMeshData.colors.start + offset, (encodedMeshData.colors.end - encodedMeshData.colors.start) / 4);
|
|
343
342
|
modelMesh.setColors(float32ArrayToVColor(float32Array10, vertexCount));
|
|
344
343
|
}
|
|
345
344
|
if (encodedMeshData.boneWeights) {
|
|
346
|
-
var float32Array11 = new Float32Array(buffer, encodedMeshData.boneWeights.start + offset
|
|
345
|
+
var float32Array11 = new Float32Array(buffer, encodedMeshData.boneWeights.start + offset, (encodedMeshData.boneWeights.end - encodedMeshData.boneWeights.start) / 4);
|
|
347
346
|
modelMesh.setBoneWeights(float32ArrayToVector4(float32Array11, vertexCount));
|
|
348
347
|
}
|
|
349
348
|
if (encodedMeshData.boneIndices) {
|
|
350
|
-
var float32Array12 = new Float32Array(buffer, encodedMeshData.boneIndices.start + offset
|
|
349
|
+
var float32Array12 = new Float32Array(buffer, encodedMeshData.boneIndices.start + offset, (encodedMeshData.boneIndices.end - encodedMeshData.boneIndices.start) / 4);
|
|
351
350
|
modelMesh.setBoneIndices(float32ArrayToVector4(float32Array12, vertexCount));
|
|
352
351
|
}
|
|
353
352
|
if (encodedMeshData.blendShapes) {
|
|
354
353
|
encodedMeshData.blendShapes.forEach(function(blendShapeData) {
|
|
355
354
|
var blendShape = new miniprogram.BlendShape(blendShapeData.name);
|
|
356
355
|
blendShapeData.frames.forEach(function(frameData) {
|
|
357
|
-
var positionArray = new Float32Array(buffer, frameData.deltaPosition.start + offset
|
|
356
|
+
var positionArray = new Float32Array(buffer, frameData.deltaPosition.start + offset, (frameData.deltaPosition.end - frameData.deltaPosition.start) / 4);
|
|
358
357
|
var count = positionArray.length / 3;
|
|
359
358
|
var deltaPosition = float32ArrayToVector3(positionArray, count);
|
|
360
359
|
if (frameData.deltaNormals) {
|
|
361
|
-
var normalsArray = new Float32Array(buffer, frameData.deltaNormals.start + offset
|
|
360
|
+
var normalsArray = new Float32Array(buffer, frameData.deltaNormals.start + offset, (frameData.deltaNormals.end - frameData.deltaNormals.start) / 4);
|
|
362
361
|
float32ArrayToVector3(normalsArray, count);
|
|
363
362
|
}
|
|
364
363
|
if (frameData.deltaTangents) {
|
|
365
|
-
var tangentsArray = new Float32Array(buffer, frameData.deltaTangents.start + offset
|
|
364
|
+
var tangentsArray = new Float32Array(buffer, frameData.deltaTangents.start + offset, (frameData.deltaTangents.end - frameData.deltaTangents.start) / 4);
|
|
366
365
|
float32ArrayToVector4(tangentsArray, count);
|
|
367
366
|
}
|
|
368
367
|
blendShape.addFrame(frameData.weight, deltaPosition);
|
|
@@ -373,9 +372,9 @@ exports.MeshDecoder = /*#__PURE__*/ function() {
|
|
|
373
372
|
if (encodedMeshData.indices) {
|
|
374
373
|
var indices = null;
|
|
375
374
|
if (encodedMeshData.indices.type === 0) {
|
|
376
|
-
indices = new Uint16Array(buffer, encodedMeshData.indices.start + offset
|
|
375
|
+
indices = new Uint16Array(buffer, encodedMeshData.indices.start + offset, (encodedMeshData.indices.end - encodedMeshData.indices.start) / 2);
|
|
377
376
|
} else {
|
|
378
|
-
indices = new Uint32Array(buffer, encodedMeshData.indices.start + offset
|
|
377
|
+
indices = new Uint32Array(buffer, encodedMeshData.indices.start + offset, (encodedMeshData.indices.end - encodedMeshData.indices.start) / 4);
|
|
379
378
|
}
|
|
380
379
|
modelMesh.setIndices(indices);
|
|
381
380
|
}
|
|
@@ -544,11 +543,17 @@ var ReflectionParser = /*#__PURE__*/ function() {
|
|
|
544
543
|
});
|
|
545
544
|
};
|
|
546
545
|
_proto.parseClassObject = function parseClassObject(item) {
|
|
546
|
+
var _this = this;
|
|
547
547
|
var Class = miniprogram.Loader.getClass(item.class);
|
|
548
548
|
var _item_constructParams;
|
|
549
549
|
var params = (_item_constructParams = item.constructParams) != null ? _item_constructParams : [];
|
|
550
|
-
|
|
551
|
-
|
|
550
|
+
return Promise.all(params.map(function(param) {
|
|
551
|
+
return _this.parseBasicType(param);
|
|
552
|
+
})).then(function(resultParams) {
|
|
553
|
+
return _construct(Class, [].concat(resultParams));
|
|
554
|
+
}).then(function(instance) {
|
|
555
|
+
return _this.parsePropsAndMethods(instance, item);
|
|
556
|
+
});
|
|
552
557
|
};
|
|
553
558
|
_proto.parsePropsAndMethods = function parsePropsAndMethods(instance, item) {
|
|
554
559
|
var promises = [];
|
|
@@ -556,16 +561,14 @@ var ReflectionParser = /*#__PURE__*/ function() {
|
|
|
556
561
|
for(var methodName in item.methods){
|
|
557
562
|
var methodParams = item.methods[methodName];
|
|
558
563
|
for(var i = 0, count = methodParams.length; i < count; i++){
|
|
559
|
-
|
|
560
|
-
var promise = this.parseMethod(instance, methodName, params);
|
|
561
|
-
promises.push(promise);
|
|
564
|
+
promises.push(this.parseMethod(instance, methodName, methodParams[i]));
|
|
562
565
|
}
|
|
563
566
|
}
|
|
564
567
|
}
|
|
565
568
|
if (item.props) {
|
|
566
569
|
var _this = this, _loop = function(key) {
|
|
567
570
|
var value = item.props[key];
|
|
568
|
-
var promise = _this.parseBasicType(value).then(function(v) {
|
|
571
|
+
var promise = _this.parseBasicType(value, instance[key]).then(function(v) {
|
|
569
572
|
return instance[key] = v;
|
|
570
573
|
});
|
|
571
574
|
promises.push(promise);
|
|
@@ -587,7 +590,7 @@ var ReflectionParser = /*#__PURE__*/ function() {
|
|
|
587
590
|
return (_instance = instance)[methodName].apply(_instance, [].concat(result));
|
|
588
591
|
});
|
|
589
592
|
};
|
|
590
|
-
_proto.parseBasicType = function parseBasicType(value) {
|
|
593
|
+
_proto.parseBasicType = function parseBasicType(value, originValue) {
|
|
591
594
|
var _this = this;
|
|
592
595
|
if (Array.isArray(value)) {
|
|
593
596
|
return Promise.all(value.map(function(item) {
|
|
@@ -604,13 +607,33 @@ var ReflectionParser = /*#__PURE__*/ function() {
|
|
|
604
607
|
} else if (ReflectionParser._isEntityRef(value)) {
|
|
605
608
|
// entity reference
|
|
606
609
|
return Promise.resolve(this._context.entityMap.get(value.entityId));
|
|
607
|
-
} else {
|
|
608
|
-
|
|
609
|
-
|
|
610
|
+
} else if (originValue) {
|
|
611
|
+
var _this1 = this, _loop = function(key) {
|
|
612
|
+
if (key === "methods") {
|
|
613
|
+
var methods = value[key];
|
|
614
|
+
for(var methodName in methods){
|
|
615
|
+
var methodParams = methods[methodName];
|
|
616
|
+
for(var i = 0, count = methodParams.length; i < count; i++){
|
|
617
|
+
var params = methodParams[i];
|
|
618
|
+
var promise = _this1.parseMethod(originValue, methodName, params);
|
|
619
|
+
promises.push(promise);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
} else {
|
|
623
|
+
promises.push(_this1.parseBasicType(value[key], originValue[key]).then(function(v) {
|
|
624
|
+
return originValue[key] = v;
|
|
625
|
+
}));
|
|
626
|
+
}
|
|
627
|
+
};
|
|
628
|
+
var promises = [];
|
|
629
|
+
for(var key in value)_loop(key);
|
|
630
|
+
return Promise.all(promises).then(function() {
|
|
631
|
+
return originValue;
|
|
632
|
+
});
|
|
610
633
|
}
|
|
611
|
-
} else {
|
|
612
|
-
return Promise.resolve(value);
|
|
613
634
|
}
|
|
635
|
+
// primitive type
|
|
636
|
+
return Promise.resolve(value);
|
|
614
637
|
};
|
|
615
638
|
_proto._getEntityByConfig = function _getEntityByConfig(entityConfig) {
|
|
616
639
|
// @ts-ignore
|
|
@@ -715,6 +738,7 @@ exports.AnimationClipDecoder = /*#__PURE__*/ function() {
|
|
|
715
738
|
var componentStr = bufferReader.nextStr();
|
|
716
739
|
var componentType = ComponentMap[componentStr];
|
|
717
740
|
var property = bufferReader.nextStr();
|
|
741
|
+
var getProperty = bufferReader.nextStr();
|
|
718
742
|
var curve = void 0;
|
|
719
743
|
var interpolation = bufferReader.nextUint8();
|
|
720
744
|
var keysLen = bufferReader.nextUint16();
|
|
@@ -839,13 +863,42 @@ exports.AnimationClipDecoder = /*#__PURE__*/ function() {
|
|
|
839
863
|
for(var j7 = 0; j7 < keysLen; ++j7){
|
|
840
864
|
var keyframe8 = new miniprogram.Keyframe();
|
|
841
865
|
keyframe8.time = bufferReader.nextFloat32();
|
|
842
|
-
|
|
866
|
+
var str = bufferReader.nextStr();
|
|
867
|
+
if (str) {
|
|
868
|
+
keyframe8.value = JSON.parse(str);
|
|
869
|
+
} else {
|
|
870
|
+
keyframe8.value = null;
|
|
871
|
+
}
|
|
843
872
|
curve.addKey(keyframe8);
|
|
844
873
|
}
|
|
845
874
|
break;
|
|
846
875
|
}
|
|
876
|
+
case "AnimationBoolCurve":
|
|
877
|
+
{
|
|
878
|
+
curve = new miniprogram.AnimationBoolCurve();
|
|
879
|
+
curve.interpolation = interpolation;
|
|
880
|
+
for(var j8 = 0; j8 < keysLen; ++j8){
|
|
881
|
+
var keyframe9 = new miniprogram.Keyframe();
|
|
882
|
+
keyframe9.time = bufferReader.nextFloat32();
|
|
883
|
+
keyframe9.value = bufferReader.nextUint8() === 1;
|
|
884
|
+
curve.addKey(keyframe9);
|
|
885
|
+
}
|
|
886
|
+
break;
|
|
887
|
+
}
|
|
888
|
+
case "AnimationStringCurve":
|
|
889
|
+
{
|
|
890
|
+
curve = new miniprogram.AnimationStringCurve();
|
|
891
|
+
curve.interpolation = interpolation;
|
|
892
|
+
for(var j9 = 0; j9 < keysLen; ++j9){
|
|
893
|
+
var keyframe10 = new miniprogram.Keyframe();
|
|
894
|
+
keyframe10.time = bufferReader.nextFloat32();
|
|
895
|
+
keyframe10.value = bufferReader.nextStr();
|
|
896
|
+
curve.addKey(keyframe10);
|
|
897
|
+
}
|
|
898
|
+
break;
|
|
899
|
+
}
|
|
847
900
|
}
|
|
848
|
-
clip.addCurveBinding(relativePath, componentType, property, curve);
|
|
901
|
+
clip.addCurveBinding(relativePath, componentType, property, getProperty, curve);
|
|
849
902
|
}
|
|
850
903
|
resolve(clip);
|
|
851
904
|
});
|
|
@@ -1099,26 +1152,34 @@ var AnimationClipLoader = /*#__PURE__*/ function(Loader1) {
|
|
|
1099
1152
|
var curveBindingPromises = clip.curveBindings.map(function(curveBinding) {
|
|
1100
1153
|
var curve = curveBinding.curve;
|
|
1101
1154
|
var promises = curve.keys.map(function(key) {
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
resourceManager// @ts-ignore
|
|
1106
|
-
.getResourceByRef(value).then(function(asset) {
|
|
1107
|
-
key.value = asset;
|
|
1108
|
-
resolve(key);
|
|
1109
|
-
}).catch(reject);
|
|
1110
|
-
});
|
|
1111
|
-
}
|
|
1155
|
+
return _this._parseKeyframeValue(key, resourceManager).then(function(actualValue) {
|
|
1156
|
+
key.value = actualValue;
|
|
1157
|
+
});
|
|
1112
1158
|
});
|
|
1113
1159
|
return Promise.all(promises);
|
|
1114
1160
|
});
|
|
1115
1161
|
return Promise.all(curveBindingPromises).then(function() {
|
|
1116
1162
|
resolve(clip);
|
|
1117
1163
|
});
|
|
1118
|
-
});
|
|
1164
|
+
}).catch(reject);
|
|
1119
1165
|
}).catch(reject);
|
|
1120
1166
|
});
|
|
1121
1167
|
};
|
|
1168
|
+
_proto._parseKeyframeValue = function _parseKeyframeValue(keyframe, resourceManager) {
|
|
1169
|
+
var _value;
|
|
1170
|
+
var value = keyframe.value;
|
|
1171
|
+
if (typeof value === "object" && ((_value = value) == null ? void 0 : _value.refId)) {
|
|
1172
|
+
return new Promise(function(resolve) {
|
|
1173
|
+
resourceManager// @ts-ignore
|
|
1174
|
+
.getResourceByRef(value).then(function(asset) {
|
|
1175
|
+
keyframe.value = asset;
|
|
1176
|
+
resolve(keyframe);
|
|
1177
|
+
});
|
|
1178
|
+
});
|
|
1179
|
+
} else {
|
|
1180
|
+
return Promise.resolve(keyframe.value);
|
|
1181
|
+
}
|
|
1182
|
+
};
|
|
1122
1183
|
return AnimationClipLoader;
|
|
1123
1184
|
}(miniprogram.Loader);
|
|
1124
1185
|
AnimationClipLoader = __decorate([
|
|
@@ -1394,6 +1455,60 @@ FontLoader = __decorate([
|
|
|
1394
1455
|
_this.url = url;
|
|
1395
1456
|
return _this;
|
|
1396
1457
|
}
|
|
1458
|
+
var _proto = GLTFResource.prototype;
|
|
1459
|
+
/**
|
|
1460
|
+
* Instantiate scene root entity.
|
|
1461
|
+
* @param sceneIndex - Scene index
|
|
1462
|
+
* @returns Root entity
|
|
1463
|
+
*/ _proto.instantiateSceneRoot = function instantiateSceneRoot(sceneIndex) {
|
|
1464
|
+
var sceneRoot = sceneIndex === undefined ? this._defaultSceneRoot : this._sceneRoots[sceneIndex];
|
|
1465
|
+
return sceneRoot.clone();
|
|
1466
|
+
};
|
|
1467
|
+
_proto._onDestroy = function _onDestroy() {
|
|
1468
|
+
ReferResource1.prototype._onDestroy.call(this);
|
|
1469
|
+
var _this = this, textures = _this.textures, materials = _this.materials, meshes = _this.meshes;
|
|
1470
|
+
textures && this._disassociationSuperResource(textures);
|
|
1471
|
+
materials && this._disassociationSuperResource(materials);
|
|
1472
|
+
if (meshes) {
|
|
1473
|
+
for(var i = 0, n = meshes.length; i < n; i++){
|
|
1474
|
+
this._disassociationSuperResource(meshes[i]);
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
};
|
|
1478
|
+
_proto._disassociationSuperResource = function _disassociationSuperResource(resources) {
|
|
1479
|
+
for(var i = 0, n = resources.length; i < n; i++){
|
|
1480
|
+
// @ts-ignore
|
|
1481
|
+
resources[i]._disassociationSuperResource(this);
|
|
1482
|
+
}
|
|
1483
|
+
};
|
|
1484
|
+
_create_class(GLTFResource, [
|
|
1485
|
+
{
|
|
1486
|
+
key: "extensionsData",
|
|
1487
|
+
get: /**
|
|
1488
|
+
* Extensions data.
|
|
1489
|
+
*/ function get() {
|
|
1490
|
+
return this._extensionsData;
|
|
1491
|
+
}
|
|
1492
|
+
},
|
|
1493
|
+
{
|
|
1494
|
+
key: "sceneRoots",
|
|
1495
|
+
get: /**
|
|
1496
|
+
* @deprecated Please use `instantiateSceneRoot` instead.
|
|
1497
|
+
* RootEntities after SceneParser.
|
|
1498
|
+
*/ function get() {
|
|
1499
|
+
return this._sceneRoots;
|
|
1500
|
+
}
|
|
1501
|
+
},
|
|
1502
|
+
{
|
|
1503
|
+
key: "defaultSceneRoot",
|
|
1504
|
+
get: /**
|
|
1505
|
+
* @deprecated Please use `instantiateSceneRoot` instead.
|
|
1506
|
+
* RootEntity after SceneParser.
|
|
1507
|
+
*/ function get() {
|
|
1508
|
+
return this._defaultSceneRoot;
|
|
1509
|
+
}
|
|
1510
|
+
}
|
|
1511
|
+
]);
|
|
1397
1512
|
return GLTFResource;
|
|
1398
1513
|
}(miniprogram.ReferResource);
|
|
1399
1514
|
|
|
@@ -1547,12 +1662,29 @@ var TextureWrapMode;
|
|
|
1547
1662
|
/**
|
|
1548
1663
|
* @internal
|
|
1549
1664
|
*/ var GLTFParserContext = /*#__PURE__*/ function() {
|
|
1550
|
-
function GLTFParserContext(glTFResource, resourceManager,
|
|
1665
|
+
function GLTFParserContext(glTFResource, resourceManager, params) {
|
|
1666
|
+
var _this = this;
|
|
1551
1667
|
this.glTFResource = glTFResource;
|
|
1552
1668
|
this.resourceManager = resourceManager;
|
|
1553
|
-
this.
|
|
1669
|
+
this.params = params;
|
|
1554
1670
|
this.accessorBufferCache = {};
|
|
1555
1671
|
this._resourceCache = new Map();
|
|
1672
|
+
this._progress = {
|
|
1673
|
+
taskDetail: {},
|
|
1674
|
+
taskComplete: {
|
|
1675
|
+
loaded: 0,
|
|
1676
|
+
total: 0
|
|
1677
|
+
}
|
|
1678
|
+
};
|
|
1679
|
+
this./**
|
|
1680
|
+
* @internal
|
|
1681
|
+
*/ _onTaskDetail = function(url, loaded, total) {
|
|
1682
|
+
var _this__progress_taskDetail, _url;
|
|
1683
|
+
var detail = (_this__progress_taskDetail = _this._progress.taskDetail)[_url = url] || (_this__progress_taskDetail[_url] = {});
|
|
1684
|
+
detail.loaded = loaded;
|
|
1685
|
+
detail.total = total;
|
|
1686
|
+
_this._setTaskDetailProgress(url, loaded, total);
|
|
1687
|
+
};
|
|
1556
1688
|
this.contentRestorer = new GLTFContentRestorer(glTFResource);
|
|
1557
1689
|
}
|
|
1558
1690
|
var _proto = GLTFParserContext.prototype;
|
|
@@ -1593,7 +1725,7 @@ var TextureWrapMode;
|
|
|
1593
1725
|
};
|
|
1594
1726
|
_proto.parse = function parse() {
|
|
1595
1727
|
var _this = this;
|
|
1596
|
-
|
|
1728
|
+
var promise = this.get(0).then(function(json) {
|
|
1597
1729
|
_this.glTF = json;
|
|
1598
1730
|
return Promise.all([
|
|
1599
1731
|
_this.get(1),
|
|
@@ -1604,10 +1736,48 @@ var TextureWrapMode;
|
|
|
1604
1736
|
_this.get(9),
|
|
1605
1737
|
_this.get(2)
|
|
1606
1738
|
]).then(function() {
|
|
1739
|
+
var glTFResource = _this.glTFResource;
|
|
1740
|
+
if (glTFResource.skins || glTFResource.animations) {
|
|
1741
|
+
_this._createAnimator(_this, glTFResource.animations);
|
|
1742
|
+
}
|
|
1607
1743
|
_this.resourceManager.addContentRestorer(_this.contentRestorer);
|
|
1608
|
-
return
|
|
1744
|
+
return glTFResource;
|
|
1609
1745
|
});
|
|
1610
1746
|
});
|
|
1747
|
+
this._addTaskCompletePromise(promise);
|
|
1748
|
+
return promise;
|
|
1749
|
+
};
|
|
1750
|
+
/**
|
|
1751
|
+
* @internal
|
|
1752
|
+
*/ _proto._addTaskCompletePromise = function _addTaskCompletePromise(taskPromise) {
|
|
1753
|
+
var _this = this;
|
|
1754
|
+
var task = this._progress.taskComplete;
|
|
1755
|
+
task.total += 1;
|
|
1756
|
+
taskPromise.then(function() {
|
|
1757
|
+
_this._setTaskCompleteProgress(++task.loaded, task.total);
|
|
1758
|
+
});
|
|
1759
|
+
};
|
|
1760
|
+
_proto._createAnimator = function _createAnimator(context, animations) {
|
|
1761
|
+
var defaultSceneRoot = context.glTFResource.defaultSceneRoot;
|
|
1762
|
+
var animator = defaultSceneRoot.addComponent(miniprogram.Animator);
|
|
1763
|
+
var animatorController = new miniprogram.AnimatorController();
|
|
1764
|
+
var layer = new miniprogram.AnimatorControllerLayer("layer");
|
|
1765
|
+
var animatorStateMachine = new miniprogram.AnimatorStateMachine();
|
|
1766
|
+
animatorController.addLayer(layer);
|
|
1767
|
+
animator.animatorController = animatorController;
|
|
1768
|
+
layer.stateMachine = animatorStateMachine;
|
|
1769
|
+
if (animations) {
|
|
1770
|
+
for(var i = 0; i < animations.length; i++){
|
|
1771
|
+
var animationClip = animations[i];
|
|
1772
|
+
var name = animationClip.name;
|
|
1773
|
+
var uniqueName = animatorStateMachine.makeUniqueStateName(name);
|
|
1774
|
+
if (uniqueName !== name) {
|
|
1775
|
+
console.warn("AnimatorState name is existed, name: " + name + " reset to " + uniqueName);
|
|
1776
|
+
}
|
|
1777
|
+
var animatorState = animatorStateMachine.addState(uniqueName);
|
|
1778
|
+
animatorState.clip = animationClip;
|
|
1779
|
+
}
|
|
1780
|
+
}
|
|
1611
1781
|
};
|
|
1612
1782
|
_proto._handleSubAsset = function _handleSubAsset(resource, type, index) {
|
|
1613
1783
|
var _this = this;
|
|
@@ -1671,7 +1841,7 @@ exports.GLTFParserType = void 0;
|
|
|
1671
1841
|
var _obj;
|
|
1672
1842
|
var glTFSchemaMap = (_obj = {}, _obj[2] = "scenes", _obj[3] = "buffers", _obj[4] = "textures", _obj[5] = "materials", _obj[6] = "meshes", _obj[7] = "nodes", _obj[8] = "skins", _obj[9] = "animations", _obj);
|
|
1673
1843
|
var _obj1;
|
|
1674
|
-
var glTFResourceMap = (_obj1 = {}, _obj1[2] = "
|
|
1844
|
+
var glTFResourceMap = (_obj1 = {}, _obj1[2] = "_sceneRoots", _obj1[4] = "textures", _obj1[5] = "materials", _obj1[6] = "meshes", _obj1[7] = "entities", _obj1[8] = "skins", _obj1[9] = "animations", _obj1);
|
|
1675
1845
|
function registerGLTFParser(pipeline) {
|
|
1676
1846
|
return function(Parser) {
|
|
1677
1847
|
var parser = new Parser();
|
|
@@ -2248,7 +2418,7 @@ var SupercompressionScheme;
|
|
|
2248
2418
|
alphaSliceByteLength: sgdReader.nextUint32()
|
|
2249
2419
|
};
|
|
2250
2420
|
}
|
|
2251
|
-
var endpointsByteOffset = sgdByteOffset + sgdReader.
|
|
2421
|
+
var endpointsByteOffset = sgdByteOffset + sgdReader.position;
|
|
2252
2422
|
var selectorsByteOffset = endpointsByteOffset + endpointsByteLength;
|
|
2253
2423
|
var tablesByteOffset = selectorsByteOffset + selectorsByteLength;
|
|
2254
2424
|
var extendedByteOffset = tablesByteOffset + tablesByteLength;
|
|
@@ -2440,6 +2610,25 @@ var AbstractTranscoder = /*#__PURE__*/ function() {
|
|
|
2440
2610
|
}();
|
|
2441
2611
|
|
|
2442
2612
|
/** @internal */ function TranscodeWorkerCode$1() {
|
|
2613
|
+
var initPromise;
|
|
2614
|
+
var init = function init(wasmBinary) {
|
|
2615
|
+
if (!initPromise) {
|
|
2616
|
+
initPromise = new Promise(function(resolve, reject) {
|
|
2617
|
+
var BasisModule = {
|
|
2618
|
+
wasmBinary: wasmBinary,
|
|
2619
|
+
onRuntimeInitialized: function() {
|
|
2620
|
+
return resolve(BasisModule);
|
|
2621
|
+
},
|
|
2622
|
+
onAbort: reject
|
|
2623
|
+
};
|
|
2624
|
+
self["BASIS"](BasisModule);
|
|
2625
|
+
}).then(function(BasisModule) {
|
|
2626
|
+
BasisModule.initializeBasis();
|
|
2627
|
+
return BasisModule.KTX2File;
|
|
2628
|
+
});
|
|
2629
|
+
}
|
|
2630
|
+
return initPromise;
|
|
2631
|
+
};
|
|
2443
2632
|
self.onmessage = function onmessage(event) {
|
|
2444
2633
|
var message = event.data;
|
|
2445
2634
|
switch(message.type){
|
|
@@ -2566,6 +2755,7 @@ function transcode(buffer, targetFormat, KTX2File) {
|
|
|
2566
2755
|
var faceCount = ktx2File.getFaces();
|
|
2567
2756
|
var format = getTranscodeFormatFromTarget(targetFormat, hasAlpha);
|
|
2568
2757
|
var faces = new Array(faceCount);
|
|
2758
|
+
var isBC = format === 2 || format === 3 || format === 7;
|
|
2569
2759
|
for(var face = 0; face < faceCount; face++){
|
|
2570
2760
|
var mipmaps = new Array(levelCount);
|
|
2571
2761
|
for(var mip = 0; mip < levelCount; mip++){
|
|
@@ -2573,8 +2763,15 @@ function transcode(buffer, targetFormat, KTX2File) {
|
|
|
2573
2763
|
var mipWidth = void 0, mipHeight = void 0;
|
|
2574
2764
|
for(var layer = 0; layer < layerCount; layer++){
|
|
2575
2765
|
var levelInfo = ktx2File.getImageLevelInfo(mip, layer, face);
|
|
2576
|
-
|
|
2577
|
-
|
|
2766
|
+
// see: https://github.com/KhronosGroup/KTX-Software/issues/254
|
|
2767
|
+
if (isBC && mip === 0 && (width !== levelInfo.width || height !== levelInfo.height)) {
|
|
2768
|
+
width = mipWidth = levelInfo.width;
|
|
2769
|
+
height = mipHeight = levelInfo.height;
|
|
2770
|
+
console.warn("KTX2 transcode to BC will resize to width: " + width + ", height: " + height + ". You'd better use an image whose size if multiple of 4.");
|
|
2771
|
+
} else {
|
|
2772
|
+
mipWidth = levelInfo.origWidth;
|
|
2773
|
+
mipHeight = levelInfo.origHeight;
|
|
2774
|
+
}
|
|
2578
2775
|
var dst = new Uint8Array(ktx2File.getImageTranscodedSizeInBytes(mip, layer, 0, format));
|
|
2579
2776
|
var status = ktx2File.transcodeImage(dst, mip, layer, face, format, 0, -1, -1);
|
|
2580
2777
|
if (!status) {
|
|
@@ -2640,7 +2837,7 @@ function transcode(buffer, targetFormat, KTX2File) {
|
|
|
2640
2837
|
} else {
|
|
2641
2838
|
var funcCode = TranscodeWorkerCode$1.toString();
|
|
2642
2839
|
var transcodeString = funcCode.substring(funcCode.indexOf("{"), funcCode.lastIndexOf("}") + 1);
|
|
2643
|
-
var workerCode = "\n " + jsCode + "\n
|
|
2840
|
+
var workerCode = "\n " + jsCode + "\n " + transcode.toString() + "\n " + transcodeString + "\n ";
|
|
2644
2841
|
var workerURL = engineMiniprogramAdapter.URL.createObjectURL(new engineMiniprogramAdapter.Blob([
|
|
2645
2842
|
workerCode
|
|
2646
2843
|
], {
|
|
@@ -2886,10 +3083,14 @@ exports.KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
|
|
|
2886
3083
|
return Loader1.apply(this, arguments);
|
|
2887
3084
|
}
|
|
2888
3085
|
var _proto = KTX2Loader1.prototype;
|
|
2889
|
-
_proto.initialize = function initialize(
|
|
3086
|
+
_proto.initialize = function initialize(_, configuration) {
|
|
2890
3087
|
if (configuration.ktx2Loader) {
|
|
2891
3088
|
var options = configuration.ktx2Loader;
|
|
2892
|
-
if (
|
|
3089
|
+
if (options.priorityFormats) {
|
|
3090
|
+
exports.KTX2Loader._priorityFormats["etc1s"] = options.priorityFormats;
|
|
3091
|
+
exports.KTX2Loader._priorityFormats["uastc"] = options.priorityFormats;
|
|
3092
|
+
}
|
|
3093
|
+
if (options.transcoder === /** Khronos transcoder. */ 1) {
|
|
2893
3094
|
return exports.KTX2Loader._getKhronosTranscoder(options.workerCount).init();
|
|
2894
3095
|
} else {
|
|
2895
3096
|
return exports.KTX2Loader._getBinomialLLCTranscoder(options.workerCount).init();
|
|
@@ -2899,34 +3100,16 @@ exports.KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
|
|
|
2899
3100
|
/**
|
|
2900
3101
|
* @internal
|
|
2901
3102
|
*/ _proto.load = function load(item, resourceManager) {
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
return exports.KTX2Loader.
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
if (priorityFormats === void 0) priorityFormats = [
|
|
2913
|
-
exports.KTX2TargetFormat.ASTC,
|
|
2914
|
-
exports.KTX2TargetFormat.ETC,
|
|
2915
|
-
exports.KTX2TargetFormat.BC7,
|
|
2916
|
-
exports.KTX2TargetFormat.BC1_BC3,
|
|
2917
|
-
exports.KTX2TargetFormat.PVRTC,
|
|
2918
|
-
exports.KTX2TargetFormat.R8G8B8A8
|
|
2919
|
-
];
|
|
2920
|
-
var supportedList = new Array();
|
|
2921
|
-
if (Array.isArray(priorityFormats[0])) {
|
|
2922
|
-
for(var i = 0; i < priorityFormats.length; i++){
|
|
2923
|
-
supportedList.push(exports.KTX2Loader._detectSupportedFormat(engine._hardwareRenderer, priorityFormats[i]));
|
|
2924
|
-
}
|
|
2925
|
-
} else {
|
|
2926
|
-
supportedList.push(exports.KTX2Loader._detectSupportedFormat(engine._hardwareRenderer, priorityFormats));
|
|
2927
|
-
}
|
|
2928
|
-
return supportedList.every(function(format) {
|
|
2929
|
-
return KhronosTranscoder.transcoderMap[format];
|
|
3103
|
+
var _this = this;
|
|
3104
|
+
return new miniprogram.AssetPromise(function(resolve, reject, setTaskCompleteProgress, setTaskDetailProgress) {
|
|
3105
|
+
_this.request(item.url, {
|
|
3106
|
+
type: "arraybuffer"
|
|
3107
|
+
}).onProgress(setTaskCompleteProgress, setTaskDetailProgress).then(function(buffer) {
|
|
3108
|
+
return exports.KTX2Loader._parseBuffer(new Uint8Array(buffer), resourceManager.engine, item.params).then(function(param) {
|
|
3109
|
+
var engine = param.engine, result = param.result, targetFormat = param.targetFormat, params = param.params;
|
|
3110
|
+
return exports.KTX2Loader._createTextureByBuffer(engine, result, targetFormat, params);
|
|
3111
|
+
});
|
|
3112
|
+
}).then(resolve).catch(reject);
|
|
2930
3113
|
});
|
|
2931
3114
|
};
|
|
2932
3115
|
/**
|
|
@@ -2941,7 +3124,8 @@ exports.KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
|
|
|
2941
3124
|
/** @internal */ KTX2Loader1._parseBuffer = function _parseBuffer(buffer, engine, params) {
|
|
2942
3125
|
var _params;
|
|
2943
3126
|
var ktx2Container = new KTX2Container(buffer);
|
|
2944
|
-
var
|
|
3127
|
+
var _params_priorityFormats;
|
|
3128
|
+
var formatPriorities = (_params_priorityFormats = (_params = params) == null ? void 0 : _params.priorityFormats) != null ? _params_priorityFormats : exports.KTX2Loader._priorityFormats[ktx2Container.isUASTC ? "uastc" : "etc1s"];
|
|
2945
3129
|
var targetFormat = exports.KTX2Loader._decideTargetFormat(engine, ktx2Container, formatPriorities);
|
|
2946
3130
|
var transcodeResultPromise;
|
|
2947
3131
|
if (exports.KTX2Loader._isBinomialInit || !KhronosTranscoder.transcoderMap[targetFormat] || !ktx2Container.isUASTC) {
|
|
@@ -3008,18 +3192,22 @@ exports.KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
|
|
|
3008
3192
|
return targetFormat;
|
|
3009
3193
|
};
|
|
3010
3194
|
KTX2Loader1._detectSupportedFormat = function _detectSupportedFormat(renderer, priorityFormats) {
|
|
3011
|
-
if (priorityFormats === void 0) priorityFormats = [
|
|
3012
|
-
exports.KTX2TargetFormat.ASTC,
|
|
3013
|
-
exports.KTX2TargetFormat.ETC,
|
|
3014
|
-
exports.KTX2TargetFormat.BC7,
|
|
3015
|
-
exports.KTX2TargetFormat.BC1_BC3,
|
|
3016
|
-
exports.KTX2TargetFormat.PVRTC
|
|
3017
|
-
];
|
|
3018
3195
|
for(var i = 0; i < priorityFormats.length; i++){
|
|
3019
|
-
var
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3196
|
+
var format = priorityFormats[i];
|
|
3197
|
+
var capabilities = this._supportedMap[format];
|
|
3198
|
+
if (capabilities) {
|
|
3199
|
+
for(var j = 0; j < capabilities.length; j++){
|
|
3200
|
+
if (renderer.canIUse(capabilities[j])) {
|
|
3201
|
+
return format;
|
|
3202
|
+
}
|
|
3203
|
+
}
|
|
3204
|
+
} else {
|
|
3205
|
+
switch(priorityFormats[i]){
|
|
3206
|
+
case exports.KTX2TargetFormat.R8G8B8A8:
|
|
3207
|
+
return format;
|
|
3208
|
+
case exports.KTX2TargetFormat.R8:
|
|
3209
|
+
case exports.KTX2TargetFormat.R8G8:
|
|
3210
|
+
if (renderer.isWebGL2) return format;
|
|
3023
3211
|
}
|
|
3024
3212
|
}
|
|
3025
3213
|
}
|
|
@@ -3056,6 +3244,23 @@ exports.KTX2Loader = (_KTX2Loader = /*#__PURE__*/ function(Loader1) {
|
|
|
3056
3244
|
return KTX2Loader1;
|
|
3057
3245
|
}(miniprogram.Loader), function() {
|
|
3058
3246
|
_KTX2Loader._isBinomialInit = false;
|
|
3247
|
+
}(), function() {
|
|
3248
|
+
_KTX2Loader._priorityFormats = {
|
|
3249
|
+
etc1s: [
|
|
3250
|
+
exports.KTX2TargetFormat.ETC,
|
|
3251
|
+
exports.KTX2TargetFormat.BC7,
|
|
3252
|
+
exports.KTX2TargetFormat.ASTC,
|
|
3253
|
+
exports.KTX2TargetFormat.BC1_BC3,
|
|
3254
|
+
exports.KTX2TargetFormat.PVRTC
|
|
3255
|
+
],
|
|
3256
|
+
uastc: [
|
|
3257
|
+
exports.KTX2TargetFormat.ASTC,
|
|
3258
|
+
exports.KTX2TargetFormat.BC7,
|
|
3259
|
+
exports.KTX2TargetFormat.ETC,
|
|
3260
|
+
exports.KTX2TargetFormat.BC1_BC3,
|
|
3261
|
+
exports.KTX2TargetFormat.PVRTC
|
|
3262
|
+
]
|
|
3263
|
+
};
|
|
3059
3264
|
}(), function() {
|
|
3060
3265
|
var _obj;
|
|
3061
3266
|
_KTX2Loader._supportedMap = (_obj = {}, _obj[exports.KTX2TargetFormat.ASTC] = [
|
|
@@ -3076,6 +3281,11 @@ exports.KTX2Loader = __decorate([
|
|
|
3076
3281
|
"ktx2"
|
|
3077
3282
|
])
|
|
3078
3283
|
], exports.KTX2Loader);
|
|
3284
|
+
exports.KTX2Transcoder = void 0;
|
|
3285
|
+
(function(KTX2Transcoder) {
|
|
3286
|
+
KTX2Transcoder[KTX2Transcoder[/** BinomialLLC transcoder. */ "BinomialLLC"] = 0] = "BinomialLLC";
|
|
3287
|
+
KTX2Transcoder[KTX2Transcoder["Khronos"] = 1] = "Khronos";
|
|
3288
|
+
})(exports.KTX2Transcoder || (exports.KTX2Transcoder = {}));
|
|
3079
3289
|
|
|
3080
3290
|
/**
|
|
3081
3291
|
* @internal
|
|
@@ -3426,7 +3636,7 @@ exports.GLTFSchemaParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
3426
3636
|
};
|
|
3427
3637
|
var isGLB = this._isGLB(url);
|
|
3428
3638
|
contentRestorer.isGLB = isGLB;
|
|
3429
|
-
var promise = isGLB ? miniprogram.request(url, requestConfig).then(function(glb) {
|
|
3639
|
+
var promise = isGLB ? miniprogram.request(url, requestConfig).onProgress(undefined, context._onTaskDetail).then(function(glb) {
|
|
3430
3640
|
restoreBufferRequests.push(new BufferRequestInfo(url, requestConfig));
|
|
3431
3641
|
return GLTFUtils.parseGLB(context, glb);
|
|
3432
3642
|
}).then(function(param) {
|
|
@@ -3435,7 +3645,7 @@ exports.GLTFSchemaParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
3435
3645
|
return glTF;
|
|
3436
3646
|
}) : miniprogram.request(url, {
|
|
3437
3647
|
type: "json"
|
|
3438
|
-
});
|
|
3648
|
+
}).onProgress(undefined, context._onTaskDetail);
|
|
3439
3649
|
return promise;
|
|
3440
3650
|
};
|
|
3441
3651
|
_proto._isGLB = function _isGLB(url) {
|
|
@@ -3467,9 +3677,9 @@ exports.GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
3467
3677
|
* @internal
|
|
3468
3678
|
*/ GLTFAnimationParser1._parseStandardProperty = function _parseStandardProperty(context, animationClip, animationInfo) {
|
|
3469
3679
|
var _loop = function(j, m) {
|
|
3470
|
-
var
|
|
3471
|
-
var inputAccessor = accessors[
|
|
3472
|
-
var outputAccessor = accessors[
|
|
3680
|
+
var glTFSampler = samplers[j];
|
|
3681
|
+
var inputAccessor = accessors[glTFSampler.input];
|
|
3682
|
+
var outputAccessor = accessors[glTFSampler.output];
|
|
3473
3683
|
var promise = Promise.all([
|
|
3474
3684
|
GLTFUtils.getAccessorBuffer(context, bufferViews, inputAccessor),
|
|
3475
3685
|
GLTFUtils.getAccessorBuffer(context, bufferViews, outputAccessor)
|
|
@@ -3485,8 +3695,8 @@ exports.GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
3485
3695
|
output = scaled;
|
|
3486
3696
|
}
|
|
3487
3697
|
var outputStride = output.length / input.length;
|
|
3488
|
-
var
|
|
3489
|
-
var interpolation = (
|
|
3698
|
+
var _glTFSampler_interpolation;
|
|
3699
|
+
var interpolation = (_glTFSampler_interpolation = glTFSampler.interpolation) != null ? _glTFSampler_interpolation : AnimationSamplerInterpolation.Linear;
|
|
3490
3700
|
var samplerInterpolation;
|
|
3491
3701
|
switch(interpolation){
|
|
3492
3702
|
case AnimationSamplerInterpolation.CubicSpine:
|
|
@@ -3519,10 +3729,11 @@ exports.GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
3519
3729
|
var promises = new Array();
|
|
3520
3730
|
// parse samplers
|
|
3521
3731
|
for(var j = 0, m = samplers.length; j < m; j++)_loop(j);
|
|
3732
|
+
promises.push(context.get(exports.GLTFParserType.Scene));
|
|
3522
3733
|
return Promise.all(promises).then(function() {
|
|
3523
3734
|
for(var j = 0, m = channels.length; j < m; j++){
|
|
3524
|
-
var
|
|
3525
|
-
var target =
|
|
3735
|
+
var glTFChannel = channels[j];
|
|
3736
|
+
var target = glTFChannel.target;
|
|
3526
3737
|
var channelTargetEntity = entities[target.node];
|
|
3527
3738
|
var relativePath = "";
|
|
3528
3739
|
var entity = channelTargetEntity;
|
|
@@ -3530,6 +3741,10 @@ exports.GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
3530
3741
|
relativePath = relativePath === "" ? "" + entity.name : entity.name + "/" + relativePath;
|
|
3531
3742
|
entity = entity.parent;
|
|
3532
3743
|
}
|
|
3744
|
+
// If the target node is in the default scene, relativePath will be empty
|
|
3745
|
+
if (context.glTFResource.sceneRoots.indexOf(entity) === -1) {
|
|
3746
|
+
continue;
|
|
3747
|
+
}
|
|
3533
3748
|
var ComponentType = void 0;
|
|
3534
3749
|
var propertyName = void 0;
|
|
3535
3750
|
switch(target.path){
|
|
@@ -3550,14 +3765,21 @@ exports.GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
3550
3765
|
propertyName = "blendShapeWeights";
|
|
3551
3766
|
break;
|
|
3552
3767
|
}
|
|
3553
|
-
var curve = _this._addCurve(target.path,
|
|
3554
|
-
|
|
3768
|
+
var curve = _this._addCurve(target.path, glTFChannel, sampleDataCollection);
|
|
3769
|
+
if (target.path === AnimationChannelTargetPath.WEIGHTS) {
|
|
3770
|
+
var mesh = glTF.nodes[target.node].mesh;
|
|
3771
|
+
for(var i = 0, n = glTF.meshes[mesh].primitives.length; i < n; i++){
|
|
3772
|
+
animationClip.addCurveBinding(relativePath, ComponentType, i, propertyName, curve);
|
|
3773
|
+
}
|
|
3774
|
+
} else {
|
|
3775
|
+
animationClip.addCurveBinding(relativePath, ComponentType, propertyName, curve);
|
|
3776
|
+
}
|
|
3555
3777
|
}
|
|
3556
3778
|
return animationClip;
|
|
3557
3779
|
});
|
|
3558
3780
|
};
|
|
3559
|
-
GLTFAnimationParser1._addCurve = function _addCurve(animationChannelTargetPath,
|
|
3560
|
-
var sampleData = sampleDataCollection[
|
|
3781
|
+
GLTFAnimationParser1._addCurve = function _addCurve(animationChannelTargetPath, glTFChannel, sampleDataCollection) {
|
|
3782
|
+
var sampleData = sampleDataCollection[glTFChannel.sampler];
|
|
3561
3783
|
var input = sampleData.input, output = sampleData.output, outputSize = sampleData.outputSize;
|
|
3562
3784
|
switch(animationChannelTargetPath){
|
|
3563
3785
|
case AnimationChannelTargetPath.TRANSLATION:
|
|
@@ -3649,7 +3871,9 @@ exports.GLTFBufferParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
3649
3871
|
};
|
|
3650
3872
|
var absoluteUrl = miniprogram.Utils.resolveAbsoluteUrl(url, bufferInfo.uri);
|
|
3651
3873
|
restoreBufferRequests.push(new BufferRequestInfo(absoluteUrl, requestConfig));
|
|
3652
|
-
|
|
3874
|
+
var promise = miniprogram.request(absoluteUrl, requestConfig).onProgress(undefined, context._onTaskDetail);
|
|
3875
|
+
context._addTaskCompletePromise(promise);
|
|
3876
|
+
return promise;
|
|
3653
3877
|
};
|
|
3654
3878
|
return GLTFBufferParser;
|
|
3655
3879
|
}(GLTFParser);
|
|
@@ -3664,10 +3888,13 @@ exports.GLTFEntityParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
3664
3888
|
}
|
|
3665
3889
|
var _proto = GLTFEntityParser.prototype;
|
|
3666
3890
|
_proto.parse = function parse(context, index) {
|
|
3891
|
+
var glTFResource = context.glTFResource;
|
|
3667
3892
|
var entityInfo = context.glTF.nodes[index];
|
|
3668
|
-
var engine =
|
|
3893
|
+
var engine = glTFResource.engine;
|
|
3669
3894
|
var matrix = entityInfo.matrix, translation = entityInfo.translation, rotation = entityInfo.rotation, scale = entityInfo.scale, extensions = entityInfo.extensions;
|
|
3670
3895
|
var entity = new miniprogram.Entity(engine, entityInfo.name || "_GLTF_ENTITY_" + index);
|
|
3896
|
+
// @ts-ignore
|
|
3897
|
+
entity._markAsTemplate(glTFResource);
|
|
3671
3898
|
var transform = entity.transform;
|
|
3672
3899
|
if (matrix) {
|
|
3673
3900
|
var localMatrix = transform.localMatrix;
|
|
@@ -3709,7 +3936,8 @@ exports.GLTFMaterialParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
3709
3936
|
var _proto = GLTFMaterialParser1.prototype;
|
|
3710
3937
|
_proto.parse = function parse(context, index) {
|
|
3711
3938
|
var materialInfo = context.glTF.materials[index];
|
|
3712
|
-
var
|
|
3939
|
+
var glTFResource = context.glTFResource;
|
|
3940
|
+
var engine = glTFResource.engine;
|
|
3713
3941
|
var material = GLTFParser.executeExtensionsCreateAndParse(materialInfo.extensions, context, materialInfo);
|
|
3714
3942
|
if (!material) {
|
|
3715
3943
|
material = new miniprogram.PBRMaterial(engine);
|
|
@@ -3717,8 +3945,10 @@ exports.GLTFMaterialParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
3717
3945
|
exports.GLTFMaterialParser._parseStandardProperty(context, material, materialInfo);
|
|
3718
3946
|
}
|
|
3719
3947
|
return Promise.resolve(material).then(function(material) {
|
|
3720
|
-
material || (material = exports.GLTFMaterialParser._getDefaultMaterial(
|
|
3948
|
+
material || (material = exports.GLTFMaterialParser._getDefaultMaterial(engine));
|
|
3721
3949
|
GLTFParser.executeExtensionsAdditiveAndParse(materialInfo.extensions, context, material, materialInfo);
|
|
3950
|
+
// @ts-ignore
|
|
3951
|
+
material._associationSuperResource(glTFResource);
|
|
3722
3952
|
return material;
|
|
3723
3953
|
});
|
|
3724
3954
|
};
|
|
@@ -3839,14 +4069,20 @@ exports.GLTFMeshParser = (_GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1)
|
|
|
3839
4069
|
var mesh = GLTFParser.executeExtensionsCreateAndParse(gltfPrimitive.extensions, context, gltfPrimitive, meshInfo);
|
|
3840
4070
|
if (mesh) {
|
|
3841
4071
|
if (_instanceof(mesh, miniprogram.ModelMesh)) {
|
|
4072
|
+
// @ts-ignore
|
|
4073
|
+
mesh._associationSuperResource(glTFResource);
|
|
3842
4074
|
resolve(mesh);
|
|
3843
4075
|
} else {
|
|
3844
4076
|
mesh.then(function(mesh) {
|
|
3845
|
-
|
|
4077
|
+
// @ts-ignore
|
|
4078
|
+
mesh._associationSuperResource(glTFResource);
|
|
4079
|
+
resolve(mesh);
|
|
3846
4080
|
});
|
|
3847
4081
|
}
|
|
3848
4082
|
} else {
|
|
3849
4083
|
var mesh1 = new miniprogram.ModelMesh(engine, meshInfo.name || i + "");
|
|
4084
|
+
// @ts-ignore
|
|
4085
|
+
mesh1._associationSuperResource(glTFResource);
|
|
3850
4086
|
var meshRestoreInfo = new ModelMeshRestoreInfo();
|
|
3851
4087
|
meshRestoreInfo.mesh = mesh1;
|
|
3852
4088
|
context.contentRestorer.meshes.push(meshRestoreInfo);
|
|
@@ -3866,12 +4102,13 @@ exports.GLTFMeshParser = (_GLTFMeshParser = /*#__PURE__*/ function(GLTFParser1)
|
|
|
3866
4102
|
return context.get(exports.GLTFParserType.Buffer).then(function(buffers) {
|
|
3867
4103
|
return GLTFUtils.getAccessorData(glTF, indexAccessor, buffers);
|
|
3868
4104
|
});
|
|
3869
|
-
}, context.keepMeshData).then(resolve);
|
|
4105
|
+
}, context.params.keepMeshData).then(resolve);
|
|
3870
4106
|
}
|
|
3871
4107
|
});
|
|
3872
4108
|
};
|
|
3873
4109
|
var meshInfo = context.glTF.meshes[index];
|
|
3874
|
-
var glTF = context.glTF,
|
|
4110
|
+
var glTF = context.glTF, glTFResource = context.glTFResource;
|
|
4111
|
+
var engine = glTFResource.engine;
|
|
3875
4112
|
var primitivePromises = new Array();
|
|
3876
4113
|
for(var i = 0, length = meshInfo.primitives.length; i < length; i++)_loop(i);
|
|
3877
4114
|
return Promise.all(primitivePromises);
|
|
@@ -4044,9 +4281,9 @@ exports.GLTFSceneParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
4044
4281
|
}
|
|
4045
4282
|
var _proto = GLTFSceneParser.prototype;
|
|
4046
4283
|
_proto.parse = function parse(context, index) {
|
|
4047
|
-
var _this = this;
|
|
4048
4284
|
var _context_glTF = context.glTF, scenes = _context_glTF.scenes, _context_glTF_scene = _context_glTF.scene, scene = _context_glTF_scene === void 0 ? 0 : _context_glTF_scene, glTFResource = context.glTFResource;
|
|
4049
4285
|
var sceneInfo = scenes[index];
|
|
4286
|
+
var sceneExtensions = sceneInfo.extensions;
|
|
4050
4287
|
var engine = glTFResource.engine;
|
|
4051
4288
|
var isDefaultScene = scene === index;
|
|
4052
4289
|
var sceneNodes = sceneInfo.nodes;
|
|
@@ -4060,30 +4297,15 @@ exports.GLTFSceneParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
4060
4297
|
sceneRoot.addChild(childEntity);
|
|
4061
4298
|
}
|
|
4062
4299
|
}
|
|
4063
|
-
// @ts-ignore
|
|
4064
|
-
sceneRoot._hookResource = glTFResource;
|
|
4065
|
-
// @ts-ignore
|
|
4066
|
-
glTFResource._addReferCount(1);
|
|
4067
4300
|
if (isDefaultScene) {
|
|
4068
|
-
glTFResource.
|
|
4301
|
+
glTFResource._defaultSceneRoot = sceneRoot;
|
|
4069
4302
|
}
|
|
4070
4303
|
var promises = new Array();
|
|
4071
4304
|
for(var i1 = 0; i1 < sceneNodes.length; i1++){
|
|
4072
4305
|
promises.push(this._parseEntityComponent(context, sceneNodes[i1]));
|
|
4073
4306
|
}
|
|
4074
4307
|
return Promise.all(promises).then(function() {
|
|
4075
|
-
|
|
4076
|
-
return Promise.all([
|
|
4077
|
-
context.get(exports.GLTFParserType.Skin),
|
|
4078
|
-
context.get(exports.GLTFParserType.Animation)
|
|
4079
|
-
]).then(function(param) {
|
|
4080
|
-
var skins = param[0], animations = param[1];
|
|
4081
|
-
if (skins || animations) {
|
|
4082
|
-
_this._createAnimator(context, animations);
|
|
4083
|
-
}
|
|
4084
|
-
return sceneRoot;
|
|
4085
|
-
});
|
|
4086
|
-
}
|
|
4308
|
+
GLTFParser.executeExtensionsAdditiveAndParse(sceneExtensions, context, sceneRoot, sceneInfo);
|
|
4087
4309
|
return sceneRoot;
|
|
4088
4310
|
});
|
|
4089
4311
|
};
|
|
@@ -4195,28 +4417,6 @@ exports.GLTFSceneParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
4195
4417
|
for(var i = 0; i < glTFMeshPrimitives.length; i++)_loop(i);
|
|
4196
4418
|
return Promise.all(promises);
|
|
4197
4419
|
};
|
|
4198
|
-
_proto._createAnimator = function _createAnimator(context, animations) {
|
|
4199
|
-
var defaultSceneRoot = context.glTFResource.defaultSceneRoot;
|
|
4200
|
-
var animator = defaultSceneRoot.addComponent(miniprogram.Animator);
|
|
4201
|
-
var animatorController = new miniprogram.AnimatorController();
|
|
4202
|
-
var layer = new miniprogram.AnimatorControllerLayer("layer");
|
|
4203
|
-
var animatorStateMachine = new miniprogram.AnimatorStateMachine();
|
|
4204
|
-
animatorController.addLayer(layer);
|
|
4205
|
-
animator.animatorController = animatorController;
|
|
4206
|
-
layer.stateMachine = animatorStateMachine;
|
|
4207
|
-
if (animations) {
|
|
4208
|
-
for(var i = 0; i < animations.length; i++){
|
|
4209
|
-
var animationClip = animations[i];
|
|
4210
|
-
var name = animationClip.name;
|
|
4211
|
-
var uniqueName = animatorStateMachine.makeUniqueStateName(name);
|
|
4212
|
-
if (uniqueName !== name) {
|
|
4213
|
-
console.warn("AnimatorState name is existed, name: " + name + " reset to " + uniqueName);
|
|
4214
|
-
}
|
|
4215
|
-
var animatorState = animatorStateMachine.addState(uniqueName);
|
|
4216
|
-
animatorState.clip = animationClip;
|
|
4217
|
-
}
|
|
4218
|
-
}
|
|
4219
|
-
};
|
|
4220
4420
|
_proto._computeLocalBounds = function _computeLocalBounds(skinnedMeshRenderer, mesh, bones, rootBone, inverseBindMatrices) {
|
|
4221
4421
|
var rootBoneIndex = bones.indexOf(rootBone);
|
|
4222
4422
|
if (rootBoneIndex !== -1) {
|
|
@@ -4365,11 +4565,12 @@ exports.GLTFTextureParser = (_GLTFTextureParser = /*#__PURE__*/ function(GLTFPar
|
|
|
4365
4565
|
params: {
|
|
4366
4566
|
mipmap: (_samplerInfo = samplerInfo) == null ? void 0 : _samplerInfo.mipmap
|
|
4367
4567
|
}
|
|
4368
|
-
}).then(function(texture) {
|
|
4568
|
+
}).onProgress(undefined, context._onTaskDetail).then(function(texture) {
|
|
4369
4569
|
texture.name = textureName || imageName || texture.name || "texture_" + index;
|
|
4370
4570
|
useSampler && GLTFUtils.parseSampler(texture, samplerInfo);
|
|
4371
4571
|
return texture;
|
|
4372
4572
|
});
|
|
4573
|
+
context._addTaskCompletePromise(texture);
|
|
4373
4574
|
} else {
|
|
4374
4575
|
var bufferView = glTF.bufferViews[bufferViewIndex];
|
|
4375
4576
|
texture = context.get(exports.GLTFParserType.Buffer).then(function(buffers) {
|
|
@@ -4391,6 +4592,8 @@ exports.GLTFTextureParser = (_GLTFTextureParser = /*#__PURE__*/ function(GLTFPar
|
|
|
4391
4592
|
}
|
|
4392
4593
|
return Promise.resolve(texture).then(function(texture) {
|
|
4393
4594
|
GLTFParser.executeExtensionsAdditiveAndParse(extensions, context, texture, textureInfo);
|
|
4595
|
+
// @ts-ignore
|
|
4596
|
+
texture._associationSuperResource(glTFResource);
|
|
4394
4597
|
return texture;
|
|
4395
4598
|
});
|
|
4396
4599
|
};
|
|
@@ -4448,12 +4651,17 @@ var GLTFLoader = /*#__PURE__*/ function(Loader1) {
|
|
|
4448
4651
|
}
|
|
4449
4652
|
var _proto = GLTFLoader.prototype;
|
|
4450
4653
|
_proto.load = function load(item, resourceManager) {
|
|
4451
|
-
var _params;
|
|
4452
4654
|
var url = item.url;
|
|
4453
4655
|
var params = item.params;
|
|
4454
4656
|
var glTFResource = new GLTFResource(resourceManager.engine, url);
|
|
4455
|
-
var context = new GLTFParserContext(glTFResource, resourceManager,
|
|
4456
|
-
|
|
4657
|
+
var context = new GLTFParserContext(glTFResource, resourceManager, _extends({
|
|
4658
|
+
keepMeshData: false
|
|
4659
|
+
}, params));
|
|
4660
|
+
return new miniprogram.AssetPromise(function(resolve, reject, setTaskCompleteProgress, setTaskDetailProgress) {
|
|
4661
|
+
context._setTaskCompleteProgress = setTaskCompleteProgress;
|
|
4662
|
+
context._setTaskDetailProgress = setTaskDetailProgress;
|
|
4663
|
+
context.parse().then(resolve).catch(reject);
|
|
4664
|
+
});
|
|
4457
4665
|
};
|
|
4458
4666
|
return GLTFLoader;
|
|
4459
4667
|
}(miniprogram.Loader);
|
|
@@ -5100,6 +5308,12 @@ var MaterialLoader = /*#__PURE__*/ function(Loader1) {
|
|
|
5100
5308
|
materialShaderData.setTexture(key, texture);
|
|
5101
5309
|
}));
|
|
5102
5310
|
break;
|
|
5311
|
+
case "Boolean":
|
|
5312
|
+
materialShaderData.setInt(key, value ? 1 : 0);
|
|
5313
|
+
break;
|
|
5314
|
+
case "Integer":
|
|
5315
|
+
materialShaderData.setInt(key, Number(value));
|
|
5316
|
+
break;
|
|
5103
5317
|
}
|
|
5104
5318
|
};
|
|
5105
5319
|
var engine = resourceManager.engine;
|
|
@@ -5220,7 +5434,7 @@ var SpriteAtlasLoader = /*#__PURE__*/ function(Loader1) {
|
|
|
5220
5434
|
var _proto = SpriteAtlasLoader.prototype;
|
|
5221
5435
|
_proto.load = function load(item, resourceManager) {
|
|
5222
5436
|
var _this = this;
|
|
5223
|
-
return new miniprogram.AssetPromise(function(resolve, reject, _, onCancel) {
|
|
5437
|
+
return new miniprogram.AssetPromise(function(resolve, reject, _, __, onCancel) {
|
|
5224
5438
|
var chainPromises = [];
|
|
5225
5439
|
onCancel(function() {
|
|
5226
5440
|
for(var i = 0; i < chainPromises.length; i++){
|
|
@@ -5235,9 +5449,10 @@ var SpriteAtlasLoader = /*#__PURE__*/ function(Loader1) {
|
|
|
5235
5449
|
var _loop = function(i) {
|
|
5236
5450
|
var atlasItem = atlasItems[i];
|
|
5237
5451
|
if (atlasItem.img) {
|
|
5452
|
+
var _atlasItem_type;
|
|
5238
5453
|
chainPromises.push(resourceManager.load({
|
|
5239
5454
|
url: miniprogram.Utils.resolveAbsoluteUrl(item.url, atlasItem.img),
|
|
5240
|
-
type: miniprogram.AssetType.Texture2D,
|
|
5455
|
+
type: (_atlasItem_type = atlasItem.type) != null ? _atlasItem_type : miniprogram.AssetType.Texture2D,
|
|
5241
5456
|
params: {
|
|
5242
5457
|
format: format,
|
|
5243
5458
|
mipmap: mipmap
|
|
@@ -5367,15 +5582,19 @@ var Texture2DLoader = /*#__PURE__*/ function(Loader1) {
|
|
|
5367
5582
|
var _proto = Texture2DLoader.prototype;
|
|
5368
5583
|
_proto.load = function load(item, resourceManager) {
|
|
5369
5584
|
var _this = this;
|
|
5370
|
-
return new miniprogram.AssetPromise(function(resolve, reject) {
|
|
5585
|
+
return new miniprogram.AssetPromise(function(resolve, reject, setTaskCompleteProgress, setTaskDetailProgress) {
|
|
5371
5586
|
var url = item.url;
|
|
5372
5587
|
var requestConfig = _extends({}, item, {
|
|
5373
5588
|
type: "image"
|
|
5374
5589
|
});
|
|
5375
|
-
_this.request(url, requestConfig).then(function(image) {
|
|
5376
|
-
var
|
|
5377
|
-
var
|
|
5378
|
-
var texture = new miniprogram.Texture2D(resourceManager.engine, image.width, image.height,
|
|
5590
|
+
_this.request(url, requestConfig).onProgress(setTaskCompleteProgress, setTaskDetailProgress).then(function(image) {
|
|
5591
|
+
var _item_params;
|
|
5592
|
+
var _ref = (_item_params = item.params) != null ? _item_params : {}, format = _ref.format, mipmap = _ref.mipmap, anisoLevel = _ref.anisoLevel, wrapModeU = _ref.wrapModeU, wrapModeV = _ref.wrapModeV, filterMode = _ref.filterMode;
|
|
5593
|
+
var texture = new miniprogram.Texture2D(resourceManager.engine, image.width, image.height, format, mipmap);
|
|
5594
|
+
texture.anisoLevel = anisoLevel != null ? anisoLevel : texture.anisoLevel;
|
|
5595
|
+
texture.filterMode = filterMode != null ? filterMode : texture.filterMode;
|
|
5596
|
+
texture.wrapModeU = wrapModeU != null ? wrapModeU : texture.wrapModeU;
|
|
5597
|
+
texture.wrapModeV = wrapModeV != null ? wrapModeV : texture.wrapModeV;
|
|
5379
5598
|
texture.setImageSource(image);
|
|
5380
5599
|
texture.generateMipmaps();
|
|
5381
5600
|
if (url.indexOf("data:") !== 0) {
|
|
@@ -5523,33 +5742,34 @@ var SceneLoader = /*#__PURE__*/ function(Loader1) {
|
|
|
5523
5742
|
var promises = [];
|
|
5524
5743
|
// parse ambient light
|
|
5525
5744
|
var ambient = data.scene.ambient;
|
|
5526
|
-
|
|
5527
|
-
|
|
5528
|
-
|
|
5529
|
-
// prettier-ignore
|
|
5530
|
-
var customAmbientPromise = resourceManager.getResourceByRef(ambient.customAmbientLight).then(function(ambientLight) {
|
|
5531
|
-
scene.ambientLight = ambientLight;
|
|
5532
|
-
scene.ambientLight.diffuseIntensity = ambient.diffuseIntensity;
|
|
5533
|
-
scene.ambientLight.specularIntensity = ambient.specularIntensity;
|
|
5534
|
-
scene.ambientLight.diffuseMode = ambient.diffuseMode;
|
|
5535
|
-
scene.ambientLight.diffuseSolidColor.copyFrom(ambient.diffuseSolidColor);
|
|
5536
|
-
});
|
|
5537
|
-
promises.push(customAmbientPromise);
|
|
5538
|
-
} else if (!useCustomAmbient && ambient.ambientLight) {
|
|
5539
|
-
// @ts-ignore
|
|
5540
|
-
// prettier-ignore
|
|
5541
|
-
var ambientLightPromise = resourceManager.getResourceByRef(ambient.ambientLight).then(function(ambientLight) {
|
|
5542
|
-
scene.ambientLight = ambientLight;
|
|
5543
|
-
scene.ambientLight.diffuseIntensity = ambient.diffuseIntensity;
|
|
5544
|
-
scene.ambientLight.specularIntensity = ambient.specularIntensity;
|
|
5545
|
-
scene.ambientLight.diffuseMode = ambient.diffuseMode;
|
|
5546
|
-
scene.ambientLight.diffuseSolidColor.copyFrom(ambient.diffuseSolidColor);
|
|
5547
|
-
});
|
|
5548
|
-
promises.push(ambientLightPromise);
|
|
5549
|
-
} else {
|
|
5745
|
+
if (ambient) {
|
|
5746
|
+
var useCustomAmbient = ambient.specularMode === "Custom";
|
|
5747
|
+
var useSH = ambient.diffuseMode === miniprogram.DiffuseMode.SphericalHarmonics;
|
|
5550
5748
|
scene.ambientLight.diffuseIntensity = ambient.diffuseIntensity;
|
|
5551
5749
|
scene.ambientLight.specularIntensity = ambient.specularIntensity;
|
|
5750
|
+
scene.ambientLight.diffuseMode = ambient.diffuseMode;
|
|
5552
5751
|
scene.ambientLight.diffuseSolidColor.copyFrom(ambient.diffuseSolidColor);
|
|
5752
|
+
scene.ambientLight.specularTextureDecodeRGBM = true;
|
|
5753
|
+
if (useCustomAmbient && ambient.customAmbientLight) {
|
|
5754
|
+
promises.push(// @ts-ignore
|
|
5755
|
+
resourceManager.getResourceByRef(ambient.customAmbientLight).then(function(ambientLight) {
|
|
5756
|
+
var _ambientLight;
|
|
5757
|
+
scene.ambientLight.specularTexture = (_ambientLight = ambientLight) == null ? void 0 : _ambientLight.specularTexture;
|
|
5758
|
+
}));
|
|
5759
|
+
}
|
|
5760
|
+
if (ambient.ambientLight && (!useCustomAmbient || useSH)) {
|
|
5761
|
+
promises.push(// @ts-ignore
|
|
5762
|
+
resourceManager.getResourceByRef(ambient.ambientLight).then(function(ambientLight) {
|
|
5763
|
+
if (!useCustomAmbient) {
|
|
5764
|
+
var _ambientLight;
|
|
5765
|
+
scene.ambientLight.specularTexture = (_ambientLight = ambientLight) == null ? void 0 : _ambientLight.specularTexture;
|
|
5766
|
+
}
|
|
5767
|
+
if (useSH) {
|
|
5768
|
+
var _ambientLight1;
|
|
5769
|
+
scene.ambientLight.diffuseSphericalHarmonics = (_ambientLight1 = ambientLight) == null ? void 0 : _ambientLight1.diffuseSphericalHarmonics;
|
|
5770
|
+
}
|
|
5771
|
+
}));
|
|
5772
|
+
}
|
|
5553
5773
|
}
|
|
5554
5774
|
var background = data.scene.background;
|
|
5555
5775
|
scene.background.mode = background.mode;
|
|
@@ -5591,6 +5811,9 @@ var SceneLoader = /*#__PURE__*/ function(Loader1) {
|
|
|
5591
5811
|
if (shadow.shadowResolution != undefined) scene.shadowResolution = shadow.shadowResolution;
|
|
5592
5812
|
if (shadow.shadowDistance != undefined) scene.shadowDistance = shadow.shadowDistance;
|
|
5593
5813
|
if (shadow.shadowCascades != undefined) scene.shadowCascades = shadow.shadowCascades;
|
|
5814
|
+
var _shadow_shadowTwoCascadeSplits;
|
|
5815
|
+
scene.shadowTwoCascadeSplits = (_shadow_shadowTwoCascadeSplits = shadow.shadowTwoCascadeSplits) != null ? _shadow_shadowTwoCascadeSplits : scene.shadowTwoCascadeSplits;
|
|
5816
|
+
shadow.shadowFourCascadeSplits && scene.shadowFourCascadeSplits.copyFrom(shadow.shadowFourCascadeSplits);
|
|
5594
5817
|
}
|
|
5595
5818
|
return Promise.all(promises).then(function() {
|
|
5596
5819
|
resolve(scene);
|
|
@@ -5606,13 +5829,13 @@ SceneLoader = __decorate([
|
|
|
5606
5829
|
"scene"
|
|
5607
5830
|
], true)
|
|
5608
5831
|
], SceneLoader);
|
|
5609
|
-
ReflectionParser.registerCustomParseComponent("TextRenderer", /*#__PURE__*/ _async_to_generator(function(instance, item
|
|
5832
|
+
ReflectionParser.registerCustomParseComponent("TextRenderer", /*#__PURE__*/ _async_to_generator(function(instance, item) {
|
|
5610
5833
|
var props;
|
|
5611
5834
|
return __generator(this, function(_state) {
|
|
5612
5835
|
props = item.props;
|
|
5613
5836
|
if (!props.font) {
|
|
5614
5837
|
// @ts-ignore
|
|
5615
|
-
instance.font = miniprogram.Font.createFromOS(engine, props.fontFamily || "Arial");
|
|
5838
|
+
instance.font = miniprogram.Font.createFromOS(instance.engine, props.fontFamily || "Arial");
|
|
5616
5839
|
}
|
|
5617
5840
|
return [
|
|
5618
5841
|
2,
|
|
@@ -5668,7 +5891,7 @@ var KHR_draco_mesh_compression = (_KHR_draco_mesh_compression = /*#__PURE__*/ fu
|
|
|
5668
5891
|
throw "BlendShape animation is not supported when using draco.";
|
|
5669
5892
|
}, function() {
|
|
5670
5893
|
return decodedGeometry.index.array;
|
|
5671
|
-
}, context.keepMeshData);
|
|
5894
|
+
}, context.params.keepMeshData);
|
|
5672
5895
|
});
|
|
5673
5896
|
});
|
|
5674
5897
|
};
|
|
@@ -5959,7 +6182,7 @@ var KHR_materials_variants = /*#__PURE__*/ function(GLTFExtensionParser1) {
|
|
|
5959
6182
|
var _glTFResource;
|
|
5960
6183
|
var _context_glTF = context.glTF, _context_glTF_extensions = _context_glTF.extensions, _context_glTF_extensions_KHR_materials_variants = _context_glTF_extensions.KHR_materials_variants, variantNames = _context_glTF_extensions_KHR_materials_variants.variants, glTFResource = context.glTFResource;
|
|
5961
6184
|
var mappings = schema.mappings;
|
|
5962
|
-
(_glTFResource = glTFResource).
|
|
6185
|
+
(_glTFResource = glTFResource)._extensionsData || (_glTFResource._extensionsData = {});
|
|
5963
6186
|
var extensionData = [];
|
|
5964
6187
|
glTFResource.extensionsData.variants = extensionData;
|
|
5965
6188
|
for(var i = 0; i < mappings.length; i++)_loop(i);
|
|
@@ -5989,7 +6212,7 @@ var KHR_texture_basisu = /*#__PURE__*/ function(GLTFExtensionParser1) {
|
|
|
5989
6212
|
var _proto = KHR_texture_basisu.prototype;
|
|
5990
6213
|
_proto.createAndParse = function createAndParse(context, schema, textureInfo) {
|
|
5991
6214
|
return _async_to_generator(function() {
|
|
5992
|
-
var glTF, glTFResource, engine, url, sampler, textureName, source, _glTF_images_source, uri, bufferViewIndex, mimeType, imageName, samplerInfo, index, bufferView;
|
|
6215
|
+
var glTF, glTFResource, engine, url, sampler, textureName, source, _glTF_images_source, uri, bufferViewIndex, mimeType, imageName, samplerInfo, index, promise, bufferView;
|
|
5993
6216
|
return __generator(this, function(_state) {
|
|
5994
6217
|
glTF = context.glTF, glTFResource = context.glTFResource;
|
|
5995
6218
|
engine = glTFResource.engine, url = glTFResource.url;
|
|
@@ -5999,20 +6222,22 @@ var KHR_texture_basisu = /*#__PURE__*/ function(GLTFExtensionParser1) {
|
|
|
5999
6222
|
samplerInfo = sampler !== undefined && GLTFUtils.getSamplerInfo(glTF.samplers[sampler]);
|
|
6000
6223
|
if (uri) {
|
|
6001
6224
|
index = uri.lastIndexOf(".");
|
|
6225
|
+
promise = engine.resourceManager.load({
|
|
6226
|
+
url: miniprogram.Utils.resolveAbsoluteUrl(url, uri),
|
|
6227
|
+
type: miniprogram.AssetType.KTX2
|
|
6228
|
+
}).onProgress(undefined, context._onTaskDetail).then(function(texture) {
|
|
6229
|
+
if (!texture.name) {
|
|
6230
|
+
texture.name = textureName || imageName || "texture_" + index;
|
|
6231
|
+
}
|
|
6232
|
+
if (sampler !== undefined) {
|
|
6233
|
+
GLTFUtils.parseSampler(texture, samplerInfo);
|
|
6234
|
+
}
|
|
6235
|
+
return texture;
|
|
6236
|
+
});
|
|
6237
|
+
context._addTaskCompletePromise(promise);
|
|
6002
6238
|
return [
|
|
6003
6239
|
2,
|
|
6004
|
-
|
|
6005
|
-
url: miniprogram.Utils.resolveAbsoluteUrl(url, uri),
|
|
6006
|
-
type: miniprogram.AssetType.KTX2
|
|
6007
|
-
}).then(function(texture) {
|
|
6008
|
-
if (!texture.name) {
|
|
6009
|
-
texture.name = textureName || imageName || "texture_" + index;
|
|
6010
|
-
}
|
|
6011
|
-
if (sampler !== undefined) {
|
|
6012
|
-
GLTFUtils.parseSampler(texture, samplerInfo);
|
|
6013
|
-
}
|
|
6014
|
-
return texture;
|
|
6015
|
-
})
|
|
6240
|
+
promise
|
|
6016
6241
|
];
|
|
6017
6242
|
} else {
|
|
6018
6243
|
bufferView = glTF.bufferViews[bufferViewIndex];
|
|
@@ -6082,7 +6307,9 @@ var GALACEAN_materials_remap = /*#__PURE__*/ function(GLTFExtensionParser1) {
|
|
|
6082
6307
|
_proto.createAndParse = function createAndParse(context, schema) {
|
|
6083
6308
|
var engine = context.glTFResource.engine;
|
|
6084
6309
|
// @ts-ignore
|
|
6085
|
-
|
|
6310
|
+
var promise = engine.resourceManager.getResourceByRef(schema);
|
|
6311
|
+
context._addTaskCompletePromise(promise);
|
|
6312
|
+
return promise;
|
|
6086
6313
|
};
|
|
6087
6314
|
return GALACEAN_materials_remap;
|
|
6088
6315
|
}(GLTFExtensionParser);
|
|
@@ -6113,6 +6340,29 @@ GALACEAN_animation_event = __decorate([
|
|
|
6113
6340
|
registerGLTFExtension("GALACEAN_animation_event", exports.GLTFExtensionMode.AdditiveParse)
|
|
6114
6341
|
], GALACEAN_animation_event);
|
|
6115
6342
|
|
|
6343
|
+
var KHR_materials_anisotropy = /*#__PURE__*/ function(GLTFExtensionParser1) {
|
|
6344
|
+
_inherits(KHR_materials_anisotropy, GLTFExtensionParser1);
|
|
6345
|
+
function KHR_materials_anisotropy() {
|
|
6346
|
+
return GLTFExtensionParser1.apply(this, arguments);
|
|
6347
|
+
}
|
|
6348
|
+
var _proto = KHR_materials_anisotropy.prototype;
|
|
6349
|
+
_proto.additiveParse = function additiveParse(context, material, schema) {
|
|
6350
|
+
var _schema_anisotropyStrength = schema.anisotropyStrength, anisotropyStrength = _schema_anisotropyStrength === void 0 ? 0 : _schema_anisotropyStrength, _schema_anisotropyRotation = schema.anisotropyRotation, anisotropyRotation = _schema_anisotropyRotation === void 0 ? 0 : _schema_anisotropyRotation, anisotropyTexture = schema.anisotropyTexture;
|
|
6351
|
+
material.anisotropy = anisotropyStrength;
|
|
6352
|
+
material.anisotropyRotation = anisotropyRotation;
|
|
6353
|
+
if (anisotropyTexture) {
|
|
6354
|
+
exports.GLTFMaterialParser._checkOtherTextureTransform(anisotropyTexture, "Anisotropy texture");
|
|
6355
|
+
context.get(exports.GLTFParserType.Texture, anisotropyTexture.index).then(function(texture) {
|
|
6356
|
+
material.anisotropyTexture = texture;
|
|
6357
|
+
});
|
|
6358
|
+
}
|
|
6359
|
+
};
|
|
6360
|
+
return KHR_materials_anisotropy;
|
|
6361
|
+
}(GLTFExtensionParser);
|
|
6362
|
+
KHR_materials_anisotropy = __decorate([
|
|
6363
|
+
registerGLTFExtension("KHR_materials_anisotropy", exports.GLTFExtensionMode.AdditiveParse)
|
|
6364
|
+
], KHR_materials_anisotropy);
|
|
6365
|
+
|
|
6116
6366
|
exports.ComponentMap = ComponentMap;
|
|
6117
6367
|
exports.GLTFExtensionParser = GLTFExtensionParser;
|
|
6118
6368
|
exports.GLTFParser = GLTFParser;
|