材质(Material)通过漫反射、镜面反射、
法线、自发光和 alpha 组件的组合来定义表面外观。这些值是使用一种
称为 Fabric 的 JSON 模式指定的,该模式会被解析并组装成 glsl 着色器代码
(在幕后完成)。有关 Fabric 的更多详细信息,请查看
wiki 页面
基础材质类型及其 uniforms:
基础材质类型及其 uniforms:
- Color
color:rgba 颜色对象。- Image
image: path to image.repeat: Object with x and y values specifying the number of times to repeat the image.- DiffuseMap
image: path to image.channels: Three character string containing any combination of r, g, b, and a for selecting the desired image channels.repeat: Object with x and y values specifying the number of times to repeat the image.- AlphaMap
image: path to image.channel: One character string containing r, g, b, or a for selecting the desired image channel.repeat: Object with x and y values specifying the number of times to repeat the image.- SpecularMap
image: path to image.channel: One character string containing r, g, b, or a for selecting the desired image channel.repeat: Object with x and y values specifying the number of times to repeat the image.- EmissionMap
image: path to image.channels: Three character string containing any combination of r, g, b, and a for selecting the desired image channels.repeat: Object with x and y values specifying the number of times to repeat the image.- BumpMap
image: path to image.channel: One character string containing r, g, b, or a for selecting the desired image channel.repeat: Object with x and y values specifying the number of times to repeat the image.strength: Bump strength value between 0.0 and 1.0 where 0.0 is small bumps and 1.0 is large bumps.- NormalMap
image: path to image.channels: Three character string containing any combination of r, g, b, and a for selecting the desired image channels.repeat: Object with x and y values specifying the number of times to repeat the image.strength: Bump strength value between 0.0 and 1.0 where 0.0 is small bumps and 1.0 is large bumps.- Grid
color: rgba color object for the whole material.cellAlpha: Alpha value for the cells between grid lines. This will be combined with color.alpha.lineCount: Object with x and y values specifying the number of columns and rows respectively.lineThickness: Object with x and y values specifying the thickness of grid lines (in pixels where available).lineOffset: Object with x and y values specifying the offset of grid lines (range is 0 to 1).- Stripe
horizontal: Boolean that determines if the stripes are horizontal or vertical.evenColor: rgba color object for the stripe's first color.oddColor: rgba color object for the stripe's second color.offset: Number that controls at which point into the pattern to begin drawing; with 0.0 being the beginning of the even color, 1.0 the beginning of the odd color, 2.0 being the even color again, and any multiple or fractional values being in between.repeat: Number that controls the total number of stripes, half light and half dark.- Checkerboard
lightColor: rgba color object for the checkerboard's light alternating color.darkColor: rgba color object for the checkerboard's dark alternating color.repeat: Object with x and y values specifying the number of columns and rows respectively.- Dot
lightColor: rgba color object for the dot color.darkColor: rgba color object for the background color.repeat: Object with x and y values specifying the number of columns and rows of dots respectively.- Water
baseWaterColor: rgba color object base color of the water.blendColor: rgba color object used when blending from water to non-water areas.specularMap: Single channel texture used to indicate areas of water.normalMap: Normal map for water normal perturbation.frequency: Number that controls the number of waves.animationSpeed: Number that controls the animations speed of the water.amplitude: Number that controls the amplitude of water waves.specularIntensity: Number that controls the intensity of specular reflections.- RimLighting
color: diffuse color and alpha.rimColor: diffuse color and alpha of the rim.width: Number that determines the rim's width.- Fade
fadeInColor: diffuse color and alpha attimefadeOutColor: diffuse color and alpha atmaximumDistancefromtimemaximumDistance: Number between 0.0 and 1.0 where thefadeInColorbecomes thefadeOutColor. A value of 0.0 gives the entire material a color offadeOutColorand a value of 1.0 gives the the entire material a color offadeInColorrepeat: true if the fade should wrap around the texture coodinates.fadeDirection: Object with x and y values specifying if the fade should be in the x and y directions.time: Object with x and y values between 0.0 and 1.0 of thefadeInColorposition- PolylineArrow
color: diffuse color and alpha.- PolylineDash
color: color for the line.gapColor: color for the gaps in the line.dashLength: Dash length in pixels.dashPattern: The 16 bit stipple pattern for the line..- PolylineGlow
color: color and maximum alpha for the glow on the line.glowPower: strength of the glow, as a percentage of the total line width (less than 1.0).taperPower: strength of the tapering effect, as a percentage of the total line length. If 1.0 or higher, no taper effect is used.- PolylineOutline
color: diffuse color and alpha for the interior of the line.outlineColor: diffuse color and alpha for the outline.outlineWidth: width of the outline in pixels.- ElevationContour
color: color and alpha for the contour line.spacing: spacing for contour lines in meters.width: Number specifying the width of the grid lines in pixels.- ElevationRamp
image: color ramp image to use for coloring the terrain.minimumHeight: minimum height for the ramp.maximumHeight: maximum height for the ramp.- SlopeRamp
image: color ramp image to use for coloring the terrain by slope.- AspectRamp
image: color ramp image to use for color the terrain by aspect.- ElevationBand
heights: image of heights sorted from lowest to highest.colors: image of colors at the corresponding heights.- WaterMask
waterColor: diffuse color and alpha for the areas covered by water.landColor: diffuse color and alpha for the areas covered by land.
| Name | Type | Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
optional
包含以下属性的对象:
|
Throws:
-
DeveloperError : fabric:uniform 的类型无效。
-
DeveloperError : fabric:uniforms 和 materials 不能共享同一个属性。
-
DeveloperError : fabric:同一节中不能同时包含 source 和 components。
-
DeveloperError : fabric:属性名无效。应为 'type'、'materials'、'uniforms'、'components' 或 'source'。
-
DeveloperError : fabric:属性名无效。应为 'diffuse'、'specular'、'shininess'、'normal'、'emission' 或 'alpha'。
-
DeveloperError : strict:着色器源代码未使用字符串。
-
DeveloperError : strict:着色器源代码未使用 uniform。
-
DeveloperError : strict:着色器源代码未使用 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 贴图材质的名称。
获取 aspect ramp 材质的名称。
获取凹凸贴图材质的名称。
获取棋盘格材质的名称。
获取颜色材质的名称。
获取或设置默认的立方体贴图纹理 uniform 值。
获取或设置默认的纹理 uniform 值。
获取漫反射贴图材质的名称。
获取点材质的名称。
获取高程带材质的名称。
获取高程等值线材质的名称。
获取高程等值线材质的名称。
获取自发光贴图材质的名称。
获取淡入淡出材质的名称。
获取网格材质的名称。
获取图像材质的名称。
获取法线贴图材质的名称。
获取折线箭头材质的名称。
获取折线发光材质的名称。
获取折线发光材质的名称。
获取折线轮廓材质的名称。
获取边缘光照材质的名称。
获取坡度渐变材质的名称。
获取高光贴图材质的名称。
获取条纹材质的名称。
获取水面掩膜材质的名称。
获取水材质的名称。
magnificationFilter : TextureMagnificationFilter
要应用于此材质纹理的
TextureMagnificationFilter。
-
Default Value:
TextureMagnificationFilter.LINEAR
将子材质名称映射到 Material 对象。
-
Default Value:
undefined
minificationFilter : TextureMinificationFilter
要应用于此材质纹理的
TextureMinificationFilter。
-
Default Value:
TextureMinificationFilter.LINEAR
此材质的 glsl 着色器源代码。
-
Default Value:
undefined
当为
true 或返回 true 的函数时,
几何体预计会呈现半透明效果。
-
Default Value:
undefined
材质类型。可以是现有类型或新类型。如果在 fabric 中未指定类型,则类型为 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 对默认 uniforms 的覆盖。 |
Returns:
新的材质对象。
Throws:
-
DeveloperError : 不存在该类型的材质。
Example:
const material = Cesium.Material.fromType('Color', {
color: new Cesium.Color(1.0, 0.0, 0.0, 1.0)
});
static Cesium.Material.fromTypeAsync(type, uniforms) → Promise.<Material>
使用现有材质类型创建新材质,并返回一个 promise,当
该材质的所有资源都已加载完成时兑现。
| Name | Type | Description |
|---|---|---|
type |
string | 基础材质类型。 |
uniforms |
object | optional 对默认 uniforms 的覆盖。 |
Returns:
一个当所有资源加载完成时兑现为新的材质对象的 promise。
Throws:
-
DeveloperError : 不存在该类型的材质。
Example:
const material = await Cesium.Material.fromTypeAsync('Image', {
image: '../Images/Cesium_Logo_overlay.png'
});
销毁此对象持有的 WebGL 资源。销毁对象可以确定性地
释放 WebGL 资源,而不是依赖垃圾回收器来销毁此对象。
一旦对象被销毁,就不应再使用它;调用除
一旦对象被销毁,就不应再使用它;调用除
isDestroyed 之外的任何函数都会导致 DeveloperError 异常。因此,
应将返回值(undefined)赋给该对象,如示例所示。
Throws:
-
DeveloperError : 此对象已被销毁,即调用了 destroy()。
Example:
material = material && material.destroy();
See:
Returns:
如果此对象已被销毁则为 true,否则为 false。
See:
获取此材质是否半透明。
Returns:
true 如果此材质是半透明的,否则为 false。
