|
| 1 | +<!doctype html> |
| 2 | +<html lang="en"> |
| 3 | + <head> |
| 4 | + <meta charset="UTF-8" /> |
| 5 | + <meta |
| 6 | + name="viewport" |
| 7 | + content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover" |
| 8 | + /> |
| 9 | + <meta http-equiv="X-UA-Compatible" content="ie=edge" /> |
| 10 | + <title>Work with Objects Factory</title> |
| 11 | + <link rel="stylesheet" href="/css/examples.css?ver=1.0.0" /> |
| 12 | + <script src="/js/examples.js?ver=1.1.1"></script> |
| 13 | + <script src="/lib/nano.slim.0.0.15.min.js"></script> |
| 14 | + </head> |
| 15 | + |
| 16 | + <body> |
| 17 | + <script type="importmap"> |
| 18 | + { |
| 19 | + "imports": { |
| 20 | + "enable3d": "/lib/enable3d/enable3d.framework.0.26.0_dev0.module.min.js" |
| 21 | + } |
| 22 | + } |
| 23 | + </script> |
| 24 | + <script type="module"> |
| 25 | + import { Project, Scene3D, PhysicsLoader, THREE, VERSION, FLAT } from 'enable3d' |
| 26 | + const { jsx, render } = nanoJSX |
| 27 | + |
| 28 | + class MainScene extends Scene3D { |
| 29 | + create() { |
| 30 | + // remove orbitControls from warp speed features |
| 31 | + this.warpSpeed('-orbitControls') |
| 32 | + |
| 33 | + // adjust the camera |
| 34 | + this.camera.position.set(10, 10, 25) |
| 35 | + this.camera.lookAt(0, 5, 0) |
| 36 | + |
| 37 | + // enable physics debugging |
| 38 | + this.physics.debug.enable() |
| 39 | + this.physics.debug.mode(1) |
| 40 | + |
| 41 | + /** |
| 42 | + * Boxes |
| 43 | + */ |
| 44 | + const cube0 = this.make.box({ x: 2.5, y: 5 }) // make |
| 45 | + this.add.existing(cube0) // add to scene |
| 46 | + this.physics.add.existing(cube0) // add physics |
| 47 | + |
| 48 | + const cube1 = this.add.box({ x: 2.5, y: 10 }) // make and add to scene |
| 49 | + this.physics.add.existing(cube1) // add physics |
| 50 | + |
| 51 | + const cube2 = this.physics.add.box({ x: 2.5, y: 15 }) // make, add to scene and add physics |
| 52 | + |
| 53 | + /** |
| 54 | + * Spheres |
| 55 | + */ |
| 56 | + const sphere0 = this.make.sphere({ x: -2.5, y: 5 }) |
| 57 | + this.add.existing(sphere0) |
| 58 | + this.physics.add.existing(sphere0) |
| 59 | + |
| 60 | + const sphere1 = this.add.sphere({ x: -2.5, y: 10 }) |
| 61 | + this.physics.add.existing(sphere1) |
| 62 | + |
| 63 | + const sphere2 = this.physics.add.sphere({ x: -2.5, y: 15 }) |
| 64 | + } |
| 65 | + } |
| 66 | + |
| 67 | + PhysicsLoader('/lib/ammo/kripken', () => new Project({ scenes: [MainScene], antialias: true })) |
| 68 | + </script> |
| 69 | + </body> |
| 70 | +</html> |
0 commit comments