Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function paint( xRot, yRot ) {
if (!initialized) { return }
if (polyBuffersOutdated) {
// buffers out of sync w/ arrays since last mutation wasn't kept
vertBuffer.update( polys.vertArr )
colBuffer.update( polys.colArr )
}
// rotation matrix (simple Euler angles)
camMatrix = mat4.create()
mat4.rotateY(camMatrix, camMatrix, yRot)
mat4.rotateX(camMatrix, camMatrix, xRot)
// paint polygons
drawData( SCREEN, perspective, camMatrix )
}
function paint(xRot, yRot) {
if (polyBuffersOutdated) {
// buffers out of sync w/ arrays since last mutation wasn't kept
vertBuffer.update(polys.getVertArray())
colBuffer.update(polys.getColorArray())
}
// rotation matrix (simple Euler angles)
camMatrix = mat4.create()
mat4.rotateY(camMatrix, camMatrix, xRot || 0)
mat4.rotateX(camMatrix, camMatrix, yRot || 0)
// paint polygons
drawData(null, perspective, camMatrix)
}
function centerGeometry(geo, scale) {
// Calculate the bounding box.
var bb = boundingBox(geo.positions);
// Translate the geometry center to the origin.
var translate = [-0.5 * (bb[0][0] + bb[1][0]), -0.5 * (bb[0][1] + bb[1][1]), -0.5 * (bb[0][2] + bb[1][2])];
var m = mat4.create();
mat4.scale(m, m, [scale, scale, scale]);
mat4.translate(m, m, translate);
geo.positions = transform(geo.positions, m)
}
FirstPersonCamera.prototype.view = function(out) {
if (!out) out = mat4.create()
mat4.rotateX(out, out, this.rotation[0])
mat4.rotateY(out, out, this.rotation[1])
mat4.rotateZ(out, out, this.rotation[2] - Math.PI)
mat4.translate(out, out, [-this.position[0], -this.position[1], -this.position[2]])
return out
}
value: function fromZCoordinate(zCoordinate) {
var xCoordinate = defaultXCoordinate,
yCoordinate = defaultYCoordinate,
coordinateVector = [xCoordinate, yCoordinate, zCoordinate],
matrix = mat4.create();
mat4.translate(matrix, matrix, coordinateVector);
var position = new Position(matrix);
return position;
}
}]);