Skip to content

Commit

Permalink
Remove for WHS.Object
Browse files Browse the repository at this point in the history
  • Loading branch information
sasha240100 committed Jul 19, 2016
1 parent c0396b8 commit 33a1e4f
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 16 deletions.
10 changes: 5 additions & 5 deletions build/whitestorm.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/whitestorm.js.map

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions build/whitestorm.light.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/whitestorm.light.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/design/saturn/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var GAME = new WHS.World({
}
});

var space = new WHS.Group();
window.space = new WHS.Group();
space.addTo(GAME);
space.rotation.z = Math.PI / 12;

Expand Down
23 changes: 23 additions & 0 deletions lib/core/Object.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,29 @@ var WHSObject = function () {
});
}
}

/**
* Remove this shape from world.
*
* @return {WHS.Shape} - this.
*/

}, {
key: 'remove',
value: function remove(source) {
this.getNative().remove(source.getNative());

this.children.splice(this.children.indexOf(source), 1);
source.parent = null;

source.emit('remove');

if (WHS.debug) {
console.debug('@WHS.Shape: Shape ' + source._type + ' was removed from world', [source]);
}

return this;
}
}]);
return WHSObject;
}();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "whitestormjs",
"version": "0.10.1",
"version": "0.10.2",
"description": "Framework for developing 3D web apps with physics.",
"main": "lib/index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src-examples/design/saturn/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const GAME = new WHS.World({
}
});

const space = new WHS.Group();
window.space = new WHS.Group();
space.addTo(GAME);
space.rotation.z = Math.PI / 12;

Expand Down
23 changes: 23 additions & 0 deletions src/core/Object.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,29 @@ class WHSObject {
});
}
}

/**
* Remove this shape from world.
*
* @return {WHS.Shape} - this.
*/
remove(source) {
this.getNative().remove(source.getNative());

this.children.splice(this.children.indexOf(source), 1);
source.parent = null;

source.emit('remove');

if (WHS.debug) {
console.debug(
`@WHS.Shape: Shape ${source._type} was removed from world`,
[source]
);
}

return this;
}
}

export {
Expand Down

0 comments on commit 33a1e4f

Please sign in to comment.