Module Structure
luma.gl contains a lot of classes and functions that might make new users wonder where to get started. luma.gl therefore organize classes and functions into groups, as shown in the following table and also in the folder structure of the source code
| Module | Description |
|---|---|
| src/webgl | A set of classes covering all WebGL objects. Currently luma.gl supports WebGL 2.0. These classes organize the WebGL2 API and makes it easy to work with in JavaScript. |
| src/core | A set of common classes across all 3D graphics applications. They are on a higher abstraction level than the WebGL API. luma.gl's signature Model class is in this folder. |
| src/geometry | This folder contains a collection of geometric primitives extending from the base Geometry class, including ConeGeometry, CubeGeometry, IcoSphereGeometry, PlaneGeometry, SphereGeometry, SphereGeometry. They can be used to create Models class with common geometries |
| src/models | Some predefined subclasses of Models created from simple geometries from the src/geometry folder |
| src/io | Node.js and browser file loaders. Also enables using streams in browser. |
| src/packages/events | A very simple browser event handling class used by luma.gl examples |
| src/shadertools | luma.gl's internal shader module system and shader assembler utility |
| src/webgl-utils | Miscellaneous utilies |
WebGL Classes
The heart of luma.gl is the webgl module, a set of JavaScript class wrappers covering all WebGL objects. From luma.gl v4,
After creating a context, perhaps with luma.gl's createGLContext function, you have can start instantiating luma.gl's WebGL2 classes: Buffer, FrameBuffer, RenderBuffer, Program, Shader, Texture2D, Texture2DArray, Texture3D, TextureCube, Query, Sampler, TransformFeedback, VertexArrayObject
Core Classes
The core classes, with the signature Model class, represents a set of objects that is common in most 3D rendering libraries or engines. These objects are at higher abstraction levels than the actual WebGL objects and that can serve as the basic building blocks for most 3D applications.
Model- A renderable object with program, attributes, uniforms and other state required for rendering 3D objects on the screenGeometry- Holds attributes and drawType for a primitive geometric objectAnimationLoop- A simple animation loop that connects with browser's animation mechanism
Basic Geometries and Models
A Geometry object holds a set of attributes (native JavaScript arrays) (vertices, normals, texCoords, indices) and a drawMode prop to indicate how to interpret those vertices and normals as actual geometries.
There are several basic geometry classes predefined in luma.gl: Geometry, ConeGeometry, CubeGeometry, IcoSphereGeometry, PlaneGeometry, SphereGeometry, SphereGeometry. They are all subclasses of the Geometry class.
Corresponding to those geometry objects, luma.gl also provides commonly used Model classes that consist of basic geometries. These include Cone, Cube, Cylinder, IcoSphere, Plane and Sphere, etc...
Users are encouraged to write their own geometries and models and luma.gl could include them in its future releases.