-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4f76310
commit b6f3f33
Showing
7 changed files
with
113 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<script setup lang="ts"> | ||
import { TresCanvas } from '@tresjs/core' | ||
import { BasicShadowMap, SRGBColorSpace, NoToneMapping } from 'three' | ||
const environmentFiles = ['/px.jpg', '/nx.jpg', '/py.jpg', '/ny.jpg', '/pz.jpg', '/nz.jpg'] | ||
import { OrbitControls, useProgress, Environment } from '@tresjs/cientos' | ||
const gl = { | ||
clearColor: '#82DBC5', | ||
shadows: true, | ||
alpha: false, | ||
shadowMapType: BasicShadowMap, | ||
outputColorSpace: SRGBColorSpace, | ||
toneMapping: NoToneMapping, | ||
} | ||
const { progress, hasFinishLoading, items } = await useProgress() | ||
</script> | ||
|
||
<template> | ||
<pre>{{ items }}</pre> | ||
<Transition | ||
name="fade-overlay" | ||
enter-active-class="opacity-1 transition-opacity duration-200" | ||
leave-active-class="opacity-0 transition-opacity duration-200" | ||
> | ||
<div | ||
v-show="!hasFinishLoading" | ||
class="absolute bg-white t-0 l-0 w-full h-full z-20 flex justify-center items-center text-black font-mono" | ||
> | ||
<div class="w-200px"> | ||
Loading... {{ progress }} % | ||
<i class="i-ic-twotone-catching-pokemon animate-rotate-in"></i> | ||
</div> | ||
</div> | ||
</Transition> | ||
<TresCanvas v-bind="gl"> | ||
<TresPerspectiveCamera :position="[3, 3, 3]" /> | ||
<OrbitControls /> | ||
<Suspense> | ||
<Environment | ||
background | ||
:files="environmentFiles" | ||
:path="'https://raw.githubusercontent.com/Tresjs/assets/main/textures/environmentMap'" | ||
/> | ||
</Suspense> | ||
<TresGridHelper /> | ||
<TresAmbientLight :intensity="1" /> | ||
</TresCanvas> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<script setup lang="ts"></script> | ||
<template> | ||
<Suspense> | ||
<PrecipitationDemo /> | ||
<EnvironmentDemo /> | ||
</Suspense> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { DefaultLoadingManager } from 'three' | ||
import { Ref, ref } from 'vue' | ||
|
||
let saveLastTotalLoaded = 0 | ||
|
||
export function useProgress(): Promise<{ | ||
hasFinishLoading: Ref<boolean> | ||
progress: Ref<number> | ||
items: Ref<string[]> | ||
}> { | ||
const hasFinishLoading = ref(false) | ||
const progress = ref(0) | ||
const items: Ref<string[]> = ref([]) | ||
|
||
return new Promise(resolve => { | ||
DefaultLoadingManager.onStart = () => { | ||
hasFinishLoading.value = false | ||
} | ||
|
||
DefaultLoadingManager.onLoad = () => { | ||
hasFinishLoading.value = true | ||
} | ||
|
||
DefaultLoadingManager.onProgress = (item, loaded, total) => { | ||
if (loaded === total) { | ||
saveLastTotalLoaded = total | ||
hasFinishLoading.value = true | ||
items.value.push(item) | ||
} | ||
progress.value = Math.round(((loaded - saveLastTotalLoaded) / (total - saveLastTotalLoaded)) * 100 || 100, 2) | ||
} | ||
|
||
DefaultLoadingManager.onError = () => { | ||
hasFinishLoading.value = true | ||
} | ||
|
||
resolve({ | ||
items, | ||
hasFinishLoading, | ||
progress, | ||
}) | ||
}) | ||
} |