-
-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #82 from Tresjs/feature/playground
feat(playground): astro playground
- Loading branch information
Showing
39 changed files
with
2,827 additions
and
878 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# build output | ||
dist/ | ||
.output/ | ||
|
||
# dependencies | ||
node_modules/ | ||
|
||
# logs | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
|
||
|
||
# environment variables | ||
.env | ||
.env.production | ||
|
||
# macOS-specific files | ||
.DS_Store |
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,4 @@ | ||
{ | ||
"recommendations": ["astro-build.astro-vscode"], | ||
"unwantedRecommendations": [] | ||
} |
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,11 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"command": "./node_modules/.bin/astro dev", | ||
"name": "Development server", | ||
"request": "launch", | ||
"type": "node-terminal" | ||
} | ||
] | ||
} |
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,50 @@ | ||
# Welcome to [Astro](https://astro.build) | ||
|
||
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/withastro/astro/tree/latest/examples/basics) | ||
[![Open with CodeSandbox](https://assets.codesandbox.io/github/button-edit-lime.svg)](https://codesandbox.io/s/github/withastro/astro/tree/latest/examples/basics) | ||
|
||
> 🧑🚀 **Seasoned astronaut?** Delete this file. Have fun! | ||
![basics](https://user-images.githubusercontent.com/4677417/186188965-73453154-fdec-4d6b-9c34-cb35c248ae5b.png) | ||
|
||
|
||
## 🚀 Project Structure | ||
|
||
Inside of your Astro project, you'll see the following folders and files: | ||
|
||
``` | ||
/ | ||
├── public/ | ||
│ └── favicon.svg | ||
├── src/ | ||
│ ├── components/ | ||
│ │ └── Card.astro | ||
│ ├── layouts/ | ||
│ │ └── Layout.astro | ||
│ └── pages/ | ||
│ └── index.astro | ||
└── package.json | ||
``` | ||
|
||
Astro looks for `.astro` or `.md` files in the `src/pages/` directory. Each page is exposed as a route based on its file name. | ||
|
||
There's nothing special about `src/components/`, but that's where we like to put any Astro/React/Vue/Svelte/Preact components. | ||
|
||
Any static assets, like images, can be placed in the `public/` directory. | ||
|
||
## 🧞 Commands | ||
|
||
All commands are run from the root of the project, from a terminal: | ||
|
||
| Command | Action | | ||
| :--------------------- | :------------------------------------------------- | | ||
| `npm install` | Installs dependencies | | ||
| `npm run dev` | Starts local dev server at `localhost:3000` | | ||
| `npm run build` | Build your production site to `./dist/` | | ||
| `npm run preview` | Preview your build locally, before deploying | | ||
| `npm run astro ...` | Run CLI commands like `astro add`, `astro preview` | | ||
| `npm run astro --help` | Get help using the Astro CLI | | ||
|
||
## 👀 Want to learn more? | ||
|
||
Feel free to check [our documentation](https://docs.astro.build) or jump into our [Discord server](https://astro.build/chat). |
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,9 @@ | ||
import { defineConfig } from 'astro/config' | ||
|
||
// https://astro.build/config | ||
import vue from '@astrojs/vue' | ||
|
||
// https://astro.build/config | ||
export default defineConfig({ | ||
integrations: [vue({ appEntrypoint: '/src/pages/_app' })], | ||
}) |
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,32 @@ | ||
{ | ||
"name": "@tresjs/playground", | ||
"description": "Playground for TresJS and R3F", | ||
"author": "Alvaro Saburido <[email protected]> (https://github.com/alvarosabu/)", | ||
"type": "module", | ||
"version": "1.0.0", | ||
"license": "MIT", | ||
"keywords": [ | ||
"vue", | ||
"3d", | ||
"threejs", | ||
"three", | ||
"threejs-vue" | ||
], | ||
"scripts": { | ||
"dev": "astro dev", | ||
"start": "astro dev", | ||
"build": "astro build", | ||
"preview": "astro preview", | ||
"astro": "astro" | ||
}, | ||
"dependencies": { | ||
"@astrojs/vue": "^1.2.2", | ||
"astro": "^1.9.2", | ||
"vue": "^3.2.45" | ||
}, | ||
"devDependencies": { | ||
"@tresjs/cientos": "workspace:^1.4.0", | ||
"@tresjs/core": "workspace:^1.5.0", | ||
"three": "^0.148.0" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,62 @@ | ||
--- | ||
export interface Props { | ||
title: string; | ||
body: string; | ||
href: string; | ||
} | ||
const { href, title, body } = Astro.props; | ||
--- | ||
|
||
<li class="link-card"> | ||
<a href={href}> | ||
<h2> | ||
{title} | ||
<span>→</span> | ||
</h2> | ||
<p> | ||
{body} | ||
</p> | ||
</a> | ||
</li> | ||
<style> | ||
.link-card { | ||
list-style: none; | ||
display: flex; | ||
padding: 0.15rem; | ||
background-color: white; | ||
background-image: var(--accent-gradient); | ||
background-size: 400%; | ||
border-radius: 0.5rem; | ||
background-position: 100%; | ||
transition: background-position 0.6s cubic-bezier(0.22, 1, 0.36, 1); | ||
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1); | ||
} | ||
|
||
.link-card > a { | ||
width: 100%; | ||
text-decoration: none; | ||
line-height: 1.4; | ||
padding: 1rem 1.3rem; | ||
border-radius: 0.35rem; | ||
color: #111; | ||
background-color: white; | ||
opacity: 0.8; | ||
} | ||
h2 { | ||
margin: 0; | ||
font-size: 1.25rem; | ||
transition: color 0.6s cubic-bezier(0.22, 1, 0.36, 1); | ||
} | ||
p { | ||
margin-top: 0.5rem; | ||
margin-bottom: 0; | ||
color: #444; | ||
} | ||
.link-card:is(:hover, :focus-within) { | ||
background-position: 0; | ||
} | ||
.link-card:is(:hover, :focus-within) h2 { | ||
color: rgb(var(--accent)); | ||
} | ||
</style> |
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,19 @@ | ||
<script setup lang="ts"> | ||
import { sRGBEncoding } from 'three' | ||
import { OrbitControls, GLTFModel } from '@tresjs/cientos' | ||
</script> | ||
|
||
<template> | ||
<Suspense> | ||
<TresCanvas clear-color="#82DBC5" shadows alpha window-size :output-encoding="sRGBEncoding"> | ||
<OrbitControls /> | ||
<TresPerspectiveCamera :position="[5, 5, 5]" :fov="75" :near="0.1" :far="1000" /> | ||
<TresScene :fog="'#82DBC5'"> | ||
<TresAmbientLight :color="0xffffff" :intensity="0.25" /> | ||
<TresDirectionalLight :position="[0, 8, 4]" :intensity="0.7" cast-shadow /> | ||
<GLTFModel path="https://raw.githubusercontent.com/Tresjs/assets/main/models/gltf/aku-aku/AkuAku.gltf" draco /> | ||
</TresScene> | ||
</TresCanvas> | ||
</Suspense> | ||
</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,115 @@ | ||
<script setup lang="ts"> | ||
import { | ||
sRGBEncoding, | ||
LinearEncoding, | ||
BasicShadowMap, | ||
PCFShadowMap, | ||
PCFSoftShadowMap, | ||
VSMShadowMap, | ||
NoToneMapping, | ||
LinearToneMapping, | ||
ReinhardToneMapping, | ||
CineonToneMapping, | ||
ACESFilmicToneMapping, | ||
CustomToneMapping, | ||
} from 'three' | ||
import { reactive, ref } from 'vue' | ||
import { OrbitControls, useTweakPane, TransformControls } from '@tresjs/cientos' | ||
/* import { OrbitControls, GLTFModel } from '@tresjs/cientos' */ | ||
const state = reactive({ | ||
clearColor: '#82DBC5', | ||
shadows: true, | ||
alpha: false, | ||
physicallyCorrectLights: true, | ||
shadowMapType: BasicShadowMap, | ||
outputEncoding: sRGBEncoding, | ||
toneMapping: NoToneMapping, | ||
}) | ||
const sphereRef = ref() | ||
const { pane } = useTweakPane() | ||
pane.addInput(state, 'clearColor', { | ||
label: 'Background Color', | ||
colorMode: 'hex', | ||
}) | ||
pane.addInput(state, 'shadows', { | ||
label: 'Shadows', | ||
}) | ||
pane.addInput(state, 'physicallyCorrectLights', { | ||
label: 'physicallyCorrectLights', | ||
}) | ||
pane | ||
.addBlade({ | ||
view: 'list', | ||
label: 'outputEncoding', | ||
options: [ | ||
{ text: 'sRGBEncoding', value: sRGBEncoding }, | ||
{ text: 'LinearEncoding', value: LinearEncoding }, | ||
], | ||
value: sRGBEncoding, | ||
}) | ||
.on('change', ev => { | ||
state.outputEncoding = ev.value | ||
}) | ||
pane | ||
.addBlade({ | ||
view: 'list', | ||
label: 'ShadowMap Type', | ||
options: [ | ||
{ text: 'BasicShadowMap', value: BasicShadowMap }, | ||
{ text: 'PCFShadowMap', value: PCFShadowMap }, | ||
{ text: 'PCFSoftShadowMap', value: PCFSoftShadowMap }, | ||
{ text: 'VSMShadowMap', value: VSMShadowMap }, | ||
], | ||
value: BasicShadowMap, | ||
}) | ||
.on('change', ev => { | ||
state.shadowMapType = ev.value | ||
}) | ||
pane | ||
.addBlade({ | ||
view: 'list', | ||
label: 'toneMapping', | ||
options: [ | ||
{ text: 'NoToneMapping', value: NoToneMapping }, | ||
{ text: 'LinearToneMapping', value: LinearToneMapping }, | ||
{ text: 'ReinhardToneMapping', value: ReinhardToneMapping }, | ||
{ text: 'CineonToneMapping', value: CineonToneMapping }, | ||
{ text: 'ACESFilmicToneMapping', value: ACESFilmicToneMapping }, | ||
{ text: 'CustomToneMapping', value: CustomToneMapping }, | ||
], | ||
value: NoToneMapping, | ||
}) | ||
.on('change', ev => { | ||
console.log(ev.value) | ||
state.toneMapping = ev.value | ||
}) | ||
</script> | ||
<template> | ||
<TresCanvas v-bind="state"> | ||
<TresPerspectiveCamera :position="[5, 5, 5]" :fov="45" :near="0.1" :far="1000" :look-at="[-8, 3, -3]" /> | ||
<OrbitControls make-default /> | ||
<TresScene> | ||
<TresAmbientLight :intensity="0.5" /> | ||
|
||
<TransformControls mode="scale" :object="sphereRef" /> | ||
|
||
<TresMesh ref="sphereRef" :position="[0, 4, 0]" cast-shadow> | ||
<TresSphereGeometry /> | ||
<TresMeshToonMaterial color="#FBB03B" /> | ||
</TresMesh> | ||
<TresDirectionalLight :position="[0, 8, 4]" :intensity="0.7" cast-shadow /> | ||
<TresMesh :rotation="[-Math.PI / 2, 0, 0]" receive-shadow> | ||
<TresPlaneGeometry :args="[10, 10, 10, 10]" /> | ||
<TresMeshToonMaterial /> | ||
</TresMesh> | ||
<TresDirectionalLight :position="[0, 2, 4]" :intensity="1" cast-shadow /> | ||
</TresScene> | ||
</TresCanvas> | ||
</template> |
Oops, something went wrong.