mirror of
https://github.com/WhitestormJS/whs.js.git
synced 2025-12-08 20:26:23 +00:00
72 lines
1.1 KiB
JavaScript
72 lines
1.1 KiB
JavaScript
import * as UTILS from '@utils';
|
|
|
|
const app = new WHS.App([
|
|
...UTILS.appModules({
|
|
position: new THREE.Vector3(0, 30, -100)
|
|
})
|
|
]);
|
|
|
|
const func = (u, v) =>
|
|
new THREE.Vector3(u * 100, Math.sin(u * 10) * 4, v * 100);
|
|
|
|
const terrain = new WHS.Parametric({
|
|
geometry: {
|
|
func,
|
|
slices: 40,
|
|
stacks: 40
|
|
},
|
|
|
|
shadow: {
|
|
cast: false
|
|
},
|
|
|
|
material: new THREE.MeshPhongMaterial({
|
|
color: UTILS.$colors.mesh,
|
|
side: THREE.DoubleSide
|
|
}),
|
|
|
|
modules: [
|
|
new PHYSICS.HeightfieldModule({
|
|
mass: 0,
|
|
size: new THREE.Vector2(40, 40),
|
|
autoAlign: true
|
|
})
|
|
]
|
|
});
|
|
|
|
terrain.addTo(app);
|
|
|
|
const sphere = new WHS.Sphere({
|
|
geometry: {
|
|
radius: 1,
|
|
widthSegments: 32,
|
|
heightSegments: 32
|
|
},
|
|
|
|
modules: [
|
|
new PHYSICS.SphereModule({
|
|
mass: 2,
|
|
restitution: 1
|
|
})
|
|
],
|
|
|
|
material: new THREE.MeshPhongMaterial({
|
|
color: UTILS.$colors.mesh
|
|
}),
|
|
|
|
position: new THREE.Vector3(-31, 20, 0) // -30, 120, -40
|
|
});
|
|
|
|
sphere.addTo(app);
|
|
|
|
UTILS.addBasicLights(app, 0.5, [0, 10, 10], 100, {
|
|
bias: 0.0001,
|
|
radius: 2,
|
|
|
|
camera: {
|
|
fov: 90
|
|
}
|
|
});
|
|
|
|
app.start(); // Start animations and physics simulation.
|