Comments (8)
from twgl.js.
I know, breaking changes are distressing. I'm not sure I can think of a way to fix this without it though.
I'm guessing the reason you added it was in case someone provided data as an array or left it out? Whatever the change, I think there needs to be a way to provide the missing info if it can't be inferred.
Might I suggest changing type
to usage
, since I think that's what's in the WebGL official spec. Also, if you add usage
, you can deprecate type
for now and make a minor version upgrade instead of having to move to v6 right away.
What do you think?
from twgl.js.
Maybe I'm mis-understanding what's broken.
The type
in AttribInfo
is the type parameter of gl.vertexAttribPointer
twgl needs to figure out what AttribInfo.type
to use for a given array in createAttribsFromArrays
. The cases are
-
you passd in a
WebGLBuffer
In this case you tell it WebGL type via
type
-
you passed in a number (so a size you want the buffer to be, no data)
In this case size is in number of values so it looks at
type
and expects a typedArray constructor. If not set it assumesFloat32Array
. From that it sets theAttribInfo.type
to the corresponding GL type -
you passed in a typedarray
In this case it sets
AttribInfo.type
to the corresponding GL type -
you passed in a JavaScript array
In this case it converts the JavaScript array to a typedarray then goes to case 3.
Which type of typedarray can be specified by settingtype
. Otherwise it guesses
where the guess is eitherUint16Array
if the name is "indices" elseFloat32Array
I guess you're bringing up the issue that 1 is different from 2, 3, 4?
One way to make it it would be to make FullArraySpec.type
a union of gl type or typedArray constructor. Everywhere it wants a typedArray constuctor in the code, if you pass in a GL type it could look up the corresponding typedArray (cases 2, 3, 4). And via versa, if you pass in a typedArray constructor it would convert it to the corresponding GL type where needed (case 1)
That would not be a breaking change.
Or, I could change case 1 to use a different field. I see the FullArraySpec
docs don't list case 1. But it's called type
in the docs for gl.vertexAttribArray
Or, I could change type
to only ever be a GL type since like I said above, it's kind of silly for case 4, when you can just do data: new TypeIWant(...)
for the native array case.
from twgl.js.
This is one of those things where if I was using someone else's library, I updated to newest, and stuff broke, I'd be upset at the waste of my time. So my gut says to go with making type
a union and having either a GL type or a typedArray constructor since that's non-breaking, even if it's less "pure" than adding a new field. It's also argubly better in the sense that you can't make conflicting settings. In other words, if I add usage
then you can do this
{
something: {
usage: gl.UNSIGNED_BYTE,
type: Float32Array, // nonsense as usage is UNSIGNED_BYTE
data: [...],
},
}
I supposed that issue already exists
{
something: {
data: new Uint8Array([...]),
type: Float32Array, // nonsense, though this is ignored since data is a typedarray
},
}
from twgl.js.
My bad: usage is something else. I was distracted. You're right, it's type. Still, unfortunate that it's such an ambiguous name.
I think your assessment looks correct. However, my only issue with using a union is that it might imply that either value would work in any of those four conditions. I think that could be achieved, though, if you inferred the type from either a number, typed array constructor or the typed array itself first, and then within the conditions 1-4, use that type if needed. Make sense?
from twgl.js.
ok, uploaded v5.1.0
from twgl.js.
Awesome. Thank you again for your work. I'll take a look first thing tomorrow.
from twgl.js.
works great!
from twgl.js.
Related Issues (20)
- Dynamically changing attribute values, does it require to create bufferinfo everytime
- Last framebuffer's attached texture is empty? HOT 3
- Incorrect sentence structure.
- GPGPU particles example performance HOT 5
- resizeCanvasToDisplaySize in a web worker sets the width and height to 0 HOT 2
- Should not update the number of elements too HOT 1
- Question about simple triangle rendering HOT 1
- Defer checking shader compile status HOT 8
- Unsetting a texture in webgl2 HOT 3
- gl.useProgram(program); HOT 1
- bindTransformFeedbackInfo with offset HOT 3
- Get the jsdoc into the tsd HOT 2
- Incorrect TypeScript types of `createAugmentedTypedArray` HOT 2
- TEXTURE_COMPARE_MODE and sampler2DShadow HOT 4
- twgl-base package.json refers to non-existent `module` file HOT 2
- Cubemap uses only first texture HOT 3
- Rendering objects using drawObjectList causes skybox to not be rendered HOT 6
- `opt_locations` of createProgramInfo is missing from typescript bindings HOT 2
- webgpu support ? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from twgl.js.