All Projects → nasikusa → three-fspy-camera-loader

nasikusa / three-fspy-camera-loader

Licence: MIT license
Script for importing fSpy camera data into three.js.

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects
CSS
56736 projects

Projects that are alternatives of or similar to three-fspy-camera-loader

element
Fast and simple custom elements.
Stars: ✭ 65 (+306.25%)
Mutual labels:  threejs, 3d-graphics
Kusabi
Coding environment 3D graphics with PureScript.
Stars: ✭ 72 (+350%)
Mutual labels:  threejs, 3d-graphics
Fspy
A cross platform app for quick and easy still image camera matching
Stars: ✭ 1,056 (+6500%)
Mutual labels:  camera-calibration, 3d-graphics
gzweb
Web client for Gazebo classic simulation
Stars: ✭ 36 (+125%)
Mutual labels:  threejs, 3d-graphics
Vue Gl
Vue.js components rendering 3D WebGL graphics reactively with three.js
Stars: ✭ 434 (+2612.5%)
Mutual labels:  threejs, 3d-graphics
Earth Defender
🚀 A distributed soft real-time 3D single/multiplayer game build with Erlang/OTP and Three.js
Stars: ✭ 7 (-56.25%)
Mutual labels:  threejs, 3d-graphics
PolyDraw
✳️ PTSource PolyDraw is a free 3D polygonal modeller for Windows x86 and x64, for creating or modifying 3D objects using a mesh of 3D points and parametric NURBS Curves .Exports and imports to over 40 formats including WebVR and 3D Printing.
Stars: ✭ 17 (+6.25%)
Mutual labels:  threejs, 3d-graphics
Glas
WebGL in WebAssembly with AssemblyScript
Stars: ✭ 278 (+1637.5%)
Mutual labels:  threejs, 3d-graphics
Map33.js
A JavaScript library to make 3D maps with three.js.
Stars: ✭ 317 (+1881.25%)
Mutual labels:  threejs, 3d-graphics
Lume
Create CSS3D/WebGL applications declaratively with HTML. Give regular DOM elements shadow and lighting.
Stars: ✭ 445 (+2681.25%)
Mutual labels:  threejs, 3d-graphics
Three.kt
Three.js port for the JVM (desktop)
Stars: ✭ 136 (+750%)
Mutual labels:  threejs, 3d-graphics
raytracing-go
A simple Go library for 3D ray-tracing rendering, implementing the book Ray Tracing in One Weekend. 📸
Stars: ✭ 53 (+231.25%)
Mutual labels:  3d-graphics
Pillar Valley
👾A cross-platform video game built with Expo, three.js, and Firebase! 🎮🕹
Stars: ✭ 242 (+1412.5%)
Mutual labels:  threejs
Webxr Emulator Extension
WebXR emulator extension
Stars: ✭ 231 (+1343.75%)
Mutual labels:  threejs
React Three A11y
♿️ Accessibility tools for React Three Fiber
Stars: ✭ 226 (+1312.5%)
Mutual labels:  threejs
fsharp-3d-and-gamedev
Resources on 3D Graphics Programming and Game Development in F#
Stars: ✭ 92 (+475%)
Mutual labels:  3d-graphics
pose-estimation-3d-with-stereo-camera
This demo uses a deep neural network and two generic cameras to perform 3D pose estimation.
Stars: ✭ 40 (+150%)
Mutual labels:  camera-calibration
Terrain Builder
🏔 Procedural terrain using Three.js and perlin noise, Now Accelerated by your GPU!
Stars: ✭ 228 (+1325%)
Mutual labels:  threejs
Xplan
A rotating earth H5 page with Vue and threejs
Stars: ✭ 226 (+1312.5%)
Mutual labels:  threejs
Maptalks.three
A maptalks Layer to render with THREE.js.
Stars: ✭ 226 (+1312.5%)
Mutual labels:  threejs

three-fspy-camera-loader

npm NPM Build Status

demo

demo page

What is this?

Script for importing fSpy camera data into three.js.

You can create a pseudo AR-like visual representation.

I made a demo on this page.

It takes in the json format camera data output by fSpy and converts it into the PerspetiveCamera of three.js.

three-fspy-camera-loader inherits the Loader object of three.js and can be used in the same way as other loaders.

I'm Japanese so I'm not good at English. So I'm sorry if I used the wrong English.

Installing from npm

$ npm install --save three-fspy-camera-loader

Examples

codesandbox(TypeScript)

If it doesn't work, reload.

Other examples are in preparation.

Link Collection

fSpy official website

fspy repository

fSpy video

fSpy importer addon for Blender

Getting Started

var loader = new FSpyCameraLoader();
var camera;

loader.load(
  'path/to/fSpyJsonFile',
  // onload
  function ( result ) {
    camera = result;
  },
  // onprogress
  function ( xhr ) {
    console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );
  },
  // onerror
  function ( error ) {
    console.log( 'ERROR' );
  }
);

