File tree Expand file tree Collapse file tree 2 files changed +51
-3
lines changed Expand file tree Collapse file tree 2 files changed +51
-3
lines changed Original file line number Diff line number Diff line change @@ -91,3 +91,45 @@ class TetraMesh extends PolyMesh {
91
91
tetrahedronIndices : Uint32Array ;
92
92
93
93
}
94
+
95
+
96
+ /**
97
+ * PointCloud class
98
+ */
99
+ export
100
+ class PointCloud extends Block {
101
+
102
+ constructor ( vertices : Float32Array , data : Data [ ] , options ?: BlockOptions ) {
103
+ super ( vertices , data , options ) ;
104
+
105
+ this . geometry = new THREE . BufferGeometry ( ) ;
106
+
107
+ const vertexBuffer = new THREE . BufferAttribute ( vertices , 3 ) ;
108
+
109
+ this . geometry . setAttribute ( 'position' , vertexBuffer ) ;
110
+
111
+ this . mesh = new NodeMesh ( THREE . Points , this . geometry , this . data ) ;
112
+ this . meshes . push ( this . mesh ) ;
113
+
114
+ this . buildMaterial ( ) ;
115
+ }
116
+
117
+ /**
118
+ * Update vertices buffers
119
+ */
120
+ handleVerticesChange ( ) {
121
+ super . handleVerticesChange ( ) ;
122
+
123
+ this . mesh . vertices = this . vertices ;
124
+ }
125
+
126
+ get boundingSphere ( ) : THREE . Sphere {
127
+ this . geometry . computeBoundingSphere ( ) ;
128
+ return this . geometry . boundingSphere ;
129
+ }
130
+
131
+ geometry : THREE . BufferGeometry ;
132
+
133
+ mesh : NodeMesh ;
134
+
135
+ }
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ enum NodeOperation {
16
16
}
17
17
18
18
export
19
- type MeshConstructor = new ( geometry : THREE . BufferGeometry , material : Nodes . StandardNodeMaterial ) => THREE . Mesh ;
19
+ type MeshConstructor = new ( geometry : THREE . BufferGeometry , material : Nodes . StandardNodeMaterial ) => THREE . Object3D ;
20
20
21
21
export
22
22
type NodeOperationResult < T extends Nodes . Node > = T | Nodes . OperatorNode ;
@@ -145,6 +145,12 @@ class NodeMesh {
145
145
// @ts -ignore
146
146
this . material . color = color ;
147
147
148
+ // Workaround for https://github.com/mrdoob/three.js/issues/18152
149
+ if ( this . mesh . type == 'Points' ) {
150
+ // @ts -ignore
151
+ this . material . normal = new Nodes . Vector3Node ( 1 , 1 , 1 ) ;
152
+ }
153
+
148
154
this . material . alphaTest = 0.1 ;
149
155
150
156
this . material . build ( ) ;
@@ -285,8 +291,8 @@ class NodeMesh {
285
291
}
286
292
287
293
geometry : THREE . BufferGeometry ;
288
- material : Nodes . StandardNodeMaterial ;
289
- mesh : THREE . Mesh ;
294
+ material : Nodes . NodeMaterial ;
295
+ mesh : THREE . Object3D ;
290
296
readonly data : Data [ ] ;
291
297
292
298
private meshCtor : MeshConstructor ;
You can’t perform that action at this time.
0 commit comments