-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: trying to create a playground for useProgress
- Loading branch information
1 parent
efdde6d
commit 3373f0a
Showing
5 changed files
with
137 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<script setup lang="ts"> | ||
import { useTexture } from '@tresjs/core' | ||
import { useGLTF } from '@tresjs/cientos' | ||
import { DoubleSide, MeshBasicMaterial } from 'three' | ||
const { nodes } = await useGLTF('https://raw.githubusercontent.com/Tresjs/lab/main/public/models/potions-classroom/wizard-potions-classroom.glb', { | ||
draco: true, | ||
}) | ||
console.log(nodes) | ||
const tableTexture = await useTexture(['https://raw.githubusercontent.com/Tresjs/lab/main/public/models/potions-classroom/table.png']) | ||
tableTexture.flipY = false | ||
const roomTexture = await useTexture(['https://raw.githubusercontent.com/Tresjs/lab/main/public/models/potions-classroom/room.png']) | ||
roomTexture.flipY = false | ||
const roomMaterial = new MeshBasicMaterial({ | ||
map: roomTexture, | ||
side: DoubleSide, | ||
}) | ||
nodes.Room.material = roomMaterial | ||
nodes.Floor.material = roomMaterial | ||
</script> | ||
|
||
<template> | ||
<primitive :object="nodes.Room" /> | ||
<primitive :object="nodes.Floor" /> | ||
</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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<script setup lang="ts"> | ||
import { useGLTF } from '@tresjs/cientos' | ||
import type { Texture } from 'three' | ||
import { DoubleSide, MeshBasicMaterial } from 'three' | ||
const props = defineProps<{ | ||
texture: Texture | ||
}>() | ||
const { nodes } = await useGLTF('https://raw.githubusercontent.com/Tresjs/lab/main/public/models/potions-classroom/wizard-potions-classroom.glb', { | ||
draco: true, | ||
}) | ||
const bakedMaterial = new MeshBasicMaterial({ | ||
map: props.texture, | ||
side: DoubleSide, | ||
}) | ||
nodes.Table.children.forEach((child) => { | ||
if (child.isMesh) { | ||
child.material = bakedMaterial | ||
} | ||
}) | ||
const stools = Object.values(nodes).filter(node => node.name.includes('Stool')) | ||
stools.forEach((stool) => { | ||
stool.material = bakedMaterial | ||
}) | ||
</script> | ||
|
||
<template> | ||
<primitive :object="nodes.Table" /> | ||
<primitive | ||
v-for="stool of stools" | ||
:object="stool" | ||
/> | ||
</template> |
29 changes: 29 additions & 0 deletions
29
playground/vue/src/pages/loaders/use-progress/UseProgressDemo.vue
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,29 @@ | ||
<script setup lang="ts"> | ||
import { OrbitControls } from '@tresjs/cientos' | ||
import Model from './Model.vue' | ||
</script> | ||
|
||
<template> | ||
<TresPerspectiveCamera :position="[5, 5, 5]" /> | ||
<Suspense> | ||
<template v-if="true"> | ||
<Model /> | ||
<Model /> | ||
<Model /> | ||
<Model /> | ||
<Model /> | ||
<Model /> | ||
<Model /> | ||
<Model /> | ||
<Model /> | ||
<Model /> | ||
<Model /> | ||
<Model /> | ||
<Model /> | ||
<Model /> | ||
</template> | ||
</Suspense> | ||
<TresGridHelper /> | ||
<TresAmbientLight :intensity="1" /> | ||
<OrbitControls /> | ||
</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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<script setup lang="ts"> | ||
import { TresCanvas } from '@tresjs/core' | ||
import { TresLeches, useControls } from '@tresjs/leches' | ||
import Experiment from './UseProgressDemo.vue' | ||
import '@tresjs/leches/styles' | ||
import { useProgress } from '@tresjs/cientos' | ||
useControls('fpsgraph') | ||
const { hasFinishLoading, progress } = await useProgress() | ||
</script> | ||
|
||
<template> | ||
<OverlayInfo> | ||
<h1>useProgress</h1> | ||
<p>This is a demo of the useProgress hook. It shows the progress of the GLTFModel loading.</p> | ||
</OverlayInfo> | ||
<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-grey-600 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 }} % | ||
</div> | ||
</div> | ||
</Transition> | ||
<TresLeches /> | ||
<TresCanvas clear-color="#000000"> | ||
<Experiment /> | ||
</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