@galacean/effects-threejs 1.6.0-beta.2 → 1.6.1
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.js +45 -9
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +3 -3
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +45 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
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.
|
|
6
|
+
* Version: v1.6.1
|
|
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
|
-
|
|
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
|
|
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:
|
|
@@ -20335,6 +20343,10 @@ var TextItem = /** @class */ (function (_super) {
|
|
|
20335
20343
|
function TextItem(props, opts, vfxItem) {
|
|
20336
20344
|
var _this = _super.call(this, props, opts, vfxItem) || this;
|
|
20337
20345
|
_this.isDirty = true;
|
|
20346
|
+
/**
|
|
20347
|
+
* 文本行数
|
|
20348
|
+
*/
|
|
20349
|
+
_this.lineCount = 0;
|
|
20338
20350
|
var options = props.options;
|
|
20339
20351
|
_this.canvas = canvasPool.getCanvas();
|
|
20340
20352
|
canvasPool.saveCanvas(_this.canvas);
|
|
@@ -20343,10 +20355,34 @@ var TextItem = /** @class */ (function (_super) {
|
|
|
20343
20355
|
_this.textStyle = new TextStyle(options);
|
|
20344
20356
|
_this.textLayout = new TextLayout(options);
|
|
20345
20357
|
_this.text = options.text;
|
|
20358
|
+
_this.lineCount = _this.getLineCount(options.text, true);
|
|
20346
20359
|
// Text
|
|
20347
20360
|
_this.mesh = new TextMesh(_this.engine, _this.renderInfo, vfxItem.composition);
|
|
20348
20361
|
return _this;
|
|
20349
20362
|
}
|
|
20363
|
+
TextItem.prototype.getLineCount = function (text, init) {
|
|
20364
|
+
var _a, _b;
|
|
20365
|
+
var context = this.context;
|
|
20366
|
+
var letterSpace = this.textLayout.letterSpace;
|
|
20367
|
+
var fontScale = init ? this.textStyle.fontSize / 10 : 1 / this.textStyle.fontScale;
|
|
20368
|
+
var width = (this.textLayout.width + this.textStyle.fontOffset);
|
|
20369
|
+
var lineCount = 1;
|
|
20370
|
+
var x = 0;
|
|
20371
|
+
for (var i = 0; i < text.length; i++) {
|
|
20372
|
+
var str = text[i];
|
|
20373
|
+
var textMetrics = ((_b = (_a = context === null || context === void 0 ? void 0 : context.measureText(str)) === null || _a === void 0 ? void 0 : _a.width) !== null && _b !== void 0 ? _b : 0) * fontScale;
|
|
20374
|
+
// 和浏览器行为保持一致
|
|
20375
|
+
x += letterSpace;
|
|
20376
|
+
if (((x + textMetrics) > width && i > 0) || str === '\n') {
|
|
20377
|
+
lineCount++;
|
|
20378
|
+
x = 0;
|
|
20379
|
+
}
|
|
20380
|
+
if (str !== '\n') {
|
|
20381
|
+
x += textMetrics;
|
|
20382
|
+
}
|
|
20383
|
+
}
|
|
20384
|
+
return lineCount;
|
|
20385
|
+
};
|
|
20350
20386
|
/**
|
|
20351
20387
|
* 设置字号大小
|
|
20352
20388
|
* @param value - 字号
|
|
@@ -20396,6 +20432,7 @@ var TextItem = /** @class */ (function (_super) {
|
|
|
20396
20432
|
return;
|
|
20397
20433
|
}
|
|
20398
20434
|
this.text = value;
|
|
20435
|
+
this.lineCount = this.getLineCount(value, false);
|
|
20399
20436
|
this.isDirty = true;
|
|
20400
20437
|
};
|
|
20401
20438
|
/**
|
|
@@ -20546,7 +20583,7 @@ var TextItem = /** @class */ (function (_super) {
|
|
|
20546
20583
|
var fontScale = style.fontScale;
|
|
20547
20584
|
var width = (layout.width + style.fontOffset) * fontScale;
|
|
20548
20585
|
var height = layout.height * fontScale;
|
|
20549
|
-
style.fontSize * fontScale;
|
|
20586
|
+
var fontSize = style.fontSize * fontScale;
|
|
20550
20587
|
var lineHeight = layout.lineHeight * fontScale;
|
|
20551
20588
|
this.char = (this.text || '').split('');
|
|
20552
20589
|
this.canvas.width = width;
|
|
@@ -20567,8 +20604,7 @@ var TextItem = /** @class */ (function (_super) {
|
|
|
20567
20604
|
context.fillStyle = "rgba(".concat(style.textColor[0], ", ").concat(style.textColor[1], ", ").concat(style.textColor[2], ", ").concat(style.textColor[3], ")");
|
|
20568
20605
|
var charsInfo = [];
|
|
20569
20606
|
var x = 0;
|
|
20570
|
-
var
|
|
20571
|
-
var y = layout.getOffsetY(style, lineCount, lineHeight);
|
|
20607
|
+
var y = layout.getOffsetY(style, this.lineCount, lineHeight, fontSize);
|
|
20572
20608
|
var charsArray = [];
|
|
20573
20609
|
var charOffsetX = [];
|
|
20574
20610
|
for (var i = 0; i < this.char.length; i++) {
|
|
@@ -27458,7 +27494,7 @@ Geometry.create = function (engine, options) {
|
|
|
27458
27494
|
Mesh.create = function (engine, props) {
|
|
27459
27495
|
return new ThreeMesh(engine, props);
|
|
27460
27496
|
};
|
|
27461
|
-
var version = "1.6.
|
|
27497
|
+
var version = "1.6.1";
|
|
27462
27498
|
logger.info('THREEJS plugin version: ' + version);
|
|
27463
27499
|
|
|
27464
27500
|
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 };
|