feat(text): wire TextSprite into SceneManager, eliminate inline text mutation
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
* and spring-animated add/remove operations.
|
* and spring-animated add/remove operations.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Container, Graphics, Text, TextStyle } from 'pixi.js';
|
import { Container } from 'pixi.js';
|
||||||
import type { Viewport } from 'pixi-viewport';
|
import type { Viewport } from 'pixi-viewport';
|
||||||
import { TextureManager } from './TextureManager';
|
import { TextureManager } from './TextureManager';
|
||||||
import { ImageSprite } from './sprites/ImageSprite';
|
import { ImageSprite } from './sprites/ImageSprite';
|
||||||
@@ -14,6 +14,7 @@ import { VideoSprite } from './sprites/VideoSprite';
|
|||||||
import { DrawingSprite } from './sprites/DrawingSprite';
|
import { DrawingSprite } from './sprites/DrawingSprite';
|
||||||
import { FrameSprite } from './sprites/FrameSprite';
|
import { FrameSprite } from './sprites/FrameSprite';
|
||||||
import { StickySprite } from './sprites/StickySprite';
|
import { StickySprite } from './sprites/StickySprite';
|
||||||
|
import { TextSprite } from './sprites/TextSprite';
|
||||||
import { SpringManager, Spring, PRESETS } from './spring';
|
import { SpringManager, Spring, PRESETS } from './spring';
|
||||||
import { reparentGroupChildren } from './grouping';
|
import { reparentGroupChildren } from './grouping';
|
||||||
import { SpatialGrid } from './SpatialGrid';
|
import { SpatialGrid } from './SpatialGrid';
|
||||||
@@ -320,13 +321,7 @@ export class SceneManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case 'text': {
|
case 'text': {
|
||||||
const txtData = data as TextObject;
|
displayObject = new TextSprite(data as TextObject);
|
||||||
const style = new TextStyle({
|
|
||||||
fontSize: txtData.fontSize,
|
|
||||||
fill: txtData.fill,
|
|
||||||
fontFamily: txtData.fontFamily,
|
|
||||||
});
|
|
||||||
displayObject = new Text({ text: txtData.text, style });
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -412,11 +407,12 @@ export class SceneManager {
|
|||||||
const drawData = data as DrawingObject;
|
const drawData = data as DrawingObject;
|
||||||
obj.setPoints(drawData.points);
|
obj.setPoints(drawData.points);
|
||||||
}
|
}
|
||||||
if (data.type === 'text' && obj instanceof Text) {
|
if (data.type === 'text' && obj instanceof TextSprite) {
|
||||||
const txtData = data as TextObject;
|
const dimensionsChanged = obj.updateFromData(data as TextObject);
|
||||||
obj.text = txtData.text;
|
if (dimensionsChanged) {
|
||||||
obj.style.fontSize = txtData.fontSize;
|
data.w = obj.measuredWidth;
|
||||||
obj.style.fill = txtData.fill;
|
data.h = obj.measuredHeight;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (data.type === 'group' && obj instanceof FrameSprite) {
|
if (data.type === 'group' && obj instanceof FrameSprite) {
|
||||||
obj.updateFromData(data as GroupObject);
|
obj.updateFromData(data as GroupObject);
|
||||||
|
|||||||
Reference in New Issue
Block a user