Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
proyecto-covid-threejs-igev
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Automate
Agent sessions
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
jonschi
proyecto-covid-threejs-igev
Commits
4e1972dc
Commit
4e1972dc
authored
Mar 31, 2022
by
jonschi
Browse files
Options
Downloads
Patches
Plain Diff
animate in with tween
parent
f2540dc7
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend/src/components/Globe.vue
+26
-6
26 additions, 6 deletions
frontend/src/components/Globe.vue
with
26 additions
and
6 deletions
frontend/src/components/Globe.vue
+
26
−
6
View file @
4e1972dc
...
...
@@ -3,6 +3,7 @@ import { nextTick, onMounted, watch } from "@vue/runtime-core";
import
*
as
THREE
from
"
three
"
;
import
{
OrbitControls
}
from
"
three/examples/jsm/controls/OrbitControls.js
"
;
import
{
VueElement
,
ref
}
from
"
vue
"
;
import
*
as
TWEEN
from
"
@tweenjs/tween.js
"
;
const
props
=
defineProps
({
geoData
:
Object
,
...
...
@@ -15,7 +16,9 @@ const emit = defineEmits(["regionSelected"]);
// Create globally usable variables for data
let
tooltipElement
;
let
tooltipString
=
ref
(
""
);
const
tooltipString
=
ref
(
""
);
const
cameraTargetPosition
=
new
THREE
.
Vector3
(
370
,
370
,
-
15
);
const
cameraInitialPosition
=
new
THREE
.
Vector3
(
1000
,
500
,
2000
);
const
offset
=
700
;
// for the globes offset to the right, TODO: change based on window width
let
rootObject
=
new
THREE
.
Object3D
();
// root object for the extruded elements
...
...
@@ -39,7 +42,11 @@ var camera = new THREE.PerspectiveCamera(
1
,
10000
);
camera
.
position
.
set
(
370
,
370
,
-
15
);
camera
.
position
.
set
(
cameraInitialPosition
.
x
,
cameraInitialPosition
.
y
,
cameraInitialPosition
.
z
);
// Prepare Raycaster
let
intersectedObject
;
...
...
@@ -50,9 +57,9 @@ let mouse = new THREE.Vector2(-1, -1); // vector to store mouse position
// Create and init lights
let
worldLight
=
new
THREE
.
DirectionalLight
(
0xffffff
);
worldLight
.
position
.
set
(
camera
.
p
osition
.
x
,
camera
.
p
osition
.
y
,
+
camera
.
p
osition
.
z
camera
TargetP
osition
.
x
,
camera
TargetP
osition
.
y
,
camera
TargetP
osition
.
z
);
worldLight
.
layers
.
set
(
worldLayer
,
objectLayer
);
scene
.
add
(
worldLight
);
...
...
@@ -301,10 +308,23 @@ onMounted(async () => {
}
controls
.
update
();
// let the globe keep spinning if user lets go of the mouse
TWEEN
.
update
();
window
.
requestAnimationFrame
(
tick
);
// request a new animation frame
};
watch
(()
=>
props
.
selectedDate
,
addAllRegions
,
{
immediate
:
true
});
watch
(
props
.
covidData
,
()
=>
{
addAllRegions
();
new
TWEEN
.
Tween
(
camera
.
position
)
.
to
(
cameraTargetPosition
,
3000
)
.
easing
(
TWEEN
.
Easing
.
Cubic
.
Out
)
.
start
();
},
{
immediate
:
true
}
);
watch
(()
=>
props
.
selectedDate
,
addAllRegions
);
tick
();
});
</
script
>
...
...
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
sign in
to comment