@galacean/engine-rhi-webgl 0.9.20 → 0.9.21

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.
@@ -3,12 +3,20 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var engineMiniprogramAdapter = require('@galacean/engine-miniprogram-adapter');
6
+ var _create_class = require('@swc/helpers/src/_create_class.mjs');
7
+ var _instanceof = require('@swc/helpers/src/_instanceof.mjs');
6
8
  var miniprogram = require('@galacean/engine-math/dist/miniprogram');
9
+ var _inherits = require('@swc/helpers/src/_inherits.mjs');
7
10
  var miniprogram$1 = require('@galacean/engine-core/dist/miniprogram');
11
+ var _extends = require('@swc/helpers/src/_extends.mjs');
12
+
13
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
14
+
15
+ var _create_class__default = /*#__PURE__*/_interopDefaultLegacy(_create_class);
16
+ var _instanceof__default = /*#__PURE__*/_interopDefaultLegacy(_instanceof);
17
+ var _inherits__default = /*#__PURE__*/_interopDefaultLegacy(_inherits);
18
+ var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends);
8
19
 
9
- /**
10
- * Smoothing plug-in.
11
- * */ exports.GLCompressedTextureInternalFormat = void 0;
12
20
  (function(GLCompressedTextureInternalFormat) {
13
21
  GLCompressedTextureInternalFormat[GLCompressedTextureInternalFormat[// astc
14
22
  "RGBA_ASTC_4X4_KHR"] = 0x93b0] = "RGBA_ASTC_4X4_KHR";
@@ -64,30 +72,6 @@ var miniprogram$1 = require('@galacean/engine-core/dist/miniprogram');
64
72
  GLCompressedTextureInternalFormat[GLCompressedTextureInternalFormat["RGBA_S3TC_DXT5_EXT"] = 0x83f3] = "RGBA_S3TC_DXT5_EXT";
65
73
  })(exports.GLCompressedTextureInternalFormat || (exports.GLCompressedTextureInternalFormat = {}));
66
74
 
