SphericalTriggerRegion的fromJSON方法解析JSON格式的数据,并使用数据创建新的SphericalTriggerRegion对象。
SphericalTriggerRegion.fromJSON(json: Object): SphericalTriggerRegion
json:一个包含SphericalTriggerRegion数据的JSON对象。SphericalTriggerRegion:一个新的SphericalTriggerRegion对象。// JSON object
const json = {
type: "spherical",
center: [0, 0, 0],
radius: 10
};
// Create a new SphericalTriggerRegion from JSON
const region = SphericalTriggerRegion.fromJSON(json);
fromJSON方法需要的JSON格式如下:
{
"type": "spherical",
"center": [x, y, z],
"radius": radius
}
type:表示区域类型,应为字符串spherical。center:表示球心坐标,应为长度为3的数字数组。radius:表示球体半径,应为数字。