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