Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
[GL.STENCIL_VALUE_MASK]: 0xBBBBBBBB,
[GL.STENCIL_BACK_FUNC]: GL.LEQUAL,
[GL.STENCIL_BACK_REF]: 0.5,
[GL.STENCIL_BACK_VALUE_MASK]: 0xBBBBBBBB,
// stencilOp
[GL.STENCIL_FAIL]: GL.REPLACE,
[GL.STENCIL_PASS_DEPTH_FAIL]: GL.INCR,
[GL.STENCIL_PASS_DEPTH_PASS]: GL.DECR,
[GL.STENCIL_BACK_FAIL]: GL.REPLACE,
[GL.STENCIL_BACK_PASS_DEPTH_FAIL]: GL.INCR,
[GL.STENCIL_BACK_PASS_DEPTH_PASS]: GL.DECR
};
resetParameters(gl);
setParameters(gl, parameters);
for (const key in expectedValues) {
const value = getParameter(gl, key);
t.deepEqual(value, expectedValues[key],
`got expected value ${stringifyTypedArray(value)} for key: ${getKey(GL, key)}`);
}
t.end();
});
_renderFrame() {
const {width, height, useDevicePixelRatio} = this.props;
const {gl} = this;
// Check for reasons not to draw
if (!gl || !(width > 0) || !(height > 0)) {
return;
}
this._resizeDrawingBuffer(gl.canvas, {useDevicePixelRatio});
// Updates WebGL viewport to latest props
setParameters(gl, {
viewport: [0, 0, gl.canvas.width, gl.canvas.height]
});
// Call render callback
this.props.onRenderFrame({gl});
this.props.onAfterRender(this.refs.overlay);
}
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,
id: this.props.id,
...assembleShaders(gl, {
vs: VERTEX_SHADER,
fs: FRAGMENT_SHADER
}),
geometry: new Geometry({
drawMode: GL.TRIANGLE_FAN,
positions: this.getPositions()
}),
isInstanced: true
});
}
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) {
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,
id: this.props.id,
...assembleShaders(gl, {
vs: VERTEX_SHADER,
fs: FRAGMENT_SHADER
}),
geometry: new Geometry({drawMode: GL.POINTS})
});
}
getModel(gl) {
return new Model({
gl,
id: this.props.id,
...assembleShaders(gl, {
vs: glslify('./reflection-layer-vertex.glsl'),
fs: glslify('./reflection-layer-fragment.glsl')
}),
geometry: new Geometry({
drawMode: this.props.drawContour ? GL.LINES : GL.TRIANGLES
}),
vertexCount: 0,
isIndexed: true
});
}