-
Notifications
You must be signed in to change notification settings - Fork 442
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
92 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import { BasicMaterialOpacity } from "../../utils/Constant"; | ||
import {LineGroupGeometry} from "../../elements/LineGroupGeometry"; | ||
|
||
function BasicLineGroupController() { | ||
|
||
// store the line group system element | ||
let lineMat = new THREE.LineBasicMaterial( { | ||
color: 0xffffff, | ||
opacity: BasicMaterialOpacity, | ||
transparent:true, | ||
vertexColors: THREE.VertexColors | ||
} ); | ||
let lineGeom = new THREE.Geometry(); | ||
lineGeom.dynamic = true; | ||
this.lineGroup = new THREE.Line(lineGeom, lineMat); | ||
|
||
} | ||
|
||
BasicLineGroupController.prototype = { | ||
|
||
getLineGroupParameters: function(selectedElement) { | ||
|
||
this.scene.updateMatrixWorld(); | ||
|
||
let lineColors = []; | ||
let lineVertices = []; | ||
|
||
let relatedElements = this.getRelativeElements(selectedElement); | ||
|
||
let startPosition = selectedElement.getWorldPosition().sub(this.neuralGroup.getWorldPosition()); | ||
|
||
for (let i = 0; i < relatedElements.length; i++) { | ||
|
||
lineColors.push(new THREE.Color(this.color)); | ||
lineColors.push(new THREE.Color(this.color)); | ||
|
||
lineVertices.push(relatedElements[i].getWorldPosition().sub(this.neuralGroup.getWorldPosition())); | ||
lineVertices.push(startPosition); | ||
|
||
} | ||
|
||
return { | ||
lineColors: lineColors, | ||
lineVertices: lineVertices | ||
} | ||
|
||
}, | ||
|
||
initLineGroup: function(selectedElement) { | ||
|
||
let lineGroupParameters = this.getLineGroupParameters(selectedElement); | ||
|
||
let lineGroupGeometryHandler = new LineGroupGeometry( | ||
lineGroupParameters.lineVertices, | ||
lineGroupParameters.lineColors | ||
); | ||
this.lineGroup.geometry = lineGroupGeometryHandler.getElement(); | ||
this.lineGroup.material.needsUpdate = true; | ||
|
||
this.neuralGroup.add(this.lineGroup); | ||
|
||
}, | ||
|
||
disposeLineGroup: function() { | ||
|
||
this.lineGroup.geometry.dispose(); | ||
this.neuralGroup.remove(this.lineGroup); | ||
|
||
}, | ||
|
||
// override this function to define relative element from previous layer | ||
getRelativeElements: function(selectedElement) { | ||
|
||
let relativeElements = []; | ||
|
||
if (selectedElement.elementType === "") { | ||
|
||
} | ||
|
||
return []; | ||
|
||
} | ||
|
||
}; | ||
|
||
export { BasicLineGroupController }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters