Added Directional arrows to connectors.

This commit is contained in:
Michael Mainguy 2024-08-23 09:26:44 -05:00
parent 83279fa5b0
commit ba2d9a7886
3 changed files with 9 additions and 15 deletions

View File

@ -182,10 +182,8 @@ export class DiagramObject {
color: oldEntity.color, color: oldEntity.color,
text: oldEntity.text text: oldEntity.text
}; };
clone.fromDiagramEntity(newEntity);
this._logger.debug('DiagramObject clone called', clone, this._diagramEntity, newEntity); this._logger.debug('DiagramObject clone called', clone, this._diagramEntity, newEntity);
return clone; return clone.fromDiagramEntity(newEntity);
} }
public fromDiagramEntity(entity: DiagramEntity): DiagramObject { public fromDiagramEntity(entity: DiagramEntity): DiagramObject {
@ -311,18 +309,13 @@ export class DiagramObject {
} }
private updateConnection() { private updateConnection() {
if (this._toMesh.absolutePosition.length() == this._toPosition && this._fromMesh.absolutePosition.length() == this._fromPosition) { if (this._toMesh.absolutePosition.length() == this._toPosition && this._fromMesh.absolutePosition.length() == this._fromPosition) {
return; return;
} }
const curve: GreasedLineMesh = ((this._mesh as unknown) as GreasedLineMesh); const curve: GreasedLineMesh = ((this._mesh as unknown) as GreasedLineMesh);
const ray = new Ray(this._fromMesh.getAbsolutePosition(), Vector3.Normalize(this._toMesh.getAbsolutePosition().subtract(this._fromMesh.getAbsolutePosition()))); const ray = new Ray(this._fromMesh.getAbsolutePosition(), Vector3.Normalize(this._toMesh.getAbsolutePosition().subtract(this._fromMesh.getAbsolutePosition())));
//const rayHelper = new RayHelper(ray);
//rayHelper.show(this._scene, new Color3(1, 0, 0));
const hit = this._scene.multiPickWithRay(ray, (mesh) => { const hit = this._scene.multiPickWithRay(ray, (mesh) => {
if (mesh.id === this._to || mesh.id === this._from) { if (mesh.id === this._to || mesh.id === this._from) {
//mesh.updateFacetData();
return true; return true;
} else { } else {
return false; return false;
@ -349,6 +342,5 @@ export class DiagramObject {
curve.setParent(this._baseTransform); curve.setParent(this._baseTransform);
curve.setEnabled(true); curve.setEnabled(true);
console.log('done'); console.log('done');
} }
} }

View File

@ -70,6 +70,7 @@ function createNewInstanceIfNecessary(entity: DiagramEntity, scene: Scene): Abst
(newMesh as GreasedLineMesh).intersectionThreshold = 2; (newMesh as GreasedLineMesh).intersectionThreshold = 2;
const material = (newMesh.material as StandardMaterial); const material = (newMesh.material as StandardMaterial);
material.emissiveTexture = AnimatedLineTexture.Texture(); material.emissiveTexture = AnimatedLineTexture.Texture();
material.opacityTexture = AnimatedLineTexture.Texture();
material.disableLighting = true; material.disableLighting = true;
newMesh.setEnabled(false); newMesh.setEnabled(false);
break; break;

View File

@ -1,13 +1,13 @@
import {Engine, RawTexture} from "@babylonjs/core"; import {Texture} from "@babylonjs/core";
import {DefaultScene} from "../defaultScene"; import {DefaultScene} from "../defaultScene";
export class AnimatedLineTexture { export class AnimatedLineTexture {
private static _textureColors = new Uint8Array([10, 10, 10, 10, 10, 10, 25, 25, 25, 10, 10, 255]) private static _textureColors = new Uint8Array([10, 10, 10, 10, 10, 10, 25, 25, 25, 10, 10, 255])
private static _texture: RawTexture; private static _texture: Texture;
public static Texture() { public static Texture() {
if (!AnimatedLineTexture._texture) { if (!AnimatedLineTexture._texture) {
this._texture = new RawTexture( /*this._texture = new RawTexture(
this._textureColors, this._textureColors,
this._textureColors.length / 3, this._textureColors.length / 3,
1, 1,
@ -16,12 +16,13 @@ export class AnimatedLineTexture {
false, false,
true, true,
Engine.TEXTURE_NEAREST_NEAREST Engine.TEXTURE_NEAREST_NEAREST
) )*/
this._texture.wrapU = RawTexture.WRAP_ADDRESSMODE this._texture = new Texture('/assets/textures/arrow.png', DefaultScene.Scene);
//this._texture.wrapU = RawTexture.WRAP_ADDRESSMODE
this._texture.name = 'blue-white-texture'; this._texture.name = 'blue-white-texture';
this._texture.uScale = 30; this._texture.uScale = 30;
DefaultScene.Scene.onBeforeRenderObservable.add(() => { DefaultScene.Scene.onBeforeRenderObservable.add(() => {
this._texture.uOffset -= 0.05 * DefaultScene.Scene.getAnimationRatio() this._texture.uOffset -= 0.01 * DefaultScene.Scene.getAnimationRatio()
}); });
} }