@awayjs/scene 0.13.273 → 0.13.275
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/bundle/awayjs-scene.umd.js +2 -2
- package/bundle/awayjs-scene.umd.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/Scene.js +1 -2
- package/dist/lib/display/Billboard.js +1 -1
- package/dist/lib/display/TextField.d.ts +0 -5
- package/dist/lib/display/TextField.d.ts.map +1 -1
- package/dist/lib/display/TextField.js +28 -62
- package/dist/lib/display/TextSprite.js +2 -2
- package/dist/lib/events/MouseEvent.d.ts.map +1 -1
- package/dist/lib/events/TouchEvent.d.ts.map +1 -1
- package/dist/lib/text/HTMLTextProcessor.d.ts.map +1 -1
- package/dist/lib/text/HTMLTextProcessor.js +3 -2
- package/dist/lib/text/TesselatedFontTable.js +1 -1
- package/index.ts +1 -1
- package/lib/Scene.ts +1 -2
- package/lib/display/Billboard.ts +1 -1
- package/lib/display/TextField.ts +24 -68
- package/lib/display/TextSprite.ts +2 -2
- package/lib/events/MouseEvent.ts +1 -4
- package/lib/events/TouchEvent.ts +1 -4
- package/lib/text/HTMLTextProcessor.ts +3 -2
- package/lib/text/TesselatedFontTable.ts +1 -1
- package/package.json +1 -1
package/lib/display/TextField.ts
CHANGED
|
@@ -257,14 +257,11 @@ export class TextField extends DisplayObjectContainer {
|
|
|
257
257
|
private _textWidth: number;
|
|
258
258
|
private _textHeight: number;
|
|
259
259
|
|
|
260
|
-
private _charBoundaries: Rectangle;
|
|
261
260
|
private _firstCharInParagraph: number;
|
|
262
261
|
private _imageReference: DisplayObject
|
|
263
|
-
private _lineMetrics: TextLineMetrics;
|
|
264
262
|
private _paragraphLength: number;
|
|
265
263
|
|
|
266
|
-
public
|
|
267
|
-
public _newTextFormat: TextFormat;
|
|
264
|
+
public _newTextFormat: TextFormat = new TextFormat();
|
|
268
265
|
public _textFormats: TextFormat[];
|
|
269
266
|
public _textFormatsIdx: number[];
|
|
270
267
|
|
|
@@ -578,7 +575,7 @@ export class TextField extends DisplayObjectContainer {
|
|
|
578
575
|
|
|
579
576
|
let x: number = 0;
|
|
580
577
|
let y: number = 0;
|
|
581
|
-
let tf: TextFormat = this.
|
|
578
|
+
let tf: TextFormat = this._newTextFormat;
|
|
582
579
|
|
|
583
580
|
if (this.char_positions_x.length == 0) {
|
|
584
581
|
x = this.textOffsetX + (this._width / 2) + this._textWidth / 2;
|
|
@@ -622,7 +619,7 @@ export class TextField extends DisplayObjectContainer {
|
|
|
622
619
|
if (this.cursorShape.style.color !== color) {
|
|
623
620
|
const alpha = ColorUtils.float32ColorToARGB(color)[0];
|
|
624
621
|
|
|
625
|
-
const obj = MaterialManager.
|
|
622
|
+
const obj = MaterialManager.getMaterialForColor(color, (alpha / 255) || 1);
|
|
626
623
|
|
|
627
624
|
if (obj.colorPos) {
|
|
628
625
|
this.cursorShape.style = new Style();
|
|
@@ -1198,8 +1195,6 @@ export class TextField extends DisplayObjectContainer {
|
|
|
1198
1195
|
this._textDirty = true;
|
|
1199
1196
|
//console.log("set text", value, "on" , this);
|
|
1200
1197
|
|
|
1201
|
-
this.newTextFormat = this._textFormats[this._textFormats.length - 1];
|
|
1202
|
-
|
|
1203
1198
|
this.invalidate();
|
|
1204
1199
|
}
|
|
1205
1200
|
|
|
@@ -1607,49 +1602,20 @@ export class TextField extends DisplayObjectContainer {
|
|
|
1607
1602
|
}
|
|
1608
1603
|
|
|
1609
1604
|
public get newTextFormat(): TextFormat {
|
|
1610
|
-
|
|
1611
|
-
if (this._newTextFormat == null) {
|
|
1612
|
-
this._newTextFormat = this._textFormat ? this._textFormat : new TextFormat();
|
|
1613
|
-
}
|
|
1614
|
-
return this._newTextFormat;
|
|
1605
|
+
return this._newTextFormat.clone();
|
|
1615
1606
|
}
|
|
1616
1607
|
|
|
1617
1608
|
public set newTextFormat(value: TextFormat) {
|
|
1618
1609
|
if (!value)
|
|
1619
1610
|
throw new Error('TextField::: set newTextFormat - no value!');
|
|
1620
1611
|
|
|
1621
|
-
if (value.equal(this.
|
|
1612
|
+
if (value.equal(this._newTextFormat))
|
|
1622
1613
|
return;
|
|
1623
1614
|
|
|
1624
1615
|
this._newTextFormat = value.clone();
|
|
1625
1616
|
|
|
1626
1617
|
this._newFormatDirty = true;
|
|
1627
|
-
}
|
|
1628
|
-
|
|
1629
|
-
public get textFormat(): TextFormat {
|
|
1630
|
-
if (this._textFormat == null) {
|
|
1631
|
-
this._textFormat = new TextFormat();
|
|
1632
|
-
}
|
|
1633
|
-
return this._textFormat;
|
|
1634
|
-
}
|
|
1635
|
-
|
|
1636
|
-
public set textFormat(value: TextFormat) {
|
|
1637
|
-
if (!value)
|
|
1638
|
-
throw new Error('TextField::: set textFormat - no value!');
|
|
1639
|
-
|
|
1640
|
-
if (value.equal(this.textFormat))
|
|
1641
|
-
return;
|
|
1642
|
-
|
|
1643
|
-
this._textFormat = value.clone();
|
|
1644
|
-
|
|
1645
1618
|
this._textShapesDirty = true;
|
|
1646
|
-
// this._positionsDirty = true;
|
|
1647
|
-
// this._glyphsDirty = true;
|
|
1648
|
-
// this._shapesDirty = true;
|
|
1649
|
-
this._textDirty = true;
|
|
1650
|
-
//this.reConstruct();
|
|
1651
|
-
|
|
1652
|
-
this.invalidate();
|
|
1653
1619
|
}
|
|
1654
1620
|
|
|
1655
1621
|
/**
|
|
@@ -1776,8 +1742,8 @@ export class TextField extends DisplayObjectContainer {
|
|
|
1776
1742
|
public get textHeight(): number {
|
|
1777
1743
|
this.reConstruct();
|
|
1778
1744
|
if (this.type == TextFieldType.INPUT && this._iText == '') {
|
|
1779
|
-
this.
|
|
1780
|
-
return this.
|
|
1745
|
+
this._newTextFormat.font_table.initFontSize(this._newTextFormat.size);
|
|
1746
|
+
return this._newTextFormat.font_table.getLineHeight();
|
|
1781
1747
|
}
|
|
1782
1748
|
|
|
1783
1749
|
return this._textHeight;
|
|
@@ -2021,8 +1987,6 @@ export class TextField extends DisplayObjectContainer {
|
|
|
2021
1987
|
|
|
2022
1988
|
this._resetParagraph();
|
|
2023
1989
|
this._clearTextShapes();
|
|
2024
|
-
|
|
2025
|
-
this._textFormat = null;
|
|
2026
1990
|
}
|
|
2027
1991
|
|
|
2028
1992
|
/**
|
|
@@ -2067,11 +2031,6 @@ export class TextField extends DisplayObjectContainer {
|
|
|
2067
2031
|
this._maxScrollV = 0;
|
|
2068
2032
|
this._maxWidthLine = 0;
|
|
2069
2033
|
|
|
2070
|
-
// sometimes needed for TLFTextfields
|
|
2071
|
-
// todo: cleanup usage of _textFormats vs _textFormats
|
|
2072
|
-
if (!this._textFormat && this._textFormats.length > 0)
|
|
2073
|
-
this._textFormat = this._textFormats[0];
|
|
2074
|
-
|
|
2075
2034
|
this.buildParagraphs();
|
|
2076
2035
|
|
|
2077
2036
|
//console.log("TextField buildParagraph", this.id, this._iText);
|
|
@@ -2092,9 +2051,9 @@ export class TextField extends DisplayObjectContainer {
|
|
|
2092
2051
|
|
|
2093
2052
|
if (this._positionsDirty) {
|
|
2094
2053
|
this._glyphsDirty = true;
|
|
2095
|
-
if (this._iText != '' && this.
|
|
2054
|
+
if (this._iText != '' && this._textFormats[0] != null) {
|
|
2096
2055
|
//console.log("TextField getWordPositions", this.id, this.words);
|
|
2097
|
-
this.getWordPositions();
|
|
2056
|
+
this.getWordPositions(this._textFormats[0]);
|
|
2098
2057
|
} else {
|
|
2099
2058
|
// this is empty text, we need to reset the text-size
|
|
2100
2059
|
this._textWidth = 0;
|
|
@@ -2105,8 +2064,8 @@ export class TextField extends DisplayObjectContainer {
|
|
|
2105
2064
|
|
|
2106
2065
|
this._height = 4;
|
|
2107
2066
|
if (this._type == TextFieldType.INPUT) {
|
|
2108
|
-
this.
|
|
2109
|
-
this._height = this.
|
|
2067
|
+
this._newTextFormat.font_table.initFontSize(this._newTextFormat.size);
|
|
2068
|
+
this._height = this._newTextFormat.font_table.getLineHeight() + 4;
|
|
2110
2069
|
}
|
|
2111
2070
|
}
|
|
2112
2071
|
if (this._type == TextFieldType.INPUT)
|
|
@@ -2199,7 +2158,7 @@ export class TextField extends DisplayObjectContainer {
|
|
|
2199
2158
|
}
|
|
2200
2159
|
|
|
2201
2160
|
// clear paragraph data when clear
|
|
2202
|
-
if (this._iText === '' || !this.
|
|
2161
|
+
if (this._iText === '' || !this._textFormats[0]) {
|
|
2203
2162
|
this._resetParagraph();
|
|
2204
2163
|
return;
|
|
2205
2164
|
}
|
|
@@ -2434,7 +2393,7 @@ export class TextField extends DisplayObjectContainer {
|
|
|
2434
2393
|
}
|
|
2435
2394
|
}
|
|
2436
2395
|
|
|
2437
|
-
private getWordPositions() {
|
|
2396
|
+
private getWordPositions(tf: TextFormat) {
|
|
2438
2397
|
/*console.log("this._iText", this._iText);
|
|
2439
2398
|
console.log("this._width", this._width);
|
|
2440
2399
|
console.log("this._height", this._height);*/
|
|
@@ -2465,13 +2424,13 @@ export class TextField extends DisplayObjectContainer {
|
|
|
2465
2424
|
// if we have autosize enabled, and no wordWrap, we can adjust the textfield width
|
|
2466
2425
|
if (this._autoSize != TextFieldAutoSize.NONE && !this._wordWrap && this._textDirty) {
|
|
2467
2426
|
const maxSizeComplete: number =
|
|
2468
|
-
this._maxWidthLine +
|
|
2469
|
-
+
|
|
2427
|
+
this._maxWidthLine + tf.indent
|
|
2428
|
+
+ tf.leftMargin + tf.rightMargin;
|
|
2470
2429
|
this.adjustPositionForAutoSize(maxSizeComplete);
|
|
2471
2430
|
}
|
|
2472
2431
|
|
|
2473
2432
|
const maxLineWidth: number =
|
|
2474
|
-
this._width - (
|
|
2433
|
+
this._width - (tf.indent + tf.leftMargin + tf.rightMargin);
|
|
2475
2434
|
|
|
2476
2435
|
let p: number = 0;
|
|
2477
2436
|
const p_len: number = this._paragraph_textRuns_indices.length;
|
|
@@ -2845,7 +2804,7 @@ export class TextField extends DisplayObjectContainer {
|
|
|
2845
2804
|
const sampler: ImageSampler = new ImageSampler();
|
|
2846
2805
|
textShape.shape.style = new Style();
|
|
2847
2806
|
if (textShape.format.material && this._textColor == 0) {
|
|
2848
|
-
textShape.shape.material = this.
|
|
2807
|
+
textShape.shape.material = this._textFormats[0].material;
|
|
2849
2808
|
textShape.shape.style.addSamplerAt(sampler, textShape.shape.material.getTextureAt(0));
|
|
2850
2809
|
(<MaterialBase> textShape.shape.material).animateUVs = true;
|
|
2851
2810
|
textShape.shape.style.uvMatrix =
|
|
@@ -2857,7 +2816,7 @@ export class TextField extends DisplayObjectContainer {
|
|
|
2857
2816
|
if (alpha == 0) {
|
|
2858
2817
|
alpha = 255;
|
|
2859
2818
|
}
|
|
2860
|
-
const obj = MaterialManager.
|
|
2819
|
+
const obj = MaterialManager.getMaterialForColor(color, alpha / 255);
|
|
2861
2820
|
|
|
2862
2821
|
textShape.shape.material = obj.material;
|
|
2863
2822
|
if (obj.colorPos) {
|
|
@@ -2981,7 +2940,7 @@ export class TextField extends DisplayObjectContainer {
|
|
|
2981
2940
|
} else if (textShape.format.material && this._textColor == 0) {
|
|
2982
2941
|
// used for textfields loaded from awd.
|
|
2983
2942
|
// the material on the format uses textureAtlas from awd
|
|
2984
|
-
textShape.shape.material = this.
|
|
2943
|
+
textShape.shape.material = this._textFormats[0].material;
|
|
2985
2944
|
textShape.shape.style.addSamplerAt(sampler, textShape.shape.material.getTextureAt(0));
|
|
2986
2945
|
(<MaterialBase> textShape.shape.material).animateUVs = true;
|
|
2987
2946
|
textShape.shape.style.uvMatrix =
|
|
@@ -2989,7 +2948,7 @@ export class TextField extends DisplayObjectContainer {
|
|
|
2989
2948
|
} else {
|
|
2990
2949
|
// used by runtime textureatlas.
|
|
2991
2950
|
// (standart for dynamic created text and text loaded from swf)
|
|
2992
|
-
const obj = MaterialManager.
|
|
2951
|
+
const obj = MaterialManager.getMaterialForColor(color, alpha / 255);
|
|
2993
2952
|
textShape.shape.material = obj.material;
|
|
2994
2953
|
if (obj.colorPos) {
|
|
2995
2954
|
textShape.shape.style.addSamplerAt(sampler, textShape.shape.material.getTextureAt(0));
|
|
@@ -3326,9 +3285,7 @@ export class TextField extends DisplayObjectContainer {
|
|
|
3326
3285
|
*/
|
|
3327
3286
|
public getTextFormat(beginIndex: number /*int*/ = -1, endIndex: number /*int*/ = -1): TextFormat {
|
|
3328
3287
|
if (!this.tf_per_char || !this.tf_per_char.length) {
|
|
3329
|
-
|
|
3330
|
-
return this._textFormat.clone();
|
|
3331
|
-
return new TextFormat();
|
|
3288
|
+
return this._textFormats[0]?.clone() || new TextFormat();
|
|
3332
3289
|
}
|
|
3333
3290
|
if (beginIndex < 0)
|
|
3334
3291
|
beginIndex = 0;
|
|
@@ -3791,9 +3748,9 @@ export class TextField extends DisplayObjectContainer {
|
|
|
3791
3748
|
if (char == '')
|
|
3792
3749
|
return;
|
|
3793
3750
|
}
|
|
3794
|
-
if (this.
|
|
3751
|
+
if (this._newTextFormat.font_table) {
|
|
3795
3752
|
|
|
3796
|
-
const table = this.
|
|
3753
|
+
const table = this._newTextFormat.font_table;
|
|
3797
3754
|
const symbol = char.charCodeAt(0).toString();
|
|
3798
3755
|
let exist = false;
|
|
3799
3756
|
|
|
@@ -3916,8 +3873,7 @@ export class TextField extends DisplayObjectContainer {
|
|
|
3916
3873
|
newInstance.html = this.html;
|
|
3917
3874
|
newInstance.width = this._width;
|
|
3918
3875
|
newInstance.height = this._height;
|
|
3919
|
-
|
|
3920
|
-
newInstance.textFormat = this._textFormat.clone();
|
|
3876
|
+
newInstance.newTextFormat = this._newTextFormat.clone();
|
|
3921
3877
|
newInstance.textColor = this._textColor;
|
|
3922
3878
|
newInstance.border = this._border;
|
|
3923
3879
|
newInstance.borderColor = this._borderColor;
|
|
@@ -15,8 +15,8 @@ export class TextSprite extends Sprite {
|
|
|
15
15
|
const tf: TextField = this.parentTextField;
|
|
16
16
|
//tf.reConstruct(true);
|
|
17
17
|
|
|
18
|
-
if (tf.
|
|
19
|
-
this.transform.colorTransform.color = (tf.textColor != null) ? tf.textColor : tf.
|
|
18
|
+
if (tf._textFormats[0] && !tf._textFormats[0].font_table.isAsset(TesselatedFontTable) && !tf._textFormats[0].material) {
|
|
19
|
+
this.transform.colorTransform.color = (tf.textColor != null) ? tf.textColor : tf._textFormats[0].color;
|
|
20
20
|
this._invalidateHierarchicalProperty(HierarchicalProperty.COLOR_TRANSFORM);
|
|
21
21
|
}
|
|
22
22
|
}
|
package/lib/events/MouseEvent.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ContainerNode, IPartitionContainer } from '@awayjs/view';
|
|
2
2
|
|
|
3
|
-
import { ContainerNode, INode, ITraversable, View, IPartitionContainer } from '@awayjs/view';
|
|
4
|
-
|
|
5
|
-
import { IMaterial } from '@awayjs/renderer';
|
|
6
3
|
import FrameScriptManager from '../managers/FrameScriptManager';
|
|
7
4
|
import { MouseButtons } from '../base/MouseButtons';
|
|
8
5
|
import { PointerEvent } from './PointerEvent';
|
package/lib/events/TouchEvent.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ContainerNode, IPartitionContainer } from '@awayjs/view';
|
|
2
2
|
|
|
3
|
-
import { ContainerNode, INode, ITraversable, View, IPartitionContainer } from '@awayjs/view';
|
|
4
|
-
|
|
5
|
-
import { IMaterial } from '@awayjs/renderer';
|
|
6
3
|
import FrameScriptManager from '../managers/FrameScriptManager';
|
|
7
4
|
import { PointerEvent } from './PointerEvent';
|
|
8
5
|
|
|
@@ -247,13 +247,14 @@ export class HTMLTextProcessor {
|
|
|
247
247
|
}
|
|
248
248
|
|
|
249
249
|
const textProps: any = { text: '' };
|
|
250
|
+
const childFormat: TextFormat = target_tf.newTextFormat;
|
|
250
251
|
|
|
251
|
-
target_tf._textFormats = [
|
|
252
|
+
target_tf._textFormats = [childFormat];
|
|
252
253
|
target_tf._textFormatsIdx = [0];
|
|
253
254
|
const doc = parse(input);
|
|
254
255
|
if (doc && doc.firstChild) {
|
|
255
256
|
textProps.multiline = doc.firstChild.childNodes.length > 0;
|
|
256
|
-
this.readHTMLTextPropertiesRecursive(target_tf, doc, textProps,
|
|
257
|
+
this.readHTMLTextPropertiesRecursive(target_tf, doc, textProps, childFormat);
|
|
257
258
|
}
|
|
258
259
|
if (textProps.text != '' && ((textProps.text.charCodeAt(textProps.text.length - 1) == 13)
|
|
259
260
|
|| (textProps.text.charCodeAt(textProps.text.length - 1) == 10))) {
|
|
@@ -377,7 +377,7 @@ export class TesselatedFontTable extends AssetBase implements IFontTable {
|
|
|
377
377
|
|
|
378
378
|
const color = 0xFFFFFF;
|
|
379
379
|
const alpha = 1;
|
|
380
|
-
const obj = MaterialManager.
|
|
380
|
+
const obj = MaterialManager.getMaterialForColor(color, alpha);
|
|
381
381
|
|
|
382
382
|
shape.material = obj.material;
|
|
383
383
|
if (obj.colorPos) {
|