Add point-cloud support to 3D scene
@@ -198,6 +198,12 @@ export default {
light.target.position.set(1, 0, 0);
mesh.add(light);
mesh.add(light.target);
+ } else if (type == "point_cloud") {
+ const geometry = new THREE.BufferGeometry();
+ geometry.setAttribute("position", new THREE.Float32BufferAttribute(args[0].flat(), 3));
+ geometry.setAttribute("color", new THREE.Float32BufferAttribute(args[1].flat(), 3));
+ const material = new THREE.PointsMaterial({ size: args[2], vertexColors: true });
+ mesh = new THREE.Points(geometry, material);
} else {
let geometry;
const wireframe = args.pop();
@@ -44,6 +44,7 @@ class Scene(Element):
from .scene_objects import Extrusion as extrusion
from .scene_objects import Group as group
from .scene_objects import Line as line
+ from .scene_objects import PointCloud as point_cloud
from .scene_objects import QuadraticBezierTube as quadratic_bezier_tube
from .scene_objects import Ring as ring
from .scene_objects import Sphere as sphere
@@ -169,3 +169,13 @@ class SpotLight(Object3D):
decay: float = 1.0,
) -> None:
super().__init__('spot_light', color, intensity, distance, angle, penumbra, decay)
+
+class PointCloud(Object3D):
+ def __init__(self,
+ points: List[List[float]],
+ colors: List[List[float]],
+ point_size: float = 1.0,
+ ) -> None:
+ super().__init__('point_cloud', points, colors, point_size)