{"_id":"three-buffer-vertex-data","_rev":"6-42bb7037c3f469945f797ae8367589a1","name":"three-buffer-vertex-data","description":"an easy way to set vertex data on a BufferGeometry","dist-tags":{"latest":"1.1.0"},"versions":{"1.0.0":{"name":"three-buffer-vertex-data","version":"1.0.0","description":"an easy way to set vertex data on a BufferGeometry","main":"index.js","license":"MIT","author":{"name":"Matt DesLauriers","email":"dave.des@gmail.com","url":"https://github.com/mattdesl"},"dependencies":{"flatten-vertex-data":"^1.0.0"},"devDependencies":{"baboon-image-uri":"^1.0.1","browserify":"^12.0.1","budo":"^7.0.0","img":"^1.0.0","primitive-quad":"^1.0.1","primitive-sphere":"^2.0.0","primitive-torus":"^1.0.4","three":"^0.73.0","three-orbit-viewer":"^69.3.0","uglify-js":"^2.6.1"},"scripts":{"test":"node test.js","start":"budo demo/index.js:bundle.js --live","build":"browserify demo/index.js | uglifyjs -cm > bundle.js"},"standard":{"globals":["THREE"]},"keywords":["buffer","geometry","BufferGeometry","three","webgl","js","threejs","three.js","data","vertex","vert","vertices","dynamic","bufferdata"],"repository":{"type":"git","url":"git://github.com/Jam3/three-buffer-vertex-data.git"},"homepage":"https://github.com/Jam3/three-buffer-vertex-data","bugs":{"url":"https://github.com/Jam3/three-buffer-vertex-data/issues"},"gitHead":"158eeb82d9af1869f133efaeb5adad6b8cde4b4a","_id":"three-buffer-vertex-data@1.0.0","_shasum":"74850993f18902c45a3454d08f8bc648bf1c6d9c","_from":".","_npmVersion":"2.11.3","_nodeVersion":"0.12.7","_npmUser":{"name":"mattdesl","email":"dave.des@gmail.com"},"dist":{"shasum":"74850993f18902c45a3454d08f8bc648bf1c6d9c","tarball":"https://registry.npmjs.org/three-buffer-vertex-data/-/three-buffer-vertex-data-1.0.0.tgz","integrity":"sha512-nm5odzyCltxNPBPh/3E5mXzZUra1LW8l1GsCbhc25GBM7LwejQX5rHOeDWiyDLd4q1xCSoA6KauX1Pfv7/Kn3w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDip/gSCawz7bnMV0nT1ZYbC7cy2ikxtssRaOwetNshCwIhALuqBT6TQaRKhC7NOLVZG+9wQqs3ziSxxAMUzy0tai4B"}]},"maintainers":[{"name":"mattdesl","email":"dave.des@gmail.com"}]},"1.0.1":{"name":"three-buffer-vertex-data","version":"1.0.1","description":"an easy way to set vertex data on a BufferGeometry","main":"index.js","license":"MIT","author":{"name":"Matt DesLauriers","email":"dave.des@gmail.com","url":"https://github.com/mattdesl"},"dependencies":{"flatten-vertex-data":"^1.0.0"},"devDependencies":{"baboon-image-uri":"^1.0.1","browserify":"^12.0.1","budo":"^7.0.0","img":"^1.0.0","primitive-quad":"^1.0.1","primitive-sphere":"^2.0.0","primitive-torus":"^1.0.4","three":"^0.73.0","three-orbit-viewer":"^69.3.0","uglify-js":"^2.6.1"},"scripts":{"test":"node test.js","start":"budo demo/index.js:bundle.js --live","build":"browserify demo/index.js | uglifyjs -cm > bundle.js"},"standard":{"globals":["THREE"]},"keywords":["buffer","geometry","BufferGeometry","three","webgl","js","threejs","three.js","data","vertex","vert","vertices","dynamic","bufferdata"],"repository":{"type":"git","url":"git://github.com/Jam3/three-buffer-vertex-data.git"},"homepage":"https://github.com/Jam3/three-buffer-vertex-data","bugs":{"url":"https://github.com/Jam3/three-buffer-vertex-data/issues"},"gitHead":"bc102c918f7d7400e464a689a3e93d703687ab2d","_id":"three-buffer-vertex-data@1.0.1","_shasum":"18a49191df41b3c0bbcd1e9a2831e7b83b83c1c9","_from":".","_npmVersion":"3.8.9","_nodeVersion":"6.2.0","_npmUser":{"name":"mattdesl","email":"dave.des@gmail.com"},"dist":{"shasum":"18a49191df41b3c0bbcd1e9a2831e7b83b83c1c9","tarball":"https://registry.npmjs.org/three-buffer-vertex-data/-/three-buffer-vertex-data-1.0.1.tgz","integrity":"sha512-jt0gEWRjL+pPUsiAIcOTj6UDvUsKJkNk95hyQHMS1j9w/0QV7ld0y1H/CueQLMd/isHv46vnxjOB8eEnP1LNnA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCdrVTJyTVhWJljND5tScewLvfGwXk26UK31vRbFjDJqAIhALFXAZmb0j3AjGunD8+AFPtoS2HSZVW28X3Dyaun30KF"}]},"maintainers":[{"name":"mattdesl","email":"dave.des@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/three-buffer-vertex-data-1.0.1.tgz_1467406076940_0.3382265248801559"}},"1.0.2":{"name":"three-buffer-vertex-data","version":"1.0.2","description":"an easy way to set vertex data on a BufferGeometry","main":"index.js","license":"MIT","author":{"name":"Matt DesLauriers","email":"dave.des@gmail.com","url":"https://github.com/mattdesl"},"dependencies":{"flatten-vertex-data":"^1.0.0"},"devDependencies":{"baboon-image-uri":"^1.0.1","browserify":"^12.0.1","budo":"^7.0.0","img":"^1.0.0","primitive-quad":"^1.0.1","primitive-sphere":"^2.0.0","primitive-torus":"^1.0.4","three":"^0.73.0","three-orbit-viewer":"^69.3.1","uglify-js":"^2.6.1"},"scripts":{"test":"node test.js","start":"budo demo/index.js:bundle.js --live","build":"browserify demo/index.js | uglifyjs -cm > bundle.js"},"standard":{"globals":["THREE"]},"keywords":["buffer","geometry","BufferGeometry","three","webgl","js","threejs","three.js","data","vertex","vert","vertices","dynamic","bufferdata"],"repository":{"type":"git","url":"git://github.com/Jam3/three-buffer-vertex-data.git"},"homepage":"https://github.com/Jam3/three-buffer-vertex-data","bugs":{"url":"https://github.com/Jam3/three-buffer-vertex-data/issues"},"gitHead":"3fc6c5cf3b5bd20e180c1cec7f022d1ba50da3b2","_id":"three-buffer-vertex-data@1.0.2","_shasum":"3d9e723321ad1031819b8786557b31b110486b23","_from":".","_npmVersion":"3.8.9","_nodeVersion":"6.2.0","_npmUser":{"name":"mattdesl","email":"dave.des@gmail.com"},"dist":{"shasum":"3d9e723321ad1031819b8786557b31b110486b23","tarball":"https://registry.npmjs.org/three-buffer-vertex-data/-/three-buffer-vertex-data-1.0.2.tgz","integrity":"sha512-hzZ2P71JwDI0q2bcDAgbcWly+gQqDGXp0PVIewNu0z6ll5r5EQZQJacAXCM5UISVMIpN7xXUWEvYqWRR7Np7cQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBuGq27skKVbdjeL/lOInPyx6ixUao6B6bJ86zK1rnXMAiEAsIIC4jwdCSefTZDB0ShCVXi1QH1hvkJvsjnZKn+cmXc="}]},"maintainers":[{"name":"mattdesl","email":"dave.des@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/three-buffer-vertex-data-1.0.2.tgz_1473175236862_0.4731563557870686"}},"1.1.0":{"name":"three-buffer-vertex-data","version":"1.1.0","description":"an easy way to set vertex data on a BufferGeometry","main":"index.js","license":"MIT","author":{"name":"Matt DesLauriers","email":"dave.des@gmail.com","url":"https://github.com/mattdesl"},"dependencies":{"flatten-vertex-data":"^1.0.0"},"devDependencies":{"baboon-image-uri":"^1.0.1","browserify":"^12.0.1","budo":"^7.0.0","img":"^1.0.0","primitive-quad":"^1.0.1","primitive-sphere":"^2.0.0","primitive-torus":"^1.0.4","three":"^0.73.0","three-orbit-viewer":"^69.3.1","uglify-js":"^2.6.1"},"scripts":{"test":"node test.js","start":"budo demo/index.js:bundle.js --live","build":"browserify demo/index.js | uglifyjs -cm > bundle.js"},"standard":{"globals":["THREE"]},"keywords":["buffer","geometry","BufferGeometry","three","webgl","js","threejs","three.js","data","vertex","vert","vertices","dynamic","bufferdata"],"repository":{"type":"git","url":"git://github.com/Jam3/three-buffer-vertex-data.git"},"homepage":"https://github.com/Jam3/three-buffer-vertex-data","bugs":{"url":"https://github.com/Jam3/three-buffer-vertex-data/issues"},"gitHead":"c5318e2b6697c40920f3abc9b02a8ac979d330ee","_id":"three-buffer-vertex-data@1.1.0","_shasum":"cf228e78427665884b961a4cabe1f85ed39f82b1","_from":".","_npmVersion":"3.8.9","_nodeVersion":"6.2.0","_npmUser":{"name":"mattdesl","email":"dave.des@gmail.com"},"dist":{"shasum":"cf228e78427665884b961a4cabe1f85ed39f82b1","tarball":"https://registry.npmjs.org/three-buffer-vertex-data/-/three-buffer-vertex-data-1.1.0.tgz","integrity":"sha512-V4kHE8eRaWXVgVoXvT/Q13WCtBffy2xOVUPq6BkQFhG33FK1cOYLuL1CMsNx5kD8eOlXK8Fxb+rinzeNuZNe5g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCZ6ltVFMy2aEdpRAAk4di2XtTDS5IA6NyRydKxEpFdFgIgBO8TUSecheeQulwibZ0hJU1iMpMBZ7wEUt161y/E45U="}]},"maintainers":[{"name":"mattdesl","email":"dave.des@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/three-buffer-vertex-data-1.1.0.tgz_1479057228246_0.07204907154664397"}}},"readme":"# three-buffer-vertex-data\n\n[![experimental](http://badges.github.io/stability-badges/dist/experimental.svg)](http://github.com/badges/stability-badges)\n\n[(demo)](http://jam3.github.io/three-buffer-vertex-data/) - [(source)](./demo/index.js)\n\nConvenience functions for sending vertex data to an attribtue of a [THREE.BufferGeometry](http://threejs.org/docs/#Reference/Core/BufferGeometry).\n\nThis will flatten vertex data if necessary, attempt to re-use arrays where possible to minimize GC, and handle some compatibility issues across different versions of ThreeJS. It can handle dynamically growing and shrinking buffers.\n\nThe input is expected in simple arrays, and can be one of:\n\n- a nested array like `[ [ x, y ], [ x, y ] ]`\n- a flat array like `[ x, y, z, x, y, z ]`\n- a typed array like `new Float32Array([ x, y ])`\n\nThis is particularly useful in new versions of ThreeJS, where BufferGeometry is required for custom shader attributes.\n\n## Install\n\n```sh\nnpm install three-buffer-vertex-data --save\n```\n\n## Example\n\nA simple example using [snowden](https://github.com/stackgl/snowden).\n\n```js\nvar buffer = require('three-buffer-vertex-data')\n\n// grab a simplicial complex\nvar snowden = require('snowden')\n\n// set up our geometry\nvar geometry = new THREE.BufferGeometry()\nbuffer.index(geometry, snowden.cells)\nbuffer.attr(geometry, 'position', snowden.positions)\n\n// add to scene\nvar material = new THREE.MeshBasicMaterial()\nvar mesh = new THREE.Mesh(geometry, material)\nscene.add(mesh)\n```\n\nThe `'position'`, `'uv'` and `'normal'` attributes are built-in to ThreeJS and will work with common materials. Result:\n\n<img src=\"http://i.imgur.com/LdHk4xB.png\" width=\"50%\" />\n\nSee [demo](./demo/index.js) for a more complex example, which cycles various [mesh primitives](https://github.com/glo-js/mesh-primitives) into the same vertex buffers.\n\n## Usage\n\n[![NPM](https://nodei.co/npm/three-buffer-vertex-data.png)](https://www.npmjs.com/package/three-buffer-vertex-data)\n\nThe `data` passed is sent through [flatten-vertex-data](https://github.com/glo-js/flatten-vertex-data), and can be in the form of:\n\n- a nested array like `[ [ x, y ], [ x, y ] ]`\n- a flat array like `[ x, y, z, x, y, z ]`\n- a typed array like `new Float32Array([ x, y ])`\n\nIf the attribute exists, its underlying `array` will try to be re-used. Otherwise, a new typed array will be created from the optional [dtype](https://www.npmjs.com/package/dtype).\n\n#### `buffer.index(geometry, data, [itemSize], [dtype])`\n\nSets the `index` attribute for the given buffer `geometry`, with your list of indices in `data`. The `itemSize` defaults to 1, and `dtype` string defaults to `'uint16'`\n\n#### `buffer.attr(geometry, key, data, [itemSize], [dtype])`\n\nSets a generic attribute on the given buffer `geometry` by the given `key` and vertex `data`. The `itemSize` defaults to 3, and `dtype` string defaults to `'float32'`.\n\n## Gotchas\n\nIn r73, ThreeJS breaks when using `wireframe` and attempting to dynamically grow/shrink and add/remove attributes.\n\nAlso, ThreeJS typically expects indices and `positions` to exist. Things may break without these attributes set. \n\nYou will need THREE r82 or newer if you wish to dynamically grow and shrink vertex buffers.\n\n## License\n\nMIT, see [LICENSE.md](http://github.com/Jam3/three-buffer-vertex-data/blob/master/LICENSE.md) for details.\n","maintainers":[{"name":"mattdesl","email":"dave.des@gmail.com"}],"time":{"modified":"2022-06-27T06:17:36.304Z","created":"2015-12-02T19:29:31.104Z","1.0.0":"2015-12-02T19:29:31.104Z","1.0.1":"2016-07-01T20:47:59.487Z","1.0.2":"2016-09-06T15:20:38.646Z","1.1.0":"2016-11-13T17:13:50.160Z"},"homepage":"https://github.com/Jam3/three-buffer-vertex-data","keywords":["buffer","geometry","BufferGeometry","three","webgl","js","threejs","three.js","data","vertex","vert","vertices","dynamic","bufferdata"],"repository":{"type":"git","url":"git://github.com/Jam3/three-buffer-vertex-data.git"},"author":{"name":"Matt DesLauriers","email":"dave.des@gmail.com","url":"https://github.com/mattdesl"},"bugs":{"url":"https://github.com/Jam3/three-buffer-vertex-data/issues"},"license":"MIT","readmeFilename":"README.md"}