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.
@@ -4787,19 +4787,42 @@ function createBspSurfaces(map) {
4787
4787
  indices: new Uint16Array(indices),
4788
4788
  texture: texInfo.texture,
4789
4789
  surfaceFlags: texInfo.flags,
4790
- lightmap: lightmapData
4790
+ lightmap: lightmapData,
4791
+ faceIndex
4791
4792
  });
4792
4793
  }
4793
4794
  return results;
4794
4795
  }
4795
- function buildBspGeometry(gl, surfaces, options = {}) {
4796
+ function buildBspGeometry(gl, surfaces, map, options = {}) {
4797
+ let filteredSurfaces = surfaces;
4798
+ if (map && options.hiddenClassnames && options.hiddenClassnames.size > 0) {
4799
+ const hiddenFaces = /* @__PURE__ */ new Set();
4800
+ for (const entity of map.entities.entities) {
4801
+ if (entity.classname && options.hiddenClassnames.has(entity.classname)) {
4802
+ const modelProp = entity.properties["model"];
4803
+ if (modelProp && modelProp.startsWith("*")) {
4804
+ const modelIndex = parseInt(modelProp.substring(1), 10);
4805
+ if (!isNaN(modelIndex) && modelIndex >= 0 && modelIndex < map.models.length) {
4806
+ const model = map.models[modelIndex];
4807
+ for (let i = 0; i < model.numFaces; i++) {
4808
+ hiddenFaces.add(model.firstFace + i);
4809
+ }
4810
+ }
4811
+ }
4812
+ }
4813
+ }
4814
+ if (hiddenFaces.size > 0) {
4815
+ filteredSurfaces = surfaces.filter((s) => !hiddenFaces.has(s.faceIndex));
4816
+ }
4817
+ }
4796
4818
  const resolved = {
4797
4819
  atlasSize: options.atlasSize ?? 1024,
4798
- lightmapPadding: options.lightmapPadding ?? 1
4820
+ lightmapPadding: options.lightmapPadding ?? 1,
4821
+ hiddenClassnames: options.hiddenClassnames ?? /* @__PURE__ */ new Set()
4799
4822
  };
4800
4823
  const atlasBuilders = [];
4801
4824
  const placements = /* @__PURE__ */ new Map();
4802
- surfaces.forEach((surface, index) => {
4825
+ filteredSurfaces.forEach((surface, index) => {
4803
4826
  if (!surface.lightmap) {
4804
4827
  return;
4805
4828
  }
@@ -4825,7 +4848,7 @@ function buildBspGeometry(gl, surfaces, options = {}) {
4825
4848
  texture.uploadImage(0, gl.RGBA, builder.width, builder.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, builder.data);
4826
4849
  return { texture, width: builder.width, height: builder.height, pixels: builder.data };
4827
4850
  });
4828
- const results = surfaces.map((surface, index) => {
4851
+ const results = filteredSurfaces.map((surface, index) => {
4829
4852
  const placement = placements.get(index);
4830
4853
  const vertexData = buildVertexData(surface, placement);
4831
4854
  const indexData = ensureIndexArray(surface.indices, vertexData.length / 7);