diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index 6ff983dedc0..c6ab1b3dea5 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -29,8 +29,8 @@ Tile | + ArrayGroup { | globalProperties: { zoom } | layoutVertexArray, - | elementArray, - | elementArray2, + | indexArray, + | indexArray2, | layerData: { | [style layer id]: { | programConfiguration, diff --git a/src/data/bucket.js b/src/data/bucket.js index e48b115d3ad..70a573640fa 100644 --- a/src/data/bucket.js +++ b/src/data/bucket.js @@ -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 diff --git a/src/data/bucket/circle_bucket.js b/src/data/bucket/circle_bucket.js index 57db71b2b87..49686aa7a27 100644 --- a/src/data/bucket/circle_bucket.js +++ b/src/data/bucket/circle_bucket.js @@ -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'); @@ -18,7 +18,7 @@ const circleInterface = { layoutAttributes: [ {name: 'a_pos', components: 2, type: 'Int16'} ], - elementArrayType: TriangleElementArray, + indexArrayType: TriangleIndexArray, paintAttributes: [ {property: 'circle-color'}, @@ -57,8 +57,8 @@ class CircleBucket implements Bucket { layoutVertexArray: StructArray; layoutVertexBuffer: VertexBuffer; - elementArray: StructArray; - elementBuffer: IndexBuffer; + indexArray: StructArray; + indexBuffer: IndexBuffer; programConfigurations: ProgramConfigurationSet; segments: SegmentVector; @@ -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(); } @@ -100,7 +100,7 @@ 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(), }; @@ -108,7 +108,7 @@ class CircleBucket implements Bucket { destroy() { this.layoutVertexBuffer.destroy(); - this.elementBuffer.destroy(); + this.indexBuffer.destroy(); this.programConfigurations.destroy(); this.segments.destroy(); } @@ -131,7 +131,7 @@ 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); @@ -139,8 +139,8 @@ class CircleBucket implements Bucket { 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; diff --git a/src/data/bucket/fill_bucket.js b/src/data/bucket/fill_bucket.js index 6ed44bae928..615077e4e24 100644 --- a/src/data/bucket/fill_bucket.js +++ b/src/data/bucket/fill_bucket.js @@ -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'); @@ -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'}, @@ -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; @@ -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(); @@ -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() @@ -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(); @@ -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 = []; @@ -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); } @@ -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]); diff --git a/src/data/bucket/fill_extrusion_bucket.js b/src/data/bucket/fill_extrusion_bucket.js index 19af94339bb..c900075d8ea 100644 --- a/src/data/bucket/fill_extrusion_bucket.js +++ b/src/data/bucket/fill_extrusion_bucket.js @@ -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'); @@ -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'}, @@ -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; @@ -64,8 +64,8 @@ class FillExtrusionBucket implements Bucket { layoutVertexArray: StructArray; layoutVertexBuffer: VertexBuffer; - elementArray: StructArray; - elementBuffer: IndexBuffer; + indexArray: StructArray; + indexBuffer: IndexBuffer; programConfigurations: ProgramConfigurationSet; segments: SegmentVector; @@ -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(); } @@ -107,7 +107,7 @@ 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(), }; @@ -115,7 +115,7 @@ class FillExtrusionBucket implements Bucket { destroy() { this.layoutVertexBuffer.destroy(); - this.elementBuffer.destroy(); + this.indexBuffer.destroy(); this.programConfigurations.destroy(); this.segments.destroy(); } @@ -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 = []; @@ -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; @@ -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]]); diff --git a/src/data/bucket/line_bucket.js b/src/data/bucket/line_bucket.js index 953e6e78650..66b3db5c748 100644 --- a/src/data/bucket/line_bucket.js +++ b/src/data/bucket/line_bucket.js @@ -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 vectorTileFeatureTypes = require('@mapbox/vector-tile').VectorTileFeature.types; @@ -65,7 +65,7 @@ const lineInterface = { {property: 'line-width'}, {property: 'line-width', name: 'floorwidth', useIntegerZoom: true}, ], - elementArrayType: TriangleElementArray + indexArrayType: TriangleIndexArray }; function addLineVertex(layoutVertexBuffer, point: Point, extrude: Point, round: boolean, up: boolean, dir: number, linesofar: number) { @@ -88,7 +88,7 @@ function addLineVertex(layoutVertexBuffer, point: Point, extrude: Point, round: } const LayoutVertexArrayType = createVertexArrayType(lineInterface.layoutAttributes); -const ElementArrayType = lineInterface.elementArrayType; +const IndexArrayType = lineInterface.indexArrayType; /** * @private @@ -109,8 +109,8 @@ class LineBucket implements Bucket { layoutVertexArray: StructArray; layoutVertexBuffer: VertexBuffer; - elementArray: StructArray; - elementBuffer: IndexBuffer; + indexArray: StructArray; + indexBuffer: IndexBuffer; programConfigurations: ProgramConfigurationSet; segments: SegmentVector; @@ -123,12 +123,12 @@ class LineBucket 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(lineInterface, 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(lineInterface, options.layers, options.zoom); this.segments = new SegmentVector(); } @@ -152,7 +152,7 @@ class LineBucket 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(), }; @@ -160,7 +160,7 @@ class LineBucket implements Bucket { destroy() { this.layoutVertexBuffer.destroy(); - this.elementBuffer.destroy(); + this.indexBuffer.destroy(); this.programConfigurations.destroy(); this.segments.destroy(); } @@ -201,7 +201,7 @@ class LineBucket implements Bucket { const firstVertex = vertices[first]; // we could be more precise, but it would only save a negligible amount of space - const segment = this.segments.prepareSegment(len * 10, this.layoutVertexArray, this.elementArray); + const segment = this.segments.prepareSegment(len * 10, this.layoutVertexArray, this.indexArray); this.distance = 0; @@ -463,14 +463,14 @@ class LineBucket implements Bucket { segment: Segment) { let extrude; const layoutVertexArray = this.layoutVertexArray; - const elementArray = this.elementArray; + const indexArray = this.indexArray; extrude = normal.clone(); if (endLeft) extrude._sub(normal.perp()._mult(endLeft)); addLineVertex(layoutVertexArray, currentVertex, extrude, round, false, endLeft, distance); this.e3 = segment.vertexLength++; if (this.e1 >= 0 && this.e2 >= 0) { - elementArray.emplaceBack(this.e1, this.e2, this.e3); + indexArray.emplaceBack(this.e1, this.e2, this.e3); segment.primitiveLength++; } this.e1 = this.e2; @@ -481,7 +481,7 @@ class LineBucket implements Bucket { addLineVertex(layoutVertexArray, currentVertex, extrude, round, true, -endRight, distance); this.e3 = segment.vertexLength++; if (this.e1 >= 0 && this.e2 >= 0) { - elementArray.emplaceBack(this.e1, this.e2, this.e3); + indexArray.emplaceBack(this.e1, this.e2, this.e3); segment.primitiveLength++; } this.e1 = this.e2; @@ -514,12 +514,12 @@ class LineBucket implements Bucket { segment: Segment) { extrude = extrude.mult(lineTurnsLeft ? -1 : 1); const layoutVertexArray = this.layoutVertexArray; - const elementArray = this.elementArray; + const indexArray = this.indexArray; addLineVertex(layoutVertexArray, currentVertex, extrude, false, lineTurnsLeft, 0, distance); this.e3 = segment.vertexLength++; if (this.e1 >= 0 && this.e2 >= 0) { - elementArray.emplaceBack(this.e1, this.e2, this.e3); + indexArray.emplaceBack(this.e1, this.e2, this.e3); segment.primitiveLength++; } diff --git a/src/data/bucket/symbol_bucket.js b/src/data/bucket/symbol_bucket.js index de74117badd..17eb1367b8c 100644 --- a/src/data/bucket/symbol_bucket.js +++ b/src/data/bucket/symbol_bucket.js @@ -6,7 +6,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, LineElementArray} = require('../element_array_type'); +const {TriangleIndexArray, LineIndexArray} = require('../index_array_type'); const EXTENT = require('../extent'); const {packUint8ToFloat} = require('../../shaders/encode_attribute'); const Anchor = require('../../symbol/anchor'); @@ -127,7 +127,7 @@ const symbolInterfaces = { text: { layoutAttributes: layoutAttributes, dynamicLayoutAttributes: dynamicLayoutAttributes, - elementArrayType: TriangleElementArray, + indexArrayType: TriangleIndexArray, paintAttributes: [ {property: 'text-color', name: 'fill_color'}, {property: 'text-halo-color', name: 'halo_color'}, @@ -139,7 +139,7 @@ const symbolInterfaces = { icon: { layoutAttributes: layoutAttributes, dynamicLayoutAttributes: dynamicLayoutAttributes, - elementArrayType: TriangleElementArray, + indexArrayType: TriangleIndexArray, paintAttributes: [ {property: 'icon-color', name: 'fill_color'}, {property: 'icon-halo-color', name: 'halo_color'}, @@ -155,7 +155,7 @@ const symbolInterfaces = { {name: 'a_extrude', components: 2, type: 'Int16'}, {name: 'a_data', components: 2, type: 'Uint8'} ], - elementArrayType: LineElementArray + indexArrayType: LineIndexArray } }; @@ -205,7 +205,7 @@ function addCollisionBoxVertex(layoutVertexArray, point, anchor, extrude, maxZoo type SerializedSymbolBuffer = { layoutVertexArray: SerializedStructArray, dynamicLayoutVertexArray: SerializedStructArray, - elementArray: SerializedStructArray, + indexArray: SerializedStructArray, programConfigurations: {[string]: ?SerializedProgramConfiguration}, segments: Array, }; @@ -214,8 +214,8 @@ class SymbolBuffers { layoutVertexArray: StructArray; layoutVertexBuffer: VertexBuffer; - elementArray: StructArray; - elementBuffer: IndexBuffer; + indexArray: StructArray; + indexBuffer: IndexBuffer; programConfigurations: ProgramConfigurationSet; segments: SegmentVector; @@ -225,16 +225,16 @@ class SymbolBuffers { constructor(programInterface: ProgramInterface, layers: Array, zoom: number, arrays?: SerializedSymbolBuffer) { const LayoutVertexArrayType = createVertexArrayType(programInterface.layoutAttributes); - const ElementArrayType = programInterface.elementArrayType; + const IndexArrayType = programInterface.indexArrayType; if (arrays) { this.layoutVertexBuffer = new VertexBuffer(arrays.layoutVertexArray, LayoutVertexArrayType.serialize()); - this.elementBuffer = new IndexBuffer(arrays.elementArray); + this.indexBuffer = new IndexBuffer(arrays.indexArray); this.programConfigurations = ProgramConfigurationSet.deserialize(programInterface, layers, zoom, arrays.programConfigurations); this.segments = new SegmentVector(arrays.segments); } else { this.layoutVertexArray = new LayoutVertexArrayType(); - this.elementArray = new ElementArrayType(); + this.indexArray = new IndexArrayType(); this.programConfigurations = new ProgramConfigurationSet(programInterface, layers, zoom); this.segments = new SegmentVector(); } @@ -256,7 +256,7 @@ class SymbolBuffers { serialize(transferables?: Array): SerializedSymbolBuffer { return { layoutVertexArray: this.layoutVertexArray.serialize(transferables), - elementArray: this.elementArray.serialize(transferables), + indexArray: this.indexArray.serialize(transferables), programConfigurations: this.programConfigurations.serialize(transferables), segments: this.segments.get(), dynamicLayoutVertexArray: this.dynamicLayoutVertexArray && this.dynamicLayoutVertexArray.serialize(transferables), @@ -265,7 +265,7 @@ class SymbolBuffers { destroy() { this.layoutVertexBuffer.destroy(); - this.elementBuffer.destroy(); + this.indexBuffer.destroy(); this.programConfigurations.destroy(); this.segments.destroy(); if (this.dynamicLayoutVertexBuffer) { @@ -852,7 +852,7 @@ class SymbolBucket implements Bucket { lineStartIndex: number, lineLength: number, placedSymbolArray: StructArray) { - const elementArray = arrays.elementArray; + const indexArray = arrays.indexArray; const layoutVertexArray = arrays.layoutVertexArray; const dynamicLayoutVertexArray = arrays.dynamicLayoutVertexArray; @@ -880,7 +880,7 @@ class SymbolBucket implements Bucket { br = symbol.br, tex = symbol.tex; - const segment = arrays.segments.prepareSegment(4, arrays.layoutVertexArray, arrays.elementArray); + const segment = arrays.segments.prepareSegment(4, arrays.layoutVertexArray, arrays.indexArray); const index = segment.vertexLength; const y = symbol.glyphOffset[1]; @@ -891,8 +891,8 @@ class SymbolBucket implements Bucket { addDynamicAttributes(dynamicLayoutVertexArray, labelAnchor, 0, placementZoom); - elementArray.emplaceBack(index, index + 1, index + 2); - elementArray.emplaceBack(index + 1, index + 2, index + 3); + indexArray.emplaceBack(index, index + 1, index + 2); + indexArray.emplaceBack(index + 1, index + 2, index + 3); segment.vertexLength += 4; segment.primitiveLength += 2; @@ -913,7 +913,7 @@ class SymbolBucket implements Bucket { addToDebugBuffers(collisionTile: CollisionTile) { const arrays = this.collisionBox; const layoutVertexArray = arrays.layoutVertexArray; - const elementArray = arrays.elementArray; + const indexArray = arrays.indexArray; const angle = -collisionTile.angle; const yStretch = collisionTile.yStretch; @@ -943,7 +943,7 @@ class SymbolBucket implements Bucket { const maxZoom = Math.max(0, Math.min(25, this.zoom + Math.log(box.maxScale) / Math.LN2)); const placementZoom = Math.max(0, Math.min(25, this.zoom + Math.log(box.placementScale) / Math.LN2)); - const segment = arrays.segments.prepareSegment(4, arrays.layoutVertexArray, arrays.elementArray); + const segment = arrays.segments.prepareSegment(4, arrays.layoutVertexArray, arrays.indexArray); const index = segment.vertexLength; addCollisionBoxVertex(layoutVertexArray, boxAnchorPoint, symbolInstance.anchor, tl, maxZoom, placementZoom); @@ -951,10 +951,10 @@ class SymbolBucket implements Bucket { addCollisionBoxVertex(layoutVertexArray, boxAnchorPoint, symbolInstance.anchor, br, maxZoom, placementZoom); addCollisionBoxVertex(layoutVertexArray, boxAnchorPoint, symbolInstance.anchor, bl, maxZoom, placementZoom); - elementArray.emplaceBack(index, index + 1); - elementArray.emplaceBack(index + 1, index + 2); - elementArray.emplaceBack(index + 2, index + 3); - elementArray.emplaceBack(index + 3, index); + indexArray.emplaceBack(index, index + 1); + indexArray.emplaceBack(index + 1, index + 2); + indexArray.emplaceBack(index + 2, index + 3); + indexArray.emplaceBack(index + 3, index); segment.vertexLength += 4; segment.primitiveLength += 4; diff --git a/src/data/element_array_type.js b/src/data/element_array_type.js deleted file mode 100644 index b8c34eb2bcc..00000000000 --- a/src/data/element_array_type.js +++ /dev/null @@ -1,25 +0,0 @@ -// @flow - -const createStructArrayType = require('../util/struct_array'); - -/** - * An element array stores Uint16 indicies of vertexes in a corresponding vertex array. We use - * two kinds of element arrays: arrays storing groups of three indicies, forming triangles; and - * arrays storing pairs of indicies, forming line segments. - * @private - */ - -function createElementArrayType(components: number) { - return createStructArrayType({ - members: [{ - type: 'Uint16', - name: 'vertices', - components - }] - }); -} - -module.exports = { - LineElementArray: createElementArrayType(2), - TriangleElementArray: createElementArrayType(3) -}; diff --git a/src/data/index_array_type.js b/src/data/index_array_type.js new file mode 100644 index 00000000000..b77f8589280 --- /dev/null +++ b/src/data/index_array_type.js @@ -0,0 +1,25 @@ +// @flow + +const createStructArrayType = require('../util/struct_array'); + +/** + * An index array stores Uint16 indicies of vertexes in a corresponding vertex array. We use + * two kinds of index arrays: arrays storing groups of three indicies, forming triangles; and + * arrays storing pairs of indicies, forming line segments. + * @private + */ + +function createIndexArrayType(components: number) { + return createStructArrayType({ + members: [{ + type: 'Uint16', + name: 'vertices', + components + }] + }); +} + +module.exports = { + LineIndexArray: createIndexArrayType(2), + TriangleIndexArray: createIndexArrayType(3) +}; diff --git a/src/data/program_configuration.js b/src/data/program_configuration.js index 5bb215afde2..782b2e3632f 100644 --- a/src/data/program_configuration.js +++ b/src/data/program_configuration.js @@ -27,10 +27,10 @@ export type PaintPropertyStatistics = { export type ProgramInterface = { layoutAttributes: Array, - elementArrayType: Class, + indexArrayType: Class, dynamicLayoutAttributes?: Array, paintAttributes?: Array, - elementArrayType2?: Class + indexArrayType2?: Class } function packColor(color: [number, number, number, number]): [number, number] { diff --git a/src/data/segment.js b/src/data/segment.js index 54e1c154794..876e3a0704b 100644 --- a/src/data/segment.js +++ b/src/data/segment.js @@ -18,12 +18,12 @@ class SegmentVector { this.segments = segments; } - prepareSegment(numVertices: number, layoutVertexArray: StructArray, elementArray: StructArray): Segment { + prepareSegment(numVertices: number, layoutVertexArray: StructArray, indexArray: StructArray): Segment { let segment: Segment = this.segments[this.segments.length - 1]; if (!segment || segment.vertexLength + numVertices > module.exports.MAX_VERTEX_ARRAY_LENGTH) { segment = ({ vertexOffset: layoutVertexArray.length, - primitiveOffset: elementArray.length, + primitiveOffset: indexArray.length, vertexLength: 0, primitiveLength: 0 }: any); diff --git a/src/render/draw_circle.js b/src/render/draw_circle.js index 669cfb43e4c..6d076e3ca84 100644 --- a/src/render/draw_circle.js +++ b/src/render/draw_circle.js @@ -59,7 +59,7 @@ function drawCircles(painter: Painter, sourceCache: SourceCache, layer: CircleSt gl.TRIANGLES, layer.id, bucket.layoutVertexBuffer, - bucket.elementBuffer, + bucket.indexBuffer, bucket.segments, programConfiguration); } diff --git a/src/render/draw_collision_debug.js b/src/render/draw_collision_debug.js index c91f4d7686c..6a3169a9d52 100644 --- a/src/render/draw_collision_debug.js +++ b/src/render/draw_collision_debug.js @@ -42,7 +42,7 @@ function drawCollisionDebug(painter: Painter, sourceCache: SourceCache, layer: S gl.LINES, layer.id, bucket.collisionBox.layoutVertexBuffer, - bucket.collisionBox.elementBuffer, + bucket.collisionBox.indexBuffer, bucket.collisionBox.segments); } } diff --git a/src/render/draw_fill.js b/src/render/draw_fill.js index 651c557b104..b0a29f5db5b 100644 --- a/src/render/draw_fill.js +++ b/src/render/draw_fill.js @@ -73,7 +73,7 @@ function drawFillTile(painter, sourceCache, layer, tile, coord, bucket, firstTil gl.TRIANGLES, layer.id, bucket.layoutVertexBuffer, - bucket.elementBuffer, + bucket.indexBuffer, bucket.segments, programConfiguration); } @@ -91,7 +91,7 @@ function drawStrokeTile(painter, sourceCache, layer, tile, coord, bucket, firstT gl.LINES, layer.id, bucket.layoutVertexBuffer, - bucket.elementBuffer2, + bucket.indexBuffer2, bucket.segments2, programConfiguration); } diff --git a/src/render/draw_fill_extrusion.js b/src/render/draw_fill_extrusion.js index 04d8c42a59c..5933b0fa531 100644 --- a/src/render/draw_fill_extrusion.js +++ b/src/render/draw_fill_extrusion.js @@ -143,7 +143,7 @@ function drawExtrusion(painter, source, layer, coord) { gl.TRIANGLES, layer.id, bucket.layoutVertexBuffer, - bucket.elementBuffer, + bucket.indexBuffer, bucket.segments, programConfiguration); } diff --git a/src/render/draw_line.js b/src/render/draw_line.js index a9a559505ba..68395cddc67 100644 --- a/src/render/draw_line.js +++ b/src/render/draw_line.js @@ -117,7 +117,7 @@ function drawLineTile(program, painter, tile, bucket, layer, coord, programConfi gl.TRIANGLES, layer.id, bucket.layoutVertexBuffer, - bucket.elementBuffer, + bucket.indexBuffer, bucket.segments, programConfiguration); } diff --git a/src/render/draw_symbol.js b/src/render/draw_symbol.js index a1df72fa56c..a8531396e70 100644 --- a/src/render/draw_symbol.js +++ b/src/render/draw_symbol.js @@ -210,7 +210,7 @@ function drawSymbolElements(buffers, layer, gl, program) { gl.TRIANGLES, layer.id, buffers.layoutVertexBuffer, - buffers.elementBuffer, + buffers.indexBuffer, buffers.segments, buffers.programConfigurations.get(layer.id), buffers.dynamicLayoutVertexBuffer); diff --git a/src/render/program.js b/src/render/program.js index 39f30e22aa4..dff0ac63699 100644 --- a/src/render/program.js +++ b/src/render/program.js @@ -86,7 +86,7 @@ class Program { drawMode: DrawMode, layerID: string, layoutVertexBuffer: VertexBuffer, - elementBuffer: IndexBuffer, + indexBuffer: IndexBuffer, segments: SegmentVector, configuration: ?ProgramConfiguration, dynamicLayoutBuffer: ?VertexBuffer) { @@ -104,7 +104,7 @@ class Program { gl, this, layoutVertexBuffer, - elementBuffer, + indexBuffer, configuration && configuration.paintVertexBuffer, segment.vertexOffset, dynamicLayoutBuffer); diff --git a/src/render/vertex_array_object.js b/src/render/vertex_array_object.js index b3d124c3f35..b6f4f5eb4d6 100644 --- a/src/render/vertex_array_object.js +++ b/src/render/vertex_array_object.js @@ -10,7 +10,7 @@ class VertexArrayObject { boundProgram: ?Program; boundVertexBuffer: ?VertexBuffer; boundVertexBuffer2: ?VertexBuffer; - boundElementBuffer: ?IndexBuffer; + boundIndexBuffer: ?IndexBuffer; boundVertexOffset: ?number; boundDynamicVertexBuffer: ?VertexBuffer; vao: any; @@ -20,7 +20,7 @@ class VertexArrayObject { this.boundProgram = null; this.boundVertexBuffer = null; this.boundVertexBuffer2 = null; - this.boundElementBuffer = null; + this.boundIndexBuffer = null; this.boundVertexOffset = null; this.boundDynamicVertexBuffer = null; this.vao = null; @@ -29,7 +29,7 @@ class VertexArrayObject { bind(gl: WebGLRenderingContext, program: Program, layoutVertexBuffer: VertexBuffer, - elementBuffer: ?IndexBuffer, + indexBuffer: ?IndexBuffer, vertexBuffer2: ?VertexBuffer, vertexOffset: ?number, dynamicVertexBuffer: ?VertexBuffer) { @@ -43,13 +43,13 @@ class VertexArrayObject { this.boundProgram !== program || this.boundVertexBuffer !== layoutVertexBuffer || this.boundVertexBuffer2 !== vertexBuffer2 || - this.boundElementBuffer !== elementBuffer || + this.boundIndexBuffer !== indexBuffer || this.boundVertexOffset !== vertexOffset || this.boundDynamicVertexBuffer !== dynamicVertexBuffer ); if (!gl.extVertexArrayObject || isFreshBindRequired) { - this.freshBind(gl, program, layoutVertexBuffer, elementBuffer, vertexBuffer2, vertexOffset, dynamicVertexBuffer); + this.freshBind(gl, program, layoutVertexBuffer, indexBuffer, vertexBuffer2, vertexOffset, dynamicVertexBuffer); this.gl = gl; } else { (gl: any).extVertexArrayObject.bindVertexArrayOES(this.vao); @@ -64,7 +64,7 @@ class VertexArrayObject { freshBind(gl: WebGLRenderingContext, program: Program, layoutVertexBuffer: VertexBuffer, - elementBuffer: ?IndexBuffer, + indexBuffer: ?IndexBuffer, vertexBuffer2: ?VertexBuffer, vertexOffset: ?number, dynamicVertexBuffer: ?VertexBuffer) { @@ -81,7 +81,7 @@ class VertexArrayObject { this.boundProgram = program; this.boundVertexBuffer = layoutVertexBuffer; this.boundVertexBuffer2 = vertexBuffer2; - this.boundElementBuffer = elementBuffer; + this.boundIndexBuffer = indexBuffer; this.boundVertexOffset = vertexOffset; this.boundDynamicVertexBuffer = dynamicVertexBuffer; @@ -116,8 +116,8 @@ class VertexArrayObject { dynamicVertexBuffer.bind(gl); dynamicVertexBuffer.setVertexAttribPointers(gl, program, vertexOffset); } - if (elementBuffer) { - elementBuffer.bind(gl); + if (indexBuffer) { + indexBuffer.bind(gl); } (gl: any).currentNumAttributes = numNextAttributes;