@galacean/engine 1.1.1 → 1.1.3
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/browser.js +194 -213
- package/dist/browser.min.js +1 -1
- package/dist/main.js +1 -1
- package/dist/miniprogram.js +1 -1
- package/dist/module.js +1 -1
- package/package.json +5 -5
- package/dist/.DS_Store +0 -0
package/dist/browser.js
CHANGED
|
@@ -13444,6 +13444,7 @@
|
|
|
13444
13444
|
this._isContentLost = false;
|
|
13445
13445
|
};
|
|
13446
13446
|
_proto._onDestroy = function _onDestroy() {
|
|
13447
|
+
GraphicsResource1.prototype._onDestroy.call(this);
|
|
13447
13448
|
this._platformPrimitive.destroy();
|
|
13448
13449
|
this._vertexElementMap = null;
|
|
13449
13450
|
};
|
|
@@ -39578,7 +39579,7 @@
|
|
|
39578
39579
|
var glTFItems = this.glTF[glTFSchemaMap[type]];
|
|
39579
39580
|
if (glTFItems && (index === undefined || glTFItems[index])) {
|
|
39580
39581
|
if (index === undefined) {
|
|
39581
|
-
resource = type ===
|
|
39582
|
+
resource = type === 8 ? glTFItems.map(function(_, index) {
|
|
39582
39583
|
return _this.get(type, index);
|
|
39583
39584
|
}) : Promise.all(glTFItems.map(function(_, index) {
|
|
39584
39585
|
return _this.get(type, index);
|
|
@@ -39600,11 +39601,11 @@
|
|
|
39600
39601
|
_this.glTF = json;
|
|
39601
39602
|
return Promise.all([
|
|
39602
39603
|
_this.get(1),
|
|
39603
|
-
_this.get(4),
|
|
39604
39604
|
_this.get(5),
|
|
39605
39605
|
_this.get(6),
|
|
39606
|
-
_this.get(
|
|
39606
|
+
_this.get(7),
|
|
39607
39607
|
_this.get(9),
|
|
39608
|
+
_this.get(10),
|
|
39608
39609
|
_this.get(2)
|
|
39609
39610
|
]).then(function() {
|
|
39610
39611
|
var glTFResource = _this.glTFResource;
|
|
@@ -39642,7 +39643,7 @@
|
|
|
39642
39643
|
var _this = this;
|
|
39643
39644
|
var glTFResourceKey = glTFResourceMap[type];
|
|
39644
39645
|
if (!glTFResourceKey) return;
|
|
39645
|
-
if (type ===
|
|
39646
|
+
if (type === 8) {
|
|
39646
39647
|
var _this_glTFResource, _glTFResourceKey;
|
|
39647
39648
|
((_this_glTFResource = this.glTFResource)[_glTFResourceKey = glTFResourceKey] || (_this_glTFResource[_glTFResourceKey] = []))[index] = resource;
|
|
39648
39649
|
} else {
|
|
@@ -39650,7 +39651,7 @@
|
|
|
39650
39651
|
resource.then(function(item) {
|
|
39651
39652
|
var _this_glTFResource, _glTFResourceKey;
|
|
39652
39653
|
((_this_glTFResource = _this.glTFResource)[_glTFResourceKey = glTFResourceKey] || (_this_glTFResource[_glTFResourceKey] = []))[index] = item;
|
|
39653
|
-
if (type ===
|
|
39654
|
+
if (type === 7) {
|
|
39654
39655
|
for(var i = 0, length = item.length; i < length; i++){
|
|
39655
39656
|
var mesh = item[i];
|
|
39656
39657
|
// @ts-ignore
|
|
@@ -39690,17 +39691,18 @@
|
|
|
39690
39691
|
GLTFParserType[GLTFParserType["Validator"] = 1] = "Validator";
|
|
39691
39692
|
GLTFParserType[GLTFParserType["Scene"] = 2] = "Scene";
|
|
39692
39693
|
GLTFParserType[GLTFParserType["Buffer"] = 3] = "Buffer";
|
|
39693
|
-
GLTFParserType[GLTFParserType["
|
|
39694
|
-
GLTFParserType[GLTFParserType["
|
|
39695
|
-
GLTFParserType[GLTFParserType["
|
|
39696
|
-
GLTFParserType[GLTFParserType["
|
|
39697
|
-
GLTFParserType[GLTFParserType["
|
|
39698
|
-
GLTFParserType[GLTFParserType["
|
|
39694
|
+
GLTFParserType[GLTFParserType["BufferView"] = 4] = "BufferView";
|
|
39695
|
+
GLTFParserType[GLTFParserType["Texture"] = 5] = "Texture";
|
|
39696
|
+
GLTFParserType[GLTFParserType["Material"] = 6] = "Material";
|
|
39697
|
+
GLTFParserType[GLTFParserType["Mesh"] = 7] = "Mesh";
|
|
39698
|
+
GLTFParserType[GLTFParserType["Entity"] = 8] = "Entity";
|
|
39699
|
+
GLTFParserType[GLTFParserType["Skin"] = 9] = "Skin";
|
|
39700
|
+
GLTFParserType[GLTFParserType["Animation"] = 10] = "Animation";
|
|
39699
39701
|
})(exports.GLTFParserType || (exports.GLTFParserType = {}));
|
|
39700
39702
|
var _obj;
|
|
39701
|
-
var glTFSchemaMap = (_obj = {}, _obj[2] = "scenes", _obj[3] = "buffers", _obj[
|
|
39703
|
+
var glTFSchemaMap = (_obj = {}, _obj[2] = "scenes", _obj[3] = "buffers", _obj[5] = "textures", _obj[6] = "materials", _obj[7] = "meshes", _obj[8] = "nodes", _obj[9] = "skins", _obj[10] = "animations", _obj[4] = "bufferViews", _obj);
|
|
39702
39704
|
var _obj1;
|
|
39703
|
-
var glTFResourceMap = (_obj1 = {}, _obj1[2] = "sceneRoots", _obj1[
|
|
39705
|
+
var glTFResourceMap = (_obj1 = {}, _obj1[2] = "sceneRoots", _obj1[5] = "textures", _obj1[6] = "materials", _obj1[7] = "meshes", _obj1[8] = "entities", _obj1[9] = "skins", _obj1[10] = "animations", _obj1);
|
|
39704
39706
|
function registerGLTFParser(pipeline) {
|
|
39705
39707
|
return function(Parser) {
|
|
39706
39708
|
var parser = new Parser();
|
|
@@ -39804,113 +39806,68 @@
|
|
|
39804
39806
|
};
|
|
39805
39807
|
GLTFUtils.getAccessorBuffer = function getAccessorBuffer(context, bufferViews, accessor) {
|
|
39806
39808
|
var componentType = accessor.componentType;
|
|
39807
|
-
var
|
|
39808
|
-
var
|
|
39809
|
-
var
|
|
39810
|
-
|
|
39811
|
-
|
|
39812
|
-
|
|
39813
|
-
|
|
39814
|
-
var
|
|
39815
|
-
var
|
|
39816
|
-
|
|
39817
|
-
|
|
39818
|
-
|
|
39819
|
-
|
|
39820
|
-
|
|
39821
|
-
|
|
39822
|
-
|
|
39823
|
-
|
|
39824
|
-
|
|
39825
|
-
|
|
39826
|
-
|
|
39827
|
-
|
|
39828
|
-
|
|
39829
|
-
|
|
39830
|
-
|
|
39831
|
-
|
|
39832
|
-
|
|
39833
|
-
|
|
39834
|
-
|
|
39835
|
-
|
|
39809
|
+
var TypedArray = GLTFUtils.getComponentType(componentType);
|
|
39810
|
+
var dataElementSize = GLTFUtils.getAccessorTypeSize(accessor.type);
|
|
39811
|
+
var dataElementBytes = TypedArray.BYTES_PER_ELEMENT;
|
|
39812
|
+
var elementStride = dataElementSize * dataElementBytes;
|
|
39813
|
+
var accessorCount = accessor.count;
|
|
39814
|
+
var promise;
|
|
39815
|
+
if (accessor.bufferView !== undefined) {
|
|
39816
|
+
var bufferViewIndex = accessor.bufferView;
|
|
39817
|
+
var bufferView = bufferViews[bufferViewIndex];
|
|
39818
|
+
promise = context.get(exports.GLTFParserType.BufferView, accessor.bufferView).then(function(bufferViewData) {
|
|
39819
|
+
var bufferIndex = bufferView.buffer;
|
|
39820
|
+
var _bufferViewData_byteOffset;
|
|
39821
|
+
var bufferByteOffset = (_bufferViewData_byteOffset = bufferViewData.byteOffset) != null ? _bufferViewData_byteOffset : 0;
|
|
39822
|
+
var _accessor_byteOffset;
|
|
39823
|
+
var byteOffset = (_accessor_byteOffset = accessor.byteOffset) != null ? _accessor_byteOffset : 0;
|
|
39824
|
+
var bufferStride = bufferView.byteStride;
|
|
39825
|
+
var bufferInfo;
|
|
39826
|
+
// According to the glTF official documentation only byteStride not undefined is allowed
|
|
39827
|
+
if (bufferStride !== undefined && bufferStride !== elementStride) {
|
|
39828
|
+
var bufferSlice = Math.floor(byteOffset / bufferStride);
|
|
39829
|
+
var bufferCacheKey = bufferViewIndex + ":" + componentType + ":" + bufferSlice + ":" + accessorCount;
|
|
39830
|
+
var accessorBufferCache = context.accessorBufferCache;
|
|
39831
|
+
bufferInfo = accessorBufferCache[bufferCacheKey];
|
|
39832
|
+
if (!bufferInfo) {
|
|
39833
|
+
var offset = bufferByteOffset + bufferSlice * bufferStride;
|
|
39834
|
+
var count = accessorCount * (bufferStride / dataElementBytes);
|
|
39835
|
+
var data = new TypedArray(bufferViewData.buffer, offset, count);
|
|
39836
|
+
accessorBufferCache[bufferCacheKey] = bufferInfo = new BufferInfo(data, true, bufferStride);
|
|
39837
|
+
bufferInfo.restoreInfo = new BufferDataRestoreInfo(new RestoreDataAccessor(bufferIndex, TypedArray, offset, count));
|
|
39838
|
+
}
|
|
39839
|
+
} else {
|
|
39840
|
+
var offset1 = bufferByteOffset + byteOffset;
|
|
39841
|
+
var count1 = accessorCount * dataElementSize;
|
|
39842
|
+
var data1 = new TypedArray(bufferViewData.buffer, offset1, count1);
|
|
39843
|
+
bufferInfo = new BufferInfo(data1, false, elementStride);
|
|
39844
|
+
bufferInfo.restoreInfo = new BufferDataRestoreInfo(new RestoreDataAccessor(bufferIndex, TypedArray, offset1, count1));
|
|
39836
39845
|
}
|
|
39837
|
-
|
|
39838
|
-
|
|
39839
|
-
|
|
39840
|
-
|
|
39841
|
-
|
|
39842
|
-
|
|
39843
|
-
|
|
39844
|
-
|
|
39845
|
-
|
|
39846
|
-
|
|
39847
|
-
return bufferInfo
|
|
39848
|
-
|
|
39846
|
+
return bufferInfo;
|
|
39847
|
+
});
|
|
39848
|
+
} else {
|
|
39849
|
+
var count = accessorCount * dataElementSize;
|
|
39850
|
+
var data = new TypedArray(count);
|
|
39851
|
+
var bufferInfo = new BufferInfo(data, false, elementStride);
|
|
39852
|
+
bufferInfo.restoreInfo = new BufferDataRestoreInfo(new RestoreDataAccessor(undefined, TypedArray, undefined, count));
|
|
39853
|
+
promise = Promise.resolve(bufferInfo);
|
|
39854
|
+
}
|
|
39855
|
+
return accessor.sparse ? promise.then(function(bufferInfo) {
|
|
39856
|
+
return GLTFUtils.processingSparseData(context, accessor, bufferInfo).then(function() {
|
|
39857
|
+
return bufferInfo;
|
|
39858
|
+
});
|
|
39859
|
+
}) : promise;
|
|
39849
39860
|
};
|
|
39850
|
-
GLTFUtils.bufferToVector3Array = function bufferToVector3Array(
|
|
39851
|
-
var
|
|
39852
|
-
var
|
|
39853
|
-
var
|
|
39854
|
-
var
|
|
39861
|
+
GLTFUtils.bufferToVector3Array = function bufferToVector3Array(buffer, byteOffset, count, normalized, componentType) {
|
|
39862
|
+
var baseOffset = byteOffset / buffer.BYTES_PER_ELEMENT;
|
|
39863
|
+
var stride = buffer.length / count;
|
|
39864
|
+
var vertices = new Array(count);
|
|
39865
|
+
var factor = normalized ? GLTFUtils.getNormalizedComponentScale(componentType) : 1;
|
|
39855
39866
|
for(var i = 0; i < count; i++){
|
|
39856
|
-
var index =
|
|
39857
|
-
|
|
39867
|
+
var index = baseOffset + i * stride;
|
|
39868
|
+
vertices[i] = new Vector3(buffer[index] * factor, buffer[index + 1] * factor, buffer[index + 2] * factor);
|
|
39858
39869
|
}
|
|
39859
|
-
return
|
|
39860
|
-
};
|
|
39861
|
-
/**
|
|
39862
|
-
* @deprecated
|
|
39863
|
-
* Get accessor data.
|
|
39864
|
-
*/ GLTFUtils.getAccessorData = function getAccessorData(glTF, accessor, buffers) {
|
|
39865
|
-
var bufferViews = glTF.bufferViews;
|
|
39866
|
-
var _accessor_bufferView;
|
|
39867
|
-
var bufferView = bufferViews[(_accessor_bufferView = accessor.bufferView) != null ? _accessor_bufferView : 0];
|
|
39868
|
-
var arrayBuffer = buffers[bufferView.buffer];
|
|
39869
|
-
var accessorByteOffset = accessor.hasOwnProperty("byteOffset") ? accessor.byteOffset : 0;
|
|
39870
|
-
var bufferViewByteOffset = bufferView.hasOwnProperty("byteOffset") ? bufferView.byteOffset : 0;
|
|
39871
|
-
var byteOffset = accessorByteOffset + bufferViewByteOffset;
|
|
39872
|
-
var accessorTypeSize = GLTFUtils.getAccessorTypeSize(accessor.type);
|
|
39873
|
-
var length = accessorTypeSize * accessor.count;
|
|
39874
|
-
var _bufferView_byteStride;
|
|
39875
|
-
var byteStride = (_bufferView_byteStride = bufferView.byteStride) != null ? _bufferView_byteStride : 0;
|
|
39876
|
-
var arrayType = GLTFUtils.getComponentType(accessor.componentType);
|
|
39877
|
-
var uint8Array;
|
|
39878
|
-
if (byteStride) {
|
|
39879
|
-
var accessorByteSize = accessorTypeSize * arrayType.BYTES_PER_ELEMENT;
|
|
39880
|
-
uint8Array = new Uint8Array(accessor.count * accessorByteSize);
|
|
39881
|
-
var originalBufferView = new Uint8Array(arrayBuffer, bufferViewByteOffset, bufferView.byteLength);
|
|
39882
|
-
for(var i = 0; i < accessor.count; i++){
|
|
39883
|
-
for(var j = 0; j < accessorByteSize; j++){
|
|
39884
|
-
uint8Array[i * accessorByteSize + j] = originalBufferView[i * byteStride + accessorByteOffset + j];
|
|
39885
|
-
}
|
|
39886
|
-
}
|
|
39887
|
-
} else {
|
|
39888
|
-
uint8Array = new Uint8Array(arrayBuffer.slice(byteOffset, byteOffset + length * arrayType.BYTES_PER_ELEMENT));
|
|
39889
|
-
}
|
|
39890
|
-
var typedArray = new arrayType(uint8Array.buffer);
|
|
39891
|
-
if (accessor.sparse) {
|
|
39892
|
-
var _accessor_sparse = accessor.sparse, count = _accessor_sparse.count, indices = _accessor_sparse.indices, values = _accessor_sparse.values;
|
|
39893
|
-
var indicesBufferView = bufferViews[indices.bufferView];
|
|
39894
|
-
var valuesBufferView = bufferViews[values.bufferView];
|
|
39895
|
-
var indicesArrayBuffer = buffers[indicesBufferView.buffer];
|
|
39896
|
-
var valuesArrayBuffer = buffers[valuesBufferView.buffer];
|
|
39897
|
-
var _indices_byteOffset, _indicesBufferView_byteOffset;
|
|
39898
|
-
var indicesByteOffset = ((_indices_byteOffset = indices.byteOffset) != null ? _indices_byteOffset : 0) + ((_indicesBufferView_byteOffset = indicesBufferView.byteOffset) != null ? _indicesBufferView_byteOffset : 0);
|
|
39899
|
-
var indicesByteLength = indicesBufferView.byteLength;
|
|
39900
|
-
var _values_byteOffset, _valuesBufferView_byteOffset;
|
|
39901
|
-
var valuesByteOffset = ((_values_byteOffset = values.byteOffset) != null ? _values_byteOffset : 0) + ((_valuesBufferView_byteOffset = valuesBufferView.byteOffset) != null ? _valuesBufferView_byteOffset : 0);
|
|
39902
|
-
var valuesByteLength = valuesBufferView.byteLength;
|
|
39903
|
-
var indicesType = GLTFUtils.getComponentType(indices.componentType);
|
|
39904
|
-
var indicesArray = new indicesType(indicesArrayBuffer, indicesByteOffset, indicesByteLength / indicesType.BYTES_PER_ELEMENT);
|
|
39905
|
-
var valuesArray = new arrayType(valuesArrayBuffer, valuesByteOffset, valuesByteLength / arrayType.BYTES_PER_ELEMENT);
|
|
39906
|
-
for(var i1 = 0; i1 < count; i1++){
|
|
39907
|
-
var replaceIndex = indicesArray[i1];
|
|
39908
|
-
for(var j1 = 0; j1 < accessorTypeSize; j1++){
|
|
39909
|
-
typedArray[replaceIndex * accessorTypeSize + j1] = valuesArray[i1 * accessorTypeSize + j1];
|
|
39910
|
-
}
|
|
39911
|
-
}
|
|
39912
|
-
}
|
|
39913
|
-
return typedArray;
|
|
39870
|
+
return vertices;
|
|
39914
39871
|
};
|
|
39915
39872
|
GLTFUtils.getBufferViewData = function getBufferViewData(bufferView, buffers) {
|
|
39916
39873
|
var _bufferView_byteOffset = bufferView.byteOffset, byteOffset = _bufferView_byteOffset === void 0 ? 0 : _bufferView_byteOffset;
|
|
@@ -39919,40 +39876,43 @@
|
|
|
39919
39876
|
};
|
|
39920
39877
|
/**
|
|
39921
39878
|
* Get accessor data.
|
|
39922
|
-
*/ GLTFUtils.processingSparseData = function processingSparseData(
|
|
39879
|
+
*/ GLTFUtils.processingSparseData = function processingSparseData(context, accessor, bufferInfo) {
|
|
39923
39880
|
var restoreInfo = bufferInfo.restoreInfo;
|
|
39881
|
+
var bufferViews = context.glTF.bufferViews;
|
|
39924
39882
|
var accessorTypeSize = GLTFUtils.getAccessorTypeSize(accessor.type);
|
|
39925
39883
|
var TypedArray = GLTFUtils.getComponentType(accessor.componentType);
|
|
39926
39884
|
var data = bufferInfo.data.slice();
|
|
39927
39885
|
var _accessor_sparse = accessor.sparse, count = _accessor_sparse.count, indices = _accessor_sparse.indices, values = _accessor_sparse.values;
|
|
39928
39886
|
var indicesBufferView = bufferViews[indices.bufferView];
|
|
39929
39887
|
var valuesBufferView = bufferViews[values.bufferView];
|
|
39930
|
-
|
|
39931
|
-
|
|
39932
|
-
|
|
39933
|
-
|
|
39934
|
-
|
|
39935
|
-
|
|
39936
|
-
|
|
39937
|
-
|
|
39938
|
-
|
|
39939
|
-
|
|
39940
|
-
|
|
39941
|
-
|
|
39942
|
-
|
|
39943
|
-
|
|
39944
|
-
|
|
39945
|
-
|
|
39946
|
-
|
|
39947
|
-
|
|
39948
|
-
|
|
39949
|
-
|
|
39950
|
-
var
|
|
39951
|
-
|
|
39952
|
-
|
|
39888
|
+
return Promise.all([
|
|
39889
|
+
context.get(exports.GLTFParserType.BufferView, indices.bufferView),
|
|
39890
|
+
context.get(exports.GLTFParserType.BufferView, values.bufferView)
|
|
39891
|
+
]).then(function(param) {
|
|
39892
|
+
var indicesUint8Array = param[0], valuesUin8Array = param[1];
|
|
39893
|
+
var _indices_byteOffset, _indicesUint8Array_byteOffset;
|
|
39894
|
+
var indicesByteOffset = ((_indices_byteOffset = indices.byteOffset) != null ? _indices_byteOffset : 0) + ((_indicesUint8Array_byteOffset = indicesUint8Array.byteOffset) != null ? _indicesUint8Array_byteOffset : 0);
|
|
39895
|
+
var indicesByteLength = indicesUint8Array.byteLength;
|
|
39896
|
+
var _values_byteOffset, _valuesUin8Array_byteOffset;
|
|
39897
|
+
var valuesByteOffset = ((_values_byteOffset = values.byteOffset) != null ? _values_byteOffset : 0) + ((_valuesUin8Array_byteOffset = valuesUin8Array.byteOffset) != null ? _valuesUin8Array_byteOffset : 0);
|
|
39898
|
+
var valuesByteLength = valuesUin8Array.byteLength;
|
|
39899
|
+
restoreInfo.typeSize = accessorTypeSize;
|
|
39900
|
+
restoreInfo.sparseCount = count;
|
|
39901
|
+
var IndexTypeArray = GLTFUtils.getComponentType(indices.componentType);
|
|
39902
|
+
var indexLength = indicesByteLength / IndexTypeArray.BYTES_PER_ELEMENT;
|
|
39903
|
+
var indicesArray = new IndexTypeArray(indicesUint8Array.buffer, indicesByteOffset, indexLength);
|
|
39904
|
+
restoreInfo.sparseIndices = new RestoreDataAccessor(indicesBufferView.buffer, IndexTypeArray, indicesByteOffset, indexLength);
|
|
39905
|
+
var valueLength = valuesByteLength / TypedArray.BYTES_PER_ELEMENT;
|
|
39906
|
+
var valuesArray = new TypedArray(valuesUin8Array.buffer, valuesByteOffset, valueLength);
|
|
39907
|
+
restoreInfo.sparseValues = new RestoreDataAccessor(valuesBufferView.buffer, TypedArray, valuesByteOffset, valueLength);
|
|
39908
|
+
for(var i = 0; i < count; i++){
|
|
39909
|
+
var replaceIndex = indicesArray[i];
|
|
39910
|
+
for(var j = 0; j < accessorTypeSize; j++){
|
|
39911
|
+
data[replaceIndex * accessorTypeSize + j] = valuesArray[i * accessorTypeSize + j];
|
|
39912
|
+
}
|
|
39953
39913
|
}
|
|
39954
|
-
|
|
39955
|
-
|
|
39914
|
+
bufferInfo.data = data;
|
|
39915
|
+
});
|
|
39956
39916
|
};
|
|
39957
39917
|
GLTFUtils.getIndexFormat = function getIndexFormat(type) {
|
|
39958
39918
|
switch(type){
|
|
@@ -41207,16 +41167,16 @@
|
|
|
41207
41167
|
var frame = restoreInfo.blendShape.frames[0];
|
|
41208
41168
|
var position = restoreInfo.position;
|
|
41209
41169
|
var positionData = _this._getBufferData(buffers, position.buffer);
|
|
41210
|
-
frame.deltaPositions = GLTFUtils.bufferToVector3Array(positionData, position.
|
|
41170
|
+
frame.deltaPositions = GLTFUtils.bufferToVector3Array(positionData, position.byteOffset, position.count, position.normalized, position.componentType);
|
|
41211
41171
|
if (restoreInfo.normal) {
|
|
41212
41172
|
var normal = restoreInfo.normal;
|
|
41213
41173
|
var normalData = _this._getBufferData(buffers, normal.buffer);
|
|
41214
|
-
frame.deltaNormals = GLTFUtils.bufferToVector3Array(normalData, normal.
|
|
41174
|
+
frame.deltaNormals = GLTFUtils.bufferToVector3Array(normalData, normal.byteOffset, normal.count, normal.normalized, normal.componentType);
|
|
41215
41175
|
}
|
|
41216
41176
|
if (restoreInfo.tangent) {
|
|
41217
41177
|
var tangent = restoreInfo.tangent;
|
|
41218
41178
|
var tangentData = _this._getBufferData(buffers, tangent.buffer);
|
|
41219
|
-
frame.deltaTangents = GLTFUtils.bufferToVector3Array(tangentData, tangent.
|
|
41179
|
+
frame.deltaTangents = GLTFUtils.bufferToVector3Array(tangentData, tangent.byteOffset, tangent.count, tangent.normalized, tangent.componentType);
|
|
41220
41180
|
}
|
|
41221
41181
|
}
|
|
41222
41182
|
mesh.uploadData(true);
|
|
@@ -41228,8 +41188,13 @@
|
|
|
41228
41188
|
};
|
|
41229
41189
|
_proto._getBufferData = function _getBufferData(buffers, restoreInfo) {
|
|
41230
41190
|
var main = restoreInfo.main;
|
|
41231
|
-
var
|
|
41232
|
-
|
|
41191
|
+
var data;
|
|
41192
|
+
if (main) {
|
|
41193
|
+
var buffer = buffers[main.bufferIndex];
|
|
41194
|
+
data = new main.TypedArray(buffer, main.byteOffset, main.length);
|
|
41195
|
+
} else {
|
|
41196
|
+
data = new main.TypedArray(main.length);
|
|
41197
|
+
}
|
|
41233
41198
|
var sparseCount = restoreInfo.sparseCount;
|
|
41234
41199
|
if (sparseCount) {
|
|
41235
41200
|
var sparseIndex = restoreInfo.sparseIndices;
|
|
@@ -41302,11 +41267,12 @@
|
|
|
41302
41267
|
};
|
|
41303
41268
|
/**
|
|
41304
41269
|
* @internal
|
|
41305
|
-
*/ var BlendShapeDataRestoreInfo = function BlendShapeDataRestoreInfo(buffer,
|
|
41270
|
+
*/ var BlendShapeDataRestoreInfo = function BlendShapeDataRestoreInfo(buffer, byteOffset, count, normalized, componentType) {
|
|
41306
41271
|
this.buffer = buffer;
|
|
41307
|
-
this.stride = stride;
|
|
41308
41272
|
this.byteOffset = byteOffset;
|
|
41309
41273
|
this.count = count;
|
|
41274
|
+
this.normalized = normalized;
|
|
41275
|
+
this.componentType = componentType;
|
|
41310
41276
|
};
|
|
41311
41277
|
/**
|
|
41312
41278
|
* Base class of glTF extension parser.
|
|
@@ -41893,7 +41859,7 @@
|
|
|
41893
41859
|
resolve(mesh);
|
|
41894
41860
|
} else {
|
|
41895
41861
|
mesh.then(function(mesh) {
|
|
41896
|
-
|
|
41862
|
+
resolve(mesh);
|
|
41897
41863
|
});
|
|
41898
41864
|
}
|
|
41899
41865
|
} else {
|
|
@@ -41901,35 +41867,20 @@
|
|
|
41901
41867
|
var meshRestoreInfo = new ModelMeshRestoreInfo();
|
|
41902
41868
|
meshRestoreInfo.mesh = mesh1;
|
|
41903
41869
|
context.contentRestorer.meshes.push(meshRestoreInfo);
|
|
41904
|
-
exports.GLTFMeshParser._parseMeshFromGLTFPrimitive(context, mesh1, meshRestoreInfo, meshInfo, gltfPrimitive, glTF,
|
|
41905
|
-
return null;
|
|
41906
|
-
}, function(attributeName, shapeIndex) {
|
|
41907
|
-
var shapeAccessorIdx = gltfPrimitive.targets[shapeIndex];
|
|
41908
|
-
var attributeAccessorIdx = shapeAccessorIdx[attributeName];
|
|
41909
|
-
if (attributeAccessorIdx) {
|
|
41910
|
-
var accessor = glTF.accessors[attributeAccessorIdx];
|
|
41911
|
-
return GLTFUtils.getAccessorBuffer(context, context.glTF.bufferViews, accessor);
|
|
41912
|
-
} else {
|
|
41913
|
-
return null;
|
|
41914
|
-
}
|
|
41915
|
-
}, function() {
|
|
41916
|
-
var indexAccessor = glTF.accessors[gltfPrimitive.indices];
|
|
41917
|
-
return context.get(exports.GLTFParserType.Buffer).then(function(buffers) {
|
|
41918
|
-
return GLTFUtils.getAccessorData(glTF, indexAccessor, buffers);
|
|
41919
|
-
});
|
|
41920
|
-
}, context.params.keepMeshData).then(resolve);
|
|
41870
|
+
exports.GLTFMeshParser._parseMeshFromGLTFPrimitive(context, mesh1, meshRestoreInfo, meshInfo, gltfPrimitive, glTF, context.params.keepMeshData).then(resolve);
|
|
41921
41871
|
}
|
|
41922
41872
|
});
|
|
41923
41873
|
};
|
|
41924
41874
|
var meshInfo = context.glTF.meshes[index];
|
|
41925
|
-
var glTF = context.glTF,
|
|
41875
|
+
var glTF = context.glTF, glTFResource = context.glTFResource;
|
|
41876
|
+
var engine = glTFResource.engine;
|
|
41926
41877
|
var primitivePromises = new Array();
|
|
41927
41878
|
for(var i = 0, length = meshInfo.primitives.length; i < length; i++)_loop(i);
|
|
41928
41879
|
return Promise.all(primitivePromises);
|
|
41929
41880
|
};
|
|
41930
41881
|
/**
|
|
41931
41882
|
* @internal
|
|
41932
|
-
*/ GLTFMeshParser1._parseMeshFromGLTFPrimitive = function _parseMeshFromGLTFPrimitive(context, mesh, meshRestoreInfo, gltfMesh, gltfPrimitive, gltf,
|
|
41883
|
+
*/ GLTFMeshParser1._parseMeshFromGLTFPrimitive = function _parseMeshFromGLTFPrimitive(context, mesh, meshRestoreInfo, gltfMesh, gltfPrimitive, gltf, keepMeshData) {
|
|
41933
41884
|
var _loop = function _loop(attribute) {
|
|
41934
41885
|
var accessor = accessors[attributes[attribute]];
|
|
41935
41886
|
var promise = GLTFUtils.getAccessorBuffer(context, gltf.bufferViews, accessor).then(function(accessorBuffer) {
|
|
@@ -42000,6 +41951,7 @@
|
|
|
42000
41951
|
});
|
|
42001
41952
|
promises.push(promise);
|
|
42002
41953
|
};
|
|
41954
|
+
var _this = this;
|
|
42003
41955
|
var accessors = gltf.accessors;
|
|
42004
41956
|
var attributes = gltfPrimitive.attributes, targets = gltfPrimitive.targets, indices = gltfPrimitive.indices, mode = gltfPrimitive.mode;
|
|
42005
41957
|
var engine = mesh.engine;
|
|
@@ -42024,61 +41976,68 @@
|
|
|
42024
41976
|
}
|
|
42025
41977
|
// BlendShapes
|
|
42026
41978
|
if (targets) {
|
|
42027
|
-
promises.push(exports.GLTFMeshParser._createBlendShape(mesh, meshRestoreInfo, gltfMesh,
|
|
41979
|
+
promises.push(exports.GLTFMeshParser._createBlendShape(context, mesh, meshRestoreInfo, gltfMesh, gltfPrimitive, targets, _this._getBlendShapeData));
|
|
42028
41980
|
}
|
|
42029
41981
|
return Promise.all(promises).then(function() {
|
|
42030
41982
|
mesh.uploadData(!keepMeshData);
|
|
42031
|
-
return
|
|
41983
|
+
return mesh;
|
|
42032
41984
|
});
|
|
42033
41985
|
});
|
|
42034
41986
|
};
|
|
41987
|
+
GLTFMeshParser1._getBlendShapeData = function _getBlendShapeData(context, glTF, accessor) {
|
|
41988
|
+
return GLTFUtils.getAccessorBuffer(context, glTF.bufferViews, accessor).then(function(bufferInfo) {
|
|
41989
|
+
var buffer = bufferInfo.data;
|
|
41990
|
+
var _accessor_byteOffset;
|
|
41991
|
+
var byteOffset = bufferInfo.interleaved ? ((_accessor_byteOffset = accessor.byteOffset) != null ? _accessor_byteOffset : 0) % bufferInfo.stride : 0;
|
|
41992
|
+
var count = accessor.count, normalized = accessor.normalized, componentType = accessor.componentType;
|
|
41993
|
+
var vertices = GLTFUtils.bufferToVector3Array(buffer, byteOffset, count, normalized, componentType);
|
|
41994
|
+
var restoreInfo = new BlendShapeDataRestoreInfo(bufferInfo.restoreInfo, byteOffset, count, normalized, componentType);
|
|
41995
|
+
return {
|
|
41996
|
+
vertices: vertices,
|
|
41997
|
+
restoreInfo: restoreInfo
|
|
41998
|
+
};
|
|
41999
|
+
});
|
|
42000
|
+
};
|
|
42035
42001
|
/**
|
|
42036
42002
|
* @internal
|
|
42037
|
-
*/ GLTFMeshParser1._createBlendShape = function _createBlendShape(mesh, meshRestoreInfo, glTFMesh,
|
|
42038
|
-
var _loop = function _loop(i
|
|
42003
|
+
*/ GLTFMeshParser1._createBlendShape = function _createBlendShape(context, mesh, meshRestoreInfo, glTFMesh, gltfPrimitive, glTFTargets, getBlendShapeData) {
|
|
42004
|
+
var _loop = function _loop(i) {
|
|
42005
|
+
var blendShapeData = {};
|
|
42006
|
+
blendShapeCollection[i] = blendShapeData;
|
|
42039
42007
|
var name = blendShapeNames ? blendShapeNames[i] : "blendShape" + i;
|
|
42008
|
+
var targets = gltfPrimitive.targets[i];
|
|
42009
|
+
var normalTarget = targets["NORMAL"];
|
|
42010
|
+
var tangentTarget = targets["TANGENT"];
|
|
42011
|
+
var hasNormal = normalTarget !== undefined;
|
|
42012
|
+
var hasTangent = tangentTarget !== undefined;
|
|
42040
42013
|
var promise = Promise.all([
|
|
42041
|
-
getBlendShapeData("POSITION"
|
|
42042
|
-
getBlendShapeData(
|
|
42043
|
-
getBlendShapeData(
|
|
42044
|
-
]).then(function(
|
|
42045
|
-
var
|
|
42046
|
-
var
|
|
42047
|
-
var tanBufferInfo = infos[2];
|
|
42048
|
-
var target = glTFTargets[i];
|
|
42049
|
-
var posAccessor;
|
|
42050
|
-
var norAccessor;
|
|
42051
|
-
var tanAccessor;
|
|
42052
|
-
var positions = null;
|
|
42053
|
-
if (posBufferInfo) {
|
|
42054
|
-
posAccessor = accessors[target["POSITION"]];
|
|
42055
|
-
var _posAccessor_byteOffset;
|
|
42056
|
-
positions = GLTFUtils.bufferToVector3Array(posBufferInfo.data, posBufferInfo.stride, (_posAccessor_byteOffset = posAccessor.byteOffset) != null ? _posAccessor_byteOffset : 0, posAccessor.count);
|
|
42057
|
-
}
|
|
42058
|
-
var normals = null;
|
|
42059
|
-
if (norBufferInfo) {
|
|
42060
|
-
norAccessor = accessors[target["NORMAL"]];
|
|
42061
|
-
var _norAccessor_byteOffset;
|
|
42062
|
-
normals = GLTFUtils.bufferToVector3Array(norBufferInfo.data, norBufferInfo.stride, (_norAccessor_byteOffset = norAccessor.byteOffset) != null ? _norAccessor_byteOffset : 0, norAccessor.count);
|
|
42063
|
-
}
|
|
42064
|
-
var tangents = null;
|
|
42065
|
-
if (tanBufferInfo) {
|
|
42066
|
-
tanAccessor = accessors[target["NORMAL"]];
|
|
42067
|
-
var _tanAccessor_byteOffset;
|
|
42068
|
-
tangents = GLTFUtils.bufferToVector3Array(tanBufferInfo.data, tanBufferInfo.stride, (_tanAccessor_byteOffset = tanAccessor.byteOffset) != null ? _tanAccessor_byteOffset : 0, tanAccessor.count);
|
|
42069
|
-
}
|
|
42014
|
+
getBlendShapeData(context, glTF, accessors[targets["POSITION"]]),
|
|
42015
|
+
hasNormal ? getBlendShapeData(context, glTF, accessors[normalTarget]) : null,
|
|
42016
|
+
hasTangent ? getBlendShapeData(context, glTF, accessors[tangentTarget]) : null
|
|
42017
|
+
]).then(function(vertices) {
|
|
42018
|
+
var _tangentData;
|
|
42019
|
+
var positionData = vertices[0], normalData = vertices[1], tangentData = vertices[2];
|
|
42070
42020
|
var blendShape = new BlendShape(name);
|
|
42071
|
-
blendShape.addFrame(1.0,
|
|
42072
|
-
|
|
42073
|
-
|
|
42074
|
-
meshRestoreInfo.blendShapes.push(new BlendShapeRestoreInfo(blendShape, new BlendShapeDataRestoreInfo(posBufferInfo.restoreInfo, posBufferInfo.stride, (_posAccessor_byteOffset1 = posAccessor.byteOffset) != null ? _posAccessor_byteOffset1 : 0, posAccessor.count), norBufferInfo ? new BlendShapeDataRestoreInfo(norBufferInfo.restoreInfo, norBufferInfo.stride, (_norAccessor_byteOffset1 = norAccessor.byteOffset) != null ? _norAccessor_byteOffset1 : 0, norAccessor.count) : null, tanBufferInfo ? new BlendShapeDataRestoreInfo(tanBufferInfo.restoreInfo, tanBufferInfo.stride, (_tanAccessor_byteOffset1 = tanAccessor.byteOffset) != null ? _tanAccessor_byteOffset1 : 0, tanAccessor.count) : null));
|
|
42021
|
+
blendShape.addFrame(1.0, positionData.vertices, hasNormal ? normalData.vertices : null, hasTangent ? tangentData.vertices : null);
|
|
42022
|
+
blendShapeData.blendShape = blendShape;
|
|
42023
|
+
blendShapeData.restoreInfo = new BlendShapeRestoreInfo(blendShape, positionData.restoreInfo, hasNormal ? normalData.restoreInfo : null, hasTangent ? (_tangentData = tangentData) == null ? void 0 : _tangentData.restoreInfo : null);
|
|
42075
42024
|
});
|
|
42076
42025
|
promises.push(promise);
|
|
42077
42026
|
};
|
|
42027
|
+
var glTF = context.glTF;
|
|
42028
|
+
var accessors = glTF.accessors;
|
|
42078
42029
|
var blendShapeNames = glTFMesh.extras ? glTFMesh.extras.targetNames : null;
|
|
42079
42030
|
var promises = new Array();
|
|
42080
|
-
|
|
42081
|
-
|
|
42031
|
+
var blendShapeCount = glTFTargets.length;
|
|
42032
|
+
var blendShapeCollection = new Array(blendShapeCount);
|
|
42033
|
+
for(var i = 0; i < blendShapeCount; i++)_loop(i);
|
|
42034
|
+
return Promise.all(promises).then(function() {
|
|
42035
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(blendShapeCollection), _step; !(_step = _iterator()).done;){
|
|
42036
|
+
var blendShape = _step.value;
|
|
42037
|
+
mesh.addBlendShape(blendShape.blendShape);
|
|
42038
|
+
meshRestoreInfo.blendShapes.push(blendShape.restoreInfo);
|
|
42039
|
+
}
|
|
42040
|
+
});
|
|
42082
42041
|
};
|
|
42083
42042
|
return GLTFMeshParser1;
|
|
42084
42043
|
}(GLTFParser), function() {
|
|
@@ -42454,6 +42413,24 @@
|
|
|
42454
42413
|
exports.GLTFValidator = __decorate([
|
|
42455
42414
|
registerGLTFParser(exports.GLTFParserType.Validator)
|
|
42456
42415
|
], exports.GLTFValidator);
|
|
42416
|
+
exports.GLTFBufferViewParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
42417
|
+
var GLTFBufferViewParser = function GLTFBufferViewParser() {
|
|
42418
|
+
return GLTFParser1.apply(this, arguments);
|
|
42419
|
+
};
|
|
42420
|
+
_inherits(GLTFBufferViewParser, GLTFParser1);
|
|
42421
|
+
var _proto = GLTFBufferViewParser.prototype;
|
|
42422
|
+
_proto.parse = function parse(context, index) {
|
|
42423
|
+
var bufferView = context.glTF.bufferViews[index];
|
|
42424
|
+
var extensions = bufferView.extensions, _bufferView_byteOffset = bufferView.byteOffset, byteOffset = _bufferView_byteOffset === void 0 ? 0 : _bufferView_byteOffset, byteLength = bufferView.byteLength, bufferIndex = bufferView.buffer;
|
|
42425
|
+
return extensions ? GLTFParser.executeExtensionsCreateAndParse(extensions, context, bufferView) : context.get(exports.GLTFParserType.Buffer, bufferIndex).then(function(buffer) {
|
|
42426
|
+
return new Uint8Array(buffer, byteOffset, byteLength);
|
|
42427
|
+
});
|
|
42428
|
+
};
|
|
42429
|
+
return GLTFBufferViewParser;
|
|
42430
|
+
}(GLTFParser);
|
|
42431
|
+
exports.GLTFBufferViewParser = __decorate([
|
|
42432
|
+
registerGLTFParser(exports.GLTFParserType.BufferView)
|
|
42433
|
+
], exports.GLTFBufferViewParser);
|
|
42457
42434
|
var GLTFLoader = /*#__PURE__*/ function(Loader1) {
|
|
42458
42435
|
var GLTFLoader = function GLTFLoader() {
|
|
42459
42436
|
return Loader1.apply(this, arguments);
|
|
@@ -43680,14 +43657,17 @@
|
|
|
43680
43657
|
var buffer = GLTFUtils.getBufferViewData(bufferViews[bufferViewIndex], buffers);
|
|
43681
43658
|
return KHR_draco_mesh_compression._decoder.decode(buffer, taskConfig).then(function(decodedGeometry) {
|
|
43682
43659
|
var mesh = new ModelMesh(engine, glTFMesh.name);
|
|
43683
|
-
|
|
43660
|
+
var meshRestoreInfo = new ModelMeshRestoreInfo();
|
|
43661
|
+
meshRestoreInfo.mesh = mesh;
|
|
43662
|
+
context.contentRestorer.meshes.push(meshRestoreInfo);
|
|
43663
|
+
return _this._parseMeshFromGLTFPrimitiveDraco(context, mesh, meshRestoreInfo, glTFMesh, glTFPrimitive, glTF, function(attributeSemantic) {
|
|
43684
43664
|
for(var j = 0; j < decodedGeometry.attributes.length; j++){
|
|
43685
43665
|
if (decodedGeometry.attributes[j].name === attributeSemantic) {
|
|
43686
43666
|
return decodedGeometry.attributes[j].array;
|
|
43687
43667
|
}
|
|
43688
43668
|
}
|
|
43689
43669
|
return null;
|
|
43690
|
-
}, function(
|
|
43670
|
+
}, function() {
|
|
43691
43671
|
throw "BlendShape animation is not supported when using draco.";
|
|
43692
43672
|
}, function() {
|
|
43693
43673
|
return decodedGeometry.index.array;
|
|
@@ -43700,7 +43680,7 @@
|
|
|
43700
43680
|
KHR_draco_mesh_compression._decoder = new DRACODecoder();
|
|
43701
43681
|
}
|
|
43702
43682
|
};
|
|
43703
|
-
_proto._parseMeshFromGLTFPrimitiveDraco = function _parseMeshFromGLTFPrimitiveDraco(mesh, gltfMesh, gltfPrimitive, gltf, getVertexBufferData, getBlendShapeData, getIndexBufferData, keepMeshData) {
|
|
43683
|
+
_proto._parseMeshFromGLTFPrimitiveDraco = function _parseMeshFromGLTFPrimitiveDraco(context, mesh, meshRestoreInfo, gltfMesh, gltfPrimitive, gltf, getVertexBufferData, getBlendShapeData, getIndexBufferData, keepMeshData) {
|
|
43704
43684
|
var attributes = gltfPrimitive.attributes, targets = gltfPrimitive.targets, indices = gltfPrimitive.indices, mode = gltfPrimitive.mode;
|
|
43705
43685
|
var vertexCount;
|
|
43706
43686
|
var accessors = gltf.accessors;
|
|
@@ -43796,7 +43776,7 @@
|
|
|
43796
43776
|
mesh.addSubMesh(0, vertexCount, mode);
|
|
43797
43777
|
}
|
|
43798
43778
|
// BlendShapes
|
|
43799
|
-
targets && exports.GLTFMeshParser._createBlendShape(mesh,
|
|
43779
|
+
targets && exports.GLTFMeshParser._createBlendShape(context, mesh, meshRestoreInfo, gltfMesh, gltfPrimitive, targets, getBlendShapeData);
|
|
43800
43780
|
mesh.uploadData(!keepMeshData);
|
|
43801
43781
|
return Promise.resolve(mesh);
|
|
43802
43782
|
};
|
|
@@ -44126,7 +44106,7 @@
|
|
|
44126
44106
|
], GALACEAN_animation_event);
|
|
44127
44107
|
|
|
44128
44108
|
//@ts-ignore
|
|
44129
|
-
var version = "1.1.
|
|
44109
|
+
var version = "1.1.3";
|
|
44130
44110
|
console.log("Galacean engine version: " + version);
|
|
44131
44111
|
for(var key in CoreObjects){
|
|
44132
44112
|
Loader.registerClass(key, CoreObjects[key]);
|
|
@@ -44159,6 +44139,7 @@
|
|
|
44159
44139
|
exports.BoxColliderShape = BoxColliderShape;
|
|
44160
44140
|
exports.BoxShape = BoxShape;
|
|
44161
44141
|
exports.Buffer = Buffer;
|
|
44142
|
+
exports.BufferInfo = BufferInfo;
|
|
44162
44143
|
exports.BufferMesh = BufferMesh;
|
|
44163
44144
|
exports.BufferUtil = BufferUtil;
|
|
44164
44145
|
exports.Burst = Burst;
|