-
Notifications
You must be signed in to change notification settings - Fork 98
Expand file tree
/
Copy pathper-body-gravity.html
More file actions
43 lines (39 loc) · 1.33 KB
/
per-body-gravity.html
File metadata and controls
43 lines (39 loc) · 1.33 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover"
/>
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Per Body Gravity</title>
<link rel="stylesheet" href="/css/examples.css?ver=1.0.0" />
<script src="/js/examples.js?ver=1.1.1"></script>
</head>
<body>
<div id="info-text">The Right Box uses a different Gravity.</div>
<script type="importmap">
{
"imports": {
"enable3d": "/lib/enable3d/enable3d.framework.0.26.0_dev0.module.min.js"
}
}
</script>
<script type="module">
import { Project, Scene3D, PhysicsLoader } from 'enable3d'
class MainScene extends Scene3D {
async create() {
const { camera, orbitControls } = await this.warpSpeed()
orbitControls.target.set(0, 3, 0)
camera.position.set(4, 4, 8)
camera.lookAt(0, 3, 0)
const leftBox = this.physics.add.box({ x: -1, y: 5 })
const rightBox = this.physics.add.box({ x: 1, y: 5 })
rightBox.body.setGravity(0, -1, 0)
}
}
PhysicsLoader('/lib/ammo', () => new Project({ scenes: [MainScene] }))
</script>
</body>
</html>