WebGL / improve doc for Helper and VectorLayerRenderer
Also created enums for attributes (like uniforms), in an attempt to clarify what is accessible to the vertex shaders.
This commit is contained in:
@@ -5,6 +5,17 @@ import AbstractBatchRenderer from './BatchRenderer.js';
|
||||
import {AttributeType} from '../../webgl/Helper.js';
|
||||
import {transform2D} from '../../geom/flat/transform.js';
|
||||
|
||||
/**
|
||||
* Names of attributes made available to the vertex shader.
|
||||
* Please note: changing these *will* break custom shaders!
|
||||
* @enum {string}
|
||||
*/
|
||||
export const Attributes = {
|
||||
SEGMENT_START: 'a_segmentStart',
|
||||
SEGMENT_END: 'a_segmentEnd',
|
||||
PARAMETERS: 'a_parameters',
|
||||
};
|
||||
|
||||
class LineStringBatchRenderer extends AbstractBatchRenderer {
|
||||
/**
|
||||
* @param {import("../../webgl/Helper.js").default} helper WebGL helper instance
|
||||
@@ -19,17 +30,17 @@ class LineStringBatchRenderer extends AbstractBatchRenderer {
|
||||
// vertices for lines must hold both a position (x,y) and an offset (dx,dy)
|
||||
this.attributes_ = [
|
||||
{
|
||||
name: 'a_segmentStart',
|
||||
name: Attributes.SEGMENT_START,
|
||||
size: 2,
|
||||
type: AttributeType.FLOAT,
|
||||
},
|
||||
{
|
||||
name: 'a_segmentEnd',
|
||||
name: Attributes.SEGMENT_END,
|
||||
size: 2,
|
||||
type: AttributeType.FLOAT,
|
||||
},
|
||||
{
|
||||
name: 'a_parameters',
|
||||
name: Attributes.PARAMETERS,
|
||||
size: 1,
|
||||
type: AttributeType.FLOAT,
|
||||
},
|
||||
|
||||
@@ -6,6 +6,16 @@ import AbstractBatchRenderer from './BatchRenderer.js';
|
||||
import {AttributeType} from '../../webgl/Helper.js';
|
||||
import {apply as applyTransform} from '../../transform.js';
|
||||
|
||||
/**
|
||||
* Names of attributes made available to the vertex shader.
|
||||
* Please note: changing these *will* break custom shaders!
|
||||
* @enum {string}
|
||||
*/
|
||||
export const Attributes = {
|
||||
POSITION: 'a_position',
|
||||
INDEX: 'a_index',
|
||||
};
|
||||
|
||||
class PointBatchRenderer extends AbstractBatchRenderer {
|
||||
/**
|
||||
* @param {import("../../webgl/Helper.js").default} helper WebGL helper instance
|
||||
@@ -20,12 +30,12 @@ class PointBatchRenderer extends AbstractBatchRenderer {
|
||||
// vertices for point must hold both a position (x,y) and an index (their position in the quad)
|
||||
this.attributes_ = [
|
||||
{
|
||||
name: 'a_position',
|
||||
name: Attributes.POSITION,
|
||||
size: 2,
|
||||
type: AttributeType.FLOAT,
|
||||
},
|
||||
{
|
||||
name: 'a_index',
|
||||
name: Attributes.INDEX,
|
||||
size: 1,
|
||||
type: AttributeType.FLOAT,
|
||||
},
|
||||
|
||||
@@ -5,6 +5,15 @@ import AbstractBatchRenderer from './BatchRenderer.js';
|
||||
import {AttributeType} from '../../webgl/Helper.js';
|
||||
import {transform2D} from '../../geom/flat/transform.js';
|
||||
|
||||
/**
|
||||
* Names of attributes made available to the vertex shader.
|
||||
* Please note: changing these *will* break custom shaders!
|
||||
* @enum {string}
|
||||
*/
|
||||
export const Attributes = {
|
||||
POSITION: 'a_position',
|
||||
};
|
||||
|
||||
class PolygonBatchRenderer extends AbstractBatchRenderer {
|
||||
/**
|
||||
* @param {import("../../webgl/Helper.js").default} helper WebGL helper instance
|
||||
@@ -19,7 +28,7 @@ class PolygonBatchRenderer extends AbstractBatchRenderer {
|
||||
// By default only a position attribute is required to render polygons
|
||||
this.attributes_ = [
|
||||
{
|
||||
name: 'a_position',
|
||||
name: Attributes.POSITION,
|
||||
size: 2,
|
||||
type: AttributeType.FLOAT,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user