Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(app): 680 UseTexture composable as component #757

Merged
merged 10 commits into from
Sep 6, 2024
Prev Previous commit
Next Next commit
fix: linter
  • Loading branch information
JaimeTorrealba committed Sep 2, 2024
commit 962ec37c613dfcc3243464a11df414777b86a66f
2 changes: 1 addition & 1 deletion playground/src/pages/basic/Textures.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup>
import { TresCanvas, UseTexture } from '@tresjs/core'
import { OrbitControls } from '@tresjs/cientos'
import { TresCanvas, UseTexture } from '@tresjs/core'

const path = 'https://raw.githubusercontent.com/Tresjs/assets/main/textures/black-rock/Rock035_2K_Displacement.jpg'
</script>
Expand Down
33 changes: 17 additions & 16 deletions playground/vue/src/pages/basic/Textures.vue
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
<script setup>
import { TresCanvas, UseTexture, vLog } from '@tresjs/core'
import { TresCanvas, UseTexture } from '@tresjs/core'
import { OrbitControls } from '@tresjs/cientos'

const path = 'https://raw.githubusercontent.com/Tresjs/assets/main/textures/black-rock/Rock035_2K_Displacement.jpg'
</script>

<template>
<TresCanvas window-size clear-color="#111">
<TresPerspectiveCamera :position="[0, 0, 3]" :fov="45" :aspect="1" :near="0.1" :far="1000" />
<OrbitControls />
<Suspense>
<UseTexture v-slot="{ textures }" :map="path">
<TresMesh>
<TresBoxGeometry />
<TresMeshStandardMaterial :map="textures.map" v-log />
</TresMesh>
</UseTexture>
</Suspense>
<TresDirectionalLight :position="[4, 4, 4]" />
<TresAmbientLight :intensity="0.5" />
</TresCanvas>
</template>
<TresCanvas window-size clear-color="#111">
<TresPerspectiveCamera :position="[0, 0, 3]" :fov="45" :aspect="1" :near="0.1" :far="1000" />
<OrbitControls />
<Suspense>
<UseTexture v-slot="{ textures }" :map="path">
<TresMesh>
<TresBoxGeometry />
<TresMeshStandardMaterial :map="textures.map" />
</TresMesh>
</UseTexture>
</Suspense>
<TresDirectionalLight :position="[4, 4, 4]" />
<TresAmbientLight :intensity="0.5" />
</TresCanvas>
</template>
1 change: 1 addition & 0 deletions src/composables/useTexture/component.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const props = defineProps<PBRUseTextureMap>()

const data = await reactive(useTexture(props))
</script>

<template>
<slot :textures="data"></slot>
</template>
6 changes: 3 additions & 3 deletions src/core/nodeOps.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1626,9 +1626,9 @@ function createSimpleMeshPrimitiveTree(nodeOps) {
const nodes = []
const objects = []
const spiesByKey: Partial<Record<
keyof typeof nodesByKey,
{ material: () => void, geometry: () => void }
>> = { }
keyof typeof nodesByKey,
{ material: () => void, geometry: () => void }
>> = { }
const spies = []
const undisposed = new Set()
for (const [key, node] of Object.entries(nodesByKey)) {
Expand Down
Loading