Skip to content

Commit

Permalink
fix: manual rendering blank (#685)
Browse files Browse the repository at this point in the history
* fix: increate time to advance on manual mode

* chore: correct playground
  • Loading branch information
alvarosabu authored May 18, 2024
1 parent f840614 commit 0720d18
Show file tree
Hide file tree
Showing 9 changed files with 119 additions and 63 deletions.
23 changes: 0 additions & 23 deletions playground/src/components/RenderingLogger.vue

This file was deleted.

1 change: 1 addition & 0 deletions playground/src/components/TheSphere.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const { onBeforeRender } = useLoop()
onBeforeRender((state) => {
if (!sphereRef.value) { return }
sphereRef.value.position.y += Math.sin(state.elapsed) * 0.01
state.invalidate()
})
</script>

Expand Down
38 changes: 0 additions & 38 deletions playground/src/pages/advanced/OnDemand.vue

This file was deleted.

28 changes: 28 additions & 0 deletions playground/src/pages/advanced/manual/experience.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<script setup lang="ts">
import { OrbitControls } from '@tresjs/cientos'
import { useTres } from '@tresjs/core'
import BlenderCube from '../../../components/BlenderCube.vue'
const { advance } = useTres()
onMounted(() => {
advance()
})
</script>

<template>
<TresPerspectiveCamera
:position="[5, 5, 5]"
:look-at="[0, 0, 0]"
/>
<Suspense>
<BlenderCube />
</Suspense>
<TresGridHelper />
<OrbitControls @change="advance" />
<TresAmbientLight :intensity="1" />
<TresDirectionalLight
:position="[0, 8, 4]"
:intensity="0.7"
/>
</template>
24 changes: 24 additions & 0 deletions playground/src/pages/advanced/manual/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<script setup lang="ts">
import { TresCanvas } from '@tresjs/core'
import { useState } from '../../../composables/state'
import GraphPane from '../../../components/GraphPane.vue'
import ManualExperience from './experience.vue'
const { renderingTimes } = useState()
function onRender() {
renderingTimes.value = 1
}
</script>

<template>
<GraphPane />
<TresCanvas
render-mode="manual"
clear-color="#82DBC5"
@render="onRender"
>
<ManualExperience />
</TresCanvas>
</template>
36 changes: 36 additions & 0 deletions playground/src/pages/advanced/on-demand/experience.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<script setup lang="ts">
import { OrbitControls } from '@tresjs/cientos'
import { useTres } from '@tresjs/core'
import { ref, watch } from 'vue'
import BlenderCube from '../../../components/BlenderCube.vue'
const { invalidate } = useTres()
const blenderCubeRef = ref()
watch(blenderCubeRef, (prev, next) => {
if (!next) { return }
invalidate()
})
function onControlChange() {
invalidate()
}
</script>

<template>
<TresPerspectiveCamera
:position="[5, 5, 5]"
:look-at="[0, 0, 0]"
/>
<Suspense>
<BlenderCube ref="blenderCubeRef" />
</Suspense>
<TresGridHelper />
<OrbitControls @change="onControlChange" />
<TresAmbientLight :intensity="1" />
<TresDirectionalLight
:position="[0, 8, 4]"
:intensity="0.7"
/>
</template>
23 changes: 23 additions & 0 deletions playground/src/pages/advanced/on-demand/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<script setup lang="ts">
import { TresCanvas } from '@tresjs/core'
import { useState } from '../../../composables/state'
import GraphPane from '../../../components/GraphPane.vue'
import OnDemandExperience from './experience.vue'
const { renderingTimes } = useState()
function onRender() {
renderingTimes.value = 1
}
</script>

<template>
<GraphPane />
<TresCanvas
render-mode="on-demand"
clear-color="#82DBC5"
@render="onRender"
>
<OnDemandExperience />
</TresCanvas>
</template>
7 changes: 6 additions & 1 deletion playground/src/router/routes/advanced.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ export const advancedRoutes = [
{
path: '/advanced/on-demand',
name: 'On Demand',
component: () => import('../../pages/advanced/OnDemand.vue'),
component: () => import('../../pages/advanced/on-demand/index.vue'),
},
{
path: '/advanced/manual',
name: 'Manual rendering',
component: () => import('../../pages/advanced/manual/index.vue'),
},
{
path: '/advanced/take-over-loop',
Expand Down
2 changes: 1 addition & 1 deletion src/composables/useRenderer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export function useRenderer(
// Advance for the first time, setTimeout to make sure there is something to render
setTimeout(() => {
advance()
}, 1)
}, 100)
}

watchEffect(() => {
Expand Down

0 comments on commit 0720d18

Please sign in to comment.