Skip to content

Commit

Permalink
Translate and shrink wires into black box, see #113
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Jun 14, 2016
1 parent 57b0824 commit d2d4777
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions js/blackbox/view/BlackBoxSceneView.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,31 @@ define( function( require ) {
// In this case there is no need to move it inside the black box
if ( blackBoxSceneModel.circuit.containsVertex( vertex ) && blackBoxSceneModel.mode === 'build' ) {

// Find all the vertices that must be translated into the box
var vertices = blackBoxSceneModel.circuit.findAllFixedVertices( vertex );
for ( var i = 0; i < vertices.length; i++ ) {
var vertexInGroup = vertices[ i ];

var closestPoint = blackBoxNode.bounds.closestPointTo( vertexInGroup.position );
var delta = closestPoint.minus( vertexInGroup.position );

blackBoxSceneView.circuitNode.translateVertexGroup( vertexInGroup, vertices, delta, null, [] );
}
// Find all the vertices that must be translated into the box, translating wires
(function() {
var vertices = blackBoxSceneModel.circuit.findAllConnectedVertices( vertex );
for ( var i = 0; i < vertices.length; i++ ) {
var vertexInGroup = vertices[ i ];

var closestPoint = blackBoxNode.bounds.closestPointTo( vertexInGroup.position );
var delta = closestPoint.minus( vertexInGroup.position );

blackBoxSceneView.circuitNode.translateVertexGroup( vertexInGroup, vertices, delta, null, [] );
}
})();

// Find all the vertices that must be translated into the box, shrinking wires
(function() {
var vertices = blackBoxSceneModel.circuit.findAllFixedVertices( vertex );
for ( var i = 0; i < vertices.length; i++ ) {
var vertexInGroup = vertices[ i ];

var closestPoint = blackBoxNode.bounds.closestPointTo( vertexInGroup.position );
var delta = closestPoint.minus( vertexInGroup.position );

blackBoxSceneView.circuitNode.translateVertexGroup( vertexInGroup, vertices, delta, null, [] );
}
})();
}
} );
}
Expand Down

0 comments on commit d2d4777

Please sign in to comment.