在Yuka js库中,BoundingSphere的set方法用于设置BoundingSphere的中心点和半径值。
set( center: Vector3, radius: number ): BoundingSphere
center
:一个Vector3,表示BoundingSphere的中心点。radius
:一个数字,表示BoundingSphere的半径值。一个新的BoundingSphere对象。
const boundingSphere = new BoundingSphere();
boundingSphere.set( new Vector3( 0, 0, 0 ), 1 );
以上代码将创建一个新的BoundingSphere对象,并将其中心点设置为 (0, 0, 0)
,半径值为 1
。
如果center参数不是一个Vector3对象,将抛出一个类型错误。
如果radius参数不是一个数字,将抛出一个类型错误。
执行该方法后,将会创建一个新的BoundingSphere对象并返回,原有的BoundingSphere对象将会被销毁。如果需要保留原有对象,请在调用该方法之前创建一个新变量进行存储。