UNPKG

awv3

Version:
23 lines (20 loc) 838 B
import * as THREE from 'three' import BaseGraphics from './base' export default class Radial extends BaseGraphics { constructor(...args) { super(...args, 2, 0, 1) } updateFromState(info, ...args) { const [center, dim] = ['center', 'dimPt'].map(x => new THREE.Vector3().fromArray(info.dimension.members[x].value), ) const radius = info.dimension.members.radius.value const end = dim.clone().sub(center).setLength(radius).add(center) const outside = dim.distanceTo(center) > end.distanceTo(center) const dir = end.clone().sub(center).normalize() this.updateLine(0, center, end) this.updateLine(1, center, dim) this.updateArrow(0, end, dir.clone().multiplyScalar(outside ? -1 : 1)) super.updateFromState(info, ...args) } }