wonder.js
Version:
91 lines (78 loc) • 4.62 kB
JavaScript
;
var Most = require("most");
var Curry = require("bs-platform/lib/js/curry.js");
var OptionService$Wonderjs = require("../../../../atom/OptionService.js");
var TextureSourceMapService$Wonderjs = require("../../../../primitive/texture/TextureSourceMapService.js");
var ImageBitmapRenderWorkerService$Wonderjs = require("../ImageBitmapRenderWorkerService.js");
var RecordCubemapTextureRenderWorkerService$Wonderjs = require("./RecordCubemapTextureRenderWorkerService.js");
var OperateTypeArrayAllCubemapTextureService$Wonderjs = require("../../../../record/all/texture/cubemap/OperateTypeArrayAllCubemapTextureService.js");
function _addPXSource(texture, imageBitmap, state) {
var match = RecordCubemapTextureRenderWorkerService$Wonderjs.getRecord(state);
TextureSourceMapService$Wonderjs.addSource(texture, imageBitmap, match[/* pxSourceMap */18]);
return state;
}
function _addNXSource(texture, imageBitmap, state) {
var match = RecordCubemapTextureRenderWorkerService$Wonderjs.getRecord(state);
TextureSourceMapService$Wonderjs.addSource(texture, imageBitmap, match[/* nxSourceMap */19]);
return state;
}
function _addPYSource(texture, imageBitmap, state) {
var match = RecordCubemapTextureRenderWorkerService$Wonderjs.getRecord(state);
TextureSourceMapService$Wonderjs.addSource(texture, imageBitmap, match[/* pySourceMap */20]);
return state;
}
function _addNYSource(texture, imageBitmap, state) {
var match = RecordCubemapTextureRenderWorkerService$Wonderjs.getRecord(state);
TextureSourceMapService$Wonderjs.addSource(texture, imageBitmap, match[/* nySourceMap */21]);
return state;
}
function _addPZSource(texture, imageBitmap, state) {
var match = RecordCubemapTextureRenderWorkerService$Wonderjs.getRecord(state);
TextureSourceMapService$Wonderjs.addSource(texture, imageBitmap, match[/* pzSourceMap */22]);
return state;
}
function _addNZSource(texture, imageBitmap, state) {
var match = RecordCubemapTextureRenderWorkerService$Wonderjs.getRecord(state);
TextureSourceMapService$Wonderjs.addSource(texture, imageBitmap, match[/* nzSourceMap */23]);
return state;
}
function _getFlipYFunc(texture, state) {
var match = RecordCubemapTextureRenderWorkerService$Wonderjs.getRecord(state);
return OperateTypeArrayAllCubemapTextureService$Wonderjs.isFlipY(texture, OptionService$Wonderjs.unsafeGet(match[/* flipYs */17]));
}
function _convertImageArrayBufferDataToImageBitmapStream(imageArrayBufferIndexSizeDataArr, addSourceFunc, state) {
return Most.flatMap((function (param) {
var texture = param[3];
return Most.map((function (imageBitmap) {
return Curry._3(addSourceFunc, texture, imageBitmap, state);
}), Most.fromPromise(ImageBitmapRenderWorkerService$Wonderjs.createImageBitmapFromImageData(/* tuple */[
param[0],
param[1],
param[2]
], (function (param) {
return _getFlipYFunc(texture, param);
}), state)));
}), Most.from(imageArrayBufferIndexSizeDataArr));
}
function _convertAllImageArrayBufferDataToImageBitmapStream(param, state) {
return Most.mergeArray(/* array */[
_convertImageArrayBufferDataToImageBitmapStream(param[0], _addPXSource, state),
_convertImageArrayBufferDataToImageBitmapStream(param[1], _addNXSource, state),
_convertImageArrayBufferDataToImageBitmapStream(param[2], _addPYSource, state),
_convertImageArrayBufferDataToImageBitmapStream(param[3], _addNYSource, state),
_convertImageArrayBufferDataToImageBitmapStream(param[4], _addPZSource, state),
_convertImageArrayBufferDataToImageBitmapStream(param[5], _addNZSource, state)
]);
}
var addSourceFromImageDataStream = _convertAllImageArrayBufferDataToImageBitmapStream;
exports._addPXSource = _addPXSource;
exports._addNXSource = _addNXSource;
exports._addPYSource = _addPYSource;
exports._addNYSource = _addNYSource;
exports._addPZSource = _addPZSource;
exports._addNZSource = _addNZSource;
exports._getFlipYFunc = _getFlipYFunc;
exports._convertImageArrayBufferDataToImageBitmapStream = _convertImageArrayBufferDataToImageBitmapStream;
exports._convertAllImageArrayBufferDataToImageBitmapStream = _convertAllImageArrayBufferDataToImageBitmapStream;
exports.addSourceFromImageDataStream = addSourceFromImageDataStream;
/* most Not a pure module */