Skip to content

Commit 7a9d78f

Browse files
authored
improve MeshSurfaceSampler example (#26031)
1 parent 44ab823 commit 7a9d78f

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

docs/examples/en/math/MeshSurfaceSampler.html

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,23 @@ <h2>Code Example</h2>
3232
.setWeightAttribute( 'color' )
3333
.build();
3434

35-
const sampleMesh = new THREE.InstancedMesh( sampleGeometry, sampleMaterial, 100 );
35+
const mesh = new THREE.InstancedMesh( sampleGeometry, sampleMaterial, 100 );
3636

37-
const _position = new THREE.Vector3();
38-
const _matrix = new THREE.Matrix4();
37+
const position = new THREE.Vector3();
38+
const matrix = new THREE.Matrix4();
3939

4040
// Sample randomly from the surface, creating an instance of the sample
4141
// geometry at each sample point.
4242
for ( let i = 0; i < 100; i ++ ) {
4343

44-
sampler.sample( _position );
44+
sampler.sample( position );
4545

46-
_matrix.makeTranslation( _position.x, _position.y, _position.z );
46+
matrix.makeTranslation( position.x, position.y, position.z );
4747

48-
mesh.setMatrixAt( i, _matrix );
48+
mesh.setMatrixAt( i, matrix );
4949

5050
}
5151

52-
mesh.instanceMatrix.needsUpdate = true;
53-
5452
scene.add( mesh );
5553
</code>
5654

0 commit comments

Comments
 (0)