Skip to content

Add 3d space#71

Merged
ai merged 29 commits intoevilmartians:v1.1from
muddv:3d-space
Mar 10, 2023
Merged

Add 3d space#71
ai merged 29 commits intoevilmartians:v1.1from
muddv:3d-space

Conversation

@muddv
Copy link
Contributor

@muddv muddv commented Feb 10, 2023

This solves the same problem as #69 but has a few additional features (and maybe some additional flaws):

  • JS bundle for 3d model is loaded only when “Show 3d space" button is activated, a loader is shown while the bundle is loading
  • If 3d model is displayed, this condition is saved in the url as ?3d
  • 3d model changes depending on "Show P3", "Show Rec2020" and "OkLch/Lch" settings
  • The size of added files is smaller, though this is somewhat counterbalanced by performance, because I do not save vertices.
  • I use a different layout in my implementation, although this, is of course, somewhat easy to fix
  • Model is generated using points, not solid surface. This also is easy to change.

I want to work on displaying currently active color from the 2d graphs on 3d model, along with several small fixes, although this will still take some time, maybe it can be done before one of the prs is in condition to be merged.
Maybe the best course of action is to work on this jointly, I hope this implementation has something to it.

@ai
Copy link
Member

ai commented Feb 10, 2023

Can you show a screenshot or screen recording (sorry, I am on the go to run PR locally)

@muddv
Copy link
Contributor Author

muddv commented Feb 10, 2023

The page looks like this:
image

@muddv
Copy link
Contributor Author

muddv commented Feb 10, 2023

Additionally:
Medium screen layout:
image
Small screen layout:
image

.card_range
+range('a', ALPHA_MAX, ALPHA_STEP, 100)

else if type === 'model'
Copy link
Member

Choose a reason for hiding this comment

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

Let’s remove the card and just add the model above the cards. We will find another spot.

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 moved the card to the model's mixin. I think some there are few more small changes that can be made to make css and page structure more consistent. Working on it

@ai
Copy link
Member

ai commented Feb 11, 2023

Can you rebase to the main to fix pnpm audit error?

@ai
Copy link
Member

ai commented Feb 11, 2023

There is a problem with a model. Did you create from set of slides?

Captura desde 2023-02-11 02-22-42

@muddv
Copy link
Contributor Author

muddv commented Feb 11, 2023

Can you rebase to the main to fix pnpm audit error?

Resolved it. This reveals a problem with package size limit. Correct me if I'm wrong, it measures all scripts, including 3d. But if 3d is disabled, in network tab the size is almost the same as in main branch. Maybe a different test condition can be made as opposed to simply increasing size limit.

@muddv
Copy link
Contributor Author

muddv commented Feb 11, 2023

There is a problem with a model. Did you create from set of slides?

What kind of problem do you mean exactly?
The model is made up from points converted from rgb (p3 rgb etc.).
If you mean that bottom is not solid, there are some fixed that can be tried.

@ai
Copy link
Member

ai commented Feb 11, 2023

Resolved it. This reveals a problem with package size limit. Correct me if I'm wrong, it measures all scripts, including 3d. But if 3d is disabled, in network tab the size is almost the same as in main branch. Maybe a different test condition can be made as opposed to simply increasing size limit.

Yes. Can we set some prefix for the 3D bundle and move it out of Size Limit check by something like !plot-*.js?

@ai
Copy link
Member

ai commented Feb 11, 2023

What kind of problem do you mean exactly?

The problem is that the space doesn’t look like a solid structure in the bottom.

@ai
Copy link
Member

ai commented Feb 11, 2023

There is still a problem with solid structure in the bottom (screenshot from latest commit)

Captura desde 2023-02-11 17-56-57

There is also a problem with moving rotating space by mouse. Looks like the rotation center is not in the center of the space.

Captura desde 2023-02-11 17-57-59

Also, current space is very small. Can you make it bigger and put just above all card (we anyway will not keep it as small card)?

@ai
Copy link
Member

ai commented Feb 11, 2023

A few other problems:

  1. There is no keyboard control of the space rotation.
  2. P3/Rec2020 toggles to break the current position of the space (space is going to origin position).

