Merge branch '0.2.0' into optimize-crs-project

0.2
Brian Chirls 2014-12-03 14:16:49 -05:00
commit d64affcba1
42 zmienionych plików z 9453 dodań i 103 usunięć

File diff suppressed because one or more lines are too long

10
build/vizi.min.js vendored

File diff suppressed because one or more lines are too long

Wyświetl plik

@ -194,97 +194,6 @@ var choroplethConfig = {
var switchboardChoropleth = new VIZI.BlueprintSwitchboard(choroplethConfig);
switchboardChoropleth.addToWorld(world);
var kmlConfig = {
input: {
type: "BlueprintInputKML",
options: {
path: "./data/sample.kml"
}
},
output: {
type: "BlueprintOutputDebugPoints",
options: {}
},
triggers: [{
triggerObject: "output",
triggerName: "initialised",
triggerArguments: [],
actionObject: "input",
actionName: "requestData",
actionArguments: [],
actionOutput: {}
}, {
triggerObject: "input",
triggerName: "dataReceived",
triggerArguments: ["kml"],
actionObject: "output",
actionName: "outputPoints",
actionArguments: ["data"],
actionOutput: {
data: {
// Loop through each item in trigger.geoJSON and return a new array of processed values (a map)
process: "map",
itemsObject: "kml",
itemsProperties: "document.placemark",
// Return a new object for each item with the given properties
transformation: {
coordinates: "point.coordinates"
}
}
}
}]
};
var switchboardKML = new VIZI.BlueprintSwitchboard(kmlConfig);
switchboardKML.addToWorld(world);
var colladaConfig = {
input: {
type: "BlueprintInputKML",
options: {
path: "./data/kml-model/sample.kml"
}
},
output: {
type: "BlueprintOutputCollada",
options: {
modelPathPrefix: "./data/kml-model/"
}
},
triggers: [{
triggerObject: "output",
triggerName: "initialised",
triggerArguments: [],
actionObject: "input",
actionName: "requestData",
actionArguments: [],
actionOutput: {}
}, {
triggerObject: "input",
triggerName: "dataReceived",
triggerArguments: ["kml"],
actionObject: "output",
actionName: "outputCollada",
actionArguments: ["collada"],
actionOutput: {
collada: {
// Loop through each item in trigger.geoJSON and return a new array of processed values (a map)
process: "map",
itemsObject: "kml",
itemsProperties: "placemark.model",
// Return a new object for each item with the given properties
transformation: {
coordinates: ["location.longitude", "location.latitude"],
modelPath: "link.href"
}
}
}
}]
};
var switchboardCollada = new VIZI.BlueprintSwitchboard(colladaConfig);
switchboardCollada.addToWorld(world);
var clock = new VIZI.Clock();
var update = function() {

Plik diff jest za duży Load Diff

Wyświetl plik

@ -0,0 +1,37 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>ViziCities - GPX Example</title>
<style type="text/css">
html, body {
height: 100%;
width: 100%;
}
body {
background: #222;
margin: 0;
overflow: hidden;
padding: 0;
}
#vizicities-viewport {
height: 720px;
left: 50%;
margin: -360px 0 0 -640px;
position: absolute;
top: 50%;
width: 1280px;
}
</style>
<link rel="stylesheet" type="text/css" href="../../build/vizi.css">
</head>
<body>
<div id="vizicities-viewport"></div>
<script src="../../build/vizi.js"></script>
<script src="main.js"></script>
</body>
</html>

Wyświetl plik

@ -0,0 +1,139 @@
var world = new VIZI.World({
viewport: document.querySelector("#vizicities-viewport")
});
var controls = new VIZI.ControlsMap(world.camera);
var gpxConfig = {
input: {
type: "BlueprintInputGPX",
options: {
path: "./data/sample.gpx"
}
},
output: {
type: "BlueprintOutputDebugLines",
options: {}
},
triggers: [{
triggerObject: "output",
triggerName: "initialised",
triggerArguments: [],
actionObject: "input",
actionName: "requestData",
actionArguments: [],
actionOutput: {}
}, {
triggerObject: "input",
triggerName: "dataReceived",
triggerArguments: ["gpx"],
actionObject: "output",
actionName: "outputLines",
actionArguments: ["data"],
actionOutput: {
data: {
process: "map",
itemsObject: "gpx",
itemsProperties: "trk.trkseg.trkpt",
transformation: {
coordinates: ["@lon", "@lat"],
height: "ele"
}
}
}
}]
};
var switchboardGPX = new VIZI.BlueprintSwitchboard(gpxConfig);
switchboardGPX.addToWorld(world);
var mapConfig = {
input: {
type: "BlueprintInputMapTiles",
options: {
tilePath: "https://a.tiles.mapbox.com/v3/examples.map-i86l3621/{z}/{x}/{y}@2x.png"
}
},
output: {
type: "BlueprintOutputImageTiles",
options: {
grids: [{
zoom: 19,
tilesPerDirection: 3,
cullZoom: 17
}, {
zoom: 18,
tilesPerDirection: 3,
cullZoom: 16
}, {
zoom: 17,
tilesPerDirection: 3,
cullZoom: 15
}, {
zoom: 16,
tilesPerDirection: 3,
cullZoom: 14
}, {
zoom: 15,
tilesPerDirection: 3,
cullZoom: 13
}, {
zoom: 14,
tilesPerDirection: 3,
cullZoom: 12
}, {
zoom: 13,
tilesPerDirection: 5,
cullZoom: 11
}]
}
},
triggers: [{
triggerObject: "output",
triggerName: "initialised",
triggerArguments: ["tiles"],
actionObject: "input",
actionName: "requestTiles",
actionArguments: ["tiles"],
actionOutput: {
tiles: "tiles" // actionArg: triggerArg
}
}, {
triggerObject: "output",
triggerName: "gridUpdated",
triggerArguments: ["tiles"],
actionObject: "input",
actionName: "requestTiles",
actionArguments: ["tiles"],
actionOutput: {
tiles: "tiles" // actionArg: triggerArg
}
}, {
triggerObject: "input",
triggerName: "tileReceived",
triggerArguments: ["image", "tile"],
actionObject: "output",
actionName: "outputImageTile",
actionArguments: ["image", "tile"],
actionOutput: {
image: "image", // actionArg: triggerArg
tile: "tile"
}
}]
};
var switchboardMap = new VIZI.BlueprintSwitchboard(mapConfig);
switchboardMap.addToWorld(world);
var clock = new VIZI.Clock();
var update = function() {
var delta = clock.getDelta();
world.onTick(delta);
world.render();
window.requestAnimationFrame(update);
};
update();

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 5.3 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 5.3 KiB

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 7.6 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 7.6 KiB

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 7.1 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 7.1 KiB

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 1.5 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 1.5 KiB

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 16 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 16 KiB

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 2.1 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 2.1 KiB

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 24 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 24 KiB

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 6.8 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 6.8 KiB

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 9.3 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 9.3 KiB

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 2.1 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 2.1 KiB

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 8.8 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 8.8 KiB

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 5.4 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 5.4 KiB

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 2.0 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 2.0 KiB

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 11 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 11 KiB

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 3.9 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 3.9 KiB

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 2.5 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 2.5 KiB

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 1.6 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 1.6 KiB

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 4.9 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 4.9 KiB

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 4.4 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 4.4 KiB

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 45 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 45 KiB

Wyświetl plik

@ -0,0 +1,37 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>ViziCities - KML Collada Example</title>
<style type="text/css">
html, body {
height: 100%;
width: 100%;
}
body {
background: #222;
margin: 0;
overflow: hidden;
padding: 0;
}
#vizicities-viewport {
height: 720px;
left: 50%;
margin: -360px 0 0 -640px;
position: absolute;
top: 50%;
width: 1280px;
}
</style>
<link rel="stylesheet" type="text/css" href="../../../build/vizi.css">
</head>
<body>
<div id="vizicities-viewport"></div>
<script src="../../../build/vizi.js"></script>
<script src="main.js"></script>
</body>
</html>

