diff --git a/examples/js/loaders/OBJLoader.js b/examples/js/loaders/OBJLoader.js index ed83c5a3583fc43b79148aad9c524d3574e5f3e3..f99da8a45ccfe40e86de60f8fc2bedd0eef53762 100644 --- a/examples/js/loaders/OBJLoader.js +++ b/examples/js/loaders/OBJLoader.js @@ -615,7 +615,18 @@ THREE.OBJLoader.prototype = { // Example asset: examples/models/obj/cerberus/Cerberus.obj var value = result[ 1 ].trim().toLowerCase(); - state.object.smooth = ( value === '1' || value === 'on' ); + /* + * http://paulbourke.net/dataformats/obj/ + * or + * http://www.cs.utah.edu/~boulos/cs3505/obj_spec.pdf + * + * From chapter "Grouping" Syntax explanation "s group_number": + * "group_number is the smoothing group number. To turn off smoothing groups, use a value of 0 or off. + * Polygonal elements use group numbers to put elements in different smoothing groups. For free-form + * surfaces, smoothing groups are either turned on or off; there is no difference between values greater + * than 0." + */ + state.object.smooth = ( value !== '0' && value !== 'off' ); var material = state.object.currentMaterial(); if ( material ) { diff --git a/examples/obj/cubes/cubes.mtl b/examples/obj/cubes/cubes.mtl new file mode 100644 index 0000000000000000000000000000000000000000..e67cc1817b8a33c701f5d0b5834ed86d893fc755 --- /dev/null +++ b/examples/obj/cubes/cubes.mtl @@ -0,0 +1,47 @@ +newmtl red +Ka 1.000000 0.000000 0.000000 +Kd 1.000000 0.000000 0.000000 +Ks 0.000000 0.000000 0.000000 +Tr 1.000000 +illum 1 +Ns 0.000000 + +newmtl blue +Ka 0.000000 0.000000 1.000000 +Kd 0.000000 0.000000 1.000000 +Ks 0.000000 0.000000 0.000000 +Tr 1.000000 +illum 1 +Ns 0.000000 + +newmtl green +Ka 0.000000 1.000000 0.000000 +Kd 0.000000 1.000000 0.000000 +Ks 0.000000 0.000000 0.000000 +Tr 1.000000 +illum 1 +Ns 0.000000 + +newmtl lightblue +Ka 0.000000 1.000000 1.000000 +Kd 0.000000 1.000000 1.000000 +Ks 0.000000 0.000000 0.000000 +Tr 1.000000 +illum 1 +Ns 0.000000 + +newmtl orange +Ka 1.000000 0.647059 0.000000 +Kd 1.000000 0.647059 0.000000 +Ks 0.000000 0.000000 0.000000 +Tr 1.000000 +illum 1 +Ns 0.000000 + +newmtl purple +Ka 0.825806 0.000000 0.825806 +Kd 0.825806 0.000000 0.825806 +Ks 0.000000 0.000000 0.000000 +Tr 1.000000 +illum 1 +Ns 0.000000 diff --git a/examples/obj/cubes/cubes.obj b/examples/obj/cubes/cubes.obj new file mode 100644 index 0000000000000000000000000000000000000000..e35e790edcffe67bde580eab53e87288571a41a3 --- /dev/null +++ b/examples/obj/cubes/cubes.obj @@ -0,0 +1,57 @@ +mtllib cubes.mtl + +# cube 01: pair of group and material per side/quad +o cube 01 + +v -10.00000 10.00000 10.00000 +v -10.00000 -10.00000 10.00000 +v 10.00000 -10.00000 10.00000 +v 10.00000 10.00000 10.00000 +v -10.00000 10.00000 -10.00000 +v -10.00000 -10.00000 -10.00000 +v 10.00000 -10.00000 -10.00000 +v 10.00000 10.00000 -10.00000 + +g front +usemtl red +f 1 2 3 4 +g back +usemtl blue +f 8 7 6 5 +g right +usemtl green +f 4 3 7 8 +g top +usemtl lightblue +f 5 1 4 8 +g left +usemtl orange +f 5 6 2 1 +g bottom +usemtl purple +f 2 6 7 3 + +# cube 02: one pair of group and material with different smoothing groups +o cube 02 + +v 20.00000 10.00000 10.00000 +v 20.00000 -10.00000 10.00000 +v 40.00000 -10.00000 10.00000 +v 40.00000 10.00000 10.00000 +v 20.00000 10.00000 -10.00000 +v 20.00000 -10.00000 -10.00000 +v 40.00000 -10.00000 -10.00000 +v 40.00000 10.00000 -10.00000 + +g cube 02 one group +usemtl blue +s 0 +f 9 10 11 12 +f 16 15 14 13 +s 1 +f 12 11 15 16 +f 13 9 12 16 +s 2 +f 13 14 10 9 +s off +f 10 14 15 11