@drawcall/charta 0.1.26 → 0.1.28

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":"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,IAAI,QAAQ;CAGzB;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;;OAGG;IACH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AQ;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;IA4OhG,OAAO;CAOR"}
@@ -61,17 +61,17 @@ export class PlaceGroup extends Group {
61
61
  const scale = Math.min(sFactorX ?? sFactorZ ?? 1, sFactorZ ?? sFactorX ?? 1);
62
62
  return new Vector3(scale, scale, scale);
63
63
  };
64
- const computeTransform = (worldX, worldZ, cell, transformOpts) => {
64
+ const computeTransform = (gridCoord, transformOpts) => {
65
65
  const normal = new Vector3();
66
- const { offsetX, offsetZ } = interpreter.worldToGrid({ x: worldX, z: worldZ });
67
- let py = 0;
66
+ let y = 0;
68
67
  if (transformOpts.useFixedY) {
69
- py = transformOpts.fixedY;
68
+ y = transformOpts.fixedY;
70
69
  }
71
70
  else {
72
- py = tilesGeometry.getHeightAt({ row: cell.row, col: cell.col, offsetX, offsetZ }, { stackIndex: transformOpts.layerIndex, normalTarget: normal });
71
+ y = tilesGeometry.getHeightAt(gridCoord, { stackIndex: transformOpts.layerIndex, normalTarget: normal });
73
72
  }
74
- const pos = new Vector3(worldX, py, worldZ);
73
+ const { x, z } = interpreter.gridToWorld(gridCoord);
74
+ const pos = new Vector3(x, y, z);
75
75
  const quat = new Quaternion();
76
76
  if (transformOpts.alignMode === 'normal' && !transformOpts.useFixedY) {
77
77
  const qAlign = new Quaternion().setFromUnitVectors(new Vector3(0, 1, 0), normal);
@@ -93,7 +93,6 @@ export class PlaceGroup extends Group {
93
93
  const placeEntries = interpreter.getCalls({ row, col }, { place: placeSchema });
94
94
  if (scatterEntries.length === 0 && placeEntries.length === 0)
95
95
  continue;
96
- const { x: cx, z: cz } = interpreter.gridToWorld({ row, col });
97
96
  const half = cellSize * 0.5;
98
97
  // Collect location points in this cell for collision/footprint validation
99
98
  const locationEntries = interpreter.getCalls({ row, col }, { location: locationSchema });
@@ -129,19 +128,16 @@ export class PlaceGroup extends Group {
129
128
  continue;
130
129
  const useFixedY = parsed.bottomY != null;
131
130
  const yawMin = parsed.yawMin ?? 0;
132
- const yawMax = parsed.yawMax ?? (parsed.yaw != null ? parsed.yaw : Math.PI * 2);
131
+ const yawMax = parsed.yawMax ?? 360;
133
132
  const minSizeX = parsed.minSizeX ?? parsed.sizeX ?? usualSize.x * 0.8;
134
133
  const maxSizeX = parsed.maxSizeX ?? parsed.sizeX ?? usualSize.x * 1.2;
135
134
  const minSizeZ = parsed.minSizeZ ?? parsed.sizeZ ?? usualSize.z * 0.8;
136
135
  const maxSizeZ = parsed.maxSizeZ ?? parsed.sizeZ ?? usualSize.z * 1.2;
137
136
  const alignMode = (parsed.align ?? 'up').toLowerCase();
138
137
  for (let i = 0; i < count; i++) {
139
- const ox = (rng() * 2 - 1) * half;
140
- const oz = (rng() * 2 - 1) * half;
141
- const px = cx + ox;
142
- const pz = cz + oz;
143
- const yaw = yawMin === yawMax ? yawMin : yawMin + (yawMax - yawMin) * rng();
144
- const { pos, quat, scl } = computeTransform(px, pz, { row, col }, {
138
+ const gridCoord = { col, row, offsetX: (rng() * 2 - 1) * half, offsetZ: (rng() * 2 - 1) * half };
139
+ const yaw = parsed.yaw ?? (yawMin + (yawMax - yawMin) * rng());
140
+ const { pos, quat, scl } = computeTransform(gridCoord, {
145
141
  alignMode,
146
142
  yaw,
147
143
  useFixedY: useFixedY,
@@ -159,7 +155,8 @@ export class PlaceGroup extends Group {
159
155
  // Check if any location point falls inside this scattered object's footprint
160
156
  const halfX = (usualSize.x * scale.x) / 2;
161
157
  const halfZ = (usualSize.z * scale.z) / 2;
162
- const overlapsLocation = locationPoints.some((locPoint) => isPointInsideFootprint(locPoint.x, locPoint.z, px, pz, halfX, halfZ));
158
+ const { x, z } = interpreter.gridToWorld(gridCoord);
159
+ const overlapsLocation = locationPoints.some((locationPoint) => isPointInsideFootprint(locationPoint.x, locationPoint.z, x, z, halfX, halfZ));
163
160
  if (overlapsLocation)
164
161
  continue;
165
162
  batchBuilder.add(matrixHelper.compose(pos, quat, scl));
@@ -172,19 +169,20 @@ export class PlaceGroup extends Group {
172
169
  if (!batchBuilder)
173
170
  continue;
174
171
  const usualSize = batchBuilder.prefabSize;
175
- const { x: px, z: pz } = interpreter.gridToWorld({
172
+ const gridCoord = {
176
173
  row,
177
174
  col,
178
175
  offsetX: parsed.offsetX,
179
176
  offsetZ: parsed.offsetZ,
180
- });
177
+ };
181
178
  // Compute scale for footprint validation (needed for both validateOnly and normal mode)
182
179
  const scale = computeScale(usualSize, parsed.sizeX, parsed.sizeZ);
183
180
  const halfX = (usualSize.x * scale.x) / 2;
184
181
  const halfZ = (usualSize.z * scale.z) / 2;
185
182
  // Validate that no location point is inside this placed object's footprint
186
- for (const locPoint of locationPoints) {
187
- if (isPointInsideFootprint(locPoint.x, locPoint.z, px, pz, halfX, halfZ)) {
183
+ const { x, z } = interpreter.gridToWorld(gridCoord);
184
+ for (const locationPoint of locationPoints) {
185
+ if (isPointInsideFootprint(locationPoint.x, locationPoint.z, x, z, halfX, halfZ)) {
188
186
  interpreter.reportError(new ChartaError(`location is inside place(${parsed.model}) footprint`, interpreter.getSource(), loc));
189
187
  }
190
188
  }
@@ -195,7 +193,7 @@ export class PlaceGroup extends Group {
195
193
  const layerIndex = interpreter.countCalls({ row, col }, (c) => c.name === 'ground' || c.name === 'ceiling', 0, callIdx) - 1;
196
194
  const yaw = parsed.yaw ?? 0;
197
195
  const alignMode = (parsed.align ?? 'up').toLowerCase();
198
- const { pos, quat, scl } = computeTransform(px, pz, { row, col }, {
196
+ const { pos, quat, scl } = computeTransform(gridCoord, {
199
197
  alignMode,
200
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ED,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;CAed,CAAA;AAEV,eAAO,MAAM,+BAA+B,QAAQ,CAAA;AAEpD,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,GAAG,SAAS,EACxC,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;YAwFO,YAAY;UACd,YAAY;;;cA6EpC;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;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"}
@@ -90,8 +90,8 @@ export function computeWallVerticalBounds(interpreter, tilesGeometry, row, col,
90
90
  checkCell(neighborRow, neighborCol);
91
91
  return bestLayer;
92
92
  };
93
- const bottomLayer = resolveLayer(parsed.bottomY, false);
94
- const topLayer = resolveLayer(parsed.topY, true);
93
+ let bottomLayer = resolveLayer(parsed.bottomY, false);
94
+ let topLayer = resolveLayer(parsed.topY, true);
95
95
  if (bottomLayer === undefined && parsed.bottomY === undefined)
96
96
  return undefined;
97
97
  if (topLayer === undefined && parsed.topY === undefined)
@@ -137,6 +137,17 @@ export function computeWallVerticalBounds(interpreter, tilesGeometry, row, col,
137
137
  else {
138
138
  yEnd[k] = parsed.topY;
139
139
  }
140
+ if (yStart[k] != yEnd[k] || (parsed.bottomY == null && parsed.topY == null)) {
141
+ continue;
142
+ }
143
+ const bottomDist = parsed.bottomY == null ? 0 : Math.abs(yStart[k] - parsed.bottomY);
144
+ const topDist = parsed.topY == null ? 0 : Math.abs(yEnd[k] - parsed.topY);
145
+ if (bottomDist > topDist) {
146
+ yStart[k] = parsed.bottomY;
147
+ }
148
+ else {
149
+ yEnd[k] = parsed.topY;
150
+ }
140
151
  }
141
152
  // Ensure non-negative height (fix inverted walls)
142
153
  for (let k = 0; k < 3; k++) {
@@ -146,6 +157,7 @@ export function computeWallVerticalBounds(interpreter, tilesGeometry, row, col,
146
157
  yEnd[k] = tmp;
147
158
  }
148
159
  }
160
+ console.log(yStart, yEnd);
149
161
  return {
150
162
  yStart,
151
163
  yEnd,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drawcall/charta",
3
- "version": "0.1.26",
3
+ "version": "0.1.28",
4
4
  "author": "Bela Bohlender",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "homepage": "https://drawcall.ai",
@@ -14,6 +14,7 @@
14
14
  "type": "module",
15
15
  "devDependencies": {
16
16
  "@gltf-transform/core": "^4.3.0",
17
+ "@gltf-transform/extensions": "^4.3.0",
17
18
  "@types/imurmurhash": "^0.1.4",
18
19
  "@types/nearley": "^2.11.5",
19
20
  "@types/seedrandom": "^3.0.8",