New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

vim-format

Package Overview
Dependencies
Maintainers
5
Versions
341
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vim-format - npm Package Compare versions

Comparing version 1.0.2-dev.27 to 1.0.2-dev.28

25

dist/bfast.js

@@ -33,8 +33,8 @@ "use strict";

if (name.startsWith('g3d')) {
const result = name.includes('int8') ? [1, Int8Array] // inlcludes uint8
: name.includes('uint16') ? [2, Uint16Array]
: name.includes('int16') ? [2, Int16Array]
: name.includes('int32') ? [4, Int32Array]
: name.includes('float32') ? [4, Float32Array]
: name.includes('uint32') ? [4, Uint32Array]
const result = name.includes(':int8:') ? [1, Int8Array] // inlcludes uint8
: name.includes(':uint16:') ? [2, Uint16Array]
: name.includes(':int16:') ? [2, Int16Array]
: name.includes(':int32:') ? [4, Int32Array]
: name.includes(':float32:') ? [4, Float32Array]
: name.includes(':uint32:') ? [4, Uint32Array]
: undefined;

@@ -47,8 +47,8 @@ if (result === undefined) {

else {
const result = name.startsWith('byte') ? [1, Int8Array]
: name.startsWith('short') ? [2, Int16Array]
: name.startsWith('int') ? [4, Int32Array]
: name.startsWith('float') ? [4, Float32Array]
: name.startsWith('long') ? [8, Float64Array]
: name.startsWith('double') ? [8, Float64Array]
const result = name.startsWith('byte:') ? [1, Int8Array]
: name.startsWith('short:') ? [2, Int16Array]
: name.startsWith('int:') ? [4, Int32Array]
: name.startsWith('float:') ? [4, Float32Array]
: name.startsWith('long:') ? [8, Float64Array]
: name.startsWith('double:') ? [8, Float64Array]
: [4, Int32Array];

@@ -251,3 +251,2 @@ return result;

return;
//Could be done in-place.
const [size, ctor] = parseName(name);

@@ -254,0 +253,0 @@ const start = Math.min(range.start + index * size, range.end);

@@ -79,5 +79,5 @@ /**

rawG3d: AbstractG3d;
MATRIX_SIZE: number;
COLOR_SIZE: number;
POSITION_SIZE: number;
static MATRIX_SIZE: number;
static COLOR_SIZE: number;
static POSITION_SIZE: number;
/**

@@ -87,3 +87,3 @@ * Opaque white

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);
constructor(instanceMeshes: Int32Array, instanceFlags: Uint16Array | undefined, instanceTransforms: Float32Array, instanceNodes: Int32Array | undefined, meshSubmeshes: Int32Array, submeshIndexOffsets: Int32Array, submeshMaterials: Int32Array, indices: Int32Array | Uint32Array, positions: Float32Array, materialColors: Float32Array);
static createFromAbstract(g3d: AbstractG3d): G3d;

@@ -90,0 +90,0 @@ static createFromBfast(bfast: BFast): Promise<G3d>;

@@ -103,8 +103,14 @@ "use strict";

static createFromBfast(bfast) {
const promises = VimAttributes.all.map((a) => bfast
.getBytes(a)
.then((bytes) => bytes
? new G3dAttribute(G3dAttributeDescriptor.fromString(a), bytes)
: undefined));
return Promise.all(promises).then((attributes) => new AbstractG3d('meta', attributes.filter((a) => a !== undefined)));
return __awaiter(this, void 0, void 0, function* () {
const attributes = yield Promise.all(VimAttributes.all.map((a) => __awaiter(this, void 0, void 0, function* () {
const bytes = yield bfast.getBytes(a);
if (!bytes)
return;
const decriptor = G3dAttributeDescriptor.fromString(a);
return new G3dAttribute(decriptor, bytes);
})));
const validAttributes = attributes.filter((a) => a !== undefined);
const g3d = new AbstractG3d('meta', validAttributes);
return g3d;
});
}

@@ -149,5 +155,2 @@ }

constructor(instanceMeshes, instanceFlags, instanceTransforms, instanceNodes, meshSubmeshes, submeshIndexOffsets, submeshMaterials, indices, positions, materialColors) {
this.MATRIX_SIZE = 16;
this.COLOR_SIZE = 4;
this.POSITION_SIZE = 3;
/**

@@ -175,3 +178,3 @@ * Opaque white

// ------------- All -----------------
this.getVertexCount = () => this.positions.length / this.POSITION_SIZE;
this.getVertexCount = () => this.positions.length / G3d.POSITION_SIZE;
// ------------- Meshes -----------------

@@ -182,9 +185,3 @@ this.getMeshCount = () => this.meshSubmeshes.length;

// ------------- Material -----------------
this.getMaterialCount = () => this.materialColors.length / this.COLOR_SIZE;
if (instanceNodes === undefined) {
instanceNodes = new Int32Array(instanceMeshes.length);
for (let i = 0; i < instanceNodes.length; i++) {
instanceNodes[i] = i;
}
}
this.getMaterialCount = () => this.materialColors.length / G3d.COLOR_SIZE;
this.instanceMeshes = instanceMeshes;

@@ -197,5 +194,11 @@ this.instanceFlags = instanceFlags;

this.submeshMaterial = submeshMaterials;
this.indices = indices;
this.indices = indices instanceof Uint32Array ? indices : new Uint32Array(indices.buffer);
this.positions = positions;
this.materialColors = materialColors;
if (this.instanceNodes === undefined) {
this.instanceNodes = new Int32Array(instanceMeshes.length);
for (let i = 0; i < this.instanceNodes.length; i++) {
this.instanceNodes[i] = i;
}
}
this.meshVertexOffsets = this.computeMeshVertexOffsets();

@@ -208,3 +211,3 @@ this.rebaseIndices();

static createFromAbstract(g3d) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
const instanceMeshes = (_a = g3d.findAttribute(VimAttributes.instanceMeshes)) === null || _a === void 0 ? void 0 : _a.data;

@@ -217,5 +220,5 @@ const instanceTransforms = (_b = g3d.findAttribute(VimAttributes.instanceTransforms)) === null || _b === void 0 ? void 0 : _b.data;

const submeshMaterial = (_h = g3d.findAttribute(VimAttributes.submeshMaterials)) === null || _h === void 0 ? void 0 : _h.data;
const indices = new Uint32Array((_k = (_j = g3d.findAttribute(VimAttributes.indices)) === null || _j === void 0 ? void 0 : _j.data) === null || _k === void 0 ? void 0 : _k.buffer);
const positions = (_l = g3d.findAttribute(VimAttributes.positions)) === null || _l === void 0 ? void 0 : _l.data;
const materialColors = (_m = g3d.findAttribute(VimAttributes.materialColors)) === null || _m === void 0 ? void 0 : _m.data;
const indices = (_j = g3d.findAttribute(VimAttributes.indices)) === null || _j === void 0 ? void 0 : _j.data;
const positions = (_k = g3d.findAttribute(VimAttributes.positions)) === null || _k === void 0 ? void 0 : _k.data;
const materialColors = (_l = g3d.findAttribute(VimAttributes.materialColors)) === null || _l === void 0 ? void 0 : _l.data;
const result = new G3d(instanceMeshes, instanceFlags, instanceTransforms, instanceNodes, meshSubmeshes, submeshIndexOffset, submeshMaterial, indices, positions, materialColors);

@@ -227,3 +230,4 @@ result.rawG3d = g3d;

return __awaiter(this, void 0, void 0, function* () {
return AbstractG3d.createFromBfast(bfast).then((g3d) => G3d.createFromAbstract(g3d));
const g3d = yield AbstractG3d.createFromBfast(bfast);
return G3d.createFromAbstract(g3d);
});

@@ -489,3 +493,3 @@ }

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);
}

@@ -499,3 +503,3 @@ /**

return this.DEFAULT_COLOR;
return this.materialColors.subarray(material * this.COLOR_SIZE, (material + 1) * this.COLOR_SIZE);
return this.materialColors.subarray(material * G3d.COLOR_SIZE, (material + 1) * G3d.COLOR_SIZE);
}

@@ -505,3 +509,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];

@@ -523,3 +527,3 @@ return result;

_positions.set(other.positions, this.positions.length);
const _indices = new Int32Array(this.indices.length + other.indices.length);
const _indices = new Uint32Array(this.indices.length + other.indices.length);
_indices.set(this.indices);

@@ -539,53 +543,7 @@ _indices.set(other.indices.map(i => i + this.positions.length / 3), this.indices.length);

_materialColors.set(other.materialColors, this.materialColors.length);
const attributes = [];
attributes.push(G3dAttribute.fromString(VimAttributes.instanceTransforms, new Uint8Array(_instanceTransforms.buffer)));
attributes.push(G3dAttribute.fromString(VimAttributes.instanceFlags, new Uint8Array(_instanceFlags.buffer)));
attributes.push(G3dAttribute.fromString(VimAttributes.instanceMeshes, new Uint8Array(_instanceMeshes.buffer)));
attributes.push(G3dAttribute.fromString(VimAttributes.meshSubmeshes, new Uint8Array(_meshSubmeshes.buffer)));
attributes.push(G3dAttribute.fromString(VimAttributes.submeshIndexOffsets, new Uint8Array(_submeshIndexOffsets.buffer)));
attributes.push(G3dAttribute.fromString(VimAttributes.indices, new Uint8Array(_indices.buffer)));
attributes.push(G3dAttribute.fromString(VimAttributes.positions, new Uint8Array(_positions.buffer)));
attributes.push(G3dAttribute.fromString(VimAttributes.submeshMaterials, new Uint8Array(_submeshMaterials.buffer)));
attributes.push(G3dAttribute.fromString(VimAttributes.materialColors, new Uint8Array(_materialColors.buffer)));
const abstract = new AbstractG3d('woot', attributes);
const g3d = G3d.createFromAbstract(abstract);
const g3d = new G3d(_instanceMeshes, _instanceFlags, _instanceTransforms, undefined, _meshSubmeshes, _submeshIndexOffsets, _submeshMaterials, _indices, _positions, _materialColors);
return g3d;
}
slice(instance) {
var _a;
const matrix = this.instanceTransforms.slice(instance * 16, (instance + 1) * 16);
const mesh = this.instanceMeshes[instance];
const flags = (_a = this.instanceFlags[instance]) !== null && _a !== void 0 ? _a : 0;
const _instanceTransforms = new Float32Array([...matrix]);
const _instanceMeshes = new Int32Array([mesh >= 0 ? 0 : -1]);
const _instanceFlags = new Uint16Array([flags]);
if (mesh < 0) {
return new G3d(_instanceMeshes, _instanceFlags, _instanceTransforms, new Int32Array([instance]), new Int32Array(), new Int32Array(), new Int32Array(), new Uint32Array(), new Float32Array(), new Float32Array());
}
const _meshSubmeshes = new Int32Array([0]);
// Submeshes
const submeshStart = this.getMeshSubmeshStart(mesh);
const submeshEnd = this.getMeshSubmeshEnd(mesh);
const originalOffsets = this.submeshIndexOffset.slice(submeshStart, submeshEnd);
const firstOffset = originalOffsets[0];
const _submeshIndexOffsets = originalOffsets.map(i => i - firstOffset);
// Vertices
const _indices = this.indices.slice(this.getMeshIndexStart(mesh), this.getMeshIndexEnd(mesh));
const _vertices = this.positions.slice(this.getMeshVertexStart(mesh) * 3, this.getMeshVertexEnd(mesh) * 3);
const _submeshMaterials = this.submeshMaterial.slice(submeshStart, submeshEnd);
const materialSet = new Set(_submeshMaterials);
const materialMap = new Map();
const _materialColors = new Float32Array(materialSet.size * 4);
let mat_i = 0;
for (let i = 0; i < this.getMaterialCount(); i++) {
if (materialSet.has(i)) {
materialMap.set(i, mat_i);
_materialColors.set(this.materialColors.slice(i * 4, (i + 1) * 4), mat_i * 4);
mat_i++;
}
}
for (let i = 0; i < _submeshMaterials.length; i++) {
_submeshMaterials[i] = _submeshMaterials[i] < 0 ? -1 : materialMap.get(_submeshMaterials[i]);
}
return new G3d(_instanceMeshes, _instanceFlags, _instanceTransforms, new Int32Array([instance]), _meshSubmeshes, _submeshIndexOffsets, _submeshMaterials, _indices, _vertices, _materialColors);
return this.filter([instance]);
}

@@ -715,4 +673,4 @@ filter(instances) {

// 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);
}

@@ -729,8 +687,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);
}

@@ -780,4 +738,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);
}

@@ -799,1 +757,4 @@ console.assert(this.meshInstances.length === this.getMeshCount());

exports.G3d = G3d;
G3d.MATRIX_SIZE = 16;
G3d.COLOR_SIZE = 4;
G3d.POSITION_SIZE = 3;
import { BFast } from "./bfast";
import { G3d, G3dAttributeDescriptor, MeshSection, TypedArray } from "./g3d";
import { G3d, G3dAttributeDescriptor, TypedArray } from "./g3d";
declare class G3dRemoteAttribute {

@@ -7,7 +7,7 @@ descriptor: G3dAttributeDescriptor;

constructor(descriptor: G3dAttributeDescriptor, bfast: BFast);
getAll(): Promise<TypedArray>;
getAll<T extends TypedArray>(): Promise<T>;
getByte(index: number): Promise<number>;
getNumber(index: number): Promise<number>;
getValue(index: number): Promise<Int8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array>;
getValues(index: number, count: number): Promise<Int8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array>;
getValue<T extends TypedArray>(index: number): Promise<T>;
getValues<T extends TypedArray>(index: number, count: number): Promise<T>;
getCount(): Promise<number>;

@@ -42,6 +42,2 @@ static fromString(description: string, bfast: BFast): G3dRemoteAttribute;

materialColors: G3dRemoteAttribute;
MATRIX_SIZE: number;
COLOR_SIZE: number;
POSITION_SIZE: number;
DEFAULT_COLOR: Float32Array;
constructor(g3d: RemoteAbstractG3d);

@@ -52,9 +48,9 @@ static createFromBfast(bfast: BFast): RemoteG3d;

getSubmeshCount: () => Promise<number>;
getMeshIndexStart(mesh: number, section?: MeshSection): Promise<number>;
getMeshIndexEnd(mesh: number, section?: MeshSection): Promise<number>;
getMeshIndexCount(mesh: number, section?: MeshSection): Promise<number>;
getMeshIndexStart(mesh: number): Promise<number>;
getMeshIndexEnd(mesh: number): Promise<number>;
getMeshIndexCount(mesh: number): Promise<number>;
getMeshIndices(mesh: number): Promise<Uint32Array>;
getMeshSubmeshEnd(mesh: number, section?: MeshSection): Promise<number>;
getMeshSubmeshStart(mesh: number, section?: MeshSection): Promise<number>;
getMeshSubmeshCount(mesh: number, section?: MeshSection): Promise<number>;
getMeshSubmeshEnd(mesh: number): Promise<number>;
getMeshSubmeshStart(mesh: number): Promise<number>;
getMeshSubmeshCount(mesh: number): Promise<number>;
getSubmeshIndexStart(submesh: number): Promise<number>;

@@ -61,0 +57,0 @@ getSubmeshIndexEnd(submesh: number): Promise<number>;

@@ -40,3 +40,4 @@ "use strict";

return __awaiter(this, void 0, void 0, function* () {
return yield this.bfast.getValues(this.descriptor.description, index * this.descriptor.dataArity, this.descriptor.dataArity);
const value = yield this.bfast.getValues(this.descriptor.description, index * this.descriptor.dataArity, this.descriptor.dataArity);
return value;
});

@@ -46,3 +47,4 @@ }

return __awaiter(this, void 0, void 0, function* () {
return yield this.bfast.getValues(this.descriptor.description, index * this.descriptor.dataArity, count * this.descriptor.dataArity);
const value = yield this.bfast.getValues(this.descriptor.description, index * this.descriptor.dataArity, count * this.descriptor.dataArity);
return value;
});

@@ -90,7 +92,2 @@ }

constructor(g3d) {
// consts
this.MATRIX_SIZE = 16;
this.COLOR_SIZE = 4;
this.POSITION_SIZE = 3;
this.DEFAULT_COLOR = new Float32Array([1, 1, 1, 1]);
// ------------- All -----------------

@@ -117,18 +114,18 @@ this.getVertexCount = () => this.positions.getCount();

}
getMeshIndexStart(mesh, section = 'all') {
getMeshIndexStart(mesh) {
return __awaiter(this, void 0, void 0, function* () {
const sub = yield this.getMeshSubmeshStart(mesh, section);
const sub = yield this.getMeshSubmeshStart(mesh);
return this.getSubmeshIndexStart(sub);
});
}
getMeshIndexEnd(mesh, section = 'all') {
getMeshIndexEnd(mesh) {
return __awaiter(this, void 0, void 0, function* () {
const sub = yield this.getMeshSubmeshEnd(mesh, section);
const sub = yield this.getMeshSubmeshEnd(mesh);
return this.getSubmeshIndexEnd(sub - 1);
});
}
getMeshIndexCount(mesh, section = 'all') {
getMeshIndexCount(mesh) {
return __awaiter(this, void 0, void 0, function* () {
const start = yield this.getMeshIndexStart(mesh, section);
const end = yield this.getMeshIndexEnd(mesh, section);
const start = yield this.getMeshIndexStart(mesh);
const end = yield this.getMeshIndexEnd(mesh);
return end - start;

@@ -145,3 +142,3 @@ });

}
getMeshSubmeshEnd(mesh, section = 'all') {
getMeshSubmeshEnd(mesh) {
return __awaiter(this, void 0, void 0, function* () {

@@ -155,3 +152,3 @@ const meshCount = yield this.getMeshCount();

}
getMeshSubmeshStart(mesh, section = 'all') {
getMeshSubmeshStart(mesh) {
return __awaiter(this, void 0, void 0, function* () {

@@ -161,6 +158,6 @@ return this.meshSubmeshes.getNumber(mesh);

}
getMeshSubmeshCount(mesh, section = 'all') {
getMeshSubmeshCount(mesh) {
return __awaiter(this, void 0, void 0, function* () {
const end = yield this.getMeshSubmeshEnd(mesh, section);
const start = yield this.getMeshSubmeshStart(mesh, section);
const end = yield this.getMeshSubmeshEnd(mesh);
const start = yield this.getMeshSubmeshStart(mesh);
return end - start;

@@ -195,67 +192,20 @@ });

return __awaiter(this, void 0, void 0, function* () {
const _instanceMeshes = yield this.instanceMeshes.getAll();
const _instanceFlags = yield this.instanceFlags.getAll();
const _instanceTransforms = yield this.instanceTransforms.getAll();
const _meshSubmeshes = yield this.meshSubmeshes.getAll();
const _submeshIndexOffsets = yield this.submeshIndexOffsets.getAll();
const _submeshMaterials = yield this.submeshMaterials.getAll();
const _indices = yield this.indices.getAll();
const _positions = yield this.positions.getAll();
const _materialColors = yield this.materialColors.getAll();
const g3d = new g3d_1.G3d(_instanceMeshes, _instanceFlags, _instanceTransforms, undefined, _meshSubmeshes, _submeshIndexOffsets, _submeshMaterials, _indices, _positions, _materialColors);
return g3d;
const attributes = yield Promise.all([
this.instanceMeshes.getAll(),
this.instanceFlags.getAll(),
this.instanceTransforms.getAll(),
Promise.resolve(undefined),
this.meshSubmeshes.getAll(),
this.submeshIndexOffsets.getAll(),
this.submeshMaterials.getAll(),
this.indices.getAll(),
this.positions.getAll(),
this.materialColors.getAll(),
]);
return new g3d_1.G3d(...attributes);
});
}
slice(instance) {
var _a, _b;
return __awaiter(this, void 0, void 0, function* () {
const mesh = yield this.instanceMeshes.getNumber(instance);
const flags = (_a = yield this.instanceFlags.getNumber(instance)) !== null && _a !== void 0 ? _a : 0;
const _instanceTransforms = yield this.instanceTransforms.getValue(instance);
const _instanceMeshes = new Int32Array([mesh >= 0 ? 0 : -1]);
const _instanceFlags = new Uint16Array([flags]);
if (mesh >= 0) {
const _meshSubmeshes = new Int32Array([0]);
const submeshStart = yield this.getMeshSubmeshStart(mesh);
const submeshEnd = yield this.getMeshSubmeshEnd(mesh);
const originalOffsets = yield this.submeshIndexOffsets.getValues(submeshStart, submeshEnd - submeshStart);
const firstOffset = originalOffsets[0];
const _submeshIndexOffsets = originalOffsets.map(i => i - firstOffset);
const originalSubmeshMaterials = yield this.submeshMaterials.getValues(submeshStart, submeshEnd - submeshStart);
const map = new Map();
originalSubmeshMaterials.forEach((m, i) => {
var _a;
const set = (_a = map.get(m)) !== null && _a !== void 0 ? _a : [];
set.push(i);
map.set(m, set);
});
const _submeshMaterials = new Int32Array(map.size);
(_b = map.get(-1)) === null || _b === void 0 ? void 0 : _b.forEach(s => _submeshMaterials[s] = -1);
const mapAsArray = Array.from(map).filter(pair => pair[0] >= 0);
const materialColors = [];
yield Promise.all(mapAsArray.map(([mat, set], index) => __awaiter(this, void 0, void 0, function* () {
if (mat >= 0) {
const color = yield this.materialColors.getValue(mat);
color.forEach(v => materialColors.push(v));
}
set.forEach((s) => _submeshMaterials[s] = index);
})));
const _materialColors = new Float32Array(materialColors);
const indices = yield this.getMeshIndices(mesh);
//get min and max vertex
let minVertex = Number.MAX_SAFE_INTEGER;
let maxVertex = Number.MIN_SAFE_INTEGER;
for (let i = 0; i < indices.length; i++) {
minVertex = Math.min(minVertex, indices[i]);
maxVertex = Math.max(maxVertex, indices[i]);
}
//rebase indices i-min
const _localIndices = new Uint32Array(indices.map(i => (i - minVertex)).buffer);
//slice vertices from min to max.
const _vertices = yield this.positions.getValues(minVertex, maxVertex - minVertex + 1);
return new g3d_1.G3d(_instanceMeshes, _instanceFlags, _instanceTransforms, new Int32Array([instance]), _meshSubmeshes, _submeshIndexOffsets, _submeshMaterials, _localIndices, _vertices, _materialColors);
}
else {
return new g3d_1.G3d(_instanceMeshes, _instanceFlags, _instanceTransforms, new Int32Array([instance]), new Int32Array(), new Int32Array(), new Int32Array(), new Uint32Array(), new Float32Array(), new Float32Array());
}
return this.filter([instance]);
});

@@ -365,7 +315,5 @@ }

continue;
let indexStart;
let indexEnd;
yield Promise.all([
this.getMeshIndexStart(mesh).then(v => indexStart = v),
this.getMeshIndexEnd(mesh).then(v => indexEnd = v)
const [indexStart, indexEnd] = yield Promise.all([
this.getMeshIndexStart(mesh),
this.getMeshIndexEnd(mesh)
]);

@@ -399,3 +347,3 @@ const indices = yield this.indices.getValues(indexStart, indexEnd - indexStart);

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 = [];

@@ -410,3 +358,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++;

@@ -430,3 +378,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++;

@@ -506,4 +454,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);
}
}

@@ -49,3 +49,3 @@ /**

static instanceTransforms: string;
static instanceElements: string;
static instanceNodes: string;
static instanceFlags: string;

@@ -80,5 +80,5 @@ static meshSubmeshes: string;

rawG3d: AbstractG3d;
MATRIX_SIZE: number;
COLOR_SIZE: number;
POSITION_SIZE: number;
static MATRIX_SIZE: number;
static COLOR_SIZE: number;
static POSITION_SIZE: number;
/**

@@ -88,3 +88,3 @@ * Opaque white

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);
constructor(instanceMeshes: Int32Array, instanceFlags: Uint16Array | undefined, instanceTransforms: Float32Array, instanceNodes: Int32Array | undefined, meshSubmeshes: Int32Array, submeshIndexOffsets: Int32Array, submeshMaterials: Int32Array, indices: Int32Array | Uint32Array, positions: Float32Array, materialColors: Float32Array);
static createFromAbstract(g3d: AbstractG3d): G3d;

@@ -91,0 +91,0 @@ static createFromBfast(bfast: BFast): Promise<G3d>;

import { BFast } from "./bfast";
import { G3d, G3dAttributeDescriptor, MeshSection, TypedArray } from "./g3d";
import { G3d, G3dAttributeDescriptor, TypedArray } from "./g3d";
declare class G3dRemoteAttribute {

@@ -7,7 +7,7 @@ descriptor: G3dAttributeDescriptor;

constructor(descriptor: G3dAttributeDescriptor, bfast: BFast);
getAll(): Promise<TypedArray>;
getAll<T extends TypedArray>(): Promise<T>;
getByte(index: number): Promise<number>;
getNumber(index: number): Promise<number>;
getValue(index: number): Promise<Int8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array>;
getValues(index: number, count: number): Promise<Int8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array>;
getValue<T extends TypedArray>(index: number): Promise<T>;
getValues<T extends TypedArray>(index: number, count: number): Promise<T>;
getCount(): Promise<number>;

@@ -42,6 +42,2 @@ static fromString(description: string, bfast: BFast): G3dRemoteAttribute;

materialColors: G3dRemoteAttribute;
MATRIX_SIZE: number;
COLOR_SIZE: number;
POSITION_SIZE: number;
DEFAULT_COLOR: Float32Array;
constructor(g3d: RemoteAbstractG3d);

@@ -52,9 +48,9 @@ static createFromBfast(bfast: BFast): RemoteG3d;

getSubmeshCount: () => Promise<number>;
getMeshIndexStart(mesh: number, section?: MeshSection): Promise<number>;
getMeshIndexEnd(mesh: number, section?: MeshSection): Promise<number>;
getMeshIndexCount(mesh: number, section?: MeshSection): Promise<number>;
getMeshIndexStart(mesh: number): Promise<number>;
getMeshIndexEnd(mesh: number): Promise<number>;
getMeshIndexCount(mesh: number): Promise<number>;
getMeshIndices(mesh: number): Promise<Uint32Array>;
getMeshSubmeshEnd(mesh: number, section?: MeshSection): Promise<number>;
getMeshSubmeshStart(mesh: number, section?: MeshSection): Promise<number>;
getMeshSubmeshCount(mesh: number, section?: MeshSection): Promise<number>;
getMeshSubmeshEnd(mesh: number): Promise<number>;
getMeshSubmeshStart(mesh: number): Promise<number>;
getMeshSubmeshCount(mesh: number): Promise<number>;
getSubmeshIndexStart(submesh: number): Promise<number>;

@@ -61,0 +57,0 @@ getSubmeshIndexEnd(submesh: number): Promise<number>;

{
"name": "vim-format",
"version": "1.0.2-dev.27",
"version": "1.0.2-dev.28",
"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": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc