@galacean/engine-physics-lite 0.0.0-experimental-0.9-plus.5 → 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.
@@ -2734,9 +2734,11 @@ function ObjectValues(obj) {
2734
2734
  renderTexture
2735
2735
  ];
2736
2736
  for(var i = 0, n = colorTextures.length; i < n; i++){
2737
- if (colorTextures[i]._isDepthTexture) {
2737
+ var colorTexture = colorTextures[i];
2738
+ if (colorTexture._isDepthTexture) {
2738
2739
  throw "Render texture can't use depth format.";
2739
2740
  }
2741
+ colorTexture._addRefCount(1);
2740
2742
  }
2741
2743
  _this._colorTextures = colorTextures;
2742
2744
  } else {
@@ -2747,6 +2749,7 @@ function ObjectValues(obj) {
2747
2749
  throw "Depth texture must use depth format.";
2748
2750
  }
2749
2751
  _this._depthTexture = depth;
2752
+ _this._depthTexture._addRefCount(1);
2750
2753
  }
2751
2754
  _this._platformRenderTarget = engine._hardwareRenderer.createPlatformRenderTarget(_assert_this_initialized(_this));
2752
2755
  return _this;
@@ -2776,8 +2779,14 @@ function ObjectValues(obj) {
2776
2779
  /**
2777
2780
  * Destroy render target.
2778
2781
  */ _proto.destroy = function destroy() {
2782
+ var _this__depthTexture;
2779
2783
  this._platformRenderTarget.destroy();
2780
- this._colorTextures.length = 0;
2784
+ var _this = this, colorTextures = _this._colorTextures;
2785
+ for(var i = 0, n = colorTextures.length; i < n; i++){
2786
+ colorTextures[i]._addRefCount(-1);
2787
+ }
2788
+ colorTextures.length = 0;
2789
+ (_this__depthTexture = this._depthTexture) == null ? void 0 : _this__depthTexture._addRefCount(-1);
2781
2790
  this._depthTexture = null;
2782
2791
  this._depth = null;
2783
2792
  };
@@ -3218,6 +3227,7 @@ function ObjectValues(obj) {
3218
3227
  var fontAtlas = new FontAtlas(engine);
3219
3228
  var texture = new Texture2D(engine, 256, 256);
3220
3229
  fontAtlas.texture = texture;
3230
+ fontAtlas.isGCIgnored = texture.isGCIgnored = true;
3221
3231
  this._fontAtlases.push(fontAtlas);
3222
3232
  return fontAtlas;
3223
3233
  };
@@ -8693,6 +8703,7 @@ exports.DynamicColliderConstraints = void 0;
8693
8703
  _proto.cloneTo = function cloneTo(target) {
8694
8704
  CloneManager.deepCloneObject(this._macroCollection, target._macroCollection);
8695
8705
  Object.assign(target._macroMap, this._macroMap);
8706
+ var referCount = target._getRefCount();
8696
8707
  var propertyValueMap = this._propertyValueMap;
8697
8708
  var targetPropertyValueMap = target._propertyValueMap;
8698
8709
  var keys = Object.keys(propertyValueMap);
@@ -8704,6 +8715,7 @@ exports.DynamicColliderConstraints = void 0;
8704
8715
  targetPropertyValueMap[k] = property;
8705
8716
  } else if (_instanceof1$2(property, Texture)) {
8706
8717
  targetPropertyValueMap[k] = property;
8718
+ referCount > 0 && property._addRefCount(referCount);
8707
8719
  } else if (_instanceof1$2(property, Array) || _instanceof1$2(property, Float32Array) || _instanceof1$2(property, Int32Array)) {
8708
8720
  targetPropertyValueMap[k] = property.slice();
8709
8721
  } else {
@@ -10031,6 +10043,14 @@ exports.Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10031
10043
  };
10032
10044
  /**
10033
10045
  * @internal
10046
+ */ _proto._cloneTo = function _cloneTo(target) {
10047
+ var materials = this._materials;
10048
+ for(var i = 0, n = materials.length; i < n; i++){
10049
+ target._setMaterial(i, materials[i]);
10050
+ }
10051
+ };
10052
+ /**
10053
+ * @internal
10034
10054
  */ _proto._onDestroy = function _onDestroy() {
10035
10055
  this.entity.transform._updateFlagManager.removeListener(this._onTransformChanged);
10036
10056
  this.shaderData._addRefCount(-1);
@@ -10209,7 +10229,7 @@ __decorate$1([
10209
10229
  ignoreClone
10210
10230
  ], exports.Renderer.prototype, "_overrideUpdate", void 0);
10211
10231
  __decorate$1([
10212
- shallowClone
10232
+ ignoreClone
10213
10233
  ], exports.Renderer.prototype, "_materials", void 0);
10214
10234
  __decorate$1([
10215
10235
  ignoreClone
@@ -10412,18 +10432,9 @@ SimpleSpriteAssembler = __decorate$1([
10412
10432
  }
10413
10433
  var _proto = SpriteMask.prototype;
10414
10434
  /**
10415
- * @override
10416
- * @inheritdoc
10417
- */ _proto._onDestroy = function _onDestroy() {
10418
- var _this__sprite;
10419
- (_this__sprite = this._sprite) == null ? void 0 : _this__sprite._updateFlagManager.removeListener(this._onSpriteChange);
10420
- this._sprite = null;
10421
- this._renderData = null;
10422
- Renderer.prototype._onDestroy.call(this);
10423
- };
10424
- /**
10425
10435
  * @internal
10426
10436
  */ _proto._cloneTo = function _cloneTo(target) {
10437
+ Renderer.prototype._cloneTo.call(this, target);
10427
10438
  target.sprite = this._sprite;
10428
10439
  };
10429
10440
  /**
@@ -10460,6 +10471,19 @@ SimpleSpriteAssembler = __decorate$1([
10460
10471
  context.camera._renderPipeline._allSpriteMasks.add(this);
10461
10472
  this._maskElement = maskElement;
10462
10473
  };
10474
+ /**
10475
+ * @internal
10476
+ * @inheritdoc
10477
+ */ _proto._onDestroy = function _onDestroy() {
10478
+ Renderer.prototype._onDestroy.call(this);
10479
+ var sprite = this._sprite;
10480
+ if (sprite) {
10481
+ sprite._addRefCount(-1);
10482
+ sprite._updateFlagManager.removeListener(this._onSpriteChange);
10483
+ }
10484
+ this._sprite = null;
10485
+ this._renderData = null;
10486
+ };
10463
10487
  _proto._calDefaultSize = function _calDefaultSize() {
10464
10488
  var sprite = this._sprite;
10465
10489
  if (sprite) {
@@ -10578,9 +10602,13 @@ SimpleSpriteAssembler = __decorate$1([
10578
10602
  set: function set(value) {
10579
10603
  var lastSprite = this._sprite;
10580
10604
  if (lastSprite !== value) {
10581
- lastSprite && lastSprite._updateFlagManager.removeListener(this._onSpriteChange);
10605
+ if (lastSprite) {
10606
+ lastSprite._addRefCount(-1);
10607
+ lastSprite._updateFlagManager.removeListener(this._onSpriteChange);
10608
+ }
10582
10609
  this._dirtyUpdateFlag |= 0x7;
10583
10610
  if (value) {
10611
+ value._addRefCount(1);
10584
10612
  value._updateFlagManager.addListener(this._onSpriteChange);
10585
10613
  this.shaderData.setTexture(SpriteMask._textureProperty, value.texture);
10586
10614
  } else {
@@ -11135,10 +11163,11 @@ var BufferUtil = /*#__PURE__*/ function() {
11135
11163
  /**
11136
11164
  * @internal
11137
11165
  */ _proto._setVertexBufferBinding = function _setVertexBufferBinding(index, binding) {
11138
- if (this._getRefCount() > 0) {
11139
- var lastBinding = this._vertexBufferBindings[index];
11140
- lastBinding && lastBinding._buffer._addRefCount(-1);
11141
- binding._buffer._addRefCount(1);
11166
+ var referCount = this._getRefCount();
11167
+ if (referCount > 0) {
11168
+ var _this__vertexBufferBindings_index;
11169
+ (_this__vertexBufferBindings_index = this._vertexBufferBindings[index]) == null ? void 0 : _this__vertexBufferBindings_index._buffer._addRefCount(-referCount);
11170
+ binding == null ? void 0 : binding._buffer._addRefCount(referCount);
11142
11171
  }
11143
11172
  this._vertexBufferBindings[index] = binding;
11144
11173
  this._bufferStructChanged = true;
@@ -11152,11 +11181,13 @@ var BufferUtil = /*#__PURE__*/ function() {
11152
11181
  /**
11153
11182
  * @override
11154
11183
  */ _proto._addRefCount = function _addRefCount(value) {
11184
+ var _this__indexBufferBinding;
11155
11185
  RefObject.prototype._addRefCount.call(this, value);
11156
11186
  var vertexBufferBindings = this._vertexBufferBindings;
11157
11187
  for(var i = 0, n = vertexBufferBindings.length; i < n; i++){
11158
11188
  vertexBufferBindings[i]._buffer._addRefCount(value);
11159
11189
  }
11190
+ (_this__indexBufferBinding = this._indexBufferBinding) == null ? void 0 : _this__indexBufferBinding._buffer._addRefCount(value);
11160
11191
  };
11161
11192
  /**
11162
11193
  * @override
@@ -11176,6 +11207,11 @@ var BufferUtil = /*#__PURE__*/ function() {
11176
11207
  };
11177
11208
  _proto._setIndexBufferBinding = function _setIndexBufferBinding(binding) {
11178
11209
  var lastBinding = this._indexBufferBinding;
11210
+ var referCount = this._getRefCount();
11211
+ if (referCount > 0) {
11212
+ lastBinding == null ? void 0 : lastBinding.buffer._addRefCount(-referCount);
11213
+ binding == null ? void 0 : binding.buffer._addRefCount(referCount);
11214
+ }
11179
11215
  if (binding) {
11180
11216
  this._indexBufferBinding = binding;
11181
11217
  this._glIndexType = BufferUtil._getGLIndexType(binding.format);
@@ -12849,6 +12885,7 @@ var VertexChangedFlags;
12849
12885
  /**
12850
12886
  * @internal
12851
12887
  */ _proto._cloneTo = function _cloneTo(target) {
12888
+ Renderer.prototype._cloneTo.call(this, target);
12852
12889
  target.mesh = this._mesh;
12853
12890
  };
12854
12891
  /**
@@ -14334,14 +14371,17 @@ var Basic2DBatcher = /*#__PURE__*/ function() {
14334
14371
  _proto._createMesh = function _createMesh(engine, index) {
14335
14372
  var MAX_VERTEX_COUNT = Basic2DBatcher.MAX_VERTEX_COUNT;
14336
14373
  var mesh = new BufferMesh(engine, "BufferMesh" + index);
14374
+ mesh.isGCIgnored = true;
14337
14375
  var vertexElements = [];
14338
14376
  var vertexStride = this.createVertexElements(vertexElements);
14339
14377
  // vertices
14340
- this._vertexBuffers[index] = new Buffer(engine, exports.BufferBindFlag.VertexBuffer, MAX_VERTEX_COUNT * 4 * vertexStride, exports.BufferUsage.Dynamic);
14378
+ var vertexBuffer = this._vertexBuffers[index] = new Buffer(engine, exports.BufferBindFlag.VertexBuffer, MAX_VERTEX_COUNT * 4 * vertexStride, exports.BufferUsage.Dynamic);
14379
+ vertexBuffer.isGCIgnored = true;
14341
14380
  // indices
14342
- this._indiceBuffers[index] = new Buffer(engine, exports.BufferBindFlag.IndexBuffer, MAX_VERTEX_COUNT * 2 * 3, exports.BufferUsage.Dynamic);
14343
- mesh.setVertexBufferBinding(this._vertexBuffers[index], vertexStride);
14344
- mesh.setIndexBufferBinding(this._indiceBuffers[index], exports.IndexFormat.UInt16);
14381
+ var indiceBuffer = this._indiceBuffers[index] = new Buffer(engine, exports.BufferBindFlag.IndexBuffer, MAX_VERTEX_COUNT * 2 * 3, exports.BufferUsage.Dynamic);
14382
+ indiceBuffer.isGCIgnored = true;
14383
+ mesh.setVertexBufferBinding(vertexBuffer, vertexStride);
14384
+ mesh.setIndexBufferBinding(indiceBuffer, exports.IndexFormat.UInt16);
14345
14385
  mesh.setVertexElements(vertexElements);
14346
14386
  return mesh;
14347
14387
  };
@@ -14574,6 +14614,12 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
14574
14614
  var _proto = Sky.prototype;
14575
14615
  /**
14576
14616
  * @internal
14617
+ */ _proto.destroy = function destroy() {
14618
+ this.mesh = null;
14619
+ this.material = null;
14620
+ };
14621
+ /**
14622
+ * @internal
14577
14623
  */ _proto._render = function _render(context) {
14578
14624
  var _this = this, material = _this.material, mesh = _this.mesh;
14579
14625
  if (!material) {
@@ -14612,6 +14658,40 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
14612
14658
  rhi.drawPrimitive(mesh, mesh.subMesh, program);
14613
14659
  cameraShaderData.setMatrix(RenderContext._vpMatrixProperty, originViewProjMatrix);
14614
14660
  };
14661
+ _create_class$2(Sky, [
14662
+ {
14663
+ key: "material",
14664
+ get: /**
14665
+ * Material of the sky.
14666
+ */ function get() {
14667
+ return this._material;
14668
+ },
14669
+ set: function set(value) {
14670
+ if (this._material !== value) {
14671
+ var _this__material;
14672
+ value == null ? void 0 : value._addRefCount(1);
14673
+ (_this__material = this._material) == null ? void 0 : _this__material._addRefCount(-1);
14674
+ this._material = value;
14675
+ }
14676
+ }
14677
+ },
14678
+ {
14679
+ key: "mesh",
14680
+ get: /**
14681
+ * Mesh of the sky.
14682
+ */ function get() {
14683
+ return this._mesh;
14684
+ },
14685
+ set: function set(value) {
14686
+ if (this._mesh !== value) {
14687
+ var _this__mesh;
14688
+ value == null ? void 0 : value._addRefCount(1);
14689
+ (_this__mesh = this._mesh) == null ? void 0 : _this__mesh._addRefCount(-1);
14690
+ this._mesh = value;
14691
+ }
14692
+ }
14693
+ }
14694
+ ]);
14615
14695
  return Sky;
14616
14696
  }();
14617
14697
  (function() {
@@ -14641,11 +14721,28 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
14641
14721
  this.sky = new Sky();
14642
14722
  this./** @internal */ _textureFillMode = exports.BackgroundTextureFillMode.AspectFitHeight;
14643
14723
  this._texture = null;
14644
- this._mesh = this._createPlane(_engine);
14724
+ this._initMesh(_engine);
14645
14725
  };
14646
14726
  var _proto = Background.prototype;
14647
14727
  /**
14648
14728
  * @internal
14729
+ */ _proto.destroy = function destroy() {
14730
+ this._mesh._addRefCount(-1);
14731
+ this._mesh = null;
14732
+ this.texture = null;
14733
+ this.solidColor = null;
14734
+ this.sky.destroy();
14735
+ this._engine = null;
14736
+ };
14737
+ /**
14738
+ * @internal
14739
+ * Standalone for CanvasRenderer plugin.
14740
+ */ _proto._initMesh = function _initMesh(engine) {
14741
+ this._mesh = this._createPlane(engine);
14742
+ this._mesh._addRefCount(1);
14743
+ };
14744
+ /**
14745
+ * @internal
14649
14746
  */ _proto._resizeBackgroundTexture = function _resizeBackgroundTexture() {
14650
14747
  if (!this._texture) {
14651
14748
  return;
@@ -14714,6 +14811,9 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
14714
14811
  },
14715
14812
  set: function set(value) {
14716
14813
  if (this._texture !== value) {
14814
+ var _this__texture;
14815
+ value == null ? void 0 : value._addRefCount(1);
14816
+ (_this__texture = this._texture) == null ? void 0 : _this__texture._addRefCount(-1);
14717
14817
  this._texture = value;
14718
14818
  this._engine._backgroundTextureMaterial.shaderData.setTexture("u_baseTexture", value);
14719
14819
  }
@@ -15222,6 +15322,7 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
15222
15322
  this._rootEntities[0].destroy();
15223
15323
  }
15224
15324
  this._activeCameras.length = 0;
15325
+ this.background.destroy();
15225
15326
  this.shaderData._addRefCount(-1);
15226
15327
  };
15227
15328
  _proto._addToRootEntityList = function _addToRootEntityList(index, rootEntity) {
@@ -15618,7 +15719,7 @@ ShaderPool.init();
15618
15719
  _this._spriteDefaultMaterial = _this._createSpriteMaterial();
15619
15720
  _this._spriteMaskDefaultMaterial = _this._createSpriteMaskMaterial();
15620
15721
  _this._textDefaultFont = Font.createFromOS(_assert_this_initialized(_this), "Arial");
15621
- _this._textDefaultFont.isGCIgnored = false;
15722
+ _this._textDefaultFont.isGCIgnored = true;
15622
15723
  _this.inputManager = new InputManager(_assert_this_initialized(_this));
15623
15724
  var magentaPixel = new Uint8Array([
15624
15725
  255,
@@ -15653,6 +15754,7 @@ ShaderPool.init();
15653
15754
  _this._magentaTexture2DArray = magentaTexture2DArray;
15654
15755
  }
15655
15756
  var magentaMaterial = new Material(_assert_this_initialized(_this), Shader.find("unlit"));
15757
+ magentaMaterial.isGCIgnored = true;
15656
15758
  magentaMaterial.shaderData.setColor("u_baseColor", new Color(1.0, 0.0, 1.01, 1.0));
15657
15759
  _this._magentaMaterial = magentaMaterial;
15658
15760
  var backgroundTextureMaterial = new Material(_assert_this_initialized(_this), Shader.find("background-texture"));
@@ -17178,7 +17280,11 @@ var /**
17178
17280
  var height = shadowCascades == exports.ShadowCascadesMode.TwoCascades ? shadowTileResolution : shadowTileResolution * 2;
17179
17281
  this._shadowMapSize.set(1.0 / width, 1.0 / height, width, height);
17180
17282
  }
17181
- this._renderTargets = null;
17283
+ var renderTargets = this._renderTargets;
17284
+ if (renderTargets) {
17285
+ renderTargets.destroy();
17286
+ this._renderTargets = null;
17287
+ }
17182
17288
  var viewportOffset = this._viewportOffsets;
17183
17289
  var shadowTileResolution1 = this._shadowTileResolution;
17184
17290
  switch(shadowCascades){
@@ -19200,10 +19306,17 @@ exports.TextVerticalAlignment = void 0;
19200
19306
  * @internal
19201
19307
  */ _proto._addSprite = function _addSprite(sprite) {
19202
19308
  this._spriteNamesToIndex[sprite.name] = this._sprites.push(sprite) - 1;
19309
+ sprite._atlas = this;
19310
+ sprite.isGCIgnored = true;
19203
19311
  };
19204
19312
  /**
19205
19313
  * @override
19206
19314
  */ _proto._onDestroy = function _onDestroy() {
19315
+ var _this = this, sprites = _this._sprites;
19316
+ for(var i = 0, n = sprites.length; i < n; i++){
19317
+ sprites[i].destroy();
19318
+ }
19319
+ sprites.length = 0;
19207
19320
  this._sprites = null;
19208
19321
  this._spriteNamesToIndex = null;
19209
19322
  };
@@ -19302,10 +19415,29 @@ exports.TextVerticalAlignment = void 0;
19302
19415
  };
19303
19416
  /**
19304
19417
  * @override
19418
+ * @internal
19419
+ */ _proto._addRefCount = function _addRefCount(value) {
19420
+ var _this__atlas;
19421
+ RefObject.prototype._addRefCount.call(this, value);
19422
+ (_this__atlas = this._atlas) == null ? void 0 : _this__atlas._addRefCount(value);
19423
+ };
19424
+ /**
19425
+ * @override
19426
+ * @internal
19305
19427
  */ _proto._onDestroy = function _onDestroy() {
19306
- if (this._texture) {
19307
- this._texture = null;
19308
- }
19428
+ this._positions.length = 0;
19429
+ this._positions = null;
19430
+ this._uvs.length = 0;
19431
+ this._uvs = null;
19432
+ this._atlasRegion = null;
19433
+ this._atlasRegionOffset = null;
19434
+ this._region = null;
19435
+ this._pivot = null;
19436
+ this._border = null;
19437
+ this._bounds = null;
19438
+ this._atlas = null;
19439
+ this._texture = null;
19440
+ this._updateFlagManager = null;
19309
19441
  };
19310
19442
  _proto._calDefaultSize = function _calDefaultSize() {
19311
19443
  if (this._texture) {
@@ -19408,7 +19540,7 @@ exports.TextVerticalAlignment = void 0;
19408
19540
  key: "width",
19409
19541
  get: /**
19410
19542
  * The width of the sprite (in world coordinates).
19411
- *
19543
+ *
19412
19544
  * @remarks
19413
19545
  * If width is set, return the set value,
19414
19546
  * otherwise return the width calculated according to `Texture.width`, `Sprite.region`, `Sprite.atlasRegion`, `Sprite.atlasRegionOffset` and `Engine._pixelsPerUnit`.
@@ -19431,7 +19563,7 @@ exports.TextVerticalAlignment = void 0;
19431
19563
  key: "height",
19432
19564
  get: /**
19433
19565
  * The height of the sprite (in world coordinates).
19434
- *
19566
+ *
19435
19567
  * @remarks
19436
19568
  * If height is set, return the set value,
19437
19569
  * otherwise return the height calculated according to `Texture.height`, `Sprite.region`, `Sprite.atlasRegion`, `Sprite.atlasRegionOffset` and `Engine._pixelsPerUnit`.
@@ -19732,21 +19864,11 @@ SlicedSpriteAssembler = __decorate$1([
19732
19864
  /**
19733
19865
  * @internal
19734
19866
  */ _proto._cloneTo = function _cloneTo(target) {
19867
+ Renderer.prototype._cloneTo.call(this, target);
19735
19868
  target.sprite = this._sprite;
19736
19869
  target.drawMode = this._drawMode;
19737
19870
  };
19738
19871
  /**
19739
- * @internal
19740
- */ _proto._onDestroy = function _onDestroy() {
19741
- var _this__sprite;
19742
- (_this__sprite = this._sprite) == null ? void 0 : _this__sprite._updateFlagManager.removeListener(this._onSpriteChange);
19743
- this._color = null;
19744
- this._sprite = null;
19745
- this._assembler = null;
19746
- this._renderData = null;
19747
- Renderer.prototype._onDestroy.call(this);
19748
- };
19749
- /**
19750
19872
  * @override
19751
19873
  */ _proto._updateBounds = function _updateBounds(worldBounds) {
19752
19874
  if (this.sprite) {
@@ -19784,6 +19906,20 @@ SlicedSpriteAssembler = __decorate$1([
19784
19906
  context.camera._renderPipeline.pushPrimitive(spriteElement);
19785
19907
  }
19786
19908
  };
19909
+ /**
19910
+ * @internal
19911
+ */ _proto._onDestroy = function _onDestroy() {
19912
+ Renderer.prototype._onDestroy.call(this);
19913
+ var sprite = this._sprite;
19914
+ if (sprite) {
19915
+ sprite._addRefCount(-1);
19916
+ sprite._updateFlagManager.removeListener(this._onSpriteChange);
19917
+ }
19918
+ this._color = null;
19919
+ this._sprite = null;
19920
+ this._assembler = null;
19921
+ this._renderData = null;
19922
+ };
19787
19923
  _proto._calDefaultSize = function _calDefaultSize() {
19788
19924
  var sprite = this._sprite;
19789
19925
  if (sprite) {
@@ -19875,9 +20011,13 @@ SlicedSpriteAssembler = __decorate$1([
19875
20011
  set: function set(value) {
19876
20012
  var lastSprite = this._sprite;
19877
20013
  if (lastSprite !== value) {
19878
- lastSprite && lastSprite._updateFlagManager.removeListener(this._onSpriteChange);
20014
+ if (lastSprite) {
20015
+ lastSprite._addRefCount(-1);
20016
+ lastSprite._updateFlagManager.removeListener(this._onSpriteChange);
20017
+ }
19879
20018
  this._dirtyUpdateFlag |= 0x7;
19880
20019
  if (value) {
20020
+ value._addRefCount(1);
19881
20021
  value._updateFlagManager.addListener(this._onSpriteChange);
19882
20022
  this.shaderData.setTexture(SpriteRenderer._textureProperty, value.texture);
19883
20023
  } else {
@@ -20481,6 +20621,7 @@ var /**
20481
20621
  /**
20482
20622
  * @internal
20483
20623
  */ _proto._cloneTo = function _cloneTo(target) {
20624
+ Renderer.prototype._cloneTo.call(this, target);
20484
20625
  target.font = this._font;
20485
20626
  target._subFont = this._subFont;
20486
20627
  };
@@ -34271,38 +34412,6 @@ function _inherits(subClass, superClass) {
34271
34412
  });
34272
34413
  if (superClass) _set_prototype_of(subClass, superClass);
34273
34414
  }
34274
- /**
34275
- * WebGL platform engine,support includes WebGL1.0 and WebGL2.0.
34276
- */ var WebGLEngine = /*#__PURE__*/ function(Engine) {
34277
- var WebGLEngine = function WebGLEngine() {
34278
- return Engine.apply(this, arguments);
34279
- };
34280
- _inherits(WebGLEngine, Engine);
34281
- /**
34282
- * Create a WebGL engine.
34283
- * @param configuration - WebGL engine configuration
34284
- * @returns A promise that will resolve when the engine is created
34285
- */ WebGLEngine.create = function create(configuration) {
34286
- var canvas = configuration.canvas;
34287
- var webCanvas = new WebCanvas(typeof canvas === "string" ? engineMiniprogramAdapter.document.getElementById(canvas) : canvas);
34288
- var webGLGraphicDevice = new WebGLGraphicDevice(configuration.graphicDeviceOptions);
34289
- var engine = new WebGLEngine(webCanvas, webGLGraphicDevice, configuration);
34290
- // @ts-ignore
34291
- return engine._initialize(configuration);
34292
- };
34293
- _create_class(WebGLEngine, [
34294
- {
34295
- key: "canvas",
34296
- get: /**
34297
- * Web canvas.
34298
- */ function get() {
34299
- // @ts-ignore
34300
- return this._canvas;
34301
- }
34302
- }
34303
- ]);
34304
- return WebGLEngine;
34305
- }(miniprogram$1$1.Engine);
34306
34415
  function _extends() {
34307
34416
  _extends = Object.assign || function assign(target) {
34308
34417
  for(var i = 1; i < arguments.length; i++){
@@ -34313,83 +34422,6 @@ function _extends() {
34313
34422
  };
34314
34423
  return _extends.apply(this, arguments);
34315
34424
  }
34316
- var GLBuffer = /*#__PURE__*/ function() {
34317
- var GLBuffer = function GLBuffer(rhi, type, byteLength, bufferUsage, data) {
34318
- if (bufferUsage === void 0) bufferUsage = miniprogram$1$1.BufferUsage.Static;
34319
- var gl = rhi.gl;
34320
- var glBuffer = gl.createBuffer();
34321
- var glBufferUsage = this._getGLBufferUsage(gl, bufferUsage);
34322
- var glBindTarget = type === miniprogram$1$1.BufferBindFlag.VertexBuffer ? gl.ARRAY_BUFFER : gl.ELEMENT_ARRAY_BUFFER;
34323
- this._gl = gl;
34324
- this._glBuffer = glBuffer;
34325
- this._glBufferUsage = glBufferUsage;
34326
- this._glBindTarget = glBindTarget;
34327
- this._isWebGL2 = rhi.isWebGL2;
34328
- this.bind();
34329
- if (data) {
34330
- gl.bufferData(glBindTarget, data, glBufferUsage);
34331
- } else {
34332
- gl.bufferData(glBindTarget, byteLength, glBufferUsage);
34333
- }
34334
- gl.bindBuffer(glBindTarget, null);
34335
- };
34336
- var _proto = GLBuffer.prototype;
34337
- _proto.bind = function bind() {
34338
- this._gl.bindBuffer(this._glBindTarget, this._glBuffer);
34339
- };
34340
- _proto.setData = function setData(byteLength, data, bufferByteOffset, dataOffset, dataLength, options) {
34341
- var gl = this._gl;
34342
- var glBindTarget = this._glBindTarget;
34343
- this.bind();
34344
- if (options === miniprogram$1$1.SetDataOptions.Discard) {
34345
- gl.bufferData(glBindTarget, byteLength, this._glBufferUsage);
34346
- }
34347
- // TypeArray is BYTES_PER_ELEMENT, unTypeArray is 1
34348
- var byteSize = data.BYTES_PER_ELEMENT || 1;
34349
- var dataByteLength = dataLength ? byteSize * dataLength : data.byteLength;
34350
- if (dataOffset !== 0 || dataByteLength < data.byteLength) {
34351
- var isArrayBufferView = data.byteOffset !== undefined;
34352
- if (this._isWebGL2 && isArrayBufferView) {
34353
- gl.bufferSubData(glBindTarget, bufferByteOffset, data, dataOffset, dataByteLength / byteSize);
34354
- } else {
34355
- var subData = new Uint8Array(isArrayBufferView ? data.buffer : data, dataOffset * byteSize, dataByteLength);
34356
- gl.bufferSubData(glBindTarget, bufferByteOffset, subData);
34357
- }
34358
- } else {
34359
- gl.bufferSubData(glBindTarget, bufferByteOffset, data);
34360
- }
34361
- gl.bindBuffer(glBindTarget, null);
34362
- };
34363
- _proto.getData = function getData(data, bufferByteOffset, dataOffset, dataLength) {
34364
- if (this._isWebGL2) {
34365
- var gl = this._gl;
34366
- this.bind();
34367
- gl.getBufferSubData(this._glBindTarget, bufferByteOffset, data, dataOffset, dataLength);
34368
- } else {
34369
- throw "Buffer is write-only on WebGL1.0 platforms.";
34370
- }
34371
- };
34372
- _proto.resize = function resize(byteLength) {
34373
- this.bind();
34374
- this._gl.bufferData(this._glBindTarget, byteLength, this._glBufferUsage);
34375
- };
34376
- _proto.destroy = function destroy() {
34377
- this._gl.deleteBuffer(this._glBuffer);
34378
- this._gl = null;
34379
- this._glBuffer = null;
34380
- };
34381
- _proto._getGLBufferUsage = function _getGLBufferUsage(gl, bufferUsage) {
34382
- switch(bufferUsage){
34383
- case miniprogram$1$1.BufferUsage.Static:
34384
- return gl.STATIC_DRAW;
34385
- case miniprogram$1$1.BufferUsage.Dynamic:
34386
- return gl.DYNAMIC_DRAW;
34387
- case miniprogram$1$1.BufferUsage.Stream:
34388
- return gl.STREAM_DRAW;
34389
- }
34390
- };
34391
- return GLBuffer;
34392
- }();
34393
34425
  /**
34394
34426
  * GL capability.
34395
34427
  */ var GLCapability = /*#__PURE__*/ function() {
@@ -34652,8 +34684,8 @@ var GLBuffer = /*#__PURE__*/ function() {
34652
34684
  if (useVao) {
34653
34685
  gl.drawElements(topology, count, _glIndexType, start * _glIndexByteCount);
34654
34686
  } else {
34655
- var _glBuffer = _indexBufferBinding.buffer._platformBuffer._glBuffer;
34656
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _glBuffer);
34687
+ var _nativeBuffer = _indexBufferBinding.buffer._nativeBuffer;
34688
+ gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _nativeBuffer);
34657
34689
  gl.drawElements(topology, count, _glIndexType, start * _glIndexByteCount);
34658
34690
  gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
34659
34691
  }
@@ -34666,8 +34698,8 @@ var GLBuffer = /*#__PURE__*/ function() {
34666
34698
  if (useVao) {
34667
34699
  gl.drawElementsInstanced(topology, count, _glIndexType, start * _glIndexByteCount, _instanceCount);
34668
34700
  } else {
34669
- var _glBuffer1 = _indexBufferBinding.buffer._platformBuffer._glBuffer;
34670
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _glBuffer1);
34701
+ var _nativeBuffer1 = _indexBufferBinding.buffer._nativeBuffer;
34702
+ gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _nativeBuffer1);
34671
34703
  gl.drawElementsInstanced(topology, count, _glIndexType, start * _glIndexByteCount, _instanceCount);
34672
34704
  gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
34673
34705
  }
@@ -34707,7 +34739,7 @@ var GLBuffer = /*#__PURE__*/ function() {
34707
34739
  var element = attributes[name];
34708
34740
  if (element) {
34709
34741
  var _vertexBufferBindings_element_bindingIndex = vertexBufferBindings[element.bindingIndex], buffer = _vertexBufferBindings_element_bindingIndex.buffer, stride = _vertexBufferBindings_element_bindingIndex.stride;
34710
- vbo = buffer._platformBuffer._glBuffer;
34742
+ vbo = buffer._nativeBuffer;
34711
34743
  // prevent binding the vbo which already bound at the last loop, e.g. a buffer with multiple attributes.
34712
34744
  if (lastBoundVbo !== vbo) {
34713
34745
  lastBoundVbo = vbo;
@@ -34739,7 +34771,7 @@ var GLBuffer = /*#__PURE__*/ function() {
34739
34771
  // @ts-ignore
34740
34772
  var _indexBufferBinding = this._primitive._indexBufferBinding;
34741
34773
  if (_indexBufferBinding) {
34742
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _indexBufferBinding.buffer._platformBuffer._glBuffer);
34774
+ gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _indexBufferBinding.buffer._nativeBuffer);
34743
34775
  }
34744
34776
  this._bindBufferAndAttrib(shaderProgram);
34745
34777
  /** unbind */ gl.bindVertexArray(null);
@@ -35796,21 +35828,23 @@ exports.WebGLMode = void 0;
35796
35828
  WebGLMode[WebGLMode[/** WebGL1.0, */ "WebGL1"] = 2] = "WebGL1";
35797
35829
  })(exports.WebGLMode || (exports.WebGLMode = {}));
35798
35830
  /**
35799
- * WebGL graphic device, including WebGL1.0 and WebGL2.0.
35800
- */ var WebGLGraphicDevice = /*#__PURE__*/ function() {
35801
- var WebGLGraphicDevice = function WebGLGraphicDevice(initializeOptions) {
35831
+ * WebGL renderer, including WebGL1.0 and WebGL2.0.
35832
+ */ var WebGLRenderer = /*#__PURE__*/ function() {
35833
+ var WebGLRenderer = function WebGLRenderer(initializeOptions) {
35802
35834
  if (initializeOptions === void 0) initializeOptions = {};
35803
- /** @internal */ this._readFrameBuffer = null;
35804
35835
  /** @internal */ this._enableGlobalDepthBias = false;
35805
35836
  this._activeTextures = new Array(32);
35837
+ // cache value
35806
35838
  this._lastViewport = new miniprogram$1.Vector4(null, null, null, null);
35807
35839
  this._lastScissor = new miniprogram$1.Vector4(null, null, null, null);
35808
35840
  this._lastClearColor = new miniprogram$1.Color(null, null, null, null);
35809
35841
  this._scissorEnable = false;
35810
35842
  var options = _extends({
35811
35843
  webGLMode: 0,
35844
+ alpha: false,
35812
35845
  stencil: true,
35813
- _forceFlush: false
35846
+ _forceFlush: false,
35847
+ _maxAllowSkinUniformVectorCount: 256
35814
35848
  }, initializeOptions);
35815
35849
  if (miniprogram$1$1.SystemInfo.platform === miniprogram$1$1.Platform.IPhone || miniprogram$1$1.SystemInfo.platform === miniprogram$1$1.Platform.IPad) {
35816
35850
  var version = miniprogram$1$1.SystemInfo.operatingSystem.match(/(\d+).?(\d+)?.?(\d+)?/);
@@ -35823,20 +35857,12 @@ exports.WebGLMode = void 0;
35823
35857
  }
35824
35858
  }
35825
35859
  this._options = options;
35826
- this._onWebGLContextLost = this._onWebGLContextLost.bind(this);
35827
- this._onWebGLContextRestored = this._onWebGLContextRestored.bind(this);
35828
35860
  };
35829
- var _proto = WebGLGraphicDevice.prototype;
35830
- _proto.init = function init(canvas, onDeviceLost, onDeviceRestored) {
35861
+ var _proto = WebGLRenderer.prototype;
35862
+ _proto.init = function init(canvas) {
35831
35863
  var options = this._options;
35832
- var webCanvas = canvas._webCanvas;
35864
+ var webCanvas = this._webCanvas = canvas._webCanvas;
35833
35865
  var webGLMode = options.webGLMode;
35834
- this._onDeviceLost = onDeviceLost;
35835
- this._onDeviceRestored = onDeviceRestored;
35836
- webCanvas.addEventListener("webglcontextlost", this._onWebGLContextLost, false);
35837
- webCanvas.addEventListener("webglcontextrestored", this._onWebGLContextRestored, false);
35838
- webCanvas.addEventListener("webglcontextcreationerror", this._onContextCreationError, false);
35839
- this._webCanvas = webCanvas;
35840
35866
  var gl;
35841
35867
  if (webGLMode == 0 || webGLMode == 1) {
35842
35868
  gl = webCanvas.getContext("webgl2", options);
@@ -35862,7 +35888,16 @@ exports.WebGLMode = void 0;
35862
35888
  throw new Error("Get GL Context FAILED.");
35863
35889
  }
35864
35890
  this._gl = gl;
35865
- this._initGLState(gl);
35891
+ this._activeTextureID = gl.TEXTURE0;
35892
+ this._renderStates = new GLRenderStates(gl);
35893
+ this._extensions = new GLExtensions(this);
35894
+ this._capability = new GLCapability(this);
35895
+ // Make sure the active texture in gl context is on default, because gl context may be used in other webgl renderer.
35896
+ gl.activeTexture(gl.TEXTURE0);
35897
+ var debugRenderInfo = gl.getExtension("WEBGL_debug_renderer_info");
35898
+ if (debugRenderInfo != null) {
35899
+ this._renderer = gl.getParameter(debugRenderInfo.UNMASKED_RENDERER_WEBGL);
35900
+ }
35866
35901
  };
35867
35902
  _proto.createPlatformPrimitive = function createPlatformPrimitive(primitive) {
35868
35903
  return new GLPrimitive(this, primitive);
@@ -35879,10 +35914,6 @@ exports.WebGLMode = void 0;
35879
35914
  _proto.createPlatformRenderTarget = function createPlatformRenderTarget(target) {
35880
35915
  return new GLRenderTarget(this, target);
35881
35916
  };
35882
- _proto.createPlatformBuffer = function createPlatformBuffer(type, byteLength, bufferUsage, data) {
35883
- if (bufferUsage === void 0) bufferUsage = miniprogram$1$1.BufferUsage.Static;
35884
- return new GLBuffer(this, type, byteLength, bufferUsage, data);
35885
- };
35886
35917
  _proto.requireExtension = function requireExtension(ext) {
35887
35918
  return this._extensions.requireExtension(ext);
35888
35919
  };
@@ -36010,57 +36041,8 @@ exports.WebGLMode = void 0;
36010
36041
  _proto.flush = function flush() {
36011
36042
  this._gl.flush();
36012
36043
  };
36013
- _proto.forceLoseDevice = function forceLoseDevice() {
36014
- var extension = this.requireExtension(miniprogram$1$1.GLCapabilityType.WEBGL_lose_context);
36015
- extension.loseContext();
36016
- };
36017
- _proto.forceRestoreDevice = function forceRestoreDevice() {
36018
- var extension = this.requireExtension(miniprogram$1$1.GLCapabilityType.WEBGL_lose_context);
36019
- extension.restoreContext();
36020
- };
36021
- _proto.resetState = function resetState() {
36022
- this._readFrameBuffer = null;
36023
- this._enableGlobalDepthBias = false;
36024
- this._currentBindShaderProgram = null;
36025
- var activeTextures = this._activeTextures;
36026
- for(var i = 0, n = activeTextures.length; i < n; i++){
36027
- activeTextures[i] = null;
36028
- }
36029
- this._lastViewport.set(null, null, null, null);
36030
- this._lastScissor.set(null, null, null, null);
36031
- this._lastClearColor.set(null, null, null, null);
36032
- this._scissorEnable = false;
36033
- this._initGLState(this._gl);
36034
- };
36035
- _proto._initGLState = function _initGLState(gl) {
36036
- this._activeTextureID = gl.TEXTURE0;
36037
- this._renderStates = new GLRenderStates(gl);
36038
- this._extensions = new GLExtensions(this);
36039
- this._capability = new GLCapability(this);
36040
- // Make sure the active texture in gl context is on default, because gl context may be used in other webgl renderer.
36041
- gl.activeTexture(gl.TEXTURE0);
36042
- var debugRenderInfo = gl.getExtension("WEBGL_debug_renderer_info");
36043
- if (debugRenderInfo != null) {
36044
- this._renderer = gl.getParameter(debugRenderInfo.UNMASKED_RENDERER_WEBGL);
36045
- }
36046
- };
36047
- _proto.destroy = function destroy() {
36048
- var webCanvas = this._webCanvas;
36049
- webCanvas.removeEventListener("webglcontextcreationerror", this._onContextCreationError, false);
36050
- webCanvas.removeEventListener("webglcontextlost", this._onWebGLContextLost, false);
36051
- webCanvas.removeEventListener("webglcontextrestored", this._onWebGLContextRestored, false);
36052
- };
36053
- _proto._onContextCreationError = function _onContextCreationError(event) {
36054
- console.error("WebGLRenderer: WebGL context could not be created. Reason: ", event.statusMessage);
36055
- };
36056
- _proto._onWebGLContextLost = function _onWebGLContextLost(event) {
36057
- event.preventDefault();
36058
- this._onDeviceLost();
36059
- };
36060
- _proto._onWebGLContextRestored = function _onWebGLContextRestored(event) {
36061
- this._onDeviceRestored();
36062
- };
36063
- _create_class(WebGLGraphicDevice, [
36044
+ _proto.destroy = function destroy() {};
36045
+ _create_class(WebGLRenderer, [
36064
36046
  {
36065
36047
  key: "isWebGL2",
36066
36048
  get: function get() {
@@ -36101,11 +36083,32 @@ exports.WebGLMode = void 0;
36101
36083
  }
36102
36084
  }
36103
36085
  ]);
36104
- return WebGLGraphicDevice;
36086
+ return WebGLRenderer;
36105
36087
  }();
36088
+ /**
36089
+ * WebGL platform engine,support includes WebGL1.0 and WebGL2.0.
36090
+ */ var WebGLEngine = /*#__PURE__*/ function(Engine) {
36091
+ var WebGLEngine = function WebGLEngine(canvas, webGLRendererOptions) {
36092
+ var webCanvas = new WebCanvas(typeof canvas === "string" ? engineMiniprogramAdapter.document.getElementById(canvas) : canvas);
36093
+ var hardwareRenderer = new WebGLRenderer(webGLRendererOptions);
36094
+ return Engine.call(this, webCanvas, hardwareRenderer);
36095
+ };
36096
+ _inherits(WebGLEngine, Engine);
36097
+ _create_class(WebGLEngine, [
36098
+ {
36099
+ key: "canvas",
36100
+ get: /**
36101
+ * Web canvas.
36102
+ */ function get() {
36103
+ return this._canvas;
36104
+ }
36105
+ }
36106
+ ]);
36107
+ return WebGLEngine;
36108
+ }(miniprogram$1$1.Engine);
36106
36109
  exports.WebCanvas = WebCanvas;
36107
36110
  exports.WebGLEngine = WebGLEngine;
36108
- exports.WebGLGraphicDevice = WebGLGraphicDevice;
36111
+ exports.WebGLRenderer = WebGLRenderer;
36109
36112
 
36110
36113
  var miniprogram$3 = /*#__PURE__*/Object.freeze({
36111
36114
  __proto__: null
@@ -36146,7 +36149,7 @@ function _interopNamespace(e) {
36146
36149
  }
36147
36150
  var CoreObjects__namespace = /*#__PURE__*/ _interopNamespace(CoreObjects);
36148
36151
  //@ts-ignore
36149
- var version = "0.0.0-experimental-0.9-plus.5";
36152
+ var version = "0.0.0-experimental-0.9-plus.7";
36150
36153
  console.log("Galacean engine version: " + version);
36151
36154
  for(var key in CoreObjects__namespace){
36152
36155
  CoreObjects.Loader.registerClass(key, CoreObjects__namespace[key]);