Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
WebARforCIFT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
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
Manuel Amesberger
WebARforCIFT
Commits
8fe9ea89
Commit
8fe9ea89
authored
5 years ago
by
Manuel Amesberger
Browse files
Options
Downloads
Patches
Plain Diff
implemented color gradient and shape change on out of range values for length of vectors
parent
bcb2a713
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
www/WebDevPlayground/three.js/examples/ARforCIFT.js
+38
-17
38 additions, 17 deletions
www/WebDevPlayground/three.js/examples/ARforCIFT.js
with
38 additions
and
17 deletions
www/WebDevPlayground/three.js/examples/ARforCIFT.js
+
38
−
17
View file @
8fe9ea89
...
...
@@ -13,12 +13,27 @@
var
offsetZmax
=
1.0
;
// =====Arrow depiction parameters=====
var
arrowMaxLength
=
5
.0
;
var
arrowMinLength
=
1
.5
;
var
arrowMaxLength
=
2
.0
;
var
arrowMinLength
=
0
.5
;
var
maxRange
=
5
.0
;
var
maxRange
=
4
.0
;
var
minRange
=
0.0
;
// ====Default sizes for non depictable arrows ======
var
nonArrowLength
=
0.1
;
var
nonArrowHeadLength
=
0.05
;
var
nonArrowHeadWidth
=
0.05
;
// ========Default GUI values=========
var
controls
=
new
function
()
{
this
.
offsetX
=
0.00
;
this
.
offsetY
=
0.00
;
this
.
offsetZ
=
0.00
;
this
.
arrowMaxLength
=
2.0
;
this
.
arrowMinLength
=
0.5
;
};
var
oldVecArrayLength
=
0
;
var
vectorlist
=
[];
...
...
@@ -59,9 +74,8 @@
if
(
fullrange
==
0
){
percentile
=
100
}
else
{
percentile
=
(
vectorLength
/
fullrange
)
*
100
;
var
percentile
=
(
vectorLength
/
fullrange
)
*
100
;
}
if
(
percentile
<
50
){
r
=
255
;
g
=
Math
.
round
(
5.1
*
percentile
);
...
...
@@ -71,7 +85,6 @@
r
=
Math
.
round
(
510
-
5.10
*
percentile
);
}
var
rgbArray
=
[
r
,
g
,
b
];
return
rgbArray
;
};
...
...
@@ -223,7 +236,7 @@
// Set color of vectors
var
hex2
=
new
THREE
.
Color
(
0xffff00
);
var
hex2
=
new
THREE
.
Color
();
hex2
.
setRGB
(
colorArray
[
0
],
colorArray
[
1
],
colorArray
[
2
]);
// Value with gradient;
// check if arrows are needed to be added and push new arrows in array
...
...
@@ -239,8 +252,21 @@
vectorlist
[
i
].
arrow
.
visible
=
true
;
vectorlist
[
i
].
arrow
.
position
.
set
(
XBase
,
YBase
,
ZBase
);
vectorlist
[
i
].
arrow
.
setDirection
(
dir2
);
vectorlist
[
i
].
arrow
.
setLength
(
dir2
.
length
());
vectorlist
[
i
].
arrow
.
setColor
(
hex2
);
console
.
log
(
"
Updating
"
)
};
// look up if the length is exceedes the set limits and set arrow to specific color and shape
if
(
vecLength
>
arrowMaxLength
){
vectorlist
[
i
].
arrow
.
setLength
(
nonArrowLength
,
nonArrowHeadLength
,
nonArrowHeadWidth
)
vectorlist
[
i
].
arrow
.
setColor
(
new
THREE
.
Color
(
0
,
0
,
1
));
};
if
(
vecLength
<
arrowMinLength
){
vectorlist
[
i
].
arrow
.
setLength
(
nonArrowLength
,
nonArrowHeadLength
,
nonArrowHeadWidth
)
vectorlist
[
i
].
arrow
.
setColor
(
new
THREE
.
Color
(
1
,
0
,
0
));
}
};
// set not needed arrowHelper objects invisible
if
(
oldVecArrayLength
>
vecArr
.
arrows
.
length
){
...
...
@@ -278,13 +304,6 @@
scene
.
add
(
vectorfield
)
//==================================GUI=============================================
var
controls
=
new
function
()
{
this
.
offsetX
=
0.00
;
this
.
offsetY
=
0.00
;
this
.
offsetZ
=
0.00
;
this
.
arrowMaxLength
=
2.5
;
this
.
arrowMinLength
=
0.5
;
};
var
gui
=
new
dat
.
GUI
();
gui
.
add
(
controls
,
'
offsetX
'
,
offsetXmin
,
offsetXmax
);
...
...
@@ -309,9 +328,11 @@
var
lastTimeMsec
=
null
requestAnimationFrame
(
function
animate
(
nowMsec
){
// offset for the vectorfield
vectorfield
.
position
.
x
=
controls
.
offsetX
vectorfield
.
position
.
y
=
controls
.
offsetY
vectorfield
.
position
.
z
=
controls
.
offsetZ
vectorfield
.
position
.
x
=
controls
.
offsetX
;
vectorfield
.
position
.
y
=
controls
.
offsetY
;
vectorfield
.
position
.
z
=
controls
.
offsetZ
;
arrowMaxLength
=
controls
.
arrowMaxLength
;
arrowMinLength
=
controls
.
arrowMinLength
;
//loopingMagic()
// keep looping
requestAnimationFrame
(
animate
);
...
...
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