@galacean/engine-core 1.1.0-beta.4 → 1.1.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2542,8 +2542,8 @@ var ActiveChangeFlag;
2542
2542
  var _this;
2543
2543
  _this = EngineObject1.call(this, entity.engine) || this;
2544
2544
  /** @internal */ _this._awoken = false;
2545
- _this._phasedActive = false;
2546
2545
  _this._phasedActiveInScene = false;
2546
+ _this._phasedActive = false;
2547
2547
  _this._enabled = true;
2548
2548
  _this._entity = entity;
2549
2549
  return _this;
@@ -2675,10 +2675,10 @@ __decorate([
2675
2675
  ], Component.prototype, "_awoken", void 0);
2676
2676
  __decorate([
2677
2677
  ignoreClone
2678
- ], Component.prototype, "_phasedActive", void 0);
2678
+ ], Component.prototype, "_phasedActiveInScene", void 0);
2679
2679
  __decorate([
2680
2680
  ignoreClone
2681
- ], Component.prototype, "_phasedActiveInScene", void 0);
2681
+ ], Component.prototype, "_phasedActive", void 0);
2682
2682
  __decorate([
2683
2683
  assignmentClone
2684
2684
  ], Component.prototype, "_enabled", void 0);
@@ -12592,16 +12592,31 @@ var SafeLoopArray = /*#__PURE__*/ function() {
12592
12592
  }
12593
12593
  var _proto = SceneManager.prototype;
12594
12594
  _proto.addScene = function addScene(indexOrScene, scene) {
12595
+ var scenes = this._scenes;
12596
+ var index;
12595
12597
  if (typeof indexOrScene === "number") {
12596
- this._scenes.add(indexOrScene, scene);
12598
+ if (indexOrScene < 0 || indexOrScene > scenes.length) {
12599
+ throw "The index is out of range.";
12600
+ }
12601
+ index = indexOrScene;
12597
12602
  } else {
12603
+ index = scenes.length;
12598
12604
  scene = indexOrScene;
12599
- this._scenes.push(scene);
12600
12605
  }
12601
12606
  if (scene.engine !== this.engine) {
12602
12607
  throw "The scene is not belong to this engine.";
12603
12608
  }
12604
- scene._processActive(true);
12609
+ if (scene._sceneManager) {
12610
+ var currentIndex = scenes.indexOf(scene);
12611
+ if (currentIndex !== index) {
12612
+ scenes.removeByIndex(currentIndex);
12613
+ scenes.add(index, scene);
12614
+ }
12615
+ } else {
12616
+ scene._sceneManager = this;
12617
+ scenes.add(index, scene);
12618
+ scene.isActive && scene._processActive(true);
12619
+ }
12605
12620
  };
12606
12621
  /**
12607
12622
  * Remove scene.
@@ -12612,7 +12627,8 @@ var SafeLoopArray = /*#__PURE__*/ function() {
12612
12627
  if (index !== -1) {
12613
12628
  var removedScene = scenes.getArray()[index];
12614
12629
  scenes.removeByIndex(index);
12615
- removedScene._processActive(false);
12630
+ scene._sceneManager = null;
12631
+ removedScene.isActive && removedScene._processActive(false);
12616
12632
  }
12617
12633
  };
12618
12634
  /**
@@ -13816,9 +13832,9 @@ exports.Collider = /*#__PURE__*/ function(Component1) {
13816
13832
  oldCollider.removeShape(shape);
13817
13833
  }
13818
13834
  this._shapes.push(shape);
13819
- this.scene.physics._addColliderShape(shape);
13820
13835
  shape._collider = this;
13821
13836
  this._nativeCollider.addShape(shape._nativeShape);
13837
+ this._phasedActiveInScene && this.scene.physics._addColliderShape(shape);
13822
13838
  }
13823
13839
  };
