@galacean/engine-physics-physx 0.9.11 → 0.9.12

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.
@@ -1516,9 +1516,11 @@ exports.GLCapabilityType = void 0;
1516
1516
  renderTexture
1517
1517
  ];
1518
1518
  for(var i = 0, n = colorTextures.length; i < n; i++){
1519
- if (colorTextures[i]._isDepthTexture) {
1519
+ var colorTexture = colorTextures[i];
1520
+ if (colorTexture._isDepthTexture) {
1520
1521
  throw "Render texture can't use depth format.";
1521
1522
  }
1523
+ colorTexture._addRefCount(1);
1522
1524
  }
1523
1525
  _this._colorTextures = colorTextures;
1524
1526
  } else {
@@ -1529,6 +1531,7 @@ exports.GLCapabilityType = void 0;
1529
1531
  throw "Depth texture must use depth format.";
1530
1532
  }
1531
1533
  _this._depthTexture = depth;
1534
+ _this._depthTexture._addRefCount(1);
1532
1535
  }
1533
1536
  _this._platformRenderTarget = engine._hardwareRenderer.createPlatformRenderTarget(_assert_this_initialized(_this));
1534
1537
  return _this;
@@ -1558,8 +1561,14 @@ exports.GLCapabilityType = void 0;
1558
1561
  /**
1559
1562
  * Destroy render target.
1560
1563
  */ _proto.destroy = function destroy() {
1564
+ var _this__depthTexture;
1561
1565
  this._platformRenderTarget.destroy();
1562
- this._colorTextures.length = 0;
1566
+ var _this = this, colorTextures = _this._colorTextures;
1567
+ for(var i = 0, n = colorTextures.length; i < n; i++){
1568
+ colorTextures[i]._addRefCount(-1);
1569
+ }
1570
+ colorTextures.length = 0;
1571
+ (_this__depthTexture = this._depthTexture) == null ? void 0 : _this__depthTexture._addRefCount(-1);
1563
1572
  this._depthTexture = null;
1564
1573
  this._depth = null;
1565
1574
  };
@@ -2000,6 +2009,7 @@ exports.GLCapabilityType = void 0;
2000
2009
  var fontAtlas = new FontAtlas(engine);
2001
2010
  var texture = new Texture2D(engine, 256, 256);
2002
2011
  fontAtlas.texture = texture;
2012
+ fontAtlas.isGCIgnored = texture.isGCIgnored = true;
2003
2013
  this._fontAtlases.push(fontAtlas);
2004
2014
  return fontAtlas;
2005
2015
  };
