Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #12354 #12359

Merged
merged 1 commit into from
Apr 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions packages/tools/nodeEditor/src/diagram/nodeLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Observable } from "core/Misc/observable";
import type { FrameNodePort } from "./frameNodePort";
import type { ISelectionChangedOptions } from "../globalState";
import type { ElbowBlock } from "core/Materials/Node/Blocks/elbowBlock";
import { NodeMaterialBlockConnectionPointTypes } from "core/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";

export class NodeLink {
private _graphCanvas: GraphCanvasComponent;
Expand Down Expand Up @@ -129,13 +130,18 @@ export class NodeLink {

onClick(evt: MouseEvent) {
if (evt.altKey) {
const nodeA = this._nodeA;
const pointA = this._portA.connectionPoint;
const nodeB = this._nodeB!;
const pointB = this._portB!.connectionPoint;

if (pointA.type === NodeMaterialBlockConnectionPointTypes.Object || pointB.type === NodeMaterialBlockConnectionPointTypes.Object) {
return; // We do not support Elbow on complex types
}

// Create an elbow at the clicked location
this._graphCanvas.globalState.onNewNodeCreatedObservable.addOnce((newNode) => {
const newElbowBlock = newNode.block as ElbowBlock;
const nodeA = this._nodeA;
const pointA = this._portA.connectionPoint;
const nodeB = this._nodeB!;
const pointB = this._portB!.connectionPoint;

// Delete previous link
this.dispose();
Expand Down