Wyświetl plik

@ -0,0 +1,142 @@
var world = new VIZI.World({
viewport: document.querySelector("#vizicities-viewport"),
center: new VIZI.LatLon(40.01000594412381, -105.2727379358738)
});
var controls = new VIZI.ControlsMap(world.camera);
var colladaConfig = {
input: {
type: "BlueprintInputKML",
options: {
path: "./data/sample.kml"
}
},
output: {
type: "BlueprintOutputCollada",
options: {
modelPathPrefix: "./data/"
}
},
triggers: [{
triggerObject: "output",
triggerName: "initialised",
triggerArguments: [],
actionObject: "input",
actionName: "requestData",
actionArguments: [],
actionOutput: {}
}, {
triggerObject: "input",
triggerName: "dataReceived",
triggerArguments: ["kml"],
actionObject: "output",
actionName: "outputCollada",
actionArguments: ["collada"],
actionOutput: {
collada: {
process: "map",
itemsObject: "kml",
itemsProperties: "placemark.model",
transformation: {
coordinates: ["location.longitude", "location.latitude"],
modelPath: "link.href"
}
}
}
}]
};
var switchboardCollada = new VIZI.BlueprintSwitchboard(colladaConfig);
switchboardCollada.addToWorld(world);
var mapConfig = {
input: {
type: "BlueprintInputMapTiles",
options: {
tilePath: "https://a.tiles.mapbox.com/v3/examples.map-i86l3621/{z}/{x}/{y}@2x.png"
}
},
output: {
type: "BlueprintOutputImageTiles",
options: {
grids: [{
zoom: 19,
tilesPerDirection: 3,
cullZoom: 17
}, {
zoom: 18,
tilesPerDirection: 3,
cullZoom: 16
}, {
zoom: 17,
tilesPerDirection: 3,
cullZoom: 15
}, {
zoom: 16,
tilesPerDirection: 3,
cullZoom: 14
}, {
zoom: 15,
tilesPerDirection: 3,
cullZoom: 13
}, {
zoom: 14,
tilesPerDirection: 3,
cullZoom: 12
}, {
zoom: 13,
tilesPerDirection: 5,
cullZoom: 11
}]
}
},
triggers: [{
triggerObject: "output",
triggerName: "initialised",
triggerArguments: ["tiles"],
actionObject: "input",
actionName: "requestTiles",
actionArguments: ["tiles"],
actionOutput: {
tiles: "tiles" // actionArg: triggerArg
}
}, {
triggerObject: "output",
triggerName: "gridUpdated",
triggerArguments: ["tiles"],
actionObject: "input",
actionName: "requestTiles",
actionArguments: ["tiles"],
actionOutput: {
tiles: "tiles" // actionArg: triggerArg
}
}, {
triggerObject: "input",
triggerName: "tileReceived",
triggerArguments: ["image", "tile"],
actionObject: "output",
actionName: "outputImageTile",
actionArguments: ["image", "tile"],
actionOutput: {
image: "image", // actionArg: triggerArg
tile: "tile"
}
}]
};
var switchboardMap = new VIZI.BlueprintSwitchboard(mapConfig);
switchboardMap.addToWorld(world);
var clock = new VIZI.Clock();
var update = function() {
var delta = clock.getDelta();
world.onTick(delta);
world.render();
window.requestAnimationFrame(update);
};
update();

Wyświetl plik

@ -0,0 +1,37 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>ViziCities - KML Point Example</title>
<style type="text/css">
html, body {
height: 100%;
width: 100%;
}
body {
background: #222;
margin: 0;
overflow: hidden;
padding: 0;
}
#vizicities-viewport {
height: 720px;
left: 50%;
margin: -360px 0 0 -640px;
position: absolute;
top: 50%;
width: 1280px;
}
</style>
<link rel="stylesheet" type="text/css" href="../../../build/vizi.css">
</head>
<body>
<div id="vizicities-viewport"></div>
<script src="../../../build/vizi.js"></script>
<script src="main.js"></script>
</body>
</html>

Wyświetl plik

@ -0,0 +1,138 @@
var world = new VIZI.World({
viewport: document.querySelector("#vizicities-viewport")
});
var controls = new VIZI.ControlsMap(world.camera);
var kmlConfig = {
input: {
type: "BlueprintInputKML",
options: {
path: "./data/sample.kml"
}
},
output: {
type: "BlueprintOutputDebugPoints",
options: {}
},
triggers: [{
triggerObject: "output",
triggerName: "initialised",
triggerArguments: [],
actionObject: "input",
actionName: "requestData",
actionArguments: [],
actionOutput: {}
}, {
triggerObject: "input",
triggerName: "dataReceived",
triggerArguments: ["kml"],
actionObject: "output",
actionName: "outputPoints",
actionArguments: ["data"],
actionOutput: {
data: {
process: "map",
itemsObject: "kml",
itemsProperties: "document.placemark",
transformation: {
coordinates: "point.coordinates[0]"
}
}
}
}]
};
var switchboardKML = new VIZI.BlueprintSwitchboard(kmlConfig);
switchboardKML.addToWorld(world);
var mapConfig = {
input: {
type: "BlueprintInputMapTiles",
options: {
tilePath: "https://a.tiles.mapbox.com/v3/examples.map-i86l3621/{z}/{x}/{y}@2x.png"
}
},
output: {
type: "BlueprintOutputImageTiles",
options: {
grids: [{
zoom: 19,
tilesPerDirection: 3,
cullZoom: 17
}, {
zoom: 18,
tilesPerDirection: 3,
cullZoom: 16
}, {
zoom: 17,
tilesPerDirection: 3,
cullZoom: 15
}, {
zoom: 16,
tilesPerDirection: 3,
cullZoom: 14
}, {
zoom: 15,
tilesPerDirection: 3,
cullZoom: 13
}, {
zoom: 14,
tilesPerDirection: 3,
cullZoom: 12
}, {
zoom: 13,
tilesPerDirection: 5,
cullZoom: 11
}]
}
},
triggers: [{
triggerObject: "output",
triggerName: "initialised",
triggerArguments: ["tiles"],
actionObject: "input",
actionName: "requestTiles",
actionArguments: ["tiles"],
actionOutput: {
tiles: "tiles" // actionArg: triggerArg
}
}, {
triggerObject: "output",
triggerName: "gridUpdated",
triggerArguments: ["tiles"],
actionObject: "input",
actionName: "requestTiles",
actionArguments: ["tiles"],
actionOutput: {
tiles: "tiles" // actionArg: triggerArg
}
}, {
triggerObject: "input",
triggerName: "tileReceived",
triggerArguments: ["image", "tile"],
actionObject: "output",
actionName: "outputImageTile",
actionArguments: ["image", "tile"],
actionOutput: {
image: "image", // actionArg: triggerArg
tile: "tile"
}
}]
};
var switchboardMap = new VIZI.BlueprintSwitchboard(mapConfig);
switchboardMap.addToWorld(world);
var clock = new VIZI.Clock();
var update = function() {
var delta = clock.getDelta();
world.onTick(delta);
world.render();
window.requestAnimationFrame(update);
};
update();

Wyświetl plik

@ -0,0 +1,64 @@
/* globals window, _, VIZI, d3, JXON */
(function() {
"use strict";
/**
* Blueprint GPX input
* @author Robin Hawkes - vizicities.com
*/
// input: {
// type: "BlueprintInputGPX",
// options: {
// path: "/data/sample.gpx"
// }
// }
VIZI.BlueprintInputGPX = function(options) {
var self = this;
VIZI.BlueprintInput.call(self, options);
_.defaults(self.options, {});
// Triggers and actions reference
self.triggers = [
{name: "initialised", arguments: []},
{name: "dataReceived", arguments: ["gpx"]}
];
self.actions = [
{name: "requestData", arguments: []}
];
};
VIZI.BlueprintInputGPX.prototype = Object.create( VIZI.BlueprintInput.prototype );
// Initialise instance and start automated processes
VIZI.BlueprintInputGPX.prototype.init = function() {
var self = this;
self.emit("initialised");
};
// TODO: Pull from cache if available
VIZI.BlueprintInputGPX.prototype.requestData = function(tiles) {
var self = this;
if (!self.options.path) {
throw new Error("Required path option missing");
}
// Request data
d3.xml(self.options.path, function(error, data) {
if (error) {
if (VIZI.DEBUG) console.log("Failed to request GPX data");
console.warn(error);
return;
}
// Process GPX into a JSON format
var jxon = JXON.build(data.querySelector("gpx"));
self.emit("dataReceived", jxon);
});
};
}());

