# geometries/sph/shapes/localBall/LocalBallShape.js

``````import {Isometry, Point} from "../../geometry/General.js";
import {BasicShape} from "../../../../core/shapes/BasicShape.js";

import distance from "../../imports/distance.glsl";
import struct from "./shaders/struct.glsl";
import sdf from "../../../../core/shapes/shaders/sdf.glsl.mustache";

/**
* @class
*
* @classdesc
* Shape of a spherical local ball
*/
export class LocalBallShape extends BasicShape {

/**
* Construction
* @param {Isometry|Point|Vector} location - data for the center of the ball
* - If the input in an Isometry, then the center is the image of the origin by this isometry.
* - If the input in a Point, then the center is that point.
* - If the input is a Vector, then the center is the image of this vector by the exponential map at the origin.
* @param {number} radius - the radius od the ball
*/
const isom = new Isometry();
if (location.isIsometry) {
isom.copy(location);
} else if (location.isPoint) {
isom.makeTranslation(location);
} else if (location.isVector) {
isom.makeTranslationFromDir(location);
} else {
throw new Error('BallShape: this type of location is not allowed');
}
super(isom);
}

updateData() {
super.updateData();
this._center = new Point().applyIsometry(this.absoluteIsom);
}

/**
* Center of the ball
* @type {Point}
*/
get center() {
if(this._center === undefined) {
this.updateData();
}
return this._center;
}

/**
* Says that the object inherits from `Ball`
* @type {boolean}
*/
get isLocalBallShape() {
return true;
}

/**
* Says whether the shape is global. True if global, false otherwise.
* @type {boolean}
*/
get isGlobal() {
return false;
}

get uniformType() {
return 'LocalBallShape';
}

static glslClass() {
return struct;
}

glslSDF() {
return sdf(this);
}