@galacean/engine 1.1.0-beta.4 → 1.1.0-beta.6

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 CHANGED
@@ -5511,13 +5511,13 @@
5511
5511
  break;
5512
5512
  case Array:
5513
5513
  var targetPropertyA = target[k];
5514
- var length1 = sourceProperty.length;
5514
+ var length = sourceProperty.length;
5515
5515
  if (targetPropertyA == null) {
5516
- target[k] = targetPropertyA = new Array(length1);
5516
+ target[k] = targetPropertyA = new Array(length);
5517
5517
  } else {
5518
- targetPropertyA.length = length1;
5518
+ targetPropertyA.length = length;
5519
5519
  }
5520
- for(var i = 0; i < length1; i++){
5520
+ for(var i = 0; i < length; i++){
5521
5521
  CloneManager.cloneProperty(sourceProperty, targetPropertyA, i, cloneMode);
5522
5522
  }
5523
5523
  default:
@@ -6238,7 +6238,7 @@
6238
6238
  /**
6239
6239
  * Two-dimensional texture array.
6240
6240
  */ var Texture2DArray = /*#__PURE__*/ function(Texture1) {
6241
- var Texture2DArray = function Texture2DArray(engine, width, height, length1, format, mipmap) {
6241
+ var Texture2DArray = function Texture2DArray(engine, width, height, length, format, mipmap) {
6242
6242
  if (format === void 0) format = exports.TextureFormat.R8G8B8A8;
6243
6243
  if (mipmap === void 0) mipmap = true;
6244
6244
  var _this;
@@ -6246,7 +6246,7 @@
6246
6246
  _this._mipmap = mipmap;
6247
6247
  _this._width = width;
6248
6248
  _this._height = height;
6249
- _this._length = length1;
6249
+ _this._length = length;
6250
6250
  _this._format = format;
6251
6251
  _this._mipmapCount = _this._getMipmapCount();
6252
6252
  _this._platformTexture = engine._hardwareRenderer.createPlatformTexture2DArray(_assert_this_initialized(_this));
@@ -6267,11 +6267,11 @@
6267
6267
  * @param width - Data width. if it's empty, width is the width corresponding to mipLevel minus x , width corresponding to mipLevel is Math.max(1, this.width >> mipLevel)
6268
6268
  * @param height - Data height. if it's empty, height is the height corresponding to mipLevel minus y , height corresponding to mipLevel is Math.max(1, this.height >> mipLevel)
6269
6269
  * @param length - Data length. if it's empty, length is the length of Texture2DArray.length
6270
- */ _proto.setPixelBuffer = function setPixelBuffer(offsetIndex, colorBuffer, mipLevel, x, y, width, height, length1) {
6270
+ */ _proto.setPixelBuffer = function setPixelBuffer(offsetIndex, colorBuffer, mipLevel, x, y, width, height, length) {
6271
6271
  if (mipLevel === void 0) mipLevel = 0;
6272
6272
  if (x === void 0) x = 0;
6273
6273
  if (y === void 0) y = 0;
6274
- this._platformTexture.setPixelBuffer(offsetIndex, colorBuffer, mipLevel, x, y, width, height, length1);
6274
+ this._platformTexture.setPixelBuffer(offsetIndex, colorBuffer, mipLevel, x, y, width, height, length);
6275
6275
  this._isContentLost = false;
6276
6276
  };
6277
6277
  /**
@@ -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, "_phasedActive", void 0);
7614
+ ], Component.prototype, "_phasedActiveInScene", void 0);
7615
7615
  __decorate$1([
7616
7616
  ignoreClone
7617
- ], Component.prototype, "_phasedActiveInScene", void 0);
7617
+ ], Component.prototype, "_phasedActive", void 0);
7618
7618
  __decorate$1([
7619
7619
  assignmentClone
7620
7620
  ], Component.prototype, "_enabled", void 0);
@@ -7890,11 +7890,11 @@
7890
7890
  var pathArr = this._stringToPath(path);
7891
7891
  var object = target;
7892
7892
  var index = 0;
7893
- var length1 = pathArr.length;
7894
- while(object != null && index < length1){
7893
+ var length = pathArr.length;
7894
+ while(object != null && index < length){
7895
7895
  object = object[pathArr[index++]];
7896
7896
  }
7897
- return index && index == length1 ? object : undefined;
7897
+ return index && index == length ? object : undefined;
7898
7898
  };
7899
7899
  /**
7900
7900
  * Fast remove an element from array.
@@ -9071,7 +9071,7 @@
9071
9071
  */ _proto.findByPath = function findByPath(path) {
9072
9072
  var splits = path.split("/");
9073
9073
  var entity = this;
9074
- for(var i = 0, length1 = splits.length; i < length1; ++i){
9074
+ for(var i = 0, length = splits.length; i < length; ++i){
9075
9075
  var split = splits[i];
9076
9076
  if (split) {
9077
9077
  entity = Entity._findChildByName(entity, split);
@@ -9303,7 +9303,7 @@
9303
9303
  };
9304
9304
  _proto._setActiveComponents = function _setActiveComponents(isActive, activeChangeFlag) {
9305
9305
  var activeChangedComponents = this._activeChangedComponents;
9306
- for(var i = 0, length1 = activeChangedComponents.length; i < length1; ++i){
9306
+ for(var i = 0, length = activeChangedComponents.length; i < length; ++i){
9307
9307
  activeChangedComponents[i]._setActive(isActive, activeChangeFlag);
9308
9308
  }
9309
9309
  this._scene._componentsManager.putActiveChangedTempList(activeChangedComponents);
@@ -13299,14 +13299,14 @@
13299
13299
  vertexElements[index] = element;
13300
13300
  this._bufferStructChanged = true;
13301
13301
  };
13302
- _proto.setVertexElementsLength = function setVertexElementsLength(length1) {
13302
+ _proto.setVertexElementsLength = function setVertexElementsLength(length) {
13303
13303
  var vertexElementMap = this._vertexElementMap;
13304
13304
  var vertexElements = this._vertexElements;
13305
- for(var i = length1, n = vertexElements.length; i < n; i++){
13305
+ for(var i = length, n = vertexElements.length; i < n; i++){
13306
13306
  var element = vertexElements[i];
13307
13307
  delete vertexElementMap[element.attribute];
13308
13308
  }
13309
- vertexElements.length = length1;
13309
+ vertexElements.length = length;
13310
13310
  };
13311
13311
  _proto.setVertexBufferBinding = function setVertexBufferBinding(index, binding) {
13312
13312
  var referCount = this._getReferCount();
@@ -13460,8 +13460,8 @@
13460
13460
  /**
13461
13461
  * @internal
13462
13462
  *
13463
- */ _proto._setVertexElementsLength = function _setVertexElementsLength(length1) {
13464
- this._primitive.setVertexElementsLength(length1);
13463
+ */ _proto._setVertexElementsLength = function _setVertexElementsLength(length) {
13464
+ this._primitive.setVertexElementsLength(length);
13465
13465
  };
13466
13466
  /**
13467
13467
  * @internal
@@ -15177,9 +15177,9 @@
15177
15177
  }
15178
15178
  var bsUpdate = !bsManager._useTextureMode() && bsManager._vertexElementsNeedUpdate();
15179
15179
  if (previousBSOffset !== bsManager._vertexElementOffset || bsUpdate && bsManager._blendShapeCount > 0) {
15180
- var length1 = bsManager._addVertexElements(this);
15181
- if (length1 < previousCount) {
15182
- this._setVertexElementsLength(length1);
15180
+ var length = bsManager._addVertexElements(this);
15181
+ if (length < previousCount) {
15182
+ this._setVertexElementsLength(length);
15183
15183
  }
15184
15184
  }
15185
15185
  };
@@ -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
- this._scenes.add(indexOrScene, scene);
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._processActive(true);
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
- removedScene._processActive(false);
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._addCollider(this);
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._removeCollider(this);
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._addCharacterController(this);
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._removeCharacterController(this);
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);
@@ -20297,9 +20333,9 @@
20297
20333
  pointer._firePointerDrag();
20298
20334
  var rayCastEntity = this._pointerRayCast(scenes, position.x / canvas.width, position.y / canvas.height);
20299
20335
  pointer._firePointerExitAndEnter(rayCastEntity);
20300
- var length1 = events.length;
20301
- if (length1 > 0) {
20302
- for(var i1 = 0; i1 < length1; i1++){
20336
+ var length = events.length;
20337
+ if (length > 0) {
20338
+ for(var i1 = 0; i1 < length; i1++){
20303
20339
  switch(events[i1].type){
20304
20340
  case "pointerdown":
20305
20341
  pointer.phase = exports.PointerPhase.Down;
@@ -20394,15 +20430,15 @@
20394
20430
  };
20395
20431
  _proto._updatePointerInfo = function _updatePointerInfo(frameCount, pointer, left, top, widthPixelRatio, heightPixelRatio) {
20396
20432
  var events = pointer._events, position = pointer.position;
20397
- var length1 = events.length;
20398
- if (length1 > 0) {
20433
+ var length = events.length;
20434
+ if (length > 0) {
20399
20435
  var _this = this, _upList = _this._upList, _upMap = _this._upMap, _downList = _this._downList, _downMap = _this._downMap;
20400
- var latestEvent = events[length1 - 1];
20436
+ var latestEvent = events[length - 1];
20401
20437
  var currX = (latestEvent.clientX - left) * widthPixelRatio;
20402
20438
  var currY = (latestEvent.clientY - top) * heightPixelRatio;
20403
20439
  pointer.deltaPosition.set(currX - position.x, currY - position.y);
20404
20440
  position.set(currX, currY);
20405
- for(var i = 0; i < length1; i++){
20441
+ for(var i = 0; i < length; i++){
20406
20442
  var event = events[i];
20407
20443
  var button = event.button;
20408
20444
  pointer.button = _pointerDec2BinMap[button] || exports.PointerButton.None;
@@ -20444,8 +20480,8 @@
20444
20480
  continue;
20445
20481
  }
20446
20482
  var cameras = scene._activeCameras;
20447
- for(var j = 0; j < cameras.length; j++){
20448
- var camera = cameras[i];
20483
+ for(var j = cameras.length - 1; j >= 0; j--){
20484
+ var camera = cameras[j];
20449
20485
  if (!camera.enabled || camera.renderTarget) {
20450
20486
  continue;
20451
20487
  }
@@ -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);
@@ -21272,9 +21304,9 @@
21272
21304
  var shaderProgramPools = this._shaderProgramPools;
21273
21305
  var pool = shaderProgramPools[index];
21274
21306
  if (!pool) {
21275
- var length1 = index + 1;
21276
- if (length1 > shaderProgramPools.length) {
21277
- shaderProgramPools.length = length1;
21307
+ var length = index + 1;
21308
+ if (length > shaderProgramPools.length) {
21309
+ shaderProgramPools.length = length;
21278
21310
  }
21279
21311
  shaderProgramPools[index] = pool = new ShaderProgramPool();
21280
21312
  }
@@ -21722,26 +21754,22 @@
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
  /**
21728
21761
  * @internal
21729
21762
  */ _proto.destroy = function destroy() {
21763
+ this.texture = null;
21730
21764
  this._mesh._addReferCount(-1);
21731
21765
  this._mesh = null;
21732
- this.texture = null;
21766
+ this._material._addReferCount(-1);
21767
+ this._material = 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._engine._backgroundTextureMaterial.shaderData.setTexture("material_BaseTexture", value);
21854
+ this._material.shaderData.setTexture("material_BaseTexture", value);
21818
21855
  }
21819
21856
  }
21820
21857
  },
@@ -21971,7 +22008,7 @@
21971
22008
  var _this = this, pendingDestroyScripts = _this._disposeDestroyScripts, disposeDestroyScripts = _this._pendingDestroyScripts;
21972
22009
  this._disposeDestroyScripts = disposeDestroyScripts;
21973
22010
  this._pendingDestroyScripts = pendingDestroyScripts;
21974
- length = disposeDestroyScripts.length;
22011
+ var length = disposeDestroyScripts.length;
21975
22012
  if (length > 0) {
21976
22013
  for(var i = length - 1; i >= 0; i--){
21977
22014
  disposeDestroyScripts[i].onDestroy();
@@ -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._componentsManager.addPendingDestroyScript(this);
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 material = engine._backgroundTextureMaterial, canvas = engine.canvas;
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.0, invViewProjMat, out.direction);
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;
@@ -28131,11 +28191,11 @@
28131
28191
  /**
28132
28192
  * @internal
28133
28193
  */ var CharRenderDataPool = /*#__PURE__*/ function() {
28134
- var CharRenderDataPool = function CharRenderDataPool(type, length1) {
28194
+ var CharRenderDataPool = function CharRenderDataPool(type, length) {
28135
28195
  this._elements = [];
28136
28196
  this._type = type;
28137
28197
  var elements = this._elements;
28138
- for(var i = 0; i < length1; ++i){
28198
+ for(var i = 0; i < length; ++i){
28139
28199
  elements[i] = new type();
28140
28200
  }
28141
28201
  };
@@ -29186,8 +29246,8 @@
29186
29246
  /**
29187
29247
  * @internal
29188
29248
  */ _proto._evaluate = function _evaluate(time, evaluateData) {
29189
- var length1 = this.keys.length;
29190
- if (!length1) {
29249
+ var length = this.keys.length;
29250
+ if (!length) {
29191
29251
  console.warn("This curve don't have any keyframes: ", this);
29192
29252
  return;
29193
29253
  }
@@ -29195,11 +29255,11 @@
29195
29255
  // Compute curIndex and nextIndex.
29196
29256
  var curIndex = evaluateData.curKeyframeIndex;
29197
29257
  // Reset loop,if delete keyfranme may cause `curIndex >= length`
29198
- if (curIndex !== -1 && (curIndex >= length1 || time < keys[curIndex].time)) {
29258
+ if (curIndex !== -1 && (curIndex >= length || time < keys[curIndex].time)) {
29199
29259
  curIndex = -1;
29200
29260
  }
29201
29261
  var nextIndex = curIndex + 1;
29202
- while(nextIndex < length1){
29262
+ while(nextIndex < length){
29203
29263
  if (time < keys[nextIndex].time) {
29204
29264
  break;
29205
29265
  }
@@ -29211,7 +29271,7 @@
29211
29271
  var value;
29212
29272
  if (curIndex === -1) {
29213
29273
  value = this._type._setValue(keys[0].value, evaluateData.value);
29214
- } else if (nextIndex === length1) {
29274
+ } else if (nextIndex === length) {
29215
29275
  value = this._type._setValue(keys[curIndex].value, evaluateData.value);
29216
29276
  } else {
29217
29277
  // Time between first frame and end frame.
@@ -31572,62 +31632,199 @@
31572
31632
  (function() {
31573
31633
  SkyProceduralMaterial._sunSimpleMacro = ShaderMacro.getByName("MATERIAL_SUN_SIMPLE");
31574
31634
  })();
31635
+ var SubPrimitive = function SubPrimitive() {};
31575
31636
  /**
31576
- * Particle Material.
31577
- */ var ParticleMaterial = /*#__PURE__*/ function(BaseMaterial1) {
31578
- var ParticleMaterial = function ParticleMaterial(engine) {
31637
+ * The rendering mode for particle renderer.
31638
+ */ exports.ParticleRenderMode = void 0;
31639
+ (function(ParticleRenderMode) {
31640
+ ParticleRenderMode[ParticleRenderMode[/** Render particles as billboards facing the active camera. */ "Billboard"] = 0] = "Billboard";
31641
+ ParticleRenderMode[ParticleRenderMode[/** Stretch particles in the direction of motion. */ "StretchBillboard"] = 1] = "StretchBillboard";
31642
+ ParticleRenderMode[ParticleRenderMode[/** Render particles as billboards always facing up along the y-Axis. */ "HorizontalBillboard"] = 2] = "HorizontalBillboard";
31643
+ ParticleRenderMode[ParticleRenderMode[/** Render particles as billboards always facing the player, but not pitching along the x-Axis. */ "VerticalBillboard"] = 3] = "VerticalBillboard";
31644
+ ParticleRenderMode[ParticleRenderMode[/** Render particles as meshes. */ "Mesh"] = 4] = "Mesh";
31645
+ ParticleRenderMode[ParticleRenderMode[/** Do not render particles. */ "None"] = 5] = "None";
31646
+ })(exports.ParticleRenderMode || (exports.ParticleRenderMode = {}));
31647
+ exports.ParticleStopMode = void 0;
31648
+ (function(ParticleStopMode) {
31649
+ ParticleStopMode[ParticleStopMode[/** Stop emitting new particles and clear existing particles immediately. */ "StopEmittingAndClear"] = 0] = "StopEmittingAndClear";
31650
+ ParticleStopMode[ParticleStopMode[/** Stop emitting new particles, but keep existing particles until they expire. */ "StopEmitting"] = 1] = "StopEmitting";
31651
+ })(exports.ParticleStopMode || (exports.ParticleStopMode = {}));
31652
+ /**
31653
+ * Particle Renderer Component.
31654
+ */ var ParticleRenderer = /*#__PURE__*/ function(Renderer1) {
31655
+ _inherits$2(ParticleRenderer, Renderer1);
31656
+ function ParticleRenderer(entity) {
31579
31657
  var _this;
31580
- _this = BaseMaterial1.call(this, engine, Shader.find("particle-shader")) || this;
31581
- var shaderData = _this.shaderData;
31582
- shaderData.enableMacro("MATERIAL_OMIT_NORMAL");
31583
- shaderData.setColor(BaseMaterial._baseColorProp, new Color$1(1, 1, 1, 1));
31584
- _this.isTransparent = true;
31658
+ _this = Renderer1.call(this, entity) || this;
31659
+ /** Particle generator. */ _this.generator = new ParticleGenerator(_assert_this_initialized(_this));
31660
+ /** Specifies how much particles stretch depending on their velocity. */ _this.velocityScale = 0;
31661
+ /** How much are the particles stretched in their direction of motion, defined as the length of the particle compared to its width. */ _this.lengthScale = 2;
31662
+ /** The pivot of particle. */ _this.pivot = new Vector3();
31663
+ _this._currentRenderModeMacro = ParticleRenderer._billboardModeMacro;
31664
+ _this.shaderData.enableMacro(ParticleRenderer._billboardModeMacro);
31665
+ _this._supportInstancedArrays = _this.engine._hardwareRenderer.canIUse(exports.GLCapabilityType.instancedArrays);
31585
31666
  return _this;
31667
+ }
31668
+ var _proto = ParticleRenderer.prototype;
31669
+ /**
31670
+ * @internal
31671
+ */ _proto._onEnable = function _onEnable() {
31672
+ if (this.generator.main.playOnEnabled) {
31673
+ this.generator.play(false);
31674
+ }
31586
31675
  };
31587
- _inherits$2(ParticleMaterial, BaseMaterial1);
31588
- var _proto = ParticleMaterial.prototype;
31589
31676
  /**
31590
- * @inheritdoc
31591
- */ _proto.clone = function clone() {
31592
- var dest = new ParticleMaterial(this._engine);
31593
- this.cloneTo(dest);
31594
- return dest;
31677
+ * @internal
31678
+ */ _proto._onDisable = function _onDisable() {
31679
+ this.generator.stop(false, exports.ParticleStopMode.StopEmittingAndClear);
31595
31680
  };
31596
- _create_class$3(ParticleMaterial, [
31681
+ /**
31682
+ * @internal
31683
+ */ _proto._prepareRender = function _prepareRender(context) {
31684
+ if (!this._supportInstancedArrays) {
31685
+ return;
31686
+ }
31687
+ var generator = this.generator;
31688
+ generator._update(this.engine.time.deltaTime);
31689
+ // No particles to render
31690
+ if (generator._firstActiveElement === generator._firstFreeElement) {
31691
+ return;
31692
+ }
31693
+ Renderer1.prototype._prepareRender.call(this, context);
31694
+ };
31695
+ /**
31696
+ * @internal
31697
+ */ _proto._updateBounds = function _updateBounds(worldBounds) {
31698
+ worldBounds.min.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
31699
+ worldBounds.max.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
31700
+ };
31701
+ /**
31702
+ * @internal
31703
+ */ _proto._updateShaderData = function _updateShaderData(context) {
31704
+ var shaderData = this.shaderData;
31705
+ shaderData.setFloat(ParticleRenderer._lengthScale, this.lengthScale);
31706
+ shaderData.setFloat(ParticleRenderer._speedScale, this.velocityScale);
31707
+ shaderData.setFloat(ParticleRenderer._currentTime, this.generator._playTime);
31708
+ shaderData.setVector3(ParticleRenderer._pivotOffsetProperty, this.pivot);
31709
+ this.generator._updateShaderData(shaderData);
31710
+ };
31711
+ _proto._render = function _render(context) {
31712
+ var generator = this.generator;
31713
+ var primitive = generator._primitive;
31714
+ if (generator._firstActiveElement < generator._firstFreeElement) {
31715
+ primitive.instanceCount = generator._firstFreeElement - generator._firstActiveElement;
31716
+ } else {
31717
+ var instanceCount = generator._currentParticleCount - generator._firstActiveElement;
31718
+ if (generator._firstFreeElement > 0) {
31719
+ instanceCount += generator._firstFreeElement;
31720
+ }
31721
+ primitive.instanceCount = instanceCount;
31722
+ }
31723
+ var material = this.getMaterial();
31724
+ var renderData = this._engine._renderDataPool.getFromPool();
31725
+ renderData.setX(this, material, generator._primitive, generator._subPrimitive);
31726
+ context.camera._renderPipeline.pushRenderData(context, renderData);
31727
+ };
31728
+ _proto._onDestroy = function _onDestroy() {
31729
+ this.generator._destroy();
31730
+ };
31731
+ _create_class$3(ParticleRenderer, [
31597
31732
  {
31598
- key: "baseColor",
31733
+ key: "renderMode",
31599
31734
  get: /**
31600
- * Base color.
31735
+ * Specifies how particles are rendered.
31601
31736
  */ function get() {
31602
- return this.shaderData.getColor(BaseMaterial._baseColorProp);
31737
+ return this._renderMode;
31603
31738
  },
31604
31739
  set: function set(value) {
31605
- var baseColor = this.shaderData.getColor(BaseMaterial._baseColorProp);
31606
- if (value !== baseColor) {
31607
- baseColor.copyFrom(value);
31740
+ if (this._renderMode !== value) {
31741
+ var lastRenderMode = this._renderMode;
31742
+ this._renderMode = value;
31743
+ var renderModeMacro = null;
31744
+ var shaderData = this.shaderData;
31745
+ switch(value){
31746
+ case exports.ParticleRenderMode.Billboard:
31747
+ renderModeMacro = ParticleRenderer._billboardModeMacro;
31748
+ break;
31749
+ case exports.ParticleRenderMode.StretchBillboard:
31750
+ renderModeMacro = ParticleRenderer._stretchedBillboardModeMacro;
31751
+ break;
31752
+ case exports.ParticleRenderMode.HorizontalBillboard:
31753
+ throw "Not implemented";
31754
+ case exports.ParticleRenderMode.VerticalBillboard:
31755
+ throw "Not implemented";
31756
+ case exports.ParticleRenderMode.Mesh:
31757
+ throw "Not implemented";
31758
+ }
31759
+ if (this._currentRenderModeMacro !== renderModeMacro) {
31760
+ this._currentRenderModeMacro && shaderData.disableMacro(this._currentRenderModeMacro);
31761
+ renderModeMacro && shaderData.enableMacro(renderModeMacro);
31762
+ this._currentRenderModeMacro = renderModeMacro;
31763
+ }
31764
+ // @ts-ignore
31765
+ if (lastRenderMode !== exports.ParticleRenderMode.Mesh !== (value === exports.ParticleRenderMode.Mesh)) {
31766
+ this.generator._reorganizeGeometryBuffers();
31767
+ }
31608
31768
  }
31609
31769
  }
31610
31770
  },
31611
31771
  {
31612
- key: "baseTexture",
31772
+ key: "mesh",
31613
31773
  get: /**
31614
- * Base texture.
31774
+ * The mesh of particle.
31775
+ * @remarks Valid when `renderMode` is `Mesh`.
31615
31776
  */ function get() {
31616
- return this.shaderData.getTexture(BaseMaterial._baseTextureProp);
31777
+ return this._mesh;
31617
31778
  },
31618
31779
  set: function set(value) {
31619
- this.shaderData.setTexture(BaseMaterial._baseTextureProp, value);
31620
- if (value) {
31621
- this.shaderData.enableMacro(BaseMaterial._baseTextureMacro);
31622
- } else {
31623
- this.shaderData.disableMacro(BaseMaterial._baseTextureMacro);
31780
+ var lastMesh = this._mesh;
31781
+ if (lastMesh !== value) {
31782
+ var _lastMesh, _value;
31783
+ this._mesh = value;
31784
+ (_lastMesh = lastMesh) == null ? void 0 : _lastMesh._addReferCount(-1);
31785
+ (_value = value) == null ? void 0 : _value._addReferCount(1);
31786
+ if (this.renderMode === exports.ParticleRenderMode.Mesh) {
31787
+ this.generator._reorganizeGeometryBuffers();
31788
+ }
31624
31789
  }
31625
31790
  }
31626
31791
  }
31627
31792
  ]);
31628
- return ParticleMaterial;
31629
- }(BaseMaterial);
31630
- var SubPrimitive = function SubPrimitive() {};
31793
+ return ParticleRenderer;
31794
+ }(exports.Renderer);
31795
+ (function() {
31796
+ ParticleRenderer._billboardModeMacro = ShaderMacro.getByName("RENDERER_MODE_SPHERE_BILLBOARD");
31797
+ })();
31798
+ (function() {
31799
+ ParticleRenderer._stretchedBillboardModeMacro = ShaderMacro.getByName("RENDERER_MODE_STRETCHED_BILLBOARD");
31800
+ })();
31801
+ (function() {
31802
+ ParticleRenderer._horizontalBillboardModeMacro = ShaderMacro.getByName("RENDERER_MODE_HORIZONTAL_BILLBOARD");
31803
+ })();
31804
+ (function() {
31805
+ ParticleRenderer._verticalBillboardModeMacro = ShaderMacro.getByName("RENDERER_MODE_VERTICAL_BILLBOARD");
31806
+ })();
31807
+ (function() {
31808
+ ParticleRenderer._renderModeMeshMacro = ShaderMacro.getByName("RENDERER_MODE_MESH");
31809
+ })();
31810
+ (function() {
31811
+ ParticleRenderer._pivotOffsetProperty = ShaderProperty.getByName("renderer_PivotOffset");
31812
+ })();
31813
+ (function() {
31814
+ ParticleRenderer._lengthScale = ShaderProperty.getByName("renderer_StretchedBillboardLengthScale");
31815
+ })();
31816
+ (function() {
31817
+ ParticleRenderer._speedScale = ShaderProperty.getByName("renderer_StretchedBillboardSpeedScale");
31818
+ })();
31819
+ (function() {
31820
+ ParticleRenderer._currentTime = ShaderProperty.getByName("renderer_CurrentTime");
31821
+ })();
31822
+ __decorate$1([
31823
+ deepClone
31824
+ ], ParticleRenderer.prototype, "generator", void 0);
31825
+ __decorate$1([
31826
+ shallowClone
31827
+ ], ParticleRenderer.prototype, "pivot", void 0);
31631
31828
  /**
31632
31829
  * Particle curve mode.
31633
31830
  */ exports.ParticleCurveMode = void 0;
@@ -31646,17 +31843,6 @@
31646
31843
  ParticleGradientMode[ParticleGradientMode[/* Single color gradient curve mode. */ "Gradient"] = 2] = "Gradient";
31647
31844
  ParticleGradientMode[ParticleGradientMode[/* Random value between two color gradients. */ "TwoGradients"] = 3] = "TwoGradients";
31648
31845
  })(exports.ParticleGradientMode || (exports.ParticleGradientMode = {}));
31649
- /**
31650
- * The rendering mode for particle renderer.
31651
- */ exports.ParticleRenderMode = void 0;
31652
- (function(ParticleRenderMode) {
31653
- ParticleRenderMode[ParticleRenderMode[/** Render particles as billboards facing the active camera. */ "Billboard"] = 0] = "Billboard";
31654
- ParticleRenderMode[ParticleRenderMode[/** Stretch particles in the direction of motion. */ "StretchBillboard"] = 1] = "StretchBillboard";
31655
- ParticleRenderMode[ParticleRenderMode[/** Render particles as billboards always facing up along the y-Axis. */ "HorizontalBillboard"] = 2] = "HorizontalBillboard";
31656
- ParticleRenderMode[ParticleRenderMode[/** Render particles as billboards always facing the player, but not pitching along the x-Axis. */ "VerticalBillboard"] = 3] = "VerticalBillboard";
31657
- ParticleRenderMode[ParticleRenderMode[/** Render particles as meshes. */ "Mesh"] = 4] = "Mesh";
31658
- ParticleRenderMode[ParticleRenderMode[/** Do not render particles. */ "None"] = 5] = "None";
31659
- })(exports.ParticleRenderMode || (exports.ParticleRenderMode = {}));
31660
31846
  /**
31661
31847
  * The space to simulate particles in.
31662
31848
  */ exports.ParticleSimulationSpace = void 0;
@@ -31664,11 +31850,6 @@
31664
31850
  ParticleSimulationSpace[ParticleSimulationSpace[/** Simulate particles in local space. */ "Local"] = 0] = "Local";
31665
31851
  ParticleSimulationSpace[ParticleSimulationSpace[/** Simulate particles in world space. */ "World"] = 1] = "World";
31666
31852
  })(exports.ParticleSimulationSpace || (exports.ParticleSimulationSpace = {}));
31667
- exports.ParticleStopMode = void 0;
31668
- (function(ParticleStopMode) {
31669
- ParticleStopMode[ParticleStopMode[/** Stop emitting new particles and clear existing particles immediately. */ "StopEmittingAndClear"] = 0] = "StopEmittingAndClear";
31670
- ParticleStopMode[ParticleStopMode[/** Stop emitting new particles, but keep existing particles until they expire. */ "StopEmitting"] = 1] = "StopEmitting";
31671
- })(exports.ParticleStopMode || (exports.ParticleStopMode = {}));
31672
31853
  /**
31673
31854
  * @internal
31674
31855
  */ var ParticleRandomSubSeeds;
@@ -33604,181 +33785,60 @@
33604
33785
  ignoreClone
33605
33786
  ], ParticleGenerator.prototype, "_instanceVertices", void 0);
33606
33787
  /**
33607
- * Particle Renderer Component.
33608
- */ var ParticleRenderer = /*#__PURE__*/ function(Renderer1) {
33609
- _inherits$2(ParticleRenderer, Renderer1);
33610
- function ParticleRenderer(entity) {
33788
+ * Particle Material.
33789
+ */ var ParticleMaterial = /*#__PURE__*/ function(BaseMaterial1) {
33790
+ var ParticleMaterial = function ParticleMaterial(engine) {
33611
33791
  var _this;
33612
- _this = Renderer1.call(this, entity) || this;
33613
- /** Particle generator. */ _this.generator = new ParticleGenerator(_assert_this_initialized(_this));
33614
- /** Specifies how much particles stretch depending on their velocity. */ _this.velocityScale = 0;
33615
- /** How much are the particles stretched in their direction of motion, defined as the length of the particle compared to its width. */ _this.lengthScale = 2;
33616
- /** The pivot of particle. */ _this.pivot = new Vector3();
33617
- _this._currentRenderModeMacro = ParticleRenderer._billboardModeMacro;
33618
- _this.shaderData.enableMacro(ParticleRenderer._billboardModeMacro);
33619
- _this._supportInstancedArrays = _this.engine._hardwareRenderer.canIUse(exports.GLCapabilityType.instancedArrays);
33792
+ _this = BaseMaterial1.call(this, engine, Shader.find("particle-shader")) || this;
33793
+ var shaderData = _this.shaderData;
33794
+ shaderData.enableMacro("MATERIAL_OMIT_NORMAL");
33795
+ shaderData.setColor(BaseMaterial._baseColorProp, new Color$1(1, 1, 1, 1));
33796
+ _this.isTransparent = true;
33620
33797
  return _this;
33621
- }
33622
- var _proto = ParticleRenderer.prototype;
33623
- /**
33624
- * @internal
33625
- */ _proto._onEnable = function _onEnable() {
33626
- if (this.generator.main.playOnEnabled) {
33627
- this.generator.play(false);
33628
- }
33629
- };
33630
- /**
33631
- * @internal
33632
- */ _proto._onDisable = function _onDisable() {
33633
- this.generator.stop(false, exports.ParticleStopMode.StopEmittingAndClear);
33634
- };
33635
- /**
33636
- * @internal
33637
- */ _proto._prepareRender = function _prepareRender(context) {
33638
- if (!this._supportInstancedArrays) {
33639
- return;
33640
- }
33641
- var generator = this.generator;
33642
- generator._update(this.engine.time.deltaTime);
33643
- // No particles to render
33644
- if (generator._firstActiveElement === generator._firstFreeElement) {
33645
- return;
33646
- }
33647
- Renderer1.prototype._prepareRender.call(this, context);
33648
- };
33649
- /**
33650
- * @internal
33651
- */ _proto._updateBounds = function _updateBounds(worldBounds) {
33652
- worldBounds.min.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
33653
- worldBounds.max.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
33654
33798
  };
33799
+ _inherits$2(ParticleMaterial, BaseMaterial1);
33800
+ var _proto = ParticleMaterial.prototype;
33655
33801
  /**
33656
- * @internal
33657
- */ _proto._updateShaderData = function _updateShaderData(context) {
33658
- var shaderData = this.shaderData;
33659
- shaderData.setFloat(ParticleRenderer._lengthScale, this.lengthScale);
33660
- shaderData.setFloat(ParticleRenderer._speedScale, this.velocityScale);
33661
- shaderData.setFloat(ParticleRenderer._currentTime, this.generator._playTime);
33662
- shaderData.setVector3(ParticleRenderer._pivotOffsetProperty, this.pivot);
33663
- this.generator._updateShaderData(shaderData);
33664
- };
33665
- _proto._render = function _render(context) {
33666
- var generator = this.generator;
33667
- var primitive = generator._primitive;
33668
- if (generator._firstActiveElement < generator._firstFreeElement) {
33669
- primitive.instanceCount = generator._firstFreeElement - generator._firstActiveElement;
33670
- } else {
33671
- var instanceCount = generator._currentParticleCount - generator._firstActiveElement;
33672
- if (generator._firstFreeElement > 0) {
33673
- instanceCount += generator._firstFreeElement;
33674
- }
33675
- primitive.instanceCount = instanceCount;
33676
- }
33677
- var material = this.getMaterial();
33678
- var renderData = this._engine._renderDataPool.getFromPool();
33679
- renderData.setX(this, material, generator._primitive, generator._subPrimitive);
33680
- context.camera._renderPipeline.pushRenderData(context, renderData);
33681
- };
33682
- _proto._onDestroy = function _onDestroy() {
33683
- this.generator._destroy();
33802
+ * @inheritdoc
33803
+ */ _proto.clone = function clone() {
33804
+ var dest = new ParticleMaterial(this._engine);
33805
+ this.cloneTo(dest);
33806
+ return dest;
33684
33807
  };
33685
- _create_class$3(ParticleRenderer, [
33808
+ _create_class$3(ParticleMaterial, [
33686
33809
  {
33687
- key: "renderMode",
33810
+ key: "baseColor",
33688
33811
  get: /**
33689
- * Specifies how particles are rendered.
33812
+ * Base color.
33690
33813
  */ function get() {
33691
- return this._renderMode;
33814
+ return this.shaderData.getColor(BaseMaterial._baseColorProp);
33692
33815
  },
33693
33816
  set: function set(value) {
33694
- if (this._renderMode !== value) {
33695
- var lastRenderMode = this._renderMode;
33696
- this._renderMode = value;
33697
- var renderModeMacro = null;
33698
- var shaderData = this.shaderData;
33699
- switch(value){
33700
- case exports.ParticleRenderMode.Billboard:
33701
- renderModeMacro = ParticleRenderer._billboardModeMacro;
33702
- break;
33703
- case exports.ParticleRenderMode.StretchBillboard:
33704
- renderModeMacro = ParticleRenderer._stretchedBillboardModeMacro;
33705
- break;
33706
- case exports.ParticleRenderMode.HorizontalBillboard:
33707
- throw "Not implemented";
33708
- case exports.ParticleRenderMode.VerticalBillboard:
33709
- throw "Not implemented";
33710
- case exports.ParticleRenderMode.Mesh:
33711
- throw "Not implemented";
33712
- }
33713
- if (this._currentRenderModeMacro !== renderModeMacro) {
33714
- this._currentRenderModeMacro && shaderData.disableMacro(this._currentRenderModeMacro);
33715
- renderModeMacro && shaderData.enableMacro(renderModeMacro);
33716
- this._currentRenderModeMacro = renderModeMacro;
33717
- }
33718
- // @ts-ignore
33719
- if (lastRenderMode !== exports.ParticleRenderMode.Mesh !== (value === exports.ParticleRenderMode.Mesh)) {
33720
- this.generator._reorganizeGeometryBuffers();
33721
- }
33817
+ var baseColor = this.shaderData.getColor(BaseMaterial._baseColorProp);
33818
+ if (value !== baseColor) {
33819
+ baseColor.copyFrom(value);
33722
33820
  }
33723
33821
  }
33724
33822
  },
33725
33823
  {
33726
- key: "mesh",
33824
+ key: "baseTexture",
33727
33825
  get: /**
33728
- * The mesh of particle.
33729
- * @remarks Valid when `renderMode` is `Mesh`.
33826
+ * Base texture.
33730
33827
  */ function get() {
33731
- return this._mesh;
33828
+ return this.shaderData.getTexture(BaseMaterial._baseTextureProp);
33732
33829
  },
33733
33830
  set: function set(value) {
33734
- var lastMesh = this._mesh;
33735
- if (lastMesh !== value) {
33736
- var _lastMesh, _value;
33737
- this._mesh = value;
33738
- (_lastMesh = lastMesh) == null ? void 0 : _lastMesh._addReferCount(-1);
33739
- (_value = value) == null ? void 0 : _value._addReferCount(1);
33740
- if (this.renderMode === exports.ParticleRenderMode.Mesh) {
33741
- this.generator._reorganizeGeometryBuffers();
33742
- }
33831
+ this.shaderData.setTexture(BaseMaterial._baseTextureProp, value);
33832
+ if (value) {
33833
+ this.shaderData.enableMacro(BaseMaterial._baseTextureMacro);
33834
+ } else {
33835
+ this.shaderData.disableMacro(BaseMaterial._baseTextureMacro);
33743
33836
  }
33744
33837
  }
33745
33838
  }
33746
33839
  ]);
33747
- return ParticleRenderer;
33748
- }(exports.Renderer);
33749
- (function() {
33750
- ParticleRenderer._billboardModeMacro = ShaderMacro.getByName("RENDERER_MODE_SPHERE_BILLBOARD");
33751
- })();
33752
- (function() {
33753
- ParticleRenderer._stretchedBillboardModeMacro = ShaderMacro.getByName("RENDERER_MODE_STRETCHED_BILLBOARD");
33754
- })();
33755
- (function() {
33756
- ParticleRenderer._horizontalBillboardModeMacro = ShaderMacro.getByName("RENDERER_MODE_HORIZONTAL_BILLBOARD");
33757
- })();
33758
- (function() {
33759
- ParticleRenderer._verticalBillboardModeMacro = ShaderMacro.getByName("RENDERER_MODE_VERTICAL_BILLBOARD");
33760
- })();
33761
- (function() {
33762
- ParticleRenderer._renderModeMeshMacro = ShaderMacro.getByName("RENDERER_MODE_MESH");
33763
- })();
33764
- (function() {
33765
- ParticleRenderer._pivotOffsetProperty = ShaderProperty.getByName("renderer_PivotOffset");
33766
- })();
33767
- (function() {
33768
- ParticleRenderer._lengthScale = ShaderProperty.getByName("renderer_StretchedBillboardLengthScale");
33769
- })();
33770
- (function() {
33771
- ParticleRenderer._speedScale = ShaderProperty.getByName("renderer_StretchedBillboardSpeedScale");
33772
- })();
33773
- (function() {
33774
- ParticleRenderer._currentTime = ShaderProperty.getByName("renderer_CurrentTime");
33775
- })();
33776
- __decorate$1([
33777
- deepClone
33778
- ], ParticleRenderer.prototype, "generator", void 0);
33779
- __decorate$1([
33780
- shallowClone
33781
- ], ParticleRenderer.prototype, "pivot", void 0);
33840
+ return ParticleMaterial;
33841
+ }(BaseMaterial);
33782
33842
  /**
33783
33843
  * A burst is a particle emission event, where a number of particles are all emitted at the same time
33784
33844
  */ var Burst = function Burst(time, count) {
@@ -34520,6 +34580,7 @@
34520
34580
  ParticleCompositeCurve: ParticleCompositeCurve,
34521
34581
  ParticleCurve: ParticleCurve,
34522
34582
  get ParticleCurveMode () { return exports.ParticleCurveMode; },
34583
+ ParticleGenerator: ParticleGenerator,
34523
34584
  get ParticleGradientMode () { return exports.ParticleGradientMode; },
34524
34585
  ParticleMaterial: ParticleMaterial,
34525
34586
  get ParticleRenderMode () { return exports.ParticleRenderMode; },
@@ -37439,12 +37500,12 @@
37439
37500
  return _construct.apply(null, arguments);
37440
37501
  }
37441
37502
  var ReflectionParser = /*#__PURE__*/ function() {
37442
- var ReflectionParser = function ReflectionParser() {};
37443
- ReflectionParser.registerCustomParseComponent = function registerCustomParseComponent(componentType, handle) {
37444
- this.customParseComponentHandles[componentType] = handle;
37503
+ var ReflectionParser = function ReflectionParser(_context) {
37504
+ this._context = _context;
37445
37505
  };
37446
- ReflectionParser.parseEntity = function parseEntity(entityConfig, engine) {
37447
- return ReflectionParser.getEntityByConfig(entityConfig, engine).then(function(entity) {
37506
+ var _proto = ReflectionParser.prototype;
37507
+ _proto.parseEntity = function parseEntity(entityConfig) {
37508
+ return this._getEntityByConfig(entityConfig).then(function(entity) {
37448
37509
  var _entityConfig_isActive;
37449
37510
  entity.isActive = (_entityConfig_isActive = entityConfig.isActive) != null ? _entityConfig_isActive : true;
37450
37511
  var position = entityConfig.position, rotation = entityConfig.rotation, scale = entityConfig.scale;
@@ -37454,72 +37515,29 @@
37454
37515
  return entity;
37455
37516
  });
37456
37517
  };
37457
- ReflectionParser.getEntityByConfig = function getEntityByConfig(entityConfig, engine) {
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;
37518
+ _proto.parseClassObject = function parseClassObject(item) {
37477
37519
  var Class = Loader.getClass(item.class);
37478
37520
  var _item_constructParams;
37479
37521
  var params = (_item_constructParams = item.constructParams) != null ? _item_constructParams : [];
37480
37522
  var instance = _construct(Class, [].concat(params));
37481
- return this.parsePropsAndMethods(instance, item, engine, resourceManager);
37523
+ return this.parsePropsAndMethods(instance, item);
37482
37524
  };
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
- }
37504
- };
37505
- ReflectionParser.parsePropsAndMethods = function parsePropsAndMethods(instance, item, engine, resourceManager) {
37506
- if (resourceManager === void 0) resourceManager = engine.resourceManager;
37507
- var _this = this;
37525
+ _proto.parsePropsAndMethods = function parsePropsAndMethods(instance, item) {
37508
37526
  var promises = [];
37509
37527
  if (item.methods) {
37510
37528
  for(var methodName in item.methods){
37511
37529
  var methodParams = item.methods[methodName];
37512
37530
  for(var i = 0, count = methodParams.length; i < count; i++){
37513
37531
  var params = methodParams[i];
37514
- var promise = this.parseMethod(instance, methodName, params, engine, resourceManager);
37532
+ var promise = this.parseMethod(instance, methodName, params);
37515
37533
  promises.push(promise);
37516
37534
  }
37517
37535
  }
37518
37536
  }
37519
37537
  if (item.props) {
37520
- var _this1 = this, _loop = function _loop(key) {
37538
+ var _this = this, _loop = function _loop(key) {
37521
37539
  var value = item.props[key];
37522
- var promise = _this1.parseBasicType(value, engine).then(function(v) {
37540
+ var promise = _this.parseBasicType(value).then(function(v) {
37523
37541
  return instance[key] = v;
37524
37542
  });
37525
37543
  promises.push(promise);
@@ -37527,27 +37545,76 @@
37527
37545
  for(var key in item.props)_loop(key);
37528
37546
  }
37529
37547
  return Promise.all(promises).then(function() {
37530
- var handle = _this.customParseComponentHandles[instance.constructor.name];
37531
- if (handle) return handle(instance, item, engine);
37548
+ var handle = ReflectionParser.customParseComponentHandles[instance.constructor.name];
37549
+ if (handle) return handle(instance, item);
37532
37550
  else return instance;
37533
37551
  });
37534
37552
  };
37535
- ReflectionParser.parseMethod = function parseMethod(instance, methodName, methodParams, engine, resourceManager) {
37536
- if (resourceManager === void 0) resourceManager = engine.resourceManager;
37553
+ _proto.parseMethod = function parseMethod(instance, methodName, methodParams) {
37537
37554
  var _this = this;
37538
37555
  return Promise.all(methodParams.map(function(param) {
37539
- return _this.parseBasicType(param, engine, resourceManager);
37556
+ return _this.parseBasicType(param);
37540
37557
  })).then(function(result) {
37541
37558
  var _instance;
37542
37559
  return (_instance = instance)[methodName].apply(_instance, [].concat(result));
37543
37560
  });
37544
37561
  };
37562
+ _proto.parseBasicType = function parseBasicType(value) {
37563
+ var _this = this;
37564
+ if (Array.isArray(value)) {
37565
+ return Promise.all(value.map(function(item) {
37566
+ return _this.parseBasicType(item);
37567
+ }));
37568
+ } else if (typeof value === "object" && value != null) {
37569
+ if (ReflectionParser._isClass(value)) {
37570
+ // class object
37571
+ return this.parseClassObject(value);
37572
+ } else if (ReflectionParser._isAssetRef(value)) {
37573
+ // reference object
37574
+ // @ts-ignore
37575
+ return this._context.resourceManager.getResourceByRef(value);
37576
+ } else if (ReflectionParser._isEntityRef(value)) {
37577
+ // entity reference
37578
+ return Promise.resolve(this._context.entityMap.get(value.entityId));
37579
+ } else {
37580
+ // basic type
37581
+ return Promise.resolve(value);
37582
+ }
37583
+ } else {
37584
+ return Promise.resolve(value);
37585
+ }
37586
+ };
37587
+ _proto._getEntityByConfig = function _getEntityByConfig(entityConfig) {
37588
+ // @ts-ignore
37589
+ var assetRefId = entityConfig.assetRefId;
37590
+ var engine = this._context.engine;
37591
+ if (assetRefId) {
37592
+ return engine.resourceManager // @ts-ignore
37593
+ .getResourceByRef({
37594
+ refId: assetRefId,
37595
+ key: entityConfig.key,
37596
+ isClone: entityConfig.isClone
37597
+ }).then(function(entity) {
37598
+ entity.name = entityConfig.name;
37599
+ return entity;
37600
+ });
37601
+ } else {
37602
+ var entity = new Entity(engine, entityConfig.name);
37603
+ return Promise.resolve(entity);
37604
+ }
37605
+ };
37606
+ ReflectionParser.registerCustomParseComponent = function registerCustomParseComponent(componentType, handle) {
37607
+ this.customParseComponentHandles[componentType] = handle;
37608
+ };
37545
37609
  ReflectionParser._isClass = function _isClass(value) {
37546
37610
  return value["class"] != undefined;
37547
37611
  };
37548
- ReflectionParser._isRef = function _isRef(value) {
37612
+ ReflectionParser._isAssetRef = function _isAssetRef(value) {
37549
37613
  return value["refId"] != undefined;
37550
37614
  };
37615
+ ReflectionParser._isEntityRef = function _isEntityRef(value) {
37616
+ return value["entityId"] != undefined;
37617
+ };
37551
37618
  return ReflectionParser;
37552
37619
  }();
37553
37620
  (function() {
@@ -37803,6 +37870,8 @@
37803
37870
  this.assets = new Map();
37804
37871
  this.entityConfigMap = new Map();
37805
37872
  this.rootIds = [];
37873
+ this.engine = scene.engine;
37874
+ this.resourceManager = scene.engine.resourceManager;
37806
37875
  };
37807
37876
  var _proto = SceneParserContext.prototype;
37808
37877
  _proto.destroy = function destroy() {
@@ -37818,7 +37887,7 @@
37818
37887
  var SceneParser = function SceneParser(context) {
37819
37888
  var _this = this;
37820
37889
  this.context = context;
37821
- this._engine = this.context.scene.engine;
37890
+ this._engine = context.scene.engine;
37822
37891
  this._organizeEntities = this._organizeEntities.bind(this);
37823
37892
  this._parseComponents = this._parseComponents.bind(this);
37824
37893
  this._clearAndResolveScene = this._clearAndResolveScene.bind(this);
@@ -37826,22 +37895,24 @@
37826
37895
  _this._reject = reject;
37827
37896
  _this._resolve = resolve;
37828
37897
  });
37898
+ this._reflectionParser = new ReflectionParser(context);
37829
37899
  };
37830
37900
  var _proto = SceneParser.prototype;
37831
37901
  /** start parse the scene */ _proto.start = function start() {
37832
37902
  this._parseEntities().then(this._organizeEntities).then(this._parseComponents).then(this._clearAndResolveScene).then(this._resolve).catch(this._reject);
37833
37903
  };
37834
37904
  _proto._parseEntities = function _parseEntities() {
37905
+ var _this = this;
37835
37906
  var entitiesConfig = this.context.originalData.entities;
37836
37907
  var entityConfigMap = this.context.entityConfigMap;
37837
37908
  var entitiesMap = this.context.entityMap;
37838
37909
  var rootIds = this.context.rootIds;
37839
- var engine = this._engine;
37910
+ this._engine;
37840
37911
  var promises = entitiesConfig.map(function(entityConfig) {
37841
37912
  entityConfigMap.set(entityConfig.id, entityConfig);
37842
37913
  // record root entities
37843
37914
  if (!entityConfig.parent) rootIds.push(entityConfig.id);
37844
- return ReflectionParser.parseEntity(entityConfig, engine);
37915
+ return _this._reflectionParser.parseEntity(entityConfig);
37845
37916
  });
37846
37917
  return Promise.all(promises).then(function(entities) {
37847
37918
  for(var i = 0, l = entities.length; i < l; i++){
@@ -37879,7 +37950,7 @@
37879
37950
  component = entity.getComponent(Loader.getClass(key));
37880
37951
  }
37881
37952
  component = component || entity.addComponent(Loader.getClass(key));
37882
- var promise = ReflectionParser.parsePropsAndMethods(component, componentConfig, entity.engine);
37953
+ var promise = this._reflectionParser.parsePropsAndMethods(component, componentConfig);
37883
37954
  promises.push(promise);
37884
37955
  }
37885
37956
  }
@@ -41210,8 +41281,7 @@
41210
41281
  mipmap: (_samplerInfo = samplerInfo) == null ? void 0 : _samplerInfo.mipmap
41211
41282
  }
41212
41283
  }).then(function(texture) {
41213
- var _texture;
41214
- (_texture = texture).name || (_texture.name = textureName || imageName || "texture_" + index);
41284
+ texture.name = textureName || imageName || texture.name || "texture_" + index;
41215
41285
  useSampler && GLTFUtils.parseSampler(texture, samplerInfo);
41216
41286
  return texture;
41217
41287
  });
@@ -42299,6 +42369,38 @@
42299
42369
  ""
42300
42370
  ])
42301
42371
  ], TextureCubeLoader);
42372
+ var ProjectLoader = /*#__PURE__*/ function(Loader1) {
42373
+ var ProjectLoader = function ProjectLoader() {
42374
+ return Loader1.apply(this, arguments);
42375
+ };
42376
+ _inherits(ProjectLoader, Loader1);
42377
+ var _proto = ProjectLoader.prototype;
42378
+ _proto.load = function load(item, resourceManager) {
42379
+ var _this = this;
42380
+ var engine = resourceManager.engine;
42381
+ return new AssetPromise(function(resolve, reject) {
42382
+ _this.request(item.url, {
42383
+ type: "json"
42384
+ }).then(function(data) {
42385
+ // @ts-ignore
42386
+ engine.resourceManager.initVirtualResources(data.files);
42387
+ return resourceManager.load({
42388
+ type: exports.AssetType.Scene,
42389
+ url: data.scene
42390
+ }).then(function(scene) {
42391
+ engine.sceneManager.activeScene = scene;
42392
+ resolve();
42393
+ });
42394
+ }).catch(reject);
42395
+ });
42396
+ };
42397
+ return ProjectLoader;
42398
+ }(Loader);
42399
+ ProjectLoader = __decorate([
42400
+ resourceLoader(exports.AssetType.Project, [
42401
+ "proj"
42402
+ ], true)
42403
+ ], ProjectLoader);
42302
42404
  var SceneLoader = /*#__PURE__*/ function(Loader1) {
42303
42405
  var SceneLoader = function SceneLoader() {
42304
42406
  return Loader1.apply(this, arguments);
@@ -42895,7 +42997,7 @@
42895
42997
  ], GALACEAN_animation_event);
42896
42998
 
42897
42999
  //@ts-ignore
42898
- var version = "1.1.0-beta.4";
43000
+ var version = "1.1.0-beta.6";
42899
43001
  console.log("Galacean engine version: " + version);
42900
43002
  for(var key in CoreObjects){
42901
43003
  Loader.registerClass(key, CoreObjects[key]);
@@ -42981,6 +43083,7 @@
42981
43083
  exports.PBRSpecularMaterial = PBRSpecularMaterial;
42982
43084
  exports.ParticleCompositeCurve = ParticleCompositeCurve;
42983
43085
  exports.ParticleCurve = ParticleCurve;
43086
+ exports.ParticleGenerator = ParticleGenerator;
42984
43087
  exports.ParticleMaterial = ParticleMaterial;
42985
43088
  exports.ParticleRenderer = ParticleRenderer;
42986
43089
  exports.PhysicsMaterial = PhysicsMaterial;