Skip to content

Commit b397418

Browse files
committed
USDZExporter: Fixed uvs and clean up.
1 parent 74809b3 commit b397418

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

examples/jsm/exporters/USDZExporter.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function buildHeader() {
4646

4747
function buildXform( object, define ) {
4848

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

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

8080
function buildMesh( geometry, material ) {
8181

82-
const name = 'Geometry' + geometry.id;
82+
const name = 'Geometry_' + geometry.id;
8383
const attributes = geometry.attributes;
8484
const count = attributes.position.count;
8585

8686
return `def Mesh "${ name }"
8787
{
8888
int[] faceVertexCounts = [${ buildMeshVertexCount( geometry ) }]
8989
int[] faceVertexIndices = [${ buildMeshVertexIndices( geometry ) }]
90-
rel material:binding = </_materials/Material_${ material.id }>
90+
rel material:binding = </Materials/Material_${ material.id }>
9191
normal3f[] normals = [${ buildVector3Array( attributes.normal, count )}] (
9292
interpolation = "vertex"
9393
)
9494
point3f[] points = [${ buildVector3Array( attributes.position, count )}]
95-
texCoord2f[] primvars:UVMap = [${ buildVector2Array( attributes.uv, count )}] (
96-
interpolation = "faceVarying"
95+
float2[] primvars:st = [${ buildVector2Array( attributes.uv, count )}] (
96+
elementSize = 1
97+
interpolation = "vertex"
9798
)
99+
int[] primvars:st:indices
98100
uniform token subdivisionScheme = "none"
99101
}
100102
`;
@@ -188,7 +190,7 @@ function buildMaterials( materials ) {
188190

189191
}
190192

191-
return `def "_materials"
193+
return `def "Materials"
192194
{
193195
${ array.join( '' ) }
194196
}
@@ -202,9 +204,9 @@ function buildMaterial( material ) {
202204
return `
203205
def Material "Material_${ material.id }"
204206
{
205-
token outputs:surface.connect = </_materials/Material_${ material.id }/previewShader.outputs:surface>
207+
token outputs:surface.connect = </Materials/Material_${ material.id }/PreviewSurface.outputs:surface>
206208
207-
def Shader "previewShader"
209+
def Shader "PreviewSurface"
208210
{
209211
uniform token info:id = "UsdPreviewSurface"
210212
color3f inputs:diffuseColor = ${ buildColor( material.color ) }

0 commit comments

Comments
 (0)