cubing / cubing.js

🛠 A library for displaying and working with twisty puzzles. Also currently home to the code for Twizzle.
https://js.cubing.net/cubing/
GNU General Public License v3.0
241 stars 44 forks source link

Java Applet Replacement #32

Open lgarron opened 12 years ago

lgarron commented 12 years ago

Implement a decent set of parameters that make it posible and worthwhile to switch out AnimCube and Randelshofer's appplets for three.js on cube pages. Ideally, this should be able to handle tons of twisties on a page (achievable by flattening the twisties per cubing/twisty.js#12 while not active).

jfly commented 12 years ago

Sounds cool. I don't think you should have to

How much do you actually gain by flattening the twisites? If nothing is being done to the twisty, I imagine no additional cpu will be used. I suppose we'd save in terms of memory usage. How much space does an instance of a twisty actually take up?

Here's the memory usage for N 3x3 cubes according to chrome (in kilobytes).

1 25,800 2 26,900 3 27,140 4 32,284 5 32,472 6 36,036 7 36,268 8 36,740 9 37,616 10 37,784 11 38,000 12 38,200

I have a bunch of tabs open, and my browser has been running for a while. This is by no means a proper study. I can't explain the 4 megabyte jump going from 5 to 6 cubes. Maybe chrome allocates large chunks of memory at a time? That doesn't explain the 200kb increases though... Either way, it doesn't look like a twisty instance is really all that much memory. Flatenning might not make any sort of a noticeable difference until you get up to 1000s of cubes on a page.

lgarron commented 12 years ago

Good point. We should keep an eye on memory, though, and any related symptoms.

jfly commented 12 years ago

Aye aye. I definitely had one issue where something I thought was getting deleted wasn't. I don't know anything about checking for memory leaks in javascript, but if there's some way of doing that, we probably should.

lgarron commented 3 years ago

I did a prototype of this for AnimCube at: https://experiments.cubing.net/cubing.js/applet-wrappers/AnimCube/

It's actually quite usable!