Assumes camera is set up correctly in gl context.
7807
def draw_edge_visibility(gl, v, e, f, hidden_wireframe=True):
    """"""
    gl.Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    ec = np.arange(1, len(e)+1)
    ec = np.tile(col(ec), (1, 3))
    ec[:, 0] = ec[:, 0] & 255
    ec[:, 1] = (ec[:, 1] >> 8 ) & 255
    ec[:, 2] = (ec[:, 2] >> 16 ) & 255
    ec = np.asarray(ec, dtype=np.uint8)
    
    draw_colored_primitives(gl, v, e, ec)
    
    if hidden_wireframe:
        gl.Enable(GL_POLYGON_OFFSET_FILL)
        gl.PolygonOffset(10.0, 1.0)
        draw_colored_primitives(gl, v, f, fc=np.zeros(f.shape))
        gl.Disable(GL_POLYGON_OFFSET_FILL)
    
    raw = np.asarray(gl.getImage(), np.uint32)
    raw = raw[:,:,0] + raw[:,:,1]*256 + raw[:,:,2]*256*256 - 1
    return raw
551912
def draw(self, clear=True):
        """"""
        if clear:
            self.clear()

        with self.gl_states, self.camera, self.light:
            for mesh in self.meshes:
                try:
                    mesh.draw()
                except AttributeError:
                    pass
1149077
function(){
          this.counter = this.data.interval;

          this.cam = new THREE.CubeCamera( 0.5, this.data.distance, this.data.resolution);
          this.el.object3D.add( this.cam );
          this.mirrorMaterial = new THREE.MeshBasicMaterial( { color: this.data.color, refractionRatio: this.data.refraction, envMap: this.cam.renderTarget.texture } );
          this.done = false;
          var mirrormat = this.mirrorMaterial;
          this.mesh = this.el.getObject3D('mesh');
          if(this.mesh){
            this.mesh.traverse( function( child ) { 
                if ( child instanceof THREE.Mesh ) child.material = mirrormat;
            });
          }
  }
952647
function renderPick() {
    if(checkContextLoss()) {
      return
    }

    gl.colorMask(true, true, true, true)
    gl.depthMask(true)
    gl.disable(gl.BLEND)
    gl.enable(gl.DEPTH_TEST)

    var numObjs = objects.length
    var numPick = pickBuffers.length
    for(var j=0; j<numPick; ++j) {
      var buf = pickBuffers[j]
      buf.shape = pickShape
      buf.begin()
      for(var i=0; i<numObjs; ++i) {
        if(pickBufferIds[i] !== j) {
          continue
        }
        var obj = objects[i]
        if(obj.drawPick) {
          obj.pixelRatio = 1
          obj.drawPick(cameraParams)
        }
      }
      buf.end()
    }
  }
847793
function UniversalCamera(name, position, scene) {
            var _this = _super.call(this, name, position, scene) || this;
            _this.inputs.addGamepad();
            return _this;
        }
1168044
public boolean process(CameraPinholeBrown intrinsic , Se3_F64 planeToCamera )
	{
		proj.setPlaneToCamera(planeToCamera,true);
		proj.setIntrinsic(intrinsic);

		// find a bounding rectangle on the ground which is visible to the camera and at a high enough resolution
		double x0 = Double.MAX_VALUE;
		double y0 = Double.MAX_VALUE;
		double x1 = -Double.MAX_VALUE;
		double y1 = -Double.MAX_VALUE;

		for( int y = 0; y < intrinsic.height; y++ ) {
			for( int x = 0; x < intrinsic.width; x++ ) {
				if( !checkValidPixel(x,y) )
					continue;

				if( plane0.x < x0 )
					x0 = plane0.x;
				if( plane0.x > x1 )
					x1 = plane0.x;
				if( plane0.y < y0 )
					y0 = plane0.y;
				if( plane0.y > y1 )
					y1 = plane0.y;
			}
		}

		if( x0 == Double.MAX_VALUE )
			return false;

		// compute parameters with the intent of maximizing viewing area
		double mapWidth = x1-x0;
		double mapHeight = y1-y0;
		overheadWidth = (int)Math.floor(mapWidth/cellSize);
		overheadHeight = (int)Math.floor(mapHeight* viewHeightFraction /cellSize);
		centerX = -x0;
		centerY = -(y0+mapHeight*(1- viewHeightFraction)/2.0);

		return true;
	}
