gpt4 book ai didi

javascript - 如何使用 Three.js 链接两个几何对象

转载 作者:行者123 更新时间:2023-12-02 18:26:51 61 4
gpt4 key购买 nike

我们如何用一条线连接两个球体?我希望它像用绳子或弹性物体连接的球一样谁能指出一些示例吗?

最佳答案

在两点之间绘制箭头很简单:

var startPoint = new THREE.Vector3(10,20,30);
var endPoint = new THREE.Vector3(70,80,90);
var direction = new THREE.Vector3().subVectors(endPoint, startPoint).normalize();
var arrow = new THREE.ArrowHelper(direction, startPoint, startPoint.distanceTo(endPoint), 0xCC0000 );
scene.add(arrow);

只画一条线有点棘手:

var lineGeometry = new THREE.Geometry();
lineGeometry.vertices.push( new THREE.Vector3(10,20,30), new THREE.Vector3(70,80,90) );
lineGeometry.computeLineDistances();
var lineMaterial = new THREE.LineBasicMaterial( { color: 0xCC0000 } );
var line = new THREE.Line( lineGeometry, lineMaterial );
scene.add(line);

关于javascript - 如何使用 Three.js 链接两个几何对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18286837/

61 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com