Skip to content

Commit c4bf2b3

Browse files
marklundinCopilot
andauthored
Adds installable LLM rules.mdc (#139)
* Enhance documentation and add AI Assisted Development section - Updated README.md to include a new section on AI Assisted Development, providing installation instructions for MDC rules. - Revised blocks.mdx to clarify the description of 3D building blocks and their usage. - Improved the SplatViewer documentation with additional details on features and usage examples. - Added new MDC files for blocks and SplatViewer to standardize component usage rules. - Enhanced the index.mdx to better explain the purpose of the PlayCanvas React library and its features. These changes improve the clarity and usability of the documentation, making it easier for developers to get started with PlayCanvas React. * Remove 'display: hidden' from blocks in _meta.tsx to improve visibility in documentation structure. * Update documentation links to point to the new Vercel URL for MDC rules in README.md and index.mdx files. * Update index.mdx to improve visibility of Codesandbox and Playground links by hiding icons on smaller screens. * Refactor SplatViewer imports and update documentation - Replaced direct imports of Splat components with a unified import from the new Splat module. - Updated the `useMDXComponents` function to include Splat as a component. - Adjusted documentation in blocks.mdx to reflect the new import structure for Splat components. * Update .gitignore and remove unused registry-mdx-components file Fixes build issue * Update packages/docs/registry/splat-viewer/.splat-viewer.mdc Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
1 parent c550ef5 commit c4bf2b3

File tree

13 files changed

+419
-139
lines changed

13 files changed

+419
-139
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,5 @@ next-env.d.ts
7373
_pagefind/
7474

7575
*.ply
76+
packages/docs/public/r/*
7677

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ const App = () => {
5454

5555
Et voilà! ✨
5656

57+
### AI Assisted Development
58+
59+
To get your IDE up to speed, run the following command from the root of your project to install the latest MDC rules. Or [grab them here](https://playcanvas-react.vercel.app/rules) to add them manually.
60+
61+
```bash
62+
mkdir -p .cursor/rules && curl -s https://playcanvas-react.vercel.app/rules -o .cursor/rules/playcanvas-react.mdc
63+
```
64+
5765
## Why @playcanvas/react?
5866

5967
@playcanvas/react gives you everything you need to build 3D apps in React — without pulling in a maze of external libraries.

packages/docs/app/rules/route.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
import { NextResponse } from 'next/server'
3+
import { readFile } from 'fs/promises'
4+
import path from 'path'
5+
6+
export async function GET() {
7+
const filePath = path.join(process.cwd(), '../lib/.playcanvas-react.mdc')
8+
const content = await readFile(filePath, 'utf8')
9+
10+
return new NextResponse(content, {
11+
headers: {
12+
'Content-Type': 'text/plain',
13+
},
14+
})
15+
}

packages/docs/content/_meta.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ const meta: MetaRecord = {
4646
blocks: {
4747
title: 'Blocks',
4848
type: 'page',
49-
display: 'hidden'
5049
},
5150
docs: {
5251
title: 'Docs',

packages/docs/content/blocks.mdx

Lines changed: 93 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -23,48 +23,64 @@ export const splatVersion = registry.items.find(item => item.name === 'splat-vie
2323
</a>
2424
# Building Blocks for 3D <Badge variant="secondary" className="-mt-2">new</Badge>
2525

26-
A set of high-level 3D building blocks for React — interactive viewers, spatial layouts, and controls—designed to help you compose immersive scenes with minimal setup.
26+
A set of high-level crafted 3D primitives for React, built on top of @playcanvas/react and @shadcn/ui — interactive viewers, spatial layouts, and controls — designed to help you compose immersive scenes with minimal setup.
27+
28+
{/* ## AI Assisted Development
29+
30+
Each block comes with it's own set of MDC rules which are used to generate the block. To install rules for the registry run the following command in your terminal.
31+
32+
```bash copy
33+
npx shadcn@latest add https://playcanvas-react.vercel.app/r/3d-blocks.json
34+
```
35+
36+
This will install the rules for the registry and for @playcanvas/react and add them to your project. */}
2737

