@galacean/effects-threejs 2.0.0-alpha.25 → 2.0.0-alpha.26

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: v2.0.0-alpha.25
6
+ * Version: v2.0.0-alpha.26
7
7
  */
8
8
 
9
9
  'use strict';
@@ -4515,8 +4515,8 @@ var index$1 = /*#__PURE__*/Object.freeze({
4515
4515
  BuiltinObjectGUID: BuiltinObjectGUID
4516
4516
  });
4517
4517
 
4518
- var decoratorInitialStore = {};
4519
- var mergedStore = {};
4518
+ var decoratorInitialStore = new Map();
4519
+ var mergedStore = new Map();
4520
4520
  var effectsClassStore = {};
4521
4521
  function effectsClass(className) {
4522
4522
  return function(target, context) {
@@ -4531,22 +4531,22 @@ function serialize(type, sourceName) {
4531
4531
  return generateSerializableMember(type, sourceName); // value member
4532
4532
  }
4533
4533
  function getMergedStore(target) {
4534
- var classKey = target.constructor.name;
4535
- if (mergedStore[classKey]) {
4536
- return mergedStore[classKey];
4534
+ var classKey = target.constructor;
4535
+ if (mergedStore.get(classKey)) {
4536
+ return mergedStore.get(classKey);
4537
4537
  }
4538
- mergedStore[classKey] = {};
4539
- var store = mergedStore[classKey];
4538
+ var store = {};
4539
+ mergedStore.set(classKey, store);
4540
4540
  var currentTarget = target;
4541
4541
  var currentKey = classKey;
4542
4542
  while(currentKey){
4543
- var initialStore = decoratorInitialStore[currentKey];
4543
+ var initialStore = decoratorInitialStore.get(currentKey);
4544
4544
  for(var property in initialStore){
4545
4545
  store[property] = initialStore[property];
4546
4546
  }
4547
4547
  var parent = Object.getPrototypeOf(currentTarget);
4548
- currentKey = Object.getPrototypeOf(parent).constructor.name;
4549
- if (currentKey === "Object") {
4548
+ currentKey = Object.getPrototypeOf(parent).constructor;
4549
+ if (currentKey === Object) {
4550
4550
  break;
4551
4551
  }
4552
4552
  currentTarget = parent;
@@ -4556,6 +4556,9 @@ function getMergedStore(target) {
4556
4556
  function generateSerializableMember(type, sourceName) {
4557
4557
  return function(target, propertyKey) {
4558
4558
  var classStore = getDirectStore(target);
4559
+ if (!classStore) {
4560
+ return;
4561
+ }
4559
4562
  if (!classStore[propertyKey]) {
4560
4563
  classStore[propertyKey] = {
4561
4564
  type: type,
@@ -4565,11 +4568,11 @@ function generateSerializableMember(type, sourceName) {
4565
4568
  };
4566
4569
  }
4567
4570
  function getDirectStore(target) {
4568
- var classKey = target.constructor.name;
4569
- if (!decoratorInitialStore[classKey]) {
4570
- decoratorInitialStore[classKey] = {};
4571
+ var classKey = target.constructor;
4572
+ if (!decoratorInitialStore.get(classKey)) {
4573
+ decoratorInitialStore.set(classKey, {});
4571
4574
  }
4572
- return decoratorInitialStore[classKey];
4575
+ return decoratorInitialStore.get(classKey);
4573
4576
  }
4574
4577
 
4575
4578
  /**
@@ -19691,7 +19694,7 @@ var TextComponentBase = /*#__PURE__*/ function() {
19691
19694
  _proto.updateWithOptions = function updateWithOptions(options) {
19692
19695
  this.textStyle = new TextStyle(options);
19693
19696
  this.textLayout = new TextLayout(options);
19694
- this.text = options.text;
19697
+ this.text = options.text.toString();
19695
19698
  this.lineCount = this.getLineCount(options.text, true);
19696
19699
  };
19697
19700
  _proto.getLineCount = function getLineCount(text, init) {
@@ -19762,7 +19765,7 @@ var TextComponentBase = /*#__PURE__*/ function() {
19762
19765
  if (this.text === value) {
19763
19766
  return;
19764
19767
  }
19765
- this.text = value;
19768
+ this.text = value.toString();
19766
19769
  this.lineCount = this.getLineCount(value, false);
19767
19770
  this.isDirty = true;
19768
19771
  };
@@ -20871,29 +20874,31 @@ var SerializationHelper = /*#__PURE__*/ function() {
20871
20874
  effectsObject.toData();
20872
20875
  res[effectsObject.getInstanceId()] = effectsObject;
20873
20876
  var serializedProperties = getMergedStore(effectsObject);
20874
- for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(serializedProperties)), _step; !(_step = _iterator()).done;){
20875
- var key = _step.value;
20876
- // TODO 待移除,序列化属性通过 effectsObject 对象直接获取
20877
- var value = effectsObject.taggedProperties[key];
20878
- if (value === undefined) {
20879
- value = effectsObject[key];
20880
- }
20881
- if (EffectsObject.is(value)) {
20882
- SerializationHelper.collectSerializableObject(value, res);
20883
- } else if (isArray(value)) {
20884
- for(var _iterator1 = _create_for_of_iterator_helper_loose(value), _step1; !(_step1 = _iterator1()).done;){
20885
- var arrayValue = _step1.value;
20886
- if (EffectsObject.is(arrayValue)) {
20887
- SerializationHelper.collectSerializableObject(arrayValue, res);
20888
- }
20877
+ if (serializedProperties) {
20878
+ for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(serializedProperties)), _step; !(_step = _iterator()).done;){
20879
+ var key = _step.value;
20880
+ // TODO 待移除,序列化属性通过 effectsObject 对象直接获取
20881
+ var value = effectsObject.taggedProperties[key];
20882
+ if (value === undefined) {
20883
+ value = effectsObject[key];
20889
20884
  }
20890
- } else if (isObject(value)) {
20891
- // 非 EffectsObject 对象只递归一层
20892
- for(var _iterator2 = _create_for_of_iterator_helper_loose(Object.keys(value)), _step2; !(_step2 = _iterator2()).done;){
20893
- var objectKey = _step2.value;
20894
- var objectValue = value[objectKey];
20895
- if (EffectsObject.is(objectValue)) {
20896
- SerializationHelper.collectSerializableObject(objectValue, res);
20885
+ if (EffectsObject.is(value)) {
20886
+ SerializationHelper.collectSerializableObject(value, res);
20887
+ } else if (isArray(value)) {
20888
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(value), _step1; !(_step1 = _iterator1()).done;){
20889
+ var arrayValue = _step1.value;
20890
+ if (EffectsObject.is(arrayValue)) {
20891
+ SerializationHelper.collectSerializableObject(arrayValue, res);
20892
+ }
20893
+ }
20894
+ } else if (isObject(value)) {
20895
+ // 非 EffectsObject 对象只递归一层
20896
+ for(var _iterator2 = _create_for_of_iterator_helper_loose(Object.keys(value)), _step2; !(_step2 = _iterator2()).done;){
20897
+ var objectKey = _step2.value;
20898
+ var objectValue = value[objectKey];
20899
+ if (EffectsObject.is(objectValue)) {
20900
+ SerializationHelper.collectSerializableObject(objectValue, res);
20901
+ }
20897
20902
  }
20898
20903
  }
20899
20904
  }
@@ -20924,27 +20929,29 @@ var SerializationHelper = /*#__PURE__*/ function() {
20924
20929
  serializedData = {};
20925
20930
  }
20926
20931
  var serializedProperties = getMergedStore(effectsObject);
20927
- for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(serializedProperties)), _step; !(_step = _iterator()).done;){
20928
- var key = _step.value;
20929
- var value = effectsObject[key];
20930
- if (typeof value === "number" || typeof value === "string" || typeof value === "boolean" || SerializationHelper.checkTypedArray(value)) {
20931
- // TODO json 数据避免传 typedArray
20932
- serializedData[key] = value;
20933
- } else if (isArray(value)) {
20934
- if (!serializedData[key]) {
20935
- serializedData[key] = [];
20936
- }
20937
- SerializationHelper.serializeArrayProperty(value, serializedData[key], 0);
20938
- } else if (EffectsObject.is(value)) {
20939
- // TODO 处理 EffectsObject 递归序列化
20940
- serializedData[key] = {
20941
- id: value.getInstanceId()
20942
- };
20943
- } else if (isObject(value)) {
20944
- if (!serializedData[key]) {
20945
- serializedData[key] = {};
20932
+ if (serializedProperties) {
20933
+ for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(serializedProperties)), _step; !(_step = _iterator()).done;){
20934
+ var key = _step.value;
20935
+ var value = effectsObject[key];
20936
+ if (typeof value === "number" || typeof value === "string" || typeof value === "boolean" || SerializationHelper.checkTypedArray(value)) {
20937
+ // TODO json 数据避免传 typedArray
20938
+ serializedData[key] = value;
20939
+ } else if (isArray(value)) {
20940
+ if (!serializedData[key]) {
20941
+ serializedData[key] = [];
20942
+ }
20943
+ SerializationHelper.serializeArrayProperty(value, serializedData[key], 0);
20944
+ } else if (EffectsObject.is(value)) {
20945
+ // TODO 处理 EffectsObject 递归序列化
20946
+ serializedData[key] = {
20947
+ id: value.getInstanceId()
20948
+ };
20949
+ } else if (isObject(value)) {
20950
+ if (!serializedData[key]) {
20951
+ serializedData[key] = {};
20952
+ }
20953
+ SerializationHelper.serializeObjectProperty(value, serializedData[key], 0);
20946
20954
  }
20947
- SerializationHelper.serializeObjectProperty(value, serializedData[key], 0);
20948
20955
  }
20949
20956
  }
20950
20957
  // TODO 待移除 tagggedProperties 为没有装饰器的临时方案
@@ -20979,22 +20986,24 @@ var SerializationHelper = /*#__PURE__*/ function() {
20979
20986
  var engine = effectsObject.engine;
20980
20987
  for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(serializedData)), _step; !(_step = _iterator()).done;){
20981
20988
  var key = _step.value;
20982
- if (serializedProperties[key]) {
20989
+ if (serializedProperties && serializedProperties[key]) {
20983
20990
  continue;
20984
20991
  }
20985
20992
  var value = serializedData[key];
20986
20993
  taggedProperties[key] = SerializationHelper.deserializeProperty(value, engine, 0);
20987
20994
  }
20988
- for(var _iterator1 = _create_for_of_iterator_helper_loose(Object.keys(serializedProperties)), _step1; !(_step1 = _iterator1()).done;){
20989
- var key1 = _step1.value;
20990
- var value1 = serializedData[key1];
20991
- if (value1 === undefined) {
20992
- continue;
20995
+ if (serializedProperties) {
20996
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(Object.keys(serializedProperties)), _step1; !(_step1 = _iterator1()).done;){
20997
+ var key1 = _step1.value;
20998
+ var value1 = serializedData[key1];
20999
+ if (value1 === undefined) {
21000
+ continue;
21001
+ }
21002
+ var propertyType = serializedProperties[key1].type;
21003
+ // FIXME: taggedProperties 为 readonly,这里存在强制赋值
21004
+ // @ts-expect-error
21005
+ effectsObject[key1] = SerializationHelper.deserializeProperty(value1, engine, 0, propertyType);
20993
21006
  }
20994
- var propertyType = serializedProperties[key1].type;
20995
- // FIXME: taggedProperties 为 readonly,这里存在强制赋值
20996
- // @ts-expect-error
20997
- effectsObject[key1] = SerializationHelper.deserializeProperty(value1, engine, 0, propertyType);
20998
21007
  }
20999
21008
  effectsObject.fromData(taggedProperties);
21000
21009
  };
@@ -21015,7 +21024,7 @@ var SerializationHelper = /*#__PURE__*/ function() {
21015
21024
  4
21016
21025
  ];
21017
21026
  key = _step.value;
21018
- if (serializedProperties[key]) {
21027
+ if (serializedProperties && serializedProperties[key]) {
21019
21028
  return [
21020
21029
  3,
21021
21030
  3
@@ -21035,6 +21044,10 @@ var SerializationHelper = /*#__PURE__*/ function() {
21035
21044
  1
21036
21045
  ];
21037
21046
  case 4:
21047
+ if (!serializedProperties) return [
21048
+ 3,
21049
+ 8
21050
+ ];
21038
21051
  _iterator1 = _create_for_of_iterator_helper_loose(Object.keys(serializedProperties));
21039
21052
  _state.label = 5;
21040
21053
  case 5:
@@ -24154,11 +24167,13 @@ var tmpScale = new Vector3(1, 1, 1);
24154
24167
  * 获取归一化坐标和 3D 世界坐标的换算比例
24155
24168
  * @param z - 当前的位置 z
24156
24169
  */ _proto.getInverseVPRatio = function getInverseVPRatio(z) {
24157
- var pos = new Vector3(0, 0, z);
24170
+ var pos = new Vector3(this.position.x, this.position.y, z);
24158
24171
  var mat = this.getViewProjectionMatrix();
24159
24172
  var inverseVP = this.getInverseViewProjectionMatrix();
24160
24173
  var _mat_projectPoint = mat.projectPoint(pos), nz = _mat_projectPoint.z;
24161
- return inverseVP.projectPoint(new Vector3(1, 1, nz));
24174
+ var _inverseVP_projectPoint = inverseVP.projectPoint(new Vector3(1, 1, nz)), xMax = _inverseVP_projectPoint.x, yMax = _inverseVP_projectPoint.y;
24175
+ var _inverseVP_projectPoint1 = inverseVP.projectPoint(new Vector3(-1, -1, nz)), xMin = _inverseVP_projectPoint1.x, yMin = _inverseVP_projectPoint1.y;
24176
+ return new Vector3((xMax - xMin) / 2, (yMax - yMin) / 2, 0);
24162
24177
  };
24163
24178
  /**
24164
24179
  * 设置相机的旋转四元数
@@ -24811,6 +24826,7 @@ var listOrder = 0;
24811
24826
  // this.extraCamera?.getComponent(TimelineComponent)?.update(deltaTime);
24812
24827
  this.updateCamera();
24813
24828
  if (this.shouldDispose()) {
24829
+ this.onEnd == null ? void 0 : this.onEnd.call(this, this);
24814
24830
  this.dispose();
24815
24831
  } else {
24816
24832
  if (!skipRender) {
@@ -25737,7 +25753,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem, true);
25737
25753
  registerPlugin("particle", ParticleLoader, exports.VFXItem, true);
25738
25754
  registerPlugin("cal", CalculateLoader, exports.VFXItem, true);
25739
25755
  registerPlugin("interact", InteractLoader, exports.VFXItem, true);
25740
- var version$1 = "2.0.0-alpha.25";
25756
+ var version$1 = "2.0.0-alpha.26";
25741
25757
  logger.info("Core version: " + version$1 + ".");
25742
25758
 
25743
25759
  var _obj;
@@ -27370,7 +27386,7 @@ setMaxSpriteMeshItemCount(8);
27370
27386
  */ Mesh.create = function(engine, props) {
27371
27387
  return new ThreeMesh(engine, props);
27372
27388
  };
27373
- var version = "2.0.0-alpha.25";
27389
+ var version = "2.0.0-alpha.26";
27374
27390
  logger.info("THREEJS plugin version: " + version + ".");
27375
27391
 
27376
27392
  exports.AbstractPlugin = AbstractPlugin;