-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathauxillary.js
28 lines (23 loc) · 938 Bytes
/
auxillary.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
function changeGravitationalCenter (center) {
var objects = currentScene.getObjects ();
for (var i = 0; i < objects.length; i++) {
if (objects[i].rigidBody && objects[i].tag == "chair") {
var direction = vec3.create ();
vec3.sub (direction, center, objects[i].transform.position);
vec3.normalize (direction, direction);
var force = vec3.create ();
vec3.scale (force, direction, objects[i].rigidBody.mass * gravity);
objects[i].rigidBody.force = vec3.clone (force);
objects[i].collider.physics = "dynamic";
objects[i].rigidBody.type = "dynamic";
}
}
}
function swapTextures (img) {
var objects = currentScene.getObjects ();
for (var i = 0; i < objects.length; i++) {
if (objects[i].texture) {
objects[i].texture = new texture (img, [ [gl.TEXTURE_MIN_FILTER, gl.NEAREST_MIPMAP_LINEAR], [gl.TEXTURE_MAG_FILTER, gl.NEAREST], [gl.TEXTURE_WRAP_S, gl.REPEAT], [gl.TEXTURE_WRAP_T, gl.REPEAT]]);
}
}
}