diff --git a/DrawableObject.js b/DrawableObject.js
index 87b4edc..8df4e7d 100644
--- a/DrawableObject.js
+++ b/DrawableObject.js
@@ -2,11 +2,21 @@
//Written by Brandon Poythress
//01MAY2018
-function DrawableObject(colorIn){
+function DrawableObject(colorIn, parentDirtyListCallbackIn){
this.graphicsMemoryAddress = null;
this.killMe = false;
+ this.passDirtyToParent = parentDirtyListCallbackIn;
this.color = new Color(colorIn.r, colorIn.g, colorIn.b, colorIn.a);
+
+ //points, lines and faces define how the object draws itself
+ this.pointList = [];
+ this.lineList = [];
+ this.surfaceList = [];
+
+ //the renderlist is the list of children that need to draw themselves
+ //after the object is finished drawing itself
+ this.renderList = [];
}
//setter to change the color
@@ -15,4 +25,8 @@ DrawableObject.prototype.setColorByObject = function(colorIn){
this.color.g = colorIn.g;
this.color.b = colorIn.b;
this.color.a = colorIn.a;
+};
+
+ModelObject.prototype.dirtyListCallback = function(dirtyObject){
+ this.passDirtyToParent(dirtyObject);
};
\ No newline at end of file
diff --git a/LabScene.js b/LabScene.js
index e32cec7..758edbf 100644
--- a/LabScene.js
+++ b/LabScene.js
@@ -6,14 +6,11 @@
function LabScene(idIn, parentIdIn, parentDirtyListCallbackIn){
- ModelObject.call(this, "Scene", idIn, parentIdIn, true, parentDirtyListCallbackIn);
+ ModelObject.call(this, "Scene", idIn, parentIdIn, true);
- console.log(this.type);
- console.log(this.usesRenderList);
+ DrawableObject.call(this, null, parentDirtyListCallbackIn);
-
-
// this.type = "Scene";
// this.id = idIn;
// this.parent = parentIdIn;
@@ -81,14 +78,14 @@ function LabScene(idIn, parentIdIn, parentDirtyListCallbackIn){
-LabScene.prototype = Object.create(ModelObject.prototype);
+LabScene.prototype = Object.create(DrawableObject.prototype);
+
+LabScene.prototype.constructor = LabScene;
LabScene.prototype.update = function(lastUpdate){
};
-LabScene.prototype.constructor = LabScene;
-
LabScene.prototype.onMouseUp = function(eyeX, eyeY, eyeZ, worldRay){
diff --git a/Line.js b/Line.js
index 6a6b302..22e3343 100644
--- a/Line.js
+++ b/Line.js
@@ -5,16 +5,16 @@
//Line object
//Line class
-function Line(idIn, parentIdIn, parentDirtyListCallbackIn, point1In, point2In, colorIn){
+function Line(idIn, parentIdIn, parentDirtyListCallbackIn, vertex1In, vertex2In, colorIn){
//Line inherits properties from ModelObject but not methods
- ModelObject.call(this, "Line", idIn, parentIdIn, false, parentDirtyListCallbackIn);
+ ModelObject.call(this, "Line", idIn, parentIdIn);
//Line is a drawable object
- DrawableObject.call(this, colorIn);
+ DrawableObject.call(this, colorIn, parentDirtyListCallbackIn);
- this.point1 = point1In;
- this.point2 = point2In;
+ this.vertex1 = vertex1In;
+ this.vertex2 = vertex2In;
}
diff --git a/ModelObject.js b/ModelObject.js
index a04b959..2219c46 100644
--- a/ModelObject.js
+++ b/ModelObject.js
@@ -6,16 +6,11 @@
//in terms of Model-View-Controller organization.
function ModelObject(typeIn, idIn, parentIdIn,
- usesRenderListIn, parentDirtyListCallbackIn){
+ usesRenderListIn){
this.type = typeIn;
this.id = idIn;
this.parent = parentIdIn;
- this.usesRenderList = usesRenderListIn;
- this.passDirtyToParent = parentDirtyListCallbackIn;
this.idGen = new IdGenerator();
- this.renderList = [];
+
}
-ModelObject.prototype.dirtyListCallback = function(dirtyObject){
- this.passDirtyToParent(dirtyObject);
-};
\ No newline at end of file
diff --git a/ModelState.js b/ModelState.js
index aa7e31c..94075cf 100644
--- a/ModelState.js
+++ b/ModelState.js
@@ -10,7 +10,14 @@ function ModelState(){
//it does not use id, parentId, or parentDirtyListCallback so they
//are set to null. It also does not need ModelObject methods,
//so ModelState doesnt grab its prototypes.
- ModelObject.call(this, "State", null, null, true, null);
+ ModelObject.call(this, "State", null, null, true);
+
+ //The model state needs many things from the drawable object class.
+ //the color and parentCallback functions are set to null
+ //because it has no color or parent. Also, there is no
+ //need to inherit any methods from this class so its prototypes are
+ //not taken.
+ DrawableObject.call(this, null, null);
//the state object manages its own model matrix
//and view matrix. The renderer handles proj
@@ -91,6 +98,8 @@ function ModelState(){
// this.portal.draw(gl, renderer);
// }
+
+
ModelState.prototype.dirtyListCallback = function(dirtyObject){
this.dirtyList.push(dirtyObject);
};
diff --git a/Plane.js b/Plane.js
index a9a801e..8437484 100644
--- a/Plane.js
+++ b/Plane.js
@@ -4,41 +4,30 @@
//Description:
//This class represents a plane.
-function Plane(idIn, parentIdIn, parentDirtyListCallback, xIn, yIn, zIn, normalXIn, normalYIn, normalZIn, upXIn, upYIn, upZIn){
+function Plane(idIn, parentIdIn, parentDirtyListCallbackIn, xIn, yIn, zIn, normalXIn, normalYIn, normalZIn, upXIn, upYIn, upZIn){
- //basic information about the plane
- this.type = "Plane";
- this.id = idIn;
- this.parent = parentIdIn;
- this.idGen = new IdGenerator();
-
- //rendering information
- this.usesRenderList = true;
- this.renderList = [];
-
- //color of the plane
- this.color = GREEN;
- //callback function to the parent
- //used to inform about children that need
- //to be updated in the GPU because they have
- //changed
- this.passDirtyToParent = parentDirtyListCallback;
+ ModelObject.call(this, "Plane", idIn, parentIdIn);
+
+ DrawableObject.call(this, GREEN, parentDirtyCallbackIn);
//location of the plane's center point
- this.x = xIn;
- this.y = yIn;
- this.z = zIn;
+ this.planePointVector = new Vector3();
+ this.planePointVector.elements[0] = xIn;
+ this.planePointVector.elements[1] = yIn;
+ this.planePointVector.elements[2] = zIn;
//normal vector components
- this.normalX = normalXIn;
- this.normalY = normalYIn;
- this.normalZ = normalZIn;
+ this.nVector = new Vector3();
+ this.nVector.elements[0] = normalXIn;
+ this.nVector.elements[1] = normalYIn;
+ this.nVector.elements[2]= normalZIn;
//Local Y axis vector components
- this.upX = upXIn;
- this.upY = upYIn;
- this.upZ = upZIn;
-
+ this.upVector = new Vector3();
+ this.upVector.elements[0] = upXIn;
+ this.upVector.elements[1] = upYIn;
+ this.upVector.elements[2]= upZIn;
+
//size of the plane in mm. May be better
//to pass this into the constructor
//but for now I will hard code it
@@ -129,9 +118,9 @@ function Plane(idIn, parentIdIn, parentDirtyListCallback, xIn, yIn, zIn, normalX
}
-Plane.prototype.dirtyListCallback = function(dirtyObject){
- this.passDirtyToParent(dirtyObject);
-};
+Plane.prototype = Object.create(DrawableObject.prototype);
+
+Plane.prototype.constructor = Plane;
Plane.prototype.update = function(){
diff --git a/Vertex.js b/Vertex.js
deleted file mode 100644
index dd76996..0000000
--- a/Vertex.js
+++ /dev/null
@@ -1,17 +0,0 @@
-//Vertex.js
-//Written by Brandon Poythress
-//14MAY2018
-//Description:
-//I found that it was necessary to separate vertices from points.
-//Points are objects that are visible and selectable to the user.
-//vertices are the building blocks for complex objects but
-//are not necessarily viewable or able to be interacted with by
-//the user. Each point will contain a vertex object, but
-//every vertex will not be necessarily be a point.
-
-function Vertex(xIn, yIn, zIn){
-
- this.x = xIn;
- this.y = yIn;
- this.z = zIn;
-}
\ No newline at end of file
diff --git a/freedom.html b/freedom.html
index 91b2ea0..56f3f3f 100644
--- a/freedom.html
+++ b/freedom.html
@@ -20,26 +20,41 @@
Please use a browser that supports "canvas"
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
-
+
-
+
+
+