提交 7ba811c6 编写于 作者: M Mr.doob 提交者: GitHub

Merge pull request #11343 from kaisalmen/Issue11270

OBJLoader: Allow flat and smooth shading within the same material definition for a specific object
......@@ -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 ) {
......
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
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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册