Skip to content

Commit

Permalink
Merge branch 'babylonjs-cleanup' into dev
Browse files Browse the repository at this point in the history
Conflicts:
	babylon.js/README.md
	babylon.js/src/babylon-ar.js
	contribs/portableAR.js/build/portable-ar.js
  • Loading branch information
jeromeetienne committed Mar 14, 2018
2 parents 76e3b37 + 796199c commit e5230f9
Show file tree
Hide file tree
Showing 16 changed files with 379 additions and 410 deletions.
13 changes: 0 additions & 13 deletions babylon.js/Makefile

This file was deleted.

14 changes: 0 additions & 14 deletions babylon.js/README.md

This file was deleted.

Binary file removed babylon.js/examples/images/UV_Grid_Sm.jpg
Binary file not shown.
1 change: 0 additions & 1 deletion babylon.js/examples/images/UV_Grid_Sm.txt

This file was deleted.

261 changes: 0 additions & 261 deletions babylon.js/src/babylon-ar.js

This file was deleted.

1 change: 1 addition & 0 deletions contribs/babylon.js/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This folder is showing how to use AR.js on babylon.js
29 changes: 26 additions & 3 deletions babylon.js/examples/basic.html → contribs/babylon.js/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
<title>Babylon.js sample code</title>
<!-- include babylon.js -->
<script src="vendor/babylon.max.js"></script>

<!-- babylon-ar.js -->
<script src="../build/babylon-ar.js"></script>
<script src="../portableAR.js/build/portable-ar.js"></script>
<script>ARjs.Context.baseURL = '../../three.js/'</script>

<style>
Expand Down Expand Up @@ -40,6 +41,7 @@
<canvas id="renderCanvas"></canvas>
</div>
<script>
;(function(){
//////////////////////////////////////////////////////////////////////////////
// initialize babylon.js engine
//////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -89,9 +91,29 @@
scene.clearColor = new BABYLON.Color4(0, 0, 0, 0)

////////////////////////////////////////////////////////////////////////////////
// Set up Arjs.Profile
// Set up EasyARjs
////////////////////////////////////////////////////////////////////////////////
ARjs.Babylon.init(engine, scene, scene.cameras[0])
// create a easyARjs instance
var easyARjs = new EasyARjs(canvas, {
debugUI : true,
// renderThreejs: true
})
// run on every iteration of babylon.js engine
engine.runRenderLoop(function(){

// update easyARjs
easyARjs.update()

// update babylon camera with easyARjs cameraProjectionMatrix
var babylonCamera = scene.cameras[0]
var babylonMatrix = BABYLON.Matrix.FromArray(easyARjs.cameraProjectionMatrix)
babylonCamera.freezeProjectionMatrix(babylonMatrix)

// update babylon camera with easyARjs cameraTransformMatrix
var babylonMatrix = BABYLON.Matrix.FromArray(easyARjs.cameraTransformMatrix);
babylonCamera._computedViewMatrix = babylonMatrix
babylonCamera._computedViewMatrix.invert()
})

//////////////////////////////////////////////////////////////////////////////
// Code Separator
Expand All @@ -104,6 +126,7 @@
window.addEventListener("resize", function () {
engine.resize();
});
})()
</script>
</body>
</html>
File renamed without changes.
14 changes: 14 additions & 0 deletions contribs/portableAR.js/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
watch: build
fswatch -0 src/*.js ../../three.js/src/*/*.js | xargs -0 -n 1 -I {} make build

.PHONY: build
build:
(cd ../../three.js/ && make build)
cat \
../../three.js/examples/vendor/three.js/build/three.js \
../../three.js/build/ar.js \
src/portable-ar.js \
> build/portable-ar.js

minify: build
uglifyjs build/portable-ar.js > build/portable-ar.min.js
28 changes: 28 additions & 0 deletions contribs/portableAR.js/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# AR.js repackaged to be easy to port

This is a repackaged AR.js specifically repackaged to be super easy to port.

# How to use

First create the class

```js
// create a easyARjs instance
var easyARjs = new EasyARjs(webglCanvas, {
// debugUI : true,
// renderThreejs: true
})
```

Second update it on every frame

```js
// on every frame, be sure to update easyARjs
easyARjs.update()

// now easyARjs.cameraProjectionMatrix is the projection matrix for the camera
// - it is a matrix4x4 as an Array(16)

// now easyARjs.cameraTransformMatrix is the tranform matrix for the camera
// - it is a matrix4x4 as an Array(16)
```
File renamed without changes.
Loading

0 comments on commit e5230f9

Please sign in to comment.