Agent skill

Vtj Raycasting System

by hexianWeb in hexianWeb/Third-Person-MC

Implements ray picking and collision detection. An agent skill from hexianWeb/Third-Person-MC.

MITAuto-check passedGame Development

Install Vtj Raycasting System

skills CLI
$ npx skills add hexianWeb/Third-Person-MC --skill vtj-raycasting-system -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install hexianWeb/Third-Person-MC vtj-raycasting-system --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/hexianWeb/Third-Person-MC.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agent/skills/vtj-raycasting-system .claude/skills/vtj-raycasting-system && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
vtj-raycasting-system
GitHub stars
194
Token cost
~2k tokens
SKILL.md length
84 words
Files
1
Skills in repo
12
Repo updated
First seen
Licence
MIT

At a glance

Implements ray picking and collision detection. An agent skill from hexianWeb/Third-Person-MC.

  • Selecting objects
  • SKILL.md covers Overview, When to Use, 基础 Raycaster 模式 and 屏幕中心射线(第一人称准星), plus 7 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md
  • Detecting block interactions

What it does

Vtj Raycasting System is an agent skill from hexianWeb/Third-Person-MC. Implements ray picking and collision detection. Use when selecting objects, detecting block interactions, or optimizing raycaster performance.

Its SKILL.md is about 2k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Game Development, covering 3D graphics and WebGL. It works with Three.js. The repository describes itself as: Three.js web version Minecraft in browser. The licence is MIT.

When your agent uses it

  • Selecting objects
  • Detecting block interactions
  • Optimizing raycaster performance

Example prompts

  • “Use the vtj-raycasting-system skill to implement ray picking and collision detection. An agent skill from hexianWeb/Third-Person-MC”
  • “/vtj-raycasting-system”

What it can do on your machine

Read from SKILL.md and the folder at commit 490203c. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are javascript).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Vtj Raycasting System loads about 2k tokens when it runs. Until then it costs about 41 tokens; SKILL.md has 84 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~41
When it runs · the whole SKILL.md, loaded when a task matches
~2k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from hexianWeb/Third-Person-MC at commit 490203c, republished under its MIT licence (© hexianWeb). 84 words, ~2,043 tokens.

