UNPKG

@animech-public/playcanvas

Version:
38 lines (35 loc) 884 B
import { BoxGeometry } from '../../../scene/geometry/box-geometry.js'; import { TriData } from '../tri-data.js'; import { Shape } from './shape.js'; class BoxShape extends Shape { constructor(device, options = {}) { super(device, options); this._size = 0.12; this._tolerance = 0.05; this.triData = [new TriData(new BoxGeometry(), 2)]; this._createCenter(); } _createCenter() { this._createRoot('boxCenter'); this._updateTransform(); this._addRenderMesh(this.entity, 'box', 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); } } export { BoxShape };