UNPKG

playcanvas

Version:

PlayCanvas WebGL game engine

38 lines (35 loc) 952 B
import { SphereGeometry } from '../../../scene/geometry/sphere-geometry.js'; import { TriData } from '../tri-data.js'; import { Shape } from './shape.js'; class SphereShape extends Shape { _createCenter() { this._createRoot('sphereCenter'); this._updateTransform(); this._addRenderMesh(this.entity, 'sphere', this._shading); } set size(value) { this._size = value != null ? value : 1; this._updateTransform(); } get size() { return this._size; } set tolerance(value) { this._tolerance = value; this._updateTransform(); } get tolerance() { return this._tolerance; } _updateTransform() { this.entity.setLocalScale(this._size, this._size, this._size); } constructor(device, options = {}){ super(device, options), this._size = 0.12, this._tolerance = 0.05; this.triData = [ new TriData(new SphereGeometry(), 2) ]; this._createCenter(); } } export { SphereShape };