{"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":17,"created_at":"2016-09-06T15:16:49Z","updated_at":"2016-09-10T19:28:27Z","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/246131427","html_url":"https://github.com/mrdoob/three.js/pull/9631#issuecomment-246131427","issue_url":"https://api.github.com/repos/mrdoob/three.js/issues/9631","id":246131427,"user":{"login":"aardgoose","id":17364910,"avatar_url":"https://avatars.githubusercontent.com/u/17364910?v=3","gravatar_id":"","url":"https://api.github.com/users/aardgoose","html_url":"https://github.com/aardgoose","followers_url":"https://api.github.com/users/aardgoose/followers","following_url":"https://api.github.com/users/aardgoose/following{/other_user}","gists_url":"https://api.github.com/users/aardgoose/gists{/gist_id}","starred_url":"https://api.github.com/users/aardgoose/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aardgoose/subscriptions","organizations_url":"https://api.github.com/users/aardgoose/orgs","repos_url":"https://api.github.com/users/aardgoose/repos","events_url":"https://api.github.com/users/aardgoose/events{/privacy}","received_events_url":"https://api.github.com/users/aardgoose/received_events","type":"User","site_admin":false},"created_at":"2016-09-10T19:28:27Z","updated_at":"2016-09-10T19:28:27Z","body":"True, there is nothing to stop them doing that, but there is nothing that says that it should work, it's fiddling with what is really a private property of the object, or would be in another language. If it breaks something, bad luck. Look at Object3D etc when certain properties like position have been made un-replaceable to stop foot/gun incidents.\r\n\r\nIf you checked incoming length on the copy methods you could get automatic resizing after altering a Geometry() with no user changes, and if you really want to play directly with the BufferAttribute like that, surely it would be better to use the copyArray() method and adjust that to check for length changes, and you could get needsUpdate and any other flag setting for free.  Simple for the user and insulates them from any changes in the future.  Resizing, however done is going to be fairly costly, so having a proper API won't add much overhead.\r\n\r\nAnyway, not my library or decision, I am just very happy that it exists and works well."}}
{"actor":{"display_login":"aardgoose"}}