forked from Tresjs/lab
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update demos to v4 (Tresjs#166)
* chore: update deps * feat(array-cameras): update to v4 * chore: clean up brickelangelo * fix: cult-of-the-lamb * feat: updated dancing-blob * chore: remove tweakpane from portal * chore: remove unused tag * feat: fixed broken experiments * feat: fixed issue with parallax on scrollscontrols demo
- Loading branch information
1 parent
377a3f2
commit ea12f07
Showing
46 changed files
with
4,109 additions
and
4,125 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 |
---|---|---|
@@ -1,7 +1,5 @@ | ||
<template> | ||
<div class=""> | ||
<NuxtLayout> | ||
<NuxtPage /> | ||
</NuxtLayout> | ||
</div> | ||
<NuxtLayout> | ||
<NuxtPage /> | ||
</NuxtLayout> | ||
</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
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 |
---|---|---|
@@ -1,21 +1,23 @@ | ||
<script setup lang="ts"> | ||
import { LoopOnce } from 'three' | ||
const { nodes, animations } = await useGLTF('/models/cult-of-the-lamb/Lamb.glb', { draco: true }) | ||
console.log(animations) | ||
const { scene, nodes, animations } = await useGLTF('/models/cult-of-the-lamb/lamb-v2.glb', { draco: true }) | ||
const lamb = nodes['rig'] | ||
const { actions, mixer } = useAnimations(animations, lamb) | ||
const { actions } = useAnimations(animations, lamb) | ||
const currentAction = ref(actions['rigAction']) | ||
const currentAction = ref(actions['elevate']) | ||
currentAction.value.clampWhenFinished = true | ||
currentAction.value.loop = LoopOnce | ||
currentAction.value.play() | ||
</script> | ||
|
||
<template> | ||
<Levioso> | ||
<primitive :object="lamb" /> | ||
</Levioso> | ||
<TresGroup> | ||
<Levioso> | ||
<primitive :object="scene" /> | ||
</Levioso> | ||
</TresGroup> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<!-- Github Luckystriike: https://github.com/luckystriike22/TresJsPlayground/ --> | ||
<script lang="ts" setup> | ||
import vertexShader from './shaders/vertex.glsl' | ||
import fragmentShader from './shaders/fragment.glsl' | ||
|
||
import { Vector2 } from 'three' | ||
|
||
const props = defineProps<{ | ||
analyser: any | ||
dataArray: any | ||
}>() | ||
|
||
// composables | ||
const { onBeforeRender } = useLoop() | ||
|
||
// refs | ||
const blobRef = shallowRef<any>(null) | ||
|
||
|
||
onBeforeRender(({ elapsed }) => { | ||
if (blobRef.value && props.analyser && props.dataArray) { | ||
props.analyser?.getByteFrequencyData(props.dataArray); | ||
|
||
// calc average frequency | ||
let sum = 0; | ||
for (let i = 0; i < props.dataArray?.length; i++) { | ||
sum += props.dataArray[i]; | ||
} | ||
|
||
uniforms.value.u_frequency.value = sum > 0 ? sum / props.dataArray?.length : 0; | ||
uniforms.value.u_time.value = elapsed | ||
blobRef.value.rotation.x += 0.01 | ||
} | ||
}) | ||
|
||
|
||
// shader | ||
// set props to pass into the shader | ||
const uniforms = ref({ | ||
u_resolution: { type: 'V2', value: new Vector2(window.innerWidth, window.innerHeight) }, | ||
u_time: { type: 'f', value: 0.0 }, | ||
u_frequency: { type: 'f', value: 0.0 }, | ||
u_amplitude: { type: 'f', value: 1.5 } | ||
}); | ||
|
||
|
||
</script> | ||
|
||
<template> | ||
<TresPerspectiveCamera :position="[13, 0, 0]" /> | ||
<OrbitControls /> | ||
<TresMesh ref="blobRef"> | ||
<TresIcosahedronGeometry :args="[4, 80]"></TresIcosahedronGeometry> | ||
<TresShaderMaterial wireframe :uniforms="uniforms" :fragment-shader="fragmentShader" | ||
:vertex-shader="vertexShader" /> | ||
</TresMesh> | ||
<TresDirectionalLight :position="[1, 1, 1]" /> | ||
<TresAmbientLight :intensity="1" /> | ||
</template> | ||
|
||
<style scoped> | ||
.gitBtn { | ||
margin-bottom: 10px; | ||
margin-right: 10px; | ||
z-index: 10; | ||
color: white; | ||
} | ||
|
||
.blobPermissionDialog { | ||
height: 100vh; | ||
justify-content: center; | ||
display: flex; | ||
background-color: #0c1a30; | ||
width: 100vw; | ||
color: white; | ||
font-size: x-large; | ||
} | ||
|
||
.blobPermissionDialog p { | ||
width: 700px; | ||
} | ||
</style> |
Oops, something went wrong.