Webgl / minor function renaming
This commit is contained in:
@@ -61,7 +61,7 @@ class WebGLLayerRenderer extends LayerRenderer {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pushes vertices and indices in the given buffers using the geometry coordinates and the following properties
|
* Pushes vertices and indices to the given buffers using the geometry coordinates and the following properties
|
||||||
* from the feature:
|
* from the feature:
|
||||||
* - `color`
|
* - `color`
|
||||||
* - `opacity`
|
* - `opacity`
|
||||||
@@ -79,13 +79,13 @@ class WebGLLayerRenderer extends LayerRenderer {
|
|||||||
* feature and pushed in the buffer in the given order. Note: attributes can only be numerical! Any other type or
|
* feature and pushed in the buffer in the given order. Note: attributes can only be numerical! Any other type or
|
||||||
* NaN will result in `0` being pushed in the buffer.
|
* NaN will result in `0` being pushed in the buffer.
|
||||||
*/
|
*/
|
||||||
export function pushFeatureInBuffer(vertexBuffer, indexBuffer, geojsonFeature, opt_attributes) {
|
export function pushFeatureToBuffer(vertexBuffer, indexBuffer, geojsonFeature, opt_attributes) {
|
||||||
if (!geojsonFeature.geometry) {
|
if (!geojsonFeature.geometry) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (geojsonFeature.geometry.type) {
|
switch (geojsonFeature.geometry.type) {
|
||||||
case 'Point':
|
case 'Point':
|
||||||
pushPointGeomInBuffer_(vertexBuffer, indexBuffer, geojsonFeature, opt_attributes);
|
pushPointFeatureToBuffer_(vertexBuffer, indexBuffer, geojsonFeature, opt_attributes);
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
@@ -102,7 +102,7 @@ const tmpArray_ = [];
|
|||||||
* @param {Array<string>} [opt_attributes] Custom attributes
|
* @param {Array<string>} [opt_attributes] Custom attributes
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
function pushPointGeomInBuffer_(vertexBuffer, indexBuffer, geojsonFeature, opt_attributes) {
|
function pushPointFeatureToBuffer_(vertexBuffer, indexBuffer, geojsonFeature, opt_attributes) {
|
||||||
const stride = 12 + (opt_attributes !== undefined ? opt_attributes.length : 0);
|
const stride = 12 + (opt_attributes !== undefined ? opt_attributes.length : 0);
|
||||||
|
|
||||||
const x = geojsonFeature.geometry.coordinates[0];
|
const x = geojsonFeature.geometry.coordinates[0];
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import WebGLArrayBuffer from '../../webgl/Buffer';
|
|||||||
import {DYNAMIC_DRAW, ARRAY_BUFFER, ELEMENT_ARRAY_BUFFER, FLOAT} from '../../webgl';
|
import {DYNAMIC_DRAW, ARRAY_BUFFER, ELEMENT_ARRAY_BUFFER, FLOAT} from '../../webgl';
|
||||||
import {DefaultAttrib, DefaultUniform} from '../../webgl/Helper';
|
import {DefaultAttrib, DefaultUniform} from '../../webgl/Helper';
|
||||||
import GeometryType from '../../geom/GeometryType';
|
import GeometryType from '../../geom/GeometryType';
|
||||||
import WebGLLayerRenderer, {getBlankTexture, pushFeatureInBuffer} from './Layer';
|
import WebGLLayerRenderer, {getBlankTexture, pushFeatureToBuffer} from './Layer';
|
||||||
import GeoJSON from '../../format/GeoJSON';
|
import GeoJSON from '../../format/GeoJSON';
|
||||||
import {getUid} from '../../util';
|
import {getUid} from '../../util';
|
||||||
import ViewHint from '../../ViewHint';
|
import ViewHint from '../../ViewHint';
|
||||||
@@ -391,7 +391,7 @@ class WebGLPointsLayerRenderer extends WebGLLayerRenderer {
|
|||||||
geojsonFeature.properties.opacity = this.opacityCallback_(feature);
|
geojsonFeature.properties.opacity = this.opacityCallback_(feature);
|
||||||
geojsonFeature.properties.rotateWithView = this.rotateWithViewCallback_(feature) ? 1 : 0;
|
geojsonFeature.properties.rotateWithView = this.rotateWithViewCallback_(feature) ? 1 : 0;
|
||||||
|
|
||||||
pushFeatureInBuffer(this.verticesBuffer_, this.indicesBuffer_, geojsonFeature);
|
pushFeatureToBuffer(this.verticesBuffer_, this.indicesBuffer_, geojsonFeature);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.helper_.flushBufferData(ARRAY_BUFFER, this.verticesBuffer_);
|
this.helper_.flushBufferData(ARRAY_BUFFER, this.verticesBuffer_);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import WebGLLayerRenderer, {getBlankTexture, pushFeatureInBuffer} from '../../../../../src/ol/renderer/webgl/Layer';
|
import WebGLLayerRenderer, {getBlankTexture, pushFeatureToBuffer} from '../../../../../src/ol/renderer/webgl/Layer';
|
||||||
import WebGLArrayBuffer from '../../../../../src/ol/webgl/Buffer';
|
import WebGLArrayBuffer from '../../../../../src/ol/webgl/Buffer';
|
||||||
import Layer from '../../../../../src/ol/layer/Layer';
|
import Layer from '../../../../../src/ol/layer/Layer';
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ describe('ol.renderer.webgl.Layer', function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('pushFeatureInBuffer', function() {
|
describe('pushFeatureToBuffer', function() {
|
||||||
let vertexBuffer, indexBuffer;
|
let vertexBuffer, indexBuffer;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
@@ -46,7 +46,7 @@ describe('ol.renderer.webgl.Layer', function() {
|
|||||||
},
|
},
|
||||||
geometry: null
|
geometry: null
|
||||||
};
|
};
|
||||||
pushFeatureInBuffer(vertexBuffer, indexBuffer, feature);
|
pushFeatureToBuffer(vertexBuffer, indexBuffer, feature);
|
||||||
expect(vertexBuffer.getArray().length).to.eql(0);
|
expect(vertexBuffer.getArray().length).to.eql(0);
|
||||||
expect(indexBuffer.getArray().length).to.eql(0);
|
expect(indexBuffer.getArray().length).to.eql(0);
|
||||||
});
|
});
|
||||||
@@ -65,7 +65,7 @@ describe('ol.renderer.webgl.Layer', function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
const attributePerVertex = 12;
|
const attributePerVertex = 12;
|
||||||
pushFeatureInBuffer(vertexBuffer, indexBuffer, feature);
|
pushFeatureToBuffer(vertexBuffer, indexBuffer, feature);
|
||||||
expect(vertexBuffer.getArray().length).to.eql(attributePerVertex * 4);
|
expect(vertexBuffer.getArray().length).to.eql(attributePerVertex * 4);
|
||||||
expect(indexBuffer.getArray().length).to.eql(6);
|
expect(indexBuffer.getArray().length).to.eql(6);
|
||||||
});
|
});
|
||||||
@@ -84,8 +84,8 @@ describe('ol.renderer.webgl.Layer', function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
const attributePerVertex = 12;
|
const attributePerVertex = 12;
|
||||||
pushFeatureInBuffer(vertexBuffer, indexBuffer, feature);
|
pushFeatureToBuffer(vertexBuffer, indexBuffer, feature);
|
||||||
pushFeatureInBuffer(vertexBuffer, indexBuffer, feature);
|
pushFeatureToBuffer(vertexBuffer, indexBuffer, feature);
|
||||||
expect(vertexBuffer.getArray()[0]).to.eql(-75);
|
expect(vertexBuffer.getArray()[0]).to.eql(-75);
|
||||||
expect(vertexBuffer.getArray()[1]).to.eql(47);
|
expect(vertexBuffer.getArray()[1]).to.eql(47);
|
||||||
expect(vertexBuffer.getArray()[0 + attributePerVertex]).to.eql(-75);
|
expect(vertexBuffer.getArray()[0 + attributePerVertex]).to.eql(-75);
|
||||||
@@ -125,7 +125,7 @@ describe('ol.renderer.webgl.Layer', function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
const attributePerVertex = 16;
|
const attributePerVertex = 16;
|
||||||
pushFeatureInBuffer(vertexBuffer, indexBuffer, feature, ['custom', 'custom2', 'customString', 'customString2']);
|
pushFeatureToBuffer(vertexBuffer, indexBuffer, feature, ['custom', 'custom2', 'customString', 'customString2']);
|
||||||
expect(vertexBuffer.getArray().length).to.eql(attributePerVertex * 4);
|
expect(vertexBuffer.getArray().length).to.eql(attributePerVertex * 4);
|
||||||
expect(indexBuffer.getArray().length).to.eql(6);
|
expect(indexBuffer.getArray().length).to.eql(6);
|
||||||
expect(vertexBuffer.getArray()[12]).to.eql(4);
|
expect(vertexBuffer.getArray()[12]).to.eql(4);
|
||||||
|
|||||||
Reference in New Issue
Block a user