本文整理汇总了TypeScript中gl-matrix.quat.create方法的典型用法代码示例。如果您正苦于以下问题:TypeScript quat.create方法的具体用法?TypeScript quat.create怎么用?TypeScript quat.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gl-matrix.quat
的用法示例。
在下文中一共展示了quat.create方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: 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]
}
示例2: 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;
}
示例3: 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));
}
示例4:
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;
// vec2
outVec2 = vec2.create();
outVec2 = vec2.clone(vec2A);
outVec2 = vec2.fromValues(1, 2);
outVec2 = vec2.copy(outVec2, vec2A);
outVec2 = vec2.set(outVec2, 1, 2);
outVec2 = vec2.add(outVec2, vec2A, vec2B);
outVec2 = vec2.subtract(outVec2, vec2A, vec2B);
outVec2 = vec2.sub(outVec2, vec2A, vec2B);
示例5:
import { mat4, quat } from 'gl-matrix'
import { addSystem } from 'shared-utils/painterState'
import * as geo from 'tvs-libs/dist/math/geometry'
import { events } from './context'
import { groundHeight } from './geometries'
let time = 0
export const wallsTransform = mat4.create()
const rotation = quat.create()
export const floorTransform = mat4.create()
export const floorMirrorView = mat4.create()
const planeEquation = geo.planeFromNormalAndCoplanarPoint(
[0, 1, 0],
[0, groundHeight, 0]
)
export const floorMirrorMatrix = geo.mirrorMatrixFromPlane(planeEquation)
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
)
示例6: 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));
}
示例7: 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));
}
示例8: inverse
public inverse(): Quaternion {
const newQuat = quat.create();
return new Quaternion(quat.invert(newQuat, this.rawElements));
}
示例9: normalize
/**
* Get normalized quaternion
*/
public normalize(): Quaternion {
const newQuat = quat.create();
return new Quaternion(quat.normalize(newQuat, this.rawElements));
}
示例10: Conjugate
/**
* Get the conjugate of this quaternion
*/
public get Conjugate(): Quaternion {
const newQuat = quat.create();
return new Quaternion(quat.conjugate(newQuat, this.rawElements));
}