MCPcopy Index your code
hub / github.com/cncjs/gcode-toolpath / constructor

Method constructor

src/Toolpath.js:610–650  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

608 // @param {function} [options.addLine]
609 // @param {function} [options.addArcCurve]
610 constructor(options) {
611 const {
612 position,
613 modal,
614 addLine = noop,
615 addArcCurve = noop
616 } = { ...options };
617 this.g92offset.x = 0;
618 this.g92offset.y = 0;
619 this.g92offset.z = 0;
620
621 // Position
622 if (position) {
623 const { x, y, z } = { ...position };
624 this.setPosition(x, y, z);
625 }
626
627 // Modal
628 const nextModal = {};
629 Object.keys({ ...modal }).forEach(key => {
630 if (!Object.prototype.hasOwnProperty.call(this.modal, key)) {
631 return;
632 }
633 nextModal[key] = modal[key];
634 });
635 this.setModal(nextModal);
636
637 this.fn = { addLine, addArcCurve };
638
639 const toolpath = new Interpreter({ handlers: this.handlers });
640 toolpath.getPosition = () => ({ ...this.position });
641 toolpath.getModal = () => ({ ...this.modal });
642 toolpath.setPosition = (...pos) => {
643 return this.setPosition(...pos);
644 };
645 toolpath.setModal = (modal) => {
646 return this.setModal(modal);
647 };
648
649 return toolpath;
650 }
651 setModal(modal) {
652 this.modal = {
653 ...this.modal,

Callers

nothing calls this directly

Calls 2

setPositionMethod · 0.95
setModalMethod · 0.95

Tested by

no test coverage detected