Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Andrew Ray
@andrewray_twitter
in order to apply a multimaterial by passing in two material id strings, i'm going to hook into that in my component and find the material
obviously a hack but don't know yet how terrible
Firtina Ozbalikci
@toxicFork
I think a more sane but more manual way would be to use refs instead...
Andrew Ray
@andrewray_twitter
refs to what?
the two materials I want to use?
Firtina Ozbalikci
@toxicFork
Ref to the object that you want to use the materials in, then add them in manually
Andrew Ray
@andrewray_twitter
indeed, but I want to re-use the same string materialId paradigm my level editor already supports, so what i'm passing in is a material
Firtina Ozbalikci
@toxicFork
Hmm
Could hack it somehow yes :D
Like inject the multi materials as the array? (...)
Andrew Ray
@andrewray_twitter
something like <Wall materialId1="brick" materialId2="stone" /> with the main takeway being i'm using strings for mat ids, and those mats exist in my resources
i'm going to manually construct the MultiMaterial in the component
I just don't want to re-make how I look up textures/shaders in the component, which I already have available in the resources
Andrew Ray
@andrewray_twitter
Parent already has a material defined !
i'm assigning this.refs.child.refs.mesh.material =
does that conflict with r3r?
Firtina Ozbalikci
@toxicFork
Argh, r3r being too possessive
Andrew Ray
@andrewray_twitter
I could make the mesh entirely in didMount
Firtina Ozbalikci
@toxicFork
yeah that may need to be necessary :(
Andrew Ray
@andrewray_twitter
multi-material.gif
multi material worked :)
Firtina Ozbalikci
@toxicFork
:clap:
i love the dynamic parts of the scene, lively!
so did you create the mesh entirely?
Andrew Ray
@andrewray_twitter
yeah =\
Firtina Ozbalikci
@toxicFork
not too bad!
if it works, that's good!
Andrew Ray
@andrewray_twitter
i've also started doing this, doing updates entirely in shouldUpdate and blocking render https://gist.github.com/AndrewRayCode/06a05b8a533d4b41d425ec86fbffa66f
Firtina Ozbalikci
@toxicFork
is this for perf purposes
or because multi mats are not supported?
Andrew Ray
@andrewray_twitter
for perf
Firtina Ozbalikci
@toxicFork
hmm!
Andrew Ray
@andrewray_twitter
it seems like one call to React.createElement is a lot of fn calls under the hood, maybe 10-20 before it even gets to the next shouldComponentUpdate
Firtina Ozbalikci
@toxicFork
yeah... :/
Andrew Ray
@andrewray_twitter
huge stacks every time nested react elements are rendered, and that's my app's main bottlneck
Firtina Ozbalikci
@toxicFork
i'm probably going to write a "compile react to non-react" project soon
Andrew Ray
@andrewray_twitter
reducing the number of times the code gets to createElement is a hack i'm trying to preempt that
interesting
Firtina Ozbalikci
@toxicFork
like, it'd extract components to non-react objects and do the updates directly
LOTS of magic
need to still wrap state and handle nesting etc, gonna be... fun.
Andrew Ray
@andrewray_twitter
in my case, 99% of my scene updates are using the same jsx structure, I just need to update props. setting up the whole scene graph in react is great, but then it's not needed until something is added or removed
Firtina Ozbalikci
@toxicFork
yeah :)
I'm thinking somehow to couple state and render more directly, and then from that coupling extract a render graph out and skip createElement entirely
super hard to describe, but may be worth it
long story short: "react is great for development but can be improved a lot for production"
(also need to sell the idea to facebook :D)
Andrew Ray
@andrewray_twitter
haha
Firtina Ozbalikci
@toxicFork
i have to use windows WPF for one project, and.. the xaml stuff is "quite close to react" but I'm missing the dynamic parts :p
sadly XAML is more like angularjs than react :violin: