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

refactor(mtlreader): add a boolean to not automatically request and l… #2406

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

Conversation

luciemac
Copy link
Contributor

@luciemac luciemac commented May 9, 2022

…oad materials files

Context

Results

Changes

  • Documentation and TypeScript definitions were updated to match those changes

PR and Code Checklist

  • semantic-release commit messages
  • Run npm run reformat to have correctly formatted code

Testing

  • This change adds or fixes unit tests
  • Tested environment:
    • vtk.js:
    • OS:
    • Browser:

@luciemac
Copy link
Contributor Author

luciemac commented May 9, 2022

@finetjul

@@ -165,6 +165,7 @@ const DEFAULT_VALUES = {
requestCount: 0,
materials: {},
interpolateTextures: true,
autoLoadMaterials: true,
Copy link
Member

Choose a reason for hiding this comment

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

rename to loadMaterialImages ?

@@ -43,7 +43,7 @@ function vtkMTLReader(publicAPI, model) {
model.materials[model.currentMaterial] = {};
}
model.materials[model.currentMaterial][tokens[0]] = tokens.slice(1);
if (tokens[0] === 'map_Kd') {
if (model.autoLoadMaterials && tokens[0] === 'map_Kd') {
Copy link
Member

Choose a reason for hiding this comment

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

setImageSrc() seems to be implemented to overwrite the image. It's similar to what you need (you already have the image in cache and you do not want to load it again).

Maybe we could combine both usage:
e.g.

image.src = model.imageSourceHelper(tokens[1]);
...
model.imageSourceHelper = (source) => [model.baseURL, source].join('/');
macro.setGet(['imageSourceBuilder']);
...
mtlReader.setImageSourceBuilder((source) => {return ''});

@jourdain what is the purpose of setImageSrc() ? What's the use case ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't necessarily have it in cache.
Sometimes "map_Kd" is mentioned, but we don't want to use it because the image source file does not exist.

Copy link
Member

Choose a reason for hiding this comment

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

@jourdain can you please tell us how you use setImageSrc()

Copy link
Collaborator

Choose a reason for hiding this comment

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

the mtl file will have a name/path and you want to link it to an HTML image so you call
setImageSrc(mtl_name, image_url)

You can see it being used here

Copy link
Member

Choose a reason for hiding this comment

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

thanks and all my apologies for not finding it myself, I blame github online search (couldn't find it), and my VSCode search that is configured to search only the "Sources" folder. My bad

Copy link
Collaborator

Choose a reason for hiding this comment

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

No worries and sorry for not providing that info sooner, but still pretty busy on trame v2.

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

3 participants