incanto 0.7.1 → 0.8.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/bin/incanto-check.mjs +6 -4
- package/dist/2d.d.ts +91 -3
- package/dist/2d.js +4 -4
- package/dist/3d.d.ts +43 -4
- package/dist/3d.js +4 -4
- package/dist/{audio-player-C3bH_eZ5.d.ts → audio-player-Dyjg5k92.d.ts} +1 -1
- package/dist/audit-C6rMyict.js +58 -0
- package/dist/{behavior-q3cejJgs.d.ts → behavior-Bod1AyJS.d.ts} +31 -1
- package/dist/{create-game-rFulaS3s.js → create-game-66c4iYJE.js} +4 -5
- package/dist/{create-game-DuDkqnjl.js → create-game-BNDSbhy-.js} +4 -5
- package/dist/debug.d.ts +1 -1
- package/dist/{errors-BMFaY68Q.d.ts → errors-1dXlIwoR.d.ts} +7 -1
- package/dist/{gameplay-CDFgSG6z.js → gameplay-DPMgZk9W.js} +108 -1
- package/dist/gameplay.d.ts +44 -3
- package/dist/gameplay.js +2 -2
- package/dist/index.d.ts +151 -9
- package/dist/index.js +189 -4
- package/dist/{loader-DnLMMRy8.d.ts → loader-BcUDfNHn.d.ts} +1 -1
- package/dist/net.d.ts +46 -2
- package/dist/net.js +54 -2
- package/dist/particle-sim-CyUU7HVU.js +281 -0
- package/dist/{physics-2d-CZM5Y90X.js → physics-2d-q2N362ph.js} +45 -4
- package/dist/{physics-3d-DT5e8izo.js → physics-3d-CvHr31d4.js} +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +1 -1
- package/dist/{register-CpXcMiEk.js → register-Cbs7QxoV.js} +139 -4
- package/dist/{register-Cl3pAxX-.js → register-Cqjxrfq0.js} +254 -4
- package/dist/{register-C35HDZpm.js → register-CxmuI9FL.js} +1 -1
- package/dist/{particle-sim-m3CdTGSl.js → register-DRPIjrKG.js} +1178 -278
- package/dist/test.d.ts +4 -10
- package/dist/test.js +11 -16
- package/editor/assets/{agent8-N4bwVH7C.js → agent8-B8QnWCeP.js} +1 -1
- package/editor/assets/{index-CXFNanuR.js → index-CVhnNkb3.js} +81 -81
- package/editor/index.html +1 -1
- package/package.json +1 -1
- package/schemas/scene.schema.json +427 -0
- package/skills/incanto-3d-character.md +14 -0
- package/skills/incanto-audio.md +23 -0
- package/skills/incanto-building-2d-games.md +31 -0
- package/skills/incanto-building-3d-games.md +21 -0
- package/skills/incanto-gameplay-behaviors.md +28 -0
- package/skills/incanto-hud.md +24 -0
- package/skills/incanto-multiplayer.md +27 -0
- package/skills/incanto-node-reference.md +73 -0
- package/skills/incanto-physics-and-input.md +9 -0
- package/skills/incanto-verifying-your-game.md +31 -0
- package/dist/register-Dl_ixIJe.js +0 -834
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import { n as jsonEquals } from "./json-BLk7H2Qa.js";
|
|
2
|
+
//#region src/core/order-groups.ts
|
|
3
|
+
const ORDER_GROUP_BASE = {
|
|
4
|
+
background: -2e3,
|
|
5
|
+
terrain: -1e3,
|
|
6
|
+
default: 0,
|
|
7
|
+
characters: 1e3,
|
|
8
|
+
effects: 2e3,
|
|
9
|
+
overlay: 3e3
|
|
10
|
+
};
|
|
11
|
+
/** base + fine offset (unknown group names fall back to `default`). */
|
|
12
|
+
function effectiveOrder(group, renderOrder) {
|
|
13
|
+
return (ORDER_GROUP_BASE[group] ?? 0) + renderOrder;
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/core/particle-presets.ts
|
|
17
|
+
const PARTICLE_PRESETS = {
|
|
18
|
+
fire: {
|
|
19
|
+
rate: 60,
|
|
20
|
+
lifetime: [.4, .9],
|
|
21
|
+
speed: [30, 70],
|
|
22
|
+
directionDeg: -90,
|
|
23
|
+
spreadDeg: 35,
|
|
24
|
+
gravity: [0, -30],
|
|
25
|
+
sizeStart: 14,
|
|
26
|
+
sizeEnd: 3,
|
|
27
|
+
colorStart: "#ffcf5a",
|
|
28
|
+
colorEnd: "#e8401f",
|
|
29
|
+
alphaStart: .9,
|
|
30
|
+
alphaEnd: 0,
|
|
31
|
+
blend: "add"
|
|
32
|
+
},
|
|
33
|
+
smoke: {
|
|
34
|
+
rate: 20,
|
|
35
|
+
lifetime: [1.5, 2.5],
|
|
36
|
+
speed: [10, 25],
|
|
37
|
+
directionDeg: -90,
|
|
38
|
+
spreadDeg: 40,
|
|
39
|
+
gravity: [0, -12],
|
|
40
|
+
sizeStart: 10,
|
|
41
|
+
sizeEnd: 26,
|
|
42
|
+
colorStart: "#8a8a8a",
|
|
43
|
+
colorEnd: "#3a3a3a",
|
|
44
|
+
alphaStart: .35,
|
|
45
|
+
alphaEnd: 0,
|
|
46
|
+
blend: "normal"
|
|
47
|
+
},
|
|
48
|
+
sparks: {
|
|
49
|
+
rate: 80,
|
|
50
|
+
lifetime: [.3, .7],
|
|
51
|
+
speed: [120, 260],
|
|
52
|
+
spreadDeg: 360,
|
|
53
|
+
gravity: [0, 240],
|
|
54
|
+
drag: 1,
|
|
55
|
+
sizeStart: 4,
|
|
56
|
+
sizeEnd: 1,
|
|
57
|
+
colorStart: "#fff3b0",
|
|
58
|
+
colorEnd: "#ff9d2e",
|
|
59
|
+
blend: "add"
|
|
60
|
+
},
|
|
61
|
+
fireworks: {
|
|
62
|
+
rate: 0,
|
|
63
|
+
burst: 120,
|
|
64
|
+
lifetime: [.8, 1.6],
|
|
65
|
+
speed: [80, 240],
|
|
66
|
+
spreadDeg: 360,
|
|
67
|
+
gravity: [0, 90],
|
|
68
|
+
drag: .6,
|
|
69
|
+
sizeStart: 5,
|
|
70
|
+
sizeEnd: 1,
|
|
71
|
+
colorStart: "#9ad8ff",
|
|
72
|
+
colorEnd: "#ff5ad8",
|
|
73
|
+
blend: "add"
|
|
74
|
+
},
|
|
75
|
+
explosion: {
|
|
76
|
+
rate: 0,
|
|
77
|
+
burst: 60,
|
|
78
|
+
lifetime: [.25, .6],
|
|
79
|
+
speed: [150, 420],
|
|
80
|
+
spreadDeg: 360,
|
|
81
|
+
drag: 3,
|
|
82
|
+
sizeStart: 16,
|
|
83
|
+
sizeEnd: 2,
|
|
84
|
+
colorStart: "#ffe08a",
|
|
85
|
+
colorEnd: "#ff3b1f",
|
|
86
|
+
blend: "add"
|
|
87
|
+
},
|
|
88
|
+
flash: {
|
|
89
|
+
rate: 0,
|
|
90
|
+
burst: 8,
|
|
91
|
+
lifetime: [.08, .16],
|
|
92
|
+
speed: [0, 30],
|
|
93
|
+
spreadDeg: 360,
|
|
94
|
+
sizeStart: 64,
|
|
95
|
+
sizeEnd: 96,
|
|
96
|
+
colorStart: "#ffffff",
|
|
97
|
+
colorEnd: "#ffffff",
|
|
98
|
+
alphaStart: 1,
|
|
99
|
+
alphaEnd: 0,
|
|
100
|
+
blend: "add"
|
|
101
|
+
},
|
|
102
|
+
lightning: {
|
|
103
|
+
rate: 90,
|
|
104
|
+
lifetime: [.05, .12],
|
|
105
|
+
speed: [400, 900],
|
|
106
|
+
directionDeg: -90,
|
|
107
|
+
spreadDeg: 14,
|
|
108
|
+
sizeStart: 6,
|
|
109
|
+
sizeEnd: 2,
|
|
110
|
+
colorStart: "#eaf2ff",
|
|
111
|
+
colorEnd: "#7fb4ff",
|
|
112
|
+
blend: "add"
|
|
113
|
+
},
|
|
114
|
+
rain: {
|
|
115
|
+
rate: 160,
|
|
116
|
+
lifetime: [.8, 1.2],
|
|
117
|
+
speed: [300, 420],
|
|
118
|
+
directionDeg: 90,
|
|
119
|
+
spreadDeg: 6,
|
|
120
|
+
sizeStart: 3,
|
|
121
|
+
sizeEnd: 3,
|
|
122
|
+
colorStart: "#9ec8ff",
|
|
123
|
+
colorEnd: "#9ec8ff",
|
|
124
|
+
alphaStart: .5,
|
|
125
|
+
alphaEnd: .2,
|
|
126
|
+
blend: "normal"
|
|
127
|
+
},
|
|
128
|
+
snow: {
|
|
129
|
+
rate: 40,
|
|
130
|
+
lifetime: [3, 5],
|
|
131
|
+
speed: [20, 50],
|
|
132
|
+
directionDeg: 90,
|
|
133
|
+
spreadDeg: 30,
|
|
134
|
+
drag: .2,
|
|
135
|
+
sizeStart: 5,
|
|
136
|
+
sizeEnd: 4,
|
|
137
|
+
colorStart: "#ffffff",
|
|
138
|
+
colorEnd: "#ffffff",
|
|
139
|
+
alphaStart: .9,
|
|
140
|
+
alphaEnd: .6,
|
|
141
|
+
blend: "normal"
|
|
142
|
+
},
|
|
143
|
+
magic: {
|
|
144
|
+
rate: 50,
|
|
145
|
+
lifetime: [.6, 1.4],
|
|
146
|
+
speed: [20, 80],
|
|
147
|
+
spreadDeg: 360,
|
|
148
|
+
gravity: [0, -20],
|
|
149
|
+
sizeStart: 7,
|
|
150
|
+
sizeEnd: 1,
|
|
151
|
+
colorStart: "#9dffe8",
|
|
152
|
+
colorEnd: "#7a5cff",
|
|
153
|
+
blend: "add"
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
const PARTICLE_PRESET_NAMES = Object.keys(PARTICLE_PRESETS);
|
|
157
|
+
/**
|
|
158
|
+
* Apply the delta rule across three layers: schema default < preset < the
|
|
159
|
+
* scene's explicit props. A prop still equal to its SCHEMA default is
|
|
160
|
+
* considered "unset" and takes the preset value.
|
|
161
|
+
*/
|
|
162
|
+
function applyParticlePreset(target, presetName, schema) {
|
|
163
|
+
if (presetName === "custom") return;
|
|
164
|
+
const preset = PARTICLE_PRESETS[presetName];
|
|
165
|
+
if (!preset) return;
|
|
166
|
+
for (const [key, presetValue] of Object.entries(preset)) {
|
|
167
|
+
const def = schema[key]?.default;
|
|
168
|
+
const current = target[key];
|
|
169
|
+
if (def !== void 0 && jsonEquals(current, def)) target[key] = Array.isArray(presetValue) ? [...presetValue] : presetValue;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
//#endregion
|
|
173
|
+
//#region src/core/particle-sim.ts
|
|
174
|
+
const FIELDS = 9;
|
|
175
|
+
var ParticleSim = class {
|
|
176
|
+
config;
|
|
177
|
+
rng;
|
|
178
|
+
data;
|
|
179
|
+
alive = 0;
|
|
180
|
+
spawnAccumulator = 0;
|
|
181
|
+
everSpawned = false;
|
|
182
|
+
constructor(config, rng) {
|
|
183
|
+
this.config = config;
|
|
184
|
+
this.rng = rng;
|
|
185
|
+
this.data = new Float64Array(Math.max(1, config.maxParticles) * FIELDS);
|
|
186
|
+
}
|
|
187
|
+
/** Change the emission rate LIVE (particles/sec; 0 pauses emission) — lets an
|
|
188
|
+
* emitter toggle on/off at runtime (drift smoke, throttle flames). */
|
|
189
|
+
setRate(rate) {
|
|
190
|
+
this.config.rate = rate;
|
|
191
|
+
if (rate <= 0) this.spawnAccumulator = 0;
|
|
192
|
+
}
|
|
193
|
+
get count() {
|
|
194
|
+
return this.alive;
|
|
195
|
+
}
|
|
196
|
+
/** True when nothing is alive and at least one particle has ever spawned. */
|
|
197
|
+
get done() {
|
|
198
|
+
return this.everSpawned && this.alive === 0;
|
|
199
|
+
}
|
|
200
|
+
/** Spawn n particles immediately (fireworks, explosions, flashes). */
|
|
201
|
+
burst(n) {
|
|
202
|
+
for (let i = 0; i < n; i++) this.spawn();
|
|
203
|
+
}
|
|
204
|
+
update(dt) {
|
|
205
|
+
if (this.config.rate > 0) {
|
|
206
|
+
this.spawnAccumulator += this.config.rate * dt;
|
|
207
|
+
while (this.spawnAccumulator >= 1) {
|
|
208
|
+
this.spawnAccumulator -= 1;
|
|
209
|
+
this.spawn();
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
const d = this.data;
|
|
213
|
+
const [gx, gy, gz] = this.config.gravity;
|
|
214
|
+
const damp = this.config.drag > 0 ? Math.exp(-this.config.drag * dt) : 1;
|
|
215
|
+
let i = 0;
|
|
216
|
+
while (i < this.alive) {
|
|
217
|
+
const base = i * FIELDS;
|
|
218
|
+
const age = d[base + 6] + dt;
|
|
219
|
+
if (age >= d[base + 7]) {
|
|
220
|
+
this.kill(i);
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
d[base + 6] = age;
|
|
224
|
+
d[base + 3] = (d[base + 3] + gx * dt) * damp;
|
|
225
|
+
d[base + 4] = (d[base + 4] + gy * dt) * damp;
|
|
226
|
+
d[base + 5] = (d[base + 5] + gz * dt) * damp;
|
|
227
|
+
d[base + 0] = d[base + 0] + d[base + 3] * dt;
|
|
228
|
+
d[base + 1] = d[base + 1] + d[base + 4] * dt;
|
|
229
|
+
d[base + 2] = d[base + 2] + d[base + 5] * dt;
|
|
230
|
+
i += 1;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
forEach(fn) {
|
|
234
|
+
const d = this.data;
|
|
235
|
+
for (let i = 0; i < this.alive; i++) {
|
|
236
|
+
const base = i * FIELDS;
|
|
237
|
+
const age = d[base + 6];
|
|
238
|
+
const life = d[base + 7];
|
|
239
|
+
fn({
|
|
240
|
+
x: d[base + 0],
|
|
241
|
+
y: d[base + 1],
|
|
242
|
+
z: d[base + 2],
|
|
243
|
+
vx: d[base + 3],
|
|
244
|
+
vy: d[base + 4],
|
|
245
|
+
vz: d[base + 5],
|
|
246
|
+
age,
|
|
247
|
+
life,
|
|
248
|
+
t: life > 0 ? age / life : 1,
|
|
249
|
+
seed: d[base + 8]
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
spawn() {
|
|
254
|
+
if (this.alive >= this.config.maxParticles) return;
|
|
255
|
+
const base = this.alive * FIELDS;
|
|
256
|
+
const d = this.data;
|
|
257
|
+
const c = this.config;
|
|
258
|
+
const angle = (c.directionDeg + (this.rng.next() - .5) * c.spreadDeg) * Math.PI / 180;
|
|
259
|
+
const speed = c.speed[0] + this.rng.next() * (c.speed[1] - c.speed[0]);
|
|
260
|
+
const zTilt = c.spreadZ ? (this.rng.next() - .5) * (c.spreadDeg * Math.PI / 180) : 0;
|
|
261
|
+
const planar = Math.cos(zTilt);
|
|
262
|
+
d[base + 0] = 0;
|
|
263
|
+
d[base + 1] = 0;
|
|
264
|
+
d[base + 2] = 0;
|
|
265
|
+
d[base + 3] = Math.cos(angle) * speed * planar;
|
|
266
|
+
d[base + 4] = Math.sin(angle) * speed * planar;
|
|
267
|
+
d[base + 5] = Math.sin(zTilt) * speed;
|
|
268
|
+
d[base + 6] = 0;
|
|
269
|
+
d[base + 7] = c.lifetime[0] + this.rng.next() * (c.lifetime[1] - c.lifetime[0]);
|
|
270
|
+
d[base + 8] = this.rng.next();
|
|
271
|
+
this.alive += 1;
|
|
272
|
+
this.everSpawned = true;
|
|
273
|
+
}
|
|
274
|
+
kill(index) {
|
|
275
|
+
const last = this.alive - 1;
|
|
276
|
+
if (index !== last) this.data.copyWithin(index * FIELDS, last * FIELDS, last * FIELDS + FIELDS);
|
|
277
|
+
this.alive = last;
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
//#endregion
|
|
281
|
+
export { ORDER_GROUP_BASE as a, applyParticlePreset as i, PARTICLE_PRESETS as n, effectiveOrder as o, PARTICLE_PRESET_NAMES as r, ParticleSim as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
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
|
|
3
|
+
import { _ as RigidBody2D, b as validateCollider2D, g as PhysicsBody2D, h as CharacterBody2D, m as Area2D, p as Joint2D, y as Node2D } from "./register-Cqjxrfq0.js";
|
|
4
4
|
import { n as registerDebugSource } from "./debug-draw-CZmOYjL2.js";
|
|
5
5
|
//#region src/2d/physics/physics-2d.ts
|
|
6
6
|
var physics_2d_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -110,11 +110,27 @@ var Physics2D = class {
|
|
|
110
110
|
if (node.snapToGround && vy >= 0) this.kcc.enableSnapToGround(.05);
|
|
111
111
|
else this.kcc.disableSnapToGround();
|
|
112
112
|
this.kcc.setMaxSlopeClimbAngle(node.slopeLimitDeg * DEG);
|
|
113
|
+
let carryX = 0;
|
|
114
|
+
let carryY = 0;
|
|
115
|
+
if (e.ground && e.ground._physics === this) {
|
|
116
|
+
const [gx, gy] = worldPosition2D(e.ground);
|
|
117
|
+
carryX = gx - (e.groundX ?? gx);
|
|
118
|
+
carryY = gy - (e.groundY ?? gy);
|
|
119
|
+
} else e.ground = null;
|
|
113
120
|
const desired = {
|
|
114
|
-
x: (node.velocity[0] ?? 0) * this.lastDt / SCALE,
|
|
115
|
-
y: vy * this.lastDt / SCALE
|
|
121
|
+
x: ((node.velocity[0] ?? 0) * this.lastDt + carryX) / SCALE * 1,
|
|
122
|
+
y: (vy * this.lastDt + carryY) / SCALE * 1
|
|
116
123
|
};
|
|
117
|
-
|
|
124
|
+
const charBottomPx = e.body.translation().y * SCALE + charHalfHeight(node);
|
|
125
|
+
const predicate = (collider) => {
|
|
126
|
+
const other = this.byColliderHandle.get(collider.handle);
|
|
127
|
+
if (other && other !== node && other.collider.oneWay === true) {
|
|
128
|
+
if (vy < 0) return false;
|
|
129
|
+
if (charBottomPx > platformTopPx(other) + ONE_WAY_TOLERANCE_PX) return false;
|
|
130
|
+
}
|
|
131
|
+
return true;
|
|
132
|
+
};
|
|
133
|
+
this.kcc.computeColliderMovement(e.collider, desired, this.R.QueryFilterFlags.EXCLUDE_SENSORS, void 0, predicate);
|
|
118
134
|
const corrected = this.kcc.computedMovement();
|
|
119
135
|
const t = e.body.translation();
|
|
120
136
|
e.body.setNextKinematicTranslation({
|
|
@@ -122,6 +138,17 @@ var Physics2D = class {
|
|
|
122
138
|
y: t.y + corrected.y
|
|
123
139
|
});
|
|
124
140
|
node._grounded = this.kcc.computedGrounded();
|
|
141
|
+
if (node._grounded) {
|
|
142
|
+
const footX = (t.x + corrected.x) * SCALE;
|
|
143
|
+
const footY = (t.y + corrected.y) * SCALE + charHalfHeight(node) - 2;
|
|
144
|
+
const hit = this.castRay([footX, footY], [0, 1], 8, node);
|
|
145
|
+
if (hit?.node && !(hit.node instanceof CharacterBody2D)) {
|
|
146
|
+
e.ground = hit.node;
|
|
147
|
+
const [gx, gy] = worldPosition2D(hit.node);
|
|
148
|
+
e.groundX = gx;
|
|
149
|
+
e.groundY = gy;
|
|
150
|
+
} else e.ground = null;
|
|
151
|
+
} else e.ground = null;
|
|
125
152
|
}
|
|
126
153
|
/** Rapier debug segments, scaled back to pixels. Null while debugDraw is off. */
|
|
127
154
|
debugLines() {
|
|
@@ -327,6 +354,20 @@ function collectBodies(node, out) {
|
|
|
327
354
|
* Composed world position (translation only — ancestor rotation/scale are NOT
|
|
328
355
|
* supported for physics bodies; keep body ancestors untransformed or offset-only).
|
|
329
356
|
*/
|
|
357
|
+
const ONE_WAY_TOLERANCE_PX = 4;
|
|
358
|
+
/** Distance from a body's center to its lowest point, px. */
|
|
359
|
+
function charHalfHeight(node) {
|
|
360
|
+
const c = node.collider;
|
|
361
|
+
if (c.shape === "rect") return (c.size?.[1] ?? 32) / 2;
|
|
362
|
+
if (c.shape === "capsule") return (c.height ?? 32) / 2 + (c.radius ?? 8);
|
|
363
|
+
return c.radius ?? 16;
|
|
364
|
+
}
|
|
365
|
+
/** The stand-on surface of a platform (y-down: its SMALLEST y), px. */
|
|
366
|
+
function platformTopPx(node) {
|
|
367
|
+
const [, wy] = worldPosition2D(node);
|
|
368
|
+
const c = node.collider;
|
|
369
|
+
return wy - (c.shape === "rect" ? (c.size?.[1] ?? 32) / 2 : c.shape === "capsule" ? (c.height ?? 32) / 2 + (c.radius ?? 8) : c.radius ?? 16);
|
|
370
|
+
}
|
|
330
371
|
function worldPosition2D(node) {
|
|
331
372
|
let x = 0;
|
|
332
373
|
let y = 0;
|
|
@@ -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
3
|
import { n as registerDebugSource } from "./debug-draw-CZmOYjL2.js";
|
|
4
|
-
import {
|
|
4
|
+
import { A as RigidBody3D, D as Area3D, E as Joint3D, M as Node3D, N as validateCollider3D, O as CharacterBody3D, S as Terrain3D, k as PhysicsBody3D } from "./register-Cbs7QxoV.js";
|
|
5
5
|
import { Euler, Quaternion } from "three";
|
|
6
6
|
//#region src/3d/physics/physics-3d.ts
|
|
7
7
|
var physics_3d_exports = /* @__PURE__ */ __exportAll({
|
package/dist/react.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as JsonValue } from "./schema-CcoWb32N.js";
|
|
2
|
-
import { n as BehaviorCtor, v as Engine, w as Scene } from "./behavior-
|
|
2
|
+
import { n as BehaviorCtor, v as Engine, w as Scene } from "./behavior-Bod1AyJS.js";
|
|
3
3
|
import { CSSProperties, ReactNode } from "react";
|
|
4
4
|
|
|
5
5
|
//#region src/react/index.d.ts
|
package/dist/react.js
CHANGED
|
@@ -156,7 +156,7 @@ function IncantoCanvas(props) {
|
|
|
156
156
|
pointer: latest.pointer,
|
|
157
157
|
...keyboard !== void 0 ? { keyboard } : {}
|
|
158
158
|
};
|
|
159
|
-
const next = await (_gameFactory ?? (mode === "3d" ? async (o) => (await import("./create-game-
|
|
159
|
+
const next = await (_gameFactory ?? (mode === "3d" ? async (o) => (await import("./create-game-66c4iYJE.js").then((n) => n.n)).createGame3D(o) : async (o) => (await import("./create-game-BNDSbhy-.js").then((n) => n.n)).createGame2D(o)))(opts);
|
|
160
160
|
if (disposed) {
|
|
161
161
|
next.dispose();
|
|
162
162
|
return;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { f as Node } from "./loader-B4OEXDZ8.js";
|
|
2
|
-
import {
|
|
2
|
+
import { t as registerCoreNodes } from "./register-DRPIjrKG.js";
|
|
3
3
|
import { t as IncantoError } from "./errors-BpWbnbb_.js";
|
|
4
4
|
import { t as Rng } from "./rng-DP-SR7eg.js";
|
|
5
|
-
import { t as registerCoreNodes } from "./register-Dl_ixIJe.js";
|
|
6
5
|
import { i as getNodeSchema, l as registerNode } from "./registry-BVJ2HbCn.js";
|
|
7
6
|
import { t as createNoise2D } from "./noise-CGUMx44x.js";
|
|
7
|
+
import { i as applyParticlePreset, o as effectiveOrder, r as PARTICLE_PRESET_NAMES, t as ParticleSim } from "./particle-sim-CyUU7HVU.js";
|
|
8
8
|
import { n as splatWeights, t as buildHeightmap } from "./heightmap-CroQPEER.js";
|
|
9
9
|
import { AdditiveBlending, AnimationClip, AnimationMixer, Box3, BoxGeometry, BufferAttribute, BufferGeometry, CanvasTexture, CapsuleGeometry, Color, ConeGeometry, CubeCamera, CylinderGeometry, DataTexture, DepthTexture, DirectionalLight, DoubleSide, Euler, FloatType, Frustum, Group, HalfFloatType, IcosahedronGeometry, ImageBitmapLoader, InstancedBufferAttribute, InstancedMesh, LinearFilter, LinearMipmapLinearFilter, LoopOnce, LoopRepeat, MathUtils, Matrix4, Mesh, MeshBasicMaterial, MeshDepthMaterial, MeshPhysicalMaterial, MeshStandardMaterial, NearestFilter, NoBlending, NormalBlending, Object3D, PerspectiveCamera, Plane, PlaneGeometry, PointLight, Points, PointsMaterial, Quaternion, QuaternionKeyframeTrack, RGBADepthPacking, RGBAFormat, RepeatWrapping, SRGBColorSpace, ShaderChunk, ShaderMaterial, Sphere, SphereGeometry, Texture, TextureLoader, UniformsLib, UniformsUtils, Vector2, Vector3, Vector4, VectorKeyframeTrack, WebGLCubeRenderTarget, WebGLRenderTarget } from "three";
|
|
10
10
|
import { clone } from "three/addons/utils/SkeletonUtils.js";
|
|
@@ -1996,7 +1996,8 @@ var CharacterController3D = class extends Node3D {
|
|
|
1996
1996
|
jumpAction: { default: "jump" },
|
|
1997
1997
|
sprintAction: { default: "sprint" },
|
|
1998
1998
|
skinPath: { default: "../Skin" },
|
|
1999
|
-
skinYawOffset: { default: 0 }
|
|
1999
|
+
skinYawOffset: { default: 0 },
|
|
2000
|
+
animations: { default: {} }
|
|
2000
2001
|
};
|
|
2001
2002
|
view = "free";
|
|
2002
2003
|
camDistance = 4;
|
|
@@ -2027,6 +2028,13 @@ var CharacterController3D = class extends Node3D {
|
|
|
2027
2028
|
* character facing away from the camera until it first moves).
|
|
2028
2029
|
*/
|
|
2029
2030
|
skinYawOffset = 0;
|
|
2031
|
+
/**
|
|
2032
|
+
* Movement-state → animation asset map, applied to the `skinPath` model
|
|
2033
|
+
* directly — no CharacterAnimator behavior needed:
|
|
2034
|
+
* "animations": { "idle": "$idle", "run": "$run", "fastRun": "$sprint",
|
|
2035
|
+
* "walk": "$walk", "airborne": "$jump" }
|
|
2036
|
+
*/
|
|
2037
|
+
animations = {};
|
|
2030
2038
|
/** Camera yaw/pitch in radians (mouse look mutates these). */
|
|
2031
2039
|
yaw = 0;
|
|
2032
2040
|
pitch = 0;
|
|
@@ -2147,6 +2155,11 @@ var CharacterController3D = class extends Node3D {
|
|
|
2147
2155
|
const next = movementState(this.grounded, moving ? intensity : 0);
|
|
2148
2156
|
if (next !== this.state) {
|
|
2149
2157
|
this.state = next;
|
|
2158
|
+
const clip = this.animations[next];
|
|
2159
|
+
if (clip && this.skinPath !== "") {
|
|
2160
|
+
const skin = this.getNodeOrNull(this.skinPath);
|
|
2161
|
+
if (skin && "animation" in skin) skin.animation = clip;
|
|
2162
|
+
}
|
|
2150
2163
|
this.emit("movementStateChanged", next);
|
|
2151
2164
|
}
|
|
2152
2165
|
if (moving && this.skinPath !== "") {
|
|
@@ -6108,6 +6121,127 @@ function softSprite() {
|
|
|
6108
6121
|
return tex;
|
|
6109
6122
|
}
|
|
6110
6123
|
//#endregion
|
|
6124
|
+
//#region src/3d/nodes/trail-3d.ts
|
|
6125
|
+
const MAX_POINTS = 128;
|
|
6126
|
+
/**
|
|
6127
|
+
* A fading ribbon behind whatever this node is parented to — wingtip trails,
|
|
6128
|
+
* sword arcs, tyre streaks. Records the node's world position over `seconds`
|
|
6129
|
+
* and renders a camera-facing strip that tapers and fades to the tail.
|
|
6130
|
+
*
|
|
6131
|
+
* { "name": "WingTrail", "type": "Trail3D",
|
|
6132
|
+
* "props": { "width": 0.4, "color": "#dddddd", "seconds": 0.8 } }
|
|
6133
|
+
*
|
|
6134
|
+
* `emitting: false` stops laying new ribbon (the old tail still fades out).
|
|
6135
|
+
*/
|
|
6136
|
+
var Trail3D = class extends Node3D {
|
|
6137
|
+
static typeName = "Trail3D";
|
|
6138
|
+
static props = {
|
|
6139
|
+
width: { default: .3 },
|
|
6140
|
+
color: { default: "#ffffff" },
|
|
6141
|
+
opacity: { default: .8 },
|
|
6142
|
+
seconds: { default: .6 },
|
|
6143
|
+
emitting: { default: true },
|
|
6144
|
+
additive: { default: false },
|
|
6145
|
+
/** Min world distance between recorded points (jitter filter). */
|
|
6146
|
+
minDistance: { default: .05 }
|
|
6147
|
+
};
|
|
6148
|
+
width = .3;
|
|
6149
|
+
color = "#ffffff";
|
|
6150
|
+
opacity = .8;
|
|
6151
|
+
seconds = .6;
|
|
6152
|
+
emitting = true;
|
|
6153
|
+
additive = false;
|
|
6154
|
+
minDistance = .05;
|
|
6155
|
+
points = [];
|
|
6156
|
+
clock = 0;
|
|
6157
|
+
mesh = null;
|
|
6158
|
+
lastColor = "";
|
|
6159
|
+
_createObject3D() {
|
|
6160
|
+
const group = new Group();
|
|
6161
|
+
const geometry = new BufferGeometry();
|
|
6162
|
+
geometry.setAttribute("position", new BufferAttribute(new Float32Array(MAX_POINTS * 2 * 3), 3));
|
|
6163
|
+
const material = new MeshBasicMaterial({
|
|
6164
|
+
color: this.color,
|
|
6165
|
+
transparent: true,
|
|
6166
|
+
opacity: this.opacity,
|
|
6167
|
+
side: DoubleSide,
|
|
6168
|
+
depthWrite: false,
|
|
6169
|
+
blending: this.additive ? AdditiveBlending : NormalBlending
|
|
6170
|
+
});
|
|
6171
|
+
this.mesh = new Mesh(geometry, material);
|
|
6172
|
+
this.mesh.frustumCulled = false;
|
|
6173
|
+
this.mesh.matrixAutoUpdate = false;
|
|
6174
|
+
group.add(this.mesh);
|
|
6175
|
+
return group;
|
|
6176
|
+
}
|
|
6177
|
+
update(dt) {
|
|
6178
|
+
this.clock += dt;
|
|
6179
|
+
while (this.points.length > 0 && this.clock - this.points[0].t > this.seconds) this.points.shift();
|
|
6180
|
+
}
|
|
6181
|
+
_onRender3D(ctx) {
|
|
6182
|
+
const obj = this._ensureObject3D();
|
|
6183
|
+
if (this.emitting) {
|
|
6184
|
+
obj.getWorldPosition(worldScratch);
|
|
6185
|
+
const last = this.points[this.points.length - 1];
|
|
6186
|
+
if (!last || (last.x - worldScratch.x) ** 2 + (last.y - worldScratch.y) ** 2 + (last.z - worldScratch.z) ** 2 > this.minDistance * this.minDistance) {
|
|
6187
|
+
this.points.push({
|
|
6188
|
+
x: worldScratch.x,
|
|
6189
|
+
y: worldScratch.y,
|
|
6190
|
+
z: worldScratch.z,
|
|
6191
|
+
t: this.clock
|
|
6192
|
+
});
|
|
6193
|
+
if (this.points.length > MAX_POINTS) this.points.shift();
|
|
6194
|
+
}
|
|
6195
|
+
}
|
|
6196
|
+
const mesh = this.mesh;
|
|
6197
|
+
if (!mesh) return;
|
|
6198
|
+
mesh.matrixWorld.identity();
|
|
6199
|
+
const mat = mesh.material;
|
|
6200
|
+
if (this.color !== this.lastColor) {
|
|
6201
|
+
this.lastColor = this.color;
|
|
6202
|
+
mat.color = new Color(this.color);
|
|
6203
|
+
}
|
|
6204
|
+
mat.opacity = this.opacity;
|
|
6205
|
+
const n = this.points.length;
|
|
6206
|
+
const geometry = mesh.geometry;
|
|
6207
|
+
const pos = geometry.getAttribute("position");
|
|
6208
|
+
if (n < 2) {
|
|
6209
|
+
geometry.setDrawRange(0, 0);
|
|
6210
|
+
return;
|
|
6211
|
+
}
|
|
6212
|
+
for (let i = 0; i < n; i++) {
|
|
6213
|
+
const p = this.points[i];
|
|
6214
|
+
const q = this.points[Math.min(i + 1, n - 1)] ?? p;
|
|
6215
|
+
dirScratch.set(q.x - p.x, q.y - p.y, q.z - p.z);
|
|
6216
|
+
if (dirScratch.lengthSq() < 1e-8) dirScratch.set(0, 1, 0);
|
|
6217
|
+
camScratch.set(ctx.camera.position.x - p.x, ctx.camera.position.y - p.y, ctx.camera.position.z - p.z);
|
|
6218
|
+
sideScratch.crossVectors(dirScratch, camScratch).normalize();
|
|
6219
|
+
const age = (this.clock - p.t) / this.seconds;
|
|
6220
|
+
const half = this.width / 2 * Math.max(0, 1 - age);
|
|
6221
|
+
pos.setXYZ(i * 2, p.x + sideScratch.x * half, p.y + sideScratch.y * half, p.z + sideScratch.z * half);
|
|
6222
|
+
pos.setXYZ(i * 2 + 1, p.x - sideScratch.x * half, p.y - sideScratch.y * half, p.z - sideScratch.z * half);
|
|
6223
|
+
}
|
|
6224
|
+
pos.needsUpdate = true;
|
|
6225
|
+
if (!geometry.index || geometry.index.count < (MAX_POINTS - 1) * 6) {
|
|
6226
|
+
const indices = [];
|
|
6227
|
+
for (let i = 0; i < MAX_POINTS - 1; i++) {
|
|
6228
|
+
const a = i * 2;
|
|
6229
|
+
indices.push(a, a + 1, a + 2, a + 1, a + 3, a + 2);
|
|
6230
|
+
}
|
|
6231
|
+
geometry.setIndex(indices);
|
|
6232
|
+
}
|
|
6233
|
+
geometry.setDrawRange(0, (n - 1) * 6);
|
|
6234
|
+
}
|
|
6235
|
+
/** Test hook: recorded point count. */
|
|
6236
|
+
get pointCount() {
|
|
6237
|
+
return this.points.length;
|
|
6238
|
+
}
|
|
6239
|
+
};
|
|
6240
|
+
const worldScratch = new Vector3();
|
|
6241
|
+
const dirScratch = new Vector3();
|
|
6242
|
+
const camScratch = new Vector3();
|
|
6243
|
+
const sideScratch = new Vector3();
|
|
6244
|
+
//#endregion
|
|
6111
6245
|
//#region src/3d/vegetation/eztree/options.ts
|
|
6112
6246
|
/**
|
|
6113
6247
|
* Predict the EXACT triangle count `buildEzTreeGeometry` will emit for these
|
|
@@ -11481,6 +11615,7 @@ function registerNodes3D() {
|
|
|
11481
11615
|
registerNode(CharacterController3D);
|
|
11482
11616
|
registerNode(VoxelGrid3D);
|
|
11483
11617
|
registerNode(Joint3D);
|
|
11618
|
+
registerNode(Trail3D);
|
|
11484
11619
|
registerNode(Terrain3D);
|
|
11485
11620
|
registerNode(Water3D);
|
|
11486
11621
|
registerNode(Foliage3D);
|
|
@@ -11496,4 +11631,4 @@ function registerNodes3D() {
|
|
|
11496
11631
|
registerNode(CharacterBody3D);
|
|
11497
11632
|
}
|
|
11498
11633
|
//#endregion
|
|
11499
|
-
export {
|
|
11634
|
+
export { RigidBody3D as A, DEFAULT_TERRAIN_TEXTURE_BASE as C, Area3D as D, Joint3D as E, cameraRelative as F, keyboardIntensity as I, movementState as L, Node3D as M, validateCollider3D as N, CharacterBody3D as O, QUARTER_PITCH as P, rigPose as R, Terrain3D as S, terrainThemeLayers as T, resolveFlowerDensity as _, VoxelGrid3D as a, Camera3D as b, Particles3D as c, MeshInstance3D as d, DirectionalLight3D as f, Flowers3D as g, DENSITY_PRESETS as h, VOXEL_PALETTE as i, StaticBody3D as j, PhysicsBody3D as k, ModelInstance3D as l, Foliage3D as m, Water3D as n, Tree3D as o, OmniLight3D as p, WATER_MAX_RIPPLES as r, Trail3D as s, registerNodes3D as t, LoftMesh3D as u, FLOWER_VARIETIES as v, TERRAIN_THEMES as w, Billboard3D as x, CharacterController3D as y };
|