1.0.8 • Published 2 years ago

fakar v1.0.8

Weekly downloads
42
License
ISC
Repository
github
Last release
2 years ago

fixar.js

npm.io

GitHub GitHub

GitHub file size in bytes GitHub

GitHub Repo stars

JavaScript rendering tools library. Designed for use with Three.js.

FixAR Fixes your Aspect Ratio.

The aim of the project is to create an easy to use, lightweight JavaScript library that pairs nicely with other libraries that render to a canvas, such as Mr. Doob's Three.js.

I've always dreamed of making 3D visualizations and games in JavaScript. Three.js provides the means to do these things in a graspable way, but I've found that browser window resizes can be difficult to develop around. Users can resize their window at any time, which can introduce problems if you intended for your scene to be viewed at a specific aspect ratio.

That's where this library comes in! By automatically setting up letterboxing/pillarboxing, you no longer have to worry about resizes, nor do you need to call any kind of update() functions! This library also includes a few other neat features:

  • Change the letter/pillarbox color
  • Adjust resolution
  • Change AR on the fly

Usage

This code creates a scene, a camera, and a geometric cube, and it adds the cube to the scene. It then creates a WebGL renderer for the scene and camera, and it adds that viewport to the document.body element. Finally, it animates the cube within the scene for the camera.

import * as THREE from './js/three.module.js';

let camera, scene, renderer;
let geometry, material, mesh;

init();

function init() {

	camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 0.01, 10 );
	camera.position.z = 1;

	scene = new THREE.Scene();

	geometry = new THREE.BoxGeometry( 0.2, 0.2, 0.2 );
	material = new THREE.MeshNormalMaterial();

	mesh = new THREE.Mesh( geometry, material );
	scene.add( mesh );

	renderer = new THREE.WebGLRenderer( { antialias: true } );
	renderer.setSize( window.innerWidth, window.innerHeight );
	renderer.setAnimationLoop( animation );
	document.body.appendChild( renderer.domElement );

}

function animation( time ) {

	mesh.rotation.x = time / 2000;
	mesh.rotation.y = time / 1000;

	renderer.render( scene, camera );

}

If everything went well, you should see this.

Cloning this repository

Cloning the repo with all its history might take a while. If you don't need the whole history you can use the depth parameter to significantly reduce download size.

git clone --depth=1 https://github.com/BraidenPsiuk/fixar.js.git
1.0.8

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

0.0.3

3 years ago

0.0.2

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

0.0.1

3 years ago

1.0.0

2 years ago

0.0.0

3 years ago