本文整理汇总了TypeScript中THREE.Vector3.crossVectors方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Vector3.crossVectors方法的具体用法?TypeScript Vector3.crossVectors怎么用?TypeScript Vector3.crossVectors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类THREE.Vector3
的用法示例。
在下文中一共展示了Vector3.crossVectors方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: setMatrix
/**
* set transformation matrix
* @param {Matrix4} matrix - 4x4 transformation matrix
* @return {undefined}
*/
setMatrix (matrix: Matrix4) {
this.matrix.copy(matrix)
const bb = this.boundingBox
const v = this.center // temporary re-purposing
const x = this.nx - 1
const y = this.ny - 1
const z = this.nz - 1
bb.makeEmpty()
bb.expandByPoint(v.set(x, y, z))
bb.expandByPoint(v.set(x, y, 0))
bb.expandByPoint(v.set(x, 0, z))
bb.expandByPoint(v.set(x, 0, 0))
bb.expandByPoint(v.set(0, y, z))
bb.expandByPoint(v.set(0, 0, z))
bb.expandByPoint(v.set(0, y, 0))
bb.expandByPoint(v.set(0, 0, 0))
bb.applyMatrix4(this.matrix)
bb.getCenter(this.center)
// make normal matrix
const me = this.matrix.elements
const r0 = new Vector3(me[0], me[1], me[2])
const r1 = new Vector3(me[4], me[5], me[6])
const r2 = new Vector3(me[8], me[9], me[10])
const cp = new Vector3()
// [ r0 ] [ r1 x r2 ]
// M3x3 = [ r1 ] N = [ r2 x r0 ]
// [ r2 ] [ r0 x r1 ]
const ne = this.normalMatrix.elements
cp.crossVectors(r1, r2)
ne[ 0 ] = cp.x
ne[ 1 ] = cp.y
ne[ 2 ] = cp.z
cp.crossVectors(r2, r0)
ne[ 3 ] = cp.x
ne[ 4 ] = cp.y
ne[ 5 ] = cp.z
cp.crossVectors(r0, r1)
ne[ 6 ] = cp.x
ne[ 7 ] = cp.y
ne[ 8 ] = cp.z
this.inverseMatrix.getInverse(this.matrix)
}
示例2: function
const getNormal = function (atoms: number[], normal: Vector3) {
v1.set(ax[ atoms[ 0 ] ], ay[ atoms[ 0 ] ], az[ atoms[ 0 ] ])
v2.set(ax[ atoms[ 1 ] ], ay[ atoms[ 1 ] ], az[ atoms[ 1 ] ])
v3.set(ax[ atoms[ 2 ] ], ay[ atoms[ 2 ] ], az[ atoms[ 2 ] ])
d1.subVectors(v1, v2)
d2.subVectors(v1, v3)
normal.crossVectors(d1, d2)
}
示例3: handleVertex
function handleVertex(v) {
n.fromArray(normals, v * 3);
n2.copy(n);
t = tan1[v];
// Gram-Schmidt orthogonalize
tmp.copy(t);
tmp.sub(n.multiplyScalar(n.dot(t))).normalize();
// Calculate handedness
tmp2.crossVectors(n2, t);
test = tmp2.dot(tan2[v]);
w = (test < 0.0) ? - 1.0 : 1.0;
tangents[v * 4] = tmp.x;
tangents[v * 4 + 1] = tmp.y;
tangents[v * 4 + 2] = tmp.z;
tangents[v * 4 + 3] = w;
}
示例4: getPosition
getPosition (): HelixPosition {
const polymer = this.polymer
const structure = polymer.structure
const n = polymer.residueCount
const n3 = n - 3
const center = new Float32Array(3 * n)
const axis = new Float32Array(3 * n)
const diff = new Float32Array(n)
const radius = new Float32Array(n)
const rise = new Float32Array(n)
const twist = new Float32Array(n)
const resdir = new Float32Array(3 * n)
const r12 = new Vector3()
const r23 = new Vector3()
const r34 = new Vector3()
const diff13 = new Vector3()
const diff24 = new Vector3()
const v1 = new Vector3()
const v2 = new Vector3()
const vt = new Vector3()
const _axis = new Vector3()
const _prevAxis = new Vector3()
const _resdir = new Vector3()
const _center = new Vector3(0, 0, 0)
const type = 'trace'
const a1 = structure.getAtomProxy()
const a2 = structure.getAtomProxy(polymer.getAtomIndexByType(0, type))
const a3 = structure.getAtomProxy(polymer.getAtomIndexByType(1, type))
const a4 = structure.getAtomProxy(polymer.getAtomIndexByType(2, type))
for (let i = 0; i < n3; ++i) {
a1.index = a2.index
a2.index = a3.index
a3.index = a4.index
a4.index = polymer.getAtomIndexByType(i + 3, type)! // TODO
const j = 3 * i
// ported from GROMACS src/tools/gmx_helixorient.c
r12.subVectors(a2 as any, a1 as any) // TODO
r23.subVectors(a3 as any, a2 as any) // TODO
r34.subVectors(a4 as any, a3 as any) // TODO
diff13.subVectors(r12, r23)
diff24.subVectors(r23, r34)
_axis.crossVectors(diff13, diff24).normalize()
_axis.toArray(axis as any, j) // TODO
if (i > 0) {
diff[ i ] = _axis.angleTo(_prevAxis)
}
const tmp = Math.cos(diff13.angleTo(diff24))
twist[ i ] = 180.0 / Math.PI * Math.acos(tmp)
const diff13Length = diff13.length()
const diff24Length = diff24.length()
radius[ i ] = (
Math.sqrt(diff24Length * diff13Length) /
// clamp, to avoid instabilities for when
// angle between diff13 and diff24 is near 0
Math.max(2.0, 2.0 * (1.0 - tmp))
)
rise[ i ] = Math.abs(r23.dot(_axis))
//
v1.copy(diff13).multiplyScalar(radius[ i ] / diff13Length)
v2.copy(diff24).multiplyScalar(radius[ i ] / diff24Length)
v1.subVectors(a2 as any, v1) // TODO
v2.subVectors(a3 as any, v2) // TODO
v1.toArray(center as any, j + 3) // TODO
v2.toArray(center as any, j + 6) // TODO
//
_resdir.subVectors(a1 as any, _center) // TODO
_resdir.toArray(resdir as any, j) // TODO
_prevAxis.copy(_axis)
_center.copy(v1)
}
//
// calc axis as dir of second and third center pos
// project first traceAtom onto axis to get first center pos
//.........这里部分代码省略.........