198211
def capture
      Gl.glBindTexture Gl::GL_TEXTURE_2D, id
      Gl.glCopyTexImage2D Gl::GL_TEXTURE_2D, 0, Gl::GL_RGBA8, 0, 0, width, height, 0
      self
    end
1150301
void constructMatrix(DMatrixRMaj L) {
		L.reshape(cameras.size*eqs,10);

		// Known aspect ratio constraint makes more sense as a square
		double RR = this.aspectRatio *this.aspectRatio;

		// F = P*Q*P'
		// F is an arbitrary variable name and not fundamental matrix
		int index = 0;
		for (int i = 0; i < cameras.size; i++) {
			Projective P = cameras.get(i);
			DMatrix3x3 A = P.A;
			DMatrix3 B = P.a;

			// hard to tell if this helped or hurt. Keeping commented out for future investigation on proper scaling
//			double scale = NormOps_DDF3.normF(P.A);
//			CommonOps_DDF3.divide(P.A,scale);
//			CommonOps_DDF3.divide(P.a,scale);

			// constraint for a zero principle point

			// row for F[0,2] == 0
			L.data[index++] = A.a11*A.a31;
			L.data[index++] = (A.a12*A.a31 + A.a11*A.a32);
			L.data[index++] = (A.a13*A.a31 + A.a11*A.a33);
			L.data[index++] = (B.a1*A.a31 + A.a11*B.a3);
			L.data[index++] = A.a12*A.a32;
			L.data[index++] = (A.a13*A.a32 + A.a12*A.a33);
			L.data[index++] = (B.a1*A.a32 + A.a12*B.a3);
			L.data[index++] = A.a13*A.a33;
			L.data[index++] = (B.a1*A.a33 + A.a13*B.a3);
			L.data[index++] = B.a1*B.a3;

			// row for F[1,2] == 0
			L.data[index++] = A.a21*A.a31;
			L.data[index++] = (A.a22*A.a31 + A.a21*A.a32);
			L.data[index++] = (A.a23*A.a31 + A.a21*A.a33);
			L.data[index++] = (B.a2*A.a31 + A.a21*B.a3);
			L.data[index++] = A.a22*A.a32;
			L.data[index++] = (A.a23*A.a32 + A.a22*A.a33);
			L.data[index++] = (B.a2*A.a32 + A.a22*B.a3);
			L.data[index++] = A.a23*A.a33;
			L.data[index++] = (B.a2*A.a33 + A.a23*B.a3);
			L.data[index++] = B.a2*B.a3;

			if( zeroSkew ) {
				// row for F[0,1] == 0
				L.data[index++] = A.a11*A.a21;
				L.data[index++] = (A.a12*A.a21 + A.a11*A.a22);
				L.data[index++] = (A.a13*A.a21 + A.a11*A.a23);
				L.data[index++] = (B.a1*A.a21 + A.a11*B.a2);
				L.data[index++] = A.a12*A.a22;
				L.data[index++] = (A.a13*A.a22 + A.a12*A.a23);
				L.data[index++] = (B.a1*A.a22 + A.a12*B.a2);
				L.data[index++] = A.a13*A.a23;
				L.data[index++] = (B.a1*A.a23 + A.a13*B.a2);
				L.data[index++] = B.a1*B.a2;
			}

			if( knownAspect ) {
				// aspect^2*F[0,0]-F[1,1]
				L.data[index++] = A.a11*A.a11*RR - A.a21*A.a21;
				L.data[index++] = 2*(A.a11*A.a12*RR - A.a21*A.a22);
				L.data[index++] = 2*(A.a11*A.a13*RR - A.a21*A.a23);
				L.data[index++] = 2*(A.a11*B.a1*RR - A.a21*B.a2);
				L.data[index++] = A.a12*A.a12*RR - A.a22*A.a22;
				L.data[index++] = 2*(A.a12*A.a13*RR - A.a22*A.a23);
				L.data[index++] = 2*(A.a12*B.a1*RR - A.a22*B.a2);
				L.data[index++] = A.a13*A.a13*RR - A.a23*A.a23;
				L.data[index++] = 2*(A.a13*B.a1*RR - A.a23*B.a2);
				L.data[index++] = B.a1*B.a1*RR - B.a2*B.a2;
			}
		}
	}
1186280
function (x, y, w, h) {
            this.gl.viewport(x, y, w, h);
        }
197535
public static void computeCameraControl(double beta[],
											List<Point3D_F64> nullPts[],
											FastQueue<Point3D_F64> cameraPts ,
											int numControl )
	{
		cameraPts.reset();
		for( int i = 0; i < numControl; i++ ) {
			cameraPts.grow().set(0,0,0);
		}

		for( int i = 0; i < numControl; i++ ) {
			double b = beta[i];
//			System.out.printf("%7.3f ", b);

			for( int j = 0; j < numControl; j++ ) {
				Point3D_F64 s = cameraPts.get(j);
				Point3D_F64 p = nullPts[i].get(j);
				s.x += b*p.x;
				s.y += b*p.y;
				s.z += b*p.z;
			}
		}
	}
188707
private void configureDisplayView() {
        if (mDisplayView instanceof GLCameraEncoderView)
            ((GLCameraEncoderView) mDisplayView).setCameraEncoder(this);
        else if (mDisplayView instanceof GLCameraView)
            ((GLCameraView) mDisplayView).setCamera(mCamera);
    }
1180540
function Render (gl, animatedModel, dt, state) {
  // TODO: get # joints from model
  var selectedKeyframes = Object.keys(animatedModel.keyframes)
  .sort()
  .slice(state.currentAnimation[0], state.currentAnimation[1] + 1)
  .reduce(function (selectedKeyframes, currentKeyframe) {
    selectedKeyframes[currentKeyframe] = animatedModel.keyframes[currentKeyframe]
    return selectedKeyframes
  }, {})

  var interpolatedJointData = interpolateJoints(selectedKeyframes, dt, animatedModel.numJoints)

  gl.viewport(0, 0, state.viewport.width, state.viewport.height)
  gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

  var pMatrix = makePerspective(Math.PI / 3, state.viewport.width / state.viewport.height, 1, 2000)

  var modelPosition = [0, 0, 0]

  var cameraMatrix = makeCamera(state.orbit, modelPosition)
  var viewMatrix = makeInverse(cameraMatrix)

  animatedModel.draw({
    interpolatedJoints: interpolatedJointData.interpolatedJoints,
    rotationQuats: interpolatedJointData.interpolatedRotQuaternions,
    translationQuats: interpolatedJointData.interpolatedTransQuaternions,
    position: modelPosition,
    perspectiveMatrix: pMatrix,
    viewMatrix: viewMatrix,
    numJoints: animatedModel.numJoints
  })
}
193557
function() {
		this.gl = this.context.gl; 
		var gl = this.gl;

		this.id = gl.createTexture(); //texture ID is recreated
		this.width = this.height = 0; //size is reset to zero until loaded
		this.target = gl.TEXTURE_2D;  //the provider can change this if necessary (e.g. cube maps)

		this.bind();

		//TODO: clean these up a little. 
		gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, Texture.UNPACK_PREMULTIPLY_ALPHA);
		gl.pixelStorei(gl.UNPACK_ALIGNMENT, Texture.UNPACK_ALIGNMENT);
		gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, Texture.UNPACK_FLIP_Y);
		
		var colorspace = Texture.UNPACK_COLORSPACE_CONVERSION || gl.BROWSER_DEFAULT_WEBGL;
		gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, colorspace);

		//setup wrap modes without binding redundantly
		this.setWrap(this.wrapS, this.wrapT, false);
		this.setFilter(this.minFilter, this.magFilter, false);
		
		if (this.managedArgs) {
			this.setup(this.managedArgs);
		}
	}
181265
def set_viewup(self, vector):
        
        if isinstance(vector, np.ndarray):
            if vector.ndim != 1:
                vector = vector.ravel()
        self.camera.SetViewUp(vector)
        self._render()