67
- function _defineProperties(target, props) {
68
- for (var i = 0; i < props.length; i++) {
69
- var descriptor = props[i];
70
- descriptor.enumerable = descriptor.enumerable || false;
71
- descriptor.configurable = true;
72
-
73
- if ("value" in descriptor) descriptor.writable = true;
74
-
75
- Object.defineProperty(target, descriptor.key, descriptor);
76
- }
77
- }
78
- function _create_class(Constructor, protoProps, staticProps) {
79
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
80
- if (staticProps) _defineProperties(Constructor, staticProps);
81
-
82
- return Constructor;
83
- }
84
-
85
- function _instanceof(left, right) {
86
- if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
87
- return !!right[Symbol.hasInstance](left);
88
- } else return left instanceof right;
89
- }
90
-
91
75
  /**
92
76
  * The canvas used on the web, which can support HTMLCanvasElement and OffscreenCanvas.
93
77
  */ var WebCanvas = /*#__PURE__*/ function() {
@@ -106,7 +90,7 @@ function _instanceof(left, right) {
106
90
  */ _proto.resizeByClientSize = function resizeByClientSize(pixelRatio) {
107
91
  if (pixelRatio === void 0) pixelRatio = engineMiniprogramAdapter.window.devicePixelRatio;
108
92
  var webCanvas = this._webCanvas;
109
- if (typeof engineMiniprogramAdapter.OffscreenCanvas === "undefined" || !_instanceof(webCanvas, engineMiniprogramAdapter.OffscreenCanvas)) {
93
+ if (typeof engineMiniprogramAdapter.OffscreenCanvas === "undefined" || !_instanceof__default['default'](webCanvas, engineMiniprogramAdapter.OffscreenCanvas)) {
110
94
  this.width = webCanvas.clientWidth * pixelRatio;
111
95
  this.height = webCanvas.clientHeight * pixelRatio;
112
96
  }
@@ -119,7 +103,7 @@ function _instanceof(left, right) {
119
103
  this._scale.set(x, y);
120
104
  this.scale = this._scale;
121
105
  };
122
- _create_class(WebCanvas, [
106
+ _create_class__default['default'](WebCanvas, [
123
107
  {
124
108
  key: "width",
125
109
  get: /**
@@ -155,14 +139,14 @@ function _instanceof(left, right) {
155
139
  * @remarks Need to re-assign after modification to ensure that the modification takes effect.
156
140
  */ function get() {
157
141
  var webCanvas = this._webCanvas;
158
- if (typeof engineMiniprogramAdapter.OffscreenCanvas === "undefined" || !_instanceof(webCanvas, engineMiniprogramAdapter.OffscreenCanvas)) {
142
+ if (typeof engineMiniprogramAdapter.OffscreenCanvas === "undefined" || !_instanceof__default['default'](webCanvas, engineMiniprogramAdapter.OffscreenCanvas)) {
159
143
  this._scale.set(webCanvas.clientWidth * engineMiniprogramAdapter.devicePixelRatio / webCanvas.width, webCanvas.clientHeight * engineMiniprogramAdapter.devicePixelRatio / webCanvas.height);
160
144
  }
161
145
  return this._scale;
162
146
  },
163
147
  set: function set(value) {
164
148
  var webCanvas = this._webCanvas;
165
- if (typeof engineMiniprogramAdapter.OffscreenCanvas === "undefined" || !_instanceof(webCanvas, engineMiniprogramAdapter.OffscreenCanvas)) {
149
+ if (typeof engineMiniprogramAdapter.OffscreenCanvas === "undefined" || !_instanceof__default['default'](webCanvas, engineMiniprogramAdapter.OffscreenCanvas)) {
166
150
  webCanvas.style.transformOrigin = "left top";
167
151
  webCanvas.style.transform = "scale(" + value.x + ", " + value.y + ")";
168
152
  }
@@ -172,39 +156,6 @@ function _instanceof(left, right) {
172
156
  return WebCanvas;
173
157
  }();
174
158
 
175
- function _set_prototype_of(o, p) {
176
- _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
177
- o.__proto__ = p;
178
-
179
- return o;
180
- };
181
-
182
- return _set_prototype_of(o, p);
183
- }
184
-
185
- function _inherits(subClass, superClass) {
186
- if (typeof superClass !== "function" && superClass !== null) {
187
- throw new TypeError("Super expression must either be null or a function");
188
- }
189
-
190
- subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } });
191
-
192
- if (superClass) _set_prototype_of(subClass, superClass);
193
- }
194
-
195
- function _extends() {
196
- _extends = Object.assign || function assign(target) {
197
- for (var i = 1; i < arguments.length; i++) {
198
- var source = arguments[i];
199
- for (var key in source) if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
200
- }
201
-
202
- return target;
203
- };
204
-
205
- return _extends.apply(this, arguments);
206
- }
207
-
208
159
  /**
209
160
  * GL capability.
210
161
  */ var GLCapability = /*#__PURE__*/ function() {
@@ -323,7 +274,7 @@ function _extends() {
323
274
  i != 0 && (items["COLOR_ATTACHMENT" + i] = "COLOR_ATTACHMENT" + i + "_WEBGL");
324
275
  items["DRAW_BUFFER" + i] = "DRAW_BUFFER" + i + "_WEBGL";
325
276
  }
326
- this._compatibleInterface(drawBuffers, _extends({
277
+ this._compatibleInterface(drawBuffers, _extends__default['default']({
327
278
  drawBuffers: "drawBuffersWEBGL"
328
279
  }, items));
329
280
  }
@@ -341,7 +292,7 @@ function _extends() {
341
292
  TEXTURE_MAX_ANISOTROPY_EXT: "TEXTURE_MAX_ANISOTROPY_EXT"
342
293
  });
343
294
  };
344
- _create_class(GLCapability, [
295
+ _create_class__default['default'](GLCapability, [
345
296
  {
346
297
  key: "maxTextureSize",
347
298
  get: function get() {
@@ -1095,7 +1046,7 @@ function _extends() {
1095
1046
  }
1096
1047
  return true;
1097
1048
  };
1098
- _create_class(GLTexture, [
1049
+ _create_class__default['default'](GLTexture, [
1099
1050
  {
1100
1051
  key: "wrapModeU",
1101
1052
  set: /**
@@ -1196,7 +1147,7 @@ function _extends() {
1196
1147
  this._isWebGL2 = rhi.isWebGL2;
1197
1148
  this._target = target;
1198
1149
  /** @ts-ignore */ var _colorTextures = target._colorTextures, _depth = target._depth, width = target.width, height = target.height;
1199
- var isDepthTexture = _instanceof(_depth, miniprogram$1.Texture);
1150
+ var isDepthTexture = _instanceof__default['default'](_depth, miniprogram$1.Texture);
1200
1151
  /** todo
1201
1152
  * MRT + Cube + [,MSAA]
1202
1153
  * MRT + MSAA
@@ -1222,7 +1173,7 @@ function _extends() {
1222
1173
  }
1223
1174
  // todo: necessary to support MRT + Cube + [,MSAA] ?
1224
1175
  if (_colorTextures.length > 1 && _colorTextures.some(function(v) {
1225
- return _instanceof(v, miniprogram$1.TextureCube);
1176
+ return _instanceof__default['default'](v, miniprogram$1.TextureCube);
1226
1177
  })) {
1227
1178
  throw new Error("MRT+Cube+[,MSAA] is not supported");
1228
1179
  }
@@ -1252,14 +1203,14 @@ function _extends() {
1252
1203
  var mipChanged = mipLevel !== this._curMipLevel;
1253
1204
  gl.bindFramebuffer(gl.FRAMEBUFFER, this._frameBuffer);
1254
1205
  if (colorTexture) {
1255
- var isCube = _instanceof(colorTexture, miniprogram$1.TextureCube);
1206
+ var isCube = _instanceof__default['default'](colorTexture, miniprogram$1.TextureCube);
1256
1207
  if (mipChanged || isCube) {
1257
1208
  gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, isCube ? gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex : gl.TEXTURE_2D, // @ts-ignore
1258
1209
  colorTexture._platformTexture._glTexture, mipLevel);
1259
1210
  }
1260
1211
  }
1261
1212
  if (depthTexture) {
1262
- var isCube1 = _instanceof(depthTexture, miniprogram$1.TextureCube);
1213
+ var isCube1 = _instanceof__default['default'](depthTexture, miniprogram$1.TextureCube);
1263
1214
  if (mipChanged || isCube1) {
1264
1215
  // @ts-ignore
1265
1216
  var platformTexture = depthTexture._platformTexture;
@@ -1337,7 +1288,7 @@ function _extends() {
1337
1288
  var colorTexture = this._target.getColorTexture(i);
1338
1289
  var attachment = gl.COLOR_ATTACHMENT0 + i;
1339
1290
  drawBuffers[i] = attachment;
1340
- if (!_instanceof(colorTexture, miniprogram$1.TextureCube)) {
1291
+ if (!_instanceof__default['default'](colorTexture, miniprogram$1.TextureCube)) {
1341
1292
  gl.framebufferTexture2D(gl.FRAMEBUFFER, attachment, gl.TEXTURE_2D, /** @ts-ignore */ colorTexture._platformTexture._glTexture, 0);
1342
1293
  }
1343
1294
  }
@@ -1346,7 +1297,7 @@ function _extends() {
1346
1297
  }
1347
1298
  this._oriDrawBuffers = drawBuffers;
1348
1299
  /** depth render buffer */ if (_depth !== null) {
1349
- if (_instanceof(_depth, miniprogram$1.Texture) && !_instanceof(_depth, miniprogram$1.TextureCube)) {
1300
+ if (_instanceof__default['default'](_depth, miniprogram$1.Texture) && !_instanceof__default['default'](_depth, miniprogram$1.TextureCube)) {
1350
1301
  // @ts-ignore
1351
1302
  var platformTexture = _depth._platformTexture;
1352
1303
  gl.framebufferTexture2D(gl.FRAMEBUFFER, platformTexture._formatDetail.attachment, gl.TEXTURE_2D, platformTexture._glTexture, 0);
@@ -1382,7 +1333,7 @@ function _extends() {
1382
1333
  gl.drawBuffers(this._oriDrawBuffers);
1383
1334
  // prepare MSAA depth RBO
1384
1335
  if (_depth !== null) {
1385
- var _ref = _instanceof(_depth, miniprogram$1.Texture) ? /** @ts-ignore */ _depth._platformTexture._formatDetail : GLTexture._getRenderBufferDepthFormatDetail(_depth, gl, isWebGL2), internalFormat = _ref.internalFormat, attachment = _ref.attachment;
1336
+ var _ref = _instanceof__default['default'](_depth, miniprogram$1.Texture) ? /** @ts-ignore */ _depth._platformTexture._formatDetail : GLTexture._getRenderBufferDepthFormatDetail(_depth, gl, isWebGL2), internalFormat = _ref.internalFormat, attachment = _ref.attachment;
1386
1337
  gl.bindRenderbuffer(gl.RENDERBUFFER, MSAADepthRenderBuffer);
1387
1338
  gl.renderbufferStorageMultisample(gl.RENDERBUFFER, antiAliasing, internalFormat, width, height);
1388
1339
  gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, MSAADepthRenderBuffer);
@@ -1415,7 +1366,7 @@ function _extends() {
1415
1366
  /**
1416
1367
  * Texture 2d in WebGL platform.
1417
1368
  */ var GLTexture2D = /*#__PURE__*/ function(GLTexture1) {
1418
- _inherits(GLTexture2D, GLTexture1);
1369
+ _inherits__default['default'](GLTexture2D, GLTexture1);
1419
1370
  function GLTexture2D(rhi, texture2D) {
1420
1371
  var _this;
1421
1372
  _this = GLTexture1.call(this, rhi, texture2D, rhi.gl.TEXTURE_2D) || this;
@@ -1485,7 +1436,7 @@ function _extends() {
1485
1436
  /**
1486
1437
  * Texture 2D array in WebGL platform.
1487
1438
  */ var GLTexture2DArray = /*#__PURE__*/ function(GLTexture1) {
1488
- _inherits(GLTexture2DArray, GLTexture1);
1439
+ _inherits__default['default'](GLTexture2DArray, GLTexture1);
1489
1440
  function GLTexture2DArray(rhi, texture2DArray) {
1490
1441
  var _this;
1491
1442
  _this = GLTexture1.call(this, rhi, texture2DArray, rhi.gl.TEXTURE_2D_ARRAY) || this;
@@ -1547,7 +1498,7 @@ function _extends() {
1547
1498
  /**
1548
1499
  * Cube texture in WebGL platform.
1549
1500
  */ var GLTextureCube = /*#__PURE__*/ function(GLTexture1) {
1550
- _inherits(GLTextureCube, GLTexture1);
1501
+ _inherits__default['default'](GLTextureCube, GLTexture1);
1551
1502
  function GLTextureCube(rhi, textureCube) {
1552
1503
  var _this;
1553
1504
  _this = GLTexture1.call(this, rhi, textureCube, rhi.gl.TEXTURE_CUBE_MAP) || this;
@@ -1619,7 +1570,6 @@ function _extends() {
1619
1570
  return GLTextureCube;
1620
1571
  }(GLTexture);
1621
1572
 
1622
- exports.WebGLMode = void 0;
1623
1573
  (function(WebGLMode) {
1624
1574
  WebGLMode[WebGLMode[/** Auto, use WebGL2.0 if support, or will fallback to WebGL1.0. */ "Auto"] = 0] = "Auto";
1625
1575
  WebGLMode[WebGLMode[/** WebGL2.0. */ "WebGL2"] = 1] = "WebGL2";
@@ -1637,7 +1587,7 @@ exports.WebGLMode = void 0;
1637
1587
  this._lastScissor = new miniprogram.Vector4(null, null, null, null);
1638
1588
  this._lastClearColor = new miniprogram.Color(null, null, null, null);
1639
1589
  this._scissorEnable = false;
1640
- var options = _extends({
1590
+ var options = _extends__default['default']({
1641
1591
  webGLMode: 0,
1642
1592
  alpha: false,
1643
1593
  stencil: true,
@@ -1664,7 +1614,7 @@ exports.WebGLMode = void 0;
1664
1614
  var gl;
1665
1615
  if (webGLMode == 0 || webGLMode == 1) {
1666
1616
  gl = webCanvas.getContext("webgl2", options);
1667
- if (!gl && (typeof engineMiniprogramAdapter.OffscreenCanvas === "undefined" || !_instanceof(webCanvas, engineMiniprogramAdapter.OffscreenCanvas))) {
1617
+ if (!gl && (typeof engineMiniprogramAdapter.OffscreenCanvas === "undefined" || !_instanceof__default['default'](webCanvas, engineMiniprogramAdapter.OffscreenCanvas))) {
1668
1618
  gl = webCanvas.getContext("experimental-webgl2", options);
1669
1619
  }
1670
1620
  this._isWebGL2 = true;
@@ -1676,7 +1626,7 @@ exports.WebGLMode = void 0;
1676
1626
  if (!gl) {
1677
1627
  if (webGLMode == 0 || webGLMode == 2) {
1678
1628
  gl = webCanvas.getContext("webgl", options);
1679
- if (!gl && (typeof engineMiniprogramAdapter.OffscreenCanvas === "undefined" || !_instanceof(webCanvas, engineMiniprogramAdapter.OffscreenCanvas))) {
1629
+ if (!gl && (typeof engineMiniprogramAdapter.OffscreenCanvas === "undefined" || !_instanceof__default['default'](webCanvas, engineMiniprogramAdapter.OffscreenCanvas))) {
1680
1630
  gl = webCanvas.getContext("experimental-webgl", options);
1681
1631
  }
1682
1632
  this._isWebGL2 = false;
@@ -1840,7 +1790,7 @@ exports.WebGLMode = void 0;
1840
1790
  this._gl.flush();
1841
1791
  };
1842
1792
  _proto.destroy = function destroy() {};
1843
- _create_class(WebGLRenderer, [
1793
+ _create_class__default['default'](WebGLRenderer, [
1844
1794
  {
1845
1795
  key: "isWebGL2",
1846
1796
  get: function get() {
@@ -1887,13 +1837,13 @@ exports.WebGLMode = void 0;
1887
1837
  /**
1888
1838
  * WebGL platform engine,support includes WebGL1.0 and WebGL2.0.
1889
1839
  */ var WebGLEngine = /*#__PURE__*/ function(Engine) {
1890
- _inherits(WebGLEngine, Engine);
1840
+ _inherits__default['default'](WebGLEngine, Engine);
1891
1841
  function WebGLEngine(canvas, webGLRendererOptions) {
1892
1842
  var webCanvas = new WebCanvas(typeof canvas === "string" ? engineMiniprogramAdapter.document.getElementById(canvas) : canvas);
1893
1843
  var hardwareRenderer = new WebGLRenderer(webGLRendererOptions);
1894
1844
  return Engine.call(this, webCanvas, hardwareRenderer);
1895
1845
  }
1896
- _create_class(WebGLEngine, [
1846
+ _create_class__default['default'](WebGLEngine, [
1897
1847
  {
1898
1848
  key: "canvas",
1899
1849
  get: /**
package/dist/module.js CHANGED
@@ -1,5 +1,9 @@
1
+ import _create_class from '@swc/helpers/src/_create_class.mjs';
2
+ import _instanceof from '@swc/helpers/src/_instanceof.mjs';
1
3
  import { Vector2, Vector4, Color } from '@galacean/engine-math';
4
+ import _inherits from '@swc/helpers/src/_inherits.mjs';
2
5
  import { GLCapabilityType, Logger, TextureWrapMode, TextureFormat, RenderBufferDepthFormat, TextureFilterMode, TextureDepthCompareFunction, Texture, TextureCube, CameraClearFlags, ColorWriteMask, SystemInfo, Platform, Engine } from '@galacean/engine-core';
6
+ import _extends from '@swc/helpers/src/_extends.mjs';
3
7
 
4
8
  /**
5
9
  * Smoothing plug-in.
@@ -59,30 +63,6 @@ import { GLCapabilityType, Logger, TextureWrapMode, TextureFormat, RenderBufferD
59
63
  GLCompressedTextureInternalFormat[GLCompressedTextureInternalFormat["RGBA_S3TC_DXT5_EXT"] = 0x83f3] = "RGBA_S3TC_DXT5_EXT";
60
64
  })(GLCompressedTextureInternalFormat || (GLCompressedTextureInternalFormat = {}));
61
65
 
62
- function _defineProperties(target, props) {
63
- for (var i = 0; i < props.length; i++) {
64
- var descriptor = props[i];
65
- descriptor.enumerable = descriptor.enumerable || false;
66
- descriptor.configurable = true;
67
-
68
- if ("value" in descriptor) descriptor.writable = true;
69
-
70
- Object.defineProperty(target, descriptor.key, descriptor);
71
- }
72
- }
73
- function _create_class(Constructor, protoProps, staticProps) {
74
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
75
- if (staticProps) _defineProperties(Constructor, staticProps);
76
-
77
- return Constructor;
78
- }
79
-
80
- function _instanceof(left, right) {
81
- if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
82
- return !!right[Symbol.hasInstance](left);
83
- } else return left instanceof right;
84
- }
85
-
86
66
  /**
87
67
  * The canvas used on the web, which can support HTMLCanvasElement and OffscreenCanvas.
88
68
  */ var WebCanvas = /*#__PURE__*/ function() {
@@ -167,39 +147,6 @@ function _instanceof(left, right) {
167
147
  return WebCanvas;
168
148
  }();
169
149
 
170
- function _set_prototype_of(o, p) {
171
- _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
172
- o.__proto__ = p;
173
-
174
- return o;
175
- };
176
-
177
- return _set_prototype_of(o, p);
178
- }
179
-
180
- function _inherits(subClass, superClass) {
181
- if (typeof superClass !== "function" && superClass !== null) {
182
- throw new TypeError("Super expression must either be null or a function");
183
- }
184
-
185
- subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } });
186
-
187
- if (superClass) _set_prototype_of(subClass, superClass);
188
- }
189
-
190
- function _extends() {
191
- _extends = Object.assign || function assign(target) {
192
- for (var i = 1; i < arguments.length; i++) {
193
- var source = arguments[i];
194
- for (var key in source) if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
195
- }
196
-
197
- return target;
198
- };
199
-
200
- return _extends.apply(this, arguments);
201
- }
202
-
203
150
  /**
204
151
  * GL capability.
205
152
  */ var GLCapability = /*#__PURE__*/ function() {