Skip to content

Commit

Permalink
deploy: 8f60773
Browse files Browse the repository at this point in the history
  • Loading branch information
jrouwe committed Oct 7, 2023
0 parents commit ede12d1
Show file tree
Hide file tree
Showing 18 changed files with 3,416 additions and 0 deletions.
Empty file added .nojekyll
Empty file.
46 changes: 46 additions & 0 deletions 2d_funnel.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>JoltPhysics.js demo</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="container">Loading...</div>
<div id="info">JoltPhysics.js demo</div>

<script src="js/three/three.min.js"></script>
<script src="js/three/OrbitControls.js"></script>
<script src="js/three/WebGL.js"></script>
<script src="js/three/stats.min.js"></script>
<script src="js/example.js"></script>

<script type="module">
import initJolt from 'https://www.unpkg.com/jolt-physics/dist/jolt-physics.wasm-compat.js';

initJolt().then(function (Jolt) {
// Initialize this example
initExample(Jolt, null);

// Create a basic floor
createFloor();

createBox(new Jolt.Vec3(-12, 8, -5), Jolt.Quat.prototype.sRotation(new Jolt.Vec3(0, 0, 1), 0.2 * Math.PI), new Jolt.Vec3(0.1, 10, 1), Jolt.Static, Jolt.NON_MOVING);
createBox(new Jolt.Vec3(12, 8, -5), Jolt.Quat.prototype.sRotation(new Jolt.Vec3(0, 0, 1), -0.2 * Math.PI), new Jolt.Vec3(0.1, 10, 1), Jolt.Static, Jolt.NON_MOVING);

let shape = new Jolt.SphereShape(0.5, null);
let creationSettings = new Jolt.BodyCreationSettings(shape, new Jolt.Vec3(0, 0, 0), Jolt.Quat.prototype.sIdentity(), Jolt.Dynamic, Jolt.MOVING);
creationSettings.mAllowedDOFs = Jolt.Plane2D;

for (let x = 0; x < 20; ++x)
for (let y = 0; y < 10; ++y) {
creationSettings.mPosition = new Jolt.Vec3(-10 + x, 10 + y, -5)
let body = bodyInterface.CreateBody(creationSettings);
addToScene(body, 0xff0000);
}
});

</script>
</body>
</html>
61 changes: 61 additions & 0 deletions add_remove_bodies.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>JoltPhysics.js demo</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="container">Loading...</div>
<div id="info">JoltPhysics.js demo</div>

<script src="js/three/three.min.js"></script>
<script src="js/three/OrbitControls.js"></script>
<script src="js/three/WebGL.js"></script>
<script src="js/three/stats.min.js"></script>
<script src="js/example.js"></script>

<script type="module">
import initJolt from 'https://www.unpkg.com/jolt-physics/dist/jolt-physics.wasm-compat.js';

initJolt().then(function (Jolt) {
// Spawning variables
var objectTimePeriod = 0.01;
var timeNextSpawn = time + objectTimePeriod;

// Initialize this example
initExample(Jolt, onUpdate);

// Create a basic floor
createFloor();

function generateObject() {
// Position and rotate body
let pos = new Jolt.Vec3((Math.random() - 0.5) * 25, 15, (Math.random() - 0.5) * 25);
let rot = getRandomQuat();

// Create physics body
let shape = new Jolt.BoxShape(new Jolt.Vec3(0.5, 0.5, 0.5), 0.05, null);
let creationSettings = new Jolt.BodyCreationSettings(shape, pos, rot, Jolt.Dynamic, Jolt.MOVING);
creationSettings.mRestitution = 0.5;
let body = bodyInterface.CreateBody(creationSettings);

addToScene(body, 0xff0000);

if (dynamicObjects.length > 200)
removeFromScene(dynamicObjects[1]); // Leave the floor alone
}

function onUpdate(time, deltaTime) {
// Check if its time to spawn a new object
if (time > timeNextSpawn) {
generateObject();
timeNextSpawn = time + objectTimePeriod;
}
}
});

</script>
</body>
</html>
Loading

0 comments on commit ede12d1

Please sign in to comment.