new Material()
Materials define surface appearance through a combination of diffuse, specular, normal, emission, and alpha components. These values are specified through a JSON schema called Fabric, which is parsed and assembled into glsl shader code to learn more about Fabric.
Base material types and their uniforms:
- Color
- color: rgba color object.
- Image
- image: The path of the image.
- repeat: An object with x and y values specifying the number of times to repeat the image.
- DiffuseMap
- image: The path of the image.
- channels: A string containing any combination of r, g, b, and a, used to select the desired image channels.
- repeat: An object with x and y values specifying the number of times to repeat the image.
- AlphaMap
- image: The path of the 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: The path of the image.
- channel: A string containing r, g, b, or a, used to select the desired image channel.
- repeat: An object with x and y values specifying the number of times to repeat the image.
- EmissionMap
- image: The path of the image.
- channels: A string containing any combination of r, g, b, and a, used to select the desired image channels.
- repeat: An object with x and y values specifying the number of times to repeat the image.
- BumpMap
- image: The path of the image.
- channel: A string containing r, g, b, or a, used to select the desired image channel.
- repeat: An object with x and y values specifying the number of times to repeat the image.
- strength: The bump strength value between 0.0 and 1.0, where 0.0 is the minimum and 1.0 is the maximum.
- NormalMap
- image: The path of the image.
- channels: A string containing any combination of r, g, b, and a, used to select the desired image channels.
- repeat: An object with x and y values specifying the number of times to repeat the image.
- strength: The normal strength value between 0.0 and 1.0, where 0.0 is the minimum and 1.0 is the maximum.
- Grid
- color: The rgba color object of the entire material.
- cellAlpha: The alpha value of the cells between grid lines. This will be combined with color.alpha.
- lineCount: An object with x and y values specifying the number of columns and rows, respectively.
- lineThickness: An object with x and y values specifying the thickness of grid lines (in pixels where available).
- lineOffset: An object with x and y values specifying the offset of grid lines (range 0 to 1).
- Stripe
- horizontal: A boolean determining whether the stripe is horizontal or vertical.
- evenColor: The rgba color object of the first stripe color.
- oddColor: The rgba color object of the second stripe color.
- offset: A number controlling at which point in the pattern to start drawing; 0.0 is the start of the even color, 1.0 is the start of the odd color, 2.0 is the even color again, and any multiple or fractional value in between.
- repeat: A number controlling the total number of stripes, half bright and half dark.
- Checkerboard
- lightColor: The rgba color object for the light alternating color of the checkerboard.
- darkColor: The rgba color object for the dark alternating color of the checkerboard.
- repeat: An object with x and y values specifying the number of columns and rows, respectively.
- Dot
- lightColor: The rgba color object for the point color.
- darkColor: The rgba color object for the background color.
- repeat: An object with x and y values specifying the number of columns and rows of points, respectively.
- Water
- baseWaterColor: The rgba color object for the base water color.
- blendColor: The rgba color object used when blending from water to non-water areas.
- specularMap: A single-channel texture used to indicate water areas.
- normalMap: A normal map for water normal perturbation.
- frequency: A number controlling the wave number.
- animationSpeed: A number controlling the animation speed of water.
- amplitude: A number controlling the amplitude of water waves.
- specularIntensity: A number controlling the intensity of specular reflection.
- RimLighting
- color: Diffuse color and alpha.
- rimColor: Diffuse color and alpha of the edges.
- width: A number determining the width of the rim.
- Fade
- fadeInColor: Diffuse color and alpha at time.
- fadeOutColor: Diffuse color and alpha from time to maximumDistance.
- maximumDistance: A number between 0.0 and 1.0 where fadeInColor transitions to fadeOutColor. A value of 0.0 makes the entire material color fadeOutColor, a value of 1.0 makes it fadeInColor.
- repeat: true if fade should wrap texture coordinates.
- fadeDirection: An object with x and y values specifying whether fade should occur in the x and y directions.
- time: The x and y values of the object between 0.0 and 1.0 at the fadeInColor position.
- PolylineArrow
- color: Diffuse color and alpha.
- PolylineDash
- color: The color of the line.
- gapColor: The color of the gaps in the line.
- dashLength: The length of the dash in pixels.
- dashPattern: The 16-bit stipple pattern of the line.
- PolylineGlow
- color: The glow color and maximum alpha on the line.
- glowPower: The glow intensity as a percentage of the line width (less than 1.0).
- PolylineOutline
- color: The diffuse color and alpha inside the line.
- outlineColor: The diffuse color and alpha of the outline.
- outlineWidth: The width of the outline in pixels.
| Name | Type | Default | Description |
|---|---|---|---|
options.strict |
Boolean | false |
optional
Throwing errors for issues that are usually overlooked, including unused variables or materials. |
options.translucent |
Boolean | function | true |
optional
When set to true or when the function returns true, geometry using this material will exhibit a semi transparent effect. |
options.fabric |
Object |
JSON used to generate materials. |
|
options.diffuse |
Color |
diffuse reflection |
|
options.specular |
Color |
highlight |
|
options.ambient |
Color |
ambient light |
|
options.shiness |
Number |
gloss |
Throws:
-
-
Fabric: The type of uniform is invalid.
- Type
- DeveloperError
-
-
-
Fabric: Uniforms and materials cannot share the same properties.
- Type
- DeveloperError
-
-
-
Fabric: Cannot include sources and components in the same section.
- Type
- DeveloperError
-
-
-
Fabric: The attribute name is invalid. It should be 'type', 'materials',' uniformity ',' components', or 'source'
- Type
- DeveloperError
-
-
-
Fabric: The attribute name is invalid. It should be 'diffuse', 'pecular', 'shinines',' normal ',' emission ', or' alpha '
- Type
- DeveloperError
-
-
-
Strict: The shader source does not use strings.
- Type
- DeveloperError
-
-
-
Strict: Shader source does not use uniformity.
- Type
- DeveloperError
-
-
-
Strict: The shader source does not use materials.
- Type
- DeveloperError
-
Example
// Create a color material with fromType:
polygon.material = SuperMap3D.Material.fromType('Color');
polygon.material.uniforms.color = new SuperMap3D.Color(1.0, 1.0, 0.0, 1.0);
// Create the default material:
polygon.material = new SuperMap3D.Material();
// Create a color material with full Fabric notation:
polygon.material = new SuperMap3D.Material({
fabric : {
type : 'Color',
uniforms : {
color : new SuperMap3D.Color(1.0, 1.0, 0.0, 1.0)
}
}
});
Members
-
static AdvancedWaterTypeString
-
Get the name of the advanced water surface material.
Example
Material({ fabric: { type: Material.AdvancedWaterType,// Water material type uniforms: { uWaterColor: new Cartesian4(0, 0.627451, 0.913725, 1.0),// Water surface color uWaterBrightness: 0.7,// Water brightness } } }) -
(static, readonly) AlphaMapTypeString
-
Get the name of the alpha texture material.
-
(static, readonly) AspectRampMaterialTypeString
-
Gets the name of the aspect ramp material.
-
(static, readonly) BumpMapTypeString
-
Get the name of the bump texture material.
-
(static, readonly) CheckerboardTypeString
-
Get the name of the checkerboard material.
-
(static, readonly) ColorTypeString
-
Get the name of the color material.
-
static DefaultCubeMapIdString
-
Get or set the value of the default cube texture uniform variable.
-
static DefaultImageIdString
-
Get or set the value of the default texture uniform variable.
-
(static, readonly) DiffuseMapTypeString
-
Get the name of the diffuse texture material.
-
(static, readonly) DotTypeString
-
Get the name of the dot shaped material.
-
(static, readonly) ElevationContourTypeString
-
Gets the name of the elevation contour material.
-
(static, readonly) ElevationRampTypeString
-
Gets the name of the elevation contour material.
-
(static, readonly) EmissionColorTypeString
-
Get the name of the self luminous color material.
-
(static, readonly) EmissionMapTypeString
-
Get the name of the self luminous texture material.
-
(static, readonly) FadeTypeString
-
Get the name of the gradient material.
-
(static, readonly) GridTypeString
-
Get the name of the mesh material.
-
(static, readonly) ImageTypeString
-
Obtain the name of the image material.
-
(static, readonly) NormalMapTypeString
-
Get the name of the normal map material.
-
(static, readonly) PbrTypeString
-
Get the name of the PBR material.
-
(static, readonly) PolylineArrowTypeString
-
Get the name of the material for the polyline arrow.
-
(static, readonly) PolylineDashTypeString
-
Get the name of the glowing material for the dashed line.
-
(static, readonly) PolylineGlowTypeString
-
Get the name of the glowing material for the polyline.
-
(static, readonly) PolylineOutlineTypeString
-
Get the name of the polyline contour material.
-
(static, readonly) RimLightingTypeString
-
Get the name of the edge lighting material.
-
(static, readonly) SlopeRampMaterialTypeString
-
Gets the name of the slope ramp material.
-
(static, readonly) SpecularMapTypeString
-
Get the name of the mirror texture material.
-
(static, readonly) StripeTypeString
-
Get the name of the striped material.
-
(static, readonly) WaterTypeString
-
Obtain the name of the basic water surface material.
-
materialsObject
-
Map sub material names to Material objects.
- Default Value: undefined
shaderSourceString
The GLSL shader source code for this material.
- Default Value: undefined
translucentBoolean function
When set to true or when the function returns true, the geometry will appear semi transparent.
- Default Value: undefined
typeString
Material type. It can be an existing type or a new type. If no type is specified in 'fabric', the type is a UID.
- Default Value: undefined
uniformsObject
Map unified variable names to their values.
- Default Value: undefined
Methods
-
static fromType(type, uniforms){Material}
-
Create a new material using an existing material type. Shorthand for: new Material({fabric : {type : type}});
Name Type Description typeString Basic material type.
uniformsObject optional Overlay default unified variables.
Throws:
-
This material type does not exist.
- Type
- DeveloperError
Returns:
Type Description Material New material object. Example
var material = SuperMap3D.Material.fromType('Color', { color : new SuperMap3D.Color(1.0, 0.0, 0.0, 1.0) }); -
-
destroy(){undefined}
-
Destroy the WebGL resources held by this object. Destroying an object can release WebGL resources deterministically, rather than relying on a garbage collector to destroy the object. Once the object is destroyed, it cannot be used again; Calling any function other than isDestroyed will result in a Developer Error exception. Therefore, please assign the return value (undefined) to the object using the method shown in the example.
- See:
Throws:
-
The object has been destroyed, i.e. destroy() has been called.
- Type
- DeveloperError
Returns:
Type Description undefined Example
material = material && material.destroy(); -
isDestroyed(){Boolean}
-
If this object is destroyed, return true; otherwise, return false. If the object has been destroyed, it should not be used; Calling functions other than isDestroyed will result in a Developer Error exception.
- See:
Returns:
Type Description Boolean If the object has been destroyed, it is true; Otherwise, it is false. -
isTranslucent()
-
Determine whether this material is semi transparent.
Returns:
如果该材质是半透明的,则为True,否则为false。