Created
November 23, 2013 23:35
-
-
Save ecto/7621390 to your computer and use it in GitHub Desktop.
calculate single-object effect on spacetime plane (with three.js PlaneGeometry)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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