13824
13840
  /**
@@ -13828,7 +13844,7 @@ exports.Collider = /*#__PURE__*/ function(Component1) {
13828
13844
  var index = this._shapes.indexOf(shape);
13829
13845
  if (index !== -1) {
13830
13846
  this._shapes.splice(index, 1);
13831
- this.scene.physics._removeColliderShape(shape);
13847
+ this._phasedActiveInScene && this.scene.physics._removeColliderShape(shape);
13832
13848
  shape._collider = null;
13833
13849
  this._nativeCollider.removeShape(shape._nativeShape);
13834
13850
  }
@@ -13839,7 +13855,7 @@ exports.Collider = /*#__PURE__*/ function(Component1) {
13839
13855
  var shapes = this._shapes;
13840
13856
  for(var i = 0, n = shapes.length; i < n; i++){
13841
13857
  var shape = shapes[i];
13842
- this.scene.physics._removeColliderShape(shape);
13858
+ this._phasedActiveInScene && this.scene.physics._removeColliderShape(shape);
13843
13859
  shape._destroy();
13844
13860
  this._nativeCollider.removeShape(shape._nativeShape);
13845
13861
  }
@@ -13864,12 +13880,22 @@ exports.Collider = /*#__PURE__*/ function(Component1) {
13864
13880
  /**
13865
13881
  * @internal
13866
13882
  */ _proto._onEnableInScene = function _onEnableInScene() {
13867
- this.scene.physics._addCollider(this);
13883
+ var physics = this.scene.physics;
13884
+ physics._addCollider(this);
13885
+ var shapes = this.shapes;
13886
+ for(var i = 0, n = shapes.length; i < n; i++){
13887
+ physics._addColliderShape(shapes[i]);
13888
+ }
13868
13889
  };
13869
13890
  /**
13870
13891
  * @internal
13871
13892
  */ _proto._onDisableInScene = function _onDisableInScene() {
13872
- this.scene.physics._removeCollider(this);
13893
+ var physics = this.scene.physics;
13894
+ physics._removeCollider(this);
13895
+ var shapes = this.shapes;
13896
+ for(var i = 0, n = shapes.length; i < n; i++){
13897
+ physics._removeColliderShape(shapes[i]);
13898
+ }
13873
13899
  };
13874
13900
  /**
13875
13901
  * @internal
@@ -14247,12 +14273,22 @@ var Collision = function Collision() {
14247
14273
  /**
14248
14274
  * @internal
14249
14275
  */ _proto._onEnableInScene = function _onEnableInScene() {
14250
- this.scene.physics._addCharacterController(this);
14276
+ var physics = this.scene.physics;
14277
+ physics._addCharacterController(this);
14278
+ var shapes = this.shapes;
14279
+ for(var i = 0, n = shapes.length; i < n; i++){
14280
+ physics._addColliderShape(shapes[i]);
14281
+ }
14251
14282
  };
14252
14283
  /**
14253
14284
  * @internal
14254
14285
  */ _proto._onDisableInScene = function _onDisableInScene() {
14255
- this.scene.physics._removeCharacterController(this);
14286
+ var physics = this.scene.physics;
14287
+ physics._removeCharacterController(this);
14288
+ var shapes = this.shapes;
14289
+ for(var i = 0, n = shapes.length; i < n; i++){
14290
+ physics._removeColliderShape(shapes[i]);
14291
+ }
14256
14292
  };
14257
14293
  _proto._setUpDirection = function _setUpDirection() {
14258
14294
  this._nativeCollider.setUpDirection(this._upDirection);
@@ -16404,10 +16440,6 @@ ShaderPool.init();
16404
16440
  magentaMaterial.isGCIgnored = true;
16405
16441
  magentaMaterial.shaderData.setColor("material_BaseColor", new Color(1.0, 0.0, 1.01, 1.0));
16406
16442
  _this._magentaMaterial = magentaMaterial;
16407
- var backgroundTextureMaterial = new Material(_assert_this_initialized(_this), Shader.find("background-texture"));
16408
- backgroundTextureMaterial.isGCIgnored = true;
16409
- backgroundTextureMaterial.renderState.depthState.compareFunction = exports.CompareFunction.LessEqual;
16410
- _this._backgroundTextureMaterial = backgroundTextureMaterial;
16411
16443
  var innerSettings = _this._settings;
16412
16444
  var colorSpace = configuration.colorSpace || exports.ColorSpace.Linear;
16413
16445
  colorSpace === exports.ColorSpace.Gamma && _this._macroCollection.enable(Engine._gammaMacro);
@@ -17025,6 +17057,7 @@ ShaderPool.init();
17025
17057
  this./** @internal */ _textureFillMode = exports.BackgroundTextureFillMode.AspectFitHeight;
17026
17058
  this._texture = null;
17027
17059
  this._initMesh(_engine);
17060
+ this._initMaterial(_engine);
17028
17061
  }
17029
17062
  var _proto = Background.prototype;
17030
17063
  /**
@@ -17032,19 +17065,14 @@ ShaderPool.init();
17032
17065
  */ _proto.destroy = function destroy() {
17033
17066
  this._mesh._addReferCount(-1);
17034
17067
  this._mesh = null;
17068
+ this._material._addReferCount(-1);
17069
+ this._material = null;
17035
17070
  this.texture = null;
17036
17071
  this.solidColor = null;
17037
17072
  this.sky.destroy();
17038
17073
  };
17039
17074
  /**
17040
17075
  * @internal
17041
- * Standalone for CanvasRenderer plugin.
17042
- */ _proto._initMesh = function _initMesh(engine) {
17043
- this._mesh = this._createPlane(engine);
17044
- this._mesh._addReferCount(1);
17045
- };
17046
- /**
17047
- * @internal
17048
17076
  */ _proto._resizeBackgroundTexture = function _resizeBackgroundTexture() {
17049
17077
  if (!this._texture) {
17050
17078
  return;
@@ -17078,6 +17106,15 @@ ShaderPool.init();
17078
17106
  _backgroundTextureMesh.setPositions(positions);
17079
17107
  _backgroundTextureMesh.uploadData(false);
17080
17108
  };
17109
+ _proto._initMesh = function _initMesh(engine) {
17110
+ this._mesh = this._createPlane(engine);
17111
+ this._mesh._addReferCount(1);
17112
+ };
17113
+ _proto._initMaterial = function _initMaterial(engine) {
17114
+ var material = this._material = new Material(engine, Shader.find("background-texture"));
17115
+ material.renderState.depthState.compareFunction = exports.CompareFunction.LessEqual;
17116
+ material._addReferCount(1);
17117
+ };
17081
17118
  _proto._createPlane = function _createPlane(engine) {
17082
17119
  var mesh = new ModelMesh(engine);
17083
17120
  mesh.isGCIgnored = true;
@@ -17117,7 +17154,7 @@ ShaderPool.init();
17117
17154
  (_value = value) == null ? void 0 : _value._addReferCount(1);
17118
17155
  (_this__texture = this._texture) == null ? void 0 : _this__texture._addReferCount(-1);
17119
17156
  this._texture = value;
17120
- this._engine._backgroundTextureMaterial.shaderData.setTexture("material_BaseTexture", value);
17157
+ this._material.shaderData.setTexture("material_BaseTexture", value);
17121
17158
  }
17122
17159
  }
17123
17160
  },
@@ -18197,6 +18234,7 @@ __decorate([
18197
18234
  _this._fogEnd = 300;
18198
18235
  _this._fogDensity = 0.01;
18199
18236
  _this._fogParams = new miniprogram.Vector4();
18237
+ _this._isActive = true;
18200
18238
  _this.name = name || "";
18201
18239
  var shaderData = _this.shaderData;
18202
18240
  shaderData._addReferCount(1);
@@ -18444,6 +18482,24 @@ __decorate([
18444
18482
  this._fogParams.w = density / Math.sqrt(Math.LN2);
18445
18483
  };
18446
18484
  _create_class(Scene, [
18485
+ {
18486
+ key: "isActive",
18487
+ get: /**
18488
+ * Whether the scene is active.
18489
+ */ function get() {
18490
+ return this._isActive;
18491
+ },
18492
+ set: function set(value) {
18493
+ if (this._isActive !== value) {
18494
+ this._isActive = value;
18495
+ if (value) {
18496
+ this._sceneManager && this._processActive(true);
18497
+ } else {
18498
+ this._sceneManager && this._processActive(false);
18499
+ }
18500
+ }
18501
+ }
18502
+ },
18447
18503
  {
18448
18504
  key: "shaderData",
18449
18505
  get: /**
@@ -18762,7 +18818,11 @@ __decorate([
18762
18818
  * @internal
18763
18819
  */ _proto._onDestroy = function _onDestroy() {
18764
18820
  Component1.prototype._onDestroy.call(this);
18765
- this.scene._componentsManager.addPendingDestroyScript(this);
18821
+ if (this.scene) {
18822
+ this.scene._componentsManager.addPendingDestroyScript(this);
18823
+ } else {
18824
+ this.onDestroy();
18825
+ }
18766
18826
  };
18767
18827
  return Script;
18768
18828
  }(Component);
@@ -20312,8 +20372,8 @@ var /**
20312
20372
  };
20313
20373
  _proto._drawBackgroundTexture = function _drawBackgroundTexture(engine, background) {
20314
20374
  var rhi = engine._hardwareRenderer;
20315
- var material = engine._backgroundTextureMaterial, canvas = engine.canvas;
20316
- var mesh = background._mesh;
20375
+ var canvas = engine.canvas;
20376
+ var material = background._material, mesh = background._mesh;
20317
20377
  if ((this._lastCanvasSize.x !== canvas.width || this._lastCanvasSize.y !== canvas.height) && background._textureFillMode !== exports.BackgroundTextureFillMode.Fill) {
20318
20378
  this._lastCanvasSize.set(canvas.width, canvas.height);
20319
20379
  background._resizeBackgroundTexture();
@@ -20488,7 +20548,7 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
20488
20548
  // Use the intersection of the near clipping plane as the origin point.
20489
20549
  var origin = this._innerViewportToWorldPoint(point.x, point.y, 0.0, invViewProjMat, out.origin);
20490
20550
  // Use the intersection of the far clipping plane as the origin point.
20491
- var direction = this._innerViewportToWorldPoint(point.x, point.y, 1.0, invViewProjMat, out.direction);
20551
+ var direction = this._innerViewportToWorldPoint(point.x, point.y, 1 - miniprogram.MathUtil.zeroTolerance, invViewProjMat, out.direction);
20492
20552
  miniprogram.Vector3.subtract(direction, origin, direction);
20493
20553
  direction.normalize();
20494
20554
  return out;
package/dist/module.js CHANGED
@@ -2537,8 +2537,8 @@ var ActiveChangeFlag;
2537
2537
  var _this;
2538
2538
  _this = EngineObject1.call(this, entity.engine) || this;
2539
2539
  /** @internal */ _this._awoken = false;
2540
- _this._phasedActive = false;
2541
2540
  _this._phasedActiveInScene = false;
2541
+ _this._phasedActive = false;
2542
2542
  _this._enabled = true;
2543
2543
  _this._entity = entity;
2544
2544
  return _this;
@@ -2670,10 +2670,10 @@ __decorate([
2670
2670
  ], Component.prototype, "_awoken", void 0);
2671
2671
  __decorate([
2672
2672
  ignoreClone
2673
- ], Component.prototype, "_phasedActive", void 0);
2673
+ ], Component.prototype, "_phasedActiveInScene", void 0);
2674
2674
  __decorate([
2675
2675
  ignoreClone
2676
- ], Component.prototype, "_phasedActiveInScene", void 0);
2676
+ ], Component.prototype, "_phasedActive", void 0);
2677
2677
  __decorate([
2678
2678
  assignmentClone
2679
2679
  ], Component.prototype, "_enabled", void 0);
@@ -12587,16 +12587,31 @@ var SafeLoopArray = /*#__PURE__*/ function() {
12587
12587
  }
12588
12588
  var _proto = SceneManager.prototype;
12589
12589
  _proto.addScene = function addScene(indexOrScene, scene) {
12590
+ var scenes = this._scenes;
12591
+ var index;
12590
12592
  if (typeof indexOrScene === "number") {
12591
- this._scenes.add(indexOrScene, scene);
12593
+ if (indexOrScene < 0 || indexOrScene > scenes.length) {
12594
+ throw "The index is out of range.";
12595
+ }
12596
+ index = indexOrScene;
12592
12597
  } else {
12598
+ index = scenes.length;
12593
12599
  scene = indexOrScene;
12594
- this._scenes.push(scene);
12595
12600
  }
12596
12601
  if (scene.engine !== this.engine) {
12597
12602
  throw "The scene is not belong to this engine.";
12598
12603
  }
12599
- scene._processActive(true);
12604
+ if (scene._sceneManager) {
12605
+ var currentIndex = scenes.indexOf(scene);
12606
+ if (currentIndex !== index) {
12607
+ scenes.removeByIndex(currentIndex);
12608
+ scenes.add(index, scene);
12609
+ }
12610
+ } else {
12611
+ scene._sceneManager = this;
12612
+ scenes.add(index, scene);
12613
+ scene.isActive && scene._processActive(true);
12614
+ }
12600
12615
  };
12601
12616
  /**
12602
12617
  * Remove scene.
@@ -12607,7 +12622,8 @@ var SafeLoopArray = /*#__PURE__*/ function() {
12607
12622
  if (index !== -1) {
12608
12623
  var removedScene = scenes.getArray()[index];
12609
12624
  scenes.removeByIndex(index);
12610
- removedScene._processActive(false);
12625
+ scene._sceneManager = null;
12626
+ removedScene.isActive && removedScene._processActive(false);
12611
12627
  }
12612
12628
  };
12613
12629
  /**
@@ -13811,9 +13827,9 @@ var Collider = /*#__PURE__*/ function(Component1) {
13811
13827
  oldCollider.removeShape(shape);
13812
13828
  }
13813
13829
  this._shapes.push(shape);
13814
- this.scene.physics._addColliderShape(shape);
13815
13830
  shape._collider = this;
13816
13831
  this._nativeCollider.addShape(shape._nativeShape);
13832
+ this._phasedActiveInScene && this.scene.physics._addColliderShape(shape);
13817
13833
  }
13818
13834
  };
13819
13835
  /**
@@ -13823,7 +13839,7 @@ var Collider = /*#__PURE__*/ function(Component1) {
13823
13839
  var index = this._shapes.indexOf(shape);
13824
13840
  if (index !== -1) {
13825
13841
  this._shapes.splice(index, 1);
13826
- this.scene.physics._removeColliderShape(shape);
13842
+ this._phasedActiveInScene && this.scene.physics._removeColliderShape(shape);
13827
13843
  shape._collider = null;
13828
13844
  this._nativeCollider.removeShape(shape._nativeShape);
13829
13845
  }
@@ -13834,7 +13850,7 @@ var Collider = /*#__PURE__*/ function(Component1) {
13834
13850
  var shapes = this._shapes;
13835
13851
  for(var i = 0, n = shapes.length; i < n; i++){
13836
13852
  var shape = shapes[i];
13837
- this.scene.physics._removeColliderShape(shape);
13853
+ this._phasedActiveInScene && this.scene.physics._removeColliderShape(shape);
13838
13854
  shape._destroy();
13839
13855
  this._nativeCollider.removeShape(shape._nativeShape);
13840
13856
  }
@@ -13859,12 +13875,22 @@ var Collider = /*#__PURE__*/ function(Component1) {
13859
13875
  /**
13860
13876
  * @internal
13861
13877
  */ _proto._onEnableInScene = function _onEnableInScene() {
13862
- this.scene.physics._addCollider(this);
13878
+ var physics = this.scene.physics;
13879
+ physics._addCollider(this);
13880
+ var shapes = this.shapes;
13881
+ for(var i = 0, n = shapes.length; i < n; i++){
13882
+ physics._addColliderShape(shapes[i]);
13883
+ }
13863
13884
  };
13864
13885
  /**
13865
13886
  * @internal
13866
13887
  */ _proto._onDisableInScene = function _onDisableInScene() {
13867
- this.scene.physics._removeCollider(this);
13888
+ var physics = this.scene.physics;
13889
+ physics._removeCollider(this);
13890
+ var shapes = this.shapes;
13891
+ for(var i = 0, n = shapes.length; i < n; i++){
13892
+ physics._removeColliderShape(shapes[i]);
13893
+ }
13868
13894
  };
13869
13895
  /**
13870
13896
  * @internal
@@ -14242,12 +14268,22 @@ var Collision = function Collision() {
14242
14268
  /**
14243
14269
  * @internal
14244
14270
  */ _proto._onEnableInScene = function _onEnableInScene() {
14245
- this.scene.physics._addCharacterController(this);
14271
+ var physics = this.scene.physics;
14272
+ physics._addCharacterController(this);
14273
+ var shapes = this.shapes;
14274
+ for(var i = 0, n = shapes.length; i < n; i++){
14275
+ physics._addColliderShape(shapes[i]);
14276
+ }
14246
14277
  };
14247
14278
  /**
14248
14279
  * @internal
14249
14280
  */ _proto._onDisableInScene = function _onDisableInScene() {
14250
- this.scene.physics._removeCharacterController(this);
14281
+ var physics = this.scene.physics;
14282
+ physics._removeCharacterController(this);
14283
+ var shapes = this.shapes;
14284
+ for(var i = 0, n = shapes.length; i < n; i++){
14285
+ physics._removeColliderShape(shapes[i]);
14286
+ }
14251
14287
  };
14252
14288
  _proto._setUpDirection = function _setUpDirection() {
14253
14289
  this._nativeCollider.setUpDirection(this._upDirection);
@@ -16399,10 +16435,6 @@ ShaderPool.init();
16399
16435
  magentaMaterial.isGCIgnored = true;
16400
16436
  magentaMaterial.shaderData.setColor("material_BaseColor", new Color(1.0, 0.0, 1.01, 1.0));
16401
16437
  _this._magentaMaterial = magentaMaterial;
16402
- var backgroundTextureMaterial = new Material(_assert_this_initialized(_this), Shader.find("background-texture"));
16403
- backgroundTextureMaterial.isGCIgnored = true;
16404
- backgroundTextureMaterial.renderState.depthState.compareFunction = CompareFunction.LessEqual;
16405
- _this._backgroundTextureMaterial = backgroundTextureMaterial;
16406
16438
  var innerSettings = _this._settings;
16407
16439
  var colorSpace = configuration.colorSpace || ColorSpace.Linear;
16408
16440
  colorSpace === ColorSpace.Gamma && _this._macroCollection.enable(Engine._gammaMacro);
@@ -17020,6 +17052,7 @@ ShaderPool.init();
17020
17052
  this./** @internal */ _textureFillMode = BackgroundTextureFillMode.AspectFitHeight;
17021
17053
  this._texture = null;
17022
17054
  this._initMesh(_engine);
17055
+ this._initMaterial(_engine);
17023
17056
  }
17024
17057
  var _proto = Background.prototype;
17025
17058
  /**
@@ -17027,19 +17060,14 @@ ShaderPool.init();
17027
17060
  */ _proto.destroy = function destroy() {
17028
17061
  this._mesh._addReferCount(-1);
17029
17062
  this._mesh = null;
17063
+ this._material._addReferCount(-1);
17064
+ this._material = null;
17030
17065
  this.texture = null;
17031
17066
  this.solidColor = null;
17032
17067
  this.sky.destroy();
17033
17068
  };
17034
17069
  /**
17035
17070
  * @internal
17036
- * Standalone for CanvasRenderer plugin.
17037
- */ _proto._initMesh = function _initMesh(engine) {
17038
- this._mesh = this._createPlane(engine);
17039
- this._mesh._addReferCount(1);
17040
- };
17041
- /**
17042
- * @internal
17043
17071
  */ _proto._resizeBackgroundTexture = function _resizeBackgroundTexture() {
17044
17072
  if (!this._texture) {
17045
17073
  return;
@@ -17073,6 +17101,15 @@ ShaderPool.init();
17073
17101
  _backgroundTextureMesh.setPositions(positions);
17074
17102
  _backgroundTextureMesh.uploadData(false);
17075
17103
  };
17104
+ _proto._initMesh = function _initMesh(engine) {
17105
+ this._mesh = this._createPlane(engine);
17106
+ this._mesh._addReferCount(1);
17107
+ };
17108
+ _proto._initMaterial = function _initMaterial(engine) {
17109
+ var material = this._material = new Material(engine, Shader.find("background-texture"));
17110
+ material.renderState.depthState.compareFunction = CompareFunction.LessEqual;
17111
+ material._addReferCount(1);
17112
+ };
17076
17113
  _proto._createPlane = function _createPlane(engine) {
17077
17114
  var mesh = new ModelMesh(engine);
17078
17115
  mesh.isGCIgnored = true;
@@ -17112,7 +17149,7 @@ ShaderPool.init();
17112
17149
  (_value = value) == null ? void 0 : _value._addReferCount(1);
17113
17150
  (_this__texture = this._texture) == null ? void 0 : _this__texture._addReferCount(-1);
17114
17151
  this._texture = value;
17115
- this._engine._backgroundTextureMaterial.shaderData.setTexture("material_BaseTexture", value);
17152
+ this._material.shaderData.setTexture("material_BaseTexture", value);
17116
17153
  }
17117
17154
  }
17118
17155
  },
@@ -18192,6 +18229,7 @@ __decorate([
18192
18229
  _this._fogEnd = 300;
18193
18230
  _this._fogDensity = 0.01;
18194
18231
  _this._fogParams = new Vector4();
18232
+ _this._isActive = true;
18195
18233
  _this.name = name || "";
18196
18234
  var shaderData = _this.shaderData;
18197
18235
  shaderData._addReferCount(1);
@@ -18439,6 +18477,24 @@ __decorate([
18439
18477
  this._fogParams.w = density / Math.sqrt(Math.LN2);
18440
18478
  };
18441
18479
  _create_class(Scene, [
18480
+ {
18481
+ key: "isActive",
18482
+ get: /**
18483
+ * Whether the scene is active.
18484
+ */ function get() {
18485
+ return this._isActive;
18486
+ },
18487
+ set: function set(value) {
18488
+ if (this._isActive !== value) {
18489
+ this._isActive = value;
18490
+ if (value) {
18491
+ this._sceneManager && this._processActive(true);
18492
+ } else {
18493
+ this._sceneManager && this._processActive(false);
18494
+ }
18495
+ }
18496
+ }
18497
+ },
18442
18498
  {
18443
18499
  key: "shaderData",
18444
18500
  get: /**
@@ -18757,7 +18813,11 @@ __decorate([
18757
18813
  * @internal
18758
18814
  */ _proto._onDestroy = function _onDestroy() {
18759
18815
  Component1.prototype._onDestroy.call(this);
18760
- this.scene._componentsManager.addPendingDestroyScript(this);
18816
+ if (this.scene) {
18817
+ this.scene._componentsManager.addPendingDestroyScript(this);
18818
+ } else {
18819
+ this.onDestroy();
18820
+ }
18761
18821
  };
18762
18822
  return Script;
18763
18823
  }(Component);
@@ -20307,8 +20367,8 @@ var /**
20307
20367
  };
20308
20368
  _proto._drawBackgroundTexture = function _drawBackgroundTexture(engine, background) {
20309
20369
  var rhi = engine._hardwareRenderer;
20310
- var material = engine._backgroundTextureMaterial, canvas = engine.canvas;
20311
- var mesh = background._mesh;
20370
+ var canvas = engine.canvas;
20371
+ var material = background._material, mesh = background._mesh;
20312
20372
  if ((this._lastCanvasSize.x !== canvas.width || this._lastCanvasSize.y !== canvas.height) && background._textureFillMode !== BackgroundTextureFillMode.Fill) {
20313
20373
  this._lastCanvasSize.set(canvas.width, canvas.height);
20314
20374
  background._resizeBackgroundTexture();
@@ -20483,7 +20543,7 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
20483
20543
  // Use the intersection of the near clipping plane as the origin point.
20484
20544
  var origin = this._innerViewportToWorldPoint(point.x, point.y, 0.0, invViewProjMat, out.origin);
20485
20545
  // Use the intersection of the far clipping plane as the origin point.
20486
- var direction = this._innerViewportToWorldPoint(point.x, point.y, 1.0, invViewProjMat, out.direction);
20546
+ var direction = this._innerViewportToWorldPoint(point.x, point.y, 1 - MathUtil$1.zeroTolerance, invViewProjMat, out.direction);
20487
20547
  Vector3.subtract(direction, origin, direction);
20488
20548
  direction.normalize();
20489
20549
  return out;