@galacean/effects-threejs 1.6.0 → 1.6.2-beta.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 threejs plugin for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v1.6.0
6
+ * Version: v1.6.2-beta.0
7
7
  */
8
8
 
9
9
  import * as THREE from 'three';
@@ -20282,13 +20282,21 @@ var TextLayout = /** @class */ (function () {
20282
20282
  this.textAlign = textAlign;
20283
20283
  this.lineHeight = lineHeight;
20284
20284
  }
20285
- TextLayout.prototype.getOffsetY = function (style, lineCount, lineHeight) {
20285
+ /**
20286
+ * 获取初始的行高偏移值
20287
+ * @param style - 字体基础数据
20288
+ * @param lineCount - 渲染行数
20289
+ * @param lineHeight - 渲染时的字体行高
20290
+ * @param fontSize - 渲染时的字体大小
20291
+ * @returns - 行高偏移值
20292
+ */
20293
+ TextLayout.prototype.getOffsetY = function (style, lineCount, lineHeight, fontSize) {
20286
20294
  var offsetResult = 0;
20287
- var fontSize = style.fontSize, outlineWidth = style.outlineWidth, fontScale = style.fontScale;
20288
- // 计算基础偏移量
20289
- var baseOffset = (fontSize + outlineWidth) * fontScale;
20295
+ var outlineWidth = style.outlineWidth, fontScale = style.fontScale;
20290
20296
  // /3 计算Y轴偏移量,以匹配编辑器行为
20291
20297
  var offsetY = (lineHeight - fontSize) / 3;
20298
+ // 计算基础偏移量
20299
+ var baseOffset = fontSize + outlineWidth * fontScale;
20292
20300
  var commonCalculation = lineHeight * (lineCount - 1);
20293
20301
  switch (this.textBaseline) {
20294
20302
  case TextBaseline$1.top:
@@ -20346,7 +20354,7 @@ var TextItem = /** @class */ (function (_super) {
20346
20354
  _this.engine = vfxItem.composition.getEngine();
20347
20355
  _this.textStyle = new TextStyle(options);
20348
20356
  _this.textLayout = new TextLayout(options);
20349
- _this.text = options.text;
20357
+ _this.text = options.text.toString();
20350
20358
  _this.lineCount = _this.getLineCount(options.text, true);
20351
20359
  // Text
20352
20360
  _this.mesh = new TextMesh(_this.engine, _this.renderInfo, vfxItem.composition);
@@ -20423,7 +20431,7 @@ var TextItem = /** @class */ (function (_super) {
20423
20431
  if (this.text === value) {
20424
20432
  return;
20425
20433
  }
20426
- this.text = value;
20434
+ this.text = value.toString();
20427
20435
  this.lineCount = this.getLineCount(value, false);
20428
20436
  this.isDirty = true;
20429
20437
  };
@@ -20575,7 +20583,7 @@ var TextItem = /** @class */ (function (_super) {
20575
20583
  var fontScale = style.fontScale;
20576
20584
  var width = (layout.width + style.fontOffset) * fontScale;
20577
20585
  var height = layout.height * fontScale;
20578
- style.fontSize * fontScale;
20586
+ var fontSize = style.fontSize * fontScale;
20579
20587
  var lineHeight = layout.lineHeight * fontScale;
20580
20588
  this.char = (this.text || '').split('');
20581
20589
  this.canvas.width = width;
@@ -20596,7 +20604,7 @@ var TextItem = /** @class */ (function (_super) {
20596
20604
  context.fillStyle = "rgba(".concat(style.textColor[0], ", ").concat(style.textColor[1], ", ").concat(style.textColor[2], ", ").concat(style.textColor[3], ")");
20597
20605
  var charsInfo = [];
20598
20606
  var x = 0;
20599
- var y = layout.getOffsetY(style, this.lineCount, lineHeight);
20607
+ var y = layout.getOffsetY(style, this.lineCount, lineHeight, fontSize);
20600
20608
  var charsArray = [];
20601
20609
  var charOffsetX = [];
20602
20610
  for (var i = 0; i < this.char.length; i++) {
@@ -21766,11 +21774,13 @@ var Camera = /** @class */ (function () {
21766
21774
  * @param z - 当前的位置 z
21767
21775
  */
21768
21776
  Camera.prototype.getInverseVPRatio = function (z) {
21769
- var pos = new Vector3(0, 0, z);
21777
+ var pos = new Vector3(this.position.x, this.position.y, z);
21770
21778
  var mat = this.getViewProjectionMatrix();
21771
21779
  var inverseVP = this.getInverseViewProjectionMatrix();
21772
21780
  var nz = mat.projectPoint(pos).z;
21773
- return inverseVP.projectPoint(new Vector3(1, 1, nz));
21781
+ var _a = inverseVP.projectPoint(new Vector3(1, 1, nz)), xMax = _a.x, yMax = _a.y;
21782
+ var _b = inverseVP.projectPoint(new Vector3(-1, -1, nz)), xMin = _b.x, yMin = _b.y;
21783
+ return new Vector3((xMax - xMin) / 2, (yMax - yMin) / 2, 0);
21774
21784
  };
21775
21785
  /**
21776
21786
  * 设置相机的旋转四元数
@@ -27486,7 +27496,7 @@ Geometry.create = function (engine, options) {
27486
27496
  Mesh.create = function (engine, props) {
27487
27497
  return new ThreeMesh(engine, props);
27488
27498
  };
27489
- var version = "1.6.0";
27499
+ var version = "1.6.2-beta.0";
27490
27500
  logger.info('THREEJS plugin version: ' + version);
27491
27501
 
27492
27502
  export { AbstractPlugin, AssetManager, BYTES_TYPE_MAP, BezierCurve, BezierCurvePath, 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, CalculateItem, CalculateLoader, CalculateVFXItem, Camera, CameraController, CameraVFXItem, CameraVFXItemLoader, Composition, CompositionSourceManager, DEFAULT_FONTS, DestroyOptions, Downloader, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, Engine, EventSystem, FILTER_NAME_NONE, FilterMode, FilterSpriteVFXItem, Float16ArrayWrapper, FrameBuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GradientValue, HELP_LINK, HitTestType, InteractBehavior$1 as InteractBehavior, InteractItem, InteractLoader, InteractMesh, InteractVFXItem, Item, KTXTexture, LineSegments, LinearValue, Material, MaterialDataBlock, MaterialRenderType, Mesh, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleLoader, ParticleMesh, ParticleSystem, ParticleVFXItem, PassTextureCache, PluginSystem, QCanvasViewer, QText, QTextWrapMode, RENDER_PASS_NAME_PREFIX, RENDER_PREFER_LOOKUP_TEXTURE, RUNTIME_ENV, RandomSetValue, RandomValue, RandomVectorValue, RenderBuffer, RenderFrame, RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, RenderTargetHandle, RenderTextureFormat, Renderer, 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, Shader, ShaderCompileResultStatus, ShaderType, SpriteItem, SpriteLoader, SpriteMesh, SpriteVFXItem, StaticValue, TEMPLATE_USE_OFFSCREEN_CANVAS, TEXTURE_UNIFORM_MAP, TextItem, TextLoader, TextMesh, TextVFXItem, Texture, TextureFactory, TextureLoadAction, TextureSourceType, TextureStoreAction, ThreeComposition, ThreeDisplayObject, ThreeMaterial, ThreeTexture, Ticker, TimelineComponent, Transform, VFXItem, ValueGetter, addByOrder, addItem, addItemWithOrder, alphaFrameFrag, alphaMaskFrag, assertExist, asserts, blend, bloomMixVert, bloomThresholdVert, calculateTranslation, cameraMove_frag as cameraMoveFrag, cameraMoveVert, canvasPool, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, combineImageTemplate1, combineImageTemplate1Async, combineImageTemplate2, combineImageTemplate2Async, combineImageTemplateAsync, compatible_frag as compatibleFrag, compatible_vert as compatibleVert, convertAnchor, copyFrag, createCopyShader, createFilter, createFilterShaders, createGLContext, createKeyFrameMeta, createShaderWithMarcos, createShape, createVFXItem, createValueGetter, decimalEqual, deepClone, defaultGlobalVolume, defaultPlugins, delayFrag, deserializeMipmapTexture, distortionFrag, distortionVert, earcut, enlargeBuffer, ensureVec3, filters, findPreviousRenderPass, gaussianDown_frag as gaussianDownFrag, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTypedArray, generateHalfFloatTexture, getBackgroundImage, getColorFromGradientStops, getConfig, getDefaultTemplateCanvasPool, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, getImageItemRenderInfo, getKTXTextureOptions, getKeyFrameMetaByRawValue, getParticleMeshShader, getPixelRatio, getPreMultiAlpha, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, getTextureSize, glContext, gpuTimer, imageDataFromColor, imageDataFromGradient, initErrors, initGLContext, integrate, interpolateColor, isAlipayMiniApp, isAndroid, isArray, isFunction, isIOS, isObject, isScene, isSimulatorCellPhone, isString, isUniformStruct, isUniformStructArray, isValidFontFamily, isWebGL2, itemFrag, itemFrameFrag, itemVert, loadBinary, loadBlob, loadImage, loadMedia, loadVideo, loadWebPOptional, logger, index as math, maxSpriteMeshItemCount, maxSpriteTextureCount, modifyMaxKeyframeShader, nearestPowerOfTwo, noop, numberToFix, parsePercent$1 as parsePercent, particleFrag, particleOriginTranslateMap, particleUniformTypeMap, particleVert, pluginLoaderMap, pointOnLine, random, registerFilter, registerFilters, registerPlugin, removeItem, requestAsync, rotateVec2, screenMeshVert, 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 };