本文整理汇总了TypeScript中THREE.Vector3.sub方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Vector3.sub方法的具体用法?TypeScript Vector3.sub怎么用?TypeScript Vector3.sub使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类THREE.Vector3
的用法示例。
在下文中一共展示了Vector3.sub方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: projectPointOnVector
export function projectPointOnVector (point: Vector3, vector: Vector3, origin?: Vector3) {
if (origin) {
point.sub(origin).projectOnVector(vector).add(origin)
} else {
point.projectOnVector(vector)
}
return point
}
示例2: getBoundingBoxCenter
export function getBoundingBoxCenter(box: BoundingBox) {
const min = new Vector3(...box.min);
const max = new Vector3(...box.max);
const center = getPointAtDistance(min, max, 0.5);
const diff = max.sub(min);
const z = Math.max(...diff.toArray());
const target = center.clone()
.setZ(z);
return {
center,
target
};
}
示例3: if
path.forEach((point, ind) => {
if (ind === 0 || ind === path.length - 1) {
newPath.push(point);
return;
}
var tmpNeighbour = neighbour;
if (ind < neighbour) {
tmpNeighbour = ind;
} else if (ind >= path.length - neighbour) {
tmpNeighbour = path.length - 1 - ind;
}
var newPoint = new Vector3();
for (var i = ind - tmpNeighbour; i <= ind + tmpNeighbour; i++) {
newPoint.add(path[i]);
}
newPoint.divideScalar(tmpNeighbour * 2 + 1);
var starInd = pointToStar[ind];
if (starInd !== null) {
var star = this._stars[starInd];
newPoint.sub(star.position).clampLength(this._getDist(star), 1/0).add(star.position);
}
newPath.push(newPoint);
});
示例4: store
const onDocumentMouseDown = (event) => {
let state: State = store().getState()
let scene: THREE.Scene = getScene(state)
let camera: THREE.Camera = getCamera(state)
let renderer: THREE.Renderer = getRenderer(state)
event.preventDefault()
mouse.x = (event.clientX / renderer.domElement.width) * 2 - 1
mouse.y = -(event.clientY / renderer.domElement.height) * 2 + 1
let vector = new THREE.Vector3(mouse.x, mouse.y, 0.5)
vector.unproject(camera)
let dir = vector.sub(camera.position).normalize()
let distance = -camera.position.z / dir.z
let pos = camera.position.clone().add(dir.multiplyScalar(distance))
pos.z = 250
store().dispatch({
type: 'MOUSE_DOWN',
pos: pos
})
}
示例5: 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;
}