diff --git a/.babelrc b/.babelrc index c13c5f6..36ef793 100644 --- a/.babelrc +++ b/.babelrc @@ -1,3 +1,3 @@ { - "presets": ["es2015"] + "presets": ["es2015", "stage-1"] } diff --git a/.gitignore b/.gitignore index 5148e52..f0bf54d 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,9 @@ lib-cov # Coverage directory used by tools like istanbul coverage +# IDE +.idea + # nyc test coverage .nyc_output diff --git a/app/app.js b/app/app.js index 98a1bcb..b307b63 100644 --- a/app/app.js +++ b/app/app.js @@ -1,6 +1,7 @@ // Core import {App} from '@whs/core/App'; +// Core Modules import { ElementModule, SceneModule, @@ -8,32 +9,90 @@ import { RenderingModule } from '@whs:app'; -import {OrbitModule} from '@whs:controls/orbit'; +import { + AmbientLight +} from '@whs+lights'; + +// Physics Modules +import { + WorldModule, + PlaneModule, + SphereModule +} from 'physics-module-ammonext'; +// Modules +import {OrbitModule} from '@whs:controls/orbit'; import {FancyMaterialModule} from './modules/FancyMaterialModule'; // Components -import {Plane} from '@whs+meshes/Plane'; import {BasicComponent} from './components/BasicComponent'; +// Mesh Components +import { + Plane, + Sphere +} from '@whs+meshes'; + +// App const app = new App([ + new WorldModule({ + ammo: 'http://localhost:8080/node_modules/three/examples/js/libs/ammo.js' + }), new ElementModule({ container: document.getElementById('app') }), new SceneModule(), new CameraModule({ position: { - z: -15 + y: 40, + z: 40, } }), new RenderingModule({bgColor: 0x000001}), new OrbitModule() ]); -app.add(new BasicComponent({ - modules: [ - new FancyMaterialModule(app) - ] -})); +// Physics Sphere +new Sphere({ + position: {y: 40}, + geometry: { + radius: 2, + widthSegments: 32, + heightSegments: 32 + }, + material: new THREE.MeshNormalMaterial(), + modules: [ + new FancyMaterialModule(app), + new SphereModule({ + mass: 10, + restitution: 2.5 + }) + ] +}).addTo(app); + +// Physics Plane +new Plane({ + geometry: { + width: 100, + height: 100 + }, + rotation: { + x: -Math.PI / 2 + }, + material: new THREE.MeshPhongMaterial({color: 0x447F8B}), + modules: [ + new PlaneModule({ + mass: 0, + restitution: 0.333 + }) + ] +}).addTo(app); + +// Global light +new AmbientLight({ + light: { + intensity: 0.7 + } +}).addTo(app); app.start(); diff --git a/package.json b/package.json index 1e7c410..3b2f7d5 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "babel-plugin-transform-runtime": "^6.23.0", "babel-preset-es2015": "^6.22.0", "babel-preset-es2015-native-modules": "^6.9.4", + "babel-preset-stage-1": "^6.22.0", "babel-register": "^6.22.0", "glsl-noise": "0.0.0", "glslify": "^6.0.1", @@ -38,9 +39,11 @@ "three": "^0.84.0", "uglifyjs-webpack-plugin": "^0.1.2", "webpack": "^2.2.0", - "webpack-dev-server": "^2.4.1" + "webpack-dev-server": "^2.4.1", + "worker-loader": "^0.8.0" }, "dependencies": { - "whs": "^2.0.0-beta.5" + "physics-module-ammonext": "^0.1.2", + "whs": "^2.0.0-beta.6" } }