MCPcopy Create free account
hub / github.com/melonjs/melonJS / sort

Method sort

packages/melonjs/src/renderable/container.js:954–982  ·  view source on GitHub ↗

* Manually trigger the sort of all the childs in the container * @param {boolean} [recursive=false] - recursively sort all containers if true

(recursive)

Source from the content-addressed store, hash-verified

952 * @param {boolean} [recursive=false] - recursively sort all containers if true
953 */
954 sort(recursive) {
955 // do nothing if there is already a pending sort
956 if (!this.pendingSort) {
957 if (recursive === true) {
958 this.forEach((child) => {
959 if (child instanceof Container) {
960 // note : this will generate one deferred sorting function
961 // for each existing containe
962 child.sort(recursive);
963 }
964 });
965 }
966 this.pendingSort = defer(function () {
967 // refresh the cached camera + container offset so
968 // `_sortDepth` sees the current view in world space —
969 // no-op for x/y/z modes.
970 if (this._sortOn === "depth") {
971 captureDepthCamera();
972 captureDepthOffset(this);
973 }
974 // sort everything in this container
975 this.getChildren().sort(this._comparator);
976 // clear the defer id
977 this.pendingSort = null;
978 // make sure we redraw everything
979 this.isDirty = true;
980 }, this);
981 }
982 }
983
984 /**
985 * Synchronous variant of {@link Container#sort}. Sorts immediately

Callers 15

addChildMethod · 0.95
retrieveMethod · 0.80
retrieveMethod · 0.80
raycastQueryFunction · 0.80
compositeFunction · 0.80
sortNowMethod · 0.80
eliminateHolesFunction · 0.80
_buildParsedStopsMethod · 0.80
convexHullFunction · 0.80
addToMethod · 0.80
container.spec.jsFile · 0.80

Calls 5

forEachMethod · 0.95
getChildrenMethod · 0.95
deferFunction · 0.90
captureDepthCameraFunction · 0.85
captureDepthOffsetFunction · 0.85

Tested by

no test coverage detected