Code Monkey home page Code Monkey logo

tilt's Introduction

Tilt: a WebGL-based 3D visualization of a Webpage

Firefox integration

Tilt is currently implemented natively in Firefox starting with version 11, part of the Developer Tools -> Inspector. You can track the development in the mozilla-central branch. If you have a Bugzilla account, here are all the known bugs and features we're working on - you're welcome to file new requests in there or even help out if you want to!

Take a look at Firefox Aurora or Firefox Nightly to try out the new and improved Tilt!

Help

If you have any questions, ping anyone on IRC in #devtools or #tilt on irc.mozilla.org.

Installation

In the bin folder you will find the latest Tilt.xpi extension build. Download, then drag and drop it to Firefox. After the installation is complete, restart, and open the extension using Ctrl+Shift+M (or Cmd+Shift+M if you're on a mac), or find it inside the Tools menu. Close it at any time with the Esc key.

Description

Tilt represents a new way of visualizing a web page. This tool creates a 3D representation of the document, with the purpose of displaying, understanding and easily analyzing the DOM. It will take advantage of the great tools Firefox has to offer, as it is an extension which contains a WebGL implementation, providing rich user-experience, fun interaction and useful information, while taking full advantage of 3D hardware acceleration, GLSL shaders and what OpenGL ES 2.0 has to offer.

The implementation consists of a Firefox extension containing a 3D representation of a web page, as both a fun visualization tool and a developer-friendly environment for debugging the document’s structure, contents and nesting of the DOM tree. Various information besides the actual contents will be displayed on request, regarding each node’s type, class, id, and other attributes if available. The rendering will be dynamic, in-browser, using WebGL and GLSL shaders.

It is being developed by Victor Porof (3D developer responsible with the Firefox extension itself), along with Cedric Vivier (creating a WebGL optimized equivalent to the privileged canvas.drawWindow, see #653656) and Rob Campbell (who first thought about creating a 3D visualization of a webpage). Everything started initially as a Google Summer of Code project, but now, with an enthusiastic team behind it and so many new features and ideas, it has become an active Developer Tools project.

![Screenshot](http://dl.dropbox.com/u/2388316/tilt/tilt02.png)

License

Tilt is licensed as Mozilla Public License Version 1.1, like any other Mozilla product. See mozilla.org/MPL for more information.

How to build

Building is done using the build script. There are two parts of the project which can be used: the engine and the extension itself. To build everything and also minify the sources, run the following ./build command from a terminal:

./build all minify

Alternatively, you can just use the engine or extension param to build only a part of the project.

./build engine
./build extension

You can append the minify and/or optimize parameter to minify and optimize the sources when building, but this is recommended only for a final release, as it takes quite a lot of time. The output files are in the bin folder. If the extension was also built, inside build you can find the unpacked Tilt.xpi archive.

Tilt uses the Google Closure compiler to optimize the Javascript files, with the --compilation_level ADVANCED_OPTIMIZATIONS flag. Therefore, some Javascript externs must be specified so important variable names are not renamed.

How to automatically install

To install the extension automatically in Firefox with the make install or ./build command, first edit the makefile and change the profile_dir to match your profile in Firefox. If you don't do this, installation will fail. Additionally, you may need to have the [email protected] folder created in the extension profile directory, depending on the OS and Firefox version. After this quick setup (provided you already compiled everything with ./build), run the following command to install the extension:

export OSTYPE; make install;

Or, to automatically minify everything, optimize and also install:

./build all minify optimize install

WebGL engine

The extension is based on a custom engine (having a syntax similar to processing.js, but with specialized features destined for DOM visualizations). Feel free to contribute to the engine in any way! You can find the sources in the src/chrome/content/engine folder. To use it outside the extension, get the latest build (unminified version here), and use it in a plain webpage like this:

var canvas, tilt;

function setup() {
  canvas = Tilt.Document.initFullScreenCanvas();
  tilt = new Tilt.Renderer(canvas);
}

function draw() {
  tilt.loop(draw);
  tilt.clear(1, 0, 0, 1);
}

setup();
draw();

Controls

Controlling the visualization is achieved using a virtual trackball (arcball), which rotates around the X and Y axes. Other mouse events exist to control yaw, pitch, roll, pan, zoom, as well as various additional keyboard shortcuts (arrow keys for translation, wasd for rotation). The controller is not tied to these peripherals only however, making it accessible and easily scalable for other input methods or devices. Double clicking a node brings up the Ace Cloud9 IDE editor, showing more useful information about the node and the inner HTML. Current implementation may change!

Implement a custom controller

The controller is initialized in browserOverlay.js when constructing the visualization:

this.visualization =
  new TiltChrome.Visualization(this.canvas,
  new TiltChrome.Controller.MouseAndKeyboard(),
  new TiltChrome.UI.Default());

The current mouse and keyboard implementation is in TiltChromeController.js. You can implement your own controller by creating a new object respecting a predefined interface. Each controller should have the init, update, resize and destroy functions, and you can access the public delegate methods in the visualization using this.visualization. Generally, you should need to handle only the following events:

  • this.visualization.setTranslation(translation)
  • this.visualization.setRotation(quaternion)
  • this.visualization.performMeshPick(x, y)

The controller pattern is:

TiltChrome.Controller.MyCustomController = function() {

  /**
   * Function called automatically by the visualization at the setup().
   * @param {HTMLCanvasElement} canvas: the canvas element
   */
  this.init = function(canvas) {
    // perform custom initialization, add event listeners...
  };

  /**
   * Function called automatically by the visualization each frame in draw().
   * @param {Number} frameDelta: the delta time elapsed between frames
   */
  this.update = function(frameDelta) {
    // access the visualization using this.visualization
    // manipulate the current model view transformation using
    //  this.visualization.setTranslation(translation) and
    //  this.visualization.setRotation(quaternion)
  };

  /**
   * Delegate method, called when the controller needs to be resized.
   *
   * @param width: the new width of the visualization
   * @param height: the new height of the visualization
   */
  this.resize = function(width, height) {
  };

  /**
   * Destroys this object and sets all members to null.
   * @param {HTMLCanvasElement} canvas: the canvas dom element
   */
  this.destroy = function(canvas) {
    // remove any events listeners and do the cleanup
  };
};

Implement a custom UI

Just like the controller, the user interface is initialized when constructing the visualization. The current work in progress implementation is in TiltChromeUI.js. You can implement your own user interface by creating a new object respecting a predefined interface.

Each UI should have the init, draw, resize and destroy functions. Moreover, you can specify events like domVisualizationMeshNodeCallback or meshNodeCallback, or meshReadyCallback handled automatically by the visualization.

The UI pattern is:

TiltChrome.UI.MyCustomUserInterface = function() {

  /**
   * Function called automatically by the visualization at the setup().
   * @param {HTMLCanvasElement} canvas: the canvas element
   */
  this.init = function(canvas) {
    // access the visualization using this.visualization
    // and the controller using this.controller
    // initialize all the UI components here
  };

  /**
   * Called automatically by the visualization after each frame in draw().
   * @param {Number} frameDelta: the delta time elapsed between frames
   */
  this.draw = function(frameDelta) {
  };

  /**
   * Delegate method, called when the user interface needs to be resized.
   *
   * @param width: the new width of the visualization
   * @param height: the new height of the visualization
   */
  this.resize = function(width, height) {
  };

  /**
   * Destroys this object and sets all members to null.
   */
  this.destroy = function(canvas) {
    // destroy all the UI components here
  };
};

Principles

Before developing this extension, I’ve experimented with various techniques of achieving the desired visualization results and polished user experience, by implementing a few of the required features and asking for feedback from knowledgeable people working in the domain. As a result, some key aspects must be pointed out:

  • Building an internal representation of the DOM shall be achieved by creating an iframe overlay in XUL as a Firefox extension. From experience, other techniques like injecting code into a web page, using already existing extensions (like Firebug), or depending on cloud services or CGI scripts are all bad ideas, as they are not scalable, deliver inconsistent user experience and don’t leave the original DOM intact.
  • Each node will be rendered as a stack element, roughly described as representing a “box”, having the X and Y positions grabbed from the object’s off-screen rendered coordinates using HTML5 canvas functions (therefore avoiding manually redrawing the entire web-page), and distributed on the Z depth axis based on the actual node depth in the DOM tree.
  • The base node will be represented by the BODY, upon which the child elements are layered to form a 3D stack of platforms. These platforms shall be build at the addition of DIVS, ULs or other nodes containing children.
  • Some elements are positioned in absolute or floating manners; these could be graphically represented in different ways, like a shadowing plane, or by graphically adding a floating animation.
  • Various other minimal information, characteristics or attributes will be visually attached to each stack representation of a node, with the possibility of displaying these properties more in depth at the user’s interaction with the visualization. Therefore, it’s a good idea to implement features that help understanding and analyzing the DOM, not just displaying it.
  • If required, a useful “map” of the DOM tree will be available, used for rapid navigation/orientation through the visualization.
  • The display will require intuitive controls, therefore an arcball controlled camera will be used, from the papers of Ken Shoemake, describing general purpose 3D rotation. Moreover, panning will be required for navigation, and other yaw, pitch and roll controls could be implemented.
  • Sliders or other UI elements could be used for modifying or setting the visualization parameters, like the distance between node layers, auto-rotation, and other effects.
  • The tool will be used as part of a web-page inspector, therefore a clean visualization will be more suited. A polished representation, not a bloated one, with subtle screen space ambient occlusion, a bit of lighting and shadowing is more appropriate and visually pleasing, adding a “stark” feel to it, thus focusing on the beauty of the web page itself and the DOM, and not on the achievable effects.
  • Ways of exporting the visualization to other WebGL compatible browsers should be implemented, for cross-platform and cross-browser user experience. This can be done by saving the representation parameters and passing them to other browsers. In the end, the export feature will actually be an URL.
  • As Tilt is designed to also be fun, a few easter-eggs could be implemented :)

Additional info

Contents

  1. A stand-alone Firefox extension which will contain the visualization
  2. A WebGL javascript library designed to facilitate creating web page DOM visualizations
  3. Examples, test-cases, stress-tests and documentation, so that the tool will continue to be developed even after the finalization of GSoC, both by me and the desiring community.

tilt's People

Contributors

victorporof avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tilt's Issues

Hotkeys

Since I have Stylish installed - the hotkey "CTRL+SHIFT+M" is occupied by it.
I know there is also a hotkey "CTRL+SHIFT+L" that opens Tilt, but I have to keep that hotkey in mind, as if I go to "Menu > Tools > Web developer > Tilt" - it shows me the CTRL+SHIFT+M hotkey.

As I'm not sure that it is an intentional duplication of used hotkes (M and L), or it is a bug/temporary solution - I am opening this issue to make things clear.
If this duplication is intentional, then a smart check like "Is CTRL+SHIFT+M hotkey occupied by another add-on? if yes - then show CTRL+SHIFT+L hotkey in the menu" would be nice, if possible.

FR: Draw margins/paddings for a selected element?

Could you please make Tilt draw the fields around the selected element to show where edges, paddings, margins and borders of this element are?

I often write styles for the usually visited sites with not so good appearance that I'd like to change. Sometimes I have to reposition its' elements, and I have to manually check every element's margins/paddings/borders/position values.
It would be way easier, if Tilt could draw colorful fields around the selected element, so I'd easily get know if any of the elements I need to reposition has any margin/padding/border/position non-zero values.

Do not draw text/images on background layers

As you see on the screenshot above - all the text is visually duplicated as it gets drawn on every background layers.
I'm not sure if it's possible, but could you make it not get drawn there? By HTML structure it takes place in some SINGLE element and not in any of it's ancestors.

p.s.: the same happens not only with text, but with images too.

Flickering display and missing menu item.

Installed Tilt 0.9.1.7

Looked in Tools> and Tools>Web Developer for Tilt. Cannot find.
Looked in Tools>Add-ons and it is installed.
Used Ctrl+Shift+M to start, and it does start and it does display the Tilt DOM and I can manipulate it in 3D space.

So even though it can't be found in the menu, it can be used.

Unfortunately with Tilt installed the menu items now flicker terribly, to the point of being unusable. By this I mean I place the mouse cursor over the "Tools" menu item and press down. The word Tools vanishes and an empty drop down box flickers momentarily and then vanishes, leaving just a drop shadow outline. If I move the cursor down into the drop down box the information reappears, but its now very touchy. At various points the box will flicker, vanish then reappear. When the cursor moves over a menu item that has a ">" for expanding another drop down box, the selection highlight jumps upward one menu item, then back down. Sometimes the second drop down opens, sometimes it doesn't.

I have the web developer tool bar installed and the behavior here is affected as well. Basically it seems to happen to all the items in the menu bar.

If I remove Tilt, everything returns to normal (thank you for that). At this point the flickering unfortunately means I can not use this tool for the time being :(

I like Tilt and can see a tremendous benefit coming from it, particularly when you get it to the point that I can click on an item in the Tilt display and get its DOM trace, css etc. I will really help visualize the location of items for those of us learning Javascript for example.

My workspace:
Firefox 7.0.1 (latest release as of nov 14 2011)

Installed Add-ons

Adblock Plus 1.3.10
Adblock Plus Pop-up Addon 0.2.9
AlertCheck 1.1
BetterPrivacy 1.67
ColorZilla 2.6.2.1
Console² 0.8
Context Font 0.6
DOM Inspector 2.0.10
Firebug 1.8.3
Flagfox 4.1.8
Ghostery 2.6.0.1
Google Analytics Opt-out Browser Add-on 0.9.5
GridFox 2.0
Hostname in Titlebar 2.0.0
MeasureIt 0.4.10
Screengrab 0.96.3
ShowIP 1.0
Tilt 0.9.1.7
Web Developer 1.1.9

Context menu and "Esc" to exit

One suggestions , since it uses webgl on canvas . why is there not a context menu to save the image ? It would be very nice to have it , and also pressing Escape to hide Visualization

Problems with FF7

I'm getting the following error message when I try to run Tilt:

Error: this.f is null
Source File: chrome://tilt/content/Tilt-content.js
Line: 96

My specs:
Windows 7(64bit)
Firefox 7.0a2
Tilt 0.1

Editor's window should have controls to move up/down in the DOM tree

  1. There should be a "Go Up" button.
  2. Double-clicking (or somehow else) on the child element's tag in the editor should "zoom in" to that element in the editor + maybe even "zoom in" the canvas to center on that element too. Centering on the element might be hard to do, since we need to face it from the front side. [And in the far future this action might gain smooth animations]
    I don't want to file a new issue, so I'll ask/request it here:
  3. Why do buttons "attributes/css/html" are up above? Shouldn't they be on the editor's window? Anyways they appear only if this window is shown.

Exploded view

It would be just great to have control over exploded view, it would very handy to analyse the design in development. The control would be a slider that will space more or less all the elements on the image, something like the technical drawings exploded view: http://s18.postimage.org/7pkeqtexz/doc1292867197390.gif.

Wonderfull work, I waited years for this extension!

Html Editing panel creates confusion

The panel on lower right (which opens up when we click on the rendering) is editable , creating a sense that we can edit the html of the page . I don't know if that is the case because even if we can change the html of the page , the rendering is not updated . And if we can't change the html of the clicked node, then the panel should not be editable.
Also the panel should have a title or something giving information about the node type, not just the content of node

How about making it useful? It definitely needs Attributes Inspector + inspect in DOMi

I use Attributes Inspector button for CustomButtons extension which is the great tool that show the info (in a tooltip) about the hovered element on the page and I can inspect it in DOMi if I middle-click (or ctrl+left-click) it.
But it's not working with Tilt. If Tilt is running then it just shows a single item (canvas) on the page and nothing else.
So could you please add a similar tool for inspecting the elements of the page by just pointing at them with a cursor and being able to send them to inspect in DOMi?
That would be totally awesome and I think even more useful then FireBug for writing/editing CSS styles.

Animation missing

Coming from the integrated Tilt feature of Firefox < 47.0 I am really missing one "feature": The animation.
Previously when accessing it it displayed a nice animation showing how to 2D website transforms into the 3D version and reverse. Now, with this addon, it just switches statically.

Integrate into dev tools

It would be nice to get the icon for starting Tilt back (as it was there in Firefox < 47 where Tilt was integrated) into the dev tools. I mean this part:
tiltbar

This way you can quickly access it.

.swf files

It would be good to see .swf animations not just the Youtube .avi formats.

Shows rotating cube - Your browser supports WebGL

Pressing Control Shift M gives a page stating:

Your browser supports WebGL
However, it indicates that support is experimental; you might see issues with some content.
You should see a spinning cube. If you do not, please visit the support site for your browser.

on Firefox 7.0.1 on Ubuntu

No option to progress to tilt.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.