import { Mesh2D } from '@turbox3d/graphic-view-pixi' ; import * as PIXI from 'pixi.js' ; import DrawUtils from '../draw-utils/index' ; interface Vec2 { x : number ; y : number ; } interface IProps { path : Vec2 [ ] ; position ? : Vec2 ; rotation ? : number ; scale ? : Vec2 ; lineWidth ? : number ; lineColor ? : number ; lineAlpha ? : number ; fillColor ? : number ; fillAlpha ? : number ; zIndex ? : number ; } /** 多边形 */ export default class Polygon extends Mesh2D < IProps > { static defaultProps : Partial < IProps > = { position : { x : 0 , y : 0 } , rotation : 0 , scale : { x : 0 , y : 0 } , } ; protected view = new PIXI . Graphics ( ) ; protected reactivePipeLine = [ this . updateGeometry , this . updateMaterial , this . updatePosition , this . updateRotation , this . updateScale , ] ; updateGeometry ( ) { this . view . clear ( ) ; const { path , lineWidth , lineColor , lineAlpha , fillColor , fillAlpha , zIndex , } = this . props ; zIndex && ( this . view . zIndex = zIndex ) ; DrawUtils . drawPolygon ( this . view , { path : path . map ( p => ( { x : p . x , y : p . y } ) ) , } , { lineWidth , lineColor , lineAlpha , fillColor , fillAlpha , } ) ; } updateMaterial ( ) { } updatePosition ( ) { } updateRotation ( ) { } updateScale ( ) { } }