three.js: Loaders: Inconsistent implementations of .setPath()
Hey dear guys,
since you urged + forced me (me, just a innocent threejs user), see https://github.com/mrdoob/three.js/issues/12903 I bravely followed you to use GLTF, and tried …
It looks, as if GLTFLoader.setPath() doesn’nt work …
The default “Blender Cube” should appear like this: https://rawgit.com/wolfgangvonludwigsburg/three.js/dev/examples/_webgl_loader_gltf_cube_PR.html
Compare to current “90dev” state: https://rawgit.com/wolfgangvonludwigsburg/three.js/dev/examples/_webgl_loader_gltf_cube_fail.html Console.log: Failed to load resource: the server responded with a status of 404 (Not Found)
To verify the loading path, I’ve put in an additionally FileLoader request (which succeeds).
The fix could be, in GLTFLoader.js, line 27, after
var path = this.path !== undefined ? this.path : THREE.LoaderUtils.extractUrlBase( url );
insert
if ( this.path !== undefined )
url = this.path + url;
If you verify the fault, should I do a PR, or the author of GLTFLoader.js ?
BTW: Additionally I tried JSONLoader.setPath() which fails (member method not available) …
- maybe all loaders should behave accordingly in the same manner … ?
90dev, Chrome, Windows
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 37 (11 by maintainers)
Commits related to this issue
- - Original Repo Issue 47: Fixed incorrect vertex color pointerC initialization (omitting first set of values) - Original Repo Pull Request 46: It is now possible to run `THREE.OBJLoader2` in nodejs 10... — committed to kaisalmen/three.js by kaisalmen 6 years ago
- Squashed commit of the following: commit 5360a81b8c557ed255e97b87c49e7d00b546b795 Author: Mr.doob <info@mrdoob.com> Date: Wed Oct 31 10:42:06 2018 -0400 r98 commit f8dc0a9335a18eda38bf028e54c... — committed to opensim-org/three.js by aymanhab 6 years ago
- - Original Repo Issue 47: Fixed incorrect vertex color pointerC initialization (omitting first set of values) - Original Repo Pull Request 46: It is now possible to run `THREE.OBJLoader2` in nodejs 10... — committed to DavidPeicho/three.js by kaisalmen 6 years ago
I also prefer
setResourcePathoversetTexturePathand the plural alternatives. Since resource is a generic term, I do not think we need an additionalsetTexturePathmethod for loaders where all of the resources happen to be textures, like MTLLoader. If we’re agreed on that, the tasks are updating (all?) loaders such that:.setPath()affects original file (or multiple original files forCubeTextureLoader).setResourcePath()affects dependencies of original file, where applicableI’m assuming
.setAnimationPath()would be forMMDLoaderonly. I think that is OK.Unfortunately not. But I think it should be okay to establish something like
.setAnimationPath()and.animationPath. Any opinions on this?@Mugen87 PR for OBJLoader2 V2.5.0 implementing this agreement, plus nodejs support and hopefully a working fix for minification problems with webpack/angular should be ready this weekend (before R98 is due).
@takahirox I’ve had a look at
MMDLoaderand I think it’s a bit complicated to implement a.setPath()method. The loader has a methodMMDLoader.loadWithAnimation()that accepts two URLs to assets, possibly both in different directories. A single base path defined via.setPath()could not handle a use case like the following. What do you think?https://github.com/mrdoob/three.js/blob/2f46e2a6ed597423c1aee7789cc1ad0e988a8772/examples/webgl_loader_mmd.html#L124-L133
Yes, I will take care. Thanks for pinging me.
@kaisalmen Can you please check how
LoaderSupportandOBJLoader2are affected by this issue? It would be great if you can provide a PR in order to align the interface if necessary.I suggest the owners mentioned in this wiki page should migrate their respective loaders.
What is left to do here? Is someone who is familiar with this issue willing to create a new post with a task list?
/ping @takahirox /ping @donmccurdy /ping @Mugen87
Sure.
To be more concrete (I’ll work it out next days; Happy 2018 !!):
I’m not sure if it’s the same issue you’re facing, but I’m already aware of that
GLTFLoadercan’t handle(display)Pointscorrectly.The reason is
GLTFLoaderdoesn’t createPointsMaterialforPoints.PointsneedsPointsMaterialto be rendered. It can’t be rendered withMesh*Material(If I’m right).I already started to work on it in my local branch.
Another issue I’m aware of is glTF doesn’t hold point size information. I’m gonna ask or open an issue to glTF team (if necessary).
As @donmccurdy mentioned, please open an issue if what I mentioned aren’t what you ran into.
I’ve renamed the issue Loaders: Inconsistent implementations of .setPath(), as I think the changes to consider would be:
setPath()for extra resources but not the original request.setPath()on FileLoader and ImageLoader, as they have no extra resources.setPath()in cases where it must behave differently than this, renaming the normal case tosetResourcePath(), or similar clarification.