@drawcall/charta 0.1.29 → 0.1.31

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.
@@ -1 +1 @@
1
- {"version":3,"file":"grammar.d.ts","sourceRoot":"","sources":["../src/grammar.ts"],"names":[],"mappings":"AAOA,UAAU,YAAY;IACpB,KAAK,EAAE,GAAG,CAAC;IACX,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,UAAU,YAAY;IACpB,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;IAC1C,IAAI,EAAE,MAAM,YAAY,GAAG,SAAS,CAAC;IACrC,IAAI,EAAE,MAAM,GAAG,CAAC;IAChB,WAAW,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,CAAC;IACtC,GAAG,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC;CACrC;AAED,UAAU,WAAW;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,EAAE,KAAK,GAAG,CAAC;CAC5D;AAED,KAAK,aAAa,GAAG,MAAM,GAAG;IAAE,OAAO,EAAE,GAAG,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAA;CAAE,CAAC;AAEnF,UAAU,OAAO;IACf,KAAK,EAAE,YAAY,GAAG,SAAS,CAAC;IAChC,WAAW,EAAE,WAAW,EAAE,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,QAAA,MAAM,OAAO,EAAE,OAuEd,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"grammar.d.ts","sourceRoot":"","sources":["../src/grammar.ts"],"names":[],"mappings":"AAOA,UAAU,YAAY;IACpB,KAAK,EAAE,GAAG,CAAC;IACX,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,UAAU,YAAY;IACpB,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;IAC1C,IAAI,EAAE,MAAM,YAAY,GAAG,SAAS,CAAC;IACrC,IAAI,EAAE,MAAM,GAAG,CAAC;IAChB,WAAW,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,CAAC;IACtC,GAAG,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC;CACrC;AAED,UAAU,WAAW;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,EAAE,KAAK,GAAG,CAAC;CAC5D;AAED,KAAK,aAAa,GAAG,MAAM,GAAG;IAAE,OAAO,EAAE,GAAG,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAA;CAAE,CAAC;AAEnF,UAAU,OAAO;IACf,KAAK,EAAE,YAAY,GAAG,SAAS,CAAC;IAChC,WAAW,EAAE,WAAW,EAAE,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,QAAA,MAAM,OAAO,EAAE,OAiEd,CAAC;AAEF,eAAe,OAAO,CAAC"}
package/dist/grammar.js CHANGED
@@ -17,32 +17,30 @@ const grammar = {
17
17
  { "name": "Rows$ebnf$1", "symbols": [] },
18
18
  { "name": "Rows$ebnf$1$subexpression$1", "symbols": ["NL", "Row"] },
19
19
  { "name": "Rows$ebnf$1", "symbols": ["Rows$ebnf$1", "Rows$ebnf$1$subexpression$1"], "postprocess": (d) => d[0].concat([d[1]]) },
20
- { "name": "Rows", "symbols": ["Row", "Rows$ebnf$1"], "postprocess": ([head, tail]) => [head, ...tail.map(([, row]) => row)] },
21
- { "name": "Row", "symbols": ["_", "CellList", "_"], "postprocess": (d, loc) => { const row = d[1]; row.offset = loc; return row; } },
20
+ { "name": "Rows", "symbols": ["Row", "Rows$ebnf$1"], "postprocess": ([h, t]) => [h, ...t.map((x) => x[1])] },
21
+ { "name": "Row", "symbols": ["CellList"], "postprocess": (d, loc) => { const r = d[0]; r.offset = loc; return r; } },
22
22
  { "name": "CellList$ebnf$1", "symbols": [] },
23
- { "name": "CellList$ebnf$1$subexpression$1", "symbols": ["PIPE", "Cell"] },
23
+ { "name": "CellList$ebnf$1$subexpression$1", "symbols": [{ "literal": "|" }, "Cell"] },
24
24
  { "name": "CellList$ebnf$1", "symbols": ["CellList$ebnf$1", "CellList$ebnf$1$subexpression$1"], "postprocess": (d) => d[0].concat([d[1]]) },
25
- { "name": "CellList", "symbols": ["Cell", "CellList$ebnf$1"], "postprocess": ([head, tail]) => [head, ...tail.map(([, cell]) => cell)] },
26
- { "name": "Cell$ebnf$1", "symbols": ["CallList"], "postprocess": id },
27
- { "name": "Cell$ebnf$1", "symbols": [], "postprocess": () => null },
28
- { "name": "Cell", "symbols": ["Cell$ebnf$1"], "postprocess": (d) => d[0] || [] },
25
+ { "name": "CellList", "symbols": ["Cell", "CellList$ebnf$1"], "postprocess": ([h, t]) => [h, ...t.map((x) => x[1])] },
26
+ { "name": "Cell", "symbols": ["_", "CallList", "_"], "postprocess": (d) => d[1] },
27
+ { "name": "Cell", "symbols": ["_"], "postprocess": () => [] },
29
28
  { "name": "CallList$ebnf$1", "symbols": [] },
30
29
  { "name": "CallList$ebnf$1$subexpression$1", "symbols": ["__", "Call"] },
31
30
  { "name": "CallList$ebnf$1", "symbols": ["CallList$ebnf$1", "CallList$ebnf$1$subexpression$1"], "postprocess": (d) => d[0].concat([d[1]]) },
32
- { "name": "CallList", "symbols": ["Call", "CallList$ebnf$1"], "postprocess": ([first, rest]) => [first, ...rest.map(([, c]) => c)] },
31
+ { "name": "CallList", "symbols": ["Call", "CallList$ebnf$1"], "postprocess": ([f, r]) => [f, ...r.map((x) => x[1])] },
33
32
  { "name": "Call", "symbols": ["Ident", { "literal": "(" }, "Args", { "literal": ")" }], "postprocess": (d, loc) => ({
34
33
  name: d[0],
35
34
  locationParams: d[2].pos,
36
35
  keyParams: d[2].kv,
37
36
  offset: loc
38
37
  }) },
39
- { "name": "Args$ebnf$1", "symbols": ["ArgItems"], "postprocess": id },
40
- { "name": "Args$ebnf$1", "symbols": [], "postprocess": () => null },
41
- { "name": "Args", "symbols": ["_", "Args$ebnf$1", "_"], "postprocess": (d) => d[1] || { pos: [], kv: [] } },
42
- { "name": "ArgItems$ebnf$1", "symbols": [] },
43
- { "name": "ArgItems$ebnf$1$subexpression$1", "symbols": ["COMMA", "Arg"] },
44
- { "name": "ArgItems$ebnf$1", "symbols": ["ArgItems$ebnf$1", "ArgItems$ebnf$1$subexpression$1"], "postprocess": (d) => d[0].concat([d[1]]) },
45
- { "name": "ArgItems", "symbols": ["Arg", "ArgItems$ebnf$1"], "postprocess": (d) => {
38
+ { "name": "Args", "symbols": ["_", "ArgList", "_"], "postprocess": (d) => d[1] },
39
+ { "name": "Args", "symbols": ["_"], "postprocess": () => ({ pos: [], kv: [] }) },
40
+ { "name": "ArgList$ebnf$1", "symbols": [] },
41
+ { "name": "ArgList$ebnf$1$subexpression$1", "symbols": ["COMMA", "Arg"] },
42
+ { "name": "ArgList$ebnf$1", "symbols": ["ArgList$ebnf$1", "ArgList$ebnf$1$subexpression$1"], "postprocess": (d) => d[0].concat([d[1]]) },
43
+ { "name": "ArgList", "symbols": ["Arg", "ArgList$ebnf$1"], "postprocess": (d) => {
46
44
  const items = [d[0], ...d[1].map((x) => x[1])];
47
45
  const pos = [];
48
46
  const kv = [];
@@ -56,21 +54,17 @@ const grammar = {
56
54
  } },
57
55
  { "name": "Arg", "symbols": ["Ident", "_", { "literal": "=" }, "_", "Value"], "postprocess": (d) => ({ kind: 'kv', key: d[0], value: d[4] }) },
58
56
  { "name": "Arg", "symbols": ["Value"], "postprocess": (d) => d[0] },
59
- { "name": "Value", "symbols": [{ "literal": "\"" }, "QuotedContent", { "literal": "\"" }], "postprocess": (d) => d[1] },
60
- { "name": "Value", "symbols": ["UnquotedValue"], "postprocess": (d) => d[0] },
61
- { "name": "QuotedContent$ebnf$1", "symbols": [] },
62
- { "name": "QuotedContent$ebnf$1", "symbols": ["QuotedContent$ebnf$1", /[^"]/], "postprocess": (d) => d[0].concat([d[1]]) },
63
- { "name": "QuotedContent", "symbols": ["QuotedContent$ebnf$1"], "postprocess": (d) => d[0].join("") },
64
- { "name": "UnquotedValue$ebnf$1", "symbols": ["UnquotedChar"] },
65
- { "name": "UnquotedValue$ebnf$1", "symbols": ["UnquotedValue$ebnf$1", "UnquotedChar"], "postprocess": (d) => d[0].concat([d[1]]) },
66
- { "name": "UnquotedValue", "symbols": ["UnquotedValue$ebnf$1"], "postprocess": (d) => d[0].join("") },
67
- { "name": "UnquotedChar", "symbols": [/[^ \t,()=|\n"]/] },
57
+ { "name": "Value", "symbols": [{ "literal": "\"" }, "QuotedChars", { "literal": "\"" }], "postprocess": (d) => d[1] },
58
+ { "name": "Value", "symbols": ["UnquotedChars"], "postprocess": (d) => d[0] },
59
+ { "name": "QuotedChars$ebnf$1", "symbols": [] },
60
+ { "name": "QuotedChars$ebnf$1", "symbols": ["QuotedChars$ebnf$1", /[^"]/], "postprocess": (d) => d[0].concat([d[1]]) },
61
+ { "name": "QuotedChars", "symbols": ["QuotedChars$ebnf$1"], "postprocess": (d) => d[0].join("") },
62
+ { "name": "UnquotedChars$ebnf$1", "symbols": [/[^ \t,()=|\n"]/] },
63
+ { "name": "UnquotedChars$ebnf$1", "symbols": ["UnquotedChars$ebnf$1", /[^ \t,()=|\n"]/], "postprocess": (d) => d[0].concat([d[1]]) },
64
+ { "name": "UnquotedChars", "symbols": ["UnquotedChars$ebnf$1"], "postprocess": (d) => d[0].join("") },
68
65
  { "name": "Ident$ebnf$1", "symbols": [] },
69
- { "name": "Ident$ebnf$1", "symbols": ["Ident$ebnf$1", "IdentRest"], "postprocess": (d) => d[0].concat([d[1]]) },
70
- { "name": "Ident", "symbols": ["IdentStart", "Ident$ebnf$1"], "postprocess": ([s, r]) => s + r.join("") },
71
- { "name": "IdentStart", "symbols": [/[a-z_\/]/] },
72
- { "name": "IdentRest", "symbols": [/[a-z0-9A-Z_\/-]/] },
73
- { "name": "PIPE", "symbols": ["_", { "literal": "|" }, "_"], "postprocess": () => null },
66
+ { "name": "Ident$ebnf$1", "symbols": ["Ident$ebnf$1", /[a-z0-9A-Z_\/-]/], "postprocess": (d) => d[0].concat([d[1]]) },
67
+ { "name": "Ident", "symbols": [/[a-z_\/]/, "Ident$ebnf$1"], "postprocess": ([s, r]) => s + r.join("") },
74
68
  { "name": "COMMA", "symbols": ["_", { "literal": "," }, "_"], "postprocess": () => null },
75
69
  { "name": "NL", "symbols": [{ "literal": "\n" }], "postprocess": () => null },
76
70
  { "name": "_$ebnf$1", "symbols": [] },
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/grass/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,aAAa,EACb,QAAQ,EAMT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAsB,KAAK,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAI9E,cAAc,eAAe,CAAC;AAK9B,MAAM,MAAM,YAAY,GAAG,oBAAoB,GAAG;IAChD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,qBAAa,SAAU,SAAQ,aAAa;gBAExC,WAAW,EAAE,WAAW,EACxB,QAAQ,GAAE,QAAkC,EAC5C,IAAI,GAAE,YAAiB;CAyP1B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/grass/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,aAAa,EACb,QAAQ,EAMT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAsB,KAAK,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAI9E,cAAc,eAAe,CAAC;AAK9B,MAAM,MAAM,YAAY,GAAG,oBAAoB,GAAG;IAChD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,qBAAa,SAAU,SAAQ,aAAa;gBAExC,WAAW,EAAE,WAAW,EACxB,QAAQ,GAAE,QAAkC,EAC5C,IAAI,GAAE,YAAiB;CA4P1B"}
@@ -151,9 +151,12 @@ export class GrassMesh extends InstancedMesh {
151
151
  const jz = (Math.random() * 2 - 1) * jitterAmp;
152
152
  const px = cx + offsetX + jx;
153
153
  const pz = cz + offsetZ + jz;
154
- let baseY = 0;
155
- if (tilesGeometry) {
156
- baseY = tilesGeometry.getHeightAt({ row, col, offsetX: offsetX + jx, offsetZ: offsetZ + jz }, { stackIndex: topStackIndex });
154
+ if (tilesGeometry == null) {
155
+ throw new Error("Missing tilesGeometry in grass generation. Did you forget to initialize the TilesMesh beforehand.");
156
+ }
157
+ const baseY = tilesGeometry.getHeightAt({ row, col, offsetX: offsetX + jx, offsetZ: offsetZ + jz }, { stackIndex: topStackIndex });
158
+ if (baseY == null) {
159
+ throw new Error(`Grass height missing at (row=${row}, col=${col}, x=${(offsetX + jx).toFixed(2)}, z=${(offsetZ + jz).toFixed(2)})`);
157
160
  }
158
161
  tmpPos.set(px, baseY, pz);
159
162
  // Scale
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/place/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAQ,MAAM,OAAO,CAAA;AACrF,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAO/C,MAAM,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAA;AAEvD,MAAM,MAAM,mBAAmB,GAAG,CAAC,IAAI,EAAE;IACvC,QAAQ,EAAE,OAAO,CAAA;IACjB,QAAQ,EAAE,UAAU,CAAA;IACpB,KAAK,EAAE,OAAO,CAAA;IACd,WAAW,EAAE,WAAW,CAAA;IACxB,IAAI,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,CAAA;IAC5D,IAAI,EAAE,MAAM,CAAA;CACb,KAAK,IAAI,CAAA;AAKV,wBAAgB,aAAa,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAOvD;AAED,qBAAa,kBAAkB;aAIX,UAAU,EAAE,OAAO;IACnC,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAJpC,SAAgB,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,CAAK;gBAG3B,UAAU,EAAE,OAAO,EAClB,iBAAiB,EAAE,CAAC,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,QAAQ;IAG5E,GAAG,CAAC,MAAM,EAAE,OAAO;IAKZ,KAAK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EAClB,iBAAiB,EAAE,CAAC,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,QAAQ;IAG5E,GAAG,CAAC,MAAM,EAAE,OAAO;IAKZ,KAAK,IAAI,QAAQ;CAGzB;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,sBAAsB,CAAC,EAAE,OAAO,CAAA;CACjC,CAAA;AAED,qBAAa,UAAW,SAAQ,KAAK;IACnC,SAAgB,aAAa,kCAAwC;gBAEzD,WAAW,EAAE,WAAW,EAAE,iBAAiB,CAAC,EAAE,QAAQ,EAAE,IAAI,GAAE,iBAAsB;IAgPhG,OAAO;CAOR"}
@@ -68,7 +68,11 @@ export class PlaceGroup extends Group {
68
68
  y = transformOpts.fixedY;
69
69
  }
70
70
  else {
71
- y = tilesGeometry.getHeightAt(gridCoord, { stackIndex: transformOpts.layerIndex, normalTarget: normal });
71
+ const heightAt = tilesGeometry.getHeightAt(gridCoord, { stackIndex: transformOpts.layerIndex, normalTarget: normal });
72
+ if (heightAt == null) {
73
+ throw new Error(`No ground height at (row=${gridCoord.row}, col=${gridCoord.col}, layerIndex=${transformOpts.layerIndex})`);
74
+ }
75
+ y = heightAt;
72
76
  }
73
77
  const { x, z } = interpreter.gridToWorld(gridCoord);
74
78
  const pos = new Vector3(x, y, z);
@@ -43,7 +43,7 @@ export declare class TilesGeometry extends BufferGeometry {
43
43
  bottom: Array<TileWallData>;
44
44
  left: Array<TileWallData>;
45
45
  }>>, mapSizeX: number, mapSizeZ: number);
46
- getHeightAt({ row, col, offsetX, offsetZ }: GridCoord, { normalTarget, stackIndex }?: GetHeightAtOptions): number;
46
+ getHeightAt({ row, col, offsetX, offsetZ }: GridCoord, { normalTarget, stackIndex }?: GetHeightAtOptions): number | undefined;
47
47
  private addVertex;
48
48
  private getVertices;
49
49
  private getConnectionVertexId;
@@ -1 +1 @@
1
- {"version":3,"file":"geometry.d.ts","sourceRoot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AAO,CAAC,QAAQ,CAAC,KAAK;aAQN,QAAQ,EAAE,MAAM;aAChB,QAAQ,EAAE,MAAM;IAxBlC,SAAgB,SAAS,EAAE,MAAM,CAAA;IACjC,SAAgB,SAAS,EAAE,MAAM,CAAA;IAEjC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA6B;IACtD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAoB;IAC9C,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAoB;IACxC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAoB;IAErD,OAAO,CAAC,SAAS,CAAI;IAErB,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAmC;IAChE,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAmC;gBAG7C,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAChC,KAAK,EAAE,KAAK,CAC3B,KAAK,CAAC;QACJ,GAAG,EAAE,KAAK,CAAC,YAAY,CAAC,CAAA;QACxB,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC,CAAA;QAC1B,MAAM,EAAE,KAAK,CAAC,YAAY,CAAC,CAAA;QAC3B,IAAI,EAAE,KAAK,CAAC,YAAY,CAAC,CAAA;KAC1B,CAAC,CACH,EACe,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM;IA0E3B,WAAW,CAChB,EAAE,GAAG,EAAE,GAAG,EAAE,OAAW,EAAE,OAAW,EAAE,EAAE,SAAS,EACjD,EAAE,YAAY,EAAE,UAAqB,EAAE,GAAE,kBAAuB;IA+ElE,OAAO,CAAC,SAAS;IAoGjB,OAAO,CAAC,WAAW;IAUnB,OAAO,CAAC,qBAAqB;CAiB9B"}
@@ -296,12 +296,12 @@ export class TilesGeometry extends BufferGeometry {
296
296
  }
297
297
  getHeightAt({ row, col, offsetX = 0, offsetZ = 0 }, { normalTarget, stackIndex = Infinity } = {}) {
298
298
  if (col < 0 || col >= this.tiles[0].length || row < 0 || row >= this.tiles.length) {
299
- throw new Error(`Tile index out of bounds: (row=${row}, col=${col}). Grid size: ${this.tiles.length}x${this.tiles[0].length}`);
299
+ return undefined;
300
300
  }
301
301
  const vertices = this.getVertices(col, row);
302
302
  const vertex1 = vertices[clamp(stackIndex, 0, vertices.length - 1)];
303
303
  if (vertex1 == null) {
304
- throw new Error(`No vertex found at stack index "${stackIndex ?? 'any'}" for tile (row=${row}, col=${col}).`);
304
+ return undefined;
305
305
  }
306
306
  const centerX = computeMeter('x', col, this.cellSizeX) - this.mapSizeX / 2;
307
307
  const centerZ = computeMeter('z', row, this.cellSizeZ) - this.mapSizeZ / 2;
@@ -14,7 +14,7 @@ export type TilesMeshOptions = {
14
14
  };
15
15
  export declare class TilesMesh extends Mesh<TilesGeometry> {
16
16
  constructor(interpreter: Interpreter, material?: Material, options?: TilesMeshOptions);
17
- getHeightAt(coord: GridCoord, options?: GetHeightAtOptions): number;
17
+ getHeightAt(coord: GridCoord, options?: GetHeightAtOptions): number | undefined;
18
18
  dispose(): void;
19
19
  }
20
20
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/walls/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAER,IAAI,EAGJ,YAAY,EAEZ,YAAY,EAOb,MAAM,OAAO,CAAA;AAEd,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAE/C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAGpD,OAAO,EAAe,aAAa,EAAE,MAAM,cAAc,CAAA;AAUzD,cAAc,eAAe,CAAA;AAK7B,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG;IACrB,CAAC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AAA;CACvB,CAAA;AAED,qBAAa,QAAS,SAAQ,IAAI;gBACpB,WAAW,EAAE,WAAW,EAAE,QAAQ,GAAE,QAAkC,EAAE,OAAO,GAAE,eAAoB;CAkTlH;AAED,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,WAGrG"}
@@ -123,7 +123,11 @@ export function computeWallVerticalBounds(interpreter, tilesGeometry, row, col,
123
123
  if (bottomLayer) {
124
124
  const offX = sX + (col - bottomLayer.col) * cellSize;
125
125
  const offZ = sZ + (row - bottomLayer.row) * cellSize;
126
- yStart[k] = tilesGeometry.getHeightAt({ row: bottomLayer.row, col: bottomLayer.col, offsetX: offX, offsetZ: offZ }, { stackIndex: bottomLayer.layerIdx });
126
+ const heightAt = tilesGeometry.getHeightAt({ row: bottomLayer.row, col: bottomLayer.col, offsetX: offX, offsetZ: offZ }, { stackIndex: bottomLayer.layerIdx });
127
+ if (heightAt == null) {
128
+ throw new Error(`Unable to sample height from TilesMesh for wall bottom at (row=${bottomLayer.row}, col=${bottomLayer.col}, layer=${bottomLayer.layerIdx})`);
129
+ }
130
+ yStart[k] = heightAt;
127
131
  }
128
132
  else {
129
133
  yStart[k] = parsed.bottomY;
@@ -132,7 +136,11 @@ export function computeWallVerticalBounds(interpreter, tilesGeometry, row, col,
132
136
  if (topLayer) {
133
137
  const offX = sX + (col - topLayer.col) * cellSize;
134
138
  const offZ = sZ + (row - topLayer.row) * cellSize;
135
- yEnd[k] = tilesGeometry.getHeightAt({ row: topLayer.row, col: topLayer.col, offsetX: offX, offsetZ: offZ }, { stackIndex: topLayer.layerIdx });
139
+ const heightAt = tilesGeometry.getHeightAt({ row: topLayer.row, col: topLayer.col, offsetX: offX, offsetZ: offZ }, { stackIndex: topLayer.layerIdx });
140
+ if (heightAt == null) {
141
+ throw new Error(`Unable to sample height from TilesMesh for wall top at (row=${topLayer.row}, col=${topLayer.col}, layer=${topLayer.layerIdx})`);
142
+ }
143
+ yEnd[k] = heightAt;
136
144
  }
137
145
  else {
138
146
  yEnd[k] = parsed.topY;
@@ -11,7 +11,7 @@ export type WaterMeshOptions = {
11
11
  };
12
12
  export declare class WaterMesh extends Mesh<TilesGeometry> {
13
13
  constructor(interpreter: Interpreter, options?: WaterMeshOptions);
14
- getHeightAt(coord: GridCoord, options?: GetHeightAtOptions): number;
14
+ getHeightAt(coord: GridCoord, options?: GetHeightAtOptions): number | undefined;
15
15
  dispose(): void;
16
16
  }
17
17
  export * from './texture.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drawcall/charta",
3
- "version": "0.1.29",
3
+ "version": "0.1.31",
4
4
  "author": "Bela Bohlender",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "homepage": "https://drawcall.ai",