← LeaderboardThe Skill Leaderboard

build-first-person-spellblade

Build or repair first-person sword and spell controls in a Three.js game. Use for mouse look, camera-relative arms, a stable weapon grip, an off-hand cast, or a parry that connects on the visible frame.

Published by MengTo ↗MengTo/Skills

Try your first task

A source-grounded starter task has not been verified for this skill yet.

SKILL.md

name: build-first-person-spellbladedescription: Build or repair first-person sword and spell controls in a Three.js game. Use for mouse look, camera-relative arms, a stable weapon grip, an off-hand cast, or a parry that connects on the visible frame.

Build a first-person spellblade

Start with one playable encounter. Walk from open ground to a doorway, raise the blade, parry a moving opponent, then cast past the doorframe. This short route exposes most camera, wrist and aiming errors before a whole move set exists.

Set up the camera and hands

  • Give the player a grounded movement root, yaw, and clamped pitch. Move along the ground-plane projection of the view direction. Consume mouse movement without holding a button. Suspend look input when the map opens, release held actions on blur, and discard the first pointer delta on return.
  • Keep a world-space pose for gameplay. A separate hand camera is useful for composition. Render the world first, clear depth before the hands pass, and preserve the color buffer. Match light direction, exposure and fog color at the player. Retract the weapon near solid surfaces so the presentation pass respects walls.
  • Calibrate the hand on the actual model. Mark the heel of the palm, index knuckle, little-finger knuckle and thumb web. Place a grip socket between the palm pads. Seat the hilt, curl the fingers around its radius, and oppose the thumb. Save the hand-to-hilt transform once. Rotate the assembled grip through a slash so the handle stays seated during recoil.
  • Measure shoulder-to-elbow and elbow-to-wrist lengths in the bind pose. Solve in the same coordinate space at runtime. The two-bone reach example returns reachable elbow and wrist positions for Three.js vectors. Use a separate solver per arm and a pole point on the natural elbow side. Aim each bone using its measured local rest axis, distribute twist through the forearm, and retain the rig's authored scales. Check skinning at the cuff if the bones stay in place but the silhouette stretches.

Give each hand an action

ActionWeapon handSupport handGameplay event
Walk or sprintCarry the hilt with small stride-driven motionCounter-swing low in frameFootfall from ground contact
SlashChamber, cross the aim line, finish past it, recoverCounterbalance or briefly brace the pommelSweep the blade from its previous pose through the active interval
Guard or parryPresent the edge, then recoil on contactBrace against the forceCompare incoming contact time with the guard window
CastKeep the sword clear of the targetGather, extend, release, relaxEmit one release from the updated palm socket

Give each hand one pose owner per action. A two-handed cut reserves both hands until its release marker. Consume an animation marker when simulation time crosses it, including when a frame spans the entire marker. A cancelled wind-up produces no projectile. Tie sparks, sound and recoil to the confirmed contact point.

Aim from the palm

Raycast from the gameplay camera through the reticle to find the intended point, using a finite range on a miss. After updating animation and world matrices, sweep from the physical hand socket toward that point. Resolve a nearby wall first. If the viewmodel uses a different field of view, align the first visual samples with the rendered palm and converge onto the world trajectory over the first short stretch. Use the world trajectory for collision throughout.

Check it in play

Record the same route at the narrowest and widest supported aspect ratios. Step through the grip at full extension, the parry contact frame and the first frame of the cast. Use a temporary side view to catch a hand that only appears to touch the hilt from the player camera. Check bone lengths, thumb contact, wall clearance, a single hit per swing per target and a single release per cast. Repeat a turn while sprinting and an interrupted cast at a low frame rate.