@openhps/core
Version:
Open Hybrid Positioning System - Core component
23 lines • 666 B
JavaScript
import { ObjectProcessingNode } from '../ObjectProcessingNode';
/**
* This node converts the positions of data objects inside the frame
* to another unit.
* @category Flow shape
*/
export class UnitConversionNode extends ObjectProcessingNode {
constructor(unit, options) {
super(options);
this._unit = unit;
}
processObject(object) {
return new Promise(resolve => {
const position = object.getPosition();
if (position && position.unit !== this._unit) {
position.fromVector(position.toVector3(this._unit));
position.unit = this._unit;
object.setPosition(position);
}
resolve(object);
});
}
}