材质通过漫反射、镜面反射、
Normal、Emission 和 Alpha 组件。这些值是使用
名为 Fabric 的 JSON 架构,它被解析并组装成 glsl 着色器代码
幕后花絮。查看 wiki 页面
了解有关 Fabric 的更多详细信息。
基础材料类型及其制服:
基础材料类型及其制服:
- Color
color
: RGBA color 对象。- Image
image
: 图像路径。repeat
: 具有 x 和 y 值的对象,用于指定重复图像的次数。- DiffuseMap
image
: 图像路径。channels
: 包含 r、g、b 和 a 的任意组合的三个字符串,用于选择所需的图像通道。repeat
: 具有 x 和 y 值的对象,用于指定重复图像的次数。- AlphaMap
image
: 图像路径。channel
: 一个包含 r、g、b 或 a 的字符串,用于选择所需的图像通道。repeat
: 具有 x 和 y 值的对象,用于指定重复图像的次数。- SpecularMap
image
: 图像路径。channel
: 一个包含 r、g、b 或 a 的字符串,用于选择所需的图像通道。repeat
: 具有 x 和 y 值的对象,用于指定重复图像的次数。- EmissionMap
image
: 图像路径。channels
: 包含 r、g、b 和 a 的任意组合的三个字符串,用于选择所需的图像通道。repeat
: 具有 x 和 y 值的对象,用于指定重复图像的次数。- BumpMap
image
: 图像路径。channel
: 一个包含 r、g、b 或 a 的字符串,用于选择所需的图像通道。repeat
: 具有 x 和 y 值的对象,用于指定重复图像的次数。strength
: “凹凸强度”(Bump strength)值介于 0.0 和 1.0 之间,其中 0.0 是小凹凸,1.0 是大凹凸。- NormalMap
image
: 图像路径。channels
: 包含 r、g、b 和 a 的任意组合的三个字符串,用于选择所需的图像通道。repeat
: 具有 x 和 y 值的对象,用于指定重复图像的次数。strength
: “凹凸强度”(Bump strength)值介于 0.0 和 1.0 之间,其中 0.0 表示小凹凸,1.0 表示大凹凸.- Grid
color
:整个材质的 RGBA 颜色对象。cellAlpha
:网格线之间单元格的 Alpha 值。 这将与 color.alpha 结合使用。lineCount
:具有 x 和 y 值的对象,分别指定列数和行数。lineThickness
:具有 x 和 y 值的对象,用于指定网格线的粗细(如果可用,则以像素为单位)。lineOffset
:具有 x 和 y 值的对象,指定网格线的偏移量(范围为 0 到 1)。- Stripe
horizontal
:确定条带是水平还是垂直的布尔值。evenColor
:条带的第一种颜色的 rgba 颜色对象。oddColor
:条带的第二种颜色的 rgba 颜色对象。offset
:控制在图案中的哪个点开始绘制的数字;0.0 是偶数颜色的开始,1.0 是奇数颜色的开始,2.0 是偶数颜色,任何倍数或分数值介于两者之间。repeat
:控制条纹总数的数字,一半是浅色,一半是深色。- Checkerboard
lightColor
:棋盘格的光交替颜色的 rgba 颜色对象。darkColor
:棋盘格的深色交替颜色的 rgba 颜色对象。repeat
:具有 x 和 y 值的对象,分别指定列数和行数。- Dot
lightColor
:点颜色的 rgba 颜色对象。darkColor
:背景色的 rgba 颜色对象。repeat
:具有 x 和 y 值的对象,分别指定点的列数和行数。- Water
baseWaterColor
:rgba 颜色对象水的底色。blendColor
:从水区域混合到非水区域时使用的 rgba 颜色对象。specularMap
:用于指示水区域的单通道纹理。normalMap
:水法线扰动的法线贴图。frequency
:控制波数的数字。animationSpeed
:控制水的动画速度的数字。amplitude
:控制水波振幅的数字。specularIntensity
:控制镜面反射强度的数字。- RimLighting (边缘照明)
颜色
:漫反射颜色和 Alpha。rimColor
:轮辋的漫反射颜色和 Alpha。width
:确定轮辋宽度的数字。- 淡化
fadeInColor
:漫反射颜色和 Alpha时间
fadeOutColor
:从时间
开始的maximumDistance
处漫反射颜色和 AlphamaximumDistance
:介于 0.0 和 1.0 之间的数字,其中fadeInColor
变为fadeOutColor
。值为 0.0 时,整个材质的颜色为fadeOutColor
,值为 1.0 时,整个材质的颜色为fadeInColor
repeat
: 如果淡入淡出应该包裹在纹理坐标周围,则为 true。fadeDirection
:具有 x 和 y 值的对象,用于指定淡化是否应在 x 和 y 方向上。time
:x 和 y 值介于fadeInColor
位置的 0.0 和 1.0 之间的对象- PolylineArrow
颜色
:漫反射颜色和 Alpha。- 多段线短划线
color
:线条的颜色。gapColor
:线条中间隙的颜色。dashLength
:虚线长度(以像素为单位)。dashPattern
:线条的 16 位点画模式..- PolylineGlow
color
:线上发光的颜色和最大 Alpha。glowPower
:发光的强度,占总线宽的百分比(小于 1.0)。TaperPower
:锥度效应的强度,占总线长的百分比。 如果为 1.0 或更高,则不使用锥化效果。- PolylineOutline
color
:线条内部的漫反射颜色和 Alpha。outlineColor
:轮廓的漫反射颜色和 Alpha。outlineWidth
:轮廓的宽度(以像素为单位)。- ElevationContour
color
:等值线的颜色和 Alpha。spacing
:等值线的间距,以米为单位。width
:指定网格线宽度(以像素为单位)的数字。- ElevationRamp
image
:用于为地形着色的 Color Ramp 图像。minimumHeight
:渐变的最小高度。maximumHeight
:渐变的最大高度。- SlopeRamp 坡道
image
:用于按坡度为地形着色的 Color Ramp 图像。- AspectRamp
image
:用于按坡向对地形进行着色的 Color Ramp 图像。- ElevationBand (高程带)
heights
:从最低到最高排序的高度图像。colors
:相应高度的颜色图像。- 水面罩
waterColor
:水覆盖区域的漫反射颜色和 Alpha。landColor
:土地覆盖区域的漫反射颜色和 Alpha。
Name | Type | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
optional
对象,具有以下属性:
|
Throws:
-
DeveloperError : fabric: uniform has invalid type.
-
DeveloperError : fabric: uniforms and materials cannot share the same property.
-
DeveloperError : fabric: cannot have source and components in the same部分。
-
DeveloperError : fabric: property name is not valid. It should be 'type', 'materials', 'uniforms', 'components', or 'source'.
-
DeveloperError : fabric: property name is not valid. It should be 'diffuse', 'specular', 'shininess', 'normal', 'emission', or 'alpha'.
-
DeveloperError : strict: shader source does not use string.
-
DeveloperError : strict: shader source does not use uniform.
-
DeveloperError : strict: shader source does not use material.
- Fabric wiki page for a more detailed options of Fabric.
Example:
// Create a color material with fromType:
polygon.material = Cesium.Material.fromType('Color');
polygon.material.uniforms.color = new Cesium.Color(1.0, 1.0, 0.0, 1.0);
// Create the default material:
polygon.material = new Cesium.Material();
// Create a color material with full Fabric notation:
polygon.material = new Cesium.Material({
fabric: {
type: 'Color',
uniforms: {
color: new Cesium.Color(1.0, 1.0, 0.0, 1.0)
}
}
});
Demo:
See:
Members
获取 Alpha 贴图材质的名称。
获取坡向渐变材质的名称。
获取凹凸贴图材质的名称。
获取棋盘材质的名称。
获取颜色材质的名称。
获取或设置默认 Cube Map Texture Uniform 值。
获取或设置Default texture uniform 值。
获取 diffuce 贴图材质的名称。
获取点材质的名称。
获取标高带材质的名称。
获取高程等值线材质的名称。
获取高程等值线材质的名称。
获取 emmision 贴图材质的名称。
获取淡化材质的名称。
获取栅格材质的名称。
获取图像素材的名称。
获取法线贴图材质的名称。
获取多段线箭头材质的名称。
获取多段线发光材质的名称。
获取多段线发光材质的名称。
获取多段线轮廓材质的名称。
获取 rim lighting 材质的名称。
获取坡度坡度材质的名称。
获取镜面反射贴图材质的名称。
获取条带材料的名称。
获取水遮罩材质的名称。
获取水材质的名称。
将子材质名称映射到材质对象。
-
Default Value:
undefined
此材质的 glsl 着色器源。
-
Default Value:
undefined
当
true
或返回 true
的函数时,
几何体应显示为半透明。
-
Default Value:
undefined
材质类型。可以是现有类型或新类型。如果未在 fabric 中指定 type,则 type 为 GUID。
-
Default Value:
undefined
将 uniform 名称映射到其值。
-
Default Value:
undefined
Methods
static Cesium.Material.fromType(type, uniforms) → Material
使用现有材质类型创建新材质。
简写: new Material({fabric : {type : type}});
简写: new Material({fabric : {type : type}});
Name | Type | Description |
---|---|---|
type |
string | 基础材质类型。 |
uniforms |
object | optional 默认 uniform 的覆盖。 |
Returns:
新的材质对象。
Throws:
-
DeveloperError : material with that type does not exist.
Example:
const material = Cesium.Material.fromType('Color', {
color: new Cesium.Color(1.0, 0.0, 0.0, 1.0)
});
销毁此对象持有的 WebGL 资源。 销毁对象允许确定性
释放 WebGL 资源,而不是依赖垃圾回收器来销毁这个对象。
一旦对象被销毁,就不应该使用它;调用
一旦对象被销毁,就不应该使用它;调用
isDestroyed
将导致 DeveloperError
异常。 因此
将返回值 (undefined
) 分配给对象,如示例中所示。
Throws:
-
DeveloperError : 这个物体被摧毁了,destroy().
Example:
material = material && material.destroy();
See:
Returns:
如果此对象被销毁,则为 True;否则为 false。
See:
获取是否 这种材料是半透明的。
Returns:
如果此材质是半透明的,则为
true
,否则为false
。