Scene. The geometry can be from a single GeometryInstance
如下文例1所示,或从一系列实例来看,即使几何不同
几何类型, e.g .,一个 RectangleGeometry ,一个 EllipsoidGeometry ,如代码例2所示.
A primitive combines geometry instances with an Appearance that describes the full shading, including
Material and RenderState. Roughly, the geometry instance defines the structure and placement,
而外观则定义了视觉特征. 调和几何和外观,让我们可以混合
并匹配其中的大部分,并添加一个新的几何或外观,彼此独立.
将多个实例合并成一个原始的,叫做批量,大大改善了静态数据的性能.
Instances can be individually picked; Scene#pick returns their GeometryInstance#id. Using
per-instance appearances like PerInstanceColorAppearance, each instance can also have a unique color.
Geometry 可以创建并分批在网络工人上或主线上. 前两个例子
显示将使用几何描述在网络工作者上创建的几何。 第三个实例
通过明确调用 NT 0 createGeometry NT 1 方法来显示如何在主线上创建几何.
| Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
optional
下列属性的对象 :
|
Examples:
// 1. Draw a translucent ellipse on the surface with a checkerboard pattern
const instance = new Cesium.GeometryInstance({
geometry : new Cesium.EllipseGeometry({
center : Cesium.Cartesian3.fromDegrees(-100.0, 20.0),
semiMinorAxis : 500000.0,
semiMajorAxis : 1000000.0,
rotation : Cesium.Math.PI_OVER_FOUR,
vertexFormat : Cesium.VertexFormat.POSITION_AND_ST
}),
id : 'object returned when this instance is picked and to get/set per-instance attributes'
});
scene.primitives.add(new Cesium.Primitive({
geometryInstances : instance,
appearance : new Cesium.EllipsoidSurfaceAppearance({
material : Cesium.Material.fromType('Checkerboard')
})
}));
// 2. Draw different instances each with a unique color
const rectangleInstance = new Cesium.GeometryInstance({
geometry : new Cesium.RectangleGeometry({
rectangle : Cesium.Rectangle.fromDegrees(-140.0, 30.0, -100.0, 40.0),
vertexFormat : Cesium.PerInstanceColorAppearance.VERTEX_FORMAT
}),
id : 'rectangle',
attributes : {
color : new Cesium.ColorGeometryInstanceAttribute(0.0, 1.0, 1.0, 0.5)
}
});
const ellipsoidInstance = new Cesium.GeometryInstance({
geometry : new Cesium.EllipsoidGeometry({
radii : new Cesium.Cartesian3(500000.0, 500000.0, 1000000.0),
vertexFormat : Cesium.VertexFormat.POSITION_AND_NORMAL
}),
modelMatrix : Cesium.Matrix4.multiplyByTranslation(Cesium.Transforms.eastNorthUpToFixedFrame(
Cesium.Cartesian3.fromDegrees(-95.59777, 40.03883)), new Cesium.Cartesian3(0.0, 0.0, 500000.0), new Cesium.Matrix4()),
id : 'ellipsoid',
attributes : {
color : Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.AQUA)
}
});
scene.primitives.add(new Cesium.Primitive({
geometryInstances : [rectangleInstance, ellipsoidInstance],
appearance : new Cesium.PerInstanceColorAppearance()
}));
// 3. Create the geometry on the main thread.
scene.primitives.add(new Cesium.Primitive({
geometryInstances : new Cesium.GeometryInstance({
geometry : Cesium.EllipsoidGeometry.createGeometry(new Cesium.EllipsoidGeometry({
radii : new Cesium.Cartesian3(500000.0, 500000.0, 1000000.0),
vertexFormat : Cesium.VertexFormat.POSITION_AND_NORMAL
})),
modelMatrix : Cesium.Matrix4.multiplyByTranslation(Cesium.Transforms.eastNorthUpToFixedFrame(
Cesium.Cartesian3.fromDegrees(-95.59777, 40.03883)), new Cesium.Cartesian3(0.0, 0.0, 500000.0), new Cesium.Matrix4()),
id : 'ellipsoid',
attributes : {
color : Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.AQUA)
}
}),
appearance : new Cesium.PerInstanceColorAppearance(),
asynchronous : false
}));
See:
Members
true, each geometry instance will only be pickable with Scene#pick. When false, GPU memory is saved. *
-
Default Value:
true
appearance : Appearance
Appearance used to shade this primitive. Each geometry
实例以相同的外观遮蔽。 一些外表,比如说
PerInstanceColorAppearance allow giving each instance unique
properties.
-
Default Value:
undefined
-
Default Value:
true
-
Default Value:
true
true, the renderer frustum culls and horizon culls the primitive's commands
依据其范围。 设定为 NT 0 false NT 1 ,以获得小的性能收益
如果你手动抚摸原始人.
-
Default Value:
true
绘制原始中每个绘图命令的边框.
-
Default Value:
false
depthFailAppearance : Appearance
Appearance 在深度测试失败时用来遮蔽这个原始的. 每个几何
实例以相同的外观遮蔽。 一些外表,比如说
PerInstanceColorAppearance allow giving each instance unique
properties.
当使用一个需要色彩属性的外观时,比如PerInstance ColorAppearance, 添加深度FailColor / 内置属性.
需要 EXT frag 深度 WebGL 扩展以正确渲染 。 如果不支持扩展, 可能还有文物.
-
Default Value:
undefined
readonly geometryInstances : Array.<GeometryInstance>|GeometryInstance
true when the primitive is constructed.
原始化后改变这个属性没有效果.
-
Default Value:
undefined
-
Default Value:
false
modelMatrix : Matrix4
Transforms.eastNorthUpToFixedFrame.
此属性仅以3D 模式支持 .
-
Default Value:
Matrix4.IDENTITY
Example:
const origin = Cesium.Cartesian3.fromDegrees(-95.0, 40.0, 200000.0);
p.modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(origin);
Primitive#update
is called.
Example:
// Wait for a primitive to become ready before accessing attributes
const removeListener = scene.postRender.addEventListener(() => {
if (!frustumPrimitive.ready) {
return;
}
const attributes = primitive.getGeometryInstanceAttributes('an id');
attributes.color = Cesium.ColorGeometryInstanceAttribute.toValue(Cesium.Color.AQUA);
removeListener();
});
true, the primitive does not keep a reference to the input geometryInstances to save memory.
-
Default Value:
true
shadows : ShadowMode
-
Default Value:
ShadowMode.DISABLED
-
Default Value:
true
-
Default Value:
true
Methods
Once an object is destroyed, it should not be used; calling any function other than
isDestroyed will result in a DeveloperError exception. Therefore,
assign the return value (undefined) to the object as done in the example.
Throws:
-
DeveloperError : This object was destroyed, i.e., destroy() was called.
Example:
e = e && e.destroy();
See:
GeometryInstance.
| Name | Type | Description |
|---|---|---|
id |
* |
The id of the GeometryInstance. |
Returns:
Throws:
-
DeveloperError : must call update before calling getGeometryInstanceAttributes.
Example:
const attributes = primitive.getGeometryInstanceAttributes('an id');
attributes.color = Cesium.ColorGeometryInstanceAttribute.toValue(Cesium.Color.AQUA);
attributes.show = Cesium.ShowGeometryInstanceAttribute.toValue(true);
attributes.distanceDisplayCondition = Cesium.DistanceDisplayConditionGeometryInstanceAttribute.toValue(100.0, 10000.0);
attributes.offset = Cesium.OffsetGeometryInstanceAttribute.toValue(Cartesian3.IDENTITY);
If this object was destroyed, it should not be used; calling any function other than
isDestroyed will result in a DeveloperError exception.
Returns:
true if this object was destroyed; otherwise, false.
See:
Viewer or CesiumWidget render the scene to
获得使这个原始化所需的绘图命令.
不要直接调用此函数 。 记录下来的只是 列出场景拍摄时可能宣传的例外情况:
Throws:
-
DeveloperError : All instance geometries must have the same primitiveType.
-
DeveloperError : Appearance and material have a uniform with the same name.
-
DeveloperError : Primitive.modelMatrix is only supported in 3D mode.
-
RuntimeError : Vertex texture fetch support is required to render primitives with per-instance attributes. The maximum number of vertex texture image units must be greater than zero.