Closed hmans closed 3 years ago
Would it be preferable to explore a syntax like <three-scene camera-id="#camera" />
?
Would it be preferable to explore a syntax like
<three-scene camera-id="#camera" />
?
I was going with that first, but it clashes with the heuristics that are already in place. In this example, right now camera-id
would translate to a cameraId
property on the wrapped object. If we handle -id
suffixes ourselves, we would face a problem if there ever is a Three.js property named *Id
that we need to set.
Prefix directives solve this cleanly because they don't clash with any existing heuristics or systems. The part where I'm not convinced that they're a good idea is that I wasn't planning on going all "frameworky" with three-elements, and this is definitely a step into that direction.
What's in this PR?
attributeChangedCallback
implementationsThreeScene.backgroundColor
now can be set via<three-scene background-color="...">
. Properties need to be white-listed via the newexposedProperties
static property.<three-scene ref:camera="#cam">
. This is necessary because some frameworks (like Preact) will automatically assign the attribute value directly to a property of the same name if that property exists, which would require us to perform the resource fetching within each of those properties. Directive solve this in a clean fashion, even if it requires folks to write a few more characters.position.x="5"
). The colon syntax is no longer supported, since we're now using colons for directives.Open questions / to decide / todo:
exposedProperties
static property, which acts as a whitelist. applyProps will check the list contained in this property before assigning to a property.ref:...
a good name for a reference directive?applyProp
to make directive support more stable (right now, a "ref" in the middle of a property name chain would be picked up as a directive, woops)applyProps
test to test applyProp specificallyCOMPLEMENTARY KITTEN: