@modelcontextprotocol/server-threejs 0.4.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -0
- package/dist/index.js +3644 -44
- package/dist/mcp-app.html +215 -219
- package/dist/server.js +1756 -1754
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -4,6 +4,45 @@
|
|
|
4
4
|
|
|
5
5
|
Interactive 3D scene renderer using Three.js. Demonstrates streaming code preview and full MCP App integration.
|
|
6
6
|
|
|
7
|
+
## MCP Client Configuration
|
|
8
|
+
|
|
9
|
+
Add to your MCP client configuration (stdio transport):
|
|
10
|
+
|
|
11
|
+
```json
|
|
12
|
+
{
|
|
13
|
+
"mcpServers": {
|
|
14
|
+
"threejs": {
|
|
15
|
+
"command": "npx",
|
|
16
|
+
"args": [
|
|
17
|
+
"-y",
|
|
18
|
+
"--silent",
|
|
19
|
+
"--registry=https://registry.npmjs.org/",
|
|
20
|
+
"@modelcontextprotocol/server-threejs",
|
|
21
|
+
"--stdio"
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Local Development
|
|
29
|
+
|
|
30
|
+
To test local modifications, use this configuration (replace `~/code/ext-apps` with your clone path):
|
|
31
|
+
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"mcpServers": {
|
|
35
|
+
"threejs": {
|
|
36
|
+
"command": "bash",
|
|
37
|
+
"args": [
|
|
38
|
+
"-c",
|
|
39
|
+
"cd ~/code/ext-apps/examples/threejs-server && npm run build >&2 && node dist/index.js --stdio"
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
7
46
|
## Features
|
|
8
47
|
|
|
9
48
|
- **Interactive 3D Rendering**: Execute JavaScript code to create and animate Three.js scenes
|
|
@@ -108,3 +147,31 @@ React component that:
|
|
|
108
147
|
- Displays streaming preview from `toolInputsPartial.code` as code arrives
|
|
109
148
|
- Executes final code from `toolInputs.code` when complete
|
|
110
149
|
- Renders to a pre-created canvas with configurable height
|
|
150
|
+
|
|
151
|
+
## Performance
|
|
152
|
+
|
|
153
|
+
### Visibility-Based Pause
|
|
154
|
+
|
|
155
|
+
Animation automatically pauses when the view scrolls out of view:
|
|
156
|
+
|
|
157
|
+
- Uses `IntersectionObserver` to track visibility (browser-native, no polling)
|
|
158
|
+
- Wraps `requestAnimationFrame` to skip frames when not visible
|
|
159
|
+
- Animation loop stops completely → zero CPU usage while hidden
|
|
160
|
+
- Queued callbacks resume instantly when scrolled back into view
|
|
161
|
+
|
|
162
|
+
This is transparent to user code - just use `requestAnimationFrame` normally.
|
|
163
|
+
|
|
164
|
+
### Transparent Background
|
|
165
|
+
|
|
166
|
+
Supports alpha transparency for seamless host UI integration:
|
|
167
|
+
|
|
168
|
+
```javascript
|
|
169
|
+
const renderer = new THREE.WebGLRenderer({
|
|
170
|
+
canvas,
|
|
171
|
+
antialias: true,
|
|
172
|
+
alpha: true,
|
|
173
|
+
});
|
|
174
|
+
renderer.setClearColor(0x000000, 0); // Fully transparent
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
This is the default - 3D objects composite directly over the host background.
|