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

fix(composer): support Windows dependency file paths in GLTF loader #417

Merged
merged 1 commit into from
Jan 5, 2023

Conversation

hwandersman
Copy link
Contributor

@hwandersman hwandersman commented Dec 5, 2022

Overview

When a GLTF file is exported on the Windows platform and has texture image files referenced in sub-folders, the generated GLTF file uses backslash character for folder hierarchy: textures\\image.png

The GLTFLoader uses this url in an S3 path like s3://bucket/textures\\image.png which cannot be resolved by S3.

Verifying Changes

Used storybook to load an existing scene in my AWS account. The scene has a model GLTF with textures set up as the following:

"images": [
    {
      "uri": "textures\\plate_baseColor.jpeg"
    },
    {
      "uri": "textures\\tire_mat4_baseColor.jpeg"
    },
    {
      "uri": "textures\\brakes1_baseColor.jpeg"
    },
    {
      "uri": "textures\\brakes1_normal.png"
    }
  ],

Before this fix the textures are not rendered and an error is shown in the browser Console:

THREE.GLTFLoader: Couldn't load texture textures\brakes1_baseColor.jpeg

Failed to load resource: the server responded with a status of 404 (Not Found)

After the fix all textures are loaded successfully.

Testing

Added a 3D model of a Tesla car that can be used for testing. Upload it to your workspace's S3 bucket / resource library and add it to a scene. With this fix all textures in the scene should load.

Legal

This project is available under the Apache 2.0 License.

Copy link
Contributor

@TheEvilDev TheEvilDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have a story that covers this case.

@lgtm-com
Copy link

lgtm-com bot commented Dec 5, 2022

This pull request introduces 1 alert when merging 8de93a7 into b76057d - view on LGTM.com

new alerts:

  • 1 for Incomplete string escaping or encoding

Heads-up: LGTM.com's PR analysis will be disabled on the 5th of December, and LGTM.com will be shut down ⏻ completely on the 16th of December 2022. Please enable GitHub code scanning, which uses the same CodeQL engine ⚙️ that powers LGTM.com. For more information, please check out our post on the GitHub blog.

@hwandersman
Copy link
Contributor Author

We should have a story that covers this case.

The issue is only when loading a model from S3, so we need a story that requires manual setup with an AWS account. Added an item in the backlog to do this.

Copy link
Contributor

@TheEvilDev TheEvilDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GLTF/BIn files need to be at the root of the public folder, there's a bug in how we implement the GLTFLoader that I haven't figured out yet, that prevents relative paths from working.

Also, please squash your commits, and make sure to use the commitlint format for commit messages.

* Add example 3D model with textures referenced with Windows paths for testing
@hwandersman hwandersman merged commit 9f7c075 into main Jan 5, 2023
@hwandersman hwandersman deleted the windows-path-fix branch January 5, 2023 19:16
@github-actions github-actions bot mentioned this pull request Jan 5, 2023
mukeshsahay pushed a commit that referenced this pull request Jan 11, 2023
author dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> 1672181186 -0800
committer Mukesh Sahay <muksahay@amazon.com> 1673468961 -0800

build(deps): bump decode-uri-component from 0.2.0 to 0.2.2 (#419)

Bumps [decode-uri-component](https://github.com/SamVerschueren/decode-uri-component) from 0.2.0 to 0.2.2.
- [Release notes](https://github.com/SamVerschueren/decode-uri-component/releases)
- [Commits](SamVerschueren/decode-uri-component@v0.2.0...v0.2.2)

---
updated-dependencies:
- dependency-name: decode-uri-component
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

chore: upgrade video.js to remove xmldom (#447)

chore(AddSVGLinting): Enforce width and height attributes on SVGs

fix(composer): support Windows dependency file paths in GLTF loader (#417)

* Add example 3D model with textures referenced with Windows paths for testing

fix(composer): Auto expand hierarchy when selecting node on scene

fix(composer): Update scene hierarchy test cases

Revert "fix(composer): Update scene hierarchy test cases"

This reverts commit fcf1666.

Revert "fix(composer): Auto expand hierarchy when selecting node on scene"

This reverts commit 0395c86.

fix(composer): Auto expand hierarchy when selecting node on scene

fix(composer): Add test for SceneHierarchyDataProvider

fix(composer): hdr url is sometimes wrong (#352)

chore: release 2.6.1 (#440)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

fix: prevent stream render if dataType unknown (#448)

chore: release 2.6.2 (#455)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

fix: prevent stream render if dataType unknown (#448)

chore: release 2.6.2 (#455)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants