@galacean/engine 1.0.0-beta.11 → 1.0.0-beta.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.
package/dist/browser.js CHANGED
@@ -5642,6 +5642,13 @@
5642
5642
  TextureFormat[TextureFormat[/** 16-bit depth + 8-bit stencil format. */ "Depth24Stencil8"] = 30] = "Depth24Stencil8";
5643
5643
  TextureFormat[TextureFormat[/** 32-bit depth + 8-bit stencil format. */ "Depth32Stencil8"] = 31] = "Depth32Stencil8";
5644
5644
  })(exports.TextureFormat || (exports.TextureFormat = {}));
5645
+ /**
5646
+ * Texture usage.
5647
+ */ exports.TextureUsage = void 0;
5648
+ (function(TextureUsage) {
5649
+ TextureUsage[TextureUsage[/** The content of the texture is intended to be specified once. */ "Static"] = 0] = "Static";
5650
+ TextureUsage[TextureUsage[/** The content of the texture is intended to be updated frequently, with better performance. */ "Dynamic"] = 1] = "Dynamic";
5651
+ })(exports.TextureUsage || (exports.TextureUsage = {}));
5645
5652
  /**
5646
5653
  * Wrapping mode of the texture.
5647
5654
  */ exports.TextureWrapMode = void 0;
@@ -5779,6 +5786,14 @@
5779
5786
  return this._height;
5780
5787
  }
5781
5788
  },
5789
+ {
5790
+ key: "usage",
5791
+ get: /**
5792
+ * The usage of the texture.
5793
+ */ function get() {
5794
+ return this._usage;
5795
+ }
5796
+ },
5782
5797
  {
5783
5798
  key: "wrapModeU",
5784
5799
  get: /**
@@ -6019,14 +6034,16 @@
6019
6034
  /**
6020
6035
  * Two-dimensional texture.
6021
6036
  */ var Texture2D = /*#__PURE__*/ function(Texture) {
6022
- var Texture2D = function Texture2D(engine, width, height, format, mipmap) {
6037
+ var Texture2D = function Texture2D(engine, width, height, format, mipmap, usage) {
6023
6038
  if (format === void 0) format = exports.TextureFormat.R8G8B8A8;
6024
6039
  if (mipmap === void 0) mipmap = true;
6040
+ if (usage === void 0) usage = exports.TextureUsage.Static;
6025
6041
  var _this;
6026
6042
  _this = Texture.call(this, engine) || this;
6027
6043
  _this._mipmap = mipmap;
6028
6044
  _this._width = width;
6029
6045
  _this._height = height;
6046
+ _this._usage = usage;
6030
6047
  _this._format = format;
6031
6048
  _this._mipmapCount = _this._getMipmapCount();
6032
6049
  _this._isDepthTexture = format == exports.TextureFormat.Depth || format == exports.TextureFormat.DepthStencil || format == exports.TextureFormat.Depth16 || format == exports.TextureFormat.Depth24 || format == exports.TextureFormat.Depth32 || format == exports.TextureFormat.Depth24Stencil8 || format == exports.TextureFormat.Depth32Stencil8;
@@ -31062,6 +31079,7 @@
31062
31079
  get TextureDepthCompareFunction () { return exports.TextureDepthCompareFunction; },
31063
31080
  get TextureFilterMode () { return exports.TextureFilterMode; },
31064
31081
  get TextureFormat () { return exports.TextureFormat; },
31082
+ get TextureUsage () { return exports.TextureUsage; },
31065
31083
  get TextureWrapMode () { return exports.TextureWrapMode; },
31066
31084
  Time: Time,
31067
31085
  TrailMaterial: TrailMaterial,
@@ -31829,9 +31847,9 @@
31829
31847
  var isWebGL2 = this._isWebGL2;
31830
31848
  var _this__formatDetail = this._formatDetail, internalFormat = _this__formatDetail.internalFormat, baseFormat = _this__formatDetail.baseFormat, dataType = _this__formatDetail.dataType;
31831
31849
  // @ts-ignore
31832
- var _this__texture = this._texture, mipmapCount = _this__texture.mipmapCount, width = _this__texture.width, height = _this__texture.height, _isDepthTexture = _this__texture._isDepthTexture;
31850
+ var _this__texture = this._texture, mipmapCount = _this__texture.mipmapCount, width = _this__texture.width, height = _this__texture.height, usage = _this__texture.usage, _isDepthTexture = _this__texture._isDepthTexture;
31833
31851
  this._bind();
31834
- if (isWebGL2 && !(baseFormat === gl.LUMINANCE_ALPHA || baseFormat === gl.ALPHA)) {
31852
+ if (isWebGL2 && !(baseFormat === gl.LUMINANCE_ALPHA || baseFormat === gl.ALPHA) && usage !== exports.TextureUsage.Dynamic) {
31835
31853
  gl.texStorage2D(this._target, mipmapCount, internalFormat, width, height);
31836
31854
  } else {
31837
31855
  if (!isCube) {
@@ -32623,11 +32641,15 @@
32623
32641
  * {@inheritDoc IPlatformTexture2D.setImageSource}
32624
32642
  */ _proto.setImageSource = function setImageSource(imageSource, mipLevel, flipY, premultiplyAlpha, x, y) {
32625
32643
  var gl = this._gl;
32626
- var _this__formatDetail = this._formatDetail, baseFormat = _this__formatDetail.baseFormat, dataType = _this__formatDetail.dataType;
32644
+ var _this__formatDetail = this._formatDetail, internalFormat = _this__formatDetail.internalFormat, baseFormat = _this__formatDetail.baseFormat, dataType = _this__formatDetail.dataType;
32627
32645
  this._bind();
32628
32646
  gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, +flipY);
32629
32647
  gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, +premultiplyAlpha);
32630
- gl.texSubImage2D(this._target, mipLevel, x || 0, y || 0, baseFormat, dataType, imageSource);
32648
+ if (this._texture.usage === exports.TextureUsage.Dynamic) {
32649
+ gl.texImage2D(this._target, mipLevel, internalFormat, baseFormat, dataType, imageSource);
32650
+ } else {
32651
+ gl.texSubImage2D(this._target, mipLevel, x || 0, y || 0, baseFormat, dataType, imageSource);
32652
+ }
32631
32653
  };
32632
32654
  /**
32633
32655
  * {@inheritDoc IPlatformTexture2D.getPixelBuffer }
@@ -38156,7 +38178,7 @@
38156
38178
  ], GALACEAN_animation_event);
38157
38179
 
38158
38180
  //@ts-ignore
38159
- var version = "1.0.0-beta.11";
38181
+ var version = "1.0.0-beta.12";
38160
38182
  console.log("Galacean engine version: " + version);
38161
38183
  for(var key in CoreObjects){
38162
38184
  Loader.registerClass(key, CoreObjects[key]);