Skip to content

Commit

Permalink
"element" → "index"
Browse files Browse the repository at this point in the history
  • Loading branch information
jfirebaugh committed Aug 24, 2017
1 parent 84393a6 commit 571b32b
Show file tree
Hide file tree
Showing 19 changed files with 132 additions and 132 deletions.
4 changes: 2 additions & 2 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ Tile
| + ArrayGroup {
| globalProperties: { zoom }
| layoutVertexArray,
| elementArray,
| elementArray2,
| indexArray,
| indexArray2,
| layerData: {
| [style layer id]: {
| programConfiguration,
Expand Down
4 changes: 2 additions & 2 deletions src/data/bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ export type IndexedFeature = {
* Create a bucket via the `StyleLayer#createBucket` method.
*
* The concrete bucket types, using layout options from the style layer,
* transform feature geometries into vertex and element data for use by the
* transform feature geometries into vertex and index data for use by the
* vertex shader. They also (via `ProgramConfiguration`) use feature
* properties and the zoom level to populate the attributes needed for
* data-driven styling.
*
* Buckets are designed to be built on a worker thread and then serialized and
* transferred back to the main thread for rendering. On the worker side, a
* bucket's vertex, element, and attribute data is stored in `bucket.arrays:
* bucket's vertex, index, and attribute data is stored in `bucket.arrays:
* ArrayGroup`. When a bucket's data is serialized and sent back to the main
* thread, is gets deserialized (using `new Bucket(serializedBucketData)`, with
* the array data now stored in `bucket.buffers: BufferGroup`. BufferGroups
Expand Down
22 changes: 11 additions & 11 deletions src/data/bucket/circle_bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const VertexBuffer = require('../../gl/vertex_buffer');
const IndexBuffer = require('../../gl/index_buffer');
const {ProgramConfigurationSet} = require('../program_configuration');
const createVertexArrayType = require('../vertex_array_type');
const {TriangleElementArray} = require('../element_array_type');
const {TriangleIndexArray} = require('../index_array_type');
const loadGeometry = require('../load_geometry');
const EXTENT = require('../extent');

Expand All @@ -18,7 +18,7 @@ const circleInterface = {
layoutAttributes: [
{name: 'a_pos', components: 2, type: 'Int16'}
],
elementArrayType: TriangleElementArray,
indexArrayType: TriangleIndexArray,

paintAttributes: [
{property: 'circle-color'},
Expand Down Expand Up @@ -57,8 +57,8 @@ class CircleBucket implements Bucket {
layoutVertexArray: StructArray;
layoutVertexBuffer: VertexBuffer;

elementArray: StructArray;
elementBuffer: IndexBuffer;
indexArray: StructArray;
indexBuffer: IndexBuffer;

programConfigurations: ProgramConfigurationSet;
segments: SegmentVector;
Expand All @@ -71,12 +71,12 @@ class CircleBucket implements Bucket {

if (options.layoutVertexArray) {
this.layoutVertexBuffer = new VertexBuffer(options.layoutVertexArray, LayoutVertexArrayType.serialize());
this.elementBuffer = new IndexBuffer(options.elementArray);
this.indexBuffer = new IndexBuffer(options.indexArray);
this.programConfigurations = ProgramConfigurationSet.deserialize(circleInterface, options.layers, options.zoom, options.programConfigurations);
this.segments = new SegmentVector(options.segments);
} else {
this.layoutVertexArray = new LayoutVertexArrayType();
this.elementArray = new TriangleElementArray();
this.indexArray = new TriangleIndexArray();
this.programConfigurations = new ProgramConfigurationSet(circleInterface, options.layers, options.zoom);
this.segments = new SegmentVector();
}
Expand All @@ -100,15 +100,15 @@ class CircleBucket implements Bucket {
zoom: this.zoom,
layerIds: this.layers.map((l) => l.id),
layoutVertexArray: this.layoutVertexArray.serialize(transferables),
elementArray: this.elementArray.serialize(transferables),
indexArray: this.indexArray.serialize(transferables),
programConfigurations: this.programConfigurations.serialize(transferables),
segments: this.segments.get(),
};
}

destroy() {
this.layoutVertexBuffer.destroy();
this.elementBuffer.destroy();
this.indexBuffer.destroy();
this.programConfigurations.destroy();
this.segments.destroy();
}
Expand All @@ -131,16 +131,16 @@ class CircleBucket implements Bucket {
// │ 0 1 │
// └─────────┘

const segment = this.segments.prepareSegment(4, this.layoutVertexArray, this.elementArray);
const segment = this.segments.prepareSegment(4, this.layoutVertexArray, this.indexArray);
const index = segment.vertexLength;

addCircleVertex(this.layoutVertexArray, x, y, -1, -1);
addCircleVertex(this.layoutVertexArray, x, y, 1, -1);
addCircleVertex(this.layoutVertexArray, x, y, 1, 1);
addCircleVertex(this.layoutVertexArray, x, y, -1, 1);

this.elementArray.emplaceBack(index, index + 1, index + 2);
this.elementArray.emplaceBack(index, index + 3, index + 2);
this.indexArray.emplaceBack(index, index + 1, index + 2);
this.indexArray.emplaceBack(index, index + 3, index + 2);

segment.vertexLength += 4;
segment.primitiveLength += 2;
Expand Down
40 changes: 20 additions & 20 deletions src/data/bucket/fill_bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const VertexBuffer = require('../../gl/vertex_buffer');
const IndexBuffer = require('../../gl/index_buffer');
const {ProgramConfigurationSet} = require('../program_configuration');
const createVertexArrayType = require('../vertex_array_type');
const {LineElementArray, TriangleElementArray} = require('../element_array_type');
const {LineIndexArray, TriangleIndexArray} = require('../index_array_type');
const loadGeometry = require('../load_geometry');
const earcut = require('earcut');
const classifyRings = require('../../util/classify_rings');
Expand All @@ -21,8 +21,8 @@ const fillInterface = {
layoutAttributes: [
{name: 'a_pos', components: 2, type: 'Int16'}
],
elementArrayType: TriangleElementArray,
elementArrayType2: LineElementArray,
indexArrayType: TriangleIndexArray,
indexArrayType2: LineIndexArray,

paintAttributes: [
{property: 'fill-color'},
Expand All @@ -44,11 +44,11 @@ class FillBucket implements Bucket {
layoutVertexArray: StructArray;
layoutVertexBuffer: VertexBuffer;

elementArray: StructArray;
elementBuffer: IndexBuffer;
indexArray: StructArray;
indexBuffer: IndexBuffer;

elementArray2: StructArray;
elementBuffer2: IndexBuffer;
indexArray2: StructArray;
indexBuffer2: IndexBuffer;

programConfigurations: ProgramConfigurationSet;
segments: SegmentVector;
Expand All @@ -62,15 +62,15 @@ class FillBucket implements Bucket {

if (options.layoutVertexArray) {
this.layoutVertexBuffer = new VertexBuffer(options.layoutVertexArray, LayoutVertexArrayType.serialize());
this.elementBuffer = new IndexBuffer(options.elementArray);
this.elementBuffer2 = new IndexBuffer(options.elementArray2);
this.indexBuffer = new IndexBuffer(options.indexArray);
this.indexBuffer2 = new IndexBuffer(options.indexArray2);
this.programConfigurations = ProgramConfigurationSet.deserialize(fillInterface, options.layers, options.zoom, options.programConfigurations);
this.segments = new SegmentVector(options.segments);
this.segments2 = new SegmentVector(options.segments2);
} else {
this.layoutVertexArray = new LayoutVertexArrayType();
this.elementArray = new TriangleElementArray();
this.elementArray2 = new LineElementArray();
this.indexArray = new TriangleIndexArray();
this.indexArray2 = new LineIndexArray();
this.programConfigurations = new ProgramConfigurationSet(fillInterface, options.layers, options.zoom);
this.segments = new SegmentVector();
this.segments2 = new SegmentVector();
Expand All @@ -95,8 +95,8 @@ class FillBucket implements Bucket {
zoom: this.zoom,
layerIds: this.layers.map((l) => l.id),
layoutVertexArray: this.layoutVertexArray.serialize(transferables),
elementArray: this.elementArray.serialize(transferables),
elementArray2: this.elementArray2.serialize(transferables),
indexArray: this.indexArray.serialize(transferables),
indexArray2: this.indexArray2.serialize(transferables),
programConfigurations: this.programConfigurations.serialize(transferables),
segments: this.segments.get(),
segments2: this.segments2.get()
Expand All @@ -105,8 +105,8 @@ class FillBucket implements Bucket {

destroy() {
this.layoutVertexBuffer.destroy();
this.elementBuffer.destroy();
this.elementBuffer2.destroy();
this.indexBuffer.destroy();
this.indexBuffer2.destroy();
this.programConfigurations.destroy();
this.segments.destroy();
this.segments2.destroy();
Expand All @@ -119,7 +119,7 @@ class FillBucket implements Bucket {
numVertices += ring.length;
}

const triangleSegment = this.segments.prepareSegment(numVertices, this.layoutVertexArray, this.elementArray);
const triangleSegment = this.segments.prepareSegment(numVertices, this.layoutVertexArray, this.indexArray);
const triangleIndex = triangleSegment.vertexLength;

const flattened = [];
Expand All @@ -134,17 +134,17 @@ class FillBucket implements Bucket {
holeIndices.push(flattened.length / 2);
}

const lineSegment = this.segments2.prepareSegment(ring.length, this.layoutVertexArray, this.elementArray2);
const lineSegment = this.segments2.prepareSegment(ring.length, this.layoutVertexArray, this.indexArray2);
const lineIndex = lineSegment.vertexLength;

this.layoutVertexArray.emplaceBack(ring[0].x, ring[0].y);
this.elementArray2.emplaceBack(lineIndex + ring.length - 1, lineIndex);
this.indexArray2.emplaceBack(lineIndex + ring.length - 1, lineIndex);
flattened.push(ring[0].x);
flattened.push(ring[0].y);

for (let i = 1; i < ring.length; i++) {
this.layoutVertexArray.emplaceBack(ring[i].x, ring[i].y);
this.elementArray2.emplaceBack(lineIndex + i - 1, lineIndex + i);
this.indexArray2.emplaceBack(lineIndex + i - 1, lineIndex + i);
flattened.push(ring[i].x);
flattened.push(ring[i].y);
}
Expand All @@ -157,7 +157,7 @@ class FillBucket implements Bucket {
assert(indices.length % 3 === 0);

for (let i = 0; i < indices.length; i += 3) {
this.elementArray.emplaceBack(
this.indexArray.emplaceBack(
triangleIndex + indices[i],
triangleIndex + indices[i + 1],
triangleIndex + indices[i + 2]);
Expand Down
26 changes: 13 additions & 13 deletions src/data/bucket/fill_extrusion_bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const VertexBuffer = require('../../gl/vertex_buffer');
const IndexBuffer = require('../../gl/index_buffer');
const {ProgramConfigurationSet} = require('../program_configuration');
const createVertexArrayType = require('../vertex_array_type');
const {TriangleElementArray} = require('../element_array_type');
const {TriangleIndexArray} = require('../index_array_type');
const loadGeometry = require('../load_geometry');
const EXTENT = require('../extent');
const earcut = require('earcut');
Expand All @@ -24,7 +24,7 @@ const fillExtrusionInterface = {
{name: 'a_normal', components: 3, type: 'Int16'},
{name: 'a_edgedistance', components: 1, type: 'Int16'}
],
elementArrayType: TriangleElementArray,
indexArrayType: TriangleIndexArray,

paintAttributes: [
{property: 'fill-extrusion-base'},
Expand All @@ -51,7 +51,7 @@ function addVertex(vertexArray, x, y, nx, ny, nz, t, e) {
}

const LayoutVertexArrayType = createVertexArrayType(fillExtrusionInterface.layoutAttributes);
const ElementArrayType = fillExtrusionInterface.elementArrayType;
const IndexArrayType = fillExtrusionInterface.indexArrayType;

class FillExtrusionBucket implements Bucket {
static programInterface: ProgramInterface;
Expand All @@ -64,8 +64,8 @@ class FillExtrusionBucket implements Bucket {
layoutVertexArray: StructArray;
layoutVertexBuffer: VertexBuffer;

elementArray: StructArray;
elementBuffer: IndexBuffer;
indexArray: StructArray;
indexBuffer: IndexBuffer;

programConfigurations: ProgramConfigurationSet;
segments: SegmentVector;
Expand All @@ -78,12 +78,12 @@ class FillExtrusionBucket implements Bucket {

if (options.layoutVertexArray) {
this.layoutVertexBuffer = new VertexBuffer(options.layoutVertexArray, LayoutVertexArrayType.serialize());
this.elementBuffer = new IndexBuffer(options.elementArray);
this.indexBuffer = new IndexBuffer(options.indexArray);
this.programConfigurations = ProgramConfigurationSet.deserialize(fillExtrusionInterface, options.layers, options.zoom, options.programConfigurations);
this.segments = new SegmentVector(options.segments);
} else {
this.layoutVertexArray = new LayoutVertexArrayType();
this.elementArray = new ElementArrayType();
this.indexArray = new IndexArrayType();
this.programConfigurations = new ProgramConfigurationSet(fillExtrusionInterface, options.layers, options.zoom);
this.segments = new SegmentVector();
}
Expand All @@ -107,15 +107,15 @@ class FillExtrusionBucket implements Bucket {
zoom: this.zoom,
layerIds: this.layers.map((l) => l.id),
layoutVertexArray: this.layoutVertexArray.serialize(transferables),
elementArray: this.elementArray.serialize(transferables),
indexArray: this.indexArray.serialize(transferables),
programConfigurations: this.programConfigurations.serialize(transferables),
segments: this.segments.get(),
};
}

destroy() {
this.layoutVertexBuffer.destroy();
this.elementBuffer.destroy();
this.indexBuffer.destroy();
this.programConfigurations.destroy();
this.segments.destroy();
}
Expand All @@ -127,7 +127,7 @@ class FillExtrusionBucket implements Bucket {
numVertices += ring.length;
}

const segment = this.segments.prepareSegment(numVertices * 5, this.layoutVertexArray, this.elementArray);
const segment = this.segments.prepareSegment(numVertices * 5, this.layoutVertexArray, this.indexArray);

const flattened = [];
const holeIndices = [];
Expand Down Expand Up @@ -166,8 +166,8 @@ class FillExtrusionBucket implements Bucket {

const bottomRight = segment.vertexLength;

this.elementArray.emplaceBack(bottomRight, bottomRight + 1, bottomRight + 2);
this.elementArray.emplaceBack(bottomRight + 1, bottomRight + 2, bottomRight + 3);
this.indexArray.emplaceBack(bottomRight, bottomRight + 1, bottomRight + 2);
this.indexArray.emplaceBack(bottomRight + 1, bottomRight + 2, bottomRight + 3);

segment.vertexLength += 4;
segment.primitiveLength += 2;
Expand All @@ -184,7 +184,7 @@ class FillExtrusionBucket implements Bucket {
assert(triangleIndices.length % 3 === 0);

for (let j = 0; j < triangleIndices.length; j += 3) {
this.elementArray.emplaceBack(
this.indexArray.emplaceBack(
indices[triangleIndices[j]],
indices[triangleIndices[j + 1]],
indices[triangleIndices[j + 2]]);
Expand Down
Loading

0 comments on commit 571b32b

Please sign in to comment.