2838
## Splat Viewer <Badge variant="secondary" className="-mt-2">beta</Badge>
2939

30-
A responsive and composable component for displaying Gaussian splats.
40+
A responsive and composable component for displaying **Gaussian splats**.
3141

3242
Includes built-in camera controls, loading states, and optional UI slots for overlays or actions.
33-
Supports large assets with lazy loading and automatic framing. Use it in modals, pages, or full-screen scenes.
43+
Supports large assets with lazy loading and automatic framing. Use it in modals, pages, or full-screen scenes.
3444

45+
Supports compressed gaussian splats.
3546

36-
<div className="outline p-28 -mx-6 mt-12 mb-0 rounded-t-lg bg-linear-to-br from-violet-600 to-purple-600 relative">
37-
<OpenInV0Button url={`https://v0.dev/chat/api/open?url=${encodeURIComponent("http://playcanvas-react.vercel.app/r/splatviewer.json")}`} className="absolute top-4 right-4" />
38-
<SplatViewer src={splatUrl} autoPlay className="bg-purple-200 rounded-lg shadow-xl cursor-grab active:cursor-grabbing" >
39-
<Controls autoHide >
40-
<div className="flex gap-2 pointer-events-auto flex-grow">
41-
<FullScreenButton />
42-
<DownloadButton />
47+
<div className="lg:outline lg:p-28 -mx-4 lg:-mx-6 mt-12 mb-0 rounded-t-lg bg-linear-to-br from-indigo-500 to-purple-600 relative">
48+
<OpenInV0Button url={`https://v0.dev/chat/api/open?url=${encodeURIComponent("http://playcanvas-react.vercel.app/r/splat-viewer.json")}`} className="absolute top-4 right-4" />
49+
<Splat.Viewer src={splatUrl} autoPlay className="bg-purple-200 rounded-t-lg lg:rounded-lg shadow-xl cursor-grab active:cursor-grabbing" >
50+
<Splat.Controls autoHide >
51+
<div className="flex gap-1 pointer-events-auto flex-grow">
52+
<Splat.FullScreenButton />
53+
<Splat.DownloadButton />
4354
</div>
44-
<div className="pointer-events-auto">
45-
<MenuButton />
55+
<div className="flex gap-1 pointer-events-auto">
56+
<Splat.CameraModeToggle />
57+
<Splat.HelpButton />
58+
<Splat.MenuButton />
4659
</div>
47-
</Controls>
48-
</SplatViewer>
60+
</Splat.Controls>
61+
</Splat.Viewer>
4962
</div>
50-
<div className="border rounded-b-lg -mx-6 demo overflow-hidden">
63+
<div className="border lg:rounded-b-lg -mx-4 lg:-mx-6 demo overflow-hidden">
5164
<Tabs items={['index.tsx', 'viewer.css']} className="!mt-0" tabClassName="!mt-2">
5265
<Tabs.Tab title='index.tsx' className="!mt-0 !rounded-t-none !rounded-b-xl">
5366
```tsx copy
54-
import { SplatViewer } from '@components/ui/splat-viewer';
67+
import Splat from '@/components/ui/splat-viewer';
5568
import './viewer.css';
5669

5770
export function SplatViewerDemo() {
5871
return (
59-
<SplatViewer src={splatUrl} autoPlay >
60-
<div className="flex gap-2 pointer-events-auto flex-grow">
61-
<FullScreenButton />
62-
<DownloadButton />
63-
</div>
64-
<div className="pointer-events-auto">
65-
<MenuButton />
66-
</div>
67-
</SplatViewer>
72+
<Splat.Viewer src={splatUrl} autoPlay >
73+
<Splat.Controls autoHide >
74+
<div className="flex gap-2 pointer-events-auto flex-grow">
75+
<Splat.FullScreenButton />
76+
<Splat.DownloadButton />
77+
</div>
78+
<div className="pointer-events-auto">
79+
<Splat.CameraModeToggle />
80+
<Splat.MenuButton />
81+
</div>
82+
</Splat.Controls>
83+
</Splat.Viewer>
6884
)
6985
}
7086
```
@@ -89,12 +105,13 @@ Supports large assets with lazy loading and automatic framing. Use it in modals,
89105
<Check>Orbit and fly controls.</Check>
90106
<Check>Keyboard and mouse controls.</Check>
91107
<Check>Controlled and uncontrolled mode.</Check>
108+
<Check>Ships with IDE Agent rules (rules.mdc).</Check>
92109
<Check>Suspenseful loading.</Check>
93110
<Dash>Camera animations. (coming soon)</Dash>
94111
<Dash>Way points. (coming soon)</Dash>
95112
</div>
96113
<div>
97-
<span>Version {splatVersion}</span>
114+
<span className="text-muted-foreground text-sm">Version <span className="font-bold">{splatVersion}</span></span>
98115
<div className="flex flex-col gap-4 -ml-2 mt-4">
99116
<a href="https://github.com/playcanvas/react-playcanvas/blob/main/packages/docs/content/blocks.mdx" target="_blank" rel="noopener noreferrer">
100117
<Badge variant="secondary" className="rounded-full px-4 py-0 text-muted-foreground hover:text-foreground transition-colors">
@@ -118,38 +135,74 @@ Supports large assets with lazy loading and automatic framing. Use it in modals,
118135
Install the component from your command line.
119136

