@galacean/effects-core 2.3.0-beta.2 → 2.3.0

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.3.0-beta.2
6
+ * Version: v2.3.0
7
7
  */
8
8
 
9
9
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
@@ -25517,9 +25517,12 @@ var TextComponentBase = /*#__PURE__*/ function() {
25517
25517
  this.textStyle = new TextStyle(options);
25518
25518
  this.textLayout = new TextLayout(options);
25519
25519
  this.text = options.text.toString();
25520
+ this.lineCount = this.getLineCount(options.text, true);
25520
25521
  };
25521
- _proto.getLineCount = function getLineCount(text, context) {
25522
+ _proto.getLineCount = function getLineCount(text, init) {
25523
+ var context = this.context;
25522
25524
  var _this_textLayout = this.textLayout, letterSpace = _this_textLayout.letterSpace, overflow = _this_textLayout.overflow;
25525
+ var fontScale = init ? this.textStyle.fontSize / 10 : 1 / this.textStyle.fontScale;
25523
25526
  var width = this.textLayout.width + this.textStyle.fontOffset;
25524
25527
  var lineCount = 1;
25525
25528
  var x = 0;
@@ -25527,7 +25530,7 @@ var TextComponentBase = /*#__PURE__*/ function() {
25527
25530
  var _context_measureText;
25528
25531
  var str = text[i];
25529
25532
  var _context_measureText_width;
25530
- var textMetrics = (_context_measureText_width = context == null ? void 0 : (_context_measureText = context.measureText(str)) == null ? void 0 : _context_measureText.width) != null ? _context_measureText_width : 0;
25533
+ var textMetrics = ((_context_measureText_width = context == null ? void 0 : (_context_measureText = context.measureText(str)) == null ? void 0 : _context_measureText.width) != null ? _context_measureText_width : 0) * fontScale;
25531
25534
  // 和浏览器行为保持一致
25532
25535
  x += letterSpace;
25533
25536
  // 处理文本结束行为
@@ -25597,6 +25600,7 @@ var TextComponentBase = /*#__PURE__*/ function() {
25597
25600
  return;
25598
25601
  }
25599
25602
  this.text = value.toString();
25603
+ this.lineCount = this.getLineCount(value, false);
25600
25604
  this.isDirty = true;
25601
25605
  };
25602
25606
  /**
@@ -25757,35 +25761,32 @@ var TextComponentBase = /*#__PURE__*/ function() {
25757
25761
  var layout = this.textLayout;
25758
25762
  var fontScale = style.fontScale;
25759
25763
  var width = (layout.width + style.fontOffset) * fontScale;
25764
+ var finalHeight = layout.lineHeight * this.lineCount;
25760
25765
  var fontSize = style.fontSize * fontScale;
25761
25766
  var lineHeight = layout.lineHeight * fontScale;
25762
25767
  style.fontDesc = this.getFontDesc(fontSize);
25763
25768
  this.char = (this.text || "").split("");
25764
25769
  this.canvas.width = width;
25765
- var height = this.canvas.height;
25766
- context.font = style.fontDesc;
25767
- this.lineCount = this.getLineCount(this.text, context);
25768
- var finalHeight = layout.lineHeight * this.lineCount;
25769
25770
  if (layout.autoWidth) {
25770
25771
  this.canvas.height = finalHeight * fontScale;
25771
25772
  this.item.transform.size.set(1, finalHeight / layout.height);
25772
25773
  } else {
25773
25774
  this.canvas.height = layout.height * fontScale;
25774
25775
  }
25776
+ var height = this.canvas.height;
25777
+ // fix bug 1/255
25778
+ context.fillStyle = "rgba(255, 255, 255, 0.0039)";
25779
+ if (!flipY) {
25780
+ context.translate(0, height);
25781
+ context.scale(1, -1);
25782
+ }
25775
25783
  // canvas size 变化后重新刷新 context
25776
25784
  if (this.maxLineWidth > width && layout.overflow === TextOverflow.display) {
25777
25785
  context.font = this.getFontDesc(fontSize * width / this.maxLineWidth);
25778
25786
  } else {
25779
25787
  context.font = style.fontDesc;
25780
25788
  }
25781
- // fix bug 1/255
25782
- context.fillStyle = "rgba(255, 255, 255, 0.0039)";
25783
25789
  context.clearRect(0, 0, width, height);
25784
- if (!flipY) {
25785
- context.translate(0, height);
25786
- context.scale(1, -1);
25787
- }
25788
- context.fillRect(0, 0, width, height);
25789
25790
  if (style.hasShadow) {
25790
25791
  this.setupShadow();
25791
25792
  }
@@ -25857,9 +25858,9 @@ var TextComponentBase = /*#__PURE__*/ function() {
25857
25858
  this.material.setTexture("_MainTex", texture);
25858
25859
  this.isDirty = false;
25859
25860
  };
25860
- _proto.getFontDesc = function getFontDesc(fontSize) {
25861
- var _this_textStyle = this.textStyle, fontFamily = _this_textStyle.fontFamily, textWeight = _this_textStyle.textWeight, fontStyle = _this_textStyle.fontStyle;
25862
- var fontDesc = "" + fontSize.toString() + "px ";
25861
+ _proto.getFontDesc = function getFontDesc(size) {
25862
+ var _this_textStyle = this.textStyle, fontSize = _this_textStyle.fontSize, fontScale = _this_textStyle.fontScale, fontFamily = _this_textStyle.fontFamily, textWeight = _this_textStyle.textWeight, fontStyle = _this_textStyle.fontStyle;
25863
+ var fontDesc = "" + (size || fontSize * fontScale).toString() + "px ";
25863
25864
  if (!DEFAULT_FONTS.includes(fontFamily)) {
25864
25865
  fontDesc += '"' + fontFamily + '"';
25865
25866
  } else {
@@ -32074,7 +32075,7 @@ registerPlugin("sprite", SpriteLoader, VFXItem);
32074
32075
  registerPlugin("particle", ParticleLoader, VFXItem);
32075
32076
  registerPlugin("cal", CalculateLoader, VFXItem);
32076
32077
  registerPlugin("interact", InteractLoader, VFXItem);
32077
- var version = "2.3.0-beta.2";
32078
+ var version = "2.3.0";
32078
32079
  logger.info("Core version: " + version + ".");
32079
32080
 
32080
32081
  export { AbstractPlugin, ActivationPlayable, ActivationPlayableAsset, ActivationTrack, AnimationClip, AnimationClipPlayable, Asset, AssetLoader, AssetManager, AssetService, BYTES_TYPE_MAP, BaseRenderComponent, Behaviour, BezierCurve, BezierCurvePath, BezierCurveQuat, BinaryAsset, COMPRESSED_TEXTURE, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, CalculateLoader, Camera, CameraController, CameraVFXItemLoader, ColorCurve, ColorPropertyPlayableAsset, ColorPropertyTrack, Component, Composition, CompositionComponent, CompositionSourceManager, 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, Engine, EventEmitter, EventSystem, Fake3DAnimationMode, Fake3DComponent, FilterMode, Float16ArrayWrapper, FloatPropertyPlayableAsset, FloatPropertyTrack, Framebuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GradientValue, HELP_LINK, HitTestType, InteractComponent, InteractLoader, InteractMesh, Item, KTXTexture, LineSegments, LinearValue, 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, 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, SpriteColorPlayableAsset, SpriteColorTrack, SpriteComponent, SpriteLoader, StaticValue, SubCompositionPlayableAsset, SubCompositionTrack, TEMPLATE_USE_OFFSCREEN_CANVAS, TextComponent, TextComponentBase, TextLayout, TextLoader, TextStyle, Texture, TextureFactory, TextureLoadAction, TextureSourceType, TextureStoreAction, 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, calculateTranslation, canvasPool, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, createCopyShader, createGLContext, createKeyFrameMeta, createShape, createValueGetter, 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, 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, isIOSByUA, isMiniProgram, isObject, isSimulatorCellPhone, isString, isUniformStruct, isUniformStructArray, isValidFontFamily, isWebGL2, isWechatMiniApp, itemFrag, 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, sortByOrder, index$1 as spec, spriteMeshShaderFromFilter, spriteMeshShaderFromRenderInfo, spriteMeshShaderIdFromRenderInfo, thresholdFrag, throwDestroyedError, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecFill, vecMulCombine, version, vertexFormatType2GLType };