stackgl / gl-texture2d Goto Github PK
View Code? Open in Web Editor NEWWebGL texture wrapper
Home Page: http://stack.gl/gl-texture2d/
License: MIT License
WebGL texture wrapper
Home Page: http://stack.gl/gl-texture2d/
License: MIT License
Currently createTexture2D
checks if provided texture object is some kind of image data by doing following checks
if(obj instanceof HTMLCanvasElement ||
obj instanceof HTMLImageElement ||
obj instanceof HTMLVideoElement ||
obj instanceof ImageData) {
that prevents us from suppling valid texture object in non browser environment like Plask.
I've run into this issue while trying to use gl-sprite-text in pex and even though i have texture wrapper passing this test:
if(obj.shape && obj.data && obj.stride) {
it breaks because of the DOM classes.
Is it possible to have a texture that is a playing video? I am trying to use this as part of gl-transitions and i can render 2 videos via a texture but it only grabs the first frame of each. I am waiting for the on play event etc. What am i missing?
This seems to be causing issues with gl-audio-analyser
stackgl/gl-audio-analyser#1
Because the bind()
calls in setPixels
is not necessarily going to be the same active unit as the user requests with tex.bind(n)
, it seems like it is causing some issues. I didn't realize this but according to the spec, the two seem tied somehow:
glTexImage2D specifies a two-dimensional or cube-map texture for the current texture unit, specified with glActiveTexture.
currently is 1.0.0, but latest version is 1.1.0
My code looks like this:
var image = require('baboon-image')
var tex = require('gl-texture2d')(gl, image)
And the image is stored on the GPU sideways. Seems like an unusual way of doing things. Any reasoning for this? Version 1.0.1
doesn't present this problem.
EDIT: Seems to happen on the example in the readme, too.
It would be nice to have a way of simply uploading a typed array without having to rely on DOM images or depend on ndarray just to do so.
EDIT: hmm, since gl-texture2d already relies on ndarray I guess this approach wouldn't make any difference in bundle size. Not such a huge deal, but I'm sure others will come looking for this feature
Hello!
I'm trying to load raw pixel data into a texture2d using node-sharp's raw data output and am having trouble getting it to work consistently. The following code works on some images (RGBA in my tests) but fails on others (some RGB images), so I'm guessing I'm doing something wrong with the translation of sharp's raw data output to ndarray/texture2d.
const createTexture = require('gl-texture2d')
const ndarray = require('ndarray')
const sharp = require('sharp')
module.exports = async (gl, filePath) => {
const {
data,
info
} = await sharp(filePath).raw().toBuffer({ resolveWithObject: true })
const array = ndarray(data, [
info.width,
info.height,
info.channels
], [
info.channels,
info.width * info.channels,
1
])
return createTexture(gl, array)
}
If I use the get-pixels
module (snippet below), everything works fine, but get-pixels
doesn't have as robust of image support (e.g., webp, random permutations of png/jpg settings that you find online).
const getPixels = require('get-pixels')
const util = require('util')
const getPixelsP = util.promisify(getPixels)
module.exports = async (gl, filePath) => {
const pixels = await getPixelsP(filePath)
return createTexture(gl, array)
}
I'm wondering if anyone has successfully used sharp
to load textures into gl-texture2d
or if I'm doing something obviously wrong with my translation of sharp
's raw data output to an ndarray
.
For reference, this is in Node via headless-gl.
Any help is greatly appreciated -- thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.