本文整理汇总了TypeScript中THREE.Vector3.applyMatrix4方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Vector3.applyMatrix4方法的具体用法?TypeScript Vector3.applyMatrix4怎么用?TypeScript Vector3.applyMatrix4使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类THREE.Vector3
的用法示例。
在下文中一共展示了Vector3.applyMatrix4方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: closeAtom
/**
* Close-by atom
* @type {AtomProxy}
*/
get closeAtom () {
const cp = this.canvasPosition
const ca = this.closestBondAtom!
if (!ca) return undefined
const acp = this.controls.getPositionOnCanvas(ca as any) // TODO
ca.positionToVector3(tmpVec)
if (this.instance) tmpVec.applyMatrix4(this.instance.matrix)
tmpVec.applyMatrix4(this.component.matrix)
const viewer = this.controls.viewer
tmpVec.add(viewer.translationGroup.position)
tmpVec.applyMatrix4(viewer.rotationGroup.matrix)
const scaleFactor = this.controls.getCanvasScaleFactor(tmpVec.z)
const sc = this.component as StructureComponent
const radius = sc.getMaxRepresentationRadius(ca.index)
//console.log(scaleFactor, cp.distanceTo(acp), radius/scaleFactor, radius)
if (cp.distanceTo(acp) <= radius/scaleFactor) {
return ca
} else {
return undefined
}
}
示例2: _applyTransformations
_applyTransformations (vector: Vector3, instance: any, component: Component) {
if (instance) {
vector.applyMatrix4(instance.matrix)
}
if (component) {
vector.applyMatrix4(component.matrix)
}
return vector
}
示例3: getImagePlaneGeo
private getImagePlaneGeo(transform: Transform, node: Node): THREE.Geometry {
if (!node.mesh.populated ||
transform.scale < 1e-2 ||
transform.scale > 50) {
return this.getFlatImagePlaneGeo(transform);
}
let geometry: THREE.Geometry = new THREE.Geometry();
let t: THREE.Matrix4 = new THREE.Matrix4().getInverse(transform.srt);
// push everything at least 5 meters in front of the camera
let minZ: number = 5.0 * transform.scale;
let maxZ: number = this.imagePlaneDepth * transform.scale;
for (let v of node.mesh.vertices) {
let z: number = Math.max(minZ, Math.min(v[2], maxZ));
let factor: number = z / v[2];
let p: THREE.Vector3 = new THREE.Vector3(v[0] * factor, v[1] * factor, z);
p.applyMatrix4(t);
geometry.vertices.push(p);
}
for (let f of node.mesh.faces) {
geometry.faces.push(new THREE.Face3(f[0], f[1], f[2]));
}
return geometry;
}
示例4: pan
pan (x: number, y: number) {
this._setPanVector(x, y)
tmpPanMatrix.getInverse(this.viewer.rotationGroup.matrix)
tmpPanVector.applyMatrix4(tmpPanMatrix)
this.controls.translate(tmpPanVector)
}
示例5: _transformPanVector
private _transformPanVector () {
if (!this.component) return
tmpPanMatrix.extractRotation(this.component.transform)
tmpPanMatrix.premultiply(this.viewer.rotationGroup.matrix)
tmpPanMatrix.getInverse(tmpPanMatrix)
tmpPanVector.applyMatrix4(tmpPanMatrix)
}
示例6: rotateComponent
rotateComponent (x: number, y: number) {
if (!this.component) return
const [ dx, dy ] = this._getRotateXY(x, y)
tmpRotateMatrix.extractRotation(this.component.transform)
tmpRotateMatrix.premultiply(this.viewer.rotationGroup.matrix)
tmpRotateMatrix.getInverse(tmpRotateMatrix)
tmpRotateVector.set(1, 0, 0)
tmpRotateVector.applyMatrix4(tmpRotateMatrix)
tmpRotateXMatrix.makeRotationAxis(tmpRotateVector, dy)
tmpRotateVector.set(0, 1, 0)
tmpRotateVector.applyMatrix4(tmpRotateMatrix)
tmpRotateYMatrix.makeRotationAxis(tmpRotateVector, dx)
tmpRotateXMatrix.multiply(tmpRotateYMatrix)
tmpRotateQuaternion.setFromRotationMatrix(tmpRotateXMatrix)
this.component.quaternion.premultiply(tmpRotateQuaternion)
this.component.updateMatrix()
}
示例7: panAtom
panAtom (x: number, y: number) {
if (!this.atom || !this.component) return
this.atom.positionToVector3(tmpAtomVector)
tmpAtomVector.add(this.viewer.translationGroup.position)
tmpAtomVector.applyMatrix4(this.viewer.rotationGroup.matrix)
this._setPanVector(x, y, tmpAtomVector.z)
this._transformPanVector()
this.atom.positionAdd(tmpPanVector)
this.component.updateRepresentations({ 'position': true })
}
示例8: _getImageSphereGeo
private _getImageSphereGeo(transform: Transform, node: Node): THREE.BufferGeometry {
let t: THREE.Matrix4 = new THREE.Matrix4().getInverse(transform.srt);
// push everything at least 5 meters in front of the camera
let minZ: number = 5.0 * transform.scale;
let maxZ: number = this._imageSphereRadius * transform.scale;
let vertices: number[] = node.mesh.vertices;
let numVertices: number = vertices.length / 3;
let positions: Float32Array = new Float32Array(vertices.length);
for (let i: number = 0; i < numVertices; ++i) {
let index: number = 3 * i;
let x: number = vertices[index + 0];
let y: number = vertices[index + 1];
let z: number = vertices[index + 2];
let l: number = Math.sqrt(x * x + y * y + z * z);
let boundedL: number = Math.max(minZ, Math.min(l, maxZ));
let factor: number = boundedL / l;
let p: THREE.Vector3 = new THREE.Vector3(x * factor, y * factor, z * factor);
p.applyMatrix4(t);
positions[index + 0] = p.x;
positions[index + 1] = p.y;
positions[index + 2] = p.z;
}
let faces: number[] = node.mesh.faces;
let indices: Uint16Array = new Uint16Array(faces.length);
for (let i: number = 0; i < faces.length; ++i) {
indices[i] = faces[i];
}
let geometry: THREE.BufferGeometry = new THREE.BufferGeometry();
geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3));
geometry.setIndex(new THREE.BufferAttribute(indices, 1));
return geometry;
}
示例9: 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
}
})