Przeglądaj źródła

NodeEditor UI (#23312)

* NodeEditor UI
- add confirmation on clic to "new" button
- modify bezier controle point distance to improve draw of small nodes distances

* esLint
Franck 3 lat temu
rodzic
commit
338e193eda

+ 3 - 1
examples/jsm/libs/flow.module.js

@@ -1645,7 +1645,9 @@ class TitleElement extends DraggableElement {
 
 const drawLine = ( p1x, p1y, p2x, p2y, invert, size, colorA, ctx, colorB = null ) => {
 
-	const offset = 100 * ( invert ? - 1 : 1 );
+	const dx = p2x - p1x;
+	const dy = p2y - p1y;
+	const offset = Math.sqrt( dx*dx + dy*dy ) * (invert ? -.3 : .3) ;
 
 	ctx.beginPath();
 

+ 5 - 1
examples/jsm/node-editor/NodeEditor.js

@@ -344,7 +344,11 @@ export class NodeEditor extends EventDispatcher {
 		menuButton.onClick( () => this.nodesContext.open() );
 		examplesButton.onClick( () => this.examplesContext.open() );
 
-		newButton.onClick( () => this.newProject() );
+		newButton.onClick( () => {
+
+			if ( confirm( 'are you sure' ) ) this.newProject();
+
+		} );
 
 		openButton.onClick( () => {