فهرست منبع

Merge pull request #545 from kielnino/point-cloud-support

Add point-cloud support to 3D scene
Falko Schindler 2 سال پیش
والد
کامیت
5ca1aece93
3فایلهای تغییر یافته به همراه17 افزوده شده و 0 حذف شده
  1. 6 0
      nicegui/elements/scene.js
  2. 1 0
      nicegui/elements/scene.py
  3. 10 0
      nicegui/elements/scene_objects.py

+ 6 - 0
nicegui/elements/scene.js

@@ -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();

+ 1 - 0
nicegui/elements/scene.py

@@ -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

+ 10 - 0
nicegui/elements/scene_objects.py

@@ -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)