Explorar el Código

Add functions to enable/disable all layers

This reduces the need to access Layers.mask directly when code needs to enable/disable all layers on an object.
Olli Etuaho hace 6 años
padre
commit
9078d8f56b
Se han modificado 3 ficheros con 25 adiciones y 0 borrados
  1. 10 0
      docs/api/en/core/Layers.html
  2. 3 0
      src/core/Layers.d.ts
  3. 12 0
      src/core/Layers.js

+ 10 - 0
docs/api/en/core/Layers.html

@@ -80,6 +80,16 @@
 			Toggle membership of *layer*.
 		</p>
 
+		<h3>[method:null enableAll]()</h3>
+		<p>
+			Add membership to all layers.
+		</p>
+
+		<h3>[method:null disableAll]()</h3>
+		<p>
+			Remove membership from all layers.
+		</p>
+
 		<h2>Source</h2>
 
 		[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]

+ 3 - 0
src/core/Layers.d.ts

@@ -10,4 +10,7 @@ export class Layers {
 	disable( channel: number ): void;
 	test( layers: Layers ): boolean;
 
+	enableAll (): void;
+	disableAll (): void;
+
 }

+ 12 - 0
src/core/Layers.js

@@ -38,6 +38,18 @@ Object.assign( Layers.prototype, {
 
 		return ( this.mask & layers.mask ) !== 0;
 
+	},
+
+	enableAll: function () {
+
+		this.mask = 0xffffffff | 0;
+
+	},
+
+	disableAll: function () {
+
+		this.mask = 0;
+
 	}
 
 } );