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

started handling profile

上级 7152fff3
- GOAL: works well using only the positional tracking, not the stereo display
- thus it works well with all three.js examples
- handle resize - currently the canvas isnt using the css it should
- LATER: make it work with a-frame
......@@ -9,6 +9,7 @@
<!-- include threex.artoolkit -->
<script src="../threex-artoolkitsource.js"></script>
<script src="../threex-artoolkitcontext.js"></script>
<script src="../threex-artoolkitprofile.js"></script>
<script src="../threex-armarkercontrols.js"></script>
<body style='margin : 0px; overflow: hidden;'><div style='position: absolute; top: 10px; width:100%; text-align: center;';>
......@@ -58,22 +59,10 @@
// handle arToolkitSource
////////////////////////////////////////////////////////////////////////////////
var arToolkitSource = new THREEx.ArToolkitSource({
// to read from the webcam
sourceType : 'webcam',
// to read from an image
// sourceType : 'image',
// sourceUrl : '../../data/images/img.jpg',
// to read from a video
// sourceType : 'video',
// sourceUrl : '../../data/videos/headtracking.mp4',
// sourceWidth: 80*3,
// sourceHeight: 60*3,
//
})
var artoolkitProfile = new THREEx.ArToolkitProfile('guess')
var arToolkitSource = new THREEx.ArToolkitSource(artoolkitProfile.sourceParameters)
arToolkitSource.init(function onReady(){
// handle resize of renderer
......@@ -91,14 +80,7 @@
// create atToolkitContext
var arToolkitContext = new THREEx.ArToolkitContext({
cameraParametersUrl: '../../data/data/camera_para.dat',
detectionMode: 'mono',
imageSmoothingEnabled: false,
maxDetectionRate: 30,
sourceWidth: arToolkitSource.parameters.sourceWidth,
sourceHeight: arToolkitSource.parameters.sourceHeight,
})
var arToolkitContext = new THREEx.ArToolkitContext(artoolkitProfile.contextParameters)
// initialize it
arToolkitContext.init(function onCompleted(){
// copy projection matrix to camera
......@@ -120,11 +102,7 @@
var markerRoot = new THREE.Group
scene.add(markerRoot)
var artoolkitMarker = new THREEx.ArMarkerControls(arToolkitContext, markerRoot, {
type : 'pattern',
patternUrl : '../../data/data/patt.hiro'
// patternUrl : '../../data/data/patt.kanji'
})
var artoolkitMarker = new THREEx.ArMarkerControls(arToolkitContext, markerRoot, artoolkitProfile.defaultMarkerParameters)
//////////////////////////////////////////////////////////////////////////////////
// add an object in the scene
......
......@@ -25,7 +25,7 @@ THREEx.ArToolkitContext = function(parameters){
// 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 : true,
imageSmoothingEnabled : parameters.imageSmoothingEnabled !== undefined ? parameters.imageSmoothingEnabled : false,
}
this.arController = null;
......
var THREEx = THREEx || {}
THREEx.ArToolkitProfile = function(label){
if( label === 'guess' ) label = this._guessLabel()
this.reset()
this.setProfile(label)
}
THREEx.ArToolkitProfile.prototype.reset = function () {
this.sourceParameters = {}
this.contextParameters = {}
this.defaultMarkerParameters = {}
};
THREEx.ArToolkitProfile.prototype._guessLabel = function () {
// TODO implement this
return 'desktop'
};
THREEx.ArToolkitProfile.prototype.setProfile = function (label) {
if( 'desktop' ){
this.desktopProfile()
}else if( 'mobile' ){
this.mobileProfile()
}else console.assert('false')
};
THREEx.ArToolkitProfile.prototype.desktopProfile = function () {
this.sourceParameters = {
// to read from the webcam
sourceType : 'webcam',
// to read from an image
// sourceType : 'image',
// sourceUrl : '../../data/images/img.jpg',
// to read from a video
// sourceType : 'video',
// sourceUrl : '../../data/videos/headtracking.mp4',
// sourceWidth: 80*3,
// sourceHeight: 60*3,
//
}
this.contextParameters = {
cameraParametersUrl: THREEx.ArToolkitContext.baseURL + '../data/data/camera_para.dat',
detectionMode: 'mono',
maxDetectionRate: 30,
}
this.defaultMarkerParameters = {
type : 'pattern',
// patternUrl : THREEx.ArToolkitContext.baseURL + '../data/data/patt.hiro'
patternUrl : THREEx.ArToolkitContext.baseURL + '../data/data/patt.kanji'
}
}
THREEx.ArToolkitProfile.prototype.mobileProfile = function () {
this.sourceParameters = {
// to read from the webcam
sourceType : 'webcam',
// to read from an image
// sourceType : 'image',
// sourceUrl : '../../data/images/img.jpg',
// to read from a video
// sourceType : 'video',
// sourceUrl : '../../data/videos/headtracking.mp4',
sourceWidth: 80*3,
sourceHeight: 60*3,
//
}
this.contextParameters = {
cameraParametersUrl: THREEx.ArToolkitContext.baseURL + '../data/data/camera_para.dat',
detectionMode: 'mono',
maxDetectionRate: 30,
sourceWidth: this.sourceParameters.sourceWidth,
sourceHeight: this.sourceParameters.sourceHeight,
}
this.defaultMarkerParameters = {
type : 'pattern',
// patternUrl : THREEx.ArToolkitContext.baseURL + '../data/data/patt.hiro'
patternUrl : THREEx.ArToolkitContext.baseURL + '../data/data/patt.kanji'
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册