CesiumGS/cesiumjs-skills / skills/cesiumjs-custom-shader
cesiumjs-custom-shader
VerifiedCustomShader authoring — vertexShaderText and fragmentShaderText against VertexInput, FragmentInput, FeatureIds, Metadata, czm_modelMaterial. Use when reading EXT_mesh_features or EXT_structural_metadata property textures/tables, vertex displacement, or shading VoxelPrimitive.
| File | Kind | Size |
|---|---|---|
| REFERENCE.md | markdown | 17.8 KB |
| SKILL.md | skill md | 20.0 KB |
| examples/01-diffuse-tint.js | script | 1.2 KB |
| examples/02-texture-swap.js | script | 1.3 KB |
| examples/03-feature-id-tileset.js | script | 1.3 KB |
| examples/04-translucent-override.js | script | 1.2 KB |
| examples/05-vertex-displacement.js | script | 1.7 KB |
| examples/06-metadata-ramp.js | script | 1.8 KB |
| examples/07-voxel-shader.js | script | 1.3 KB |
| examples/README.md | markdown | 972 B |
| examples/_sandcastle-template.html | other | 409 B |
examples/02-texture-swap.js
View on GitHub// 02-texture-swap.js — Animated texture uniform via SAMPLER_2D + TextureUniform.
// Assets: Sandcastle SampleData — CesiumAir + cesium_stripes.png.
import {
CustomShader,
UniformType,
TextureUniform,
Model,
Cartesian3,
HeadingPitchRoll,
Transforms,
} from "cesium";
const stripeShader = new CustomShader({
uniforms: {
u_time: { type: UniformType.FLOAT, value: 0.0 },
u_stripes: {
type: UniformType.SAMPLER_2D,
value: new TextureUniform({ url: "../../SampleData/cesium_stripes.png", repeat: true }),
},
},
fragmentShaderText: `
void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material) {
vec2 uv = fsInput.attributes.texCoord_0 + vec2(0.1 * u_time, 0.0);
material.diffuse = texture(u_stripes, uv).rgb;
}
`,
});
const position = Cartesian3.fromDegrees(-123.0744619, 44.0503706, 5000);
const model = await Model.fromGltfAsync({
url: "../../SampleData/models/CesiumAir/Cesium_Air.glb",
modelMatrix: Transforms.headingPitchRollToFixedFrame(position, new HeadingPitchRoll()),
customShader: stripeShader,
});
viewer.scene.primitives.add(model);
viewer.camera.flyToBoundingSphere(model.boundingSphere, { duration: 0 });
const start = performance.now();
viewer.scene.postUpdate.addEventListener(() => {
stripeShader.setUniform("u_time", (performance.now() - start) / 1000.0);
});
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |