Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USDZExporter: Add anchoring support. #22854

Merged
merged 6 commits into from
Oct 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions examples/jsm/exporters/USDZExporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@ import * as fflate from '../libs/fflate.module.js';

class USDZExporter {

options = {
ar: { anchoring: { type: 'plane' }, planeAnchoring: { alignment: 'vertical' } }
};

setOptions( options ) {

this.options = options;

}

async parse( scene ) {

const files = {};
Expand All @@ -12,6 +22,25 @@ class USDZExporter {

let output = buildHeader();

output += `def Xform "Root"
{
def Scope "Scenes" (
kind = "sceneLibrary"
)
{
def Xform "Scene" (
customData = {
bool preliminary_collidesWithEnvironment = 0
string sceneName = "Scene"
}
sceneName = "Scene"
)
{
token preliminary:anchoring:type = "${this.options.ar.anchoring.type}"
token preliminary:planeAnchoring:alignment = "${this.options.ar.planeAnchoring.alignment}"

`;

const materials = {};
const textures = {};

Expand Down Expand Up @@ -43,6 +72,14 @@ class USDZExporter {

} );


output += `
}
}
}

`;

output += buildMaterials( materials, textures );

files[ modelFileName ] = fflate.strToU8( output );
Expand Down