提交 b72fe9cf 编写于 作者: J Jerome Etienne

more work

上级 6b52e3fe
......@@ -225,6 +225,7 @@ var THREEx = THREEx || {}
THREEx.ArMarkerControls = function(context, object3d, parameters){
var _this = this
this.id = THREEx.ArMarkerControls.id++
this.context = context
// handle default parameters
this.parameters = {
......@@ -238,6 +239,8 @@ THREEx.ArMarkerControls = function(context, object3d, parameters){
barcodeValue : parameters.barcodeValue !== undefined ? parameters.barcodeValue : null,
// change matrix mode - [modelViewMatrix, cameraTransformMatrix]
changeMatrixMode : parameters.changeMatrixMode !== undefined ? parameters.changeMatrixMode : 'modelViewMatrix',
// minimal confidence in the marke recognition - between [0, 1] - default to 1
minConfidence: parameters.minConfidence !== undefined ? parameters.minConfidence : 0.6,
}
// sanity check
......@@ -271,6 +274,8 @@ THREEx.ArMarkerControls = function(context, object3d, parameters){
}
THREEx.ArMarkerControls.id = 0
THREEx.ArMarkerControls.prototype._postInit = function(){
var _this = this
var markerObject3D = this.object3d;
......@@ -324,13 +329,16 @@ THREEx.ArMarkerControls.prototype._postInit = function(){
return
function onMarkerFound(event){
// honor his.parameters.minConfidence
if( event.data.marker.cf < _this.parameters.minConfidence ) return
// mark object as visible
markerObject3D.visible = true
// data.matrix is the model view matrix
var modelViewMatrix = new THREE.Matrix4().fromArray(event.data.matrix)
// apply context._axisTransformMatrix - change artoolkit axis to match usual webgl one
var tmpMatrix = new THREE.Matrix4().copy(_this.context._projectionAxisTransformMatrix)
tmpMatrix.multiply(modelViewMatrix)
......@@ -351,7 +359,7 @@ THREEx.ArMarkerControls.prototype._postInit = function(){
console.assert(false)
}
// decompose the matrix into .position, .quaternion, .scale
// decompose - the matrix into .position, .quaternion, .scale
markerObject3D.matrix.decompose(markerObject3D.position, markerObject3D.quaternion, markerObject3D.scale)
// dispatchEvent
......@@ -369,6 +377,45 @@ THREEx.ArMarkerControls.prototype.dispose = function(){
}
var THREEx = THREEx || {}
THREEx.ArMarkerHelper = function(markerControls){
this.object3d = new THREE.Group
var mesh = new THREE.AxisHelper()
this.object3d.add(mesh)
// var text = markerControls.id
// debugger
var text = markerControls.parameters.patternUrl.slice(-1).toUpperCase();
var canvas = document.createElement( 'canvas' );
canvas.width = 64;
canvas.height = 64;
var context = canvas.getContext( '2d' );
var texture = new THREE.CanvasTexture( canvas );
// put the text in the sprite
context.font = '48px monospace';
context.fillStyle = 'rgba(192,192,255, 0.5)';
context.fillRect( 0, 0, canvas.width, canvas.height );
context.fillStyle = 'darkblue';
context.fillText(text, canvas.width/4, 3*canvas.height/4 )
texture.needsUpdate = true
// var geometry = new THREE.CubeGeometry(1, 1, 1)
var geometry = new THREE.PlaneGeometry(1, 1)
var material = new THREE.MeshBasicMaterial({
map: texture,
transparent: true
});
var mesh = new THREE.Mesh(geometry, material)
mesh.rotation.x = -Math.PI/2
this.object3d.add(mesh)
}
var THREEx = THREEx || {}
THREEx.ArToolkitContext = function(parameters){
var _this = this
......@@ -411,7 +458,8 @@ THREEx.ArToolkitContext = function(parameters){
Object.assign( THREEx.ArToolkitContext.prototype, THREE.EventDispatcher.prototype );
// THREEx.ArToolkitContext.baseURL = '../'
THREEx.ArToolkitContext.baseURL = 'https://raw.githubusercontent.com/jeromeetienne/ar.js/master/'
// default to github page
THREEx.ArToolkitContext.baseURL = 'https://jeromeetienne.github.io/AR.js/'
THREEx.ArToolkitContext.REVISION = '1.0.1-dev'
/**
......@@ -1454,6 +1502,7 @@ var Qb=[Ik,Zh,_h,Qj,Qi,Pi,Ri,Ag,sg,qg,rg,yg,kh,jh,Oi,Mj];var Rb=[Jk,ki,ji,gi];va
} else {
this.getTransMatSquare(i, visible.markerWidth, visible.matrix);
}
// this.getTransMatSquare(i, visible.markerWidth, visible.matrix);
visible.inCurrent = true;
this.transMatToGLMat(visible.matrix, this.transform_mat);
......
......@@ -41,9 +41,9 @@ THREEx.ArToolkitContext = function(parameters){
Object.assign( THREEx.ArToolkitContext.prototype, THREE.EventDispatcher.prototype );
THREEx.ArToolkitContext.baseURL = '../'
// THREEx.ArToolkitContext.baseURL = '../'
// default to github page
// THREEx.ArToolkitContext.baseURL = 'https://raw.githubusercontent.com/jeromeetienne/ar.js/master/three.js/'
THREEx.ArToolkitContext.baseURL = 'https://jeromeetienne.github.io/AR.js/'
THREEx.ArToolkitContext.REVISION = '1.0.1-dev'
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册