{"action":"created","issue":{"url":"https://api.github.com/repos/mrdoob/three.js/issues/9631","repository_url":"https://api.github.com/repos/mrdoob/three.js","labels_url":"https://api.github.com/repos/mrdoob/three.js/issues/9631/labels{/name}","comments_url":"https://api.github.com/repos/mrdoob/three.js/issues/9631/comments","events_url":"https://api.github.com/repos/mrdoob/three.js/issues/9631/events","html_url":"https://github.com/mrdoob/three.js/pull/9631","id":175274564,"number":9631,"title":"Allow user to copy full buffer with `gl.bufferData`","user":{"login":"mattdesl","id":1383811,"avatar_url":"https://avatars.githubusercontent.com/u/1383811?v=3","gravatar_id":"","url":"https://api.github.com/users/mattdesl","html_url":"https://github.com/mattdesl","followers_url":"https://api.github.com/users/mattdesl/followers","following_url":"https://api.github.com/users/mattdesl/following{/other_user}","gists_url":"https://api.github.com/users/mattdesl/gists{/gist_id}","starred_url":"https://api.github.com/users/mattdesl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattdesl/subscriptions","organizations_url":"https://api.github.com/users/mattdesl/orgs","repos_url":"https://api.github.com/users/mattdesl/repos","events_url":"https://api.github.com/users/mattdesl/events{/privacy}","received_events_url":"https://api.github.com/users/mattdesl/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":24,"created_at":"2016-09-06T15:16:49Z","updated_at":"2016-09-23T13:57:01Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/mrdoob/three.js/pulls/9631","html_url":"https://github.com/mrdoob/three.js/pull/9631","diff_url":"https://github.com/mrdoob/three.js/pull/9631.diff","patch_url":"https://github.com/mrdoob/three.js/pull/9631.patch"},"body":"Currently all GL buffers are updated with `gl.bufferSubData` — which makes sense most of the time for performance.\r\n\r\nHowever, this means you need to use fixed-size buffers, and can't re-use a GL buffer with a larger or smaller array than before. This is a problem for geometry that needs to dynamically grow/shrink.\r\n\r\nOne solution is to dispose and re-create your THREE.Geometry instances every time they need to shrink/grow, but this can be a bit tedious for the end-user since they have to restructure their application logic to handle changing geometries.\r\n\r\nAnother solution is to have a flag (disabled by default) on BufferAttribute that tells the engine to update the *entire* contents of the array (using `gl.bufferData`) rather than only a sub-region. This way the same GL buffers can be re-used without deleting/re-creating them (causing needless noise in GL inspectors), and with the right abstractions the user will never need to change their application logic.\r\n\r\nIn practice this shows up with a library like [three-bmfont-text](https://github.com/Jam3/three-bmfont-text) since users may choose to add/remove glyphs (quads) at runtime. This PR will allow developers like myself more control over the GL buffers, allowing cleaner and more optimized abstractions without affecting the end-user's code.\r\n\r\nThanks! :smile: "},"comment":{"url":"https://api.github.com/repos/mrdoob/three.js/issues/comments/249200125","html_url":"https://github.com/mrdoob/three.js/pull/9631#issuecomment-249200125","issue_url":"https://api.github.com/repos/mrdoob/three.js/issues/9631","id":249200125,"user":{"login":"mattdesl","id":1383811,"avatar_url":"https://avatars.githubusercontent.com/u/1383811?v=3","gravatar_id":"","url":"https://api.github.com/users/mattdesl","html_url":"https://github.com/mattdesl","followers_url":"https://api.github.com/users/mattdesl/followers","following_url":"https://api.github.com/users/mattdesl/following{/other_user}","gists_url":"https://api.github.com/users/mattdesl/gists{/gist_id}","starred_url":"https://api.github.com/users/mattdesl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattdesl/subscriptions","organizations_url":"https://api.github.com/users/mattdesl/orgs","repos_url":"https://api.github.com/users/mattdesl/repos","events_url":"https://api.github.com/users/mattdesl/events{/privacy}","received_events_url":"https://api.github.com/users/mattdesl/received_events","type":"User","site_admin":false},"created_at":"2016-09-23T13:57:00Z","updated_at":"2016-09-23T13:57:00Z","body":"I pushed a change to update the API with `setArray` and `needsFullBuffer`.\r\n\r\n---\r\n\r\n> How about adding a setArray() method would then update count and also set a needsFullUpdate or maybe needsUpload to true?\r\n\r\nHmm, the only issue is that the method introduces a side-effect that users might not be expecting. For example, they might use `setArray` even though the new array is the same size, so it doesn't actually need a `bufferData`. All of a sudden, the engine will be using a different strategy for buffer uploads.\r\n\r\nWe could check in `setArray` whether the new size is different than the old size, though it sounds like it's getting a bit fragile/complex. This is why I felt like it was best as a flag that advanced users can opt-in to.\r\n\r\nWe could call the boolean `dynamicSize`, and in the docs suggest users set it to true if they expect to have different sizes in `setArray()` calls. Otherwise all buffer attributes are expected to be fixed sized (as they are now)."}}
{"actor":{"display_login":"mattdesl"}}