Diff
Not logged in

Differences From Artifact [0b9640f7fc]:

To Artifact [ba994e1850]:


1




2
3
4
5
6
7
8


9
10

11


12



13
14
15
16
17
18
19





























































20


21
22
23
24
25
26
27
...
335
336
337
338
339
340
341

342
343
344
345






// global namespace object
var WireframeModel;


(function(){



//  A wireframe model and all the controls needed to move the camera and draw.
//  despite the name, it may also include polygon surfaces.




var origin = [0, 0, 0];






var points = []; //global
var solo_points = {};
var lines = [];






























































var point_projections = [];


var line_midpoint_projections = [];


var highlight_object = null;
var mouse_dragging = false;
var last_mouse_down = null;
var mouse_loc = null;
................................................................................
				ctx.rect(minx, miny, maxx - minx, maxy - miny);
				ctx.stroke(); }}
	}
    
    ctx.fillStyle = "rgb(0,0,0)";
	writeMsg(canvas, msg); }
	

	


})();

>
>
>
>







>
>


>

>
>
|
>
>
>



|
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

>
>







 







>
|
<
<
<
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
...
410
411
412
413
414
415
416
417
418





// requires matrix_vector_lib.js
// TODO we could make some libraryless way of checking dependencies and versions.


// global namespace object
var WireframeModel;


(function(){



//  A wireframe model and all the controls needed to move the camera and draw.
//  despite the name, it may also include polygon surfaces.
function __WireframeModel(){

	var WFMObj = this;
	
	var view_origin = [0, 0, 0];
	var view_transform = [[1, 0, 0],
	                      [0, 1, 0],
						  [0, 0, 1]];



	var points = []; //global
	var solo_points = {};
	var lines = [];
	
	
	// just because these actual objects is returned
	// doesn't mean you should modify it externally if you can help it.
	
	WFMObj.getPoints = function getPoints(){
		return points; }
	
	WFMObj.getLines = function getLines(){
		return lines; }
	
	WFMObj.getViewTransform = function getViewTransform(){
		return view_transform; }
	
	
	
	WFMObj.addPoint = function addPoint(pt){
		
		//  Check type of passed object.
		if(Array.isArray && !Array.isArray(pt)){  // only check if Array.isArray function is available
			throw "pt object is not an array"; }
			
		if(pt.length != 3){
			throw "pt array object not length 3"; }
		
		for(var i = 0; i < 3; ++i){
			if(isNaN(pt[i])) throw "pt object array does not store a number at index " + i; }
			
		points.push(pt);
		return points.length - 1; }
	
	
	
	WFMObj.addLine = function addLine(line){
		if(Array.isArray && !Array.isArray(line)){
			throw "line object is not an array" }
		
		if(line.length != 2){
			throw "line object must be between 2 points.  line object has length: " + line.length; }
		
		for(var i = 0; i < 2; ++i){
			var ptindex = line[i];
			if(isNaN(ptindex) || Math.floor(ptindex) != ptindex){
				throw "pt ref at index " + i + " of line was not an integer: " + ptindex; }
			
			if(ptindex < 0 || ptindex >= points.length){
				throw "pt ref at index " + i + " of line was not in bounds: " + ptindex; }}
		
		lines.push(line);
		return lines.length - 1; }
				
	
}

//  use constructor as global namespace object.
WireframeModel = __WireframeModel;


})();

/*

var point_projections = [];


var line_midpoint_projections = [];


var highlight_object = null;
var mouse_dragging = false;
var last_mouse_down = null;
var mouse_loc = null;
................................................................................
				ctx.rect(minx, miny, maxx - minx, maxy - miny);
				ctx.stroke(); }}
	}
    
    ctx.fillStyle = "rgb(0,0,0)";
	writeMsg(canvas, msg); }
	
*/