createBufferGeometryFromObject static method
dynamic
createBufferGeometryFromObject(
- dynamic object
Implementation
static createBufferGeometryFromObject(object) {
var buffergeometry = new THREE.BufferGeometry();
var geometry = object.geometry;
if (object.isPoints || object.isLine) {
var positions = new THREE.Float32BufferAttribute(
geometry.vertices.length * 3, 3, false);
var colors = new THREE.Float32BufferAttribute(
geometry.colors.length * 3, 3, false);
buffergeometry.setAttribute(
'position', positions.copyVector3sArray(geometry.vertices));
buffergeometry.setAttribute(
'color', colors.copyColorsArray(geometry.colors));
if (geometry.lineDistances &&
geometry.lineDistances.length == geometry.vertices.length) {
var lineDistances = new THREE.Float32BufferAttribute(
geometry.lineDistances.length, 1, false);
buffergeometry.setAttribute(
'lineDistance', lineDistances.copyArray(geometry.lineDistances));
}
if (geometry.boundingSphere != null) {
buffergeometry.boundingSphere = geometry.boundingSphere.clone();
}
if (geometry.boundingBox != null) {
buffergeometry.boundingBox = geometry.boundingBox.clone();
}
} else if (object.isMesh) {
buffergeometry = geometry.toBufferGeometry();
}
return buffergeometry;
}