Difference between revisions of "XML 3D - BTS530/630 Project"

From CDOT Wiki
Jump to: navigation, search
(Tag Reference)
Line 14: Line 14:
 
The objective of Canvas was to provide a drawing interface inside the HTML document which website designers could use to create interactive content. It also allows the designers of the webpage to change the Canvas object on the fly using JavaScript or Python. The Canvas tag exposes the functionality of XUL with added security and safeguards to prevent damage to the client's computer.
 
The objective of Canvas was to provide a drawing interface inside the HTML document which website designers could use to create interactive content. It also allows the designers of the webpage to change the Canvas object on the fly using JavaScript or Python. The Canvas tag exposes the functionality of XUL with added security and safeguards to prevent damage to the client's computer.
  
= XML 3D Addition to Canvas =
+
= XML 2D/3D Addition to Canvas =
  
 
== Rationale ==
 
== Rationale ==
Line 20: Line 20:
 
The basis of the Canvas tag is to provide immediate drawing to the screen. The drawing can consist of regular 2D pixel manipulations as well as a proposed 3D model manipulation. In addition, it will provide a safe and simple application programming interface (API) to the OpenGL Layer. The OpenGL Layer is a library that handles the math required for 3D transformations. Unfortunately, OpenGL has the power to talk directly to the hardware therefore allowing direct manipulation of the hardware or possibly potential damage. Consequently, the OpenGL Layer will not be included in this project due to its complex nature and constant upkeep. In addition, the OpenGL API is extremely low-level and may be confusing when exposed to the internet. <br/> <br/>
 
The basis of the Canvas tag is to provide immediate drawing to the screen. The drawing can consist of regular 2D pixel manipulations as well as a proposed 3D model manipulation. In addition, it will provide a safe and simple application programming interface (API) to the OpenGL Layer. The OpenGL Layer is a library that handles the math required for 3D transformations. Unfortunately, OpenGL has the power to talk directly to the hardware therefore allowing direct manipulation of the hardware or possibly potential damage. Consequently, the OpenGL Layer will not be included in this project due to its complex nature and constant upkeep. In addition, the OpenGL API is extremely low-level and may be confusing when exposed to the internet. <br/> <br/>
  
However, the first step in creating a 3D Canvas element is to use a custom XML tag to specify the 3D objects on the screen as well as the drawing area available. In this case, the developer will be able to create 3D objects on the client's screen as well as provide logic to modify these objects in real-time. By using the Document Object Model (DOM) to interpret the XML language and retrieve the attributes of the objects, this causes the objects to be presented for modification purposes.
+
However, the first step in creating a 2D/3D Canvas element is to use a custom XML tag to specify the 2D/3D objects on the screen as well as the drawing area available. In this case, the developer will be able to create 3D objects on the client's screen as well as provide logic to modify these objects in real-time. By using the Document Object Model (DOM) to interpret the XML language and retrieve the attributes of the objects, this causes the objects to be presented for modification purposes.
  
 
== The Document Object Model ==
 
== The Document Object Model ==
Line 26: Line 26:
 
The Document Object Model is an API that allows for the interpretation of HTML and XML documents. It provides a structural representation of the document, which enables for easy modification and visual representation of the webpage. In essence, it connects the markup languages to structural code inside the browser. The DOM is contained in a tree structure that allows for easy search and retrieval of HTML and XML tags and their properties. This technology allows the Canvas tags to be read and retrieved in an efficient manner.
 
The Document Object Model is an API that allows for the interpretation of HTML and XML documents. It provides a structural representation of the document, which enables for easy modification and visual representation of the webpage. In essence, it connects the markup languages to structural code inside the browser. The DOM is contained in a tree structure that allows for easy search and retrieval of HTML and XML tags and their properties. This technology allows the Canvas tags to be read and retrieved in an efficient manner.
  
== Use of XML 3D ==
+
== Use of XML 2D/3D ==
  
 
The Canvas 3D Tags will be based upon the syntax of its counterpart, the 2D Canvas tags. Essentially, the syntax will be similar to the following:<br/>
 
The Canvas 3D Tags will be based upon the syntax of its counterpart, the 2D Canvas tags. Essentially, the syntax will be similar to the following:<br/>
Line 32: Line 32:
 
<pre>
 
<pre>
 
<canvas>
 
<canvas>
  -- size is size of a size, orientation is a quaternion
+
  -- draw a qube, size is a quaternion
 
  <cube position="x y z" orientation="a b c d" size="4"/>
 
  <cube position="x y z" orientation="a b c d" size="4"/>
  -- size is radius
+
  -- draw a sphere
 
  <sphere position="x y z" size="5"/>
 
  <sphere position="x y z" size="5"/>
 +
-- draw a square on the screen
 +
<rectangle width="4" height="10"/>
 
</canvas>
 
</canvas>
 
</pre>
 
</pre>
Line 66: Line 68:
 
</pre>
 
</pre>
  
== Use of XML 3D in JavaScript ==
+
== Use of XML 2D/3D in JavaScript ==
  
 
In order to draw the objects onto the screen, JavaScript will be used to call functions inside the core of Firefox. The API will be written to allow programmers to not only access the various attributes of the Objects but also write drawing logic. The webpage will initiate a call to a JavaScript function that will start the drawing/manipulation code. This part of the project is being handled by Vlad Vukicevic from Mozilla.  
 
In order to draw the objects onto the screen, JavaScript will be used to call functions inside the core of Firefox. The API will be written to allow programmers to not only access the various attributes of the Objects but also write drawing logic. The webpage will initiate a call to a JavaScript function that will start the drawing/manipulation code. This part of the project is being handled by Vlad Vukicevic from Mozilla.  
Line 73: Line 75:
  
 
This is a list of Tags that will be Written as of Oct 1, 2006. This is a tentative List and will change in time:
 
This is a list of Tags that will be Written as of Oct 1, 2006. This is a tentative List and will change in time:
* Primative Objects:
+
* 2D Tags
 +
**[[Canvas_3D_-_Line_Tag|<line>]]
 +
**[[Canvas_3D_-_Arc_Tag|<arc>]]
 +
**[[Canvas_3D_-_Circle_Tag|<circle>]]
 +
**[[Canvas_3D_-_Rectangle_Tag|<rectangle>]]
 +
**[[Canvas_3D_-_Image_Tag|<image>]]
 +
* 2D Group Modifiers
 +
** [[Canvas_3D_-_Translate_Tags|<translate2D>]]
 +
** [[Canvas_3D_-_Scale_Tags|<scale2D>]]
 +
* 3D Primative Objects:
 
** [[Canvas_3D_-_Cube_Tag|<cube />]]
 
** [[Canvas_3D_-_Cube_Tag|<cube />]]
 
** [[Canvas_3D_-_Sphere_Tag|<sphere />]]
 
** [[Canvas_3D_-_Sphere_Tag|<sphere />]]
Line 79: Line 90:
 
** [[Canvas_3D_-_Light_Tag|<light />]]
 
** [[Canvas_3D_-_Light_Tag|<light />]]
 
** [[Canvas_3D_-_Texture_Tag|<texture />]]
 
** [[Canvas_3D_-_Texture_Tag|<texture />]]
* Complex Objects:
+
* 3D Complex Objects:
 
** [[Canvas_3D_-_Mesh_Tag|<mesh />]]
 
** [[Canvas_3D_-_Mesh_Tag|<mesh />]]
* Group Modifiers:
+
* 3D Group Modifiers:
** [[Canvas_3D_-_Transform_Tags|<transform>]]
+
** [[Canvas_3D_-_Transform_Tags|<transform3D>]]
** [[Canvas_3D_-_Scale_Tags|<scale>]]
+
** [[Canvas_3D_-_Scale_Tags|<scale3D>]]
** [[Canvas_3D_-_Rotate_Tags|<rotate>]]
+
** [[Canvas_3D_-_Rotate_Tags|<rotate3D>]]
** [[Canvas_3D_-_Translate_Tags|<translate>]]
+
** [[Canvas_3D_-_Translate_Tags|<translate3D>]]
* 2D Tags
+
 
**[[Canvas_3D_-_Line_Tag|<line>]]
+
= Iterations & Progress =
**[[Canvas_3D_-_Arc_Tag|<arc>]]
 
**[[Canvas_3D_-_Circle_Tag|<circle>]]
 
