toJSON
方法用于将Yuka.js库的BoundingSphere对象转化为JSON格式的字符串。
toJSON()
一个表示Yuka.js库的BoundingSphere对象的JSON字符串。
const boundingSphere = new BoundingSphere( new Vector3( 10, 20, 30 ), 5 );
const json = boundingSphere.toJSON();
console.log( json );
输出结果:
{"type":"BoundingSphere","center":{"x":10,"y":20,"z":30},"radius":5}
该方法没有任何参数。
该方法不会抛出异常。
JSON字符串中的每个对象都包含 type
属性,表示对象的类型。BoundingSphere
类对应的 type
属性的值为 "BoundingSphere"
。
在默认情况下,JSON字符串中的每个属性都带有引号。若希望省略引号,则需要手动修改。