@galacean/effects-threejs 2.0.0-alpha.15 → 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 threejs plugin for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v2.0.0-alpha.15
6
+ * Version: v2.0.0-alpha.16
7
7
  */
8
8
 
9
9
  import * as THREE from 'three';
@@ -13689,13 +13689,16 @@ var SpriteColorPlayable = /*#__PURE__*/ function(Playable) {
13689
13689
  }
13690
13690
  var _proto = SpriteColorPlayable.prototype;
13691
13691
  _proto.processFrame = function processFrame(context) {
13692
- var boundItem = context.output.getUserData();
13692
+ var boundObject = context.output.getUserData();
13693
+ if (!_instanceof1(boundObject, VFXItem)) {
13694
+ return;
13695
+ }
13693
13696
  if (!this.spriteMaterial) {
13694
- this.spriteMaterial = boundItem.getComponent(SpriteComponent).material;
13697
+ this.spriteMaterial = boundObject.getComponent(SpriteComponent).material;
13695
13698
  }
13696
13699
  var colorInc = vecFill(tempColor, 1);
13697
13700
  var colorChanged;
13698
- var life = this.time / boundItem.duration;
13701
+ var life = this.time / boundObject.duration;
13699
13702
  var opacityOverLifetime = this.opacityOverLifetime;
13700
13703
  var colorOverLifetime = this.colorOverLifetime;
13701
13704
  if (colorOverLifetime) {
@@ -13825,7 +13828,6 @@ var SpriteComponent = /*#__PURE__*/ function(RendererComponent) {
13825
13828
  renderer.drawGeometry(geo, material);
13826
13829
  };
13827
13830
  _proto.start = function start() {
13828
- this.priority = this.item.listIndex;
13829
13831
  this.item.getHitTestParams = this.getHitTestParams;
13830
13832
  };
13831
13833
  _proto.update = function update(dt) {
@@ -16229,7 +16231,7 @@ function getTrailMeshShader(trails, particleMaxCount, name, env, gpuCapability)
16229
16231
  }
16230
16232
  var _proto = ParticleSystemRenderer.prototype;
16231
16233
  _proto.start = function start() {
16232
- this._priority = this.item.listIndex;
16234
+ this._priority = this.item.renderOrder;
16233
16235
  this.particleMesh.gravityModifier.scaleXCoord(this.item.duration);
16234
16236
  for(var _iterator = _create_for_of_iterator_helper_loose(this.meshes), _step; !(_step = _iterator()).done;){
16235
16237
  var mesh = _step.value;
@@ -17279,13 +17281,13 @@ function randomArrItem(arr, keepArr) {
17279
17281
  }
17280
17282
  var _proto = ParticleBehaviourPlayable.prototype;
17281
17283
  _proto.start = function start(context) {
17282
- var binding = context.output.getUserData();
17283
- if (this.particleSystem) {
17284
+ var boundObject = context.output.getUserData();
17285
+ if (this.particleSystem || !_instanceof1(boundObject, VFXItem)) {
17284
17286
  return;
17285
17287
  }
17286
- this.particleSystem = binding.getComponent(ParticleSystem);
17288
+ this.particleSystem = boundObject.getComponent(ParticleSystem);
17287
17289
  if (this.particleSystem) {
17288
- this.particleSystem.name = binding.name;
17290
+ this.particleSystem.name = boundObject.name;
17289
17291
  this.particleSystem.start();
17290
17292
  this.particleSystem.initEmitterTransform();
17291
17293
  }
@@ -18443,10 +18445,13 @@ var tempPos = new Vector3();
18443
18445
  };
18444
18446
  _proto.processFrame = function processFrame(context) {
18445
18447
  if (!this.binding) {
18446
- this.binding = context.output.getUserData();
18447
- this.start();
18448
+ var boundObject = context.output.getUserData();
18449
+ if (_instanceof1(boundObject, VFXItem)) {
18450
+ this.binding = boundObject;
18451
+ this.start();
18452
+ }
18448
18453
  }
18449
- if (this.binding.composition) {
18454
+ if (this.binding && this.binding.composition) {
18450
18455
  this.sampleAnimation();
18451
18456
  }
18452
18457
  };
@@ -18655,9 +18660,12 @@ var AnimationClipPlayable = /*#__PURE__*/ function(Playable) {
18655
18660
  }
18656
18661
  var _proto = AnimationClipPlayable.prototype;
18657
18662
  _proto.processFrame = function processFrame(context) {
18658
- var boundItem = context.output.getUserData();
18659
- if (boundItem.composition) {
18660
- this.clip.sampleAnimation(boundItem, this.time);
18663
+ var boundObject = context.output.getUserData();
18664
+ if (!_instanceof1(boundObject, VFXItem)) {
18665
+ return;
18666
+ }
18667
+ if (boundObject.composition) {
18668
+ this.clip.sampleAnimation(boundObject, this.time);
18661
18669
  }
18662
18670
  };
18663
18671
  return AnimationClipPlayable;
@@ -18901,13 +18909,11 @@ var ActivationMixerPlayable = /*#__PURE__*/ function(Playable) {
18901
18909
  }
18902
18910
  var _proto = ActivationMixerPlayable.prototype;
18903
18911
  _proto.processFrame = function processFrame(context) {
18904
- if (!this.bindingItem) {
18905
- this.bindingItem = context.output.getUserData();
18906
- }
18907
- if (!this.bindingItem) {
18912
+ var boundObject = context.output.getUserData();
18913
+ if (!_instanceof1(boundObject, VFXItem)) {
18908
18914
  return;
18909
18915
  }
18910
- var bindingItem = this.bindingItem;
18916
+ var boundItem = boundObject;
18911
18917
  var hasInput = false;
18912
18918
  for(var i = 0; i < this.getInputCount(); i++){
18913
18919
  if (this.getInputWeight(i) > 0) {
@@ -18916,11 +18922,11 @@ var ActivationMixerPlayable = /*#__PURE__*/ function(Playable) {
18916
18922
  }
18917
18923
  }
18918
18924
  if (hasInput) {
18919
- bindingItem.transform.setValid(true);
18920
- this.showRendererComponents(bindingItem);
18925
+ boundItem.transform.setValid(true);
18926
+ this.showRendererComponents(boundItem);
18921
18927
  } else {
18922
- bindingItem.transform.setValid(false);
18923
- this.hideRendererComponents(bindingItem);
18928
+ boundItem.transform.setValid(false);
18929
+ this.hideRendererComponents(boundItem);
18924
18930
  }
18925
18931
  };
18926
18932
  _proto.hideRendererComponents = function hideRendererComponents(item) {
@@ -19347,7 +19353,9 @@ var SubCompositionClipPlayable = /*#__PURE__*/ function(Playable) {
19347
19353
  var _proto = SubCompositionClipPlayable.prototype;
19348
19354
  _proto.processFrame = function processFrame(context) {
19349
19355
  var boundObject = context.output.getUserData();
19350
- boundObject.time = this.getTime();
19356
+ if (_instanceof1(boundObject, CompositionComponent)) {
19357
+ boundObject.time = this.getTime();
19358
+ }
19351
19359
  };
19352
19360
  return SubCompositionClipPlayable;
19353
19361
  }(Playable);
@@ -20374,7 +20382,7 @@ var VFXItem = /*#__PURE__*/ function(EffectsObject) {
20374
20382
  this.parentId = parentId;
20375
20383
  this.duration = duration;
20376
20384
  this.endBehavior = endBehavior;
20377
- this.listIndex = listIndex;
20385
+ this.renderOrder = listIndex;
20378
20386
  //@ts-expect-error
20379
20387
  this.oldId = data.oldId;
20380
20388
  if (!data.content) {
@@ -20506,6 +20514,23 @@ var VFXItem = /*#__PURE__*/ function(EffectsObject) {
20506
20514
  var _this_composition_reusable;
20507
20515
  return (_this_composition_reusable = (_this_composition = this.composition) == null ? void 0 : _this_composition.reusable) != null ? _this_composition_reusable : false;
20508
20516
  }
20517
+ },
20518
+ {
20519
+ key: "renderOrder",
20520
+ get: /**
20521
+ * 元素在合成中的索引
20522
+ */ function get() {
20523
+ return this.listIndex;
20524
+ },
20525
+ set: function set(value) {
20526
+ if (this.listIndex !== value) {
20527
+ this.listIndex = value;
20528
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.rendererComponents), _step; !(_step = _iterator()).done;){
20529
+ var rendererComponent = _step.value;
20530
+ rendererComponent.priority = value;
20531
+ }
20532
+ }
20533
+ }
20509
20534
  }
20510
20535
  ]);
20511
20536
  return VFXItem;
@@ -20954,9 +20979,8 @@ var SerializationHelper = /*#__PURE__*/ function() {
20954
20979
  console.error("序列化数据的内嵌对象层数大于上限");
20955
20980
  return;
20956
20981
  }
20957
- if (typeof property === "number" || typeof property === "string" || typeof property === "boolean") {
20958
- return property;
20959
- } else if (_instanceof1(property, Array)) {
20982
+ // 加载并链接 DataPath 字段表示的 EffectsObject 引用。Class 对象 copy [key, value] 会丢失对象信息,因此只递归数组对象和普通 js Object 结构对象。
20983
+ if (_instanceof1(property, Array)) {
20960
20984
  var res = [];
20961
20985
  for(var _iterator = _create_for_of_iterator_helper_loose(property), _step; !(_step = _iterator()).done;){
20962
20986
  var value = _step.value;
@@ -20966,9 +20990,7 @@ var SerializationHelper = /*#__PURE__*/ function() {
20966
20990
  // TODO json 数据避免传 typedArray
20967
20991
  } else if (SerializationHelper.checkDataPath(property)) {
20968
20992
  return engine.assetLoader.loadGUID(property.id);
20969
- } else if (_instanceof1(property, EffectsObject) || SerializationHelper.checkImageSource(property) || SerializationHelper.checkTypedArray(property) || SerializationHelper.checkGLTFNode(property)) {
20970
- return property;
20971
- } else if (_instanceof1(property, Object)) {
20993
+ } else if (_instanceof1(property, Object) && property.constructor === Object) {
20972
20994
  var res1;
20973
20995
  if (type) {
20974
20996
  var classConstructor = effectsClassStore[type];
@@ -20982,6 +21004,8 @@ var SerializationHelper = /*#__PURE__*/ function() {
20982
21004
  res1[key] = SerializationHelper.deserializeProperty(property[key], engine, level + 1);
20983
21005
  }
20984
21006
  return res1;
21007
+ } else {
21008
+ return property;
20985
21009
  }
20986
21010
  };
20987
21011
  SerializationHelper.deserializePropertyAsync = function deserializePropertyAsync(property, engine, level, type) {
@@ -20996,26 +21020,17 @@ var SerializationHelper = /*#__PURE__*/ function() {
20996
21020
  2
20997
21021
  ];
20998
21022
  }
20999
- if (!(typeof property === "number" || typeof property === "string" || typeof property === "boolean")) return [
21000
- 3,
21001
- 1
21002
- ];
21003
- return [
21004
- 2,
21005
- property
21006
- ];
21007
- case 1:
21008
21023
  if (!_instanceof1(property, Array)) return [
21009
21024
  3,
21010
- 6
21025
+ 5
21011
21026
  ];
21012
21027
  res = [];
21013
21028
  _iterator = _create_for_of_iterator_helper_loose(property);
21014
- _state.label = 2;
21015
- case 2:
21029
+ _state.label = 1;
21030
+ case 1:
21016
21031
  if (!!(_step = _iterator()).done) return [
21017
21032
  3,
21018
- 5
21033
+ 4
21019
21034
  ];
21020
21035
  value = _step.value;
21021
21036
  _ = res.push;
@@ -21023,43 +21038,38 @@ var SerializationHelper = /*#__PURE__*/ function() {
21023
21038
  4,
21024
21039
  SerializationHelper.deserializePropertyAsync(value, engine, level + 1, type)
21025
21040
  ];
21026
- case 3:
21041
+ case 2:
21027
21042
  _.apply(res, [
21028
21043
  _state.sent()
21029
21044
  ]);
21030
- _state.label = 4;
21031
- case 4:
21045
+ _state.label = 3;
21046
+ case 3:
21032
21047
  return [
21033
21048
  3,
21034
- 2
21049
+ 1
21035
21050
  ];
21036
- case 5:
21051
+ case 4:
21037
21052
  return [
21038
21053
  2,
21039
21054
  res
21040
21055
  ];
21041
- case 6:
21056
+ case 5:
21042
21057
  if (!SerializationHelper.checkDataPath(property)) return [
21043
21058
  3,
21044
- 8
21059
+ 7
21045
21060
  ];
21046
21061
  return [
21047
21062
  4,
21048
21063
  engine.assetLoader.loadGUIDAsync(property.id)
21049
21064
  ];
21050
- case 7:
21065
+ case 6:
21051
21066
  res1 = _state.sent();
21052
21067
  return [
21053
21068
  2,
21054
21069
  res1
21055
21070
  ];
21056
- case 8:
21057
- if (_instanceof1(property, EffectsObject) || SerializationHelper.checkImageSource(property) || SerializationHelper.checkTypedArray(property) || SerializationHelper.checkGLTFNode(property)) {
21058
- return [
21059
- 2,
21060
- property
21061
- ];
21062
- } else if (_instanceof1(property, Object)) {
21071
+ case 7:
21072
+ if (_instanceof1(property, Object) && property.constructor === Object) {
21063
21073
  if (type) {
21064
21074
  classConstructor = effectsClassStore[type];
21065
21075
  res2 = new classConstructor();
@@ -21075,9 +21085,13 @@ var SerializationHelper = /*#__PURE__*/ function() {
21075
21085
  2,
21076
21086
  res2
21077
21087
  ];
21088
+ } else {
21089
+ return [
21090
+ 2,
21091
+ property
21092
+ ];
21078
21093
  }
21079
- _state.label = 9;
21080
- case 9:
21094
+ case 8:
21081
21095
  return [
21082
21096
  2
21083
21097
  ];
@@ -22971,7 +22985,17 @@ function getStandardItem(item, opt) {
22971
22985
  }
22972
22986
 
22973
22987
  var _obj$1;
22974
- var renderLevelPassSet = (_obj$1 = {}, _obj$1[RenderLevel.S] = [
22988
+ /**
22989
+ * 机型和渲染等级对应表
22990
+ *
22991
+ * 机型:B-低端机、A-中端机、S-高端机
22992
+ * 渲染等级:B-低、A-中、S-高、A+-中高、B+-全部
22993
+ *
22994
+ * - S(高端机):高、全部、中高
22995
+ * - A(中端机):中、全部、中高
22996
+ * - B(低端机):低、全部
22997
+ * - undefined(全部机型)
22998
+ */ var renderLevelPassSet = (_obj$1 = {}, _obj$1[RenderLevel.S] = [
22975
22999
  RenderLevel.S,
22976
23000
  RenderLevel.BPlus,
22977
23001
  RenderLevel.APlus
@@ -24375,7 +24399,7 @@ var listOrder = 0;
24375
24399
  scene.textures = undefined;
24376
24400
  scene.consumed = true;
24377
24401
  }
24378
- var _this_compositionSourceManager = this.compositionSourceManager, sourceContent = _this_compositionSourceManager.sourceContent, pluginSystem = _this_compositionSourceManager.pluginSystem, imgUsage = _this_compositionSourceManager.imgUsage, totalTime = _this_compositionSourceManager.totalTime, renderLevel = _this_compositionSourceManager.renderLevel, refCompositionProps = _this_compositionSourceManager.refCompositionProps;
24402
+ var _this_compositionSourceManager = this.compositionSourceManager, sourceContent = _this_compositionSourceManager.sourceContent, pluginSystem = _this_compositionSourceManager.pluginSystem, imgUsage = _this_compositionSourceManager.imgUsage, totalTime = _this_compositionSourceManager.totalTime, refCompositionProps = _this_compositionSourceManager.refCompositionProps;
24379
24403
  assertExist(sourceContent);
24380
24404
  this.renderer = renderer;
24381
24405
  this.refCompositionProps = refCompositionProps;
@@ -24401,7 +24425,6 @@ var listOrder = 0;
24401
24425
  };
24402
24426
  this.reusable = reusable;
24403
24427
  this.speed = speed;
24404
- this.renderLevel = renderLevel;
24405
24428
  this.autoRefTex = !this.keepResource && imageUsage && this.rootItem.endBehavior !== ItemEndBehavior.loop;
24406
24429
  this.name = sourceContent.name;
24407
24430
  this.pluginSystem = pluginSystem;
@@ -27133,7 +27156,7 @@ setMaxSpriteMeshItemCount(8);
27133
27156
  */ Mesh.create = function(engine, props) {
27134
27157
  return new ThreeMesh(engine, props);
27135
27158
  };
27136
- var version = "2.0.0-alpha.15";
27159
+ var version = "2.0.0-alpha.16";
27137
27160
  logger.info("THREEJS plugin version: " + version);
27138
27161
 
27139
27162
  export { AbstractPlugin, ActivationPlayable, ActivationPlayableAsset, ActivationTrack, AnimationClip, AnimationClipPlayable, AssetLoader, AssetManager, BYTES_TYPE_MAP, Behaviour, BezierCurve, BezierCurvePath, BezierCurveQuat, BinaryAsset, COMPRESSED_TEXTURE, CONSTANT_MAP_BLEND, CONSTANT_MAP_DEPTH, CONSTANT_MAP_STENCIL_FUNC, CONSTANT_MAP_STENCIL_OP, 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, TEXTURE_UNIFORM_MAP, TextComponent, TextLoader, Texture, TextureFactory, TextureLoadAction, TextureSourceType, TextureStoreAction, ThreeComposition, ThreeDisplayObject, ThreeEngine, ThreeMaterial, ThreeSpriteComponent, ThreeTexture, 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, setUniformValue, sortByOrder, index$1 as spec, spriteMeshShaderFromFilter, spriteMeshShaderFromRenderInfo, spriteMeshShaderIdFromRenderInfo, thresholdFrag, throwDestroyedError, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecAssign, vecFill, vecMulCombine, vecNormalize, version, vertexFormatType2GLType };