Skip to content

Commit 48c7775

Browse files
committed
fix: missing files
1 parent 756acf0 commit 48c7775

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+8075
-0
lines changed

README.md

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Nuxt 3 Minimal Starter
2+
3+
Look at the [Nuxt 3 documentation](https://nuxt.com/docs/getting-started/introduction) to learn more.
4+
5+
## Setup
6+
7+
Make sure to install the dependencies:
8+
9+
```bash
10+
# yarn
11+
yarn install
12+
13+
# npm
14+
npm install
15+
16+
# pnpm
17+
pnpm install
18+
```
19+
20+
## Development Server
21+
22+
Start the development server on http://localhost:3000
23+
24+
```bash
25+
npm run dev
26+
```
27+
28+
## Production
29+
30+
Build the application for production:
31+
32+
```bash
33+
npm run build
34+
```
35+
36+
Locally preview production build:
37+
38+
```bash
39+
npm run preview
40+
```
41+
42+
Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.

app.vue

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<script lang="ts">
2+
import { extend } from '@tresjs/core'
3+
import { OrbitControls } from 'three-stdlib'
4+
5+
extend({ OrbitControls })
6+
</script>
7+
8+
<template>
9+
<div>
10+
<NuxtLayout>
11+
<NuxtPage />
12+
</NuxtLayout>
13+
</div>
14+
</template>

assets/logo.svg

+5
Loading

components/TestOrbitControls.vue

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<script lang="ts" setup>
2+
import { useTres } from '@tresjs/core'
3+
import { Camera, Vector3 } from 'three'
4+
import { OrbitControls } from 'three-stdlib'
5+
import { ref, type Ref } from 'vue'
6+
7+
export interface OrbitControlsProps {
8+
/**
9+
* Whether to make this the default controls.
10+
*
11+
* @default false
12+
* @type {boolean}
13+
* @memberof OrbitControlsProps
14+
* @see https://threejs.org/docs/#examples/en/controls/OrbitControls
15+
*/
16+
makeDefault?: boolean
17+
/**
18+
* The camera to control.
19+
*
20+
* @type {Camera}
21+
* @memberof OrbitControlsProps
22+
* @see https://threejs.org/docs/#examples/en/controls/OrbitControls
23+
*/
24+
camera?: Camera
25+
/**
26+
* The dom element to listen to.
27+
*
28+
* @type {HTMLElement}
29+
* @memberof OrbitControlsProps
30+
* @see https://threejs.org/docs/#examples/en/controls/OrbitControls
31+
*/
32+
domElement?: HTMLElement
33+
/**
34+
* The target to orbit around.
35+
*
36+
* @type {Ref<Vector3>}
37+
* @memberof OrbitControlsProps
38+
* @see https://threejs.org/docs/#examples/en/controls/OrbitControls
39+
*/
40+
target?: Ref<Vector3>
41+
/**
42+
* Whether to enable damping.
43+
*
44+
* @default false
45+
* @type {boolean}
46+
* @memberof OrbitControlsProps
47+
* @see https://threejs.org/docs/#examples/en/controls/OrbitControls
48+
*/
49+
enableDamping?: boolean
50+
}
51+
52+
const props = withDefaults(defineProps<OrbitControlsProps>(), {
53+
makeDefault: false,
54+
})
55+
56+
const controls: Ref<OrbitControls | null> = ref(null)
57+
58+
defineExpose({ controls })
59+
60+
const { state, setState } = useTres()
61+
62+
watchEffect(
63+
() => {
64+
if (!state.renderer || !state.camera) return
65+
66+
controls.value = new OrbitControls(state.camera, state.renderer.domElement)
67+
if (props.makeDefault) {
68+
setState('controls', controls.value)
69+
}
70+
},
71+
{
72+
flush: 'post',
73+
},
74+
)
75+
</script>
76+
77+
<template></template>

components/TheCard.vue

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<script setup lang="ts">
2+
defineProps<{
3+
title: string
4+
path: string
5+
media: string
6+
description: string
7+
author: {
8+
name: string
9+
avatar: string
10+
}
11+
tags: string[]
12+
}>()
13+
</script>
14+
<template>
15+
<NuxtLink :to="path">
16+
<div class="shadow-lg rounded-lg overflow-hidden">
17+
<NuxtImg class="aspect-video object-cover" :src="media" />
18+
<div class="p-4">
19+
<h2 class="font-bold text-lg mb-2">{{ title }}</h2>
20+
<p class="text-sm text-gray-400 mb-2 min-h-75px">{{ description }}</p>
21+
<div class="flex gap-4">
22+
<TheTag v-for="tag in tags" :key="tag" :tag="tag">{{ tag }}</TheTag>
23+
</div>
24+
</div>
25+
<footer class="flex px-4 pb-4 gap-4">
26+
<div class="flex items-center">
27+
<NuxtImg :src="author.avatar" class="border-2 border-gray-200 w-8 h-8 mr-4 rounded-full" />
28+
<span class="font-bold text-sm">{{ author.name }}</span>
29+
</div>
30+
</footer>
31+
</div>
32+
</NuxtLink>
33+
</template>

components/TheTag.vue

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<script lang="ts" setup></script>
2+
3+
<template>
4+
<span class="bg-primary inline-flex px-2 py-1 text-xs rounded">
5+
<slot />
6+
</span>
7+
</template>
8+
9+
<style scoped></style>

components/TheToolbar.vue

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<script lang="ts" setup>
2+
import Logo from '/assets/logo.svg'
3+
</script>
4+
5+
<template>
6+
<header class="fixed top-0 z-10 w-full bg-base-100 bg-opacity-60 py-4">
7+
<div class="px-4 sm:px-0 container mx-auto flex justify-between">
8+
<div class="flex items-center">
9+
<Logo class="mr-8" />
10+
<a class="font-bold" href="/" title="Home">Playground</a>
11+
</div>
12+
<ul class="flex justify-between w-50px">
13+
<a href="https://tresjs.org/" target="_blank" class="i-carbon-document"></a>
14+
<a href="https://github.com/Tresjs/playground" target="_blank" class="i-logos-github-icon"></a>
15+
</ul>
16+
</div>
17+
</header>
18+
</template>
19+
20+
<style scoped></style>
+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<script setup lang="ts">
2+
import { TresCanvas, TresInstance, useRenderLoop, useTres } from '@tresjs/core'
3+
import { BasicShadowMap, sRGBEncoding, NoToneMapping } from 'three'
4+
5+
import { TransformControls } from '@tresjs/cientos'
6+
import { ShallowRef } from 'vue'
7+
8+
const gl = {
9+
clearColor: '#82DBC5',
10+
shadows: true,
11+
alpha: false,
12+
shadowMapType: BasicShadowMap,
13+
outputEncoding: sRGBEncoding,
14+
toneMapping: NoToneMapping,
15+
}
16+
17+
const boxRef: ShallowRef<TresInstance | null> = shallowRef(null)
18+
19+
const { onLoop } = useRenderLoop()
20+
21+
onLoop(({ delta, elapsed }) => {
22+
if (boxRef.value) {
23+
boxRef.value.rotation.y += delta
24+
boxRef.value.rotation.z = elapsed * 0.2
25+
}
26+
})
27+
28+
const camera = ref(null)
29+
30+
watchEffect(() => {
31+
if (camera.value) {
32+
camera.value.lookAt(0, 0, 0)
33+
}
34+
})
35+
36+
const transformState = shallowReactive({
37+
mode: 'translate',
38+
size: 1,
39+
axis: 'XY',
40+
showX: true,
41+
showY: true,
42+
showZ: true,
43+
})
44+
</script>
45+
46+
<template>
47+
<TresCanvas v-bind="gl">
48+
<!-- <OrbitControls /> -->
49+
<TestOrbitControls make-default />
50+
<TresPerspectiveCamera ref="camera" :position="[3, 3, 3]" />
51+
<TresMesh ref="boxRef" :scale="1">
52+
<TresBoxGeometry :args="[1, 1, 1]" />
53+
<TresMeshNormalMaterial />
54+
</TresMesh>
55+
<TresAmbientLight :intensity="1" />
56+
<TresDirectionalLight :position="[0, 2, 4]" :intensity="2" />
57+
</TresCanvas>
58+
</template>

components/content/Events.vue

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<script setup lang="ts">
2+
import { TresCanvas, TresEvent } from '@tresjs/core'
3+
import { BasicShadowMap, sRGBEncoding, NoToneMapping } from 'three'
4+
5+
import { OrbitControls } from '@tresjs/cientos'
6+
7+
const gl = {
8+
clearColor: '#202020',
9+
shadows: true,
10+
alpha: false,
11+
shadowMapType: BasicShadowMap,
12+
outputEncoding: sRGBEncoding,
13+
toneMapping: NoToneMapping,
14+
}
15+
16+
function onClick(ev: TresEvent) {
17+
if (ev) {
18+
ev.object.material.color.set('#008080')
19+
}
20+
}
21+
22+
function onPointerEnter(ev: TresEvent) {
23+
console.log(ev)
24+
if (ev) {
25+
ev.object.material.color.set('#CCFF03')
26+
}
27+
}
28+
29+
function onPointerLeave(ev: TresEvent) {
30+
if (ev) {
31+
/* ev.object.material.color.set('#efefef') */
32+
}
33+
}
34+
</script>
35+
36+
<template>
37+
<TresCanvas v-bind="gl">
38+
<OrbitControls />
39+
<TresPerspectiveCamera :position="[11, 11, 11]" :fov="45" :near="0.1" :far="1000" :look-at="[0, 0, 0]" />
40+
41+
<template v-for="x in [-2.5, 0, 2.5]">
42+
<template v-for="y in [-2.5, 0, 2.5]">
43+
<TresMesh
44+
v-for="z in [-2.5, 0, 2.5]"
45+
:key="`${[x, y, z]}`"
46+
:position="[x, y, z]"
47+
@click="onClick"
48+
@pointer-enter="onPointerEnter"
49+
@pointer-leave="onPointerLeave"
50+
>
51+
<TresBoxGeometry :args="[1, 1, 1]" />
52+
<TresMeshToonMaterial color="#efefef" />
53+
</TresMesh>
54+
</template>
55+
</template>
56+
<TresDirectionalLight :intensity="1" />
57+
<TresAmbientLight :intensity="1" />
58+
</TresCanvas>
59+
</template>

0 commit comments

Comments
 (0)