Closed zepumph closed 4 days ago
This was quite a challenge, and I will describe my findings in this comment. And afterwards, the preliminary patch of these changes.
LonePairGeometryData.js
which in a way imports geometry data from a file called balloon2.obj
(multiple files but that's not important).obj2three.js
node script. That one was also eventually deprecated and the current way of doing this is quite different, but by downloading r86 and running that script we got it to work. Not great, but not terrible. (commit above updates balloon2-README.txt
and links to this issue)The following patch sloppily implements this, without the actual duck geometry. We still have to figure out how to get the physics body vertices working, as well as the transverse area (projection?). @zepumph and I are on this.
Latest duck file :) (164KB)
Update: Tried to test the new duck data but the patch was really outdated and had to merge new changes.
Here's a more up to date patch, but not entirely fixed as there are some assertions I couldn't get through:
Update patch + a few files were committed
@zepumph git-hooks are failing, so I regenerated the density API file in https://github.com/phetsims/phet-io-sim-specific/commit/d55438c197914e1b30415c30ee8ce46454bad151. How did this get past git-hooks?
density BREAKING PROBLEMS
Type missing: EnumerationIO(BLOCK|ELLIPSOID|VERTICAL_CYLINDER|HORIZONTAL_CYLINDER|CONE|INVERTED_CONE)
density DESIGN PROBLEMS
New PhET-iO Element not in reference: density.general.model.strings.densityBuoyancyCommon.shape.duckStringProperty
Right. Thanks @pixelzoom for the commit.
We are also going to want to figure out how best to support migration problems with Density. That sim doesn't have a duck, but MassShape does, and adding that entry to the EnumerationIO has made a bunch of changes to the API (see above). I don't know that we want to have that in Density, but also it isn't clear what is the easier path (let alone desirable).
Been investigating into creating the Duck's flat geometry and it's been way more complicated than I anticipated. The following are a couple of patches that get this (sort of?) working. Sort of because they either clip through the floor, or depend on hard computed numbers, or raise assertions, or are a convex hull and not the concave duck shape.
I think the most successful one is the second, but it didn't get the accurate duck geometry.
For reference, here are the two patches side by side... The first one is misleading, because to get that to work, it was like an hour of wrestling the geometry data and literally writing a recursive python script to sort the points (and then sort some manually) to get it to behave like a good polygon. The second one is just auto generated from the duck geometry.
After talking with @zepumph it seems the first duck shape is preferrable, in spite of the difficulty to replicate, which I'll describe here briefly before moving all these steps into its own documentation file.
Goal: Get from the 3D duck mesh into a 2D projection of it we can use in the p2 model. Difficulty: It's not as easy as it seems. 3D to 2D projection algorithms apparently work really well with convex shapes, but not with a shape like the duck. Disclaimer: There's likely and hopefully easier ways to achieve this, and it's probably worth asking in the internet or to other devs (@jonathanolson maybe). But for now this is the best way I could get it working. Discussion and advice is welcome. Steps:
@DianaTavares please review.
Will be looking into a remaining duck dancing bug in https://github.com/phetsims/buoyancy/issues/148
Sorry, I forgot to answer this issue!! Well, the duck is super cute!! But @AgustinVallejo needs to review the volume because now it is very small. Comparing the duck with the bigger Block, looks like the duck needs to be less that 10L, probably like 5 to 7?
@DianaTavares and I decided to hollywood the Duck's displayed volume to be 5L at maximum.
From the design meeting today, we humored the idea of having an extra, irregular shape on the shapes screen. A duck seems like an obvious choice, but we will want to do some investigation to see how hard it would be. @AgustinVallejo mentioned that he knows enough about blender that it isn't automatically out of the question to use our own custom mesh for this.