@vaguevoid/fiasco / ecs/components / TextureRender
Type Alias: TextureRender
TextureRender =
Component
<{textureId
:TextureId
;uvRegion
:UVRegion
;visible
:boolean
; }>
Defined in: src/ecs/components.ts:400
The TextureRender component is used for rendering an entity as a texture at the given entity's Transform.
ts
import { GpuInterface, EventWriter, Events, assert } from '@vaguevoid/fiasco'
import Sailboat from './assets/sailboat.png'
import Components from '../.fiasco/generated'
function system(gpuInterface: GpuInterface, newTexureEventWriter: EventWriter<Events.Graphics.NewTexture>) {
const texture = gpuInterface.textureAssetManager.loadTexture(newTexureEventWriter, Sailboat)
assert(texture)
engine.spawn([
// ...
new Components.TextureRender({
textureId: texture.id,
uvRegion: {
position: { x: 0, y: 0 },
dimensions: { x:1, y: 1 }
},
visible: true
})
])
}