@galacean/engine 1.1.0-beta.1 → 1.1.0-beta.10

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,15 +5511,16 @@
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
+ break;
5523
5524
  default:
5524
5525
  var _target, _k;
5525
5526
  var targetOProperty = (_target = target)[_k = k] || (_target[_k] = new sourceProperty.constructor());
@@ -6238,7 +6239,7 @@
6238
6239
  /**
6239
6240
  * Two-dimensional texture array.
6240
6241
  */ var Texture2DArray = /*#__PURE__*/ function(Texture1) {
6241
- var Texture2DArray = function Texture2DArray(engine, width, height, length1, format, mipmap) {
6242
+ var Texture2DArray = function Texture2DArray(engine, width, height, length, format, mipmap) {
6242
6243
  if (format === void 0) format = exports.TextureFormat.R8G8B8A8;
6243
6244
  if (mipmap === void 0) mipmap = true;
6244
6245
  var _this;
@@ -6246,7 +6247,7 @@
6246
6247
  _this._mipmap = mipmap;
6247
6248
  _this._width = width;
6248
6249
  _this._height = height;
6249
- _this._length = length1;
6250
+ _this._length = length;
6250
6251
  _this._format = format;
6251
6252
  _this._mipmapCount = _this._getMipmapCount();
6252
6253
  _this._platformTexture = engine._hardwareRenderer.createPlatformTexture2DArray(_assert_this_initialized(_this));
@@ -6267,11 +6268,11 @@
6267
6268
  * @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
6269
  * @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
6270
  * @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) {
6271
+ */ _proto.setPixelBuffer = function setPixelBuffer(offsetIndex, colorBuffer, mipLevel, x, y, width, height, length) {
6271
6272
  if (mipLevel === void 0) mipLevel = 0;
6272
6273
  if (x === void 0) x = 0;
6273
6274
  if (y === void 0) y = 0;
6274
- this._platformTexture.setPixelBuffer(offsetIndex, colorBuffer, mipLevel, x, y, width, height, length1);
6275
+ this._platformTexture.setPixelBuffer(offsetIndex, colorBuffer, mipLevel, x, y, width, height, length);
6275
6276
  this._isContentLost = false;
6276
6277
  };
6277
6278
  /**
@@ -7477,8 +7478,8 @@
7477
7478
  var _this;
7478
7479
  _this = EngineObject1.call(this, entity.engine) || this;
7479
7480
  /** @internal */ _this._awoken = false;
7480
- _this._phasedActive = false;
7481
7481
  _this._phasedActiveInScene = false;
7482
+ _this._phasedActive = false;
7482
7483
  _this._enabled = true;
7483
7484
  _this._entity = entity;
7484
7485
  return _this;
@@ -7611,10 +7612,10 @@
7611
7612
  ], Component.prototype, "_awoken", void 0);
7612
7613
  __decorate$1([
7613
7614
  ignoreClone
7614
- ], Component.prototype, "_phasedActive", void 0);
7615
+ ], Component.prototype, "_phasedActiveInScene", void 0);
7615
7616
  __decorate$1([
7616
7617
  ignoreClone
7617
- ], Component.prototype, "_phasedActiveInScene", void 0);
7618
+ ], Component.prototype, "_phasedActive", void 0);
7618
7619
  __decorate$1([
7619
7620
  assignmentClone
7620
7621
  ], Component.prototype, "_enabled", void 0);
@@ -7769,14 +7770,14 @@
7769
7770
  }
7770
7771
  return end;
7771
7772
  };
