Creates a new 3D polygon object on the terrain.
create3DPolygon(vertices, height, [lineColor], [fillColor], [name], [heightType]);
Parameter |
Description |
vertices |
Array of SGCoord3D, SGCoord2D, SGPosition or numbers. If the array is composed of numbers, they must be as follows: x1, h1, y1, x2, h2, y2… |
height |
The height of the object from top to bottom (not its height above the ground) |
lineColor |
Optional, default: sgLime It can be one of the following: SGColor, HTML color string (e.g., “#FF0000”), a number that represents ABGR color (e.g., 0xAA0000FF) or one of the predefined Skyline Globe colors (e.g., sgRed). For a complete list of the predefined colors, see Skyline Globe Colors |
fillColor |
Optional, default: sgDimgray The color of the object filling Can be one of the following: SGColor, HTML color string (e.g., “#FF0000”), a number that represents ABGR color (e.g., 0xAA0000FF) or one of the predefined Skyline Globe colors (e.g., sgRed). For a complete list of the predefined colors, see Skyline Globe Colors |
name |
Optional The node name |
heightType |
Optional The height type of the object. It can be sgHeightRelative, or sgHeightAbsolute |
Return Value
An SGNode object. If the method fails, the return value is null. SGWorld.lastError will contain the failure reason.
Remarks
To modify other properties of the 3Dpolygon, access the node innerObj. See SGNode.innerObj property and ITerrain3DPolygon5 interface for more details.
Unlike a 2D object (e.g., rectangle), a 3D object has volume and cannot be drawn on the terrain surface. Therefore, if specifying the position of a 3D object using SGCoord2D, its height will be set to 0 and its height type will we set to sgHeightRelative.
Example
The following example illustrates the use of the create3DPolygon method.
function create3DPolygon()
{
var points = new Array(
new SGCoord3D(-114.03822,41.99547, 100000),
new SGCoord3D(-111.04795,41.99626, 100000),
new SGCoord3D(-111.05028,40.99663, 100000),
new SGCoord3D(-109.04763,40.99847, 100000),
new SGCoord3D(-109.04782,36.99664, 100000),
new SGCoord3D(-114.04313,36.99656, 100000)
);
var poly3D = globe.creator.create3DPolygon(
points,
500000.0
);
globe.root.appendChild(poly3D);
globe.navigate.flyTo(poly3D);
}