Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Scientific Software
vEXP
Commits
f01f38db
Commit
f01f38db
authored
May 14, 2020
by
legoc
Browse files
First factorisation of material and geometry of HKLLine
parent
26c1a5dc
Changes
2
Hide whitespace changes
Inline
Side-by-side
js/client/utils/shapes/energy-line.js
View file @
f01f38db
...
...
@@ -10,6 +10,7 @@ class EnergyLine extends TrajectoryLine {
constructor
(
type
,
parent
,
start
,
end
,
center
,
steps
)
{
super
(
type
,
parent
,
start
,
end
,
center
,
steps
);
// The data stored.
this
.
_data
=
[];
// The line is a segment.
...
...
@@ -114,7 +115,7 @@ class EnergyLine extends TrajectoryLine {
}
highlightSpheres
(
value
)
{
// The spheres are always visible in spy mode.
if
(
!
mode
.
spyMode
)
{
this
.
_deltaSphereGroup
.
visible
=
value
;
...
...
js/client/utils/shapes/hkl-line.js
View file @
f01f38db
...
...
@@ -10,15 +10,19 @@ class HKLLine extends TrajectoryLine {
constructor
(
type
,
parent
,
start
,
end
,
center
,
steps
)
{
super
(
type
,
parent
,
start
,
end
,
center
,
steps
);
let
geometry
=
new
THREE
.
SphereGeometry
(
1
/
scale
,
8
,
8
);
let
material
=
new
THREE
.
MeshBasicMaterial
({
color
:
0x0000ff
,
opacity
:
0.5
,
depthTest
:
true
,
transparent
:
false
});
// Geometry and material.
this
.
_lineSphereGeometry
=
new
THREE
.
SphereGeometry
(
0.5
/
scale
,
8
,
8
);
this
.
_lineMaterial
=
new
THREE
.
MeshBasicMaterial
({
color
:
Color
.
Q
,
depthTest
:
true
,
transparent
:
false
});
this
.
_sphereGeometry
=
new
THREE
.
SphereGeometry
(
1
/
scale
,
8
,
8
);
this
.
_sphereMaterial
=
new
THREE
.
MeshBasicMaterial
({
color
:
0xffffff
,
depthTest
:
true
,
transparent
:
false
});
// Create the trajectory start sphere
this
.
_startSphere
=
new
THREE
.
Mesh
(
geometry
,
m
aterial
);
this
.
_startSphere
=
new
THREE
.
Mesh
(
this
.
_lineSphereGeometry
,
this
.
_lineM
aterial
);
this
.
_startSphere
.
renderOrder
=
1
;
// Create the trajectory end sphere.
this
.
_endSphere
=
new
THREE
.
Mesh
(
geometry
,
m
aterial
);
this
.
_endSphere
=
new
THREE
.
Mesh
(
this
.
_lineSphereGeometry
,
this
.
_lineM
aterial
);
this
.
_endSphere
.
renderOrder
=
1
;
// The line is an array of segments.
...
...
@@ -45,9 +49,7 @@ class HKLLine extends TrajectoryLine {
this
.
_startSphere
.
position
.
copy
(
this
.
_start
.
clone
());
this
.
_endSphere
.
position
.
copy
(
this
.
_end
.
clone
());
let
geometry
=
new
THREE
.
SphereGeometry
(
1
/
scale
,
8
,
8
);
let
material
=
new
THREE
.
MeshBasicMaterial
({
color
:
0xffffff
,
depthTest
:
true
,
transparent
:
false
});
// Define the iterator.
let
iterator
=
null
;
if
(
this
.
_type
==
'
q
'
)
{
iterator
=
new
TrajectorySegmentIterator
(
this
.
_start
,
this
.
_end
,
this
.
_intervals
);
...
...
@@ -69,15 +71,11 @@ class HKLLine extends TrajectoryLine {
this
.
_deltaSphereGroup
.
remove
(
this
.
_deltaSphereGroup
.
children
[
i
]);
}
// Create the line.
let
lineMaterial
=
new
THREE
.
LineBasicMaterial
({
color
:
Color
.
Q
,
linewidth
:
5
,
depthTest
:
true
,
transparent
:
false
});
lineMaterial
.
color
.
set
(
this
.
getColor
(
true
));
// Define the previous point for the line segments.
let
previousPoint
=
null
;
// Place new spheres and segments.
for
(
let
i
=
0
;
i
<
this
.
_intervals
;
i
++
)
{
for
(
let
i
=
0
;
i
<
this
.
_intervals
+
1
;
i
++
)
{
// Get the current point.
let
currentPoint
=
iterator
.
value
().
clone
();
...
...
@@ -87,14 +85,14 @@ class HKLLine extends TrajectoryLine {
let
length
=
currentPoint
.
clone
().
sub
(
previousPoint
).
length
();
// Add the segment if start and end points are different (bad drawing otherwise).
if
(
length
!==
0
)
{
let
segment
=
new
LineSegment
(
previousPoint
,
currentPoint
,
0.5
/
scale
,
lineMaterial
);
let
segment
=
new
LineSegment
(
previousPoint
,
currentPoint
,
0.5
/
scale
,
this
.
_
lineMaterial
);
this
.
_line
.
push
(
segment
);
this
.
_lineGroup
.
add
(
segment
.
object3D
);
}
}
// Define a sphere.
let
stepSphere
=
new
THREE
.
Mesh
(
geometry
,
m
aterial
);
let
stepSphere
=
new
THREE
.
Mesh
(
this
.
_sphereGeometry
,
this
.
_sphereM
aterial
);
stepSphere
.
renderOrder
=
3
;
stepSphere
.
position
.
copy
(
iterator
.
value
());
this
.
_deltaSphereGroup
.
add
(
stepSphere
);
...
...
@@ -105,25 +103,11 @@ class HKLLine extends TrajectoryLine {
// Next iteration.
iterator
.
next
();
}
// Last segment.
if
(
previousPoint
!==
null
)
{
let
lastPoint
=
iterator
.
value
().
clone
();
let
length
=
lastPoint
.
clone
().
sub
(
previousPoint
).
length
();
// Add the segment if start and end points are different (bad drawing otherwise).
if
(
length
!==
0
)
{
let
segment
=
new
LineSegment
(
previousPoint
,
lastPoint
,
0.5
/
scale
,
lineMaterial
);
this
.
_lineGroup
.
add
(
segment
.
object3D
);
}
}
}
highlightLines
(
color
)
{
// Change the color of the segments.
for
(
let
i
=
0
;
i
<
this
.
_line
.
length
;
i
++
)
{
this
.
_line
[
i
].
material
.
color
.
set
(
color
);
}
// Change the line material color.
this
.
_lineMaterial
.
color
.
set
(
color
);
}
highlightSpheres
(
value
)
{
...
...
@@ -144,15 +128,11 @@ class HKLLine extends TrajectoryLine {
* Remove this trajectory properly.
*/
destroy
()
{
this
.
_startSphere
.
geometry
.
dispose
();
this
.
_endSphere
.
geometry
.
dispose
();
this
.
_startSphere
.
material
.
dispose
();
this
.
_endSphere
.
material
.
dispose
();
for
(
let
d
of
this
.
_deltaSphereGroup
.
children
)
{
d
.
geometry
.
dispose
();
d
.
material
.
dispose
();
}
this
.
_lineSphereGeometry
.
dispose
();
this
.
_lineMaterial
.
dispose
();
this
.
_sphereGeometry
.
dispose
();
this
.
_sphereMaterial
.
dispose
();
}
}
...
...
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