UNPKG

@openhps/core

Version:

Open Hybrid Positioning System - Core component

58 lines (56 loc) 2.38 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.instancedArray = exports.attributeArray = void 0; var _StorageInstancedBufferAttribute = _interopRequireDefault(require("../../renderers/common/StorageInstancedBufferAttribute.js")); var _StorageBufferAttribute = _interopRequireDefault(require("../../renderers/common/StorageBufferAttribute.js")); var _StorageBufferNode = require("./StorageBufferNode.js"); var _NodeUtils = require("../core/NodeUtils.js"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * TSL function for creating a storage buffer node with a configured `StorageBufferAttribute`. * * @tsl * @function * @param {number|TypedArray} count - The data count. It is also valid to pass a typed array as an argument. * @param {string|Struct} [type='float'] - The data type. * @returns {StorageBufferNode} */ const attributeArray = (count, type = 'float') => { let itemSize, typedArray; if (type.isStruct === true) { itemSize = type.layout.getLength(); typedArray = (0, _NodeUtils.getTypedArrayFromType)('float'); } else { itemSize = (0, _NodeUtils.getLengthFromType)(type); typedArray = (0, _NodeUtils.getTypedArrayFromType)(type); } const buffer = new _StorageBufferAttribute.default(count, itemSize, typedArray); const node = (0, _StorageBufferNode.storage)(buffer, type, count); return node; }; /** * TSL function for creating a storage buffer node with a configured `StorageInstancedBufferAttribute`. * * @tsl * @function * @param {number|TypedArray} count - The data count. It is also valid to pass a typed array as an argument. * @param {string|Struct} [type='float'] - The data type. * @returns {StorageBufferNode} */ exports.attributeArray = attributeArray; const instancedArray = (count, type = 'float') => { let itemSize, typedArray; if (type.isStruct === true) { itemSize = type.layout.getLength(); typedArray = (0, _NodeUtils.getTypedArrayFromType)('float'); } else { itemSize = (0, _NodeUtils.getLengthFromType)(type); typedArray = (0, _NodeUtils.getTypedArrayFromType)(type); } const buffer = new _StorageInstancedBufferAttribute.default(count, itemSize, typedArray); const node = (0, _StorageBufferNode.storage)(buffer, type, count); return node; }; exports.instancedArray = instancedArray;