MCPcopy Index your code
hub / github.com/processing/p5.js / _userVertexPropertyHelper

Method _userVertexPropertyHelper

src/webgl/p5.Geometry.js:1807–1869  ·  view source on GitHub ↗
(propertyName, data, size)

Source from the content-addressed store, hash-verified

1805 }
1806
1807 _userVertexPropertyHelper(propertyName, data, size){
1808 const geometryInstance = this;
1809 const prop = this.userVertexProperties[propertyName] = {
1810 name: propertyName,
1811 dataSize: size ? size : data.length ? data.length : 1,
1812 geometry: geometryInstance,
1813 // Getters
1814 getName(){
1815 return this.name;
1816 },
1817 getCurrentData(){
1818 if (this.currentData === undefined) {
1819 this.currentData = new Array(this.getDataSize()).fill(0);
1820 }
1821 return this.currentData;
1822 },
1823 getDataSize() {
1824 return this.dataSize;
1825 },
1826 getSrcName() {
1827 const src = this.name.concat('Src');
1828 return src;
1829 },
1830 getDstName() {
1831 const dst = this.name.concat('Buffer');
1832 return dst;
1833 },
1834 getSrcArray() {
1835 const srcName = this.getSrcName();
1836 return this.geometry[srcName];
1837 },
1838 //Setters
1839 setCurrentData(data) {
1840 const size = data.length ? data.length : 1;
1841 // if (size != this.getDataSize()){
1842 // p5._friendlyError(`Custom vertex property '${this.name}' has been set with various data sizes. You can change it's name, or if it was an accident, set '${this.name}' to have the same number of inputs each time!`, 'vertexProperty()');
1843 // }
1844 this.currentData = data;
1845 },
1846 // Utilities
1847 pushCurrentData(){
1848 const data = this.getCurrentData();
1849 this.pushDirect(data);
1850 },
1851 pushDirect(data) {
1852 if (data.length){
1853 this.getSrcArray().push(...data);
1854 } else{
1855 this.getSrcArray().push(data);
1856 }
1857 },
1858 resetSrcArray(){
1859 this.geometry[this.getSrcName()] = [];
1860 },
1861 delete() {
1862 const srcName = this.getSrcName();
1863 delete this.geometry[srcName];
1864 delete this;

Callers 2

vertexPropertyMethod · 0.95
constructFromContoursMethod · 0.80

Calls 1

getSrcNameMethod · 0.80

Tested by

no test coverage detected