@galacean/effects 1.5.0-alpha.0 → 1.5.0

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/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects runtime player for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v1.5.0-alpha.0
6
+ * Version: v1.5.0
7
7
  */
8
8
 
9
9
  'use strict';
@@ -509,6 +509,10 @@ function isAndroid() {
509
509
  function isSimulatorCellPhone() {
510
510
  return isAndroid() || /\b(iPad|iPhone|iPod)\b/.test(navigator.userAgent);
511
511
  }
512
+ function isAlipayMiniApp() {
513
+ //@ts-expect-error
514
+ return typeof my !== 'undefined' && (my === null || my === void 0 ? void 0 : my.renderTarget) === 'web';
515
+ }
512
516
 
513
517
  function imageDataFromColor(value) {
514
518
  if (isString(value)) {
@@ -24255,7 +24259,7 @@ var AssetManager = /** @class */ (function () {
24255
24259
  _a = this.options, useCompressedTexture = _a.useCompressedTexture, variables = _a.variables;
24256
24260
  baseUrl = this.baseUrl;
24257
24261
  jobs = images.map(function (img, idx) { return __awaiter(_this, void 0, void 0, function () {
24258
- var png, webp, imageURL, webpURL, template, isTemplateV2, background, url_1, isVideo, loadFn, resultImage, resultImage, compressed, src, bufferURL, _a, url, image;
24262
+ var png, webp, imageURL, webpURL, template, isTemplateV2, background, url_1, isVideo, loadFn, resultImage, e_3, resultImage, compressed, src, bufferURL, _a, url, image;
24259
24263
  return __generator(this, function (_b) {
24260
24264
  switch (_b.label) {
24261
24265
  case 0:
@@ -24290,8 +24294,8 @@ var AssetManager = /** @class */ (function () {
24290
24294
  case 4: return [2 /*return*/, _b.sent()];
24291
24295
  case 5: return [3 /*break*/, 7];
24292
24296
  case 6:
24293
- _b.sent();
24294
- throw new Error("Failed to load. Check the template or if the URL is ".concat(isVideo ? 'video' : 'image', " type, URL: ").concat(url_1, "."));
24297
+ e_3 = _b.sent();
24298
+ throw new Error("Failed to load. Check the template or if the URL is ".concat(isVideo ? 'video' : 'image', " type, URL: ").concat(url_1, ", Error: ").concat(e_3.message));
24295
24299
  case 7: return [3 /*break*/, 12];
24296
24300
  case 8:
24297
24301
  _b.trys.push([8, 11, , 12]);
@@ -25643,7 +25647,7 @@ var Composition = /** @class */ (function () {
25643
25647
  }());
25644
25648
 
25645
25649
  /**
25646
- * Engine 基类,负责维护所有 GPU 资源的销毁
25650
+ * Engine 基类,负责维护所有 GPU 资源的管理及销毁
25647
25651
  */
25648
25652
  var Engine = /** @class */ (function () {
25649
25653
  function Engine() {
@@ -25653,6 +25657,10 @@ var Engine = /** @class */ (function () {
25653
25657
  this.geometries = [];
25654
25658
  this.meshes = [];
25655
25659
  this.renderPasses = [];
25660
+ /**
25661
+ * 渲染过程中错误队列
25662
+ */
25663
+ this.renderErrors = new Set();
25656
25664
  }
25657
25665
  Engine.prototype.addTexture = function (tex) {
25658
25666
  if (this.destroyed) {
@@ -26496,7 +26504,6 @@ var GLRendererInternal = /** @class */ (function () {
26496
26504
  var glMaterial = material;
26497
26505
  var program = glMaterial.shader.program;
26498
26506
  if (!program) {
26499
- console.warn('Material ' + glMaterial.name + ' 的shader着色器程序未初始化。');
26500
26507
  return;
26501
26508
  }
26502
26509
  var vao = program.setupAttributes(glGeometry);
@@ -26580,13 +26587,8 @@ var GLRendererInternal = /** @class */ (function () {
26580
26587
  logger.error('gl lost, destroy glRenderer by default', e.target);
26581
26588
  this.deleteResource();
26582
26589
  };
26583
- GLRendererInternal.prototype.dispose = function (haltGL) {
26590
+ GLRendererInternal.prototype.dispose = function () {
26584
26591
  this.deleteResource();
26585
- var gl = this.gl;
26586
- if (gl && haltGL) {
26587
- var ex = gl.getExtension('WEBGL_lose_context');
26588
- ex === null || ex === void 0 ? void 0 : ex.loseContext();
26589
- }
26590
26592
  // @ts-expect-error safe to assign
26591
26593
  this.emptyTexture2D = this.emptyTextureCube = this.pipelineContext = this.gpu = this.gl = null;
26592
26594
  this.destroyed = true;
@@ -27604,29 +27606,34 @@ var GLMaterial = /** @class */ (function (_super) {
27604
27606
  };
27605
27607
  GLMaterial.prototype.use = function (renderer, globalUniforms) {
27606
27608
  var e_1, _a, e_2, _b;
27609
+ var _c;
27607
27610
  var engine = renderer.engine;
27608
27611
  var pipelineContext = engine.getGLPipelineContext();
27612
+ if (!this.shader.program) {
27613
+ (_c = this.engine) === null || _c === void 0 ? void 0 : _c.renderErrors.add(new Error('Shader program is not initialized'));
27614
+ return;
27615
+ }
27609
27616
  this.shader.program.bind();
27610
27617
  this.setupStates(pipelineContext);
27611
27618
  var name;
27612
27619
  if (globalUniforms) {
27613
27620
  try {
27614
27621
  // 加入全局 uniform 名称
27615
- for (var _c = __values$1(globalUniforms.uniforms), _d = _c.next(); !_d.done; _d = _c.next()) {
27616
- name = _d.value;
27622
+ for (var _d = __values$1(globalUniforms.uniforms), _e = _d.next(); !_e.done; _e = _d.next()) {
27623
+ name = _e.value;
27617
27624
  this.checkUniform(name);
27618
27625
  }
27619
27626
  }
27620
27627
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
27621
27628
  finally {
27622
27629
  try {
27623
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
27630
+ if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
27624
27631
  }
27625
27632
  finally { if (e_1) throw e_1.error; }
27626
27633
  }
27627
27634
  try {
27628
- for (var _e = __values$1(globalUniforms.samplers), _f = _e.next(); !_f.done; _f = _e.next()) {
27629
- name = _f.value;
27635
+ for (var _f = __values$1(globalUniforms.samplers), _g = _f.next(); !_g.done; _g = _f.next()) {
27636
+ name = _g.value;
27630
27637
  if (!this.samplers.includes(name)) {
27631
27638
  this.samplers.push(name);
27632
27639
  this.uniformDirtyFlag = true;
@@ -27636,7 +27643,7 @@ var GLMaterial = /** @class */ (function (_super) {
27636
27643
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
27637
27644
  finally {
27638
27645
  try {
27639
- if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
27646
+ if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
27640
27647
  }
27641
27648
  finally { if (e_2) throw e_2.error; }
27642
27649
  }
@@ -28156,6 +28163,31 @@ var GLContextManager = /** @class */ (function () {
28156
28163
  return GLContextManager;
28157
28164
  }());
28158
28165
 
28166
+ var GLEngine = /** @class */ (function (_super) {
28167
+ __extends(GLEngine, _super);
28168
+ function GLEngine(gl) {
28169
+ var _this = _super.call(this) || this;
28170
+ _this.gpuCapability = new GPUCapability(gl);
28171
+ return _this;
28172
+ }
28173
+ GLEngine.prototype.dispose = function () {
28174
+ if (this.isDestroyed) {
28175
+ return;
28176
+ }
28177
+ _super.prototype.dispose.call(this);
28178
+ };
28179
+ GLEngine.prototype.getGLRenderer = function () {
28180
+ return this.renderer;
28181
+ };
28182
+ GLEngine.prototype.getGLRendererInternal = function () {
28183
+ return this.getGLRenderer().glRenderer;
28184
+ };
28185
+ GLEngine.prototype.getGLPipelineContext = function () {
28186
+ return this.getGLRenderer().pipelineContext;
28187
+ };
28188
+ return GLEngine;
28189
+ }(Engine));
28190
+
28159
28191
  var GLRenderBuffer = /** @class */ (function (_super) {
28160
28192
  __extends(GLRenderBuffer, _super);
28161
28193
  function GLRenderBuffer(props, renderer) {
@@ -29697,31 +29729,6 @@ var GLPipelineContext = /** @class */ (function () {
29697
29729
  return GLPipelineContext;
29698
29730
  }());
29699
29731
 
29700
- var GLEngine = /** @class */ (function (_super) {
29701
- __extends(GLEngine, _super);
29702
- function GLEngine(gl) {
29703
- var _this = _super.call(this) || this;
29704
- _this.gpuCapability = new GPUCapability(gl);
29705
- return _this;
29706
- }
29707
- GLEngine.prototype.dispose = function () {
29708
- if (this.isDestroyed) {
29709
- return;
29710
- }
29711
- _super.prototype.dispose.call(this);
29712
- };
29713
- GLEngine.prototype.getGLRenderer = function () {
29714
- return this.renderer;
29715
- };
29716
- GLEngine.prototype.getGLRendererInternal = function () {
29717
- return this.getGLRenderer().glRenderer;
29718
- };
29719
- GLEngine.prototype.getGLPipelineContext = function () {
29720
- return this.getGLRenderer().pipelineContext;
29721
- };
29722
- return GLEngine;
29723
- }(Engine));
29724
-
29725
29732
  var GLRenderer = /** @class */ (function (_super) {
29726
29733
  __extends(GLRenderer, _super);
29727
29734
  function GLRenderer(canvas, framework, renderOptions) {
@@ -29999,12 +30006,12 @@ var GLRenderer = /** @class */ (function (_super) {
29999
30006
  GLRenderer.prototype.getHeight = function () {
30000
30007
  return this.height;
30001
30008
  };
30002
- GLRenderer.prototype.dispose = function (haltGL) {
30009
+ GLRenderer.prototype.dispose = function () {
30003
30010
  var _a;
30004
30011
  this.context.dispose();
30005
30012
  this.extension.dispose();
30006
30013
  this.pipelineContext.dispose();
30007
- (_a = this.glRenderer) === null || _a === void 0 ? void 0 : _a.dispose(haltGL);
30014
+ (_a = this.glRenderer) === null || _a === void 0 ? void 0 : _a.dispose();
30008
30015
  // @ts-expect-error
30009
30016
  this.canvas = null;
30010
30017
  this.engine.dispose();
@@ -30554,7 +30561,14 @@ var Player = /** @class */ (function () {
30554
30561
  };
30555
30562
  Player.prototype.doTick = function (dt, forceRender) {
30556
30563
  var _this = this;
30557
- var _a, _b, _c;
30564
+ var _a, _b, _c, _d, _e;
30565
+ var renderErrors = this.renderer.engine.renderErrors;
30566
+ // TODO: 临时处理,2.0.0 做优化
30567
+ if (renderErrors.size > 0) {
30568
+ (_a = this.handleRenderError) === null || _a === void 0 ? void 0 : _a.call(this, renderErrors.values().next().value);
30569
+ // 有渲染错误时暂停播放
30570
+ (_b = this.ticker) === null || _b === void 0 ? void 0 : _b.pause();
30571
+ }
30558
30572
  dt = Math.min(dt, 33) * this.speed;
30559
30573
  var comps = this.compositions;
30560
30574
  var skipRender = false;
@@ -30577,8 +30591,8 @@ var Player = /** @class */ (function () {
30577
30591
  }
30578
30592
  this.baseCompositionIndex = this.compositions.length;
30579
30593
  if (skipRender) {
30580
- (_a = this.handleRenderError) === null || _a === void 0 ? void 0 : _a.call(this, new Error('play when texture offloaded'));
30581
- return (_b = this.ticker) === null || _b === void 0 ? void 0 : _b.pause();
30594
+ (_c = this.handleRenderError) === null || _c === void 0 ? void 0 : _c.call(this, new Error('play when texture offloaded'));
30595
+ return (_d = this.ticker) === null || _d === void 0 ? void 0 : _d.pause();
30582
30596
  }
30583
30597
  if (!this.paused || forceRender) {
30584
30598
  var level = this.gpuCapability.level;
@@ -30602,7 +30616,7 @@ var Player = /** @class */ (function () {
30602
30616
  time === null || time === void 0 ? void 0 : time.end();
30603
30617
  time === null || time === void 0 ? void 0 : time.getTime().then(function (t) { var _a; return (_a = _this.reportGPUTime) === null || _a === void 0 ? void 0 : _a.call(_this, t !== null && t !== void 0 ? t : 0); }).catch;
30604
30618
  if (this.autoPlaying) {
30605
- (_c = this.handlePlayableUpdate) === null || _c === void 0 ? void 0 : _c.call(this, {
30619
+ (_e = this.handlePlayableUpdate) === null || _e === void 0 ? void 0 : _e.call(this, {
30606
30620
  player: this,
30607
30621
  playing: true,
30608
30622
  });
@@ -30927,7 +30941,7 @@ Renderer.create = function (canvas, framework, renderOptions) {
30927
30941
  Engine.create = function (gl) {
30928
30942
  return new GLEngine(gl);
30929
30943
  };
30930
- var version = "1.5.0-alpha.0";
30944
+ var version = "1.5.0";
30931
30945
  logger.info('player version: ' + version);
30932
30946
 
30933
30947
  exports.AbstractPlugin = AbstractPlugin;
@@ -31113,6 +31127,7 @@ exports.initErrors = initErrors;
31113
31127
  exports.initGLContext = initGLContext;
31114
31128
  exports.integrate = integrate;
31115
31129
  exports.interpolateColor = interpolateColor;
31130
+ exports.isAlipayMiniApp = isAlipayMiniApp;
31116
31131
  exports.isAndroid = isAndroid;
31117
31132
  exports.isArray = isArray;
31118
31133
  exports.isCanvasUsedByPlayer = isCanvasUsedByPlayer;