@drawcall/charta 0.1.12 → 0.1.14
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.
- package/dist/assets/loader.d.ts.map +1 -1
- package/dist/assets/loader.js +1 -5
- package/dist/grass/index.d.ts.map +1 -1
- package/dist/grass/index.js +1 -6
- package/dist/interpreter.d.ts +3 -4
- package/dist/interpreter.d.ts.map +1 -1
- package/dist/interpreter.js +3 -3
- package/dist/locations.d.ts +3 -1
- package/dist/locations.d.ts.map +1 -1
- package/dist/locations.js +15 -7
- package/dist/pillars/index.d.ts.map +1 -1
- package/dist/pillars/index.js +1 -10
- package/dist/place/index.d.ts.map +1 -1
- package/dist/place/index.js +54 -28
- package/dist/schemas.d.ts +125 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +100 -0
- package/dist/tiles/index.d.ts +2 -9
- package/dist/tiles/index.d.ts.map +1 -1
- package/dist/tiles/index.js +2 -4
- package/dist/walls/index.d.ts +2 -25
- package/dist/walls/index.d.ts.map +1 -1
- package/dist/walls/index.js +2 -21
- package/dist/water/index.d.ts.map +1 -1
- package/dist/water/index.js +1 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/assets/loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiC,cAAc,EAAqB,MAAM,EAAW,MAAM,OAAO,CAAA;AAEzG,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/assets/loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiC,cAAc,EAAqB,MAAM,EAAW,MAAM,OAAO,CAAA;AAEzG,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAM/C,qBAAa,WAAY,SAAQ,MAAM,CAAC,IAAI,EAAE,WAAW,CAAC;IAIlB,OAAO,CAAC,QAAQ,CAAC,IAAI;IAH3D,OAAO,CAAC,aAAa,CAAe;IACpC,OAAO,CAAC,UAAU,CAAY;gBAElB,OAAO,CAAC,EAAE,cAAc,EAAmB,IAAI,GAAE,OAAe;IAM5E,IAAI,CACF,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,EAC5B,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,EAC3C,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,GAC/B,IAAI;YAuBO,iBAAiB;YA8BjB,eAAe;CAuC9B"}
|
package/dist/assets/loader.js
CHANGED
|
@@ -2,12 +2,8 @@ import { Texture, TextureLoader, Object3D, Loader, Vector3 } from 'three';
|
|
|
2
2
|
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
|
|
3
3
|
import { ChartaError } from '../errors.js';
|
|
4
4
|
import { InstancedMeshGroup } from '../utils/instanced-mesh-group.js';
|
|
5
|
-
import { object, string } from 'zod';
|
|
6
5
|
import { measureObject, PrefabBatchBuilder } from '../place/index.js';
|
|
7
|
-
|
|
8
|
-
const basePathSchema = object({ path: string() });
|
|
9
|
-
const loadTextureSchema = object({ name: string(), path: string() });
|
|
10
|
-
const loadModelSchema = object({ name: string(), path: string() });
|
|
6
|
+
import { basePathSchema, loadTextureSchema, loadModelSchema } from '../schemas.js';
|
|
11
7
|
export class AssetLoader extends Loader {
|
|
12
8
|
mock;
|
|
13
9
|
textureLoader;
|
|
@@ -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;
|
|
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;AAO9E,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,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,qBAAa,SAAU,SAAQ,aAAa;gBAExC,WAAW,EAAE,WAAW,EACxB,QAAQ,GAAE,QAAkC,EAC5C,IAAI,GAAE,YAAiB;CAoP1B"}
|
package/dist/grass/index.js
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import { Color, DoubleSide, InstancedMesh, Matrix4, MeshPhongMaterial, PlaneGeometry, Quaternion, Vector3, } from "three";
|
|
2
|
-
import { coerce, object, string } from "zod";
|
|
3
2
|
import { buildGrassMaterial } from "./material.js";
|
|
4
3
|
import { TilesGeometry } from "../tiles/geometry.js";
|
|
5
|
-
|
|
6
|
-
color: string().optional(),
|
|
7
|
-
height: coerce.number().optional(),
|
|
8
|
-
density: coerce.number().optional(),
|
|
9
|
-
});
|
|
4
|
+
import { grassSchema } from "../schemas.js";
|
|
10
5
|
const UpVector = new Vector3(0, 1, 0);
|
|
11
6
|
const colorHelper = new Color();
|
|
12
7
|
export class GrassMesh extends InstancedMesh {
|
package/dist/interpreter.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { output, ZodObject } from 'zod';
|
|
2
2
|
import { Call } from './parser.js';
|
|
3
3
|
import { ChartaError, ErrorLocation } from './errors.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}, import("zod/v4/core").$strip>;
|
|
4
|
+
import { cellSizeSchema } from './schemas.js';
|
|
5
|
+
export { cellSizeSchema as cellSizeFunctionParams };
|
|
7
6
|
export type InterpreterOptions = {
|
|
8
7
|
throwOnError?: boolean;
|
|
9
8
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interpreter.d.ts","sourceRoot":"","sources":["../src/interpreter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"interpreter.d.ts","sourceRoot":"","sources":["../src/interpreter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAa,MAAM,KAAK,CAAA;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAClC,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAE7C,OAAO,EAAE,cAAc,IAAI,sBAAsB,EAAE,CAAA;AAEnD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,CAAA;AAED,qBAAa,WAAW;IAKpB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IANzB,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,YAAY,CAAS;gBAGV,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,EACf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,YAAK,EAChC,MAAM,EAAE,MAAM,EAC/B,OAAO,GAAE,kBAAuB;IAelC,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI;IAOrC,SAAS,IAAI,WAAW,EAAE;IAI1B,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAQ;IACzC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAU;IAEtC,SAAS,IAAI,MAAM;IAInB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAMtC,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAO9D,OAAO,IAAI,MAAM;IAKjB,OAAO,IAAI,MAAM;IAKjB,UAAU,CACR,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,EACnC,MAAM,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,EAC1C,OAAO,GAAE,MAAU,EACnB,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM;IAgBT,QAAQ,CAAC,CAAC,SAAS;SAAG,GAAG,IAAI,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC;KAAE,EACpD,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,EACnC,WAAW,EAAE,CAAC,GACb,KAAK,CACN;SACG,GAAG,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,MAAM,CAAA;SAAE,CAAC;KACpG,CAAC,MAAM,CAAC,CAAC,CACX;IA0GD,OAAO,CAAC,aAAa;IAmBrB,OAAO,CAAC,uBAAuB;IAa/B,gBAAgB,CAAC,CAAC,EAAE,WAAW,EAAE;QAAE,KAAK,GAAG,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;KAAE,EAAE,IAAI,GAAE,MAAyB,GAAG,CAAC,GAAG,SAAS;IAWlH,QAAQ,CAAC,CAAC,EACR,WAAW,EAAE;QAAE,KAAK,GAAG,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;KAAE,EAC7C,IAAI,GAAE,MAAyB,EAC/B,GAAG,CAAC,EAAE,aAAa,GAClB,CAAC,GAAG,SAAS;IAmBhB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IAIxC,WAAW,IAAI,MAAM;CAStB"}
|
package/dist/interpreter.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { coerce, object } from 'zod';
|
|
2
1
|
import { ChartaError } from './errors.js';
|
|
3
|
-
|
|
2
|
+
import { cellSizeSchema } from './schemas.js';
|
|
3
|
+
export { cellSizeSchema as cellSizeFunctionParams };
|
|
4
4
|
export class Interpreter {
|
|
5
5
|
ast;
|
|
6
6
|
assets;
|
|
@@ -217,7 +217,7 @@ export class Interpreter {
|
|
|
217
217
|
getCellSize() {
|
|
218
218
|
let cellSize = 1;
|
|
219
219
|
for (const [, { size }] of this.getCalls(undefined, {
|
|
220
|
-
cellSize:
|
|
220
|
+
cellSize: cellSizeSchema,
|
|
221
221
|
})) {
|
|
222
222
|
cellSize = size;
|
|
223
223
|
}
|
package/dist/locations.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { Interpreter } from './interpreter.js';
|
|
2
2
|
import { Vector3 } from 'three';
|
|
3
|
+
import { locationSchema } from './schemas.js';
|
|
4
|
+
export { locationSchema };
|
|
3
5
|
export declare class Locations {
|
|
4
6
|
private readonly interpreter;
|
|
5
7
|
private readonly nameToCell;
|
|
6
8
|
constructor(interpreter: Interpreter);
|
|
7
9
|
/**
|
|
8
10
|
* Resolve a named location to a world-space position (x, y, z).
|
|
9
|
-
* - X/Z are the center of the owning cell.
|
|
11
|
+
* - X/Z are the center of the owning cell plus any offsetX/offsetZ.
|
|
10
12
|
* - Y is sampled from the nearest relevant layer stack at that cell.
|
|
11
13
|
*
|
|
12
14
|
* If terrain data is unavailable, Y defaults to 0.
|
package/dist/locations.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locations.d.ts","sourceRoot":"","sources":["../src/locations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"locations.d.ts","sourceRoot":"","sources":["../src/locations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAG9C,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAE7C,OAAO,EAAE,cAAc,EAAE,CAAA;AAIzB,qBAAa,SAAS;IAGR,OAAO,CAAC,QAAQ,CAAC,WAAW;IAFxC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAkC;gBAEhC,WAAW,EAAE,WAAW;IA2BrD;;;;;;OAMG;IACH,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO;CA0BzD"}
|
package/dist/locations.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { object, string } from 'zod';
|
|
2
1
|
import { TilesGeometry } from './tiles/geometry.js';
|
|
3
2
|
import { ChartaError } from './errors.js';
|
|
3
|
+
import { locationSchema } from './schemas.js';
|
|
4
|
+
export { locationSchema };
|
|
4
5
|
export class Locations {
|
|
5
6
|
interpreter;
|
|
6
7
|
nameToCell = new Map();
|
|
@@ -8,7 +9,6 @@ export class Locations {
|
|
|
8
9
|
this.interpreter = interpreter;
|
|
9
10
|
const rows = interpreter.getRows();
|
|
10
11
|
const cols = interpreter.getCols();
|
|
11
|
-
const locationSchema = object({ name: string() });
|
|
12
12
|
for (let row = 0; row < rows; row++) {
|
|
13
13
|
for (let col = 0; col < cols; col++) {
|
|
14
14
|
const entries = interpreter.getCalls([row, col], {
|
|
@@ -20,14 +20,20 @@ export class Locations {
|
|
|
20
20
|
interpreter.reportError(new ChartaError(`duplicate location "${name}"`, interpreter.getSource(), loc));
|
|
21
21
|
continue;
|
|
22
22
|
}
|
|
23
|
-
this.nameToCell.set(name, {
|
|
23
|
+
this.nameToCell.set(name, {
|
|
24
|
+
row,
|
|
25
|
+
col,
|
|
26
|
+
callIdx,
|
|
27
|
+
offsetX: parsed.offsetX ?? 0,
|
|
28
|
+
offsetZ: parsed.offsetZ ?? 0,
|
|
29
|
+
});
|
|
24
30
|
}
|
|
25
31
|
}
|
|
26
32
|
}
|
|
27
33
|
}
|
|
28
34
|
/**
|
|
29
35
|
* Resolve a named location to a world-space position (x, y, z).
|
|
30
|
-
* - X/Z are the center of the owning cell.
|
|
36
|
+
* - X/Z are the center of the owning cell plus any offsetX/offsetZ.
|
|
31
37
|
* - Y is sampled from the nearest relevant layer stack at that cell.
|
|
32
38
|
*
|
|
33
39
|
* If terrain data is unavailable, Y defaults to 0.
|
|
@@ -37,8 +43,10 @@ export class Locations {
|
|
|
37
43
|
if (!cellLoc) {
|
|
38
44
|
throw new Error(`Unknown location "${name}".`);
|
|
39
45
|
}
|
|
40
|
-
const { row, col, callIdx } = cellLoc;
|
|
41
|
-
const [
|
|
46
|
+
const { row, col, callIdx, offsetX, offsetZ } = cellLoc;
|
|
47
|
+
const [cx, cz] = this.interpreter.getWorldCellCenter(row, col);
|
|
48
|
+
const x = cx + offsetX;
|
|
49
|
+
const z = cz + offsetZ;
|
|
42
50
|
// Determine the stack index similarly to how walls/pillars derive defaults.
|
|
43
51
|
const isLayer = (c) => c.name === 'ground' || c.name === 'ceiling';
|
|
44
52
|
const layersBefore = this.interpreter.countCalls([row, col], isLayer, 0, callIdx);
|
|
@@ -51,7 +59,7 @@ export class Locations {
|
|
|
51
59
|
stackIndex = layersAfter > 0 ? 0 : 0;
|
|
52
60
|
}
|
|
53
61
|
const tilesGeometry = this.interpreter.getAsset(TilesGeometry, 'tilesGeometry');
|
|
54
|
-
const y = tilesGeometry?.getHeight(row, col, stackIndex,
|
|
62
|
+
const y = tilesGeometry?.getHeight(row, col, stackIndex, offsetX, offsetZ) ?? 0;
|
|
55
63
|
target.set(x, y, z);
|
|
56
64
|
return target;
|
|
57
65
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pillars/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,aAAa,EAEb,QAAQ,EAMT,MAAM,OAAO,CAAA;AACd,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAO/C,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,UAAU,GAAG,aAAa,GAAG,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pillars/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,aAAa,EAEb,QAAQ,EAMT,MAAM,OAAO,CAAA;AACd,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAO/C,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,UAAU,GAAG,aAAa,GAAG,YAAY,CAAA;AAYhF,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;CACf,CAAA;AAED,qBAAa,UAAW,SAAQ,aAAa;gBAC/B,WAAW,EAAE,WAAW,EAAE,QAAQ,GAAE,QAAkC,EAAE,OAAO,GAAE,iBAAsB;CAoLpH"}
|
package/dist/pillars/index.js
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
import { BoxGeometry, InstancedMesh, InstancedBufferAttribute, Matrix4, MeshBasicMaterial, Quaternion, Vector3, Texture, } from 'three';
|
|
2
2
|
import { TilesGeometry } from '../tiles/geometry.js';
|
|
3
|
-
import { coerce, object, string, z } from 'zod';
|
|
4
3
|
import { buildTextureArrayFromAssets } from '../utils/texture.js';
|
|
5
4
|
import { buildPillarMeshMaterial } from './material.js';
|
|
6
5
|
import { ChartaError } from '../errors.js';
|
|
7
|
-
|
|
8
|
-
const pillarSchema = object({
|
|
9
|
-
corner: cornerEnum, // positional 0
|
|
10
|
-
texture: string(), // positional 1
|
|
11
|
-
sizeX: coerce.number().optional(),
|
|
12
|
-
sizeZ: coerce.number().optional(),
|
|
13
|
-
bottomY: coerce.number().optional(),
|
|
14
|
-
topY: coerce.number().optional(),
|
|
15
|
-
});
|
|
6
|
+
import { pillarSchema } from '../schemas.js';
|
|
16
7
|
export class PillarMesh extends InstancedMesh {
|
|
17
8
|
constructor(interpreter, material = new MeshBasicMaterial(), options = {}) {
|
|
18
9
|
const rows = interpreter.getRows();
|
|
@@ -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;
|
|
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;AAY/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,OAAO,CAAC,QAAQ,CAAqB;gBAGnB,UAAU,EAAE,OAAO,EAClB,iBAAiB,EAAE,CAAC,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,QAAQ;IAG5E,GAAG,CAAC,MAAM,EAAE,OAAO;IAKZ,KAAK,IAAI,QAAQ;CAKzB;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAA;AAED,qBAAa,UAAW,SAAQ,KAAK;IACnC,OAAO,CAAC,aAAa,CAAgC;gBAEzC,WAAW,EAAE,WAAW,EAAE,iBAAiB,CAAC,EAAE,QAAQ,EAAE,IAAI,GAAE,iBAAsB;IAsThG,OAAO;CAOR"}
|
package/dist/place/index.js
CHANGED
|
@@ -1,34 +1,9 @@
|
|
|
1
1
|
import { Group, Matrix4, Quaternion, Vector3, Box3 } from 'three';
|
|
2
2
|
import { TilesGeometry } from '../tiles/geometry.js';
|
|
3
|
-
import { coerce, object, string, enum as zodEnum } from 'zod';
|
|
4
3
|
import { createRng, hashNumbersToUint32, hashStringToUint32 } from '../utils/random.js';
|
|
5
4
|
import { degToRad } from 'three/src/math/MathUtils.js';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
model: string(),
|
|
9
|
-
density: coerce.number().optional(),
|
|
10
|
-
bottomY: coerce.number().optional(),
|
|
11
|
-
yaw: coerce.number().optional(),
|
|
12
|
-
yawMin: coerce.number().optional(),
|
|
13
|
-
yawMax: coerce.number().optional(),
|
|
14
|
-
align: alignEnum.optional(),
|
|
15
|
-
sizeX: coerce.number().optional(),
|
|
16
|
-
minSizeX: coerce.number().optional(),
|
|
17
|
-
maxSizeX: coerce.number().optional(),
|
|
18
|
-
sizeZ: coerce.number().optional(),
|
|
19
|
-
minSizeZ: coerce.number().optional(),
|
|
20
|
-
maxSizeZ: coerce.number().optional(),
|
|
21
|
-
});
|
|
22
|
-
const placeSchema = object({
|
|
23
|
-
model: string(),
|
|
24
|
-
offsetX: coerce.number().optional(),
|
|
25
|
-
offsetZ: coerce.number().optional(),
|
|
26
|
-
bottomY: coerce.number().optional(),
|
|
27
|
-
yaw: coerce.number().optional(),
|
|
28
|
-
align: alignEnum.optional(),
|
|
29
|
-
sizeX: coerce.number().optional(),
|
|
30
|
-
sizeZ: coerce.number().optional(),
|
|
31
|
-
});
|
|
5
|
+
import { locationSchema, placeSchema, scatterSchema, isPointInsideFootprint, } from '../schemas.js';
|
|
6
|
+
import { ChartaError } from '../errors.js';
|
|
32
7
|
const boxHelper = new Box3();
|
|
33
8
|
const matrixHelper = new Matrix4();
|
|
34
9
|
export function measureObject(object) {
|
|
@@ -65,17 +40,48 @@ export class PlaceGroup extends Group {
|
|
|
65
40
|
if (opts.mock) {
|
|
66
41
|
const rows = interpreter.getRows();
|
|
67
42
|
const cols = interpreter.getCols();
|
|
43
|
+
const cellSize = interpreter.getCellSize();
|
|
68
44
|
for (let row = 0; row < rows; row++) {
|
|
69
45
|
for (let col = 0; col < cols; col++) {
|
|
70
46
|
// getCalls validates the schema and reports errors
|
|
71
47
|
const scatterEntries = interpreter.getCalls([row, col], { scatter: scatterSchema });
|
|
72
48
|
const placeEntries = interpreter.getCalls([row, col], { place: placeSchema });
|
|
49
|
+
const cx = (col - cols / 2 + 0.5) * cellSize;
|
|
50
|
+
const cz = (row - rows / 2 + 0.5) * cellSize;
|
|
51
|
+
// Collect location points for overlap validation
|
|
52
|
+
const locationEntries = interpreter.getCalls([row, col], { location: locationSchema });
|
|
53
|
+
const locationPoints = locationEntries.map(([, parsed]) => ({
|
|
54
|
+
x: cx + (parsed.offsetX ?? 0),
|
|
55
|
+
z: cz + (parsed.offsetZ ?? 0),
|
|
56
|
+
}));
|
|
73
57
|
// Validate that referenced models exist (triggers "unknown asset" errors)
|
|
74
58
|
for (const [, parsed, , loc] of scatterEntries) {
|
|
75
59
|
interpreter.getAsset(PrefabBatchBuilder, `${parsed.model}Prefab`, loc);
|
|
76
60
|
}
|
|
77
61
|
for (const [, parsed, , loc] of placeEntries) {
|
|
78
|
-
interpreter.getAsset(PrefabBatchBuilder, `${parsed.model}Prefab`, loc);
|
|
62
|
+
const batchBuilder = interpreter.getAsset(PrefabBatchBuilder, `${parsed.model}Prefab`, loc);
|
|
63
|
+
if (!batchBuilder)
|
|
64
|
+
continue;
|
|
65
|
+
// Validate that no location is inside this place footprint
|
|
66
|
+
const px = cx + (parsed.offsetX ?? 0);
|
|
67
|
+
const pz = cz + (parsed.offsetZ ?? 0);
|
|
68
|
+
const usualSize = batchBuilder.prefabSize;
|
|
69
|
+
// Compute scale factor
|
|
70
|
+
let scaleFactor = 1;
|
|
71
|
+
if (parsed.sizeX !== undefined || parsed.sizeZ !== undefined) {
|
|
72
|
+
const safeUsualX = Math.max(usualSize.x, 0.001);
|
|
73
|
+
const safeUsualZ = Math.max(usualSize.z, 0.001);
|
|
74
|
+
const sFactorX = parsed.sizeX !== undefined ? parsed.sizeX / safeUsualX : undefined;
|
|
75
|
+
const sFactorZ = parsed.sizeZ !== undefined ? parsed.sizeZ / safeUsualZ : undefined;
|
|
76
|
+
scaleFactor = Math.min(sFactorX ?? sFactorZ ?? 1, sFactorZ ?? sFactorX ?? 1);
|
|
77
|
+
}
|
|
78
|
+
const halfX = (usualSize.x * scaleFactor) / 2;
|
|
79
|
+
const halfZ = (usualSize.z * scaleFactor) / 2;
|
|
80
|
+
for (const locPoint of locationPoints) {
|
|
81
|
+
if (isPointInsideFootprint(locPoint.x, locPoint.z, px, pz, halfX, halfZ)) {
|
|
82
|
+
interpreter.reportError(new ChartaError(`location is inside place(${parsed.model}) footprint`, interpreter.getSource(), loc));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
79
85
|
}
|
|
80
86
|
}
|
|
81
87
|
}
|
|
@@ -144,6 +150,12 @@ export class PlaceGroup extends Group {
|
|
|
144
150
|
const cx = (col - cols / 2 + 0.5) * cellSize;
|
|
145
151
|
const cz = (row - rows / 2 + 0.5) * cellSize;
|
|
146
152
|
const half = cellSize * 0.5;
|
|
153
|
+
// Collect location points in this cell for collision detection
|
|
154
|
+
const locationEntries = interpreter.getCalls([row, col], { location: locationSchema });
|
|
155
|
+
const locationPoints = locationEntries.map(([, parsed]) => ({
|
|
156
|
+
x: cx + (parsed.offsetX ?? 0),
|
|
157
|
+
z: cz + (parsed.offsetZ ?? 0),
|
|
158
|
+
}));
|
|
147
159
|
// scatter: randomized distribution, density is count for now
|
|
148
160
|
for (const [, parsed, callIdx, loc] of scatterEntries) {
|
|
149
161
|
const layerIndex = interpreter.countCalls([row, col], (c) => c.name === 'ground' || c.name === 'ceiling', 0, callIdx) - 1;
|
|
@@ -196,6 +208,12 @@ export class PlaceGroup extends Group {
|
|
|
196
208
|
: minSizeZ ?? maxSizeZ;
|
|
197
209
|
const scale = computeScale(usualSize, sX, sZ);
|
|
198
210
|
scl.multiply(scale);
|
|
211
|
+
// Check if any location point falls inside this scattered object's footprint
|
|
212
|
+
const halfX = (usualSize.x * scale.x) / 2;
|
|
213
|
+
const halfZ = (usualSize.z * scale.z) / 2;
|
|
214
|
+
const overlapsLocation = locationPoints.some((loc) => isPointInsideFootprint(loc.x, loc.z, px, pz, halfX, halfZ));
|
|
215
|
+
if (overlapsLocation)
|
|
216
|
+
continue;
|
|
199
217
|
batchBuilder.add(matrixHelper.compose(pos, quat, scl));
|
|
200
218
|
}
|
|
201
219
|
}
|
|
@@ -223,6 +241,14 @@ export class PlaceGroup extends Group {
|
|
|
223
241
|
usualSize.copy(batchBuilder.prefabSize);
|
|
224
242
|
const scale = computeScale(usualSize, parsed.sizeX, parsed.sizeZ);
|
|
225
243
|
scl.multiply(scale);
|
|
244
|
+
// Validate that no location point is inside this placed object's footprint
|
|
245
|
+
const halfX = (usualSize.x * scale.x) / 2;
|
|
246
|
+
const halfZ = (usualSize.z * scale.z) / 2;
|
|
247
|
+
for (const locPoint of locationPoints) {
|
|
248
|
+
if (isPointInsideFootprint(locPoint.x, locPoint.z, px, pz, halfX, halfZ)) {
|
|
249
|
+
interpreter.reportError(new ChartaError(`location is inside place(${parsed.model}) footprint`, interpreter.getSource(), loc));
|
|
250
|
+
}
|
|
251
|
+
}
|
|
226
252
|
batchBuilder.add(matrixHelper.compose(pos, quat, scl));
|
|
227
253
|
}
|
|
228
254
|
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { coerce } from 'zod';
|
|
2
|
+
export declare const alignEnum: import("zod").ZodEnum<{
|
|
3
|
+
up: "up";
|
|
4
|
+
normal: "normal";
|
|
5
|
+
}>;
|
|
6
|
+
export declare const cornerEnum: import("zod").ZodEnum<{
|
|
7
|
+
topleft: "topleft";
|
|
8
|
+
topright: "topright";
|
|
9
|
+
bottomright: "bottomright";
|
|
10
|
+
bottomleft: "bottomleft";
|
|
11
|
+
}>;
|
|
12
|
+
export declare const wallDirEnum: import("zod").ZodEnum<{
|
|
13
|
+
top: "top";
|
|
14
|
+
bottom: "bottom";
|
|
15
|
+
left: "left";
|
|
16
|
+
right: "right";
|
|
17
|
+
}>;
|
|
18
|
+
export declare const cellSizeSchema: import("zod").ZodObject<{
|
|
19
|
+
size: coerce.ZodCoercedNumber<unknown>;
|
|
20
|
+
}, import("zod/v4/core").$strip>;
|
|
21
|
+
export declare const basePathSchema: import("zod").ZodObject<{
|
|
22
|
+
path: import("zod").ZodString;
|
|
23
|
+
}, import("zod/v4/core").$strip>;
|
|
24
|
+
export declare const loadTextureSchema: import("zod").ZodObject<{
|
|
25
|
+
name: import("zod").ZodString;
|
|
26
|
+
path: import("zod").ZodString;
|
|
27
|
+
}, import("zod/v4/core").$strip>;
|
|
28
|
+
export declare const loadModelSchema: import("zod").ZodObject<{
|
|
29
|
+
name: import("zod").ZodString;
|
|
30
|
+
path: import("zod").ZodString;
|
|
31
|
+
}, import("zod/v4/core").$strip>;
|
|
32
|
+
export declare const groundSchema: import("zod").ZodObject<{
|
|
33
|
+
texture: import("zod").ZodString;
|
|
34
|
+
y: coerce.ZodCoercedNumber<unknown>;
|
|
35
|
+
}, import("zod/v4/core").$strip>;
|
|
36
|
+
export declare const ceilingSchema: import("zod").ZodObject<{
|
|
37
|
+
texture: import("zod").ZodString;
|
|
38
|
+
y: coerce.ZodCoercedNumber<unknown>;
|
|
39
|
+
}, import("zod/v4/core").$strip>;
|
|
40
|
+
export declare const waterSchema: import("zod").ZodObject<{
|
|
41
|
+
y: coerce.ZodCoercedNumber<unknown>;
|
|
42
|
+
}, import("zod/v4/core").$strip>;
|
|
43
|
+
export declare const wallSchema: import("zod").ZodObject<{
|
|
44
|
+
dir: import("zod").ZodEnum<{
|
|
45
|
+
top: "top";
|
|
46
|
+
bottom: "bottom";
|
|
47
|
+
left: "left";
|
|
48
|
+
right: "right";
|
|
49
|
+
}>;
|
|
50
|
+
texture: import("zod").ZodString;
|
|
51
|
+
bottomY: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
52
|
+
topY: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
53
|
+
}, import("zod/v4/core").$strip>;
|
|
54
|
+
export declare const windowSchema: import("zod").ZodObject<{
|
|
55
|
+
offsetX: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
56
|
+
bottomY: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
57
|
+
topY: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
58
|
+
width: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
59
|
+
}, import("zod/v4/core").$strip>;
|
|
60
|
+
export declare const doorSchema: import("zod").ZodObject<{
|
|
61
|
+
offsetX: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
62
|
+
bottomY: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
63
|
+
topY: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
64
|
+
height: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
65
|
+
width: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
66
|
+
}, import("zod/v4/core").$strip>;
|
|
67
|
+
export declare const pillarSchema: import("zod").ZodObject<{
|
|
68
|
+
corner: import("zod").ZodEnum<{
|
|
69
|
+
topleft: "topleft";
|
|
70
|
+
topright: "topright";
|
|
71
|
+
bottomright: "bottomright";
|
|
72
|
+
bottomleft: "bottomleft";
|
|
73
|
+
}>;
|
|
74
|
+
texture: import("zod").ZodString;
|
|
75
|
+
sizeX: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
76
|
+
sizeZ: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
77
|
+
bottomY: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
78
|
+
topY: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
79
|
+
}, import("zod/v4/core").$strip>;
|
|
80
|
+
export declare const locationSchema: import("zod").ZodObject<{
|
|
81
|
+
name: import("zod").ZodString;
|
|
82
|
+
offsetX: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
83
|
+
offsetZ: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
84
|
+
}, import("zod/v4/core").$strip>;
|
|
85
|
+
export declare const placeSchema: import("zod").ZodObject<{
|
|
86
|
+
model: import("zod").ZodString;
|
|
87
|
+
offsetX: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
88
|
+
offsetZ: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
89
|
+
bottomY: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
90
|
+
yaw: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
91
|
+
align: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
92
|
+
up: "up";
|
|
93
|
+
normal: "normal";
|
|
94
|
+
}>>;
|
|
95
|
+
sizeX: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
96
|
+
sizeZ: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
97
|
+
}, import("zod/v4/core").$strip>;
|
|
98
|
+
export declare const scatterSchema: import("zod").ZodObject<{
|
|
99
|
+
model: import("zod").ZodString;
|
|
100
|
+
density: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
101
|
+
bottomY: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
102
|
+
yaw: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
103
|
+
yawMin: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
104
|
+
yawMax: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
105
|
+
align: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
106
|
+
up: "up";
|
|
107
|
+
normal: "normal";
|
|
108
|
+
}>>;
|
|
109
|
+
sizeX: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
110
|
+
minSizeX: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
111
|
+
maxSizeX: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
112
|
+
sizeZ: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
113
|
+
minSizeZ: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
114
|
+
maxSizeZ: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
115
|
+
}, import("zod/v4/core").$strip>;
|
|
116
|
+
export declare const grassSchema: import("zod").ZodObject<{
|
|
117
|
+
color: import("zod").ZodOptional<import("zod").ZodString>;
|
|
118
|
+
height: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
119
|
+
density: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
120
|
+
}, import("zod/v4/core").$strip>;
|
|
121
|
+
/**
|
|
122
|
+
* Check if a point is inside an object's footprint (axis-aligned bounding box in X/Z).
|
|
123
|
+
*/
|
|
124
|
+
export declare function isPointInsideFootprint(pointX: number, pointZ: number, objectX: number, objectZ: number, halfSizeX: number, halfSizeZ: number): boolean;
|
|
125
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAmC,MAAM,KAAK,CAAA;AAM7D,eAAO,MAAM,SAAS;;;EAA4B,CAAA;AAClD,eAAO,MAAM,UAAU;;;;;EAAgE,CAAA;AACvF,eAAO,MAAM,WAAW;;;;;EAA8C,CAAA;AAMtE,eAAO,MAAM,cAAc;;gCAAoC,CAAA;AAC/D,eAAO,MAAM,cAAc;;gCAA6B,CAAA;AACxD,eAAO,MAAM,iBAAiB;;;gCAA6C,CAAA;AAC3E,eAAO,MAAM,eAAe;;;gCAA6C,CAAA;AAMzE,eAAO,MAAM,YAAY;;;gCAAoD,CAAA;AAC7E,eAAO,MAAM,aAAa;;;gCAAoD,CAAA;AAC9E,eAAO,MAAM,WAAW;;gCAAiC,CAAA;AAMzD,eAAO,MAAM,UAAU;;;;;;;;;;gCAKrB,CAAA;AAEF,eAAO,MAAM,YAAY;;;;;gCAKvB,CAAA;AAEF,eAAO,MAAM,UAAU;;;;;;gCAMrB,CAAA;AAEF,eAAO,MAAM,YAAY;;;;;;;;;;;;gCAOvB,CAAA;AAMF,eAAO,MAAM,cAAc;;;;gCAIzB,CAAA;AAEF,eAAO,MAAM,WAAW;;;;;;;;;;;;gCAStB,CAAA;AAEF,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;gCAcxB,CAAA;AAMF,eAAO,MAAM,WAAW;;;;gCAItB,CAAA;AAMF;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB,OAAO,CAET"}
|
package/dist/schemas.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { coerce, object, string, enum as zodEnum } from 'zod';
|
|
2
|
+
// ============================================================================
|
|
3
|
+
// Enums
|
|
4
|
+
// ============================================================================
|
|
5
|
+
export const alignEnum = zodEnum(['up', 'normal']);
|
|
6
|
+
export const cornerEnum = zodEnum(['topleft', 'topright', 'bottomright', 'bottomleft']);
|
|
7
|
+
export const wallDirEnum = zodEnum(['top', 'bottom', 'left', 'right']);
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// Meta Schemas (first row)
|
|
10
|
+
// ============================================================================
|
|
11
|
+
export const cellSizeSchema = object({ size: coerce.number() });
|
|
12
|
+
export const basePathSchema = object({ path: string() });
|
|
13
|
+
export const loadTextureSchema = object({ name: string(), path: string() });
|
|
14
|
+
export const loadModelSchema = object({ name: string(), path: string() });
|
|
15
|
+
// ============================================================================
|
|
16
|
+
// Layer Schemas
|
|
17
|
+
// ============================================================================
|
|
18
|
+
export const groundSchema = object({ texture: string(), y: coerce.number() });
|
|
19
|
+
export const ceilingSchema = object({ texture: string(), y: coerce.number() });
|
|
20
|
+
export const waterSchema = object({ y: coerce.number() });
|
|
21
|
+
// ============================================================================
|
|
22
|
+
// Structural Schemas
|
|
23
|
+
// ============================================================================
|
|
24
|
+
export const wallSchema = object({
|
|
25
|
+
dir: wallDirEnum,
|
|
26
|
+
texture: string(),
|
|
27
|
+
bottomY: coerce.number().optional(),
|
|
28
|
+
topY: coerce.number().optional(),
|
|
29
|
+
});
|
|
30
|
+
export const windowSchema = object({
|
|
31
|
+
offsetX: coerce.number().optional(),
|
|
32
|
+
bottomY: coerce.number().optional(),
|
|
33
|
+
topY: coerce.number().optional(),
|
|
34
|
+
width: coerce.number().optional(),
|
|
35
|
+
});
|
|
36
|
+
export const doorSchema = object({
|
|
37
|
+
offsetX: coerce.number().optional(),
|
|
38
|
+
bottomY: coerce.number().optional(),
|
|
39
|
+
topY: coerce.number().optional(),
|
|
40
|
+
height: coerce.number().optional(),
|
|
41
|
+
width: coerce.number().optional(),
|
|
42
|
+
});
|
|
43
|
+
export const pillarSchema = object({
|
|
44
|
+
corner: cornerEnum,
|
|
45
|
+
texture: string(),
|
|
46
|
+
sizeX: coerce.number().optional(),
|
|
47
|
+
sizeZ: coerce.number().optional(),
|
|
48
|
+
bottomY: coerce.number().optional(),
|
|
49
|
+
topY: coerce.number().optional(),
|
|
50
|
+
});
|
|
51
|
+
// ============================================================================
|
|
52
|
+
// Object Placement Schemas
|
|
53
|
+
// ============================================================================
|
|
54
|
+
export const locationSchema = object({
|
|
55
|
+
name: string(),
|
|
56
|
+
offsetX: coerce.number().optional(),
|
|
57
|
+
offsetZ: coerce.number().optional(),
|
|
58
|
+
});
|
|
59
|
+
export const placeSchema = object({
|
|
60
|
+
model: string(),
|
|
61
|
+
offsetX: coerce.number().optional(),
|
|
62
|
+
offsetZ: coerce.number().optional(),
|
|
63
|
+
bottomY: coerce.number().optional(),
|
|
64
|
+
yaw: coerce.number().optional(),
|
|
65
|
+
align: alignEnum.optional(),
|
|
66
|
+
sizeX: coerce.number().optional(),
|
|
67
|
+
sizeZ: coerce.number().optional(),
|
|
68
|
+
});
|
|
69
|
+
export const scatterSchema = object({
|
|
70
|
+
model: string(),
|
|
71
|
+
density: coerce.number().optional(),
|
|
72
|
+
bottomY: coerce.number().optional(),
|
|
73
|
+
yaw: coerce.number().optional(),
|
|
74
|
+
yawMin: coerce.number().optional(),
|
|
75
|
+
yawMax: coerce.number().optional(),
|
|
76
|
+
align: alignEnum.optional(),
|
|
77
|
+
sizeX: coerce.number().optional(),
|
|
78
|
+
minSizeX: coerce.number().optional(),
|
|
79
|
+
maxSizeX: coerce.number().optional(),
|
|
80
|
+
sizeZ: coerce.number().optional(),
|
|
81
|
+
minSizeZ: coerce.number().optional(),
|
|
82
|
+
maxSizeZ: coerce.number().optional(),
|
|
83
|
+
});
|
|
84
|
+
// ============================================================================
|
|
85
|
+
// Decoration Schemas
|
|
86
|
+
// ============================================================================
|
|
87
|
+
export const grassSchema = object({
|
|
88
|
+
color: string().optional(),
|
|
89
|
+
height: coerce.number().optional(),
|
|
90
|
+
density: coerce.number().optional(),
|
|
91
|
+
});
|
|
92
|
+
// ============================================================================
|
|
93
|
+
// Utility Functions
|
|
94
|
+
// ============================================================================
|
|
95
|
+
/**
|
|
96
|
+
* Check if a point is inside an object's footprint (axis-aligned bounding box in X/Z).
|
|
97
|
+
*/
|
|
98
|
+
export function isPointInsideFootprint(pointX, pointZ, objectX, objectZ, halfSizeX, halfSizeZ) {
|
|
99
|
+
return Math.abs(pointX - objectX) < halfSizeX && Math.abs(pointZ - objectZ) < halfSizeZ;
|
|
100
|
+
}
|
package/dist/tiles/index.d.ts
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
import { Material, Mesh } from 'three';
|
|
2
2
|
import { Interpreter } from '../interpreter.js';
|
|
3
|
-
import { coerce } from 'zod';
|
|
4
3
|
import { TilesGeometry } from './geometry.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
y: coerce.ZodCoercedNumber<unknown>;
|
|
8
|
-
}, import("zod/v4/core").$strip>;
|
|
9
|
-
export declare const ceilingSchema: import("zod").ZodObject<{
|
|
10
|
-
texture: import("zod").ZodString;
|
|
11
|
-
y: coerce.ZodCoercedNumber<unknown>;
|
|
12
|
-
}, import("zod/v4/core").$strip>;
|
|
4
|
+
import { groundSchema, ceilingSchema } from '../schemas.js';
|
|
5
|
+
export { groundSchema, ceilingSchema };
|
|
13
6
|
export type TilesMeshOptions = {
|
|
14
7
|
/**
|
|
15
8
|
* Mock mode: validates ground/ceiling/wall calls but skips geometry creation.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tiles/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EACR,IAAI,EAOL,MAAM,OAAO,CAAA;AACd,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tiles/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EACR,IAAI,EAOL,MAAM,OAAO,CAAA;AACd,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAuB,MAAM,eAAe,CAAA;AAIlE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAc,MAAM,eAAe,CAAA;AAEvE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,CAAA;AAEtC,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;CACf,CAAA;AAyCD,qBAAa,SAAU,SAAQ,IAAI,CAAC,aAAa,CAAC;gBACpC,WAAW,EAAE,WAAW,EAAE,QAAQ,GAAE,QAAkC,EAAE,OAAO,GAAE,gBAAqB;CA0JnH"}
|
package/dist/tiles/index.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { Mesh, Texture, MeshBasicMaterial, } from 'three';
|
|
2
|
-
import { coerce, object, string } from 'zod';
|
|
3
2
|
import { TilesGeometry } from './geometry.js';
|
|
4
3
|
import { buildTilesMaterial } from './material.js';
|
|
5
4
|
import { ChartaError } from '../errors.js';
|
|
6
|
-
import { wallSchema } from '../walls/index.js';
|
|
7
5
|
import { buildTextureArrayFromAssets } from '../utils/texture.js';
|
|
8
|
-
|
|
9
|
-
export
|
|
6
|
+
import { groundSchema, ceilingSchema, wallSchema } from '../schemas.js';
|
|
7
|
+
export { groundSchema, ceilingSchema };
|
|
10
8
|
function resolveHeights(position, items, interpreter, reverse) {
|
|
11
9
|
items = [...items];
|
|
12
10
|
if (reverse) {
|
package/dist/walls/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Material, Mesh, Vector2Tuple, Vector3Tuple } from 'three';
|
|
2
2
|
import { Interpreter } from '../interpreter.js';
|
|
3
|
-
import { coerce } from 'zod';
|
|
4
3
|
import { TilesGeometry } from '../tiles/geometry.js';
|
|
5
4
|
import { ErrorLocation } from '../errors.js';
|
|
5
|
+
import { wallSchema, windowSchema, doorSchema } from '../schemas.js';
|
|
6
|
+
export { wallSchema, windowSchema, doorSchema };
|
|
6
7
|
export type WindowData = {
|
|
7
8
|
offsetX: number;
|
|
8
9
|
bottomY: number;
|
|
@@ -19,30 +20,6 @@ export type WallData = {
|
|
|
19
20
|
textureId: number;
|
|
20
21
|
windows: WindowData[];
|
|
21
22
|
};
|
|
22
|
-
export declare const windowSchema: import("zod").ZodObject<{
|
|
23
|
-
offsetX: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
24
|
-
bottomY: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
25
|
-
topY: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
26
|
-
width: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
27
|
-
}, import("zod/v4/core").$strip>;
|
|
28
|
-
export declare const doorSchema: import("zod").ZodObject<{
|
|
29
|
-
offsetX: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
30
|
-
bottomY: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
31
|
-
topY: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
32
|
-
height: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
33
|
-
width: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
34
|
-
}, import("zod/v4/core").$strip>;
|
|
35
|
-
export declare const wallSchema: import("zod").ZodObject<{
|
|
36
|
-
dir: import("zod").ZodEnum<{
|
|
37
|
-
top: "top";
|
|
38
|
-
bottom: "bottom";
|
|
39
|
-
left: "left";
|
|
40
|
-
right: "right";
|
|
41
|
-
}>;
|
|
42
|
-
texture: import("zod").ZodString;
|
|
43
|
-
bottomY: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
44
|
-
topY: import("zod").ZodOptional<coerce.ZodCoercedNumber<unknown>>;
|
|
45
|
-
}, import("zod/v4/core").$strip>;
|
|
46
23
|
export declare const WALL_CONFIG: {
|
|
47
24
|
readonly top: {
|
|
48
25
|
readonly zOffset: -0.5;
|
|
@@ -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;
|
|
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;AACzD,OAAO,EAGL,UAAU,EACV,YAAY,EACZ,UAAU,EACX,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,CAAA;AAK/C,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,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,MAAM,EAAE,YAAY,CAAA;IACpB,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,YAAY,CAAA;IACpB,IAAI,EAAE,YAAY,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,UAAU,EAAE,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;CAed,CAAA;AAEV,eAAO,MAAM,+BAA+B,QAAQ,CAAA;AAEpD,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAC5B,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,EACf,MAAM,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,EACxD,MAAM,EAAE,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,EACtD,GAAG,EAAE,aAAa;;;;;cAqInB;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;CACf,CAAA;AAED,qBAAa,QAAS,SAAQ,IAAI;gBACpB,WAAW,EAAE,WAAW,EAAE,QAAQ,GAAE,QAAkC,EAAE,OAAO,GAAE,eAAoB;CA6SlH;AAED,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,WAGrG"}
|
package/dist/walls/index.js
CHANGED
|
@@ -1,32 +1,13 @@
|
|
|
1
1
|
import { Euler, Matrix4, Mesh, MeshBasicMaterial, Quaternion, Vector3, BufferAttribute, Texture, Shape, ExtrudeGeometry, Path, } from 'three';
|
|
2
2
|
import { mergeGeometries } from 'three/examples/jsm/utils/BufferGeometryUtils.js';
|
|
3
|
-
import { coerce, object, string, enum as enum_ } from 'zod';
|
|
4
3
|
import { TilesGeometry } from '../tiles/geometry.js';
|
|
5
4
|
import { buildTextureArrayFromAssets } from '../utils/texture.js';
|
|
6
5
|
import { buildWallMeshMaterial } from './material.js';
|
|
7
6
|
import { ChartaError } from '../errors.js';
|
|
8
|
-
import { ceilingSchema,
|
|
7
|
+
import { groundSchema, ceilingSchema, wallSchema, windowSchema, doorSchema, } from '../schemas.js';
|
|
8
|
+
export { wallSchema, windowSchema, doorSchema };
|
|
9
9
|
const eulerHelper = new Euler();
|
|
10
10
|
const scaleHelper = new Vector3(1, 1, 1);
|
|
11
|
-
export const windowSchema = object({
|
|
12
|
-
offsetX: coerce.number().optional(),
|
|
13
|
-
bottomY: coerce.number().optional(),
|
|
14
|
-
topY: coerce.number().optional(),
|
|
15
|
-
width: coerce.number().optional(),
|
|
16
|
-
});
|
|
17
|
-
export const doorSchema = object({
|
|
18
|
-
offsetX: coerce.number().optional(),
|
|
19
|
-
bottomY: coerce.number().optional(),
|
|
20
|
-
topY: coerce.number().optional(),
|
|
21
|
-
height: coerce.number().optional(),
|
|
22
|
-
width: coerce.number().optional(),
|
|
23
|
-
});
|
|
24
|
-
export const wallSchema = object({
|
|
25
|
-
dir: enum_(['top', 'bottom', 'left', 'right']),
|
|
26
|
-
texture: string(),
|
|
27
|
-
bottomY: coerce.number().optional(),
|
|
28
|
-
topY: coerce.number().optional(),
|
|
29
|
-
});
|
|
30
11
|
export const WALL_CONFIG = {
|
|
31
12
|
top: { zOffset: -0.5, rotation: 0, axis: 'z', sampleDir: 1 },
|
|
32
13
|
bottom: { zOffset: 0.5, rotation: 0, axis: 'z', sampleDir: 1 },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/water/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAY,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIhD,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;CACf,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/water/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAY,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIhD,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;CACf,CAAC;AAEF,qBAAa,SAAU,SAAQ,IAAI;gBACrB,WAAW,EAAE,WAAW,EAAE,OAAO,GAAE,gBAAqB;IAkDpE,OAAO,IAAI,IAAI;CAMhB;AAED,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA"}
|
package/dist/water/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Mesh, Material } from "three";
|
|
2
2
|
import { TilesGeometry } from "../tiles/geometry.js";
|
|
3
|
-
import {
|
|
4
|
-
const waterSchema = object({ y: coerce.number() });
|
|
3
|
+
import { waterSchema } from "../schemas.js";
|
|
5
4
|
export class WaterMesh extends Mesh {
|
|
6
5
|
constructor(interpreter, options = {}) {
|
|
7
6
|
const rows = interpreter.getRows();
|