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 loading models without materials #439

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ikmersia
Copy link

Buenas Jesus! Subo un fix de un problema que me he encontrado:

When using onAdd, if options.mtl is not specified MTLLoader.js fails and the model is not loaded.
I encountered this error using .glb file.
when url is not passed, loader.load call is made with url = current navigation path.
When testing in local this value was localhost:3000, which worked well (returned 304 and then object is loaded)
When uploading to production, url value was https://dev.immersia.eu/emplazamiento/45, (note that this is the current frontend path where map is rendered). I have frontend in aws cloudfront, the response is 404 and the model is not loaded

How to reproduce: pass https://dev.immersia.eu/emplazamiento/45, for example, as options.mtl for tb.loadObj function.

My fix:
If material is specified, try to load the material, if not, just render the object without the material.
I tried it and it works.

Temporal fix, just use a url that doesn't return an error value for mtl field (any page with allow any cors origin?), for example:

const options = {
obj: modelUrl,
type: modelType,
units: "meters",
scale: layerScale,
anchor: "bottom",
rotation: { x: 90, y: 0, z: 0 },
mtl: "https://jsonplaceholder.typicode.com/",
};

image

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.

1 participant