Skip to content

Commit 3496702

Browse files
authored
PLYExporter Example: Add vertex colors for testing (#23375)
* Add vertex colors to ply exporter example * update screenshot
1 parent 67ff114 commit 3496702

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

examples/misc_exporter_ply.html

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,17 @@
7777
// export mesh
7878

7979
const geometry = new THREE.BoxGeometry( 50, 50, 50 );
80-
const material = new THREE.MeshPhongMaterial( { color: 0x00ff00 } );
80+
const material = new THREE.MeshPhongMaterial( { vertexColors: true } );
81+
82+
// color vertices based on vertex positions
83+
const colors = geometry.getAttribute( 'position' ).array.slice();
84+
for ( let i = 0, l = colors.length; i < l; i ++ ) {
85+
86+
if ( colors[ i ] > 0 ) colors[ i ] = 0.5;
87+
else colors[ i ] = 0;
88+
89+
}
90+
geometry.setAttribute( 'color', new THREE.BufferAttribute( colors, 3, false ) );
8191

8292
mesh = new THREE.Mesh( geometry, material );
8393
mesh.castShadow = true;
@@ -87,6 +97,7 @@
8797
//
8898

8999
renderer = new THREE.WebGLRenderer( { antialias: true } );
100+
renderer.outputEncoding = THREE.sRGBEncoding;
90101
renderer.setPixelRatio( window.devicePixelRatio );
91102
renderer.setSize( window.innerWidth, window.innerHeight );
92103
renderer.shadowMap.enabled = true;
534 Bytes
Loading

0 commit comments

Comments
 (0)