An ECS based game engine built in TypeScript with WebGL and WebGPU support and NVidia PhysX integration.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. Examples can be found in the examples directory and a demo website will be created soon.
Start with cloning this repo on your local machine:
$ git clone https://github.com/Aliremu/ventea.git
$ cd ventea
To install and set up the library, run:
$ npm install ventea
import * as VENTEA from 'ventea';
const canvas = document.createElement('canvas');
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
document.body.appendChild(canvas);
canvas.onclick = () => {
canvas.requestPointerLock();
};
(async () => {
// Initializes the engine with WebGL and physics disabled
const engine = new VENTEA.Engine(canvas);
await engine.init({
api: VENTEA.API.WebGL,
physics: false
});
// Creates perspective camera and first person controls
const camera = new VENTEA.PerspectiveCamera(90, canvas.width / canvas.height, 0.01, 1000.0);
const controls = new VENTEA.FirstPersonControls(camera);
controls.update();
const scene = new VENTEA.Scene();
// Creates a directional light and sets the color and direction
const light = scene.createEntity('Light');
light.addComponent(VENTEA.Light, { r: 2, g: 1.8, b: 1.4, type: VENTEA.LightType.Directional });
light.position.set(1, 1, 1);
const grid = scene.createEntity('Grid');
grid.addComponent(VENTEA.MeshRenderer, new VENTEA.GridMesh(100, 100));
const box = scene.createEntity('Box');
box.addComponent(VENTEA.MeshRenderer, new VENTEA.BoxMesh(2, 2, 2));
box.position.set(0, 1, 0);
// Resizes the canvas on window resize
window.addEventListener('resize', (e) => {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
camera.aspect = canvas.width / canvas.height;
camera.updateProjection();
VENTEA.Renderer.resize(window.innerWidth, window.innerHeight);
});
const render = (time: number) => {
controls.update();
// Rotates the box by 0.01 radians every frame on the y-axis
box.rotation.y += 0.01;
// Renders the scene
VENTEA.Renderer.renderScene(scene, time, camera);
requestAnimationFrame(render);
}
requestAnimationFrame(render);
})();
$ npm run build
This task will create a distribution version of the project
inside your local dist/
folder
$ cd examples
$ npm run dev
MIT License © Andrea SonnY