Skip to content

danoszz/fe3-assessment-3

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Street lights in D3.js and webVR 💡

This 3D scatterplot is constructed from a dataset storing the location of public lighting like street laterns in the area of Bloemendaal, the Netherlands. It is based on this awesome experiment by @almossawi (No license included) for the course FE3.

Patriotic warning The demo visualization is in Dutch 🇳🇱

TL;DR

Since time is precious and endless stories can be forgotten: I'll sum up the project real quick:

  • Datavisualization of street laterns made in D3.js and webVR framework A-frame
  • The whole dataset crashed my laptop, only worked with 15%.
  • Main inspiration was this awesome interactive creation.
  • The code is customized for this dataset. Styling as well.
  • Updating D3 V3 and A-Frame 0.2.0 to the newest version was a pain in the ass.
    • Only D3 is updated, A-Frame isn't yet.
  • Multiple D3 visualization: the map and point graph (street laterns)

Fun fact: during the last 32 hours the Internet company decided to kill our internet and let me work from an iPhone hotspot. Thanks Ziggo.

Workflow

First I will give a quick illustration of my workflow throughout the process of coding this assignment. Afterwards I will go in depth on the points where I feel is needed.

The in depth storytelling is not always the case in this documentation. And saves both me and the reader some time

  1. Find interesting Dataset
  2. Sketch ideas on plain ol' paper
  3. Research VR + D3.js
  4. Convert CSV to JSON
  5. Load data in to example
  6. Adjust code to make it work and re-write if necessary
  7. Create own environment
  8. Convert D3 V3 to V4
  9. Update Aframe 0.4 to latest release and bug testing
    • Find out whole thing breaks, need to debug
  10. Apply styling an UI changes

Interesting code stuff

The example had all it's code in D3 V3 and A-Frame 0.2.0, so it needed a update. From D3 V3 -> V4 was easily done, but updating A-Frame was more time consuming. It needed to be done because the size of the dataset in combination with the FPS. At the end this pull request in the A-Frame library and the following code bit caused the bugs. Still don't know how to fix it.

	.attr("position", (d, i) => {
		const x = x_scale(d.longitude);
		const z = z_scale(d.latitude);
		const y = y_scale(d.Hoogte) / 2;
		return `${x} ${y} ${z}`;
	})

// resulted in NaN for position attribute in de debugger in >0.2.0

Since it takes a while for the whole scene to render I decided to put a loading screen before the user can interact with the visualization. The loading screen is called back when the data is loaded completely

d3.select(".loading").classed("hide", false); // Set 'fake' loading screen for

// data loading on each object

.call(function(d){
	d3.select(".loading").classed("hide", true); // remove loading screen when data is loaded
});

Resources

  • D3.js - D3.js is a JavaScript library for manipulating documents based on data.

  • A-frame - A web framework for building virtual reality experiences

  • Textures.js - Textures.js is a Javascript library for creating SVG patterns. Made on top of d3.js, it is designed for data visualization.

Todo

  • Add reflection and more in depth documentation in readme
  • Add used D3 & A-frame features
  • Make a workable mobile and VR set UI
  • Create an environment including Gulp
  • Update Aframe to V0.7.0 without any bugs.
  • Change direction of first view: south -> north.
  • Add preview gif instead of static picture
  • Make assets local instead of from CDN

License

The original code by @almossawi does not contain any license. Please contact me if there are any problems legal wise. My extended version license is below.


MIT License

Copyright (c) 2017 Daan van der Zwaag

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 41.4%
  • HTML 40.3%
  • CSS 18.3%