Material

new Cesium.Material(options)



材质通过漫反射、镜面反射和, 法线、发射和α分量。这些值是使用 JSON模式称为Fabric,它被解析并组装成glsl着色器代码 在幕后。看看wiki page 有关面料的详细信息。 基材类型及其制服:
  • Color
    • color: rgba color object.
  • 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.
    • normalMap: Normal map for water normal perturbation.
    • 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 at time
    • fadeOutColor: diffuse color and alpha at maximumDistance from time
    • maximumDistance: Number between 0.0 and 1.0 where the fadeInColor becomes the fadeOutColor. A value of 0.0 gives the entire material a color of fadeOutColor and a value of 1.0 gives the the entire material a color of fadeInColor
    • repeat: 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 the fadeInColor position
  • 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.
Name Type Description
options Object optional 具有以下属性的对象:
Name Type Default Description
strict Boolean false optional 对通常被忽略的问题抛出错误,包括未使用的制服或材料。
translucent Boolean | function true optionaltrue或返回true的函数时,几何图形 用这种材料预计会显得半透明。
minificationFilter TextureMinificationFilter TextureMinificationFilter.LINEAR optional 应用于此材质纹理的TextureMinificationFilter
magnificationFilter TextureMagnificationFilter TextureMagnificationFilter.LINEAR optional 应用于此材质纹理的TextureMagnificationFilter
fabric Object 用于生成材质的fabric JSON。
Throws:
  • DeveloperError :fabric:uniform的类型无效。
  • DeveloperError :面料:制服和材料不能共享同一属性。
  • DeveloperError :fabric:不能在同一节中包含源和组件。
  • DeveloperError :fabric:属性名无效。它应该是“类型”、“材料”、“制服”、“组件”或“来源”。
  • DeveloperError :fabric:属性名无效。它应该是“漫反射”、“镜面反射”、“反光度”、“法线”、“发射”或“阿尔法”。
  • DeveloperError :strict:着色器源不使用字符串。
  • DeveloperError :strict:shader source不使用uniform。
  • DeveloperError :strict:着色器源不使用材质。
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

static readonly Cesium.Material.AlphaMapType : String

获取alpha贴图材质的名称。

static readonly Cesium.Material.AspectRampMaterialType : String

获取目标渐变材质的名称。

static readonly Cesium.Material.BumpMapType : String

获取凹凸贴图材质的名称。

static readonly Cesium.Material.CheckerboardType : String

获取棋盘材质的名称。

static readonly Cesium.Material.ColorType : String

获取颜色材质的名称。

static Cesium.Material.DefaultCubeMapId : String

获取或设置默认的多维数据集贴图纹理统一值。

static Cesium.Material.DefaultImageId : String

获取或设置默认纹理统一值。

static readonly Cesium.Material.DiffuseMapType : String

获取diffuce贴图材质的名称。

static readonly Cesium.Material.DotType : String

获取点材质的名称。

static readonly Cesium.Material.ElevationContourType : String

获取立面轮廓材质的名称。

static readonly Cesium.Material.ElevationRampType : String

获取立面轮廓材质的名称。

static readonly Cesium.Material.EmissionMapType : String

获取emmision贴图材质的名称。

static readonly Cesium.Material.FadeType : String

获取淡入淡出材质的名称。

static readonly Cesium.Material.GridType : String

获取栅格材质的名称。

static readonly Cesium.Material.ImageType : String

获取图像材质的名称。

static readonly Cesium.Material.NormalMapType : String

获取法线贴图材质的名称。

static readonly Cesium.Material.PolylineArrowType : String

获取折线箭头材质的名称。

static readonly Cesium.Material.PolylineDashType : String

获取折线发光材质的名称。

static readonly Cesium.Material.PolylineGlowType : String

获取折线发光材质的名称。

static readonly Cesium.Material.PolylineOutlineType : String

获取折线轮廓材质的名称。

static readonly Cesium.Material.RimLightingType : String

获取边缘照明材质的名称。

static readonly Cesium.Material.SlopeRampMaterialType : String

获取坡度渐变材质的名称。

static readonly Cesium.Material.SpecularMapType : String

获取高光贴图材质的名称。

static readonly Cesium.Material.StripeType : String

获取条纹材质的名称。

static readonly Cesium.Material.WaterType : String

获取水材质的名称。

materials : Object

将子材质名称映射到材质对象。
Default Value: undefined

shaderSource : String

此材质的glsl着色器源。
Default Value: undefined

translucent : Boolean|function

true或返回true的函数时, 几何体看起来是半透明的。
Default Value: undefined

type : String

材料类型。可以是现有类型或新类型。如果结构中未指定类型,则类型为GUID。
Default Value: undefined

uniforms : Object

将统一名称映射到它们的值。
Default Value: undefined

Methods

static Cesium.Material.fromType(type, uniforms)Material



使用现有材质类型创建新材质。 简写:新材料({fabric:{type:type}});
Name Type Description
type String 基材类型。
uniforms Object optional 默认制服的覆盖。
Returns:
新材质对象。
Throws:
Example:
var material = Cesium.Material.fromType('Color', {
    color : new Cesium.Color(1.0, 0.0, 0.0, 1.0)
});


销毁此对象持有的WebGL资源。销毁一个对象允许确定性 释放WebGL资源,而不是依赖垃圾回收器销毁此对象。 一旦一个对象被销毁,就不应该使用它;调用除 isDestroyed将导致DeveloperError异常。因此, 如示例所示,将返回值(undefined)分配给对象。
Throws:
Example:
material = material && material.destroy();
See:

isDestroyed()Boolean



如果此对象已销毁,则返回true;否则返回false。 如果此对象已被销毁,则不应使用它;调用除 isDestroyed将导致DeveloperError异常。
Returns:
如果此对象被销毁,则为True;否则为false。
See:

isTranslucent()Boolean

不管材料是否透明。
Returns:
如果这种材料是半透明的,则为true,否则为false