https://planetazip.ru/wp-content/plugins/3d-scene-viewer/assets/js/3js/src/core/GLBufferAttribute.js
vendor: 3,965 bytes, lines 1-171
1/** 2 * An alternative version of a buffer attribute with more control over the VBO. 3 * 4 * The renderer does not construct a VBO for this kind of attribute. Instead, it uses 5 * whatever VBO is passed in constructor and can later be altered via the `buffer` property. 6 * 7 * The most common use case for this class is when some kind of GPGPU calculation interferes 8 * or even produces the VBOs in question. 9 * 10 * Notice that this class can only be used with {@link WebGLRenderer}. 11 */ 12class GLBufferAttribute { 13 14 /** 15 * Constructs a new GL buffer attribute. 16 * 17 * @param {WebGLBuffer} buffer - The native WebGL buffer. 18 * @param {number} type - The native data type (e.g. `gl.FLOAT`). 19 * @param {number} itemSize - The item size. 20 * @param {number} elementSize - The corresponding size (in bytes) for the given `type` parameter. 21 * @param {number} count - The expected number of vertices in VBO. 22 * @param {boolean} [normalized=false] - Whether the data are normalized or not. 23 */ 24 constructor( buffer, type, itemSize, elementSize, count, normalized = false ) { 25 26 /** 27 * This flag can be used for type testing. 28 * 29 * @type {boolean} 30 * @readonly 31 * @default true 32 */ 33 this.isGLBufferAttribute = true; 34 35 /** 36 * The name of the buffer attribute. 37 * 38 * @type {string} 39 */ 40 this.name = ''; 41 42 /** 43 * The native WebGL buffer. 44 * 45 * @type {WebGLBuffer} 46 */ 47 this.buffer = buffer; 48 49 /** 50 * The native data type. 51 * 52 * @type {number} 53 */ 54 this.type = type; 55 56 /** 57 * The item size, see {@link BufferAttribute#itemSize}. 58 * 59 * @type {number} 60 */ 61 this.itemSize = itemSize; 62 63 /** 64 * The corresponding size (in bytes) for the given `type` parameter. 65 * 66 * @type {number} 67 */ 68 this.elementSize = elementSize; 69 70 /** 71 * The expected number of vertices in VBO. 72 * 73 * @type {number} 74 */ 75 this.count = count; 76 77 /** 78 * Applies to integer data only. Indicates how the underlying data in the buffer maps to 79 * the values in the GLSL code. For instance, if `buffer` contains data of `gl.UNSIGNED_SHORT`, 80 * and `normalized` is `true`, the values `0 - +65535` in the buffer data will be mapped to 81 * `0.0f - +1.0f` in the GLSL attribute. If `normalized` is `false`, the values will be converted 82 * to floats unmodified, i.e. `65535` becomes `65535.0f`. 83 * 84 * @type {boolean} 85 */ 86 this.normalized = normalized; 87 88 /** 89 * A version number, incremented every time the `needsUpdate` is set to `true`. 90 * 91 * @type {number} 92 */ 93 this.version = 0; 94 95 } 96 97 /** 98 * Flag to indicate that this attribute has changed and should be re-sent to 99 * the GPU. Set this to `true` when you modify the value of the array. 100 * 101 * @type {number} 102 * @default false 103 * @param {boolean} value 104 */ 105 set needsUpdate( value ) { 106 107 if ( value === true ) this.version ++; 108 109 } 110 111 /** 112 * Sets the given native WebGL buffer. 113 * 114 * @param {WebGLBuffer} buffer - The buffer to set. 115 * @return {BufferAttribute} A reference to this instance. 116 */ 117 setBuffer( buffer ) { 118 119 this.buffer = buffer; 120 121 return this; 122 123 } 124 125 /** 126 * Sets the given native data type and element size. 127 * 128 * @param {number} type - The native data type (e.g. `gl.FLOAT`). 129 * @param {number} elementSize - The corresponding size (in bytes) for the given `type` parameter. 130 * @return {BufferAttribute} A reference to this instance. 131 */ 132 setType( type, elementSize ) { 133 134 this.type = type; 135 this.elementSize = elementSize; 136 137 return this; 138 139 } 140 141 /** 142 * Sets the item size. 143 * 144 * @param {number} itemSize - The item size. 145 * @return {BufferAttribute} A reference to this instance. 146 */ 147 setItemSize( itemSize ) { 148 149 this.itemSize = itemSize; 150 151 return this; 152 153 } 154 155 /** 156 * Sets the count (the expected number of vertices in VBO). 157 * 158 * @param {number} count - The count. 159 * @return {BufferAttribute} A reference to this instance. 160 */ 161 setCount( count ) { 162 163 this.count = count; 164 165 return this; 166 167 } 168 169} 170 171export { GLBufferAttribute };
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.