three.js icon indicating copy to clipboard operation
three.js copied to clipboard

Editor: Project assets management

Open dineshsalunke opened this issue 4 years ago • 30 comments

Description

Problem

Since there is no single place for loading texture in editor, we currently have to load texture's explicitly where ever needed. This causes duplication of resources. for example : If I have 3 materials on which I want to use same diffuse map I have to load that image on the map for every material individually, this causes causes 3 textures and 3 images to be created and then assigned which is inefficient.

Proposed Solution I propose to solve this issue in 3 steps.

  1. Add functionality to import textures using the import option in the file menu.
  2. Add dedicated texture's panel in the sidebar project section in order to manage the texture.
  3. Texture slots ( material maps and scene background etc ) to show an option to select the texture for the loaded list.

Regarding the above 3rd point I am completely not sure on how the ui or the interaction will work. A rough Idea I had was to another select / dropdown components besides the map preview slot, in which we can list all the existing textures.

Also I am planning to add a texture panel besides the material panel in sidebar. It can be helpful in configuring the textures like setting encoding, tilling etc.

dineshsalunke avatar Feb 27 '21 01:02 dineshsalunke

Here is a very crude and quick mockup of the idea for texture panel

image

dineshsalunke avatar Feb 27 '21 02:02 dineshsalunke

Also I am planning to add a texture panel besides the material panel in sidebar.

I think this is the wrong place. The UI for this needs to be placed elsewhere since your marked place is object sensitive. Meaning it shows information depending on the selected 3D object.

Since there is no single place for loading texture in editor,

This also true for materials. Generally speaking, the editor needs the ability to manage resources independently from added 3D objects. So you have a place where you can create, edit and delete materials and textures. In the sidebar highlighted in the above screenshot, you can then select existing materials and resources from select boxes.

Mugen87 avatar Feb 27 '21 09:02 Mugen87

How about having a bottom bar, some sort of assets panel it will solve both the issues with the materials and textures

dineshsalunke avatar Feb 27 '21 16:02 dineshsalunke

Yes, that could be a possible approach.

Or the a material and textures panels are placed inside the Project tab because they represent in some sense the project's assets. Unity's project window does it the same way.

BTW: There was an initial material browser in the editor however it is not integrated in the view anymore since last release (see e5139eb6d699c7e17dab669771007eb971d6a0a4).

Mugen87 avatar Feb 27 '21 17:02 Mugen87

Or the a material and textures panels are placed inside the Project tab because they represent in some sense the project's assets. Unity's project window does it the same way.

Yeah that's a possibility but extra switching of tabs feels too much. But that's what I feel, if others don't mind it then we can surely go with that approach.

BTW: There was an initial material browser in the editor however it is not integrated in the view anymore since last release (see e5139eb).

Yeah that was by me as well :)

dineshsalunke avatar Feb 27 '21 18:02 dineshsalunke

Ok here is something I thought of,

image

Materials and Textures as a TabbedPanel in the project pane.

So the idea is that selecting the texture in the texture list will show texture option below the list, will make a quick draft on that as well later

dineshsalunke avatar Mar 03 '21 03:03 dineshsalunke

@mrdoob I noticed you had disabled the material panel, any specific reason to do this. I am asking coz I am enabling it back again in this PR if its ok.

dineshsalunke avatar Mar 03 '21 03:03 dineshsalunke

Ok here is something I thought of,

image

That is looking good!

We'll need a geometries tab too 💪

mrdoob avatar Mar 03 '21 10:03 mrdoob

Yes we can have that. I am only concerned about storing this data in indexed db, since its going to be huge

dineshsalunke avatar Mar 03 '21 11:03 dineshsalunke

I am only concerned about storing this data in indexed db, since its going to be huge

Lets keep things simple and not store this in indexed db. If the tab reloads and the geometry/material/texture has not been added to the scene we'll have to lose it for now.

mrdoob avatar Mar 03 '21 11:03 mrdoob

