* Destroy function * @ignore
()
| 1033 | * @ignore |
| 1034 | */ |
| 1035 | destroy() { |
| 1036 | // allow recycling object properties |
| 1037 | this.currentTransform = undefined; |
| 1038 | |
| 1039 | this.anchorPoint.revoke(); |
| 1040 | this.anchorPoint = undefined; |
| 1041 | |
| 1042 | this.pos = undefined; |
| 1043 | |
| 1044 | if (this._absPos) { |
| 1045 | vector3dPool.release(this._absPos); |
| 1046 | this._absPos = undefined; |
| 1047 | } |
| 1048 | |
| 1049 | if (this._bounds) { |
| 1050 | boundsPool.release(this._bounds); |
| 1051 | this._bounds = undefined; |
| 1052 | } |
| 1053 | |
| 1054 | this.onVisibilityChange = undefined; |
| 1055 | |
| 1056 | if (this.mask) { |
| 1057 | pool.push(this.mask); |
| 1058 | this.mask = undefined; |
| 1059 | } |
| 1060 | |
| 1061 | if (this._tint) { |
| 1062 | colorPool.release(this._tint); |
| 1063 | this._tint = undefined; |
| 1064 | } |
| 1065 | |
| 1066 | // cannot import and reference a Container from a Renderable, since Container extends Renderable, creating a circular dependency |
| 1067 | //if (this.ancestor instanceof Container || this.ancestor instanceof Entity) { |
| 1068 | this.ancestor = undefined; |
| 1069 | |
| 1070 | // cannot import and reference a Application from a Renderable, messsing up class order in the bundle |
| 1071 | //if (this._parentApp instanceof Application) { |
| 1072 | this._parentApp = undefined; |
| 1073 | //} |
| 1074 | |
| 1075 | // destroy the physic body if a builtin body object |
| 1076 | if (this.body instanceof Body) { |
| 1077 | this.body.destroy.apply(this.body, arguments); |
| 1078 | this.body = undefined; |
| 1079 | } |
| 1080 | |
| 1081 | // release all registered events |
| 1082 | releaseAllPointerEvents(this); |
| 1083 | |
| 1084 | // call the user defined destroy method |
| 1085 | this.onDestroyEvent.apply(this, arguments); |
| 1086 | |
| 1087 | // destroy any shader effects if not done by the user through onDestroyEvent() |
| 1088 | for (const effect of this.postEffects) { |
| 1089 | if (typeof effect.destroy === "function") { |
| 1090 | effect.destroy(); |
| 1091 | } |
| 1092 | } |