import M3ParserRegion from '../../../parsers/m3/region' ; import Shader from '../../gl/shader' ; import M3Model from './model' ; /**
 * An M3 region.
 */ export default class M3Region { gl : WebGLRenderingContext ; firstBoneLookupIndex : number ; boneWeightPairsCount : number ; offset : number ; verticesCount : number ; elements : number ; constructor ( model , region , triangles , elementArray , offset ) { const firstVertexIndex = region . firstVertexIndex ; const triangleIndicesCount = region . triangleIndicesCount ; const firstTriangleIndex = region . firstTriangleIndex ; for ( let i = 0 ; i < triangleIndicesCount ; i ++ ) { elementArray [ offset + i ] = triangles [ firstTriangleIndex + i ] + firstVertexIndex ; } this . gl = model . viewer . gl ; this . firstBoneLookupIndex = region . firstBoneLookupIndex ; this . boneWeightPairsCount = region . boneWeightPairsCount ; this . offset = offset * 2 ; this . verticesCount = region . verticesCount ; this . elements = triangleIndicesCount ; } render ( shader ) { const gl = this . gl ; gl . uniform1f ( shader . uniforms [ 'u_firstBoneLookupIndex' ] , this . firstBoneLookupIndex ) ; gl . uniform1f ( shader . uniforms [ 'u_boneWeightPairsCount' ] , this . boneWeightPairsCount ) ; gl . drawElements ( gl . TRIANGLES , this . elements , gl . UNSIGNED_SHORT , this . offset ) ; } }