Closed shamansir closed 7 years ago
This functionality is not reviewed by community, not needed for now and could be too exclusive for my case.
@shamansir just had an idea, it may be possible to send a blob url through ports to Elm and then load it as a texture. This may partially cover this use case.
...such as
canvas
,video
,svg
, even with animation.Adds
Texture.fromElement elementId
: load the DOM element content once and use it as a texture;Texture.fromElementWith options elementId
: same as above, but with options;Texture.fromDynamicElement <UseRAF | UseInterval interval> elementId
: load content from the DOM element and userequestAnimationFrame
orsetInterval interval
to ask for the content again and update the texture;ElementNotFound
error;Adds
dynamic-texture.elm
example, which is just a copy ofcrate.elm
, with few changes:Caveats
canvas
,video
itself... The reason is:collage
fromevancz/elm-graphics
is not allowing to set ID to thecanvas
itself, but its wrapper;minify = linear
options is currently forced to be set, or else WebGL fails to render such elements (actually it just shouldn't be the defaultResize Smaller
);requestAnimationFrame
/setInterval
in large amounts;div
), then the error is just reported to console and not returned to the Elm code, since it is fired duringcreateTexture
call;requestAnimationFrame
/setInterval
calls used to update it.Motivation
Usually the source element is hidden, so it’s quite a useful method. For example, I need to show a video in a texture, others also use this method to display text in 3D with almost no hardware tension. Or to add shader-based effects to HTML components, see http://htmlgl.com/.