Bläddra i källkod

Merge pull request #12410 from WestLangley/dev-defaults

Box and Plane geometry: specify default values
Mr.doob 7 år sedan
förälder
incheckning
5e6e5bd2ba

+ 4 - 4
docs/api/geometries/BoxBufferGeometry.html

@@ -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>
@@ -44,9 +44,9 @@
 
 		<h3>[name]([page:Float width], [page:Float height], [page:Float depth], [page:Integer widthSegments], [page:Integer heightSegments], [page:Integer depthSegments])</h3>
 		<div>
-		width — Width of the sides on the X axis.<br />
-		height — Height of the sides on the Y axis.<br />
-		depth — Depth of the sides on the Z axis.<br />
+		width — Width of the sides on the X axis. Default is 1.<br />
+		height — Height of the sides on the Y axis. Default is 1.<br />
+		depth — Depth of the sides on the Z axis. Default is 1.<br />
 		widthSegments — Optional. Number of segmented faces along the width of the sides. Default is 1.<br />
 		heightSegments — Optional. Number of segmented faces along the height of the sides. Default is 1.<br />
 		depthSegments — Optional. Number of segmented faces along the depth of the sides. Default is 1.

+ 4 - 4
docs/api/geometries/BoxGeometry.html

@@ -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>
@@ -44,9 +44,9 @@
 
 		<h3>[name]([page:Float width], [page:Float height], [page:Float depth], [page:Integer widthSegments], [page:Integer heightSegments], [page:Integer depthSegments])</h3>
 		<div>
-		width — Width of the sides on the X axis.<br />
-		height — Height of the sides on the Y axis.<br />
-		depth — Depth of the sides on the Z axis.<br />
+		width — Width of the sides on the X axis. Default is 1.<br />
+		height — Height of the sides on the Y axis. Default is 1.<br />
+		depth — Depth of the sides on the Z axis. Default is 1.<br />
 		widthSegments — Optional. Number of segmented faces along the width of the sides. Default is 1.<br />
 		heightSegments — Optional. Number of segmented faces along the height of the sides. Default is 1.<br />
 		depthSegments — Optional. Number of segmented faces along the depth of the sides. Default is 1.

+ 3 - 3
docs/api/geometries/PlaneBufferGeometry.html

@@ -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>
@@ -44,8 +44,8 @@
 
 		<h3>[name]([page:Float width], [page:Float height], [page:Integer widthSegments], [page:Integer heightSegments])</h3>
 		<div>
-		width — Width along the X axis.<br />
-		height — Height along the Y axis.<br />
+		width — Width along the X axis. Default is 1.<br />
+		height — Height along the Y axis. Default is 1.<br />
 		widthSegments — Optional. Default is 1. <br />
 		heightSegments — Optional. Default is 1.
 		</div>

+ 18 - 18
docs/api/geometries/PlaneGeometry.html

@@ -15,22 +15,22 @@
 		<div class="desc">A class for generating plane geometries</div>
 
 		<iframe id="scene" src="scenes/geometry-browser.html#PlaneGeometry"></iframe>
-
-		<script>
-
-		// iOS iframe auto-resize workaround
-
-		if ( /(iPad|iPhone|iPod)/g.test( navigator.userAgent ) ) {
-
-			var scene = document.getElementById( 'scene' );
-
-			scene.style.width = getComputedStyle( scene ).width;
-			scene.style.height = getComputedStyle( scene ).height;
-			scene.setAttribute( 'scrolling', 'no' );
-
-		}
-
-		</script>
+
+		<script>
+
+		// iOS iframe auto-resize workaround
+
+		if ( /(iPad|iPhone|iPod)/g.test( navigator.userAgent ) ) {
+
+			var scene = document.getElementById( 'scene' );
+
+			scene.style.width = getComputedStyle( scene ).width;
+			scene.style.height = getComputedStyle( scene ).height;
+			scene.setAttribute( 'scrolling', 'no' );
+
+		}
+
+		</script>
 
 		<h2>Example</h2>
 
@@ -44,8 +44,8 @@
 
 		<h3>[name]([page:Float width], [page:Float height], [page:Integer widthSegments], [page:Integer heightSegments])</h3>
 		<div>
-		width — Width along the X axis.<br />
-		height — Height along the Y axis.<br />
+		width — Width along the X axis. Default is 1.<br />
+		height — Height along the Y axis. Default is 1.<br />
 		widthSegments — Optional. Default is 1. <br />
 		heightSegments — Optional. Default is 1.
 		</div>

+ 4 - 0
src/geometries/BoxGeometry.js

@@ -52,6 +52,10 @@ function BoxBufferGeometry( width, height, depth, widthSegments, heightSegments,
 
 	var scope = this;
 
+	width = width || 1;
+	height = height || 1;
+	depth = depth || 1;
+
 	// segments
 
 	widthSegments = Math.floor( widthSegments ) || 1;

+ 3 - 0
src/geometries/PlaneGeometry.js

@@ -45,6 +45,9 @@ function PlaneBufferGeometry( width, height, widthSegments, heightSegments ) {
 		heightSegments: heightSegments
 	};
 
+	width = width || 1;
+	height = height || 1;
+
 	var width_half = width / 2;
 	var height_half = height / 2;