Fill Geometry with points

Hi guys,
I am very new to three.js and also to Javascript.

What I am trying to do?
I am actually loading a 3d text with TextBufferGeometry and it works fine. But, I want to fill that geometry with points, probably using points material. I think the points material only gets applied to vertices. So, when I create a mesh using TextBufferGeometry and Points Material, I only see points on vertices. But I want to fill the whole geometry with points.

I came across some jsfiddles where somebody was using GeometryUtils.randomPointsInGeometry(). I am unable to use that function, probably it is not being bundled or something. As I said I am very new to this.

If somebody could please tell me how to import or use that function, that would be really appreciated. If what I am trying to achieve is not possible in this way, please point me in the right direction. Let me know if you need more clarification.

GeometryUtils is not in the core. You can find this function here:

You need to include this file seperately. Assuming two things:

  1. You are using BufferGeometry
  2. You are using the module version of the core from build/three.module.js

If you are using the older non-modular build/three.js then the function is here.

@Mugen87 I expected to find this function in BufferGeometryUtils rather than GeometryUtils. Do you know why it’s not in that file?

Thanks for your reply.
I am not using module version. I am doing "import * as THREE from “three” " in my project. I am still not sure how can I import and use this function.

This means that you are using the module version. import/export are the JavaScript modules keywords.

Here’s how to import GeometryUtils:

import { GeometryUtils } from 'three.js/examples/jsm/utils/GeometryUtils.js'

Appreciate that. It worked. I was trying to import it from three/examples/js and not from three/examples/jsm.

1 Like

@kashish-jain Just in case, if you need more ideas: How fill a loaded STL mesh ( NOT SIMPLE SHAPES LIKE CUBE ETC) with random particles and animate with this geometry bound in three.js

2 Likes