UNPKG

wonder.js

Version:
129 lines (114 loc) 5.3 kB
'use strict'; var Caml_array = require("bs-platform/lib/js/caml_array.js"); var Caml_int32 = require("bs-platform/lib/js/caml_int32.js"); var OptionService$Wonderjs = require("../../../../atom/OptionService.js"); var TypeArrayService$Wonderjs = require("../../../../primitive/buffer/TypeArrayService.js"); var ArrayService$WonderCommonlib = require("wonder-commonlib/lib/js/src/ArrayService.js"); var BufferSettingService$Wonderjs = require("../../../../record/main/setting/BufferSettingService.js"); var CopyTypeArrayService$Wonderjs = require("../../../../primitive/copy/CopyTypeArrayService.js"); var BufferDirectionLightService$Wonderjs = require("../../../../record/main/light/direction/BufferDirectionLightService.js"); var MutableSparseMapService$WonderCommonlib = require("wonder-commonlib/lib/js/src/MutableSparseMapService.js"); var CreateTypeArrayAllDirectionLightService$Wonderjs = require("../../../../record/all/light/direction/CreateTypeArrayAllDirectionLightService.js"); function getRecord(param) { return OptionService$Wonderjs.unsafeGet(param[/* directionLightRecord */21]); } function getDefaultColor(param) { return /* array */[ 1, 1, 1 ]; } function getDefaultIntensity(param) { return 1; } function getColor(index, typeArr) { return TypeArrayService$Wonderjs.getFloat3(BufferDirectionLightService$Wonderjs.getColorIndex(index), typeArr); } function setColor(index, color, typeArr) { return TypeArrayService$Wonderjs.setFloat3(BufferDirectionLightService$Wonderjs.getColorIndex(index), color, typeArr); } function getIntensity(index, typeArr) { return TypeArrayService$Wonderjs.getFloat1(BufferDirectionLightService$Wonderjs.getIntensityIndex(index), typeArr); } function setIntensity(index, intensity, typeArr) { return TypeArrayService$Wonderjs.setFloat1(BufferDirectionLightService$Wonderjs.getIntensityIndex(index), intensity, typeArr); } function setAllTypeArrDataToDefault(count, param) { var defaultColor = /* array */[ 1, 1, 1 ]; return ArrayService$WonderCommonlib.reduceOneParam((function (param, index) { return /* tuple */[ setColor(index, defaultColor, param[0]), setIntensity(index, 1, param[1]) ]; }), /* tuple */[ param[0], param[1] ], ArrayService$WonderCommonlib.range(0, count - 1 | 0)); } function _setAllTypeArrDataToDefault(count, param) { return /* tuple */[ param[0], setAllTypeArrDataToDefault(count, /* tuple */[ param[1], param[2] ]) ]; } function _initBufferData(count) { var buffer = BufferDirectionLightService$Wonderjs.createBuffer(count); var match = CreateTypeArrayAllDirectionLightService$Wonderjs.createTypeArrays(buffer, count); return _setAllTypeArrDataToDefault(count, /* tuple */[ buffer, match[0], match[1] ]); } function create(state) { var lightCount = BufferSettingService$Wonderjs.getDirectionLightCount(state[/* settingRecord */0]); var match = _initBufferData(lightCount); var match$1 = match[1]; var newrecord = Caml_array.caml_array_dup(state); newrecord[/* directionLightRecord */21] = /* record */[ /* index */0, /* buffer */match[0], /* colors */match$1[0], /* intensities */match$1[1], /* renderLightArr */ArrayService$WonderCommonlib.createEmpty(/* () */0), /* gameObjectMap */MutableSparseMapService$WonderCommonlib.createEmpty(/* () */0), /* disposedIndexArray */ArrayService$WonderCommonlib.createEmpty(/* () */0) ]; return newrecord; } function deepCopyForRestore(state) { var directionLightRecord = getRecord(state); var index = directionLightRecord[/* index */0]; var newrecord = Caml_array.caml_array_dup(state); newrecord[/* directionLightRecord */21] = /* record */[ /* index */index, /* buffer */directionLightRecord[/* buffer */1], /* colors */CopyTypeArrayService$Wonderjs.copyFloat32ArrayWithEndIndex(Caml_int32.imul(index, BufferDirectionLightService$Wonderjs.getColorsSize(/* () */0)), directionLightRecord[/* colors */2]), /* intensities */CopyTypeArrayService$Wonderjs.copyFloat32ArrayWithEndIndex(Caml_int32.imul(index, BufferDirectionLightService$Wonderjs.getIntensitiesSize(/* () */0)), directionLightRecord[/* intensities */3]), /* renderLightArr */directionLightRecord[/* renderLightArr */4].slice(), /* gameObjectMap */MutableSparseMapService$WonderCommonlib.copy(directionLightRecord[/* gameObjectMap */5]), /* disposedIndexArray */directionLightRecord[/* disposedIndexArray */6].slice() ]; return newrecord; } exports.getRecord = getRecord; exports.getDefaultColor = getDefaultColor; exports.getDefaultIntensity = getDefaultIntensity; exports.getColor = getColor; exports.setColor = setColor; exports.getIntensity = getIntensity; exports.setIntensity = setIntensity; exports.setAllTypeArrDataToDefault = setAllTypeArrDataToDefault; exports._setAllTypeArrDataToDefault = _setAllTypeArrDataToDefault; exports._initBufferData = _initBufferData; exports.create = create; exports.deepCopyForRestore = deepCopyForRestore; /* OptionService-Wonderjs Not a pure module */