Skip to content

Skia

What It Demonstrates

  • SkiaCanvas — off-screen texture rendering and screen-space overlay modes
  • Drawing nodesSkiaRect, SkiaCircle, SkiaLine, SkiaPathNode, SkiaTextNode, SkiaGroup
  • SkiaPaint — custom gradient shaders applied to drawing nodes
  • SkiaPath — programmatic paths with boolean operations (difference, intersect, union, xor)
  • SkiaTypeface / SkiaFontLoader — font loading with useLoader, sized fonts via atSize()
  • attachSkiaTexture — R3F attach helper for compositing Skia output onto 3D mesh materials
  • useFrame phases{ before: 'render' } and { after: 'render' } for render pipeline control

Key Patterns

Texture Mode

Render Skia shapes to a texture and apply it to a 3D mesh:

import { Skia, SkiaPaint } from '@three-flatland/skia'
import { SkiaCanvas, SkiaRect, SkiaGroup } from '@three-flatland/skia/three'
const skia = await Skia.init(renderer)
const canvas = new SkiaCanvas({ renderer, width: 1024, height: 880 })
canvas.add(new SkiaRect()) // add shapes
// In animation loop:
canvas.render()
material.map = canvas.texture

Overlay Mode

Draw directly on top of the 3D scene (HUD, debug text):

const overlay = new SkiaCanvas({
renderer,
width: window.innerWidth * dpr,
height: window.innerHeight * dpr,
overlay: true,
})
// Render AFTER the 3D scene:
renderer.render(scene, camera)
overlay.render()

Custom Paints (Gradients, Shaders)

For effects beyond flat fill/stroke, create a SkiaPaint and assign it to a node’s paint prop:

import { SkiaPaint } from '@three-flatland/skia'
const paint = new SkiaPaint(skia).setFill()
paint.setLinearGradient(0, 0, 200, 0,
[0xFFFF0000, 0xFF0000FF], [0, 1])
rect.paint = paint

Next Steps