@galacean/engine 0.0.0-experimental-0.9-plus.6 → 0.0.0-experimental-0.9-plus.7

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
@@ -7468,9 +7468,11 @@
7468
7468
  renderTexture
7469
7469
  ];
7470
7470
  for(var i = 0, n = colorTextures.length; i < n; i++){
7471
- if (colorTextures[i]._isDepthTexture) {
7471
+ var colorTexture = colorTextures[i];
7472
+ if (colorTexture._isDepthTexture) {
7472
7473
  throw "Render texture can't use depth format.";
7473
7474
  }
7475
+ colorTexture._addRefCount(1);
7474
7476
  }
7475
7477
  _this._colorTextures = colorTextures;
7476
7478
  } else {
@@ -7481,6 +7483,7 @@
7481
7483
  throw "Depth texture must use depth format.";
7482
7484
  }
7483
7485
  _this._depthTexture = depth;
7486
+ _this._depthTexture._addRefCount(1);
7484
7487
  }
7485
7488
  _this._platformRenderTarget = engine._hardwareRenderer.createPlatformRenderTarget(_assert_this_initialized(_this));
7486
7489
  return _this;
@@ -7510,8 +7513,14 @@
7510
7513
  /**
7511
7514
  * Destroy render target.
7512
7515
  */ _proto.destroy = function destroy() {
7516
+ var _this__depthTexture;
7513
7517
  this._platformRenderTarget.destroy();
7514
- this._colorTextures.length = 0;
7518
+ var _this = this, colorTextures = _this._colorTextures;
7519
+ for(var i = 0, n = colorTextures.length; i < n; i++){
7520
+ colorTextures[i]._addRefCount(-1);
7521
+ }
7522
+ colorTextures.length = 0;
7523
+ (_this__depthTexture = this._depthTexture) == null ? void 0 : _this__depthTexture._addRefCount(-1);
7515
7524
  this._depthTexture = null;
7516
7525
  this._depth = null;
7517
7526
  };
@@ -7952,6 +7961,7 @@
7952
7961
  var fontAtlas = new FontAtlas(engine);
7953
7962
  var texture = new Texture2D(engine, 256, 256);
7954
7963
  fontAtlas.texture = texture;
7964
+ fontAtlas.isGCIgnored = texture.isGCIgnored = true;
7955
7965
  this._fontAtlases.push(fontAtlas);
7956
7966
  return fontAtlas;
7957
7967
  };
@@ -13427,6 +13437,7 @@
13427
13437
  _proto.cloneTo = function cloneTo(target) {
13428
13438
  CloneManager.deepCloneObject(this._macroCollection, target._macroCollection);
13429
13439
  Object.assign(target._macroMap, this._macroMap);
13440
+ var referCount = target._getRefCount();
13430
13441
  var propertyValueMap = this._propertyValueMap;
13431
13442
  var targetPropertyValueMap = target._propertyValueMap;
13432
13443
  var keys = Object.keys(propertyValueMap);
@@ -13438,6 +13449,7 @@
13438
13449
  targetPropertyValueMap[k] = property;
13439
13450
  } else if (_instanceof1$2(property, Texture)) {
13440
13451
  targetPropertyValueMap[k] = property;
13452
+ referCount > 0 && property._addRefCount(referCount);
13441
13453
  } else if (_instanceof1$2(property, Array) || _instanceof1$2(property, Float32Array) || _instanceof1$2(property, Int32Array)) {
13442
13454
  targetPropertyValueMap[k] = property.slice();
13443
13455
  } else {
@@ -15154,16 +15166,6 @@
15154
15166
  }
15155
15167
  var _proto = SpriteMask.prototype;
15156
15168
  /**
15157
- * @override
15158
- * @inheritdoc
15159
- */ _proto._onDestroy = function _onDestroy() {
15160
- var _this__sprite;
15161
- (_this__sprite = this._sprite) == null ? void 0 : _this__sprite._updateFlagManager.removeListener(this._onSpriteChange);
15162
- this._sprite = null;
15163
- this._renderData = null;
15164
- Renderer.prototype._onDestroy.call(this);
15165
- };
15166
- /**
15167
15169
  * @internal
15168
15170
  */ _proto._cloneTo = function _cloneTo(target) {
15169
15171
  Renderer.prototype._cloneTo.call(this, target);
@@ -15203,6 +15205,19 @@
15203
15205
  context.camera._renderPipeline._allSpriteMasks.add(this);
15204
15206
  this._maskElement = maskElement;
15205
15207
  };
