If I want to create the following curve, how to do in three.s to create multiple same objects in one call, in order to be less expensive? And how to animate them all together? Should I just use Three.group? Thanks.
const curve = new THREE.CatmullRomCurve3([
new THREE.Vector3( -5, 0, 5 ),
new THREE.Vector3( -5, 15, 5 ),
new THREE.Vector3( 5, -15, 5 ),
new THREE.Vector3( 5, 0, 5 )]
)
let count = 100;
const geometry = new THREE.BufferGeometry()
const points = new THREE.Points(geometry, material)
const positions = new Float32Array(count * 3)
geometry.setAttribute(‘position’, new THREE.BufferAttribute(positions, 3))
scene.add(points)
Can I ask you one further question ? How about use MeshSurfaceSampler to get Vertex and Normal from any 3D object like a ball and then add other 3D object onto it?
What’s the difference between using this way and your self-made examples?
From the examples given, MeshSurfaceSampler seems to be able to do the same in the https://codepen.io/prisoner849/pen/LYXGzRb. That’s why I’m curious about the difference they make to implement the similar effect.
MeshSurfaceSampler cant, Such implementations are only really possible in some simple geometries like Sphere, Cube (With cube you will need to calculate like Pavel Boytchev did), Plane. Just some simple geometry.
==> As for complex geometries. You must have another method ( SDF/Volume/DepthTexture ) to get the best surface information. Because your case is moving lines, and lines created from points, so you need accurate information of the model surface, so that the line can move like a worm…