Jean-Yves Didier

corrected bug in component instanciation from url

......@@ -295,10 +295,12 @@ ARCS.Context = function( ctx ) {
if (this.status >= 200 && this.status < 300) {
resolve(JSON.parse(this.responseText));
} else {
console.error(this.statusText);
reject(this.statusText);
}
};
client.onerror = function() {
console.error(this.statusText);
reject(this.statusText);
};
});
......@@ -350,6 +352,7 @@ ARCS.Context = function( ctx ) {
instanciateComponents = function() {
var p, promises=[];
console.log(components);
for (p in components) {
if (components.hasOwnProperty(p)) {
......@@ -359,18 +362,23 @@ ARCS.Context = function( ctx ) {
return ;
}
factory = factories[components[p].type];
//console.log("instanciating ", p);
try {
if (components[p].value !== undefined || components[p].url !== undefined || components[p].ref !== undefined) {
if (components[p].value !== undefined) {
console.log("instanciating ", p);
components[p].instance = new factory(components[p].value);
}
if (components[p].url !== undefined) {
promises.push(
loadDataFile(components[p].url).then(function(obj) {
// we need currying here !
var delayInstanciation = function(p,factory) {
return function(obj) {
components[p].instance = new factory(obj);
})
return Promise.resolve();
}
};
promises.push(
loadDataFile(components[p].url).then(delayInstanciation(p,factory))
);
}
if (components[p].ref !== undefined) {
......@@ -1854,6 +1862,7 @@ ARCS.Statemachine = new ARCS.Component.create(function (obj) {
* the initial state (by default, it is the departure of the first transition
*/
this.start = function () {
console.log("statemachine", this, initial,obj);
setSheet(initial);
};
......
This diff is collapsed. Click to expand it.
arcs_module(function (ARCS,three) {
var PipeNetwork = ARCS.Component.create(
function ( jsonData ) {
console.log("instanciating pipe network");
var pipeNetwork = new THREE.Object3D();
var X_OFFSET = 0; // 2.428592;
var Y_OFFSET = 0; // 48.613426;
......
arcs_module(
function(ARCS) {
var GPSInertialPose = new ARCS.Component(
var GPSInertialPose = new ARCS.Component.create(
function() {
var id = 0;
var pose = {
......
......@@ -63,10 +63,12 @@ ARCS.Context = function( ctx ) {
if (this.status >= 200 && this.status < 300) {
resolve(JSON.parse(this.responseText));
} else {
console.error(this.statusText);
reject(this.statusText);
}
};
client.onerror = function() {
console.error(this.statusText);
reject(this.statusText);
};
});
......@@ -118,6 +120,7 @@ ARCS.Context = function( ctx ) {
instanciateComponents = function() {
var p, promises=[];
console.log(components);
for (p in components) {
if (components.hasOwnProperty(p)) {
......@@ -127,18 +130,23 @@ ARCS.Context = function( ctx ) {
return ;
}
factory = factories[components[p].type];
//console.log("instanciating ", p);
try {
if (components[p].value !== undefined || components[p].url !== undefined || components[p].ref !== undefined) {
if (components[p].value !== undefined) {
console.log("instanciating ", p);
components[p].instance = new factory(components[p].value);
}
if (components[p].url !== undefined) {
promises.push(
loadDataFile(components[p].url).then(function(obj) {
// we need currying here !
var delayInstanciation = function(p,factory) {
return function(obj) {
components[p].instance = new factory(obj);
})
return Promise.resolve();
}
};
promises.push(
loadDataFile(components[p].url).then(delayInstanciation(p,factory))
);
}
if (components[p].ref !== undefined) {
......
......@@ -146,6 +146,7 @@ ARCS.Statemachine = new ARCS.Component.create(function (obj) {
* the initial state (by default, it is the departure of the first transition
*/
this.start = function () {
console.log("statemachine", this, initial,obj);
setSheet(initial);
};
......
......@@ -17,7 +17,7 @@
"gps" : { "type" : "GeoLocator" },
"inertial" : { "type" : "Inertial" },
"fuser" : { "type" : "GPSInertialPose" },
"pipeNetwork" : { "type" : "PipeNetwork", "file": "tests/pipe/Conduites_UFRST.geojson"},
"pipeNetwork" : { "type" : "PipeNetwork", "url": "./Conduites_UFRST.geojson"},
"video": {"type": "VideoSource"},
"statemachine" : {
"type": "StateMachine",
......@@ -41,13 +41,13 @@
{ "destination": "fuser", "slot": "setId", "value": [ 17 ] },
{ "destination": "viewer", "slot": "setSceneId", "value": [17] },
{ "destination": "inertial", "slot": "start", "value": [] },
{ "destination": "gps", "slot": "watchPosition", "value": [] },
{ "destination": "gps", "slot": "watchPosition", "value": [] }
],
"postconnections": [
{ "destination": "pipeNetwork", "slot": "init", "value": [] }
],
"connections": [
{ "destination": "viewer", "slot": "addScene", "source": "pipeNetwork", "signal": "sendSceneGraph" }
{ "destination": "viewer", "slot": "addScene", "source": "pipeNetwork", "signal": "sendSceneGraph" },
{ "destination": "statemachine", "slot": "next", "source": "pipeNetwork", "signal": "sendSceneGraph" }
],
"cleanups": [
......@@ -55,17 +55,19 @@
},
"start": {
"preconnections": [
],
"postconnections": [
{ "destination": "viewer", "slot": "viewAll", "value": []},
{ "destination": "animator", "slot": "start", "value":[]}
],
"postconnections": [],
"connections": [
{ "source": "windowresize", "signal": "onResize", "destination": "viewer", "slot":"setSize"},
{ "source": "animator", "signal": "onAnimationFrame", "destination": "video", "slot": "grabFrame"},
{ "source": "animator", "signal": "onAnimationFrame", "destination": "viewer", "slot": "render"},
{ "source": "video", "signal": "onReady", "destination": "viewer", "slot": "resetCamera"},
{ "source": "gps", "signal": "sendCoordinates", "destination": "fuser", "slot": "setPosition"},
{ "source": "inertial", "signal": "sendOrientation", "destination": "fuser", "slot": "sendPosition"},
{ "source": "inertial", "signal": "sendOrientation", "destination": "fuser", "slot": "setOrientation"},
{ "source": "fuser", "signal": "sendPose", "destination": "viewer", "slot": "setExtrinsics"}
],
"cleanups": []
......
......@@ -13,6 +13,17 @@
</head>
<body>
<video id="video" width=320 height=240 autoplay="true" loop="true" style="display: none;">
</video>
<canvas id="canvas"></canvas>
<div id="container" ></div>
<div id="contents">
<!-- div id="console">
<div style="float: right; font-size: 150%; padding:0; margin:0;" onclick="document.getElementById('output').classList.toggle('hide');">&#9881;</div>
<p id="output">Console log:<br/></p>
</div -->
<a id="logo" href="http://arcs.ibisc.univ-evry.fr"><img src="../../docs/arcs_logo.png" alt="ARCS"/></a>
</div>
</body>
......