How to use the luma.gl.Model function in luma

To help you get started, we’ve selected a few luma examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github uber / deck.gl / showcases / wind / src / layers / elevation-layer / elevation-layer.js View on Github external
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']
    });
  }
}
github uber / deck.gl / modules / experimental-layers / src / bitmap-layer / bitmap-layer.js View on Github external
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;
github uber / deck.gl / modules / experimental-layers / src / trips-layer / trips-layer.js View on Github external
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);
github uber / deck.gl / modules / experimental-layers / src / gpu-screen-grid-layer / gpu-screen-grid-layer.js View on Github external
_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
      })
    );
  }
github uber / deck.gl / src / deprecated-layers / choropleth-layer / choropleth-layer.js View on Github external
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
    }));
  }
github uber / deck.gl / src / layers / core / icon-layer / icon-layer.js View on Github external
_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
    }));
  }
github uber / deck.gl / src / experimental-layers / src / mesh-layer / mesh-layer.js View on Github external
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
      })
    );
  }
github uber / streetscape.gl / modules / core / src / layers / mesh-layer / mesh-layer.js View on Github external
_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
      })
    );
  }
github uber / deck.gl / dist / layers / grid-layer / grid-layer.js View on Github external
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
      });
    }
  }, {
github uber / deck.gl / dist / layers / choropleth-layer / choropleth-layer.js View on Github external
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'
        })
      });
    }
  }, {

luma

A library for creating unified, beautiful shadows.

MIT
Latest version published 3 years ago

Package Health Score

67 / 100
Full package analysis