Fixed animation direction for connections.

This commit is contained in:
Michael Mainguy 2024-08-22 19:14:44 -05:00
parent c00fc55462
commit b443e1854b
3 changed files with 10 additions and 15 deletions

View File

@ -328,22 +328,15 @@ export class DiagramObject {
return false; return false;
} }
}); });
if (hit[0].pickedMesh.id === this._to) {
//this._fromMesh.updateFacetData(); hit.reverse();
//this._toMesh.updateFacetData(); }
const distance = Math.abs(hit[0].pickedPoint.subtract(hit[1].pickedPoint).length());
//const positions = this._fromMesh.getFacetLocalPositions();
const hit0matrix = hit[0].pickedMesh.computeWorldMatrix(true);
const hit1matrix = hit[1].pickedMesh.computeWorldMatrix(true);
const hitpoint0 = Vector3.TransformCoordinates(hit[0].pickedPoint, hit0matrix);
const hitpoint1 = Vector3.TransformCoordinates(hit[1].pickedPoint, hit1matrix);
const distance = Math.abs(hit[0].pickedPoint.subtract(hit[1].pickedPoint).lengthSquared());
const fromNormal = hit[0].pickedMesh.getFacetNormal(hit[0].faceId); const fromNormal = hit[0].pickedMesh.getFacetNormal(hit[0].faceId);
const toNormal = hit[1].pickedMesh.getFacetNormal(hit[1].faceId); const toNormal = hit[1].pickedMesh.getFacetNormal(hit[1].faceId);
const c = Curve3.CreateCubicBezier(hit[0].pickedPoint, hit[0].pickedPoint.add(fromNormal.normalize().scale(distance * .2)), const c = Curve3.CreateCubicBezier(hit[0].pickedPoint, hit[0].pickedPoint.add(fromNormal.normalize().scale(.21 * distance)),
hit[1].pickedPoint.add(toNormal.normalize().scale(distance * .2)), hit[1].pickedPoint.add(toNormal.normalize().scale(.21 * distance)),
hit[1].pickedPoint, 40); hit[1].pickedPoint, 40);
const p = c.getPoints().flatMap((point) => { const p = c.getPoints().flatMap((point) => {
return point.asArray() return point.asArray()

View File

@ -68,7 +68,9 @@ function createNewInstanceIfNecessary(entity: DiagramEntity, scene: Scene): Abst
colorMode: GreasedLineMeshColorMode.COLOR_MODE_MULTIPLY colorMode: GreasedLineMeshColorMode.COLOR_MODE_MULTIPLY
}, scene); }, scene);
(newMesh as GreasedLineMesh).intersectionThreshold = 2; (newMesh as GreasedLineMesh).intersectionThreshold = 2;
(newMesh.material as StandardMaterial).emissiveTexture = AnimatedLineTexture.Texture(); const material = (newMesh.material as StandardMaterial);
material.emissiveTexture = AnimatedLineTexture.Texture();
material.disableLighting = true;
newMesh.setEnabled(false); newMesh.setEnabled(false);
break; break;
case DiagramTemplates.BOX: case DiagramTemplates.BOX:

View File

@ -21,7 +21,7 @@ export class AnimatedLineTexture {
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.05 * DefaultScene.Scene.getAnimationRatio()
}); });
} }