提交 6fa0e41d 编写于 作者: J Jerome Etienne

more work

上级 d0df5ed4
......@@ -304,7 +304,13 @@ console.log('this.data.markerhelpers', this.data.markerhelpers)
}else console.assert(false)
// build a smoothedControls
this.arSmoothedControls = new THREEx.ArSmoothedControls(this.el.object3D)
this.arSmoothedControls = new THREEx.ArSmoothedControls(this.el.object3D,{
lerpPosition : 0.1,
lerpQuaternion : 0.1,
lerpScale : 0.1,
// minVisibleDelay: 0,
// minUnvisibleDelay: 0,
})
......
此差异已折叠。
因为 它太大了无法显示 source diff 。你可以改为 查看blob
......@@ -27,7 +27,7 @@
<a-animation attribute="rotation" to="360 0 0" dur="3000" easing='linear' repeat="indefinite"></a-animation>
</a-torus-knot>
</a-box>
<a-marker-camera preset='hiro'></a-marker-camera>
<a-marker-camera preset='area'></a-marker-camera>
</a-scene>
<!-- <a-scene embedded arjs='sourceType: webcam; trackingBackend: tango;'>
......
此差异已折叠。
因为 它太大了无法显示 source diff 。你可以改为 查看blob
<!DOCTYPE html>
<meta name='viewport' content='width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0'>
<!-- three.js library -->
<script src='../examples/vendor/three.js/build/three.js'></script>
<script src='../examples/vendor/three.js/build/three.min.js'></script>
<!-- include for artoolkit trackingBackend -->
<script src='../vendor/jsartoolkit5/build/artoolkit.min.js'></script>
<script src='../vendor/jsartoolkit5/js/artoolkit.api.js'></script>
......
......@@ -105,8 +105,8 @@
// detectionMode: 'color_and_matrix',
// matrixCodeType: '3x3',
// canvasWidth: 80*3,
// canvasHeight: 60*3,
canvasWidth: 80*3,
canvasHeight: 60*3,
maxDetectionRate: 30,
})
......
......@@ -17,7 +17,6 @@ ARjs.Session = function(parameters){
THREEx.ArMultiMarkerUtils.storeDefaultMultiMarkerFile(parameters.contextParameters.trackingBackend)
}
//////////////////////////////////////////////////////////////////////////////
// init arSource
//////////////////////////////////////////////////////////////////////////////
......@@ -35,7 +34,7 @@ ARjs.Session = function(parameters){
//////////////////////////////////////////////////////////////////////////////
// init arContext
//////////////////////////////////////////////////////////////////////////////
// create atToolkitContext
var arContext = _this.arContext = new THREEx.ArToolkitContext(parameters.contextParameters)
......
......@@ -8,26 +8,26 @@ THREEx.ArToolkitContext = function(parameters){
// handle default parameters
this.parameters = {
// AR backend - ['artoolkit', 'aruco', 'tango']
trackingBackend: parameters.trackingBackend !== undefined ? parameters.trackingBackend : 'artoolkit',
trackingBackend: 'artoolkit',
// debug - true if one should display artoolkit debug canvas, false otherwise
debug: parameters.debug !== undefined ? parameters.debug : false,
debug: false,
// the mode of detection - ['color', 'color_and_matrix', 'mono', 'mono_and_matrix']
detectionMode: parameters.detectionMode !== undefined ? parameters.detectionMode : 'mono',
detectionMode: 'mono',
// type of matrix code - valid iif detectionMode end with 'matrix' - [3x3, 3x3_HAMMING63, 3x3_PARITY65, 4x4, 4x4_BCH_13_9_3, 4x4_BCH_13_5_5]
matrixCodeType: parameters.matrixCodeType !== undefined ? parameters.matrixCodeType : '3x3',
matrixCodeType: '3x3',
// url of the camera parameters
cameraParametersUrl: parameters.cameraParametersUrl !== undefined ? parameters.cameraParametersUrl : THREEx.ArToolkitContext.baseURL + 'parameters/camera_para.dat',
cameraParametersUrl: THREEx.ArToolkitContext.baseURL + 'parameters/camera_para.dat',
// tune the maximum rate of pose detection in the source image
maxDetectionRate: parameters.maxDetectionRate !== undefined ? parameters.maxDetectionRate : 60,
maxDetectionRate: 60,
// resolution of at which we detect pose in the source image
canvasWidth: parameters.canvasWidth !== undefined ? parameters.canvasWidth : 640,
canvasHeight: parameters.canvasHeight !== undefined ? parameters.canvasHeight : 480,
canvasWidth: 640,
canvasHeight: 480,
// enable image smoothing or not for canvas copy - default to true
// https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/imageSmoothingEnabled
imageSmoothingEnabled : parameters.imageSmoothingEnabled !== undefined ? parameters.imageSmoothingEnabled : false,
imageSmoothingEnabled : false,
}
// parameters sanity check
console.assert(['artoolkit', 'aruco', 'tango'].indexOf(this.parameters.trackingBackend) !== -1, 'invalid parameter trackingBackend', this.parameters.trackingBackend)
......@@ -40,6 +40,8 @@ THREEx.ArToolkitContext = function(parameters){
this._arMarkersControls = []
this._setParameters(parameters)
}
Object.assign( THREEx.ArToolkitContext.prototype, THREE.EventDispatcher.prototype );
......@@ -50,6 +52,33 @@ THREEx.ArToolkitContext.baseURL = 'https://jeromeetienne.github.io/AR.js/three.j
THREEx.ArToolkitContext.REVISION = '1.0.1-dev'
/**
* set parameters
* @param {[type]} values [description]
* @return {[type]} [description]
*/
THREEx.ArToolkitContext.prototype._setParameters = function (values){
if ( values === undefined ) return;
for( var key in values ){
var newValue = values[ key ];
if( newValue === undefined ){
console.warn( "THREEx.ArToolkitContext: '" + key + "' parameter is undefined." );
continue;
}
var currentValue = this.parameters[ key ];
if( currentValue === undefined ){
console.warn( "THREEx.ArToolkitContext: '" + key + "' is not a property of this material." );
continue;
}
this.parameters[ key ] = newValue;
}
};
/**
* Create a default camera for this trackingBackend
* @param {string} trackingBackend - the tracking to user
......@@ -101,7 +130,7 @@ THREEx.ArToolkitContext.prototype.init = function(onCompleted){
THREEx.ArToolkitContext.prototype.update = function(srcElement){
// be sure arController is fully initialized
if (this.parameters.trackingBackend === 'artoolkit' && this.arController === null) return false;
if(this.parameters.trackingBackend === 'artoolkit' && this.arController === null) return false;
// honor this.parameters.maxDetectionRate
var present = performance.now()
......@@ -164,7 +193,7 @@ THREEx.ArToolkitContext.prototype._initArtoolkit = function(onCompleted){
this._artoolkitProjectionAxisTransformMatrix.multiply(new THREE.Matrix4().makeRotationZ(Math.PI))
// get cameraParameters
var cameraParameters = new ARCameraParam(_this.parameters.cameraParametersUrl, function() {
var cameraParameters = new ARCameraParam(_this.parameters.cameraParametersUrl, function(){
// init controller
var arController = new ARController(_this.parameters.canvasWidth, _this.parameters.canvasHeight, cameraParameters);
_this.arController = arController
......@@ -308,9 +337,9 @@ THREEx.ArToolkitContext.prototype._updateAruco = function(srcElement){
THREEx.ArToolkitContext.prototype._initTango = function(onCompleted){
var _this = this
// check webvr is available
if (navigator.getVRDisplays) {
if (navigator.getVRDisplays){
// do nothing
} else if (navigator.getVRDevices) {
} else if (navigator.getVRDevices){
alert("Your browser supports WebVR but not the latest version. See <a href='http://webvr.info'>webvr.info</a> for more info.");
} else {
alert("Your browser does not support WebVR. See <a href='http://webvr.info'>webvr.info</a> for assistance.");
......@@ -325,7 +354,7 @@ THREEx.ArToolkitContext.prototype._initTango = function(onCompleted){
// get vrDisplay
navigator.getVRDisplays().then(function (vrDisplays) {
navigator.getVRDisplays().then(function (vrDisplays){
if( vrDisplays.length === 0 ) alert('no vrDisplays available')
var vrDisplay = _this._tangoContext.vrDisplay = vrDisplays[0]
......@@ -339,7 +368,7 @@ THREEx.ArToolkitContext.prototype._initTango = function(onCompleted){
// NOTE it doesnt seem necessary and it fails on tango
// var canvasElement = document.createElement('canvas')
// document.body.appendChild(canvasElement)
// _this._tangoContext.requestPresent([{ source: canvasElement }]).then(function() {
// _this._tangoContext.requestPresent([{ source: canvasElement }]).then(function(){
// console.log('vrdisplay request accepted')
// });
......
......@@ -63,33 +63,35 @@ ARjs.Profile.prototype.reset = function () {
ARjs.Profile.prototype.performance = function(label) {
if( label === 'default' ){
label = this._guessPerformanceLabel()
}
if( label === 'desktop-fast' ){
this.contextParameters.sourceWidth = 640*3
this.contextParameters.sourceHeight = 480*3
this.contextParameters.canvasWidth = 640*3
this.contextParameters.canvasHeight = 480*3
this.contextParameters.maxDetectionRate = 30
}else if( label === 'desktop-normal' ){
this.contextParameters.sourceWidth = 640
this.contextParameters.sourceHeight = 480
this.contextParameters.canvasWidth = 640
this.contextParameters.canvasHeight = 480
this.contextParameters.maxDetectionRate = 60
}else if( label === 'phone-normal' ){
this.contextParameters.sourceWidth = 80*4
this.contextParameters.sourceHeight = 60*4
this.contextParameters.canvasWidth = 80*4
this.contextParameters.canvasHeight = 60*4
this.contextParameters.maxDetectionRate = 30
}else if( label === 'phone-slow' ){
this.contextParameters.sourceWidth = 80*3
this.contextParameters.sourceHeight = 60*3
this.contextParameters.canvasWidth = 80*3
this.contextParameters.canvasHeight = 60*3
this.contextParameters.maxDetectionRate = 30
}else {
console.assert(false, 'unknonwn label '+label)
}
return this
}
//////////////////////////////////////////////////////////////////////////////
......
......@@ -354,7 +354,9 @@ THREEx.ArToolkitSource.prototype.onResize2 = function(arToolkitContext, renderer
// UPDATE CAMERA
if( trackingBackend === 'artoolkit' ){
camera.projectionMatrix.copy( arToolkitContext.getProjectionMatrix() );
if( arToolkitContext.arController !== null ){
camera.projectionMatrix.copy( arToolkitContext.getProjectionMatrix() );
}
}else if( trackingBackend === 'aruco' ){
camera.aspect = renderer.domElement.width / renderer.domElement.height;
camera.updateProjectionMatrix();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册