incanto 0.28.0 → 0.30.0
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/README.md +44 -0
- package/bin/incanto-editor.mjs +219 -29
- package/dist/2d.d.ts +54 -6
- package/dist/2d.js +3 -3
- package/dist/3d.d.ts +353 -16
- package/dist/3d.js +5 -5
- package/dist/{behavior-CPibUfnH.d.ts → behavior-BAc0erXF.d.ts} +21 -0
- package/dist/{create-game-71TJjW1T.js → create-game-5z_QVtLx.js} +59 -16
- package/dist/{create-game-BRgWpNsa.js → create-game-DuBTv2zI.js} +276 -49
- package/dist/debug-draw-BM3DsvtT.js +18 -0
- package/dist/debug.d.ts +51 -6
- package/dist/debug.js +242 -19
- package/dist/editor-switch-B0wB_DSr.d.ts +59 -0
- package/dist/editor.d.ts +49 -0
- package/dist/editor.js +8554 -0
- package/dist/{gameplay-DEG-TP7D.js → gameplay-Cfr6aFZ1.js} +219 -40
- package/dist/gameplay.d.ts +1 -1
- package/dist/gameplay.js +1 -1
- package/dist/index.d.ts +31 -3
- package/dist/index.js +2 -2
- package/dist/{loader-DILt9PGC.d.ts → loader-B242FF6N.d.ts} +1 -1
- package/dist/net.d.ts +1 -1
- package/dist/net.js +2 -2
- package/dist/{pathfinding-RWYkNKx9.d.ts → pathfinding-BwD974Ss.d.ts} +1 -1
- package/dist/{physics-2d-DiVFFlH3.js → physics-2d-3kOQCtgd.js} +88 -3
- package/dist/{physics-3d--y5clE2j.js → physics-3d-CeRH-Ff_.js} +475 -9
- package/dist/react.d.ts +1 -1
- package/dist/react.js +1 -1
- package/dist/{register-nObreUQR.js → register-BTg0EM7s.js} +35 -3
- package/dist/{register-6R75AC7-.js → register-DJ0SByQg.js} +5550 -5073
- package/dist/{register-CvpSUU3O.js → register-DWcWq4QG.js} +22 -2
- package/dist/{register-BFFE1Mh1.js → register-MelqEdza.js} +1 -1
- package/dist/teardown-ByzfDPyu.js +240 -0
- package/dist/test.d.ts +35 -3
- package/dist/test.js +104 -10
- package/dist/vite.d.ts +139 -1
- package/dist/vite.js +355 -4
- package/editor/assets/{agent8-CojUfCXN.js → agent8-CAp0i5qn.js} +1 -1
- package/editor/assets/debug-BoEYfbqK.js +2 -0
- package/editor/assets/index-BO6WU8by.js +10696 -0
- package/editor/index.html +3 -157
- package/package.json +3 -2
- package/schemas/scene.schema.json +102 -4
- package/skills/incanto-3d-models.md +38 -0
- package/skills/incanto-assets.md +13 -0
- package/skills/incanto-building-3d-games.md +83 -6
- package/skills/incanto-editor.md +212 -8
- package/skills/incanto-environment.md +65 -1
- package/skills/incanto-node-reference.md +33 -1
- package/skills/incanto-physics-and-input.md +60 -6
- package/skills/incanto-verifying-your-game.md +57 -2
- package/templates-app/beacon-isle-3d/docs/project-3d-rules.md +5 -0
- package/templates-app/beacon-isle-3d/package.json +1 -1
- package/templates-app/beacon-isle-3d/vite.config.ts +7 -0
- package/templates-app/tps-3d/docs/project-3d-rules.md +5 -0
- package/templates-app/tps-3d/package.json +1 -1
- package/templates-app/tps-3d/vite.config.ts +7 -0
- package/templates-app/village-quest-3d/docs/project-3d-rules.md +5 -0
- package/templates-app/village-quest-3d/package.json +1 -1
- package/templates-app/village-quest-3d/vite.config.ts +7 -0
- package/dist/debug-draw-CZmOYjL2.js +0 -13
- package/editor/assets/index-D6RQgROR.js +0 -8330
- package/editor/assets/index-D8QvwvOm.css +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
|
|
2
2
|
import { t as IncantoError } from "./errors-BpWbnbb_.js";
|
|
3
|
-
import { _ as RigidBody2D, b as validateCollider2D, g as PhysicsBody2D, h as CharacterBody2D, m as Area2D, p as Joint2D, y as Node2D } from "./register-
|
|
4
|
-
import { n as registerDebugSource } from "./debug-draw-
|
|
3
|
+
import { _ as RigidBody2D, b as validateCollider2D, g as PhysicsBody2D, h as CharacterBody2D, m as Area2D, p as Joint2D, y as Node2D } from "./register-DWcWq4QG.js";
|
|
4
|
+
import { n as registerDebugSource } from "./debug-draw-BM3DsvtT.js";
|
|
5
5
|
//#region src/2d/physics/physics-2d.ts
|
|
6
6
|
var physics_2d_exports = /* @__PURE__ */ __exportAll({
|
|
7
7
|
Physics2D: () => Physics2D,
|
|
@@ -28,6 +28,8 @@ var Physics2D = class {
|
|
|
28
28
|
engine;
|
|
29
29
|
/** Render collider outlines in the GAME view (renderers pick this up). */
|
|
30
30
|
debugDraw = false;
|
|
31
|
+
/** Narrow those outlines to one node's subtree (see DebugLineSource). */
|
|
32
|
+
debugScope = null;
|
|
31
33
|
dimension = "2d";
|
|
32
34
|
unregisterDebug;
|
|
33
35
|
warnedNoCollider = /* @__PURE__ */ new WeakSet();
|
|
@@ -44,6 +46,7 @@ var Physics2D = class {
|
|
|
44
46
|
this.R = R;
|
|
45
47
|
this.engine = engine;
|
|
46
48
|
this.optsGravity = opts?.gravity;
|
|
49
|
+
this.simulate = opts?.simulate ?? true;
|
|
47
50
|
this.lastScene = engine.scene;
|
|
48
51
|
const declared = engine.scene?.physics?.gravity;
|
|
49
52
|
const g = opts?.gravity ?? declared ?? [0, 980];
|
|
@@ -62,8 +65,15 @@ var Physics2D = class {
|
|
|
62
65
|
this.syncBodies();
|
|
63
66
|
}
|
|
64
67
|
/** @internal Driven by engine.fixedUpdated. */
|
|
68
|
+
/** Whether the solver runs at all. False = collider outlines only. */
|
|
69
|
+
simulate;
|
|
65
70
|
step(dt) {
|
|
66
71
|
this.lastDt = dt;
|
|
72
|
+
if (!this.simulate) {
|
|
73
|
+
this.syncBodies();
|
|
74
|
+
this.poseFromTree();
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
67
77
|
if (this.engine.scene !== this.lastScene) {
|
|
68
78
|
this.lastScene = this.engine.scene;
|
|
69
79
|
if (!this.optsGravity) {
|
|
@@ -157,11 +167,69 @@ var Physics2D = class {
|
|
|
157
167
|
/** Rapier debug segments, scaled back to pixels. Null while debugDraw is off. */
|
|
158
168
|
debugLines() {
|
|
159
169
|
if (!this.debugDraw) return null;
|
|
160
|
-
const raw = this.world.debugRender().vertices;
|
|
170
|
+
const raw = this.debugScope ? this.scopedLines(this.debugScope) : this.world.debugRender().vertices;
|
|
161
171
|
const px = new Float32Array(raw.length);
|
|
162
172
|
for (let i = 0; i < raw.length; i++) px[i] = raw[i] * SCALE;
|
|
163
173
|
return px;
|
|
164
174
|
}
|
|
175
|
+
/**
|
|
176
|
+
* Only the selected node's colliders (meters — the caller scales to pixels).
|
|
177
|
+
* Rapier draws the whole world or nothing, so a chosen few are outlined from
|
|
178
|
+
* the same shape data the solver holds. 2D colliders are rect/circle/capsule,
|
|
179
|
+
* which is the whole switch.
|
|
180
|
+
*/
|
|
181
|
+
scopedLines(node) {
|
|
182
|
+
const out = [];
|
|
183
|
+
const bodies = [];
|
|
184
|
+
const collect = (n) => {
|
|
185
|
+
const entry = this.entries.get(n);
|
|
186
|
+
if (entry) bodies.push(entry.body);
|
|
187
|
+
for (const child of n.children) collect(child);
|
|
188
|
+
};
|
|
189
|
+
collect(node);
|
|
190
|
+
for (let p = node.parent; p && bodies.length === 0; p = p.parent) {
|
|
191
|
+
const entry = this.entries.get(p);
|
|
192
|
+
if (entry) bodies.push(entry.body);
|
|
193
|
+
}
|
|
194
|
+
const RING = 24;
|
|
195
|
+
for (const body of bodies) for (let i = 0; i < body.numColliders(); i++) {
|
|
196
|
+
const collider = body.collider(i);
|
|
197
|
+
if (!collider) continue;
|
|
198
|
+
const t = collider.translation();
|
|
199
|
+
const angle = collider.rotation();
|
|
200
|
+
const cos = Math.cos(angle);
|
|
201
|
+
const sin = Math.sin(angle);
|
|
202
|
+
const put = (x, y) => {
|
|
203
|
+
out.push(t.x + x * cos - y * sin, t.y + x * sin + y * cos);
|
|
204
|
+
};
|
|
205
|
+
const seg = (ax, ay, bx, by) => {
|
|
206
|
+
put(ax, ay);
|
|
207
|
+
put(bx, by);
|
|
208
|
+
};
|
|
209
|
+
const shape = collider.shape;
|
|
210
|
+
if (shape.halfExtents) {
|
|
211
|
+
const { x, y } = shape.halfExtents;
|
|
212
|
+
seg(-x, -y, x, -y);
|
|
213
|
+
seg(x, -y, x, y);
|
|
214
|
+
seg(x, y, -x, y);
|
|
215
|
+
seg(-x, y, -x, -y);
|
|
216
|
+
} else if (shape.radius !== void 0) {
|
|
217
|
+
const r = shape.radius;
|
|
218
|
+
const half = shape.halfHeight ?? 0;
|
|
219
|
+
for (let k = 0; k < RING; k++) {
|
|
220
|
+
const a = k / RING * Math.PI * 2;
|
|
221
|
+
const b = (k + 1) / RING * Math.PI * 2;
|
|
222
|
+
const lift = (v) => v >= 0 ? half : -half;
|
|
223
|
+
seg(Math.cos(a) * r, Math.sin(a) * r + lift(Math.sin(a)), Math.cos(b) * r, Math.sin(b) * r + lift(Math.sin(b)));
|
|
224
|
+
}
|
|
225
|
+
if (half > 0) {
|
|
226
|
+
seg(-r, -half, -r, half);
|
|
227
|
+
seg(r, -half, r, half);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return new Float32Array(out);
|
|
232
|
+
}
|
|
165
233
|
/** Create newly-arrived joints; tear down departed ones. */
|
|
166
234
|
syncJoints(structureChanged) {
|
|
167
235
|
const R = this.R;
|
|
@@ -234,6 +302,23 @@ var Physics2D = class {
|
|
|
234
302
|
jointSet = /* @__PURE__ */ new Set();
|
|
235
303
|
joints = /* @__PURE__ */ new Map();
|
|
236
304
|
bodySet = /* @__PURE__ */ new Set();
|
|
305
|
+
/**
|
|
306
|
+
* Move every body to its node's current transform — outline mode only.
|
|
307
|
+
*
|
|
308
|
+
* Computed exactly as `ensureEntry` computes a body's first pose, so an
|
|
309
|
+
* outline drawn in the editor is the outline the running game draws.
|
|
310
|
+
*/
|
|
311
|
+
poseFromTree() {
|
|
312
|
+
for (const [node, e] of this.entries) {
|
|
313
|
+
const [wx, wy] = worldPosition2D(node);
|
|
314
|
+
e.body.setTranslation({
|
|
315
|
+
x: wx / SCALE,
|
|
316
|
+
y: wy / SCALE
|
|
317
|
+
}, false);
|
|
318
|
+
e.body.setRotation(node.rotation * DEG, false);
|
|
319
|
+
}
|
|
320
|
+
this.world.propagateModifiedBodyPositionsToColliders();
|
|
321
|
+
}
|
|
237
322
|
syncBodies() {
|
|
238
323
|
const scene = this.engine.scene;
|
|
239
324
|
if (!scene) return;
|