@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/alipay.js CHANGED
@@ -503,6 +503,10 @@ function isAndroid() {
503
503
  function isSimulatorCellPhone() {
504
504
  return isAndroid() || /\b(iPad|iPhone|iPod)\b/.test(alipay.navigator.userAgent);
505
505
  }
506
+ function isAlipayMiniApp() {
507
+ //@ts-expect-error
508
+ return typeof my !== 'undefined' && (my === null || my === void 0 ? void 0 : my.renderTarget) === 'web';
509
+ }
506
510
 
507
511
  function imageDataFromColor(value) {
508
512
  if (isString(value)) {
@@ -24249,7 +24253,7 @@ var AssetManager = /** @class */ (function () {
24249
24253
  _a = this.options, useCompressedTexture = _a.useCompressedTexture, variables = _a.variables;
24250
24254
  baseUrl = this.baseUrl;
24251
24255
  jobs = images.map(function (img, idx) { return __awaiter(_this, void 0, void 0, function () {
24252
- var png, webp, imageURL, webpURL, template, isTemplateV2, background, url_1, isVideo, loadFn, resultImage, resultImage, compressed, src, bufferURL, _a, url, image;
24256
+ var png, webp, imageURL, webpURL, template, isTemplateV2, background, url_1, isVideo, loadFn, resultImage, e_3, resultImage, compressed, src, bufferURL, _a, url, image;
24253
24257
  return __generator(this, function (_b) {
24254
24258
  switch (_b.label) {
24255
24259
  case 0:
@@ -24284,8 +24288,8 @@ var AssetManager = /** @class */ (function () {
24284
24288
  case 4: return [2 /*return*/, _b.sent()];
24285
24289
  case 5: return [3 /*break*/, 7];
24286
24290
  case 6:
24287
- _b.sent();
24288
- throw new Error("Failed to load. Check the template or if the URL is ".concat(isVideo ? 'video' : 'image', " type, URL: ").concat(url_1, "."));
24291
+ e_3 = _b.sent();
24292
+ 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));
24289
24293
  case 7: return [3 /*break*/, 12];
24290
24294
  case 8:
24291
24295
  _b.trys.push([8, 11, , 12]);
@@ -25637,7 +25641,7 @@ var Composition = /** @class */ (function () {
25637
25641
  }());
25638
25642
 
25639
25643
  /**
25640
- * Engine 基类,负责维护所有 GPU 资源的销毁
25644
+ * Engine 基类,负责维护所有 GPU 资源的管理及销毁
25641
25645
  */
25642
25646
  var Engine = /** @class */ (function () {
25643
25647
  function Engine() {
@@ -25647,6 +25651,10 @@ var Engine = /** @class */ (function () {
25647
25651
  this.geometries = [];
25648
25652
  this.meshes = [];
25649
25653
  this.renderPasses = [];
25654
+ /**
25655
+ * 渲染过程中错误队列
25656
+ */
25657
+ this.renderErrors = new Set();
25650
25658
  }
25651
25659
  Engine.prototype.addTexture = function (tex) {
25652
25660
  if (this.destroyed) {
@@ -26490,7 +26498,6 @@ var GLRendererInternal = /** @class */ (function () {
26490
26498
  var glMaterial = material;
26491
26499
  var program = glMaterial.shader.program;
26492
26500
  if (!program) {
26493
- console.warn('Material ' + glMaterial.name + ' 的shader着色器程序未初始化。');
26494
26501
  return;
26495
26502
  }
26496
26503
  var vao = program.setupAttributes(glGeometry);
@@ -26574,13 +26581,8 @@ var GLRendererInternal = /** @class */ (function () {
26574
26581
  logger.error('gl lost, destroy glRenderer by default', e.target);
26575
26582
  this.deleteResource();
26576
26583
  };
26577
- GLRendererInternal.prototype.dispose = function (haltGL) {
26584
+ GLRendererInternal.prototype.dispose = function () {
26578
26585
  this.deleteResource();
26579
- var gl = this.gl;
26580
- if (gl && haltGL) {
26581
- var ex = gl.getExtension('WEBGL_lose_context');
26582
- ex === null || ex === void 0 ? void 0 : ex.loseContext();
26583
- }
26584
26586
  // @ts-expect-error safe to assign
26585
26587
  this.emptyTexture2D = this.emptyTextureCube = this.pipelineContext = this.gpu = this.gl = null;
26586
26588
  this.destroyed = true;
@@ -27598,29 +27600,34 @@ var GLMaterial = /** @class */ (function (_super) {
27598
27600
  };
27599
27601
  GLMaterial.prototype.use = function (renderer, globalUniforms) {
27600
27602
  var e_1, _a, e_2, _b;
27603
+ var _c;
27601
27604
  var engine = renderer.engine;
27602
27605
  var pipelineContext = engine.getGLPipelineContext();
27606
+ if (!this.shader.program) {
27607
+ (_c = this.engine) === null || _c === void 0 ? void 0 : _c.renderErrors.add(new Error('Shader program is not initialized'));
27608
+ return;
27609
+ }
27603
27610
  this.shader.program.bind();
27604
27611
  this.setupStates(pipelineContext);
27605
27612
  var name;
27606
27613
  if (globalUniforms) {
27607
27614
  try {
27608
27615
  // 加入全局 uniform 名称
27609
- for (var _c = __values$1(globalUniforms.uniforms), _d = _c.next(); !_d.done; _d = _c.next()) {
27610
- name = _d.value;
27616
+ for (var _d = __values$1(globalUniforms.uniforms), _e = _d.next(); !_e.done; _e = _d.next()) {
27617
+ name = _e.value;
27611
27618
  this.checkUniform(name);
27612
27619
  }
27613
27620
  }
27614
27621
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
27615
27622
  finally {
27616
27623
  try {
27617
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
27624
+ if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
27618
27625
  }
27619
27626
  finally { if (e_1) throw e_1.error; }
27620
27627
  }
27621
27628
  try {
27622
- for (var _e = __values$1(globalUniforms.samplers), _f = _e.next(); !_f.done; _f = _e.next()) {
27623
- name = _f.value;
27629
+ for (var _f = __values$1(globalUniforms.samplers), _g = _f.next(); !_g.done; _g = _f.next()) {
27630
+ name = _g.value;
27624
27631
  if (!this.samplers.includes(name)) {
27625
27632
  this.samplers.push(name);
27626
27633
  this.uniformDirtyFlag = true;
@@ -27630,7 +27637,7 @@ var GLMaterial = /** @class */ (function (_super) {
27630
27637
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
27631
27638
  finally {
27632
27639
  try {
27633
- if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
27640
+ if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
27634
27641
  }
27635
27642
  finally { if (e_2) throw e_2.error; }
27636
27643
  }
@@ -28150,6 +28157,31 @@ var GLContextManager = /** @class */ (function () {
28150
28157
  return GLContextManager;
28151
28158
  }());
28152
28159
 
28160
+ var GLEngine = /** @class */ (function (_super) {
28161
+ __extends(GLEngine, _super);
28162
+ function GLEngine(gl) {
28163
+ var _this = _super.call(this) || this;
28164
+ _this.gpuCapability = new GPUCapability(gl);
28165
+ return _this;
28166
+ }
28167
+ GLEngine.prototype.dispose = function () {
28168
+ if (this.isDestroyed) {
28169
+ return;
28170
+ }
28171
+ _super.prototype.dispose.call(this);
28172
+ };
28173
+ GLEngine.prototype.getGLRenderer = function () {
28174
+ return this.renderer;
28175
+ };
28176
+ GLEngine.prototype.getGLRendererInternal = function () {
28177
+ return this.getGLRenderer().glRenderer;
28178
+ };
28179
+ GLEngine.prototype.getGLPipelineContext = function () {
28180
+ return this.getGLRenderer().pipelineContext;
28181
+ };
28182
+ return GLEngine;
28183
+ }(Engine));
28184
+
28153
28185
  var GLRenderBuffer = /** @class */ (function (_super) {
28154
28186
  __extends(GLRenderBuffer, _super);
28155
28187
  function GLRenderBuffer(props, renderer) {
@@ -29691,31 +29723,6 @@ var GLPipelineContext = /** @class */ (function () {
29691
29723
  return GLPipelineContext;
29692
29724
  }());
29693
29725
 
29694
- var GLEngine = /** @class */ (function (_super) {
29695
- __extends(GLEngine, _super);
29696
- function GLEngine(gl) {
29697
- var _this = _super.call(this) || this;
29698
- _this.gpuCapability = new GPUCapability(gl);
29699
- return _this;
29700
- }
29701
- GLEngine.prototype.dispose = function () {
29702
- if (this.isDestroyed) {
29703
- return;
29704
- }
29705
- _super.prototype.dispose.call(this);
29706
- };
29707
- GLEngine.prototype.getGLRenderer = function () {
29708
- return this.renderer;
29709
- };
29710
- GLEngine.prototype.getGLRendererInternal = function () {
29711
- return this.getGLRenderer().glRenderer;
29712
- };
29713
- GLEngine.prototype.getGLPipelineContext = function () {
29714
- return this.getGLRenderer().pipelineContext;
29715
- };
29716
- return GLEngine;
29717
- }(Engine));
29718
-
29719
29726
  var GLRenderer = /** @class */ (function (_super) {
29720
29727
  __extends(GLRenderer, _super);
29721
29728
  function GLRenderer(canvas, framework, renderOptions) {
@@ -29993,12 +30000,12 @@ var GLRenderer = /** @class */ (function (_super) {
29993
30000
  GLRenderer.prototype.getHeight = function () {
29994
30001
  return this.height;
29995
30002
  };
29996
- GLRenderer.prototype.dispose = function (haltGL) {
30003
+ GLRenderer.prototype.dispose = function () {
29997
30004
  var _a;
29998
30005
  this.context.dispose();
29999
30006
  this.extension.dispose();
30000
30007
  this.pipelineContext.dispose();
30001
- (_a = this.glRenderer) === null || _a === void 0 ? void 0 : _a.dispose(haltGL);
30008
+ (_a = this.glRenderer) === null || _a === void 0 ? void 0 : _a.dispose();
30002
30009
  // @ts-expect-error
30003
30010
  this.canvas = null;
30004
30011
  this.engine.dispose();
@@ -30548,7 +30555,14 @@ var Player = /** @class */ (function () {
30548
30555
  };
30549
30556
  Player.prototype.doTick = function (dt, forceRender) {
30550
30557
  var _this = this;
30551
- var _a, _b, _c;
30558
+ var _a, _b, _c, _d, _e;
30559
+ var renderErrors = this.renderer.engine.renderErrors;
30560
+ // TODO: 临时处理,2.0.0 做优化
30561
+ if (renderErrors.size > 0) {
30562
+ (_a = this.handleRenderError) === null || _a === void 0 ? void 0 : _a.call(this, renderErrors.values().next().value);
30563
+ // 有渲染错误时暂停播放
30564
+ (_b = this.ticker) === null || _b === void 0 ? void 0 : _b.pause();
30565
+ }
30552
30566
  dt = Math.min(dt, 33) * this.speed;
30553
30567
  var comps = this.compositions;
30554
30568
  var skipRender = false;
@@ -30571,8 +30585,8 @@ var Player = /** @class */ (function () {
30571
30585
  }
30572
30586
  this.baseCompositionIndex = this.compositions.length;
30573
30587
  if (skipRender) {
30574
- (_a = this.handleRenderError) === null || _a === void 0 ? void 0 : _a.call(this, new Error('play when texture offloaded'));
30575
- return (_b = this.ticker) === null || _b === void 0 ? void 0 : _b.pause();
30588
+ (_c = this.handleRenderError) === null || _c === void 0 ? void 0 : _c.call(this, new Error('play when texture offloaded'));
30589
+ return (_d = this.ticker) === null || _d === void 0 ? void 0 : _d.pause();
30576
30590
  }
30577
30591
  if (!this.paused || forceRender) {
30578
30592
  var level = this.gpuCapability.level;
@@ -30596,7 +30610,7 @@ var Player = /** @class */ (function () {
30596
30610
  time === null || time === void 0 ? void 0 : time.end();
30597
30611
  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;
30598
30612
  if (this.autoPlaying) {
30599
- (_c = this.handlePlayableUpdate) === null || _c === void 0 ? void 0 : _c.call(this, {
30613
+ (_e = this.handlePlayableUpdate) === null || _e === void 0 ? void 0 : _e.call(this, {
30600
30614
  player: this,
30601
30615
  playing: true,
30602
30616
  });
@@ -30921,7 +30935,7 @@ Renderer.create = function (canvas, framework, renderOptions) {
30921
30935
  Engine.create = function (gl) {
30922
30936
  return new GLEngine(gl);
30923
30937
  };
30924
- var version = "1.5.0-alpha.0";
30938
+ var version = "1.5.0";
30925
30939
  logger.info('player version: ' + version);
30926
30940
 
30927
30941
  exports.AbstractPlugin = AbstractPlugin;
@@ -31107,6 +31121,7 @@ exports.initErrors = initErrors;
31107
31121
  exports.initGLContext = initGLContext;
31108
31122
  exports.integrate = integrate;
31109
31123
  exports.interpolateColor = interpolateColor;
31124
+ exports.isAlipayMiniApp = isAlipayMiniApp;
31110
31125
  exports.isAndroid = isAndroid;
31111
31126
  exports.isArray = isArray;
31112
31127
  exports.isCanvasUsedByPlayer = isCanvasUsedByPlayer;