All files / app/codeCharta/services/3DExports/3DPreview/MeshModels textMesh.ts

100% Statements 13/13
50% Branches 1/2
100% Functions 4/4
100% Lines 13/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 359x   9x 9x   9x           49x 49x   49x       42x   42x   42x       37x 37x       37x      
import { CustomVisibilityMesh } from "./customVisibilityMesh"
import { GeometryOptions } from "../preview3DPrintMesh"
import { CreateTextGeometryStrategy, CreateTextGeometryStrategyOptions } from "../CreateGeometryStrategies/createTextGeometryStrategy"
import { BackPrintColorChangeStrategy } from "../ColorChangeStrategies/backPrintColorChangeStrategy"
 
export class TextMesh extends CustomVisibilityMesh {
    constructor(
        name: string,
        colorChangeStrategy = new BackPrintColorChangeStrategy(),
        minScale: number,
        manualVisibility: boolean,
        public createTextGeometryOptions: CreateTextGeometryStrategyOptions,
        private createTextGeometryStrategy = new CreateTextGeometryStrategy()
    ) {
        super(name, colorChangeStrategy, minScale, manualVisibility)
    }
 
    async init(geometryOptions: GeometryOptions): Promise<TextMesh> {
        this.geometry = await this.createTextGeometryStrategy.create(geometryOptions, this.createTextGeometryOptions)
 
        this.updateColor(geometryOptions.numberOfColors)
 
        return this
    }
 
    async updateText(geometryOptions: GeometryOptions) {
        this.geometry = await this.createTextGeometryStrategy.create(geometryOptions, this.createTextGeometryOptions)
        this.boundingBoxCalculated = false
    }
 
    updateTextGeometryOptions(text: string) {
        this.createTextGeometryOptions.text = text
    }
}