Wyświetl plik

@ -0,0 +1,87 @@
/* globals window, _, VIZI, THREE */
(function() {
"use strict";
/**
* Blueprint debug lines output
* @author Robin Hawkes - vizicities.com
*/
// output: {
// type: "BlueprintOutputDebugLines",
// options: {}
// }
VIZI.BlueprintOutputDebugLines = function(options) {
var self = this;
VIZI.BlueprintOutput.call(self, options);
_.defaults(self.options, {});
// Triggers and actions reference
self.triggers = [
{name: "initialised", arguments: []}
];
self.actions = [
{name: "outputLines", arguments: ["data"]}
];
self.world;
};
VIZI.BlueprintOutputDebugLines.prototype = Object.create( VIZI.BlueprintOutput.prototype );
// Initialise instance and start automated processes
VIZI.BlueprintOutputDebugLines.prototype.init = function() {
var self = this;
self.emit("initialised");
};
// {
// coordinates: [lon, lat],
// height: 123
// }
VIZI.BlueprintOutputDebugLines.prototype.outputLines = function(data) {
var self = this;
var material = new THREE.LineBasicMaterial({
color: 0xff0000,
linewidth: 3
});
var geom = new THREE.Geometry();
// Local pixels per meter - set once per tile
var pixelsPerMeter;
_.each(data, function(point) {
var latLon = new VIZI.LatLon(point.coordinates[1], point.coordinates[0]);
var geoCoord = self.world.project(latLon);
// Set local pixels per meter if not set
if (pixelsPerMeter === undefined) {
pixelsPerMeter = self.world.pixelsPerMeter(latLon);
}
// TODO: Get this from options
var height = point.height || 10;
// Multiply height in meters by pixels per meter ratio at latitude
height *= pixelsPerMeter.y;
geom.vertices.push(new THREE.Vector3( geoCoord.x, height, geoCoord.y ));
});
var line = new THREE.Line( geom, material );
self.add(line);
};
VIZI.BlueprintOutputDebugLines.prototype.onAdd = function(world) {
var self = this;
self.world = world;
self.init();
};
}());

5
src/Vendor/JXON.js vendored
Wyświetl plik

@ -53,7 +53,10 @@ var JXON = new (function () {
oNode = oParentNode.childNodes.item(nItem);
if (oNode.nodeType === 4) { sCollectedTxt += oNode.nodeValue; } /* nodeType is "CDATASection" (4) */
else if (oNode.nodeType === 3) { sCollectedTxt += oNode.nodeValue.trim(); } /* nodeType is "Text" (3) */
else if (oNode.nodeType === 1 && !oNode.prefix) { aCache.push(oNode); } /* nodeType is "Element" (1) */
// Removed "&& !oNode.prefix" as per namespace note on MDN
// https://developer.mozilla.org/en-US/docs/JXON
// else if (oNode.nodeType === 1 && !oNode.prefix) { aCache.push(oNode); } /* nodeType is "Element" (1) */
else if (oNode.nodeType === 1) { aCache.push(oNode); } /* nodeType is "Element" (1) */
}
}

Wyświetl plik

@ -363,8 +363,10 @@ THREE.MapControls = function ( object, domElement ) {
}
function getZoomScale() {
// Reduce zoom speed when using touch control
var zoomSpeed = (state === STATE.TOUCH_DOLLY) ? scope.zoomSpeed : scope.zoomSpeed * 0.7;
return Math.pow( 0.95, scope.zoomSpeed );
return Math.pow( 0.95, zoomSpeed );
}

Wyświetl plik

@ -331,8 +331,10 @@ THREE.OrbitControls = function ( object, domElement ) {
}
function getZoomScale() {
// Reduce zoom speed when using touch control
var zoomSpeed = (state === STATE.TOUCH_DOLLY) ? scope.zoomSpeed : scope.zoomSpeed * 0.7;
return Math.pow( 0.95, scope.zoomSpeed );
return Math.pow( 0.95, zoomSpeed );
}