**[[Canvas_3D_-_Rectangle_Tag|<rectangle>]]
 
**[[Canvas_3D_-_Image_Tag|<image>]]
 
  
== XML 3D Progress ==
+
== Completed Iterations ==
 +
*<b>Iteration 0: Fix Tag Compatibility (Completed: Dec 2006)</b>
 +
** Write DOM Parsing Code
 +
** Create Wiki site to detail out the Tags
 +
** Write JavaScript code to manage and Draw the Tag information
  
There are several steps to starting this project which are beyond the scope of data modelling and design. Here is a list of steps that we used to setup our environment in order to start working on the Code.
+
*<b>Iteration 1: Fix Tag Compatibility (Completed: Jan 2007)</b>
 +
** Restructure the parsing Code to Accept Tags without an Ending Tag
 +
** Write a Test for the above task
 +
** Rewrite Tag parsing Code
 +
** Write Test for the Tag Parsing Code
 +
** Update the Wiki with new content
 +
** '''Issue: A temporary fix to the first task was to serve the page as XHTML'''
  
# Experiences with the 1.8.0 Branch and [[Building_Firefox_1.5|How we Built Firefox 1.5]].
+
== Incomplete Iterations ==
# Experiences with [[Debug_Mode_Firefox_1.5|Running Firefox In Debug Mode]].
 
# The place our code will sit is located in a stand-alone JavaScript file which webpages will inherit. The DOM will be used extensively in our code.
 
# A JavaScript file was created to read the tags from the HTML file dynamically.
 
# JSUnit tests were created to assure code quality.
 
  
= Iterations =
+
* <b>Iteration 2: Create New 2D Tags</b>
 +
** Line Tag
 +
*** Create <Line> Tag
 +
*** Write Test for the Line Tag
 +
** Arc Tag
 +
*** Create <Arc> Tag
 +
*** Write Test for the Arc Tag
 +
** Circle Tag
 +
*** Create <Circle> Tag
 +
*** Write Test for the Circle Tag
 +
** Rectangle Tag
 +
*** Create <Rectangle> Tag
 +
*** Write Test for the Rectangle Tag
 +
** Image Tag
 +
*** Create <Image> Tag
 +
*** Write Test for the Image Tag
 +
** Update Wiki Site to reflect Above Changes
  
*<b>Iteration 1: Fix Tag Compatibility</b>
+
* <b>Iteration 3: Enhancing the DOM Parsing Code</b>
**Restructure the parsing Code to Accept Tags without an Ending Tag
+
** Create the ability to Dynamically Look for Tags
**Write a Test for the above task
+
** Write a test for the above task
**Rewrite Tag parsing Code
+
** Create a way to map a dynamic tag to a function
**Write Test for the Tag Parsing Code
+
** Create code to modify the Dom tree on the fly
**Update the Wiki with new content
+
** Write a test for the above task
 +
** Research into DOM events which are fired when changes are made
 +
** Update Wiki Site to reflect Above Changes
  
*<b>Iteration 2: Create New 2D Tags</b>
+
* <b>Iteration 4: Create Grouping Tags</b>
**Line Tag
+
** Scale Tag
***Create <Line> Tag
+
*** Create <Scale> Tag
***Write Test for the Line Tag
+
*** Write Test for the Scale Tag
**Arc Tag
+
** Rotate Tag
***Create <Arc> Tag
+
*** Create <Rotate> Tag
***Write Test for the Arc Tag
+
*** Write Test for the Rotate Tag
**Circle Tag
+
** Translate Tag
***Create <Circle> Tag
+
*** Create <Translate> Tag
***Write Test for the Circle Tag
+
*** Write Test for Translate Tag
**Rectangle Tag
+
** Transform Tag
***Create <Rectangle> Tag
+
*** Create <Transform> Tag
***Write Test for the Rectangle Tag
+
*** Write test for the Transform Tag
**Image Tag
+
** Update Wiki Site to reflect Above Changes
***Create <Image> Tag
 
***Write Test for the Image Tag
 
**Update Wiki Site to reflect Above Changes
 
  
*<b>Iteration 3: Enhancing the DOM Parsing Code</b>
+
== SVN Repository ==
**Create the ability to Dynamically Look for Tags
 
**Write a test for the above task
 
**Create a way to map a dynamic tag to a function
 
**Create code to modify the Dom tree on the fly
 
**Write a test for the above task
 
**Research into DOM events which are fired when changes are made
 
**Update Wiki Site to reflect Above Changes
 
  
*<b>Iteration 4: Create Grouping Tags</b>
+
* svn://zenit.senecac.on.ca/bts630_071r7
**Scale Tag
 
***Create <Scale> Tag
 
***Write Test for the Scale Tag
 
**Rotate Tag
 
***Create <Rotate> Tag
 
***Write Test for the Rotate Tag
 
**Translate Tag
 
***Create <Translate> Tag
 
***Write Test for Translate Tag
 
**Transform Tag
 
***Create <Transform> Tag
 
***Write test for the Transform Tag
 
**Update Wiki Site to reflect Above Changes
 
  
== References Used ==
+
= References Used =
  
 
[http://wiki.mozilla.org/Main_Page Mozilla Wiki Main Page]<br />
 
[http://wiki.mozilla.org/Main_Page Mozilla Wiki Main Page]<br />
 
[http://wiki.mozilla.org/Canvas:3D Official Canvas 3D Wiki]<br />
 
[http://wiki.mozilla.org/Canvas:3D Official Canvas 3D Wiki]<br />
[http://whatwg.org/specs/web-apps/current-work/#scs-dynamic Canvas 2D Reference]<br />
+
[http://whatwg.org/specs/web-apps/current-work/#the-2d Canvas 2D Reference]<br />
 
[http://whatwg.org/specs/web-apps/current-work/#the-3d Canvas 3D Reference]
 
[http://whatwg.org/specs/web-apps/current-work/#the-3d Canvas 3D Reference]

Revision as of 13:27, 2 February 2007

Programmers

Mark Paruzel
Yi Shen

Canvas Object

History

Canvas elements simplify the drawing of custom pixels to the screen as well as the modification of these pixels in real-time. There have been numerous requests for a canvas tag inside HTML documents which provided custom draw ability inside XUL (A Cross-Platform drawing management library). Unfortunately, XUL is client side based which only allows the modification of web pages from the user’s endpoint. The Canvas Tag was originally developed in order to create modifications to the browser from the server end. An on-screen Canvas object is basically a wrapper around the XUL engine that allows the visual manipulation of pixels on the webpage.

Objective

The objective of Canvas was to provide a drawing interface inside the HTML document which website designers could use to create interactive content. It also allows the designers of the webpage to change the Canvas object on the fly using JavaScript or Python. The Canvas tag exposes the functionality of XUL with added security and safeguards to prevent damage to the client's computer.

XML 2D/3D Addition to Canvas

Rationale

The basis of the Canvas tag is to provide immediate drawing to the screen. The drawing can consist of regular 2D pixel manipulations as well as a proposed 3D model manipulation. In addition, it will provide a safe and simple application programming interface (API) to the OpenGL Layer. The OpenGL Layer is a library that handles the math required for 3D transformations. Unfortunately, OpenGL has the power to talk directly to the hardware therefore allowing direct manipulation of the hardware or possibly potential damage. Consequently, the OpenGL Layer will not be included in this project due to its complex nature and constant upkeep. In addition, the OpenGL API is extremely low-level and may be confusing when exposed to the internet.

However, the first step in creating a 2D/3D Canvas element is to use a custom XML tag to specify the 2D/3D objects on the screen as well as the drawing area available. In this case, the developer will be able to create 3D objects on the client's screen as well as provide logic to modify these objects in real-time. By using the Document Object Model (DOM) to interpret the XML language and retrieve the attributes of the objects, this causes the objects to be presented for modification purposes.

The Document Object Model

The Document Object Model is an API that allows for the interpretation of HTML and XML documents. It provides a structural representation of the document, which enables for easy modification and visual representation of the webpage. In essence, it connects the markup languages to structural code inside the browser. The DOM is contained in a tree structure that allows for easy search and retrieval of HTML and XML tags and their properties. This technology allows the Canvas tags to be read and retrieved in an efficient manner.

Use of XML 2D/3D

The Canvas 3D Tags will be based upon the syntax of its counterpart, the 2D Canvas tags. Essentially, the syntax will be similar to the following:

<canvas>
 -- draw a qube, size is a quaternion
 <cube position="x y z" orientation="a b c d" size="4"/>
 -- draw a sphere
 <sphere position="x y z" size="5"/>
 -- draw a square on the screen
 <rectangle width="4" height="10"/>
</canvas>

The Canvas Tags are already handled by the browser and therefore do not need to be implemented. Rather, the tags that will create the 3D objects will be added to the current Canvas Framework to enable the creation of 3D objects in memory. For example, the <cube /> tag will create a 3D cube in memory. The Attributes associated with it, such as position, orientation and size are all modifiers that will be exposed within JavaScript. Each tag that is used inside the Canvas Tag will have similar properties that will also be available for modification in the JavaScript Code.

Within a 3D world, a programmer can add numerous transformations sequentially in order to place an object in a given place. It will provide a larger flexibility aspect to the markup language:

<canvas>
 -- either with an explicit matrix
 <transform position="m1..m16">
 <cube size="5"/>
 </transform>

 -- or with position and/or orientation
 <transform position="x y z" orientation="a b c d">
 <cube size="5"/>
 </transform>
</canvas>

These are the basic principles that govern 3D controls over an Object. An object can be anything from a simple primitive such as a Cube or Sphere to a complex Mesh that can be downloaded from the internet or from the client's computer. Furthermore, the usage of lighting and camera modifications will follows the same structure as the primitives.

<canvas>
 -- create a light
 <light type="spot" color="blue" position="x y z" orientation="a b c d" />
</canvas>

Use of XML 2D/3D in JavaScript

In order to draw the objects onto the screen, JavaScript will be used to call functions inside the core of Firefox. The API will be written to allow programmers to not only access the various attributes of the Objects but also write drawing logic. The webpage will initiate a call to a JavaScript function that will start the drawing/manipulation code. This part of the project is being handled by Vlad Vukicevic from Mozilla.

Tag Reference

This is a list of Tags that will be Written as of Oct 1, 2006. This is a tentative List and will change in time:

Iterations & Progress

Completed Iterations

  • Iteration 0: Fix Tag Compatibility (Completed: Dec 2006)
    • Write DOM Parsing Code
    • Create Wiki site to detail out the Tags
    • Write JavaScript code to manage and Draw the Tag information
  • Iteration 1: Fix Tag Compatibility (Completed: Jan 2007)
    • Restructure the parsing Code to Accept Tags without an Ending Tag
    • Write a Test for the above task
    • Rewrite Tag parsing Code
    • Write Test for the Tag Parsing Code
    • Update the Wiki with new content
    • Issue: A temporary fix to the first task was to serve the page as XHTML

Incomplete Iterations

  • Iteration 2: Create New 2D Tags
    • Line Tag
      • Create <Line> Tag
      • Write Test for the Line Tag
    • Arc Tag
      • Create <Arc> Tag
      • Write Test for the Arc Tag
    • Circle Tag
      • Create <Circle> Tag
      • Write Test for the Circle Tag
    • Rectangle Tag
      • Create <Rectangle> Tag
      • Write Test for the Rectangle Tag
    • Image Tag
      • Create <Image> Tag
      • Write Test for the Image Tag
    • Update Wiki Site to reflect Above Changes
  • Iteration 3: Enhancing the DOM Parsing Code
    • Create the ability to Dynamically Look for Tags
    • Write a test for the above task
    • Create a way to map a dynamic tag to a function
    • Create code to modify the Dom tree on the fly
    • Write a test for the above task
    • Research into DOM events which are fired when changes are made
    • Update Wiki Site to reflect Above Changes
  • Iteration 4: Create Grouping Tags
    • Scale Tag
      • Create <Scale> Tag
      • Write Test for the Scale Tag
    • Rotate Tag
      • Create <Rotate> Tag
      • Write Test for the Rotate Tag
    • Translate Tag
      • Create <Translate> Tag
      • Write Test for Translate Tag
    • Transform Tag
      • Create <Transform> Tag
      • Write test for the Transform Tag
    • Update Wiki Site to reflect Above Changes

SVN Repository

References Used

Mozilla Wiki Main Page
Official Canvas 3D Wiki
Canvas 2D Reference
Canvas 3D Reference