UNPKG

cione-comp-lib

Version:

`$ yarn add cione-comp-lib` 或者 `$ npm i cione-comp-lib -S`

36 lines (35 loc) 1.1 kB
var dynamicConvertMixin = { convertToDynamicArray: function(clear) { if (clear) { this.resetOffset(); } var attributes = this.attributes; for (var name in attributes) { if (clear || !attributes[name].value) { attributes[name].value = []; } else { attributes[name].value = Array.prototype.slice.call(attributes[name].value); } } if (clear || !this.indices) { this.indices = []; } else { this.indices = Array.prototype.slice.call(this.indices); } }, convertToTypedArray: function() { var attributes = this.attributes; for (var name in attributes) { if (attributes[name].value && attributes[name].value.length > 0) { attributes[name].value = new Float32Array(attributes[name].value); } else { attributes[name].value = null; } } if (this.indices && this.indices.length > 0) { this.indices = this.vertexCount > 65535 ? new Uint32Array(this.indices) : new Uint16Array(this.indices); } this.dirty(); } }; export { dynamicConvertMixin as default };