Skip to content

Instantly share code, notes, and snippets.

@ecto
Created November 23, 2013 23:35
Show Gist options
  • Save ecto/7621390 to your computer and use it in GitHub Desktop.
Save ecto/7621390 to your computer and use it in GitHub Desktop.
calculate single-object effect on spacetime plane (with three.js PlaneGeometry)
var G = 100;
var vertex;
for (var i = 0; i < plane.geometry.vertices.length; i++) {
vertex = plane.geometry.vertices[i];
var distance = Math.sqrt(Math.pow(vertex.x - sphere.position.x, 2) + Math.pow(vertex.y - -sphere.position.z, 2));
var f = -(G * sphere.mass) / Math.pow(distance, 2);
vertex.z = f;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment