Skip to content

CesiumGS/cesiumjs-skills / skills/cesiumjs-custom-shader

cesiumjs-custom-shader

Verified

CustomShader 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.

examples/01-diffuse-tint.js

View on GitHub
// 01-diffuse-tint.js — Time-driven diffuse tint on a Model.
// Asset: Sandcastle-provided SampleData/models/CesiumAir/Cesium_Air.glb.

import {
  CustomShader,
  UniformType,
  Cartesian3,
  Model,
  HeadingPitchRoll,
  Transforms,
} from "cesium";

const tintShader = new CustomShader({
  uniforms: {
    u_tint: { type: UniformType.VEC3, value: new Cartesian3(1.0, 0.5, 0.2) },
    u_time: { type: UniformType.FLOAT, value: 0.0 },
  },
  fragmentShaderText: `
    void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material) {
      float pulse = 0.5 + 0.5 * sin(u_time);
      material.diffuse = mix(material.diffuse, u_tint, pulse);
    }
  `,
});

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: tintShader,
});
viewer.scene.primitives.add(model);
viewer.camera.flyToBoundingSphere(model.boundingSphere, { duration: 0 });

const start = performance.now();
viewer.scene.postUpdate.addEventListener(() => {
  tintShader.setUniform("u_time", (performance.now() - start) / 1000.0);
});
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: 198kUpdated Claude CodeCodexVerifiedInstall
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: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
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: 194kUpdated Claude CodeCodexVerifiedInstall