7772
- _proto.forEach = function forEach(callbackFn) {
7773
+ _proto.forEach = function forEach(callbackFn, swapFn) {
7773
7774
  this._startLoop();
7774
7775
  var elements = this._elements;
7775
7776
  for(var i = 0; i < this.length; i++){
7776
7777
  var element = elements[i];
7777
7778
  element && callbackFn(element);
7778
7779
  }
7779
- this._endLoop();
7780
+ this._endLoop(swapFn);
7780
7781
  };
7781
7782
  _proto.forEachAndClean = function forEachAndClean(callbackFn) {
7782
7783
  this._startLoop();
@@ -7793,16 +7794,24 @@
7793
7794
  _proto._startLoop = function _startLoop() {
7794
7795
  this._isLooping = true;
7795
7796
  };
7796
- _proto._endLoop = function _endLoop() {
7797
+ _proto._endLoop = function _endLoop(swapFn) {
7797
7798
  this._isLooping = false;
7798
7799
  if (this._blankCount) {
7800
+ var from = 0;
7801
+ var to = this.length - 1;
7799
7802
  var elements = this._elements;
7800
- for(var i = 0, j = 0, n = this.length; i < n; i++){
7801
- var element = elements[i];
7802
- if (element) {
7803
- elements[j++] = element;
7804
- }
7805
- }
7803
+ partition: do {
7804
+ while(elements[from])if (++from >= to) {
7805
+ break partition;
7806
+ }
7807
+ while(!elements[to])if (from >= --to) {
7808
+ break partition;
7809
+ }
7810
+ var swapElement = elements[to];
7811
+ swapFn(swapElement, from);
7812
+ elements[from++] = swapElement;
7813
+ elements[to--] = null;
7814
+ }while (from < to);
7806
7815
  this.length -= this._blankCount;
7807
7816
  this._blankCount = 0;
7808
7817
  }
@@ -7890,11 +7899,11 @@
7890
7899
  var pathArr = this._stringToPath(path);
7891
7900
  var object = target;
7892
7901
  var index = 0;
7893
- var length1 = pathArr.length;
7894
- while(object != null && index < length1){
7902
+ var length = pathArr.length;
7903
+ while(object != null && index < length){
7895
7904
  object = object[pathArr[index++]];
7896
7905
  }
7897
- return index && index == length1 ? object : undefined;
7906
+ return index && index == length ? object : undefined;
7898
7907
  };
7899
7908
  /**
7900
7909
  * Fast remove an element from array.
@@ -9071,7 +9080,7 @@
9071
9080
  */ _proto.findByPath = function findByPath(path) {
9072
9081
  var splits = path.split("/");
9073
9082
  var entity = this;
9074
- for(var i = 0, length1 = splits.length; i < length1; ++i){
9083
+ for(var i = 0, length = splits.length; i < length; ++i){
9075
9084
  var split = splits[i];
9076
9085
  if (split) {
9077
9086
  entity = Entity._findChildByName(entity, split);
@@ -9303,7 +9312,7 @@
9303
9312
  };
9304
9313
  _proto._setActiveComponents = function _setActiveComponents(isActive, activeChangeFlag) {
9305
9314
  var activeChangedComponents = this._activeChangedComponents;
9306
- for(var i = 0, length1 = activeChangedComponents.length; i < length1; ++i){
9315
+ for(var i = 0, length = activeChangedComponents.length; i < length; ++i){
9307
9316
  activeChangedComponents[i]._setActive(isActive, activeChangeFlag);
9308
9317
  }
9309
9318
  this._scene._componentsManager.putActiveChangedTempList(activeChangedComponents);
@@ -11056,6 +11065,12 @@
11056
11065
  };
11057
11066
  return BlendState;
11058
11067
  }();
11068
+ __decorate$1([
11069
+ deepClone
11070
+ ], BlendState.prototype, "targetBlendState", void 0);
11071
+ __decorate$1([
11072
+ deepClone
11073
+ ], BlendState.prototype, "blendColor", void 0);
11059
11074
  /**
11060
11075
  * Depth state.
11061
11076
  */ var DepthState = /*#__PURE__*/ function() {
@@ -11434,6 +11449,18 @@
11434
11449
  };
11435
11450
  return RenderState;
11436
11451
  }();
11452
+ __decorate$1([
11453
+ deepClone
11454
+ ], RenderState.prototype, "blendState", void 0);
11455
+ __decorate$1([
11456
+ deepClone
11457
+ ], RenderState.prototype, "depthState", void 0);
11458
+ __decorate$1([
11459
+ deepClone
11460
+ ], RenderState.prototype, "stencilState", void 0);
11461
+ __decorate$1([
11462
+ deepClone
11463
+ ], RenderState.prototype, "rasterState", void 0);
11437
11464
  /**
11438
11465
  * Shader for rendering.
11439
11466
  */ var Shader = /*#__PURE__*/ function() {
@@ -12335,7 +12362,7 @@
12335
12362
  ignoreClone
12336
12363
  ], exports.Renderer.prototype, "_globalShaderMacro", void 0);
12337
12364
  __decorate$1([
12338
- deepClone
12365
+ ignoreClone
12339
12366
  ], exports.Renderer.prototype, "_bounds", void 0);
12340
12367
  __decorate$1([
12341
12368
  ignoreClone
@@ -13281,14 +13308,14 @@
13281
13308
  vertexElements[index] = element;
13282
13309
  this._bufferStructChanged = true;
13283
13310
  };
13284
- _proto.setVertexElementsLength = function setVertexElementsLength(length1) {
13311
+ _proto.setVertexElementsLength = function setVertexElementsLength(length) {
13285
13312
  var vertexElementMap = this._vertexElementMap;
13286
13313
  var vertexElements = this._vertexElements;
13287
- for(var i = length1, n = vertexElements.length; i < n; i++){
13314
+ for(var i = length, n = vertexElements.length; i < n; i++){
13288
13315
  var element = vertexElements[i];
13289
13316
  delete vertexElementMap[element.attribute];
13290
13317
  }
13291
- vertexElements.length = length1;
13318
+ vertexElements.length = length;
13292
13319
  };
13293
13320
  _proto.setVertexBufferBinding = function setVertexBufferBinding(index, binding) {
13294
13321
  var referCount = this._getReferCount();
@@ -13442,8 +13469,8 @@
13442
13469
  /**
13443
13470
  * @internal
13444
13471
  *
13445
- */ _proto._setVertexElementsLength = function _setVertexElementsLength(length1) {
13446
- this._primitive.setVertexElementsLength(length1);
13472
+ */ _proto._setVertexElementsLength = function _setVertexElementsLength(length) {
13473
+ this._primitive.setVertexElementsLength(length);
13447
13474
  };
13448
13475
  /**
13449
13476
  * @internal
@@ -15159,9 +15186,9 @@
15159
15186
  }
15160
15187
  var bsUpdate = !bsManager._useTextureMode() && bsManager._vertexElementsNeedUpdate();
15161
15188
  if (previousBSOffset !== bsManager._vertexElementOffset || bsUpdate && bsManager._blendShapeCount > 0) {
15162
- var length1 = bsManager._addVertexElements(this);
15163
- if (length1 < previousCount) {
15164
- this._setVertexElementsLength(length1);
15189
+ var length = bsManager._addVertexElements(this);
15190
+ if (length < previousCount) {
15191
+ this._setVertexElementsLength(length);
15165
15192
  }
15166
15193
  }
15167
15194
  };
@@ -17073,7 +17100,7 @@
17073
17100
  _proto.drawBatches = function drawBatches(camera) {
17074
17101
  var _this = this, engine = _this._engine, batchedQueue = _this._batchedQueue;
17075
17102
  var mesh = this._meshes[this._flushId];
17076
- var subMeshes = mesh.subMeshes;
17103
+ var subMeshes = mesh.subMeshes, primitive = mesh._primitive;
17077
17104
  var sceneData = camera.scene.shaderData;
17078
17105
  var cameraData = camera.shaderData;
17079
17106
  for(var i = 0, len = subMeshes.length; i < len; i++){
@@ -17105,7 +17132,7 @@
17105
17132
  program.uploadAll(program.rendererUniformBlock, renderer.shaderData);
17106
17133
  program.uploadAll(program.materialUniformBlock, material.shaderData);
17107
17134
  material.renderState._apply(engine, false, pass._renderStateDataMap, material.shaderData);
17108
- engine._hardwareRenderer.drawPrimitive(mesh._primitive, subMesh, program);
17135
+ engine._hardwareRenderer.drawPrimitive(primitive, subMesh, program);
17109
17136
  }
17110
17137
  };
17111
17138
  return SpriteMaskBatcher;
@@ -17344,16 +17371,31 @@
17344
17371
  };
17345
17372
  var _proto = SceneManager.prototype;
17346
17373
  _proto.addScene = function addScene(indexOrScene, scene) {
17374
+ var scenes = this._scenes;
17375
+ var index;
17347
17376
  if (typeof indexOrScene === "number") {
17348
- this._scenes.add(indexOrScene, scene);
17377
+ if (indexOrScene < 0 || indexOrScene > scenes.length) {
17378
+ throw "The index is out of range.";
17379
+ }
17380
+ index = indexOrScene;
17349
17381
  } else {
17382
+ index = scenes.length;
17350
17383
  scene = indexOrScene;
17351
- this._scenes.push(scene);
17352
17384
  }
17353
17385
  if (scene.engine !== this.engine) {
17354
17386
  throw "The scene is not belong to this engine.";
17355
17387
  }
17356
- scene._processActive(true);
17388
+ if (scene._sceneManager) {
17389
+ var currentIndex = scenes.indexOf(scene);
17390
+ if (currentIndex !== index) {
17391
+ scenes.removeByIndex(currentIndex);
17392
+ scenes.add(index, scene);
17393
+ }
17394
+ } else {
17395
+ scene._sceneManager = this;
17396
+ scenes.add(index, scene);
17397
+ scene.isActive && scene._processActive(true);
17398
+ }
17357
17399
  };
17358
17400
  /**
17359
17401
  * Remove scene.
@@ -17364,7 +17406,8 @@
17364
17406
  if (index !== -1) {
17365
17407
  var removedScene = scenes.getArray()[index];
17366
17408
  scenes.removeByIndex(index);
17367
- removedScene._processActive(false);
17409
+ scene._sceneManager = null;
17410
+ removedScene.isActive && removedScene._processActive(false);
17368
17411
  }
17369
17412
  };
17370
17413
  /**
@@ -18015,11 +18058,15 @@
18015
18058
  if (this._currentEnteredEntity) {
18016
18059
  this._currentEnteredEntity._scripts.forEach(function(element) {
18017
18060
  element.onPointerExit(_this);
18061
+ }, function(element, index) {
18062
+ element._entityScriptsIndex = index;
18018
18063
  });
18019
18064
  }
18020
18065
  if (rayCastEntity) {
18021
18066
  rayCastEntity._scripts.forEach(function(element) {
18022
18067
  element.onPointerEnter(_this);
18068
+ }, function(element, index) {
18069
+ element._entityScriptsIndex = index;
18023
18070
  });
18024
18071
  }
18025
18072
  this._currentEnteredEntity = rayCastEntity;
@@ -18032,6 +18079,8 @@
18032
18079
  if (rayCastEntity) {
18033
18080
  rayCastEntity._scripts.forEach(function(element) {
18034
18081
  element.onPointerDown(_this);
18082
+ }, function(element, index) {
18083
+ element._entityScriptsIndex = index;
18035
18084
  });
18036
18085
  }
18037
18086
  this._currentPressedEntity = rayCastEntity;
@@ -18043,6 +18092,8 @@
18043
18092
  if (this._currentPressedEntity) {
18044
18093
  this._currentPressedEntity._scripts.forEach(function(element) {
18045
18094
  element.onPointerDrag(_this);
18095
+ }, function(element, index) {
18096
+ element._entityScriptsIndex = index;
18046
18097
  });
18047
18098
  }
18048
18099
  };
@@ -18056,6 +18107,8 @@
18056
18107
  pressedEntity._scripts.forEach(function(element) {
18057
18108
  sameTarget && element.onPointerClick(_this);
18058
18109
  element.onPointerUp(_this);
18110
+ }, function(element, index) {
18111
+ element._entityScriptsIndex = index;
18059
18112
  });
18060
18113
  this._currentPressedEntity = null;
18061
18114
  }
@@ -18556,9 +18609,9 @@
18556
18609
  oldCollider.removeShape(shape);
18557
18610
  }
18558
18611
  this._shapes.push(shape);
18559
- this.scene.physics._addColliderShape(shape);
18560
18612
  shape._collider = this;
18561
18613
  this._nativeCollider.addShape(shape._nativeShape);
18614
+ this._phasedActiveInScene && this.scene.physics._addColliderShape(shape);
18562
18615
  }
18563
18616
  };
18564
18617
  /**
@@ -18568,7 +18621,7 @@
18568
18621
  var index = this._shapes.indexOf(shape);
18569
18622
  if (index !== -1) {
18570
18623
  this._shapes.splice(index, 1);
18571
- this.scene.physics._removeColliderShape(shape);
18624
+ this._phasedActiveInScene && this.scene.physics._removeColliderShape(shape);
18572
18625
  shape._collider = null;
18573
18626
  this._nativeCollider.removeShape(shape._nativeShape);
18574
18627
  }
@@ -18579,7 +18632,7 @@
18579
18632
  var shapes = this._shapes;
18580
18633
  for(var i = 0, n = shapes.length; i < n; i++){
18581
18634
  var shape = shapes[i];
18582
- this.scene.physics._removeColliderShape(shape);
18635
+ this._phasedActiveInScene && this.scene.physics._removeColliderShape(shape);
18583
18636
  shape._destroy();
18584
18637
  this._nativeCollider.removeShape(shape._nativeShape);
18585
18638
  }
@@ -18604,12 +18657,30 @@
18604
18657
  /**
18605
18658
  * @internal
18606
18659
  */ _proto._onEnableInScene = function _onEnableInScene() {
18607
- this.scene.physics._addCollider(this);
18660
+ var physics = this.scene.physics;
18661
+ physics._addCollider(this);
18662
+ var shapes = this.shapes;
18663
+ for(var i = 0, n = shapes.length; i < n; i++){
18664
+ physics._addColliderShape(shapes[i]);
18665
+ }
18608
18666
  };
18609
18667
  /**
18610
18668
  * @internal
18611
18669
  */ _proto._onDisableInScene = function _onDisableInScene() {
18612
- this.scene.physics._removeCollider(this);
18670
+ var physics = this.scene.physics;
18671
+ physics._removeCollider(this);
18672
+ var shapes = this.shapes;
18673
+ for(var i = 0, n = shapes.length; i < n; i++){
18674
+ physics._removeColliderShape(shapes[i]);
18675
+ }
18676
+ };
18677
+ /**
18678
+ * @internal
18679
+ */ _proto._cloneTo = function _cloneTo(target) {
18680
+ var shapes = target._shapes;
18681
+ for(var i = 0, n = shapes.length; i < n; i++){
18682
+ target._addPhysicsShape(shapes[i]);
18683
+ }
18613
18684
  };
18614
18685
  /**
18615
18686
  * @internal
@@ -18618,6 +18689,11 @@
18618
18689
  this.clearShapes();
18619
18690
  this._nativeCollider.destroy();
18620
18691
  };
18692
+ _proto._addPhysicsShape = function _addPhysicsShape(shape) {
18693
+ shape._collider = this;
18694
+ this._nativeCollider.addShape(shape._nativeShape);
18695
+ this._phasedActiveInScene && this.scene.physics._addColliderShape(shape);
18696
+ };
18621
18697
  _create_class$3(Collider, [
18622
18698
  {
18623
18699
  key: "shapes",
@@ -18633,6 +18709,15 @@
18633
18709
  __decorate$1([
18634
18710
  ignoreClone
18635
18711
  ], exports.Collider.prototype, "_index", void 0);
18712
+ __decorate$1([
18713
+ ignoreClone
18714
+ ], exports.Collider.prototype, "_nativeCollider", void 0);
18715
+ __decorate$1([
18716
+ ignoreClone
18717
+ ], exports.Collider.prototype, "_updateFlag", void 0);
18718
+ __decorate$1([
18719
+ deepClone
18720
+ ], exports.Collider.prototype, "_shapes", void 0);
18636
18721
  exports.Collider = __decorate$1([
18637
18722
  dependentComponents(Transform, exports.DependentMode.CheckOnly)
18638
18723
  ], exports.Collider);
@@ -18654,11 +18739,15 @@
18654
18739
  var collision = PhysicsScene._collision;
18655
18740
  collision.shape = shape2;
18656
18741
  element.onCollisionEnter(collision);
18742
+ }, function(element, index) {
18743
+ element._entityScriptsIndex = index;
18657
18744
  });
18658
18745
  shape2.collider.entity._scripts.forEach(function(element) {
18659
18746
  var collision = PhysicsScene._collision;
18660
18747
  collision.shape = shape1;
18661
18748
  element.onCollisionEnter(collision);
18749
+ }, function(element, index) {
18750
+ element._entityScriptsIndex = index;
18662
18751
  });
18663
18752
  };
18664
18753
  this._onContactExit = function(obj1, obj2) {
@@ -18669,11 +18758,15 @@
18669
18758
  var collision = PhysicsScene._collision;
18670
18759
  collision.shape = shape2;
18671
18760
  element.onCollisionExit(collision);
18761
+ }, function(element, index) {
18762
+ element._entityScriptsIndex = index;
18672
18763
  });
18673
18764
  shape2.collider.entity._scripts.forEach(function(element) {
18674
18765
  var collision = PhysicsScene._collision;
18675
18766
  collision.shape = shape1;
18676
18767
  element.onCollisionExit(collision);
18768
+ }, function(element, index) {
18769
+ element._entityScriptsIndex = index;
18677
18770
  });
18678
18771
  };
18679
18772
  this._onContactStay = function(obj1, obj2) {
@@ -18684,11 +18777,15 @@
18684
18777
  var collision = PhysicsScene._collision;
18685
18778
  collision.shape = shape2;
18686
18779
  element.onCollisionStay(collision);
18780
+ }, function(element, index) {
18781
+ element._entityScriptsIndex = index;
18687
18782
  });
18688
18783
  shape2.collider.entity._scripts.forEach(function(element) {
18689
18784
  var collision = PhysicsScene._collision;
18690
18785
  collision.shape = shape1;
18691
18786
  element.onCollisionStay(collision);
18787
+ }, function(element, index) {
18788
+ element._entityScriptsIndex = index;
18692
18789
  });
18693
18790
  };
18694
18791
  this._onTriggerEnter = function(obj1, obj2) {
@@ -18697,9 +18794,13 @@
18697
18794
  var shape2 = physicalObjectsMap[obj2];
18698
18795
  shape1.collider.entity._scripts.forEach(function(element) {
18699
18796
  element.onTriggerEnter(shape2);
18797
+ }, function(element, index) {
18798
+ element._entityScriptsIndex = index;
18700
18799
  });
18701
18800
  shape2.collider.entity._scripts.forEach(function(element) {
18702
18801
  element.onTriggerEnter(shape1);
18802
+ }, function(element, index) {
18803
+ element._entityScriptsIndex = index;
18703
18804
  });
18704
18805
  };
18705
18806
  this._onTriggerExit = function(obj1, obj2) {
@@ -18708,9 +18809,13 @@
18708
18809
  var shape2 = physicalObjectsMap[obj2];
18709
18810
  shape1.collider.entity._scripts.forEach(function(element) {
18710
18811
  element.onTriggerExit(shape2);
18812
+ }, function(element, index) {
18813
+ element._entityScriptsIndex = index;
18711
18814
  });
18712
18815
  shape2.collider.entity._scripts.forEach(function(element) {
18713
18816
  element.onTriggerExit(shape1);
18817
+ }, function(element, index) {
18818
+ element._entityScriptsIndex = index;
18714
18819
  });
18715
18820
  };
18716
18821
  this._onTriggerStay = function(obj1, obj2) {
@@ -18719,9 +18824,13 @@
18719
18824
  var shape2 = physicalObjectsMap[obj2];
18720
18825
  shape1.collider.entity._scripts.forEach(function(element) {
18721
18826
  element.onTriggerStay(shape2);
18827
+ }, function(element, index) {
18828
+ element._entityScriptsIndex = index;
18722
18829
  });
18723
18830
  shape2.collider.entity._scripts.forEach(function(element) {
18724
18831
  element.onTriggerStay(shape1);
18832
+ }, function(element, index) {
18833
+ element._entityScriptsIndex = index;
18725
18834
  });
18726
18835
  };
18727
18836
  this._scene = scene;
@@ -18754,6 +18863,9 @@
18754
18863
  }
18755
18864
  var onRaycast = function onRaycast(obj) {
18756
18865
  var shape = _this._scene.engine._physicalObjectsMap[obj];
18866
+ if (!shape) {
18867
+ return false;
18868
+ }
18757
18869
  return shape.collider.entity.layer & layerMask && shape.isSceneQuery;
18758
18870
  };
18759
18871
  if (hitResult != undefined) {
@@ -18976,18 +19088,27 @@
18976
19088
  */ _proto._onLateUpdate = function _onLateUpdate() {
18977
19089
  var position = this.entity.transform.worldPosition;
18978
19090
  this._nativeCollider.getWorldPosition(position);
18979
- this.entity.transform.worldPosition = position;
18980
19091
  this._updateFlag.flag = false;
18981
19092
  };
18982
19093
  /**
18983
19094
  * @internal
18984
19095
  */ _proto._onEnableInScene = function _onEnableInScene() {
18985
- this.scene.physics._addCharacterController(this);
19096
+ var physics = this.scene.physics;
19097
+ physics._addCharacterController(this);
19098
+ var shapes = this.shapes;
19099
+ for(var i = 0, n = shapes.length; i < n; i++){
19100
+ physics._addColliderShape(shapes[i]);
19101
+ }
18986
19102
  };
18987
19103
  /**
18988
19104
  * @internal
18989
19105
  */ _proto._onDisableInScene = function _onDisableInScene() {
18990
- this.scene.physics._removeCharacterController(this);
19106
+ var physics = this.scene.physics;
19107
+ physics._removeCharacterController(this);
19108
+ var shapes = this.shapes;
19109
+ for(var i = 0, n = shapes.length; i < n; i++){
19110
+ physics._removeColliderShape(shapes[i]);
19111
+ }
18991
19112
  };
18992
19113
  _proto._setUpDirection = function _setUpDirection() {
18993
19114
  this._nativeCollider.setUpDirection(this._upDirection);
@@ -19122,6 +19243,25 @@
19122
19243
  this._nativeCollider.getWorldTransform(worldPosition, worldRotationQuaternion);
19123
19244
  this._updateFlag.flag = false;
19124
19245
  };
19246
+ /**
19247
+ * @internal
19248
+ */ _proto._cloneTo = function _cloneTo(target) {
19249
+ Collider1.prototype._cloneTo.call(this, target);
19250
+ target.linearDamping = this.linearDamping;
19251
+ target.angularDamping = this.angularDamping;
19252
+ target.linearVelocity = this.linearVelocity;
19253
+ target.angularVelocity = this.angularVelocity;
19254
+ target.mass = this.mass;
19255
+ target.centerOfMass = this.centerOfMass;
19256
+ target.inertiaTensor = this.inertiaTensor;
19257
+ target.maxAngularVelocity = this.maxAngularVelocity;
19258
+ target.maxDepenetrationVelocity = this.maxDepenetrationVelocity;
19259
+ target.sleepThreshold = this.sleepThreshold;
19260
+ target.solverIterations = this.solverIterations;
19261
+ target.isKinematic = this.isKinematic;
19262
+ target.constraints = this.constraints;
19263
+ target.collisionDetectionMode = this.collisionDetectionMode;
19264
+ };
19125
19265
  _proto._setLinearVelocity = function _setLinearVelocity() {
19126
19266
  this._nativeCollider.setLinearVelocity(this._linearVelocity);
19127
19267
  };
@@ -19330,6 +19470,48 @@
19330
19470
  ]);
19331
19471
  return DynamicCollider;
19332
19472
  }(exports.Collider);
19473
+ __decorate$1([
19474
+ ignoreClone
19475
+ ], DynamicCollider.prototype, "_linearDamping", void 0);
19476
+ __decorate$1([
19477
+ ignoreClone
19478
+ ], DynamicCollider.prototype, "_angularDamping", void 0);
19479
+ __decorate$1([
19480
+ ignoreClone
19481
+ ], DynamicCollider.prototype, "_linearVelocity", void 0);
19482
+ __decorate$1([
19483
+ ignoreClone
19484
+ ], DynamicCollider.prototype, "_angularVelocity", void 0);
19485
+ __decorate$1([
19486
+ ignoreClone
19487
+ ], DynamicCollider.prototype, "_mass", void 0);
19488
+ __decorate$1([
19489
+ ignoreClone
19490
+ ], DynamicCollider.prototype, "_centerOfMass", void 0);
19491
+ __decorate$1([
19492
+ ignoreClone
19493
+ ], DynamicCollider.prototype, "_inertiaTensor", void 0);
19494
+ __decorate$1([
19495
+ ignoreClone
19496
+ ], DynamicCollider.prototype, "_maxAngularVelocity", void 0);
19497
+ __decorate$1([
19498
+ ignoreClone
19499
+ ], DynamicCollider.prototype, "_maxDepenetrationVelocity", void 0);
19500
+ __decorate$1([
19501
+ ignoreClone
19502
+ ], DynamicCollider.prototype, "_solverIterations", void 0);
19503
+ __decorate$1([
19504
+ ignoreClone
19505
+ ], DynamicCollider.prototype, "_isKinematic", void 0);
19506
+ __decorate$1([
19507
+ ignoreClone
19508
+ ], DynamicCollider.prototype, "_constraints", void 0);
19509
+ __decorate$1([
19510
+ ignoreClone
19511
+ ], DynamicCollider.prototype, "_collisionDetectionMode", void 0);
19512
+ __decorate$1([
19513
+ ignoreClone
19514
+ ], DynamicCollider.prototype, "_sleepThreshold", void 0);
19333
19515
  exports.CollisionDetectionMode = void 0;
19334
19516
  (function(CollisionDetectionMode) {
19335
19517
  CollisionDetectionMode[CollisionDetectionMode["Discrete"] = 0] = "Discrete";
@@ -19379,7 +19561,8 @@
19379
19561
  /**
19380
19562
  * @internal
19381
19563
  */ _proto._destroy = function _destroy() {
19382
- this._nativeMaterial.destroy();
19564
+ !this._destroyed && this._nativeMaterial.destroy();
19565
+ this._destroyed = true;
19383
19566
  };
19384
19567
  _create_class$3(PhysicsMaterial, [
19385
19568
  {
@@ -19489,25 +19672,38 @@
19489
19672
  var Joint = function Joint(entity) {
19490
19673
  var _this;
19491
19674
  _this = Component1.call(this, entity) || this;
19492
- _this._connectedCollider = new JointCollider();
19493
- _this._collider = new JointCollider();
19675
+ _this._colliderInfo = new JointColliderInfo();
19676
+ _this._connectedColliderInfo = new JointColliderInfo();
19494
19677
  _this._force = 0;
19495
19678
  _this._torque = 0;
19496
- _this._connectedCollider.localPosition = new Vector3();
19679
+ _this._connectedColliderInfo.localPosition = new Vector3();
19497
19680
  return _this;
19498
19681
  };
19499
19682
  _inherits$2(Joint, Component1);
19683
+ var _proto = Joint.prototype;
19684
+ /**
19685
+ * @internal
19686
+ */ _proto._cloneTo = function _cloneTo(target) {
19687
+ target.connectedCollider = this.connectedCollider;
19688
+ target.connectedAnchor = this.connectedAnchor;
19689
+ target.connectedMassScale = this.connectedMassScale;
19690
+ target.connectedInertiaScale = this.connectedInertiaScale;
19691
+ target.massScale = this.massScale;
19692
+ target.inertiaScale = this.inertiaScale;
19693
+ target.breakForce = this.breakForce;
19694
+ target.breakTorque = this.breakTorque;
19695
+ };
19500
19696
  _create_class$3(Joint, [
19501
19697
  {
19502
19698
  key: "connectedCollider",
19503
19699
  get: /**
19504
19700
  * The connected collider.
19505
19701
  */ function get() {
19506
- return this._connectedCollider.collider;
19702
+ return this._connectedColliderInfo.collider;
19507
19703
  },
19508
19704
  set: function set(value) {
19509
- if (this._connectedCollider.collider !== value) {
19510
- this._connectedCollider.collider = value;
19705
+ if (this._connectedColliderInfo.collider !== value) {
19706
+ this._connectedColliderInfo.collider = value;
19511
19707
  this._nativeJoint.setConnectedCollider(value._nativeCollider);
19512
19708
  }
19513
19709
  }
@@ -19518,10 +19714,10 @@
19518
19714
  * The connected anchor position.
19519
19715
  * @remarks If connectedCollider is set, this anchor is relative offset, or the anchor is world position.
19520
19716
  */ function get() {
19521
- return this._connectedCollider.localPosition;
19717
+ return this._connectedColliderInfo.localPosition;
19522
19718
  },
19523
19719
  set: function set(value) {
19524
- var connectedAnchor = this._connectedCollider.localPosition;
19720
+ var connectedAnchor = this._connectedColliderInfo.localPosition;
19525
19721
  if (value !== connectedAnchor) {
19526
19722
  connectedAnchor.copyFrom(value);
19527
19723
  }
@@ -19533,11 +19729,11 @@
19533
19729
  get: /**
19534
19730
  * The scale to apply to the inverse mass of collider 0 for resolving this constraint.
19535
19731
  */ function get() {
19536
- return this._connectedCollider.massScale;
19732
+ return this._connectedColliderInfo.massScale;
19537
19733
  },
19538
19734
  set: function set(value) {
19539
- if (value !== this._connectedCollider.massScale) {
19540
- this._connectedCollider.massScale = value;
19735
+ if (value !== this._connectedColliderInfo.massScale) {
19736
+ this._connectedColliderInfo.massScale = value;
19541
19737
  this._nativeJoint.setConnectedMassScale(value);
19542
19738
  }
19543
19739
  }
@@ -19547,11 +19743,11 @@
19547
19743
  get: /**
19548
19744
  * The scale to apply to the inverse inertia of collider0 for resolving this constraint.
19549
19745
  */ function get() {
19550
- return this._connectedCollider.inertiaScale;
19746
+ return this._connectedColliderInfo.inertiaScale;
19551
19747
  },
19552
19748
  set: function set(value) {
19553
- if (value !== this._connectedCollider.inertiaScale) {
19554
- this._connectedCollider.inertiaScale = value;
19749
+ if (value !== this._connectedColliderInfo.inertiaScale) {
19750
+ this._connectedColliderInfo.inertiaScale = value;
19555
19751
  this._nativeJoint.setConnectedInertiaScale(value);
19556
19752
  }
19557
19753
  }
@@ -19561,11 +19757,11 @@
19561
19757
  get: /**
19562
19758
  * The scale to apply to the inverse mass of collider 1 for resolving this constraint.
19563
19759
  */ function get() {
19564
- return this._collider.massScale;
19760
+ return this._colliderInfo.massScale;
19565
19761
  },
19566
19762
  set: function set(value) {
19567
- if (value !== this._collider.massScale) {
19568
- this._collider.massScale = value;
19763
+ if (value !== this._colliderInfo.massScale) {
19764
+ this._colliderInfo.massScale = value;
19569
19765
  this._nativeJoint.setMassScale(value);
19570
19766
  }
19571
19767
  }
@@ -19575,11 +19771,11 @@
19575
19771
  get: /**
19576
19772
  * The scale to apply to the inverse inertia of collider1 for resolving this constraint.
19577
19773
  */ function get() {
19578
- return this._collider.inertiaScale;
19774
+ return this._colliderInfo.inertiaScale;
19579
19775
  },
19580
19776
  set: function set(value) {
19581
- if (value !== this._collider.inertiaScale) {
19582
- this._collider.inertiaScale = value;
19777
+ if (value !== this._colliderInfo.inertiaScale) {
19778
+ this._colliderInfo.inertiaScale = value;
19583
19779
  this._nativeJoint.setInertiaScale(value);
19584
19780
  }
19585
19781
  }
@@ -19615,12 +19811,27 @@
19615
19811
  ]);
19616
19812
  return Joint;
19617
19813
  }(Component);
19814
+ __decorate$1([
19815
+ ignoreClone
19816
+ ], exports.Joint.prototype, "_colliderInfo", void 0);
19817
+ __decorate$1([
19818
+ ignoreClone
19819
+ ], exports.Joint.prototype, "_connectedColliderInfo", void 0);
19820
+ __decorate$1([
19821
+ ignoreClone
19822
+ ], exports.Joint.prototype, "_nativeJoint", void 0);
19823
+ __decorate$1([
19824
+ ignoreClone
19825
+ ], exports.Joint.prototype, "_force", void 0);
19826
+ __decorate$1([
19827
+ ignoreClone
19828
+ ], exports.Joint.prototype, "_torque", void 0);
19618
19829
  exports.Joint = __decorate$1([
19619
19830
  dependentComponents(exports.Collider, exports.DependentMode.CheckOnly)
19620
19831
  ], exports.Joint);
19621
19832
  /**
19622
19833
  * @internal
19623
- */ var JointCollider = function JointCollider() {
19834
+ */ var JointColliderInfo = function JointColliderInfo() {
19624
19835
  this.collider = null;
19625
19836
  this.massScale = 0;
19626
19837
  this.inertiaScale = 0;
@@ -19636,7 +19847,7 @@
19636
19847
  /**
19637
19848
  * @internal
19638
19849
  */ _proto._onAwake = function _onAwake() {
19639
- var collider = this._collider;
19850
+ var collider = this._colliderInfo;
19640
19851
  collider.collider = this.entity.getComponent(exports.Collider);
19641
19852
  this._nativeJoint = PhysicsScene._nativePhysics.createFixedJoint(collider.collider._nativeCollider);
19642
19853
  };
@@ -19668,11 +19879,22 @@
19668
19879
  /**
19669
19880
  * @internal
19670
19881
  */ _proto._onAwake = function _onAwake() {
19671
- var collider = this._collider;
19882
+ var collider = this._colliderInfo;
19672
19883
  collider.localPosition = new Vector3();
19673
19884
  collider.collider = this.entity.getComponent(exports.Collider);
19674
19885
  this._nativeJoint = PhysicsScene._nativePhysics.createHingeJoint(collider.collider._nativeCollider);
19675
19886
  };
19887
+ /**
19888
+ * @internal
19889
+ */ _proto._cloneTo = function _cloneTo(target) {
19890
+ target.axis = this.axis;
19891
+ target.swingOffset = this.swingOffset;
19892
+ target.useLimits = this.useLimits;
19893
+ target.useMotor = this.useMotor;
19894
+ target.useSpring = this.useSpring;
19895
+ target.motor = this.motor;
19896
+ target.limits = this.limits;
19897
+ };
19676
19898
  _create_class$3(HingeJoint, [
19677
19899
  {
19678
19900
  key: "axis",
@@ -19694,10 +19916,10 @@
19694
19916
  get: /**
19695
19917
  * The swing offset.
19696
19918
  */ function get() {
19697
- return this._collider.localPosition;
19919
+ return this._colliderInfo.localPosition;
19698
19920
  },
19699
19921
  set: function set(value) {
19700
- var swingOffset = this._collider.localPosition;
19922
+ var swingOffset = this._colliderInfo.localPosition;
19701
19923
  if (value !== swingOffset) {
19702
19924
  swingOffset.copyFrom(value);
19703
19925
  }
@@ -19800,6 +20022,21 @@
19800
20022
  ]);
19801
20023
  return HingeJoint;
19802
20024
  }(exports.Joint);
20025
+ __decorate$1([
20026
+ ignoreClone
20027
+ ], HingeJoint.prototype, "_axis", void 0);
20028
+ __decorate$1([
20029
+ ignoreClone
20030
+ ], HingeJoint.prototype, "_hingeFlags", void 0);
20031
+ __decorate$1([
20032
+ ignoreClone
20033
+ ], HingeJoint.prototype, "_useSpring", void 0);
20034
+ __decorate$1([
20035
+ ignoreClone
20036
+ ], HingeJoint.prototype, "_jointMonitor", void 0);
20037
+ __decorate$1([
20038
+ ignoreClone
20039
+ ], HingeJoint.prototype, "_limits", void 0);
19803
20040
  /**
19804
20041
  * A joint that maintains an upper or lower bound (or both) on the distance between two points on different objects.
19805
20042
  */ var SpringJoint = /*#__PURE__*/ function(Joint1) {
@@ -19818,21 +20055,31 @@
19818
20055
  /**
19819
20056
  * @internal
19820
20057
  */ _proto._onAwake = function _onAwake() {
19821
- var collider = this._collider;
20058
+ var collider = this._colliderInfo;
19822
20059
  collider.localPosition = new Vector3();
19823
20060
  collider.collider = this.entity.getComponent(exports.Collider);
19824
20061
  this._nativeJoint = PhysicsScene._nativePhysics.createSpringJoint(collider.collider._nativeCollider);
19825
20062
  };
20063
+ /**
20064
+ * @internal
20065
+ */ _proto._cloneTo = function _cloneTo(target) {
20066
+ target.swingOffset = this.swingOffset;
20067
+ target.minDistance = this.minDistance;
20068
+ target.maxDistance = this.maxDistance;
20069
+ target.tolerance = this.tolerance;
20070
+ target.stiffness = this.stiffness;
20071
+ target.damping = this.damping;
20072
+ };
19826
20073
  _create_class$3(SpringJoint, [
19827
20074
  {
19828
20075
  key: "swingOffset",
19829
20076
  get: /**
19830
20077
  * The swing offset.
19831
20078
  */ function get() {
19832
- return this._collider.localPosition;
20079
+ return this._colliderInfo.localPosition;
19833
20080
  },
19834
20081
  set: function set(value) {
19835
- var swingOffset = this._collider.localPosition;
20082
+ var swingOffset = this._colliderInfo.localPosition;
19836
20083
  if (value !== swingOffset) {
19837
20084
  swingOffset.copyFrom(value);
19838
20085
  }
@@ -19954,6 +20201,15 @@
19954
20201
  var _proto = ColliderShape.prototype;
19955
20202
  /**
19956
20203
  * @internal
20204
+ */ _proto._cloneTo = function _cloneTo(target) {
20205
+ target.contactOffset = this.contactOffset;
20206
+ target.rotation = this.rotation;
20207
+ target.position = this.position;
20208
+ target.isTrigger = this.isTrigger;
20209
+ target.material = this.material;
20210
+ };
20211
+ /**
20212
+ * @internal
19957
20213
  */ _proto._destroy = function _destroy() {
19958
20214
  this._material._destroy();
19959
20215
  this._nativeShape.destroy();
@@ -20055,6 +20311,30 @@
20055
20311
  (function() {
20056
20312
  ColliderShape._idGenerator = 0;
20057
20313
  })();
20314
+ __decorate$1([
20315
+ ignoreClone
20316
+ ], ColliderShape.prototype, "_collider", void 0);
20317
+ __decorate$1([
20318
+ ignoreClone
20319
+ ], ColliderShape.prototype, "_nativeShape", void 0);
20320
+ __decorate$1([
20321
+ ignoreClone
20322
+ ], ColliderShape.prototype, "_id", void 0);
20323
+ __decorate$1([
20324
+ ignoreClone
20325
+ ], ColliderShape.prototype, "_material", void 0);
20326
+ __decorate$1([
20327
+ ignoreClone
20328
+ ], ColliderShape.prototype, "_isTrigger", void 0);
20329
+ __decorate$1([
20330
+ ignoreClone
20331
+ ], ColliderShape.prototype, "_rotation", void 0);
20332
+ __decorate$1([
20333
+ ignoreClone
20334
+ ], ColliderShape.prototype, "_position", void 0);
20335
+ __decorate$1([
20336
+ ignoreClone
20337
+ ], ColliderShape.prototype, "_contactOffset", void 0);
20058
20338
  /**
20059
20339
  * Physical collider shape for box.
20060
20340
  */ var BoxColliderShape = /*#__PURE__*/ function(ColliderShape1) {
@@ -20070,6 +20350,12 @@
20070
20350
  };
20071
20351
  _inherits$2(BoxColliderShape, ColliderShape1);
20072
20352
  var _proto = BoxColliderShape.prototype;
20353
+ /**
20354
+ * @internal
20355
+ */ _proto._cloneTo = function _cloneTo(target) {
20356
+ ColliderShape1.prototype._cloneTo.call(this, target);
20357
+ target.size = this.size;
20358
+ };
20073
20359
  _proto._setSize = function _setSize() {
20074
20360
  this._nativeShape.setSize(this._size);
20075
20361
  };
@@ -20090,6 +20376,9 @@
20090
20376
  ]);
20091
20377
  return BoxColliderShape;
20092
20378
  }(ColliderShape);
20379
+ __decorate$1([
20380
+ ignoreClone
20381
+ ], BoxColliderShape.prototype, "_size", void 0);
20093
20382
  /**
20094
20383
  * Physical collider shape for sphere.
20095
20384
  */ var SphereColliderShape = /*#__PURE__*/ function(ColliderShape1) {
@@ -20101,6 +20390,11 @@
20101
20390
  return _this;
20102
20391
  };
20103
20392
  _inherits$2(SphereColliderShape, ColliderShape1);
20393
+ var _proto = SphereColliderShape.prototype;
20394
+ _proto._cloneTo = function _cloneTo(target) {
20395
+ ColliderShape1.prototype._cloneTo.call(this, target);
20396
+ target.radius = this.radius;
20397
+ };
20104
20398
  _create_class$3(SphereColliderShape, [
20105
20399
  {
20106
20400
  key: "radius",
@@ -20119,6 +20413,9 @@
20119
20413
  ]);
20120
20414
  return SphereColliderShape;
20121
20415
  }(ColliderShape);
20416
+ __decorate$1([
20417
+ ignoreClone
20418
+ ], SphereColliderShape.prototype, "_radius", void 0);
20122
20419
  /**
20123
20420
  * Physical collider shape plane.
20124
20421
  */ var PlaneColliderShape = /*#__PURE__*/ function(ColliderShape1) {
@@ -20144,6 +20441,15 @@
20144
20441
  return _this;
20145
20442
  };
20146
20443
  _inherits$2(CapsuleColliderShape, ColliderShape1);
20444
+ var _proto = CapsuleColliderShape.prototype;
20445
+ /**
20446
+ * @internal
20447
+ */ _proto._cloneTo = function _cloneTo(target) {
20448
+ ColliderShape1.prototype._cloneTo.call(this, target);
20449
+ target.radius = this.radius;
20450
+ target.height = this.height;
20451
+ target.upAxis = this.upAxis;
20452
+ };
20147
20453
  _create_class$3(CapsuleColliderShape, [
20148
20454
  {
20149
20455
  key: "radius",
@@ -20190,6 +20496,15 @@
20190
20496
  ]);
20191
20497
  return CapsuleColliderShape;
20192
20498
  }(ColliderShape);
20499
+ __decorate$1([
20500
+ ignoreClone
20501
+ ], CapsuleColliderShape.prototype, "_radius", void 0);
20502
+ __decorate$1([
20503
+ ignoreClone
20504
+ ], CapsuleColliderShape.prototype, "_height", void 0);
20505
+ __decorate$1([
20506
+ ignoreClone
20507
+ ], CapsuleColliderShape.prototype, "_upAxis", void 0);
20193
20508
  /**
20194
20509
  * Pointer Manager.
20195
20510
  * @internal
@@ -20279,9 +20594,9 @@
20279
20594
  pointer._firePointerDrag();
20280
20595
  var rayCastEntity = this._pointerRayCast(scenes, position.x / canvas.width, position.y / canvas.height);
20281
20596
  pointer._firePointerExitAndEnter(rayCastEntity);
20282
- var length1 = events.length;
20283
- if (length1 > 0) {
20284
- for(var i1 = 0; i1 < length1; i1++){
20597
+ var length = events.length;
20598
+ if (length > 0) {
20599
+ for(var i1 = 0; i1 < length; i1++){
20285
20600
  switch(events[i1].type){
20286
20601
  case "pointerdown":
20287
20602
  pointer.phase = exports.PointerPhase.Down;
@@ -20376,15 +20691,15 @@
20376
20691
  };
20377
20692
  _proto._updatePointerInfo = function _updatePointerInfo(frameCount, pointer, left, top, widthPixelRatio, heightPixelRatio) {
20378
20693
  var events = pointer._events, position = pointer.position;
20379
- var length1 = events.length;
20380
- if (length1 > 0) {
20694
+ var length = events.length;
20695
+ if (length > 0) {
20381
20696
  var _this = this, _upList = _this._upList, _upMap = _this._upMap, _downList = _this._downList, _downMap = _this._downMap;
20382
- var latestEvent = events[length1 - 1];
20697
+ var latestEvent = events[length - 1];
20383
20698
  var currX = (latestEvent.clientX - left) * widthPixelRatio;
20384
20699
  var currY = (latestEvent.clientY - top) * heightPixelRatio;
20385
20700
  pointer.deltaPosition.set(currX - position.x, currY - position.y);
20386
20701
  position.set(currX, currY);
20387
- for(var i = 0; i < length1; i++){
20702
+ for(var i = 0; i < length; i++){
20388
20703
  var event = events[i];
20389
20704
  var button = event.button;
20390
20705
  pointer.button = _pointerDec2BinMap[button] || exports.PointerButton.None;
@@ -20426,8 +20741,8 @@
20426
20741
  continue;
20427
20742
  }
20428
20743
  var cameras = scene._activeCameras;
20429
- for(var j = 0; j < cameras.length; j++){
20430
- var camera = cameras[i];
20744
+ for(var j = cameras.length - 1; j >= 0; j--){
20745
+ var camera = cameras[j];
20431
20746
  if (!camera.enabled || camera.renderTarget) {
20432
20747
  continue;
20433
20748
  }
@@ -21087,10 +21402,6 @@
21087
21402
  magentaMaterial.isGCIgnored = true;
21088
21403
  magentaMaterial.shaderData.setColor("material_BaseColor", new Color(1.0, 0.0, 1.01, 1.0));
21089
21404
  _this._magentaMaterial = magentaMaterial;
21090
- var backgroundTextureMaterial = new Material(_assert_this_initialized(_this), Shader.find("background-texture"));
21091
- backgroundTextureMaterial.isGCIgnored = true;
21092
- backgroundTextureMaterial.renderState.depthState.compareFunction = exports.CompareFunction.LessEqual;
21093
- _this._backgroundTextureMaterial = backgroundTextureMaterial;
21094
21405
  var innerSettings = _this._settings;
21095
21406
  var colorSpace = configuration.colorSpace || exports.ColorSpace.Linear;
21096
21407
  colorSpace === exports.ColorSpace.Gamma && _this._macroCollection.enable(Engine._gammaMacro);
@@ -21254,9 +21565,9 @@
21254
21565
  var shaderProgramPools = this._shaderProgramPools;
21255
21566
  var pool = shaderProgramPools[index];
21256
21567
  if (!pool) {
21257
- var length1 = index + 1;
21258
- if (length1 > shaderProgramPools.length) {
21259
- shaderProgramPools.length = length1;
21568
+ var length = index + 1;
21569
+ if (length > shaderProgramPools.length) {
21570
+ shaderProgramPools.length = length;
21260
21571
  }
21261
21572
  shaderProgramPools[index] = pool = new ShaderProgramPool();
21262
21573
  }
@@ -21704,34 +22015,29 @@
21704
22015
  this./** @internal */ _textureFillMode = exports.BackgroundTextureFillMode.AspectFitHeight;
21705
22016
  this._texture = null;
21706
22017
  this._initMesh(_engine);
22018
+ this._initMaterial(_engine);
21707
22019
  };
21708
22020
  var _proto = Background.prototype;
21709
22021
  /**
21710
22022
  * @internal
21711
22023
  */ _proto.destroy = function destroy() {
22024
+ this.texture = null;
21712
22025
  this._mesh._addReferCount(-1);
21713
22026
  this._mesh = null;
21714
- this.texture = null;
22027
+ this._material._addReferCount(-1);
22028
+ this._material = null;
21715
22029
  this.solidColor = null;
21716
22030
  this.sky.destroy();
21717
22031
  };
21718
22032
  /**
21719
22033
  * @internal
21720
- * Standalone for CanvasRenderer plugin.
21721
- */ _proto._initMesh = function _initMesh(engine) {
21722
- this._mesh = this._createPlane(engine);
21723
- this._mesh._addReferCount(1);
21724
- };
21725
- /**
21726
- * @internal
21727
22034
  */ _proto._resizeBackgroundTexture = function _resizeBackgroundTexture() {
22035
+ var _this = this, texture = _this._texture, mesh = _this._mesh;
21728
22036
  if (!this._texture) {
21729
22037
  return;
21730
22038
  }
21731
- var canvas = this._engine.canvas;
21732
- var width = canvas.width, height = canvas.height;
21733
- var _this = this, _backgroundTextureMesh = _this._mesh;
21734
- var positions = _backgroundTextureMesh.getPositions();
22039
+ var _this__engine_canvas = this._engine.canvas, width = _this__engine_canvas.width, height = _this__engine_canvas.height;
22040
+ var positions = mesh.getPositions();
21735
22041
  switch(this._textureFillMode){
21736
22042
  case exports.BackgroundTextureFillMode.Fill:
21737
22043
  positions[0].set(-1, -1, 1);
@@ -21740,22 +22046,31 @@
21740
22046
  positions[3].set(1, 1, 1);
21741
22047
  break;
21742
22048
  case exports.BackgroundTextureFillMode.AspectFitWidth:
21743
- var fitWidthScale = this._texture.height * width / this.texture.width / height;
22049
+ var fitWidthScale = texture.height * width / texture.width / height;
21744
22050
  positions[0].set(-1, -fitWidthScale, 1);
21745
22051
  positions[1].set(1, -fitWidthScale, 1);
21746
22052
  positions[2].set(-1, fitWidthScale, 1);
21747
22053
  positions[3].set(1, fitWidthScale, 1);
21748
22054
  break;
21749
22055
  case exports.BackgroundTextureFillMode.AspectFitHeight:
21750
- var fitHeightScale = this._texture.width * height / this.texture.height / width;
22056
+ var fitHeightScale = texture.width * height / texture.height / width;
21751
22057
  positions[0].set(-fitHeightScale, -1, 1);
21752
22058
  positions[1].set(fitHeightScale, -1, 1);
21753
22059
  positions[2].set(-fitHeightScale, 1, 1);
21754
22060
  positions[3].set(fitHeightScale, 1, 1);
21755
22061
  break;
21756
22062
  }
21757
- _backgroundTextureMesh.setPositions(positions);
21758
- _backgroundTextureMesh.uploadData(false);
22063
+ mesh.setPositions(positions);
22064
+ mesh.uploadData(false);
22065
+ };
22066
+ _proto._initMesh = function _initMesh(engine) {
22067
+ this._mesh = this._createPlane(engine);
22068
+ this._mesh._addReferCount(1);
22069
+ };
22070
+ _proto._initMaterial = function _initMaterial(engine) {
22071
+ var material = this._material = new Material(engine, Shader.find("background-texture"));
22072
+ material.renderState.depthState.compareFunction = exports.CompareFunction.LessEqual;
22073
+ material._addReferCount(1);
21759
22074
  };
21760
22075
  _proto._createPlane = function _createPlane(engine) {
21761
22076
  var mesh = new ModelMesh(engine);
@@ -21796,14 +22111,14 @@
21796
22111
  (_value = value) == null ? void 0 : _value._addReferCount(1);
21797
22112
  (_this__texture = this._texture) == null ? void 0 : _this__texture._addReferCount(-1);
21798
22113
  this._texture = value;
21799
- this._engine._backgroundTextureMaterial.shaderData.setTexture("material_BaseTexture", value);
22114
+ this._material.shaderData.setTexture("material_BaseTexture", value);
22115
+ this._resizeBackgroundTexture();
21800
22116
  }
21801
22117
  }
21802
22118
  },
21803
22119
  {
21804
22120
  key: "textureFillMode",
21805
22121
  get: /**
21806
- * @internal
21807
22122
  * Background texture fill mode.
21808
22123
  * @remarks When `mode` is `BackgroundMode.Texture`, the property will take effects.
21809
22124
  * @defaultValue `BackgroundTextureFillMode.FitHeight`
@@ -21920,40 +22235,44 @@
21920
22235
  };
21921
22236
  _proto.callScriptOnUpdate = function callScriptOnUpdate(deltaTime) {
21922
22237
  this._onUpdateScripts.forEach(function(element) {
21923
- if (element._started) {
21924
- element.onUpdate(deltaTime);
21925
- }
22238
+ element._started && element.onUpdate(deltaTime);
22239
+ }, function(element, index) {
22240
+ element._onUpdateIndex = index;
21926
22241
  });
21927
22242
  };
21928
22243
  _proto.callScriptOnLateUpdate = function callScriptOnLateUpdate(deltaTime) {
21929
22244
  this._onLateUpdateScripts.forEach(function(element) {
21930
- if (element._started) {
21931
- element.onLateUpdate(deltaTime);
21932
- }
22245
+ element._started && element.onLateUpdate(deltaTime);
22246
+ }, function(element, index) {
22247
+ element._onLateUpdateIndex = index;
21933
22248
  });
21934
22249
  };
21935
22250
  _proto.callScriptOnPhysicsUpdate = function callScriptOnPhysicsUpdate() {
21936
22251
  this._onPhysicsUpdateScripts.forEach(function(element) {
21937
- if (element._started) {
21938
- element.onPhysicsUpdate();
21939
- }
22252
+ element._started && element.onPhysicsUpdate();
22253
+ }, function(element, index) {
22254
+ element._onPhysicsUpdateIndex = index;
21940
22255
  });
21941
22256
  };
21942
22257
  _proto.callAnimationUpdate = function callAnimationUpdate(deltaTime) {
21943
22258
  this._onUpdateAnimations.forEach(function(element) {
21944
22259
  element.engine.time.frameCount > element._playFrameCount && element.update(deltaTime);
22260
+ }, function(element, index) {
22261
+ element._onUpdateIndex = index;
21945
22262
  });
21946
22263
  };
21947
22264
  _proto.callRendererOnUpdate = function callRendererOnUpdate(deltaTime) {
21948
22265
  this._onUpdateRenderers.forEach(function(element) {
21949
22266
  element.update(deltaTime);
22267
+ }, function(element, index) {
22268
+ element._onUpdateIndex = index;
21950
22269
  });
21951
22270
  };
21952
22271
  _proto.handlingInvalidScripts = function handlingInvalidScripts() {
21953
22272
  var _this = this, pendingDestroyScripts = _this._disposeDestroyScripts, disposeDestroyScripts = _this._pendingDestroyScripts;
21954
22273
  this._disposeDestroyScripts = disposeDestroyScripts;
21955
22274
  this._pendingDestroyScripts = pendingDestroyScripts;
21956
- length = disposeDestroyScripts.length;
22275
+ var length = disposeDestroyScripts.length;
21957
22276
  if (length > 0) {
21958
22277
  for(var i = length - 1; i >= 0; i--){
21959
22278
  disposeDestroyScripts[i].onDestroy();
@@ -21964,11 +22283,15 @@
21964
22283
  _proto.callCameraOnBeginRender = function callCameraOnBeginRender(camera) {
21965
22284
  camera.entity._scripts.forEach(function(element) {
21966
22285
  element.onBeginRender(camera);
22286
+ }, function(element, index) {
22287
+ element._entityScriptsIndex = index;
21967
22288
  });
21968
22289
  };
21969
22290
  _proto.callCameraOnEndRender = function callCameraOnEndRender(camera) {
21970
22291
  camera.entity._scripts.forEach(function(element) {
21971
22292
  element.onEndRender(camera);
22293
+ }, function(element, index) {
22294
+ element._entityScriptsIndex = index;
21972
22295
  });
21973
22296
  };
21974
22297
  _proto.getActiveChangedTempList = function getActiveChangedTempList() {
@@ -22363,11 +22686,6 @@
22363
22686
  ]);
22364
22687
  return Light;
22365
22688
  }(Component);
22366
- (function() {
22367
- /**
22368
- * Each type of light source is at most 10, beyond which it will not take effect.
22369
- * */ Light._maxLight = 10;
22370
- })();
22371
22689
  __decorate$1([
22372
22690
  ignoreClone
22373
22691
  ], Light.prototype, "_lightIndex", void 0);
@@ -22384,13 +22702,12 @@
22384
22702
  var _proto = DirectLight.prototype;
22385
22703
  /**
22386
22704
  * @internal
22387
- */ _proto._appendData = function _appendData(lightIndex) {
22705
+ */ _proto._appendData = function _appendData(lightIndex, data) {
22388
22706
  var cullingMaskStart = lightIndex * 2;
22389
22707
  var colorStart = lightIndex * 3;
22390
22708
  var directionStart = lightIndex * 3;
22391
22709
  var lightColor = this._getLightIntensityColor();
22392
22710
  var direction = this.direction;
22393
- var data = DirectLight._combinedData;
22394
22711
  var cullingMask = this.cullingMask;
22395
22712
  data.cullingMask[cullingMaskStart] = cullingMask & 65535;
22396
22713
  data.cullingMask[cullingMaskStart + 1] = cullingMask >>> 16 & 65535;
@@ -22419,8 +22736,7 @@
22419
22736
  };
22420
22737
  /**
22421
22738
  * @internal
22422
- */ DirectLight._updateShaderData = function _updateShaderData(shaderData) {
22423
- var data = DirectLight._combinedData;
22739
+ */ DirectLight._updateShaderData = function _updateShaderData(shaderData, data) {
22424
22740
  shaderData.setIntArray(DirectLight._cullingMaskProperty, data.cullingMask);
22425
22741
  shaderData.setFloatArray(DirectLight._colorProperty, data.color);
22426
22742
  shaderData.setFloatArray(DirectLight._directionProperty, data.direction);
@@ -22463,13 +22779,6 @@
22463
22779
  (function() {
22464
22780
  DirectLight._directionProperty = ShaderProperty.getByName("scene_DirectLightDirection");
22465
22781
  })();
22466
- (function() {
22467
- DirectLight._combinedData = {
22468
- cullingMask: new Int32Array(Light._maxLight * 2),
22469
- color: new Float32Array(Light._maxLight * 3),
22470
- direction: new Float32Array(Light._maxLight * 3)
22471
- };
22472
- })();
22473
22782
  /**
22474
22783
  * Point light.
22475
22784
  */ var PointLight = /*#__PURE__*/ function(Light1) {
@@ -22483,14 +22792,13 @@
22483
22792
  var _proto = PointLight.prototype;
22484
22793
  /**
22485
22794
  * @internal
22486
- */ _proto._appendData = function _appendData(lightIndex) {
22795
+ */ _proto._appendData = function _appendData(lightIndex, data) {
22487
22796
  var cullingMaskStart = lightIndex * 2;
22488
22797
  var colorStart = lightIndex * 3;
22489
22798
  var positionStart = lightIndex * 3;
22490
22799
  var distanceStart = lightIndex;
22491
22800
  var lightColor = this._getLightIntensityColor();
22492
22801
  var lightPosition = this.position;
22493
- var data = PointLight._combinedData;
22494
22802
  var cullingMask = this.cullingMask;
22495
22803
  data.cullingMask[cullingMaskStart] = cullingMask & 65535;
22496
22804
  data.cullingMask[cullingMaskStart + 1] = cullingMask >>> 16 & 65535;
@@ -22520,8 +22828,7 @@
22520
22828
  };
22521
22829
  /**
22522
22830
  * @internal
22523
- */ PointLight._updateShaderData = function _updateShaderData(shaderData) {
22524
- var data = PointLight._combinedData;
22831
+ */ PointLight._updateShaderData = function _updateShaderData(shaderData, data) {
22525
22832
  shaderData.setIntArray(PointLight._cullingMaskProperty, data.cullingMask);
22526
22833
  shaderData.setFloatArray(PointLight._colorProperty, data.color);
22527
22834
  shaderData.setFloatArray(PointLight._positionProperty, data.position);
@@ -22559,14 +22866,6 @@
22559
22866
  (function() {
22560
22867
  PointLight._distanceProperty = ShaderProperty.getByName("scene_PointLightDistance");
22561
22868
  })();
22562
- (function() {
22563
- PointLight._combinedData = {
22564
- cullingMask: new Int32Array(Light._maxLight * 2),
22565
- color: new Float32Array(Light._maxLight * 3),
22566
- position: new Float32Array(Light._maxLight * 3),
22567
- distance: new Float32Array(Light._maxLight)
22568
- };
22569
- })();
22570
22869
  /**
22571
22870
  * Spot light.
22572
22871
  */ var SpotLight = /*#__PURE__*/ function(Light1) {
@@ -22584,7 +22883,7 @@
22584
22883
  var _proto = SpotLight.prototype;
22585
22884
  /**
22586
22885
  * @internal
22587
- */ _proto._appendData = function _appendData(lightIndex) {
22886
+ */ _proto._appendData = function _appendData(lightIndex, data) {
22588
22887
  var cullingMaskStart = lightIndex * 2;
22589
22888
  var colorStart = lightIndex * 3;
22590
22889
  var positionStart = lightIndex * 3;
@@ -22595,7 +22894,6 @@
22595
22894
  var lightColor = this._getLightIntensityColor();
22596
22895
  var position = this.position;
22597
22896
  var direction = this.direction;
22598
- var data = SpotLight._combinedData;
22599
22897
  var cullingMask = this.cullingMask;
22600
22898
  data.cullingMask[cullingMaskStart] = cullingMask & 65535;
22601
22899
  data.cullingMask[cullingMaskStart + 1] = cullingMask >>> 16 & 65535;
@@ -22630,8 +22928,7 @@
22630
22928
  };
22631
22929
  /**
22632
22930
  * @internal
22633
- */ SpotLight._updateShaderData = function _updateShaderData(shaderData) {
22634
- var data = SpotLight._combinedData;
22931
+ */ SpotLight._updateShaderData = function _updateShaderData(shaderData, data) {
22635
22932
  shaderData.setIntArray(SpotLight._cullingMaskProperty, data.cullingMask);
22636
22933
  shaderData.setFloatArray(SpotLight._colorProperty, data.color);
22637
22934
  shaderData.setFloatArray(SpotLight._positionProperty, data.position);
@@ -22701,25 +22998,34 @@
22701
22998
  (function() {
22702
22999
  SpotLight._penumbraCosProperty = ShaderProperty.getByName("scene_SpotLightPenumbraCos");
22703
23000
  })();
22704
- (function() {
22705
- SpotLight._combinedData = {
22706
- cullingMask: new Int32Array(Light._maxLight * 2),
22707
- color: new Float32Array(Light._maxLight * 3),
22708
- position: new Float32Array(Light._maxLight * 3),
22709
- direction: new Float32Array(Light._maxLight * 3),
22710
- distance: new Float32Array(Light._maxLight),
22711
- angleCos: new Float32Array(Light._maxLight),
22712
- penumbraCos: new Float32Array(Light._maxLight)
22713
- };
22714
- })();
22715
23001
  /**
22716
23002
  * Light manager.
22717
23003
  */ var LightManager = /*#__PURE__*/ function() {
22718
- var LightManager = function LightManager() {
23004
+ function LightManager() {
22719
23005
  /** @internal */ this._spotLights = new DisorderedArray();
22720
23006
  /** @internal */ this._pointLights = new DisorderedArray();
22721
23007
  /** @internal */ this._directLights = new DisorderedArray();
22722
- };
23008
+ this._directData = {
23009
+ cullingMask: new Int32Array(LightManager._maxLight * 2),
23010
+ color: new Float32Array(LightManager._maxLight * 3),
23011
+ direction: new Float32Array(LightManager._maxLight * 3)
23012
+ };
23013
+ this._pointData = {
23014
+ cullingMask: new Int32Array(LightManager._maxLight * 2),
23015
+ color: new Float32Array(LightManager._maxLight * 3),
23016
+ position: new Float32Array(LightManager._maxLight * 3),
23017
+ distance: new Float32Array(LightManager._maxLight)
23018
+ };
23019
+ this._spotData = {
23020
+ cullingMask: new Int32Array(LightManager._maxLight * 2),
23021
+ color: new Float32Array(LightManager._maxLight * 3),
23022
+ position: new Float32Array(LightManager._maxLight * 3),
23023
+ direction: new Float32Array(LightManager._maxLight * 3),
23024
+ distance: new Float32Array(LightManager._maxLight),
23025
+ angleCos: new Float32Array(LightManager._maxLight),
23026
+ penumbraCos: new Float32Array(LightManager._maxLight)
23027
+ };
23028
+ }
22723
23029
  var _proto = LightManager.prototype;
22724
23030
  /**
22725
23031
  * @internal
@@ -22778,38 +23084,34 @@
22778
23084
  /**
22779
23085
  * @internal
22780
23086
  */ _proto._updateShaderData = function _updateShaderData(shaderData) {
22781
- var spotLight = this._spotLights;
22782
- var pointLight = this._pointLights;
22783
- var directLight = this._directLights;
23087
+ var _this = this, spotLight = _this._spotLights, pointLight = _this._pointLights, directLight = _this._directLights;
23088
+ var _this1 = this, spotData = _this1._spotData, pointData = _this1._pointData, directData = _this1._directData;
22784
23089
  var spotLightCount = spotLight.length;
22785
23090
  var pointLightCount = pointLight.length;
22786
23091
  var directLightCount = directLight.length;
22787
- for(var i = 0, len = spotLightCount; i < len; i++){
22788
- var light = spotLight.get(i);
22789
- light._appendData(i);
23092
+ for(var i = 0; i < spotLightCount; i++){
23093
+ spotLight.get(i)._appendData(i, spotData);
22790
23094
  }
22791
- for(var i1 = 0, len1 = pointLightCount; i1 < len1; i1++){
22792
- var light1 = pointLight.get(i1);
22793
- light1._appendData(i1);
23095
+ for(var i1 = 0; i1 < pointLightCount; i1++){
23096
+ pointLight.get(i1)._appendData(i1, pointData);
22794
23097
  }
22795
- for(var i2 = 0, len2 = directLightCount; i2 < len2; i2++){
22796
- var light2 = directLight.get(i2);
22797
- light2._appendData(i2);
23098
+ for(var i2 = 0; i2 < directLightCount; i2++){
23099
+ directLight.get(i2)._appendData(i2, directData);
22798
23100
  }
22799
23101
  if (directLightCount) {
22800
- DirectLight._updateShaderData(shaderData);
23102
+ DirectLight._updateShaderData(shaderData, directData);
22801
23103
  shaderData.enableMacro("SCENE_DIRECT_LIGHT_COUNT", directLightCount.toString());
22802
23104
  } else {
22803
23105
  shaderData.disableMacro("SCENE_DIRECT_LIGHT_COUNT");
22804
23106
  }
22805
23107
  if (pointLightCount) {
22806
- PointLight._updateShaderData(shaderData);
23108
+ PointLight._updateShaderData(shaderData, pointData);
22807
23109
  shaderData.enableMacro("SCENE_POINT_LIGHT_COUNT", pointLightCount.toString());
22808
23110
  } else {
22809
23111
  shaderData.disableMacro("SCENE_POINT_LIGHT_COUNT");
22810
23112
  }
22811
23113
  if (spotLightCount) {
22812
- SpotLight._updateShaderData(shaderData);
23114
+ SpotLight._updateShaderData(shaderData, spotData);
22813
23115
  shaderData.enableMacro("SCENE_SPOT_LIGHT_COUNT", spotLightCount.toString());
22814
23116
  } else {
22815
23117
  shaderData.disableMacro("SCENE_SPOT_LIGHT_COUNT");
@@ -22850,6 +23152,11 @@
22850
23152
  };
22851
23153
  return LightManager;
22852
23154
  }();
23155
+ (function() {
23156
+ /**
23157
+ * Each type of light source is at most 10, beyond which it will not take effect.
23158
+ * */ LightManager._maxLight = 10;
23159
+ })();
22853
23160
  /**
22854
23161
  * Scene.
22855
23162
  */ var Scene = /*#__PURE__*/ function(EngineObject1) {
@@ -22879,6 +23186,7 @@
22879
23186
  _this._fogEnd = 300;
22880
23187
  _this._fogDensity = 0.01;
22881
23188
  _this._fogParams = new Vector4();
23189
+ _this._isActive = true;
22882
23190
  _this.name = name1 || "";
22883
23191
  var shaderData = _this.shaderData;
22884
23192
  shaderData._addReferCount(1);
@@ -23126,6 +23434,24 @@
23126
23434
  this._fogParams.w = density / Math.sqrt(Math.LN2);
23127
23435
  };
23128
23436
  _create_class$3(Scene, [
23437
+ {
23438
+ key: "isActive",
23439
+ get: /**
23440
+ * Whether the scene is active.
23441
+ */ function get() {
23442
+ return this._isActive;
23443
+ },
23444
+ set: function set(value) {
23445
+ if (this._isActive !== value) {
23446
+ this._isActive = value;
23447
+ if (value) {
23448
+ this._sceneManager && this._processActive(true);
23449
+ } else {
23450
+ this._sceneManager && this._processActive(false);
23451
+ }
23452
+ }
23453
+ }
23454
+ },
23129
23455
  {
23130
23456
  key: "shaderData",
23131
23457
  get: /**
@@ -23443,7 +23769,11 @@
23443
23769
  * @internal
23444
23770
  */ _proto._onDestroy = function _onDestroy() {
23445
23771
  Component1.prototype._onDestroy.call(this);
23446
- this.scene._componentsManager.addPendingDestroyScript(this);
23772
+ if (this.scene) {
23773
+ this.scene._componentsManager.addPendingDestroyScript(this);
23774
+ } else {
23775
+ this.onDestroy();
23776
+ }
23447
23777
  };
23448
23778
  return Script;
23449
23779
  }(Component);
@@ -23583,7 +23913,7 @@
23583
23913
  _proto.drawBatches = function drawBatches(camera) {
23584
23914
  var _this = this, engine = _this._engine, batchedQueue = _this._batchedQueue;
23585
23915
  var mesh = this._meshes[this._flushId];
23586
- var subMeshes = mesh.subMeshes;
23916
+ var subMeshes = mesh.subMeshes, primitive = mesh._primitive;
23587
23917
  var maskManager = engine._spriteMaskManager;
23588
23918
  var sceneData = camera.scene.shaderData;
23589
23919
  var cameraData = camera.shaderData;
@@ -23613,7 +23943,7 @@
23613
23943
  program.uploadAll(program.rendererUniformBlock, renderer.shaderData);
23614
23944
  program.uploadAll(program.materialUniformBlock, material.shaderData);
23615
23945
  material.renderState._apply(engine, false, shaderPass._renderStateDataMap, material.shaderData);
23616
- engine._hardwareRenderer.drawPrimitive(mesh._primitive, subMesh, program);
23946
+ engine._hardwareRenderer.drawPrimitive(primitive, subMesh, program);
23617
23947
  maskManager.postRender(renderer);
23618
23948
  }
23619
23949
  };
@@ -24980,8 +25310,8 @@
24980
25310
  };
24981
25311
  _proto._drawBackgroundTexture = function _drawBackgroundTexture(engine, background) {
24982
25312
  var rhi = engine._hardwareRenderer;
24983
- var material = engine._backgroundTextureMaterial, canvas = engine.canvas;
24984
- var mesh = background._mesh;
25313
+ var canvas = engine.canvas;
25314
+ var material = background._material, mesh = background._mesh;
24985
25315
  if ((this._lastCanvasSize.x !== canvas.width || this._lastCanvasSize.y !== canvas.height) && background._textureFillMode !== exports.BackgroundTextureFillMode.Fill) {
24986
25316
  this._lastCanvasSize.set(canvas.width, canvas.height);
24987
25317
  background._resizeBackgroundTexture();
@@ -25154,7 +25484,7 @@
25154
25484
  // Use the intersection of the near clipping plane as the origin point.
25155
25485
  var origin = this._innerViewportToWorldPoint(point.x, point.y, 0.0, invViewProjMat, out.origin);
25156
25486
  // Use the intersection of the far clipping plane as the origin point.
25157
- var direction = this._innerViewportToWorldPoint(point.x, point.y, 1.0, invViewProjMat, out.direction);
25487
+ var direction = this._innerViewportToWorldPoint(point.x, point.y, 1 - MathUtil$1.zeroTolerance, invViewProjMat, out.direction);
25158
25488
  Vector3.subtract(direction, origin, direction);
25159
25489
  direction.normalize();
25160
25490
  return out;
@@ -28129,11 +28459,11 @@
28129
28459
  /**
28130
28460
  * @internal
28131
28461
  */ var CharRenderDataPool = /*#__PURE__*/ function() {
28132
- var CharRenderDataPool = function CharRenderDataPool(type, length1) {
28462
+ var CharRenderDataPool = function CharRenderDataPool(type, length) {
28133
28463
  this._elements = [];
28134
28464
  this._type = type;
28135
28465
  var elements = this._elements;
28136
- for(var i = 0; i < length1; ++i){
28466
+ for(var i = 0; i < length; ++i){
28137
28467
  elements[i] = new type();
28138
28468
  }
28139
28469
  };
@@ -28768,6 +29098,9 @@
28768
29098
  this.property = property;
28769
29099
  this.component = target.getComponent(type);
28770
29100
  this.cureType = cureType;
29101
+ var isBlendShape = _instanceof1$2(this.component, SkinnedMeshRenderer);
29102
+ // @todo: Temp solution with blendShape
29103
+ this._isCopyMode = cureType._isCopyMode && !isBlendShape;
28771
29104
  var assemblerType = AnimationCurveOwner.getAssemblerType(type, property);
28772
29105
  this._assembler = new assemblerType();
28773
29106
  this._assembler.initialize(this);
@@ -28799,7 +29132,7 @@
28799
29132
  this._assembler.setTargetValue(this.defaultValue);
28800
29133
  };
28801
29134
  _proto.getEvaluateValue = function getEvaluateValue(out) {
28802
- if (this.cureType._isCopyMode) {
29135
+ if (this._isCopyMode) {
28803
29136
  this.cureType._setValue(this.baseEvaluateData.value, out);
28804
29137
  return out;
28805
29138
  } else {
@@ -28807,14 +29140,14 @@
28807
29140
  }
28808
29141
  };
28809
29142
  _proto.saveDefaultValue = function saveDefaultValue() {
28810
- if (this.cureType._isCopyMode) {
29143
+ if (this._isCopyMode) {
28811
29144
  this.cureType._setValue(this.referenceTargetValue, this.defaultValue);
28812
29145
  } else {
28813
29146
  this.defaultValue = this._assembler.getTargetValue();
28814
29147
  }
28815
29148
  };
28816
29149
  _proto.saveFixedPoseValue = function saveFixedPoseValue() {
28817
- if (this.cureType._isCopyMode) {
29150
+ if (this._isCopyMode) {
28818
29151
  this.cureType._setValue(this.referenceTargetValue, this.fixedPoseValue);
28819
29152
  } else {
28820
29153
  this.fixedPoseValue = this._assembler.getTargetValue();
@@ -28823,7 +29156,7 @@
28823
29156
  _proto.applyValue = function applyValue(value, weight, additive) {
28824
29157
  var cureType = this.cureType;
28825
29158
  if (additive) {
28826
- if (cureType._isCopyMode) {
29159
+ if (this._isCopyMode) {
28827
29160
  cureType._additiveValue(value, weight, this.referenceTargetValue);
28828
29161
  } else {
28829
29162
  var assembler = this._assembler;
@@ -28833,13 +29166,13 @@
28833
29166
  }
28834
29167
  } else {
28835
29168
  if (weight === 1.0) {
28836
- if (cureType._isCopyMode) {
29169
+ if (this._isCopyMode) {
28837
29170
  cureType._setValue(value, this.referenceTargetValue);
28838
29171
  } else {
28839
29172
  this._assembler.setTargetValue(value);
28840
29173
  }
28841
29174
  } else {
28842
- if (cureType._isCopyMode) {
29175
+ if (this._isCopyMode) {
28843
29176
  var targetValue = this.referenceTargetValue;
28844
29177
  cureType._lerpValue(targetValue, value, weight, targetValue);
28845
29178
  } else {
@@ -28851,7 +29184,7 @@
28851
29184
  }
28852
29185
  };
28853
29186
  _proto._lerpValue = function _lerpValue(srcValue, destValue, crossWeight) {
28854
- if (this.cureType._isCopyMode) {
29187
+ if (this._isCopyMode) {
28855
29188
  return this.cureType._lerpValue(srcValue, destValue, crossWeight, this.baseEvaluateData.value);
28856
29189
  } else {
28857
29190
  this.baseEvaluateData.value = this.cureType._lerpValue(srcValue, destValue, crossWeight);
@@ -28930,16 +29263,22 @@
28930
29263
  /**
28931
29264
  * @internal
28932
29265
  */ var BlendShapeWeightsAnimationCurveOwnerAssembler = /*#__PURE__*/ function() {
28933
- var BlendShapeWeightsAnimationCurveOwnerAssembler = function BlendShapeWeightsAnimationCurveOwnerAssembler() {};
29266
+ var BlendShapeWeightsAnimationCurveOwnerAssembler = function BlendShapeWeightsAnimationCurveOwnerAssembler() {
29267
+ this._skinnedMeshRenderer = [];
29268
+ };
28934
29269
  var _proto = BlendShapeWeightsAnimationCurveOwnerAssembler.prototype;
28935
29270
  _proto.initialize = function initialize(owner) {
28936
- this._skinnedMeshRenderer = owner.target.getComponent(SkinnedMeshRenderer);
29271
+ // @todo: Compatible with multiple SkinnedMeshRenderer in a entity, optimize later.
29272
+ owner.target.getComponents(SkinnedMeshRenderer, this._skinnedMeshRenderer);
28937
29273
  };
28938
29274
  _proto.getTargetValue = function getTargetValue() {
28939
- return this._skinnedMeshRenderer.blendShapeWeights;
29275
+ return this._skinnedMeshRenderer[0].blendShapeWeights;
28940
29276
  };
28941
29277
  _proto.setTargetValue = function setTargetValue(value) {
28942
- this._skinnedMeshRenderer.blendShapeWeights = value;
29278
+ var skinnedMeshRenderer = this._skinnedMeshRenderer;
29279
+ for(var i = 0, n = skinnedMeshRenderer.length; i < n; i++){
29280
+ skinnedMeshRenderer[i].blendShapeWeights = value;
29281
+ }
28943
29282
  };
28944
29283
  return BlendShapeWeightsAnimationCurveOwnerAssembler;
28945
29284
  }();
@@ -29178,8 +29517,8 @@
29178
29517
  /**
29179
29518
  * @internal
29180
29519
  */ _proto._evaluate = function _evaluate(time, evaluateData) {
29181
- var length1 = this.keys.length;
29182
- if (!length1) {
29520
+ var length = this.keys.length;
29521
+ if (!length) {
29183
29522
  console.warn("This curve don't have any keyframes: ", this);
29184
29523
  return;
29185
29524
  }
@@ -29187,11 +29526,11 @@
29187
29526
  // Compute curIndex and nextIndex.
29188
29527
  var curIndex = evaluateData.curKeyframeIndex;
29189
29528
  // Reset loop,if delete keyfranme may cause `curIndex >= length`
29190
- if (curIndex !== -1 && (curIndex >= length1 || time < keys[curIndex].time)) {
29529
+ if (curIndex !== -1 && (curIndex >= length || time < keys[curIndex].time)) {
29191
29530
  curIndex = -1;
29192
29531
  }
29193
29532
  var nextIndex = curIndex + 1;
29194
- while(nextIndex < length1){
29533
+ while(nextIndex < length){
29195
29534
  if (time < keys[nextIndex].time) {
29196
29535
  break;
29197
29536
  }
@@ -29203,7 +29542,7 @@
29203
29542
  var value;
29204
29543
  if (curIndex === -1) {
29205
29544
  value = this._type._setValue(keys[0].value, evaluateData.value);
29206
- } else if (nextIndex === length1) {
29545
+ } else if (nextIndex === length) {
29207
29546
  value = this._type._setValue(keys[curIndex].value, evaluateData.value);
29208
29547
  } else {
29209
29548
  // Time between first frame and end frame.
@@ -31564,62 +31903,199 @@
31564
31903
  (function() {
31565
31904
  SkyProceduralMaterial._sunSimpleMacro = ShaderMacro.getByName("MATERIAL_SUN_SIMPLE");
31566
31905
  })();
31906
+ var SubPrimitive = function SubPrimitive() {};
31567
31907
  /**
31568
- * Particle Material.
31569
- */ var ParticleMaterial = /*#__PURE__*/ function(BaseMaterial1) {
31570
- var ParticleMaterial = function ParticleMaterial(engine) {
31908
+ * The rendering mode for particle renderer.
31909
+ */ exports.ParticleRenderMode = void 0;
31910
+ (function(ParticleRenderMode) {
31911
+ ParticleRenderMode[ParticleRenderMode[/** Render particles as billboards facing the active camera. */ "Billboard"] = 0] = "Billboard";
31912
+ ParticleRenderMode[ParticleRenderMode[/** Stretch particles in the direction of motion. */ "StretchBillboard"] = 1] = "StretchBillboard";
31913
+ ParticleRenderMode[ParticleRenderMode[/** Render particles as billboards always facing up along the y-Axis. */ "HorizontalBillboard"] = 2] = "HorizontalBillboard";
31914
+ ParticleRenderMode[ParticleRenderMode[/** Render particles as billboards always facing the player, but not pitching along the x-Axis. */ "VerticalBillboard"] = 3] = "VerticalBillboard";
31915
+ ParticleRenderMode[ParticleRenderMode[/** Render particles as meshes. */ "Mesh"] = 4] = "Mesh";
31916
+ ParticleRenderMode[ParticleRenderMode[/** Do not render particles. */ "None"] = 5] = "None";
31917
+ })(exports.ParticleRenderMode || (exports.ParticleRenderMode = {}));
31918
+ exports.ParticleStopMode = void 0;
31919
+ (function(ParticleStopMode) {
31920
+ ParticleStopMode[ParticleStopMode[/** Stop emitting new particles and clear existing particles immediately. */ "StopEmittingAndClear"] = 0] = "StopEmittingAndClear";
31921
+ ParticleStopMode[ParticleStopMode[/** Stop emitting new particles, but keep existing particles until they expire. */ "StopEmitting"] = 1] = "StopEmitting";
31922
+ })(exports.ParticleStopMode || (exports.ParticleStopMode = {}));
31923
+ /**
31924
+ * Particle Renderer Component.
31925
+ */ var ParticleRenderer = /*#__PURE__*/ function(Renderer1) {
31926
+ _inherits$2(ParticleRenderer, Renderer1);
31927
+ function ParticleRenderer(entity) {
31571
31928
  var _this;
31572
- _this = BaseMaterial1.call(this, engine, Shader.find("particle-shader")) || this;
31573
- var shaderData = _this.shaderData;
31574
- shaderData.enableMacro("MATERIAL_OMIT_NORMAL");
31575
- shaderData.setColor(BaseMaterial._baseColorProp, new Color$1(1, 1, 1, 1));
31576
- _this.isTransparent = true;
31929
+ _this = Renderer1.call(this, entity) || this;
31930
+ /** Particle generator. */ _this.generator = new ParticleGenerator(_assert_this_initialized(_this));
31931
+ /** Specifies how much particles stretch depending on their velocity. */ _this.velocityScale = 0;
31932
+ /** 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;
31933
+ /** The pivot of particle. */ _this.pivot = new Vector3();
31934
+ _this._currentRenderModeMacro = ParticleRenderer._billboardModeMacro;
31935
+ _this.shaderData.enableMacro(ParticleRenderer._billboardModeMacro);
31936
+ _this._supportInstancedArrays = _this.engine._hardwareRenderer.canIUse(exports.GLCapabilityType.instancedArrays);
31577
31937
  return _this;
31938
+ }
31939
+ var _proto = ParticleRenderer.prototype;
31940
+ /**
31941
+ * @internal
31942
+ */ _proto._onEnable = function _onEnable() {
31943
+ if (this.generator.main.playOnEnabled) {
31944
+ this.generator.play(false);
31945
+ }
31578
31946
  };
31579
- _inherits$2(ParticleMaterial, BaseMaterial1);
31580
- var _proto = ParticleMaterial.prototype;
31581
31947
  /**
31582
- * @inheritdoc
31583
- */ _proto.clone = function clone() {
31584
- var dest = new ParticleMaterial(this._engine);
31585
- this.cloneTo(dest);
31586
- return dest;
31948
+ * @internal
31949
+ */ _proto._onDisable = function _onDisable() {
31950
+ this.generator.stop(false, exports.ParticleStopMode.StopEmittingAndClear);
31587
31951
  };
31588
- _create_class$3(ParticleMaterial, [
31952
+ /**
31953
+ * @internal
31954
+ */ _proto._prepareRender = function _prepareRender(context) {
31955
+ if (!this._supportInstancedArrays) {
31956
+ return;
31957
+ }
31958
+ var generator = this.generator;
31959
+ generator._update(this.engine.time.deltaTime);
31960
+ // No particles to render
31961
+ if (generator._firstActiveElement === generator._firstFreeElement) {
31962
+ return;
31963
+ }
31964
+ Renderer1.prototype._prepareRender.call(this, context);
31965
+ };
31966
+ /**
31967
+ * @internal
31968
+ */ _proto._updateBounds = function _updateBounds(worldBounds) {
31969
+ worldBounds.min.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
31970
+ worldBounds.max.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
31971
+ };
31972
+ /**
31973
+ * @internal
31974
+ */ _proto._updateShaderData = function _updateShaderData(context) {
31975
+ var shaderData = this.shaderData;
31976
+ shaderData.setFloat(ParticleRenderer._lengthScale, this.lengthScale);
31977
+ shaderData.setFloat(ParticleRenderer._speedScale, this.velocityScale);
31978
+ shaderData.setFloat(ParticleRenderer._currentTime, this.generator._playTime);
31979
+ shaderData.setVector3(ParticleRenderer._pivotOffsetProperty, this.pivot);
31980
+ this.generator._updateShaderData(shaderData);
31981
+ };
31982
+ _proto._render = function _render(context) {
31983
+ var generator = this.generator;
31984
+ var primitive = generator._primitive;
31985
+ if (generator._firstActiveElement < generator._firstFreeElement) {
31986
+ primitive.instanceCount = generator._firstFreeElement - generator._firstActiveElement;
31987
+ } else {
31988
+ var instanceCount = generator._currentParticleCount - generator._firstActiveElement;
31989
+ if (generator._firstFreeElement > 0) {
31990
+ instanceCount += generator._firstFreeElement;
31991
+ }
31992
+ primitive.instanceCount = instanceCount;
31993
+ }
31994
+ var material = this.getMaterial();
31995
+ var renderData = this._engine._renderDataPool.getFromPool();
31996
+ renderData.setX(this, material, generator._primitive, generator._subPrimitive);
31997
+ context.camera._renderPipeline.pushRenderData(context, renderData);
31998
+ };
31999
+ _proto._onDestroy = function _onDestroy() {
32000
+ this.generator._destroy();
32001
+ };
32002
+ _create_class$3(ParticleRenderer, [
31589
32003
  {
31590
- key: "baseColor",
32004
+ key: "renderMode",
31591
32005
  get: /**
31592
- * Base color.
32006
+ * Specifies how particles are rendered.
31593
32007
  */ function get() {
31594
- return this.shaderData.getColor(BaseMaterial._baseColorProp);
32008
+ return this._renderMode;
31595
32009
  },
31596
32010
  set: function set(value) {
31597
- var baseColor = this.shaderData.getColor(BaseMaterial._baseColorProp);
31598
- if (value !== baseColor) {
31599
- baseColor.copyFrom(value);
32011
+ if (this._renderMode !== value) {
32012
+ var lastRenderMode = this._renderMode;
32013
+ this._renderMode = value;
32014
+ var renderModeMacro = null;
32015
+ var shaderData = this.shaderData;
32016
+ switch(value){
32017
+ case exports.ParticleRenderMode.Billboard:
32018
+ renderModeMacro = ParticleRenderer._billboardModeMacro;
32019
+ break;
32020
+ case exports.ParticleRenderMode.StretchBillboard:
32021
+ renderModeMacro = ParticleRenderer._stretchedBillboardModeMacro;
32022
+ break;
32023
+ case exports.ParticleRenderMode.HorizontalBillboard:
32024
+ throw "Not implemented";
32025
+ case exports.ParticleRenderMode.VerticalBillboard:
32026
+ throw "Not implemented";
32027
+ case exports.ParticleRenderMode.Mesh:
32028
+ throw "Not implemented";
32029
+ }
32030
+ if (this._currentRenderModeMacro !== renderModeMacro) {
32031
+ this._currentRenderModeMacro && shaderData.disableMacro(this._currentRenderModeMacro);
32032
+ renderModeMacro && shaderData.enableMacro(renderModeMacro);
32033
+ this._currentRenderModeMacro = renderModeMacro;
32034
+ }
32035
+ // @ts-ignore
32036
+ if (lastRenderMode !== exports.ParticleRenderMode.Mesh !== (value === exports.ParticleRenderMode.Mesh)) {
32037
+ this.generator._reorganizeGeometryBuffers();
32038
+ }
31600
32039
  }
31601
32040
  }
31602
32041
  },
31603
32042
  {
31604
- key: "baseTexture",
32043
+ key: "mesh",
31605
32044
  get: /**
31606
- * Base texture.
32045
+ * The mesh of particle.
32046
+ * @remarks Valid when `renderMode` is `Mesh`.
31607
32047
  */ function get() {
31608
- return this.shaderData.getTexture(BaseMaterial._baseTextureProp);
32048
+ return this._mesh;
31609
32049
  },
31610
32050
  set: function set(value) {
31611
- this.shaderData.setTexture(BaseMaterial._baseTextureProp, value);
31612
- if (value) {
31613
- this.shaderData.enableMacro(BaseMaterial._baseTextureMacro);
31614
- } else {
31615
- this.shaderData.disableMacro(BaseMaterial._baseTextureMacro);
32051
+ var lastMesh = this._mesh;
32052
+ if (lastMesh !== value) {
32053
+ var _lastMesh, _value;
32054
+ this._mesh = value;
32055
+ (_lastMesh = lastMesh) == null ? void 0 : _lastMesh._addReferCount(-1);
32056
+ (_value = value) == null ? void 0 : _value._addReferCount(1);
32057
+ if (this.renderMode === exports.ParticleRenderMode.Mesh) {
32058
+ this.generator._reorganizeGeometryBuffers();
32059
+ }
31616
32060
  }
31617
32061
  }
31618
32062
  }
31619
32063
  ]);
31620
- return ParticleMaterial;
31621
- }(BaseMaterial);
31622
- var SubPrimitive = function SubPrimitive() {};
32064
+ return ParticleRenderer;
32065
+ }(exports.Renderer);
32066
+ (function() {
32067
+ ParticleRenderer._billboardModeMacro = ShaderMacro.getByName("RENDERER_MODE_SPHERE_BILLBOARD");
32068
+ })();
32069
+ (function() {
32070
+ ParticleRenderer._stretchedBillboardModeMacro = ShaderMacro.getByName("RENDERER_MODE_STRETCHED_BILLBOARD");
32071
+ })();
32072
+ (function() {
32073
+ ParticleRenderer._horizontalBillboardModeMacro = ShaderMacro.getByName("RENDERER_MODE_HORIZONTAL_BILLBOARD");
32074
+ })();
32075
+ (function() {
32076
+ ParticleRenderer._verticalBillboardModeMacro = ShaderMacro.getByName("RENDERER_MODE_VERTICAL_BILLBOARD");
32077
+ })();
32078
+ (function() {
32079
+ ParticleRenderer._renderModeMeshMacro = ShaderMacro.getByName("RENDERER_MODE_MESH");
32080
+ })();
32081
+ (function() {
32082
+ ParticleRenderer._pivotOffsetProperty = ShaderProperty.getByName("renderer_PivotOffset");
32083
+ })();
32084
+ (function() {
32085
+ ParticleRenderer._lengthScale = ShaderProperty.getByName("renderer_StretchedBillboardLengthScale");
32086
+ })();
32087
+ (function() {
32088
+ ParticleRenderer._speedScale = ShaderProperty.getByName("renderer_StretchedBillboardSpeedScale");
32089
+ })();
32090
+ (function() {
32091
+ ParticleRenderer._currentTime = ShaderProperty.getByName("renderer_CurrentTime");
32092
+ })();
32093
+ __decorate$1([
32094
+ deepClone
32095
+ ], ParticleRenderer.prototype, "generator", void 0);
32096
+ __decorate$1([
32097
+ shallowClone
32098
+ ], ParticleRenderer.prototype, "pivot", void 0);
31623
32099
  /**
31624
32100
  * Particle curve mode.
31625
32101
  */ exports.ParticleCurveMode = void 0;
@@ -31638,17 +32114,6 @@
31638
32114
  ParticleGradientMode[ParticleGradientMode[/* Single color gradient curve mode. */ "Gradient"] = 2] = "Gradient";
31639
32115
  ParticleGradientMode[ParticleGradientMode[/* Random value between two color gradients. */ "TwoGradients"] = 3] = "TwoGradients";
31640
32116
  })(exports.ParticleGradientMode || (exports.ParticleGradientMode = {}));
31641
- /**
31642
- * The rendering mode for particle renderer.
31643
- */ exports.ParticleRenderMode = void 0;
31644
- (function(ParticleRenderMode) {
31645
- ParticleRenderMode[ParticleRenderMode[/** Render particles as billboards facing the active camera. */ "Billboard"] = 0] = "Billboard";
31646
- ParticleRenderMode[ParticleRenderMode[/** Stretch particles in the direction of motion. */ "StretchBillboard"] = 1] = "StretchBillboard";
31647
- ParticleRenderMode[ParticleRenderMode[/** Render particles as billboards always facing up along the y-Axis. */ "HorizontalBillboard"] = 2] = "HorizontalBillboard";
31648
- ParticleRenderMode[ParticleRenderMode[/** Render particles as billboards always facing the player, but not pitching along the x-Axis. */ "VerticalBillboard"] = 3] = "VerticalBillboard";
31649
- ParticleRenderMode[ParticleRenderMode[/** Render particles as meshes. */ "Mesh"] = 4] = "Mesh";
31650
- ParticleRenderMode[ParticleRenderMode[/** Do not render particles. */ "None"] = 5] = "None";
31651
- })(exports.ParticleRenderMode || (exports.ParticleRenderMode = {}));
31652
32117
  /**
31653
32118
  * The space to simulate particles in.
31654
32119
  */ exports.ParticleSimulationSpace = void 0;
@@ -31656,11 +32121,6 @@
31656
32121
  ParticleSimulationSpace[ParticleSimulationSpace[/** Simulate particles in local space. */ "Local"] = 0] = "Local";
31657
32122
  ParticleSimulationSpace[ParticleSimulationSpace[/** Simulate particles in world space. */ "World"] = 1] = "World";
31658
32123
  })(exports.ParticleSimulationSpace || (exports.ParticleSimulationSpace = {}));
31659
- exports.ParticleStopMode = void 0;
31660
- (function(ParticleStopMode) {
31661
- ParticleStopMode[ParticleStopMode[/** Stop emitting new particles and clear existing particles immediately. */ "StopEmittingAndClear"] = 0] = "StopEmittingAndClear";
31662
- ParticleStopMode[ParticleStopMode[/** Stop emitting new particles, but keep existing particles until they expire. */ "StopEmitting"] = 1] = "StopEmitting";
31663
- })(exports.ParticleStopMode || (exports.ParticleStopMode = {}));
31664
32124
  /**
31665
32125
  * @internal
31666
32126
  */ var ParticleRandomSubSeeds;
@@ -32280,15 +32740,13 @@
32280
32740
  /** The initial lifetime of particles when emitted. */ this.startLifetime = new ParticleCompositeCurve(5);
32281
32741
  /** The initial speed of particles when the Particle Generator first spawns them. */ this.startSpeed = new ParticleCompositeCurve(5);
32282
32742
  /** A flag to enable specifying particle size individually for each axis. */ this.startSize3D = false;
32283
- /** The initial size of particles when the Particle Generator first spawns them. */ this.startSize = new ParticleCompositeCurve(1);
32284
32743
  /** The initial size of particles along the x-axis when the Particle Generator first spawns them. */ this.startSizeX = new ParticleCompositeCurve(1);
32285
32744
  /** The initial size of particles along the y-axis when the Particle Generator first spawns them. */ this.startSizeY = new ParticleCompositeCurve(1);
32286
32745
  /** The initial size of particles along the z-axis when the Particle Generator first spawns them. */ this.startSizeZ = new ParticleCompositeCurve(1);
32287
- /** A flag to enable 3D particle rotation. */ this.startRotation3D = false;
32288
- /** The initial rotation of particles when the Particle Generator first spawns them. */ this.startRotation = new ParticleCompositeCurve(0);
32746
+ /** A flag to enable 3D particle rotation, when disabled, only `startRotationZ` is used. */ this.startRotation3D = false;
32289
32747
  /** The initial rotation of particles around the x-axis when emitted.*/ this.startRotationX = new ParticleCompositeCurve(0);
32290
32748
  /** The initial rotation of particles around the y-axis when emitted. */ this.startRotationY = new ParticleCompositeCurve(0);
32291
- this.startRotationZ = new ParticleCompositeCurve(0);
32749
+ /** The initial rotation of particles around the z-axis when emitted. */ this.startRotationZ = new ParticleCompositeCurve(0);
32292
32750
  /** Makes some particles spin in the opposite direction. */ this.flipRotation = 0;
32293
32751
  /** The mode of start color */ this.startColor = new ParticleCompositeGradient(new Color$1(1, 1, 1, 1));
32294
32752
  /** A scale that this Particle Generator applies to gravity, defined by Physics.gravity. */ this.gravityModifier = new ParticleCompositeCurve(0);
@@ -32391,6 +32849,17 @@
32391
32849
  }
32392
32850
  }
32393
32851
  }
32852
+ },
32853
+ {
32854
+ key: "startSize",
32855
+ get: /**
32856
+ * The initial size of particles when the Particle Generator first spawns them.
32857
+ */ function get() {
32858
+ return this.startSizeX;
32859
+ },
32860
+ set: function set(value) {
32861
+ this.startSizeX = value;
32862
+ }
32394
32863
  }
32395
32864
  ]);
32396
32865
  return MainModule;
@@ -32434,9 +32903,6 @@
32434
32903
  __decorate$1([
32435
32904
  deepClone
32436
32905
  ], MainModule.prototype, "startSpeed", void 0);
32437
- __decorate$1([
32438
- deepClone
32439
- ], MainModule.prototype, "startSize", void 0);
32440
32906
  __decorate$1([
32441
32907
  deepClone
32442
32908
  ], MainModule.prototype, "startSizeX", void 0);
@@ -32446,9 +32912,6 @@
32446
32912
  __decorate$1([
32447
32913
  deepClone
32448
32914
  ], MainModule.prototype, "startSizeZ", void 0);
32449
- __decorate$1([
32450
- deepClone
32451
- ], MainModule.prototype, "startRotation", void 0);
32452
32915
  __decorate$1([
32453
32916
  deepClone
32454
32917
  ], MainModule.prototype, "startRotationX", void 0);
@@ -32456,7 +32919,6 @@
32456
32919
  deepClone
32457
32920
  ], MainModule.prototype, "startRotationY", void 0);
32458
32921
  __decorate$1([
32459
- deepClone,
32460
32922
  deepClone
32461
32923
  ], MainModule.prototype, "startRotationZ", void 0);
32462
32924
  __decorate$1([
@@ -32495,7 +32957,7 @@
32495
32957
  var RotationOverLifetimeModule = function RotationOverLifetimeModule() {
32496
32958
  var _this;
32497
32959
  _this = ParticleGeneratorModule1.apply(this, arguments) || this;
32498
- /** Specifies whether the rotation is separate on each axis, when disabled only z axis is used. */ _this.separateAxes = false;
32960
+ /** Specifies whether the rotation is separate on each axis, when disabled, only `rotationZ` is used. */ _this.separateAxes = false;
32499
32961
  /** Rotation over lifetime for z axis. */ _this.rotationX = new ParticleCompositeCurve(0);
32500
32962
  /** Rotation over lifetime for z axis. */ _this.rotationY = new ParticleCompositeCurve(0);
32501
32963
  /** Rotation over lifetime for z axis. */ _this.rotationZ = new ParticleCompositeCurve(45);
@@ -32847,9 +33309,6 @@
32847
33309
  _inherits$2(TextureSheetAnimationModule, ParticleGeneratorModule1);
32848
33310
  var _proto = TextureSheetAnimationModule.prototype;
32849
33311
  /**
32850
- * @inheritDoc
32851
- */ _proto.cloneTo = function cloneTo(dest) {};
32852
- /**
32853
33312
  * @internal
32854
33313
  */ _proto._updateShaderData = function _updateShaderData(shaderData) {
32855
33314
  var frameMacro = null;
@@ -33335,7 +33794,7 @@
33335
33794
  instanceVertices[offset + 16] = MathUtil$1.degreeToRadian(main.startRotationY.evaluate(undefined, startRotationRand.random()));
33336
33795
  instanceVertices[offset + 17] = MathUtil$1.degreeToRadian(main.startRotationZ.evaluate(undefined, startRotationRand.random()));
33337
33796
  } else {
33338
- instanceVertices[offset + 15] = MathUtil$1.degreeToRadian(main.startRotation.evaluate(undefined, startRotationRand.random()));
33797
+ instanceVertices[offset + 15] = MathUtil$1.degreeToRadian(main.startRotationZ.evaluate(undefined, startRotationRand.random()));
33339
33798
  }
33340
33799
  // Start speed
33341
33800
  instanceVertices[offset + 18] = startSpeed;
@@ -33597,181 +34056,60 @@
33597
34056
  ignoreClone
33598
34057
  ], ParticleGenerator.prototype, "_instanceVertices", void 0);
33599
34058
  /**
33600
- * Particle Renderer Component.
33601
- */ var ParticleRenderer = /*#__PURE__*/ function(Renderer1) {
33602
- _inherits$2(ParticleRenderer, Renderer1);
33603
- function ParticleRenderer(entity) {
34059
+ * Particle Material.
34060
+ */ var ParticleMaterial = /*#__PURE__*/ function(BaseMaterial1) {
34061
+ var ParticleMaterial = function ParticleMaterial(engine) {
33604
34062
  var _this;
33605
- _this = Renderer1.call(this, entity) || this;
33606
- /** Particle generator. */ _this.generator = new ParticleGenerator(_assert_this_initialized(_this));
33607
- /** Specifies how much particles stretch depending on their velocity. */ _this.velocityScale = 0;
33608
- /** 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;
33609
- /** The pivot of particle. */ _this.pivot = new Vector3();
33610
- _this._currentRenderModeMacro = ParticleRenderer._billboardModeMacro;
33611
- _this.shaderData.enableMacro(ParticleRenderer._billboardModeMacro);
33612
- _this._supportInstancedArrays = _this.engine._hardwareRenderer.canIUse(exports.GLCapabilityType.instancedArrays);
34063
+ _this = BaseMaterial1.call(this, engine, Shader.find("particle-shader")) || this;
34064
+ var shaderData = _this.shaderData;
34065
+ shaderData.enableMacro("MATERIAL_OMIT_NORMAL");
34066
+ shaderData.setColor(BaseMaterial._baseColorProp, new Color$1(1, 1, 1, 1));
34067
+ _this.isTransparent = true;
33613
34068
  return _this;
33614
- }
33615
- var _proto = ParticleRenderer.prototype;
33616
- /**
33617
- * @internal
33618
- */ _proto._onEnable = function _onEnable() {
33619
- if (this.generator.main.playOnEnabled) {
33620
- this.generator.play(false);
33621
- }
33622
- };
33623
- /**
33624
- * @internal
33625
- */ _proto._onDisable = function _onDisable() {
33626
- this.generator.stop(false, exports.ParticleStopMode.StopEmittingAndClear);
33627
- };
33628
- /**
33629
- * @internal
33630
- */ _proto._prepareRender = function _prepareRender(context) {
33631
- if (!this._supportInstancedArrays) {
33632
- return;
33633
- }
33634
- var generator = this.generator;
33635
- generator._update(this.engine.time.deltaTime);
33636
- // No particles to render
33637
- if (generator._firstActiveElement === generator._firstFreeElement) {
33638
- return;
33639
- }
33640
- Renderer1.prototype._prepareRender.call(this, context);
33641
- };
33642
- /**
33643
- * @internal
33644
- */ _proto._updateBounds = function _updateBounds(worldBounds) {
33645
- worldBounds.min.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
33646
- worldBounds.max.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
33647
34069
  };
34070
+ _inherits$2(ParticleMaterial, BaseMaterial1);
34071
+ var _proto = ParticleMaterial.prototype;
33648
34072
  /**
33649
- * @internal
33650
- */ _proto._updateShaderData = function _updateShaderData(context) {
33651
- var shaderData = this.shaderData;
33652
- shaderData.setFloat(ParticleRenderer._lengthScale, this.lengthScale);
33653
- shaderData.setFloat(ParticleRenderer._speedScale, this.velocityScale);
33654
- shaderData.setFloat(ParticleRenderer._currentTime, this.generator._playTime);
33655
- shaderData.setVector3(ParticleRenderer._pivotOffsetProperty, this.pivot);
33656
- this.generator._updateShaderData(shaderData);
33657
- };
33658
- _proto._render = function _render(context) {
33659
- var generator = this.generator;
33660
- var primitive = generator._primitive;
33661
- if (generator._firstActiveElement < generator._firstFreeElement) {
33662
- primitive.instanceCount = generator._firstFreeElement - generator._firstActiveElement;
33663
- } else {
33664
- var instanceCount = generator._currentParticleCount - generator._firstActiveElement;
33665
- if (generator._firstFreeElement > 0) {
33666
- instanceCount += generator._firstFreeElement;
33667
- }
33668
- primitive.instanceCount = instanceCount;
33669
- }
33670
- var material = this.getMaterial();
33671
- var renderData = this._engine._renderDataPool.getFromPool();
33672
- renderData.setX(this, material, generator._primitive, generator._subPrimitive);
33673
- context.camera._renderPipeline.pushRenderData(context, renderData);
33674
- };
33675
- _proto._onDestroy = function _onDestroy() {
33676
- this.generator._destroy();
34073
+ * @inheritdoc
34074
+ */ _proto.clone = function clone() {
34075
+ var dest = new ParticleMaterial(this._engine);
34076
+ this.cloneTo(dest);
34077
+ return dest;
33677
34078
  };
33678
- _create_class$3(ParticleRenderer, [
34079
+ _create_class$3(ParticleMaterial, [
33679
34080
  {
33680
- key: "renderMode",
34081
+ key: "baseColor",
33681
34082
  get: /**
33682
- * Specifies how particles are rendered.
34083
+ * Base color.
33683
34084
  */ function get() {
33684
- return this._renderMode;
34085
+ return this.shaderData.getColor(BaseMaterial._baseColorProp);
33685
34086
  },
33686
34087
  set: function set(value) {
33687
- if (this._renderMode !== value) {
33688
- var lastRenderMode = this._renderMode;
33689
- this._renderMode = value;
33690
- var renderModeMacro = null;
33691
- var shaderData = this.shaderData;
33692
- switch(value){
33693
- case exports.ParticleRenderMode.Billboard:
33694
- renderModeMacro = ParticleRenderer._billboardModeMacro;
33695
- break;
33696
- case exports.ParticleRenderMode.StretchBillboard:
33697
- renderModeMacro = ParticleRenderer._stretchedBillboardModeMacro;
33698
- break;
33699
- case exports.ParticleRenderMode.HorizontalBillboard:
33700
- throw "Not implemented";
33701
- case exports.ParticleRenderMode.VerticalBillboard:
33702
- throw "Not implemented";
33703
- case exports.ParticleRenderMode.Mesh:
33704
- throw "Not implemented";
33705
- }
33706
- if (this._currentRenderModeMacro !== renderModeMacro) {
33707
- this._currentRenderModeMacro && shaderData.disableMacro(this._currentRenderModeMacro);
33708
- renderModeMacro && shaderData.enableMacro(renderModeMacro);
33709
- this._currentRenderModeMacro = renderModeMacro;
33710
- }
33711
- // @ts-ignore
33712
- if (lastRenderMode !== exports.ParticleRenderMode.Mesh !== (value === exports.ParticleRenderMode.Mesh)) {
33713
- this.generator._reorganizeGeometryBuffers();
33714
- }
34088
+ var baseColor = this.shaderData.getColor(BaseMaterial._baseColorProp);
34089
+ if (value !== baseColor) {
34090
+ baseColor.copyFrom(value);
33715
34091
  }
33716
34092
  }
33717
34093
  },
33718
34094
  {
33719
- key: "mesh",
34095
+ key: "baseTexture",
33720
34096
  get: /**
33721
- * The mesh of particle.
33722
- * @remarks Valid when `renderMode` is `Mesh`.
34097
+ * Base texture.
33723
34098
  */ function get() {
33724
- return this._mesh;
34099
+ return this.shaderData.getTexture(BaseMaterial._baseTextureProp);
33725
34100
  },
33726
34101
  set: function set(value) {
33727
- var lastMesh = this._mesh;
33728
- if (lastMesh !== value) {
33729
- var _lastMesh, _value;
33730
- this._mesh = value;
33731
- (_lastMesh = lastMesh) == null ? void 0 : _lastMesh._addReferCount(-1);
33732
- (_value = value) == null ? void 0 : _value._addReferCount(1);
33733
- if (this.renderMode === exports.ParticleRenderMode.Mesh) {
33734
- this.generator._reorganizeGeometryBuffers();
33735
- }
34102
+ this.shaderData.setTexture(BaseMaterial._baseTextureProp, value);
34103
+ if (value) {
34104
+ this.shaderData.enableMacro(BaseMaterial._baseTextureMacro);
34105
+ } else {
34106
+ this.shaderData.disableMacro(BaseMaterial._baseTextureMacro);
33736
34107
  }
33737
34108
  }
33738
34109
  }
33739
34110
  ]);
33740
- return ParticleRenderer;
33741
- }(exports.Renderer);
33742
- (function() {
33743
- ParticleRenderer._billboardModeMacro = ShaderMacro.getByName("RENDERER_MODE_SPHERE_BILLBOARD");
33744
- })();
33745
- (function() {
33746
- ParticleRenderer._stretchedBillboardModeMacro = ShaderMacro.getByName("RENDERER_MODE_STRETCHED_BILLBOARD");
33747
- })();
33748
- (function() {
33749
- ParticleRenderer._horizontalBillboardModeMacro = ShaderMacro.getByName("RENDERER_MODE_HORIZONTAL_BILLBOARD");
33750
- })();
33751
- (function() {
33752
- ParticleRenderer._verticalBillboardModeMacro = ShaderMacro.getByName("RENDERER_MODE_VERTICAL_BILLBOARD");
33753
- })();
33754
- (function() {
33755
- ParticleRenderer._renderModeMeshMacro = ShaderMacro.getByName("RENDERER_MODE_MESH");
33756
- })();
33757
- (function() {
33758
- ParticleRenderer._pivotOffsetProperty = ShaderProperty.getByName("renderer_PivotOffset");
33759
- })();
33760
- (function() {
33761
- ParticleRenderer._lengthScale = ShaderProperty.getByName("renderer_StretchedBillboardLengthScale");
33762
- })();
33763
- (function() {
33764
- ParticleRenderer._speedScale = ShaderProperty.getByName("renderer_StretchedBillboardSpeedScale");
33765
- })();
33766
- (function() {
33767
- ParticleRenderer._currentTime = ShaderProperty.getByName("renderer_CurrentTime");
33768
- })();
33769
- __decorate$1([
33770
- deepClone
33771
- ], ParticleRenderer.prototype, "generator", void 0);
33772
- __decorate$1([
33773
- shallowClone
33774
- ], ParticleRenderer.prototype, "pivot", void 0);
34111
+ return ParticleMaterial;
34112
+ }(BaseMaterial);
33775
34113
  /**
33776
34114
  * A burst is a particle emission event, where a number of particles are all emitted at the same time
33777
34115
  */ var Burst = function Burst(time, count) {
@@ -34456,6 +34794,7 @@
34456
34794
  ColliderShape: ColliderShape,
34457
34795
  get ColliderShapeUpAxis () { return exports.ColliderShapeUpAxis; },
34458
34796
  get CollisionDetectionMode () { return exports.CollisionDetectionMode; },
34797
+ ColorOverLifetimeModule: ColorOverLifetimeModule,
34459
34798
  get ColorSpace () { return exports.ColorSpace; },
34460
34799
  get ColorWriteMask () { return exports.ColorWriteMask; },
34461
34800
  get CompareFunction () { return exports.CompareFunction; },
@@ -34476,6 +34815,7 @@
34476
34815
  DirectLight: DirectLight,
34477
34816
  DynamicCollider: DynamicCollider,
34478
34817
  get DynamicColliderConstraints () { return exports.DynamicColliderConstraints; },
34818
+ EmissionModule: EmissionModule,
34479
34819
  Engine: Engine,
34480
34820
  EngineObject: EngineObject,
34481
34821
  Entity: Entity,
@@ -34485,6 +34825,8 @@
34485
34825
  Font: Font,
34486
34826
  get FontStyle () { return exports.FontStyle; },
34487
34827
  get GLCapabilityType () { return exports.GLCapabilityType; },
34828
+ GradientAlphaKey: GradientAlphaKey,
34829
+ GradientColorKey: GradientColorKey,
34488
34830
  HemisphereShape: HemisphereShape,
34489
34831
  HingeJoint: HingeJoint,
34490
34832
  HitResult: HitResult,
@@ -34501,6 +34843,7 @@
34501
34843
  Light: Light,
34502
34844
  Loader: Loader,
34503
34845
  Logger: Logger,
34846
+ MainModule: MainModule,
34504
34847
  Material: Material,
34505
34848
  Mesh: Mesh,
34506
34849
  MeshRenderer: MeshRenderer,
@@ -34511,8 +34854,11 @@
34511
34854
  PBRMaterial: PBRMaterial,
34512
34855
  PBRSpecularMaterial: PBRSpecularMaterial,
34513
34856
  ParticleCompositeCurve: ParticleCompositeCurve,
34857
+ ParticleCompositeGradient: ParticleCompositeGradient,
34514
34858
  ParticleCurve: ParticleCurve,
34515
34859
  get ParticleCurveMode () { return exports.ParticleCurveMode; },
34860
+ ParticleGenerator: ParticleGenerator,
34861
+ ParticleGradient: ParticleGradient,
34516
34862
  get ParticleGradientMode () { return exports.ParticleGradientMode; },
34517
34863
  ParticleMaterial: ParticleMaterial,
34518
34864
  get ParticleRenderMode () { return exports.ParticleRenderMode; },
@@ -34547,6 +34893,7 @@
34547
34893
  RenderTargetBlendState: RenderTargetBlendState,
34548
34894
  get Renderer () { return exports.Renderer; },
34549
34895
  ResourceManager: ResourceManager,
34896
+ RotationOverLifetimeModule: RotationOverLifetimeModule,
34550
34897
  Scene: Scene,
34551
34898
  SceneManager: SceneManager,
34552
34899
  Script: Script,
@@ -34563,6 +34910,7 @@
34563
34910
  get ShadowCascadesMode () { return exports.ShadowCascadesMode; },
34564
34911
  get ShadowResolution () { return exports.ShadowResolution; },
34565
34912
  get ShadowType () { return exports.ShadowType; },
34913
+ SizeOverLifetimeModule: SizeOverLifetimeModule,
34566
34914
  Skin: Skin,
34567
34915
  SkinnedMeshRenderer: SkinnedMeshRenderer,
34568
34916
  Sky: Sky,
@@ -34601,6 +34949,7 @@
34601
34949
  get TextureDepthCompareFunction () { return exports.TextureDepthCompareFunction; },
34602
34950
  get TextureFilterMode () { return exports.TextureFilterMode; },
34603
34951
  get TextureFormat () { return exports.TextureFormat; },
34952
+ TextureSheetAnimationModule: TextureSheetAnimationModule,
34604
34953
  get TextureUsage () { return exports.TextureUsage; },
34605
34954
  get TextureWrapMode () { return exports.TextureWrapMode; },
34606
34955
  Time: Time,
@@ -34609,6 +34958,7 @@
34609
34958
  Transform: Transform,
34610
34959
  UnlitMaterial: UnlitMaterial,
34611
34960
  Utils: Utils,
34961
+ VelocityOverLifetimeModule: VelocityOverLifetimeModule,
34612
34962
  get VertexAttribute () { return exports.VertexAttribute; },
34613
34963
  VertexBufferBinding: VertexBufferBinding,
34614
34964
  VertexElement: VertexElement,
@@ -37432,12 +37782,12 @@
37432
37782
  return _construct.apply(null, arguments);
37433
37783
  }
37434
37784
  var ReflectionParser = /*#__PURE__*/ function() {
37435
- var ReflectionParser = function ReflectionParser() {};
37436
- ReflectionParser.registerCustomParseComponent = function registerCustomParseComponent(componentType, handle) {
37437
- this.customParseComponentHandles[componentType] = handle;
37785
+ var ReflectionParser = function ReflectionParser(_context) {
37786
+ this._context = _context;
37438
37787
  };
37439
- ReflectionParser.parseEntity = function parseEntity(entityConfig, engine) {
37440
- return ReflectionParser.getEntityByConfig(entityConfig, engine).then(function(entity) {
37788
+ var _proto = ReflectionParser.prototype;
37789
+ _proto.parseEntity = function parseEntity(entityConfig) {
37790
+ return this._getEntityByConfig(entityConfig).then(function(entity) {
37441
37791
  var _entityConfig_isActive;
37442
37792
  entity.isActive = (_entityConfig_isActive = entityConfig.isActive) != null ? _entityConfig_isActive : true;
37443
37793
  var position = entityConfig.position, rotation = entityConfig.rotation, scale = entityConfig.scale;
@@ -37447,72 +37797,29 @@
37447
37797
  return entity;
37448
37798
  });
37449
37799
  };
37450
- ReflectionParser.getEntityByConfig = function getEntityByConfig(entityConfig, engine) {
37451
- // @ts-ignore
37452
- var assetRefId = entityConfig.assetRefId;
37453
- if (assetRefId) {
37454
- return engine.resourceManager // @ts-ignore
37455
- .getResourceByRef({
37456
- refId: assetRefId,
37457
- key: entityConfig.key,
37458
- isClone: entityConfig.isClone
37459
- }).then(function(entity) {
37460
- entity.name = entityConfig.name;
37461
- return entity;
37462
- });
37463
- } else {
37464
- var entity = new Entity(engine, entityConfig.name);
37465
- return Promise.resolve(entity);
37466
- }
37467
- };
37468
- ReflectionParser.parseClassObject = function parseClassObject(item, engine, resourceManager) {
37469
- if (resourceManager === void 0) resourceManager = engine.resourceManager;
37800
+ _proto.parseClassObject = function parseClassObject(item) {
37470
37801
  var Class = Loader.getClass(item.class);
37471
37802
  var _item_constructParams;
37472
37803
  var params = (_item_constructParams = item.constructParams) != null ? _item_constructParams : [];
37473
37804
  var instance = _construct(Class, [].concat(params));
37474
- return this.parsePropsAndMethods(instance, item, engine, resourceManager);
37805
+ return this.parsePropsAndMethods(instance, item);
37475
37806
  };
37476
- ReflectionParser.parseBasicType = function parseBasicType(value, engine, resourceManager) {
37477
- if (resourceManager === void 0) resourceManager = engine.resourceManager;
37478
- var _this = this;
37479
- if (Array.isArray(value)) {
37480
- return Promise.all(value.map(function(item) {
37481
- return _this.parseBasicType(item, engine, resourceManager);
37482
- }));
37483
- } else if (typeof value === "object" && value != null) {
37484
- if (this._isClass(value)) {
37485
- // class object
37486
- return this.parseClassObject(value, engine, resourceManager);
37487
- } else if (this._isRef(value)) {
37488
- // reference object
37489
- return resourceManager.getResourceByRef(value);
37490
- } else {
37491
- // basic type
37492
- return Promise.resolve(value);
37493
- }
37494
- } else {
37495
- return Promise.resolve(value);
37496
- }
37497
- };
37498
- ReflectionParser.parsePropsAndMethods = function parsePropsAndMethods(instance, item, engine, resourceManager) {
37499
- if (resourceManager === void 0) resourceManager = engine.resourceManager;
37500
- var _this = this;
37807
+ _proto.parsePropsAndMethods = function parsePropsAndMethods(instance, item) {
37501
37808
  var promises = [];
37502
37809
  if (item.methods) {
37503
37810
  for(var methodName in item.methods){
37504
37811
  var methodParams = item.methods[methodName];
37505
37812
  for(var i = 0, count = methodParams.length; i < count; i++){
37506
37813
  var params = methodParams[i];
37507
- var promise = this.parseMethod(instance, methodName, params, engine, resourceManager);
37814
+ var promise = this.parseMethod(instance, methodName, params);
37508
37815
  promises.push(promise);
37509
37816
  }
37510
37817
  }
37511
37818
  }
37512
37819
  if (item.props) {
37513
- var _this1 = this, _loop = function _loop(key) {
37820
+ var _this = this, _loop = function _loop(key) {
37514
37821
  var value = item.props[key];
37515
- var promise = _this1.parseBasicType(value, engine).then(function(v) {
37822
+ var promise = _this.parseBasicType(value).then(function(v) {
37516
37823
  return instance[key] = v;
37517
37824
  });
37518
37825
  promises.push(promise);
@@ -37520,27 +37827,76 @@
37520
37827
  for(var key in item.props)_loop(key);
37521
37828
  }
37522
37829
  return Promise.all(promises).then(function() {
37523
- var handle = _this.customParseComponentHandles[instance.constructor.name];
37524
- if (handle) return handle(instance, item, engine);
37830
+ var handle = ReflectionParser.customParseComponentHandles[instance.constructor.name];
37831
+ if (handle) return handle(instance, item);
37525
37832
  else return instance;
37526
37833
  });
37527
37834
  };
37528
- ReflectionParser.parseMethod = function parseMethod(instance, methodName, methodParams, engine, resourceManager) {
37529
- if (resourceManager === void 0) resourceManager = engine.resourceManager;
37835
+ _proto.parseMethod = function parseMethod(instance, methodName, methodParams) {
37530
37836
  var _this = this;
37531
37837
  return Promise.all(methodParams.map(function(param) {
37532
- return _this.parseBasicType(param, engine, resourceManager);
37838
+ return _this.parseBasicType(param);
37533
37839
  })).then(function(result) {
37534
37840
  var _instance;
37535
37841
  return (_instance = instance)[methodName].apply(_instance, [].concat(result));
37536
37842
  });
37537
37843
  };
37844
+ _proto.parseBasicType = function parseBasicType(value) {
37845
+ var _this = this;
37846
+ if (Array.isArray(value)) {
37847
+ return Promise.all(value.map(function(item) {
37848
+ return _this.parseBasicType(item);
37849
+ }));
37850
+ } else if (typeof value === "object" && value != null) {
37851
+ if (ReflectionParser._isClass(value)) {
37852
+ // class object
37853
+ return this.parseClassObject(value);
37854
+ } else if (ReflectionParser._isAssetRef(value)) {
37855
+ // reference object
37856
+ // @ts-ignore
37857
+ return this._context.resourceManager.getResourceByRef(value);
37858
+ } else if (ReflectionParser._isEntityRef(value)) {
37859
+ // entity reference
37860
+ return Promise.resolve(this._context.entityMap.get(value.entityId));
37861
+ } else {
37862
+ // basic type
37863
+ return Promise.resolve(value);
37864
+ }
37865
+ } else {
37866
+ return Promise.resolve(value);
37867
+ }
37868
+ };
37869
+ _proto._getEntityByConfig = function _getEntityByConfig(entityConfig) {
37870
+ // @ts-ignore
37871
+ var assetRefId = entityConfig.assetRefId;
37872
+ var engine = this._context.engine;
37873
+ if (assetRefId) {
37874
+ return engine.resourceManager // @ts-ignore
37875
+ .getResourceByRef({
37876
+ refId: assetRefId,
37877
+ key: entityConfig.key,
37878
+ isClone: entityConfig.isClone
37879
+ }).then(function(entity) {
37880
+ entity.name = entityConfig.name;
37881
+ return entity;
37882
+ });
37883
+ } else {
37884
+ var entity = new Entity(engine, entityConfig.name);
37885
+ return Promise.resolve(entity);
37886
+ }
37887
+ };
37888
+ ReflectionParser.registerCustomParseComponent = function registerCustomParseComponent(componentType, handle) {
37889
+ this.customParseComponentHandles[componentType] = handle;
37890
+ };
37538
37891
  ReflectionParser._isClass = function _isClass(value) {
37539
37892
  return value["class"] != undefined;
37540
37893
  };
37541
- ReflectionParser._isRef = function _isRef(value) {
37894
+ ReflectionParser._isAssetRef = function _isAssetRef(value) {
37542
37895
  return value["refId"] != undefined;
37543
37896
  };
37897
+ ReflectionParser._isEntityRef = function _isEntityRef(value) {
37898
+ return value["entityId"] != undefined;
37899
+ };
37544
37900
  return ReflectionParser;
37545
37901
  }();
37546
37902
  (function() {
@@ -37796,6 +38152,8 @@
37796
38152
  this.assets = new Map();
37797
38153
  this.entityConfigMap = new Map();
37798
38154
  this.rootIds = [];
38155
+ this.engine = scene.engine;
38156
+ this.resourceManager = scene.engine.resourceManager;
37799
38157
  };
37800
38158
  var _proto = SceneParserContext.prototype;
37801
38159
  _proto.destroy = function destroy() {
@@ -37811,7 +38169,7 @@
37811
38169
  var SceneParser = function SceneParser(context) {
37812
38170
  var _this = this;
37813
38171
  this.context = context;
37814
- this._engine = this.context.scene.engine;
38172
+ this._engine = context.scene.engine;
37815
38173
  this._organizeEntities = this._organizeEntities.bind(this);
37816
38174
  this._parseComponents = this._parseComponents.bind(this);
37817
38175
  this._clearAndResolveScene = this._clearAndResolveScene.bind(this);
@@ -37819,22 +38177,24 @@
37819
38177
  _this._reject = reject;
37820
38178
  _this._resolve = resolve;
37821
38179
  });
38180
+ this._reflectionParser = new ReflectionParser(context);
37822
38181
  };
37823
38182
  var _proto = SceneParser.prototype;
37824
38183
  /** start parse the scene */ _proto.start = function start() {
37825
38184
  this._parseEntities().then(this._organizeEntities).then(this._parseComponents).then(this._clearAndResolveScene).then(this._resolve).catch(this._reject);
37826
38185
  };
37827
38186
  _proto._parseEntities = function _parseEntities() {
38187
+ var _this = this;
37828
38188
  var entitiesConfig = this.context.originalData.entities;
37829
38189
  var entityConfigMap = this.context.entityConfigMap;
37830
38190
  var entitiesMap = this.context.entityMap;
37831
38191
  var rootIds = this.context.rootIds;
37832
- var engine = this._engine;
38192
+ this._engine;
37833
38193
  var promises = entitiesConfig.map(function(entityConfig) {
37834
38194
  entityConfigMap.set(entityConfig.id, entityConfig);
37835
38195
  // record root entities
37836
38196
  if (!entityConfig.parent) rootIds.push(entityConfig.id);
37837
- return ReflectionParser.parseEntity(entityConfig, engine);
38197
+ return _this._reflectionParser.parseEntity(entityConfig);
37838
38198
  });
37839
38199
  return Promise.all(promises).then(function(entities) {
37840
38200
  for(var i = 0, l = entities.length; i < l; i++){
@@ -37872,7 +38232,7 @@
37872
38232
  component = entity.getComponent(Loader.getClass(key));
37873
38233
  }
37874
38234
  component = component || entity.addComponent(Loader.getClass(key));
37875
- var promise = ReflectionParser.parsePropsAndMethods(component, componentConfig, entity.engine);
38235
+ var promise = this._reflectionParser.parsePropsAndMethods(component, componentConfig);
37876
38236
  promises.push(promise);
37877
38237
  }
37878
38238
  }
@@ -39299,20 +39659,56 @@
39299
39659
  return AbstractTranscoder;
39300
39660
  }();
39301
39661
  /** @internal */ function TranscodeWorkerCode$1() {
39302
- var concat = function concat(arrays) {
39303
- if (arrays.length === 1) return arrays[0];
39304
- var totalByteLength = 0;
39305
- for(var i = 0; i < arrays.length; i++){
39306
- totalByteLength += arrays[i].byteLength;
39662
+ self.onmessage = function onmessage(event) {
39663
+ var message = event.data;
39664
+ switch(message.type){
39665
+ case "init":
39666
+ init(message.transcoderWasm).then(function() {
39667
+ self.postMessage("init-completed");
39668
+ }).catch(function(e) {
39669
+ return self.postMessage({
39670
+ error: e
39671
+ });
39672
+ });
39673
+ break;
39674
+ case "transcode":
39675
+ init().then(function(KTX2File) {
39676
+ var result = transcode(message.buffer, message.format, KTX2File);
39677
+ // @ts-ignore
39678
+ result.type = "transcoded";
39679
+ self.postMessage(result);
39680
+ }).catch(function(e) {
39681
+ return self.postMessage({
39682
+ error: e
39683
+ });
39684
+ });
39685
+ break;
39307
39686
  }
39308
- var result = new Uint8Array(totalByteLength);
39309
- var byteOffset = 0;
39310
- for(var i1 = 0; i1 < arrays.length; i1++){
39311
- result.set(arrays[i1], byteOffset);
39312
- byteOffset += arrays[i1].byteLength;
39687
+ };
39688
+ }
39689
+ var _init = function init() {
39690
+ var initPromise;
39691
+ return function init(wasmBinary) {
39692
+ if (!initPromise) {
39693
+ initPromise = new Promise(function(resolve, reject) {
39694
+ var BasisModule = {
39695
+ wasmBinary: wasmBinary,
39696
+ onRuntimeInitialized: function onRuntimeInitialized() {
39697
+ return resolve(BasisModule);
39698
+ },
39699
+ onAbort: reject
39700
+ };
39701
+ self["BASIS"](BasisModule);
39702
+ }).then(function(BasisModule) {
39703
+ BasisModule.initializeBasis();
39704
+ return BasisModule.KTX2File;
39705
+ });
39313
39706
  }
39314
- return result;
39707
+ return initPromise;
39315
39708
  };
39709
+ };
39710
+ var init = _init();
39711
+ function transcode(buffer, targetFormat, KTX2File) {
39316
39712
  var getTranscodeFormatFromTarget = function getTranscodeFormatFromTarget(target, hasAlpha) {
39317
39713
  switch(target){
39318
39714
  case 2:
@@ -39329,76 +39725,24 @@
39329
39725
  return 7;
39330
39726
  }
39331
39727
  };
39332
- var init = function init(wasmBinary) {
39333
- transcodePromise = new Promise(function(resolve, reject) {
39334
- var BasisModule = {
39335
- wasmBinary: wasmBinary,
39336
- onRuntimeInitialized: function onRuntimeInitialized() {
39337
- return resolve(BasisModule);
39338
- },
39339
- onAbort: reject
39340
- };
39341
- self["BASIS"](BasisModule);
39342
- }).then(function(BasisModule) {
39343
- BasisModule.initializeBasis();
39344
- return BasisModule.KTX2File;
39345
- });
39346
- return transcodePromise;
39347
- };
39348
- var transcode = function transcode(buffer, targetFormat, KTX2File) {
39349
- var cleanup = function cleanup() {
39350
- ktx2File.close();
39351
- ktx2File.delete();
39352
- };
39353
- var ktx2File = new KTX2File(new Uint8Array(buffer));
39354
- if (!ktx2File.isValid()) {
39355
- cleanup();
39356
- throw new Error("Invalid or unsupported .ktx2 file");
39357
- }
39358
- var width = ktx2File.getWidth();
39359
- var height = ktx2File.getHeight();
39360
- var layerCount = ktx2File.getLayers() || 1;
39361
- var levelCount = ktx2File.getLevels();
39362
- var hasAlpha = ktx2File.getHasAlpha();
39363
- var faceCount = ktx2File.getFaces();
39364
- var format = getTranscodeFormatFromTarget(targetFormat, hasAlpha);
39365
- var faces = new Array(faceCount);
39366
- for(var face = 0; face < faceCount; face++){
39367
- var mipmaps = new Array(levelCount);
39368
- for(var mip = 0; mip < levelCount; mip++){
39369
- var layerMips = new Array(layerCount);
39370
- var mipWidth = void 0, mipHeight = void 0;
39371
- for(var layer = 0; layer < layerCount; layer++){
39372
- var levelInfo = ktx2File.getImageLevelInfo(mip, layer, face);
39373
- mipWidth = levelInfo.origWidth;
39374
- mipHeight = levelInfo.origHeight;
39375
- var dst = new Uint8Array(ktx2File.getImageTranscodedSizeInBytes(mip, layer, 0, format));
39376
- var status = ktx2File.transcodeImage(dst, mip, layer, face, format, 0, -1, -1);
39377
- if (!status) {
39378
- cleanup();
39379
- throw new Error("transcodeImage failed.");
39380
- }
39381
- layerMips[layer] = dst;
39382
- }
39383
- mipmaps[mip] = {
39384
- data: concat(layerMips),
39385
- width: mipWidth,
39386
- height: mipHeight
39387
- };
39388
- }
39389
- faces[face] = mipmaps;
39728
+ var concat = function concat(arrays) {
39729
+ if (arrays.length === 1) return arrays[0];
39730
+ var totalByteLength = 0;
39731
+ for(var i = 0; i < arrays.length; i++){
39732
+ totalByteLength += arrays[i].byteLength;
39390
39733
  }
39391
- cleanup();
39392
- return {
39393
- faces: faces,
39394
- width: width,
39395
- height: height,
39396
- hasAlpha: hasAlpha,
39397
- faceCount: faceCount,
39398
- format: format
39399
- };
39734
+ var result = new Uint8Array(totalByteLength);
39735
+ var byteOffset = 0;
39736
+ for(var i1 = 0; i1 < arrays.length; i1++){
39737
+ result.set(arrays[i1], byteOffset);
39738
+ byteOffset += arrays[i1].byteLength;
39739
+ }
39740
+ return result;
39741
+ };
39742
+ var cleanup = function cleanup() {
39743
+ ktx2File.close();
39744
+ ktx2File.delete();
39400
39745
  };
39401
- var transcodePromise;
39402
39746
  var BasisFormat;
39403
39747
  (function(BasisFormat) {
39404
39748
  BasisFormat[BasisFormat["ETC1"] = 0] = "ETC1";
@@ -39424,31 +39768,56 @@
39424
39768
  TargetFormat[TargetFormat["RG8"] = 6] = "RG8";
39425
39769
  TargetFormat[TargetFormat["RGBA8"] = 7] = "RGBA8";
39426
39770
  })(TargetFormat || (TargetFormat = {}));
39427
- self.onmessage = function onmessage(event) {
39428
- var message = event.data;
39429
- switch(message.type){
39430
- case "init":
39431
- init(message.transcoderWasm).then(function() {
39432
- return self.postMessage("init-completed");
39433
- }).catch(function(e) {
39434
- return self.postMessage({
39435
- error: e
39436
- });
39437
- });
39438
- break;
39439
- case "transcode":
39440
- transcodePromise.then(function(KTX2File) {
39441
- var result = transcode(message.buffer, message.format, KTX2File);
39442
- // @ts-ignore
39443
- result.type = "transcoded";
39444
- self.postMessage(result);
39445
- }).catch(function(e) {
39446
- return self.postMessage({
39447
- error: e
39448
- });
39449
- });
39450
- break;
39771
+ var ktx2File = new KTX2File(new Uint8Array(buffer));
39772
+ if (!ktx2File.isValid()) {
39773
+ cleanup();
39774
+ throw new Error("Invalid or unsupported .ktx2 file");
39775
+ }
39776
+ if (!ktx2File.startTranscoding()) {
39777
+ cleanup();
39778
+ throw new Error("KTX2 startTranscoding failed");
39779
+ }
39780
+ var width = ktx2File.getWidth();
39781
+ var height = ktx2File.getHeight();
39782
+ var layerCount = ktx2File.getLayers() || 1;
39783
+ var levelCount = ktx2File.getLevels();
39784
+ var hasAlpha = ktx2File.getHasAlpha();
39785
+ var faceCount = ktx2File.getFaces();
39786
+ var format = getTranscodeFormatFromTarget(targetFormat, hasAlpha);
39787
+ var faces = new Array(faceCount);
39788
+ for(var face = 0; face < faceCount; face++){
39789
+ var mipmaps = new Array(levelCount);
39790
+ for(var mip = 0; mip < levelCount; mip++){
39791
+ var layerMips = new Array(layerCount);
39792
+ var mipWidth = void 0, mipHeight = void 0;
39793
+ for(var layer = 0; layer < layerCount; layer++){
39794
+ var levelInfo = ktx2File.getImageLevelInfo(mip, layer, face);
39795
+ mipWidth = levelInfo.origWidth;
39796
+ mipHeight = levelInfo.origHeight;
39797
+ var dst = new Uint8Array(ktx2File.getImageTranscodedSizeInBytes(mip, layer, 0, format));
39798
+ var status = ktx2File.transcodeImage(dst, mip, layer, face, format, 0, -1, -1);
39799
+ if (!status) {
39800
+ cleanup();
39801
+ throw new Error("transcodeImage failed.");
39802
+ }
39803
+ layerMips[layer] = dst;
39804
+ }
39805
+ mipmaps[mip] = {
39806
+ data: concat(layerMips),
39807
+ width: mipWidth,
39808
+ height: mipHeight
39809
+ };
39451
39810
  }
39811
+ faces[face] = mipmaps;
39812
+ }
39813
+ cleanup();
39814
+ return {
39815
+ faces: faces,
39816
+ width: width,
39817
+ height: height,
39818
+ hasAlpha: hasAlpha,
39819
+ faceCount: faceCount,
39820
+ format: format
39452
39821
  };
39453
39822
  }
39454
39823
  /** @internal */ var BinomialLLCTranscoder = /*#__PURE__*/ function(AbstractTranscoder1) {
@@ -39468,23 +39837,49 @@
39468
39837
  })
39469
39838
  ]).then(function(param) {
39470
39839
  var jsCode = param[0], wasmBuffer = param[1];
39471
- var funcCode = TranscodeWorkerCode$1.toString();
39472
- var transcodeString = funcCode.substring(funcCode.indexOf("{"), funcCode.lastIndexOf("}") + 1);
39473
- var workerCode = "\n " + jsCode + "\n " + transcodeString + "\n ";
39474
- var workerURL = URL.createObjectURL(new Blob([
39475
- workerCode
39476
- ], {
39477
- type: "application/javascript"
39478
- }));
39479
- return _this._createTranscodePool(workerURL, wasmBuffer);
39840
+ if (_this.workerLimitCount === 0) {
39841
+ return new Promise(function(resolve, reject) {
39842
+ var scriptDom = document.createElement("script");
39843
+ scriptDom.src = URL.createObjectURL(new Blob([
39844
+ jsCode
39845
+ ], {
39846
+ type: "application/javascript"
39847
+ }));
39848
+ document.body.appendChild(scriptDom);
39849
+ scriptDom.onload = function() {
39850
+ init(wasmBuffer).then(function() {
39851
+ resolve(null);
39852
+ });
39853
+ };
39854
+ scriptDom.onerror = function() {
39855
+ reject();
39856
+ };
39857
+ });
39858
+ } else {
39859
+ var funcCode = TranscodeWorkerCode$1.toString();
39860
+ var transcodeString = funcCode.substring(funcCode.indexOf("{"), funcCode.lastIndexOf("}") + 1);
39861
+ var workerCode = "\n " + jsCode + "\n var init = (" + _init.toString() + ")();\n " + transcode.toString() + "\n " + transcodeString + "\n ";
39862
+ var workerURL = URL.createObjectURL(new Blob([
39863
+ workerCode
39864
+ ], {
39865
+ type: "application/javascript"
39866
+ }));
39867
+ return _this._createTranscodePool(workerURL, wasmBuffer);
39868
+ }
39480
39869
  });
39481
39870
  };
39482
- _proto.transcode = function transcode(buffer, format) {
39483
- return this._transcodeWorkerPool.postMessage({
39484
- buffer: buffer,
39485
- format: format,
39486
- type: "transcode"
39487
- });
39871
+ _proto.transcode = function transcode1(buffer, format) {
39872
+ if (this.workerLimitCount === 0) {
39873
+ return init().then(function(KTX2File) {
39874
+ return transcode(buffer, format, KTX2File);
39875
+ });
39876
+ } else {
39877
+ return this._transcodeWorkerPool.postMessage({
39878
+ buffer: buffer,
39879
+ format: format,
39880
+ type: "transcode"
39881
+ });
39882
+ }
39488
39883
  };
39489
39884
  return BinomialLLCTranscoder;
39490
39885
  }(AbstractTranscoder);
@@ -39708,7 +40103,7 @@
39708
40103
  _proto.initialize = function initialize(engine, configuration) {
39709
40104
  if (configuration.ktx2Loader) {
39710
40105
  var options = configuration.ktx2Loader;
39711
- if (this._isKhronosSupported(options.priorityFormats, engine)) {
40106
+ if (this._isKhronosSupported(options.priorityFormats, engine) && options.workerCount !== 0) {
39712
40107
  return exports.KTX2Loader._getKhronosTranscoder(options.workerCount).init();
39713
40108
  } else {
39714
40109
  return exports.KTX2Loader._getBinomialLLCTranscoder(options.workerCount).init();
@@ -40424,12 +40819,12 @@
40424
40819
  if (curve2.interpolation === exports.InterpolationType.CubicSpine) {
40425
40820
  keyframe2.inTangent = Array.from(output.subarray(offset2, offset2 + outputSize));
40426
40821
  offset2 += outputSize;
40427
- keyframe2.value = output.subarray(offset2, offset2 + outputSize);
40822
+ keyframe2.value = output.slice(offset2, offset2 + outputSize);
40428
40823
  offset2 += outputSize;
40429
40824
  keyframe2.outTangent = Array.from(output.subarray(offset2, offset2 + outputSize));
40430
40825
  offset2 += outputSize;
40431
40826
  } else {
40432
- keyframe2.value = output.subarray(offset2, offset2 + outputSize);
40827
+ keyframe2.value = output.slice(offset2, offset2 + outputSize);
40433
40828
  offset2 += outputSize;
40434
40829
  }
40435
40830
  curve2.addKey(keyframe2);
@@ -41172,8 +41567,7 @@
41172
41567
  mipmap: (_samplerInfo = samplerInfo) == null ? void 0 : _samplerInfo.mipmap
41173
41568
  }
41174
41569
  }).then(function(texture) {
41175
- var _texture;
41176
- (_texture = texture).name || (_texture.name = textureName || imageName || "texture_" + index);
41570
+ texture.name = textureName || imageName || texture.name || "texture_" + index;
41177
41571
  useSampler && GLTFUtils.parseSampler(texture, samplerInfo);
41178
41572
  return texture;
41179
41573
  });
@@ -42261,6 +42655,38 @@
42261
42655
  ""
42262
42656
  ])
42263
42657
  ], TextureCubeLoader);
42658
+ var ProjectLoader = /*#__PURE__*/ function(Loader1) {
42659
+ var ProjectLoader = function ProjectLoader() {
42660
+ return Loader1.apply(this, arguments);
42661
+ };
42662
+ _inherits(ProjectLoader, Loader1);
42663
+ var _proto = ProjectLoader.prototype;
42664
+ _proto.load = function load(item, resourceManager) {
42665
+ var _this = this;
42666
+ var engine = resourceManager.engine;
42667
+ return new AssetPromise(function(resolve, reject) {
42668
+ _this.request(item.url, {
42669
+ type: "json"
42670
+ }).then(function(data) {
42671
+ // @ts-ignore
42672
+ engine.resourceManager.initVirtualResources(data.files);
42673
+ return resourceManager.load({
42674
+ type: exports.AssetType.Scene,
42675
+ url: data.scene
42676
+ }).then(function(scene) {
42677
+ engine.sceneManager.activeScene = scene;
42678
+ resolve();
42679
+ });
42680
+ }).catch(reject);
42681
+ });
42682
+ };
42683
+ return ProjectLoader;
42684
+ }(Loader);
42685
+ ProjectLoader = __decorate([
42686
+ resourceLoader(exports.AssetType.Project, [
42687
+ "proj"
42688
+ ], false)
42689
+ ], ProjectLoader);
42264
42690
  var SceneLoader = /*#__PURE__*/ function(Loader1) {
42265
42691
  var SceneLoader = function SceneLoader() {
42266
42692
  return Loader1.apply(this, arguments);
@@ -42279,32 +42705,26 @@
42279
42705
  // parse ambient light
42280
42706
  var ambient = data.scene.ambient;
42281
42707
  var useCustomAmbient = ambient.specularMode === "Custom";
42708
+ var useSH = ambient.diffuseMode === exports.DiffuseMode.SphericalHarmonics;
42709
+ scene.ambientLight.diffuseIntensity = ambient.diffuseIntensity;
42710
+ scene.ambientLight.specularIntensity = ambient.specularIntensity;
42711
+ scene.ambientLight.diffuseMode = ambient.diffuseMode;
42712
+ scene.ambientLight.diffuseSolidColor.copyFrom(ambient.diffuseSolidColor);
42713
+ scene.ambientLight.specularTextureDecodeRGBM = true;
42282
42714
  if (useCustomAmbient && ambient.customAmbientLight) {
42283
- // @ts-ignore
42284
- // prettier-ignore
42285
- var customAmbientPromise = resourceManager.getResourceByRef(ambient.customAmbientLight).then(function(ambientLight) {
42286
- scene.ambientLight = ambientLight;
42287
- scene.ambientLight.diffuseIntensity = ambient.diffuseIntensity;
42288
- scene.ambientLight.specularIntensity = ambient.specularIntensity;
42289
- scene.ambientLight.diffuseMode = ambient.diffuseMode;
42290
- scene.ambientLight.diffuseSolidColor.copyFrom(ambient.diffuseSolidColor);
42291
- });
42292
- promises.push(customAmbientPromise);
42293
- } else if (!useCustomAmbient && ambient.ambientLight) {
42294
- // @ts-ignore
42295
- // prettier-ignore
42296
- var ambientLightPromise = resourceManager.getResourceByRef(ambient.ambientLight).then(function(ambientLight) {
42297
- scene.ambientLight = ambientLight;
42298
- scene.ambientLight.diffuseIntensity = ambient.diffuseIntensity;
42299
- scene.ambientLight.specularIntensity = ambient.specularIntensity;
42300
- scene.ambientLight.diffuseMode = ambient.diffuseMode;
42301
- scene.ambientLight.diffuseSolidColor.copyFrom(ambient.diffuseSolidColor);
42302
- });
42303
- promises.push(ambientLightPromise);
42304
- } else {
42305
- scene.ambientLight.diffuseIntensity = ambient.diffuseIntensity;
42306
- scene.ambientLight.specularIntensity = ambient.specularIntensity;
42307
- scene.ambientLight.diffuseSolidColor.copyFrom(ambient.diffuseSolidColor);
42715
+ promises.push(resourceManager.getResourceByRef(ambient.customAmbientLight).then(function(ambientLight) {
42716
+ scene.ambientLight.specularTexture = ambientLight.specularTexture;
42717
+ }));
42718
+ }
42719
+ if (ambient.ambientLight && (!useCustomAmbient || useSH)) {
42720
+ promises.push(resourceManager.getResourceByRef(ambient.ambientLight).then(function(ambientLight) {
42721
+ if (!useCustomAmbient) {
42722
+ scene.ambientLight.specularTexture = ambientLight.specularTexture;
42723
+ }
42724
+ if (useSH) {
42725
+ scene.ambientLight.diffuseSphericalHarmonics = ambientLight.diffuseSphericalHarmonics;
42726
+ }
42727
+ }));
42308
42728
  }
42309
42729
  var background = data.scene.background;
42310
42730
  scene.background.mode = background.mode;
@@ -42857,7 +43277,7 @@
42857
43277
  ], GALACEAN_animation_event);
42858
43278
 
42859
43279
  //@ts-ignore
42860
- var version = "1.1.0-beta.1";
43280
+ var version = "1.1.0-beta.10";
42861
43281
  console.log("Galacean engine version: " + version);
42862
43282
  for(var key in CoreObjects){
42863
43283
  Loader.registerClass(key, CoreObjects[key]);
@@ -42900,6 +43320,7 @@
42900
43320
  exports.ColliderShape = ColliderShape;
42901
43321
  exports.CollisionUtil = CollisionUtil;
42902
43322
  exports.Color = Color$1;
43323
+ exports.ColorOverLifetimeModule = ColorOverLifetimeModule;
42903
43324
  exports.Component = Component;
42904
43325
  exports.ComponentMap = ComponentMap;
42905
43326
  exports.ConeShape = ConeShape;
@@ -42909,6 +43330,7 @@
42909
43330
  exports.DepthState = DepthState;
42910
43331
  exports.DirectLight = DirectLight;
42911
43332
  exports.DynamicCollider = DynamicCollider;
43333
+ exports.EmissionModule = EmissionModule;
42912
43334
  exports.Engine = Engine;
42913
43335
  exports.EngineObject = EngineObject;
42914
43336
  exports.Entity = Entity;
@@ -42920,6 +43342,8 @@
42920
43342
  exports.GLTFParserContext = GLTFParserContext;
42921
43343
  exports.GLTFResource = GLTFResource;
42922
43344
  exports.GLTFUtils = GLTFUtils;
43345
+ exports.GradientAlphaKey = GradientAlphaKey;
43346
+ exports.GradientColorKey = GradientColorKey;
42923
43347
  exports.HemisphereShape = HemisphereShape;
42924
43348
  exports.HingeJoint = HingeJoint;
42925
43349
  exports.HitResult = HitResult;
@@ -42931,6 +43355,7 @@
42931
43355
  exports.Light = Light;
42932
43356
  exports.Loader = Loader;
42933
43357
  exports.Logger = Logger;
43358
+ exports.MainModule = MainModule;
42934
43359
  exports.Material = Material;
42935
43360
  exports.MathUtil = MathUtil$1;
42936
43361
  exports.Matrix = Matrix;
@@ -42942,7 +43367,10 @@
42942
43367
  exports.PBRMaterial = PBRMaterial;
42943
43368
  exports.PBRSpecularMaterial = PBRSpecularMaterial;
42944
43369
  exports.ParticleCompositeCurve = ParticleCompositeCurve;
43370
+ exports.ParticleCompositeGradient = ParticleCompositeGradient;
42945
43371
  exports.ParticleCurve = ParticleCurve;
43372
+ exports.ParticleGenerator = ParticleGenerator;
43373
+ exports.ParticleGradient = ParticleGradient;
42946
43374
  exports.ParticleMaterial = ParticleMaterial;
42947
43375
  exports.ParticleRenderer = ParticleRenderer;
42948
43376
  exports.PhysicsMaterial = PhysicsMaterial;
@@ -42968,6 +43396,7 @@
42968
43396
  exports.RenderTarget = RenderTarget;
42969
43397
  exports.RenderTargetBlendState = RenderTargetBlendState;
42970
43398
  exports.ResourceManager = ResourceManager;
43399
+ exports.RotationOverLifetimeModule = RotationOverLifetimeModule;
42971
43400
  exports.Scene = Scene;
42972
43401
  exports.SceneManager = SceneManager;
42973
43402
  exports.SceneParser = SceneParser;
@@ -42980,6 +43409,7 @@
42980
43409
  exports.ShaderPass = ShaderPass;
42981
43410
  exports.ShaderProperty = ShaderProperty;
42982
43411
  exports.ShaderTagKey = ShaderTagKey;
43412
+ exports.SizeOverLifetimeModule = SizeOverLifetimeModule;
42983
43413
  exports.Skin = Skin;
42984
43414
  exports.SkinnedMeshRenderer = SkinnedMeshRenderer;
42985
43415
  exports.Sky = Sky;
@@ -43006,6 +43436,7 @@
43006
43436
  exports.Texture2D = Texture2D;
43007
43437
  exports.Texture2DArray = Texture2DArray;
43008
43438
  exports.TextureCube = TextureCube;
43439
+ exports.TextureSheetAnimationModule = TextureSheetAnimationModule;
43009
43440
  exports.Time = Time;
43010
43441
  exports.TrailMaterial = TrailMaterial;
43011
43442
  exports.TrailRenderer = TrailRenderer;
@@ -43015,6 +43446,7 @@
43015
43446
  exports.Vector2 = Vector2;
43016
43447
  exports.Vector3 = Vector3;
43017
43448
  exports.Vector4 = Vector4;
43449
+ exports.VelocityOverLifetimeModule = VelocityOverLifetimeModule;
43018
43450
  exports.VertexBufferBinding = VertexBufferBinding;
43019
43451
  exports.VertexElement = VertexElement;
43020
43452
  exports.WebCanvas = WebCanvas;