import { ColorTransform } from "../ColorTransform" ; import { Mesh as MeshBase , MeshGeometry } from '@pixi/mesh' ; import { SpriteH } from "../sprites/SpriteH" ; import { Geometry , Renderer , State , Texture } from "@pixi/core" ; import { DoubleTintMeshMaterial } from "./DoubleTintMeshMaterial" ; export class MeshH extends MeshBase { color : ColorTransform = null ; maskSprite : SpriteH = null ; useSpriteMask = false ; constructor ( geometry , shader , state , drawMode ? ) { super ( geometry , shader as any , state , drawMode ) ; this . color = shader . color ; } _renderDefault ( renderer ) { const shader = this . shader as any as DoubleTintMeshMaterial ; shader . color . alpha = this . worldAlpha ; if ( shader . update ) { shader . update ( ) ; } renderer . batch . flush ( ) ; shader . uniforms . translationMatrix = this . worldTransform . toArray ( true ) ; renderer . shader . bind ( shader , false ) ; renderer . state . set ( this . state ) ; renderer . geometry . bind ( this . geometry , shader ) ; renderer . geometry . draw ( this . drawMode , this . size , this . start , ( this . geometry as any ) . instanceCount ) ; } _render ( renderer ) { if ( this . maskSprite ) { this . useSpriteMask = true ; } if ( this . useSpriteMask ) { ( this . material as any ) . pluginName = 'batchMasked' ; this . _renderToBatch ( renderer ) ; } else { super . _renderDefault ( renderer ) ; } } _renderToBatch ( renderer ) { this . color . updateTransform ( ) ; super . _renderToBatch ( renderer ) ; } } export class SimpleMeshH extends MeshH { constructor ( texture , vertices ? , uvs ? , indices ? , drawMode ? ) { super ( new MeshGeometry ( vertices , uvs , indices ) , new DoubleTintMeshMaterial ( texture ) , null , drawMode ) ; ( this . geometry . getBuffer ( 'aVertexPosition' ) as any ) . static = false ; } autoUpdate = true ; get vertices ( ) { return this . geometry . getBuffer ( 'aVertexPosition' ) . data as Float32Array ; } set vertices ( value ) { this . geometry . getBuffer ( 'aVertexPosition' ) . data = value ; } _render ( renderer ) { if ( this . autoUpdate ) { this . geometry . getBuffer ( 'aVertexPosition' ) . update ( ) ; } ( super . _render as any ) ( renderer ) ; } }