How to create multiple 3D curves in one call to be less expensive

Hi Experts,

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)

Please use instancedmesh, and move each base gl_InstanceID

Thanks for your info. I’m trying it out.

One more question, if I want to make those multiple curves fixed onto one single surface, like plane or ball, how to use Three.js in the regard?

Thanks.

I think depends on how you define the plane/sphere in the coordinate axis. then based on normal and core point to use projection, or projection matrix

Maybe batched mesh

Something spherical, made of instanced curves :thinking:

2 Likes

Thanks for your good examples. You are pro.

Hi Pro,

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?

Thanks.

Explore the source code of this example: three.js examples
All the things you ask about is there

They are totally different things. :thinking:

I’m not a technical guy.

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.

Neither am I :slight_smile:

If you see it this way, don’t hesitate to implement it with MeshSurfaceSampler. Creativity is up to you :handshake:

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…

Thanks for your input. The point you refer to, SDF/Volume/DepthTexture, seems more difficult. I will try to search that.

Thanks.

Hi Pro,

Could you teach me how to create multiple objects of the following object on the same surface? https://codepen.io/prisoner849/full/ZEqGpRR

Thanks.

I found his work, Pavel Boytchev.

But, my question is how to create the same multiple objects in three.js. If you know, please teach me how to. Thanks.

Instancedmesh , u need try use chatgpt , it very good for tutorial

Thanks for reply

I tried using instancedMesh. When the amount is set at 1000, the browser slows down. Maybe my computer needs to be replaced.