Skip to content
/ ventea Public

ECS TypeScript game engine with WebGL and WebGPU support and NVidia PhysX integration

Notifications You must be signed in to change notification settings

Aliremu/ventea

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

npm version minzipped size code style: prettier

ventea

An ECS based game engine built in TypeScript with WebGL and WebGPU support and NVidia PhysX integration.

Table of contents

Getting Started

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.

Installation

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

Usage

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);
})();

Building a distribution version

$ npm run build

This task will create a distribution version of the project inside your local dist/ folder

Running the examples

$ cd examples
$ npm run dev

License

MIT License © Andrea SonnY

About

ECS TypeScript game engine with WebGL and WebGPU support and NVidia PhysX integration

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published