|
@@ -106,7 +106,7 @@
|
|
|
|
|
|
//
|
|
|
|
|
|
- var geom = newGeometry(data);
|
|
|
+ var geom = newGeometry( data );
|
|
|
|
|
|
var mesh = new THREE.Mesh( geom, meshMaterial );
|
|
|
var lineSegments = new THREE.LineSegments( new THREE.WireframeGeometry( geom ), lineMaterial );
|
|
@@ -120,24 +120,26 @@
|
|
|
gui = new GUI();
|
|
|
gui.width = 350;
|
|
|
|
|
|
- function newGeometry(data) {
|
|
|
+ function newGeometry( data ) {
|
|
|
|
|
|
- switch (data.model) {
|
|
|
- case "Icosahedron":
|
|
|
+ switch ( data.model ) {
|
|
|
+
|
|
|
+ case "Icosahedron":
|
|
|
return new THREE.IcosahedronBufferGeometry( radius, data.detail );
|
|
|
- case "Cylinder":
|
|
|
+ case "Cylinder":
|
|
|
return new THREE.CylinderBufferGeometry( radius, radius, radius * 2, data.detail * 6 );
|
|
|
- case "Teapot":
|
|
|
+ case "Teapot":
|
|
|
return new TeapotBufferGeometry( radius, data.detail * 3, true, true, true, true, true );
|
|
|
- case "TorusKnot":
|
|
|
+ case "TorusKnot":
|
|
|
return new THREE.TorusKnotBufferGeometry( radius, 10, data.detail * 20, data.detail * 6, 3, 4 );
|
|
|
- }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
function generateGeometry() {
|
|
|
|
|
|
- geom = newGeometry(data);
|
|
|
+ geom = newGeometry( data );
|
|
|
|
|
|
updateGroupGeometry(
|
|
|
mesh,
|
|
@@ -155,7 +157,7 @@
|
|
|
}
|
|
|
|
|
|
var folder = gui.addFolder( 'Scene' );
|
|
|
- folder.add( data, 'model', ["Icosahedron", "Cylinder", "TorusKnot", "Teapot"] ).onChange( generateGeometry );
|
|
|
+ folder.add( data, 'model', [ "Icosahedron", "Cylinder", "TorusKnot", "Teapot" ] ).onChange( generateGeometry );
|
|
|
folder.add( data, 'wireframe', false ).onChange( updateLineSegments );
|
|
|
folder.add( data, 'texture', false ).onChange( generateGeometry );
|
|
|
folder.add( data, 'detail', 1, 8, 1 ).onChange( generateGeometry );
|
|
@@ -167,7 +169,7 @@
|
|
|
folder.open();
|
|
|
|
|
|
folder = gui.addFolder( 'Normal Compression' );
|
|
|
- folder.add( data, 'NormEncodingMethods', ["None", "DEFAULT", "OCT1Byte", "OCT2Byte", "ANGLES"] ).onChange( generateGeometry );
|
|
|
+ folder.add( data, 'NormEncodingMethods', [ "None", "DEFAULT", "OCT1Byte", "OCT2Byte", "ANGLES" ] ).onChange( generateGeometry );
|
|
|
folder.open();
|
|
|
|
|
|
folder = gui.addFolder( 'UV Compression' );
|
|
@@ -252,19 +254,19 @@
|
|
|
mesh.material = new THREE.MeshPhongMaterial( { color: 0xffffff, emissive: 0x111111 } );
|
|
|
mesh.material.map = data.texture ? texture : null;
|
|
|
|
|
|
- if ( data["QuantizePosEncoding"] ) {
|
|
|
+ if ( data[ "QuantizePosEncoding" ] ) {
|
|
|
|
|
|
GeometryCompressionUtils.compressPositions( mesh );
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( data["NormEncodingMethods"] !== "None" ) {
|
|
|
+ if ( data[ "NormEncodingMethods" ] !== "None" ) {
|
|
|
|
|
|
- GeometryCompressionUtils.compressNormals( mesh, data["NormEncodingMethods"] );
|
|
|
+ GeometryCompressionUtils.compressNormals( mesh, data[ "NormEncodingMethods" ] );
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( data["DefaultUVEncoding"] ) {
|
|
|
+ if ( data[ "DefaultUVEncoding" ] ) {
|
|
|
|
|
|
GeometryCompressionUtils.compressUvs( mesh );
|
|
|
|
|
@@ -278,7 +280,7 @@
|
|
|
function computeGPUMemory( mesh ) {
|
|
|
|
|
|
// Use BufferGeometryUtils to do memory calculation
|
|
|
- memoryDisplay.setValue( BufferGeometryUtils.estimateBytesUsed(mesh.geometry) + " bytes");
|
|
|
+ memoryDisplay.setValue( BufferGeometryUtils.estimateBytesUsed( mesh.geometry ) + " bytes" );
|
|
|
|
|
|
}
|
|
|
|