Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const vsShader = shaders.vs;
const fsSource = shaders.fs;
const fsShader = `\
precision highp float;
${fsSource}`;
const {lngResolution, latResolution, boundingBox} = this.props;
const geometry = new GridGeometry({
xResolution: lngResolution,
yResolution: latResolution,
boundingBox
});
return new Model(gl, {
id: this.props.id,
vs: vsShader,
fs: fsShader,
geometry,
// FIXME - isIndexed should be set in "GridGeometry"
isIndexed: true,
modules: ['lighting']
});
}
}
getModel(gl) {
// Two triangles making up a square to render the bitmap texture on
const verts = [[1, 1, 0], [-1, 1, 0], [1, -1, 0], [-1, 1, 0], [1, -1, 0], [-1, -1, 0]];
const positions = [];
const texCoords = [];
verts.forEach(vertex => {
// geometry: unit square centered on origin
positions.push(vertex[0] / 2, vertex[1] / 2, vertex[2] / 2);
// texture: unit square with bottom left in origin
texCoords.push(vertex[0] / 2 + 0.5, -vertex[1] / 2 + 0.5);
});
const model = new Model(gl, {
id: this.props.id,
vs: BITMAP_VERTEX_SHADER,
fs: BITMAP_FRAGMENT_SHADER,
shaderCache: this.context.shaderCache,
geometry: new Geometry({
drawMode: GL.TRIANGLES,
vertexCount: 6,
attributes: {
positions: new Float32Array(positions),
texCoords: new Float32Array(texCoords)
}
}),
isInstanced: true
});
return model;
getModel(gl) {
return new Model(gl, {
id: this.props.id,
vs: tripsVertex,
fs: tripsFragment,
geometry: new Geometry({
id: this.props.id,
drawMode: 'LINES'
}),
vertexCount: 0,
isIndexed: true,
// TODO-state-management: onBeforeRender can go to settings, onAfterRender, we should
// move this settings of corresponding draw.
onBeforeRender: () => {
gl.enable(gl.BLEND);
gl.enable(gl.POLYGON_OFFSET_FILL);
gl.polygonOffset(2.0, 1.0);
gl.blendFunc(gl.SRC_ALPHA, gl.ONE);
_getModel(gl) {
return new Model(
gl,
Object.assign({}, this.getShaders(), {
id: this.props.id,
geometry: new Geometry({
drawMode: GL.TRIANGLE_FAN,
attributes: {
vertices: new Float32Array([0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0])
}
}),
isInstanced: true,
shaderCache: this.context.shaderCache
})
);
}
getModel(gl) {
return new Model(gl, Object.assign({}, this.getShaders(), {
id: this.props.id,
geometry: new Geometry({
drawMode: this.props.drawContour ? GL.LINES : GL.TRIANGLES
}),
vertexCount: 0,
isIndexed: true,
shaderCache: this.context.shaderCache
}));
}
_getModel(gl) {
const positions = [-1, -1, 0, -1, 1, 0, 1, 1, 0, 1, -1, 0];
return new Model(gl, Object.assign({}, this.getShaders(), {
id: this.props.id,
geometry: new Geometry({
drawMode: GL.TRIANGLE_FAN,
positions: new Float32Array(positions)
}),
isInstanced: true,
shaderCache: this.context.shaderCache
}));
}
getModel(gl) {
const isValidMesh = this.props.mesh instanceof Geometry && this.props.mesh.attributes.positions;
assert(isValidMesh);
return new Model(
gl,
Object.assign({}, this.getShaders(), {
id: this.props.id,
geometry: this.props.mesh,
isInstanced: true
})
);
}
_getModel(gl) {
if (!this.props.mesh) {
return null;
}
return new Model(
gl,
Object.assign({}, this.getShaders(), {
id: this.props.id,
geometry: getGeometry(this.props.mesh),
drawMode: this.props.wireframe ? GL.LINE_STRIP : GL.TRIANGLES,
isInstanced: true,
shaderCache: this.context.shaderCache
})
);
}
value: function getModel(gl) {
return new _luma.Model({
program: new _luma.Program(gl, {
vs: glslify('./grid-layer-vertex.glsl'),
fs: glslify('./grid-layer-fragment.glsl'),
id: 'grid'
}),
geometry: new _luma.Geometry({
id: this.props.id,
drawMode: 'TRIANGLE_FAN',
vertices: new Float32Array([0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0])
}),
instanced: true
});
}
}, {
value: function getModel(gl) {
return new _luma.Model({
program: new _luma.Program(gl, {
vs: glslify('./choropleth-layer-vertex.glsl'),
fs: glslify('./choropleth-layer-fragment.glsl'),
id: 'choropleth'
}),
geometry: new _luma.Geometry({
id: this.props.id,
drawMode: this.props.drawContour ? 'LINES' : 'TRIANGLES'
})
});
}
}, {