-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: render emit and advance playgroudn for render modes
- Loading branch information
1 parent
544fb39
commit 5d256fc
Showing
8 changed files
with
216 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<script lang="ts" setup> | ||
import { ref } from 'vue' | ||
import { useRafFn } from '@vueuse/core' | ||
import { useState } from '../composables/state' | ||
const width = 160 | ||
const height = 40 | ||
const strokeWidth = 2 | ||
const updateInterval = 100 // Update interval in milliseconds | ||
const topOffset = 0 // Offset from the top | ||
const points = ref('') | ||
const frameTimes = ref([]) | ||
const maxFrames = ref(width / strokeWidth) | ||
let lastUpdateTime = performance.now() | ||
const { renderingTimes } = useState() | ||
useRafFn(({ timestamp }) => { | ||
if (timestamp - lastUpdateTime >= updateInterval) { | ||
lastUpdateTime = timestamp | ||
frameTimes.value.push(renderingTimes?.value) | ||
renderingTimes.value = 0 | ||
if (frameTimes.value.length > maxFrames.value) { | ||
frameTimes.value.shift() | ||
} | ||
points.value = frameTimes.value | ||
.map( | ||
(value, index) => | ||
`${index * strokeWidth},${ | ||
height + topOffset - strokeWidth / 2 - (value * (height + topOffset - strokeWidth)) / 2 | ||
}`, | ||
) | ||
.join(' ') | ||
} | ||
}) | ||
</script> | ||
|
||
<template> | ||
<div | ||
class="absolute | ||
right-2 | ||
top-2 | ||
flex | ||
px-4 | ||
py-1 | ||
justify-between | ||
gap-4 | ||
items-center | ||
mb-2 | ||
z-10 | ||
bg-white | ||
dark:bg-dark | ||
shadow-xl | ||
rounded | ||
border-4 | ||
border-solid | ||
bg-primary | ||
border-primary | ||
pointer-events-none | ||
overflow-hidden" | ||
> | ||
<label class="text-secondary text-xs w-1/3">Rendering Activity</label> | ||
|
||
<div | ||
class=" | ||
bg-gray-100 | ||
dark:bg-gray-600 | ||
relative | ||
w-2/3 | ||
p-1 | ||
rounded | ||
text-right | ||
text-xs | ||
focus:border-gray-200 | ||
outline-none | ||
border-none | ||
font-sans | ||
" | ||
> | ||
<svg | ||
:width="width" | ||
:height="height" | ||
xmlns="http://www.w3.org/2000/svg" | ||
fill="none" | ||
> | ||
<polyline | ||
:points="points" | ||
stroke="lightgray" | ||
:stroke-width="strokeWidth" | ||
stroke-linecap="round" | ||
stroke-linejoin="round" | ||
/> | ||
</svg> | ||
</div> | ||
</div> | ||
</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,10 @@ | ||
import { reactive, toRefs } from 'vue' | ||
|
||
const state = reactive({ | ||
renderingTimes: 0, | ||
}) | ||
export function useState() { | ||
return { | ||
...toRefs(state), | ||
} | ||
} |
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,48 @@ | ||
<script setup lang="ts"> | ||
import { OrbitControls } from '@tresjs/cientos' | ||
import { useTres } from '@tresjs/core' | ||
import { EffectComposer, Pixelation } from '@tresjs/post-processing' | ||
import { useState } from '../../../composables/state' | ||
const { invalidate } = useTres() | ||
function onControlChange() { | ||
invalidate() | ||
} | ||
const { renderingTimes } = useState() | ||
function onRender() { | ||
renderingTimes.value = 1 | ||
} | ||
</script> | ||
|
||
<template> | ||
<TresPerspectiveCamera | ||
:position="[5, 5, 5]" | ||
:look-at="[0, 0, 0]" | ||
/> | ||
<OrbitControls @change="onControlChange" /> | ||
<TresMesh | ||
:position="[-3.5, 1, 0]" | ||
> | ||
<TresConeGeometry :args="[1.25, 2, 4, 1, false, Math.PI * 0.25]" /> | ||
<TresMeshNormalMaterial /> | ||
</TresMesh> | ||
|
||
<TresMesh :position="[0, 1, 0]"> | ||
<TresBoxGeometry :args="[2, 2, 2]" /> | ||
<TresMeshNormalMaterial /> | ||
</TresMesh> | ||
|
||
<TresMesh :position="[3.5, 1, 0]"> | ||
<TresSphereGeometry /> | ||
<TresMeshNormalMaterial /> | ||
</TresMesh> | ||
|
||
<TresGridHelper /> | ||
|
||
<EffectComposer @render="onRender"> | ||
<Pixelation :granularity="10" /> | ||
</EffectComposer> | ||
</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,16 @@ | ||
<script setup lang="ts"> | ||
import { TresCanvas } from '@tresjs/core' | ||
import GraphPane from '../../../components/GraphPane.vue' | ||
import OnDemandExperience from './experience.vue' | ||
</script> | ||
|
||
<template> | ||
<GraphPane /> | ||
<TresCanvas | ||
render-mode="on-demand" | ||
clear-color="#c0ffee" | ||
@render="onRender" | ||
> | ||
<OnDemandExperience /> | ||
</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
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