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

more work

上级 0ce0aae4
## New API - aframe
- buttons aframe doesnt work
- how to create the scene dynamically in aframe
- handle that with a reload
- rename HitTester into HitTesting
- do a button - display-hittester-plane
- in three.js and in aframe.js
- maybe a class arjs-session-debugui.js
- create the UI
- let user attach it to the dom
- rename arjsmarker aframe component into arjs-anchor
- with backward compatibility ? no need
- implement working build
- apparently some issue if artoolkit is included in the build
- it worked in aframe before... what is happening
- what if i change the order of the scripts
- implement picking in aframe
- first make it works
- then find a good API
- <ar-hittester enabled='true' renderDebug='false'> inside the controlled object
- buttons aframe doesnt work
- how to create the scene dynamically in aframe
- handle that with a reload
- better handling of the area stuff in trackingMethod
-
- FIXME in aframe, i define .initialised but aframe defined .initialized..!?!?! super error prone
- rename as in isReady ? better than nothing. good for now
- honor marker preset
- hiro + kanji and area
- old issue with the same markers ?? deep in jsartoolkit
......@@ -26,6 +44,7 @@
- <ar-anchor>
- REFACTOR trackingMethod - should i put changeMatrixMode into trackingMethod ?
- should just drop it ? ??? why insit. it seems trouble
- it is needed for all the test and all
- what is trackingMethod ? it is unclear and messy
- trackingMethod = trackingBackend + defaultAnchorDefinition
......@@ -53,6 +72,7 @@
- this is not a threex
- in arjs.session.js - TODO change that to a usual this.parameters
- do emulation layer with display
- LATER aruco got perspective issue - likely camera init
......
<!DOCTYPE html>
<!-- include a-frame -->
<!-- <script src="vendor/aframe.js"></script> -->
<script src="vendor/aframe-v0.6.1-three-r86.js"></script>
<!-- include for artoolkit trackingBackend -->
<script src='../../three.js/vendor/jsartoolkit5/build/artoolkit.min.js'></script>
<script src='../../three.js/vendor/jsartoolkit5/js/artoolkit.api.js'></script>
<!-- include for aruco trackingBackend -->
<script src='../../three.js/vendor/js-aruco/src/svd.js'></script>
<script src='../../three.js/vendor/js-aruco/src/posit1.js'></script>
<script src='../../three.js/vendor/js-aruco/src/cv.js'></script>
<script src='../../three.js/vendor/js-aruco/src/aruco.js'></script>
<script src='../../three.js/src/threex/threex-aruco/threex-arucocontext.js'></script>
<script src='../../three.js/src/threex/threex-aruco/threex-arucodebug.js'></script>
<!-- include for tango trackingBackend -->
<script src='../../three.js/vendor/chromium-tango/THREE.WebAR.js'></script>
<!-- include ar.js -->
<script src='../../three.js/src/threex/threex-artoolkitprofile.js'></script>
<script src='../../three.js/src/threex/threex-artoolkitsource.js'></script>
<script src='../../three.js/src/threex/threex-artoolkitcontext.js'></script>
<script src='../../three.js/src/threex/threex-arbasecontrols.js'></script>
<script src='../../three.js/src/threex/threex-armarkercontrols.js'></script>
<script src='../../three.js/src/threex/threex-arsmoothedcontrols.js'></script>
<script src='../../three.js/src/threex/threex-hittester-plane.js'></script>
<script src='../../three.js/src/threex/threex-hittester-tango.js'></script>
<script src='../../three.js/src/threex/threex-armarkerhelper.js'></script>
<script src='../../three.js/src/new-api/arjs-utils.js'></script>
<script src='../../three.js/src/new-api/arjs-session.js'></script>
<script src='../../three.js/src/new-api/arjs-anchor.js'></script>
<script src='../../three.js/src/new-api/arjs-hittester.js'></script>
<script src='../../three.js/src/new-api/arjs-tangovideomesh.js'></script>
<script src='../../three.js/src/new-api/arjs-tangopointcloud.js'></script>
<script src='../../three.js/src/markers-area/threex-armultimarkerutils.js'></script>
<script src='../../three.js/src/markers-area/threex-armultimarkercontrols.js'></script>
<script src='../../three.js/src/markers-area/threex-armultimarkerlearning.js'></script>
<!-- include aframe-ar.js -->
<script src="../src/system-ar-session.js"></script>
<script src="../src/component-anchor.js"></script>
<script src="../src/component-hit-tester.js"></script>
<!-- include ar.js for aframe -->
<script src="../build/aframe-ar.js"></script>
<script>ARjs.Context.baseURL = '../../three.js/'</script>
<body style='margin : 0px; overflow: hidden; font-family: Monospace; background-color: black;'>
<div style='position: fixed; top: 10px; width:inherit; text-align: center; z-index: 1;'>
<a href="https://github.com/jeromeetienne/AR.js/" target="_blank">AR.js</a> - tango example for a-frame by <a href='https://twitter.com/jerome_etienne' target='_blank'>@jerome_etienne</a>
<br/>
<strong>Tracking Method:</strong> <span id='trackingMethod'>unknown</span>
-
Switch to :
<a href='#artoolkit' onclick='location.reload()'>artoolkit</a>
/
<a href='#aruco' onclick='location.reload()'>aruco</a>
/
<a href='#area-artoolkit' onclick='location.reload()'>area artoolkit</a>
/
<a href='#area-aruco' onclick='location.reload()'>area aruco</a>
/
<a href='#tango' onclick='location.reload()'>tango</a>
/
<a href='#best' onclick='location.reload()'>best</a>
<br/>
<a href='javascript:void(0)' id='buttonTangoTogglePointCloud'>toggle-point-cloud</a>
<a href='javascript:void(0)' id='buttonToggleMarkerHelpers'>toggle-marker-helper</a>
<a href='javascript:void(0)' id='buttonMarkersAreaLearner'>Learn-new-marker-area</a>
<a href='javascript:void(0)' id='buttonMarkersAreaReset'>Reset-marker-area</a>
</div>
<body style='margin : 0px; overflow: hidden;'>
<!-- Define your scene -->
<a-scene embedded arjs='trackingMethod: best'>
<a-entity arjsmarker arjs-hit-tester>
<!-- Create a anchor to attach your augmented reality -->
<a-entity arjsmarker arjs-hit-testing>
<!-- Add your augmented reality here -->
<a-box position='0 0.5 0' material='color:red'></a-box>
</a-entity>
<!-- Define a static camera -->
<a-camera-static/>
</a-scene>
</body>
</html>
......@@ -21,13 +21,13 @@
<script src='../../three.js/src/threex/threex-arbasecontrols.js'></script>
<script src='../../three.js/src/threex/threex-armarkercontrols.js'></script>
<script src='../../three.js/src/threex/threex-arsmoothedcontrols.js'></script>
<script src='../../three.js/src/threex/threex-hittester-plane.js'></script>
<script src='../../three.js/src/threex/threex-hittester-tango.js'></script>
<script src='../../three.js/src/threex/threex-hittesting-plane.js'></script>
<script src='../../three.js/src/threex/threex-hittesting-tango.js'></script>
<script src='../../three.js/src/threex/threex-armarkerhelper.js'></script>
<script src='../../three.js/src/new-api/arjs-utils.js'></script>
<script src='../../three.js/src/new-api/arjs-session.js'></script>
<script src='../../three.js/src/new-api/arjs-anchor.js'></script>
<script src='../../three.js/src/new-api/arjs-hittester.js'></script>
<script src='../../three.js/src/new-api/arjs-hittesting.js'></script>
<script src='../../three.js/src/new-api/arjs-tangovideomesh.js'></script>
<script src='../../three.js/src/new-api/arjs-tangopointcloud.js'></script>
<script src='../../three.js/src/markers-area/threex-armultimarkerutils.js'></script>
......@@ -36,7 +36,7 @@
<!-- include aframe-ar.js -->
<script src="../src/system-ar-session.js"></script>
<script src="../src/component-anchor.js"></script>
<script src="../src/component-hit-tester.js"></script>
<script src="../src/component-hit-testing.js"></script>
<script>ARjs.Context.baseURL = '../../three.js/'</script>
......@@ -66,9 +66,11 @@
</div>
<a-scene embedded arjs='trackingMethod: best; debugUIEnabled: true;'>
<a-entity arjsmarker arjs-hit-tester>
<a-entity arjsmarker arjs-hit-testing>
<a-box position='0 0.5 0' material='opacity: 0.5; side:double; color:red;'></a-box>
</a-entity>
<a-entity camera></a-entity>
......
//////////////////////////////////////////////////////////////////////////////
// arjsmarker
//////////////////////////////////////////////////////////////////////////////
AFRAME.registerComponent('arjs-hit-tester', {
AFRAME.registerComponent('arjs-hit-testing', {
dependencies: ['arjs', 'artoolkit'],
schema: {
enabled : {
......@@ -21,7 +21,7 @@ AFRAME.registerComponent('arjs-hit-tester', {
//
_this.initialised = false
_this._arAnchor = null
_this._arHitTester = null
_this._arHitTesting = null
// trick to wait until arjsSystem is initialised
var startedAt = Date.now()
......@@ -40,7 +40,7 @@ AFRAME.registerComponent('arjs-hit-tester', {
var arSession = arjsSystem._arSession
var renderer = arSession.renderer
var hitTester = _this._arHitTester = new ARjs.HitTester(arSession)
var hitTester = _this._arHitTesting = new ARjs.HitTesting(arSession)
// tango only - picking to set object position
renderer.domElement.addEventListener("click", function(domEvent){
......@@ -71,8 +71,8 @@ AFRAME.registerComponent('arjs-hit-tester', {
var arAnchor = arjsMarker._arAnchor
var hitTester = this._arHitTester
var camera = arSession.camera
var hitTester = this._arHitTesting
var camera = arSession.parameters.camera
// console.log(camera.position)
hitTester.update(camera, arAnchor.object3d, arAnchor.parameters.changeMatrixMode)
}
......@@ -82,12 +82,12 @@ AFRAME.registerComponent('arjs-hit-tester', {
// define some primitives shortcuts
//////////////////////////////////////////////////////////////////////////////
AFRAME.registerPrimitive('a-hit-tester', AFRAME.utils.extendDeep({}, AFRAME.primitives.getMeshMixin(), {
AFRAME.registerPrimitive('a-hit-testing', AFRAME.utils.extendDeep({}, AFRAME.primitives.getMeshMixin(), {
defaultComponents: {
'arjs-hit-tester': {},
'arjs-hit-testing': {},
},
mappings: {
'enabled': 'arjs-hit-tester.enabled',
'renderDebug': 'arjs-hit-tester.renderDebug',
'enabled': 'arjs-hit-testing.enabled',
'renderDebug': 'arjs-hit-testing.renderDebug',
}
}));
watch: build
fswatch -0 three.js/*.js | xargs -0 -n 1 -I {} make build
fswatch -0 src/*/*.js | xargs -0 -n 1 -I {} make build
.PHONY: build
build:
(cd src/threex/threex-aruco && make build)
cat vendor/jsartoolkit5/build/artoolkit.min.js \
vendor/jsartoolkit5/js/artoolkit.api.js \
src/threex/threex-aruco/build/threex-aruco.js \
vendor/chromium-tango/THREE.WebAR.js \
src/threex/*.js \
echo > build/ar.js
cat src/threex/*.js \
src/new-api/*.js \
src/markers-area/*.js \
> build/ar.js
src/markers-area/*.js >> build/ar.js
cat vendor/jsartoolkit5/build/artoolkit.min.js \
vendor/jsartoolkit5/js/artoolkit.api.js >> build/ar.js
cat src/threex/threex-aruco/build/threex-aruco.js >> build/ar.js
cat vendor/chromium-tango/THREE.WebAR.js >> build/ar.js
.PHONY: build
minify: build
uglifyjs build/ar.js > build/ar.min.js
......
此差异已折叠。
因为 它太大了无法显示 source diff 。你可以改为 查看blob
......@@ -6,11 +6,11 @@
<script src='../vendor/jsartoolkit5/build/artoolkit.min.js'></script>
<script src='../vendor/jsartoolkit5/js/artoolkit.api.js'></script>
<!-- include for aruco trackingBackend -->
<script src='../vendor/js-aruco/src/svd.js'></script>
<script src='../vendor/js-aruco/src/posit1.js'></script>
<script src='../vendor/js-aruco/src/cv.js'></script>
<script src='../vendor/js-aruco/src/aruco.js'></script>
<script src='../src/threex/threex-aruco/threex-arucocontext.js'></script>
<script src='../vendor/js-aruco/src/svd.js'></script>
<script src='../vendor/js-aruco/src/posit1.js'></script>
<script src='../vendor/js-aruco/src/cv.js'></script>
<script src='../vendor/js-aruco/src/aruco.js'></script>
<script src='../src/threex/threex-aruco/threex-arucocontext.js'></script>
<script src='../src/threex/threex-aruco/threex-arucodebug.js'></script>
<!-- include for tango trackingBackend -->
<script src='../vendor/chromium-tango/THREE.WebAR.js'></script>
......@@ -22,17 +22,19 @@
<script src='../src/threex/threex-armarkercontrols.js'></script>
<script src='../src/threex/threex-armarkerhelper.js'></script>
<script src='../src/threex/threex-arsmoothedcontrols.js'></script>
<script src='../src/threex/threex-hittester-plane.js'></script>
<script src='../src/threex/threex-hittester-tango.js'></script>
<script src='../src/threex/threex-hittesting-plane.js'></script>
<script src='../src/threex/threex-hittesting-tango.js'></script>
<script src='../src/new-api/arjs-utils.js'></script>
<script src='../src/new-api/arjs-session.js'></script>
<script src='../src/new-api/arjs-anchor.js'></script>
<script src='../src/new-api/arjs-hittester.js'></script>
<script src='../src/new-api/arjs-hittesting.js'></script>
<script src='../src/new-api/arjs-tangovideomesh.js'></script>
<script src='../src/new-api/arjs-tangopointcloud.js'></script>
<script src='../src/markers-area/threex-armultimarkerutils.js'></script>
<script src='../src/markers-area/threex-armultimarkercontrols.js'></script>
<script src='../src/markers-area/threex-armultimarkerlearning.js'></script>
<script>ARjs.Context.baseURL = '../'</script>
<body style='margin : 0px; overflow: hidden; font-family: Monospace;'><div style='position: absolute; top: 10px; width:100%; text-align: center; z-index: 1;'>
......@@ -63,6 +65,7 @@
<a href='javascript:void(0)' id='buttonToggleMarkerHelpers'>toggle-marker-helper</a>
<a href='javascript:void(0)' id='buttonMarkersAreaLearner'>Learn-new-marker-area</a>
<a href='javascript:void(0)' id='buttonMarkersAreaReset'>Reset-marker-area</a>
<a href='javascript:void(0)' id='displayHittestingPlane'>Display-hit-testing-plane</a>
</div><script>
;(function(){
// get tracking method from location.hash
......@@ -145,14 +148,14 @@
// handle Hit Tester
//////////////////////////////////////////////////////////////////////////////
var hitTester = new ARjs.HitTester(arSession)
var hitTesting = new ARjs.HitTesting(arSession)
onRenderFcts.push(function(){
hitTester.update(camera, arAnchor.object3d, arAnchor.parameters.changeMatrixMode)
hitTesting.update(camera, arAnchor.object3d, arAnchor.parameters.changeMatrixMode)
})
// tango only - picking to set object position
renderer.domElement.addEventListener("click", function(domEvent){
var hitTestResults = hitTester.testDomEvent(domEvent)
var hitTestResults = hitTesting.testDomEvent(domEvent)
if( hitTestResults.length === 0 ) return
var hitTestResult = hitTestResults[0]
......@@ -169,6 +172,9 @@
onRenderFcts.push(function(){
tangoVideoMesh.update()
})
}
if( arProfile.contextParameters.trackingBackend === 'tango' ){
// init tangoPointCloud
var tangoPointCloud = new ARjs.TangoPointCloud(arSession)
scene.add(tangoPointCloud.object3d)
......@@ -238,7 +244,7 @@
var learnerBaseURL = THREEx.ArToolkitContext.baseURL + 'examples/multi-markers/examples/learner.html'
var trackingBackend = arProfile.contextParameters.trackingBackend
ARjs.MarkersAreaUtils.navigateToLearnerPage(learnerBaseURL, trackingBackend)
})
})
}else{
document.querySelector('#buttonToggleMarkerHelpers').style.display = 'none'
document.querySelector('#buttonMarkersAreaReset').style.display = 'none'
......@@ -259,10 +265,10 @@
tangoVideoMesh.render()
}
// render hitTester pickingPlane - for debug
var renderHitTesterPickingPlane = true
if( renderHitTesterPickingPlane && hitTester._hitTesterPlane){
hitTester._hitTesterPlane.renderDebug(renderer)
// render hitTesting pickingPlane - for debug
var renderHitTestingPickingPlane = true
if( renderHitTestingPickingPlane && hitTesting._hitTestingPlane){
hitTesting._hitTestingPlane.renderDebug(renderer)
}
renderer.render( scene, camera );
......
......@@ -13,8 +13,8 @@ var ARjs = ARjs || {}
ARjs.Anchor = function(arSession, markerParameters){
var _this = this
var arContext = arSession.arContext
var scene = arSession.scene
var camera = arSession.camera
var scene = arSession.parameters.scene
var camera = arSession.parameters.camera
this.parameters = markerParameters
......@@ -124,7 +124,7 @@ ARjs.Anchor = function(arSession, markerParameters){
/**
* Apply ARjs.Session.HitTestResult to the controlled object3d
*
* @param {ARjs.HitTester.Result} hitTestResult - the result to apply
* @param {ARjs.HitTesting.Result} hitTestResult - the result to apply
*/
ARjs.Anchor.prototype.applyHitTestResult = function(hitTestResult){
......
......@@ -7,19 +7,20 @@ var ARjs = ARjs || {}
* @param {ARjs.Session} arSession - the session on which we create the anchor
* @param {Object} markerParameters - parameter of this anchor
*/
ARjs.HitTester = function(arSession){
ARjs.HitTesting = function(arSession){
var _this = this
var arContext = arSession.arContext
var trackingBackend = arContext.parameters.trackingBackend
this.enabled = true
this._arSession = arSession
this._hitTesterPlane = null
this._hitTesterTango = null
this._hitTestingPlane = null
this._hitTestingTango = null
if( trackingBackend === 'tango' ){
_this._hitTesterTango = new THREEx.HitTesterTango(arContext)
_this._hitTestingTango = new THREEx.HitTestingTango(arContext)
}else{
_this._hitTesterPlane = new THREEx.HitTesterPlane(arSession.arSource.domElement)
_this._hitTestingPlane = new THREEx.HitTestingPlane(arSession.arSource.domElement)
}
}
......@@ -32,11 +33,14 @@ ARjs.HitTester = function(arSession){
* @param {THREE.Camera} camera - the camera to use
* @param {THREE.Object3D} object3d -
*/
ARjs.HitTester.prototype.update = function (camera, pickingRoot, changeMatrixMode) {
if( this._hitTesterTango !== null ){
this._hitTesterTango.update()
}else if( this._hitTesterPlane !== null ){
this._hitTesterPlane.update(camera, pickingRoot, changeMatrixMode)
ARjs.HitTesting.prototype.update = function (camera, pickingRoot, changeMatrixMode) {
// if it isnt enabled, do nothing
if( this.enabled === false ) return
if( this._hitTestingTango !== null ){
this._hitTestingTango.update()
}else if( this._hitTestingPlane !== null ){
this._hitTestingPlane.update(camera, pickingRoot, changeMatrixMode)
}else console.assert(false)
}
......@@ -49,11 +53,14 @@ ARjs.HitTester.prototype.update = function (camera, pickingRoot, changeMatrixMod
*
* @param {Number} mouseX - position X of the hit [-1, +1]
* @param {Number} mouseY - position Y of the hit [-1, +1]
* @return {[ARjs.HitTester.Result]} - array of result
* @return {[ARjs.HitTesting.Result]} - array of result
*/
ARjs.HitTester.prototype.testDomEvent = function(domEvent){
ARjs.HitTesting.prototype.testDomEvent = function(domEvent){
var trackingBackend = this._arSession.arContext.parameters.trackingBackend
var arSource = this._arSession.arSource
// if it isnt enabled, do nothing
if( this.enabled === false ) return
if( trackingBackend === 'tango' ){
var mouseX = domEvent.pageX / window.innerWidth
......@@ -72,41 +79,44 @@ ARjs.HitTester.prototype.testDomEvent = function(domEvent){
*
* @param {Number} mouseX - position X of the hit [0, +1]
* @param {Number} mouseY - position Y of the hit [0, +1]
* @return {[ARjs.HitTester.Result]} - array of result
* @return {[ARjs.HitTesting.Result]} - array of result
*/
ARjs.HitTester.prototype.test = function(mouseX, mouseY){
ARjs.HitTesting.prototype.test = function(mouseX, mouseY){
var arContext = this._arSession.arContext
var trackingBackend = arContext.parameters.trackingBackend
var hitTestResults = []
// if it isnt enabled, do nothing
if( this.enabled === false ) return
var result = null
if( trackingBackend === 'tango' ){
var result = this._hitTesterTango.test(mouseX, mouseY)
var result = this._hitTestingTango.test(mouseX, mouseY)
}else{
var result = this._hitTesterPlane.test(mouseX, mouseY)
var result = this._hitTestingPlane.test(mouseX, mouseY)
}
// if no result is found, return now
if( result === null ) return hitTestResults
// build a ARjs.HitTester.Result
var hitTestResult = new ARjs.HitTester.Result(result.position, result.quaternion, result.scale)
// build a ARjs.HitTesting.Result
var hitTestResult = new ARjs.HitTesting.Result(result.position, result.quaternion, result.scale)
hitTestResults.push(hitTestResult)
return hitTestResults
}
//////////////////////////////////////////////////////////////////////////////
// ARjs.HitTester.Result
// ARjs.HitTesting.Result
//////////////////////////////////////////////////////////////////////////////
/**
* Contains the result of ARjs.HitTester.test()
* Contains the result of ARjs.HitTesting.test()
*
* @param {THREE.Vector3} position - position to use
* @param {THREE.Quaternion} quaternion - quaternion to use
* @param {THREE.Vector3} scale - scale
*/
ARjs.HitTester.Result = function(position, quaternion, scale){
ARjs.HitTesting.Result = function(position, quaternion, scale){
this.position = position
this.quaternion = quaternion
this.scale = scale
......
......@@ -7,11 +7,59 @@ var ARjs = ARjs || {}
*/
ARjs.Session = function(parameters){
var _this = this
// handle default parameters
this.parameters = {
renderer: null,
camera: null,
scene: null,
sourceParameters: {},
contextParameters: {},
}
//////////////////////////////////////////////////////////////////////////////
// setParameters
//////////////////////////////////////////////////////////////////////////////
setParameters(parameters)
function setParameters(parameters){
if( parameters === undefined ) return
for( var key in parameters ){
var newValue = parameters[ key ]
if( newValue === undefined ){
console.warn( "THREEx.Session: '" + key + "' parameter is undefined." )
continue
}
var currentValue = _this.parameters[ key ]
if( currentValue === undefined ){
console.warn( "THREEx.Session: '" + key + "' is not a property of this material." )
continue
}
_this.parameters[ key ] = newValue
}
}
// sanity check
console.assert(this.parameters.renderer instanceof THREE.WebGLRenderer)
console.assert(this.parameters.camera instanceof THREE.Camera)
console.assert(this.parameters.scene instanceof THREE.Scene)
// backward emulation
Object.defineProperty(this, 'renderer', {get: function(){
console.warn('use .parameters.renderer renderer')
return this.parameters.renderer;
}});
Object.defineProperty(this, 'camera', {get: function(){
console.warn('use .parameters.camera instead')
return this.parameters.camera;
}});
Object.defineProperty(this, 'scene', {get: function(){
console.warn('use .parameters.scene instead')
return this.parameters.scene;
}});
// TODO change that to a usual this.parameters
this.renderer = parameters.renderer
this.camera = parameters.camera
this.scene = parameters.scene
// log the version
console.log('AR.js', ARjs.Context.REVISION, '- trackingBackend:', parameters.contextParameters.trackingBackend)
......@@ -22,12 +70,12 @@ ARjs.Session = function(parameters){
var arSource = _this.arSource = new ARjs.Source(parameters.sourceParameters)
arSource.init(function onReady(){
arSource.onResize(arContext, _this.renderer, _this.camera)
arSource.onResize(arContext, _this.parameters.renderer, _this.parameters.camera)
})
// handle resize
window.addEventListener('resize', function(){
arSource.onResize(arContext, _this.renderer, _this.camera)
arSource.onResize(arContext, _this.parameters.renderer, _this.parameters.camera)
})
//////////////////////////////////////////////////////////////////////////////
......@@ -41,7 +89,7 @@ ARjs.Session = function(parameters){
_this.arContext.init()
arContext.addEventListener('initialized', function(event){
arSource.onResize(arContext, _this.renderer, _this.camera)
arSource.onResize(arContext, _this.parameters.renderer, _this.parameters.camera)
})
//////////////////////////////////////////////////////////////////////////////
......@@ -56,5 +104,5 @@ ARjs.Session = function(parameters){
}
ARjs.Session.prototype.onResize = function () {
this.arSource.onResize(this.arContext, this.renderer, this.camera)
this.arSource.onResize(this.arContext, this.parameters.renderer, this.parameters.camera)
};
var THREEx = THREEx || {}
// TODO this is useless - prefere arjs-hittester.js
// TODO this is useless - prefere arjs-HitTesting.js
/**
* - maybe support .onClickFcts in each object3d
......@@ -15,7 +15,7 @@ THREEx.ARClickability = function(sourceElement){
this._cameraPicking = new THREE.PerspectiveCamera(42, fullWidth / fullHeight, 0.1, 100);
console.warn('THREEx.ARClickability works only in modelViewMatrix')
console.warn('OBSOLETE OBSOLETE! instead use THREEx.HitTesterPlane or THREEx.HitTesterTango')
console.warn('OBSOLETE OBSOLETE! instead use THREEx.HitTestingPlane or THREEx.HitTestingTango')
}
THREEx.ARClickability.prototype.onResize = function(){
......@@ -55,7 +55,7 @@ THREEx.ARClickability.prototype.update = function(){
THREEx.ARClickability.tangoPickingPointCloud = function(artoolkitContext, mouseX, mouseY){
// THIS IS CRAP!!!! use THREEx.HitTesterTango
// THIS IS CRAP!!!! use THREEx.HitTestingTango
var vrDisplay = artoolkitContext._tangoContext.vrDisplay
if (vrDisplay === null ) return null
......
......@@ -59,6 +59,9 @@ THREEx.ArMarkerControls = function(context, object3d, parameters){
}
}
//////////////////////////////////////////////////////////////////////////////
// Code Separator
//////////////////////////////////////////////////////////////////////////////
// add this marker to artoolkitsystem
// TODO rename that .addMarkerControls
context.addMarker(this)
......
var THREEx = THREEx || {}
// TODO this is useless - prefere arjs-hittester.js
// TODO this is useless - prefere arjs-HitTesting.js
/**
* - maybe support .onClickFcts in each object3d
* - seems an easy light layer for clickable object
* - up to
*/
THREEx.HitTesterPlane = function(sourceElement){
THREEx.HitTestingPlane = function(sourceElement){
this._sourceElement = sourceElement
// create _pickingScene
......@@ -36,7 +36,7 @@ THREEx.HitTesterPlane = function(sourceElement){
// update function
//////////////////////////////////////////////////////////////////////////////
THREEx.HitTesterPlane.prototype.update = function(camera, pickingRoot, changeMatrixMode){
THREEx.HitTestingPlane.prototype.update = function(camera, pickingRoot, changeMatrixMode){
this.onResize()
......@@ -69,7 +69,7 @@ THREEx.HitTesterPlane.prototype.update = function(camera, pickingRoot, changeMat
// resize camera
//////////////////////////////////////////////////////////////////////////////
THREEx.HitTesterPlane.prototype.onResize = function(){
THREEx.HitTestingPlane.prototype.onResize = function(){
var sourceElement = this._sourceElement
var pickingCamera = this._pickingCamera
......@@ -85,7 +85,7 @@ THREEx.HitTesterPlane.prototype.onResize = function(){
//////////////////////////////////////////////////////////////////////////////
// Perform test
//////////////////////////////////////////////////////////////////////////////
THREEx.HitTesterPlane.prototype.test = function(mouseX, mouseY){
THREEx.HitTestingPlane.prototype.test = function(mouseX, mouseY){
// convert mouseX, mouseY to [-1, +1]
mouseX = (mouseX-0.5)*2
mouseY =-(mouseY-0.5)*2
......@@ -117,7 +117,7 @@ THREEx.HitTesterPlane.prototype.test = function(mouseX, mouseY){
// render the pickingPlane for debug
//////////////////////////////////////////////////////////////////////////////
THREEx.HitTesterPlane.prototype.renderDebug = function(renderer){
THREEx.HitTestingPlane.prototype.renderDebug = function(renderer){
// render sceneOrtho
renderer.render( this._pickingScene, this._pickingCamera )
}
......@@ -5,7 +5,7 @@ var THREEx = THREEx || {}
*
* @return {[type]} [description]
*/
THREEx.HitTesterTango = function(arContext){
THREEx.HitTestingTango = function(arContext){
this._arContext = arContext
// seems to be the object bounding sphere for picking
this.boundingSphereRadius = 0.01
......@@ -17,7 +17,7 @@ THREEx.HitTesterTango = function(arContext){
// update function
//////////////////////////////////////////////////////////////////////////////
THREEx.HitTesterTango.prototype.update = function(){
THREEx.HitTestingTango.prototype.update = function(){
}
//////////////////////////////////////////////////////////////////////////////
......@@ -31,7 +31,7 @@ THREEx.HitTesterTango.prototype.update = function(){
* @param {Numer} mouseY - mouse y coordinate in [0, 1]
* @return {Object} - result
*/
THREEx.HitTesterTango.prototype.test = function(mouseX, mouseY){
THREEx.HitTestingTango.prototype.test = function(mouseX, mouseY){
var vrDisplay = this._arContext._tangoContext.vrDisplay
if (vrDisplay === null ) return null
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册