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

Function getBuffersFromGeometry

docs/app/js/sanddance-app.js:76943–76978  ·  view source on GitHub ↗
(gl, geometry, options)

Source from the content-addressed store, hash-verified

76941 TEXCOORD_2: "texCoords2"
76942};
76943function getBuffersFromGeometry(gl, geometry, options) {
76944 var buffers = {};
76945 var indices = geometry.indices;
76946 for(var name in geometry.attributes){
76947 var attribute = geometry.attributes[name];
76948 var remappedName = mapAttributeName(name, options);
76949 if (name === "indices") indices = attribute;
76950 else if (attribute.constant) buffers[remappedName] = attribute.value;
76951 else {
76952 var typedArray = attribute.value;
76953 var accessor = (0, _objectSpreadDefault.default)({}, attribute);
76954 delete accessor.value;
76955 buffers[remappedName] = [
76956 new (0, _webgl.Buffer)(gl, typedArray),
76957 accessor
76958 ];
76959 inferAttributeAccessor(name, accessor);
76960 }
76961 }
76962 if (indices) {
76963 var data = indices.value || indices;
76964 (0, _webgl.assert)(data instanceof Uint16Array || data instanceof Uint32Array, 'attribute array for "indices" must be of integer type');
76965 var _accessor = {
76966 size: 1,
76967 isIndexed: indices.isIndexed === undefined ? true : indices.isIndexed
76968 };
76969 buffers.indices = [
76970 new (0, _webgl.Buffer)(gl, {
76971 data: data,
76972 target: 34963
76973 }),
76974 _accessor
76975 ];
76976 }
76977 return buffers;
76978}
76979function mapAttributeName(name, options) {
76980 var _ref = options || {}, _ref$attributeMap = _ref.attributeMap, attributeMap = _ref$attributeMap === void 0 ? GLTF_TO_LUMA_ATTRIBUTE_MAP : _ref$attributeMap;
76981 return attributeMap && attributeMap[name] || name;

Callers

nothing calls this directly

Calls 2

mapAttributeNameFunction · 0.70
inferAttributeAccessorFunction · 0.70

Tested by

no test coverage detected