This repository has been archived by the owner on Apr 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from chthollyphile/dev
Dev
- Loading branch information
Showing
5 changed files
with
99 additions
and
23 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 |
---|---|---|
|
@@ -45,4 +45,3 @@ export function Dgraph7c94cd() { | |
} | ||
return graph | ||
} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { ItemView, WorkspaceLeaf } from "obsidian"; | ||
import * as React from "react"; | ||
import * as ReactDOM from "react-dom"; | ||
import { Dgraph7c94cd } from "./ReactView"; | ||
import { createRoot } from "react-dom/client"; | ||
import ForceGraph3D from 'react-force-graph-3d'; | ||
import SpriteText from 'three-spritetext'; | ||
export const VIEW_TYPE_OB3GV = "Obsidian-3D-Graph-Viewer"; | ||
|
||
export class Ob3gvView extends ItemView { | ||
constructor(leaf: WorkspaceLeaf) { | ||
super(leaf); | ||
} | ||
|
||
getViewType() { | ||
return VIEW_TYPE_OB3GV; | ||
} | ||
|
||
getDisplayText() { | ||
return "3D Graph View"; | ||
} | ||
|
||
async onOpen() { | ||
const graphJson = Dgraph7c94cd() | ||
const root = createRoot(this.containerEl.children[1]) | ||
root.render( | ||
<ForceGraph3D | ||
graphData={graphJson} | ||
nodeColor={() => '#b6bfc1db'} | ||
nodeResolution={8} | ||
linkColor={() => "#f5f5f5"} | ||
linkCurvature={0.8} | ||
linkCurveRotation={4} | ||
linkDirectionalArrowColor={"#ffffff"} | ||
linkDirectionalArrowLength={4} | ||
backgroundColor={'#202020'} | ||
nodeThreeObjectExtend={true} | ||
nodeThreeObject={node => { | ||
const sprite = new SpriteText(node.id); | ||
sprite.color = 'lightgrey'; | ||
sprite.textHeight = 4; | ||
return sprite; | ||
}} | ||
/> | ||
) | ||
} | ||
|
||
async onClose() { | ||
ReactDOM.unmountComponentAtNode(this.containerEl); | ||
} | ||
} |