.playcanvas-react

A set of coding rules for building 3D scenes in React with the PlayCanvas game engine. It covers the structure for entities, cameras, lights, rendered models, materials, and loaded assets.

In plain words
What is it for?
Use it to create React-based 3D scenes, load models or splat assets, set up cameras and lights, and add physics, animation, or collision components.
Why use it?
It gives the agent the required PlayCanvas structure so generated 3D React code can initialize the engine and connect scene components correctly.

Cursor rule

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/playcanvas/react/playcanvas-react
Clone the repo
git clone --depth 1 https://github.com/playcanvas/react
Per session 559 This file is loaded in full into every session.
When invoked 559 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00559 $0.00559
Opus 5 $0.00280 $0.00280
Sonnet 5 $0.00112 $0.00112
Haiku 4.5 $0.00056 $0.00056

Measured yesterday against content hash 03de0bf71080, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

.playcanvas-react scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

packages/lib/.playcanvas-react.mdc · 84 lines

What it actually says

Overview of @playcanvas/react

@playcanvas/react is a fully featured thin wrapper around the PlayCanvas API. You use it to build 3D content

📚 Full Docs
🔗 GitHub Repo
🧩 API Reference

Structure

// Core 
import { Application, Entity } from '@playcanvas/react'
// Components add behaviors to Entities
import { Light, Camera, Render, Gsplat, Screen, Collision, RigidBody, Anim } from '@playcanvas/react/components'
// Hooks add functionality
import { useModel, useSplat, useAppEvent, useParent, useApp } from '@playcanvas/react/hooks'

Rules for 3D Content

When generating 3D content with @playcanvas/react, follow these conventions:

  • Always wrap components at the root in an <Application /> to initialize the engine.
  • <Entity /> defines a transform node — use it for position, rotation, and scale. It does not render anything on its own.
  • Use components from @playcanvas/react/components to add functionality (e.g., <Camera />, <Light />, <Render />).
  • Load assets using hooks like useModel(src) and useSplat(src).
  • Materials must be created using the useMaterial() hook.
  • Use numeric arrays for colors and vectors:
    • Colors: [1, 0, 0]
    • Position/rotation/scale: [0, 0, 0]

Examples

📸 A Camera

Transform goes on <Entity />, camera settings go on <Camera />.

<Entity position={[0, 0, 4]}>
    <Camera fov={30}/>
</Entity>

A Light

<Entity position={[0, 0, 4]}>
    <Light type='directional' />
</Entity>

A Primitive

<Entity position={[0, 0, 4]}>
    <Render type='sphere' />
</Entity>

An Asset

export const Car = () => {
  const { asset } = useModel('./car.glb');
  if (!asset) return null;

  return (
    <Entity>
      <Render type="asset" asset={asset} />
    </Entity>
  );
};
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 84 lines · 559 tokens per session scan A 03de0bf71080

Subscribe to this mod's changes

.playcanvas-react is a cursor rule published in the GitHub repository playcanvas/react (525 stars, last pushed 12d ago), licensed MIT. It adds 559 tokens to every session, about $0.0028 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.