MCPcopy Create free account
hub / github.com/Code-Bullet/Jump-King / _sphere

Function _sphere

libraries/p5.js:34519–34534  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

34517 var gId = 'sphere|'+radius+'|'+detailX+'|'+detailY;
34518 if(!this._renderer.geometryInHash(gId)){
34519 var _sphere = function(){
34520 var u,v,p;
34521 for (var i = 0; i <= this.detailY; i++){
34522 v = i / this.detailY;
34523 for (var j = 0; j <= this.detailX; j++){
34524 u = j / this.detailX;
34525 var theta = 2 * Math.PI * u;
34526 var phi = Math.PI * v - Math.PI / 2;
34527 p = new p5.Vector(radius * Math.cos(phi) * Math.sin(theta),
34528 radius * Math.sin(phi),
34529 radius * Math.cos(phi) * Math.cos(theta));
34530 this.vertices.push(p);
34531 this.uvs.push([u,v]);
34532 }
34533 }
34534 };
34535 var sphereGeom = new p5.Geometry(detailX, detailY, _sphere);
34536 sphereGeom
34537 .computeFaces()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected