PageSourceSearch

https://www.emilyallchurch.com/wp-content/plugins/photo-gallery/js/3DEngine/3DEngine.js?ver=1.0.0

js emilyallchurch.com collected 2026-10-03 21:20:17 UTC 4,841 bytes, 198 lines download raw bytes

1
2/*
3* DisplayObject3D ----------------------------------------------
4*/
5var DisplayObject3D = function(){
6	return this;
7};
8
9DisplayObject3D.prototype._x = 0;
10DisplayObject3D.prototype._y = 0;
11
12//Create 3d Points
13DisplayObject3D.prototype.make3DPoint = function(x,y,z) {
14	var point = {};
15	point.x = x;
16	point.y = y;
17	point.z = z;
18	return point;
19};
20
21//Create 2d Points
22DisplayObject3D.prototype.make2DPoint = function(x, y, depth, scaleFactor){
23	var point = {};
24	point.x = x;
25	point.y = y;
26	point.depth = depth;
27	point.scaleFactor = scaleFactor;
28	return point;
29};
30
31DisplayObject3D.prototype.container = undefined;
32DisplayObject3D.prototype.pointsArray = [];
33
34DisplayObject3D.prototype.init = function (container){
35	
36	this.container = container;
37	this.containerId = this.container.attr("id");
38	
39	//if there isn't a ul than it creates a list of +'s
40	if (container.has("ul").length === 0){
41		for (i=0; i < this.pointsArray.length; i++){
42			this.container.append('<b id="tags_cloud_item'+i+'">+</b>');
43		}
44	}
45};	
46
47/*
48* DisplayObject3D End ----------------------------------------------
49*/
50
51
52/*
53* Camera3D ----------------------------------------------
54*/
55var Camera3D = function (){};
56
57Camera3D.prototype.x = 0;
58Camera3D.prototype.y = 0;
59Camera3D.prototype.z = 500;
60Camera3D.prototype.focalLength = 1000;
61
62Camera3D.prototype.scaleRatio = function(item){
63	return this.focalLength / (this.focalLength + item.z - this.z);
64};
65
66Camera3D.prototype.init = function (x, y, z, focalLength){
67	this.x = x;
68	this.y = y;
69	this.z = z;
70	this.focalLength = focalLength;
71};
72
73
74/*
75* Camera3D End ----------------------------------------------
76*/
77
78
79/*
80* Object3D ----------------------------------------------
81*/
82var Object3D = function (container){
83	this.container = container;
84};
85
86Object3D.prototype.objects = [];
87
88Object3D.prototype.addChild = function (object3D){		
89	this.objects.push(object3D);	
90	object3D.init(this.container);	
91	return object3D;
92};
93
94/*
95* Object3D End ----------------------------------------------
96*/
97
98
99/*
100* Scene3D ----------------------------------------------
101*/
102
103var Scene3D = function (){};
104
105Scene3D.prototype.sceneItems = [];
106Scene3D.prototype.addToScene = function (object){
107	this.sceneItems.push(object);
108};
109
110Scene3D.prototype.Transform3DPointsTo2DPoints = function(points, axisRotations, camera){
111	var TransformedPointsArray = [];
112	var sx = Math.sin(axisRotations.x);
113	var cx = Math.cos(axisRotations.x);
114	var sy = Math.sin(axisRotations.y);
115	var cy = Math.cos(axisRotations.y);
116	var sz = Math.sin(axisRotations.z);
117	var cz = Math.cos(axisRotations.z);
118	var x,y,z, xy,xz, yx,yz, zx,zy, scaleFactor;
119
120	var i = points.length;
121	
122	while (i--){
123		x = points[i].x;
124		y = points[i].y;
125		z = points[i].z;
126
127		// rotation around x
128		xy = cx * y - sx * z;
129		xz = sx * y + cx * z;
130		// rotation around y
131		yz = cy * xz - sy * x;
132		yx = sy * xz + cy * x;
133		// rotation around z
134		zx = cz * yx - sz * xy;
135		zy = sz * yx + cz * xy;
136		
137		scaleFactor = camera.focalLength / (camera.focalLength + yz);
138		x = zx * scaleFactor;
139		y = zy * scaleFactor;
140		z = yz;
141		
142		var displayObject = new DisplayObject3D();
143		TransformedPointsArray[i] = displayObject.make2DPoint(x, y, -z, scaleFactor);
144	}
145	
146	return TransformedPointsArray;
147};
148
149Scene3D.prototype.renderCamera = function (camera){
150
151	for(var i = 0 ; i < this.sceneItems.length; i++){
152
153		var obj = this.sceneItems[i].objects[0];
154	
155		var screenPoints = this.Transform3DPointsTo2DPoints(obj.pointsArray, axisRotation, camera);
156		
157		var hasList = (document.getElementById(obj.containerId).getElementsByTagName("ul").length > 0);
158		
159		for (k=0; k < obj.pointsArray.length; k++){
160			var currItem = null;
161			
162			if (hasList){
163				currItem = document.getElementById(obj.containerId).getElementsByTagName("ul")[0].getElementsByTagName("li")[k];
164			}else{				
165				currItem = document.getElementById(obj.containerId).getElementsByTagName("*")[k];
166			}
167			
168			if(currItem){
169        
170				currItem._x = screenPoints[k].x;
171				currItem._y = screenPoints[k].y;
172				currItem.scale = screenPoints[k].scaleFactor;
173				
174				currItem.style.position = "absolute";
175				currItem.style.top = (currItem._y + jQuery("#" + obj.containerId).height() * 0.4)+'px';
176				currItem.style.left = (currItem._x + jQuery("#" + obj.containerId).width() * 0.4)+'px';
177				currItem.style.fontSize = 100 * currItem.scale + '%';
178        
179				jQuery(currItem).css({opacity:(currItem.scale-.5)});
180        
181        curChild = jQuery(currItem).find("#imgg");
182        if (curChild) {
183          jQuery(currItem).css("zIndex", Math.round(currItem.scale * 100));
184          curChild.css({maxWidth:(currItem.scale*50)});
185          curChild.css({maxHeight:(currItem.scale*50)});
186        }
187			}			
188		}
189	}
190};
191
192/*
193* Scene3D End ----------------------------------------------
194*/
195
196
197//Center for rotation
198var axisRotation = new DisplayObject3D().make3DPoint(0,0,0);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.