vim-format
Advanced tools
Comparing version 1.0.2-dev.33 to 1.0.2-dev.34
@@ -79,9 +79,9 @@ /** | ||
rawG3d: AbstractG3d; | ||
MATRIX_SIZE: number; | ||
COLOR_SIZE: number; | ||
POSITION_SIZE: number; | ||
static MATRIX_SIZE: number; | ||
static COLOR_SIZE: number; | ||
static POSITION_SIZE: number; | ||
/** | ||
* Opaque white | ||
*/ | ||
DEFAULT_COLOR: Float32Array; | ||
static DEFAULT_COLOR: Float32Array; | ||
constructor(instanceMeshes: Int32Array, instanceFlags: Uint16Array | undefined, instanceTransforms: Float32Array, instanceNodes: Int32Array | undefined, meshSubmeshes: Int32Array, submeshIndexOffsets: Int32Array, submeshMaterials: Int32Array, indices: Uint32Array, positions: Float32Array, materialColors: Float32Array); | ||
@@ -88,0 +88,0 @@ static createFromAbstract(g3d: AbstractG3d): G3d; |
@@ -148,10 +148,3 @@ "use strict"; | ||
constructor(instanceMeshes, instanceFlags, instanceTransforms, instanceNodes, meshSubmeshes, submeshIndexOffsets, submeshMaterials, indices, positions, materialColors) { | ||
this.MATRIX_SIZE = 16; | ||
this.COLOR_SIZE = 4; | ||
this.POSITION_SIZE = 3; | ||
/** | ||
* Opaque white | ||
*/ | ||
this.DEFAULT_COLOR = new Float32Array([1, 1, 1, 1]); | ||
/** | ||
* Computes all instances pointing to each mesh. | ||
@@ -174,3 +167,3 @@ */ | ||
// ------------- All ----------------- | ||
this.getVertexCount = () => this.positions.length / this.POSITION_SIZE; | ||
this.getVertexCount = () => this.positions.length / G3d.POSITION_SIZE; | ||
// ------------- Meshes ----------------- | ||
@@ -181,3 +174,3 @@ this.getMeshCount = () => this.meshSubmeshes.length; | ||
// ------------- Material ----------------- | ||
this.getMaterialCount = () => this.materialColors.length / this.COLOR_SIZE; | ||
this.getMaterialCount = () => this.materialColors.length / G3d.COLOR_SIZE; | ||
if (instanceNodes === undefined) { | ||
@@ -484,3 +477,3 @@ instanceNodes = new Int32Array(instanceMeshes.length); | ||
getInstanceMatrix(instance) { | ||
return this.instanceTransforms.subarray(instance * this.MATRIX_SIZE, (instance + 1) * this.MATRIX_SIZE); | ||
return this.instanceTransforms.subarray(instance * G3d.MATRIX_SIZE, (instance + 1) * G3d.MATRIX_SIZE); | ||
} | ||
@@ -493,4 +486,4 @@ /** | ||
if (material < 0) | ||
return this.DEFAULT_COLOR; | ||
return this.materialColors.subarray(material * this.COLOR_SIZE, (material + 1) * this.COLOR_SIZE); | ||
return G3d.DEFAULT_COLOR; | ||
return this.materialColors.subarray(material * G3d.COLOR_SIZE, (material + 1) * G3d.COLOR_SIZE); | ||
} | ||
@@ -500,3 +493,3 @@ getMaterialAlpha(material) { | ||
return 1; | ||
const index = material * this.COLOR_SIZE + this.COLOR_SIZE - 1; | ||
const index = material * G3d.COLOR_SIZE + G3d.COLOR_SIZE - 1; | ||
const result = this.materialColors[index]; | ||
@@ -673,4 +666,4 @@ return result; | ||
// Basic | ||
if (this.positions.length % this.POSITION_SIZE !== 0) { | ||
throw new Error('Invalid position buffer, must be divisible by ' + this.POSITION_SIZE); | ||
if (this.positions.length % G3d.POSITION_SIZE !== 0) { | ||
throw new Error('Invalid position buffer, must be divisible by ' + G3d.POSITION_SIZE); | ||
} | ||
@@ -687,8 +680,8 @@ if (this.indices.length % 3 !== 0) { | ||
if (this.instanceMeshes.length !== | ||
this.instanceTransforms.length / this.MATRIX_SIZE) { | ||
this.instanceTransforms.length / G3d.MATRIX_SIZE) { | ||
throw new Error('Instance buffers mismatched'); | ||
} | ||
if (this.instanceTransforms.length % this.MATRIX_SIZE !== 0) { | ||
if (this.instanceTransforms.length % G3d.MATRIX_SIZE !== 0) { | ||
throw new Error('Invalid InstanceTransform buffer, must respect arity ' + | ||
this.MATRIX_SIZE); | ||
G3d.MATRIX_SIZE); | ||
} | ||
@@ -738,4 +731,4 @@ for (let i = 0; i < this.instanceMeshes.length; i++) { | ||
// Materials | ||
if (this.materialColors.length % this.COLOR_SIZE !== 0) { | ||
throw new Error('Invalid material color buffer, must be divisible by ' + this.COLOR_SIZE); | ||
if (this.materialColors.length % G3d.COLOR_SIZE !== 0) { | ||
throw new Error('Invalid material color buffer, must be divisible by ' + G3d.COLOR_SIZE); | ||
} | ||
@@ -757,1 +750,8 @@ console.assert(this.meshInstances.length === this.getMeshCount()); | ||
exports.G3d = G3d; | ||
G3d.MATRIX_SIZE = 16; | ||
G3d.COLOR_SIZE = 4; | ||
G3d.POSITION_SIZE = 3; | ||
/** | ||
* Opaque white | ||
*/ | ||
G3d.DEFAULT_COLOR = new Float32Array([1, 1, 1, 1]); |
@@ -343,3 +343,3 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const _positions = new Float32Array(indices.positionCount * 3); | ||
const _positions = new Float32Array(indices.positionCount * g3d_1.G3d.POSITION_SIZE); | ||
const promises = []; | ||
@@ -354,3 +354,3 @@ let mesh_i = 0; | ||
promises.push(this.positions.getValues(vertexStart, vertexEnd - vertexStart) | ||
.then(v => _positions.set(v, indices.vertexOffsets[current] * 3))); | ||
.then(v => _positions.set(v, indices.vertexOffsets[current] * g3d_1.G3d.POSITION_SIZE))); | ||
mesh_i++; | ||
@@ -374,3 +374,3 @@ } | ||
promises.push(this.materialColors.getValue(i) | ||
.then(c => materials.colors.set(c, current * 4))); | ||
.then(c => materials.colors.set(c, current * g3d_1.G3d.COLOR_SIZE))); | ||
color_i++; | ||
@@ -450,4 +450,4 @@ } | ||
this.map = new Map(); | ||
this.colors = new Float32Array(this.set.size * 4); | ||
this.colors = new Float32Array(this.set.size * g3d_1.G3d.COLOR_SIZE); | ||
} | ||
} |
{ | ||
"name": "vim-format", | ||
"version": "1.0.2-dev.33", | ||
"version": "1.0.2-dev.34", | ||
"description": "The VIM format is a modern and efficient open 3D data interchange format designed for BIM and manufacturing data optimized for efficient loading and rendering on low-power devices.", | ||
@@ -5,0 +5,0 @@ "directories": { |
652702