Skip to content

Commit ea0c16f

Browse files
committed
afterPaperSubmit
1 parent 8fffa23 commit ea0c16f

17 files changed

Lines changed: 218 additions & 72 deletions

addLight.js

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,28 @@ $(function() {
8282
var canvas = document.getElementById( "gl-canvas" );
8383
canvas.addEventListener("mousedown", function(evt){
8484
mouseFlag = 1;
85+
evt.preventDefault();
8586
}, false);
86-
canvas.addEventListener("mousemove", function(evt){
87+
canvas.addEventListener("touchstart", function(evt){
88+
mouseFlag = 1;
89+
}, false);
90+
91+
document.addEventListener("mousemove", function(evt){
8792
if(mouseFlag === 1){
8893
setMousePos(canvas, evt, 0);//add default light event;
8994
}
9095
}, false);
91-
canvas.addEventListener("mouseup", function(){
96+
document.addEventListener("touchmove", function(evt){
97+
if(mouseFlag === 1){
98+
setMousePos(canvas, evt, 0);//add default light event;
99+
}
100+
}, false);
101+
102+
document.addEventListener("mouseup", function(){
103+
mouseFlag = 0;
104+
//mouseFlag = (mouseFlag ==0)?1:0;
105+
}, false);
106+
document.addEventListener("touchend", function(){
92107
mouseFlag = 0;
93108
//mouseFlag = (mouseFlag ==0)?1:0;
94109
}, false);
@@ -195,7 +210,12 @@ function addLightParameters(index){
195210

196211
//mouse
197212
var canvas = document.getElementById( "gl-canvas" );
198-
canvas.addEventListener("mousemove", function(evt){
213+
document.addEventListener("mousemove", function(evt){
214+
if(mouseFlag === 1){
215+
setMousePos(canvas, evt, index);
216+
}
217+
}, false);
218+
document.addEventListener("touchmove", function(evt){
199219
if(mouseFlag === 1){
200220
setMousePos(canvas, evt, index);
201221
}
@@ -215,13 +235,12 @@ function setLightMarkFill(index)
215235

216236
function setLightMarkPosition(index)
217237
{
238+
218239
var lightPx = (mouseXY[index][0] + 0.5)*100 + "%";
219240
var lightPy = (mouseXY[index][1] + 0.5)*100 + "%";
220241

221242
var lightMarkName = '#lightMark'+index;
222243
$(lightMarkName).attr('cx', lightPx).attr('cy', lightPy);
223-
224-
console.log("inMark");
225244
}
226245

227246
function drawLightMarkPosition(index){
@@ -243,9 +262,10 @@ function makeSVG(tag, attrs) {
243262
//mouse functions
244263

245264
function setMousePos(canvas, evt, i){
246-
265+
var rect = canvas.getBoundingClientRect();
266+
247267
if (currentLight == i)
248-
{
268+
{
249269
mouseXY[i][0] = getMousePos(canvas, evt).x;
250270
mouseXY[i][1] = getMousePos(canvas, evt).y;
251271
setLightMarkPosition(i);
@@ -256,9 +276,26 @@ function setMousePos(canvas, evt, i){
256276

257277
function getMousePos(canvas, evt) {
258278
var rect = canvas.getBoundingClientRect();
279+
280+
var newX, newY;
281+
if(evt.type == 'touchstart' || evt.type == 'touchmove' || evt.type == 'touchend' || evt.type == 'touchcancel'){
282+
var touch = evt.touches[0] || evt.changedTouches[0];
283+
newX = touch.pageX;
284+
newY = touch.pageY;
285+
} else if (evt.type == 'mousedown' || evt.type == 'mouseup' || evt.type == 'mousemove' || evt.type == 'mouseover'|| evt.type=='mouseout' || evt.type=='mouseenter' || evt.type=='mouseleave') {
286+
newX = evt.pageX;
287+
newY = evt.pageY;
288+
}
289+
290+
if (newY < rect.top) newY = rect.top;
291+
if (newY > rect.bottom) newY = rect.bottom;
292+
if (newX < rect.left) newX = rect.left;
293+
if (newX > rect.right) newX = rect.right;
294+
295+
259296
return {
260-
x: (evt.clientX - rect.left)/(rect.right - rect.left) - 0.5,
261-
y: (evt.clientY - rect.top)/(rect.bottom - rect.top) - 0.5
297+
x: (newX - rect.left)/(rect.right - rect.left) - 0.5,
298+
y: (newY - rect.top)/(rect.bottom - rect.top) - 0.5
262299
};
263300
}
264301

css/mock3d.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ label{margin-bottom:0;}
355355
position: relative;
356356
top: 50%;
357357
transform: translateY(-50%);
358+
cursor: none;
358359
}
359360

360361
#lightPosition_container{

cube.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
/****************** For SliderBar Parameter ******************/
1+
/****************** For SlideBar Parameter ******************/
22
var mouseFlag = 0;// 0 : moving ; 1: stop
33
var currentLight = 0;
44
var lightNum = 1;
55

6+
7+
//light section parameters
68
var mouseXY = [];
79
mouseXY[0] = [0.3, -0.3]; //default light
810

@@ -20,7 +22,7 @@ var pointLightDis = [];
2022
pointLightDis[0] = 0.5;
2123

2224
var pointLightDecay = [];
23-
pointLightDecay[0] = 0.1;
25+
pointLightDecay[0] = 0.0;
2426

2527
var showDiffuse = [];
2628
showDiffuse[0] = 1;
@@ -29,18 +31,21 @@ var showSpec = [];
2931
showSpec[0] = 1;
3032

3133

32-
34+
//style section parameters
3335

3436
var styleBright = 0,
3537
styleDark = 1;
3638

39+
//Diffuse Alpha parameters
3740
var alphaR = 1;
3841
var alphaG = 1;
3942
var alphaB = 1;
4043

44+
//refraction parameters
4145
var logIOR = 0.25;//[-1, 1]
4246
var BGdis = 0.6;
4347

48+
//reflection parameters
4449
var FGdis = 0.2;
4550

4651
var reflMap = 1;//1: plane; 2:hemisphere
@@ -50,11 +55,21 @@ var FGshiftY = 0;
5055
var FGscaleX = 0.5;
5156
var FGscaleY = 0.5;
5257

58+
59+
//Fresnel parameters
5360
var fresnelIntensity = 0;
5461
var fresnelB = 0.3; //cos = 0.95
5562
var fresnelC = 0.6; //cos = 0.7
5663
var checkFresnel = 0;
5764

65+
66+
67+
68+
69+
70+
71+
72+
5873
//Locs
5974

6075
var currentLightLoc;

dragndrop.js

Lines changed: 81 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -26,43 +26,64 @@ UPLOADinit = function()
2626
// image1.src = "images/Holmer/Holmer_dark.png"; //dark
2727
// image2.src = "images/Holmer/Holmer_bright.png"; //bright
2828
// image4.src = "images/reflect_window2.png";//reflection
29-
// //image5.src = "images/dark.png"; //refraction
30-
// image5.src = "images/checker.jpg";//refraction
29+
// image5.src = "images/dark.png"; //refraction
30+
// //image5.src = "images/checker.jpg";//refraction
3131
// image6.src = "images/Holmer/Holmer_new_alphaControl.png";
3232

3333

3434

3535
//Sphere for fresnel
36-
alphaR = 0;
37-
reflMap = 1;
38-
fresnelB = 0.36;
39-
fresnelC = 0.73;
40-
image1.src = "images/dark.png"//dark
41-
image2.src = "images/white.png"//bright
42-
image3.src = "images/sphere.png"; //shape
43-
image4.src = "images/trees.jpg"; //reflection
44-
image6.src = "images/white.png"; //alpha
45-
image5.src = "images/checker2.png"; //refraction
36+
// alphaR = 0;
37+
// reflMap = 1;
38+
// fresnelB = 0.36;
39+
// fresnelC = 0.73;
40+
// image1.src = "images/dark.png"//dark
41+
// image2.src = "images/white.png"//bright
42+
// image3.src = "images/sphere.png"; //shape
43+
// image4.src = "images/trees.jpg"; //reflection
44+
// image6.src = "images/white.png"; //alpha
45+
// image5.src = "images/tree_blurry.jpg"; //refraction
46+
47+
48+
//Bubble for fresnel
49+
// mouseXY[0] = [0.27, -0.323];
50+
// FGshiftX = 0.0;
51+
// FGshiftY = -0.03;
52+
// FGscaleX = 0.72;
53+
// FGscaleY = 0.83;
54+
// logIOR = 0.08;
55+
// FGdis = 0.27;
56+
// alphaR = 0;
57+
// reflMap = 1;
58+
// fresnelB = 0.39;
59+
// fresnelC = 0.63;
60+
// image1.src = "images/dark.png"//dark
61+
// image2.src = "images/white.png"//bright
62+
// image3.src = "images/bubble.png"; //shape
63+
// image4.src = "images/trees.jpg"; //reflection
64+
// image6.src = "images/white.png"; //alpha
65+
// image5.src = "images/tree_blurry.jpg"; //refraction
66+
4667

4768
//newBottle for Fresnel
48-
alphaR = 0;
49-
reflMap = 1;
50-
logIOR = 0.1;
51-
mouseXY[0] = [0.32, -0.06];
52-
fresnelB = 0.36;
53-
fresnelC = 0.73;
54-
FGshiftX = 0.1;
55-
FGshiftY = -0.05;
56-
FGscaleX = 0.92;
57-
FGscaleY = 0.67;
58-
FGdis = 0.27;
59-
image1.src = "images/dark.png"//dark
60-
image2.src = "images/white.png"//bright
61-
//image3.src = "images/sphere.png"; //shape
62-
image4.src = "images/indoor.jpg"; //reflection
63-
image6.src = "images/white.png"; //alpha
64-
image5.src = "images/checker2.png"; //refraction
65-
image3.src = "images/newBottleForFresnel.png"; //shape map
69+
// alphaR = 0;
70+
// reflMap = 1;
71+
// logIOR = 0.1;
72+
// mouseXY[0] = [0.32, -0.06];
73+
// fresnelB = 0.36;
74+
// fresnelC = 0.73;
75+
// FGshiftX = 0.1;
76+
// FGshiftY = -0.05;
77+
// FGscaleX = 0.92;
78+
// FGscaleY = 0.67;
79+
// FGdis = 0.27;
80+
// image1.src = "images/dark.png"//dark
81+
// image2.src = "images/white.png"//bright
82+
// //image3.src = "images/sphere.png"; //shape
83+
// image4.src = "images/indoor.jpg"; //reflection
84+
// image6.src = "images/white.png"; //alpha
85+
// image5.src = "images/checker2.png"; //refraction
86+
// image3.src = "images/newBottleForFresnel.png"; //shape map
6687

6788

6889
//sphere for test
@@ -112,16 +133,22 @@ UPLOADinit = function()
112133
// image3.src = "images/newBottleForFresnel.png"; //shape map
113134
// image4.src = "images/white.png"; //reflection
114135
// image6.src = "images/white.png"; //alpha
115-
// image5.src = "images/checker.jpg";//refraction
136+
// image5.src = "images/checker2.png";//refraction
116137

117138

118139
//Escher/eye
119140
// alphaR = 1;
141+
// mouseXY[0] = [0.27, -0.41];
142+
// FGshiftX = -0.21;
143+
// FGshiftY = -0.17;
144+
// FGscaleX = 0.62;
145+
// FGscaleY = 0.64;
146+
// FGdis = 0.2;
120147
// image1.src = "images/Escher/eye/dark.jpg"; //dark
121148
// image2.src = "images/Escher/eye/bright.jpg"; //bright
122149
// image3.src = "images/Escher/eye/shape.png"; //shape map
123150
// image4.src = "images/Escher/eye/reflect.png"; //reflection
124-
// image5.src = "images/checker.jpg";//refraction
151+
// image5.src = "images/dark.png";//refraction
125152
// image6.src = "images/Escher/eye/alphaControl.jpg";
126153

127154
//Escher/handWithSphere
@@ -133,23 +160,32 @@ UPLOADinit = function()
133160
// FGshiftX = -0.09;
134161
// FGshiftY = 0.08;
135162
// FGscaleX = 0.8;
136-
// FGscaleY = 0.52;
163+
// FGscaleY = 0.6;
137164
// reflMap =1;
138165
// FGdis = 0.11;
139166
// image1.src = "images/Escher/handWithSphere/dark.jpg"; //dark
140167
// image2.src = "images/Escher/handWithSphere/bright.jpg"; //bright
141168
// image3.src = "images/Escher/handWithSphere/shape.png"; //shape map
142169
// image4.src = "images/Escher/handWithSphere/reflect2.jpg"; //reflection
143-
// image5.src = "images/checker.jpg";//refraction
170+
// image5.src = "images/dark.png";//refraction
144171
// image6.src = "images/Escher/handWithSphere/alphaControl.png";
145172

146173
//newBottle
147174
// alphaR = 0;
175+
// FGshiftX = -0.11;
176+
// FGshiftY = -0.0;
177+
// FGscaleX = 0.6;
178+
// FGscaleY = 0.67;
179+
// FGdis = 0.22;
180+
// mouseXY[0] = [0.34, -0.0746];
181+
// fresnelB = 0.3;
182+
// fresnelC = 0.53;
183+
// logIOR = 0.27;
148184
// image1.src = "images/newBottle/diffuse.png"; //dark
149-
// image2.src = "images/newBottle/diffuse.png"; //bright
185+
// image2.src = "images/newBottle/diffuse_bright.png"; //bright
150186
// image3.src = "images/newBottle/shape.png"; //shape map
151-
// image4.src = "images/newBottle/reflect.png"; //reflection
152-
// image5.src = "images/newBottle/BG.png";//refraction
187+
// image4.src = "images/newBottle/reflect.jpg"; //reflection
188+
// image5.src = "images/newBottle/bg.png";//refraction
153189
// image6.src = "images/newBottle/alpha.png";
154190

155191

@@ -159,7 +195,7 @@ UPLOADinit = function()
159195
// image1.src = "images/underWater/dark.jpg"; //dark
160196
// image2.src = "images/underWater/bright.jpg"; //bright
161197
// image3.src = "images/underWater/shape.jpg"; //shape map
162-
// image4.src = "images/white.png"; //reflection
198+
// image4.src = "images/dark.png"; //reflection
163199
// image5.src = "images/underWater/BG.jpg";//refraction
164200
// image6.src = "images/underWater/alphaControl.jpg";
165201

@@ -200,13 +236,13 @@ UPLOADinit = function()
200236
// image6.src = "images/white.png"; //alpha
201237

202238
//impossible_gradient
203-
// alphaR = 1;
204-
// image1.src = "images/dark.png"; //dark
205-
// image2.src = "images/white.png"; //bright
206-
// image3.src = "images/impossible_gradient/shape.png"; //shape map
207-
// image4.src = "images/dark.png"; //reflection
208-
// image5.src = "images/dark.png"; //refraction
209-
// image6.src = "images/white.png"; //alpha
239+
alphaR = 1;
240+
image1.src = "images/dark.png"; //dark
241+
image2.src = "images/white.png"; //bright
242+
image3.src = "images/impossible_gradient/shape.png"; //shape map
243+
image4.src = "images/dark.png"; //reflection
244+
image5.src = "images/dark.png"; //refraction
245+
image6.src = "images/white.png"; //alpha
210246

211247

212248

images/bubble.png

97.8 KB
Loading

images/newBottle/bg.jpg

59.9 KB
Loading
503 KB
Loading

images/newBottle/reflect.jpg

81.5 KB
Loading

images/newBottle/reflect.png

150 KB
Loading

images/newBottle/reflect0.png

418 KB
Loading

0 commit comments

Comments
 (0)