Skip to content

Commit

Permalink
USDZExporter: Fixed uvs and clean up.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdoob committed Feb 9, 2021
1 parent 74809b3 commit b397418
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions examples/jsm/exporters/USDZExporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function buildHeader() {

function buildXform( object, define ) {

const name = 'Object' + object.id;
const name = 'Object_' + object.id;
const transform = buildMatrix( object.matrixWorld );

return `def Xform "${ name }"
Expand Down Expand Up @@ -79,22 +79,24 @@ function buildMatrixRow( array, offset ) {

function buildMesh( geometry, material ) {

const name = 'Geometry' + geometry.id;
const name = 'Geometry_' + geometry.id;
const attributes = geometry.attributes;
const count = attributes.position.count;

return `def Mesh "${ name }"
{
int[] faceVertexCounts = [${ buildMeshVertexCount( geometry ) }]
int[] faceVertexIndices = [${ buildMeshVertexIndices( geometry ) }]
rel material:binding = </_materials/Material_${ material.id }>
rel material:binding = </Materials/Material_${ material.id }>
normal3f[] normals = [${ buildVector3Array( attributes.normal, count )}] (
interpolation = "vertex"
)
point3f[] points = [${ buildVector3Array( attributes.position, count )}]
texCoord2f[] primvars:UVMap = [${ buildVector2Array( attributes.uv, count )}] (
interpolation = "faceVarying"
float2[] primvars:st = [${ buildVector2Array( attributes.uv, count )}] (
elementSize = 1
interpolation = "vertex"
)
int[] primvars:st:indices
uniform token subdivisionScheme = "none"
}
`;
Expand Down Expand Up @@ -188,7 +190,7 @@ function buildMaterials( materials ) {

}

return `def "_materials"
return `def "Materials"
{
${ array.join( '' ) }
}
Expand All @@ -202,9 +204,9 @@ function buildMaterial( material ) {
return `
def Material "Material_${ material.id }"
{
token outputs:surface.connect = </_materials/Material_${ material.id }/previewShader.outputs:surface>
token outputs:surface.connect = </Materials/Material_${ material.id }/PreviewSurface.outputs:surface>
def Shader "previewShader"
def Shader "PreviewSurface"
{
uniform token info:id = "UsdPreviewSurface"
color3f inputs:diffuseColor = ${ buildColor( material.color ) }
Expand Down

0 comments on commit b397418

Please sign in to comment.