未验证 提交 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 @@
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>
<p>
......
......@@ -93,26 +93,48 @@
stats = new Stats();
container.appendChild( stats.dom );
var layers = { red: true, green: true, blue: true };
var layers = {
//
// Init gui
var gui = new GUI();
gui.add( layers, 'red' ).onChange( function () {
'toggle red': function() {
camera.layers.toggle( 0 );
},
'toggle green': function() {
camera.layers.toggle( 1 );
},
camera.layers.toggle( 0 );
'toggle blue': function() {
} );
gui.add( layers, 'green' ).onChange( function () {
camera.layers.toggle( 2 );
camera.layers.toggle( 1 );
},
} );
gui.add( layers, 'blue' ).onChange( function () {
'enable all': 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 );
......
......@@ -10,4 +10,7 @@ export class Layers {
disable( channel: number ): void;
test( layers: Layers ): boolean;
enableAll (): void;
disableAll (): void;
}
......@@ -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;
}
} );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册