15208
+ /**
15209
+ * @internal
15210
+ * @inheritdoc
15211
+ */ _proto._onDestroy = function _onDestroy() {
15212
+ Renderer.prototype._onDestroy.call(this);
15213
+ var sprite = this._sprite;
15214
+ if (sprite) {
15215
+ sprite._addRefCount(-1);
15216
+ sprite._updateFlagManager.removeListener(this._onSpriteChange);
15217
+ }
15218
+ this._sprite = null;
15219
+ this._renderData = null;
15220
+ };
15206
15221
  _proto._calDefaultSize = function _calDefaultSize() {
15207
15222
  var sprite = this._sprite;
15208
15223
  if (sprite) {
@@ -15321,9 +15336,13 @@
15321
15336
  set: function set(value) {
15322
15337
  var lastSprite = this._sprite;
15323
15338
  if (lastSprite !== value) {
15324
- lastSprite && lastSprite._updateFlagManager.removeListener(this._onSpriteChange);
15339
+ if (lastSprite) {
15340
+ lastSprite._addRefCount(-1);
15341
+ lastSprite._updateFlagManager.removeListener(this._onSpriteChange);
15342
+ }
15325
15343
  this._dirtyUpdateFlag |= 0x7;
15326
15344
  if (value) {
15345
+ value._addRefCount(1);
15327
15346
  value._updateFlagManager.addListener(this._onSpriteChange);
15328
15347
  this.shaderData.setTexture(SpriteMask._textureProperty, value.texture);
15329
15348
  } else {
@@ -15878,10 +15897,11 @@
15878
15897
  /**
15879
15898
  * @internal
15880
15899
  */ _proto._setVertexBufferBinding = function _setVertexBufferBinding(index, binding) {
15881
- if (this._getRefCount() > 0) {
15882
- var lastBinding = this._vertexBufferBindings[index];
15883
- lastBinding && lastBinding._buffer._addRefCount(-1);
15884
- binding._buffer._addRefCount(1);
15900
+ var referCount = this._getRefCount();
15901
+ if (referCount > 0) {
15902
+ var _this__vertexBufferBindings_index;
15903
+ (_this__vertexBufferBindings_index = this._vertexBufferBindings[index]) == null ? void 0 : _this__vertexBufferBindings_index._buffer._addRefCount(-referCount);
15904
+ binding == null ? void 0 : binding._buffer._addRefCount(referCount);
15885
15905
  }
15886
15906
  this._vertexBufferBindings[index] = binding;
15887
15907
  this._bufferStructChanged = true;
@@ -15895,11 +15915,13 @@
15895
15915
  /**
15896
15916
  * @override
15897
15917
  */ _proto._addRefCount = function _addRefCount(value) {
15918
+ var _this__indexBufferBinding;
15898
15919
  RefObject.prototype._addRefCount.call(this, value);
15899
15920
  var vertexBufferBindings = this._vertexBufferBindings;
15900
15921
  for(var i = 0, n = vertexBufferBindings.length; i < n; i++){
15901
15922
  vertexBufferBindings[i]._buffer._addRefCount(value);
15902
15923
  }
15924
+ (_this__indexBufferBinding = this._indexBufferBinding) == null ? void 0 : _this__indexBufferBinding._buffer._addRefCount(value);
15903
15925
  };
15904
15926
  /**
15905
15927
  * @override
@@ -15919,6 +15941,11 @@
15919
15941
  };
15920
15942
  _proto._setIndexBufferBinding = function _setIndexBufferBinding(binding) {
15921
15943
  var lastBinding = this._indexBufferBinding;
15944
+ var referCount = this._getRefCount();
15945
+ if (referCount > 0) {
15946
+ lastBinding == null ? void 0 : lastBinding.buffer._addRefCount(-referCount);
15947
+ binding == null ? void 0 : binding.buffer._addRefCount(referCount);
15948
+ }
15922
15949
  if (binding) {
15923
15950
  this._indexBufferBinding = binding;
15924
15951
  this._glIndexType = BufferUtil._getGLIndexType(binding.format);
@@ -19078,14 +19105,17 @@
19078
19105
  _proto._createMesh = function _createMesh(engine, index) {
19079
19106
  var MAX_VERTEX_COUNT = Basic2DBatcher.MAX_VERTEX_COUNT;
19080
19107
  var mesh = new BufferMesh(engine, "BufferMesh" + index);
19108
+ mesh.isGCIgnored = true;
19081
19109
  var vertexElements = [];
19082
19110
  var vertexStride = this.createVertexElements(vertexElements);
19083
19111
  // vertices
19084
- this._vertexBuffers[index] = new Buffer(engine, exports.BufferBindFlag.VertexBuffer, MAX_VERTEX_COUNT * 4 * vertexStride, exports.BufferUsage.Dynamic);
19112
+ var vertexBuffer = this._vertexBuffers[index] = new Buffer(engine, exports.BufferBindFlag.VertexBuffer, MAX_VERTEX_COUNT * 4 * vertexStride, exports.BufferUsage.Dynamic);
19113
+ vertexBuffer.isGCIgnored = true;
19085
19114
  // indices
19086
- this._indiceBuffers[index] = new Buffer(engine, exports.BufferBindFlag.IndexBuffer, MAX_VERTEX_COUNT * 2 * 3, exports.BufferUsage.Dynamic);
19087
- mesh.setVertexBufferBinding(this._vertexBuffers[index], vertexStride);
19088
- mesh.setIndexBufferBinding(this._indiceBuffers[index], exports.IndexFormat.UInt16);
19115
+ var indiceBuffer = this._indiceBuffers[index] = new Buffer(engine, exports.BufferBindFlag.IndexBuffer, MAX_VERTEX_COUNT * 2 * 3, exports.BufferUsage.Dynamic);
19116
+ indiceBuffer.isGCIgnored = true;
19117
+ mesh.setVertexBufferBinding(vertexBuffer, vertexStride);
19118
+ mesh.setIndexBufferBinding(indiceBuffer, exports.IndexFormat.UInt16);
19089
19119
  mesh.setVertexElements(vertexElements);
19090
19120
  return mesh;
19091
19121
  };
@@ -19318,6 +19348,12 @@
19318
19348
  var _proto = Sky.prototype;
19319
19349
  /**
19320
19350
  * @internal
19351
+ */ _proto.destroy = function destroy() {
19352
+ this.mesh = null;
19353
+ this.material = null;
19354
+ };
19355
+ /**
19356
+ * @internal
19321
19357
  */ _proto._render = function _render(context) {
19322
19358
  var _this = this, material = _this.material, mesh = _this.mesh;
19323
19359
  if (!material) {
@@ -19356,6 +19392,40 @@
19356
19392
  rhi.drawPrimitive(mesh, mesh.subMesh, program);
19357
19393
  cameraShaderData.setMatrix(RenderContext._vpMatrixProperty, originViewProjMatrix);
19358
19394
  };
19395
+ _create_class$3(Sky, [
19396
+ {
19397
+ key: "material",
19398
+ get: /**
19399
+ * Material of the sky.
19400
+ */ function get() {
19401
+ return this._material;
19402
+ },
19403
+ set: function set(value) {
19404
+ if (this._material !== value) {
19405
+ var _this__material;
19406
+ value == null ? void 0 : value._addRefCount(1);
19407
+ (_this__material = this._material) == null ? void 0 : _this__material._addRefCount(-1);
19408
+ this._material = value;
19409
+ }
19410
+ }
19411
+ },
19412
+ {
19413
+ key: "mesh",
19414
+ get: /**
19415
+ * Mesh of the sky.
19416
+ */ function get() {
19417
+ return this._mesh;
19418
+ },
19419
+ set: function set(value) {
19420
+ if (this._mesh !== value) {
19421
+ var _this__mesh;
19422
+ value == null ? void 0 : value._addRefCount(1);
19423
+ (_this__mesh = this._mesh) == null ? void 0 : _this__mesh._addRefCount(-1);
19424
+ this._mesh = value;
19425
+ }
19426
+ }
19427
+ }
19428
+ ]);
19359
19429
  return Sky;
19360
19430
  }();
19361
19431
  (function() {
@@ -19385,11 +19455,28 @@
19385
19455
  this.sky = new Sky();
19386
19456
  this./** @internal */ _textureFillMode = exports.BackgroundTextureFillMode.AspectFitHeight;
19387
19457
  this._texture = null;
19388
- this._mesh = this._createPlane(_engine);
19458
+ this._initMesh(_engine);
19389
19459
  };
19390
19460
  var _proto = Background.prototype;
19391
19461
  /**
19392
19462
  * @internal
19463
+ */ _proto.destroy = function destroy() {
19464
+ this._mesh._addRefCount(-1);
19465
+ this._mesh = null;
19466
+ this.texture = null;
19467
+ this.solidColor = null;
19468
+ this.sky.destroy();
19469
+ this._engine = null;
19470
+ };
19471
+ /**
19472
+ * @internal
19473
+ * Standalone for CanvasRenderer plugin.
19474
+ */ _proto._initMesh = function _initMesh(engine) {
19475
+ this._mesh = this._createPlane(engine);
19476
+ this._mesh._addRefCount(1);
19477
+ };
19478
+ /**
19479
+ * @internal
19393
19480
  */ _proto._resizeBackgroundTexture = function _resizeBackgroundTexture() {
19394
19481
  if (!this._texture) {
19395
19482
  return;
@@ -19458,6 +19545,9 @@
19458
19545
  },
19459
19546
  set: function set(value) {
19460
19547
  if (this._texture !== value) {
19548
+ var _this__texture;
19549
+ value == null ? void 0 : value._addRefCount(1);
19550
+ (_this__texture = this._texture) == null ? void 0 : _this__texture._addRefCount(-1);
19461
19551
  this._texture = value;
19462
19552
  this._engine._backgroundTextureMaterial.shaderData.setTexture("u_baseTexture", value);
19463
19553
  }
@@ -19966,6 +20056,7 @@
19966
20056
  this._rootEntities[0].destroy();
19967
20057
  }
19968
20058
  this._activeCameras.length = 0;
20059
+ this.background.destroy();
19969
20060
  this.shaderData._addRefCount(-1);
19970
20061
  };
19971
20062
  _proto._addToRootEntityList = function _addToRootEntityList(index, rootEntity) {
@@ -20362,7 +20453,7 @@
20362
20453
  _this._spriteDefaultMaterial = _this._createSpriteMaterial();
20363
20454
  _this._spriteMaskDefaultMaterial = _this._createSpriteMaskMaterial();
20364
20455
  _this._textDefaultFont = Font.createFromOS(_assert_this_initialized(_this), "Arial");
20365
- _this._textDefaultFont.isGCIgnored = false;
20456
+ _this._textDefaultFont.isGCIgnored = true;
20366
20457
  _this.inputManager = new InputManager(_assert_this_initialized(_this));
20367
20458
  var magentaPixel = new Uint8Array([
20368
20459
  255,
@@ -20397,6 +20488,7 @@
20397
20488
  _this._magentaTexture2DArray = magentaTexture2DArray;
20398
20489
  }
20399
20490
  var magentaMaterial = new Material(_assert_this_initialized(_this), Shader.find("unlit"));
20491
+ magentaMaterial.isGCIgnored = true;
20400
20492
  magentaMaterial.shaderData.setColor("u_baseColor", new Color(1.0, 0.0, 1.01, 1.0));
20401
20493
  _this._magentaMaterial = magentaMaterial;
20402
20494
  var backgroundTextureMaterial = new Material(_assert_this_initialized(_this), Shader.find("background-texture"));
@@ -21922,7 +22014,11 @@
21922
22014
  var height = shadowCascades == exports.ShadowCascadesMode.TwoCascades ? shadowTileResolution : shadowTileResolution * 2;
21923
22015
  this._shadowMapSize.set(1.0 / width, 1.0 / height, width, height);
21924
22016
  }
21925
- this._renderTargets = null;
22017
+ var renderTargets = this._renderTargets;
22018
+ if (renderTargets) {
22019
+ renderTargets.destroy();
22020
+ this._renderTargets = null;
22021
+ }
21926
22022
  var viewportOffset = this._viewportOffsets;
21927
22023
  var shadowTileResolution1 = this._shadowTileResolution;
21928
22024
  switch(shadowCascades){
@@ -23944,10 +24040,17 @@
23944
24040
  * @internal
23945
24041
  */ _proto._addSprite = function _addSprite(sprite) {
23946
24042
  this._spriteNamesToIndex[sprite.name] = this._sprites.push(sprite) - 1;
24043
+ sprite._atlas = this;
24044
+ sprite.isGCIgnored = true;
23947
24045
  };
23948
24046
  /**
23949
24047
  * @override
23950
24048
  */ _proto._onDestroy = function _onDestroy() {
24049
+ var _this = this, sprites = _this._sprites;
24050
+ for(var i = 0, n = sprites.length; i < n; i++){
24051
+ sprites[i].destroy();
24052
+ }
24053
+ sprites.length = 0;
23951
24054
  this._sprites = null;
23952
24055
  this._spriteNamesToIndex = null;
23953
24056
  };
@@ -24046,10 +24149,29 @@
24046
24149
  };
24047
24150
  /**
24048
24151
  * @override
24152
+ * @internal
24153
+ */ _proto._addRefCount = function _addRefCount(value) {
24154
+ var _this__atlas;
24155
+ RefObject.prototype._addRefCount.call(this, value);
24156
+ (_this__atlas = this._atlas) == null ? void 0 : _this__atlas._addRefCount(value);
24157
+ };
24158
+ /**
24159
+ * @override
24160
+ * @internal
24049
24161
  */ _proto._onDestroy = function _onDestroy() {
24050
- if (this._texture) {
24051
- this._texture = null;
24052
- }
24162
+ this._positions.length = 0;
24163
+ this._positions = null;
24164
+ this._uvs.length = 0;
24165
+ this._uvs = null;
24166
+ this._atlasRegion = null;
24167
+ this._atlasRegionOffset = null;
24168
+ this._region = null;
24169
+ this._pivot = null;
24170
+ this._border = null;
24171
+ this._bounds = null;
24172
+ this._atlas = null;
24173
+ this._texture = null;
24174
+ this._updateFlagManager = null;
24053
24175
  };
24054
24176
  _proto._calDefaultSize = function _calDefaultSize() {
24055
24177
  if (this._texture) {
@@ -24152,7 +24274,7 @@
24152
24274
  key: "width",
24153
24275
  get: /**
24154
24276
  * The width of the sprite (in world coordinates).
24155
- *
24277
+ *
24156
24278
  * @remarks
24157
24279
  * If width is set, return the set value,
24158
24280
  * otherwise return the width calculated according to `Texture.width`, `Sprite.region`, `Sprite.atlasRegion`, `Sprite.atlasRegionOffset` and `Engine._pixelsPerUnit`.
@@ -24175,7 +24297,7 @@
24175
24297
  key: "height",
24176
24298
  get: /**
24177
24299
  * The height of the sprite (in world coordinates).
24178
- *
24300
+ *
24179
24301
  * @remarks
24180
24302
  * If height is set, return the set value,
24181
24303
  * otherwise return the height calculated according to `Texture.height`, `Sprite.region`, `Sprite.atlasRegion`, `Sprite.atlasRegionOffset` and `Engine._pixelsPerUnit`.
@@ -24481,17 +24603,6 @@
24481
24603
  target.drawMode = this._drawMode;
24482
24604
  };
24483
24605
  /**
24484
- * @internal
24485
- */ _proto._onDestroy = function _onDestroy() {
24486
- var _this__sprite;
24487
- (_this__sprite = this._sprite) == null ? void 0 : _this__sprite._updateFlagManager.removeListener(this._onSpriteChange);
24488
- this._color = null;
24489
- this._sprite = null;
24490
- this._assembler = null;
24491
- this._renderData = null;
24492
- Renderer.prototype._onDestroy.call(this);
24493
- };
24494
- /**
24495
24606
  * @override
24496
24607
  */ _proto._updateBounds = function _updateBounds(worldBounds) {
24497
24608
  if (this.sprite) {
@@ -24529,6 +24640,20 @@
24529
24640
  context.camera._renderPipeline.pushPrimitive(spriteElement);
24530
24641
  }
24531
24642
  };
24643
+ /**
24644
+ * @internal
24645
+ */ _proto._onDestroy = function _onDestroy() {
24646
+ Renderer.prototype._onDestroy.call(this);
24647
+ var sprite = this._sprite;
24648
+ if (sprite) {
24649
+ sprite._addRefCount(-1);
24650
+ sprite._updateFlagManager.removeListener(this._onSpriteChange);
24651
+ }
24652
+ this._color = null;
24653
+ this._sprite = null;
24654
+ this._assembler = null;
24655
+ this._renderData = null;
24656
+ };
24532
24657
  _proto._calDefaultSize = function _calDefaultSize() {
24533
24658
  var sprite = this._sprite;
24534
24659
  if (sprite) {
@@ -24620,9 +24745,13 @@
24620
24745
  set: function set(value) {
24621
24746
  var lastSprite = this._sprite;
24622
24747
  if (lastSprite !== value) {
24623
- lastSprite && lastSprite._updateFlagManager.removeListener(this._onSpriteChange);
24748
+ if (lastSprite) {
24749
+ lastSprite._addRefCount(-1);
24750
+ lastSprite._updateFlagManager.removeListener(this._onSpriteChange);
24751
+ }
24624
24752
  this._dirtyUpdateFlag |= 0x7;
24625
24753
  if (value) {
24754
+ value._addRefCount(1);
24626
24755
  value._updateFlagManager.addListener(this._onSpriteChange);
24627
24756
  this.shaderData.setTexture(SpriteRenderer._textureProperty, value.texture);
24628
24757
  } else {
@@ -36131,7 +36260,7 @@
36131
36260
  ], OasisMaterialsRemap);
36132
36261
 
36133
36262
  //@ts-ignore
36134
- var version = "0.0.0-experimental-0.9-plus.6";
36263
+ var version = "0.0.0-experimental-0.9-plus.7";
36135
36264
  console.log("Galacean engine version: " + version);
36136
36265
  for(var key in CoreObjects){
36137
36266
  Loader.registerClass(key, CoreObjects[key]);