MCPcopy
hub / github.com/regl-project/regl / createElements

Function createElements

lib/elements.js:167–268  ·  view source on GitHub ↗
(options, persistent)

Source from the content-addressed store, hash-verified

165 }
166
167 function createElements (options, persistent) {
168 var buffer = bufferState.create(null, GL_ELEMENT_ARRAY_BUFFER, true)
169 var elements = new REGLElementBuffer(buffer._buffer)
170 stats.elementsCount++
171
172 function reglElements (options) {
173 if (!options) {
174 buffer()
175 elements.primType = GL_TRIANGLES
176 elements.vertCount = 0
177 elements.type = GL_UNSIGNED_BYTE
178 } else if (typeof options === 'number') {
179 buffer(options)
180 elements.primType = GL_TRIANGLES
181 elements.vertCount = options | 0
182 elements.type = GL_UNSIGNED_BYTE
183 } else {
184 var data = null
185 var usage = GL_STATIC_DRAW
186 var primType = -1
187 var vertCount = -1
188 var byteLength = 0
189 var dtype = 0
190 if (Array.isArray(options) ||
191 isTypedArray(options) ||
192 isNDArrayLike(options)) {
193 data = options
194 } else {
195 check.type(options, 'object', 'invalid arguments for elements')
196 if ('data' in options) {
197 data = options.data
198 check(
199 Array.isArray(data) ||
200 isTypedArray(data) ||
201 isNDArrayLike(data),
202 'invalid data for element buffer')
203 }
204 if ('usage' in options) {
205 check.parameter(
206 options.usage,
207 usageTypes,
208 'invalid element buffer usage')
209 usage = usageTypes[options.usage]
210 }
211 if ('primitive' in options) {
212 check.parameter(
213 options.primitive,
214 primTypes,
215 'invalid element buffer primitive')
216 primType = primTypes[options.primitive]
217 }
218 if ('count' in options) {
219 check(
220 typeof options.count === 'number' && options.count >= 0,
221 'invalid vertex count for elements')
222 vertCount = options.count | 0
223 }
224 if ('type' in options) {

Callers

nothing calls this directly

Calls 3

reglElementsFunction · 0.85
destroyElementsFunction · 0.85
subdataMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…