If you want to include a background image, you can use the following example. Of course, other methods are also acceptable.

html,body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
}
#myCanvas {
  width: 100%;
  height: 100%;
  background-image: url(path/to/image);
  background-size: cover;
  background-position: 50% 50%;
  background-repeat: no-repeat;
}
var camera;

var renderer = new THREE.WebGLRenderer({
  canvas: document.querySelector('#myCanvas'),
  alpha: true,
});
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setClearColor(0x000000, 0);
renderer.setSize(window.innerWidth, window.innerHeight);

var scene = new THREE.Scene();
var geometry = new THREE.BoxGeometry(3, 3, 3);
var material = new THREE.MeshNormalMaterial();
var box = new THREE.Mesh(geometry, material);
box.position.set(0, 0, 0);
scene.add(box);

var fSpyCameraLoader = new FSpyCameraLoader();
fSpyCameraLoader.setCanvas(document.querySelector('#myCanvas'));
// If you want to make the behavior behave like CSS background-size: cover, use this function.
fSpyCameraLoader.setResizeUpdate();

fSpyCameraLoader.load('path/to/fSpyJson', function ( result ) {
  camera = result;
  renderLoop();
});

window.addEventListener('resize', function () {
  renderer.setSize(window.innerWidth, window.innerHeight);
});

function renderLoop() {
  requestAnimationFrame(renderLoop);
  renderer.render(scene, camera);
  box.rotation.y += 0.01;
}

Notice

json export

You can export json using fSpy from here.

export

Axis setting

When using with three.js, it is recommended that the Y-axis be up.

note

constructor

+ new FSpyCamerLoader(manager?: LoadingManager): FSpyCamerLoader

Overrides void

Defined in src/FSpyCameraLoader.ts:37

Parameters:

Name Type
manager? LoadingManager

Returns: FSpyCamerLoader

Main Properties

Name Type Description
.camera PerspectiveCamera PerspectiveCamera of three.js. The final result is stored on this camera.
.dataManager FSpyDataManager Class that manages camera data of fSpy. Mainly used internally.
more information
.targetCanvas HTMLCanvasElement | null Canvas that is the target for drawing WebGL. It is mainly used for updating the camera according to the resize.
.isEnableResizeEvent boolean (get) Gets whether the resize event is set.
(set) Enable / disable resize event

all properties

Main Methods

load

load(url: string, onLoad?: undefined | function, onProgress?: undefined | function, onError?: undefined | function): void

Defined in src/FSpyCameraLoader.ts:80

load fSpy's camera data json

Parameters:

Name Type Description
url string Path to camera data json to be exported by fSpy
onLoad? undefined | function Function after loading
onProgress? undefined | function Function being loaded. Probably not needed due to the small data size.
onError? undefined | function Function when the error occurred TODO: IE

Returns: void


loadAsync

loadAsync(url: string, onProgress?: undefined | function): Promise‹any›

Defined in node_modules/three/src/loaders/Loader.d.ts:20

Parameters:

Name Type Description
url string Path to camera data json to be exported by fSpy
onProgress? undefined | function Function being loaded. Probably not needed due to the small data size.

Returns: Promise‹any›


parse

parse(fSpyJson: FSpyCameraJson): PerspectiveCamera

Defined in src/FSpyCameraLoader.ts:115

Parses fSpy json data. This function is also called after the load function.

Parameters:

Name Type Description
fSpyJson FSpyCameraJson json data from fSpy. Please put the parsed one, such as JSON.parse (json) ;.

Returns: PerspectiveCamera

Camera using fSpy camera data


getComputedData

getComputedData(): FSpyCameraData | null

Defined in src/FSpyCameraLoader.ts:227

Get camera data processed for three.js

Returns: FSpyCameraData | null

json data from fSpy converted to data for three.js


getData

getData(): FSpyCameraJson | null

Defined in src/FSpyCameraLoader.ts:219

Get unprocessed internal camera data

Returns: FSpyCameraJson | null

json data output from fSpy


onResize

onResize(): void

Defined in src/FSpyCameraLoader.ts:195

Change the camera data according to the size of the canvas to render.

Returns: void


setCanvas

setCanvas(canvas: HTMLCanvasElement): void

Defined in src/FSpyCameraLoader.ts:124

Add the data for the canvas element for the library to know.

Parameters:

Name Type Description
canvas HTMLCanvasElement Canvas that is the target for drawing WebGL

Returns: void


removeCanvas

removeCanvas(): void

Defined in src/FSpyCameraLoader.ts:131

Remove the data for the canvas element.

Returns: void


setResizeUpdate

setResizeUpdate(): void

Defined in src/FSpyCameraLoader.ts:138

Enables the ability to change the camera data according to the size of the canvas to render.

Returns: void


removeResizeupdate

removeResizeupdate(): void

Defined in src/FSpyCameraLoader.ts:145

Disables the ability to change camera data to fit the size of the canvas to render.

Returns: void


all methods

API documentation

Please see here.

LISENCE

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].