English中文

Material

new Cesium.Material(options)

材质通过漫反射、镜面反射、法线、发射和 alpha 分量的组合来定义表面外观。这些值是使用名为 Fabric 的 JSON 模式指定的,该模式在幕后被解析并组装成 glsl 着色器代码。查看 A Material defines surface appearance through a combination of diffuse, specular, normal, emission, and alpha components. These values are specified using a JSON schema called Fabric which gets parsed and assembled into glsl shader code behind-the-scenes. Check out the wiki page 有关面料的更多详细信息。 for more details on Fabric.

基材类型及其制服: Base material types and their uniforms:
  • Color
    • color:rgba 颜色对象。 : rgba color object.
  • Image
    • image:图像的路径。 : path to image.
    • repeat:具有 x 和 y 值的对象,指定重复图像的次数。 : 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:具有 x 和 y 值的对象,指定重复图像的次数。 : Object with x and y values specifying the number of times to repeat the image.
  • AlphaMap
    • image:图像的路径。 : path to image.
    • channel:包含r、g、b或a的一个字符串,用于选择所需的图像通道。 : One character string containing r, g, b, or a for selecting the desired image channel.
    • repeat:具有 x 和 y 值的对象,指定重复图像的次数。 : Object with x and y values specifying the number of times to repeat the image.
  • SpecularMap
    • image:图像的路径。 : path to image.
    • channel:包含r、g、b或a的一个字符串,用于选择所需的图像通道。 : One character string containing r, g, b, or a for selecting the desired image channel.
    • repeat:具有 x 和 y 值的对象,指定重复图像的次数。 : 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:具有 x 和 y 值的对象,指定重复图像的次数。 : Object with x and y values specifying the number of times to repeat the image.
  • BumpMap
    • image:图像的路径。 : path to image.
    • channel:包含r、g、b或a的一个字符串,用于选择所需的图像通道。 : One character string containing r, g, b, or a for selecting the desired image channel.
    • repeat:具有 x 和 y 值的对象,指定重复图像的次数。 : Object with x and y values specifying the number of times to repeat the image.
    • strength:凹凸强度值介于 0.0 和 1.0 之间,其中 0.0 为小凹凸,1.0 为大凹凸。 : 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:具有 x 和 y 值的对象,指定重复图像的次数。 : Object with x and y values specifying the number of times to repeat the image.
    • strength:凹凸强度值介于 0.0 和 1.0 之间,其中 0.0 为小凹凸,1.0 为大凹凸。 : Bump strength value between 0.0 and 1.0 where 0.0 is small bumps and 1.0 is large bumps.
  • Grid
    • color:整个材质的rgba颜色对象。 : rgba color object for the whole material.
    • cellAlpha:网格线之间的单元格的 Alpha 值。这将与 color.alpha 结合。 : Alpha value for the cells between grid lines. This will be combined with color.alpha.
    • lineCount:具有 x 和 y 值的对象,分别指定列数和行数。 : Object with x and y values specifying the number of columns and rows respectively.
    • lineThickness:具有 x 和 y 值的对象,指定网格线的粗细(以像素为单位,如果可用)。 : Object with x and y values specifying the thickness of grid lines (in pixels where available).
    • lineOffset:具有 x 和 y 值的对象,指定网格线的偏移量(范围为 0 到 1)。 : 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 颜色对象。 : rgba color object for the stripe's first color.
    • oddColor:条纹第二个颜色的 rgba 颜色对象。 : rgba color object for the stripe's second color.
    • offset:控制图案中开始绘制的点的数字; 0.0 是偶数颜色的开始,1.0 是奇数颜色的开始,2.0 又是偶数颜色,以及中间的任何倍数或小数值。 : 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 颜色对象。 : rgba color object for the checkerboard's light alternating color.
    • darkColor:棋盘深色交替颜色的 rgba 颜色对象。 : rgba color object for the checkerboard's dark alternating color.
    • repeat:具有 x 和 y 值的对象,分别指定列数和行数。 : Object with x and y values specifying the number of columns and rows respectively.
  • Dot
    • lightColor:点颜色的 rgba 颜色对象。 : rgba color object for the dot color.
    • darkColor:背景颜色的rgba颜色对象。 : rgba color object for the background color.
    • repeat:具有 x 和 y 值的对象,分别指定点的列数和行数。 : Object with x and y values specifying the number of columns and rows of dots respectively.
  • Water
    • baseWaterColor:水的rgba颜色对象基色。 : rgba color object base color of the water.
    • blendColor:从水区域混合到非水区域时使用的 rgba 颜色对象。 : 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:漫反射颜色和 Alpha。 : diffuse color and alpha.
    • rimColor:边缘的漫反射颜色和 Alpha。 : diffuse color and alpha of the rim.
    • width:决定轮辋宽度的数字。 : Number that determines the rim's width.
  • Fade
    • fadeInColor:漫反射颜色和 Alpha : diffuse color and alpha at time
    • fadeOutColor:漫反射颜色和 Alpha : diffuse color and alpha at maximumDistance from time
    • maximumDistance:0.0 和 1.0 之间的数字,其中 : Number between 0.0 and 1.0 where the fadeInColor 成为 becomes the fadeOutColor。值为 0.0 时,整个材质的颜色为 . A value of 0.0 gives the entire material a color of fadeOutColor 值为 1.0 时,整个材质的颜色为 and a value of 1.0 gives the the entire material a color of fadeInColor
    • repeat:如果淡入淡出应该环绕纹理坐标,则为 true。 : true if the fade should wrap around the texture coodinates.
    • fadeDirection:具有 x 和 y 值的对象,指定淡入淡出是否应在 x 和 y 方向上。 : Object with x and y values specifying if the fade should be in the x and y directions.
    • time:x 和 y 值在 0.0 到 1.0 之间的对象 : Object with x and y values between 0.0 and 1.0 of the fadeInColor position
  • PolylineArrow
    • color:漫反射颜色和 Alpha。 : 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:发光强度,以总线宽的百分比表示(小于 1.0)。 : strength of the glow, as a percentage of the total line width (less than 1.0).
    • taperPower:锥形效果的强度,以总线长度的百分比表示。如果为 1.0 或更高,则不使用锥度效果。 : 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:线条内部的漫反射颜色和 Alpha。 : diffuse color and alpha for the interior of the line.
    • outlineColor:轮廓的漫反射颜色和 Alpha。 : diffuse color and alpha for the outline.
    • outlineWidth:轮廓的宽度(以像素为单位)。 : width of the outline in pixels.
  • ElevationContour
    • color:轮廓线的颜色和 Alpha。 : 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:土地覆盖区域的漫反射颜色和 Alpha。 : diffuse color and alpha for the areas covered by land.