Download SKILL.mdSave it as .claude/skills/vtj-raycasting-system/SKILL.md (or your agent's skills folder).
name
vtj-raycasting-system
description
Implements ray picking and collision detection. Use when selecting objects, detecting block interactions, or optimizing raycaster performance.

vite-threejs Raycasting System

Overview

本项目的射线系统主要用于 方块交互(挖掘、放置)和 目标选择。

核心原则:始终使用 iMouse.normalizedMouse 获取 NDC 坐标,射线检测结果通过 mitt 事件通知。

When to Use

  • 实现点击拾取功能
  • 检测鼠标悬停对象
  • 实现方块交互(挖掘、放置)
  • 添加目标锁定功能

基础 Raycaster 模式

javascript
import * as THREE from 'three'
import Experience from './experience.js'
import emitter from './utils/event-bus.js'

export default class ObjectPicker {
  constructor() {
    this.experience = new Experience()
    this.scene = this.experience.scene
    this.camera = this.experience.camera.instance
    this.iMouse = this.experience.iMouse
    
    this.raycaster = new THREE.Raycaster()
    this.intersects = []
    
    // 配置
    this.params = {
      enabled: true,
      maxDistance: 100,
    }
    
    // 绑定事件
    this._handleClick = this._handleClick.bind(this)
    emitter.on('input:mouse_down', this._handleClick)
  }
  
  _handleClick({ button }) {
    if (button !== 0 || !this.params.enabled) return
    
    // 使用 IMouse 的 normalizedMouse(MANDATORY)
    const ndc = this.iMouse.normalizedMouse
    this.raycaster.setFromCamera(ndc, this.camera)
    
    // 检测交叉
    this.intersects = this.raycaster.intersectObjects(
      this.scene.children,
      true  // recursive
    )
    
    if (this.intersects.length > 0) {
      const hit = this.intersects[0]
      emitter.emit('game:object-picked', {
        object: hit.object,
        point: hit.point,
        distance: hit.distance,
      })
    }
  }
  
  destroy() {
    emitter.off('input:mouse_down', this._handleClick)
  }
}

屏幕中心射线(第一人称准星)

javascript
const CENTER_SCREEN = new THREE.Vector2(0, 0)

update() {
  // 第一人称:从屏幕中心发射
  this.raycaster.setFromCamera(CENTER_SCREEN, this.camera)
  
  // 或者第三人称:从鼠标位置发射
  // this.raycaster.setFromCamera(this.iMouse.normalizedMouse, this.camera)
  
  const intersects = this.raycaster.intersectObjects(this.targets, true)
  // ...
}

方块交互模式

本项目的 BlockRaycaster 实现了体素方块的射线检测:

javascript
// src/js/interaction/block-raycaster.js
export default class BlockRaycaster {
  constructor() {
    this.experience = new Experience()
    this.camera = this.experience.camera.instance
    this.iMouse = this.experience.iMouse
    
    this.raycaster = new THREE.Raycaster()
    this.raycaster.far = 8  // 最大交互距离
    
    this.params = {
      useMouse: false,  // false = 屏幕中心, true = 鼠标位置
    }
    
    this.result = {
      hit: false,
      blockPos: null,
      faceNormal: null,
      adjacentPos: null,  // 放置方块的位置
    }
  }
  
  update(terrainMeshes) {
    // 选择射线原点
    const ndc = this.params.useMouse
      ? this.iMouse.normalizedMouse
      : new THREE.Vector2(0, 0)
    
    this.raycaster.setFromCamera(ndc, this.camera)
    
    const intersects = this.raycaster.intersectObjects(terrainMeshes, false)
    
    if (intersects.length > 0) {
      const hit = intersects[0]
      
      // 计算方块坐标(向下取整到格子中心)
      const blockX = Math.floor(hit.point.x - hit.face.normal.x * 0.5)
      const blockY = Math.floor(hit.point.y - hit.face.normal.y * 0.5)
      const blockZ = Math.floor(hit.point.z - hit.face.normal.z * 0.5)
      
      // 计算相邻方块位置(放置用)
      const adjacentX = blockX + Math.round(hit.face.normal.x)
      const adjacentY = blockY + Math.round(hit.face.normal.y)
      const adjacentZ = blockZ + Math.round(hit.face.normal.z)
      
      this.result = {
        hit: true,
        blockPos: new THREE.Vector3(blockX, blockY, blockZ),
        faceNormal: hit.face.normal.clone(),
        adjacentPos: new THREE.Vector3(adjacentX, adjacentY, adjacentZ),
        distance: hit.distance,
      }
    } else {
      this.result.hit = false
    }
    
    return this.result
  }
}

交互管理器

javascript
// src/js/interaction/block-interaction-manager.js
export default class BlockInteractionManager {
  constructor(terrainRenderer) {
    this.terrainRenderer = terrainRenderer
    this.raycaster = new BlockRaycaster()
    
    this._handleMouseDown = this._handleMouseDown.bind(this)
    emitter.on('input:mouse_down', this._handleMouseDown)
  }
  
  _handleMouseDown({ button }) {
    const result = this.raycaster.result
    if (!result.hit) return
    
    if (button === 0) {
      // 左键:挖掘方块
      this.terrainRenderer.removeBlock(
        result.blockPos.x,
        result.blockPos.y,
        result.blockPos.z
      )
    } else if (button === 2) {
      // 右键:放置方块
      this.terrainRenderer.placeBlock(
        result.adjacentPos.x,
        result.adjacentPos.y,
        result.adjacentPos.z,
        this.currentBlockType
      )
    }
  }
  
  update() {
    // 每帧更新射线检测
    const meshes = this.terrainRenderer.getMeshes()
    this.raycaster.update(meshes)
  }
  
  destroy() {
    emitter.off('input:mouse_down', this._handleMouseDown)
  }
}

层过滤

使用 layers 过滤检测对象:

javascript
// 设置层
const LAYER_TERRAIN = 1
const LAYER_PLAYER = 2
const LAYER_UI = 3

// 设置对象层
terrainMesh.layers.set(LAYER_TERRAIN)
playerMesh.layers.set(LAYER_PLAYER)

// 配置 Raycaster 只检测特定层
this.raycaster.layers.set(LAYER_TERRAIN)  // 只检测地形

// 或启用多个层
this.raycaster.layers.enable(LAYER_TERRAIN)
this.raycaster.layers.enable(LAYER_PLAYER)

性能优化

限制检测距离
javascript
this.raycaster.near = 0.1
this.raycaster.far = 50  // 限制最大距离
分组检测
javascript
// 只检测相关对象组,而非整个场景
const intersects = this.raycaster.intersectObjects(
  this.interactableGroup.children,
  false  // 不递归检测子对象
)
降低检测频率
javascript
update() {
  this._frameCount++
  
  // 每 3 帧检测一次
  if (this._frameCount % 3 !== 0) return
  
  this.raycaster.setFromCamera(...)
  // ...
}
使用 BVH(边界体积层次)

对于复杂几何体,考虑使用 three-mesh-bvh:

javascript
import { computeBoundsTree } from 'three-mesh-bvh'

// 为复杂几何体构建 BVH
mesh.geometry.computeBoundsTree()

// 射线检测会自动使用 BVH 加速

悬停检测

javascript
export default class HoverDetector {
  constructor() {
    this.hoveredObject = null
  }
  
  update() {
    const ndc = this.iMouse.normalizedMouse
    this.raycaster.setFromCamera(ndc, this.camera)
    
    const intersects = this.raycaster.intersectObjects(this.targets)
    
    const newHovered = intersects.length > 0 ? intersects[0].object : null
    
    if (newHovered !== this.hoveredObject) {
      if (this.hoveredObject) {
        emitter.emit('game:hover-exit', { object: this.hoveredObject })
      }
      if (newHovered) {
        emitter.emit('game:hover-enter', { object: newHovered })
      }
      this.hoveredObject = newHovered
    }
  }
}

Common Mistakes

❌ 手动计算 NDC
javascript
// BAD
const x = (event.clientX / window.innerWidth) * 2 - 1
const y = -(event.clientY / window.innerHeight) * 2 + 1
this.raycaster.setFromCamera(new THREE.Vector2(x, y), this.camera)

// GOOD
this.raycaster.setFromCamera(this.iMouse.normalizedMouse, this.camera)
❌ 检测整个场景
javascript
// BAD: 检测所有对象,性能差
const intersects = this.raycaster.intersectObjects(this.scene.children, true)

// GOOD: 只检测相关对象
const intersects = this.raycaster.intersectObjects(this.interactables, false)
❌ 忘记设置 far 距离
javascript
// BAD: 默认 far = Infinity
this.raycaster = new THREE.Raycaster()

// GOOD: 限制检测距离
this.raycaster = new THREE.Raycaster()
this.raycaster.far = 50
❌ 在事件处理中忘记检查条件
javascript
// BAD: 没有检查是否有效
_handleClick({ button }) {
  const hit = this.intersects[0]  // 可能为空!
  this.doSomething(hit.object)
}

// GOOD: 检查条件
_handleClick({ button }) {
  if (button !== 0) return
  if (!this.result.hit) return
  
  this.doSomething(this.result.blockPos)
}

Quick Reference

需求做法
从鼠标发射射线raycaster.setFromCamera(iMouse.normalizedMouse, camera)
从屏幕中心发射raycaster.setFromCamera(new Vector2(0, 0), camera)
限制距离raycaster.far = 50
层过滤raycaster.layers.set(LAYER_ID)
获取点击位置intersects[0].point
获取面法线intersects[0].face.normal
体素方块特有说明
方块坐标floor(hit.point - normal * 0.5)
相邻方块blockPos + round(normal)
面法线用于确定点击的是哪个面

© hexianWeb, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agent/skills/vtj-raycasting-system of hexianWeb/Third-Person-MC.

Open the folder on GitHubat commit 490203c

Compare with similar skills

Vtj Raycasting System next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Vtj Raycasting System compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Vtj Raycasting System this skillhexianWeb/Third-Person-MC194—~2kAutomated safety check: PassMIT
Image to Three.js Modelimg2threejs/img2threejs18k1 repos~8.2kAutomated safety check: PassApache-2.0
Web CloneJane-xiaoer/claude-skill-web-clone1k2 repos~2.7kAutomated safety check: PassMIT
Threejs Game Directormajidmanzarpour/threejs-game-skills2.4k—~2.2kAutomated safety check: PassMIT
Threejs Gameplay Systemsvalkor-ai/loom1.2k1 repos~1.4kAutomated safety check: PassApache-2.0
Threejs World Generationcalesthio/OpenMontage65k—~2kAutomated safety check: PassAGPL-3.0

Similar skills

  • Image to Three.js Model

    img2threejs/img2threejs

    Rebuilds the object in a reference image as a procedural, animation-ready Three.js model written entirely in code, using staged sculpting with quality checks.

    18k GitHub starsUsed in 1 repo~8.2k tokens
    Game DevelopmentAuto-check passed
  • Web Clone

    Jane-xiaoer/claude-skill-web-clone

    网站复刻 / 克隆方法论。USE WHEN 用户说 复刻网站、克隆网站、clone website、抄个站、仿站、 照着这个站做一个、reproduce site、还原某个网页效果、把这个站搬下来改成我的、 复刻某个交互/WebGL/Canvas/Three.js 效果。提供「先拿真源码 → 判路径 → 逆向拆解 → 搭工程 → 替换内容」的可移植决策树,覆盖静态站 /…

    1k GitHub starsUsed in 2 repos~2.7k tokens
    Game DevelopmentAuto-check passed
  • Threejs Game Director

    majidmanzarpour/threejs-game-skills

    Entrypoint for building, upgrading, and finishing Three.js browser games.

    2.4k GitHub stars~2.2k tokensUpdated 10 days ago
    Game DevelopmentAuto-check passed
  • Build and iterate playable Three.js game systems: starter scaffold, architecture, design briefs, core loops, level and encounter design, entities, input, camera, collision and physics, scoring…

    1.2k GitHub starsUsed in 1 repo~1.4k tokens
    Game DevelopmentAuto-check passed
  • Threejs World Generation

    calesthio/OpenMontage

    Build deterministic, editable, free-viewpoint Three.js worlds from text or structured briefs.

    65k GitHub stars~2k tokensUpdated 4 days ago
    Game DevelopmentAuto-check passed
  • 3Dviz Pro Max Scene Builder

    viettranx/3dviz-pro-max

    Guides building an expressive 3D scene in Three.js or Blender by reasoning through intent, object construction and scientific grounding before using a catalog of recipes and kits.

    683 GitHub stars~2.8k tokensUpdated 27 days ago
    Game DevelopmentAuto-check passed

More from hexianWeb/Third-Person-MC

All 12 skills in this repo
  • Vtj Debug Panel

    hexianWeb/Third-Person-MC

    Configures Tweakpane debug panels for 3D components. An agent skill from hexianWeb/Third-Person-MC.

    194 GitHub stars~638 tokensUpdated 2 mo ago
    Auto-check passed
  • Vtj Camera System

    hexianWeb/Third-Person-MC

    Configures third-person camera systems with collision avoidance.

    194 GitHub stars~1.9k tokensUpdated 2 mo ago
    Auto-check passed
  • Vtj Component Model

    hexianWeb/Third-Person-MC

    Creates 3D components using the Experience singleton pattern.

    194 GitHub stars~1.5k tokensUpdated 2 mo ago
    Auto-check passed
  • Vtj Input System

    hexianWeb/Third-Person-MC

    Handles mouse, keyboard, and touch input via the IMouse and InputManager systems.

    194 GitHub stars~1.8k tokensUpdated 2 mo ago
    Auto-check passed
  • Vtj Performance

    hexianWeb/Third-Person-MC

    Optimizes Three.js rendering performance. An agent skill from hexianWeb/Third-Person-MC.

    194 GitHub stars~802 tokensUpdated 2 mo ago
    Auto-check passed
  • Vtj Resource Management

    hexianWeb/Third-Person-MC

    Loads and manages 3D assets via the Resources system. An agent skill from hexianWeb/Third-Person-MC.

    194 GitHub stars~1.6k tokensUpdated 2 mo ago
    Auto-check passed

Works with

Questions about Vtj Raycasting System

What does Vtj Raycasting System do?

Implements ray picking and collision detection. An agent skill from hexianWeb/Third-Person-MC. Vtj Raycasting System is an agent skill from hexianWeb/Third-Person-MC. Implements ray picking and collision detection.

When should I use Vtj Raycasting System?

Vtj Raycasting System fits situations like: selecting objects; detecting block interactions; optimizing raycaster performance.

How do I install Vtj Raycasting System in Claude Code?

Run `npx skills add hexianWeb/Third-Person-MC --skill vtj-raycasting-system -a claude-code`. Or copy the skill folder (.agent/skills/vtj-raycasting-system in hexianWeb/Third-Person-MC) into .claude/skills/vtj-raycasting-system in your project. Claude Code loads it when a task matches its description.

How do I install Vtj Raycasting System in Codex?

Run `npx skills add hexianWeb/Third-Person-MC --skill vtj-raycasting-system -a codex`. Or copy the skill folder (.agent/skills/vtj-raycasting-system in hexianWeb/Third-Person-MC) into .agents/skills/vtj-raycasting-system in your project. Codex loads it when a task matches its description.

Can I use Vtj Raycasting System in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add hexianWeb/Third-Person-MC --skill vtj-raycasting-system -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/vtj-raycasting-system, .gemini/skills/vtj-raycasting-system, .github/skills/vtj-raycasting-system and .opencode/skills/vtj-raycasting-system in your project.

What does Vtj Raycasting System need to run?

SKILL.md names no scripts, command-line tools or credentials: Vtj Raycasting System is instructions for the agent only.

Does Vtj Raycasting System access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Vtj Raycasting System safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Vtj Raycasting System use?

Vtj Raycasting System is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Vtj Raycasting System use?

About 2k tokens (SKILL.md is roughly 8.2k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Vtj Raycasting System?

Skills that share tags, products or a category with Vtj Raycasting System: Image to Three.js Model (img2threejs/img2threejs, 18k stars), Web Clone (Jane-xiaoer/claude-skill-web-clone, 1k stars), Threejs Game Director (majidmanzarpour/threejs-game-skills, 2.4k stars) and Threejs Gameplay Systems (valkor-ai/loom, 1.2k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Vtj Raycasting System?

hexianWeb (a GitHub user) maintains it in hexianWeb/Third-Person-MC, which has 194 GitHub stars. The repository holds 12 skills in this directory. The repository was last updated on July 27, 2026.

Source: hexianWeb/Third-Person-MC on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.