fromPoints是Yuka js库中的一个方法,它用于计算一组点的最小外接球体。
BoundingSphere.fromPoints( points, result );
points:一个包含点的数组。result:计算结果的BoundingSphere实例。const points = [
new Vector3( 0, 0, 0 ),
new Vector3( 0, 1, 0 ),
new Vector3( 1, 0, 0 ),
new Vector3( 1, 1, 0 ),
new Vector3( 0.5, 0.5, 1 )
];
const boundingSphere = new BoundingSphere();
BoundingSphere.fromPoints( points, boundingSphere );
此示例将使用给定点的坐标计算最小外接球体,并将其存储在boundingSphere变量中。
result参数未提供,则将创建一个新的BoundingSphere实例并返回。points参数必须包含至少一个点。 否则,该方法将不会运行并引发错误。