Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 23 html component #184

Merged
merged 39 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
8f1922e
feat: render html from tres back to vue app
alvarosabu Jul 13, 2023
38388c6
feat: correct objectScale and calculatePosition
alvarosabu Jul 13, 2023
2f79b5c
feat: transform html
alvarosabu Jul 14, 2023
34783b2
feat: add px to style transforms
alvarosabu Jul 14, 2023
72e2ef9
feat: first attempt of occlussion
alvarosabu Jul 14, 2023
7e480f1
feat: fixed occlussion
alvarosabu Jul 24, 2023
b509723
Merge branch 'main' into feature/23-html-component
alvarosabu Aug 25, 2023
e893dcc
feat: update html to new `useContextProvider`
alvarosabu Aug 26, 2023
4b5f9ac
Merge branch 'main' into feature/23-html-component
alvarosabu Sep 13, 2023
7d79f6d
feat: occlude works 🥳🎉
alvarosabu Sep 14, 2023
256b698
docs: html page
alvarosabu Sep 14, 2023
f332b79
Merge branch 'main' into feature/23-html-component
alvarosabu Sep 14, 2023
2aeadcb
docs: html examples
alvarosabu Sep 15, 2023
5c29810
Merge branch 'main' into feature/23-html-component
alvarosabu Sep 15, 2023
8166b6a
chore: update lock
alvarosabu Sep 15, 2023
b5c37a5
chore: updated lock with docs
alvarosabu Sep 15, 2023
533175c
fix: build issue Stats
alvarosabu Sep 15, 2023
4cb1c16
fix: add will change trasnform to force GPU
alvarosabu Sep 15, 2023
8b6033b
chore: lock update
alvarosabu Sep 15, 2023
2817f64
docs: scroll control demo remove console
alvarosabu Sep 15, 2023
9f091d2
docs: temp
alvarosabu Sep 15, 2023
ec95263
docs: why is broken idg
alvarosabu Sep 15, 2023
d08b89c
chore: remove console logs
alvarosabu Sep 15, 2023
5b9a530
docs: add client only again
alvarosabu Sep 15, 2023
7452c64
docs: props table
alvarosabu Sep 16, 2023
a22ee55
Merge branch 'main' into feature/23-html-component
alvarosabu Sep 19, 2023
137b889
chore: updated lint
alvarosabu Sep 19, 2023
07b845e
chore: added rule override and fix Sky
alvarosabu Sep 19, 2023
47f822c
chore: move html transform utils to its own file
alvarosabu Sep 19, 2023
39ac919
chore: fixed lint issue on utils
alvarosabu Sep 19, 2023
a0c2134
chore: html shaders to glsl files
alvarosabu Sep 19, 2023
5120b86
chore: disposal of shaderMaterial
alvarosabu Sep 20, 2023
b729b85
chore: added vite-plugin-glsl for build
alvarosabu Sep 21, 2023
558aaf4
Merge branch 'main' into feature/23-html-component
alvarosabu Sep 21, 2023
e967e68
chore: install correct deps
alvarosabu Sep 21, 2023
829b445
chore: fix lint misc routes
alvarosabu Sep 21, 2023
e749ccb
docs: added geometry and material props to html
alvarosabu Sep 27, 2023
1744f92
Merge branch 'main' into feature/23-html-component
alvarosabu Sep 27, 2023
b8b1b68
chore: components playground dts
alvarosabu Sep 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "@tresjs/eslint-config-vue",
"rules": {
"@typescript-eslint/no-use-before-define": "off"
"@typescript-eslint/no-use-before-define": "off",
"vue/attribute-hyphenation": "off"
}
}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ dist-ssr
*.sln
*.sw?
docs/.vitepress/dist
docs/.vitepress/cache/deps/*.*
docs/.vitepress/cache/deps/*.*
docs/.vitepress/.temp
15 changes: 12 additions & 3 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { defineConfig } from 'vitepress'
import Unocss from 'unocss/vite'
import svgLoader from 'vite-svg-loader'
import { resolve } from 'pathe'
import { templateCompilerOptions } from '@tresjs/core'

const whitelist = [
'TresCanvas',
'TresLeches',
'TresScene',
]

// https://vitepress.dev/reference/site-config
export default defineConfig({
title: 'Cientos',
Expand Down Expand Up @@ -104,6 +108,7 @@ export default defineConfig({
items: [
{ text: 'useTweakpane', link: '/guide/misc/use-tweakpane' },
{ text: 'Stats', link: '/guide/misc/stats' },
{ text: 'Html', link: '/guide/misc/html-component' },
{ text: 'StatsGl', link: '/guide/misc/stats-gl' },
],
},
Expand Down Expand Up @@ -142,6 +147,10 @@ export default defineConfig({
},
},
vue: {
...templateCompilerOptions,
template: {
compilerOptions: {
isCustomElement: (tag: string) => tag.startsWith('Tres') && !whitelist.includes(tag) || tag === 'primitive',
JaimeTorrealba marked this conversation as resolved.
Show resolved Hide resolved
},
},
},
})
4 changes: 2 additions & 2 deletions docs/.vitepress/theme/TresLayout.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script setup>
import DefaultTheme from 'vitepress/theme'
import Theme from 'vitepress/theme'
import LoveVueThreeJS from './components/LoveVueThreeJS.vue'

const { Layout } = DefaultTheme
const { Layout } = Theme
</script>

<template>
Expand Down
6 changes: 3 additions & 3 deletions docs/.vitepress/theme/components/DocsDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<template>
<ClientOnly>
<div
class="relative"
style="aspect-ratio: 16/9; height: auto; margin: 2rem 0; border-radius: 8px; overflow:hidden;"
class="relative aspect-video"
style=" height: auto; margin: 2rem 0; border-radius: 8px; overflow:hidden;"
>
<Suspense>
<slot />
</Suspense>
</div>
</div>
</ClientOnly>
</template>
40 changes: 40 additions & 0 deletions docs/.vitepress/theme/components/HtmlDemo.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<script setup lang="ts">
import { TresCanvas } from '@tresjs/core'
import { BasicShadowMap, SRGBColorSpace, NoToneMapping } from 'three'

import { OrbitControls, Html } from '@tresjs/cientos'
import { reactive } from 'vue'

const gl = {
clearColor: '#82DBC5',
shadows: true,
alpha: false,
shadowMapType: BasicShadowMap,
outputColorSpace: SRGBColorSpace,
toneMapping: NoToneMapping,
}
</script>

<template>
<TresCanvas v-bind="gl">
<TresPerspectiveCamera :position="[3, 3, 8]" />
<OrbitControls />
<TresMesh :position="[1, 1, 1]">
<TresBoxGeometry />
<TresMeshNormalMaterial />
<Html
center
transform
:distance-factor="4"
:position="[0, 0, 0.65]"
:scale="[0.75, 0.75, 0.75]"
>
<h1 class="bg-white dark:bg-dark text-xs p-1 rounded">
I'm a Box 📦
</h1>
</Html>
</TresMesh>
<TresGridHelper />
<TresAmbientLight :intensity="1" />
</TresCanvas>
</template>
61 changes: 61 additions & 0 deletions docs/.vitepress/theme/components/HtmlLaptopDemo.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<script setup lang="ts">
import { TresCanvas } from '@tresjs/core'
import { BasicShadowMap, SRGBColorSpace, NoToneMapping } from 'three'

import { OrbitControls, Html, useGLTF, Levioso, ContactShadows } from '@tresjs/cientos'

const gl = {
clearColor: '#241a1a',
shadows: true,
alpha: false,
shadowMapType: BasicShadowMap,
outputColorSpace: SRGBColorSpace,
toneMapping: NoToneMapping,
}

const { nodes }
= await useGLTF('https://vazxmixjsiawhamofees.supabase.co/storage/v1/object/public/models/macbook/model.gltf',
{ draco: true },
)
</script>

<template>
<TresCanvas v-bind="gl">
<TresPerspectiveCamera :position="[-5, 4, 3]" />
<OrbitControls />

<primitive :object="nodes.Macbook">
<Html
transform
wrapper-class="webpage"
:distance-factor="11"
:position="[0, 10.5, -13.6]"
occlude
:rotation-x="-0.256"
>
<iframe
class="rounded-lg w-[1024px] h-[670px]"
src="https://tresjs.org"
frameborder="0"
/>
</Html>
</primitive>

<ContactShadows
:blur="3.5"
:resolution="512"
:opacity="1"
/>
<TresAmbientLight :intensity="1" />
<TresDirectionalLight
:intensity="2"
:position="[2, 3, 0]"
:cast-shadow="true"
:shadow-camera-far="50"
:shadow-camera-left="-10"
:shadow-camera-right="10"
:shadow-camera-top="10"
:shadow-camera-bottom="-10"
/>
</TresCanvas>
</template>
57 changes: 57 additions & 0 deletions docs/.vitepress/theme/components/HtmlOccludeDemo.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<script setup lang="ts">
import { TresCanvas } from '@tresjs/core'
import { BasicShadowMap, SRGBColorSpace, NoToneMapping } from 'three'

import { OrbitControls, Html } from '@tresjs/cientos'
import { reactive, ref } from 'vue'

const gl = {
clearColor: '#82DBC5',
shadows: true,
alpha: false,
shadowMapType: BasicShadowMap,
outputColorSpace: SRGBColorSpace,
toneMapping: NoToneMapping,
}

const sphereRef = ref(null)
</script>

<template>
<TresCanvas v-bind="gl">
<TresPerspectiveCamera :position="[3, 3, 8]" />
<OrbitControls />
<TresMesh :position="[1, 1, 1]">
<TresBoxGeometry />
<TresMeshNormalMaterial />
<Html
center
transform
:occlude="[sphereRef]"
:distance-factor="4"
>
<h1 class="bg-white dark:bg-dark text-xs p-1 rounded">
Move camera
</h1>
</Html>
</TresMesh>
<TresMesh
ref="sphereRef"
:position="[3, 1, 1]"
>
<TresSphereGeometry />
<TresMeshNormalMaterial />
<Html
center
transform
:distance-factor="4"
>
<h1 class="bg-white dark:bg-dark text-xs p-1 rounded">
Sphere
</h1>
</Html>
</TresMesh>
<TresGridHelper />
<TresAmbientLight :intensity="1" />
</TresCanvas>
</template>
5 changes: 0 additions & 5 deletions docs/.vitepress/theme/components/ScrollControlsDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ const sphereRef = ref()
const boxRef = ref()
const progress = ref(0)

watchEffect(() => {
// eslint-disable-next-line no-console
console.log('jaime ~ progress:', progress.value)
})

const gl = {
clearColor: '#333',
alpha: true,
Expand Down
9 changes: 3 additions & 6 deletions docs/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ declare module 'vue' {
BackdropDemo: typeof import('./.vitepress/theme/components/BackdropDemo.vue')['default']
CameraControlsDemo: typeof import('./.vitepress/theme/components/CameraControlsDemo.vue')['default']
ContactShadowDemo: typeof import('./.vitepress/theme/components/ContactShadowDemo.vue')['default']
copy: typeof import('./.vitepress/theme/components/GLTFModelDemo copy.vue')['default']
DocDemo: typeof import('./.vitepress/theme/components/DocDemo.vue')['default']
DocsDemo: typeof import('./.vitepress/theme/components/DocsDemo.vue')['default']
FBXModelDemo: typeof import('./.vitepress/theme/components/FBXModelDemo.vue')['default']
Feather: typeof import('./.vitepress/theme/components/Feather.vue')['default']
GlassMaterialDemo: typeof import('./.vitepress/theme/components/GlassMaterialDemo.vue')['default']
GltfDemo: typeof import('./.vitepress/theme/components/GltfDemo.vue')['default']
GltfModelDemo: typeof import('./.vitepress/theme/components/GltfModelDemo.vue')['default']
GLTFModelDemo: typeof import('./.vitepress/theme/components/GLTFModelDemo.vue')['default']
HtmlDemo: typeof import('./.vitepress/theme/components/HtmlDemo.vue')['default']
HtmlLaptopDemo: typeof import('./.vitepress/theme/components/HtmlLaptopDemo.vue')['default']
HtmlOccludeDemo: typeof import('./.vitepress/theme/components/HtmlOccludeDemo.vue')['default']
LeviosoDemo: typeof import('./.vitepress/theme/components/LeviosoDemo.vue')['default']
LoveVueThreeJS: typeof import('./.vitepress/theme/components/LoveVueThreeJS.vue')['default']
MapControlsDemo: typeof import('./.vitepress/theme/components/MapControlsDemo.vue')['default']
Expand All @@ -30,10 +29,8 @@ declare module 'vue' {
ScrollControlsDemo: typeof import('./.vitepress/theme/components/ScrollControlsDemo.vue')['default']
SmokeDemo: typeof import('./.vitepress/theme/components/SmokeDemo.vue')['default']
StarsDemo: typeof import('./.vitepress/theme/components/StarsDemo.vue')['default']
StatsGlDemo: typeof import('./.vitepress/theme/components/StatsGlDemo.vue')['default']
Text3Demo: typeof import('./.vitepress/theme/components/Text3Demo.vue')['default']
TransformControlsDemo: typeof import('./.vitepress/theme/components/TransformControlsDemo.vue')['default']
VideoTexture: typeof import('./.vitepress/theme/components/VideoTexture.vue')['default']
VideoTextureDemo: typeof import('./.vitepress/theme/components/VideoTextureDemo.vue')['default']
WobbleMaterialDemo: typeof import('./.vitepress/theme/components/WobbleMaterialDemo.vue')['default']
}
Expand Down
Loading