3.9 KiB
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
| New Module | Purpose |
|---|---|
| constants | WebGL enum values |
| shadertools | Tools for manipulating and composing shader text |
| gltool | Tooling and polyfilling for the WebGL context |
| webgl | Wrapper classes for WebGL |
| core | Single module re-exporting key parts of engine, webgl, shadertools |
| engine | High-level drawing APIs |
| addons | Experimental, unsupported APIs. Use at your own risk! |
| debug | Debug tooling for the other modules |
| test-utils | Test tooling for the other modules |
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, Texture3D, TextureCube, Query, 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.