Doodle3D-Slicer/three.js-master/editor_slicer/js/Sidebar.Geometry.Modifiers.js
2015-06-13 20:09:44 +02:00

71 lines
1.4 KiB
JavaScript
Executable File

/**
* @author mrdoob / http://mrdoob.com/
*/
Sidebar.Geometry.Modifiers = function ( signals, object ) {
var container = new UI.Panel().setPaddingLeft( '90px' );
var geometry = object.geometry;
// Compute Vertex Normals
var button = new UI.Button( 'Compute Vertex Normals' );
button.onClick( function () {
geometry.computeVertexNormals();
if ( geometry instanceof THREE.BufferGeometry ) {
geometry.attributes.normal.needsUpdate = true;
} else {
geometry.normalsNeedUpdate = true;
}
signals.geometryChanged.dispatch( object );
} );
container.add( button );
// Convert to Geometry/BufferGeometry
var isBufferGeometry = geometry instanceof THREE.BufferGeometry;
if ( geometry instanceof THREE.BufferGeometry ) {
var button = new UI.Button( 'Convert to Geometry' );
button.onClick( function () {
if ( confirm( 'Are you sure?' ) === false ) return;
object.geometry = new THREE.Geometry().fromBufferGeometry( object.geometry );
signals.geometryChanged.dispatch( object );
} );
container.add( button );
} else {
var button = new UI.Button( 'Convert to BufferGeometry' );
button.onClick( function () {
if ( confirm( 'Are you sure?' ) === false ) return;
object.geometry = new THREE.BufferGeometry().fromGeometry( object.geometry );
signals.geometryChanged.dispatch( object );
} );
container.add( button );
}
return container;
}