Flows Glb File in Curve Modifier

Hello folks. i did something but i am in trouble now. Can someone help me?

In this code, i success to add flow to curve. But as you see, geometry is a BoxGeometry.

My purpose is changes Box Geometry with any .glb file. I know i need to use Loader and clone instanced meshes for 4000 glb files.

I tried with ChatGpt, it is not enough for this or i cant manage.

Can someone show the right way?

const curve = new THREE.CatmullRomCurve3( curveVertices );
					curve.curveType = 'chordal';
					curve.closed = false;

const geometry = new BoxGeometry(0.06,0.06,0.06);

const material1 = new THREE.MeshPhongMaterial(  {    
						color: 0xff0000,
						stencilWrite: true,
						stencilRef: 1,
						stencilFunc:  THREE.EqualStencilFunc,
						stencilFail: THREE.KeepStencilOp,
						stencilZFail: THREE.KeepStencilOp,
						stencilZPass: THREE.KeepStencilOp, } );

const numberOfInstances1 = 4000;

let flow1 = new InstancedFlow( numberOfInstances1, curves.length, geometry, material1 );


curves.forEach( function ( { curve }, i ) {

			flow1.updateCurve( i, curve );
														
			scene.add( flow1.object3D );
						

} );
1 Like
	                        const geometry1=[]
				loader.load('textures/araba.glb', function ( gltf ) {
					const geometry = gltf.scene.children[0].geometry.clone();
					geometry1.push(geometry) // Clone the geometry of the first child mesh
					console.log(geometry1)
				});
This way works...

This is the best opening line I’ve read so far in this forum!

Have you figured out why cloning resolves your problem?

1 Like

Actually I solved it but I had an incredible fps loss. I dropped from 112 fps to 52 fps. This got me down a lot. My goal was to replace boxGeometry with a low poly car.