quake2ts 0.0.178 → 0.0.180

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4601,19 +4601,42 @@ function createBspSurfaces(map) {
4601
4601
  indices: new Uint16Array(indices),
4602
4602
  texture: texInfo.texture,
4603
4603
  surfaceFlags: texInfo.flags,
4604
- lightmap: lightmapData
4604
+ lightmap: lightmapData,
4605
+ faceIndex
4605
4606
  });
4606
4607
  }
4607
4608
  return results;
4608
4609
  }
4609
- function buildBspGeometry(gl, surfaces, options = {}) {
4610
+ function buildBspGeometry(gl, surfaces, map, options = {}) {
4611
+ let filteredSurfaces = surfaces;
4612
+ if (map && options.hiddenClassnames && options.hiddenClassnames.size > 0) {
4613
+ const hiddenFaces = /* @__PURE__ */ new Set();
4614
+ for (const entity of map.entities.entities) {
4615
+ if (entity.classname && options.hiddenClassnames.has(entity.classname)) {
4616
+ const modelProp = entity.properties["model"];
4617
+ if (modelProp && modelProp.startsWith("*")) {
4618
+ const modelIndex = parseInt(modelProp.substring(1), 10);
4619
+ if (!isNaN(modelIndex) && modelIndex >= 0 && modelIndex < map.models.length) {
4620
+ const model = map.models[modelIndex];
4621
+ for (let i = 0; i < model.numFaces; i++) {
4622
+ hiddenFaces.add(model.firstFace + i);
4623
+ }
4624
+ }
4625
+ }
4626
+ }
4627
+ }
4628
+ if (hiddenFaces.size > 0) {
4629
+ filteredSurfaces = surfaces.filter((s) => !hiddenFaces.has(s.faceIndex));
4630
+ }
4631
+ }
4610
4632
  const resolved = {
4611
4633
  atlasSize: options.atlasSize ?? 1024,
4612
- lightmapPadding: options.lightmapPadding ?? 1
4634
+ lightmapPadding: options.lightmapPadding ?? 1,
4635
+ hiddenClassnames: options.hiddenClassnames ?? /* @__PURE__ */ new Set()
4613
4636
  };
4614
4637
  const atlasBuilders = [];
4615
4638
  const placements = /* @__PURE__ */ new Map();
4616
- surfaces.forEach((surface, index) => {
4639
+ filteredSurfaces.forEach((surface, index) => {
4617
4640
  if (!surface.lightmap) {
4618
4641
  return;
4619
4642
  }
@@ -4639,7 +4662,7 @@ function buildBspGeometry(gl, surfaces, options = {}) {
4639
4662
  texture.uploadImage(0, gl.RGBA, builder.width, builder.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, builder.data);
4640
4663
  return { texture, width: builder.width, height: builder.height, pixels: builder.data };
4641
4664
  });
4642
- const results = surfaces.map((surface, index) => {
4665
+ const results = filteredSurfaces.map((surface, index) => {
4643
4666
  const placement = placements.get(index);
4644
4667
  const vertexData = buildVertexData(surface, placement);
4645
4668
  const indexData = ensureIndexArray(surface.indices, vertexData.length / 7);