Write position bounds to gltf file.
This commit is contained in:
parent
a35bceadea
commit
b4832a7cd0
@ -267,6 +267,7 @@ OV.ExporterGltf = class extends OV.ExporterBase
|
||||
material : primitive.material
|
||||
};
|
||||
|
||||
let bounds = primitive.GetBounds ();
|
||||
mainJson.accessors.push ({
|
||||
bufferView : bufferViewIndex,
|
||||
byteOffset : 0,
|
||||
@ -279,6 +280,8 @@ OV.ExporterGltf = class extends OV.ExporterBase
|
||||
byteOffset : 0,
|
||||
componentType : this.components.number.type,
|
||||
count : primitive.vertices.length / 3,
|
||||
min : bounds.min,
|
||||
max : bounds.max,
|
||||
type : 'VEC3'
|
||||
});
|
||||
mainJson.accessors.push ({
|
||||
|
||||
@ -17,7 +17,7 @@ OV.BinaryWriter = class
|
||||
{
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
|
||||
End ()
|
||||
{
|
||||
return this.position >= this.arrayBuffer.byteLength;
|
||||
|
||||
@ -9,6 +9,22 @@ OV.MeshPrimitiveBuffer = class
|
||||
this.material = null;
|
||||
}
|
||||
|
||||
GetBounds ()
|
||||
{
|
||||
let min = [Infinity, Infinity, Infinity];
|
||||
let max = [-Infinity, -Infinity, -Infinity];
|
||||
for (let i = 0; i < this.vertices.length / 3; i++) {
|
||||
for (let j = 0; j < 3; j++) {
|
||||
min[j] = Math.min (min[j], this.vertices[i * 3 + j]);
|
||||
max[j] = Math.max (max[j], this.vertices[i * 3 + j]);
|
||||
}
|
||||
}
|
||||
return {
|
||||
min : min,
|
||||
max : max
|
||||
}
|
||||
}
|
||||
|
||||
GetByteLength (indexTypeSize, numberTypeSize)
|
||||
{
|
||||
let indexCount = this.indices.length;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user