269932
@Override
	public boolean process(double x, double y) {

		leftPixelToRect.compute(x,y,pixelRect);

		// round to the nearest pixel
		if( !disparity.process((int)(pixelRect.x+0.5),(int)(pixelRect.y+0.5)) )
			return false;

		// Compute coordinate in camera frame
		this.w = disparity.getDisparity();
		computeHomo3D(pixelRect.x, pixelRect.y, pointLeft);

		return true;
	}
1117993
function handleNode (node, gltf, i, ctx, renderer, options) {
  const components = []

  components.push(renderer.transform(
    node.matrix
      ? {
        position: [node.matrix[12], node.matrix[13], node.matrix[14]],
        rotation: quat.fromMat4(quat.create(), node.matrix),
        scale: [
          Math.hypot(node.matrix[0], node.matrix[1], node.matrix[2]),
          Math.hypot(node.matrix[4], node.matrix[5], node.matrix[6]),
          Math.hypot(node.matrix[8], node.matrix[9], node.matrix[10])
        ]
      }
      : {
        position: node.translation || [0, 0, 0],
        rotation: node.rotation || [0, 0, 0, 1],
        scale: node.scale || [1, 1, 1]
      }
  ))

  if (options.includeCameras && Number.isInteger(node.camera)) {
    const camera = gltf.cameras[node.camera]
    const enabled = options.enabledCameras.includes(node.camera)

    // https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/schema/camera.schema.json
    if (camera.type === 'orthographic') {
      // https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/schema/camera.orthographic.schema.json
      components.push(renderer.camera({
        enabled,
        name: camera.name || `camera_${node.camera}`,
        projection: 'orthographic',
        near: camera.orthographic.znear,
        far: camera.orthographic.zfar,
        left: -camera.orthographic.xmag / 2,
        right: camera.orthographic.xmag / 2,
        top: camera.orthographic.ymag / 2,
        bottom: camera.orthographic.ymag / 2
      }))
    } else {
      // https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/schema/camera.perspective.schema.json
      components.push(renderer.camera({
        enabled,
        name: camera.name || `camera_${node.camera}`,
        near: camera.perspective.znear,
        far: camera.perspective.zfar || Infinity,
        fov: camera.perspective.yfov,
        aspect: camera.perspective.aspectRatio || ctx.gl.drawingBufferWidth / ctx.gl.drawingBufferHeight
      }))
    }
  }

  node.entity = renderer.entity(components)
  node.entity.name = node.name || `node_${i}`

  // https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/schema/skin.schema.json
  let skinCmp = null
  if (Number.isInteger(node.skin)) {
    const skin = gltf.skins[node.skin]
    const accessor = getAccessor(gltf.accessors[skin.inverseBindMatrices], gltf.bufferViews)

    let inverseBindMatrices = []
    for (let i = 0; i < accessor._data.length; i += 16) {
      inverseBindMatrices.push(accessor._data.slice(i, i + 16))
    }

    skinCmp = renderer.skin({
      inverseBindMatrices: inverseBindMatrices
    })
  }

  if (Number.isInteger(node.mesh)) {
    const primitives = handleMesh(gltf.meshes[node.mesh], gltf, ctx, renderer)

    if (primitives.length === 1) {
      primitives[0].forEach((component) => {
        node.entity.addComponent(component)
      })
      if (skinCmp) node.entity.addComponent(skinCmp)
      return node.entity
    } else {
      // create sub nodes for each primitive
      const primitiveNodes = primitives.map((components, j) => {
        const subEntity = renderer.entity(components)
        subEntity.name = `node_${i}_${j}`
        subEntity.transform.set({ parent: node.entity.transform })

        // TODO: should skin component be shared?
        if (skinCmp) subEntity.addComponent(skinCmp)
        return subEntity
      })
      const nodes = [node.entity].concat(primitiveNodes)

      return nodes
    }
  }
  return node.entity
}
1110601
function () {
    var el = this.el;
    var savedPose = this.savedPose;

    if (!this.hasSavedPose) { return; }

    // Reset camera orientation.
    el.object3D.position.copy(savedPose.position);
    el.object3D.rotation.copy(savedPose.rotation);
    this.hasSavedPose = false;
  }