/cesiumjs-skills:cesiumjs-models-particlesfrom cesiumjs-skills
Loads and manipulates glTF/GLB models in CesiumJS, including compressed KHR_meshopt_geometry, CAD extensions, edge rendering, model animations, node transforms, and particle systems with various emitters.
Ships in cesiumjs-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Version baseline: CesiumJS v1.144.
| Class | Purpose |
|---|---|
Model | Low-level glTF/GLB primitive; positioned via modelMatrix |
ModelAnimation | Active animation instance on a model |
ModelAnimationCollection | Collection at model.activeAnimations |
ModelNode | Named node with modifiable transform |
ModelFeature | Per-feature styling/picking for feature-ID models |
EdgeDisplayMode | Controls draft glTF edge-visibility rendering on Model/Cesium3DTileset |
ParticleSystem | Billboard-based particle manager (fire, smoke, rain) |
Particle | Single particle with position, velocity, life |
ParticleBurst | Scheduled burst of particles |
BoxEmitter / CircleEmitter | Emit within box volume / flat disk |
ConeEmitter / SphereEmitter | Emit from cone tip / within sphere |
The Entity API exposes models through ModelGraphics (see cesiumjs-entities). The Primitive API uses Model.fromGltfAsync for full control over modelMatrix, animations, and node transforms.
Always use the async factory -- never call the constructor directly.
import { Model, Cartesian3, Transforms, HeadingPitchRoll, Math as CesiumMath } from "cesium";
const model = await Model.fromGltfAsync({ url: "path/to/model.glb" });
viewer.scene.primitives.add(model);
CesiumJS ships sample models usable without ion tokens:
https://raw.githubusercontent.com/CesiumGS/cesium/main/Apps/SampleData/models/CesiumAir/Cesium_Air.glb
https://raw.githubusercontent.com/CesiumGS/cesium/main/Apps/SampleData/models/CesiumMan/Cesium_Man.glb
https://raw.githubusercontent.com/CesiumGS/cesium/main/Apps/SampleData/models/CesiumMilkTruck/CesiumMilkTruck.glb
CesiumJS 1.143 decodes KHR_meshopt_compression automatically, including the
v1 attribute codec and COLOR filter. Do not import a decoder or private loader
helper. When loading compressed glTF, CAD-style lines/points/edges, or
constant-LOD textures, read REFERENCE.md for the complete
support and authoring matrix. The same loader behavior applies to glTF content
inside 3D Tiles.
const position = Cartesian3.fromDegrees(-123.074, 44.050, 5000);
const hpr = new HeadingPitchRoll(CesiumMath.toRadians(135), 0, 0);
const model = await Model.fromGltfAsync({
url: "CesiumAir.glb",
modelMatrix: Transforms.headingPitchRollToFixedFrame(position, hpr),
minimumPixelSize: 128, // never smaller than 128 px on screen
maximumScale: 20000, // cap for minimumPixelSize enlargement
scale: 2.0, // uniform scale multiplier
});
viewer.scene.primitives.add(model);
Visual eval framing: for model screenshots, the model must be fully inside the frame and recognizable, not clipped at the bottom edge. Use
minimumPixelSize256-400 for public sample aircraft, add a subtlesilhouetteColor/silhouetteSize, and place the camera with explicit coordinates aimed at the known model position. Avoid shallow pitches that put the model below the frame or rely onviewer.flyTo(model), which is version-sensitive forModelprimitives.
Models can appear stretched or warped when scale is applied non-uniformly or when the orientation matrix is built incorrectly. Common pitfalls:
Transforms.headingPitchRollToFixedFrame (or the Entity API's headingPitchRollQuaternion) for ground-aligned orientation. Hand-rolled quaternions often invert pitch/roll axes and produce vertically stretched silhouettes.scale (uniform) for size, not a non-uniform Matrix4.fromScale. A non-uniform scale baked into modelMatrix will distort the model. Reserve Matrix4.fromScale for per-node tweaks (e.g., stretching a single turret), not the whole model.minimumPixelSize with a sensible maximumScale. Without a cap, distant small models can balloon to fill the frame and look elongated when the camera is close.Model.fromGltfAsync Options| Option | Type | Default |
|---|---|---|
url | string|Resource | required |
modelMatrix | Matrix4 | IDENTITY |
scale | number | 1.0 |
minimumPixelSize | number | 0.0 |
maximumScale | number | -- |
show | boolean | true |
color / colorBlendMode / colorBlendAmount | Color / ColorBlendMode / number | -- / HIGHLIGHT / 0.5 |
edgeDisplayMode | EdgeDisplayMode | SURFACES_ONLY |
silhouetteColor / silhouetteSize | Color / number | RED / 0.0 |
shadows | ShadowMode | ENABLED |
heightReference | HeightReference | NONE |
customShader | CustomShader | -- |
id | any | -- |
allowPicking | boolean | true |
fromGltfAsync resolves once glTF JSON is parsed, but WebGL resources may still load. Wait for readyEvent before accessing animations, nodes, or boundingSphere.
const model = await Model.fromGltfAsync({ url: "robot.glb" });
viewer.scene.primitives.add(model);
model.readyEvent.addEventListener(() => {
console.log("Bounding sphere:", model.boundingSphere);
});
// Synchronous check
if (model.ready) { const bs = model.boundingSphere; }
Managed through model.activeAnimations (ModelAnimationCollection).
model.readyEvent.addEventListener(() => {
// Single animation
const anim = model.activeAnimations.add({
name: "Walk", // glTF animation name
loop: Cesium.ModelAnimationLoop.REPEAT, // NONE | REPEAT | MIRRORED_REPEAT
multiplier: 1.0, // playback speed (must be > 0)
});
anim.start.addEventListener((m, a) => console.log(`Started: ${a.name}`));
// Or play all animations at once
model.activeAnimations.addAll({
loop: Cesium.ModelAnimationLoop.REPEAT,
multiplier: 0.5,
});
});
Additional add options: index, reverse, startTime, stopTime, delay, removeOnStop, animationTime (custom time callback).
Animations require viewer.clock.shouldAnimate = true to advance. A walking character will appear frozen mid-pose (or distorted if at the seam between keyframes) if the clock is stopped.
animation.start.addEventListener((model, animation) => { });
animation.update.addEventListener((model, animation, time) => { });
animation.stop.addEventListener((model, animation) => { });
// Collection-level
model.activeAnimations.animationAdded.addEventListener((model, anim) => { });
model.activeAnimations.remove(animation); // remove one
model.activeAnimations.removeAll(); // remove all
Override named node transforms for procedural animation (e.g., turret rotation).
model.readyEvent.addEventListener(() => {
const node = model.getNode("Turret");
node.matrix = Cesium.Matrix4.fromScale(
new Cesium.Cartesian3(5.0, 1.0, 1.0), node.matrix
);
});
Properties: name (read-only), id (read-only index), show (boolean), matrix (Matrix4 -- set to undefined to restore original and re-enable glTF animations).
// Tint + silhouette
model.color = Cesium.Color.RED.withAlpha(0.5);
model.colorBlendMode = Cesium.ColorBlendMode.MIX;
model.colorBlendAmount = 0.5;
model.silhouetteColor = Cesium.Color.YELLOW;
model.silhouetteSize = 2.0;
For glTF assets using the draft EXT_mesh_primitive_edge_visibility extension,
EdgeDisplayMode controls whether extension-provided edges are hidden, composited
over surfaces, or rendered alone. Models without the extension are unaffected.
import { EdgeDisplayMode, Model } from "cesium";
const model = await Model.fromGltfAsync({
url: "/models/cad-part.glb",
edgeDisplayMode: EdgeDisplayMode.SURFACES_AND_EDGES,
});
viewer.scene.primitives.add(model);
model.edgeDisplayMode = EdgeDisplayMode.EDGES_ONLY; // CAD-style wireframe
model.edgeDisplayMode = EdgeDisplayMode.SURFACES_ONLY; // default
When a glTF has EXT_mesh_features or EXT_structural_metadata, picking returns a ModelFeature:
const handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
handler.setInputAction((movement) => {
const picked = viewer.scene.pick(movement.endPosition);
if (picked instanceof Cesium.ModelFeature) {
picked.getPropertyIds().forEach((name) => {
console.log(`${name}: ${picked.getProperty(name)}`);
});
picked.color = Cesium.Color.YELLOW;
}
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
// Primitive API -- scene is required for height reference
const model = await Model.fromGltfAsync({
url: "truck.glb",
heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
scene: viewer.scene,
});
// Entity API
viewer.entities.add({
position: Cartesian3.fromDegrees(-75.59, 40.03),
model: { uri: "truck.glb", heightReference: Cesium.HeightReference.CLAMP_TO_GROUND },
});
Values: NONE, CLAMP_TO_GROUND, RELATIVE_TO_GROUND, CLAMP_TO_TERRAIN, RELATIVE_TO_TERRAIN, CLAMP_TO_3D_TILE, RELATIVE_TO_3D_TILE.
ParticleSystem renders billboard-based effects. Position with modelMatrix (world) and emitterModelMatrix (local offset).
Always set viewer.clock.shouldAnimate = true before adding a particle system -- particles only move when the clock is running. A stopped clock produces a static "blob" at the emitter origin rather than a directional plume.
A common failure mode is rendering a diffuse spherical blob instead of a recognizable rising column. To make plumes read as vertical:
CircleEmitter or a narrow ConeEmitter for upward-biased velocity. SphereEmitter and BoxEmitter radiate in all directions and produce blob-like shapes.modelMatrix frame; set modelMatrix via Transforms.eastNorthUpToFixedFrame so +Z is local up.minimumParticleLife / maximumParticleLife (e.g., 1.5-4.0) so particles travel far enough to form a visible column before fading.startScale small, endScale 3-6x larger) so the plume widens with height, matching real smoke.viewer.clock.shouldAnimate = true and wait.import { ParticleSystem, CircleEmitter, Color, Cartesian2, Transforms, Cartesian3 } from "cesium";
viewer.clock.shouldAnimate = true; // required -- particles don't move on a stopped clock
const smokeSystem = new ParticleSystem({
image: "smoke.png",
startColor: Color.LIGHTGRAY.withAlpha(0.7),
endColor: Color.WHITE.withAlpha(0.0),
startScale: 1.0,
endScale: 5.0,
emissionRate: 10,
minimumSpeed: 1.0,
maximumSpeed: 4.0,
minimumParticleLife: 1.2,
maximumParticleLife: 3.0,
imageSize: new Cartesian2(25, 25), // pixel size
emitter: new CircleEmitter(2.0), // radius in meters
modelMatrix: Transforms.eastNorthUpToFixedFrame(Cartesian3.fromDegrees(-75.157, 39.978)),
lifetime: 16.0,
loop: true,
});
viewer.scene.primitives.add(smokeSystem);
For terrain-scale smoke such as Mount St. Helens, use an oblique camera and a restrained source marker. The marker should confirm the emitter location without becoming a giant ground disk, and the plume should fit entirely in frame with terrain visible underneath.
import { ParticleSystem, CircleEmitter, Color, Cartesian2, Transforms, Cartesian3 } from "cesium";
viewer.clock.shouldAnimate = true;
const sourcePosition = Cartesian3.fromDegrees(-122.1944, 46.1914, 2549);
viewer.entities.add({
position: sourcePosition,
point: {
pixelSize: 10,
color: Color.ORANGE,
outlineColor: Color.BLACK,
outlineWidth: 2,
},
});
const craterSmoke = new ParticleSystem({
image: createRadialParticle(48, "rgba(180,180,180,0.75)"),
startColor: Color.LIGHTGRAY.withAlpha(0.65),
endColor: Color.WHITE.withAlpha(0.0),
startScale: 0.8,
endScale: 4.0,
emissionRate: 35,
minimumSpeed: 20.0,
maximumSpeed: 45.0,
minimumParticleLife: 2.0,
maximumParticleLife: 4.0,
imageSize: new Cartesian2(22, 22),
emitter: new CircleEmitter(35.0),
modelMatrix: Transforms.eastNorthUpToFixedFrame(sourcePosition),
lifetime: 20.0,
loop: true,
});
viewer.scene.primitives.add(craterSmoke);
viewer.trackedEntity = undefined;
viewer.camera.lookAt(
sourcePosition,
new Cesium.HeadingPitchRange(
Cesium.Math.toRadians(35),
Cesium.Math.toRadians(-22),
6500
)
);
Use this pattern when a prompt asks for smoke over a named geographic source:
point or small billboard marker over an ellipse unless the prompt specifically asks for a ground footprint.import { BoxEmitter, CircleEmitter, ConeEmitter, SphereEmitter } from "cesium";
new BoxEmitter(new Cesium.Cartesian3(10, 10, 10)); // 3D box, velocity outward
new CircleEmitter(2.0); // flat disk, velocity +Z
new ConeEmitter(Cesium.Math.toRadians(30)); // cone tip, velocity toward base
new SphereEmitter(5.0); // sphere, velocity radiates out
const firework = new ParticleSystem({
image: getParticleCanvas(),
startColor: Color.RED,
endColor: Color.RED.withAlpha(0.0),
particleLife: 1.0,
speed: 100.0,
imageSize: new Cartesian2(7, 7),
emissionRate: 0, // bursts only
emitter: new SphereEmitter(0.1),
bursts: [
new Cesium.ParticleBurst({ time: 0.0, minimum: 100, maximum: 200 }),
new Cesium.ParticleBurst({ time: 2.0, minimum: 50, maximum: 100 }),
new Cesium.ParticleBurst({ time: 4.0, minimum: 200, maximum: 300 }),
],
lifetime: 6.0,
loop: false,
modelMatrix: Transforms.eastNorthUpToFixedFrame(Cartesian3.fromDegrees(-75.597, 40.038)),
});
viewer.scene.primitives.add(firework);
The updateCallback runs per-particle per-frame for forces like gravity.
const gravityScratch = new Cesium.Cartesian3();
function applyGravity(particle, dt) {
Cesium.Cartesian3.normalize(particle.position, gravityScratch);
Cesium.Cartesian3.multiplyByScalar(gravityScratch, -9.8 * dt, gravityScratch);
particle.velocity = Cesium.Cartesian3.add(particle.velocity, gravityScratch, particle.velocity);
}
const system = new ParticleSystem({
image: "smoke.png",
emissionRate: 20,
emitter: new ConeEmitter(Cesium.Math.toRadians(45)),
updateCallback: applyGravity,
modelMatrix: Transforms.eastNorthUpToFixedFrame(Cartesian3.fromDegrees(-105, 40, 1000)),
});
viewer.scene.primitives.add(system);
Particle effects should stand out against the map underneath, not against the sky or a featureless background. Two common framing failures:
Use viewer.camera.lookAt with HeadingPitchRange to anchor on the emitter and dial in an oblique view that keeps the map context visible:
const position = Cartesian3.fromDegrees(-122.1944, 46.1914, 2549);
viewer.trackedEntity = undefined;
viewer.camera.lookAt(
position,
new Cesium.HeadingPitchRange(
Cesium.Math.toRadians(35), // heading
Cesium.Math.toRadians(-22), // oblique pitch preserves plume height
6500 // increase range until top and base fit
)
);
Guidelines:
viewer.trackedEntity = undefined before lookAt, or the tracked entity's reference frame will override your camera transform.Sync modelMatrix each frame via scene.preUpdate. Use emitterModelMatrix for a local offset (e.g., exhaust pipe).
const entity = viewer.entities.add({
position: sampledPosition,
orientation: new Cesium.VelocityOrientationProperty(sampledPosition),
model: { uri: "truck.glb", minimumPixelSize: 64 },
});
// Local offset to exhaust pipe
const trs = new Cesium.TranslationRotationScale();
trs.translation = new Cesium.Cartesian3(-4.0, 0.0, 1.4);
const emitterModelMatrix = Cesium.Matrix4.fromTranslationRotationScale(trs, new Cesium.Matrix4());
const exhaust = new ParticleSystem({
image: "smoke.png",
startColor: Color.GRAY.withAlpha(0.7),
endColor: Color.TRANSPARENT,
emissionRate: 8,
speed: 2.0,
particleLife: 1.5,
imageSize: new Cartesian2(20, 20),
emitter: new CircleEmitter(0.5),
emitterModelMatrix: emitterModelMatrix,
});
viewer.scene.primitives.add(exhaust);
viewer.scene.preUpdate.addEventListener((scene, time) => {
exhaust.modelMatrix = entity.computeModelMatrix(time, new Cesium.Matrix4());
});
Generate particle textures dynamically instead of loading image files. A radial gradient produces soft, realistic edges for smoke and water effects.
// Soft radial-gradient particle (smoke, water, fog)
function createRadialParticle(size = 32, colorStop = "rgba(200,200,200,0.9)") {
const c = document.createElement("canvas");
c.width = c.height = size;
const ctx = c.getContext("2d");
const half = size / 2;
const grad = ctx.createRadialGradient(half, half, 0, half, half, half);
grad.addColorStop(0, colorStop);
grad.addColorStop(1, "rgba(0,0,0,0)");
ctx.fillStyle = grad;
ctx.fillRect(0, 0, size, size);
return c;
}
// Solid circle (high-contrast, fireworks, sparks)
function createCircleImage(size = 20) {
const c = document.createElement("canvas");
c.width = c.height = size;
const ctx = c.getContext("2d");
ctx.beginPath();
ctx.arc(size / 2, size / 2, size / 2, 0, Math.PI * 2);
ctx.fillStyle = "#fff";
ctx.fill();
return c;
}
// Pass canvas directly as image
new ParticleSystem({ image: createRadialParticle(), /* ...other options */ });
Use Color.fromCssColorString for specific particle colors when named colors don't suffice:
startColor: Cesium.Color.fromCssColorString("#66ccff").withAlpha(0.95),
endColor: Cesium.Color.WHITE.withAlpha(0.0),
For simpler use cases, add a model through the Entity API (see cesiumjs-entities for full coverage).
const entity = viewer.entities.add({
name: "Aircraft",
position: Cartesian3.fromDegrees(-123.074, 44.050, 5000),
orientation: Cesium.Transforms.headingPitchRollQuaternion(
Cartesian3.fromDegrees(-123.074, 44.050, 5000),
new Cesium.HeadingPitchRoll(Cesium.Math.toRadians(135), 0, 0)
),
model: {
uri: "CesiumAir.glb",
minimumPixelSize: 128,
maximumScale: 20000,
silhouetteColor: Color.RED,
silhouetteSize: 2.0,
},
});
viewer.trackedEntity = entity;
Framing trade-off with viewer.trackedEntity: tracking centers the model but uses an auto-computed range derived from the bounding sphere, which often produces a too-close, low-context shot. For prompts that ask for both the model and map context (terrain, landmarks, labels), prefer viewer.camera.flyTo / lookAt to a manually chosen position and clear viewer.trackedEntity = undefined first.
CesiumJS experimentally supports the NGA Geospatial Positioning Metadata glTF extension. Types: AnchorPointDirect, AnchorPointIndirect, CorrelationGroup, GltfGpmLocal, Spdcf. Parsed automatically when loading a glTF with NGA_gpm_local -- the API is experimental and subject to change.
.glb over .gltf -- binary format avoids extra HTTP requests and is smaller on the wire.KHR_draco_mesh_compression) for 80-90% smaller meshes.KHR_texture_basisu) for GPU-compressed textures; keep dimensions power-of-two.minimumPixelSize carefully -- large values force enlargement of distant models, increasing draw cost.Matrix4 objects -- avoid allocating every frame when syncing particle systems to moving entities.sizeInMeters: false, default) -- meter-sized particles are expensive at close range.lifetime on particle systems -- Number.MAX_VALUE (default) prevents pool cleanup.allowPicking: false saves GPU memory on models that need no interaction.viewer.scene.primitives.remove(model) then model.destroy() to free WebGL resources.Model.customShader (struct reference, feature IDs, metadata, vertex displacement)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub cesiumgs/cesiumjs-skills --plugin cesiumjs-skills15 skills in this plugin
/cesiumjs-3d-tilesCesiumJS 3D Tiles - Cesium3DTileset, compressed and CAD-style glTF content, MVTDataProvider, UrlTemplate3DTilesDataProvider, styling, metadata, feature picking, voxels, point clouds, I3S, Gaussian splats, clipping. Use when a task involves loading 3D Tiles or Mapbox Vector Tiles, draping vector tiles on terrain, rendering KHR meshopt/CAD content, styling or querying features, working with voxels or point clouds, or clipping spatial data./cesiumjs-cameraCesiumJS camera control - Camera, flyTo, lookAt, setView, ScreenSpaceCameraController, composable Controller camera controllers (1.144), CameraEventAggregator, flight animation. Use when positioning the camera, creating flyTo animations, constraining user navigation, adding custom or asset-inspection camera controllers, tracking entities, or converting between screen and world coordinates./cesiumjs-core-utilitiesOther plugins' skills for the same job