MCPcopy Create free account
hub / github.com/microsoft/SandDance / padBuffer

Function padBuffer

docs/app/js/sanddance-app.js:86436–86479  ·  view source on GitHub ↗
(_ref)

Source from the content-addressed store, hash-verified

86434 return (settings.noAlloc ? value.length : numInstances * size) * multiplier;
86435}
86436function padBuffer(_ref) {
86437 var buffer = _ref.buffer, numInstances = _ref.numInstances, attribute = _ref.attribute, fromLength = _ref.fromLength, fromStartIndices = _ref.fromStartIndices, _ref$getData = _ref.getData, getData = _ref$getData === void 0 ? function(x) {
86438 return x;
86439 } : _ref$getData;
86440 var precisionMultiplier = attribute.doublePrecision ? 2 : 1;
86441 var size = attribute.size * precisionMultiplier;
86442 var byteOffset = attribute.byteOffset;
86443 var toStartIndices = attribute.startIndices;
86444 var hasStartIndices = fromStartIndices && toStartIndices;
86445 var toLength = getAttributeBufferLength(attribute, numInstances);
86446 var isConstant = attribute.state.constant;
86447 if (!hasStartIndices && fromLength >= toLength) return;
86448 var toData = isConstant ? attribute.value : attribute.getBuffer().getData({
86449 srcByteOffset: byteOffset
86450 });
86451 if (attribute.settings.normalized && !isConstant) {
86452 var getter = getData;
86453 getData = function getData(value, chunk) {
86454 return attribute._normalizeConstant(getter(value, chunk));
86455 };
86456 }
86457 var getMissingData = isConstant ? function(i, chunk) {
86458 return getData(toData, chunk);
86459 } : function(i, chunk) {
86460 return getData(toData.subarray(i, i + size), chunk);
86461 };
86462 var source = buffer.getData({
86463 length: fromLength
86464 });
86465 var data = new Float32Array(toLength);
86466 (0, _arrayUtils.padArray)({
86467 source: source,
86468 target: data,
86469 sourceStartIndices: fromStartIndices,
86470 targetStartIndices: toStartIndices,
86471 size: size,
86472 getData: getMissingData
86473 });
86474 if (buffer.byteLength < data.byteLength + byteOffset) buffer.reallocate(data.byteLength + byteOffset);
86475 buffer.subData({
86476 data: data,
86477 offset: byteOffset
86478 });
86479}
86480
86481},{"../../utils/array-utils":"k2sup","@parcel/transformer-js/src/esmodule-helpers.js":"jA2du"}],"k2sup":[function(require,module,exports) {
86482var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");

Callers

nothing calls this directly

Calls 3

getAttributeBufferLengthFunction · 0.70
getterFunction · 0.70
getDataFunction · 0.70

Tested by

no test coverage detected