Ver Fonte

USDZExporter: Anchoring support (#22854)

* WIP: Wall placement

* wallplacement config

* use options function and remove console.log

* tabs for spaces

* replace tabs with spaces in strings of USDZExporter

Co-authored-by: Thorsten Bux <[email protected]>
Alexander Neumann há 2 anos atrás
pai
commit
868aee4c3b
1 ficheiros alterados com 37 adições e 0 exclusões
  1. 37 0
      examples/jsm/exporters/USDZExporter.js

+ 37 - 0
examples/jsm/exporters/USDZExporter.js

@@ -6,6 +6,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 = {};
@@ -16,6 +26,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 = {};
 
@@ -59,6 +88,14 @@ class USDZExporter {
 
 		} );
 
+
+		output += `
+        }
+    }
+}
+
+`;
+
 		output += buildMaterials( materials, textures );
 
 		files[ modelFileName ] = fflate.strToU8( output );