CSS Stroke + 3D Shadows

Pure CSS Stroke Effects with Three.js 3D Shadow Layers

CSS Stroke Outline + 3D Shadow Layers

Drag to rotate in all axes

3D Outline + Red Shadow Behind with Mouse Rotation

Click to rotate

Perfect CSS Stroke + WebGL Shadow Combination

ShapeGeometry + LineBasicMaterial

// Generate shapes from font (Three.js standard approach)
const shapes = font.generateShapes(text, size * 20)

// Create shape geometry
const geometry = new THREE.ShapeGeometry(shapes)
geometry.computeBoundingBox()

const xMid = -0.5 * (geometry.boundingBox.max.x - geometry.boundingBox.min.x)
geometry.translate(xMid, 0, 0)

// Materials
const matDark = new THREE.LineBasicMaterial({
  color: 0x4A90E2, // Blue outline
  side: THREE.DoubleSide
})

const matLite = new THREE.MeshBasicMaterial({
  color: 0xFF6B6B, // Red fill/shadow
  transparent: true,
  opacity: 0.6,
  side: THREE.DoubleSide
})

Layered Rendering

// Create filled mesh (background) - positioned behind
const fillMesh = new THREE.Mesh(geometry, matLite)
fillMesh.position.z = -150
scene.add(fillMesh)

// Create line outline - positioned in front
const lineText = new THREE.Object3D()

for (let i = 0; i < shapes.length; i++) {
  const shape = shapes[i]
  const points = shape.getPoints()
  const lineGeometry = new THREE.BufferGeometry().setFromPoints(points)
  lineGeometry.translate(xMid, 0, 0)

  const lineMesh = new THREE.Line(lineGeometry, matDark)
  lineText.add(lineMesh)
}

scene.add(lineText)

Effect Details

LineBasicMaterial Outline

  • • Blue line outline using Three.js Lines
  • • ShapeGeometry from font.generateShapes()
  • • Handles holes and complex shapes
  • • Standard Three.js text approach

Fill Layer Behind

  • • Red filled mesh positioned behind (z: -150)
  • • MeshBasicMaterial with transparency
  • • Same ShapeGeometry as outline
  • • Mouse drag rotation in perspective

CSS Stroke vs Three.js Shadows

CSS Stroke Benefits

  • WebKit text stroke: 2px blue outline using CSS
  • Multiple text shadows: Diagonal shadow cascade
  • Drop shadow filter: Subtle glow effect
  • Synchronized rotation: Matches 3D shadow rotation

Three.js Shadow Benefits

  • 3D positioned shadows: True depth with Z-stacking
  • Diagonal offset: Exact angle matching reference image
  • Opacity fade: Realistic depth perception
  • Rotation sync: Maintains effect during rotation

CSS + WebGL Hybrid Approach

Best of both worlds: CSS stroke for rich outline effects + Three.js for precise 3D shadow positioning