Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Knowledge Space WP Plugin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
alg
Knowledge Space WP Plugin
Commits
50e04d79
Commit
50e04d79
authored
3 years ago
by
Matthias Konitzny
Browse files
Options
Downloads
Patches
Plain Diff
Proof of concept for overlay text.
parent
47f3b603
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
graph.js
+28
-9
28 additions, 9 deletions
graph.js
kg-style.css
+25
-0
25 additions, 0 deletions
kg-style.css
knowledge-space.php
+6
-0
6 additions, 0 deletions
knowledge-space.php
with
59 additions
and
9 deletions
graph.js
+
28
−
9
View file @
50e04d79
...
...
@@ -14,16 +14,32 @@ const Graph = ForceGraph3D()
.
onNodeHover
(
nodeHover
)
.
onLinkHover
(
linkHover
);
const
sphereGeometry
=
new
THREE
.
SphereGeometry
(
10000
,
32
,
32
);
//const planeGeometry = new THREE.PlaneGeometry(1000, 1000, 1, 1);
const
loader
=
new
THREE
.
TextureLoader
();
//const planeMaterial = new THREE.MeshLambertMaterial({color: 0xFF0000, side: THREE.DoubleSide}); //THREE.BackSide
const
planeMaterial
=
new
THREE
.
MeshBasicMaterial
({
map
:
loader
.
load
(
plugin_path
+
'
background.jpg
'
),
side
:
THREE
.
DoubleSide
});
//THREE.BackSide
const
mesh
=
new
THREE
.
Mesh
(
sphereGeometry
,
planeMaterial
);
mesh
.
position
.
set
(
0
,
0
,
0
);
//mesh.rotation.set(0.5 * Math.PI, 0, 0);
add_background
()
drawOverlay
()
function
drawOverlay
()
{
const
domNode
=
document
.
getElementById
(
'
3d-graph
'
);
const
sceneNode
=
domNode
.
firstChild
.
firstChild
.
firstChild
const
overlayNode
=
document
.
createElement
(
'
div
'
);
overlayNode
.
className
=
'
kg-overlay
'
;
overlayNode
.
innerText
=
'
Hello there!
'
;
//sceneNode.appendChild(overlayNode);
sceneNode
.
insertBefore
(
overlayNode
,
sceneNode
.
childNodes
[
2
])
}
Graph
.
scene
().
add
(
mesh
);
function
add_background
()
{
const
sphereGeometry
=
new
THREE
.
SphereGeometry
(
20000
,
32
,
32
);
//const planeGeometry = new THREE.PlaneGeometry(1000, 1000, 1, 1);
const
loader
=
new
THREE
.
TextureLoader
();
//const planeMaterial = new THREE.MeshLambertMaterial({color: 0xFF0000, side: THREE.DoubleSide}); //THREE.BackSide
const
planeMaterial
=
new
THREE
.
MeshBasicMaterial
({
map
:
loader
.
load
(
plugin_path
+
'
background.jpg
'
),
side
:
THREE
.
DoubleSide
});
//THREE.BackSide
const
mesh
=
new
THREE
.
Mesh
(
sphereGeometry
,
planeMaterial
);
mesh
.
position
.
set
(
0
,
0
,
0
);
//mesh.rotation.set(0.5 * Math.PI, 0, 0);
Graph
.
scene
().
add
(
mesh
);
}
function
updateLinks
()
{
...
...
@@ -58,6 +74,7 @@ function focusOnNode(node) {
);
}
function
nodeHover
(
node
)
{
// no state change
...
...
@@ -79,6 +96,7 @@ function nodeHover(node) {
updateHighlight
();
}
function
linkHover
(
link
)
{
highlightNodes
.
clear
();
highlightLinks
.
clear
();
...
...
@@ -92,6 +110,7 @@ function linkHover(link) {
updateHighlight
();
}
function
updateHighlight
()
{
// trigger update of highlighted objects in scene
Graph
...
...
This diff is collapsed.
Click to expand it.
kg-style.css
0 → 100644
+
25
−
0
View file @
50e04d79
#3
d-graph
{
display
:
flex
;
}
.kg-overlay
{
position
:
absolute
;
bottom
:
5px
;
pointer-events
:
none
;
width
:
100%
;
text-align
:
center
;
left
:
0
;
display
:
inline-block
;
background-color
:
rgba
(
0
,
0
,
0
,
.6
);
padding
:
5px
;
}
.renderer_label
{
/*position: absolute;*/
bottom
:
5px
;
width
:
100%
;
/*color: white;*/
/*z-index: 10;*/
/*display: block;*/
text-align
:
center
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
knowledge-space.php
+
6
−
0
View file @
50e04d79
...
...
@@ -23,4 +23,10 @@ function ks_add_graph(): string
return
$graph
.
$three
.
$div
.
$variables
.
$script
;
}
function
kg_load_css
()
{
$plugin_dir
=
plugin_dir_url
(
__FILE__
);
wp_enqueue_style
(
'kg-style'
,
$plugin_dir
.
'kg-style.css'
);
}
add_action
(
'wp_enqueue_scripts'
,
'kg_load_css'
);
add_shortcode
(
'knowledge-space'
,
'ks_add_graph'
);
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment