Skip to content

Commit d352444

Browse files
committed
feat: add loading screen realistic pokeball
1 parent f3f286d commit d352444

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

components/content/realistic/index.vue

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,41 @@
11
<script setup lang="ts">
22
import { TresCanvas } from '@tresjs/core'
33
import { OrbitControls, Environment } from '@tresjs/cientos'
4+
import { DefaultLoadingManager } from 'three'
45
const environmentFiles = ['/px.jpg', '/nx.jpg', '/py.jpg', '/ny.jpg', '/pz.jpg', '/nz.jpg']
6+
7+
//TODO: replace this when UseProgress is implemented https://github.com/Tresjs/cientos/issues/22
8+
9+
const hasFinishLoading = ref(false)
10+
const progress = ref(0)
11+
12+
let saveLastTotalLoaded = 0
13+
14+
DefaultLoadingManager.onProgress = (item, loaded, total) => {
15+
if (loaded === total) {
16+
saveLastTotalLoaded = total
17+
hasFinishLoading.value = true
18+
}
19+
progress.value = Math.round(((loaded - saveLastTotalLoaded) / (total - saveLastTotalLoaded)) * 100 || 100, 2)
20+
}
521
</script>
622

723
<template>
24+
<Transition
25+
name="fade-overlay"
26+
enter-active-class="opacity-1 transition-opacity duration-200"
27+
leave-active-class="opacity-0 transition-opacity duration-200"
28+
>
29+
<div
30+
v-show="!hasFinishLoading"
31+
class="absolute bg-grey-600 t-0 l-0 w-full h-full z-20 flex justify-center items-center text-black font-mono"
32+
>
33+
<div class="w-200px">
34+
Loading... {{ progress }} %
35+
<i class="i-ic-twotone-catching-pokemon animate-rotate-in"></i>
36+
</div>
37+
</div>
38+
</Transition>
839
<TresCanvas preset="realistic">
940
<OrbitControls />
1041
<TresPerspectiveCamera :position="[11, 11, 11]" />

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"vite-plugin-glsl": "^1.1.2"
2121
},
2222
"dependencies": {
23+
"@iconify-json/ic": "^1.1.13",
2324
"@tresjs/cientos": "2.0.0-alpha.5",
2425
"@tresjs/core": "2.0.0-alpha.4",
2526
"postprocessing": "^6.30.2",

pnpm-lock.yaml

Lines changed: 8 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)