提交 be7f3e0b 编写于 作者: S Sven Andersson

Blender (2.57) export script keep track of texture wrapping option.

上级 8429ff11
......@@ -505,9 +505,9 @@ function(){h-=1;o();d.onLoadComplete()};for(z in E.cameras){D=E.cameras[z];if(D.
N.cameras[E.defaults.camera];if(N.fogs&&E.defaults.fog)N.scene.fog=N.fogs[E.defaults.fog];D=E.defaults.bgcolor;N.bgColor=new THREE.Color;N.bgColor.setRGB(D[0],D[1],D[2]);N.bgColorAlpha=E.defaults.bgalpha;for(p in E.geometries)if(A=E.geometries[p],A.type=="bin_mesh"||A.type=="ascii_mesh")T+=1,d.onLoadStart();Q=T;for(p in E.geometries)A=E.geometries[p],A.type=="cube"?(B=new THREE.CubeGeometry(A.width,A.height,A.depth,A.segmentsWidth,A.segmentsHeight,A.segmentsDepth,null,A.flipped,A.sides),N.geometries[p]=
B):A.type=="plane"?(B=new THREE.PlaneGeometry(A.width,A.height,A.segmentsWidth,A.segmentsHeight),N.geometries[p]=B):A.type=="sphere"?(B=new THREE.SphereGeometry(A.radius,A.segmentsWidth,A.segmentsHeight),N.geometries[p]=B):A.type=="cylinder"?(B=new THREE.CylinderGeometry(A.numSegs,A.topRad,A.botRad,A.height,A.topOffset,A.botOffset),N.geometries[p]=B):A.type=="torus"?(B=new THREE.TorusGeometry(A.radius,A.tube,A.segmentsR,A.segmentsT),N.geometries[p]=B):A.type=="icosahedron"?(B=new THREE.IcosahedronGeometry(A.subdivisions),
N.geometries[p]=B):A.type=="bin_mesh"?b.load({model:e(A.url,E.urlBaseType),callback:m(p)}):A.type=="ascii_mesh"?M.load({model:e(A.url,E.urlBaseType),callback:m(p)}):A.type=="embedded_mesh"&&(A=E.embeds[A.id])&&M.createModel(A,n(p),"");for(x in E.textures)if(p=E.textures[x],p.url instanceof Array){h+=p.url.length;for(b=0;b<p.url.length;b++)d.onLoadStart()}else h+=1,d.onLoadStart();R=h;for(x in E.textures){p=E.textures[x];if(p.mapping!=void 0&&THREE[p.mapping]!=void 0)p.mapping=new THREE[p.mapping];
if(p.url instanceof Array){for(var b=[],V=0;V<p.url.length;V++)b[V]=e(p.url[V],E.urlBaseType);b=THREE.ImageUtils.loadTextureCube(b,p.mapping,aa)}else{b=THREE.ImageUtils.loadTexture(e(p.url,E.urlBaseType),p.mapping,aa);if(THREE[p.minFilter]!=void 0)b.minFilter=THREE[p.minFilter];if(THREE[p.magFilter]!=void 0)b.magFilter=THREE[p.magFilter];if(p.repeat)b.repeat.set(p.repeat[0],p.repeat[1]),b.wrapS=b.wrapT=THREE.RepeatWrapping}N.textures[x]=b}for(t in E.materials){x=E.materials[t];for(F in x.parameters)if(F==
"envMap"||F=="map"||F=="lightMap")x.parameters[F]=N.textures[x.parameters[F]];else if(F=="shading")x.parameters[F]=x.parameters[F]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(F=="blending")x.parameters[F]=THREE[x.parameters[F]]?THREE[x.parameters[F]]:THREE.NormalBlending;else if(F=="combine")x.parameters[F]=x.parameters[F]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;else if(F=="vertexColors")if(x.parameters[F]=="face")x.parameters[F]=THREE.FaceColors;else if(x.parameters[F])x.parameters[F]=
THREE.VertexColors;if(x.parameters.opacity!==void 0&&x.parameters.opacity<1)x.parameters.transparent=!0;x=new THREE[x.type](x.parameters);N.materials[t]=x}k();d.callbackSync(N)}}};
if(p.url instanceof Array){for(var b=[],V=0;V<p.url.length;V++)b[V]=e(p.url[V],E.urlBaseType);b=THREE.ImageUtils.loadTextureCube(b,p.mapping,aa)}else{b=THREE.ImageUtils.loadTexture(e(p.url,E.urlBaseType),p.mapping,aa);if(THREE[p.minFilter]!=void 0)b.minFilter=THREE[p.minFilter];if(THREE[p.magFilter]!=void 0)b.magFilter=THREE[p.magFilter];if(p.wrap&&p.wrap=="repeat")b.wrapS=b.wrapT=THREE.RepeatWrapping;if(p.repeat)b.repeat.set(p.repeat[0],p.repeat[1]),b.wrapS=b.wrapT=THREE.RepeatWrapping}N.textures[x]=
b}for(t in E.materials){x=E.materials[t];for(F in x.parameters)if(F=="envMap"||F=="map"||F=="lightMap")x.parameters[F]=N.textures[x.parameters[F]];else if(F=="shading")x.parameters[F]=x.parameters[F]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(F=="blending")x.parameters[F]=THREE[x.parameters[F]]?THREE[x.parameters[F]]:THREE.NormalBlending;else if(F=="combine")x.parameters[F]=x.parameters[F]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;else if(F=="vertexColors")if(x.parameters[F]==
"face")x.parameters[F]=THREE.FaceColors;else if(x.parameters[F])x.parameters[F]=THREE.VertexColors;if(x.parameters.opacity!==void 0&&x.parameters.opacity<1)x.parameters.transparent=!0;x=new THREE[x.type](x.parameters);N.materials[t]=x}k();d.callbackSync(N)}}};
THREE.MarchingCubes=function(b,c){THREE.Object3D.call(this);this.materials=c instanceof Array?c:[c];this.init=function(b){this.isolation=80;this.size=b;this.size2=this.size*this.size;this.size3=this.size2*this.size;this.halfsize=this.size/2;this.delta=2/this.size;this.yd=this.size;this.zd=this.size2;this.field=new Float32Array(this.size3);this.normal_cache=new Float32Array(this.size3*3);this.vlist=new Float32Array(36);this.nlist=new Float32Array(36);this.firstDraw=!0;this.maxCount=4096;this.count=
0;this.hasNormal=this.hasPos=!1;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(b,c,f){return b+(c-b)*f};this.VIntX=function(b,c,f,g,j,k,m,n,o,p){j=(j-o)/(p-o);o=this.normal_cache;c[g]=k+j*this.delta;c[g+1]=m;c[g+2]=n;f[g]=this.lerp(o[b],o[b+3],j);f[g+1]=this.lerp(o[b+1],o[b+4],j);f[g+2]=this.lerp(o[b+2],o[b+5],j)};this.VIntY=function(b,c,f,g,j,k,m,n,o,p){j=(j-o)/(p-o);o=this.normal_cache;c[g]=k;c[g+1]=m+j*this.delta;c[g+
2]=n;c=b+this.yd*3;f[g]=this.lerp(o[b],o[c],j);f[g+1]=this.lerp(o[b+1],o[c+1],j);f[g+2]=this.lerp(o[b+2],o[c+2],j)};this.VIntZ=function(b,c,f,g,j,k,m,n,o,p){j=(j-o)/(p-o);o=this.normal_cache;c[g]=k;c[g+1]=m;c[g+2]=n+j*this.delta;c=b+this.zd*3;f[g]=this.lerp(o[b],o[c],j);f[g+1]=this.lerp(o[b+1],o[c+1],j);f[g+2]=this.lerp(o[b+2],o[c+2],j)};this.compNorm=function(b){var c=b*3;this.normal_cache[c]==0&&(this.normal_cache[c]=this.field[b-1]-this.field[b+1],this.normal_cache[c+1]=this.field[b-this.yd]-this.field[b+
......
......@@ -162,9 +162,9 @@ t.direction,light=new THREE.DirectionalLight(D,y),light.position.set(p[0],p[1],p
if(A.fogs&&B.defaults.fog)A.scene.fog=A.fogs[B.defaults.fog];y=B.defaults.bgcolor;A.bgColor=new THREE.Color;A.bgColor.setRGB(y[0],y[1],y[2]);A.bgColorAlpha=B.defaults.bgalpha;for(m in B.geometries)if(v=B.geometries[m],v.type=="bin_mesh"||v.type=="ascii_mesh")L+=1,c.onLoadStart();M=L;for(m in B.geometries)v=B.geometries[m],v.type=="cube"?(C=new THREE.CubeGeometry(v.width,v.height,v.depth,v.segmentsWidth,v.segmentsHeight,v.segmentsDepth,null,v.flipped,v.sides),A.geometries[m]=C):v.type=="plane"?(C=
new THREE.PlaneGeometry(v.width,v.height,v.segmentsWidth,v.segmentsHeight),A.geometries[m]=C):v.type=="sphere"?(C=new THREE.SphereGeometry(v.radius,v.segmentsWidth,v.segmentsHeight),A.geometries[m]=C):v.type=="cylinder"?(C=new THREE.CylinderGeometry(v.numSegs,v.topRad,v.botRad,v.height,v.topOffset,v.botOffset),A.geometries[m]=C):v.type=="torus"?(C=new THREE.TorusGeometry(v.radius,v.tube,v.segmentsR,v.segmentsT),A.geometries[m]=C):v.type=="icosahedron"?(C=new THREE.IcosahedronGeometry(v.subdivisions),
A.geometries[m]=C):v.type=="bin_mesh"?a.load({model:d(v.url,B.urlBaseType),callback:h(m)}):v.type=="ascii_mesh"?J.load({model:d(v.url,B.urlBaseType),callback:h(m)}):v.type=="embedded_mesh"&&(v=B.embeds[v.id])&&J.createModel(v,k(m),"");for(x in B.textures)if(m=B.textures[x],m.url instanceof Array){G+=m.url.length;for(a=0;a<m.url.length;a++)c.onLoadStart()}else G+=1,c.onLoadStart();H=G;for(x in B.textures){m=B.textures[x];if(m.mapping!=void 0&&THREE[m.mapping]!=void 0)m.mapping=new THREE[m.mapping];
if(m.url instanceof Array){for(var a=[],N=0;N<m.url.length;N++)a[N]=d(m.url[N],B.urlBaseType);a=THREE.ImageUtils.loadTextureCube(a,m.mapping,I)}else{a=THREE.ImageUtils.loadTexture(d(m.url,B.urlBaseType),m.mapping,I);if(THREE[m.minFilter]!=void 0)a.minFilter=THREE[m.minFilter];if(THREE[m.magFilter]!=void 0)a.magFilter=THREE[m.magFilter];if(m.repeat)a.repeat.set(m.repeat[0],m.repeat[1]),a.wrapS=a.wrapT=THREE.RepeatWrapping}A.textures[x]=a}for(n in B.materials){x=B.materials[n];for(z in x.parameters)if(z==
"envMap"||z=="map"||z=="lightMap")x.parameters[z]=A.textures[x.parameters[z]];else if(z=="shading")x.parameters[z]=x.parameters[z]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(z=="blending")x.parameters[z]=THREE[x.parameters[z]]?THREE[x.parameters[z]]:THREE.NormalBlending;else if(z=="combine")x.parameters[z]=x.parameters[z]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;else if(z=="vertexColors")if(x.parameters[z]=="face")x.parameters[z]=THREE.FaceColors;else if(x.parameters[z])x.parameters[z]=
THREE.VertexColors;if(x.parameters.opacity!==void 0&&x.parameters.opacity<1)x.parameters.transparent=!0;x=new THREE[x.type](x.parameters);A.materials[n]=x}j();c.callbackSync(A)}}};
if(m.url instanceof Array){for(var a=[],N=0;N<m.url.length;N++)a[N]=d(m.url[N],B.urlBaseType);a=THREE.ImageUtils.loadTextureCube(a,m.mapping,I)}else{a=THREE.ImageUtils.loadTexture(d(m.url,B.urlBaseType),m.mapping,I);if(THREE[m.minFilter]!=void 0)a.minFilter=THREE[m.minFilter];if(THREE[m.magFilter]!=void 0)a.magFilter=THREE[m.magFilter];if(m.wrap&&m.wrap=="repeat")a.wrapS=a.wrapT=THREE.RepeatWrapping;if(m.repeat)a.repeat.set(m.repeat[0],m.repeat[1]),a.wrapS=a.wrapT=THREE.RepeatWrapping}A.textures[x]=
a}for(n in B.materials){x=B.materials[n];for(z in x.parameters)if(z=="envMap"||z=="map"||z=="lightMap")x.parameters[z]=A.textures[x.parameters[z]];else if(z=="shading")x.parameters[z]=x.parameters[z]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(z=="blending")x.parameters[z]=THREE[x.parameters[z]]?THREE[x.parameters[z]]:THREE.NormalBlending;else if(z=="combine")x.parameters[z]=x.parameters[z]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;else if(z=="vertexColors")if(x.parameters[z]==
"face")x.parameters[z]=THREE.FaceColors;else if(x.parameters[z])x.parameters[z]=THREE.VertexColors;if(x.parameters.opacity!==void 0&&x.parameters.opacity<1)x.parameters.transparent=!0;x=new THREE[x.type](x.parameters);A.materials[n]=x}j();c.callbackSync(A)}}};
THREE.MarchingCubes=function(a,b){THREE.Object3D.call(this);this.materials=b instanceof Array?b:[b];this.init=function(a){this.isolation=80;this.size=a;this.size2=this.size*this.size;this.size3=this.size2*this.size;this.halfsize=this.size/2;this.delta=2/this.size;this.yd=this.size;this.zd=this.size2;this.field=new Float32Array(this.size3);this.normal_cache=new Float32Array(this.size3*3);this.vlist=new Float32Array(36);this.nlist=new Float32Array(36);this.firstDraw=!0;this.maxCount=4096;this.count=
0;this.hasNormal=this.hasPos=!1;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(a,b,e){return a+(b-a)*e};this.VIntX=function(a,b,e,f,g,j,h,k,l,m){g=(g-l)/(m-l);l=this.normal_cache;b[f]=j+g*this.delta;b[f+1]=h;b[f+2]=k;e[f]=this.lerp(l[a],l[a+3],g);e[f+1]=this.lerp(l[a+1],l[a+4],g);e[f+2]=this.lerp(l[a+2],l[a+5],g)};this.VIntY=function(a,b,e,f,g,j,h,k,l,m){g=(g-l)/(m-l);l=this.normal_cache;b[f]=j;b[f+1]=h+g*this.delta;b[f+
2]=k;b=a+this.yd*3;e[f]=this.lerp(l[a],l[b],g);e[f+1]=this.lerp(l[a+1],l[b+1],g);e[f+2]=this.lerp(l[a+2],l[b+2],g)};this.VIntZ=function(a,b,e,f,g,j,h,k,l,m){g=(g-l)/(m-l);l=this.normal_cache;b[f]=j;b[f+1]=h;b[f+2]=k+g*this.delta;b=a+this.zd*3;e[f]=this.lerp(l[a],l[b],g);e[f+1]=this.lerp(l[a+1],l[b+1],g);e[f+2]=this.lerp(l[a+2],l[b+2],g)};this.compNorm=function(a){var b=a*3;this.normal_cache[b]==0&&(this.normal_cache[b]=this.field[a-1]-this.field[a+1],this.normal_cache[b+1]=this.field[a-this.yd]-this.field[a+
......
......@@ -590,6 +590,13 @@ THREE.SceneLoader.prototype = {
if ( THREE[ tt.magFilter ] != undefined )
texture.magFilter = THREE[ tt.magFilter ];
if ( tt.wrap ) {
if (tt.wrap == "repeat")
texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
}
if ( tt.repeat ) {
texture.repeat.set( tt.repeat[ 0 ], tt.repeat[ 1 ] );
......
......@@ -766,6 +766,9 @@ def extract_materials(mesh, scene, option_colors):
if texture.repeat_x != 1 or texture.repeat_y != 1:
material['mapDiffuseRepeat'] = [texture.repeat_x, texture.repeat_y]
if texture.extension == "REPEAT":
material["mapDiffuseWrap"] = "repeat"
material["vertexColors"] = m.THREE_useVertexColors and option_colors
# can't really use this reliably to tell apart Phong from Lambert
......@@ -1200,6 +1203,9 @@ def generate_textures_scene(data):
if texture.repeat_x != 1 or texture.repeat_y != 1:
extras = ',\n "repeat": [%f, %f]' % (texture.repeat_x, texture.repeat_y)
if texture.extension == "REPEAT":
extras = ',\n "wrap": "repeat"'
texture_string = TEMPLATE_TEXTURE % {
"texture_id" : generate_string(texture_id),
"texture_file" : generate_string(texture_file),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册