MCPcopy Index your code
hub / github.com/NikLever/ThreeJS-PathEditor / insertNode

Method insertNode

index.js:375–397  ·  view source on GitHub ↗
( )

Source from the content-addressed store, hash-verified

373 }
374
375 insertNode( ){
376 //Called by context menu
377 const pt = this.menu.position;
378 const prevPt = {};
379 let found = false;
380
381 this.nodes.forEach( node => {
382 if ( !found ){
383 const pt1 = this.graph.convertPathToScreen( node.x, node.y );
384
385 if ( node.tool == 'lineTo' && prevPt.x != undefined ){
386 if ( Geometry.calcIsInsideThickLineSegment( prevPt, pt1, pt, 10 ) ){
387 const index = this.nodes.indexOf( node );
388 this.addNode( this.config.tool, pt.x, pt.y, index );
389 found = true;
390 }
391 }
392
393 prevPt.x = pt1.x;
394 prevPt.y = pt1.y;
395 }
396 })
397 }
398
399 changeNode(){
400 //Called by context menu

Callers

nothing calls this directly

Calls 3

addNodeMethod · 0.95
convertPathToScreenMethod · 0.80

Tested by

no test coverage detected