Back to list
verekia

weapon-trail

by verekia

⚛️ React Three Fiber Game Dev Recipes

17🍴 0📅 Jan 22, 2026

SKILL.md


name: weapon-trail description: Create a ribbon trail effect that follows a weapon's movement.

Weapon Trail

Create a ribbon trail effect that follows a weapon's movement.

Technique

Build a custom BufferGeometry that stores a history of positions in a ring buffer. Each frame, record the current world positions of trail points and update the geometry vertices to create a ribbon connecting all historical positions.

Key Concepts

  • Define trail points (e.g., base and tip of weapon)
  • Use a ring buffer to store position history efficiently
  • Create geometry with proper UVs for texture mapping (gradient fade)
  • Update vertex positions each frame with positions.needsUpdate = true
  • Use localToWorld() to get world positions from the target object
  • Support enabling/disabling with fade out animation

Usage

const trailPoints = [new Vector3(0, 0, 0), new Vector3(0, 1.5, 0)]

<group ref={weaponRef}>
  <mesh>{/* weapon mesh */}</mesh>
</group>
<Trail target={weaponRef} points={trailPoints} enabled={isAttacking} />

Geometry Structure

  • Segments: historical snapshots (oldest to newest)
  • Points per segment: trail point positions at that time
  • UVs: u = position along trail (0-1), v = age (0 = newest, 1 = oldest)
  • Alpha map texture for gradient fade effect

This skill is part of verekia's r3f-gamedev.

Score

Total Score

65/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

1ヶ月以内に更新

+10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

+5

Reviews

💬

Reviews coming soon