@needle-tools/engine
Version:
Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in.
23 lines • 750 B
JavaScript
import { Layers } from "three";
const $customVisibilityFlag = Symbol("customVisibilityFlag");
/**
* Sets the visibility of a single object without affecting the visibility of the child hierarchy
*/
export function setCustomVisibility(obj, visible) {
obj.layers[$customVisibilityFlag] = visible;
}
const $didPatch = Symbol("DidPatchLayers");
export function patchLayers() {
const prot = Layers.prototype;
if (prot[$didPatch])
return;
prot[$didPatch] = true;
const origTest = prot.test;
prot.test = function (layer) {
if (this[$customVisibilityFlag] === false)
return false;
return origTest.call(this, layer);
};
}
patchLayers();
//# sourceMappingURL=Layers.js.map