@@ -8672,6 +8682,7 @@ var ShaderFactory = /*#__PURE__*/ function() {
8672
8682
  _proto.cloneTo = function cloneTo(target) {
8673
8683
  CloneManager.deepCloneObject(this._macroCollection, target._macroCollection);
8674
8684
  Object.assign(target._macroMap, this._macroMap);
8685
+ var referCount = target._getRefCount();
8675
8686
  var propertyValueMap = this._propertyValueMap;
8676
8687
  var targetPropertyValueMap = target._propertyValueMap;
8677
8688
  var keys = Object.keys(propertyValueMap);
@@ -8683,6 +8694,7 @@ var ShaderFactory = /*#__PURE__*/ function() {
8683
8694
  targetPropertyValueMap[k] = property;
8684
8695
  } else if (_instanceof1$2(property, Texture)) {
8685
8696
  targetPropertyValueMap[k] = property;
8697
+ referCount > 0 && property._addRefCount(referCount);
8686
8698
  } else if (_instanceof1$2(property, Array) || _instanceof1$2(property, Float32Array) || _instanceof1$2(property, Int32Array)) {
8687
8699
  targetPropertyValueMap[k] = property.slice();
8688
8700
  } else {
@@ -10399,16 +10411,6 @@ SimpleSpriteAssembler = __decorate$1([
10399
10411
  }
10400
10412
  var _proto = SpriteMask.prototype;
10401
10413
  /**
10402
- * @override
10403
- * @inheritdoc
10404
- */ _proto._onDestroy = function _onDestroy() {
10405
- var _this__sprite;
10406
- (_this__sprite = this._sprite) == null ? void 0 : _this__sprite._updateFlagManager.removeListener(this._onSpriteChange);
10407
- this._sprite = null;
10408
- this._renderData = null;
10409
- Renderer.prototype._onDestroy.call(this);
10410
- };
10411
- /**
10412
10414
  * @internal
10413
10415
  */ _proto._cloneTo = function _cloneTo(target) {
10414
10416
  Renderer.prototype._cloneTo.call(this, target);
@@ -10448,6 +10450,19 @@ SimpleSpriteAssembler = __decorate$1([
10448
10450
  context.camera._renderPipeline._allSpriteMasks.add(this);
10449
10451
  this._maskElement = maskElement;
10450
10452
  };
10453
+ /**
10454
+ * @internal
10455
+ * @inheritdoc
10456
+ */ _proto._onDestroy = function _onDestroy() {
10457
+ Renderer.prototype._onDestroy.call(this);
10458
+ var sprite = this._sprite;
10459
+ if (sprite) {
10460
+ sprite._addRefCount(-1);
10461
+ sprite._updateFlagManager.removeListener(this._onSpriteChange);
10462
+ }
10463
+ this._sprite = null;
10464
+ this._renderData = null;
10465
+ };
10451
10466
  _proto._calDefaultSize = function _calDefaultSize() {
10452
10467
  var sprite = this._sprite;
10453
10468
  if (sprite) {
@@ -10566,9 +10581,13 @@ SimpleSpriteAssembler = __decorate$1([
10566
10581
  set: function set(value) {
10567
10582
  var lastSprite = this._sprite;
10568
10583
  if (lastSprite !== value) {
10569
- lastSprite && lastSprite._updateFlagManager.removeListener(this._onSpriteChange);
10584
+ if (lastSprite) {
10585
+ lastSprite._addRefCount(-1);
10586
+ lastSprite._updateFlagManager.removeListener(this._onSpriteChange);
10587
+ }
10570
10588
  this._dirtyUpdateFlag |= 0x7;
10571
10589
  if (value) {
10590
+ value._addRefCount(1);
10572
10591
  value._updateFlagManager.addListener(this._onSpriteChange);
10573
10592
  this.shaderData.setTexture(SpriteMask._textureProperty, value.texture);
10574
10593
  } else {
@@ -11123,10 +11142,11 @@ var BufferUtil = /*#__PURE__*/ function() {
11123
11142
  /**
11124
11143
  * @internal
11125
11144
  */ _proto._setVertexBufferBinding = function _setVertexBufferBinding(index, binding) {
11126
- if (this._getRefCount() > 0) {
11127
- var lastBinding = this._vertexBufferBindings[index];
11128
- lastBinding && lastBinding._buffer._addRefCount(-1);
11129
- binding._buffer._addRefCount(1);
11145
+ var referCount = this._getRefCount();
11146
+ if (referCount > 0) {
11147
+ var _this__vertexBufferBindings_index;
11148
+ (_this__vertexBufferBindings_index = this._vertexBufferBindings[index]) == null ? void 0 : _this__vertexBufferBindings_index._buffer._addRefCount(-referCount);
11149
+ binding == null ? void 0 : binding._buffer._addRefCount(referCount);
11130
11150
  }
11131
11151
  this._vertexBufferBindings[index] = binding;
11132
11152
  this._bufferStructChanged = true;
@@ -11140,11 +11160,13 @@ var BufferUtil = /*#__PURE__*/ function() {
11140
11160
  /**
11141
11161
  * @override
11142
11162
  */ _proto._addRefCount = function _addRefCount(value) {
11163
+ var _this__indexBufferBinding;
11143
11164
  RefObject.prototype._addRefCount.call(this, value);
11144
11165
  var vertexBufferBindings = this._vertexBufferBindings;
11145
11166
  for(var i = 0, n = vertexBufferBindings.length; i < n; i++){
11146
11167
  vertexBufferBindings[i]._buffer._addRefCount(value);
11147
11168
  }
11169
+ (_this__indexBufferBinding = this._indexBufferBinding) == null ? void 0 : _this__indexBufferBinding._buffer._addRefCount(value);
11148
11170
  };
11149
11171
  /**
11150
11172
  * @override
@@ -11164,6 +11186,11 @@ var BufferUtil = /*#__PURE__*/ function() {
11164
11186
  };
11165
11187
  _proto._setIndexBufferBinding = function _setIndexBufferBinding(binding) {
11166
11188
  var lastBinding = this._indexBufferBinding;
11189
+ var referCount = this._getRefCount();
11190
+ if (referCount > 0) {
11191
+ lastBinding == null ? void 0 : lastBinding.buffer._addRefCount(-referCount);
11192
+ binding == null ? void 0 : binding.buffer._addRefCount(referCount);
11193
+ }
11167
11194
  if (binding) {
11168
11195
  this._indexBufferBinding = binding;
11169
11196
  this._glIndexType = BufferUtil._getGLIndexType(binding.format);
@@ -14323,14 +14350,17 @@ var Basic2DBatcher = /*#__PURE__*/ function() {
14323
14350
  _proto._createMesh = function _createMesh(engine, index) {
14324
14351
  var MAX_VERTEX_COUNT = Basic2DBatcher.MAX_VERTEX_COUNT;
14325
14352
  var mesh = new BufferMesh(engine, "BufferMesh" + index);
14353
+ mesh.isGCIgnored = true;
14326
14354
  var vertexElements = [];
14327
14355
  var vertexStride = this.createVertexElements(vertexElements);
14328
14356
  // vertices
14329
- this._vertexBuffers[index] = new Buffer(engine, exports.BufferBindFlag.VertexBuffer, MAX_VERTEX_COUNT * 4 * vertexStride, exports.BufferUsage.Dynamic);
14357
+ var vertexBuffer = this._vertexBuffers[index] = new Buffer(engine, exports.BufferBindFlag.VertexBuffer, MAX_VERTEX_COUNT * 4 * vertexStride, exports.BufferUsage.Dynamic);
14358
+ vertexBuffer.isGCIgnored = true;
14330
14359
  // indices
14331
- this._indiceBuffers[index] = new Buffer(engine, exports.BufferBindFlag.IndexBuffer, MAX_VERTEX_COUNT * 2 * 3, exports.BufferUsage.Dynamic);
14332
- mesh.setVertexBufferBinding(this._vertexBuffers[index], vertexStride);
14333
- mesh.setIndexBufferBinding(this._indiceBuffers[index], exports.IndexFormat.UInt16);
14360
+ var indiceBuffer = this._indiceBuffers[index] = new Buffer(engine, exports.BufferBindFlag.IndexBuffer, MAX_VERTEX_COUNT * 2 * 3, exports.BufferUsage.Dynamic);
14361
+ indiceBuffer.isGCIgnored = true;
14362
+ mesh.setVertexBufferBinding(vertexBuffer, vertexStride);
14363
+ mesh.setIndexBufferBinding(indiceBuffer, exports.IndexFormat.UInt16);
14334
14364
  mesh.setVertexElements(vertexElements);
14335
14365
  return mesh;
14336
14366
  };
@@ -14563,6 +14593,12 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
14563
14593
  var _proto = Sky.prototype;
14564
14594
  /**
14565
14595
  * @internal
14596
+ */ _proto.destroy = function destroy() {
14597
+ this.mesh = null;
14598
+ this.material = null;
14599
+ };
14600
+ /**
14601
+ * @internal
14566
14602
  */ _proto._render = function _render(context) {
14567
14603
  var _this = this, material = _this.material, mesh = _this.mesh;
14568
14604
  if (!material) {
@@ -14601,6 +14637,40 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
14601
14637
  rhi.drawPrimitive(mesh, mesh.subMesh, program);
14602
14638
  cameraShaderData.setMatrix(RenderContext._vpMatrixProperty, originViewProjMatrix);
14603
14639
  };
14640
+ _create_class$2(Sky, [
14641
+ {
14642
+ key: "material",
14643
+ get: /**
14644
+ * Material of the sky.
14645
+ */ function get() {
14646
+ return this._material;
14647
+ },
14648
+ set: function set(value) {
14649
+ if (this._material !== value) {
14650
+ var _this__material;
14651
+ value == null ? void 0 : value._addRefCount(1);
14652
+ (_this__material = this._material) == null ? void 0 : _this__material._addRefCount(-1);
14653
+ this._material = value;
14654
+ }
14655
+ }
14656
+ },
14657
+ {
14658
+ key: "mesh",
14659
+ get: /**
14660
+ * Mesh of the sky.
14661
+ */ function get() {
14662
+ return this._mesh;
14663
+ },
14664
+ set: function set(value) {
14665
+ if (this._mesh !== value) {
14666
+ var _this__mesh;
14667
+ value == null ? void 0 : value._addRefCount(1);
14668
+ (_this__mesh = this._mesh) == null ? void 0 : _this__mesh._addRefCount(-1);
14669
+ this._mesh = value;
14670
+ }
14671
+ }
14672
+ }
14673
+ ]);
14604
14674
  return Sky;
14605
14675
  }();
14606
14676
  (function() {
@@ -14630,11 +14700,28 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
14630
14700
  this.sky = new Sky();
14631
14701
  this./** @internal */ _textureFillMode = exports.BackgroundTextureFillMode.AspectFitHeight;
14632
14702
  this._texture = null;
14633
- this._mesh = this._createPlane(_engine);
14703
+ this._initMesh(_engine);
14634
14704
  };
14635
14705
  var _proto = Background.prototype;
14636
14706
  /**
14637
14707
  * @internal
14708
+ */ _proto.destroy = function destroy() {
14709
+ this._mesh._addRefCount(-1);
14710
+ this._mesh = null;
14711
+ this.texture = null;
14712
+ this.solidColor = null;
14713
+ this.sky.destroy();
14714
+ this._engine = null;
14715
+ };
14716
+ /**
14717
+ * @internal
14718
+ * Standalone for CanvasRenderer plugin.
14719
+ */ _proto._initMesh = function _initMesh(engine) {
14720
+ this._mesh = this._createPlane(engine);
14721
+ this._mesh._addRefCount(1);
14722
+ };
14723
+ /**
14724
+ * @internal
14638
14725
  */ _proto._resizeBackgroundTexture = function _resizeBackgroundTexture() {
14639
14726
  if (!this._texture) {
14640
14727
  return;
@@ -14703,6 +14790,9 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
14703
14790
  },
14704
14791
  set: function set(value) {
14705
14792
  if (this._texture !== value) {
14793
+ var _this__texture;
14794
+ value == null ? void 0 : value._addRefCount(1);
14795
+ (_this__texture = this._texture) == null ? void 0 : _this__texture._addRefCount(-1);
14706
14796
  this._texture = value;
14707
14797
  this._engine._backgroundTextureMaterial.shaderData.setTexture("u_baseTexture", value);
14708
14798
  }
@@ -15202,6 +15292,7 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
15202
15292
  this._rootEntities[0].destroy();
15203
15293
  }
15204
15294
  this._activeCameras.length = 0;
15295
+ this.background.destroy();
15205
15296
  this.shaderData._addRefCount(-1);
15206
15297
  };
15207
15298
  _proto._addToRootEntityList = function _addToRootEntityList(index, rootEntity) {
@@ -15592,7 +15683,7 @@ ShaderPool.init();
15592
15683
  _this._spriteDefaultMaterial = _this._createSpriteMaterial();
15593
15684
  _this._spriteMaskDefaultMaterial = _this._createSpriteMaskMaterial();
15594
15685
  _this._textDefaultFont = Font.createFromOS(_assert_this_initialized(_this), "Arial");
15595
- _this._textDefaultFont.isGCIgnored = false;
15686
+ _this._textDefaultFont.isGCIgnored = true;
15596
15687
  _this.inputManager = new InputManager(_assert_this_initialized(_this));
15597
15688
  var magentaPixel = new Uint8Array([
15598
15689
  255,
@@ -15627,6 +15718,7 @@ ShaderPool.init();
15627
15718
  _this._magentaTexture2DArray = magentaTexture2DArray;
15628
15719
  }
15629
15720
  var magentaMaterial = new Material(_assert_this_initialized(_this), Shader.find("unlit"));
15721
+ magentaMaterial.isGCIgnored = true;
15630
15722
  magentaMaterial.shaderData.setColor("u_baseColor", new Color(1.0, 0.0, 1.01, 1.0));
15631
15723
  _this._magentaMaterial = magentaMaterial;
15632
15724
  var backgroundTextureMaterial = new Material(_assert_this_initialized(_this), Shader.find("background-texture"));
@@ -17152,7 +17244,11 @@ var /**
17152
17244
  var height = shadowCascades == exports.ShadowCascadesMode.TwoCascades ? shadowTileResolution : shadowTileResolution * 2;
17153
17245
  this._shadowMapSize.set(1.0 / width, 1.0 / height, width, height);
17154
17246
  }
17155
- this._renderTargets = null;
17247
+ var renderTargets = this._renderTargets;
17248
+ if (renderTargets) {
17249
+ renderTargets.destroy();
17250
+ this._renderTargets = null;
17251
+ }
17156
17252
  var viewportOffset = this._viewportOffsets;
17157
17253
  var shadowTileResolution1 = this._shadowTileResolution;
17158
17254
  switch(shadowCascades){
@@ -19174,10 +19270,17 @@ exports.TextVerticalAlignment = void 0;
19174
19270
  * @internal
19175
19271
  */ _proto._addSprite = function _addSprite(sprite) {
19176
19272
  this._spriteNamesToIndex[sprite.name] = this._sprites.push(sprite) - 1;
19273
+ sprite._atlas = this;
19274
+ sprite.isGCIgnored = true;
19177
19275
  };
19178
19276
  /**
19179
19277
  * @override
19180
19278
  */ _proto._onDestroy = function _onDestroy() {
19279
+ var _this = this, sprites = _this._sprites;
19280
+ for(var i = 0, n = sprites.length; i < n; i++){
19281
+ sprites[i].destroy();
19282
+ }
19283
+ sprites.length = 0;
19181
19284
  this._sprites = null;
19182
19285
  this._spriteNamesToIndex = null;
19183
19286
  };
@@ -19276,10 +19379,29 @@ exports.TextVerticalAlignment = void 0;
19276
19379
  };
19277
19380
  /**
19278
19381
  * @override
19382
+ * @internal
19383
+ */ _proto._addRefCount = function _addRefCount(value) {
19384
+ var _this__atlas;
19385
+ RefObject.prototype._addRefCount.call(this, value);
19386
+ (_this__atlas = this._atlas) == null ? void 0 : _this__atlas._addRefCount(value);
19387
+ };
19388
+ /**
19389
+ * @override
19390
+ * @internal
19279
19391
  */ _proto._onDestroy = function _onDestroy() {
19280
- if (this._texture) {
19281
- this._texture = null;
19282
- }
19392
+ this._positions.length = 0;
19393
+ this._positions = null;
19394
+ this._uvs.length = 0;
19395
+ this._uvs = null;
19396
+ this._atlasRegion = null;
19397
+ this._atlasRegionOffset = null;
19398
+ this._region = null;
19399
+ this._pivot = null;
19400
+ this._border = null;
19401
+ this._bounds = null;
19402
+ this._atlas = null;
19403
+ this._texture = null;
19404
+ this._updateFlagManager = null;
19283
19405
  };
19284
19406
  _proto._calDefaultSize = function _calDefaultSize() {
19285
19407
  if (this._texture) {
@@ -19382,7 +19504,7 @@ exports.TextVerticalAlignment = void 0;
19382
19504
  key: "width",
19383
19505
  get: /**
19384
19506
  * The width of the sprite (in world coordinates).
19385
- *
19507
+ *
19386
19508
  * @remarks
19387
19509
  * If width is set, return the set value,
19388
19510
  * otherwise return the width calculated according to `Texture.width`, `Sprite.region`, `Sprite.atlasRegion`, `Sprite.atlasRegionOffset` and `Engine._pixelsPerUnit`.
@@ -19405,7 +19527,7 @@ exports.TextVerticalAlignment = void 0;
19405
19527
  key: "height",
19406
19528
  get: /**
19407
19529
  * The height of the sprite (in world coordinates).
19408
- *
19530
+ *
19409
19531
  * @remarks
19410
19532
  * If height is set, return the set value,
19411
19533
  * otherwise return the height calculated according to `Texture.height`, `Sprite.region`, `Sprite.atlasRegion`, `Sprite.atlasRegionOffset` and `Engine._pixelsPerUnit`.
@@ -19711,17 +19833,6 @@ SlicedSpriteAssembler = __decorate$1([
19711
19833
  target.drawMode = this._drawMode;
19712
19834
  };
19713
19835
  /**
19714
- * @internal
19715
- */ _proto._onDestroy = function _onDestroy() {
19716
- var _this__sprite;
19717
- (_this__sprite = this._sprite) == null ? void 0 : _this__sprite._updateFlagManager.removeListener(this._onSpriteChange);
19718
- this._color = null;
19719
- this._sprite = null;
19720
- this._assembler = null;
19721
- this._renderData = null;
19722
- Renderer.prototype._onDestroy.call(this);
19723
- };
19724
- /**
19725
19836
  * @override
19726
19837
  */ _proto._updateBounds = function _updateBounds(worldBounds) {
19727
19838
  if (this.sprite) {
@@ -19759,6 +19870,20 @@ SlicedSpriteAssembler = __decorate$1([
19759
19870
  context.camera._renderPipeline.pushPrimitive(spriteElement);
19760
19871
  }
19761
19872
  };
19873
+ /**
19874
+ * @internal
19875
+ */ _proto._onDestroy = function _onDestroy() {
19876
+ Renderer.prototype._onDestroy.call(this);
19877
+ var sprite = this._sprite;
19878
+ if (sprite) {
19879
+ sprite._addRefCount(-1);
19880
+ sprite._updateFlagManager.removeListener(this._onSpriteChange);
19881
+ }
19882
+ this._color = null;
19883
+ this._sprite = null;
19884
+ this._assembler = null;
19885
+ this._renderData = null;
19886
+ };
19762
19887
  _proto._calDefaultSize = function _calDefaultSize() {
19763
19888
  var sprite = this._sprite;
19764
19889
  if (sprite) {
@@ -19850,9 +19975,13 @@ SlicedSpriteAssembler = __decorate$1([
19850
19975
  set: function set(value) {
19851
19976
  var lastSprite = this._sprite;
19852
19977
  if (lastSprite !== value) {
19853
- lastSprite && lastSprite._updateFlagManager.removeListener(this._onSpriteChange);
19978
+ if (lastSprite) {
19979
+ lastSprite._addRefCount(-1);
19980
+ lastSprite._updateFlagManager.removeListener(this._onSpriteChange);
19981
+ }
19854
19982
  this._dirtyUpdateFlag |= 0x7;
19855
19983
  if (value) {
19984
+ value._addRefCount(1);
19856
19985
  value._updateFlagManager.addListener(this._onSpriteChange);
19857
19986
  this.shaderData.setTexture(SpriteRenderer._textureProperty, value.texture);
19858
19987
  } else {
@@ -35877,7 +36006,7 @@ function _interopNamespace(e) {
35877
36006
  }
35878
36007
  var CoreObjects__namespace = /*#__PURE__*/ _interopNamespace(CoreObjects);
35879
36008
  //@ts-ignore
35880
- var version = "0.9.11";
36009
+ var version = "0.9.12";
35881
36010
  console.log("Galacean engine version: " + version);
35882
36011
  for(var key in CoreObjects__namespace){
35883
36012
  CoreObjects.Loader.registerClass(key, CoreObjects__namespace[key]);