The IDLgrGLTF object allows you to save the contents of an Object Graphics hierarchy into an GLTF or GLB format file with an optional Cesium 3D Tiles JSON file. The graphics tree can only contain a single view. The resulting GLTF file is interactive and allows you to explore the geometry interactively using an GLTF viewer.
Note: The file format will either be JSON/ASCII or binary, depending upon the file suffix. If the file suffix is .glb then the format will be binary. If the file suffix is .gltf then the format will be JSON/ASCII. For .gltf, IDL may create an additional .bin file that contains any binary data.
Note: For both .glb and .gltf, IDL will also create a .json file that contains the description needed for the Cesium 3D Tiles format.
Note: Objects or subclasses of this type can not be saved or restored.
The object is limited to the primitives supported by GLTF. Several entities cannot be translated perfectly. These include:
-
IDLgrImage - Rotation and Z buffer behavior are not completely supported. BLEND_FUNCTION is not completely supported (only binary srcAlpha,1-srcAlpha) This function is applied automatically if an alpha channel is present. It is also depends upon the renderer. Channel masks are not supported. Tiled images are not supported.
-
IDLgrPolygon and IDLgrSurface - Hidden line/hidden point display, color and vertex color blending with texture colors, and bottom color are not supported. Hidden parts are skipped instead of rendered. Shading may be viewer dependent. Front face culling is not supported and back face culling is only supported at the renderer’s discretion. The AMBIENT material property is not supported.
-
IDLgrLight - Lighting scope and intensity may be viewer dependent.
-
IDLgrText - The ONGLASS property is not supported. All text is emitted as 3D geometry in world space.
-
IDLgrViewgroup, IDLgrScene, IDLgrVolume - These objects are not supported.
-
IDLgrPalette - Palette objects are simulated using an RGB color model.
-
IDLgrPattern - Only solid or clear patterns are supported.
-
IDLgrFont, IDLgrSymbol - The THICK property is not supported.
-
IDLgrPolyline, IDLgrSymbol, IDLgrSurface, IDLgrPolygon and IDLgrPlot - Line attributes (thickness, linestyle) are not supported.
-
IDLgrView - Z-clipping control, aspect ratio preservation, the LOCATION property, depth buffering, clipping rects, and orthographic projections are not supported.
-
Destination Objects - The COLOR_MODEL property is not fully supported in Indexed Color mode, when using a SHADER_RANGE (an RGB model will be substituted instead). The QUALITY property is not supported.
Example
Construct a 3D model of a set of "buildings" of different heights, then export to a GLTF file:
verts = [[0,0,0],[1,0,0],[1,1,0],[0,1,0], $
[0,0,1],[1,0,1],[1,1,1],[0,1,1]]
poly = [4, 0,1,2,3, 4, 4,5,6,7, 4, 0,1,5,4, $
4, 2,3,7,6, 4, 0,3,7,4, 4, 1,2,6,5]
oModel = IDLgrModel()
for i = 0, 5 do for j = 0, 5 do begin & $
color = bytscl(randomu(seed, 3)) & $
vert1 = float(verts) & $
vert1[0, *] += i & vert1[1, *] += j & $
vert1[2, *] *= 4 * randomu(seed) & $
oPoly = IDLgrPolygon(vert1, POLYGON=poly, COLOR=color) & $
oModel.Add, oPoly & $
endfor
oView = IDLgrView()
oView.Add, oModel
obj = IDLgrGLTF(filename='buildings.glb')
obj.Draw, oView
obj = 0
Superclasses
IDLitComponent
Properties
Objects of this class have the following properties. In addition, objects of this class inherit the properties of all superclasses of this class.
FILENAME
A string that specifies the name of a file into which the vector data will be saved. The default is idl.glb.
Note: If the file suffix is .glb then the format will be GLTF binary. If the file suffix is .gltf then the format will be JSON/ASCII. For .gltf, IDL may create an additional .bin file that contains any binary data. For both .glb and .gltf, IDL will also create a .json file that contains the description needed for the Cesium 3D Tiles format.
GRAPHICS_TREE
An object reference of type IDLgrView. If this property is set to a valid object reference, calling the Draw method on the destination object with no arguments will cause the object reference associated with this property to be drawn. If this object is valid and the destination object is destroyed, this object reference will be destroyed as well. By default the GRAPHICS_TREE property is set equal to the null-object.
WORLDTITLE (Init only)
A string containing the name of the main node. The default is 'IDL GLTF file'.
Methods
This class has the following methods:
In addition, this class inherits the methods of its superclasses (if any).
IDLgrGLTF::Draw
The IDLgrGLTF::Draw procedure method draws the given picture to this graphics destination.
Syntax
Obj->[IDLgrGLTF::]Draw [, Picture]
Arguments
Picture
The view (an instance of an IDLgrView object) to be drawn. If the view has a LOCATION property, it is ignored.
Tip: Instead of using the Picture argument, it is strongly recommended that you set the GRAPHICS_TREE property and call the ::Draw method without an argument. This allows the IDLgrGLTF to automatically clean up the graphics tree when it is destroyed. If you do use the Picture argument, then you are responsible for cleaning up the graphics tree (automatic garbage collection will not work because of the parent/child circular references within the graphics hierarchy).
Keywords
None
IDLgrGLTF::GetProperty
The IDLgrGLTF::GetProperty procedure method retrieves the value of a property or group of properties for the GLTF object.
Syntax
Obj->[IDLgrGLTF::]GetProperty[, PROPERTY=variable]
Arguments
None
Keywords
To retrieve the value of a property, specify the property name as a keyword set equal to a named variable that will contain the value of the property.
Any keyword not recognized is passed to this object’s superclass.
IDLgrGLTF::SetProperty
The IDLgrGLTF::SetProperty procedure method sets the value of a property or group of properties for the GLTF world.
Syntax
Obj->[IDLgrGLTF::]SetProperty[, PROPERTY=value]
Arguments
None
Keywords
To set the value of a property, specify the property name as a keyword set equal to the appropriate property value.
Version History