@galacean/engine 1.2.0-beta.3 → 1.2.0-beta.4
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/LICENSE +2 -2
- package/dist/browser.js +88 -51
- package/dist/browser.js.map +1 -1
- package/dist/browser.min.js +1 -1
- package/dist/browser.min.js.map +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/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License
|
|
2
2
|
|
|
3
|
-
Copyright
|
|
3
|
+
Copyright (c) 2020 - present Ant Group
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
THE SOFTWARE.
|
|
21
|
+
THE SOFTWARE.
|
package/dist/browser.js
CHANGED
|
@@ -9794,7 +9794,8 @@
|
|
|
9794
9794
|
}
|
|
9795
9795
|
var shaderInfo = Shader._shaderLab.parseShader(nameOrShaderSource);
|
|
9796
9796
|
if (shaderMap[shaderInfo.name]) {
|
|
9797
|
-
|
|
9797
|
+
console.error('Shader named "' + shaderInfo.name + '" already exists.');
|
|
9798
|
+
return;
|
|
9798
9799
|
}
|
|
9799
9800
|
var subShaderList = shaderInfo.subShaders.map(function(subShaderInfo) {
|
|
9800
9801
|
var passList = subShaderInfo.passes.map(function(passInfo) {
|
|
@@ -9833,7 +9834,8 @@
|
|
|
9833
9834
|
return shader;
|
|
9834
9835
|
} else {
|
|
9835
9836
|
if (shaderMap[nameOrShaderSource]) {
|
|
9836
|
-
|
|
9837
|
+
console.error('Shader named "' + nameOrShaderSource + '" already exists.');
|
|
9838
|
+
return;
|
|
9837
9839
|
}
|
|
9838
9840
|
if (typeof vertexSourceOrShaderPassesOrSubShaders === "string") {
|
|
9839
9841
|
var shaderPass = new ShaderPass(vertexSourceOrShaderPassesOrSubShaders, fragmentSource);
|
|
@@ -26802,9 +26804,10 @@
|
|
|
26802
26804
|
*/ _proto._updateShaderData = function _updateShaderData(shaderData) {
|
|
26803
26805
|
var _this = this, spotLight = _this._spotLights, pointLight = _this._pointLights, directLight = _this._directLights;
|
|
26804
26806
|
var _this1 = this, spotData = _this1._spotData, pointData = _this1._pointData, directData = _this1._directData;
|
|
26805
|
-
var
|
|
26806
|
-
var
|
|
26807
|
-
var
|
|
26807
|
+
var maxLight = LightManager._maxLight;
|
|
26808
|
+
var spotLightCount = Math.min(spotLight.length, maxLight);
|
|
26809
|
+
var pointLightCount = Math.min(pointLight.length, maxLight);
|
|
26810
|
+
var directLightCount = Math.min(directLight.length, maxLight);
|
|
26808
26811
|
for(var i = 0; i < spotLightCount; i++){
|
|
26809
26812
|
spotLight.get(i)._appendData(i, spotData);
|
|
26810
26813
|
}
|
|
@@ -31852,20 +31855,19 @@
|
|
|
31852
31855
|
var relativePath = curve.relativePath;
|
|
31853
31856
|
var targetEntity = curve.relativePath === "" ? entity : entity.findByPath(curve.relativePath);
|
|
31854
31857
|
if (targetEntity) {
|
|
31855
|
-
var _curveOwnerPool, _instanceId, _propertyOwners, _property, _layerCurveOwnerPool, _instanceId1, _layerPropertyOwners,
|
|
31856
|
-
var propertyPath = "" + curve.typeIndex + "." + curve.property;
|
|
31858
|
+
var _curveOwnerPool, _instanceId, _propertyOwners, _property, _layerCurveOwnerPool, _instanceId1, _layerPropertyOwners, _property1;
|
|
31857
31859
|
var component = curve.typeIndex > 0 ? targetEntity.getComponents(curve.type, AnimationCurveOwner._components)[curve.typeIndex] : targetEntity.getComponent(curve.type);
|
|
31858
31860
|
if (!component) {
|
|
31859
31861
|
continue;
|
|
31860
31862
|
}
|
|
31861
31863
|
var property = curve.property;
|
|
31862
|
-
var instanceId =
|
|
31864
|
+
var instanceId = component.instanceId;
|
|
31863
31865
|
// Get owner
|
|
31864
31866
|
var propertyOwners = (_curveOwnerPool = curveOwnerPool)[_instanceId = instanceId] || (_curveOwnerPool[_instanceId] = Object.create(null));
|
|
31865
31867
|
var owner = (_propertyOwners = propertyOwners)[_property = property] || (_propertyOwners[_property] = curve._createCurveOwner(targetEntity, component));
|
|
31866
31868
|
// Get layer owner
|
|
31867
31869
|
var layerPropertyOwners = (_layerCurveOwnerPool = layerCurveOwnerPool)[_instanceId1 = instanceId] || (_layerCurveOwnerPool[_instanceId1] = Object.create(null));
|
|
31868
|
-
var layerOwner = (_layerPropertyOwners = layerPropertyOwners)[
|
|
31870
|
+
var layerOwner = (_layerPropertyOwners = layerPropertyOwners)[_property1 = property] || (_layerPropertyOwners[_property1] = curve._createCurveLayerOwner(owner));
|
|
31869
31871
|
if (mask && mask.pathMasks.length) {
|
|
31870
31872
|
var _mask_getPathMask;
|
|
31871
31873
|
var _mask_getPathMask_active;
|
|
@@ -40212,6 +40214,7 @@
|
|
|
40212
40214
|
this.resourceManager = resourceManager;
|
|
40213
40215
|
this.params = params;
|
|
40214
40216
|
this.accessorBufferCache = {};
|
|
40217
|
+
this.needAnimatorController = false;
|
|
40215
40218
|
this._resourceCache = new Map();
|
|
40216
40219
|
this._progress = {
|
|
40217
40220
|
taskDetail: {},
|
|
@@ -40239,16 +40242,15 @@
|
|
|
40239
40242
|
return Promise.resolve(null);
|
|
40240
40243
|
}
|
|
40241
40244
|
var cache = this._resourceCache;
|
|
40242
|
-
var
|
|
40243
|
-
var cacheKey = isOnlyOne || index === undefined ? "" + type : type + ":" + index;
|
|
40245
|
+
var cacheKey = index === undefined ? "" + type : type + ":" + index;
|
|
40244
40246
|
var resource = cache.get(cacheKey);
|
|
40245
40247
|
if (resource) {
|
|
40246
40248
|
return resource;
|
|
40247
40249
|
}
|
|
40248
|
-
|
|
40249
|
-
|
|
40250
|
-
|
|
40251
|
-
var glTFItems = this.glTF[
|
|
40250
|
+
var glTFSchemaKey = glTFSchemaMap[type];
|
|
40251
|
+
var isSubAsset = !!glTFResourceMap[type];
|
|
40252
|
+
if (glTFSchemaKey) {
|
|
40253
|
+
var glTFItems = this.glTF[glTFSchemaKey];
|
|
40252
40254
|
if (glTFItems && (index === undefined || glTFItems[index])) {
|
|
40253
40255
|
if (index === undefined) {
|
|
40254
40256
|
resource = type === 8 ? glTFItems.map(function(_, index) {
|
|
@@ -40258,11 +40260,14 @@
|
|
|
40258
40260
|
}));
|
|
40259
40261
|
} else {
|
|
40260
40262
|
resource = parser.parse(this, index);
|
|
40261
|
-
this._handleSubAsset(resource, type, index);
|
|
40263
|
+
isSubAsset && this._handleSubAsset(resource, type, index);
|
|
40262
40264
|
}
|
|
40263
40265
|
} else {
|
|
40264
40266
|
resource = Promise.resolve(null);
|
|
40265
40267
|
}
|
|
40268
|
+
} else {
|
|
40269
|
+
resource = parser.parse(this, index);
|
|
40270
|
+
isSubAsset && this._handleSubAsset(resource, type, index);
|
|
40266
40271
|
}
|
|
40267
40272
|
cache.set(cacheKey, resource);
|
|
40268
40273
|
return resource;
|
|
@@ -40271,6 +40276,7 @@
|
|
|
40271
40276
|
var _this = this;
|
|
40272
40277
|
var promise = this.get(0).then(function(json) {
|
|
40273
40278
|
_this.glTF = json;
|
|
40279
|
+
_this.needAnimatorController = !!(json.skins || json.animations);
|
|
40274
40280
|
return Promise.all([
|
|
40275
40281
|
_this.get(1),
|
|
40276
40282
|
_this.get(5),
|
|
@@ -40278,11 +40284,14 @@
|
|
|
40278
40284
|
_this.get(7),
|
|
40279
40285
|
_this.get(9),
|
|
40280
40286
|
_this.get(10),
|
|
40287
|
+
_this.get(11),
|
|
40281
40288
|
_this.get(2)
|
|
40282
40289
|
]).then(function() {
|
|
40283
40290
|
var glTFResource = _this.glTFResource;
|
|
40284
|
-
|
|
40285
|
-
|
|
40291
|
+
var animatorController = glTFResource.animatorController;
|
|
40292
|
+
if (animatorController) {
|
|
40293
|
+
var animator = glTFResource._defaultSceneRoot.addComponent(Animator);
|
|
40294
|
+
animator.animatorController = animatorController;
|
|
40286
40295
|
}
|
|
40287
40296
|
_this.resourceManager.addContentRestorer(_this.contentRestorer);
|
|
40288
40297
|
return glTFResource;
|
|
@@ -40301,40 +40310,21 @@
|
|
|
40301
40310
|
_this._setTaskCompleteProgress(++task.loaded, task.total);
|
|
40302
40311
|
});
|
|
40303
40312
|
};
|
|
40304
|
-
_proto._createAnimator = function _createAnimator(context, animations) {
|
|
40305
|
-
var defaultSceneRoot = context.glTFResource.defaultSceneRoot;
|
|
40306
|
-
var animator = defaultSceneRoot.addComponent(Animator);
|
|
40307
|
-
var animatorController = new AnimatorController();
|
|
40308
|
-
var layer = new AnimatorControllerLayer("layer");
|
|
40309
|
-
var animatorStateMachine = new AnimatorStateMachine();
|
|
40310
|
-
animatorController.addLayer(layer);
|
|
40311
|
-
animator.animatorController = animatorController;
|
|
40312
|
-
layer.stateMachine = animatorStateMachine;
|
|
40313
|
-
if (animations) {
|
|
40314
|
-
for(var i = 0; i < animations.length; i++){
|
|
40315
|
-
var animationClip = animations[i];
|
|
40316
|
-
var name = animationClip.name;
|
|
40317
|
-
var uniqueName = animatorStateMachine.makeUniqueStateName(name);
|
|
40318
|
-
if (uniqueName !== name) {
|
|
40319
|
-
console.warn("AnimatorState name is existed, name: " + name + " reset to " + uniqueName);
|
|
40320
|
-
}
|
|
40321
|
-
var animatorState = animatorStateMachine.addState(uniqueName);
|
|
40322
|
-
animatorState.clip = animationClip;
|
|
40323
|
-
}
|
|
40324
|
-
}
|
|
40325
|
-
};
|
|
40326
40313
|
_proto._handleSubAsset = function _handleSubAsset(resource, type, index) {
|
|
40327
40314
|
var _this = this;
|
|
40328
40315
|
var glTFResourceKey = glTFResourceMap[type];
|
|
40329
|
-
if (!glTFResourceKey) return;
|
|
40330
40316
|
if (type === 8) {
|
|
40331
40317
|
var _this_glTFResource, _glTFResourceKey;
|
|
40332
40318
|
((_this_glTFResource = this.glTFResource)[_glTFResourceKey = glTFResourceKey] || (_this_glTFResource[_glTFResourceKey] = []))[index] = resource;
|
|
40333
40319
|
} else {
|
|
40334
40320
|
var url = this.glTFResource.url;
|
|
40335
40321
|
resource.then(function(item) {
|
|
40336
|
-
|
|
40337
|
-
|
|
40322
|
+
if (index == undefined) {
|
|
40323
|
+
_this.glTFResource[glTFResourceKey] = item;
|
|
40324
|
+
} else {
|
|
40325
|
+
var _this_glTFResource, _glTFResourceKey;
|
|
40326
|
+
((_this_glTFResource = _this.glTFResource)[_glTFResourceKey = glTFResourceKey] || (_this_glTFResource[_glTFResourceKey] = []))[index] = item;
|
|
40327
|
+
}
|
|
40338
40328
|
if (type === 7) {
|
|
40339
40329
|
for(var i = 0, length = item.length; i < length; i++){
|
|
40340
40330
|
var mesh = item[i];
|
|
@@ -40382,11 +40372,12 @@
|
|
|
40382
40372
|
GLTFParserType[GLTFParserType["Entity"] = 8] = "Entity";
|
|
40383
40373
|
GLTFParserType[GLTFParserType["Skin"] = 9] = "Skin";
|
|
40384
40374
|
GLTFParserType[GLTFParserType["Animation"] = 10] = "Animation";
|
|
40375
|
+
GLTFParserType[GLTFParserType["AnimatorController"] = 11] = "AnimatorController";
|
|
40385
40376
|
})(exports.GLTFParserType || (exports.GLTFParserType = {}));
|
|
40386
40377
|
var _obj;
|
|
40387
40378
|
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);
|
|
40388
40379
|
var _obj1;
|
|
40389
|
-
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);
|
|
40380
|
+
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[11] = "animatorController", _obj1);
|
|
40390
40381
|
function registerGLTFParser(pipeline) {
|
|
40391
40382
|
return function(Parser) {
|
|
40392
40383
|
var parser = new Parser();
|
|
@@ -43139,6 +43130,47 @@
|
|
|
43139
43130
|
exports.GLTFBufferViewParser = __decorate([
|
|
43140
43131
|
registerGLTFParser(exports.GLTFParserType.BufferView)
|
|
43141
43132
|
], exports.GLTFBufferViewParser);
|
|
43133
|
+
exports.GLTFAnimatorControllerParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
43134
|
+
var GLTFAnimatorControllerParser = function GLTFAnimatorControllerParser() {
|
|
43135
|
+
return GLTFParser1.apply(this, arguments);
|
|
43136
|
+
};
|
|
43137
|
+
_inherits(GLTFAnimatorControllerParser, GLTFParser1);
|
|
43138
|
+
var _proto = GLTFAnimatorControllerParser.prototype;
|
|
43139
|
+
_proto.parse = function parse(context) {
|
|
43140
|
+
var _this = this;
|
|
43141
|
+
if (!context.needAnimatorController) {
|
|
43142
|
+
return Promise.resolve(null);
|
|
43143
|
+
}
|
|
43144
|
+
return context.get(exports.GLTFParserType.Animation).then(function(animations) {
|
|
43145
|
+
var animatorController = _this._createAnimatorController(animations);
|
|
43146
|
+
return Promise.resolve(animatorController);
|
|
43147
|
+
});
|
|
43148
|
+
};
|
|
43149
|
+
_proto._createAnimatorController = function _createAnimatorController(animations) {
|
|
43150
|
+
var animatorController = new AnimatorController();
|
|
43151
|
+
var layer = new AnimatorControllerLayer("layer");
|
|
43152
|
+
var animatorStateMachine = new AnimatorStateMachine();
|
|
43153
|
+
animatorController.addLayer(layer);
|
|
43154
|
+
layer.stateMachine = animatorStateMachine;
|
|
43155
|
+
if (animations) {
|
|
43156
|
+
for(var i = 0; i < animations.length; i++){
|
|
43157
|
+
var animationClip = animations[i];
|
|
43158
|
+
var name = animationClip.name;
|
|
43159
|
+
var uniqueName = animatorStateMachine.makeUniqueStateName(name);
|
|
43160
|
+
if (uniqueName !== name) {
|
|
43161
|
+
console.warn("AnimatorState name is existed, name: " + name + " reset to " + uniqueName);
|
|
43162
|
+
}
|
|
43163
|
+
var animatorState = animatorStateMachine.addState(uniqueName);
|
|
43164
|
+
animatorState.clip = animationClip;
|
|
43165
|
+
}
|
|
43166
|
+
}
|
|
43167
|
+
return animatorController;
|
|
43168
|
+
};
|
|
43169
|
+
return GLTFAnimatorControllerParser;
|
|
43170
|
+
}(GLTFParser);
|
|
43171
|
+
exports.GLTFAnimatorControllerParser = __decorate([
|
|
43172
|
+
registerGLTFParser(exports.GLTFParserType.AnimatorController)
|
|
43173
|
+
], exports.GLTFAnimatorControllerParser);
|
|
43142
43174
|
// Source: https://github.com/zeux/meshoptimizer/blob/master/js/meshopt_decoder.js
|
|
43143
43175
|
var MeshoptDecoder = function() {
|
|
43144
43176
|
var unpack = function unpack(data) {
|
|
@@ -43544,15 +43576,20 @@
|
|
|
43544
43576
|
var dataRGBA = new Uint8Array(4 * width * height);
|
|
43545
43577
|
var offset = 0, pos = 0;
|
|
43546
43578
|
var ptrEnd = 4 * scanLineWidth;
|
|
43547
|
-
var rgbeStart = new Uint8Array(4);
|
|
43548
43579
|
var scanLineBuffer = new Uint8Array(ptrEnd);
|
|
43549
43580
|
var numScanLines = height; // read in each successive scanLine
|
|
43550
43581
|
while(numScanLines > 0 && pos < byteLength){
|
|
43551
|
-
|
|
43552
|
-
|
|
43553
|
-
|
|
43554
|
-
|
|
43555
|
-
if (
|
|
43582
|
+
var a = buffer[pos++];
|
|
43583
|
+
var b = buffer[pos++];
|
|
43584
|
+
var c = buffer[pos++];
|
|
43585
|
+
var d = buffer[pos++];
|
|
43586
|
+
if (a != 2 || b != 2 || c & 0x80 || width < 8 || width > 32767) {
|
|
43587
|
+
// this file is not run length encoded
|
|
43588
|
+
// read values sequentially
|
|
43589
|
+
return buffer;
|
|
43590
|
+
}
|
|
43591
|
+
if ((c << 8 | d) != scanLineWidth) {
|
|
43592
|
+
// eslint-disable-next-line no-throw-literal
|
|
43556
43593
|
throw "HDR Bad header format, wrong scan line width";
|
|
43557
43594
|
}
|
|
43558
43595
|
// read each of the four channels for the scanline into the buffer
|
|
@@ -44958,7 +44995,7 @@
|
|
|
44958
44995
|
], KHR_materials_anisotropy);
|
|
44959
44996
|
|
|
44960
44997
|
//@ts-ignore
|
|
44961
|
-
var version = "1.2.0-beta.
|
|
44998
|
+
var version = "1.2.0-beta.4";
|
|
44962
44999
|
console.log("Galacean engine version: " + version);
|
|
44963
45000
|
for(var key in CoreObjects){
|
|
44964
45001
|
Loader.registerClass(key, CoreObjects[key]);
|