@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.
26 lines (25 loc) • 882 B
JavaScript
;
exports.__esModule = true;
exports.tryGetGuid = exports.tryCastBinary = exports.registerBinaryType = exports.binaryIdentifierCasts = void 0;
// registry
exports.binaryIdentifierCasts = {};
function registerBinaryType(identifier, cast) {
exports.binaryIdentifierCasts[identifier] = cast;
}
exports.registerBinaryType = registerBinaryType;
// called by networking on receiving a new binary blob
// it's just a little helper method so listeners dont have to cast to types every time
function tryCastBinary(bin) {
var id = bin.getBufferIdentifier();
var cast = exports.binaryIdentifierCasts[id];
var mod = cast(bin);
return mod;
}
exports.tryCastBinary = tryCastBinary;
function tryGetGuid(obj) {
if (typeof obj["guid"] === "function") {
return obj.guid();
}
return null;
}
exports.tryGetGuid = tryGetGuid;