websim is a powerful web simulation platform that allows users to create interactive, dynamic web experiences through natural language prompts. This extensive guide covers everything from basic concepts to advanced features.
websim prompts follow a simple structure:
action [parameters] description
create interactive button with hover effect blue to red
// Create reusable card component
create card-component with shadow hover-effect
// Use in multiple places
insert card-component into grid-layout
// Create dynamic light source
create sphere with gradient-glow
animate light-source follow-mouse
websim supports sophisticated user interactions including:
websim.createSequence([
{ element: '#hero', animation: 'fadeIn', duration: 1000 },
{ element: '.cards', animation: 'slideUp', duration: 800, delay: 200 },
{ element: '#cta', animation: 'pulse', duration: 500, delay: 1000 }
]);
Fine-tune websim's behavior to match your specific needs:
{
"model_params": {
"temperature": 0.7,
"response_style": "technical",
"domain_focus": "e-commerce"
}
}
Improve model performance with:
{
"agent_type": "dialog",
"capabilities": ["natural_language", "context_awareness"],
"personality": "professional",
"knowledge_base": "technical_support"
}
websim.initMultiplayer({
room: "project-space-1",
maxUsers: 10,
syncInterval: 1000,
conflictResolution: "last-write-wins"
});
websim.createSharedCanvas({
tools: ['brush', 'eraser', 'shapes'],
syncMode: 'realtime',
onDraw: (data) => {
broadcastToRoom(data);
}
});
// Create new simulation
POST https://api.websim.ai/v1/simulations
// Update existing simulation
PUT https://api.websim.ai/v1/simulations/{id}
// Get simulation state
GET https://api.websim.ai/v1/simulations/{id}
const ws = new WebSocket('wss://api.websim.ai/v1/ws');
ws.onmessage = (event) => {
const update = JSON.parse(event.data);
// Handle real-time updates
};
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
}
// Generate dynamic scene based on API data
async function createDynamicScene(data) {
const scene = await websim.create('scene');
data.forEach(item => {
scene.add({
type: item.type,
position: item.coords,
properties: item.attributes
});
});
}
!create
- Generate new content!edit
- Modify existing content!style
- Update styling!animate
- Add animations!interact
- Add interactive elements!state
- Manage state!debug
- Troubleshooting mode
websim.initLanguageModel({
model: "gpt-4",
temperature: 0.7,
maxTokens: 1000,
contextWindow: "auto"
});
websim.initFileUploader({
maxSize: "50mb",
allowedTypes: ["image/*", ".glb", ".pdf"],
endpoint: "https://api.websim.ai/v1/upload",
onProgress: (progress) => {
console.log(`Upload progress: ${progress}%`);
}
});
// Store metadata
await websim.metadata.set('scene-1', {
author: 'username',
created: Date.now(),
tags: ['interactive', '3d']
});
// Retrieve metadata
const meta = await websim.metadata.get('scene-1');
// Connect to WebsimDB
const db = await websim.database.connect({
type: 'websimdb',
collection: 'scenes'
});
// Store data
await db.insert({
id: 'scene-1',
data: sceneData,
timestamp: Date.now()
});
// Query data
const scenes = await db.query({
author: 'username',
tags: { $contains: 'interactive' }
});