@galacean/effects-core 2.0.0-alpha.14 → 2.0.0-alpha.16

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.mjs CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects runtime core for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v2.0.0-alpha.14
6
+ * Version: v2.0.0-alpha.16
7
7
  */
8
8
 
9
9
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
@@ -593,6 +593,11 @@ function noop() {}
593
593
  */ function isObject(obj) {
594
594
  return Object.prototype.toString.call(obj) === '[object Object]';
595
595
  }
596
+ function isCanvas(canvas) {
597
+ var _canvas_tagName;
598
+ // 小程序 Canvas 无法使用 instanceof HTMLCanvasElement 判断
599
+ return typeof canvas === 'object' && canvas !== null && ((_canvas_tagName = canvas.tagName) == null ? void 0 : _canvas_tagName.toUpperCase()) === 'CANVAS';
600
+ }
596
601
  function deepClone(obj) {
597
602
  if (isArray(obj)) {
598
603
  return obj.map(deepClone);
@@ -620,6 +625,35 @@ function throwDestroyedError() {
620
625
  function generateGUID() {
621
626
  return v4().replace(/-/g, '');
622
627
  }
628
+ function base64ToFile(base64, filename = 'base64File', contentType = '') {
629
+ // 去掉 Base64 字符串的 Data URL 部分(如果存在)
630
+ const base64WithoutPrefix = base64.split(',')[1] || base64;
631
+ // 将 base64 编码的字符串转换为二进制字符串
632
+ const byteCharacters = atob(base64WithoutPrefix);
633
+ // 创建一个 8 位无符号整数值的数组,即“字节数组”
634
+ const byteArrays = [];
635
+ // 切割二进制字符串为多个片段,并将每个片段转换成一个字节数组
636
+ for(let offset = 0; offset < byteCharacters.length; offset += 512){
637
+ const slice = byteCharacters.slice(offset, offset + 512);
638
+ const byteNumbers = new Array(slice.length);
639
+ for(let i = 0; i < slice.length; i++){
640
+ byteNumbers[i] = slice.charCodeAt(i);
641
+ }
642
+ const byteArray = new Uint8Array(byteNumbers);
643
+ byteArrays.push(byteArray);
644
+ }
645
+ // 使用字节数组创建 Blob 对象
646
+ const blob = new Blob(byteArrays, {
647
+ type: contentType
648
+ });
649
+ // 创建 File 对象
650
+ const file = new File([
651
+ blob
652
+ ], filename, {
653
+ type: contentType
654
+ });
655
+ return file;
656
+ }
623
657
 
624
658
  function __decorate(decorators, target, key, desc) {
625
659
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -12740,13 +12774,16 @@ const tempColor = [
12740
12774
  let seed$3 = 0;
12741
12775
  class SpriteColorPlayable extends Playable {
12742
12776
  processFrame(context) {
12743
- const boundItem = context.output.getUserData();
12777
+ const boundObject = context.output.getUserData();
12778
+ if (!(boundObject instanceof VFXItem)) {
12779
+ return;
12780
+ }
12744
12781
  if (!this.spriteMaterial) {
12745
- this.spriteMaterial = boundItem.getComponent(SpriteComponent).material;
12782
+ this.spriteMaterial = boundObject.getComponent(SpriteComponent).material;
12746
12783
  }
12747
12784
  let colorInc = vecFill(tempColor, 1);
12748
12785
  let colorChanged;
12749
- const life = this.time / boundItem.duration;
12786
+ const life = this.time / boundObject.duration;
12750
12787
  const opacityOverLifetime = this.opacityOverLifetime;
12751
12788
  const colorOverLifetime = this.colorOverLifetime;
12752
12789
  if (colorOverLifetime) {
@@ -12845,7 +12882,6 @@ class SpriteComponent extends RendererComponent {
12845
12882
  renderer.drawGeometry(geo, material);
12846
12883
  }
12847
12884
  start() {
12848
- this.priority = this.item.listIndex;
12849
12885
  this.item.getHitTestParams = this.getHitTestParams;
12850
12886
  }
12851
12887
  update(dt) {
@@ -15214,7 +15250,7 @@ function getTrailMeshShader(trails, particleMaxCount, name, env = '', gpuCapabil
15214
15250
  * @internal
15215
15251
  */ class ParticleSystemRenderer extends RendererComponent {
15216
15252
  start() {
15217
- this._priority = this.item.listIndex;
15253
+ this._priority = this.item.renderOrder;
15218
15254
  this.particleMesh.gravityModifier.scaleXCoord(this.item.duration);
15219
15255
  for (const mesh of this.meshes){
15220
15256
  mesh.start();
@@ -16244,13 +16280,13 @@ function randomArrItem(arr, keepArr) {
16244
16280
  * @internal
16245
16281
  */ class ParticleBehaviourPlayable extends Playable {
16246
16282
  start(context) {
16247
- const binding = context.output.getUserData();
16248
- if (this.particleSystem) {
16283
+ const boundObject = context.output.getUserData();
16284
+ if (this.particleSystem || !(boundObject instanceof VFXItem)) {
16249
16285
  return;
16250
16286
  }
16251
- this.particleSystem = binding.getComponent(ParticleSystem);
16287
+ this.particleSystem = boundObject.getComponent(ParticleSystem);
16252
16288
  if (this.particleSystem) {
16253
- this.particleSystem.name = binding.name;
16289
+ this.particleSystem.name = boundObject.name;
16254
16290
  this.particleSystem.start();
16255
16291
  this.particleSystem.initEmitterTransform();
16256
16292
  }
@@ -17370,10 +17406,13 @@ const tempPos = new Vector3();
17370
17406
  }
17371
17407
  processFrame(context) {
17372
17408
  if (!this.binding) {
17373
- this.binding = context.output.getUserData();
17374
- this.start();
17409
+ const boundObject = context.output.getUserData();
17410
+ if (boundObject instanceof VFXItem) {
17411
+ this.binding = boundObject;
17412
+ this.start();
17413
+ }
17375
17414
  }
17376
- if (this.binding.composition) {
17415
+ if (this.binding && this.binding.composition) {
17377
17416
  this.sampleAnimation();
17378
17417
  }
17379
17418
  }
@@ -17541,24 +17580,26 @@ AnimationClip = __decorate([
17541
17580
  ], AnimationClip);
17542
17581
  class AnimationClipPlayable extends Playable {
17543
17582
  processFrame(context) {
17544
- const boundItem = context.output.getUserData();
17545
- if (boundItem.composition) {
17546
- this.clip.sampleAnimation(boundItem, this.time);
17583
+ const boundObject = context.output.getUserData();
17584
+ if (!(boundObject instanceof VFXItem)) {
17585
+ return;
17586
+ }
17587
+ if (boundObject.composition) {
17588
+ this.clip.sampleAnimation(boundObject, this.time);
17547
17589
  }
17548
17590
  }
17549
17591
  }
17550
17592
 
17551
17593
  class TrackAsset extends PlayableAsset {
17552
- initializeBinding(parentBinding) {
17553
- this.binding = parentBinding;
17594
+ /**
17595
+ * 重写该方法以获取自定义对象绑定
17596
+ */ resolveBinding(parentBinding) {
17597
+ return parentBinding;
17554
17598
  }
17555
17599
  /**
17556
- * @internal
17557
- */ initializeBindingRecursive(parentBinding) {
17558
- this.initializeBinding(parentBinding);
17559
- for (const subTrack of this.children){
17560
- subTrack.initializeBindingRecursive(this.binding);
17561
- }
17600
+ * 重写该方法以创建自定义混合器
17601
+ */ createTrackMixer(graph) {
17602
+ return new Playable(graph);
17562
17603
  }
17563
17604
  createOutput() {
17564
17605
  const output = new PlayableOutput();
@@ -17587,11 +17628,6 @@ class TrackAsset extends PlayableAsset {
17587
17628
  }
17588
17629
  return mixer;
17589
17630
  }
17590
- /**
17591
- * 重写该方法以创建自定义混合器
17592
- */ createTrackMixer(graph) {
17593
- return new Playable(graph);
17594
- }
17595
17631
  createPlayable(graph) {
17596
17632
  return new Playable(graph);
17597
17633
  }
@@ -17732,13 +17768,6 @@ class RuntimeClip {
17732
17768
  class ObjectBindingTrack extends TrackAsset {
17733
17769
  create(timelineAsset) {
17734
17770
  const boundItem = this.binding;
17735
- this.options = {
17736
- start: boundItem.start,
17737
- duration: boundItem.duration,
17738
- looping: boundItem.endBehavior === ItemEndBehavior.loop,
17739
- endBehavior: boundItem.endBehavior || ItemEndBehavior.destroy
17740
- };
17741
- this.name = boundItem.name;
17742
17771
  // 添加粒子动画 clip
17743
17772
  if (boundItem.getComponent(ParticleSystem)) {
17744
17773
  const particleTrack = timelineAsset.createTrack(TrackAsset, this, 'ParticleTrack');
@@ -17749,18 +17778,6 @@ class ObjectBindingTrack extends TrackAsset {
17749
17778
  particleClip.endBehaviour = boundItem.endBehavior;
17750
17779
  }
17751
17780
  }
17752
- toLocalTime(time) {
17753
- let localTime = time - this.options.start;
17754
- const duration = this.options.duration;
17755
- if (localTime - duration > 0.001) {
17756
- if (this.options.endBehavior === END_BEHAVIOR_RESTART) {
17757
- localTime = localTime % duration;
17758
- } else if (this.options.endBehavior === END_BEHAVIOR_FREEZE) {
17759
- localTime = Math.min(duration, localTime);
17760
- }
17761
- }
17762
- return localTime;
17763
- }
17764
17781
  fromData(data) {
17765
17782
  super.fromData(data);
17766
17783
  this.data = data;
@@ -17778,13 +17795,11 @@ TransformTrack = __decorate([
17778
17795
 
17779
17796
  class ActivationMixerPlayable extends Playable {
17780
17797
  processFrame(context) {
17781
- if (!this.bindingItem) {
17782
- this.bindingItem = context.output.getUserData();
17783
- }
17784
- if (!this.bindingItem) {
17798
+ const boundObject = context.output.getUserData();
17799
+ if (!(boundObject instanceof VFXItem)) {
17785
17800
  return;
17786
17801
  }
17787
- const bindingItem = this.bindingItem;
17802
+ const boundItem = boundObject;
17788
17803
  let hasInput = false;
17789
17804
  for(let i = 0; i < this.getInputCount(); i++){
17790
17805
  if (this.getInputWeight(i) > 0) {
@@ -17793,11 +17808,11 @@ class ActivationMixerPlayable extends Playable {
17793
17808
  }
17794
17809
  }
17795
17810
  if (hasInput) {
17796
- bindingItem.transform.setValid(true);
17797
- this.showRendererComponents(bindingItem);
17811
+ boundItem.transform.setValid(true);
17812
+ this.showRendererComponents(boundItem);
17798
17813
  } else {
17799
- bindingItem.transform.setValid(false);
17800
- this.hideRendererComponents(bindingItem);
17814
+ boundItem.transform.setValid(false);
17815
+ this.hideRendererComponents(boundItem);
17801
17816
  }
17802
17817
  }
17803
17818
  hideRendererComponents(item) {
@@ -17817,9 +17832,6 @@ class ActivationMixerPlayable extends Playable {
17817
17832
  }
17818
17833
 
17819
17834
  class ActivationTrack extends TrackAsset {
17820
- initializeBinding(parentBinding) {
17821
- this.binding = parentBinding;
17822
- }
17823
17835
  createTrackMixer(graph) {
17824
17836
  return new ActivationMixerPlayable(graph);
17825
17837
  }
@@ -17836,7 +17848,6 @@ SpriteColorTrack = __decorate([
17836
17848
 
17837
17849
  class TimelineAsset extends PlayableAsset {
17838
17850
  createPlayable(graph) {
17839
- this.graph = graph;
17840
17851
  const timelinePlayable = new TimelinePlayable(graph);
17841
17852
  timelinePlayable.setTraversalMode(PlayableTraversalMode.Passthrough);
17842
17853
  for (const track of this.tracks){
@@ -17947,179 +17958,415 @@ function compareTracks(a, b) {
17947
17958
  }
17948
17959
  }
17949
17960
 
17950
- class TextLayout {
17951
- getOffsetY(style) {
17952
- let offsetY = 0;
17953
- const offset = (style.fontSize + style.outlineWidth) * style.fontScale;
17954
- switch(this.textBaseline){
17955
- case TextBaseline.top:
17956
- offsetY = offset;
17957
- break;
17958
- case TextBaseline.middle:
17959
- offsetY = (this.height + offset) / 2; // fonSize;
17960
- break;
17961
- case TextBaseline.bottom:
17962
- offsetY = this.height - offset / 2;
17963
- break;
17961
+ /**
17962
+ * @since 2.0.0
17963
+ * @internal
17964
+ */ class CompositionComponent extends ItemBehaviour {
17965
+ start() {
17966
+ const { startTime = 0 } = this.item.props;
17967
+ this.startTime = startTime;
17968
+ this.resolveBindings();
17969
+ this.timelinePlayable = this.timelineAsset.createPlayable(this.graph);
17970
+ this.timelinePlayable.play();
17971
+ // 重播不销毁元素
17972
+ if (this.item.endBehavior !== ItemEndBehavior.destroy) {
17973
+ this.setReusable(true);
17964
17974
  }
17965
- return offsetY;
17966
17975
  }
17967
- getOffsetX(style, maxWidth) {
17968
- let offsetX = 0;
17969
- switch(this.textAlign){
17970
- case TextAlignment.left:
17971
- offsetX = style.outlineWidth * style.fontScale;
17972
- break;
17973
- case TextAlignment.middle:
17974
- offsetX = (this.width * style.fontScale - maxWidth) / 2;
17975
- break;
17976
- case TextAlignment.right:
17977
- offsetX = this.width * style.fontScale - maxWidth;
17978
- break;
17976
+ setReusable(value) {
17977
+ for (const track of this.timelineAsset.tracks){
17978
+ const binding = track.binding;
17979
+ if (binding instanceof VFXItem) {
17980
+ if (track instanceof ObjectBindingTrack) {
17981
+ binding.reusable = value;
17982
+ }
17983
+ const subCompositionComponent = binding.getComponent(CompositionComponent);
17984
+ if (subCompositionComponent) {
17985
+ subCompositionComponent.setReusable(value);
17986
+ }
17987
+ }
17979
17988
  }
17980
- return offsetX;
17981
- }
17982
- /**
17983
- * 设置文本框的宽度和高度
17984
- * @param width 文本框宽度
17985
- * @param height 文本框高度
17986
- */ setSize(width, height) {
17987
- this.width = width;
17988
- this.height = height;
17989
17989
  }
17990
- constructor(options){
17991
- this.width = 0;
17992
- this.height = 0;
17993
- const { textHeight = 100, textWidth = 100, textOverflow = TextOverflow.display, textBaseline = TextBaseline.top, textAlign = TextAlignment.left, text, letterSpace = 0, autoWidth = false, fontSize, lineHeight = fontSize } = options;
17994
- const tempWidth = fontSize + letterSpace;
17995
- this.autoWidth = autoWidth;
17996
- this.maxTextWidth = text.length * tempWidth;
17997
- // if (autoWidth) {
17998
- // this.width = this.maxTextWidth + this.lineWidth;
17999
- // this.height = fontSize + this.lineHeight;
18000
- // } else {
18001
- // if (textWidth) {
18002
- // this.maxCharCount = Math.floor((textWidth - this.lineWidth) / (tempWidth));
18003
- // this.width = textWidth;
18004
- // } else {
18005
- // this.width = basicScale[0] * 100;
18006
- // }
18007
- // this.height = basicScale[1] * 100;
18008
- // }
18009
- this.width = textWidth;
18010
- this.height = textHeight;
18011
- this.letterSpace = letterSpace;
18012
- this.overFlow = textOverflow;
18013
- this.textBaseline = textBaseline;
18014
- this.textAlign = textAlign;
18015
- this.lineHeight = lineHeight;
17990
+ getReusable() {
17991
+ return this.reusable;
18016
17992
  }
18017
- }
18018
-
18019
- class TextStyle {
18020
- constructor(options){
18021
- /**
18022
- * 是否有下划线(暂时无效)
18023
- */ this.isUnderline = false // ttf
18024
- ;
18025
- /**
18026
- * 下划线高度(暂时无效)
18027
- */ this.underlineHeight = 1 // ttf
18028
- ;
18029
- /**
18030
- * 是否有外描边
18031
- */ this.isOutlined = false // both // ttf & char
18032
- ;
18033
- /**
18034
- * 外描边宽度
18035
- */ this.outlineWidth = 0 // both // ttf & char
18036
- ;
18037
- /**
18038
- * 是否有阴影
18039
- */ this.hasShadow = false // ttf
18040
- ;
18041
- this.fontDesc = '' // both
18042
- ;
18043
- /**
18044
- * 字体倍数
18045
- */ this.fontScale = 2;
18046
- this.fontOffset = 0;
18047
- const { textColor = [
18048
- 1,
18049
- 1,
18050
- 1,
18051
- 1
18052
- ], fontSize = 40, outline, shadow, fontWeight = 'normal', fontStyle = 'normal', fontFamily = 'sans-serif' } = options;
18053
- this.textColor = textColor;
18054
- //@ts-expect-error
18055
- this.textWeight = fontWeight;
18056
- //@ts-expect-error
18057
- this.fontStyle = fontStyle;
18058
- this.fontFamily = fontFamily;
18059
- this.fontSize = fontSize; // 暂时取消字号限制 Math.min(fontSize, this.maxFontSize);
18060
- if (outline) {
18061
- this.isOutlined = true;
18062
- var _outline_outlineColor;
18063
- this.outlineColor = (_outline_outlineColor = outline.outlineColor) != null ? _outline_outlineColor : [
18064
- 1,
18065
- 1,
18066
- 1,
18067
- 1
18068
- ];
18069
- var _outline_outlineWidth;
18070
- this.outlineWidth = (_outline_outlineWidth = outline.outlineWidth) != null ? _outline_outlineWidth : 1;
18071
- this.fontOffset += this.outlineWidth;
18072
- }
18073
- if (shadow) {
18074
- this.hasShadow = true;
18075
- var _shadow_shadowBlur;
18076
- this.shadowBlur = (_shadow_shadowBlur = shadow.shadowBlur) != null ? _shadow_shadowBlur : 2;
18077
- var _shadow_shadowColor;
18078
- this.shadowColor = (_shadow_shadowColor = shadow.shadowColor) != null ? _shadow_shadowColor : [
18079
- 0,
18080
- 0,
18081
- 0,
18082
- 1
18083
- ];
18084
- var _shadow_shadowOffsetX;
18085
- this.shadowOffsetX = (_shadow_shadowOffsetX = shadow.shadowOffsetX) != null ? _shadow_shadowOffsetX : 0;
18086
- var _shadow_shadowOffsetY;
18087
- this.shadowOffsetY = (_shadow_shadowOffsetY = shadow.shadowOffsetY) != null ? _shadow_shadowOffsetY : 0;
18088
- }
18089
- if (this.fontStyle !== FontStyle.normal) {
18090
- // 0.0174532925 = 3.141592653 / 180
18091
- this.fontOffset += this.fontSize * Math.tan(12 * 0.0174532925);
17993
+ update(dt) {
17994
+ const time = this.time;
17995
+ // 主合成 rootItem 没有绑定轨道,增加结束行为判断。
17996
+ if (this.item.isEnded(this.time) && !this.item.parent) {
17997
+ this.item.ended = true;
18092
17998
  }
17999
+ this.timelinePlayable.setTime(time);
18000
+ this.graph.evaluate(dt);
18093
18001
  }
18094
- }
18095
-
18096
- class CanvasPool {
18097
- dispose() {
18098
- this.elements.forEach((e)=>e.remove());
18099
- // clearing the array
18100
- this.elements.length = 0;
18101
- }
18102
- getCanvas() {
18103
- if (this.elements.length !== 0) {
18104
- return this.elements.shift();
18105
- }
18106
- if (getConfig(TEMPLATE_USE_OFFSCREEN_CANVAS)) {
18107
- // @ts-expect-error
18108
- return window._createOffscreenCanvas(10, 10);
18109
- } else {
18110
- // in hongmeng system, create too many canvas will case render error
18111
- const defCanvas = document.createElement('canvas');
18112
- defCanvas.getContext('2d', {
18113
- willReadFrequently: true
18002
+ createContent() {
18003
+ const sceneBindings = [];
18004
+ for (const sceneBindingData of this.data.sceneBindings){
18005
+ sceneBindings.push({
18006
+ key: this.engine.assetLoader.loadGUID(sceneBindingData.key.id),
18007
+ value: this.engine.assetLoader.loadGUID(sceneBindingData.value.id)
18114
18008
  });
18115
- return defCanvas;
18116
18009
  }
18117
- }
18118
- saveCanvas(canvas) {
18119
- canvas.width = 1;
18120
- canvas.height = 1;
18121
- if (this.elements.length < 3) {
18122
- addItem(this.elements, canvas);
18010
+ this.sceneBindings = sceneBindings;
18011
+ const timelineAsset = this.data.timelineAsset ? this.engine.assetLoader.loadGUID(this.data.timelineAsset.id) : new TimelineAsset(this.engine);
18012
+ this.timelineAsset = timelineAsset;
18013
+ const items = this.items;
18014
+ this.items.length = 0;
18015
+ if (this.item.composition) {
18016
+ const assetLoader = this.item.engine.assetLoader;
18017
+ const itemProps = this.item.props.items ? this.item.props.items : [];
18018
+ for(let i = 0; i < itemProps.length; i++){
18019
+ let item;
18020
+ const itemData = itemProps[i];
18021
+ // 设置预合成作为元素时的时长、结束行为和渲染延时
18022
+ if (Item.isComposition(itemData)) {
18023
+ const refId = itemData.content.options.refId;
18024
+ const props = this.item.composition.refCompositionProps.get(refId);
18025
+ if (!props) {
18026
+ throw new Error(`引用的Id: ${refId} 的预合成不存在`);
18027
+ }
18028
+ // endBehaviour 类型需优化
18029
+ props.content = itemData.content;
18030
+ item = assetLoader.loadGUID(itemData.id);
18031
+ item.composition = this.item.composition;
18032
+ const compositionComponent = item.addComponent(CompositionComponent);
18033
+ compositionComponent.data = props;
18034
+ compositionComponent.refId = refId;
18035
+ item.transform.parentTransform = this.transform;
18036
+ this.item.composition.refContent.push(item);
18037
+ if (item.endBehavior === ItemEndBehavior.loop) {
18038
+ this.item.composition.autoRefTex = false;
18039
+ }
18040
+ compositionComponent.createContent();
18041
+ for (const vfxItem of compositionComponent.items){
18042
+ vfxItem.setInstanceId(generateGUID());
18043
+ for (const component of vfxItem.components){
18044
+ component.setInstanceId(generateGUID());
18045
+ }
18046
+ }
18047
+ } else {
18048
+ item = assetLoader.loadGUID(itemData.id);
18049
+ item.composition = this.item.composition;
18050
+ }
18051
+ item.parent = this.item;
18052
+ // 相机不跟随合成移动
18053
+ item.transform.parentTransform = itemData.type === ItemType.camera ? new Transform() : this.transform;
18054
+ if (VFXItem.isExtraCamera(item)) {
18055
+ this.item.composition.extraCamera = item;
18056
+ }
18057
+ items.push(item);
18058
+ }
18059
+ }
18060
+ }
18061
+ onDestroy() {
18062
+ if (this.item.composition) {
18063
+ if (this.items) {
18064
+ this.items.forEach((item)=>item.dispose());
18065
+ this.items.length = 0;
18066
+ }
18067
+ }
18068
+ }
18069
+ hitTest(ray, x, y, regions, force, options) {
18070
+ const hitPositions = [];
18071
+ const stop = (options == null ? void 0 : options.stop) || noop;
18072
+ const skip = (options == null ? void 0 : options.skip) || noop;
18073
+ const maxCount = (options == null ? void 0 : options.maxCount) || this.items.length;
18074
+ for(let i = 0; i < this.items.length && regions.length < maxCount; i++){
18075
+ const item = this.items[i];
18076
+ if (item.getVisible() && !item.ended && !VFXItem.isComposition(item) && !skip(item)) {
18077
+ const hitParams = item.getHitTestParams(force);
18078
+ if (hitParams) {
18079
+ let success = false;
18080
+ const intersectPoint = new Vector3();
18081
+ if (hitParams.type === HitTestType.triangle) {
18082
+ const { triangles, backfaceCulling } = hitParams;
18083
+ for(let j = 0; j < triangles.length; j++){
18084
+ const triangle = triangles[j];
18085
+ if (ray.intersectTriangle(triangle, intersectPoint, backfaceCulling)) {
18086
+ success = true;
18087
+ hitPositions.push(intersectPoint);
18088
+ break;
18089
+ }
18090
+ }
18091
+ } else if (hitParams.type === HitTestType.box) {
18092
+ const { center, size } = hitParams;
18093
+ const boxMin = center.clone().addScaledVector(size, 0.5);
18094
+ const boxMax = center.clone().addScaledVector(size, -0.5);
18095
+ if (ray.intersectBox({
18096
+ min: boxMin,
18097
+ max: boxMax
18098
+ }, intersectPoint)) {
18099
+ success = true;
18100
+ hitPositions.push(intersectPoint);
18101
+ }
18102
+ } else if (hitParams.type === HitTestType.sphere) {
18103
+ const { center, radius } = hitParams;
18104
+ if (ray.intersectSphere({
18105
+ center,
18106
+ radius
18107
+ }, intersectPoint)) {
18108
+ success = true;
18109
+ hitPositions.push(intersectPoint);
18110
+ }
18111
+ } else if (hitParams.type === HitTestType.custom) {
18112
+ const tempPosition = hitParams.collect(ray, new Vector2(x, y));
18113
+ if (tempPosition && tempPosition.length > 0) {
18114
+ tempPosition.forEach((pos)=>{
18115
+ hitPositions.push(pos);
18116
+ });
18117
+ success = true;
18118
+ }
18119
+ }
18120
+ if (success) {
18121
+ const region = {
18122
+ compContent: this.item,
18123
+ id: item.id,
18124
+ name: item.name,
18125
+ position: hitPositions[hitPositions.length - 1],
18126
+ parentId: item.parentId,
18127
+ hitPositions,
18128
+ behavior: hitParams.behavior
18129
+ };
18130
+ regions.push(region);
18131
+ if (stop(region)) {
18132
+ return regions;
18133
+ }
18134
+ }
18135
+ }
18136
+ }
18137
+ }
18138
+ return regions;
18139
+ }
18140
+ fromData(data) {}
18141
+ resolveBindings() {
18142
+ for (const sceneBinding of this.sceneBindings){
18143
+ sceneBinding.key.binding = sceneBinding.value;
18144
+ }
18145
+ for (const masterTrack of this.timelineAsset.tracks){
18146
+ this.resolveTrackBindingsWithRoot(masterTrack);
18147
+ }
18148
+ }
18149
+ resolveTrackBindingsWithRoot(track) {
18150
+ for (const subTrack of track.getChildTracks()){
18151
+ subTrack.binding = subTrack.resolveBinding(track.binding);
18152
+ this.resolveTrackBindingsWithRoot(subTrack);
18153
+ }
18154
+ }
18155
+ constructor(...args){
18156
+ super(...args);
18157
+ this.time = 0;
18158
+ this.startTime = 0;
18159
+ this.items = [] // 场景的所有元素
18160
+ ;
18161
+ this.reusable = false;
18162
+ this.sceneBindings = [];
18163
+ this.graph = new PlayableGraph();
18164
+ }
18165
+ }
18166
+
18167
+ class SubCompositionTrack extends TrackAsset {
18168
+ resolveBinding(parentBinding) {
18169
+ if (!(parentBinding instanceof VFXItem)) {
18170
+ throw new Error('SubCompositionTrack needs to be set under the VFXItem track');
18171
+ }
18172
+ return parentBinding.getComponent(CompositionComponent);
18173
+ }
18174
+ }
18175
+ SubCompositionTrack = __decorate([
18176
+ effectsClass('SubCompositionTrack')
18177
+ ], SubCompositionTrack);
18178
+
18179
+ class SubCompositionClipPlayable extends Playable {
18180
+ processFrame(context) {
18181
+ const boundObject = context.output.getUserData();
18182
+ if (boundObject instanceof CompositionComponent) {
18183
+ boundObject.time = this.getTime();
18184
+ }
18185
+ }
18186
+ }
18187
+
18188
+ class SubCompositionPlayableAsset extends PlayableAsset {
18189
+ createPlayable(graph) {
18190
+ return new SubCompositionClipPlayable(graph);
18191
+ }
18192
+ }
18193
+ SubCompositionPlayableAsset = __decorate([
18194
+ effectsClass('SubCompositionPlayableAsset')
18195
+ ], SubCompositionPlayableAsset);
18196
+
18197
+ class TextLayout {
18198
+ getOffsetY(style) {
18199
+ let offsetY = 0;
18200
+ const offset = (style.fontSize + style.outlineWidth) * style.fontScale;
18201
+ switch(this.textBaseline){
18202
+ case TextBaseline.top:
18203
+ offsetY = offset;
18204
+ break;
18205
+ case TextBaseline.middle:
18206
+ offsetY = (this.height + offset) / 2; // fonSize;
18207
+ break;
18208
+ case TextBaseline.bottom:
18209
+ offsetY = this.height - offset / 2;
18210
+ break;
18211
+ }
18212
+ return offsetY;
18213
+ }
18214
+ getOffsetX(style, maxWidth) {
18215
+ let offsetX = 0;
18216
+ switch(this.textAlign){
18217
+ case TextAlignment.left:
18218
+ offsetX = style.outlineWidth * style.fontScale;
18219
+ break;
18220
+ case TextAlignment.middle:
18221
+ offsetX = (this.width * style.fontScale - maxWidth) / 2;
18222
+ break;
18223
+ case TextAlignment.right:
18224
+ offsetX = this.width * style.fontScale - maxWidth;
18225
+ break;
18226
+ }
18227
+ return offsetX;
18228
+ }
18229
+ /**
18230
+ * 设置文本框的宽度和高度
18231
+ * @param width 文本框宽度
18232
+ * @param height 文本框高度
18233
+ */ setSize(width, height) {
18234
+ this.width = width;
18235
+ this.height = height;
18236
+ }
18237
+ constructor(options){
18238
+ this.width = 0;
18239
+ this.height = 0;
18240
+ const { textHeight = 100, textWidth = 100, textOverflow = TextOverflow.display, textBaseline = TextBaseline.top, textAlign = TextAlignment.left, text, letterSpace = 0, autoWidth = false, fontSize, lineHeight = fontSize } = options;
18241
+ const tempWidth = fontSize + letterSpace;
18242
+ this.autoWidth = autoWidth;
18243
+ this.maxTextWidth = text.length * tempWidth;
18244
+ // if (autoWidth) {
18245
+ // this.width = this.maxTextWidth + this.lineWidth;
18246
+ // this.height = fontSize + this.lineHeight;
18247
+ // } else {
18248
+ // if (textWidth) {
18249
+ // this.maxCharCount = Math.floor((textWidth - this.lineWidth) / (tempWidth));
18250
+ // this.width = textWidth;
18251
+ // } else {
18252
+ // this.width = basicScale[0] * 100;
18253
+ // }
18254
+ // this.height = basicScale[1] * 100;
18255
+ // }
18256
+ this.width = textWidth;
18257
+ this.height = textHeight;
18258
+ this.letterSpace = letterSpace;
18259
+ this.overFlow = textOverflow;
18260
+ this.textBaseline = textBaseline;
18261
+ this.textAlign = textAlign;
18262
+ this.lineHeight = lineHeight;
18263
+ }
18264
+ }
18265
+
18266
+ class TextStyle {
18267
+ constructor(options){
18268
+ /**
18269
+ * 是否有下划线(暂时无效)
18270
+ */ this.isUnderline = false // ttf
18271
+ ;
18272
+ /**
18273
+ * 下划线高度(暂时无效)
18274
+ */ this.underlineHeight = 1 // ttf
18275
+ ;
18276
+ /**
18277
+ * 是否有外描边
18278
+ */ this.isOutlined = false // both // ttf & char
18279
+ ;
18280
+ /**
18281
+ * 外描边宽度
18282
+ */ this.outlineWidth = 0 // both // ttf & char
18283
+ ;
18284
+ /**
18285
+ * 是否有阴影
18286
+ */ this.hasShadow = false // ttf
18287
+ ;
18288
+ this.fontDesc = '' // both
18289
+ ;
18290
+ /**
18291
+ * 字体倍数
18292
+ */ this.fontScale = 2;
18293
+ this.fontOffset = 0;
18294
+ const { textColor = [
18295
+ 1,
18296
+ 1,
18297
+ 1,
18298
+ 1
18299
+ ], fontSize = 40, outline, shadow, fontWeight = 'normal', fontStyle = 'normal', fontFamily = 'sans-serif' } = options;
18300
+ this.textColor = textColor;
18301
+ //@ts-expect-error
18302
+ this.textWeight = fontWeight;
18303
+ //@ts-expect-error
18304
+ this.fontStyle = fontStyle;
18305
+ this.fontFamily = fontFamily;
18306
+ this.fontSize = fontSize; // 暂时取消字号限制 Math.min(fontSize, this.maxFontSize);
18307
+ if (outline) {
18308
+ this.isOutlined = true;
18309
+ var _outline_outlineColor;
18310
+ this.outlineColor = (_outline_outlineColor = outline.outlineColor) != null ? _outline_outlineColor : [
18311
+ 1,
18312
+ 1,
18313
+ 1,
18314
+ 1
18315
+ ];
18316
+ var _outline_outlineWidth;
18317
+ this.outlineWidth = (_outline_outlineWidth = outline.outlineWidth) != null ? _outline_outlineWidth : 1;
18318
+ this.fontOffset += this.outlineWidth;
18319
+ }
18320
+ if (shadow) {
18321
+ this.hasShadow = true;
18322
+ var _shadow_shadowBlur;
18323
+ this.shadowBlur = (_shadow_shadowBlur = shadow.shadowBlur) != null ? _shadow_shadowBlur : 2;
18324
+ var _shadow_shadowColor;
18325
+ this.shadowColor = (_shadow_shadowColor = shadow.shadowColor) != null ? _shadow_shadowColor : [
18326
+ 0,
18327
+ 0,
18328
+ 0,
18329
+ 1
18330
+ ];
18331
+ var _shadow_shadowOffsetX;
18332
+ this.shadowOffsetX = (_shadow_shadowOffsetX = shadow.shadowOffsetX) != null ? _shadow_shadowOffsetX : 0;
18333
+ var _shadow_shadowOffsetY;
18334
+ this.shadowOffsetY = (_shadow_shadowOffsetY = shadow.shadowOffsetY) != null ? _shadow_shadowOffsetY : 0;
18335
+ }
18336
+ if (this.fontStyle !== FontStyle.normal) {
18337
+ // 0.0174532925 = 3.141592653 / 180
18338
+ this.fontOffset += this.fontSize * Math.tan(12 * 0.0174532925);
18339
+ }
18340
+ }
18341
+ }
18342
+
18343
+ class CanvasPool {
18344
+ dispose() {
18345
+ this.elements.forEach((e)=>e.remove());
18346
+ // clearing the array
18347
+ this.elements.length = 0;
18348
+ }
18349
+ getCanvas() {
18350
+ if (this.elements.length !== 0) {
18351
+ return this.elements.shift();
18352
+ }
18353
+ if (getConfig(TEMPLATE_USE_OFFSCREEN_CANVAS)) {
18354
+ // @ts-expect-error
18355
+ return window._createOffscreenCanvas(10, 10);
18356
+ } else {
18357
+ // in hongmeng system, create too many canvas will case render error
18358
+ const defCanvas = document.createElement('canvas');
18359
+ defCanvas.getContext('2d', {
18360
+ willReadFrequently: true
18361
+ });
18362
+ return defCanvas;
18363
+ }
18364
+ }
18365
+ saveCanvas(canvas) {
18366
+ canvas.width = 1;
18367
+ canvas.height = 1;
18368
+ if (this.elements.length < 3) {
18369
+ addItem(this.elements, canvas);
18123
18370
  } else {
18124
18371
  canvas.remove();
18125
18372
  }
@@ -18659,6 +18906,19 @@ class VFXItem extends EffectsObject {
18659
18906
  return (_this_composition_reusable = (_this_composition = this.composition) == null ? void 0 : _this_composition.reusable) != null ? _this_composition_reusable : false;
18660
18907
  }
18661
18908
  /**
18909
+ * 元素在合成中的索引
18910
+ */ get renderOrder() {
18911
+ return this.listIndex;
18912
+ }
18913
+ set renderOrder(value) {
18914
+ if (this.listIndex !== value) {
18915
+ this.listIndex = value;
18916
+ for (const rendererComponent of this.rendererComponents){
18917
+ rendererComponent.priority = value;
18918
+ }
18919
+ }
18920
+ }
18921
+ /**
18662
18922
  * 设置元素的动画速度
18663
18923
  * @param speed - 速度
18664
18924
  */ setSpeed(speed) {
@@ -18915,7 +19175,7 @@ class VFXItem extends EffectsObject {
18915
19175
  this.parentId = parentId;
18916
19176
  this.duration = duration;
18917
19177
  this.endBehavior = endBehavior;
18918
- this.listIndex = listIndex;
19178
+ this.renderOrder = listIndex;
18919
19179
  //@ts-expect-error
18920
19180
  this.oldId = data.oldId;
18921
19181
  if (!data.content) {
@@ -19383,14 +19643,16 @@ class SerializationHelper {
19383
19643
  static checkGLTFNode(value) {
19384
19644
  return value instanceof Object && value.nodeIndex !== undefined && value.isJoint !== undefined;
19385
19645
  }
19646
+ static checkImageSource(value) {
19647
+ return isCanvas(value) || value instanceof HTMLImageElement;
19648
+ }
19386
19649
  static deserializeProperty(property, engine, level, type) {
19387
19650
  if (level > 14) {
19388
19651
  console.error('序列化数据的内嵌对象层数大于上限');
19389
19652
  return;
19390
19653
  }
19391
- if (typeof property === 'number' || typeof property === 'string' || typeof property === 'boolean') {
19392
- return property;
19393
- } else if (property instanceof Array) {
19654
+ // 加载并链接 DataPath 字段表示的 EffectsObject 引用。Class 对象 copy [key, value] 会丢失对象信息,因此只递归数组对象和普通 js Object 结构对象。
19655
+ if (property instanceof Array) {
19394
19656
  const res = [];
19395
19657
  for (const value of property){
19396
19658
  res.push(SerializationHelper.deserializeProperty(value, engine, level + 1, type));
@@ -19399,9 +19661,7 @@ class SerializationHelper {
19399
19661
  // TODO json 数据避免传 typedArray
19400
19662
  } else if (SerializationHelper.checkDataPath(property)) {
19401
19663
  return engine.assetLoader.loadGUID(property.id);
19402
- } else if (property instanceof EffectsObject || SerializationHelper.checkTypedArray(property) || SerializationHelper.checkGLTFNode(property)) {
19403
- return property;
19404
- } else if (property instanceof Object) {
19664
+ } else if (property instanceof Object && property.constructor === Object) {
19405
19665
  let res;
19406
19666
  if (type) {
19407
19667
  const classConstructor = effectsClassStore[type];
@@ -19414,6 +19674,8 @@ class SerializationHelper {
19414
19674
  res[key] = SerializationHelper.deserializeProperty(property[key], engine, level + 1);
19415
19675
  }
19416
19676
  return res;
19677
+ } else {
19678
+ return property;
19417
19679
  }
19418
19680
  }
19419
19681
  static deserializePropertyAsync(property, engine, level, type) {
@@ -19422,9 +19684,7 @@ class SerializationHelper {
19422
19684
  console.error('序列化数据的内嵌对象层数大于上限');
19423
19685
  return;
19424
19686
  }
19425
- if (typeof property === 'number' || typeof property === 'string' || typeof property === 'boolean') {
19426
- return property;
19427
- } else if (property instanceof Array) {
19687
+ if (property instanceof Array) {
19428
19688
  const res = [];
19429
19689
  for (const value of property){
19430
19690
  res.push((yield SerializationHelper.deserializePropertyAsync(value, engine, level + 1, type)));
@@ -19434,9 +19694,7 @@ class SerializationHelper {
19434
19694
  } else if (SerializationHelper.checkDataPath(property)) {
19435
19695
  const res = yield engine.assetLoader.loadGUIDAsync(property.id);
19436
19696
  return res;
19437
- } else if (property instanceof EffectsObject || SerializationHelper.checkTypedArray(property) || SerializationHelper.checkGLTFNode(property)) {
19438
- return property;
19439
- } else if (property instanceof Object) {
19697
+ } else if (property instanceof Object && property.constructor === Object) {
19440
19698
  let res;
19441
19699
  if (type) {
19442
19700
  const classConstructor = effectsClassStore[type];
@@ -19449,6 +19707,8 @@ class SerializationHelper {
19449
19707
  res[key] = SerializationHelper.deserializeProperty(property[key], engine, level + 1);
19450
19708
  }
19451
19709
  return res;
19710
+ } else {
19711
+ return property;
19452
19712
  }
19453
19713
  })();
19454
19714
  }
@@ -19538,9 +19798,8 @@ class SerializationHelper {
19538
19798
  effectsObject = Geometry.create(this.engine);
19539
19799
  break;
19540
19800
  case DataType.Texture:
19541
- // @ts-expect-error
19542
- effectsObject = Texture.create(this.engine, effectsObjectData);
19543
- return effectsObject;
19801
+ effectsObject = Texture.create(this.engine);
19802
+ break;
19544
19803
  default:
19545
19804
  {
19546
19805
  const classConstructor = AssetLoader.getClass(effectsObjectData.dataType);
@@ -19588,9 +19847,8 @@ class SerializationHelper {
19588
19847
  effectsObject = Geometry.create(_this.engine);
19589
19848
  break;
19590
19849
  case DataType.Texture:
19591
- // @ts-expect-error
19592
- effectsObject = Texture.create(_this.engine, effectsObjectData);
19593
- return effectsObject;
19850
+ effectsObject = Texture.create(_this.engine);
19851
+ break;
19594
19852
  default:
19595
19853
  {
19596
19854
  const classConstructor = AssetLoader.getClass(effectsObjectData.dataType);
@@ -20445,6 +20703,7 @@ function getStandardCameraContent(model) {
20445
20703
  _result;
20446
20704
  const result = _extends({}, json, {
20447
20705
  items: [],
20706
+ compositions: [],
20448
20707
  components: [],
20449
20708
  materials: [],
20450
20709
  shaders: [],
@@ -20535,8 +20794,15 @@ function getStandardCameraContent(model) {
20535
20794
  id: item.id
20536
20795
  };
20537
20796
  });
20797
+ const compositionData = _extends({}, composition, {
20798
+ timelineAsset: {
20799
+ id: ''
20800
+ },
20801
+ sceneBindings: []
20802
+ });
20803
+ result.compositions.push(compositionData);
20538
20804
  // 生成时间轴数据
20539
- convertTimelineAsset(composition, guidToItemMap, result);
20805
+ convertTimelineAsset(compositionData, guidToItemMap, result);
20540
20806
  }
20541
20807
  for (const item of result.items){
20542
20808
  // 原 texture 索引转为统一 guid 索引
@@ -20703,10 +20969,7 @@ function getStandardCameraContent(model) {
20703
20969
  item.type = 'orientation-transformer';
20704
20970
  }
20705
20971
  // item 的 content 转为 component data 加入 JSONScene.components
20706
- if (item.type === ItemType.sprite || item.type === ItemType.particle || item.type === ItemType.mesh || item.type === ItemType.skybox || item.type === ItemType.light || // @ts-expect-error
20707
- item.type === 'camera' || item.type === ItemType.tree || item.type === ItemType.interact || item.type === ItemType.camera || item.type === ItemType.text || item.type === ItemType.spine || // @ts-expect-error
20708
- item.type === 'editor-gizmo' || // @ts-expect-error
20709
- item.type === 'orientation-transformer') {
20972
+ if (item.type === ItemType.sprite || item.type === ItemType.particle || item.type === ItemType.mesh || item.type === ItemType.skybox || item.type === ItemType.light || item.type === 'camera' || item.type === ItemType.tree || item.type === ItemType.interact || item.type === ItemType.camera || item.type === ItemType.text || item.type === ItemType.spine || item.type === 'editor-gizmo' || item.type === 'orientation-transformer') {
20710
20973
  item.components = [];
20711
20974
  result.components.push(item.content);
20712
20975
  item.content.id = generateGUID();
@@ -20738,15 +21001,12 @@ function getStandardCameraContent(model) {
20738
21001
  case ItemType.light:
20739
21002
  item.content.dataType = DataType.LightComponent;
20740
21003
  break;
20741
- // @ts-expect-error
20742
21004
  case 'camera':
20743
21005
  item.content.dataType = DataType.CameraComponent;
20744
21006
  break;
20745
- // @ts-expect-error
20746
21007
  case 'editor-gizmo':
20747
21008
  item.content.dataType = 'GizmoComponent';
20748
21009
  break;
20749
- // @ts-expect-error
20750
21010
  case 'orientation-transformer':
20751
21011
  item.content.dataType = 'OrientationComponent';
20752
21012
  break;
@@ -20896,6 +21156,32 @@ function convertTimelineAsset(composition, guidToItemMap, jsonScene) {
20896
21156
  });
20897
21157
  trackDatas.push(newTrackData);
20898
21158
  }
21159
+ if (item.type === ItemType.composition) {
21160
+ const newSubCompositionPlayableAssetData = {
21161
+ id: generateGUID(),
21162
+ dataType: 'SubCompositionPlayableAsset'
21163
+ };
21164
+ playableAssetDatas.push(newSubCompositionPlayableAssetData);
21165
+ const newTrackData = {
21166
+ id: generateGUID(),
21167
+ dataType: 'SubCompositionTrack',
21168
+ children: [],
21169
+ clips: [
21170
+ {
21171
+ start: item.delay,
21172
+ duration: item.duration,
21173
+ endBehaviour: item.endBehavior,
21174
+ asset: {
21175
+ id: newSubCompositionPlayableAssetData.id
21176
+ }
21177
+ }
21178
+ ]
21179
+ };
21180
+ subTrackDatas.push({
21181
+ id: newTrackData.id
21182
+ });
21183
+ trackDatas.push(newTrackData);
21184
+ }
20899
21185
  const bindingTrackData = {
20900
21186
  id: generateGUID(),
20901
21187
  dataType: 'ObjectBindingTrack',
@@ -20921,11 +21207,9 @@ function convertTimelineAsset(composition, guidToItemMap, jsonScene) {
20921
21207
  id: trackData.id
20922
21208
  });
20923
21209
  }
20924
- //@ts-expect-error
20925
21210
  composition.timelineAsset = {
20926
21211
  id: timelineAssetData.id
20927
21212
  };
20928
- //@ts-expect-error
20929
21213
  composition.sceneBindings = sceneBindings;
20930
21214
  if (!jsonScene.animations) {
20931
21215
  jsonScene.animations = [];
@@ -21243,7 +21527,17 @@ function getStandardItem(item, opt = {}) {
21243
21527
  }
21244
21528
  }
21245
21529
 
21246
- const renderLevelPassSet = {
21530
+ /**
21531
+ * 机型和渲染等级对应表
21532
+ *
21533
+ * 机型:B-低端机、A-中端机、S-高端机
21534
+ * 渲染等级:B-低、A-中、S-高、A+-中高、B+-全部
21535
+ *
21536
+ * - S(高端机):高、全部、中高
21537
+ * - A(中端机):中、全部、中高
21538
+ * - B(低端机):低、全部
21539
+ * - undefined(全部机型)
21540
+ */ const renderLevelPassSet = {
21247
21541
  [RenderLevel.S]: [
21248
21542
  RenderLevel.S,
21249
21543
  RenderLevel.BPlus,
@@ -21792,40 +22086,6 @@ function createTextureOptionsBySource(image, sourceFrom) {
21792
22086
  }
21793
22087
  throw new Error('Invalid texture options');
21794
22088
  }
21795
- function base64ToFile(base64, filename = 'base64File', contentType = '') {
21796
- // 去掉 Base64 字符串的 Data URL 部分(如果存在)
21797
- const base64WithoutPrefix = base64.split(',')[1] || base64;
21798
- // 将 base64 编码的字符串转换为二进制字符串
21799
- const byteCharacters = atob(base64WithoutPrefix);
21800
- // 创建一个 8 位无符号整数值的数组,即“字节数组”
21801
- const byteArrays = [];
21802
- // 切割二进制字符串为多个片段,并将每个片段转换成一个字节数组
21803
- for(let offset = 0; offset < byteCharacters.length; offset += 512){
21804
- const slice = byteCharacters.slice(offset, offset + 512);
21805
- const byteNumbers = new Array(slice.length);
21806
- for(let i = 0; i < slice.length; i++){
21807
- byteNumbers[i] = slice.charCodeAt(i);
21808
- }
21809
- const byteArray = new Uint8Array(byteNumbers);
21810
- byteArrays.push(byteArray);
21811
- }
21812
- // 使用字节数组创建 Blob 对象
21813
- const blob = new Blob(byteArrays, {
21814
- type: contentType
21815
- });
21816
- // 创建 File 对象
21817
- const file = new File([
21818
- blob
21819
- ], filename, {
21820
- type: contentType
21821
- });
21822
- return file;
21823
- }
21824
- function isCanvas(canvas) {
21825
- var _canvas_tagName;
21826
- // 小程序 Canvas 无法使用 instanceof HTMLCanvasElement 判断
21827
- return typeof canvas === 'object' && canvas !== null && ((_canvas_tagName = canvas.tagName) == null ? void 0 : _canvas_tagName.toUpperCase()) === 'CANVAS';
21828
- }
21829
22089
 
21830
22090
  const tmpScale = new Vector3(1, 1, 1);
21831
22091
  /**
@@ -22079,217 +22339,173 @@ const tmpScale = new Vector3(1, 1, 1);
22079
22339
  this.dirty = true;
22080
22340
  this.updateMatrix();
22081
22341
  }
22082
- }
22083
-
22084
- /**
22085
- * @since 2.0.0
22086
- * @internal
22087
- */ class CompositionComponent extends ItemBehaviour {
22088
- start() {
22089
- const { startTime = 0 } = this.item.props;
22090
- this.startTime = startTime;
22091
- this.masterTracks = [];
22092
- for (const sceneBinding of this.sceneBindings){
22093
- sceneBinding.key.binding = sceneBinding.value;
22342
+ }
22343
+
22344
+ let listOrder = 0;
22345
+ /**
22346
+ * 合成资源管理
22347
+ */ class CompositionSourceManager {
22348
+ getContent(composition) {
22349
+ // TODO: specification 中补充 globalVolume 类型
22350
+ // @ts-expect-error
22351
+ const { id, duration, name, endBehavior, camera, globalVolume, startTime = 0 } = composition;
22352
+ const items = this.assembleItems(composition);
22353
+ return _extends({}, composition, {
22354
+ id,
22355
+ duration,
22356
+ name,
22357
+ endBehavior: isNaN(endBehavior) ? END_BEHAVIOR_PAUSE : endBehavior,
22358
+ // looping,
22359
+ items,
22360
+ camera,
22361
+ startTime,
22362
+ globalVolume
22363
+ });
22364
+ }
22365
+ assembleItems(composition) {
22366
+ const items = [];
22367
+ this.mask++;
22368
+ const componentMap = {};
22369
+ //@ts-expect-error
22370
+ for (const component of this.jsonScene.components){
22371
+ componentMap[component.id] = component;
22094
22372
  }
22095
- this.initializeTrackBindings(this.timelineAsset.tracks);
22096
- this.timelinePlayable = this.timelineAsset.createPlayable(this.graph);
22097
- this.timelinePlayable.play();
22098
- for (const track of this.timelineAsset.tracks){
22099
- const binding = track.binding;
22100
- if (binding instanceof VFXItem) {
22101
- // 重播不销毁元素
22102
- if (this.item.endBehavior !== ItemEndBehavior.destroy || this.reusable) {
22103
- if (track instanceof ObjectBindingTrack) {
22104
- binding.reusable = true;
22373
+ for (const itemDataPath of composition.items){
22374
+ //@ts-expect-error
22375
+ const sourceItemData = this.engine.jsonSceneData[itemDataPath.id];
22376
+ const itemProps = sourceItemData;
22377
+ if (passRenderLevel(sourceItemData.renderLevel, this.renderLevel)) {
22378
+ if (itemProps.type === ItemType.sprite || itemProps.type === ItemType.particle) {
22379
+ for (const componentPath of itemProps.components){
22380
+ const componentData = componentMap[componentPath.id];
22381
+ this.preProcessItemContent(componentData);
22382
+ }
22383
+ } else {
22384
+ const renderContent = itemProps.content;
22385
+ if (renderContent) {
22386
+ this.preProcessItemContent(renderContent);
22387
+ }
22388
+ }
22389
+ itemProps.listIndex = listOrder++;
22390
+ // 处理预合成的渲染顺序
22391
+ if (itemProps.type === ItemType.composition) {
22392
+ const refId = sourceItemData.content.options.refId;
22393
+ if (!this.refCompositions.get(refId)) {
22394
+ throw new Error('Invalid Ref Composition id: ' + refId);
22105
22395
  }
22106
- const subCompositionComponent = binding.getComponent(CompositionComponent);
22107
- if (subCompositionComponent) {
22108
- subCompositionComponent.reusable = true;
22396
+ const ref = this.getContent(this.refCompositions.get(refId));
22397
+ if (!this.refCompositionProps.has(refId)) {
22398
+ this.refCompositionProps.set(refId, ref);
22109
22399
  }
22400
+ ref.items.forEach((item)=>{
22401
+ this.processMask(item.content);
22402
+ });
22403
+ itemProps.items = ref.items;
22110
22404
  }
22405
+ items.push(itemProps);
22111
22406
  }
22112
- this.masterTracks.push(track);
22113
22407
  }
22408
+ return items;
22114
22409
  }
22115
- initializeTrackBindings(masterTracks) {
22116
- for (const track of masterTracks){
22117
- track.initializeBindingRecursive(track.binding);
22410
+ preProcessItemContent(renderContent) {
22411
+ if (renderContent.renderer) {
22412
+ renderContent.renderer = this.changeTex(renderContent.renderer);
22413
+ if (!renderContent.renderer.mask) {
22414
+ this.processMask(renderContent.renderer);
22415
+ }
22416
+ const split = renderContent.splits && !renderContent.textureSheetAnimation && renderContent.splits[0];
22417
+ if (Number.isInteger(renderContent.renderer.shape)) {
22418
+ var _this_jsonScene;
22419
+ // TODO: scene.shapes 类型问题?
22420
+ renderContent.renderer.shape = getGeometryByShape((_this_jsonScene = this.jsonScene) == null ? void 0 : _this_jsonScene.shapes[renderContent.renderer.shape], split);
22421
+ } else if (renderContent.renderer.shape && isObject(renderContent.renderer.shape)) {
22422
+ renderContent.renderer.shape = getGeometryByShape(renderContent.renderer.shape, split);
22423
+ }
22424
+ }
22425
+ if (renderContent.trails) {
22426
+ renderContent.trails = this.changeTex(renderContent.trails);
22118
22427
  }
22119
22428
  }
22120
- update(dt) {
22121
- const time = this.time;
22122
- // 主合成 rootItem 没有绑定轨道,增加结束行为判断。
22123
- if (this.item.isEnded(this.time) && !this.item.parent) {
22124
- this.item.ended = true;
22429
+ changeTex(renderer) {
22430
+ if (!renderer.texture) {
22431
+ return renderer;
22125
22432
  }
22126
- this.timelinePlayable.setTime(time);
22127
- this.graph.evaluate(dt);
22128
- for(let i = 0; i < this.items.length; i++){
22129
- const item = this.items[i];
22130
- const subCompostionComponent = item.getComponent(CompositionComponent);
22131
- if (subCompostionComponent) {
22132
- const subCompositionTrack = this.masterTracks[i];
22133
- subCompostionComponent.time = subCompositionTrack.toLocalTime(time);
22134
- }
22433
+ //@ts-expect-error
22434
+ const texIdx = renderer.texture.id;
22435
+ if (texIdx !== undefined) {
22436
+ //@ts-expect-error
22437
+ this.addTextureUsage(texIdx) || texIdx;
22135
22438
  }
22439
+ return renderer;
22136
22440
  }
22137
- /**
22138
- * 重置元素状态属性
22139
- */ resetStatus() {
22140
- this.item.ended = false;
22141
- }
22142
- createContent() {
22143
- const sceneBindings = [];
22144
- for (const sceneBindingData of this.data.sceneBindings){
22145
- sceneBindings.push({
22146
- key: this.engine.assetLoader.loadGUID(sceneBindingData.key.id),
22147
- value: this.engine.assetLoader.loadGUID(sceneBindingData.value.id)
22148
- });
22149
- }
22150
- this.sceneBindings = sceneBindings;
22151
- const timelineAsset = this.data.timelineAsset ? this.engine.assetLoader.loadGUID(this.data.timelineAsset.id) : new TimelineAsset(this.engine);
22152
- this.timelineAsset = timelineAsset;
22153
- const items = this.items;
22154
- this.items.length = 0;
22155
- if (this.item.composition) {
22156
- const assetLoader = this.item.engine.assetLoader;
22157
- const itemProps = this.item.props.items ? this.item.props.items : [];
22158
- for(let i = 0; i < itemProps.length; i++){
22159
- let item;
22160
- const itemData = itemProps[i];
22161
- // 设置预合成作为元素时的时长、结束行为和渲染延时
22162
- if (Item.isComposition(itemData)) {
22163
- const refId = itemData.content.options.refId;
22164
- const props = this.item.composition.refCompositionProps.get(refId);
22165
- if (!props) {
22166
- throw new Error(`引用的Id: ${refId} 的预合成不存在`);
22167
- }
22168
- // endBehaviour 类型需优化
22169
- props.content = itemData.content;
22170
- item = assetLoader.loadGUID(itemData.id);
22171
- item.composition = this.item.composition;
22172
- const compositionComponent = item.addComponent(CompositionComponent);
22173
- compositionComponent.data = props;
22174
- compositionComponent.refId = refId;
22175
- item.transform.parentTransform = this.transform;
22176
- this.item.composition.refContent.push(item);
22177
- if (item.endBehavior === ItemEndBehavior.loop) {
22178
- this.item.composition.autoRefTex = false;
22179
- }
22180
- compositionComponent.createContent();
22181
- for (const vfxItem of compositionComponent.items){
22182
- vfxItem.setInstanceId(generateGUID());
22183
- for (const component of vfxItem.components){
22184
- component.setInstanceId(generateGUID());
22185
- }
22186
- }
22187
- } else {
22188
- item = assetLoader.loadGUID(itemData.id);
22189
- item.composition = this.item.composition;
22190
- }
22191
- item.parent = this.item;
22192
- // 相机不跟随合成移动
22193
- item.transform.parentTransform = itemData.type === ItemType.camera ? new Transform() : this.transform;
22194
- if (VFXItem.isExtraCamera(item)) {
22195
- this.item.composition.extraCamera = item;
22196
- }
22197
- items.push(item);
22441
+ addTextureUsage(texIdx) {
22442
+ const texId = texIdx;
22443
+ var _this_imgUsage;
22444
+ // FIXME: imageUsage 取自 scene.imgUsage,类型为 Record<string, number[]>,这里给的 number,类型对不上
22445
+ const imageUsage = (_this_imgUsage = this.imgUsage) != null ? _this_imgUsage : {};
22446
+ if (texId && imageUsage) {
22447
+ // eslint-disable-next-line no-prototype-builtins
22448
+ if (!imageUsage.hasOwnProperty(texId)) {
22449
+ imageUsage[texId] = 0;
22198
22450
  }
22451
+ imageUsage[texId]++;
22199
22452
  }
22200
22453
  }
22201
- onDestroy() {
22202
- if (this.item.composition) {
22203
- if (this.items) {
22204
- this.items.forEach((item)=>item.dispose());
22205
- this.items.length = 0;
22454
+ /**
22455
+ * 处理蒙版和遮挡关系写入 stencil 的 ref 值
22456
+ */ processMask(renderer) {
22457
+ const maskMode = renderer.maskMode;
22458
+ if (maskMode === MaskMode.NONE) {
22459
+ return;
22460
+ }
22461
+ if (!renderer.mask) {
22462
+ if (maskMode === MaskMode.MASK) {
22463
+ renderer.mask = ++this.mask;
22464
+ } else if (maskMode === MaskMode.OBSCURED || maskMode === MaskMode.REVERSE_OBSCURED) {
22465
+ renderer.mask = this.mask;
22206
22466
  }
22207
22467
  }
22208
22468
  }
22209
- hitTest(ray, x, y, regions, force, options) {
22210
- const hitPositions = [];
22211
- const stop = (options == null ? void 0 : options.stop) || noop;
22212
- const skip = (options == null ? void 0 : options.skip) || noop;
22213
- const maxCount = (options == null ? void 0 : options.maxCount) || this.items.length;
22214
- for(let i = 0; i < this.items.length && regions.length < maxCount; i++){
22215
- const item = this.items[i];
22216
- if (item.getVisible() && !item.ended && !VFXItem.isComposition(item) && !skip(item)) {
22217
- const hitParams = item.getHitTestParams(force);
22218
- if (hitParams) {
22219
- let success = false;
22220
- const intersectPoint = new Vector3();
22221
- if (hitParams.type === HitTestType.triangle) {
22222
- const { triangles, backfaceCulling } = hitParams;
22223
- for(let j = 0; j < triangles.length; j++){
22224
- const triangle = triangles[j];
22225
- if (ray.intersectTriangle(triangle, intersectPoint, backfaceCulling)) {
22226
- success = true;
22227
- hitPositions.push(intersectPoint);
22228
- break;
22229
- }
22230
- }
22231
- } else if (hitParams.type === HitTestType.box) {
22232
- const { center, size } = hitParams;
22233
- const boxMin = center.clone().addScaledVector(size, 0.5);
22234
- const boxMax = center.clone().addScaledVector(size, -0.5);
22235
- if (ray.intersectBox({
22236
- min: boxMin,
22237
- max: boxMax
22238
- }, intersectPoint)) {
22239
- success = true;
22240
- hitPositions.push(intersectPoint);
22241
- }
22242
- } else if (hitParams.type === HitTestType.sphere) {
22243
- const { center, radius } = hitParams;
22244
- if (ray.intersectSphere({
22245
- center,
22246
- radius
22247
- }, intersectPoint)) {
22248
- success = true;
22249
- hitPositions.push(intersectPoint);
22250
- }
22251
- } else if (hitParams.type === HitTestType.custom) {
22252
- const tempPosition = hitParams.collect(ray, new Vector2(x, y));
22253
- if (tempPosition && tempPosition.length > 0) {
22254
- tempPosition.forEach((pos)=>{
22255
- hitPositions.push(pos);
22256
- });
22257
- success = true;
22258
- }
22259
- }
22260
- if (success) {
22261
- const region = {
22262
- compContent: this.item,
22263
- id: item.id,
22264
- name: item.name,
22265
- position: hitPositions[hitPositions.length - 1],
22266
- parentId: item.parentId,
22267
- hitPositions,
22268
- behavior: hitParams.behavior
22269
- };
22270
- regions.push(region);
22271
- if (stop(region)) {
22272
- return regions;
22273
- }
22274
- }
22275
- }
22469
+ dispose() {
22470
+ this.textures = [];
22471
+ this.composition = undefined;
22472
+ this.jsonScene = undefined;
22473
+ this.totalTime = 0;
22474
+ this.pluginSystem = undefined;
22475
+ this.sourceContent = undefined;
22476
+ this.refCompositions.clear();
22477
+ this.refCompositionProps.clear();
22478
+ }
22479
+ constructor(scene, engine){
22480
+ this.refCompositions = new Map();
22481
+ this.refCompositionProps = new Map();
22482
+ this.mask = 0;
22483
+ this.engine = engine;
22484
+ // 资源
22485
+ const { jsonScene, renderLevel, textureOptions, pluginSystem, totalTime } = scene;
22486
+ const { compositions, imgUsage, compositionId } = jsonScene;
22487
+ if (!textureOptions) {
22488
+ throw new Error('scene.textures expected');
22489
+ }
22490
+ const cachedTextures = textureOptions;
22491
+ for (const comp of compositions){
22492
+ if (comp.id === compositionId) {
22493
+ this.composition = comp;
22494
+ } else {
22495
+ this.refCompositions.set(comp.id, comp);
22276
22496
  }
22277
22497
  }
22278
- return regions;
22279
- }
22280
- fromData(data) {
22281
- // this.timelineAsset = data.timelineAsset;
22282
- }
22283
- constructor(...args){
22284
- super(...args);
22285
- this.time = 0;
22286
- this.startTime = 0;
22287
- this.items = [] // 场景的所有元素
22288
- ;
22289
- this.reusable = false;
22290
- this.sceneBindings = [];
22291
- this.masterTracks = [];
22292
- this.graph = new PlayableGraph();
22498
+ if (!this.composition) {
22499
+ throw new Error('Invalid composition id: ' + compositionId);
22500
+ }
22501
+ this.jsonScene = jsonScene;
22502
+ this.renderLevel = renderLevel;
22503
+ this.pluginSystem = pluginSystem;
22504
+ this.totalTime = totalTime != null ? totalTime : 0;
22505
+ this.imgUsage = imgUsage != null ? imgUsage : {};
22506
+ this.textures = cachedTextures;
22507
+ listOrder = 0;
22508
+ this.sourceContent = this.getContent(this.composition);
22293
22509
  }
22294
22510
  }
22295
22511
 
@@ -22299,6 +22515,11 @@ const tmpScale = new Vector3(1, 1, 1);
22299
22515
  * 也负责 Item 相关的动画播放控制,和持有渲染帧数据。
22300
22516
  */ class Composition {
22301
22517
  /**
22518
+ * 所有合成 Item 的根变换
22519
+ */ get transform() {
22520
+ return this.rootItem.transform;
22521
+ }
22522
+ /**
22302
22523
  * 获取场景中的纹理数组
22303
22524
  */ get textures() {
22304
22525
  return this.compositionSourceManager.textures;
@@ -22332,16 +22553,8 @@ const tmpScale = new Vector3(1, 1, 1);
22332
22553
  /**
22333
22554
  * 重新开始合成
22334
22555
  */ restart() {
22335
- // const contentItems = this.rootComposition.items;
22336
- // contentItems.forEach(item => item.dispose());
22337
- // contentItems.length = 0;
22338
- this.prepareRender();
22339
22556
  this.reset();
22340
- this.transform.setValid(true);
22341
- this.rootComposition.resetStatus();
22342
22557
  this.forwardTime(this.startTime);
22343
- // this.content.onUpdate(0);
22344
- // this.loaderData.spriteGroup.onUpdate(0);
22345
22558
  }
22346
22559
  /**
22347
22560
  * 设置当前合成的渲染顺序
@@ -22468,27 +22681,9 @@ const tmpScale = new Vector3(1, 1, 1);
22468
22681
  /**
22469
22682
  * 重置状态函数
22470
22683
  */ reset() {
22471
- const vfxItem = new VFXItem(this.getEngine(), this.compositionSourceManager.sourceContent);
22472
- // TODO 编辑器数据传入 composition type 后移除
22473
- vfxItem.type = ItemType.composition;
22474
- vfxItem.composition = this;
22475
- this.rootComposition = vfxItem.addComponent(CompositionComponent);
22476
- this.rootComposition.data = this.compositionSourceManager.sourceContent;
22477
- this.transform = new Transform({
22478
- name: this.name
22479
- });
22480
- this.transform.engine = this.getEngine();
22481
- vfxItem.transform = this.transform;
22482
- this.rootItem = vfxItem;
22483
22684
  this.rendererOptions = null;
22484
22685
  this.globalTime = 0;
22485
- this.rootComposition.createContent();
22486
- this.buildItemTree(this.rootItem);
22487
- this.rootItem.onEnd = ()=>{
22488
- window.setTimeout(()=>{
22489
- this.onEnd == null ? void 0 : this.onEnd.call(this, this);
22490
- }, 0);
22491
- };
22686
+ this.rootItem.ended = false;
22492
22687
  this.pluginSystem.resetComposition(this, this.renderFrame);
22493
22688
  }
22494
22689
  prepareRender() {
@@ -22529,7 +22724,6 @@ const tmpScale = new Vector3(1, 1, 1);
22529
22724
  }
22530
22725
  const { ended, endBehavior } = this.rootItem;
22531
22726
  // TODO: 合成结束行为
22532
- // @ts-expect-error
22533
22727
  return ended && (!endBehavior || endBehavior === END_BEHAVIOR_PAUSE_AND_DESTROY);
22534
22728
  }
22535
22729
  /**
@@ -22618,7 +22812,7 @@ const tmpScale = new Vector3(1, 1, 1);
22618
22812
  for (const child of item.children){
22619
22813
  if (VFXItem.isComposition(child)) {
22620
22814
  if (child.ended && child.endBehavior === ItemEndBehavior.loop) {
22621
- child.getComponent(CompositionComponent).resetStatus();
22815
+ child.ended = false;
22622
22816
  // TODO K帧动画在元素重建后需要 tick ,否则会导致元素位置和 k 帧第一帧位置不一致
22623
22817
  this.callUpdate(child, 0);
22624
22818
  } else {
@@ -22985,46 +23179,48 @@ const tmpScale = new Vector3(1, 1, 1);
22985
23179
  * @param props - composition 的创建参数
22986
23180
  * @param scene
22987
23181
  * @param compositionSourceManager
22988
- */ constructor(props, scene, compositionSourceManager){
22989
- this.compositionSourceManager = compositionSourceManager;
22990
- this./**
23182
+ */ constructor(props, scene){
23183
+ /**
22991
23184
  * 动画播放速度
22992
- */ speed = 1;
22993
- this.loaderData = {};
22994
- this.refContent = [];
22995
- this./**
23185
+ */ this.speed = 1;
23186
+ /**
23187
+ * 用于保存与当前合成相关的插件数据
23188
+ */ this.loaderData = {};
23189
+ /**
23190
+ * 预合成数组
23191
+ */ this.refContent = [];
23192
+ /**
22996
23193
  * 预合成的合成属性,在 content 中会被其元素属性覆盖
22997
- */ refCompositionProps = new Map();
23194
+ */ this.refCompositionProps = new Map();
22998
23195
  this.editorScaleRatio = 1.0;
23196
+ // TODO: 待优化
22999
23197
  this.assigned = false;
23000
- this.destroyed = false;
23001
- this.paused = false;
23198
+ /**
23199
+ * 销毁状态位
23200
+ */ this.destroyed = false;
23201
+ /**
23202
+ * 合成暂停/播放 标识
23203
+ */ this.paused = false;
23002
23204
  this.lastVideoUpdateTime = 0;
23003
23205
  this.postLoaders = [];
23004
23206
  const { reusable = false, speed = 1, baseRenderOrder = 0, renderer, onPlayerPause, onMessageItem, onEnd, event, width, height } = props;
23207
+ this.compositionSourceManager = new CompositionSourceManager(scene, renderer.engine);
23005
23208
  scene.jsonScene.imgUsage = undefined;
23006
23209
  if (reusable) {
23007
23210
  this.keepResource = true;
23008
23211
  scene.textures = undefined;
23009
23212
  scene.consumed = true;
23010
23213
  }
23011
- const { sourceContent, pluginSystem, imgUsage, totalTime, renderLevel, refCompositionProps } = this.compositionSourceManager;
23214
+ const { sourceContent, pluginSystem, imgUsage, totalTime, refCompositionProps } = this.compositionSourceManager;
23012
23215
  assertExist(sourceContent);
23013
23216
  this.renderer = renderer;
23014
23217
  this.refCompositionProps = refCompositionProps;
23015
- const vfxItem = new VFXItem(this.getEngine(), sourceContent);
23016
- vfxItem.name = 'rootItem';
23017
- // TODO 编辑器数据传入 composition type 后移除
23018
- vfxItem.type = ItemType.composition;
23019
- vfxItem.composition = this;
23020
- this.rootComposition = vfxItem.addComponent(CompositionComponent);
23218
+ this.rootItem = new VFXItem(this.getEngine(), sourceContent);
23219
+ this.rootItem.name = 'rootItem';
23220
+ this.rootItem.composition = this;
23221
+ this.rootComposition = this.rootItem.addComponent(CompositionComponent);
23021
23222
  this.rootComposition.data = sourceContent;
23022
23223
  const imageUsage = !reusable && imgUsage;
23023
- this.transform = new Transform({
23024
- name: this.name
23025
- });
23026
- this.transform.engine = this.getEngine();
23027
- vfxItem.transform = this.transform;
23028
23224
  this.globalVolume = sourceContent.globalVolume;
23029
23225
  this.width = width;
23030
23226
  this.height = height;
@@ -23041,9 +23237,7 @@ const tmpScale = new Vector3(1, 1, 1);
23041
23237
  };
23042
23238
  this.reusable = reusable;
23043
23239
  this.speed = speed;
23044
- this.renderLevel = renderLevel;
23045
- this.autoRefTex = !this.keepResource && imageUsage && vfxItem.endBehavior !== ItemEndBehavior.loop;
23046
- this.rootItem = vfxItem;
23240
+ this.autoRefTex = !this.keepResource && imageUsage && this.rootItem.endBehavior !== ItemEndBehavior.loop;
23047
23241
  this.name = sourceContent.name;
23048
23242
  this.pluginSystem = pluginSystem;
23049
23243
  this.pluginSystem.initializeComposition(this, scene);
@@ -23069,182 +23263,6 @@ const tmpScale = new Vector3(1, 1, 1);
23069
23263
  }
23070
23264
  }
23071
23265
 
23072
- let listOrder = 0;
23073
- /**
23074
- * 合成资源管理
23075
- */ class CompositionSourceManager {
23076
- getContent(composition) {
23077
- // TODO: specification 中补充 globalVolume 类型
23078
- // @ts-expect-error
23079
- const { id, duration, name, endBehavior, camera, globalVolume, startTime = 0, timelineAsset } = composition;
23080
- const items = this.assembleItems(composition);
23081
- //@ts-expect-error
23082
- if (!composition.sceneBindings) {
23083
- //@ts-expect-error
23084
- composition.sceneBindings = [];
23085
- }
23086
- return {
23087
- id,
23088
- duration,
23089
- name,
23090
- endBehavior: isNaN(endBehavior) ? END_BEHAVIOR_PAUSE : endBehavior,
23091
- // looping,
23092
- items,
23093
- camera,
23094
- startTime,
23095
- globalVolume,
23096
- timelineAsset: timelineAsset,
23097
- //@ts-expect-error
23098
- sceneBindings: composition.sceneBindings
23099
- };
23100
- }
23101
- assembleItems(composition) {
23102
- const items = [];
23103
- this.mask++;
23104
- const componentMap = {};
23105
- //@ts-expect-error
23106
- for (const component of this.jsonScene.components){
23107
- componentMap[component.id] = component;
23108
- }
23109
- for (const itemDataPath of composition.items){
23110
- //@ts-expect-error
23111
- const sourceItemData = this.engine.jsonSceneData[itemDataPath.id];
23112
- const itemProps = sourceItemData;
23113
- if (passRenderLevel(sourceItemData.renderLevel, this.renderLevel)) {
23114
- if (itemProps.type === ItemType.sprite || itemProps.type === ItemType.particle) {
23115
- for (const componentPath of itemProps.components){
23116
- const componentData = componentMap[componentPath.id];
23117
- this.preProcessItemContent(componentData);
23118
- }
23119
- } else {
23120
- const renderContent = itemProps.content;
23121
- if (renderContent) {
23122
- this.preProcessItemContent(renderContent);
23123
- }
23124
- }
23125
- itemProps.listIndex = listOrder++;
23126
- // 处理预合成的渲染顺序
23127
- if (itemProps.type === ItemType.composition) {
23128
- const refId = sourceItemData.content.options.refId;
23129
- if (!this.refCompositions.get(refId)) {
23130
- throw new Error('Invalid Ref Composition id: ' + refId);
23131
- }
23132
- const ref = this.getContent(this.refCompositions.get(refId));
23133
- if (!this.refCompositionProps.has(refId)) {
23134
- this.refCompositionProps.set(refId, ref);
23135
- }
23136
- ref.items.forEach((item)=>{
23137
- this.processMask(item.content);
23138
- });
23139
- itemProps.items = ref.items;
23140
- }
23141
- items.push(itemProps);
23142
- }
23143
- }
23144
- return items;
23145
- }
23146
- preProcessItemContent(renderContent) {
23147
- if (renderContent.renderer) {
23148
- renderContent.renderer = this.changeTex(renderContent.renderer);
23149
- if (!renderContent.renderer.mask) {
23150
- this.processMask(renderContent.renderer);
23151
- }
23152
- const split = renderContent.splits && !renderContent.textureSheetAnimation && renderContent.splits[0];
23153
- if (Number.isInteger(renderContent.renderer.shape)) {
23154
- var _this_jsonScene;
23155
- // TODO: scene.shapes 类型问题?
23156
- renderContent.renderer.shape = getGeometryByShape((_this_jsonScene = this.jsonScene) == null ? void 0 : _this_jsonScene.shapes[renderContent.renderer.shape], split);
23157
- } else if (renderContent.renderer.shape && isObject(renderContent.renderer.shape)) {
23158
- renderContent.renderer.shape = getGeometryByShape(renderContent.renderer.shape, split);
23159
- }
23160
- }
23161
- if (renderContent.trails) {
23162
- renderContent.trails = this.changeTex(renderContent.trails);
23163
- }
23164
- }
23165
- changeTex(renderer) {
23166
- if (!renderer.texture) {
23167
- return renderer;
23168
- }
23169
- //@ts-expect-error
23170
- const texIdx = renderer.texture.id;
23171
- if (texIdx !== undefined) {
23172
- //@ts-expect-error
23173
- this.addTextureUsage(texIdx) || texIdx;
23174
- }
23175
- return renderer;
23176
- }
23177
- addTextureUsage(texIdx) {
23178
- const texId = texIdx;
23179
- var _this_imgUsage;
23180
- // FIXME: imageUsage 取自 scene.imgUsage,类型为 Record<string, number[]>,这里给的 number,类型对不上
23181
- const imageUsage = (_this_imgUsage = this.imgUsage) != null ? _this_imgUsage : {};
23182
- if (texId && imageUsage) {
23183
- // eslint-disable-next-line no-prototype-builtins
23184
- if (!imageUsage.hasOwnProperty(texId)) {
23185
- imageUsage[texId] = 0;
23186
- }
23187
- imageUsage[texId]++;
23188
- }
23189
- }
23190
- /**
23191
- * 处理蒙版和遮挡关系写入 stencil 的 ref 值
23192
- */ processMask(renderer) {
23193
- const maskMode = renderer.maskMode;
23194
- if (maskMode === MaskMode.NONE) {
23195
- return;
23196
- }
23197
- if (!renderer.mask) {
23198
- if (maskMode === MaskMode.MASK) {
23199
- renderer.mask = ++this.mask;
23200
- } else if (maskMode === MaskMode.OBSCURED || maskMode === MaskMode.REVERSE_OBSCURED) {
23201
- renderer.mask = this.mask;
23202
- }
23203
- }
23204
- }
23205
- dispose() {
23206
- this.textures = [];
23207
- this.composition = undefined;
23208
- this.jsonScene = undefined;
23209
- this.totalTime = 0;
23210
- this.pluginSystem = undefined;
23211
- this.sourceContent = undefined;
23212
- this.refCompositions.clear();
23213
- this.refCompositionProps.clear();
23214
- }
23215
- constructor(scene, engine){
23216
- this.refCompositions = new Map();
23217
- this.refCompositionProps = new Map();
23218
- this.mask = 0;
23219
- this.engine = engine;
23220
- // 资源
23221
- const { jsonScene, renderLevel, textureOptions, pluginSystem, totalTime } = scene;
23222
- const { compositions, imgUsage, compositionId } = jsonScene;
23223
- if (!textureOptions) {
23224
- throw new Error('scene.textures expected');
23225
- }
23226
- const cachedTextures = textureOptions;
23227
- for (const comp of compositions){
23228
- if (comp.id === compositionId) {
23229
- this.composition = comp;
23230
- } else {
23231
- this.refCompositions.set(comp.id, comp);
23232
- }
23233
- }
23234
- if (!this.composition) {
23235
- throw new Error('Invalid composition id: ' + compositionId);
23236
- }
23237
- this.jsonScene = jsonScene;
23238
- this.renderLevel = renderLevel;
23239
- this.pluginSystem = pluginSystem;
23240
- this.totalTime = totalTime != null ? totalTime : 0;
23241
- this.imgUsage = imgUsage != null ? imgUsage : {};
23242
- this.textures = cachedTextures;
23243
- listOrder = 0;
23244
- this.sourceContent = this.getContent(this.composition);
23245
- }
23246
- }
23247
-
23248
23266
  /**
23249
23267
  * Engine 基类,负责维护所有 GPU 资源的管理及销毁
23250
23268
  */ class Engine {
@@ -23268,65 +23286,48 @@ let listOrder = 0;
23268
23286
  delete this.objectInstance[id];
23269
23287
  }
23270
23288
  addPackageDatas(scene) {
23271
- const jsonScene = scene.jsonScene;
23272
- if (jsonScene.items) {
23273
- for (const vfxItemData of jsonScene.items){
23274
- this.addEffectsObjectData(vfxItemData);
23275
- }
23289
+ const { jsonScene, textureOptions = [] } = scene;
23290
+ const { items = [], materials = [], shaders = [], geometries = [], components = [], animations = [], bins = [] } = jsonScene;
23291
+ for (const vfxItemData of items){
23292
+ this.addEffectsObjectData(vfxItemData);
23276
23293
  }
23277
- if (jsonScene.materials) {
23278
- for (const materialData of jsonScene.materials){
23279
- this.addEffectsObjectData(materialData);
23280
- }
23294
+ for (const materialData of materials){
23295
+ this.addEffectsObjectData(materialData);
23281
23296
  }
23282
- if (jsonScene.shaders) {
23283
- for (const shaderData of jsonScene.shaders){
23284
- this.addEffectsObjectData(shaderData);
23285
- }
23297
+ for (const shaderData of shaders){
23298
+ this.addEffectsObjectData(shaderData);
23286
23299
  }
23287
- if (jsonScene.geometries) {
23288
- for (const geometryData of jsonScene.geometries){
23289
- this.addEffectsObjectData(geometryData);
23290
- }
23300
+ for (const geometryData of geometries){
23301
+ this.addEffectsObjectData(geometryData);
23291
23302
  }
23292
- if (jsonScene.components) {
23293
- for (const componentData of jsonScene.components){
23294
- this.addEffectsObjectData(componentData);
23295
- }
23303
+ for (const componentData of components){
23304
+ this.addEffectsObjectData(componentData);
23296
23305
  }
23297
- if (jsonScene.animations) {
23298
- for (const animationData of jsonScene.animations){
23299
- this.addEffectsObjectData(animationData);
23300
- }
23306
+ for (const animationData of animations){
23307
+ this.addEffectsObjectData(animationData);
23301
23308
  }
23302
- if (jsonScene.bins) {
23303
- for(let i = 0; i < jsonScene.bins.length; i++){
23304
- const binaryData = jsonScene.bins[i];
23305
- const binaryBuffer = scene.bins[i];
23306
- //@ts-expect-error
23307
- binaryData.buffer = binaryBuffer;
23309
+ for(let i = 0; i < bins.length; i++){
23310
+ const binaryData = bins[i];
23311
+ const binaryBuffer = scene.bins[i];
23312
+ //@ts-expect-error
23313
+ binaryData.buffer = binaryBuffer;
23314
+ //@ts-expect-error
23315
+ if (binaryData.id) {
23308
23316
  //@ts-expect-error
23309
- if (binaryData.id) {
23310
- //@ts-expect-error
23311
- this.addEffectsObjectData(binaryData);
23312
- }
23317
+ this.addEffectsObjectData(binaryData);
23313
23318
  }
23314
23319
  }
23315
- if (scene.textureOptions) {
23316
- for (const textureData of scene.textureOptions){
23317
- this.addEffectsObjectData(textureData);
23318
- }
23320
+ for (const textureData of textureOptions){
23321
+ this.addEffectsObjectData(textureData);
23319
23322
  }
23320
23323
  }
23321
23324
  createVFXItems(scene) {
23322
23325
  var _this = this;
23323
23326
  return _async_to_generator(function*() {
23324
- const jsonScene = scene.jsonScene;
23327
+ const { jsonScene } = scene;
23325
23328
  for (const itemData of jsonScene.items){
23326
23329
  const itemType = itemData.type;
23327
- if (!// @ts-expect-error
23328
- (itemType === 'ECS' || // @ts-expect-error
23329
- itemType === 'camera' || itemType === ItemType.sprite || itemType === ItemType.particle || itemType === ItemType.mesh || itemType === ItemType.skybox || itemType === ItemType.light || itemType === ItemType.tree || itemType === ItemType.interact || itemType === ItemType.camera)) {
23330
+ if (!(itemType === 'ECS' || itemType === 'camera' || itemType === ItemType.sprite || itemType === ItemType.particle || itemType === ItemType.mesh || itemType === ItemType.skybox || itemType === ItemType.light || itemType === ItemType.tree || itemType === ItemType.interact || itemType === ItemType.camera)) {
23330
23331
  continue;
23331
23332
  }
23332
23333
  if (_this.database) {
@@ -23424,21 +23425,11 @@ let listOrder = 0;
23424
23425
  if (info.length > 0) {
23425
23426
  logger.warn(`Release GPU memory: ${info.join(', ')}`);
23426
23427
  }
23427
- this.renderPasses.forEach((pass)=>{
23428
- pass.dispose();
23429
- });
23430
- this.meshes.forEach((mesh)=>{
23431
- mesh.dispose();
23432
- });
23433
- this.geometries.forEach((geo)=>{
23434
- geo.dispose();
23435
- });
23436
- this.materials.forEach((mat)=>{
23437
- mat.dispose();
23438
- });
23439
- this.textures.forEach((tex)=>{
23440
- tex.dispose();
23441
- });
23428
+ this.renderPasses.forEach((pass)=>pass.dispose());
23429
+ this.meshes.forEach((mesh)=>mesh.dispose());
23430
+ this.geometries.forEach((geo)=>geo.dispose());
23431
+ this.materials.forEach((mat)=>mat.dispose());
23432
+ this.textures.forEach((tex)=>tex.dispose());
23442
23433
  this.textures = [];
23443
23434
  this.materials = [];
23444
23435
  this.geometries = [];
@@ -23588,5 +23579,5 @@ registerPlugin('particle', ParticleLoader, VFXItem, true);
23588
23579
  registerPlugin('cal', CalculateLoader, VFXItem, true);
23589
23580
  registerPlugin('interact', InteractLoader, VFXItem, true);
23590
23581
 
23591
- export { AbstractPlugin, ActivationPlayable, ActivationPlayableAsset, ActivationTrack, AnimationClip, AnimationClipPlayable, AssetLoader, AssetManager, BYTES_TYPE_MAP, Behaviour, BezierCurve, BezierCurvePath, BezierCurveQuat, BinaryAsset, COMPRESSED_TEXTURE, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, CalculateLoader, Camera, CameraController, CameraVFXItemLoader, Component, Composition, CompositionComponent, CompositionSourceManager, DEFAULT_FONTS, Database, DestroyOptions, Downloader, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, EffectComponent, EffectsObject, Engine, EventSystem, FilterMode, Float16ArrayWrapper, Framebuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GradientValue, HELP_LINK, HitTestType, InteractComponent, InteractLoader, InteractMesh, Item, ItemBehaviour, KTXTexture, LineSegments, LinearValue, Material, MaterialDataBlock, MaterialRenderType, Mesh, ObjectBindingTrack, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleBehaviourPlayable, ParticleBehaviourPlayableAsset, ParticleLoader, ParticleMesh, ParticleSystem, ParticleSystemRenderer, PassTextureCache, PathSegments, PluginSystem, RENDER_PASS_NAME_PREFIX, RENDER_PREFER_LOOKUP_TEXTURE, RUNTIME_ENV, RandomSetValue, RandomValue, RandomVectorValue, RenderFrame, RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, RenderTargetHandle, RenderTextureFormat, Renderbuffer, Renderer, RendererComponent, RuntimeClip, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0, SEMANTIC_PRE_COLOR_ATTACHMENT_0, SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0, SPRITE_VERTEX_STRIDE, SemanticMap, SerializationHelper, Shader, ShaderCompileResultStatus, ShaderType, ShaderVariant, SpriteColorPlayable, SpriteColorPlayableAsset, SpriteColorTrack, SpriteComponent, SpriteLoader, StaticValue, TEMPLATE_USE_OFFSCREEN_CANVAS, TextComponent, TextLoader, Texture, TextureFactory, TextureLoadAction, TextureSourceType, TextureStoreAction, Ticker, TimelineAsset, TimelineClip, TimelinePlayable, TrackAsset, TrackSortWrapper, TrackType, Transform, TransformAnimationPlayable, TransformPlayableAsset, TransformTrack, VFXItem, ValueGetter, addByOrder, addItem, addItemWithOrder, assertExist, asserts, blend, calculateTranslation, canvasPool, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, compatible_frag as compatibleFrag, compatible_vert as compatibleVert, createCopyShader, createGLContext, createKeyFrameMeta, createShaderWithMarcos, createShape, createVFXItem, createValueGetter, decimalEqual, deepClone, defaultGlobalVolume, defaultPlugins, deserializeMipmapTexture, earcut, effectsClass, effectsClassStore, enlargeBuffer, ensureFixedNumber, ensureVec3, findPreviousRenderPass, gaussianDown_frag as gaussianDownFrag, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTypedArray, generateGUID, generateHalfFloatTexture, generateTransparentTexture, generateWhiteTexture, getBackgroundImage, getColorFromGradientStops, getConfig, getDefaultTemplateCanvasPool, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, getImageItemRenderInfo, getKTXTextureOptions, getKeyFrameMetaByRawValue, getMergedStore, getParticleMeshShader, getPixelRatio, getPreMultiAlpha, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, getTextureSize, glContext, glType2VertexFormatType, gpuTimer, imageDataFromColor, imageDataFromGradient, initErrors, initGLContext, integrate, interpolateColor, isAlipayMiniApp, isAndroid, isArray, isFunction, isIOS, isObject, isSceneJSON, isSceneURL, isSceneWithOptions, isSimulatorCellPhone, isString, isUniformStruct, isUniformStructArray, isValidFontFamily, isWebGL2, itemFrag, itemFrameFrag, itemVert, loadBinary, loadBlob, loadImage, loadMedia, loadVideo, loadWebPOptional, logger, index as math, maxSpriteMeshItemCount, maxSpriteTextureCount, modifyMaxKeyframeShader, nearestPowerOfTwo, noop, normalizeColor, numberToFix, parsePercent$1 as parsePercent, particleFrag, particleOriginTranslateMap$1 as particleOriginTranslateMap, particleUniformTypeMap, particleVert, pluginLoaderMap, pointOnLine, random, registerPlugin, removeItem, rotateVec2, screenMeshVert, serialize, setBlendMode, setConfig, setDefaultTextureFactory, setMaskMode, setMaxSpriteMeshItemCount, setRayFromCamera, setSideMode, setSpriteMeshMaxFragmentTextures, setSpriteMeshMaxItemCountByGPU, sortByOrder, index$1 as spec, spriteMeshShaderFromFilter, spriteMeshShaderFromRenderInfo, spriteMeshShaderIdFromRenderInfo, thresholdFrag, throwDestroyedError, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecAssign, vecFill, vecMulCombine, vecNormalize, vertexFormatType2GLType };
23582
+ export { AbstractPlugin, ActivationPlayable, ActivationPlayableAsset, ActivationTrack, AnimationClip, AnimationClipPlayable, AssetLoader, AssetManager, BYTES_TYPE_MAP, Behaviour, BezierCurve, BezierCurvePath, BezierCurveQuat, BinaryAsset, COMPRESSED_TEXTURE, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, CalculateLoader, Camera, CameraController, CameraVFXItemLoader, Component, Composition, CompositionComponent, CompositionSourceManager, DEFAULT_FONTS, Database, DestroyOptions, Downloader, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, EffectComponent, EffectsObject, Engine, EventSystem, FilterMode, Float16ArrayWrapper, Framebuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GradientValue, HELP_LINK, HitTestType, InteractComponent, InteractLoader, InteractMesh, Item, ItemBehaviour, KTXTexture, LineSegments, LinearValue, Material, MaterialDataBlock, MaterialRenderType, Mesh, ObjectBindingTrack, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleBehaviourPlayable, ParticleBehaviourPlayableAsset, ParticleLoader, ParticleMesh, ParticleSystem, ParticleSystemRenderer, PassTextureCache, PathSegments, PluginSystem, RENDER_PASS_NAME_PREFIX, RENDER_PREFER_LOOKUP_TEXTURE, RUNTIME_ENV, RandomSetValue, RandomValue, RandomVectorValue, RenderFrame, RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, RenderTargetHandle, RenderTextureFormat, Renderbuffer, Renderer, RendererComponent, RuntimeClip, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0, SEMANTIC_PRE_COLOR_ATTACHMENT_0, SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0, SPRITE_VERTEX_STRIDE, SemanticMap, SerializationHelper, Shader, ShaderCompileResultStatus, ShaderType, ShaderVariant, SpriteColorPlayable, SpriteColorPlayableAsset, SpriteColorTrack, SpriteComponent, SpriteLoader, StaticValue, SubCompositionPlayableAsset, SubCompositionTrack, TEMPLATE_USE_OFFSCREEN_CANVAS, TextComponent, TextLoader, Texture, TextureFactory, TextureLoadAction, TextureSourceType, TextureStoreAction, Ticker, TimelineAsset, TimelineClip, TimelinePlayable, TrackAsset, TrackSortWrapper, TrackType, Transform, TransformAnimationPlayable, TransformPlayableAsset, TransformTrack, VFXItem, ValueGetter, addByOrder, addItem, addItemWithOrder, assertExist, asserts, base64ToFile, blend, calculateTranslation, canvasPool, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, compatible_frag as compatibleFrag, compatible_vert as compatibleVert, createCopyShader, createGLContext, createKeyFrameMeta, createShaderWithMarcos, createShape, createVFXItem, createValueGetter, decimalEqual, deepClone, defaultGlobalVolume, defaultPlugins, deserializeMipmapTexture, earcut, effectsClass, effectsClassStore, enlargeBuffer, ensureFixedNumber, ensureVec3, findPreviousRenderPass, gaussianDown_frag as gaussianDownFrag, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTypedArray, generateGUID, generateHalfFloatTexture, generateTransparentTexture, generateWhiteTexture, getBackgroundImage, getColorFromGradientStops, getConfig, getDefaultTemplateCanvasPool, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, getImageItemRenderInfo, getKTXTextureOptions, getKeyFrameMetaByRawValue, getMergedStore, getParticleMeshShader, getPixelRatio, getPreMultiAlpha, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, getTextureSize, glContext, glType2VertexFormatType, gpuTimer, imageDataFromColor, imageDataFromGradient, initErrors, initGLContext, integrate, interpolateColor, isAlipayMiniApp, isAndroid, isArray, isCanvas, isFunction, isIOS, isObject, isSceneJSON, isSceneURL, isSceneWithOptions, isSimulatorCellPhone, isString, isUniformStruct, isUniformStructArray, isValidFontFamily, isWebGL2, itemFrag, itemFrameFrag, itemVert, loadBinary, loadBlob, loadImage, loadMedia, loadVideo, loadWebPOptional, logger, index as math, maxSpriteMeshItemCount, maxSpriteTextureCount, modifyMaxKeyframeShader, nearestPowerOfTwo, noop, normalizeColor, numberToFix, parsePercent$1 as parsePercent, particleFrag, particleOriginTranslateMap$1 as particleOriginTranslateMap, particleUniformTypeMap, particleVert, pluginLoaderMap, pointOnLine, random, registerPlugin, removeItem, rotateVec2, screenMeshVert, serialize, setBlendMode, setConfig, setDefaultTextureFactory, setMaskMode, setMaxSpriteMeshItemCount, setRayFromCamera, setSideMode, setSpriteMeshMaxFragmentTextures, setSpriteMeshMaxItemCountByGPU, sortByOrder, index$1 as spec, spriteMeshShaderFromFilter, spriteMeshShaderFromRenderInfo, spriteMeshShaderIdFromRenderInfo, thresholdFrag, throwDestroyedError, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecAssign, vecFill, vecMulCombine, vecNormalize, vertexFormatType2GLType };
23592
23583
  //# sourceMappingURL=index.mjs.map