Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Grégoire Locqueville
purescript-gargantext
Commits
73d8960a
Verified
Commit
73d8960a
authored
Mar 10, 2023
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[sigma.js] add triangle node renderer
Doesn't work yet though.
parent
b7d50688
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
133 additions
and
0 deletions
+133
-0
Sigma.js
src/Gargantext/Hooks/Sigmax/Sigma.js
+1
-0
sigmajs-triangle.js
src/external-deps/sigmajs-triangle.js
+132
-0
No files found.
src/Gargantext/Hooks/Sigmax/Sigma.js
View file @
73d8960a
...
@@ -5,6 +5,7 @@ import Sigma from 'sigma';
...
@@ -5,6 +5,7 @@ import Sigma from 'sigma';
import
{
takeScreenshot
}
from
'../../src/external-deps/sigmajs-screenshot.js'
;
import
{
takeScreenshot
}
from
'../../src/external-deps/sigmajs-screenshot.js'
;
import
CircleNodeProgram
from
'sigma/rendering/webgl/programs/node.fast'
;
import
CircleNodeProgram
from
'sigma/rendering/webgl/programs/node.fast'
;
import
ContourCircleNodeProgram
from
'../../src/external-deps/sigmajs-circle-with-contour.js'
;
import
ContourCircleNodeProgram
from
'../../src/external-deps/sigmajs-circle-with-contour.js'
;
import
TriangleNodeProgram
from
'../../src/external-deps/sigmajs-triangle.js'
;
let
sigma
=
Sigma
.
Sigma
;
let
sigma
=
Sigma
.
Sigma
;
console
.
log
(
'imported sigma'
,
Sigma
);
console
.
log
(
'imported sigma'
,
Sigma
);
...
...
src/external-deps/sigmajs-triangle.js
0 → 100644
View file @
73d8960a
/**
* Sigma.js WebGL Renderer Node Program
* =====================================
*
* Simple program rendering nodes as triangles.
* It does not extend AbstractNodeProgram, which works very differently, and
* really targets the gl.POINTS drawing methods.
* @module
*/
import
{
NodeDisplayData
}
from
"sigma/types"
;
import
{
floatColor
}
from
"sigma/utils"
;
import
vertexShaderSource
from
"sigma/rendering/webgl/shaders/node.vert.glsl"
;
import
fragmentShaderSource
from
"sigma/rendering/webgl/shaders/node.frag.glsl"
;
import
{
AbstractProgram
,
RenderParams
}
from
"sigma/rendering/webgl/programs/common/program"
;
const
POINTS
=
1
;
const
ATTRIBUTES
=
5
;
const
ANGLE_1
=
0
;
//const ANGLE_2 = (2 * Math.PI) / 3;
//const ANGLE_3 = (4 * Math.PI) / 3;
export
default
class
NodeProgram
extends
AbstractProgram
{
// positionLocation: GLint;
// sizeLocation: GLint;
// colorLocation: GLint;
// matrixLocation: WebGLUniformLocation;
// sqrtZoomRatioLocation: WebGLUniformLocation;
// correctionRatioLocation: WebGLUniformLocation;
constructor
(
gl
)
{
super
(
gl
,
vertexShaderSource
,
fragmentShaderSource
,
POINTS
,
ATTRIBUTES
);
// Locations
this
.
positionLocation
=
gl
.
getAttribLocation
(
this
.
program
,
"a_position"
);
this
.
sizeLocation
=
gl
.
getAttribLocation
(
this
.
program
,
"a_size"
);
this
.
colorLocation
=
gl
.
getAttribLocation
(
this
.
program
,
"a_color"
);
this
.
angleLocation
=
gl
.
getAttribLocation
(
this
.
program
,
"a_angle"
);
// Uniform Location
const
matrixLocation
=
gl
.
getUniformLocation
(
this
.
program
,
"u_matrix"
);
if
(
matrixLocation
===
null
)
throw
new
Error
(
"AbstractNodeProgram: error while getting matrixLocation"
);
this
.
matrixLocation
=
matrixLocation
;
const
sqrtZoomRatioLocation
=
gl
.
getUniformLocation
(
this
.
program
,
"u_sqrtZoomRatio"
);
if
(
sqrtZoomRatioLocation
===
null
)
throw
new
Error
(
"NodeProgram: error while getting sqrtZoomRatioLocation"
);
this
.
sqrtZoomRatioLocation
=
sqrtZoomRatioLocation
;
const
correctionRatioLocation
=
gl
.
getUniformLocation
(
this
.
program
,
"u_correctionRatio"
);
if
(
correctionRatioLocation
===
null
)
throw
new
Error
(
"NodeProgram: error while getting correctionRatioLocation"
);
this
.
correctionRatioLocation
=
correctionRatioLocation
;
this
.
bind
();
}
bind
()
{
const
gl
=
this
.
gl
;
gl
.
enableVertexAttribArray
(
this
.
positionLocation
);
gl
.
enableVertexAttribArray
(
this
.
sizeLocation
);
gl
.
enableVertexAttribArray
(
this
.
colorLocation
);
gl
.
enableVertexAttribArray
(
this
.
angleLocation
);
gl
.
vertexAttribPointer
(
this
.
positionLocation
,
2
,
gl
.
FLOAT
,
false
,
this
.
attributes
*
Float32Array
.
BYTES_PER_ELEMENT
,
0
,
);
gl
.
vertexAttribPointer
(
this
.
sizeLocation
,
1
,
gl
.
FLOAT
,
false
,
this
.
attributes
*
Float32Array
.
BYTES_PER_ELEMENT
,
8
);
gl
.
vertexAttribPointer
(
this
.
colorLocation
,
4
,
gl
.
UNSIGNED_BYTE
,
true
,
this
.
attributes
*
Float32Array
.
BYTES_PER_ELEMENT
,
12
,
);
gl
.
vertexAttribPointer
(
this
.
angleLocation
,
1
,
gl
.
FLOAT
,
false
,
this
.
attributes
*
Float32Array
.
BYTES_PER_ELEMENT
,
16
,
);
}
process
(
data
,
hidden
,
offset
)
{
const
array
=
this
.
array
;
let
i
=
offset
*
POINTS
*
ATTRIBUTES
;
if
(
hidden
)
{
for
(
let
l
=
i
+
POINTS
*
ATTRIBUTES
;
i
<
l
;
i
++
)
array
[
i
]
=
0
;
return
;
}
const
color
=
floatColor
(
data
.
color
);
array
[
i
++
]
=
data
.
x
;
array
[
i
++
]
=
data
.
y
;
array
[
i
++
]
=
data
.
size
;
array
[
i
++
]
=
color
;
array
[
i
]
=
ANGLE_1
;
}
render
(
params
)
{
if
(
this
.
hasNothingToRender
())
return
;
const
gl
=
this
.
gl
;
const
program
=
this
.
program
;
gl
.
useProgram
(
program
);
gl
.
uniformMatrix3fv
(
this
.
matrixLocation
,
false
,
params
.
matrix
);
gl
.
uniform1f
(
this
.
sqrtZoomRatioLocation
,
Math
.
sqrt
(
params
.
ratio
));
gl
.
uniform1f
(
this
.
correctionRatioLocation
,
params
.
correctionRatio
);
gl
.
drawArrays
(
gl
.
TRIANGLES
,
0
,
this
.
array
.
length
/
ATTRIBUTES
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment