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

How to properly add OBJ files #244

Open
Philip2809 opened this issue Jul 14, 2021 · 0 comments
Open

How to properly add OBJ files #244

Philip2809 opened this issue Jul 14, 2021 · 0 comments

Comments

@Philip2809
Copy link

Hello!

I am working with this library and I like it, it's really good, but it has its flaws. If you feel like adding an OBJ file you have to remember a couple of things, first of all, import them into blender or something similar and triangulate the OBJ file, in blender you add a "modifier". You will get a MTL file created with your OBJ file, this if for if you have any materials and their colors, if you don't want to add the colors this way but instead set the colors via the addOBJ commands options you can edit your OBJ file and remove the "mtllib" line, and then you don't have to worry about the mtl. If you wish to use them MTL for different materials and colors there is something you have to know. It only takes the color and nothing else as far as I know and can see from the code. the line Kd (r, g, b) in the MTL file. (and the material name ofc ('newmtl') )

There is also a bug in the current code that makes it so when you add your MTL but no options.color the color will be black, this is because it reads [undefined, undefined, undefined] as the color. If you have a options.color it will use that, this is because an array with undefined's is not read as undefined, so to fix this, open the features.workers.js and find 'processOBJ', then make 'optionColor' into a let (so you can change it) and add this:
if (optionColor[0] === undefined) {optionColor = undefined; }

After editing it should look like this:

    items = [],
    position = options.position;


  // If there is no options.color optionColor will be a array full of undefined
  // and when that happens it still picks that as a valid option at 'color = optionColor || ...'
  // and then we just get a black OBJ. 
  let optionColor = Qolor.parse(options.color).toArray();
  if (optionColor[0] === undefined) {optionColor = undefined; }

I also removed the DEFAULT_COLOR from 'color = ...' because it was just undefined.

After these changes it should be working, I know there might be better ways to write this, but this works at least.

Questions for the owner of OSMB:

  • Is trancparancy something that might be added in the future?
  • Why is there like no documentation on this library?
  • Is there any way to nicely disable shadows or the thing that makes the sunlight be different of different parts of a OBJ and if you can't disable shadows how to make them NOT follow the time of day? In other words, how to make the lighting the same no matter what time it is? I realized the lighting and shadows are calculated based on the time on the computer.

If you have any questions feel free to comment below, and if something does not work for you or you need help, do the same!

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

No branches or pull requests

1 participant