* BoxHelper set color in constructor (#8896) * Added unit test for BoxHelper.
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
- <meta charset="utf-8" />
+ <meta charset="utf-8" />
<base href="../../../" />
<script src="list.js"></script>
<script src="page.js"></script>
@@ -26,7 +26,11 @@
<h2>Constructor</h2>
- <h3>[name]( [page:Object3D object] )</h3>
+ <h3>[name]( [page:Object3D object], [page:Number hex] )</h3>
+ <div>
+ object -- Object3D -- the object3D to show the world-axis-aligned boundingbox.<br />
+ hex -- hexadecimal value to define color ex:0xffff00
+ </div>
<div>Creates a new wireframe box matching the size of the passed box.</div>
<h2>Properties</h2>
@@ -2,16 +2,17 @@
* @author mrdoob / http://mrdoob.com/
*/
-THREE.BoxHelper = function ( object ) {
+THREE.BoxHelper = function ( object, hex ) {
var indices = new Uint16Array( [ 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7 ] );
var positions = new Float32Array( 8 * 3 );
+ var color = ( hex !== undefined ) ? hex : 0xffff00;
var geometry = new THREE.BufferGeometry();
geometry.setIndex( new THREE.BufferAttribute( indices, 1 ) );
geometry.addAttribute( 'position', new THREE.BufferAttribute( positions, 3 ) );
- THREE.LineSegments.call( this, geometry, new THREE.LineBasicMaterial( { color: 0xffff00 } ) );
+ THREE.LineSegments.call( this, geometry, new THREE.LineBasicMaterial( { color: color } ) );
if ( object !== undefined ) {
@@ -0,0 +1,36 @@
+(function () {
+
+ 'use strict';
+ var parameters = {
+ diameter: 10,
+ };
+ var geometries;
+ QUnit.module( "Extras - Helpers - BoxHelper", {
+ beforeEach: function() {
+ var greenMaterial = new THREE.MeshBasicMaterial( {color: 0x00ff00} );
+ // Test with a normal cube and a box helper
+ var boxGeometry = new THREE.BoxGeometry( parameters.diameter );
+ var box = new THREE.Mesh( boxGeometry, greenMaterial );
+ var boxHelper = new THREE.BoxHelper( box );
+ // The same should happen with a comparable sphere
+ var sphereGeometry = new THREE.SphereGeometry( parameters.diameter / 2 );
+ var sphere = new THREE.Mesh( sphereGeometry, greenMaterial );
+ var sphereBoxHelper = new THREE.BoxHelper( sphere );
+ // Note that unlike what I'd like to, these doesn't check the equivalency of the two generated geometries
+ geometries = [ boxHelper.geometry, sphereBoxHelper.geometry ];
+ }
+ });
+ QUnit.test( "standard geometry tests", function( assert ) {
+ runStdGeometryTests( assert, geometries );
+})();
@@ -91,6 +91,8 @@
<script src="extras/geometries/TubeGeometry.tests.js"></script>
<script src="extras/geometries/WireframeGeometry.tests.js"></script>
+ <script src="extras/helpers/BoxHelper.tests.js"></script>
<!-- for debug output -->
<!--