@galacean/engine 1.1.0-beta.4 → 1.1.0-beta.5
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 +198 -97
- 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/browser.js
CHANGED
|
@@ -7477,8 +7477,8 @@
|
|
|
7477
7477
|
var _this;
|
|
7478
7478
|
_this = EngineObject1.call(this, entity.engine) || this;
|
|
7479
7479
|
/** @internal */ _this._awoken = false;
|
|
7480
|
-
_this._phasedActive = false;
|
|
7481
7480
|
_this._phasedActiveInScene = false;
|
|
7481
|
+
_this._phasedActive = false;
|
|
7482
7482
|
_this._enabled = true;
|
|
7483
7483
|
_this._entity = entity;
|
|
7484
7484
|
return _this;
|
|
@@ -7611,10 +7611,10 @@
|
|
|
7611
7611
|
], Component.prototype, "_awoken", void 0);
|
|
7612
7612
|
__decorate$1([
|
|
7613
7613
|
ignoreClone
|
|
7614
|
-
], Component.prototype, "
|
|
7614
|
+
], Component.prototype, "_phasedActiveInScene", void 0);
|
|
7615
7615
|
__decorate$1([
|
|
7616
7616
|
ignoreClone
|
|
7617
|
-
], Component.prototype, "
|
|
7617
|
+
], Component.prototype, "_phasedActive", void 0);
|
|
7618
7618
|
__decorate$1([
|
|
7619
7619
|
assignmentClone
|
|
7620
7620
|
], Component.prototype, "_enabled", void 0);
|
|
@@ -17362,16 +17362,31 @@
|
|
|
17362
17362
|
};
|
|
17363
17363
|
var _proto = SceneManager.prototype;
|
|
17364
17364
|
_proto.addScene = function addScene(indexOrScene, scene) {
|
|
17365
|
+
var scenes = this._scenes;
|
|
17366
|
+
var index;
|
|
17365
17367
|
if (typeof indexOrScene === "number") {
|
|
17366
|
-
|
|
17368
|
+
if (indexOrScene < 0 || indexOrScene > scenes.length) {
|
|
17369
|
+
throw "The index is out of range.";
|
|
17370
|
+
}
|
|
17371
|
+
index = indexOrScene;
|
|
17367
17372
|
} else {
|
|
17373
|
+
index = scenes.length;
|
|
17368
17374
|
scene = indexOrScene;
|
|
17369
|
-
this._scenes.push(scene);
|
|
17370
17375
|
}
|
|
17371
17376
|
if (scene.engine !== this.engine) {
|
|
17372
17377
|
throw "The scene is not belong to this engine.";
|
|
17373
17378
|
}
|
|
17374
|
-
scene.
|
|
17379
|
+
if (scene._sceneManager) {
|
|
17380
|
+
var currentIndex = scenes.indexOf(scene);
|
|
17381
|
+
if (currentIndex !== index) {
|
|
17382
|
+
scenes.removeByIndex(currentIndex);
|
|
17383
|
+
scenes.add(index, scene);
|
|
17384
|
+
}
|
|
17385
|
+
} else {
|
|
17386
|
+
scene._sceneManager = this;
|
|
17387
|
+
scenes.add(index, scene);
|
|
17388
|
+
scene.isActive && scene._processActive(true);
|
|
17389
|
+
}
|
|
17375
17390
|
};
|
|
17376
17391
|
/**
|
|
17377
17392
|
* Remove scene.
|
|
@@ -17382,7 +17397,8 @@
|
|
|
17382
17397
|
if (index !== -1) {
|
|
17383
17398
|
var removedScene = scenes.getArray()[index];
|
|
17384
17399
|
scenes.removeByIndex(index);
|
|
17385
|
-
|
|
17400
|
+
scene._sceneManager = null;
|
|
17401
|
+
removedScene.isActive && removedScene._processActive(false);
|
|
17386
17402
|
}
|
|
17387
17403
|
};
|
|
17388
17404
|
/**
|
|
@@ -18574,9 +18590,9 @@
|
|
|
18574
18590
|
oldCollider.removeShape(shape);
|
|
18575
18591
|
}
|
|
18576
18592
|
this._shapes.push(shape);
|
|
18577
|
-
this.scene.physics._addColliderShape(shape);
|
|
18578
18593
|
shape._collider = this;
|
|
18579
18594
|
this._nativeCollider.addShape(shape._nativeShape);
|
|
18595
|
+
this._phasedActiveInScene && this.scene.physics._addColliderShape(shape);
|
|
18580
18596
|
}
|
|
18581
18597
|
};
|
|
18582
18598
|
/**
|
|
@@ -18586,7 +18602,7 @@
|
|
|
18586
18602
|
var index = this._shapes.indexOf(shape);
|
|
18587
18603
|
if (index !== -1) {
|
|
18588
18604
|
this._shapes.splice(index, 1);
|
|
18589
|
-
this.scene.physics._removeColliderShape(shape);
|
|
18605
|
+
this._phasedActiveInScene && this.scene.physics._removeColliderShape(shape);
|
|
18590
18606
|
shape._collider = null;
|
|
18591
18607
|
this._nativeCollider.removeShape(shape._nativeShape);
|
|
18592
18608
|
}
|
|
@@ -18597,7 +18613,7 @@
|
|
|
18597
18613
|
var shapes = this._shapes;
|
|
18598
18614
|
for(var i = 0, n = shapes.length; i < n; i++){
|
|
18599
18615
|
var shape = shapes[i];
|
|
18600
|
-
this.scene.physics._removeColliderShape(shape);
|
|
18616
|
+
this._phasedActiveInScene && this.scene.physics._removeColliderShape(shape);
|
|
18601
18617
|
shape._destroy();
|
|
18602
18618
|
this._nativeCollider.removeShape(shape._nativeShape);
|
|
18603
18619
|
}
|
|
@@ -18622,12 +18638,22 @@
|
|
|
18622
18638
|
/**
|
|
18623
18639
|
* @internal
|
|
18624
18640
|
*/ _proto._onEnableInScene = function _onEnableInScene() {
|
|
18625
|
-
this.scene.physics
|
|
18641
|
+
var physics = this.scene.physics;
|
|
18642
|
+
physics._addCollider(this);
|
|
18643
|
+
var shapes = this.shapes;
|
|
18644
|
+
for(var i = 0, n = shapes.length; i < n; i++){
|
|
18645
|
+
physics._addColliderShape(shapes[i]);
|
|
18646
|
+
}
|
|
18626
18647
|
};
|
|
18627
18648
|
/**
|
|
18628
18649
|
* @internal
|
|
18629
18650
|
*/ _proto._onDisableInScene = function _onDisableInScene() {
|
|
18630
|
-
this.scene.physics
|
|
18651
|
+
var physics = this.scene.physics;
|
|
18652
|
+
physics._removeCollider(this);
|
|
18653
|
+
var shapes = this.shapes;
|
|
18654
|
+
for(var i = 0, n = shapes.length; i < n; i++){
|
|
18655
|
+
physics._removeColliderShape(shapes[i]);
|
|
18656
|
+
}
|
|
18631
18657
|
};
|
|
18632
18658
|
/**
|
|
18633
18659
|
* @internal
|
|
@@ -19000,12 +19026,22 @@
|
|
|
19000
19026
|
/**
|
|
19001
19027
|
* @internal
|
|
19002
19028
|
*/ _proto._onEnableInScene = function _onEnableInScene() {
|
|
19003
|
-
this.scene.physics
|
|
19029
|
+
var physics = this.scene.physics;
|
|
19030
|
+
physics._addCharacterController(this);
|
|
19031
|
+
var shapes = this.shapes;
|
|
19032
|
+
for(var i = 0, n = shapes.length; i < n; i++){
|
|
19033
|
+
physics._addColliderShape(shapes[i]);
|
|
19034
|
+
}
|
|
19004
19035
|
};
|
|
19005
19036
|
/**
|
|
19006
19037
|
* @internal
|
|
19007
19038
|
*/ _proto._onDisableInScene = function _onDisableInScene() {
|
|
19008
|
-
this.scene.physics
|
|
19039
|
+
var physics = this.scene.physics;
|
|
19040
|
+
physics._removeCharacterController(this);
|
|
19041
|
+
var shapes = this.shapes;
|
|
19042
|
+
for(var i = 0, n = shapes.length; i < n; i++){
|
|
19043
|
+
physics._removeColliderShape(shapes[i]);
|
|
19044
|
+
}
|
|
19009
19045
|
};
|
|
19010
19046
|
_proto._setUpDirection = function _setUpDirection() {
|
|
19011
19047
|
this._nativeCollider.setUpDirection(this._upDirection);
|
|
@@ -21105,10 +21141,6 @@
|
|
|
21105
21141
|
magentaMaterial.isGCIgnored = true;
|
|
21106
21142
|
magentaMaterial.shaderData.setColor("material_BaseColor", new Color(1.0, 0.0, 1.01, 1.0));
|
|
21107
21143
|
_this._magentaMaterial = magentaMaterial;
|
|
21108
|
-
var backgroundTextureMaterial = new Material(_assert_this_initialized(_this), Shader.find("background-texture"));
|
|
21109
|
-
backgroundTextureMaterial.isGCIgnored = true;
|
|
21110
|
-
backgroundTextureMaterial.renderState.depthState.compareFunction = exports.CompareFunction.LessEqual;
|
|
21111
|
-
_this._backgroundTextureMaterial = backgroundTextureMaterial;
|
|
21112
21144
|
var innerSettings = _this._settings;
|
|
21113
21145
|
var colorSpace = configuration.colorSpace || exports.ColorSpace.Linear;
|
|
21114
21146
|
colorSpace === exports.ColorSpace.Gamma && _this._macroCollection.enable(Engine._gammaMacro);
|
|
@@ -21722,6 +21754,7 @@
|
|
|
21722
21754
|
this./** @internal */ _textureFillMode = exports.BackgroundTextureFillMode.AspectFitHeight;
|
|
21723
21755
|
this._texture = null;
|
|
21724
21756
|
this._initMesh(_engine);
|
|
21757
|
+
this._initMaterial(_engine);
|
|
21725
21758
|
};
|
|
21726
21759
|
var _proto = Background.prototype;
|
|
21727
21760
|
/**
|
|
@@ -21729,19 +21762,14 @@
|
|
|
21729
21762
|
*/ _proto.destroy = function destroy() {
|
|
21730
21763
|
this._mesh._addReferCount(-1);
|
|
21731
21764
|
this._mesh = null;
|
|
21765
|
+
this._material._addReferCount(-1);
|
|
21766
|
+
this._material = null;
|
|
21732
21767
|
this.texture = null;
|
|
21733
21768
|
this.solidColor = null;
|
|
21734
21769
|
this.sky.destroy();
|
|
21735
21770
|
};
|
|
21736
21771
|
/**
|
|
21737
21772
|
* @internal
|
|
21738
|
-
* Standalone for CanvasRenderer plugin.
|
|
21739
|
-
*/ _proto._initMesh = function _initMesh(engine) {
|
|
21740
|
-
this._mesh = this._createPlane(engine);
|
|
21741
|
-
this._mesh._addReferCount(1);
|
|
21742
|
-
};
|
|
21743
|
-
/**
|
|
21744
|
-
* @internal
|
|
21745
21773
|
*/ _proto._resizeBackgroundTexture = function _resizeBackgroundTexture() {
|
|
21746
21774
|
if (!this._texture) {
|
|
21747
21775
|
return;
|
|
@@ -21775,6 +21803,15 @@
|
|
|
21775
21803
|
_backgroundTextureMesh.setPositions(positions);
|
|
21776
21804
|
_backgroundTextureMesh.uploadData(false);
|
|
21777
21805
|
};
|
|
21806
|
+
_proto._initMesh = function _initMesh(engine) {
|
|
21807
|
+
this._mesh = this._createPlane(engine);
|
|
21808
|
+
this._mesh._addReferCount(1);
|
|
21809
|
+
};
|
|
21810
|
+
_proto._initMaterial = function _initMaterial(engine) {
|
|
21811
|
+
var material = this._material = new Material(engine, Shader.find("background-texture"));
|
|
21812
|
+
material.renderState.depthState.compareFunction = exports.CompareFunction.LessEqual;
|
|
21813
|
+
material._addReferCount(1);
|
|
21814
|
+
};
|
|
21778
21815
|
_proto._createPlane = function _createPlane(engine) {
|
|
21779
21816
|
var mesh = new ModelMesh(engine);
|
|
21780
21817
|
mesh.isGCIgnored = true;
|
|
@@ -21814,7 +21851,7 @@
|
|
|
21814
21851
|
(_value = value) == null ? void 0 : _value._addReferCount(1);
|
|
21815
21852
|
(_this__texture = this._texture) == null ? void 0 : _this__texture._addReferCount(-1);
|
|
21816
21853
|
this._texture = value;
|
|
21817
|
-
this.
|
|
21854
|
+
this._material.shaderData.setTexture("material_BaseTexture", value);
|
|
21818
21855
|
}
|
|
21819
21856
|
}
|
|
21820
21857
|
},
|
|
@@ -22881,6 +22918,7 @@
|
|
|
22881
22918
|
_this._fogEnd = 300;
|
|
22882
22919
|
_this._fogDensity = 0.01;
|
|
22883
22920
|
_this._fogParams = new Vector4();
|
|
22921
|
+
_this._isActive = true;
|
|
22884
22922
|
_this.name = name1 || "";
|
|
22885
22923
|
var shaderData = _this.shaderData;
|
|
22886
22924
|
shaderData._addReferCount(1);
|
|
@@ -23128,6 +23166,24 @@
|
|
|
23128
23166
|
this._fogParams.w = density / Math.sqrt(Math.LN2);
|
|
23129
23167
|
};
|
|
23130
23168
|
_create_class$3(Scene, [
|
|
23169
|
+
{
|
|
23170
|
+
key: "isActive",
|
|
23171
|
+
get: /**
|
|
23172
|
+
* Whether the scene is active.
|
|
23173
|
+
*/ function get() {
|
|
23174
|
+
return this._isActive;
|
|
23175
|
+
},
|
|
23176
|
+
set: function set(value) {
|
|
23177
|
+
if (this._isActive !== value) {
|
|
23178
|
+
this._isActive = value;
|
|
23179
|
+
if (value) {
|
|
23180
|
+
this._sceneManager && this._processActive(true);
|
|
23181
|
+
} else {
|
|
23182
|
+
this._sceneManager && this._processActive(false);
|
|
23183
|
+
}
|
|
23184
|
+
}
|
|
23185
|
+
}
|
|
23186
|
+
},
|
|
23131
23187
|
{
|
|
23132
23188
|
key: "shaderData",
|
|
23133
23189
|
get: /**
|
|
@@ -23445,7 +23501,11 @@
|
|
|
23445
23501
|
* @internal
|
|
23446
23502
|
*/ _proto._onDestroy = function _onDestroy() {
|
|
23447
23503
|
Component1.prototype._onDestroy.call(this);
|
|
23448
|
-
this.scene
|
|
23504
|
+
if (this.scene) {
|
|
23505
|
+
this.scene._componentsManager.addPendingDestroyScript(this);
|
|
23506
|
+
} else {
|
|
23507
|
+
this.onDestroy();
|
|
23508
|
+
}
|
|
23449
23509
|
};
|
|
23450
23510
|
return Script;
|
|
23451
23511
|
}(Component);
|
|
@@ -24982,8 +25042,8 @@
|
|
|
24982
25042
|
};
|
|
24983
25043
|
_proto._drawBackgroundTexture = function _drawBackgroundTexture(engine, background) {
|
|
24984
25044
|
var rhi = engine._hardwareRenderer;
|
|
24985
|
-
var
|
|
24986
|
-
var mesh = background._mesh;
|
|
25045
|
+
var canvas = engine.canvas;
|
|
25046
|
+
var material = background._material, mesh = background._mesh;
|
|
24987
25047
|
if ((this._lastCanvasSize.x !== canvas.width || this._lastCanvasSize.y !== canvas.height) && background._textureFillMode !== exports.BackgroundTextureFillMode.Fill) {
|
|
24988
25048
|
this._lastCanvasSize.set(canvas.width, canvas.height);
|
|
24989
25049
|
background._resizeBackgroundTexture();
|
|
@@ -25156,7 +25216,7 @@
|
|
|
25156
25216
|
// Use the intersection of the near clipping plane as the origin point.
|
|
25157
25217
|
var origin = this._innerViewportToWorldPoint(point.x, point.y, 0.0, invViewProjMat, out.origin);
|
|
25158
25218
|
// Use the intersection of the far clipping plane as the origin point.
|
|
25159
|
-
var direction = this._innerViewportToWorldPoint(point.x, point.y, 1.
|
|
25219
|
+
var direction = this._innerViewportToWorldPoint(point.x, point.y, 1 - MathUtil$1.zeroTolerance, invViewProjMat, out.direction);
|
|
25160
25220
|
Vector3.subtract(direction, origin, direction);
|
|
25161
25221
|
direction.normalize();
|
|
25162
25222
|
return out;
|
|
@@ -37439,12 +37499,12 @@
|
|
|
37439
37499
|
return _construct.apply(null, arguments);
|
|
37440
37500
|
}
|
|
37441
37501
|
var ReflectionParser = /*#__PURE__*/ function() {
|
|
37442
|
-
var ReflectionParser = function ReflectionParser() {
|
|
37443
|
-
|
|
37444
|
-
this.customParseComponentHandles[componentType] = handle;
|
|
37502
|
+
var ReflectionParser = function ReflectionParser(_context) {
|
|
37503
|
+
this._context = _context;
|
|
37445
37504
|
};
|
|
37446
|
-
|
|
37447
|
-
|
|
37505
|
+
var _proto = ReflectionParser.prototype;
|
|
37506
|
+
_proto.parseEntity = function parseEntity(entityConfig) {
|
|
37507
|
+
return this._getEntityByConfig(entityConfig).then(function(entity) {
|
|
37448
37508
|
var _entityConfig_isActive;
|
|
37449
37509
|
entity.isActive = (_entityConfig_isActive = entityConfig.isActive) != null ? _entityConfig_isActive : true;
|
|
37450
37510
|
var position = entityConfig.position, rotation = entityConfig.rotation, scale = entityConfig.scale;
|
|
@@ -37454,72 +37514,29 @@
|
|
|
37454
37514
|
return entity;
|
|
37455
37515
|
});
|
|
37456
37516
|
};
|
|
37457
|
-
|
|
37458
|
-
// @ts-ignore
|
|
37459
|
-
var assetRefId = entityConfig.assetRefId;
|
|
37460
|
-
if (assetRefId) {
|
|
37461
|
-
return engine.resourceManager // @ts-ignore
|
|
37462
|
-
.getResourceByRef({
|
|
37463
|
-
refId: assetRefId,
|
|
37464
|
-
key: entityConfig.key,
|
|
37465
|
-
isClone: entityConfig.isClone
|
|
37466
|
-
}).then(function(entity) {
|
|
37467
|
-
entity.name = entityConfig.name;
|
|
37468
|
-
return entity;
|
|
37469
|
-
});
|
|
37470
|
-
} else {
|
|
37471
|
-
var entity = new Entity(engine, entityConfig.name);
|
|
37472
|
-
return Promise.resolve(entity);
|
|
37473
|
-
}
|
|
37474
|
-
};
|
|
37475
|
-
ReflectionParser.parseClassObject = function parseClassObject(item, engine, resourceManager) {
|
|
37476
|
-
if (resourceManager === void 0) resourceManager = engine.resourceManager;
|
|
37517
|
+
_proto.parseClassObject = function parseClassObject(item) {
|
|
37477
37518
|
var Class = Loader.getClass(item.class);
|
|
37478
37519
|
var _item_constructParams;
|
|
37479
37520
|
var params = (_item_constructParams = item.constructParams) != null ? _item_constructParams : [];
|
|
37480
37521
|
var instance = _construct(Class, [].concat(params));
|
|
37481
|
-
return this.parsePropsAndMethods(instance, item
|
|
37482
|
-
};
|
|
37483
|
-
ReflectionParser.parseBasicType = function parseBasicType(value, engine, resourceManager) {
|
|
37484
|
-
if (resourceManager === void 0) resourceManager = engine.resourceManager;
|
|
37485
|
-
var _this = this;
|
|
37486
|
-
if (Array.isArray(value)) {
|
|
37487
|
-
return Promise.all(value.map(function(item) {
|
|
37488
|
-
return _this.parseBasicType(item, engine, resourceManager);
|
|
37489
|
-
}));
|
|
37490
|
-
} else if (typeof value === "object" && value != null) {
|
|
37491
|
-
if (this._isClass(value)) {
|
|
37492
|
-
// class object
|
|
37493
|
-
return this.parseClassObject(value, engine, resourceManager);
|
|
37494
|
-
} else if (this._isRef(value)) {
|
|
37495
|
-
// reference object
|
|
37496
|
-
return resourceManager.getResourceByRef(value);
|
|
37497
|
-
} else {
|
|
37498
|
-
// basic type
|
|
37499
|
-
return Promise.resolve(value);
|
|
37500
|
-
}
|
|
37501
|
-
} else {
|
|
37502
|
-
return Promise.resolve(value);
|
|
37503
|
-
}
|
|
37522
|
+
return this.parsePropsAndMethods(instance, item);
|
|
37504
37523
|
};
|
|
37505
|
-
|
|
37506
|
-
if (resourceManager === void 0) resourceManager = engine.resourceManager;
|
|
37507
|
-
var _this = this;
|
|
37524
|
+
_proto.parsePropsAndMethods = function parsePropsAndMethods(instance, item) {
|
|
37508
37525
|
var promises = [];
|
|
37509
37526
|
if (item.methods) {
|
|
37510
37527
|
for(var methodName in item.methods){
|
|
37511
37528
|
var methodParams = item.methods[methodName];
|
|
37512
37529
|
for(var i = 0, count = methodParams.length; i < count; i++){
|
|
37513
37530
|
var params = methodParams[i];
|
|
37514
|
-
var promise = this.parseMethod(instance, methodName, params
|
|
37531
|
+
var promise = this.parseMethod(instance, methodName, params);
|
|
37515
37532
|
promises.push(promise);
|
|
37516
37533
|
}
|
|
37517
37534
|
}
|
|
37518
37535
|
}
|
|
37519
37536
|
if (item.props) {
|
|
37520
|
-
var
|
|
37537
|
+
var _this = this, _loop = function _loop(key) {
|
|
37521
37538
|
var value = item.props[key];
|
|
37522
|
-
var promise =
|
|
37539
|
+
var promise = _this.parseBasicType(value).then(function(v) {
|
|
37523
37540
|
return instance[key] = v;
|
|
37524
37541
|
});
|
|
37525
37542
|
promises.push(promise);
|
|
@@ -37527,27 +37544,76 @@
|
|
|
37527
37544
|
for(var key in item.props)_loop(key);
|
|
37528
37545
|
}
|
|
37529
37546
|
return Promise.all(promises).then(function() {
|
|
37530
|
-
var handle =
|
|
37531
|
-
if (handle) return handle(instance, item
|
|
37547
|
+
var handle = ReflectionParser.customParseComponentHandles[instance.constructor.name];
|
|
37548
|
+
if (handle) return handle(instance, item);
|
|
37532
37549
|
else return instance;
|
|
37533
37550
|
});
|
|
37534
37551
|
};
|
|
37535
|
-
|
|
37536
|
-
if (resourceManager === void 0) resourceManager = engine.resourceManager;
|
|
37552
|
+
_proto.parseMethod = function parseMethod(instance, methodName, methodParams) {
|
|
37537
37553
|
var _this = this;
|
|
37538
37554
|
return Promise.all(methodParams.map(function(param) {
|
|
37539
|
-
return _this.parseBasicType(param
|
|
37555
|
+
return _this.parseBasicType(param);
|
|
37540
37556
|
})).then(function(result) {
|
|
37541
37557
|
var _instance;
|
|
37542
37558
|
return (_instance = instance)[methodName].apply(_instance, [].concat(result));
|
|
37543
37559
|
});
|
|
37544
37560
|
};
|
|
37561
|
+
_proto.parseBasicType = function parseBasicType(value) {
|
|
37562
|
+
var _this = this;
|
|
37563
|
+
if (Array.isArray(value)) {
|
|
37564
|
+
return Promise.all(value.map(function(item) {
|
|
37565
|
+
return _this.parseBasicType(item);
|
|
37566
|
+
}));
|
|
37567
|
+
} else if (typeof value === "object" && value != null) {
|
|
37568
|
+
if (ReflectionParser._isClass(value)) {
|
|
37569
|
+
// class object
|
|
37570
|
+
return this.parseClassObject(value);
|
|
37571
|
+
} else if (ReflectionParser._isAssetRef(value)) {
|
|
37572
|
+
// reference object
|
|
37573
|
+
// @ts-ignore
|
|
37574
|
+
return this._context.resourceManager.getResourceByRef(value);
|
|
37575
|
+
} else if (ReflectionParser._isEntityRef(value)) {
|
|
37576
|
+
// entity reference
|
|
37577
|
+
return Promise.resolve(this._context.entityMap.get(value.entityId));
|
|
37578
|
+
} else {
|
|
37579
|
+
// basic type
|
|
37580
|
+
return Promise.resolve(value);
|
|
37581
|
+
}
|
|
37582
|
+
} else {
|
|
37583
|
+
return Promise.resolve(value);
|
|
37584
|
+
}
|
|
37585
|
+
};
|
|
37586
|
+
_proto._getEntityByConfig = function _getEntityByConfig(entityConfig) {
|
|
37587
|
+
// @ts-ignore
|
|
37588
|
+
var assetRefId = entityConfig.assetRefId;
|
|
37589
|
+
var engine = this._context.engine;
|
|
37590
|
+
if (assetRefId) {
|
|
37591
|
+
return engine.resourceManager // @ts-ignore
|
|
37592
|
+
.getResourceByRef({
|
|
37593
|
+
refId: assetRefId,
|
|
37594
|
+
key: entityConfig.key,
|
|
37595
|
+
isClone: entityConfig.isClone
|
|
37596
|
+
}).then(function(entity) {
|
|
37597
|
+
entity.name = entityConfig.name;
|
|
37598
|
+
return entity;
|
|
37599
|
+
});
|
|
37600
|
+
} else {
|
|
37601
|
+
var entity = new Entity(engine, entityConfig.name);
|
|
37602
|
+
return Promise.resolve(entity);
|
|
37603
|
+
}
|
|
37604
|
+
};
|
|
37605
|
+
ReflectionParser.registerCustomParseComponent = function registerCustomParseComponent(componentType, handle) {
|
|
37606
|
+
this.customParseComponentHandles[componentType] = handle;
|
|
37607
|
+
};
|
|
37545
37608
|
ReflectionParser._isClass = function _isClass(value) {
|
|
37546
37609
|
return value["class"] != undefined;
|
|
37547
37610
|
};
|
|
37548
|
-
ReflectionParser.
|
|
37611
|
+
ReflectionParser._isAssetRef = function _isAssetRef(value) {
|
|
37549
37612
|
return value["refId"] != undefined;
|
|
37550
37613
|
};
|
|
37614
|
+
ReflectionParser._isEntityRef = function _isEntityRef(value) {
|
|
37615
|
+
return value["entityId"] != undefined;
|
|
37616
|
+
};
|
|
37551
37617
|
return ReflectionParser;
|
|
37552
37618
|
}();
|
|
37553
37619
|
(function() {
|
|
@@ -37803,6 +37869,8 @@
|
|
|
37803
37869
|
this.assets = new Map();
|
|
37804
37870
|
this.entityConfigMap = new Map();
|
|
37805
37871
|
this.rootIds = [];
|
|
37872
|
+
this.engine = scene.engine;
|
|
37873
|
+
this.resourceManager = scene.engine.resourceManager;
|
|
37806
37874
|
};
|
|
37807
37875
|
var _proto = SceneParserContext.prototype;
|
|
37808
37876
|
_proto.destroy = function destroy() {
|
|
@@ -37818,7 +37886,7 @@
|
|
|
37818
37886
|
var SceneParser = function SceneParser(context) {
|
|
37819
37887
|
var _this = this;
|
|
37820
37888
|
this.context = context;
|
|
37821
|
-
this._engine =
|
|
37889
|
+
this._engine = context.scene.engine;
|
|
37822
37890
|
this._organizeEntities = this._organizeEntities.bind(this);
|
|
37823
37891
|
this._parseComponents = this._parseComponents.bind(this);
|
|
37824
37892
|
this._clearAndResolveScene = this._clearAndResolveScene.bind(this);
|
|
@@ -37826,22 +37894,24 @@
|
|
|
37826
37894
|
_this._reject = reject;
|
|
37827
37895
|
_this._resolve = resolve;
|
|
37828
37896
|
});
|
|
37897
|
+
this._reflectionParser = new ReflectionParser(context);
|
|
37829
37898
|
};
|
|
37830
37899
|
var _proto = SceneParser.prototype;
|
|
37831
37900
|
/** start parse the scene */ _proto.start = function start() {
|
|
37832
37901
|
this._parseEntities().then(this._organizeEntities).then(this._parseComponents).then(this._clearAndResolveScene).then(this._resolve).catch(this._reject);
|
|
37833
37902
|
};
|
|
37834
37903
|
_proto._parseEntities = function _parseEntities() {
|
|
37904
|
+
var _this = this;
|
|
37835
37905
|
var entitiesConfig = this.context.originalData.entities;
|
|
37836
37906
|
var entityConfigMap = this.context.entityConfigMap;
|
|
37837
37907
|
var entitiesMap = this.context.entityMap;
|
|
37838
37908
|
var rootIds = this.context.rootIds;
|
|
37839
|
-
|
|
37909
|
+
this._engine;
|
|
37840
37910
|
var promises = entitiesConfig.map(function(entityConfig) {
|
|
37841
37911
|
entityConfigMap.set(entityConfig.id, entityConfig);
|
|
37842
37912
|
// record root entities
|
|
37843
37913
|
if (!entityConfig.parent) rootIds.push(entityConfig.id);
|
|
37844
|
-
return
|
|
37914
|
+
return _this._reflectionParser.parseEntity(entityConfig);
|
|
37845
37915
|
});
|
|
37846
37916
|
return Promise.all(promises).then(function(entities) {
|
|
37847
37917
|
for(var i = 0, l = entities.length; i < l; i++){
|
|
@@ -37879,7 +37949,7 @@
|
|
|
37879
37949
|
component = entity.getComponent(Loader.getClass(key));
|
|
37880
37950
|
}
|
|
37881
37951
|
component = component || entity.addComponent(Loader.getClass(key));
|
|
37882
|
-
var promise =
|
|
37952
|
+
var promise = this._reflectionParser.parsePropsAndMethods(component, componentConfig);
|
|
37883
37953
|
promises.push(promise);
|
|
37884
37954
|
}
|
|
37885
37955
|
}
|
|
@@ -41210,8 +41280,7 @@
|
|
|
41210
41280
|
mipmap: (_samplerInfo = samplerInfo) == null ? void 0 : _samplerInfo.mipmap
|
|
41211
41281
|
}
|
|
41212
41282
|
}).then(function(texture) {
|
|
41213
|
-
|
|
41214
|
-
(_texture = texture).name || (_texture.name = textureName || imageName || "texture_" + index);
|
|
41283
|
+
texture.name = textureName || imageName || texture.name || "texture_" + index;
|
|
41215
41284
|
useSampler && GLTFUtils.parseSampler(texture, samplerInfo);
|
|
41216
41285
|
return texture;
|
|
41217
41286
|
});
|
|
@@ -42299,6 +42368,38 @@
|
|
|
42299
42368
|
""
|
|
42300
42369
|
])
|
|
42301
42370
|
], TextureCubeLoader);
|
|
42371
|
+
var ProjectLoader = /*#__PURE__*/ function(Loader1) {
|
|
42372
|
+
var ProjectLoader = function ProjectLoader() {
|
|
42373
|
+
return Loader1.apply(this, arguments);
|
|
42374
|
+
};
|
|
42375
|
+
_inherits(ProjectLoader, Loader1);
|
|
42376
|
+
var _proto = ProjectLoader.prototype;
|
|
42377
|
+
_proto.load = function load(item, resourceManager) {
|
|
42378
|
+
var _this = this;
|
|
42379
|
+
var engine = resourceManager.engine;
|
|
42380
|
+
return new AssetPromise(function(resolve, reject) {
|
|
42381
|
+
_this.request(item.url, {
|
|
42382
|
+
type: "json"
|
|
42383
|
+
}).then(function(data) {
|
|
42384
|
+
// @ts-ignore
|
|
42385
|
+
engine.resourceManager.initVirtualResources(data.files);
|
|
42386
|
+
return resourceManager.load({
|
|
42387
|
+
type: exports.AssetType.Scene,
|
|
42388
|
+
url: data.scene
|
|
42389
|
+
}).then(function(scene) {
|
|
42390
|
+
engine.sceneManager.activeScene = scene;
|
|
42391
|
+
resolve();
|
|
42392
|
+
});
|
|
42393
|
+
}).catch(reject);
|
|
42394
|
+
});
|
|
42395
|
+
};
|
|
42396
|
+
return ProjectLoader;
|
|
42397
|
+
}(Loader);
|
|
42398
|
+
ProjectLoader = __decorate([
|
|
42399
|
+
resourceLoader(exports.AssetType.Project, [
|
|
42400
|
+
"proj"
|
|
42401
|
+
], true)
|
|
42402
|
+
], ProjectLoader);
|
|
42302
42403
|
var SceneLoader = /*#__PURE__*/ function(Loader1) {
|
|
42303
42404
|
var SceneLoader = function SceneLoader() {
|
|
42304
42405
|
return Loader1.apply(this, arguments);
|
|
@@ -42895,7 +42996,7 @@
|
|
|
42895
42996
|
], GALACEAN_animation_event);
|
|
42896
42997
|
|
|
42897
42998
|
//@ts-ignore
|
|
42898
|
-
var version = "1.1.0-beta.
|
|
42999
|
+
var version = "1.1.0-beta.5";
|
|
42899
43000
|
console.log("Galacean engine version: " + version);
|
|
42900
43001
|
for(var key in CoreObjects){
|
|
42901
43002
|
Loader.registerClass(key, CoreObjects[key]);
|