Skip to content

Commit

Permalink
Object3D: Renamed removeAll to clear.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdoob committed Oct 14, 2020
1 parent 2b082dc commit 315d0fc
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/api/en/core/Object3D.html
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ <h3>[method:this remove]( [param:Object3D object], ... )</h3>
Removes *object* as child of this object. An arbitrary number of objects may be removed.
</p>

<h3>[method:this removeAll]()</h3>
<h3>[method:this clear]()</h3>
<p>
Removes all child objects.
</p>
Expand Down
2 changes: 1 addition & 1 deletion src/core/Object3D.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ export class Object3D extends EventDispatcher {
/**
* Removes all child objects.
*/
removeAll(): this;
clear(): this;

This comment has been minimized.

Copy link
@linbingquan

linbingquan Oct 18, 2020

Contributor

PS D:\github\three.js> npm run test-lint

three@0.121.1 test-lint D:\github\three.js
eslint src --ext js --ext ts && tsc -p utils/build/tsconfig.lint.json

src/cameras/CubeCamera.d.ts:16:2 - error TS2416: Property 'clear' in type 'CubeCamera' is not assignable to the same property in base type 'Object3D'.
Type '(renderer: WebGLRenderer, color: boolean, depth: boolean, stencil: boolean) => void' is not assignable to type '() => this'.

16 clear( renderer: WebGLRenderer, color: boolean, depth: boolean, stencil: boolean ): void;
~~~~~

Found 1 error.

This comment has been minimized.

Copy link
@Mugen87

Mugen87 Oct 18, 2020

Collaborator

This is a known issue, see #20478 (comment)


/**
* Adds object as a child of this, while maintaining the object's world transform.
Expand Down
2 changes: 1 addition & 1 deletion src/core/Object3D.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ),

},

removeAll: function () {
clear: function () {

for ( let i = 0; i < this.children.length; i ++ ) {

Expand Down
4 changes: 2 additions & 2 deletions test/unit/src/core/Object3D.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ export default QUnit.module( 'Core', () => {

} );

QUnit.test( "add/remove/removeAll", ( assert ) => {
QUnit.test( "add/remove/clear", ( assert ) => {

var a = new Object3D();
var child1 = new Object3D();
Expand Down Expand Up @@ -330,7 +330,7 @@ export default QUnit.module( 'Core', () => {

a.add( child1 );
assert.strictEqual( a.children.length, 2, "The first child was added to the parent" );
a.removeAll();
a.clear();
assert.strictEqual( a.children.length, 0, "All childrens were removed" );
assert.strictEqual( child1.parent, null, "First child has no parent" );
assert.strictEqual( child2.parent, null, "Second child has no parent" );
Expand Down

0 comments on commit 315d0fc

Please sign in to comment.