The converted document exported using threejs-usdzExporter does not appear correctly on an iPhone

I loaded a glb file using THREE.js GLTFLoader and then exported it to usdz using USDZ Exporter. When I tried to open it in the browser, it showed up in Safari but didn't appear in ARkit in object mode. Instead, it appeared above my head in AR mode. This is a simple file.

View the file here

This was my attempt to make it work.

const loader = new GLTFLoader().setPath(`${origin}${folderPath}`);
        loader.load(modelName, async function (gltf) {

            model = gltf.scene;
            scene.add(model);
      const exporter = new USDZExporter();
            const arraybuffer = await exporter.parse(model );
            const blob = new Blob([arraybuffer], { type: 'application/octet-stream' });

            const link = document.getElementById('usdz-link');
            link.style.display = ''
            link.href = URL.createObjectURL(blob);

I also tried centering the glb model with this code.

        const box = new THREE.Box3().setFromObject(gltf.scene);
        const center = box.getCenter(new THREE.Vector3());
        var sceneCopy=gltf.scene.clone();
        sceneCopy.position.x += (gltf.scene.position.x - center.x);
        sceneCopy.position.y += (gltf.scene.position.y - center.y);
        sceneCopy.position.z += (gltf.scene.position.z - center.z);

However, using sceneCopy to export to usdz did not solve the issue.

Answer №1

It seems like this question was already addressed on Slack, but just to confirm and provide closure...

In order for the model to display accurately in the quicklook viewer on iPad/iPhone, the offset must be near the origin.

To manually adjust the offset, simply modify these three lines: https://github.com/wallabyway/quicklook-example/blob/6f1e1453b983e0effc4ad82b2eda5eac905865a9/alliedbim-piping.gltf#L1023-L1025

These three values should be the opposite: https://github.com/wallabyway/quicklook-example/blob/6f1e1453b983e0effc4ad82b2eda5eac905865a9/alliedbim-piping.gltf#L1044-L1046

It's worth noting that the center option in forge-convert-utils may not consider the offset when using filtering.

A request has been made on GitHub to address this issue: https://github.com/petrbroz/forge-convert-utils/issues/44

Additionally, there is a potential solution available in a separate branch. https://github.com/petrbroz/forge-convert-utils/commit/bb4bd0a13c685c34966a3bf5c2784ba9b1343a7d

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

When an array is passed into a Vuex action function, it transforms into something other than just

EDIT: Added extra code in the filterEvents snippet for more context. I'm struggling to understand the behavior of my code. My goal is to pass an array into an action function within my Vuex store. However, when I return a Promise inside that action f ...

Swap out the <a> tag for an <input type="button"> element that includes a "download" property

I have been working on a simple canvas-to-image exporter. You can find it here. Currently, it only works with the following code: <a id="download" download="CanvasDemo.png">Download as image</a> However, I would like to use something like th ...

Steps to create a pop-up displaying a unique message ID retrieved from my database

My goal is to implement a pop-up message dialog on my website. When a user clicks on a reply icon, a pop-up message will appear with a textarea for the user to respond to a question they have been asked. The current issue is that clicking on the tag alway ...

Reducing the slide margins in impress.js?

When using Impress.js, I noticed that the default slides have a large left margin (or padding - it's hard to determine with Firefox's Inspector). I have a slide with a wide <pre> block that would fit if it were aligned to the left, but it d ...

Methods to prompt a user to select an option using Bootstrap

I have been struggling with this problem for hours and it's really starting to frustrate me! Currently, I am incorporating Twitter Bootstrap along with bootstrap-min.js. This is the code snippet in question: <select id="assettype" name="assettyp ...

Issue with displaying props value at the beginning of a function in ReactJS render

But the this.props.NotesAll object retrieved from another component is displaying under the render() method. However, when I attempt to use this.props.NotesAll above the render in a function to manipulate the objects and check their values with console.log ...

Keeping Chart.JS Up to Date: Updating Only Fresh Data

When a button is pressed on my website, a Bootstrap modal containing a Chart.JS is called. The data for this chart is loaded via an Ajax call as shown below: function loadReports(data) { $.ajax({ type: "POST", url: "Default.aspx/getRep ...

Sending JSON data containing an IFormFile and a string as parameters to C#

Software Versions: ASP.NET and Web Tools - 17.10.341.11210 C# Tools - 4.10.0-3.24312.19+ JQuery - 3.3.1.js JS - 2.8.3.js Currently, I am attempting to pass an IFormFile and a string from a JSON file select and a string input. After thorough testing, I ha ...

Rails successfully processed the request with a 200 OK status code, however, the $.ajax() function is triggering the 'error' callback instead of the 'success' callback

In my controller, the ajax request is handled as shown below (simplified): def create ... @answer = Answer.new(video: video_file) if @answer.save render json: @answer.video.url else ... end end This is how I have defined my ajax function: $.aja ...

The code snippets in the Vue3 documentation are quite peculiar

As I peruse the Vue 3 documentation, I notice a recurring pattern in how example code is presented for components: Vue.createApp({}) However, my experience with Vue 3 has been different. Instead of the above syntax, I simply use: <script> export d ...

Having difficulties redirecting with the button's onclick function

I'm struggling to redirect users to another page using a button (assuming the hostname is localhost:8000) $('#getFruit').attr('onclick', window.location.host + '/getFruit/banana') <script src="https://cdnjs.cloudfl ...

Assign Texture to Plane with Clarity

How can I adjust the way a texture is mapped onto a plane in Three.js? Assuming we have a 1x1 plane and a 16:9 image, how can we ensure the image maintains its aspect ratio and any overlap is trimmed off? Currently, the image is "squished" by default. Is ...

Troubleshooting the problem with JavaScript's week start date

I am encountering an issue with JavaScript when trying to obtain the first day of the week. It seems to be functioning correctly for most cases, but there is a discrepancy when it comes to the first day of the month. Could there be something that I am ove ...

Updating AngularJS views based on window resizing

I've been working on an Angularjs application and everything is running smoothly, but I'm facing challenges when it comes to implementing a mobile version of the site. Simply using responsive styles won't cut it; I need to use different view ...

Combining objects using mathematical operations for identical properties in JavaScript

Imagine I have two sets of data: const obj1 = { CRITICAL: 0, ERROR: 1, INFO: 0, WARNING: 0, }; const obj2 = { CRITICAL: 0, ERROR: 0, INFO: 0, WARNING: 1, }; I'm looking to merge them into a single object with the summed values for e ...

Are you experiencing issues with modal contents extending beyond the modal on smaller screens?

I recently installed a modal plugin called blockUI for my image uploading needs. Although I have styled and positioned everything accordingly, I am facing an issue: Whenever I resize the browser screen, switch to my iPhone, or use another screen, some con ...

When using a variable to fetch data in JSON, an undefined error occurs. However, if a hardcoded index

I am facing an issue while trying to extract and manipulate JSON data from a file for an application I am developing. When looping through the data, I encounter an undefined error that seems to indicate a missing property in the JSON object when accessing ...

Modify a single parameter of an element in a Map

Imagine I have a map data type exampleMap: Map<string, any> The key in the map is always a string, and the corresponding value is an object. This object might look like this: { name: 'sampleName', age: 30} Now, let's say the user se ...

Canvg | Is there a way to customize canvas elements while converting from SVG?

Recently, I encountered an issue with styling SVG graphics dynamically generated from data. The SVG graphic appears like this: https://i.sstatic.net/xvIpE.png To address the problem, I turned to Canvg in hopes of converting the SVG into an image or PDF us ...

Utilizing React Router V4 to Render Dual Components on a Single Route

Looking for help with these routes <Route exact path={`/admin/caters/:id`} component={Cater} /> <Route exact path={'/admin/caters/create'} component={CreateCater} /> After visiting the first route, I see a cater with an ID display ...