Then where do you want to store this data ? Editor class already has a map for the textures, materials and geometries ( Only materials is maintained for now though ) and editor.toJSON() already converts all this and saves it back to indexed db

dineshsalunke avatar Mar 03 '21 12:03 dineshsalunke

We skip adding texture to editor texture hash if user loading the same image file. This will be decided based on the image filename.

@mrdoob and @Mugen87 any thoughts on this.

For now importing same image file a 100 times loads 100 textures in the editor texture hash

dineshsalunke avatar Mar 04 '21 03:03 dineshsalunke

For testing: https://raw.githack.com/dineshsalunke/three.js/editor-texture-panel/editor/

mrdoob avatar Mar 04 '21 15:03 mrdoob

UI feedback:

We don't need to add a title to the section. We can already see we're in the TEXTURES tab. Screen Shot 2021-03-04 at 3 36 22 PM

mrdoob avatar Mar 04 '21 15:03 mrdoob

yeah I did feel that as well, I will remove it

dineshsalunke avatar Mar 04 '21 15:03 dineshsalunke

Editor class already has a map for the textures, materials and geometries ( Only materials is maintained for now though )

Yes, lets use these for now.

mrdoob avatar Mar 04 '21 15:03 mrdoob

I am already using that to store the textures right now

dineshsalunke avatar Mar 04 '21 15:03 dineshsalunke

What about this

We skip adding texture to editor texture hash if user loading the same image file. This will be decided based on the image filename.

dineshsalunke avatar Mar 04 '21 15:03 dineshsalunke

Why would someone import the same image 100 times?

mrdoob avatar Mar 04 '21 15:03 mrdoob

@mrdoob Added a properties panel to update the texture. it visible when selecting the texture in the list

For now I have only added label's. this is to confirm if this route is ok. If it's ok then I will move forward and complete the implementation

https://raw.githack.com/dineshsalunke/three.js/editor-texture-panel/editor/

dineshsalunke avatar Mar 07 '21 05:03 dineshsalunke

@mrdoob I have only included the bare minimum props for the texture in the texture panel for now. If you feel something else is needed let me know

dineshsalunke avatar Mar 17 '21 04:03 dineshsalunke

BUMP

dineshsalunke avatar Mar 30 '21 03:03 dineshsalunke

Wow, I just saw the textures panel.

Screenshot 2021-03-30 at 21 00 04

Impressive!

mrdoob avatar Mar 30 '21 20:03 mrdoob

I'll have to think about this...

For the time being, could you remove the line under the tabs?

Screenshot 2021-03-30 at 21 00 04_

So it looks like this:

Screenshot 2021-03-30 at 21 00 04__

mrdoob avatar Mar 30 '21 20:03 mrdoob

If you don't me asking, what would you like to think about.

dineshsalunke avatar Mar 31 '21 16:03 dineshsalunke

Hmm, I need to think about the UX...

If we do this for textures, we would have to do the same for materials and geometries, which means that we would have duplicated functionality.

mrdoob avatar Mar 31 '21 19:03 mrdoob

After this PR I was gonna go for that change as it is.

Also just a crazy thought, at some point I thought of creating a generic properties inspector panel. :D

dineshsalunke avatar Apr 02 '21 03:04 dineshsalunke

Added a preview for the texture, not the best UI but does the job. image

Hmm, I need to think about the UX...

If we do this for textures, we would have to do the same for materials and geometries, which means that we would have duplicated functionality.

any update on this ?

dineshsalunke avatar Apr 29 '21 04:04 dineshsalunke

@mrdoob a quick question, why don't we have the assets panel at the bottom on the window ? Is there any reason why all the things are implemented and pushed in the sidebar ?

image

dineshsalunke avatar Apr 29 '21 04:04 dineshsalunke

@mrdoob @Mugen87 I have extracted the textures panel code in a separate standalone component, we could do this for the material panel as well and reuse it where ever needed, your thoughts ?!

dineshsalunke avatar May 12 '21 04:05 dineshsalunke