@galacean/effects-threejs 2.4.0-beta.1 → 2.4.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.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.4.0-beta.1
6
+ * Version: v2.4.0-beta.3
7
7
  */
8
8
 
9
9
  import * as THREE from 'three';
@@ -6106,8 +6106,7 @@ function setSideMode(material, side) {
6106
6106
  material.cullFace = side === SideMode.BACK ? glContext.BACK : glContext.FRONT;
6107
6107
  }
6108
6108
  }
6109
- function setMaskMode(material, maskMode, colorMask) {
6110
- if (colorMask === void 0) colorMask = false;
6109
+ function setMaskMode(material, maskMode) {
6111
6110
  switch(maskMode){
6112
6111
  case undefined:
6113
6112
  material.stencilTest = false;
@@ -6122,13 +6121,6 @@ function setMaskMode(material, maskMode, colorMask) {
6122
6121
  glContext.REPLACE,
6123
6122
  glContext.REPLACE
6124
6123
  ];
6125
- // 关闭/开启蒙版元素的颜色写入
6126
- material.colorMask = [
6127
- colorMask,
6128
- colorMask,
6129
- colorMask,
6130
- colorMask
6131
- ];
6132
6124
  break;
6133
6125
  case MaskMode.OBSCURED:
6134
6126
  material.stencilTest = true;
@@ -7600,13 +7592,6 @@ var MaterialRenderType;
7600
7592
  set: /**
7601
7593
  * 设置 Material 的通过 alpha 值决定临时覆盖值计算的开关
7602
7594
  * @param value - 是否开启 alpha 抖动
7603
- */ function set(value) {}
7604
- },
7605
- {
7606
- key: "colorMask",
7607
- set: /**
7608
- * 设置 Material 颜色缓冲区的写入开关
7609
- * @param value
7610
7595
  */ function set(value) {}
7611
7596
  },
7612
7597
  {
@@ -7665,10 +7650,15 @@ var MaskProcessor = /*#__PURE__*/ function() {
7665
7650
  } else if (mode === ObscuredMode.OBSCURED || mode === ObscuredMode.REVERSE_OBSCURED) {
7666
7651
  maskMode = mode === ObscuredMode.OBSCURED ? MaskMode.OBSCURED : MaskMode.REVERSE_OBSCURED;
7667
7652
  this.maskRef = ref.maskManager.getRefValue();
7653
+ this.maskable = ref;
7668
7654
  }
7669
7655
  }
7670
7656
  return maskMode;
7671
7657
  };
7658
+ _proto.drawStencilMask = function drawStencilMask(renderer) {
7659
+ var _this_maskable;
7660
+ (_this_maskable = this.maskable) == null ? void 0 : _this_maskable.drawStencilMask(renderer);
7661
+ };
7672
7662
  return MaskProcessor;
7673
7663
  }();
7674
7664
 
@@ -12575,17 +12565,16 @@ function getBezier2DValue(out, t, p0, p1, cpx0, cpy0, cpx1, cpy1) {
12575
12565
  if (!this.getVisible()) {
12576
12566
  return;
12577
12567
  }
12578
- if (renderer.renderingData.currentFrame.globalUniforms) {
12579
- renderer.setGlobalMatrix("effects_ObjectToWorld", this.transform.getWorldMatrix());
12580
- }
12581
- for(var i = 0; i < this.materials.length; i++){
12582
- var material = this.materials[i];
12583
- material.setVector2("_Size", this.transform.size);
12584
- if (this.renderer.renderMode === RenderMode.BILLBOARD || this.renderer.renderMode === RenderMode.VERTICAL_BILLBOARD || this.renderer.renderMode === RenderMode.HORIZONTAL_BILLBOARD) {
12585
- material.setVector3("_Scale", this.transform.scale);
12586
- }
12587
- renderer.drawGeometry(this.geometry, material, i);
12588
- }
12568
+ this.maskManager.drawStencilMask(renderer);
12569
+ this.draw(renderer);
12570
+ };
12571
+ /**
12572
+ * @internal
12573
+ */ _proto.drawStencilMask = function drawStencilMask(renderer) {
12574
+ var previousColorMask = this.material.colorMask;
12575
+ this.material.colorMask = false;
12576
+ this.draw(renderer);
12577
+ this.material.colorMask = previousColorMask;
12589
12578
  };
