Skip to content

Commit

Permalink
chore: internal playground organisation (#601)
Browse files Browse the repository at this point in the history
* chore: new internal playground org and testing pages

* chore: fix lint

* chore: better styling of playground landing page

* chore: lint
  • Loading branch information
alvarosabu authored Mar 27, 2024
1 parent cd0c3bc commit a6578a7
Show file tree
Hide file tree
Showing 30 changed files with 446 additions and 154 deletions.
32 changes: 27 additions & 5 deletions docs/public/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions playground/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export {}
declare module 'vue' {
export interface GlobalComponents {
AnimatedModel: typeof import('./src/components/AnimatedModel.vue')['default']
BlenderCube: typeof import('./src/components/BlenderCube.vue')['default']
CameraOperator: typeof import('./src/components/CameraOperator.vue')['default']
Cameras: typeof import('./src/components/Cameras.vue')['default']
copy: typeof import('./src/components/TheBasic copy.vue')['default']
Expand All @@ -17,10 +18,12 @@ declare module 'vue' {
DynamicModel: typeof import('./src/components/DynamicModel.vue')['default']
FBXModels: typeof import('./src/components/FBXModels.vue')['default']
Gltf: typeof import('./src/components/gltf/index.vue')['default']
GraphPane: typeof import('./src/components/GraphPane.vue')['default']
LocalOrbitControls: typeof import('./src/components/LocalOrbitControls.vue')['default']
MeshWobbleMaterial: typeof import('./src/components/meshWobbleMaterial/index.vue')['default']
MultipleCanvas: typeof import('./src/components/MultipleCanvas.vue')['default']
PortalJourney: typeof import('./src/components/portal-journey/index.vue')['default']
RenderingLogger: typeof import('./src/components/RenderingLogger.vue')['default']
Responsiveness: typeof import('./src/components/Responsiveness.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
Expand Down
27 changes: 27 additions & 0 deletions playground/public/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 12 additions & 2 deletions playground/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
<script setup lang="ts">
import { watch } from 'vue'
import { useRoute } from 'vue-router'
const route = useRoute()
function setBodyClass(routeName: string) {
document.title = `Core Playground - ${routeName}`
document.body.className = routeName
}
watch([route], () => setBodyClass(route.name?.toString() ?? ''))
</script>

<template>
<router-view />
<Suspense>
<router-view />
</Suspense>
</template>

18 changes: 18 additions & 0 deletions playground/src/components/BlenderCube.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<script setup lang="ts">
import { useTresContext } from '@tresjs/core'
import { useGLTF } from '@tresjs/cientos'
const { nodes } = await useGLTF('https://raw.githubusercontent.com/Tresjs/assets/main/models/gltf/blender-cube.glb',
{ draco: true })
const model = nodes.Cube
model.position.set(0, 1, 0)
const state = useTresContext()
state.invalidate()
</script>

<template>
<primitive :object="model" />
</template>
101 changes: 101 additions & 0 deletions playground/src/components/GraphPane.vue
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>
24 changes: 24 additions & 0 deletions playground/src/components/RenderingLogger.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<script setup lang="ts">
import { useRenderLoop, useTresContext } from '@tresjs/core'
import { OrbitControls } from '@tresjs/cientos'
import { onMounted } from 'vue'
import { useState } from '../composables/state'
const { renderingTimes } = useState()
const state = useTresContext()
function manualInvalidate() {
state.invalidate()
}
onMounted(() => {
manualInvalidate()
})
</script>

<template>
<OrbitControls
@change="manualInvalidate"
/>
</template>
11 changes: 11 additions & 0 deletions playground/src/composables/state.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { reactive, toRefs } from 'vue'

const state = reactive({
renderingTimes: 0,
})
export function useState() {
return {
...toRefs(state),

}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import TheBasic from './TheBasic.vue'
import TheBasic from '../basic/index.vue'
</script>

<template>
Expand Down
File renamed without changes.
File renamed without changes.
41 changes: 0 additions & 41 deletions playground/src/pages/click-blocking-box.vue

This file was deleted.

File renamed without changes.
Loading

0 comments on commit a6578a7

Please sign in to comment.