Skip to content

Texture problem with detached DOM elements #26

Open
@jgottero

Description

@jgottero

When you create a texture from a DOM element, for example a canvas, if this element is not attached to the document, the texture will not work.

The reason is texture size is read from the element's offsetWidth/offsetHeight properties, and these properties are always 0 for DOM detached elements; hence texture size will be (0,0).

            boolean isImagePowerOfTwo = Mathematics.isPowerOfTwo( image.getOffsetWidth() ) 
                    && Mathematics.isPowerOfTwo( image.getOffsetHeight() );

(NB: I pasted these few lines of code but same problem in others methods.)

Three.js read width/height properties instead, which is nice because you must fill these properties when you create a canvas to use it as a texture; thus you dont need to attach the canvas to the document.
One possible solution would be to first read width/height properties, then having a fallback on offsetWidth/Height (I can provide a patch if you wish and if you agree on this solution).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions