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


TypeScript gl-matrix.quat类代码示例

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


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

示例1: lookAt

export function lookAt(eye: vec3, target: vec3, up: vec3) {
  const quatOut = quat.create();
  const x = vec3.create();
  const y = vec3.create();
  const z = vec3.create();

  vec3.sub(z, eye, target);

  if (vec3.squaredLength(z) === 0) {
    // eye and target are in the same position
    z[2] = 1;
  }

  vec3.normalize(z, z);
  vec3.cross(x, up, z);

  if (vec3.squaredLength(x) === 0) {
    // eye and target are in the same vertical
    z[2] += 0.0001;
    vec3.cross(x, up, z);
  }

  vec3.normalize(x, x);
  vec3.cross(y, z, x);

  quat.setAxes(quatOut, z, x, y);
  quat.invert(quatOut, quatOut);

  return quatOut;
}
开发者ID:davidpaulrosser,项目名称:leonardo,代码行数:30,代码来源:Utils.ts

示例2: angleAxis

 /**
 * Calculate the rotation quaternion represented as pair of angle and axis.
 */
 public static angleAxis(angle: number, axis: Vector3): Quaternion {
   const axisVec = vec3.create();
   axisVec[0] = axis.X;
   axisVec[1] = axis.Y;
   axisVec[2] = axis.Z;
   const newQuat = quat.create();
   return new Quaternion(quat.setAxisAngle(newQuat, axisVec, +angle));
 }
开发者ID:kyasbal-1994,项目名称:jThree,代码行数:11,代码来源:Quaternion.ts

示例3: constructor

 constructor() {
   this.children = [];
   this.localMatrix = mat4.create();
   this.modelMatrix = mat4.create();
   this.modelViewMatrix = mat4.create();
   this.matrixAutoUpdate = true;
   this.position = new Vector3();
   this.rotation = new Vector3();
   this.scale = new Vector3(1, 1, 1);
   this.isObject3D = true;
   this.quaternion = quat.create();
   this.quaternionLookAt = quat.create();
   this.lookAtUp = vec3.create(); // needs to be [0, 0, 0] although it should be [0, 1, 0]
 }
开发者ID:davidpaulrosser,项目名称:leonardo,代码行数:14,代码来源:Object3D.ts

示例4: addSystem

addSystem('state', (e, s) => {
	if (e === events.FRAME) {
		time += s.device.tpf

		quat.fromEuler(
			rotation,
			Math.sin(0.0007 * time) * 1.1,
			time * 0.001,
			Math.sin(0.0008 * time) * 1.1
		)

		mat4.fromRotationTranslationScaleOrigin(
			wallsTransform,
			rotation,
			[0, 0, 0],
			[1, 1, 1],
			[0, 100, 0]
		)
	}
})
开发者ID:trivial-space,项目名称:playground,代码行数:20,代码来源:state.ts

示例5: updateMatrix

  public updateMatrix(camera: Camera | PerspectiveCamera | OrthographicCamera) {
    mat4.identity(this.modelViewMatrix);

    if (this.matrixAutoUpdate) {
      // Reset
      mat4.identity(this.localMatrix);
      mat4.identity(this.modelMatrix);
      quat.identity(this.quaternion);

      // If Object3D has a parent, copy the computed modelMatrix into localMatrix
      if (this.parent) {
        mat4.copy(this.localMatrix, this.parent.modelMatrix);
        mat4.multiply(this.modelMatrix, this.modelMatrix, this.localMatrix);
      }

      // Use lookAt quat as base
      // Note: this.rotation isn't updated if lookAt's used
      quat.copy(this.quaternion, this.quaternionLookAt);

      // Apply local transitions to modelMatrix
      mat4.translate(this.modelMatrix, this.modelMatrix, this.position.v);
      quat.rotateX(this.quaternion, this.quaternion, this.rotation.x);
      quat.rotateY(this.quaternion, this.quaternion, this.rotation.y);
      quat.rotateZ(this.quaternion, this.quaternion, this.rotation.z);
      axisAngle = quat.getAxisAngle(quaternionAxisAngle, this.quaternion);
      mat4.rotate(
        this.modelMatrix,
        this.modelMatrix,
        axisAngle,
        quaternionAxisAngle
      );
      mat4.scale(this.modelMatrix, this.modelMatrix, this.scale.v);
    }

    // Model View Matrix
    if (camera) {
      mat4.multiply(
        this.modelViewMatrix,
        camera.worldInverseMatrix,
        this.modelMatrix
      );
    }
  }
开发者ID:davidpaulrosser,项目名称:leonardo,代码行数:43,代码来源:Object3D.ts

示例6:

let vec2A = vec2.fromValues(1, 2);
let vec2B = vec2.fromValues(3, 4);
let vec3A = vec3.fromValues(1, 2, 3);
let vec3B = vec3.fromValues(3, 4, 5);
let vec4A = vec4.fromValues(1, 2, 3, 4);
let vec4B = vec4.fromValues(3, 4, 5, 6);
let mat2A = mat2.fromValues(1, 2, 3, 4);
let mat2B = mat2.fromValues(1, 2, 3, 4);
let mat2dA = mat2d.fromValues(1, 2, 3, 4, 5, 6);
let mat2dB = mat2d.fromValues(1, 2, 3, 4, 5, 6);
let mat3A = mat3.fromValues(1, 2, 3, 4, 5, 6, 7, 8, 9);
let mat3B = mat3.fromValues(1, 2, 3, 4, 5, 6, 7, 8, 9);
let mat4A = mat4.fromValues(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
let mat4B = mat4.fromValues(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
let quatA = quat.fromValues(1, 2, 3, 4);
let quatB = quat.fromValues(5, 6, 7, 8);

let outVec2 = vec2.create();
let outVec3 = vec3.create();
let outVec4 = vec4.create();
let outMat2 = mat2.create();
let outMat2d = mat2d.create();
let outMat3 = mat3.create();
let outMat4 = mat4.create();
let outQuat = quat.create();

let outMat2Null: mat2 | null;
let outMat2dNull: mat2d | null;
let outMat3Null: mat3 | null;
let outMat4Null: mat4 | null;
开发者ID:DenisCarriere,项目名称:DefinitelyTyped,代码行数:30,代码来源:gl-matrix-tests.ts

示例7: lookAt

 public lookAt(target: Vector3) {
   quat.identity(this.quaternionLookAt);
   this.quaternionLookAt = lookAt(this.position.v, target.v, this.lookAtUp);
 }
开发者ID:davidpaulrosser,项目名称:leonardo,代码行数:4,代码来源:Object3D.ts

示例8: slerp

 public static slerp(q1: Quaternion, q2: Quaternion, t: number): Quaternion {
   const newQuat = quat.create();
   return new Quaternion(quat.slerp(newQuat, q1.rawElements, q2.rawElements, +t));
 }
开发者ID:kyasbal-1994,项目名称:jThree,代码行数:4,代码来源:Quaternion.ts

示例9: multiply

 /**
 * Calculate multiply result of two quaternion
 */
 public static multiply(q1: Quaternion, q2: Quaternion): Quaternion {
   const newQuat = quat.create();
   return new Quaternion(quat.mul(newQuat, q1.rawElements, q2.rawElements));
 }
开发者ID:kyasbal-1994,项目名称:jThree,代码行数:7,代码来源:Quaternion.ts


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