@galacean/effects-threejs 1.1.1 → 1.1.3

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 threejs plugin for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v1.1.1
6
+ * Version: v1.1.3
7
7
  */
8
8
 
9
9
  'use strict';
@@ -9349,11 +9349,9 @@ var Matrix4 = /** @class */ (function () {
9349
9349
  var vX = Matrix4.tempVec0;
9350
9350
  var vY = Matrix4.tempVec1;
9351
9351
  var vZ = Matrix4.tempVec2;
9352
- vZ.subtractVectors(target, eye);
9352
+ vZ.subtractVectors(eye, target);
9353
9353
  vZ.normalize();
9354
- vY.copyFrom(up);
9355
- vY.normalize();
9356
- vX.crossVectors(vY, vZ);
9354
+ vX.crossVectors(up, vZ);
9357
9355
  vX.normalize();
9358
9356
  vY.crossVectors(vZ, vX);
9359
9357
  var te = this.elements;
@@ -16042,7 +16040,7 @@ function loadImage(source) {
16042
16040
  }
16043
16041
  // 2. 非法类型
16044
16042
  if (!url) {
16045
- throw new Error("Invalid url type: ".concat(source));
16043
+ throw new Error("Invalid url type: ".concat(JSON.stringify(source)));
16046
16044
  }
16047
16045
  return [2 /*return*/, new Promise(function (resolve, reject) {
16048
16046
  var img = new Image();
@@ -16061,7 +16059,7 @@ function loadImage(source) {
16061
16059
  if (revokeURL) {
16062
16060
  URL.revokeObjectURL(url);
16063
16061
  }
16064
- return reject("Load image fail: ".concat(e));
16062
+ return reject("Load image fail: ".concat(JSON.stringify(e)));
16065
16063
  };
16066
16064
  img.src = url;
16067
16065
  })];
@@ -19392,18 +19390,19 @@ var SpriteMesh = /** @class */ (function () {
19392
19390
  var uSizeStart = start + 4;
19393
19391
  var uQuatStart = start + 8;
19394
19392
  var uColorStart = start + 12;
19395
- if (!selfData.visible && !init) {
19396
- mainDataArray[uSizeStart + 2] = -1;
19397
- return;
19398
- }
19399
- var uColor = selfData.color || [mainDataArray[uColorStart], mainDataArray[uColorStart + 1], mainDataArray[uColorStart + 2], mainDataArray[uColorStart + 3]];
19400
- // if (selfData.startSize) {
19401
- // selfData.transform.scaleBy(1 / selfData.startSize[0], 1 / selfData.startSize[1], 1);
19402
- // }
19403
19393
  var tempPos = new Vector3();
19404
19394
  var tempQuat = new Quaternion();
19405
19395
  var tempScale = new Vector3();
19406
- selfData.transform.assignWorldTRS(tempPos, tempQuat, tempScale);
19396
+ var uColor = selfData.color || [mainDataArray[uColorStart], mainDataArray[uColorStart + 1], mainDataArray[uColorStart + 2], mainDataArray[uColorStart + 3]];
19397
+ if (selfData.visible) {
19398
+ selfData.transform.assignWorldTRS(tempPos, tempQuat, tempScale);
19399
+ }
19400
+ else {
19401
+ if (!init) {
19402
+ mainDataArray[uSizeStart + 2] = -1;
19403
+ return;
19404
+ }
19405
+ }
19407
19406
  var uPos = __spreadArray$2(__spreadArray$2([], __read$3(tempPos.toArray()), false), [0], false);
19408
19407
  var uSize = __spreadArray$2(__spreadArray$2([], __read$3(tempScale.toArray()), false), [0], false);
19409
19408
  var uQuat = tempQuat.toArray();
@@ -29194,6 +29193,7 @@ var CompositionSourceManager = /** @class */ (function () {
29194
29193
  var e_1, _a;
29195
29194
  this.refCompositions = new Map();
29196
29195
  this.refCompositionProps = new Map();
29196
+ this.mask = 0;
29197
29197
  // 资源
29198
29198
  var jsonScene = scene.jsonScene, renderLevel = scene.renderLevel, textureOptions = scene.textureOptions, pluginSystem = scene.pluginSystem, totalTime = scene.totalTime;
29199
29199
  var compositions = jsonScene.compositions, imgUsage = jsonScene.imgUsage, compositionId = jsonScene.compositionId;
@@ -29232,7 +29232,6 @@ var CompositionSourceManager = /** @class */ (function () {
29232
29232
  this.totalTime = totalTime !== null && totalTime !== void 0 ? totalTime : 0;
29233
29233
  this.imgUsage = imgUsage !== null && imgUsage !== void 0 ? imgUsage : {};
29234
29234
  this.textures = cachedTextures;
29235
- this.mask = 0;
29236
29235
  listOrder = 0;
29237
29236
  this.textureOptions = textureOptions;
29238
29237
  this.sourceContent = this.getContent(this.composition);
@@ -29257,10 +29256,6 @@ var CompositionSourceManager = /** @class */ (function () {
29257
29256
  CompositionSourceManager.prototype.assembleItems = function (composition) {
29258
29257
  var _this = this;
29259
29258
  var items = [];
29260
- var mask = this.mask;
29261
- if (isNaN(mask)) {
29262
- mask = 0;
29263
- }
29264
29259
  composition.items.forEach(function (item) {
29265
29260
  var _a;
29266
29261
  var option = {};
@@ -29276,15 +29271,7 @@ var CompositionSourceManager = /** @class */ (function () {
29276
29271
  option.type = type;
29277
29272
  if (renderContent.renderer) {
29278
29273
  renderContent.renderer = _this.changeTex(renderContent.renderer);
29279
- if (!renderContent.renderer.mask) {
29280
- var maskMode = renderContent.renderer.maskMode;
29281
- if (maskMode === MaskMode$1.MASK) {
29282
- renderContent.renderer.mask = ++mask;
29283
- }
29284
- else if (maskMode === MaskMode$1.OBSCURED || maskMode === MaskMode$1.REVERSE_OBSCURED) {
29285
- renderContent.renderer.mask = mask;
29286
- }
29287
- }
29274
+ _this.processMask(renderContent.renderer);
29288
29275
  var split = renderContent.splits && !renderContent.textureSheetAnimation && renderContent.splits[0];
29289
29276
  if (Number.isInteger(renderContent.renderer.shape)) {
29290
29277
  // TODO: scene.shapes 类型问题?
@@ -29329,16 +29316,18 @@ var CompositionSourceManager = /** @class */ (function () {
29329
29316
  }
29330
29317
  // 处理预合成的渲染顺序
29331
29318
  if (option.type === ItemType$1.composition) {
29319
+ ++_this.mask;
29332
29320
  var refId = item.content.options.refId;
29333
29321
  if (!_this.refCompositions.get(refId)) {
29334
29322
  throw new Error('Invalid Ref Composition id: ' + refId);
29335
29323
  }
29324
+ var ref = _this.getContent(_this.refCompositions.get(refId));
29336
29325
  if (!_this.refCompositionProps.has(refId)) {
29337
- _this.refCompositionProps.set(refId, _this.getContent(_this.refCompositions.get(refId)));
29326
+ _this.refCompositionProps.set(refId, ref);
29338
29327
  }
29339
- var ref = _this.refCompositionProps.get(refId);
29340
29328
  ref.items.forEach(function (item) {
29341
29329
  item.listIndex = listOrder++;
29330
+ _this.processMask(item.content);
29342
29331
  });
29343
29332
  option.items = ref.items;
29344
29333
  }
@@ -29374,6 +29363,23 @@ var CompositionSourceManager = /** @class */ (function () {
29374
29363
  }
29375
29364
  }
29376
29365
  };
29366
+ /**
29367
+ * 处理蒙版和遮挡关系写入 stencil 的 ref 值
29368
+ */
29369
+ CompositionSourceManager.prototype.processMask = function (renderer) {
29370
+ if (renderer.maskMode === MaskMode$1.NONE) {
29371
+ return;
29372
+ }
29373
+ if (!renderer.mask) {
29374
+ var maskMode = renderer.maskMode;
29375
+ if (maskMode === MaskMode$1.MASK) {
29376
+ renderer.mask = ++this.mask;
29377
+ }
29378
+ else if (maskMode === MaskMode$1.OBSCURED || maskMode === MaskMode$1.REVERSE_OBSCURED) {
29379
+ renderer.mask = this.mask;
29380
+ }
29381
+ }
29382
+ };
29377
29383
  CompositionSourceManager.prototype.dispose = function () {
29378
29384
  this.textureOptions = [];
29379
29385
  this.textures = [];
@@ -29448,7 +29454,7 @@ var AssetManager = /** @class */ (function () {
29448
29454
  waitPromise = new Promise(function (resolve, reject) {
29449
29455
  return loadTimer = window.setTimeout(function () {
29450
29456
  cancelLoading = true;
29451
- reject("Load time out: ".concat(url));
29457
+ reject("Load time out: ".concat(JSON.stringify(url)));
29452
29458
  }, _this.timeout * 1000);
29453
29459
  });
29454
29460
  hookTimeInfo = function (label, func) { return __awaiter(_this, void 0, void 0, function () {
@@ -29613,7 +29619,7 @@ var AssetManager = /** @class */ (function () {
29613
29619
  if (passRenderLevel(bin.renderLevel, renderLevel)) {
29614
29620
  return _this.loadBins(bin.url);
29615
29621
  }
29616
- throw new Error("Invalid bins source: ".concat(bins));
29622
+ throw new Error("Invalid bins source: ".concat(JSON.stringify(bins)));
29617
29623
  });
29618
29624
  return [2 /*return*/, Promise.all(jobs)];
29619
29625
  });
@@ -29649,7 +29655,7 @@ var AssetManager = /** @class */ (function () {
29649
29655
  case 3:
29650
29656
  _b.sent();
29651
29657
  console.warn({
29652
- content: "Invalid fonts source: ".concat(font.fontURL),
29658
+ content: "Invalid fonts source: ".concat(JSON.stringify(font.fontURL)),
29653
29659
  type: LOG_TYPE,
29654
29660
  });
29655
29661
  return [3 /*break*/, 4];
@@ -29818,7 +29824,7 @@ var AssetManager = /** @class */ (function () {
29818
29824
  return __generator(this, function (_a) {
29819
29825
  return [2 /*return*/, new Promise(function (resolve, reject) {
29820
29826
  _this.downloader.downloadJSON(url, resolve, function (status, responseText) {
29821
- reject("Couldn't load JSON ".concat(url, ": status ").concat(status, ", ").concat(responseText));
29827
+ reject("Couldn't load JSON ".concat(JSON.stringify(url), ": status ").concat(status, ", ").concat(responseText));
29822
29828
  });
29823
29829
  })];
29824
29830
  });
@@ -29830,7 +29836,7 @@ var AssetManager = /** @class */ (function () {
29830
29836
  return __generator(this, function (_a) {
29831
29837
  return [2 /*return*/, new Promise(function (resolve, reject) {
29832
29838
  _this.downloader.downloadBinary(url, resolve, function (status, responseText) {
29833
- reject("Couldn't load bins ".concat(url, ": status ").concat(status, ", ").concat(responseText));
29839
+ reject("Couldn't load bins ".concat(JSON.stringify(url), ": status ").concat(status, ", ").concat(responseText));
29834
29840
  });
29835
29841
  })];
29836
29842
  });
@@ -31176,7 +31182,10 @@ var Ticker = /** @class */ (function () {
31176
31182
  };
31177
31183
  Ticker.prototype.setFPS = function (fps) {
31178
31184
  this.targetFPS = clamp$1(fps, 1, 120);
31179
- this.interval = Math.floor(1000 / fps) - 1;
31185
+ // 注意:-2 的原因是保证帧率稳定
31186
+ // interval 在 fps 为 60 的时候设成 15 累计误差会很大,设成 14 较稳定
31187
+ // requestanimationFrame 在不同的刷新率下时间间隔不一样,120hz 的误差在 8 以内,60hz 的误差在 16 以内
31188
+ this.interval = Math.floor(1000 / fps) - 2;
31180
31189
  };
31181
31190
  /**
31182
31191
  * 获取定时器暂停标志位
@@ -32776,9 +32785,9 @@ Geometry.create = function (engine, options) {
32776
32785
  Mesh.create = function (engine, props) {
32777
32786
  return new ThreeMesh(engine, props);
32778
32787
  };
32779
- var version = "1.1.1";
32788
+ var version = "1.1.3";
32780
32789
  console.info({
32781
- content: '[Galacean Effects THREEJS] version: ' + "1.1.1",
32790
+ content: '[Galacean Effects THREEJS] version: ' + "1.1.3",
32782
32791
  type: LOG_TYPE,
32783
32792
  });
32784
32793