Skip to content

Commit 014f446

Browse files
committed
edit docs; fix setAmbient; edit getPromiseResults
1 parent 7d6ff55 commit 014f446

File tree

2 files changed

+35
-15
lines changed

2 files changed

+35
-15
lines changed

camera.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ Camera.prototype._angleVertical=function(angleDegrees){
7777
/**
7878
* Moves the camera up or down, adjusting its angle, while
7979
* maintaining its distance to the target position.
80-
* The camera won't turn to 90 degrees above or beyond,
81-
* or to 90 degrees below or beyond.
8280
* @param {number} angleDegrees Angle, in degrees,
8381
* to move the camera. Positive angles mean down,
8482
* negative angles mean up.

glutil.js

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -156,30 +156,48 @@ var GLUtil={
156156
* @return {Promise} A promise that is never rejected and resolves when
157157
* all of the promises are each resolved or rejected. The result
158158
* of the promise will be an object with
159-
* two keys:
159+
* three keys:
160160
* "successes" - contains a list of results from the
161-
* promises that succeeded.
161+
* promises that succeeded, in the order in which those promises were listed.
162162
* "failures" - contains a list of results from the
163-
* promises that failed.
163+
* promises that failed, in the order in which those promises were listed.
164+
* "results" - contains a list of boolean values for each
165+
* promise, in the order in which the promises were listed.
166+
* True means success, and false means failure.
164167
*/
165168
"getPromiseResults":function(promises,
166169
progressResolve, progressReject){
167170
if(!promises || promises.length==0){
168171
return Promise.resolve({
169-
successes:[], failures:[]});
172+
successes:[], failures:[], results:[]});
170173
}
171-
var ret={successes:[], failures:[]};
174+
var ret={successes:[], failures:[], results:[]};
172175
var newPromises=[]
173176
for(var i=0;i<promises.length;i++){
177+
var index=i;
174178
newPromises.push(promises[i].then(function(x){
175-
ret.successes.push(x)
179+
ret.successes[index]=x
176180
return true;
177181
},function(x){
178-
ret.failures.push(x)
179-
return true;
182+
ret.failures[index]=x
183+
return false;
180184
}));
181185
}
182-
return Promise.all(newPromises).then(function(x){
186+
return Promise.all(newPromises).then(function(results){
187+
// compact the successes and failures arrays
188+
for(var i=0;i<ret.successes.length;i++){
189+
if(typeof ret.successes[i]=="undefined"){
190+
ret.successes.splice(i,1);
191+
i-=1;
192+
}
193+
}
194+
for(var i=0;i<ret.failures.length;i++){
195+
if(typeof ret.failures[i]=="undefined"){
196+
ret.failures.splice(i,1);
197+
i-=1;
198+
}
199+
}
200+
ret.results=results;
183201
return Promise.resolve(ret)
184202
});
185203
},
@@ -548,7 +566,9 @@ Lights._createNewLight=function(index){
548566
}
549567
/**
550568
* Not documented yet.
551-
* @param {*} index
569+
* @param {number} index Zero-based index of the light to set. The first
570+
* light has index 0, the second has index 1, and so on.
571+
* If the light doesn't exist at that index, it will be created.
552572
* @return {LightSource} The corresponding light source object.
553573
*/
554574
Lights.prototype.getLight=function(index){
@@ -557,7 +577,9 @@ Lights.prototype.getLight=function(index){
557577
}
558578
/**
559579
* Not documented yet.
560-
* @param {*} index
580+
* @param {number} index Zero-based index of the light to set. The first
581+
* light has index 0, the second has index 1, and so on.
582+
* If the light doesn't exist at that index, it will be created.
561583
* @param {object} params An object as described in {@link glutil.LightSource.setParams}.
562584
* @return {Lights} This object.
563585
*/
@@ -1714,8 +1736,8 @@ Scene3D.prototype.setLightParams=function(index,params){
17141736
* @return {glutil.Scene3D} This object.
17151737
*/
17161738
Scene3D.prototype.setAmbient=function(r,g,b,a){
1717-
this.lightSource.ambient=GLUtil["toGLColor"](r,g,b,a);
1718-
this.lightSource.ambient=this.lightSource.ambient.slice(0,4)
1739+
this.lightSource.sceneAmbient=GLUtil["toGLColor"](r,g,b,a);
1740+
this.lightSource.sceneAmbient=this.lightSource.sceneAmbient.slice(0,4)
17191741
new LightsBinder(this.lightSource).bind(this.program);
17201742
return this;
17211743
}

0 commit comments

Comments
 (0)