名称 Name 类型 Type 说明 Description
options object 可选 optional 具有以下属性的对象: Object with the following properties:
名称 Name 类型 Type 默认值 Default 说明 Description
strict boolean false 可选 optional 针对通常会被忽略的问题引发错误,包括未使用的制服或材料。 Throws errors for issues that would normally be ignored, including unused uniforms or materials.
translucent boolean | function true 可选 optional When true 或返回的函数 or a function that returns true,使用这种材料的几何形状预计会呈现半透明。 , the geometry with this material is expected to appear translucent.
minificationFilter TextureMinificationFilter TextureMinificationFilter.LINEAR 可选 optional The TextureMinificationFilter 应用于该材质的纹理。 to apply to this material's textures.
magnificationFilter TextureMagnificationFilter TextureMagnificationFilter.LINEAR 可选 optional The TextureMagnificationFilter 应用于该材质的纹理。 to apply to this material's textures.
fabric object 用于生成材质的织物 JSON。 The fabric JSON used to generate the material.
抛出: 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 section.
  • 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: 着色器源不使用字符串。 : strict: shader source does not use string.
  • DeveloperError : strict: shader source does not use uniform.
  • DeveloperError :严格:着色器源不使用材质。 : strict: shader source does not use material.
示例: 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:
  • Fabric wiki page 了解 Fabric 的更详细选项。 for a more detailed options of Fabric.

成员 Members

static readonly Cesium.Material.AlphaMapType : string

获取 alpha 贴图材质的名称。 Gets the name of the alpha map material.

static readonly Cesium.Material.AspectRampMaterialType : string

获取坡向坡道材质的名称。 Gets the name of the aspect ramp material.

static readonly Cesium.Material.BumpMapType : string

获取凹凸贴图材质的名称。 Gets the name of the bump map material.

static readonly Cesium.Material.CheckerboardType : string

获取棋盘材质的名称。 Gets the name of the checkerboard material.

static readonly Cesium.Material.ColorType : string

获取颜色材质的名称。 Gets the name of the color material.

static Cesium.Material.DefaultCubeMapId : string

获取或设置默认的立方体贴图纹理统一值。 Gets or sets the default cube map texture uniform value.

static Cesium.Material.DefaultImageId : string

获取或设置默认纹理统一值。 Gets or sets the default texture uniform value.

static readonly Cesium.Material.DiffuseMapType : string

获取漫反射贴图材质的名称。 Gets the name of the diffuce map material.

static readonly Cesium.Material.DotType : string

获取点材质的名称。 Gets the name of the dot material.

static readonly Cesium.Material.ElevationBandType : string

获取高程带材质的名称。 Gets the name of the elevation band material.

static readonly Cesium.Material.ElevationContourType : string

获取高程轮廓材质的名称。 Gets the name of the elevation contour material.

static readonly Cesium.Material.ElevationRampType : string

获取高程轮廓材质的名称。 Gets the name of the elevation contour material.

static readonly Cesium.Material.EmissionMapType : string

获取发射贴图材质的名称。 Gets the name of the emmision map material.

static readonly Cesium.Material.FadeType : string

