未验证 提交 87f983d6 编写于 作者: M Mr.doob 提交者: GitHub

Merge pull request #17305 from higharc/layers-enable-disable-all

Add functions to enable/disable all layers
...@@ -80,6 +80,16 @@ ...@@ -80,6 +80,16 @@
Toggle membership of *layer*. Toggle membership of *layer*.
</p> </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> <h2>Source</h2>
<p> <p>
......
...@@ -93,26 +93,48 @@ ...@@ -93,26 +93,48 @@
stats = new Stats(); stats = new Stats();
container.appendChild( stats.dom ); container.appendChild( stats.dom );
var layers = { red: true, green: true, blue: true }; var layers = {
// 'toggle red': function() {
// Init gui
var gui = new GUI(); camera.layers.toggle( 0 );
gui.add( layers, 'red' ).onChange( function () {
},
'toggle green': function() {
camera.layers.toggle( 1 );
},
camera.layers.toggle( 0 ); 'toggle blue': function() {
} ); camera.layers.toggle( 2 );
gui.add( layers, 'green' ).onChange( function () {
camera.layers.toggle( 1 ); },
} ); 'enable all': function() {
gui.add( layers, 'blue' ).onChange( function () {
camera.layers.toggle( 2 ); camera.layers.enableAll();
} ); },
'disable all': function() {
camera.layers.disableAll();
}
};
//
// Init gui
var gui = new GUI();
gui.add( layers, 'toggle red' );
gui.add( layers, 'toggle green' );
gui.add( layers, 'toggle blue' );
gui.add( layers, 'enable all' );
gui.add( layers, 'disable all' );
window.addEventListener( 'resize', onWindowResize, false ); window.addEventListener( 'resize', onWindowResize, false );
......
...@@ -10,4 +10,7 @@ export class Layers { ...@@ -10,4 +10,7 @@ export class Layers {
disable( channel: number ): void; disable( channel: number ): void;
test( layers: Layers ): boolean; test( layers: Layers ): boolean;
enableAll (): void;
disableAll (): void;
} }
...@@ -38,6 +38,18 @@ Object.assign( Layers.prototype, { ...@@ -38,6 +38,18 @@ Object.assign( Layers.prototype, {
return ( this.mask & layers.mask ) !== 0; return ( this.mask & layers.mask ) !== 0;
},
enableAll: function () {
this.mask = 0xffffffff | 0;
},
disableAll: function () {
this.mask = 0;
} }
} ); } );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册