12590
12579
  _proto.onStart = function onStart() {
12591
12580
  this.item.getHitTestParams = this.getHitTestParams;
@@ -12703,7 +12692,7 @@ function getBezier2DValue(out, t, p0, p1, cpx0, cpy0, cpx1, cpy1) {
12703
12692
  ] : undefined;
12704
12693
  setBlendMode(material, blendMode);
12705
12694
  // 兼容旧数据中模板需要渲染的情况
12706
- setMaskMode(material, maskMode, !!this.renderer.shape);
12695
+ setMaskMode(material, maskMode);
12707
12696
  setSideMode(material, side);
12708
12697
  material.shader.shaderData.properties = '_MainTex("_MainTex",2D) = "white" {}';
12709
12698
  material.setColor("_Color", new Color(0, 0, 0, 1));
@@ -12723,6 +12712,19 @@ function getBezier2DValue(out, t, p0, p1, cpx0, cpy0, cpx1, cpy1) {
12723
12712
  }
12724
12713
  return material;
12725
12714
  };
12715
+ _proto.draw = function draw(renderer) {
12716
+ if (renderer.renderingData.currentFrame.globalUniforms) {
12717
+ renderer.setGlobalMatrix("effects_ObjectToWorld", this.transform.getWorldMatrix());
12718
+ }
12719
+ for(var i = 0; i < this.materials.length; i++){
12720
+ var material = this.materials[i];
12721
+ material.setVector2("_Size", this.transform.size);
12722
+ if (this.renderer.renderMode === RenderMode.BILLBOARD || this.renderer.renderMode === RenderMode.VERTICAL_BILLBOARD || this.renderer.renderMode === RenderMode.HORIZONTAL_BILLBOARD) {
12723
+ material.setVector3("_Scale", this.transform.scale);
12724
+ }
12725
+ renderer.drawGeometry(this.geometry, material, i);
12726
+ }
12727
+ };
12726
12728
  _proto.fromData = function fromData(data) {
12727
12729
  RendererComponent.prototype.fromData.call(this, data);
12728
12730
  var _data_renderer;
@@ -15363,6 +15365,7 @@ var InteractComponent = /*#__PURE__*/ function(RendererComponent) {
15363
15365
  };
15364
15366
  _this.duringPlay = false;
15365
15367
  /** 是否响应点击和拖拽交互事件 */ _this._interactive = true;
15368
+ _this.lastTime = -1;
15366
15369
  _this.getHitTestParams = function(force) {
15367
15370
  if (!_this.clickable) {
15368
15371
  return;
@@ -15453,11 +15456,21 @@ var InteractComponent = /*#__PURE__*/ function(RendererComponent) {
15453
15456
  var _this_previewContent;
15454
15457
  this.duringPlay = true;
15455
15458
  // trigger messageBegin when item enter
15456
- if (this.item.time > 0 && this.item.time - dt / 1000 <= 0) {
15457
- var _this_item_composition;
15458
- var options = this.item.props.content.options;
15459
- (_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.addInteractiveItem(this.item, options.type);
15459
+ if (this.lastTime <= this.item.time) {
15460
+ if (this.item.time >= 0 && this.lastTime < 0) {
15461
+ var _this_item_composition;
15462
+ var options = this.item.props.content.options;
15463
+ (_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.addInteractiveItem(this.item, options.type);
15464
+ }
15465
+ } else {
15466
+ // loop trigger
15467
+ if (this.item.time >= 0) {
15468
+ var _this_item_composition1;
15469
+ var options1 = this.item.props.content.options;
15470
+ (_this_item_composition1 = this.item.composition) == null ? void 0 : _this_item_composition1.addInteractiveItem(this.item, options1.type);
15471
+ }
15460
15472
  }
15473
+ this.lastTime = this.item.time;
15461
15474
  (_this_previewContent = this.previewContent) == null ? void 0 : _this_previewContent.updateMesh();
15462
15475
  if (!this.dragEvent || !this.bouncingArg) {
15463
15476
  return;
@@ -18589,6 +18602,7 @@ function modifyMaxKeyframeShader(shader, maxVertex, maxFrag) {
18589
18602
  this.particleMesh.mesh.material.setVector4("uParams", uParams.set(time, this.item.duration, 0, 0));
18590
18603
  };
18591
18604
  _proto.render = function render(renderer) {
18605
+ this.maskManager.drawStencilMask(renderer);
18592
18606
  for(var _iterator = _create_for_of_iterator_helper_loose(this.meshes), _step; !(_step = _iterator()).done;){
18593
18607
  var mesh = _step.value;
18594
18608
  mesh.render(renderer);
@@ -19538,6 +19552,7 @@ var ParticleSystem = /*#__PURE__*/ function(Component) {
19538
19552
  }
19539
19553
  this.renderer = new ParticleSystemRenderer(this.engine, particleMeshProps, trailMeshProps);
19540
19554
  this.renderer.item = this.item;
19555
+ this.renderer.maskManager = this.maskManager;
19541
19556
  this.meshes = this.renderer.meshes;
19542
19557
  var interaction = props.interaction;
19543
19558
  if (interaction) {
@@ -31621,7 +31636,7 @@ registerPlugin("sprite", SpriteLoader, VFXItem);
31621
31636
  registerPlugin("particle", ParticleLoader, VFXItem);
31622
31637
  registerPlugin("cal", CalculateLoader, VFXItem);
31623
31638
  registerPlugin("interact", InteractLoader, VFXItem);
31624
- var version$1 = "2.4.0-beta.1";
31639
+ var version$1 = "2.4.0-beta.3";
31625
31640
  logger.info("Core version: " + version$1 + ".");
31626
31641
 
31627
31642
  var _obj;
@@ -32214,6 +32229,17 @@ var _obj3;
32214
32229
  this.material.side = THREE.BackSide;
32215
32230
  }
32216
32231
  }
32232
+ },
32233
+ {
32234
+ key: "colorMask",
32235
+ get: function get() {
32236
+ return this.material.colorWrite;
32237
+ },
32238
+ set: /**
32239
+ * 获取颜色写入开关
32240
+ */ function set(value) {
32241
+ this.material.colorWrite = value;
32242
+ }
32217
32243
  }
32218
32244
  ]);
32219
32245
  return ThreeMaterial;
@@ -33212,7 +33238,7 @@ setMaxSpriteMeshItemCount(8);
33212
33238
  */ Mesh.create = function(engine, props) {
33213
33239
  return new ThreeMesh(engine, props);
33214
33240
  };
33215
- var version = "2.4.0-beta.1";
33241
+ var version = "2.4.0-beta.3";
33216
33242
  logger.info("THREEJS plugin version: " + version + ".");
33217
33243
 
33218
33244
  export { AbstractPlugin, ActivationPlayable, ActivationPlayableAsset, ActivationTrack, AnimationClip, AnimationClipPlayable, Asset, AssetLoader, AssetManager, AssetService, BYTES_TYPE_MAP, BaseRenderComponent, 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, ColorCurve, ColorPropertyPlayableAsset, ColorPropertyTrack, Component, Composition, CompositionComponent, DEFAULT_FONTS, DEFAULT_FPS, Database, DestroyOptions, Downloader, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, EffectComponent, EffectsObject, EffectsPackage, Ellipse, Engine, EventEmitter, EventSystem, Fake3DAnimationMode, Fake3DComponent, FilterMode, Float16ArrayWrapper, FloatPropertyPlayableAsset, FloatPropertyTrack, Framebuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GradientValue, GraphicsPath, HELP_LINK, HitTestType, InteractComponent, InteractLoader, InteractMesh, Item, KTXTexture, LineSegments, LinearValue, MaskMode, MaskProcessor, MaskRefManager, Material, MaterialDataBlock, MaterialRenderType, MaterialTrack, Mesh, MeshCollider, ObjectBindingTrack, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleBehaviourPlayable, ParticleBehaviourPlayableAsset, ParticleLoader, ParticleMesh, ParticleSystem, ParticleSystemRenderer, ParticleTrack, PassTextureCache, PathSegments, PluginSystem, PolyStar, Polygon, PostProcessVolume, PropertyTrack, 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, Scene, SemanticMap, SerializationHelper, Shader, ShaderCompileResultStatus, ShaderFactory, ShaderType, ShaderVariant, ShapeComponent, ShapePath, SpriteColorPlayableAsset, SpriteColorTrack, SpriteComponent, SpriteLoader, StarType, StaticValue, SubCompositionPlayableAsset, SubCompositionTrack, TEMPLATE_USE_OFFSCREEN_CANVAS, TEXTURE_UNIFORM_MAP, TextComponent, TextComponentBase, TextLayout, TextLoader, TextStyle, Texture, TextureFactory, TextureLoadAction, TextureSourceType, TextureStoreAction, ThreeComposition, ThreeDisplayObject, ThreeEngine, ThreeMaterial, ThreeSpriteComponent, ThreeTextComponent, ThreeTexture, Ticker, TimelineAsset, TimelineClip, TimelinePlayable, TrackAsset, TrackSortWrapper, TrackType, Transform, TransformAnimationPlayable, TransformPlayableAsset, TransformTrack, VFXItem, ValueGetter, Vector2Curve, Vector2PropertyPlayableAsset, Vector2PropertyTrack, Vector4Curve, Vector4PropertyPlayableAsset, Vector4PropertyTrack, addByOrder, addItem, addItemWithOrder, applyMixins, assertExist, asserts, base64ToFile, blend, buildLine, calculateTranslation, canvasPool, closePointEps, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, createCopyShader, createGLContext, createKeyFrameMeta, createShape, createValueGetter, curveEps, decimalEqual, defaultPlugins, deserializeMipmapTexture, earcut, effectsClass, effectsClassStore, enlargeBuffer, ensureFixedNumber, ensureVec3, findPreviousRenderPass, gaussianDown_frag as gaussianDownFrag, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTypedArray, generateGUID, generateHalfFloatTexture, generateTransparentTexture, generateWhiteTexture, getBackgroundImage, getColorFromGradientStops, getConfig, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, 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, isIOSByUA, isMiniProgram, isObject, isSimulatorCellPhone, isString, isUniformStruct, isUniformStructArray, isValidFontFamily, isWebGL2, isWechatMiniApp, itemFrag, itemFrame_frag as itemFrameFrag, itemVert, loadAVIFOptional, loadBinary, loadBlob, loadImage, loadMedia, loadVideo, loadWebPOptional, logger, index as math, maxSpriteMeshItemCount, modifyMaxKeyframeShader, nearestPowerOfTwo, noop, normalizeColor, numberToFix, parsePercent$1 as parsePercent, particleFrag, particleOriginTranslateMap$1 as particleOriginTranslateMap, particleUniformTypeMap, particleVert, passRenderLevel, pluginLoaderMap, randomInRange, registerPlugin, removeItem, rotateVec2, screenMeshVert, serialize, setBlendMode, setConfig, setDefaultTextureFactory, setMaskMode, setMaxSpriteMeshItemCount, setRayFromCamera, setSideMode, setSpriteMeshMaxItemCountByGPU, setUniformValue, sortByOrder, index$1 as spec, thresholdFrag, throwDestroyedError, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecFill, vecMulCombine, version, vertexFormatType2GLType };