UNPKG

@animech-public/playcanvas

Version:
41 lines (37 loc) 985 B
import { SphereGeometry } from '../../../scene/geometry/sphere-geometry.js'; import { TriData } from '../tri-data.js'; import { Shape } from './shape.js'; class SphereShape extends Shape { constructor(device, options = {}) { super(device, options); this._size = 0.12; this._tolerance = 0.05; this.triData = [new TriData(new SphereGeometry(), 2)]; this._createCenter(); } _createCenter() { this._createRoot('sphereCenter'); this._updateTransform(); // box 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() { // intersect/render this.entity.setLocalScale(this._size, this._size, this._size); } } export { SphereShape };