LasseD / buildinginstructions.js

Render LEGO building instructions in the browser using three.js
The Unlicense
115 stars 31 forks source link

Change the model locally #29

Closed urllib2 closed 4 years ago

urllib2 commented 4 years ago

Hi, I manage to run "sample_instructions.htm" with the default model. I want now to try another mpd locally. I change the line "var model = 'models/corvette_full.mpd';" by "var model = 'models/genbot.mpd';" and I place the file genbot.mpd in the models folder. I tested then the building instructions but it showed the old model. How should I proceed in order to see my own model? Thanks

LasseD commented 4 years ago

It sounds like it caches the instructions. Try to replace the ‘#’ literal in the LDR.InstructionsManager parameters with model.

If this works, then I will update the sample file similarly.

urllib2 commented 4 years ago

I deleted the caches and I reloaded the page but it didn't work. I also replaced the parameter # in LDR.InstructionsManager with models/fll_solve.mpd and it failed one more time. I attached the log with this message. log.txt

Thanks

LasseD commented 4 years ago

Thanks for the detailed bug report. I discovered an issue with the persistence code that writes to Indexeddb - it would fail when attempting to save instructions before all parts are loaded. This has been fixed in the latest push to master.

This can be disabled altogether by removing the parameters "key" and "timestamp".

Does it work now with the latest version of the code?

urllib2 commented 4 years ago

Hi, I pull the code but it didn't work even when I remove the parameters "key" and "timestamp" I tried another model from a folder "models/glitter.ldr" and I attached the log file. log.txt

LasseD commented 4 years ago

The only issues I see in the log are related to storing in the indexeddb. I have pushed a new commit to master where the file js/ClientStorage.js is optional. Try to run the sample_instructions.htm page where the js/ClientStorage.js line has been removed.

Unfortunately I have been unable to recreate any issues, but this might give us some hints at what is going wrong with your setup.

urllib2 commented 4 years ago

Hi, I pulled the code source and retry without the js/ClientStorage.js It seems that that the problem of indexeddb is no longer there. However, there is an issue now with purgePart. This is the log: log.txt

LasseD commented 4 years ago

I have updated the Javascript source in the latest push to master, so that purgePart now no longer throws an error when it encounters parts that are not loaded. This should remove the error you see, but I am still worried about you getting the error in the first place: purgePart is called when empty LDraw models are encountered. There are no empty models in the sample files that you mention.

Does it work now?

urllib2 commented 4 years ago

Finally, the last modifications succeeded to show the model! I downloaded this one https://brickhub.org/i/352 but when I go through the steps but log there are some missing steps like step 6, 9, 17... The logs show a problem with the property "startsWith".

LasseD commented 4 years ago

Thanks again for the feedback. The issue you see there is caused by missing descriptions of parts. I have fixed this in the latest push to master.

urllib2 commented 4 years ago

Thank you man, you made my day! I tested with the model above with the new update and it worked like a charm. However, when I put my own model something weird happened in the display. There is an imperfection in the pieces. Is it an issue relative to design? I use MLcad to build the robot. Any idea, please? Assemblage.zip brik moteur

LasseD commented 4 years ago

This is caused by the rotation matrices in your model having negative determinants, thus causing triangles to be inverted.

You can fix this on lines 2113 and 2114 in LDRLoader.js by switching which of the two lines that are commented out:

            //mesh.geometry.applyMatrix(m4);
            mesh.applyMatrix(m4); // Doesn't work for LDraw parts as the matrix needs to be decomposable to position, quaternion and scale.
urllib2 commented 4 years ago

Outstanding tip! I can visualize my model now. Thank you very much.