Rich-Harris/svelte-cubed

How to interact with objects in the scene?

joram56 opened this issue · 1 comments

I would like to run some functions or display some toasts when users click on various objects in the scene, is that possible at the moment? Or is this a feature request?

Something like

<script>
	import * as THREE from 'three';
	import * as SC from 'svelte-cubed';
</script>

<SC.Canvas>
	<SC.Mesh
	   on:click={()=>{console.log("running my function")}    <<--------- THIS
	   geometry={new THREE.BoxGeometry()} />
	<SC.PerspectiveCamera position={[1, 1, 3]} />
</SC.Canvas>

This is the best solution I have found.
https://codesandbox.io/s/basic-threejs-example-with-re-use-dsrvn

Would be nice if these things can happen behind the scenes and you can just do a simple on:click(), not sure how possible that is.