Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support and integration with 'ammonext' physics. #10

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"presets": ["es2015"]
"presets": ["es2015", "stage-1"]
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ lib-cov
# Coverage directory used by tools like istanbul
coverage

# IDE
.idea

# nyc test coverage
.nyc_output

Expand Down
75 changes: 67 additions & 8 deletions app/app.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,98 @@
// Core
import {App} from '@whs/core/App';

// Core Modules
import {
ElementModule,
SceneModule,
CameraModule,
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();
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
}
}