Wyświetl plik

@ -52,6 +52,7 @@
<script src="spec/Blueprint/BlueprintInputMapTiles.js"></script>
<script src="spec/Blueprint/BlueprintInputGeoJSON.js"></script>
<script src="spec/Blueprint/BlueprintInputKML.js"></script>
<script src="spec/Blueprint/BlueprintInputGPX.js"></script>
<script src="spec/Blueprint/BlueprintHelperTileGrid.js"></script>
@ -60,6 +61,7 @@
<script src="spec/Blueprint/BlueprintOutputBuildingTiles.js"></script>
<script src="spec/Blueprint/BlueprintOutputChoropleth.js"></script>
<script src="spec/Blueprint/BlueprintOutputDebugPoints.js"></script>
<script src="spec/Blueprint/BlueprintOutputDebugLines.js"></script>
<script src="spec/Blueprint/BlueprintOutputCollada.js"></script>
<script src="spec/Blueprint/BlueprintSwitchboard.js"></script>

Wyświetl plik

@ -0,0 +1,51 @@
describe("VIZI.BlueprintInputGPX", function() {
var input;
before(function() {
input = new VIZI.BlueprintInputGPX();
});
it("exists in VIZI namespace", function() {
expect(VIZI.BlueprintInputGPX).to.exist;
});
it("has a requestData method", function() {
expect(input.requestData).to.exist;
});
// TODO: Enable when a CORS-enabled endpoint can be found for the data
// it("can request data", function() {
// var input2 = new VIZI.BlueprintInputGPX({
// path: "/path/to/sample.gpx"
// });
// var spy = new sinon.spy(input2, "requestData");
// input2.requestData();
// expect(spy).to.have.been.called;
// input2.requestData.restore();
// input2 = undefined;
// spy = undefined;
// });
// TODO: Enable when a CORS-enabled endpoint can be found for the data
// it("can send event after receiving data", function() {
// var input2 = new VIZI.BlueprintInputGPX({
// path: "/path/to/sample.gpx"
// });
// var spy = sinon.spy();
// input2.on("dataReceived", spy);
// input2.requestData();
// setTimeout(function() {
// expect(spy).to.have.been.called;
// expect(spy.args[0].length).to.equal(1);
// input2 = undefined;
// spy = undefined;
// }, 500);
// });
});

Wyświetl plik

@ -0,0 +1,76 @@
// TODO: Flesh out with more tests
describe("VIZI.BlueprintOutputDebugLines", function() {
var config;
var output;
var world;
before(function() {
world = new VIZI.World({
viewport: document.createElement("div"),
camera: new VIZI.Camera({
aspect: 1024 / 768
}),
suppressRenderer: true
});
config = {
type: "BlueprintOutputDebugLines",
options: {}
};
output = new VIZI.BlueprintOutputDebugLines(config);
});
it("exists in VIZI namespace", function() {
expect(VIZI.BlueprintOutputDebugLines).to.exist;
});
it("has a triggers property with correct triggers", function() {
expect(output.triggers).to.exist;
expect(output.triggers[0].name).to.equal("initialised");
});
it("has an actions property with correct actions", function() {
expect(output.actions).to.exist;
expect(output.actions[0].name).to.equal("outputLines");
});
it("has an undefined world property", function() {
expect(output.world).to.be.undefined;
});
it("has an init method", function() {
expect(output.init).to.exist;
});
it("has an outputLines method", function() {
expect(output.outputLines).to.exist;
});
it("has an onAdd method", function() {
expect(output.onAdd).to.exist;
});
it("can initialise when added to world", function() {
var spy = new sinon.spy(output, "init");
output.onAdd(world);
expect(output.world).to.equal(world);
expect(spy).to.have.been.called;
output.init.restore();
spy = undefined;
});
it("can emit event on initialisation", function() {
var spy = new sinon.spy();
output.on("initialised", spy);
output.onAdd(world);
expect(spy).to.have.been.called;
spy = undefined;
});
});