-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
USDZ file loader #16005
base: master
Are you sure you want to change the base?
USDZ file loader #16005
Conversation
Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s). |
Snapshot stored with reference name: Test environment: To test a playground add it to the URL, for example: https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/refs/pull/16005/merge/index.html#WGZLGJ#4600 Links to test babylon tools with this snapshot: https://playground.babylonjs.com/?snapshot=refs/pull/16005/merge To test the snapshot in the playground with a playground ID add it after the snapshot query string: https://playground.babylonjs.com/?snapshot=refs/pull/16005/merge#BCU1XR#0 |
Visualization tests for WebGPU (Experimental) |
WebGL2 visualization test reporter: |
private _initializeTinyUSDZAsync(): Promise<void> { | ||
return USDFileLoader._LoadScriptModuleAsync( | ||
` | ||
import Module from 'https://lighttransport.github.io/tinyusdz/tinyusdz.js'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should do that differently in the framework itself. A few notes:
- Can we host it on our own CDN?
- We should provide it as part of our
@babylonjs/loaders
package, if possible - This should be overridable. And injectable - i.e. people should be able to host it themselves, or load it themselves and pass the package to the loader
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've reworked the options so user can change module url.
My intent is to do a PR on tinyusdz repo with a new Github action job that will build the wasm and upload it as a npm. Then, use https://unpkg.com
like CSG2 did.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, didn't see the csg2 code. i'll resolve this, but we will need to discuss hosting it ourselves.
… usdzLoader # Conflicts: # packages/tools/tests/test/visualization/config.json
} | ||
|
||
private static readonly _DefaultLoadingOptions = { | ||
usdLoaderUrl: "https://lighttransport.github.io/tinyusdz/", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default should be https://cdn.babylonjs.com (it is important so we can use the ability to change base URL)
export function _LoadScriptModuleAsync(scriptUrl: string, scriptId?: string): Promise<any> { | ||
return new Promise((resolve, reject) => { | ||
// Need a relay | ||
let windowAsAny: any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe type this so at least within this function it is less likely to have a type or type error? And use a map?
let windowAsAny: any; | |
let windowAsAny: { _LoadScriptModuleResolve?: Map<number, unknown> }; |
* USD(z) file type loader. | ||
* This is a babylon scene loader plugin. | ||
*/ | ||
export class USDFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For new code, I would consider not having the plugin itself implement ISceneLoaderPluginFactory
. You'll want to add a factory to packages\dev\loaders\src\dynamic.ts
, so really you could follow the same pattern for the registerSceneLoaderPlugin
side effect.
Some features are not supported by tinyusdz like flattening for usdz. I've open an issue on tinyusdz repo lighttransport/tinyusdz#216 I'm waiting for some answers before chosing if the work should continue with this PR. Setting it to draft for now. |
_LoadScriptModuleAsync
has been copy/pasted. Is there a better way to handle it?