• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript gl-matrix.vec2类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中gl-matrix.vec2的典型用法代码示例。如果您正苦于以下问题:TypeScript vec2类的具体用法?TypeScript vec2怎么用?TypeScript vec2使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: tileToViewport

 /**
  * viewportPos = viewportFromSquare * squareFromMap * mapFromTile * tilePos
  * viewportPos = (viewportFromClip * verticalFlip * clipFromSquare) * squareFromMap * (verticalFlip * mapFromTile) * tilePos
  */
 tileToViewport(...pos : number[]) : PosXY{
   let vec = pos as any as vec2;
   vec2.transformMat2d(vec, vec, this.mapFromTileMatrix);
   vec2.transformMat2d(vec, vec, this.squareFromMapMatrix);
   vec2.transformMat2d(vec, vec, this.viewportFromSquareMatrix);
   return vec as any as PosXY;
 }
开发者ID:mariusGundersen,项目名称:Ekkiog,代码行数:11,代码来源:Perspective.ts


示例2: viewportToTile

 /**
  * tilePos = mapToTile * squareToMap * viewportToSquare * viewportPos
  * tilePos = (mapToTile * verticalFlip) * squareToMap * (clipToSquare * verticalFlip * viewportToClip) * viewportPos
  */
 viewportToTile(...pos : number[]) : PosXY{
   let vec = pos as any as vec2;
   vec2.transformMat2d(vec, vec, this.viewportToSquareMatrix);
   vec2.transformMat2d(vec, vec, this.squareToMapMatrix);
   vec2.transformMat2d(vec, vec, this.mapToTileMatrix);
   return vec as any as PosXY;
 }
开发者ID:mariusGundersen,项目名称:Ekkiog,代码行数:11,代码来源:Perspective.ts


示例3: reset

 /** Resets to fit tiles in viewport */
 reset({top, left, bottom, right} : Box){
   const topLeft = [left, top] as PosXY;
   const bottomRight = [right, bottom] as PosXY;
   vec2.transformMat2d(topLeft as any, topLeft, this.mapFromTileMatrix);
   vec2.transformMat2d(bottomRight as any, bottomRight, this.mapFromTileMatrix);
   this.transformMapToSquare(
     [topLeft, [-1,1]],
     [bottomRight, [ 1,-1]]
   );
 }
开发者ID:mariusGundersen,项目名称:Ekkiog,代码行数:11,代码来源:Perspective.ts


示例4: constructor

  constructor(gl : WebGLRenderingContext, image : HTMLImageElement){
    super(gl, 0);
    this.width = image.width;
    this.height = image.height;
    this.image = image;

    vec2.set(this.size, image.width, image.height);
    vec2.set(this.halfSize, image.width/2, image.height/2);
    vec2.set(this.inverseSize, 1/image.width, 1/image.height);

    this.update();
  }
开发者ID:mariusGundersen,项目名称:Ekkiog,代码行数:12,代码来源:ImageTexture.ts


示例5: constructor

  constructor(gl : WebGLRenderingContext, width=0, height=width){
    this.gl = gl;
    this.texture = gl.createTexture() || (() => {throw new Error("Could not make texture")})();

    this.width = width;
    this.height = height;

    this.size = vec2.fromValues(width, height);
    this.halfSize = vec2.fromValues(width/2, height/2);
    this.inverseSize = vec2.fromValues(1/width, 1/height);

    this.bind();

    this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MAG_FILTER, this.gl.NEAREST);
    this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MIN_FILTER, this.gl.NEAREST);

    this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_S, this.gl.CLAMP_TO_EDGE);
    this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_T, this.gl.CLAMP_TO_EDGE);
  }
开发者ID:mariusGundersen,项目名称:Ekkiog,代码行数:19,代码来源:Texture.ts


示例6: intersectObject

  public intersectObject(object: Mesh) {
    if (!object.visible) return;
    let intersect;
    let uv;
    let face;

    // Check sphere
    if (object.boundingSphere === undefined) object.computeBoundingSphere();
    sphere.copy(object.boundingSphere);
    // Apply object modelMatrix, incase object has been transformed
    sphere.applyMatrix(object.modelMatrix);

    // Exit if the ray doesn't intersect the sphere
    if (!this.ray.intersectsSphere(sphere)) {
      return;
    }

    for (const f of object.geometry.faces) {
      vec3.copy(fvA.v, f.vertices[0].v);
      vec3.copy(fvB.v, f.vertices[1].v);
      vec3.copy(fvC.v, f.vertices[2].v);

      // Multiply vertices by object matrix
      vec3.transformMat4(fvA.v, fvA.v, object.modelMatrix);
      vec3.transformMat4(fvB.v, fvB.v, object.modelMatrix);
      vec3.transformMat4(fvC.v, fvC.v, object.modelMatrix);

      intersect = this.ray.intersectTriangle(fvA, fvB, fvC);

      if (intersect) {
        // Get uv intersection
        vec2.copy(uvA.v, object.geometry.uvs[f.uvs[0]].v);
        vec2.copy(uvB.v, object.geometry.uvs[f.uvs[1]].v);
        vec2.copy(uvC.v, object.geometry.uvs[f.uvs[2]].v);
        face = f;
        uv = this.uvIntersection(intersect, fvA, fvB, fvC);
        break;
      }
    }

    return intersect ? { point: intersect, uv, face } : null;
  }
开发者ID:davidpaulrosser,项目名称:leonardo,代码行数:42,代码来源:Raycaster.ts


示例7: distance

 public distance(vector2: Vector2) {
   return vec2.distance(this.v, vector2.v);
 }
开发者ID:davidpaulrosser,项目名称:leonardo,代码行数:3,代码来源:Vector2.ts


示例8: constructor

 constructor(x = 0, y = 0) {
   this.v = vec2.create();
   this.set(x, y);
   return this;
 }
开发者ID:davidpaulrosser,项目名称:leonardo,代码行数:5,代码来源:Vector2.ts


示例9: scale

 public scale(value: number) {
   vec2.scale(this.v, this.v, value);
   return this;
 }
开发者ID:davidpaulrosser,项目名称:leonardo,代码行数:4,代码来源:Vector2.ts


示例10: subtractVectors

 public subtractVectors(vector0: Vector2, vector1: Vector2) {
   const out = vec2.create();
   vec2.subtract(out, vector0.v, vector1.v);
   return out;
 }
开发者ID:davidpaulrosser,项目名称:leonardo,代码行数:5,代码来源:Vector2.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript gl-matrix.vec3类代码示例发布时间:2022-05-25
下一篇:
TypeScript gl-matrix.quat类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap