UNPKG

wonder.js

Version:
69 lines (61 loc) 3.74 kB
'use strict'; var Curry = require("bs-platform/lib/js/curry.js"); var Js_option = require("bs-platform/lib/js/js_option.js"); var Log$WonderLog = require("wonder-log/lib/js/src/Log.js"); var ArrayService$Wonderjs = require("../../../atom/ArrayService.js"); var OptionService$Wonderjs = require("../../../atom/OptionService.js"); var ArrayService$WonderCommonlib = require("wonder-commonlib/lib/js/src/ArrayService.js"); var TextureIndexService$Wonderjs = require("../../../primitive/material/TextureIndexService.js"); var BufferMaterialService$Wonderjs = require("../../../record/main/material/BufferMaterialService.js"); var DisposeComponentService$Wonderjs = require("../../../primitive/component/DisposeComponentService.js"); var IndexSourceTextureMainService$Wonderjs = require("../texture/source/IndexSourceTextureMainService.js"); var DisposeBasicSourceTextureMainService$Wonderjs = require("../texture/source/basic_source/DisposeBasicSourceTextureMainService.js"); var DisposeArrayBufferViewSourceTextureMainService$Wonderjs = require("../texture/source/arrayBufferView_source/DisposeArrayBufferViewSourceTextureMainService.js"); function disposeTextureIndices(material, getTextureIndicesIndexFunc, textureIndices) { var sourceIndex = Curry._1(getTextureIndicesIndexFunc, material); var defaultIndex = TextureIndexService$Wonderjs.getDefaultTextureIndex(/* () */0); for(var i = 0 ,i_finish = BufferMaterialService$Wonderjs.getTextureIndicesSize(/* () */0) - 1 | 0; i <= i_finish; ++i){ textureIndices[sourceIndex + i | 0] = defaultIndex; } return textureIndices; } var isAlive = DisposeComponentService$Wonderjs.isAlive; function _getExistMapArr(mapArr) { return mapArr.filter(Js_option.isSome).map(OptionService$Wonderjs.unsafeGet); } function addAllMaps(mapArr, state) { return ArrayService$WonderCommonlib.reduceOneParam((function (param, map) { var arrayBufferViewSourceTextureArr = param[1]; var basicSourceTextureArr = param[0]; var match = IndexSourceTextureMainService$Wonderjs.isBasicSourceTextureIndex(map, state); if (match) { return /* tuple */[ ArrayService$Wonderjs.push(map, basicSourceTextureArr), arrayBufferViewSourceTextureArr ]; } else { var match$1 = IndexSourceTextureMainService$Wonderjs.isArrayBufferViewSourceTextureIndex(map, state); if (match$1) { return /* tuple */[ basicSourceTextureArr, ArrayService$Wonderjs.push(map, arrayBufferViewSourceTextureArr) ]; } else { return Log$WonderLog.fatal(Log$WonderLog.buildFatalMessage("addAllMaps", "unknown map: " + (String(map) + ""), "", "", "")); } } }), /* tuple */[ ArrayService$WonderCommonlib.createEmpty(/* () */0), ArrayService$WonderCommonlib.createEmpty(/* () */0) ], _getExistMapArr(mapArr)); } function disposeSourceMaps(isRemoveTexture, materialData, mapArr, state) { var match = addAllMaps(mapArr, state); return DisposeArrayBufferViewSourceTextureMainService$Wonderjs.handleDispose(isRemoveTexture, materialData, match[1], DisposeBasicSourceTextureMainService$Wonderjs.handleDispose(isRemoveTexture, materialData, match[0], state)); } exports.disposeTextureIndices = disposeTextureIndices; exports.isAlive = isAlive; exports._getExistMapArr = _getExistMapArr; exports.addAllMaps = addAllMaps; exports.disposeSourceMaps = disposeSourceMaps; /* Log-WonderLog Not a pure module */