2
0
Эх сурвалжийг харах

CTRL Click to set objects color White

Random color set when clicked but control-click sets the target object to white.
Master James 9 жил өмнө
parent
commit
d39e343e8c

+ 13 - 5
examples/webgl_lights_spotlight.html

@@ -36,7 +36,8 @@
 		<div id="container"></div>
 		<div id="container"></div>
 		<div id="info">
 		<div id="info">
 			<a href="http://threejs.org" target="_blank">three.js</a> - Just to show the spot light and it's edge - by <a href="http://master-domain.com" target="_blank">Master James</a><br />
 			<a href="http://threejs.org" target="_blank">three.js</a> - Just to show the spot light and it's edge - by <a href="http://master-domain.com" target="_blank">Master James</a><br />
-			Right click and drag to move OrbitControls,<br /> center across the edge of the shadow.<br />
+			Right click and drag to move OrbitControls, center across the edge of the shadow.<br />
+			Click to set random color CTRL-Click for White.<br />
 		</div>
 		</div>
 
 
 		<script src="../build/three.js"></script>
 		<script src="../build/three.js"></script>
@@ -214,22 +215,31 @@
 				if( event.type === 'mousedown' ) {
 				if( event.type === 'mousedown' ) {
 
 
 					mouseDown.x = ( event.clientX / rndDom.clientWidth ) * 2 - 1;
 					mouseDown.x = ( event.clientX / rndDom.clientWidth ) * 2 - 1;
+					
 					mouseDown.y = - ( event.clientY / rndDom.clientHeight ) * 2 + 1;
 					mouseDown.y = - ( event.clientY / rndDom.clientHeight ) * 2 + 1;
 
 
 				}
 				}
 				else {
 				else {
 
 
 					mouse.x = ( event.clientX / rndDom.clientWidth ) * 2 - 1;
 					mouse.x = ( event.clientX / rndDom.clientWidth ) * 2 - 1;
+
 					mouse.y = - ( event.clientY / rndDom.clientHeight ) * 2 + 1;
 					mouse.y = - ( event.clientY / rndDom.clientHeight ) * 2 + 1;
 
 
-					console.log(mouseDown.distanceTo(mouse));
 					if (mouseDown.distanceTo(mouse) < 0.0075) {
 					if (mouseDown.distanceTo(mouse) < 0.0075) {
 
 
 						ray.setFromCamera( mouse, cam );
 						ray.setFromCamera( mouse, cam );
 
 
 						var found = ray.intersectObjects( [ mshBox, mshFloor ] );
 						var found = ray.intersectObjects( [ mshBox, mshFloor ] );
 
 
-						if ( found.length > 0 ) randomColor( found[0].object );
+						if ( found.length > 0 ) {
+
+							if( event.ctrlKey === false ) randomColor( found[0].object );
+
+							else found[0].object.material.color.set( 0xffffff );
+
+							render();
+							
+						}
 
 
 					}
 					}
 
 
@@ -247,8 +257,6 @@
 
 
 						target.color.setHex( 0xffffff * Math.random() );
 						target.color.setHex( 0xffffff * Math.random() );
 
 
-						render();
-
 					}
 					}
 				}
 				}