@muddv
Copy link
Contributor Author

muddv commented Feb 11, 2023

There is still a problem with solid structure in the bottom (screenshot from latest commit)

Yes it was kind of a quick hack, I want to adjust point generation math further to make it look better.

P3/Rec2020 toggles to break the current position of the space (space is going to origin position)

I think this can be paired with syncing the current position on the 2d charts with 3d space

Also, current space is very small. Can you make it bigger and put just above all card (we anyway will not keep it as small card)?

Can 3d space take up position of current LCH charts + settings on large screen? I think it can look good this way.

for (let z = 0.01; z <= 1; z += 0.01) {
let rgb: Rgb | P3 | Rec2020 = { mode, r: x, g: y, b: z }
let color
LCH ? (color = lch(rgb)) : (color = oklch(rgb))
Copy link
Member

Choose a reason for hiding this comment

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

@ai
Copy link
Member

ai commented Feb 14, 2023

Yes, we fixed the problem with solid surface of the model. What we still have:

  1. Strange ; file
  2. Bad mouse control. Seems like rotation center is out of the model.
  3. We can zoom too close (need to add limit).
  4. The bottom of surface looks wrong.

How it looks now:
Captura desde 2023-02-14 20-27-24

How it should look (like Hue graph on C=0):
Captura desde 2023-02-14 20-29-18

@ai
Copy link
Member

ai commented Feb 15, 2023

Next changes to fix:

  1. P3/Rec2020 checkbox should not reset zoom and position.
  2. The rotation control is not very easy. Seems like rotation center is not inside the model and controls are not very intuitive (compare to globe on sitnik.ru)
Grabacion.de.pantalla.desde.2023-02-15.18-21-51.webm

@muddv
Copy link
Contributor Author

muddv commented Feb 15, 2023

I think most of the issues mentioned previously are fixed.

  • I moved object to the center and controls feel better now. We can also add keyboard controls. Should we use arrow keys or wasd or something else?
  • LCH model is currently broken, working on a fix if we need it.
  • Camera needs to stay in the same position if user regenerates objects by clicking 'Show Rec 2020' for example
  • Obviously something needs to be done about styling

Is there anything else major that I'm missing?

@muddv
Copy link
Contributor Author

muddv commented Feb 16, 2023

Camera position is now remembered between renders. It would be easy to also add it to url if ?3d is included. Would it be a good idea to add it?

@ai
Copy link
Member

ai commented Feb 21, 2023

While we are waiting for design, can we add a current slices to the space?

@ai ai changed the base branch from main to v1.1 March 10, 2023 16:41
@ai ai merged commit 006a083 into evilmartians:v1.1 Mar 10, 2023
@ai
Copy link
Member

ai commented Mar 11, 2023

@muddv here is a preview of design on top of your feature:

https://ai-oklch--pr85-v1-1-znr8xs52.web.app/#70,0.1,128,100

Do you have Twitter account to mention you in release tweet?

@muddv
Copy link
Contributor Author

muddv commented Mar 12, 2023

Looks great, thank you!
My twitter is @null_preference, would appreciate a mention!

ai added a commit that referenced this pull request Mar 14, 2023
* Resolve merge conflict

* Add 3d space condition to url

* Dynamic import for model script

* Move model to top

* Fix model not loading when ?3d is in url

* Move model event handlers

* Adjust layout for different screens

* Add loader

* Tune camera and model generation settings

* Hide model canvas when 3d space is disabled

* Fixes: model card, unnecessary then

* Resolve merge conflicts

* Infer loader type from selector

* Increase solidity of gamut's bottom

* Convert grid to 2 letters

* Resolve merge conflict

* Move model to top

* Exclude 3d model from size limit test

* Fix model generation for LCH

* Fix grid

* Change model generation to make it solid

* Make 3d space canvas visible

* Delete unnecessary file

* Refactor model generation, fix control center and bottom surface color

* Fixes: add hash to model chunk, remove unneded async

* Fix model generation for LCH

* Save camera position between renders

* Adjust controls

---------

Co-authored-by: Andrey Sitnik <andrey@sitnik.ru>
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.

2 participants