@galacean/engine-loader 1.1.0-beta.16 → 1.1.0-beta.18
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 +84 -93
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +84 -93
- package/dist/module.js +84 -93
- package/dist/module.js.map +1 -1
- package/package.json +5 -5
- package/types/gltf/parser/GLTFParserContext.d.ts +1 -0
- package/types/gltf/parser/GLTFSceneParser.d.ts +0 -1
- package/types/resource-deserialize/utils/BufferReader.d.ts +1 -1
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.
|
|
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
|
}
|
|
@@ -1604,11 +1603,37 @@ var TextureWrapMode;
|
|
|
1604
1603
|
_this.get(9),
|
|
1605
1604
|
_this.get(2)
|
|
1606
1605
|
]).then(function() {
|
|
1606
|
+
var glTFResource = _this.glTFResource;
|
|
1607
|
+
if (glTFResource.skins || glTFResource.animations) {
|
|
1608
|
+
_this._createAnimator(_this, glTFResource.animations);
|
|
1609
|
+
}
|
|
1607
1610
|
_this.resourceManager.addContentRestorer(_this.contentRestorer);
|
|
1608
|
-
return
|
|
1611
|
+
return glTFResource;
|
|
1609
1612
|
});
|
|
1610
1613
|
});
|
|
1611
1614
|
};
|
|
1615
|
+
_proto._createAnimator = function _createAnimator(context, animations) {
|
|
1616
|
+
var defaultSceneRoot = context.glTFResource.defaultSceneRoot;
|
|
1617
|
+
var animator = defaultSceneRoot.addComponent(miniprogram.Animator);
|
|
1618
|
+
var animatorController = new miniprogram.AnimatorController();
|
|
1619
|
+
var layer = new miniprogram.AnimatorControllerLayer("layer");
|
|
1620
|
+
var animatorStateMachine = new miniprogram.AnimatorStateMachine();
|
|
1621
|
+
animatorController.addLayer(layer);
|
|
1622
|
+
animator.animatorController = animatorController;
|
|
1623
|
+
layer.stateMachine = animatorStateMachine;
|
|
1624
|
+
if (animations) {
|
|
1625
|
+
for(var i = 0; i < animations.length; i++){
|
|
1626
|
+
var animationClip = animations[i];
|
|
1627
|
+
var name = animationClip.name;
|
|
1628
|
+
var uniqueName = animatorStateMachine.makeUniqueStateName(name);
|
|
1629
|
+
if (uniqueName !== name) {
|
|
1630
|
+
console.warn("AnimatorState name is existed, name: " + name + " reset to " + uniqueName);
|
|
1631
|
+
}
|
|
1632
|
+
var animatorState = animatorStateMachine.addState(uniqueName);
|
|
1633
|
+
animatorState.clip = animationClip;
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1636
|
+
};
|
|
1612
1637
|
_proto._handleSubAsset = function _handleSubAsset(resource, type, index) {
|
|
1613
1638
|
var _this = this;
|
|
1614
1639
|
var glTFResourceKey = glTFResourceMap[type];
|
|
@@ -3534,6 +3559,7 @@ exports.GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
3534
3559
|
var promises = new Array();
|
|
3535
3560
|
// parse samplers
|
|
3536
3561
|
for(var j = 0, m = samplers.length; j < m; j++)_loop(j);
|
|
3562
|
+
promises.push(context.get(exports.GLTFParserType.Scene));
|
|
3537
3563
|
return Promise.all(promises).then(function() {
|
|
3538
3564
|
for(var j = 0, m = channels.length; j < m; j++){
|
|
3539
3565
|
var gltfChannel = channels[j];
|
|
@@ -3546,7 +3572,7 @@ exports.GLTFAnimationParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
3546
3572
|
entity = entity.parent;
|
|
3547
3573
|
}
|
|
3548
3574
|
// If the target node is in the default scene, relativePath will be empty
|
|
3549
|
-
if (
|
|
3575
|
+
if (context.glTFResource.sceneRoots.indexOf(entity) === -1) {
|
|
3550
3576
|
continue;
|
|
3551
3577
|
}
|
|
3552
3578
|
var ComponentType = void 0;
|
|
@@ -4063,7 +4089,6 @@ exports.GLTFSceneParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
4063
4089
|
}
|
|
4064
4090
|
var _proto = GLTFSceneParser.prototype;
|
|
4065
4091
|
_proto.parse = function parse(context, index) {
|
|
4066
|
-
var _this = this;
|
|
4067
4092
|
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;
|
|
4068
4093
|
var sceneInfo = scenes[index];
|
|
4069
4094
|
var sceneExtensions = sceneInfo.extensions;
|
|
@@ -4093,18 +4118,6 @@ exports.GLTFSceneParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
4093
4118
|
}
|
|
4094
4119
|
return Promise.all(promises).then(function() {
|
|
4095
4120
|
GLTFParser.executeExtensionsAdditiveAndParse(sceneExtensions, context, sceneRoot, sceneInfo);
|
|
4096
|
-
if (isDefaultScene) {
|
|
4097
|
-
return Promise.all([
|
|
4098
|
-
context.get(exports.GLTFParserType.Skin),
|
|
4099
|
-
context.get(exports.GLTFParserType.Animation)
|
|
4100
|
-
]).then(function(param) {
|
|
4101
|
-
var skins = param[0], animations = param[1];
|
|
4102
|
-
if (skins || animations) {
|
|
4103
|
-
_this._createAnimator(context, animations);
|
|
4104
|
-
}
|
|
4105
|
-
return sceneRoot;
|
|
4106
|
-
});
|
|
4107
|
-
}
|
|
4108
4121
|
return sceneRoot;
|
|
4109
4122
|
});
|
|
4110
4123
|
};
|
|
@@ -4216,28 +4229,6 @@ exports.GLTFSceneParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
4216
4229
|
for(var i = 0; i < glTFMeshPrimitives.length; i++)_loop(i);
|
|
4217
4230
|
return Promise.all(promises);
|
|
4218
4231
|
};
|
|
4219
|
-
_proto._createAnimator = function _createAnimator(context, animations) {
|
|
4220
|
-
var defaultSceneRoot = context.glTFResource.defaultSceneRoot;
|
|
4221
|
-
var animator = defaultSceneRoot.addComponent(miniprogram.Animator);
|
|
4222
|
-
var animatorController = new miniprogram.AnimatorController();
|
|
4223
|
-
var layer = new miniprogram.AnimatorControllerLayer("layer");
|
|
4224
|
-
var animatorStateMachine = new miniprogram.AnimatorStateMachine();
|
|
4225
|
-
animatorController.addLayer(layer);
|
|
4226
|
-
animator.animatorController = animatorController;
|
|
4227
|
-
layer.stateMachine = animatorStateMachine;
|
|
4228
|
-
if (animations) {
|
|
4229
|
-
for(var i = 0; i < animations.length; i++){
|
|
4230
|
-
var animationClip = animations[i];
|
|
4231
|
-
var name = animationClip.name;
|
|
4232
|
-
var uniqueName = animatorStateMachine.makeUniqueStateName(name);
|
|
4233
|
-
if (uniqueName !== name) {
|
|
4234
|
-
console.warn("AnimatorState name is existed, name: " + name + " reset to " + uniqueName);
|
|
4235
|
-
}
|
|
4236
|
-
var animatorState = animatorStateMachine.addState(uniqueName);
|
|
4237
|
-
animatorState.clip = animationClip;
|
|
4238
|
-
}
|
|
4239
|
-
}
|
|
4240
|
-
};
|
|
4241
4232
|
_proto._computeLocalBounds = function _computeLocalBounds(skinnedMeshRenderer, mesh, bones, rootBone, inverseBindMatrices) {
|
|
4242
4233
|
var rootBoneIndex = bones.indexOf(rootBone);
|
|
4243
4234
|
if (rootBoneIndex !== -1) {
|