pos audio
This commit is contained in:
parent
a07be2f270
commit
a76d6b700f
|
@ -57,7 +57,6 @@ onLoop(() => {
|
||||||
<div :class="[{ 'invisible': !hasFinishLoading }]">
|
<div :class="[{ 'invisible': !hasFinishLoading }]">
|
||||||
<TresCanvas window-size alpha shadows clear-color="#87ceeb">
|
<TresCanvas window-size alpha shadows clear-color="#87ceeb">
|
||||||
<TresPerspectiveCamera :position="cameraPosition" />
|
<TresPerspectiveCamera :position="cameraPosition" />
|
||||||
<GlobalAudio src="/sea.ogg" :playTrigger="undefined" />
|
|
||||||
<CameraControls v-bind="controlsState" @change="onChange" make-default />
|
<CameraControls v-bind="controlsState" @change="onChange" make-default />
|
||||||
|
|
||||||
<!-- <TresGridHelper :args="[50, 50]" /> -->
|
<!-- <TresGridHelper :args="[50, 50]" /> -->
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Box3, Vector3 } from 'three';
|
import { Box3, Vector3 } from 'three';
|
||||||
import { useGLTF, } from '@tresjs/cientos'
|
import { PositionalAudio, useGLTF, } from '@tresjs/cientos'
|
||||||
|
import { onMounted, onUnmounted, shallowRef } from 'vue';
|
||||||
|
|
||||||
const props = defineProps(['modelUrl', 'onClick'])
|
const props = defineProps(['modelUrl', 'onClick'])
|
||||||
|
|
||||||
|
@ -19,13 +20,21 @@ const show_alert = () => {
|
||||||
}
|
}
|
||||||
scene.receiveShadow = true
|
scene.receiveShadow = true
|
||||||
scene.castShadow = true
|
scene.castShadow = true
|
||||||
console.log(scene, props.modelUrl)
|
|
||||||
|
const positionalAudioRef = shallowRef(null)
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
positionalAudioRef?.value?.dispose()
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<TresGroup :posiion="[0, 0, 0]">
|
<TresGroup :posiion="[0, 0, 0]">
|
||||||
<TresMesh :position="center" @click="show_alert" cast-shadow receive-shadow>
|
<TresMesh :position="center" @click="show_alert" cast-shadow receive-shadow>
|
||||||
<TresBoxGeometry :args="box_size" />
|
<TresBoxGeometry :args="box_size" />
|
||||||
<TresMeshPhysicalMaterial :opacity="0" color="pink" :transparent="true" />
|
<TresMeshPhysicalMaterial :opacity="0" color="pink" :transparent="true" />
|
||||||
|
<Suspense>
|
||||||
|
<PositionalAudio ref="positionalAudioRef" url="/sea.ogg" helper />
|
||||||
|
</Suspense>
|
||||||
</TresMesh>
|
</TresMesh>
|
||||||
<TresMesh cast-shadow receive-shadow>
|
<TresMesh cast-shadow receive-shadow>
|
||||||
<primitive :object="scene" />
|
<primitive :object="scene" />
|
||||||
|
|
Loading…
Reference in New Issue