archilogic-com / 3dio-js

JavaScript toolkit for interior apps
https://3d.io
MIT License
275 stars 73 forks source link

Design API for custom materials in a-frame component "io3d-data3d" #15

Open frederic-schwarz opened 7 years ago

frederic-schwarz commented 7 years ago

End goal: Allow people to assign custom materials & textures to io3d-data3d entities. Components: io3d-data3d

After @tomas-polach asked an important question during #4, Madlaina brought up the question how we would do this for io3d-data3d.

The possibility to change textures and colors on materials is opening up many possibilities, e.g. changing the diffuse map without having to change the lightmap allows more dynamic materials without needing to re-bake.

The outcome should fulfill the following criteria:

Kasparlogic commented 7 years ago

This has relevance for Home Story as we would like to change the materials in a backed model

Aadjou commented 7 years ago

Following problems need to be solved to make material editability on baked models a good experience for users:

of course we can already offer editability before solving this issue. but for user experience I recommend that this should be adressed.

@Kasparlogic @frederic-schwarz @AVGP we should probably discuss this soon in a meeting

Kasparlogic commented 7 years ago

@Aadjou yes please, taking it to slack

tomas-polach commented 7 years ago

updated title to be more specific (considering that not all issues are related to a-frame components)

tomas-polach commented 7 years ago

btw. any updates on this one?

urish commented 7 years ago

I'd also love to have this, as the current workflow really slows down prototyping, having to wait for the bake process to complete whenever I make even the slightest change to the material configuration. Please make this happen 👍

tomas-polach commented 7 years ago

@Aadjou thx for pointing this out. another solution proposals:

regarding the material mixup after baking: i suggest to introduce a "Do not optimize model" checkbox in lighting tab. this would result in optimizing function not being used, keeping the original material structure in place. doing this on a material level in the editor would be quite exhausting because we do not have a multiselect feature.

tomas-polach commented 7 years ago

API design proposal for embedded material definitions:

<style type="text/data3d">
#house .wall27, .wall12 {
  diffuse-color: #0ee;
  diffuse-texture: url('https://...');
  specular-texture: storageId('/whatever...');
}
</style>

<scene>
  <a-entity id="house" io3d-data3d="url:http://..."></a-entity>
</scene>

@AVGP if i am not mistaking, style elements with custom type will not be parsed as CSS by the browser. (it works like that with the script element. scripts of custom type will be simply ignored). will jsfiddle it in a sec ...

https://jsfiddle.net/3dio/spv10272/ chrome, firefox and safari do not complain at all :) can anybody try IE pls?

tomas-polach commented 7 years ago

using CSS syntax would be cool:

tomas-polach commented 7 years ago

@urish what do you think?

urish commented 7 years ago

I'm not sure CSS would be the best way to go, see the following discussion:

https://github.com/aframevr/aframe/issues/1102

tomas-polach commented 7 years ago

@urish thx for your feedback.

to unblock you i wrote some example code using undocumented data3dView methods: https://codepen.io/tomas-polach/pen/rGVjbg?editors=1010

data3d__set_material

pls make sure to use the specific io3d.js version from the example (not the "1.x.x" dist URL) because the data3dView methods will most likely change in the future.

does that help you or did i miss something?

urish commented 7 years ago

Looks great, thank you!

tomas-polach commented 7 years ago

happy to help! would love to know what you are working on (...if it's not confidential)

urish commented 7 years ago

Sure, it is a VR Workshop for AngularConnect

tomas-polach commented 7 years ago

that's cool!!

this might be interesting for you as well: https://github.com/archilogic-com/aframe-gblock

allows to load google blocks models directly as components (material changes there work differently because its indexed buffergeometries with vertex colors) but you can get a lot of 3d content and build a cool scene pretty quickly

urish commented 7 years ago

Awesome, thanks! I love that :)

tomas-polach commented 7 years ago

proposal using a-asset-item as proposed by @frederic-schwarz in #94

support for custom materials could look like this:

  <a-assets>
     <a-asset-item id="my-mat" io3d-material="colorDiffuse: #fff; colorSpecular: #09f; mapDiffuse: texture1.jps"></a-asset-item>
  </a-assets>
<a-entity io3d-wall="h:2.4, l:3, material_front: #my-mat" position="2 0 -1" rotation="0 12 0"></a-entity>
tomas-polach commented 6 years ago

this is also relevant for the architecture toolkit: https://github.com/archilogic-com/3dio-js/blob/0191bf01071d07477d40b3fc631dc118038b7e23/src/scene/structure/to-aframe-elements.js#L373