cesiumjs-models-particles
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCesiumJS Models, glTF & Particle Effects
CesiumJS 模型、glTF 与粒子效果
Version baseline: CesiumJS v1.143.
版本基线:CesiumJS v1.143.
Quick Reference
快速参考
| Class | Purpose |
|---|---|
| Low-level glTF/GLB primitive; positioned via |
| Active animation instance on a model |
| Collection at |
| Named node with modifiable transform |
| Per-feature styling/picking for feature-ID models |
| Controls draft glTF edge-visibility rendering on Model/Cesium3DTileset |
| Billboard-based particle manager (fire, smoke, rain) |
| Single particle with position, velocity, life |
| Scheduled burst of particles |
| Emit within box volume / flat disk |
| Emit from cone tip / within sphere |
The Entity API exposes models through (see cesiumjs-entities). The Primitive API uses for full control over , animations, and node transforms.
ModelGraphicsModel.fromGltfAsyncmodelMatrix| 类 | 用途 |
|---|---|
| 底层glTF/GLB图元;通过 |
| 模型上的活跃动画实例 |
| 存储于 |
| 可修改变换的命名节点 |
| 支持Feature-ID模型的逐要素样式设置/拾取 |
| 控制Model/Cesium3DTileset的草案glTF边缘可见性渲染 |
| 基于公告板的粒子管理器(用于火焰、烟雾、雨水等效果) |
| 包含位置、速度、生命周期的单个粒子 |
| 按计划触发的粒子爆发效果 |
| 在立方体空间/平面圆盘内发射粒子 |
| 从圆锥尖端/球体内部发射粒子 |
Entity API 通过暴露模型(详见cesiumjs-entities)。Primitive API 使用以完全控制、动画和节点变换。
ModelGraphicsModel.fromGltfAsyncmodelMatrixLoading a glTF/GLB Model
加载glTF/GLB模型
Always use the async factory -- never call the constructor directly.
js
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 1.143 decodes automatically, including the
v1 attribute codec and 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.
KHR_meshopt_compressionCOLOR务必使用异步工厂方法——切勿直接调用构造函数。
js
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 1.143会自动解码,包括v1属性编解码器和过滤器。无需导入解码器或私有加载器工具。加载压缩glTF、CAD风格线/点/边或恒定LOD纹理时,请阅读REFERENCE.md获取完整的支持和创作矩阵。相同的加载器行为适用于3D Tiles内的glTF内容。
KHR_meshopt_compressionCOLORPositioned Model with Heading
设置朝向的定位模型
js
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);js
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, // 屏幕上永不小于128像素
maximumScale: 20000, // 限制minimumPixelSize的放大上限
scale: 2.0, // 统一缩放倍数
});
viewer.scene.primitives.add(model);Key Model.fromGltfAsync
Options
Model.fromGltfAsyncModel.fromGltfAsync
关键选项
Model.fromGltfAsync| Option | Type | Default |
|---|---|---|
| | required |
| | |
| | |
| | |
| | -- |
| | |
| | -- / |
| | |
| | |
| | |
| | |
| | -- |
| | -- |
| | |
| 选项 | 类型 | 默认值 |
|---|---|---|
| | 必填 |
| | |
| | |
| | |
| | -- |
| | |
| | -- / |
| | |
| | |
| | |
| | |
| | -- |
| | -- |
| | |
Readiness and Lifecycle
就绪状态与生命周期
fromGltfAsyncreadyEventboundingSpherejs
const model = await Model.fromGltfAsync({ url: "robot.glb" });
viewer.scene.primitives.add(model);
model.readyEvent.addEventListener(() => {
console.log("Bounding sphere:", model.boundingSphere);
});js
// Synchronous check
if (model.ready) { const bs = model.boundingSphere; }fromGltfAsyncboundingSpherereadyEventjs
const model = await Model.fromGltfAsync({ url: "robot.glb" });
viewer.scene.primitives.add(model);
model.readyEvent.addEventListener(() => {
console.log("包围球:", model.boundingSphere);
});js
// 同步检查
if (model.ready) { const bs = model.boundingSphere; }Animations
动画
Managed through ().
model.activeAnimationsModelAnimationCollection通过()管理动画。
model.activeAnimationsModelAnimationCollectionPlay by Name / Play All
按名称播放/播放全部
js
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 options: , , , , , , (custom time callback).
addindexreversestartTimestopTimedelayremoveOnStopanimationTimejs
model.readyEvent.addEventListener(() => {
// 单个动画
const anim = model.activeAnimations.add({
name: "Walk", // glTF动画名称
loop: Cesium.ModelAnimationLoop.REPEAT, // NONE | REPEAT | MIRRORED_REPEAT
multiplier: 1.0, // 播放速度(必须>0)
});
anim.start.addEventListener((m, a) => console.log(`已启动: ${a.name}`));
// 或一次性播放所有动画
model.activeAnimations.addAll({
loop: Cesium.ModelAnimationLoop.REPEAT,
multiplier: 0.5,
});
});addindexreversestartTimestopTimedelayremoveOnStopanimationTimeAnimation Events
动画事件
js
animation.start.addEventListener((model, animation) => { });
animation.update.addEventListener((model, animation, time) => { });
animation.stop.addEventListener((model, animation) => { });
// Collection-level
model.activeAnimations.animationAdded.addEventListener((model, anim) => { });js
model.activeAnimations.remove(animation); // remove one
model.activeAnimations.removeAll(); // remove alljs
animation.start.addEventListener((model, animation) => { });
animation.update.addEventListener((model, animation, time) => { });
animation.stop.addEventListener((model, animation) => { });
// 集合级事件
model.activeAnimations.animationAdded.addEventListener((model, anim) => { });js
model.activeAnimations.remove(animation); // 移除单个动画
model.activeAnimations.removeAll(); // 移除所有动画Model Nodes
模型节点
Override named node transforms for procedural animation (e.g., turret rotation).
js
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: (read-only), (read-only index), (boolean), (Matrix4 -- set to to restore original and re-enable glTF animations).
nameidshowmatrixundefined覆盖命名节点的变换,实现程序化动画(如炮塔旋转)。
js
model.readyEvent.addEventListener(() => {
const node = model.getNode("Turret");
node.matrix = Cesium.Matrix4.fromScale(
new Cesium.Cartesian3(5.0, 1.0, 1.0), node.matrix
);
});属性:(只读)、(只读索引)、(布尔值)、(Matrix4——设置为可恢复原始值并重新启用glTF动画)。
nameidshowmatrixundefinedColoring, Silhouettes, and Feature Picking
着色、轮廓与要素拾取
js
// 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;js
// 着色+轮廓
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;Edge Display Mode (Experimental, 1.142+)
边缘显示模式(实验性,1.142+)
For glTF assets using the draft extension,
controls whether extension-provided edges are hidden, composited
over surfaces, or rendered alone. Models without the extension are unaffected.
EXT_mesh_primitive_edge_visibilityEdgeDisplayModejs
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; // defaultWhen a glTF has or , picking returns a :
EXT_mesh_featuresEXT_structural_metadataModelFeaturejs
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);对于使用草案扩展的glTF资源,控制扩展提供的边缘是隐藏、叠加在表面上还是单独渲染。不支持该扩展的模型不受影响。
EXT_mesh_primitive_edge_visibilityEdgeDisplayModejs
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风格线框
model.edgeDisplayMode = EdgeDisplayMode.SURFACES_ONLY; // 默认值当glTF包含或时,拾取操作会返回:
EXT_mesh_featuresEXT_structural_metadataModelFeaturejs
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);Height Reference
高度参考
js
// 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: , , , , , , .
NONECLAMP_TO_GROUNDRELATIVE_TO_GROUNDCLAMP_TO_TERRAINRELATIVE_TO_TERRAINCLAMP_TO_3D_TILERELATIVE_TO_3D_TILEjs
// Primitive API -- 高度参考需要场景实例
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 },
});可选值:、、、、、、。
NONECLAMP_TO_GROUNDRELATIVE_TO_GROUNDCLAMP_TO_TERRAINRELATIVE_TO_TERRAINCLAMP_TO_3D_TILERELATIVE_TO_3D_TILEParticle Systems
粒子系统
ParticleSystemmodelMatrixemitterModelMatrixParticleSystemmodelMatrixemitterModelMatrixSmoke Trail
烟雾轨迹
js
import { ParticleSystem, CircleEmitter, Color, Cartesian2, Transforms, Cartesian3 } from "cesium";
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);js
import { ParticleSystem, CircleEmitter, Color, Cartesian2, Transforms, Cartesian3 } from "cesium";
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), // 像素尺寸
emitter: new CircleEmitter(2.0), // 半径(米)
modelMatrix: Transforms.eastNorthUpToFixedFrame(Cartesian3.fromDegrees(-75.157, 39.978)),
lifetime: 16.0,
loop: true,
});
viewer.scene.primitives.add(smokeSystem);Emitter Types
发射器类型
js
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 outjs
import { BoxEmitter, CircleEmitter, ConeEmitter, SphereEmitter } from "cesium";
new BoxEmitter(new Cesium.Cartesian3(10, 10, 10)); // 3D立方体,向外发射
new CircleEmitter(2.0); // 平面圆盘,沿+Z方向发射
new ConeEmitter(Cesium.Math.toRadians(30)); // 圆锥尖端,朝向底部发射
new SphereEmitter(5.0); // 球体,向外辐射发射Particle Bursts
粒子爆发
js
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);js
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, // 仅使用爆发效果
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);Update Callback (Gravity / Wind)
更新回调(重力/风力)
The runs per-particle per-frame for forces like gravity.
updateCallbackjs
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);updateCallbackjs
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);Attaching Particles to a Moving Model
将粒子附加到移动模型
Sync each frame via . Use for a local offset (e.g., exhaust pipe).
modelMatrixscene.preUpdateemitterModelMatrixjs
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());
});通过逐帧同步。使用设置本地偏移(如排气管位置)。
scene.preUpdatemodelMatrixemitterModelMatrixjs
const entity = viewer.entities.add({
position: sampledPosition,
orientation: new Cesium.VelocityOrientationProperty(sampledPosition),
model: { uri: "truck.glb", minimumPixelSize: 64 },
});
// 排气管的本地偏移
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());
});Canvas-Based Particle Images
基于Canvas的粒子图像
Generate particle textures dynamically instead of loading image files.
js
function createCircleImage() {
const c = document.createElement("canvas");
c.width = c.height = 20;
const ctx = c.getContext("2d");
ctx.beginPath();
ctx.arc(10, 10, 10, 0, Math.PI * 2);
ctx.fillStyle = "#fff";
ctx.fill();
return c;
}
// Pass canvas directly as image
new ParticleSystem({ image: createCircleImage(), /* ...other options */ });动态生成粒子纹理,而非加载图像文件。
js
function createCircleImage() {
const c = document.createElement("canvas");
c.width = c.height = 20;
const ctx = c.getContext("2d");
ctx.beginPath();
ctx.arc(10, 10, 10, 0, Math.PI * 2);
ctx.fillStyle = "#fff";
ctx.fill();
return c;
}
// 直接传入canvas作为图像
new ParticleSystem({ image: createCircleImage(), /* ...其他选项 */ });Entity API Model (ModelGraphics)
Entity API 模型(ModelGraphics)
For simpler use cases, add a model through the Entity API (see cesiumjs-entities for full coverage).
js
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;对于简单场景,可通过Entity API添加模型(完整说明详见cesiumjs-entities)。
js
const entity = viewer.entities.add({
name: "飞行器",
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;GPM Extension (NGA_gpm_local)
GPM扩展(NGA_gpm_local)
CesiumJS experimentally supports the NGA Geospatial Positioning Metadata glTF extension. Types: , , , , . Parsed automatically when loading a glTF with -- the API is experimental and subject to change.
AnchorPointDirectAnchorPointIndirectCorrelationGroupGltfGpmLocalSpdcfNGA_gpm_localCesiumJS实验性支持NGA地理空间定位元数据glTF扩展。类型包括:、、、、。加载包含的glTF时会自动解析——该API为实验性,可能随时变更。
AnchorPointDirectAnchorPointIndirectCorrelationGroupGltfGpmLocalSpdcfNGA_gpm_localPerformance Tips
性能优化技巧
- Use over
.glb-- binary format avoids extra HTTP requests and is smaller on the wire..gltf - Enable Draco compression () for 80-90% smaller meshes.
KHR_draco_mesh_compression - Use KTX2/Basis textures () for GPU-compressed textures; keep dimensions power-of-two.
KHR_texture_basisu - Set carefully -- large values force enlargement of distant models, increasing draw cost.
minimumPixelSize - Limit silhouettes -- extra rendering pass per silhouetted model; more than 256 may cause stencil artifacts.
- Reuse scratch objects -- avoid allocating every frame when syncing particle systems to moving entities.
Matrix4 - Keep emission rates low -- each particle is a billboard; rates above 200/s can hurt frame rate. Use bursts for short effects.
- Prefer pixel-sized particles (, default) -- meter-sized particles are expensive at close range.
sizeInMeters: false - Set finite on particle systems --
lifetime(default) prevents pool cleanup.Number.MAX_VALUE - Disable picking for decorations -- saves GPU memory on models that need no interaction.
allowPicking: false - Destroy when done -- then
viewer.scene.primitives.remove(model)to free WebGL resources.model.destroy()
- 优先使用而非
.glb——二进制格式避免额外HTTP请求,传输体积更小。.gltf - 启用Draco压缩()可使网格体积缩小80-90%。
KHR_draco_mesh_compression - 使用KTX2/Basis纹理()实现GPU压缩纹理;保持尺寸为2的幂次。
KHR_texture_basisu - 谨慎设置——过大的值会强制放大远处模型,增加绘制成本。
minimumPixelSize - 限制轮廓数量——每个带轮廓的模型会增加一次渲染通道;超过256个可能导致模板缓存 artifacts。
- 复用临时对象——同步粒子系统与移动实体时,避免每帧分配新对象。
Matrix4 - 降低发射速率——每个粒子都是一个公告板;速率超过200/秒会影响帧率。短效果使用爆发模式。
- 优先使用像素尺寸粒子(,默认值)——米级粒子在近距离时性能开销大。
sizeInMeters: false - 为粒子系统设置有限——默认值
lifetime会阻止对象池清理。Number.MAX_VALUE - 禁用装饰性模型的拾取——可节省无需交互的模型的GPU内存。
allowPicking: false - 使用完毕后销毁——调用后再执行
viewer.scene.primitives.remove(model)以释放WebGL资源。model.destroy()
See Also
相关链接
- cesiumjs-custom-shader -- GLSL authoring for (struct reference, feature IDs, metadata, vertex displacement)
Model.customShader - cesiumjs-materials-shaders -- ImageBasedLighting, post-processing stages for models
- cesiumjs-entities -- Entity API ModelGraphics, data sources, time-dynamic properties
- cesiumjs-3d-tiles -- Cesium3DTileset (uses Model internally), clipping, styling
- cesiumjs-custom-shader——为编写GLSL代码(结构体参考、要素ID、元数据、顶点位移)
Model.customShader - cesiumjs-materials-shaders——模型的基于图像的光照、后处理阶段
- cesiumjs-entities——Entity API的ModelGraphics、数据源、时间动态属性
- cesiumjs-3d-tiles——Cesium3DTileset(内部使用Model)、裁剪、样式设置