-
-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: localstate for objects with events and manual register/unregiste…
…r from nodeOps using ctx (#767) * fix: localstate for objects with events and manual register/unregister from nodeOps using ctx * chore: remove unused imports * feat: use shallowRef for objects with events * chore: remove unused import
- Loading branch information
1 parent
f637bf3
commit 9a53e60
Showing
9 changed files
with
1,743 additions
and
2,005 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
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,61 @@ | ||
<script setup lang="ts"> | ||
import { reactive } from 'vue' | ||
import { TresCanvas } from '@tresjs/core' | ||
import { Box, OrbitControls, Sphere, StatsGl } from '@tresjs/cientos' | ||
const hotspots = reactive([ | ||
{ | ||
position: [-2, 0, -2], | ||
}, | ||
{ | ||
position: [0, 0, -2], | ||
}, | ||
{ | ||
position: [2, 0, -2], | ||
}, | ||
]) | ||
const addHotspot = () => { | ||
const newHotspot = reactive({ | ||
position: [-2, 0, 0], | ||
}) | ||
hotspots.push(newHotspot) | ||
} | ||
const removeHotspot = () => { | ||
hotspots.pop() | ||
} | ||
const grow = (event) => { | ||
event.object.scale.set(1.5, 1.5, 1.5) | ||
} | ||
const shrink = (event) => { | ||
event.object.scale.set(1, 1, 1) | ||
} | ||
</script> | ||
|
||
<template> | ||
<TresCanvas> | ||
<Suspense> | ||
<StatsGl /> | ||
</Suspense> | ||
<OrbitControls /> | ||
<TresPerspectiveCamera /> | ||
<TresAmbientLight :args="['white', 0.5]" /> | ||
<Box :position="[0, 0, 0]" :scale="[1, 1, 1]" @click="addHotspot" @context-menu="removeHotspot"> | ||
<TresMeshNormalMaterial /> | ||
</Box> | ||
<Sphere | ||
v-for="(hotspot, index) in hotspots" | ||
:key="index" | ||
:args="[0.5, 16, 16]" | ||
:position="hotspot.position" | ||
@click="console.log('click', index)" | ||
@pointer-enter="grow" | ||
@pointer-leave="shrink" | ||
> | ||
<TresMeshNormalMaterial /> | ||
</Sphere> | ||
</TresCanvas> | ||
</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
Oops, something went wrong.