关于 spatial-developer
spatial-developer 是面向空间计算开发者的技能,涵盖 WebXR、Vision Pro 和 3D Web 应用,并提供交互与空间音频实现示例。
主要功能
- 01构建浏览器中的 AR/VR 体验
- 02开发 Vision Pro 空间界面
- 03制作 Three.js 与 React Three Fiber 场景
- 04实现凝视选择与手势交互
- 05添加空间音频
适用场景
- 01搭建 WebXR 项目
- 02开发基于浏览器的 AR 功能
- 03创建 Vision Pro 原生应用
- 04为 3D 场景加入手势或空间声音
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ daffy0208/ ai-dev-standards --skill spatial-developer安装后在 Claude Code 中输入/spatial-developer确认已加载。
附带文件manifest.yamlREADME.md
详细介绍
空间开发技能
我可以帮助你构建 AR/VR 体验、空间界面和沉浸式 3D 应用。
我能做什么
WebXR 开发:
- 浏览器中的 AR/VR 体验
- 手部追踪和控制器
- 空间锚点
- 沉浸式环境
Vision Pro 开发:
- visionOS 原生应用
- 空间 UI 设计
- Reality Composer 集成
- SharePlay 体验
3D Web:
- Three.js 场景
- React Three Fiber
- 3D 交互
- 空间音频
WebXR 基础
npm install three @react-three/fiber @react-three/drei @react-three/xr
简单的 VR 场景
// components/VRScene.tsx
'use client'
import { Canvas } from '@react-three/fiber'
import { VRButton, XR, Controllers, Hands } from '@react-three/xr'
import { Box, OrbitControls } from '@react-three/drei'
export function VRScene() {
return (
<>
<VRButton />
<Canvas>
<XR>
<ambientLight intensity={0.5} />
<pointLight position={[10, 10, 10]} />
{/* 3D Content */}
<Box position={[0, 1, -2]} args={[1, 1, 1]}>
<meshStandardMaterial color="hotpink" />
</Box>
{/* VR Controllers */}
<Controllers />
{/* Hand Tracking */}
<Hands />
</XR>
</Canvas>
</>
)
}
Web 上的 AR(WebXR)
// components/ARScene.tsx
'use client'
import { Canvas } from '@react-three/fiber'
import { ARButton, XR } from '@react-three/xr'
import { useState } from 'react'
export function ARScene() {
const [hitTest, setHitTest] = useState(null)
return (
<>
<ARButton
sessionInit={{
requiredFeatures: ['hit-test'],
optionalFeatures: ['dom-overlay']
}}
/>
<Canvas>
<XR
onHitTest={(hitMatrix, hit) => {
setHitTest(hit)
}}
>
<ambientLight />
{hitTest && (
<mesh position={hitTest.position}>
<sphereGeometry args={[0.1]} />
<meshStandardMaterial color="blue" />
</mesh>
)}
</XR>
</Canvas>
</>
)
}
Vision Pro 空间 UI
// ContentView.swift
import SwiftUI
import RealityKit
struct ContentView: View {
var body: some View {
RealityView { content in
// Add 3D content
let model = ModelEntity(
mesh: .generateSphere(radius: 0.1),
materials: [SimpleMaterial(color: .blue, isMetallic: false)]
)
content.add(model)
}
.toolbar {
ToolbarItem(placement: .bottomOrnament) {
HStack {
Button("Reset") {
// Reset scene
}
Button("Share") {
// SharePlay
}
}
}
}
}
}
3D 交互模式
基于注视的选择
'use client'
import { useXR } from '@react-three/xr'
import { useFrame } from '@react-three/fiber'
import { useState } from 'react'
export function GazeSelect() {
const { player } = useXR()
const [gazing, setGazing] = useState(false)
useFrame(() => {
// Raycast from camera
const direction = player.camera.getWorldDirection(new Vector3())
// Check intersection with objects
// If gazing for 2 seconds, select
})
return (
<mesh onPointerEnter={() => setGazing(true)}>
<boxGeometry />
<meshStandardMaterial
color={gazing ? 'green' : 'white'}
/>
</mesh>
)
}
手势识别
'use client'
import { useXREvent } from '@react-three/xr'
export function GestureControl() {
useXREvent('squeeze', (e) => {
console.log('Pinch gesture detected')
// Perform action
})
useXREvent('select', (e) => {
console.log('Select gesture')
})
return (
<mesh>
<sphereGeometry args={[0.05]} />
<meshStandardMaterial color="red" />
</mesh>
)
}
空间音频
'use client'
import { PositionalAudio } from '@react-three/drei'
import { useRef } from 'react'
export function SpatialSound() {
const sound = useRef()
return (
<mesh position={[2, 1, -3]}>
<sphereGeometry args={[0.2]} />
<meshStandardMaterial color="yellow" emissive="yellow" />
<PositionalAudio
ref={sound}
url="/sounds/ambient.mp3"
distance={5}
loop
autoplay
/>
</mesh>
)
}
何时使用我
非常适合:
- 构建 AR/VR Web 体验
- 创建 Vision Pro 应用
- 实现 3D 交互
- 设计空间 UI
- 打造沉浸式叙事体验
我可以帮助你:
- 搭建 WebXR 项目
- 构建 AR 功能
- 实现手部追踪
- 设计空间界面
- 优化 3D 性能
我将创建的内容
🥽 VR Experiences
📱 AR Applications
👋 Hand Tracking
🎧 Spatial Audio
🌐 WebXR Scenes
🍎 Vision Pro Apps
让我们共同打造空间计算的未来!
评论
支持 Markdown