particles-physics
Physics simulation for particle systems—forces (gravity, wind, drag), attractors/repulsors, velocity fields, turbulence, and collision. Use when particles need realistic or artistic motion, swarm behavior, or field-based animation.
What this skill does
# Particle Physics
Apply forces, fields, and constraints to create dynamic particle motion.
## Quick Start
```tsx
// Simple gravity + velocity
useFrame((_, delta) => {
for (let i = 0; i < count; i++) {
// Apply gravity
velocities[i * 3 + 1] -= 9.8 * delta;
// Update position
positions[i * 3] += velocities[i * 3] * delta;
positions[i * 3 + 1] += velocities[i * 3 + 1] * delta;
positions[i * 3 + 2] += velocities[i * 3 + 2] * delta;
}
geometry.attributes.position.needsUpdate = true;
});
```
## Force Types
### Gravity (Constant Force)
```tsx
function applyGravity(
velocities: Float32Array,
count: number,
gravity: THREE.Vector3,
delta: number
) {
for (let i = 0; i < count; i++) {
velocities[i * 3] += gravity.x * delta;
velocities[i * 3 + 1] += gravity.y * delta;
velocities[i * 3 + 2] += gravity.z * delta;
}
}
// Usage
const gravity = new THREE.Vector3(0, -9.8, 0);
applyGravity(velocities, count, gravity, delta);
```
### Wind (Directional + Noise)
```tsx
function applyWind(
velocities: Float32Array,
positions: Float32Array,
count: number,
direction: THREE.Vector3,
strength: number,
turbulence: number,
time: number,
delta: number
) {
for (let i = 0; i < count; i++) {
const x = positions[i * 3];
const y = positions[i * 3 + 1];
const z = positions[i * 3 + 2];
// Base wind
let wx = direction.x * strength;
let wy = direction.y * strength;
let wz = direction.z * strength;
// Add turbulence (using simple noise approximation)
const noise = Math.sin(x * 0.5 + time) * Math.cos(z * 0.5 + time);
wx += noise * turbulence;
wy += Math.sin(y * 0.3 + time * 1.3) * turbulence * 0.5;
wz += Math.cos(x * 0.4 + time * 0.7) * turbulence;
velocities[i * 3] += wx * delta;
velocities[i * 3 + 1] += wy * delta;
velocities[i * 3 + 2] += wz * delta;
}
}
```
### Drag (Velocity Damping)
```tsx
function applyDrag(
velocities: Float32Array,
count: number,
drag: number, // 0-1, higher = more drag
delta: number
) {
const factor = 1 - drag * delta;
for (let i = 0; i < count; i++) {
velocities[i * 3] *= factor;
velocities[i * 3 + 1] *= factor;
velocities[i * 3 + 2] *= factor;
}
}
// Quadratic drag (more realistic)
function applyQuadraticDrag(
velocities: Float32Array,
count: number,
coefficient: number,
delta: number
) {
for (let i = 0; i < count; i++) {
const vx = velocities[i * 3];
const vy = velocities[i * 3 + 1];
const vz = velocities[i * 3 + 2];
const speed = Math.sqrt(vx * vx + vy * vy + vz * vz);
if (speed > 0) {
const dragForce = coefficient * speed * speed;
const factor = Math.max(0, 1 - (dragForce * delta) / speed);
velocities[i * 3] *= factor;
velocities[i * 3 + 1] *= factor;
velocities[i * 3 + 2] *= factor;
}
}
}
```
## Attractors & Repulsors
### Point Attractor
```tsx
function applyAttractor(
velocities: Float32Array,
positions: Float32Array,
count: number,
attractorPos: THREE.Vector3,
strength: number, // Positive = attract, negative = repel
delta: number
) {
for (let i = 0; i < count; i++) {
const dx = attractorPos.x - positions[i * 3];
const dy = attractorPos.y - positions[i * 3 + 1];
const dz = attractorPos.z - positions[i * 3 + 2];
const distSq = dx * dx + dy * dy + dz * dz;
const dist = Math.sqrt(distSq);
if (dist > 0.1) { // Avoid division by zero
// Inverse square falloff
const force = strength / distSq;
velocities[i * 3] += (dx / dist) * force * delta;
velocities[i * 3 + 1] += (dy / dist) * force * delta;
velocities[i * 3 + 2] += (dz / dist) * force * delta;
}
}
}
```
### Orbit Attractor
```tsx
function applyOrbitAttractor(
velocities: Float32Array,
positions: Float32Array,
count: number,
center: THREE.Vector3,
orbitStrength: number,
pullStrength: number,
delta: number
) {
for (let i = 0; i < count; i++) {
const dx = positions[i * 3] - center.x;
const dy = positions[i * 3 + 1] - center.y;
const dz = positions[i * 3 + 2] - center.z;
const dist = Math.sqrt(dx * dx + dy * dy + dz * dz);
if (dist > 0.1) {
// Tangential force (orbit)
const tx = -dz / dist;
const tz = dx / dist;
velocities[i * 3] += tx * orbitStrength * delta;
velocities[i * 3 + 2] += tz * orbitStrength * delta;
// Radial force (pull toward center)
velocities[i * 3] -= (dx / dist) * pullStrength * delta;
velocities[i * 3 + 1] -= (dy / dist) * pullStrength * delta;
velocities[i * 3 + 2] -= (dz / dist) * pullStrength * delta;
}
}
}
```
### Multiple Attractors
```tsx
interface Attractor {
position: THREE.Vector3;
strength: number;
radius: number; // Influence radius
}
function applyAttractors(
velocities: Float32Array,
positions: Float32Array,
count: number,
attractors: Attractor[],
delta: number
) {
for (let i = 0; i < count; i++) {
const px = positions[i * 3];
const py = positions[i * 3 + 1];
const pz = positions[i * 3 + 2];
for (const attractor of attractors) {
const dx = attractor.position.x - px;
const dy = attractor.position.y - py;
const dz = attractor.position.z - pz;
const dist = Math.sqrt(dx * dx + dy * dy + dz * dz);
if (dist > 0.1 && dist < attractor.radius) {
// Smooth falloff within radius
const falloff = 1 - dist / attractor.radius;
const force = attractor.strength * falloff * falloff;
velocities[i * 3] += (dx / dist) * force * delta;
velocities[i * 3 + 1] += (dy / dist) * force * delta;
velocities[i * 3 + 2] += (dz / dist) * force * delta;
}
}
}
}
```
## Velocity Fields
### Curl Noise Field
```tsx
// In shader (GPU)
vec3 curlNoise(vec3 p) {
const float e = 0.1;
vec3 dx = vec3(e, 0.0, 0.0);
vec3 dy = vec3(0.0, e, 0.0);
vec3 dz = vec3(0.0, 0.0, e);
float n1 = snoise(p + dy) - snoise(p - dy);
float n2 = snoise(p + dz) - snoise(p - dz);
float n3 = snoise(p + dx) - snoise(p - dx);
float n4 = snoise(p + dz) - snoise(p - dz);
float n5 = snoise(p + dx) - snoise(p - dx);
float n6 = snoise(p + dy) - snoise(p - dy);
return normalize(vec3(n1 - n2, n3 - n4, n5 - n6));
}
// Usage in vertex shader
vec3 velocity = curlNoise(position * 0.5 + uTime * 0.1);
position += velocity * delta;
```
### Flow Field (2D/3D Grid)
```tsx
class FlowField {
private field: THREE.Vector3[];
private resolution: number;
private size: number;
constructor(resolution: number, size: number) {
this.resolution = resolution;
this.size = size;
this.field = [];
for (let i = 0; i < resolution ** 3; i++) {
this.field.push(new THREE.Vector3());
}
}
// Generate field from noise
generate(time: number, scale: number) {
for (let x = 0; x < this.resolution; x++) {
for (let y = 0; y < this.resolution; y++) {
for (let z = 0; z < this.resolution; z++) {
const index = x + y * this.resolution + z * this.resolution * this.resolution;
// Use noise to generate flow direction
const wx = x / this.resolution * scale;
const wy = y / this.resolution * scale;
const wz = z / this.resolution * scale;
const angle1 = noise3D(wx, wy, wz + time) * Math.PI * 2;
const angle2 = noise3D(wx + 100, wy, wz + time) * Math.PI * 2;
this.field[index].set(
Math.cos(angle1) * Math.cos(angle2),
Math.sin(angle2),
Math.sin(angle1) * Math.cos(angle2)
);
}
}
}
}
// Sample field at position
sample(position: THREE.Vector3): THREE.Vector3 {
const halfSize = this.size / 2;
const x = Math.floor(((position.x + halfSize) / this.size) * this.resolution);
coRelated in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.