120137
```bash copy
121-
npx shadcn@latest add https://playcanvas-react.vercel.app/r/splatviewer.json
138+
npx shadcn@latest add https://playcanvas-react.vercel.app/r/splat-viewer.json
122139
```
123140

124141
### Anatomy
125142

126143
Import all parts and piece them together.
127144

128145
```jsx
129-
import {
130-
SplatViewer,
131-
FullScreenButton,
132-
DownloadButton,
133-
MenuButton,
134-
} from "@components/ui/splat-viewer";
146+
import Splat from "@/components/ui/splat-viewer/";
135147

136148
export default () => (
137-
<SplatViewer src={splatUrl} >
138-
<FullScreenButton />
139-
<DownloadButton />
140-
<MenuButton />
141-
</SplatViewer>
149+
<Splat.Viewer src={splatUrl} >
150+
<Splat.Controls >
151+
<Splat.FullScreenButton />
152+
<Splat.DownloadButton />
153+
<Splat.CameraModeToggle />
154+
<Splat.MenuButton />
155+
</Splat.Controls>
156+
</Splat.Viewer>
142157
)
143158
```
144159

145160
### API Reference
146161

162+
#### SplatViewer
163+
164+
A responsive and composable component for displaying **Gaussian splats**.
165+
166+
<TSDoc
167+
code={`
168+
import * as Splat from '@registry/splat-viewer/';
169+
type $ = React.ComponentProps<typeof Splat.Viewer>;
170+
export default $;
171+
`}
172+
/>
173+
174+
#### Controls
175+
176+
A simple container for UI controls that creates a sensible layout and optionally auto hides when the user is interacting.
177+
147178
<TSDoc
148179
code={`
149-
import { SplatViewer } from '@registry/splat-viewer/splat-viewer';
150-
type $ = React.ComponentProps<typeof SplatViewer>;
180+
import * as Splat from '@registry/splat-viewer/';
181+
type $ = React.ComponentProps<typeof Splat.Controls>;
151182
export default $;
152183
`}
153184
/>
154185

186+
#### FullScreenButton
187+
188+
A button for entering and exiting full screen mode.
189+
190+
<TSDoc
191+
code={`
192+
import * as Splat from '@registry/splat-viewer/';
193+
type $ = React.ComponentProps<typeof Splat.FullScreenButton>;
194+
export default $;
195+
`}
196+
/>
155197

198+
#### DownloadButton
199+
200+
A button for downloading the current scene.
201+
202+
<TSDoc
203+
code={`
204+
import * as Splat from '@registry/splat-viewer/';
205+
type $ = React.ComponentProps<typeof Splat.DownloadButton>;
206+
export default $;
207+
`}
208+
/>

0 commit comments

Comments
 (0)