获取淡入淡出材质的名称。 Gets the name of the fade material.

static readonly Cesium.Material.GridType : string

获取网格材质的名称。 Gets the name of the grid material.

static readonly Cesium.Material.ImageType : string

获取图像材质的名称。 Gets the name of the image material.

static readonly Cesium.Material.NormalMapType : string

获取法线贴图材质的名称。 Gets the name of the normal map material.

static readonly Cesium.Material.PolylineArrowType : string

获取折线箭头材质的名称。 Gets the name of the polyline arrow material.

static readonly Cesium.Material.PolylineDashType : string

获取折线发光材质的名称。 Gets the name of the polyline glow material.

static readonly Cesium.Material.PolylineGlowType : string

获取折线发光材质的名称。 Gets the name of the polyline glow material.

static readonly Cesium.Material.PolylineOutlineType : string

获取折线轮廓材质的名称。 Gets the name of the polyline outline material.

static readonly Cesium.Material.RimLightingType : string

获取边缘照明材质的名称。 Gets the name of the rim lighting material.

static readonly Cesium.Material.SlopeRampMaterialType : string

获取斜坡材质的名称。 Gets the name of the slope ramp material.

static readonly Cesium.Material.SpecularMapType : string

获取高光贴图材质的名称。 Gets the name of the specular map material.

static readonly Cesium.Material.StripeType : string

获取条纹材质的名称。 Gets the name of the stripe material.

static readonly Cesium.Material.WaterMaskType : string

获取水罩材质的名称。 Gets the name of the water mask material.

static readonly Cesium.Material.WaterType : string

获取水材质的名称。 Gets the name of the water material.
The TextureMagnificationFilter 应用于该材质的纹理。 to apply to this material's textures.
默认值: Default Value: TextureMagnificationFilter.LINEAR
将子材质名称映射到材质对象。 Maps sub-material names to Material objects.
默认值: Default Value: undefined
The TextureMinificationFilter 应用于该材质的纹理。 to apply to this material's textures.
默认值: Default Value: TextureMinificationFilter.LINEAR

shaderSource : string

该材质的 glsl 着色器源。 The glsl shader source for this material.
默认值: Default Value: undefined

translucent : boolean|function

When true 或返回的函数 or a function that returns true,几何体预计会呈现半透明。 , the geometry is expected to appear translucent.
默认值: Default Value: undefined
材料类型。可以是现有类型或新类型。如果结构中未指定类型,则类型是 GUID。 The material type. Can be an existing type or a new type. If no type is specified in fabric, type is a GUID.
默认值: Default Value: undefined
将统一名称映射到它们的值。 Maps uniform names to their values.
默认值: Default Value: undefined

方法 Methods

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

使用现有材质类型创建新材质。 Creates a new material using an existing material type.

简写: new Material({fabric: {type: type}}); Shorthand for: new Material({fabric : {type : type}});
名称 Name 类型 Type 说明 Description
type string 基材类型。 The base material type.
uniforms object 可选 optional 覆盖默认制服。 Overrides for the default uniforms.
返回: Returns:
新的物质对象。 New material object.
抛出: Throws:
示例: 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>

使用现有材质类型创建新材质,并返回一个承诺,该承诺在加载所有材质资源后解析。 Creates a new material using an existing material type and returns a promise that resolves when all of the material's resources have been loaded.
名称 Name 类型 Type 说明 Description
type string 基材类型。 The base material type.
uniforms object 可选 optional 覆盖默认制服。 Overrides for the default uniforms.
返回: Returns:
加载所有资源后解析为新材质对象的承诺。 A promise that resolves to a new material object when all resources are loaded.
抛出: Throws:
示例: Example:
const material = await Cesium.Material.fromTypeAsync('Image', {
   image: '../Images/Cesium_Logo_overlay.png'
});
销毁该对象持有的 WebGL 资源。销毁对象可以确定性地释放 WebGL 资源,而不是依赖垃圾收集器来销毁该对象。 Destroys the WebGL resources held by this object. Destroying an object allows for deterministic release of WebGL resources, instead of relying on the garbage collector to destroy this object.

一旦对象被销毁,就不应再使用;调用除 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:
material = material && material.destroy();
另见: See:

isDestroyed()boolean

如果该对象被销毁则返回 true;否则为假。 Returns true if this object was destroyed; otherwise, false.

如果该对象被破坏,则不应使用它;调用除 If this object was destroyed, it should not be used; calling any function other than isDestroyed 将导致 will result in a DeveloperError exception.
返回: Returns:
如果该对象被销毁,则为 True;否则为假。 True if this object was destroyed; otherwise, false.
另见: See:

isTranslucent()boolean

获取此材质是否半透明。 Gets whether or not this material is translucent.
返回: Returns:
true 如果这种材料是半透明的, if this material is translucent, false otherwise.
需要帮助吗?获得答案的最快方法是从社区和团队那里获得答案 Need help? The fastest way to get answers is from the community and team on the Cesium Forum.