MCPcopy Index your code
hub / github.com/plotly/plotly.js / createBackgroundCube

Function createBackgroundCube

stackgl_modules/index.js:12374–12431  ·  view source on GitHub ↗
(gl)

Source from the content-addressed store, hash-verified

12372}
12373
12374function createBackgroundCube(gl) {
12375 //Create cube vertices
12376 var vertices = []
12377 var indices = []
12378 var ptr = 0
12379 for(var d=0; d<3; ++d) {
12380 var u = (d+1) % 3
12381 var v = (d+2) % 3
12382 var x = [0,0,0]
12383 var c = [0,0,0]
12384 for(var s=-1; s<=1; s+=2) {
12385 indices.push(ptr, ptr+2, ptr+1,
12386 ptr+1, ptr+2, ptr+3)
12387 x[d] = s
12388 c[d] = s
12389 for(var i=-1; i<=1; i+=2) {
12390 x[u] = i
12391 for(var j=-1; j<=1; j+=2) {
12392 x[v] = j
12393 vertices.push(x[0], x[1], x[2],
12394 c[0], c[1], c[2])
12395 ptr += 1
12396 }
12397 }
12398 //Swap u and v
12399 var tt = u
12400 u = v
12401 v = tt
12402 }
12403 }
12404
12405 //Allocate buffer and vertex array
12406 var buffer = createBuffer(gl, new Float32Array(vertices))
12407 var elements = createBuffer(gl, new Uint16Array(indices), gl.ELEMENT_ARRAY_BUFFER)
12408 var vao = createVAO(gl, [
12409 {
12410 buffer: buffer,
12411 type: gl.FLOAT,
12412 size: 3,
12413 offset: 0,
12414 stride: 24
12415 },
12416 {
12417 buffer: buffer,
12418 type: gl.FLOAT,
12419 size: 3,
12420 offset: 12,
12421 stride: 24
12422 }
12423 ], elements)
12424
12425 //Create shader object
12426 var shader = createShader(gl)
12427 shader.attributes.position.location = 0
12428 shader.attributes.normal.location = 1
12429
12430 return new BackgroundCube(gl, buffer, vao, shader)
12431}

Callers

nothing calls this directly

Calls 3

createBufferFunction · 0.85
createVAOFunction · 0.85
createShaderFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…