本文整理汇总了TypeScript中THREE.Vector3.fromArray方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Vector3.fromArray方法的具体用法?TypeScript Vector3.fromArray怎么用?TypeScript Vector3.fromArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类THREE.Vector3
的用法示例。
在下文中一共展示了Vector3.fromArray方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: handleTriangle
function handleTriangle(a, b, c) {
vA.fromArray(positions, a * 3);
vB.fromArray(positions, b * 3);
vC.fromArray(positions, c * 3);
uvA.fromArray(uvs, a * 2);
uvB.fromArray(uvs, b * 2);
uvC.fromArray(uvs, c * 2);
var x1 = vB.x - vA.x;
var x2 = vC.x - vA.x;
var y1 = vB.y - vA.y;
var y2 = vC.y - vA.y;
var z1 = vB.z - vA.z;
var z2 = vC.z - vA.z;
var s1 = uvB.x - uvA.x;
var s2 = uvC.x - uvA.x;
var t1 = uvB.y - uvA.y;
var t2 = uvC.y - uvA.y;
var r = 1.0 / (s1 * t2 - s2 * t1);
sdir.set(
(t2 * x1 - t1 * x2) * r,
(t2 * y1 - t1 * y2) * r,
(t2 * z1 - t1 * z2) * r
);
tdir.set(
(s1 * x2 - s2 * x1) * r,
(s1 * y2 - s2 * y1) * r,
(s1 * z2 - s2 * z1) * r
);
tan1[a].add(sdir);
tan1[b].add(sdir);
tan1[c].add(sdir);
tan2[a].add(tdir);
tan2[b].add(tdir);
tan2[c].add(tdir);
}
示例2: function
const cgPolymer = function (p: Polymer) {
const localAngle = 20
const centerDist = 2.0
const residueStore = p.residueStore
const offset = p.residueIndexStart
const helixbundle = new Helixbundle(p)
const pos = helixbundle.position
const c1 = new Vector3()
const c2 = new Vector3()
for (let i = 0, il = p.residueCount; i < il; ++i) {
c1.fromArray(pos.center as any, i * 3) // TODO
c2.fromArray(pos.center as any, i * 3 + 3) // TODO
const d = c1.distanceTo(c2)
if (d < centerDist && d > 1.0 && pos.bending[ i ] < localAngle) {
residueStore.sstruc[ offset + i ] = 'h'.charCodeAt(0)
residueStore.sstruc[ offset + i + 1 ] = 'h'.charCodeAt(0)
}
}
}
示例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: getAxis
getAxis (localAngle: number, centerDist: number, ssBorder: boolean, colorParams: { scheme: string} & ColormakerParameters, radiusParams: RadiusParams): Axis {
localAngle = localAngle || 30
centerDist = centerDist || 2.5
ssBorder = ssBorder === undefined ? false : ssBorder
const polymer = this.polymer
const structure = polymer.structure
const n = polymer.residueCount
const residueIndexStart = polymer.residueIndexStart
const pos = this.position
const cp = colorParams || {}
cp.structure = structure
const colormaker = ColormakerRegistry.getScheme(cp)
const radiusFactory = new RadiusFactory(radiusParams)
let j = 0
let k = 0
const axis: number[] = []
const center: number[] = []
const beg: number[] = []
const end: number[] = []
const col: number[] = []
const pick = []
const size = []
const residueOffset = []
const residueCount = []
let tmpAxis = new Float32Array(n * 3)
let tmpCenter = new Float32Array(n * 3)
let _axis, _center
const _beg = new Vector3()
const _end = new Vector3()
const rp1 = structure.getResidueProxy()
const rp2 = structure.getResidueProxy()
const ap = structure.getAtomProxy()
const c1 = new Vector3()
const c2 = new Vector3()
let split = false
for (let i = 0; i < n; ++i) {
rp1.index = residueIndexStart + i
c1.fromArray(pos.center as any, i * 3)
if (i === n - 1) {
split = true
} else {
rp2.index = residueIndexStart + i + 1
c2.fromArray(pos.center as any, i * 3 + 3)
if (ssBorder && rp1.sstruc !== rp2.sstruc) {
split = true
} else if (c1.distanceTo(c2) > centerDist) {
split = true
} else if (pos.bending[ i ] > localAngle) {
split = true
}
}
if (split) {
if (i - j < 4) {
j = i
split = false
continue
}
ap.index = rp1.traceAtomIndex
// ignore first and last axis
tmpAxis = pos.axis.subarray(j * 3 + 3, i * 3)
tmpCenter = pos.center.subarray(j * 3, i * 3 + 3)
_axis = calculateMeanVector3(tmpAxis).normalize()
_center = calculateMeanVector3(tmpCenter)
_beg.fromArray(tmpCenter as any)
projectPointOnVector(_beg, _axis, _center)
_end.fromArray(tmpCenter as any, tmpCenter.length - 3)
projectPointOnVector(_end, _axis, _center)
_axis.subVectors(_end, _beg)
_axis.toArray(axis as any, k)
_center.toArray(center as any, k)
_beg.toArray(beg as any, k)
_end.toArray(end as any, k)
colormaker.atomColorToArray(ap, col, k)
pick.push(ap.index)
//.........这里部分代码省略.........
示例5: getPosition
//.........这里部分代码省略.........
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
v1.fromArray(center as any, 3) // TODO
v2.fromArray(center as any, 6) // TODO
_axis.subVectors(v1, v2).normalize()
// _center.copy( res[ 0 ].getTraceAtom() );
a1.index = polymer.getAtomIndexByType(0, type)! // TODO
_center.copy(a1 as any) // TODO
vt.copy(a1 as any) // TODO
projectPointOnVector(vt, _axis, v1)
vt.toArray(center as any, 0) // TODO
// calc first resdir
_resdir.subVectors(_center, v1)
_resdir.toArray(resdir as any, 0) // TODO
// calc axis as dir of n-1 and n-2 center pos
// project last traceAtom onto axis to get last center pos
v1.fromArray(center as any, 3 * n - 6) // TODO
v2.fromArray(center as any, 3 * n - 9) // TODO
_axis.subVectors(v1, v2).normalize()
// _center.copy( res[ n - 1 ].getTraceAtom() );
a1.index = polymer.getAtomIndexByType(n - 1, type)! // TODO
_center.copy(a1 as any) // TODO
vt.copy(a1 as any) // TODO
projectPointOnVector(vt, _axis, v1)
vt.toArray(center as any, 3 * n - 3) // TODO
// calc last three resdir
for (let i = n - 3; i < n; ++i) {
v1.fromArray(center as any, 3 * i) // TODO
// _center.copy( res[ i ].getTraceAtom() );
a1.index = polymer.getAtomIndexByType(i, type)! // TODO
_center.copy(a1 as any) // TODO
示例6: Float32Array
scene.traverseVisible(function (o) {
if (!(o instanceof Points) || !o.userData.buffer.parameters.sortParticles) {
return
}
const attributes = (o.geometry as any).attributes // TODO
const n = attributes.position.count
if (n === 0) return
matrix.multiplyMatrices(
camera.matrixWorldInverse, o.matrixWorld
)
modelViewProjectionMatrix.multiplyMatrices(
camera.projectionMatrix, matrix
)
let sortData, sortArray, zArray: Float32Array, cmpFn
if (!o.userData.sortData) {
zArray = new Float32Array(n)
sortArray = new Uint32Array(n)
cmpFn = function (ai: number, bi: number) {
const a = zArray[ ai ]
const b = zArray[ bi ]
if (a > b) return 1
if (a < b) return -1
return 0
}
sortData = {
__zArray: zArray,
__sortArray: sortArray,
__cmpFn: cmpFn
}
o.userData.sortData = sortData
} else {
sortData = o.userData.sortData
zArray = sortData.__zArray
sortArray = sortData.__sortArray
cmpFn = sortData.__cmpFn
}
for (let i = 0; i < n; ++i) {
vertex.fromArray(attributes.position.array, i * 3)
vertex.applyMatrix4(modelViewProjectionMatrix)
// negate, so that sorting order is reversed
zArray[ i ] = -vertex.z
sortArray[ i ] = i
}
quicksortCmp(sortArray, cmpFn)
let index, indexSrc, indexDst, tmpTab
for (let name in attributes) {
const attr = attributes[ name ]
const array = attr.array
const itemSize = attr.itemSize
if (!sortData[ name ]) {
sortData[ name ] = new Float32Array(itemSize * n)
}
tmpTab = sortData[ name ]
sortData[ name ] = array
for (let i = 0; i < n; ++i) {
index = sortArray[ i ]
for (let j = 0; j < itemSize; ++j) {
indexSrc = index * itemSize + j
indexDst = i * itemSize + j
tmpTab[ indexDst ] = array[ indexSrc ]
}
}
attributes[ name ].array = tmpTab
attributes[ name ].needsUpdate = true
}
})