UNPKG

wonder.js

Version:
53 lines (45 loc) 2.37 kB
'use strict'; var Log$WonderLog = require("wonder-log/lib/js/src/Log.js"); var Contract$WonderLog = require("wonder-log/lib/js/src/Contract.js"); var StateDataMain$Wonderjs = require("../../../state/main/data/StateDataMain.js"); var ArrayMapService$Wonderjs = require("../../../atom/ArrayMapService.js"); var IsDebugMainService$Wonderjs = require("../../../state/main/state/IsDebugMainService.js"); var MutableSparseMapService$Wonderjs = require("../../../atom/MutableSparseMapService.js"); var MutableSparseMapService$WonderCommonlib = require("wonder-commonlib/lib/js/src/MutableSparseMapService.js"); var getMaterialDataArr = MutableSparseMapService$WonderCommonlib.get; function unsafeGetMaterialDataArr(texture, materialsMap) { return Contract$WonderLog.ensureCheck((function (materialData) { return Contract$WonderLog.test(Log$WonderLog.buildAssertMessage("texture\'s materialData exist", "not"), (function (param) { return Contract$WonderLog.assertNullableExist(materialData); })); }), IsDebugMainService$Wonderjs.getIsDebug(StateDataMain$Wonderjs.stateData), MutableSparseMapService$WonderCommonlib.unsafeGet(texture, materialsMap)); } function addMaterial(param, texture, materialsMap) { return ArrayMapService$Wonderjs.addValue(texture, /* tuple */[ param[0], param[1] ], materialsMap); } function removeMaterial(param, texture, materialsMap) { var materialType = param[1]; var material = param[0]; var match = MutableSparseMapService$Wonderjs.fastGet(texture, materialsMap); if (match[0]) { return MutableSparseMapService$WonderCommonlib.set(texture, match[1].filter((function (param) { if (param[1] !== materialType) { return true; } else { return param[0] !== material; } })), materialsMap); } else { return materialsMap; } } var clearMaterial = MutableSparseMapService$WonderCommonlib.deleteVal; exports.getMaterialDataArr = getMaterialDataArr; exports.unsafeGetMaterialDataArr = unsafeGetMaterialDataArr; exports.addMaterial = addMaterial; exports.removeMaterial = removeMaterial; exports.clearMaterial = clearMaterial; /* Log-WonderLog Not a pure module */