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

Method sortNow

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

* Synchronous variant of Container#sort. Sorts immediately * — no defer — using the current `_comparator`. Intended for * per-frame callers that need the order to be valid for the very * next render (e.g. `Camera3d` refreshing the `"depth"` sort after * the camera has moved, where wa

(recursive)

Source from the content-addressed store, hash-verified

991 * @param {boolean} [recursive=false] - recursively sort sub-containers
992 */
993 sortNow(recursive) {
994 if (this._sortOn === "depth") {
995 captureDepthCamera();
996 captureDepthOffset(this);
997 }
998 const children = this.getChildren();
999 if (children.length > 1) {
1000 children.sort(this._comparator);
1001 this.isDirty = true;
1002 }
1003 if (recursive === true) {
1004 for (let i = 0; i < children.length; i++) {
1005 const c = children[i];
1006 if (c instanceof Container) {
1007 c.sortNow(true);
1008 }
1009 }
1010 }
1011 }
1012
1013 /**
1014 * @ignore

Callers 2

container.spec.jsFile · 0.80

Calls 4

getChildrenMethod · 0.95
captureDepthCameraFunction · 0.85
captureDepthOffsetFunction · 0.85
sortMethod · 0.80

Tested by

no test coverage detected