当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript VertexBuffer.set_size方法代码示例

本文整理汇总了TypeScript中gloo2.VertexBuffer.set_size方法的典型用法代码示例。如果您正苦于以下问题:TypeScript VertexBuffer.set_size方法的具体用法?TypeScript VertexBuffer.set_size怎么用?TypeScript VertexBuffer.set_size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gloo2.VertexBuffer的用法示例。


在下文中一共展示了VertexBuffer.set_size方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: _set_data

 protected _set_data(nvertices: number): void {
   const n = nvertices * 4;  // in bytes
   // Set buffer size
   this.vbo_x.set_size(n)
   this.vbo_y.set_size(n)
   this.vbo_a.set_size(n)
   this.vbo_s.set_size(n)
   // Upload data for x and y, apply a baked-in offset for float32 precision (issue #3795)
   // The exact value for the baked_offset does not matter, as long as it brings the data to less extreme values
   const xx = new Float64Array(this.glyph._x)
   const yy = new Float64Array(this.glyph._y)
   for (let i = 0, end = nvertices; i < end; i++) {
      xx[i] += this._baked_offset[0]
      yy[i] += this._baked_offset[1]
   }
   this.vbo_x.set_data(0, new Float32Array(xx))
   this.vbo_y.set_data(0, new Float32Array(yy))
   // Angle if available; circle does not have angle. If we don't set data, angle is default 0 in glsl
   if (this.glyph._angle != null) {
     this.vbo_a.set_data(0, new Float32Array(this.glyph._angle))
   }
   // Radius is special; some markes allow radius in data-coords instead of screen coords
   // @radius tells us that radius is in units, sradius is the pre-calculated screen radius
   if (this.glyph instanceof CircleView && this.glyph._radius != null)
     this.vbo_s.set_data(0, new Float32Array(map(this.glyph.sradius, (s) => s*2)))
   else
     this.vbo_s.set_data(0, new Float32Array(this.glyph._size))
 }
开发者ID:gully,项目名称:bokeh,代码行数:28,代码来源:markers.ts

示例2: _set_data

    _set_data() {
      this._bake();

      this.vbo_position.set_size(this.V_position.length*4);
      this.vbo_position.set_data(0, this.V_position);

      this.vbo_tangents.set_size(this.V_tangents.length*4);
      this.vbo_tangents.set_data(0, this.V_tangents);

      this.vbo_angles.set_size(this.V_angles.length*4);
      this.vbo_angles.set_data(0, this.V_angles);

      this.vbo_texcoord.set_size(this.V_texcoord.length*4);
      return this.vbo_texcoord.set_data(0, this.V_texcoord);
    }
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:15,代码来源:line.ts

示例3: _update_scale

    _update_scale(sx, sy) {
      // Update segment data and cumsum so the length along the line has the
      // scale aspect ratio in it. In the vertex shader we multiply with the
      // "isotropic part" of the scale.

      let V_segment2;
      const n = this.nvertices;
      const m = (4 * n) - 4;
      // Prepare arrays
      const T = this.tangents;
      const N = new Float32Array(n-1);
      const V_segment = new Float32Array(n*2);  // Elements are initialized with 0
      this.V_segment = (V_segment2 = new Float32Array(m*2));
      // Calculate vector lengths - with scale aspect ratio taken into account
      for (let i = 0, end = n-1; i < end; i++) {
        N[i] = Math.sqrt(Math.pow(T[(i*2)+0] * sx, 2) + Math.pow(T[(i*2)+1] * sy, 2));
      }
      // Calculate Segments
      let cumsum = 0;
      for (let i = 0, end = n-1; i < end; i++) {
        cumsum += N[i];
        V_segment[((i+1)*2)+0] = cumsum;
        V_segment[(i*2)+1] = cumsum;
      }
      // Upscale (same loop as in _bake())
      for (let i = 0, end = n; i < end; i++) {
         for (let j = 0; j < 4; j++) {
            for (let k = 0; k < 2; k++) {
              V_segment2[(((i*4)+j)*2)+k] = V_segment[(i*2)+k];
          }
        }
      }
      // Update
      this.cumsum = cumsum;  // L[-1] in Nico's code
      this.vbo_segment.set_size(this.V_segment.length*4);
      return this.vbo_segment.set_data(0, this.V_segment);
    }
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:37,代码来源:line.ts


注:本文中的gloo2.VertexBuffer.set_size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。