threlte icon indicating copy to clipboard operation
threlte copied to clipboard

THREE.Points not available

Open FreddieRa opened this issue 3 years ago • 2 comments

While Mesh has been implemented fine, Points has not been put in. It can be bodged in very easily, but duplicating the Mesh.svelte, replacing

setup(new THREE.Mesh(geometry, material));

with

setup(new THREE.Points(geometry, material));

and fiddling around with exports, but there may well be a more efficient way of doing things.

FreddieRa avatar Feb 07 '22 22:02 FreddieRa

Good point! (Ha! I'll see myself out.)

Indeed Mesh and Points share quite a lot. I'm undecided how to deal with that. In the meantime it's rather easy to implement that yourself:

<script>
import { Points } from 'three'
import { Object3DInstance, useFrame } from 'threlte'

const points = new Points(…)
const posX = 0

useFrame(() => {
  posX = Math.sin(Date.now() / 1000)
})
</script>


<Object3DInstance position={{ x: posX }} object={points} />

The threlte component <Mesh> is providing raycasting which you probably don't want on a THREE.Points object anyway?

grischaerbe avatar Feb 07 '22 23:02 grischaerbe

Ahh I see, this is better than my bodged solution, thanks

FreddieRa avatar Feb 08 '22 12:02 FreddieRa

With Threlte 6, the APIs now exactly mirror the ThreeJS API.

ixxie avatar Apr 11 '23 21:04 ixxie