API リファレンスはソースコード内の Go ドキュメントコメントから生成されており、英語で記述されています。
package mcp3d
import "github.com/nsgo-dev/game/pkg/mcp/mcp3d"概要
Package mcp3d is experimental: its API and documented formats may change in a minor release. See the API stability policy.
Package mcp3d defines optional serializable records and a provider contract for inspecting a running 3D scene over MCP: nodes, the active camera and raycast hits. It imports no renderer, scene3d or physics3d package, so pkg/mcp stays free of 3D code and the game keeps ownership of rendering and physics. Package game/mcp registers the game3d_* tools over a Provider set as mcp.Config.ThreeD.
目次
変数
var ErrNotFound = errors.New("mcp3d: node not found")ErrNotFound reports that no node has the requested path.
型
type Camera struct {
Position Vec3 `json:"position"`
Forward Vec3 `json:"forward"`
Projection string `json:"projection"`
FOV float32 `json:"fov,omitempty"`
}Camera is the active camera's pose and projection. Projection is "perspective" or "orthographic"; FOV is the vertical field of view in degrees for a perspective camera.
type Hit struct {
NodePath string `json:"nodePath"`
Point Vec3 `json:"point"`
Normal Vec3 `json:"normal"`
Distance float32 `json:"distance"`
}Hit is the nearest node a ray hits, with the world-space hit point and surface normal and the distance along the ray.
type Node struct {
Path string `json:"path"`
Kind string `json:"kind,omitempty"`
Name string `json:"name,omitempty"`
Position Vec3 `json:"position"`
Scale Vec3 `json:"scale"`
BoundsMin Vec3 `json:"boundsMin"`
BoundsMax Vec3 `json:"boundsMax"`
Model string `json:"model,omitempty"`
Material string `json:"material,omitempty"`
}Node is one node of the 3D scene graph. Path is unique within the scene; BoundsMin and BoundsMax are the node's world-space axis-aligned bounds, and Model and Material name the assets it draws with, if any.
type Provider interface {
Nodes() []Node
Camera() Camera
Raycast(origin, direction Vec3) (Hit, bool)
}Provider is implemented by the game over its own scene, camera and physics. Raycast reports false when the ray hits nothing.