1.0.1 • Published 2 years ago

wvgljs v1.0.1

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
2 years ago
npm install wvgljs --save

This will allow you to import wvglJS entirely using:

or individual classes to benefit from enhanced tree shaking using :

Usage

import { Engine } from "@wvgljs/core/Engines/engine";
import { Scene } from "@wvgljs/core/scene";
import { Vector3 } from "@wvgljs/core/Maths/math";
import { FreeCamera } from "@wvgljs/core/Cameras/freeCamera";
import { HemisphericLight } from "@wvgljs/core/Lights/hemisphericLight";
import { Mesh } from "@wvgljs/core/Meshes/mesh";

// Side-effects only imports allowing the standard material to be used as default.
import "@wvgljs/core/Materials/standardMaterial";
// Side-effects only imports allowing Mesh to create default shapes (to enhance tree shaking, the construction methods on mesh are not available if the meshbuilder has not been imported).
import "@wvgljs/core/Meshes/Builders/sphereBuilder";
import "@wvgljs/core/Meshes/Builders/boxBuilder";
import "@wvgljs/core/Meshes/Builders/groundBuilder";

const canvas = document.getElementById("renderCanvas") as HTMLCanvasElement;
const engine = new Engine(canvas);
var scene = new Scene(engine);

// This creates and positions a free camera (non-mesh)
var camera = new FreeCamera("camera1", new Vector3(0, 5, -10), scene);

// This targets the camera to scene origin
camera.setTarget(Vector3.Zero());

// This attaches the camera to the canvas
camera.attachControl(canvas, true);

// This creates a light, aiming 0,1,0 - to the sky (non-mesh)
var light = new HemisphericLight("light1", new Vector3(0, 1, 0), scene);

// Default intensity is 1. Let's dim the light a small amount
light.intensity = 0.7;

// Our built-in 'sphere' shape. Params: name, subdivs, size, scene
var sphere = Mesh.CreateSphere("sphere1", 16, 2, scene);

// Move the sphere upward 1/2 its height
sphere.position.y = 2;

// Our built-in 'ground' shape. Params: name, width, depth, subdivs, scene
Mesh.CreateGround("ground1", 6, 6, 2, scene);

engine.runRenderLoop(() => {
    scene.render();
});
1.0.1

2 years ago

1.0.0

2 years ago