mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-11-16 11:07:57 +01:00
67 lines
1.2 KiB
JavaScript
Executable File
67 lines
1.2 KiB
JavaScript
Executable File
/**
|
|
* @author mrdoob / http://mrdoob.com/
|
|
*/
|
|
|
|
Sidebar.Geometry.BufferGeometry = function ( signals ) {
|
|
|
|
var container = new UI.Panel();
|
|
|
|
// vertices
|
|
|
|
var verticesRow = new UI.Panel();
|
|
var vertices = new UI.Text().setFontSize( '12px' );
|
|
|
|
verticesRow.add( new UI.Text( 'Vertices' ).setWidth( '90px' ) );
|
|
verticesRow.add( vertices );
|
|
|
|
container.add( verticesRow );
|
|
|
|
// faces
|
|
|
|
var facesRow = new UI.Panel();
|
|
var faces = new UI.Text().setFontSize( '12px' );
|
|
|
|
facesRow.add( new UI.Text( 'Faces' ).setWidth( '90px' ) );
|
|
facesRow.add( faces );
|
|
|
|
container.add( facesRow );
|
|
|
|
//
|
|
|
|
var update = function ( object ) {
|
|
|
|
if ( object === null ) return;
|
|
|
|
var geometry = object.geometry;
|
|
|
|
if ( geometry instanceof THREE.BufferGeometry ) {
|
|
|
|
container.setDisplay( 'block' );
|
|
|
|
vertices.setValue( ( geometry.attributes.position.array.length / 3 ).format() );
|
|
|
|
if ( geometry.attributes.index !== undefined ) {
|
|
|
|
faces.setValue( ( geometry.attributes.index.array.length / 3 ).format() );
|
|
|
|
} else {
|
|
|
|
faces.setValue( ( geometry.attributes.position.array.length / 9 ).format() );
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
container.setDisplay( 'none' );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
signals.objectSelected.add( update );
|
|
signals.geometryChanged.add( update );
|
|
|
|
return container;
|
|
|
|
}
|