incanto 0.73.0 → 0.74.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/dist/2d.js +3 -3
- package/dist/3d.js +4 -4
- package/dist/{create-game-CAu-ucHg.js → create-game-BAiA-FjP.js} +4 -4
- package/dist/{create-game-CbTLFjis.js → create-game-ssvGvP7W.js} +4 -4
- package/dist/{environment-presets-BsFJM3v0.js → environment-presets-BkqlWewf.js} +1 -1
- package/dist/{gameplay-CRte0OVf.js → gameplay-Bxe1sMVT.js} +35 -17
- package/dist/gameplay.d.ts +5 -3
- package/dist/gameplay.js +1 -1
- package/dist/index.js +1 -1
- package/dist/{physics-2d-CovokK7s.js → physics-2d-C-SfvjzH.js} +1 -1
- package/dist/{physics-3d-BiK6Emwn.js → physics-3d-rOzeg890.js} +2 -2
- package/dist/{picking-Dtd8JInh.js → picking-BMV34Pjl.js} +1 -1
- package/dist/react.js +1 -1
- package/dist/{register-CY9QCCZs.js → register-DRQyZKGU.js} +1 -1
- package/dist/{src-D-dnVrFY.js → src-CqtvYtSN.js} +1 -1
- package/dist/{test-DZmCFz0Q.js → test-CEl0y2Sw.js} +7 -7
- package/dist/test.js +1 -1
- package/dist/vite.js +2 -2
- package/editor/assets/{agent8-GuZ5u5bi.js → agent8-BlzturGi.js} +1 -1
- package/editor/assets/{debug-BbxionO2.js → debug-BMUi8usj.js} +1 -1
- package/editor/assets/{index-CNlTzQbm.js → index-CrUCQoaB.js} +2 -2
- package/editor/index.html +1 -1
- package/package.json +1 -1
- package/skills/incanto-gameplay-behaviors.md +7 -3
- package/skills/incanto-node-reference.md +2 -0
- package/templates-app/beacon-isle-3d/package.json +1 -1
- package/templates-app/molehill-2d/package.json +1 -1
- package/templates-app/platformer-2d/package.json +1 -1
- package/templates-app/star-survivor/package.json +1 -1
- package/templates-app/tps-3d/package.json +1 -1
- package/templates-app/village-quest-3d/package.json +1 -1
package/dist/2d.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as IncantoError } from "./errors-BpWbnbb_.js";
|
|
2
2
|
import { t as showBootFailure } from "./boot-failure-CKYrEcGF.js";
|
|
3
3
|
import { t as isWebGLAvailable } from "./webgl-unavailable-C8aDbGmR.js";
|
|
4
|
-
import { a as AssetStore2D, i as syncTree2D, r as Renderer2D, t as createGame2D } from "./create-game-
|
|
5
|
-
import { _ as RigidBody2D, a as parseCells, c as ColorRect2D, d as AnimatedSprite2D, f as Sprite2D, g as PhysicsBody2D, h as CharacterBody2D, i as mergeSolidRects, l as CharacterController2D, m as Area2D, n as UILayer, o as Particles2D, p as Joint2D, r as TileMap2D, s as Label, t as registerNodes2D, u as Camera2D, v as StaticBody2D, y as Node2D } from "./register-
|
|
6
|
-
import { n as enablePhysics2D, t as Physics2D } from "./physics-2d-
|
|
4
|
+
import { a as AssetStore2D, i as syncTree2D, r as Renderer2D, t as createGame2D } from "./create-game-ssvGvP7W.js";
|
|
5
|
+
import { _ as RigidBody2D, a as parseCells, c as ColorRect2D, d as AnimatedSprite2D, f as Sprite2D, g as PhysicsBody2D, h as CharacterBody2D, i as mergeSolidRects, l as CharacterController2D, m as Area2D, n as UILayer, o as Particles2D, p as Joint2D, r as TileMap2D, s as Label, t as registerNodes2D, u as Camera2D, v as StaticBody2D, y as Node2D } from "./register-DRQyZKGU.js";
|
|
6
|
+
import { n as enablePhysics2D, t as Physics2D } from "./physics-2d-C-SfvjzH.js";
|
|
7
7
|
//#region src/2d/library-sprite.ts
|
|
8
8
|
/**
|
|
9
9
|
* What a `CharacterController2D`/`3D` will ask a skin to play, and the clip in
|
package/dist/3d.js
CHANGED
|
@@ -2,11 +2,11 @@ import { C as sunDirectionFromSky, S as sunDirectionFromElevationAzimuth, b as h
|
|
|
2
2
|
import { t as showBootFailure } from "./boot-failure-CKYrEcGF.js";
|
|
3
3
|
import { t as isWebGLAvailable } from "./webgl-unavailable-C8aDbGmR.js";
|
|
4
4
|
import { a as frameSignature, n as diffSignatures, o as frameStats, r as diffText, s as frameText, t as SIGNATURE_GRID } from "./frame-report-D-_7YF2G.js";
|
|
5
|
-
import { B as WATER_CUTOUT_MAX, G as PhysicsBody3D, J as Node3D, K as RigidBody3D, U as Area3D, V as WaterCutout3D, W as CharacterBody3D, Z as WATER_MAX_RIPPLES, q as StaticBody3D, z as Water3D } from "./gameplay-
|
|
6
|
-
import { A as Billboard3D, B as cameraRelative, C as Flowers3D, D as Camera3D, E as CharacterController3D, F as Joint3D, G as acquireOwnTexture, H as movementState, I as InstancedMesh3D, K as acquireTexture, L as MeshInstance3D, M as DEFAULT_TERRAIN_TEXTURE_BASE, N as TERRAIN_THEMES, O as BoneLookAt3D, P as terrainThemeLayers, S as DENSITY_PRESETS, T as FLOWER_VARIETIES, U as rigPose, V as keyboardIntensity, W as TextureCache3D, _ as LoftMesh3D, a as Tree3D, b as SpotLight3D, c as buildRiverRings, d as riverCarveChannels, f as riverStepFor, g as ModelInstance3D, h as Particles3D, i as VoxelGrid3D, j as Terrain3D, k as BoneAttachment3D, l as findRiverCoverageGaps, m as traceDownhillPath, n as registerNodes3D, o as Trail3D, p as smoothCourse, r as VOXEL_PALETTE, s as River3D, u as projectToRiver, v as DirectionalLight3D, w as resolveFlowerDensity, x as Foliage3D, y as OmniLight3D, z as QUARTER_PITCH } from "./environment-presets-
|
|
7
|
-
import { a as Environment3D, c as AssetStore3D, i as syncTree, o as applyQualityTier3D, r as Renderer3D, s as setEnvironment3D, t as createGame3D } from "./create-game-
|
|
5
|
+
import { B as WATER_CUTOUT_MAX, G as PhysicsBody3D, J as Node3D, K as RigidBody3D, U as Area3D, V as WaterCutout3D, W as CharacterBody3D, Z as WATER_MAX_RIPPLES, q as StaticBody3D, z as Water3D } from "./gameplay-Bxe1sMVT.js";
|
|
6
|
+
import { A as Billboard3D, B as cameraRelative, C as Flowers3D, D as Camera3D, E as CharacterController3D, F as Joint3D, G as acquireOwnTexture, H as movementState, I as InstancedMesh3D, K as acquireTexture, L as MeshInstance3D, M as DEFAULT_TERRAIN_TEXTURE_BASE, N as TERRAIN_THEMES, O as BoneLookAt3D, P as terrainThemeLayers, S as DENSITY_PRESETS, T as FLOWER_VARIETIES, U as rigPose, V as keyboardIntensity, W as TextureCache3D, _ as LoftMesh3D, a as Tree3D, b as SpotLight3D, c as buildRiverRings, d as riverCarveChannels, f as riverStepFor, g as ModelInstance3D, h as Particles3D, i as VoxelGrid3D, j as Terrain3D, k as BoneAttachment3D, l as findRiverCoverageGaps, m as traceDownhillPath, n as registerNodes3D, o as Trail3D, p as smoothCourse, r as VOXEL_PALETTE, s as River3D, u as projectToRiver, v as DirectionalLight3D, w as resolveFlowerDensity, x as Foliage3D, y as OmniLight3D, z as QUARTER_PITCH } from "./environment-presets-BkqlWewf.js";
|
|
7
|
+
import { a as Environment3D, c as AssetStore3D, i as syncTree, o as applyQualityTier3D, r as Renderer3D, s as setEnvironment3D, t as createGame3D } from "./create-game-BAiA-FjP.js";
|
|
8
8
|
import { n as splatWeights, t as buildHeightmap } from "./heightmap-BYgD5Edk.js";
|
|
9
|
-
import { n as enablePhysics3D, t as Physics3D } from "./physics-3d-
|
|
9
|
+
import { n as enablePhysics3D, t as Physics3D } from "./physics-3d-rOzeg890.js";
|
|
10
10
|
//#region src/3d/model-verdict.ts
|
|
11
11
|
/** Mixamo exports every bone as `mixamorigX`; the retargeter binds by that name. */
|
|
12
12
|
const MIXAMO = /^mixamorig[:_]?/i;
|
|
@@ -4,12 +4,12 @@ import { C as qualityRendering, S as qualityEnvironment, _ as AudioPlayer, v as
|
|
|
4
4
|
import { t as IncantoError } from "./errors-BpWbnbb_.js";
|
|
5
5
|
import { n as attachTouchControls } from "./touch-CioTZB-y.js";
|
|
6
6
|
import { n as withWebGLContext, r as resolveRendering } from "./webgl-unavailable-C8aDbGmR.js";
|
|
7
|
-
import { a as devServerLibrary, c as applyDriveStep, d as audioErrors, i as crossFade, l as wireDevChannel, n as teardown, o as openBundledEditor, r as pauseWhenHidden, s as poseFromRenderer, t as nodeFromHits, u as claimCanvasGestures } from "./picking-
|
|
7
|
+
import { a as devServerLibrary, c as applyDriveStep, d as audioErrors, i as crossFade, l as wireDevChannel, n as teardown, o as openBundledEditor, r as pauseWhenHidden, s as poseFromRenderer, t as nodeFromHits, u as claimCanvasGestures } from "./picking-BMV34Pjl.js";
|
|
8
8
|
import { o as frameStats } from "./frame-report-D-_7YF2G.js";
|
|
9
|
-
import { G as PhysicsBody3D, J as Node3D, X as createCausticsQuad, n as registerGameplayBehaviors } from "./gameplay-
|
|
9
|
+
import { G as PhysicsBody3D, J as Node3D, X as createCausticsQuad, n as registerGameplayBehaviors } from "./gameplay-Bxe1sMVT.js";
|
|
10
10
|
import { t as debugSources } from "./debug-draw-BM3DsvtT.js";
|
|
11
|
-
import { D as Camera3D, W as TextureCache3D, g as ModelInstance3D, n as registerNodes3D, t as resolveEnvironmentHdri, v as DirectionalLight3D } from "./environment-presets-
|
|
12
|
-
import { n as enablePhysics3D } from "./physics-3d-
|
|
11
|
+
import { D as Camera3D, W as TextureCache3D, g as ModelInstance3D, n as registerNodes3D, t as resolveEnvironmentHdri, v as DirectionalLight3D } from "./environment-presets-BkqlWewf.js";
|
|
12
|
+
import { n as enablePhysics3D } from "./physics-3d-rOzeg890.js";
|
|
13
13
|
import { ACESFilmicToneMapping, AmbientLight, Box3, BufferAttribute, BufferGeometry, Color, DepthTexture, EquirectangularReflectionMapping, FloatType, Fog, HalfFloatType, LineBasicMaterial, LineSegments, LoadingManager, Matrix4, Mesh, PCFShadowMap, PMREMGenerator, PerspectiveCamera, PlaneGeometry, Quaternion, Raycaster, Scene, ShaderMaterial, Vector2, Vector3, WebGLRenderTarget, WebGLRenderer } from "three";
|
|
14
14
|
import { VRMLoaderPlugin, VRMUtils } from "@pixiv/three-vrm";
|
|
15
15
|
import { GLTFLoader } from "three/addons/loaders/GLTFLoader.js";
|
|
@@ -4,12 +4,12 @@ import { C as qualityRendering, _ as AudioPlayer, v as Engine } from "./register
|
|
|
4
4
|
import { t as IncantoError } from "./errors-BpWbnbb_.js";
|
|
5
5
|
import { n as attachTouchControls } from "./touch-CioTZB-y.js";
|
|
6
6
|
import { n as withWebGLContext, r as resolveRendering } from "./webgl-unavailable-C8aDbGmR.js";
|
|
7
|
-
import { a as devServerLibrary, c as applyDriveStep, d as audioErrors, i as crossFade, l as wireDevChannel, n as teardown, o as openBundledEditor, r as pauseWhenHidden, t as nodeFromHits, u as claimCanvasGestures } from "./picking-
|
|
7
|
+
import { a as devServerLibrary, c as applyDriveStep, d as audioErrors, i as crossFade, l as wireDevChannel, n as teardown, o as openBundledEditor, r as pauseWhenHidden, t as nodeFromHits, u as claimCanvasGestures } from "./picking-BMV34Pjl.js";
|
|
8
8
|
import { o as frameStats } from "./frame-report-D-_7YF2G.js";
|
|
9
|
-
import { n as registerGameplayBehaviors } from "./gameplay-
|
|
10
|
-
import { g as PhysicsBody2D, n as UILayer, t as registerNodes2D, u as Camera2D, y as Node2D } from "./register-
|
|
9
|
+
import { n as registerGameplayBehaviors } from "./gameplay-Bxe1sMVT.js";
|
|
10
|
+
import { g as PhysicsBody2D, n as UILayer, t as registerNodes2D, u as Camera2D, y as Node2D } from "./register-DRQyZKGU.js";
|
|
11
11
|
import { t as debugSources } from "./debug-draw-BM3DsvtT.js";
|
|
12
|
-
import { n as enablePhysics2D } from "./physics-2d-
|
|
12
|
+
import { n as enablePhysics2D } from "./physics-2d-C-SfvjzH.js";
|
|
13
13
|
import { Box3, BufferAttribute, BufferGeometry, Color, LineBasicMaterial, LineSegments, LinearFilter, NearestFilter, OrthographicCamera, Raycaster, SRGBColorSpace, Scene, TextureLoader, Vector2, Vector3, WebGLRenderer } from "three";
|
|
14
14
|
//#region src/2d/assets.ts
|
|
15
15
|
/**
|
|
@@ -5,7 +5,7 @@ import { t as Rng } from "./rng-CDOMybym.js";
|
|
|
5
5
|
import { c as getNodeSchema, h as didYouMean, p as registerNode } from "./touch-CioTZB-y.js";
|
|
6
6
|
import { t as createNoise2D } from "./noise-D3nPpmFg.js";
|
|
7
7
|
import { i as ParticleSim, n as resolveFrames, o as PARTICLE_PRESET_NAMES, r as validateAnimations, s as applyParticlePreset, t as resolveAnimation } from "./sprite-animation-Bz3DHD_4.js";
|
|
8
|
-
import { E as tolerateUnknownAction, G as PhysicsBody3D, H as rejectScale, J as Node3D, K as RigidBody3D, O as effectRng, Q as colliderFootDrop, U as Area3D, V as WaterCutout3D, W as CharacterBody3D, et as worldPosition, q as StaticBody3D, z as Water3D } from "./gameplay-
|
|
8
|
+
import { E as tolerateUnknownAction, G as PhysicsBody3D, H as rejectScale, J as Node3D, K as RigidBody3D, O as effectRng, Q as colliderFootDrop, U as Area3D, V as WaterCutout3D, W as CharacterBody3D, et as worldPosition, q as StaticBody3D, z as Water3D } from "./gameplay-Bxe1sMVT.js";
|
|
9
9
|
import { t as checkSheetGrid } from "./sheet-grid-Cea343VO.js";
|
|
10
10
|
import { n as splatWeights, t as buildHeightmap } from "./heightmap-BYgD5Edk.js";
|
|
11
11
|
import { AdditiveBlending, AnimationClip, AnimationMixer, Box3, BoxGeometry, BufferAttribute, BufferGeometry, CanvasTexture, CapsuleGeometry, ClampToEdgeWrapping, Color, ConeGeometry, CylinderGeometry, DataTexture, DirectionalLight, DoubleSide, DynamicDrawUsage, Euler, Group, IcosahedronGeometry, ImageBitmapLoader, InstancedBufferAttribute, InstancedMesh, LinearFilter, LinearMipmapLinearFilter, LoopOnce, LoopRepeat, MathUtils, Matrix4, Mesh, MeshBasicMaterial, MeshDepthMaterial, MeshPhysicalMaterial, MeshStandardMaterial, NearestFilter, NoBlending, NoColorSpace, NormalBlending, PerspectiveCamera, PlaneGeometry, PointLight, Points, PointsMaterial, Quaternion, QuaternionKeyframeTrack, RGBADepthPacking, RGBAFormat, RepeatWrapping, SRGBColorSpace, ShaderChunk, ShaderMaterial, SphereGeometry, SpotLight, Texture, TextureLoader, UniformsLib, UniformsUtils, Vector3, Vector4, VectorKeyframeTrack } from "three";
|
|
@@ -5737,15 +5737,15 @@ var DayNight = class extends Behavior {
|
|
|
5737
5737
|
}
|
|
5738
5738
|
update(dt) {
|
|
5739
5739
|
if (!this.paused) this.hour = (this.hour + dt / this.daySeconds * 24) % 24;
|
|
5740
|
-
this.applyClock -= dt;
|
|
5741
|
-
if (this.applyClock > 0) return;
|
|
5742
|
-
this.applyClock = .2;
|
|
5743
|
-
this.applyHour();
|
|
5744
5740
|
const next = phaseOf(this.hour);
|
|
5745
5741
|
if (next !== this.phase) {
|
|
5746
5742
|
this.phase = next;
|
|
5747
5743
|
this.emit("dayPhaseChanged", next);
|
|
5748
5744
|
}
|
|
5745
|
+
this.applyClock -= dt;
|
|
5746
|
+
if (this.applyClock > 0) return;
|
|
5747
|
+
this.applyClock = .2;
|
|
5748
|
+
this.applyHour();
|
|
5749
5749
|
}
|
|
5750
5750
|
applyHour() {
|
|
5751
5751
|
const engine = this.node.tree?.engine;
|
|
@@ -6437,10 +6437,11 @@ var Interactable = class extends Behavior {
|
|
|
6437
6437
|
/**
|
|
6438
6438
|
* Which Interactable answers a press when several are in range. `any`:
|
|
6439
6439
|
* every one of them (the old rule). `nearest`: only the closest to the
|
|
6440
|
-
* actor. `facing`:
|
|
6441
|
-
* forward
|
|
6442
|
-
* on the desk and the drawer under it are two different looks
|
|
6443
|
-
*
|
|
6440
|
+
* actor. `facing`: of those inside `coneDeg` of the current camera's
|
|
6441
|
+
* forward, the one nearest the CENTRE of the view — a crosshair — so a
|
|
6442
|
+
* note on the desk and the drawer under it are two different looks, and
|
|
6443
|
+
* in third person the plot the farmer looks at beats the plot under the
|
|
6444
|
+
* farmer's feet (with no camera, the same as `nearest`).
|
|
6444
6445
|
*/
|
|
6445
6446
|
focus: {
|
|
6446
6447
|
default: "any",
|
|
@@ -6516,24 +6517,27 @@ var Interactable = class extends Behavior {
|
|
|
6516
6517
|
claims(actor, self) {
|
|
6517
6518
|
const eye = this.focus === "facing" ? cameraEye(this.node.getRoot()) : null;
|
|
6518
6519
|
const from = eye ? eye.at : worldPosition(actor);
|
|
6519
|
-
const
|
|
6520
|
-
if (!eye) return
|
|
6520
|
+
const centred = (target) => {
|
|
6521
|
+
if (!eye) return 1;
|
|
6521
6522
|
const dx = (target[0] ?? 0) - (from[0] ?? 0);
|
|
6522
6523
|
const dy = (target[1] ?? 0) - (from[1] ?? 0);
|
|
6523
6524
|
const dz = (target[2] ?? 0) - (from[2] ?? 0);
|
|
6524
6525
|
const len = Math.hypot(dx, dy, dz);
|
|
6525
|
-
if (len < 1e-6) return
|
|
6526
|
-
return dx / len * eye.fx + dy / len * eye.fy + dz / len * eye.fz
|
|
6526
|
+
if (len < 1e-6) return 1;
|
|
6527
|
+
return dx / len * eye.fx + dy / len * eye.fy + dz / len * eye.fz;
|
|
6527
6528
|
};
|
|
6528
|
-
|
|
6529
|
-
const
|
|
6529
|
+
const edge = Math.cos(this.coneDeg / 2 * (Math.PI / 180));
|
|
6530
|
+
const mineCentred = centred(self);
|
|
6531
|
+
if (mineCentred < edge) return false;
|
|
6532
|
+
const mine = eye ? -mineCentred : distance(from, self);
|
|
6530
6533
|
for (const other of interactablesIn(this.node.getRoot())) {
|
|
6531
6534
|
if (other === this || other.focus === "any" || other.actorGroup !== this.actorGroup) continue;
|
|
6532
6535
|
if (!hasPosition(other.node)) continue;
|
|
6533
6536
|
const there = worldPosition(other.node);
|
|
6534
6537
|
if (distance(worldPosition(actor), there) > other.range) continue;
|
|
6535
|
-
|
|
6536
|
-
if (
|
|
6538
|
+
const theirsCentred = centred(there);
|
|
6539
|
+
if (eye && theirsCentred < edge) continue;
|
|
6540
|
+
if ((eye ? -theirsCentred : distance(from, there)) < mine) return false;
|
|
6537
6541
|
}
|
|
6538
6542
|
return true;
|
|
6539
6543
|
}
|
|
@@ -7046,12 +7050,16 @@ var PathFollow = class extends Behavior {
|
|
|
7046
7050
|
speed: { default: 120 },
|
|
7047
7051
|
loop: { default: false },
|
|
7048
7052
|
/** Move the parent node instead of this one — the AI-on-a-child pattern `Chase`/`Patrol`/`Wander` share. */
|
|
7049
|
-
moveParent: { default: false }
|
|
7053
|
+
moveParent: { default: false },
|
|
7054
|
+
/** A node to TURN toward the direction of travel (a skin, a hull) — the same `facePath`/`turnSpeed` the other movers have. */
|
|
7055
|
+
...FACING_PROPS
|
|
7050
7056
|
};
|
|
7051
7057
|
/** Units per second (px in 2D, meters in 3D). */
|
|
7052
7058
|
speed = 120;
|
|
7053
7059
|
loop = false;
|
|
7054
7060
|
moveParent = false;
|
|
7061
|
+
facePath = "";
|
|
7062
|
+
turnSpeed = 100;
|
|
7055
7063
|
waypoints = [];
|
|
7056
7064
|
index = 0;
|
|
7057
7065
|
/** True while there is somewhere left to go. */
|
|
@@ -7071,6 +7079,7 @@ var PathFollow = class extends Behavior {
|
|
|
7071
7079
|
if (!this.moving) return;
|
|
7072
7080
|
const node = this.mover();
|
|
7073
7081
|
let budget = this.speed * dt;
|
|
7082
|
+
const from = [...node.position];
|
|
7074
7083
|
let at = [...node.position];
|
|
7075
7084
|
while (budget > 0 && this.index < this.waypoints.length) {
|
|
7076
7085
|
const target = this.waypoints[this.index];
|
|
@@ -7084,12 +7093,21 @@ var PathFollow = class extends Behavior {
|
|
|
7084
7093
|
if (this.index >= this.waypoints.length) if (this.loop && this.waypoints.length > 1) this.index = 0;
|
|
7085
7094
|
else {
|
|
7086
7095
|
moveBody(node, at, dt);
|
|
7096
|
+
this.face(node, from, at, dt);
|
|
7087
7097
|
this.node.emit("arrived");
|
|
7088
7098
|
return;
|
|
7089
7099
|
}
|
|
7090
7100
|
} else break;
|
|
7091
7101
|
}
|
|
7092
7102
|
moveBody(node, at, dt);
|
|
7103
|
+
this.face(node, from, at, dt);
|
|
7104
|
+
}
|
|
7105
|
+
/** `facePath` turns toward where this frame went — nothing when it did not move. */
|
|
7106
|
+
face(node, from, to, dt) {
|
|
7107
|
+
if (this.facePath === "") return;
|
|
7108
|
+
const skin = this.node.getNodeOrNull(this.facePath);
|
|
7109
|
+
if (!skin) return;
|
|
7110
|
+
faceTravel(skin, to.map((v, i) => v - (from[i] ?? 0)), dt, this.turnSpeed);
|
|
7093
7111
|
}
|
|
7094
7112
|
/** The node this walks: the parent under `moveParent`, else this one — both must be spatial. */
|
|
7095
7113
|
mover() {
|
package/dist/gameplay.d.ts
CHANGED
|
@@ -1334,13 +1334,13 @@ declare function hitStop(engine: Engine, seconds?: number): void;
|
|
|
1334
1334
|
*/
|
|
1335
1335
|
declare class PathFollow extends Behavior {
|
|
1336
1336
|
static readonly signals: readonly string[];
|
|
1337
|
-
static readonly props:
|
|
1338
|
-
default: number | boolean;
|
|
1339
|
-
}>;
|
|
1337
|
+
static readonly props: PropSchema;
|
|
1340
1338
|
/** Units per second (px in 2D, meters in 3D). */
|
|
1341
1339
|
speed: number;
|
|
1342
1340
|
loop: boolean;
|
|
1343
1341
|
moveParent: boolean;
|
|
1342
|
+
facePath: string;
|
|
1343
|
+
turnSpeed: number;
|
|
1344
1344
|
private waypoints;
|
|
1345
1345
|
private index;
|
|
1346
1346
|
/** True while there is somewhere left to go. */
|
|
@@ -1349,6 +1349,8 @@ declare class PathFollow extends Behavior {
|
|
|
1349
1349
|
/** Stop in place (keeps the node where it is). */
|
|
1350
1350
|
stop(): void;
|
|
1351
1351
|
override update(dt: number): void;
|
|
1352
|
+
/** `facePath` turns toward where this frame went — nothing when it did not move. */
|
|
1353
|
+
private face;
|
|
1352
1354
|
/** The node this walks: the parent under `moveParent`, else this one — both must be spatial. */
|
|
1353
1355
|
private mover;
|
|
1354
1356
|
}
|
package/dist/gameplay.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as localFromWorld, A as FaceTarget, C as GameFlow, D as FollowCamera, F as Currency, I as Collector, L as Checkpoint, M as phaseOf, N as DamageOnContact, P as Health, R as Chase, S as Interactable, T as restartScene, _ as Lifetime, a as Wander, b as hitStop, c as ScoreKeeper, d as PrefabShelf, et as worldPosition, f as Pickup, g as MoveTo, h as Oscillate, i as WaveSpawner, j as DayNight, k as FloatAway, l as SavePoint, m as PathFollow, n as registerGameplayBehaviors, o as Turret, p as Patrol, r as ZombieAI, s as Spawner, t as GAMEPLAY_BEHAVIORS, u as Projectile, v as CameraShake, w as goToScene, x as screenFlash, y as Cooldown } from "./gameplay-
|
|
1
|
+
import { $ as localFromWorld, A as FaceTarget, C as GameFlow, D as FollowCamera, F as Currency, I as Collector, L as Checkpoint, M as phaseOf, N as DamageOnContact, P as Health, R as Chase, S as Interactable, T as restartScene, _ as Lifetime, a as Wander, b as hitStop, c as ScoreKeeper, d as PrefabShelf, et as worldPosition, f as Pickup, g as MoveTo, h as Oscillate, i as WaveSpawner, j as DayNight, k as FloatAway, l as SavePoint, m as PathFollow, n as registerGameplayBehaviors, o as Turret, p as Patrol, r as ZombieAI, s as Spawner, t as GAMEPLAY_BEHAVIORS, u as Projectile, v as CameraShake, w as goToScene, x as screenFlash, y as Cooldown } from "./gameplay-Bxe1sMVT.js";
|
|
2
2
|
export { CameraShake, Chase, Checkpoint, Collector, Cooldown, Currency, DamageOnContact, DayNight, FaceTarget, FloatAway, FollowCamera, GAMEPLAY_BEHAVIORS, GameFlow, Health, Interactable, Lifetime, MoveTo, Oscillate, PathFollow, Patrol, Pickup, PrefabShelf, Projectile, SavePoint, ScoreKeeper, Spawner, Turret, Wander, WaveSpawner, ZombieAI, goToScene, hitStop, localFromWorld, phaseOf, registerGameplayBehaviors, restartScene, screenFlash, worldPosition };
|
package/dist/index.js
CHANGED
|
@@ -9,5 +9,5 @@ import { t as showBootFailure } from "./boot-failure-CKYrEcGF.js";
|
|
|
9
9
|
import { a as logText, i as logReport, o as parseDrive, r as resolveRendering, t as isWebGLAvailable } from "./webgl-unavailable-C8aDbGmR.js";
|
|
10
10
|
import { t as createNoise2D } from "./noise-D3nPpmFg.js";
|
|
11
11
|
import { a as PARTICLE_PRESETS, i as ParticleSim, n as resolveFrames, o as PARTICLE_PRESET_NAMES, s as applyParticlePreset, t as resolveAnimation } from "./sprite-animation-Bz3DHD_4.js";
|
|
12
|
-
import { a as findPath, i as preloadUrls, n as assetUrls, o as gridFromRows, r as preloadSceneAssets, t as VERSION } from "./src-
|
|
12
|
+
import { a as findPath, i as preloadUrls, n as assetUrls, o as gridFromRows, r as preloadSceneAssets, t as VERSION } from "./src-CqtvYtSN.js";
|
|
13
13
|
export { AudioBuses, AudioPlayer, BASE_LOCALE, Behavior, CONST_REF_KEY, EffectLog, Engine, HudLayer, IncantoError, InputMap, Localization, LogManager, MusicManager, Node, ORDER_GROUP_BASE, PARTICLE_PRESETS, PARTICLE_PRESET_NAMES, ParticleSim, ROLLOFF_MODELS, Respawn, Rng, SCENE_FORMAT, SFX_PRESETS, SFX_PRESET_NAMES, SaveSlots, Scene, SceneTree, Settings, SfxEngine, Signal, T_PREFIX, Timer, TouchControls, UiBanner, UiBar, UiButton, UiDialogue, UiFrameCapSelect, UiImage, UiLanguageSelect, UiMuteToggle, UiPanel, UiQualitySelect, UiRenderScaleSelect, UiSelect, UiSlider, UiText, UiToggle, UiVolumeSlider, VERSION, WebAudioMusicBackend, applyParticlePreset, assetUrls, attachTouchControls, auditScene, behaviorSchema, behaviorSignals, behaviorsWithoutSave, captureBehaviors, clearBehaviors, clearRegistry, computeViewport, createNode, createNoise2D, createSaveStore, crossfadeGains, describeRefProblem, duplicateNode, effectiveOrder, fadeGain, findPath, getBehavior, getNodeSchema, getNodeSignals, getNodeType, gridFromRows, isAudioContextAvailable, isConstRef, isWebGLAvailable, joystickVector, jsonClone, jsonEquals, jsonKind, loadScene, logReport, logText, mergeStaticSignals, newUid, nodeRefWarnings, parseDrive, parseNodePath, preloadSceneAssets, preloadUrls, qualityEnvironment, readDeviceHints, registerBehavior, registerCoreNodes, registerNode, registeredBehaviors, registeredTypes, replay, resolveAnimation, resolveConstants, resolveFrames, resolveOrderGroups, resolveRefInJson, resolveRendering, resolveViewport, restoreBehaviors, savesWithoutUid, serializeNode, sfxDuration, showBootFailure, spatialGain, spatialPan, startRecording, suggestLocale, suggestQuality, synthSfx, translationKey };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { o as __exportAll } from "./json-CfTjpvW8.js";
|
|
2
2
|
import { Y as diagnose } from "./save-slots-CEUGeLuB.js";
|
|
3
3
|
import { t as IncantoError } from "./errors-BpWbnbb_.js";
|
|
4
|
-
import { _ as RigidBody2D, b as validateCollider2D, g as PhysicsBody2D, h as CharacterBody2D, m as Area2D, p as Joint2D, v as StaticBody2D, y as Node2D } from "./register-
|
|
4
|
+
import { _ as RigidBody2D, b as validateCollider2D, g as PhysicsBody2D, h as CharacterBody2D, m as Area2D, p as Joint2D, v as StaticBody2D, y as Node2D } from "./register-DRQyZKGU.js";
|
|
5
5
|
import { n as registerDebugSource } from "./debug-draw-BM3DsvtT.js";
|
|
6
6
|
import { n as jointContacts, t as withoutRapierInitNoise } from "./quiet-rapier-C6fW4zcW.js";
|
|
7
7
|
//#region src/2d/physics/physics-2d.ts
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { o as __exportAll } from "./json-CfTjpvW8.js";
|
|
2
2
|
import { Y as diagnose } from "./save-slots-CEUGeLuB.js";
|
|
3
3
|
import { t as IncantoError } from "./errors-BpWbnbb_.js";
|
|
4
|
-
import { G as PhysicsBody3D, J as Node3D, K as RigidBody3D, U as Area3D, W as CharacterBody3D, Y as validateCollider3D, q as StaticBody3D } from "./gameplay-
|
|
4
|
+
import { G as PhysicsBody3D, J as Node3D, K as RigidBody3D, U as Area3D, W as CharacterBody3D, Y as validateCollider3D, q as StaticBody3D } from "./gameplay-Bxe1sMVT.js";
|
|
5
5
|
import { n as registerDebugSource } from "./debug-draw-BM3DsvtT.js";
|
|
6
6
|
import { n as jointContacts, t as withoutRapierInitNoise } from "./quiet-rapier-C6fW4zcW.js";
|
|
7
|
-
import { F as Joint3D, I as InstancedMesh3D, R as buildMeshGeometry, j as Terrain3D } from "./environment-presets-
|
|
7
|
+
import { F as Joint3D, I as InstancedMesh3D, R as buildMeshGeometry, j as Terrain3D } from "./environment-presets-BkqlWewf.js";
|
|
8
8
|
import { Euler, Matrix4, Quaternion, Vector3 } from "three";
|
|
9
9
|
//#region src/3d/physics/collider-lines.ts
|
|
10
10
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { _ as AudioPlayer } from "./register-CjociOtt.js";
|
|
2
2
|
import { i as logReport, o as parseDrive } from "./webgl-unavailable-C8aDbGmR.js";
|
|
3
3
|
import { a as frameSignature, i as frameImage, o as frameStats } from "./frame-report-D-_7YF2G.js";
|
|
4
|
-
import { et as worldPosition } from "./gameplay-
|
|
4
|
+
import { et as worldPosition } from "./gameplay-Bxe1sMVT.js";
|
|
5
5
|
//#region src/core/audio-errors.ts
|
|
6
6
|
/** Every AudioPlayer under `root` whose source could not be played. */
|
|
7
7
|
function audioErrors(root) {
|
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-BAiA-FjP.js").then((n) => n.n)).createGame3D(o) : async (o) => (await import("./create-game-ssvGvP7W.js").then((n) => n.n)).createGame2D(o)))(opts);
|
|
160
160
|
if (disposed) {
|
|
161
161
|
next.dispose();
|
|
162
162
|
return;
|
|
@@ -3,7 +3,7 @@ import { M as translateOn, t as registerCoreNodes } from "./register-CjociOtt.js
|
|
|
3
3
|
import { t as IncantoError } from "./errors-BpWbnbb_.js";
|
|
4
4
|
import { c as getNodeSchema, h as didYouMean, p as registerNode } from "./touch-CioTZB-y.js";
|
|
5
5
|
import { i as ParticleSim, n as resolveFrames, o as PARTICLE_PRESET_NAMES, r as validateAnimations, s as applyParticlePreset, t as resolveAnimation } from "./sprite-animation-Bz3DHD_4.js";
|
|
6
|
-
import { $ as localFromWorld, E as tolerateUnknownAction, O as effectRng, et as worldPosition } from "./gameplay-
|
|
6
|
+
import { $ as localFromWorld, E as tolerateUnknownAction, O as effectRng, et as worldPosition } from "./gameplay-Bxe1sMVT.js";
|
|
7
7
|
import { t as checkSheetGrid } from "./sheet-grid-Cea343VO.js";
|
|
8
8
|
import { AdditiveBlending, BufferAttribute, BufferGeometry, CanvasTexture, Color, DynamicDrawUsage, Group, InstancedMesh, MathUtils, Matrix4, Mesh, MeshBasicMaterial, NearestFilter, NormalBlending, Object3D, PlaneGeometry, SRGBColorSpace } from "three";
|
|
9
9
|
//#region src/2d/physics/collider-validate.ts
|
|
@@ -199,6 +199,6 @@ async function preloadSceneAssets(assets, title) {
|
|
|
199
199
|
//#endregion
|
|
200
200
|
//#region src/index.ts
|
|
201
201
|
/** Engine version. Kept in sync with package.json by the release pipeline. */
|
|
202
|
-
const VERSION = "0.
|
|
202
|
+
const VERSION = "0.74.0";
|
|
203
203
|
//#endregion
|
|
204
204
|
export { findPath as a, preloadUrls as i, assetUrls as n, gridFromRows as o, preloadSceneAssets as r, VERSION as t };
|
|
@@ -5,9 +5,9 @@ import { t as IncantoError } from "./errors-BpWbnbb_.js";
|
|
|
5
5
|
import { t as Rng } from "./rng-CDOMybym.js";
|
|
6
6
|
import { a as LIGHT_NODE_TYPES, n as startRecording } from "./replay-B6BbgGM_.js";
|
|
7
7
|
import { c as getNodeSchema, d as mergeStaticProps, u as getNodeType } from "./touch-CioTZB-y.js";
|
|
8
|
-
import { et as worldPosition, n as registerGameplayBehaviors } from "./gameplay-
|
|
9
|
-
import { t as registerNodes2D } from "./register-
|
|
10
|
-
import { n as registerNodes3D, t as resolveEnvironmentHdri } from "./environment-presets-
|
|
8
|
+
import { et as worldPosition, n as registerGameplayBehaviors } from "./gameplay-Bxe1sMVT.js";
|
|
9
|
+
import { t as registerNodes2D } from "./register-DRQyZKGU.js";
|
|
10
|
+
import { n as registerNodes3D, t as resolveEnvironmentHdri } from "./environment-presets-BkqlWewf.js";
|
|
11
11
|
import { a as NetworkManager, c as readSyncKey, i as sanitizeName, n as registerNodesNet, r as NetworkSpawner, s as findOwnerNode, t as createSplitScreen } from "./split-screen-BxZ5rBe7.js";
|
|
12
12
|
import { Box3, Euler, Frustum, Matrix4, PerspectiveCamera, Quaternion, Ray, Vector3 } from "three";
|
|
13
13
|
//#region src/core/asset-urls.ts
|
|
@@ -4109,10 +4109,10 @@ async function runScript(json, opts) {
|
|
|
4109
4109
|
if (opts.locale) engine.locale.locale = opts.locale;
|
|
4110
4110
|
const physics = opts.physics ?? "auto";
|
|
4111
4111
|
if (physics === "2d" || physics === "auto" && scene.dimension === "2d") {
|
|
4112
|
-
const { enablePhysics2D } = await import("./physics-2d-
|
|
4112
|
+
const { enablePhysics2D } = await import("./physics-2d-C-SfvjzH.js").then((n) => n.r);
|
|
4113
4113
|
await enablePhysics2D(engine);
|
|
4114
4114
|
} else if (physics === "3d" || physics === "auto" && scene.dimension === "3d") {
|
|
4115
|
-
const { enablePhysics3D } = await import("./physics-3d-
|
|
4115
|
+
const { enablePhysics3D } = await import("./physics-3d-rOzeg890.js").then((n) => n.r);
|
|
4116
4116
|
await enablePhysics3D(engine);
|
|
4117
4117
|
}
|
|
4118
4118
|
const failures = [];
|
|
@@ -4350,10 +4350,10 @@ async function createPlaySession(json, opts = {}) {
|
|
|
4350
4350
|
engine.setScene(scene);
|
|
4351
4351
|
const physics = opts.physics ?? "auto";
|
|
4352
4352
|
if (physics === "2d" || physics === "auto" && scene.dimension === "2d") {
|
|
4353
|
-
const { enablePhysics2D } = await import("./physics-2d-
|
|
4353
|
+
const { enablePhysics2D } = await import("./physics-2d-C-SfvjzH.js").then((n) => n.r);
|
|
4354
4354
|
await enablePhysics2D(engine);
|
|
4355
4355
|
} else if (physics === "3d" || physics === "auto" && scene.dimension === "3d") {
|
|
4356
|
-
const { enablePhysics3D } = await import("./physics-3d-
|
|
4356
|
+
const { enablePhysics3D } = await import("./physics-3d-rOzeg890.js").then((n) => n.r);
|
|
4357
4357
|
await enablePhysics3D(engine);
|
|
4358
4358
|
}
|
|
4359
4359
|
const stepMs = 1e3 / (opts.fixedHz ?? 60);
|
package/dist/test.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { i as instancedScenes, r as auditScene } from "./replay-B6BbgGM_.js";
|
|
2
|
-
import { A as geometricPicker, C as facingReport, D as playtest, E as findPlayer, F as sceneAssetUrls, M as pointAtNode, N as describeFraming, O as playtestFailed, P as framingText, S as collectionProblems, T as failingReplays, _ as feelReport, a as registerAllNodes, b as takeCollectionSnapshots, c as feelsRung, d as ladderVerdict, f as saysRung, g as playMultiplayer, h as multiplayText, i as findFloatingProps, j as geometricView, k as playtestText, l as firstLine, m as multiplayProblems, n as createPlaySession, o as runScript, p as unmeasuredPlays, r as describeCapture, s as validateScene, t as captureScene, u as ladderText, v as feelText, w as facingText, x as agreementProblems, y as takeAgreementSnapshots } from "./test-
|
|
2
|
+
import { A as geometricPicker, C as facingReport, D as playtest, E as findPlayer, F as sceneAssetUrls, M as pointAtNode, N as describeFraming, O as playtestFailed, P as framingText, S as collectionProblems, T as failingReplays, _ as feelReport, a as registerAllNodes, b as takeCollectionSnapshots, c as feelsRung, d as ladderVerdict, f as saysRung, g as playMultiplayer, h as multiplayText, i as findFloatingProps, j as geometricView, k as playtestText, l as firstLine, m as multiplayProblems, n as createPlaySession, o as runScript, p as unmeasuredPlays, r as describeCapture, s as validateScene, t as captureScene, u as ladderText, v as feelText, w as facingText, x as agreementProblems, y as takeAgreementSnapshots } from "./test-CEl0y2Sw.js";
|
|
3
3
|
export { agreementProblems, auditScene, captureScene, collectionProblems, createPlaySession, describeCapture, describeFraming, facingReport, facingText, failingReplays, feelReport, feelText, feelsRung, findFloatingProps, findPlayer, firstLine, framingText, geometricPicker, geometricView, instancedScenes, ladderText, ladderVerdict, multiplayProblems, multiplayText, playMultiplayer, playtest, playtestFailed, playtestText, pointAtNode, registerAllNodes, runScript, saysRung, sceneAssetUrls, takeAgreementSnapshots, takeCollectionSnapshots, unmeasuredPlays, validateScene };
|
package/dist/vite.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { a as parseJsonText } from "./json-CfTjpvW8.js";
|
|
2
2
|
import { k as newUid } from "./save-slots-CEUGeLuB.js";
|
|
3
3
|
import { t as IncantoError } from "./errors-BpWbnbb_.js";
|
|
4
|
-
import { t as VERSION } from "./src-
|
|
4
|
+
import { t as VERSION } from "./src-CqtvYtSN.js";
|
|
5
5
|
import { n as diffSignatures } from "./frame-report-D-_7YF2G.js";
|
|
6
|
-
import { s as validateScene } from "./test-
|
|
6
|
+
import { s as validateScene } from "./test-CEl0y2Sw.js";
|
|
7
7
|
import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
|
|
8
8
|
import { basename, dirname, extname, join, normalize, relative, resolve, sep } from "node:path";
|
|
9
9
|
import { fileURLToPath } from "node:url";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,n as t}from"./index-
|
|
1
|
+
import{i as e,n as t}from"./index-CrUCQoaB.js";async function n(e,n){return new a((await t(()=>import(`./GameServer-C56iOUgF.js`),[],import.meta.url)).GameServer,e,{diagnostics:n})}var r=[500,1e3,2e3,4e3,8e3],i=8,a=class{raw;active=new Map;reconnecting=!1;disposed=!1;diagnostics;wait;constructor(e,t,n){this.diagnostics=n?.diagnostics??null,this.wait=n?.wait??(e=>new Promise(t=>{setTimeout(t,e)})),this.raw=new e({...t})}get account(){return this.raw.account}get connected(){return this.raw.connected}connect(){return this.raw.connected?Promise.resolve(!0):(this.disposed=!1,this.rawConnect())}rawConnect(){return this.raw.connect({onDisconnect:()=>void this.reconnect()})}disconnect(){this.disposed=!0;for(let e of this.active.values())e.off();return this.active.clear(),this.raw.disconnect()}remoteFunction(e,t,n){return this.raw.remoteFunction(e,t,n)}track(e){let t=Symbol(`sub`),n={make:e,off:e()};return this.active.set(t,n),()=>{n.off(),this.active.delete(t)}}async reconnect(){if(!this.disposed&&!this.reconnecting){this.reconnecting=!0;try{for(let t=0;t<i;t++){let n=!1,i=null;try{n=await this.rawConnect()!==!1}catch(e){i=e}if(this.disposed)return;if(n){for(let e of this.active.values())e.off(),e.off=e.make();t>0&&e(this.diagnostics,`info`,`[incanto] multiplayer reconnected after ${t+1} attempts.`);return}t===0&&e(this.diagnostics,`warn`,`[incanto] the multiplayer connection dropped and the server would not take it back${i?` (${i instanceof Error?i.message:String(i)})`:``}. Retrying — other players cannot see this one until it comes back.`);let a=r[Math.min(t,r.length-1)]??8e3;if(await this.wait(a),this.disposed)return}e(this.diagnostics,`error`,`[incanto] multiplayer gave up after ${i} reconnect attempts — this client is offline and the others cannot see it. Call connect() again to retry.`)}finally{this.reconnecting=!1}}}subscribeRoomState(e,t){return this.track(()=>this.raw.subscribeRoomState(e,t))}subscribeRoomMyState(e,t){return this.track(()=>this.raw.subscribeRoomMyState(e,t))}subscribeRoomAllUserStates(e,t){return this.track(()=>this.raw.subscribeRoomAllUserStates(e,e=>{let n={};for(let t of e??[]){if(!t||typeof t.account!=`string`||t.__leaved)continue;let{account:e,__updated:r,__leaved:i,...a}=t;n[e]=a}t(n)}))}subscribeRoomCollection(e,t,n){return this.track(()=>this.raw.subscribeRoomCollection(e,t,({items:e})=>{let t={};for(let n of e??[])n&&typeof n.__id==`string`&&(t[n.__id]=n);n(t)}))}onRoomMessage(e,t,n){return this.track(()=>this.raw.onRoomMessage(e,t,n))}onRoomUserJoin(e,t){return this.track(()=>this.raw.onRoomUserJoin(e,t))}onRoomUserLeave(e,t){return this.track(()=>this.raw.onRoomUserLeave(e,t))}subscribeGlobalState(e){return this.track(()=>this.raw.subscribeGlobalState(e))}subscribeGlobalMyState(e){return this.track(()=>this.raw.subscribeGlobalMyState(e))}subscribeGlobalUserState(e,t){return this.track(()=>this.raw.subscribeGlobalUserState(e,t))}subscribeGlobalCollection(e,t){return this.track(()=>this.raw.subscribeGlobalCollection(e,({items:e})=>{let n={};for(let t of e??[])t&&typeof t.__id==`string`&&(n[t.__id]=t);t(n)}))}subscribeAsset(e,t){return this.track(()=>this.raw.subscribeAsset(e,t))}onGlobalMessage(e,t){return this.track(()=>this.raw.onGlobalMessage(e,t))}};export{n as createAgent8Server};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as e,o as t,r as n,t as r}from"./index-
|
|
1
|
+
import{a as e,o as t,r as n,t as r}from"./index-CrUCQoaB.js";function i(e,t,n,r=1){let i=Math.min(e.x0,e.x1)*r,a=Math.max(e.x0,e.x1)*r,o=Math.min(e.y0,e.y1)*r,s=Math.max(e.y0,e.y1)*r,c=Math.max(0,Math.min(Math.round(i),t-1)),l=Math.max(0,Math.min(Math.round(o),n-1));return{x:c,y:l,w:Math.max(1,Math.min(Math.round(a-i),t-c)),h:Math.max(1,Math.min(Math.round(s-o),n-l))}}function a(e,t,n,r){let{x:i,y:a,w:o,h:s}=r,c=new Uint8ClampedArray(o*s*4);for(let n=0;n<s;n++){let r=((a+n)*t+i)*4,s=n*o*4;c.set(e.subarray(r,r+o*4),s)}return{pixels:c,width:o,height:s}}function o(e){if(!e)return`// no scene loaded`;let t=e.source??e;return JSON.stringify(t,null,2)}async function s(e){let t=globalThis.navigator;if(!t?.clipboard?.writeText)return!1;try{return await t.clipboard.writeText(e),!0}catch{return!1}}async function c(e,t){let n=globalThis,r=n.navigator?.clipboard?.write;if(!r||!n.ImageData||!n.ClipboardItem)return!1;try{let i=e.createElement(`canvas`);i.width=t.width,i.height=t.height;let a=i.getContext(`2d`);if(!a)return!1;a.putImageData(new n.ImageData(t.pixels,t.width,t.height),0,0);let o=await new Promise(e=>i.toBlob(e,`image/png`));return o?(await r.call(n.navigator?.clipboard,[new n.ClipboardItem({"image/png":o})]),!0):!1}catch{return!1}}var l=[`nw`,`n`,`ne`,`e`,`se`,`s`,`sw`,`w`],u={nw:[0,0],n:[.5,0],ne:[1,0],e:[1,.5],se:[1,1],s:[.5,1],sw:[0,1],w:[0,.5]},d={nw:`nwse-resize`,se:`nwse-resize`,ne:`nesw-resize`,sw:`nesw-resize`,n:`ns-resize`,s:`ns-resize`,e:`ew-resize`,w:`ew-resize`},f=(e,t,n)=>Math.max(t,Math.min(n,e));function p(e){return{x:Math.min(e.x0,e.x1),y:Math.min(e.y0,e.y1),w:Math.abs(e.x1-e.x0),h:Math.abs(e.y1-e.y0)}}function m(e,t,n,r,i,a){let o=e.x,s=e.y,c=e.x+e.w,l=e.y+e.h;return t.includes(`w`)&&(o=f(o+n,0,i)),t.includes(`e`)&&(c=f(c+n,0,i)),t.includes(`n`)&&(s=f(s+r,0,a)),t.includes(`s`)&&(l=f(l+r,0,a)),{x:Math.min(o,c),y:Math.min(s,l),w:Math.max(1,Math.abs(c-o)),h:Math.max(1,Math.abs(l-s))}}function h(e,t,n,r,i){return{...e,x:f(e.x+t,0,Math.max(0,r-e.w)),y:f(e.y+n,0,Math.max(0,i-e.h))}}function g(e,t,n,r,i,a=8){let o=f(e.x+e.w/2-t/2,a,Math.max(a,r-t-a)),s=e.y+e.h+a,c=e.y-n-a;return{x:o,y:s+n<=i-a?s:c>=a?c:f(s,a,Math.max(a,i-n-a))}}function _(e,t,n,r,i,a,o=180,s=120){let c=Math.max(o,n),l=Math.max(s,r);return{x:Math.min(Math.max(0,e),Math.max(0,i-c)),y:Math.min(Math.max(0,t),Math.max(0,a-l)),w:c,h:l}}function v(e,t,n,r,i,a=4){let o=Math.min(Math.max(0,e.x),Math.max(0,r-t)),s=e.y+e.h+a,c=e.y-n-a;return s+n<=i?{x:o,y:s}:c>=0?{x:o,y:c}:{x:o,y:Math.min(Math.max(0,s),Math.max(0,i-n))}}function y(e,t,n){let r=e=>{e.key===`Escape`&&n()},i=e=>{let r=e.target;if(r){for(let e of t)if(e&&(e===r||e.contains?.(r)))return;n()}};return e.addEventListener?.(`keydown`,r),e.addEventListener?.(`pointerdown`,i),()=>{e.removeEventListener?.(`keydown`,r),e.removeEventListener?.(`pointerdown`,i)}}function b(e,t){for(let[n,r]of Object.entries(t))e.style[n]=r}var x=`rgba(18, 20, 26, 0.92)`,S=`1px solid rgba(255,255,255,0.14)`,C=`12px ui-monospace, SFMono-Regular, Menlo, monospace`,w=class{host;el;body;onClose=()=>{};x;y;w;h;constructor(e,t,n,r){this.host=t,this.x=r.x,this.y=r.y,this.w=r.w,this.h=r.h,this.el=e.createElement(`div`),b(this.el,{position:`absolute`,background:x,border:S,borderRadius:`8px`,color:`rgba(255,255,255,0.88)`,font:C,display:`flex`,flexDirection:`column`,overflow:`hidden`,zIndex:`40`,pointerEvents:`auto`,boxShadow:`0 8px 28px rgba(0,0,0,0.45)`});let i=e.createElement(`div`);i.textContent=n,b(i,{padding:`6px 28px 6px 10px`,background:`rgba(255,255,255,0.07)`,cursor:`move`,userSelect:`none`,touchAction:`none`,fontWeight:`700`}),this.el.appendChild(i);let a=e.createElement(`div`);a.textContent=`×`,a.title=`close`,b(a,{position:`absolute`,top:`2px`,right:`8px`,cursor:`pointer`,fontSize:`16px`,lineHeight:`20px`,opacity:`0.7`}),a.addEventListener(`click`,()=>this.onClose()),this.el.appendChild(a),this.body=e.createElement(`div`),b(this.body,{flex:`1`,overflow:`auto`,padding:`8px 10px`}),this.el.appendChild(this.body);let o=e.createElement(`div`);o.textContent=`◢`,b(o,{position:`absolute`,right:`2px`,bottom:`0`,cursor:`nwse-resize`,opacity:`0.5`,userSelect:`none`,touchAction:`none`}),this.el.appendChild(o),this.wireDrag(i,(e,t)=>{this.x+=e,this.y+=t,this.layout()}),this.wireDrag(o,(e,t)=>{this.w+=e,this.h+=t,this.layout()}),this.layout(),t.appendChild(this.el)}remove(){this.el.remove()}layout(){let e=this.host.getBoundingClientRect(),t=_(this.x,this.y,this.w,this.h,e.width,e.height);this.x=t.x,this.y=t.y,this.w=t.w,this.h=t.h,b(this.el,{left:`${t.x}px`,top:`${t.y}px`,width:`${t.w}px`,height:`${t.h}px`})}wireDrag(e,t){let r=null,i=0,a=0;e.addEventListener(`pointerdown`,t=>{r=t.pointerId,i=t.clientX,a=t.clientY,n(e,t.pointerId)}),e.addEventListener(`pointermove`,e=>{e.pointerId===r&&(t(e.clientX-i,e.clientY-a),i=e.clientX,a=e.clientY)});let o=e=>{e.pointerId===r&&(r=null)};e.addEventListener(`pointerup`,o),e.addEventListener(`pointercancel`,o)}},T=4,E=`#6ee7dc`,D=`rgba(18,20,26,0.94)`,O=`12px ui-monospace, Menlo, monospace`;function k(e){let{doc:t,container:r}=e,i=t.createElement(`div`);b(i,{position:`absolute`,inset:`0`,cursor:`crosshair`,zIndex:`80`,pointerEvents:`auto`,userSelect:`none`,touchAction:`none`});let a=t.createElement(`div`);b(a,{position:`absolute`,inset:`0`,background:`rgba(10,14,20,0.35)`,pointerEvents:`none`}),i.appendChild(a);let o=t.createElement(`div`);b(o,{position:`absolute`,outline:`1px solid ${E}`,boxShadow:`0 0 0 9999px rgba(10,14,20,0.35)`,cursor:`grab`,display:`none`,pointerEvents:`auto`}),i.appendChild(o);let s=t.createElement(`div`);b(s,{position:`absolute`,padding:`2px 6px`,borderRadius:`4px`,background:D,color:E,font:O,pointerEvents:`none`,display:`none`,whiteSpace:`nowrap`}),i.appendChild(s);let c=t.createElement(`div`);c.textContent=`drag to select · Esc to cancel`,b(c,{position:`absolute`,top:`10px`,left:`50%`,transform:`translateX(-50%)`,padding:`4px 10px`,borderRadius:`6px`,background:D,color:`rgba(255,255,255,0.85)`,font:O,pointerEvents:`none`,whiteSpace:`nowrap`}),i.appendChild(c);let f=null,_=`idle`,v={x:0,y:0},y={x:0,y:0,w:0,h:0},x=()=>({w:r.clientWidth||1,h:r.clientHeight||1});for(let e of l){let n=t.createElement(`div`),[r,i]=u[e];b(n,{position:`absolute`,left:`${r*100}%`,top:`${i*100}%`,width:`10px`,height:`10px`,marginLeft:`-5px`,marginTop:`-5px`,borderRadius:`2px`,background:E,border:`1px solid rgba(10,14,20,0.75)`,cursor:d[e],pointerEvents:`auto`}),n.addEventListener(`pointerdown`,t=>{A(t,e)}),o.appendChild(n)}let S=t.createElement(`div`);b(S,{position:`absolute`,display:`none`,gap:`6px`,padding:`6px`,borderRadius:`8px`,background:D,border:`1px solid rgba(255,255,255,0.18)`,font:O,pointerEvents:`auto`,whiteSpace:`nowrap`,boxShadow:`0 4px 16px rgba(0,0,0,0.45)`});let C=(e,n,r)=>{let i=t.createElement(`div`);return i.textContent=e,b(i,{padding:`5px 10px`,borderRadius:`5px`,cursor:`pointer`,color:n?`#08121a`:`rgba(255,255,255,0.85)`,background:n?E:`rgba(255,255,255,0.08)`,userSelect:`none`}),i.addEventListener(`pointerdown`,e=>{w(e),r()}),i};S.appendChild(C(`Copy to clipboard`,!0,()=>P())),S.appendChild(C(`Cancel`,!1,()=>L())),i.appendChild(S);function w(e){e.preventDefault?.(),e.stopPropagation?.()}function k(e){let t=e,n=r.getBoundingClientRect?.()??{left:0,top:0};return{x:(t.clientX??0)-n.left,y:(t.clientY??0)-n.top}}function A(e,t){w(e),v=k(e),_=t,t===`create`?f={x:v.x,y:v.y,w:0,h:0}:f&&(y=f),b(S,{display:`none`}),b(o,{cursor:t===`move`?`grabbing`:`crosshair`});let r=e.pointerId;r!==void 0&&n(i,r),j()}function j(){if(!f){b(o,{display:`none`}),b(s,{display:`none`}),b(a,{display:`block`});return}b(a,{display:`none`}),b(o,{display:`block`,left:`${f.x}px`,top:`${f.y}px`,width:`${f.w}px`,height:`${f.h}px`});let t=e.scale();s.textContent=`${Math.round(f.w*t)}×${Math.round(f.h*t)}`;let n=f.y-24;b(s,{display:`block`,left:`${Math.max(2,f.x)}px`,top:`${n>=2?n:f.y+4}px`})}function M(){if(!f||f.w<T||f.h<T)return;b(S,{display:`flex`});let e=x(),t=S.offsetWidth||200,n=S.offsetHeight||36,r=g(f,t,n,e.w,e.h);b(S,{left:`${r.x}px`,top:`${r.y}px`})}i.addEventListener(`pointerdown`,e=>{A(e,`create`)}),o.addEventListener(`pointerdown`,e=>{A(e,`move`)}),i.addEventListener(`pointermove`,e=>{if(_===`idle`||!f)return;let t=k(e),n=x();if(_===`create`){let e=p({x0:v.x,y0:v.y,x1:t.x,y1:t.y});f={x:Math.max(0,Math.min(e.x,n.w)),y:Math.max(0,Math.min(e.y,n.h)),w:Math.min(e.w,n.w-Math.max(0,Math.min(e.x,n.w))),h:Math.min(e.h,n.h-Math.max(0,Math.min(e.y,n.h)))}}else f=_===`move`?h(y,t.x-v.x,t.y-v.y,n.w,n.h):m(y,_,t.x-v.x,t.y-v.y,n.w,n.h);j()});let N=()=>{_!==`idle`&&(_===`create`&&f&&(f.w<T||f.h<T)&&(f=null),_=`idle`,b(o,{cursor:`grab`}),c.textContent=f?`drag the handles or the middle · Enter to copy · Esc to cancel`:`drag to select · Esc to cancel`,j(),M())};i.addEventListener(`pointerup`,N),i.addEventListener(`pointercancel`,N);function P(){let t=f;L(),t&&e.onCopy(t)}let F=e=>{let t=e.key;t===`Escape`?L():t===`Enter`&&f&&P()};t.addEventListener?.(`keydown`,F);let I=!1;function L(){I||(I=!0,t.removeEventListener?.(`keydown`,F),i.remove(),e.onClose())}return r.appendChild(i),{element:i,close:L}}var A=96,j=200,M=8192;function N(e){return Array.isArray(e)?`Array(${e.length})`:`Object(${Object.keys(e).length} keys)`}function P(e,t){if(Array.isArray(e)&&e.some(e=>typeof e==`object`&&!!e)){let t=e.slice(0,j).map(e=>JSON.stringify(e)),n=e.length-j;return t.join(`
|
|
2
2
|
`)+(n>0?`\n… ${n} more`:``)}return t.length>M?`${t.slice(0,M)} … (${t.length-M} more chars)`:t}function F(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var I=2,L=4;function R(e,t={}){let n=t.doc??(typeof document<`u`?document:null);if(!n)return null;let r=t.container??(typeof document<`u`?document.body:null);return!r||typeof r.appendChild!=`function`?null:new V(e,r,n,t.statsSource,t.actions,t.frameSource)}var z=300,B=[`log`,`info`,`warn`,`error`,`debug`],V=class{engine;container;doc;statsSource;actions;frameSource;panels=new Map;cleanups=[];menuButton;dropdown=null;dismissDropdown=null;menuPos={x:8,y:8};selected=null;collapsedFlags=new Map;statsChip=null;logRows=[];levelEnabled={debug:!0,info:!0,warn:!0,error:!0};consoleCapture=!1;consolePatched=[];frame=0;editing=0;detailOpen=new WeakMap;resumeScale=1;timeEls=null;hovering=!1;constructor(e,t,n,r,i=[],a){this.engine=e,this.container=t,this.doc=n,this.statsSource=r,this.actions=i,this.frameSource=a,this.menuButton=n.createElement(`div`),this.menuButton.textContent=`☰ debug`,b(this.menuButton,{position:`absolute`,top:`8px`,left:`8px`,padding:`4px 10px`,background:`rgba(18,20,26,0.85)`,border:`1px solid rgba(255,255,255,0.18)`,borderRadius:`6px`,color:`rgba(255,255,255,0.85)`,font:`12px ui-monospace, Menlo, monospace`,cursor:`pointer`,userSelect:`none`,zIndex:`50`,pointerEvents:`auto`}),this.bindMenuDrag(),t.style.position||(t.style.position=`relative`),t.appendChild(this.menuButton),this.cleanups.push(e.log.added.connect(e=>{this.pushLog({level:e.level,source:`engine`,text:e.parts.map(W).join(` `)})})),this.cleanups.push(e.sceneChanged.connect(()=>{this.selected=null,this.applyColliderScope(),this.renderExplorer(),this.renderInspector()})),this.cleanups.push(e.updated.connect(()=>{this.frame+=1,this.frame%30==0&&(this.renderExplorer(),this.renderStats(),this.editing===0&&!this.hovering&&this.renderInspector(),this.syncTime())}))}isOpen(e){return e===`copyScene`||e===`captureRegion`?!1:e===`colliders`?this.colliderMode!==`off`:e===`stats`?this.statsChip!==null:this.panels.has(e)}colliderMode=`off`;setColliders(e){this.colliderMode=e,this.applyColliderScope()}applyColliderScope(){let e=this.colliderMode;for(let t of r(`2d`).concat(r(`3d`)))t.debugDraw=e!==`off`,t.debugScope=e===`selected`?this.selected:null}open(e){if(e===`stats`){this.openStatsChip();return}if(this.panels.has(e)){e===`explorer`&&this.renderExplorer(),e===`inspector`&&this.renderInspector(),e===`logs`&&this.renderLogs(),e===`time`&&this.renderTime();return}let t=new w(this.doc,this.container,{explorer:`Explorer`,inspector:`Inspector`,logs:`Logs`,time:`Time`}[e],{explorer:{x:12,y:44,w:240,h:320},inspector:{x:264,y:44,w:280,h:320},logs:{x:12,y:380,w:532,h:200},time:{x:556,y:44,w:260,h:150}}[e]);t.onClose=()=>this.close(e),e===`inspector`&&(t.body.addEventListener(`pointerenter`,()=>{this.hovering=!0}),t.body.addEventListener(`pointerleave`,()=>{this.hovering=!1})),this.panels.set(e,t),e===`explorer`&&this.renderExplorer(),e===`inspector`&&this.renderInspector(),e===`logs`&&this.renderLogs(),e===`time`&&this.renderTime()}close(e){if(e===`inspector`&&(this.hovering=!1),e===`stats`){this.statsChip?.remove(),this.statsChip=null;return}let t=this.panels.get(e);t&&(t.remove(),this.panels.delete(e))}toggle(e){if(e===`copyScene`){this.copyScene();return}if(e===`captureRegion`){this.captureRegion();return}if(e===`colliders`){this.setColliders({off:`all`,all:`selected`,selected:`off`}[this.colliderMode]);return}this.isOpen(e)?this.close(e):this.open(e)}setLevelEnabled(e,t){this.levelEnabled[e]=t,this.renderLogs()}setConsoleCapture(e){if(e!==this.consoleCapture)if(this.consoleCapture=e,e){this.renderLogs();let e=console;for(let t of B){let n=e[t];e[t]=(...e)=>{n.apply(console,e);let r=t===`log`?`info`:t;this.pushLog({level:r,source:`console`,text:e.map(W).join(` `)})},this.consolePatched.push(()=>{e[t]=n})}}else{for(let e of this.consolePatched)e();this.consolePatched=[],this.renderLogs()}}dispose(){this.engine.debugSelection=null,this.setColliders(`off`),this.setConsoleCapture(!1);for(let e of this.cleanups)e();for(let e of[...this.panels.keys()])this.close(e);this.close(`stats`),this.closeDropdown(),this.menuButton.remove()}menuLabel(e,t){let n=e===`colliders`&&this.colliderMode!==`off`?` · ${this.colliderMode}`:``;return`${this.isOpen(e)?`✓ `:``}${t}${n}`}bindMenuDrag(){let e=null,t=!1;this.menuButton.addEventListener(`pointerdown`,n=>{let r=n;e={x:r.clientX??0,y:r.clientY??0,bx:this.menuPos.x,by:this.menuPos.y},t=!1,r.pointerId!==void 0&&this.menuButton.setPointerCapture?.(r.pointerId)}),this.menuButton.addEventListener(`pointermove`,n=>{if(!e)return;let r=n,i=(r.clientX??0)-e.x,a=(r.clientY??0)-e.y;!t&&Math.hypot(i,a)<L||(t||(t=!0,this.closeDropdown(),b(this.menuButton,{cursor:`grabbing`})),this.moveMenuButton(e.bx+i,e.by+a))});let n=()=>{if(!e)return;let n=t;e=null,t=!1,b(this.menuButton,{cursor:`pointer`}),n||this.toggleDropdown()};this.menuButton.addEventListener(`pointerup`,n),this.menuButton.addEventListener(`pointercancel`,n)}moveMenuButton(e,t){let n=this.menuButton,r=_(e,t,n.offsetWidth??0,n.offsetHeight??0,this.container.clientWidth||0,this.container.clientHeight||0,0,0);this.menuPos={x:r.x,y:r.y},b(this.menuButton,{left:`${r.x}px`,top:`${r.y}px`})}closeDropdown(){this.dismissDropdown?.(),this.dismissDropdown=null,this.dropdown?.remove(),this.dropdown=null}toggleDropdown(){if(this.dropdown){this.closeDropdown();return}let e=this.doc.createElement(`div`);b(e,{position:`absolute`,background:`rgba(18,20,26,0.95)`,border:`1px solid rgba(255,255,255,0.18)`,borderRadius:`6px`,font:`12px ui-monospace, Menlo, monospace`,color:`rgba(255,255,255,0.85)`,zIndex:`60`,pointerEvents:`auto`,overflow:`hidden`});for(let[t,n]of[[`explorer`,`Explorer`],[`inspector`,`Inspector`],[`logs`,`Logs`],[`time`,`Time`],[`copyScene`,`Copy scene JSON`],[`captureRegion`,`Capture region`],[`stats`,`Stats`],[`colliders`,`Colliders`]]){let r=this.doc.createElement(`div`);r.textContent=this.menuLabel(t,n),b(r,{padding:`6px 14px`,cursor:`pointer`,userSelect:`none`}),r.addEventListener(`click`,()=>{if(this.toggle(t),t===`colliders`){r.textContent=this.menuLabel(t,n);return}this.closeDropdown()}),e.appendChild(r)}for(let t of this.actions){let n=this.doc.createElement(`div`);n.textContent=t.label,b(n,{padding:`6px 14px`,cursor:`pointer`,userSelect:`none`,borderTop:`1px solid rgba(255,255,255,0.14)`,color:`rgba(158,232,220,0.95)`}),n.addEventListener(`click`,()=>{this.closeDropdown(),t.run()}),e.appendChild(n)}this.container.appendChild(e),this.dropdown=e;let t=e,n=this.menuButton,r=v({x:this.menuPos.x,y:this.menuPos.y,w:n.offsetWidth??0,h:n.offsetHeight??26},t.offsetWidth??0,t.offsetHeight??0,this.container.clientWidth||0,this.container.clientHeight||0);b(e,{left:`${r.x}px`,top:`${r.y}px`}),this.dismissDropdown=y(this.doc,[e,this.menuButton],()=>this.closeDropdown())}openStatsChip(){if(this.statsChip)return;let e=this.doc.createElement(`div`);b(e,{position:`absolute`,top:`8px`,right:`8px`,padding:`4px 10px`,background:`rgba(18,20,26,0.85)`,border:`1px solid rgba(255,255,255,0.18)`,borderRadius:`6px`,color:`rgba(255,255,255,0.85)`,font:`12px ui-monospace, Menlo, monospace`,textAlign:`right`,whiteSpace:`pre`,userSelect:`none`,pointerEvents:`none`,zIndex:`70`}),this.container.appendChild(e),this.statsChip=e,this.renderStats()}renderStats(){let e=this.statsChip;if(!e)return;let t=this.engine.stats(),n=this.statsSource?.()??{},r=[`nodes ${t.nodes}`,...n.triangles===void 0?[]:[`tris ${U(n.triangles)}`],...n.drawCalls===void 0?[]:[`calls ${n.drawCalls}`]].join(` · `),i=t.phases,a=`\nphys ${i.fixedMs.toFixed(1)} · logic ${i.updateMs.toFixed(1)} · draw ${i.renderMs.toFixed(1)} · other ${i.otherMs.toFixed(1)}`;e.textContent=`${Math.round(t.fps)} fps · ${t.frameMs.toFixed(1)} ms\n${r}${a}`}renderExplorer(){let e=this.panels.get(`explorer`);if(!e)return;let t=e.body.scrollTop;H(e.body);let n=this.engine.scene?.root;if(!n){e.body.scrollTop=t;return}let r=(e,t)=>{let n=e.constructor,i=e.children.length>0,a=this.collapsedFlags.get(e)===!0,o=this.doc.createElement(`div`);b(o,{display:`flex`,alignItems:`center`,cursor:`pointer`,padding:`1px 2px`,borderRadius:`3px`,background:e===this.selected?`rgba(110,160,255,0.25)`:`transparent`});let s=this.doc.createElement(`span`);s.textContent=i?a?`▸`:`▾`:`·`,b(s,{width:`14px`,flex:`none`,textAlign:`center`,opacity:i?`0.85`:`0.25`,userSelect:`none`}),i&&s.addEventListener(`click`,t=>{t.stopPropagation?.(),this.collapsedFlags.set(e,!a),this.renderExplorer()}),o.appendChild(s);let c=this.doc.createElement(`span`);c.textContent=e.name,b(c,{whiteSpace:`nowrap`}),o.appendChild(c);let l=this.doc.createElement(`span`);if(l.textContent=` ${n.typeName}`,b(l,{opacity:`0.45`,whiteSpace:`nowrap`,fontSize:`10px`}),o.appendChild(l),i&&a){let t=this.doc.createElement(`span`);t.textContent=` (${e.children.length})`,b(t,{opacity:`0.35`,fontSize:`10px`}),o.appendChild(t)}if(o.addEventListener(`click`,()=>{this.selected=e,this.engine.debugSelection=e,this.applyColliderScope(),this.open(`inspector`),this.renderExplorer(),this.renderInspector()}),t.appendChild(o),i&&!a){let n=this.doc.createElement(`div`);b(n,{marginLeft:`8px`,paddingLeft:`8px`,borderLeft:`1px solid rgba(255,255,255,0.14)`});for(let t of e.children)r(t,n);t.appendChild(n)}};r(n,e.body),e.body.scrollTop=t}renderInspector(){let t=this.panels.get(`inspector`);if(!t)return;let n=t.body.scrollTop;H(t.body);let r=this.selected;if(r&&r.tree===null&&(this.selected=null,this.engine.debugSelection=null,this.applyColliderScope(),r=null),!r){let e=this.doc.createElement(`div`);e.textContent=`select a node in the Explorer`,b(e,{opacity:`0.6`}),t.body.appendChild(e);return}let i=r.constructor,a=this.doc.createElement(`div`);if(a.textContent=`${r.getPath()} · ${i.typeName}${r.uid?` · ${r.uid}`:``}`,b(a,{fontWeight:`700`,marginBottom:`6px`,whiteSpace:`pre-wrap`}),t.body.appendChild(a),r.groups.size>0){let e=this.doc.createElement(`div`);e.textContent=`groups: ${[...r.groups].join(`, `)}`,b(e,{opacity:`0.7`,marginBottom:`6px`}),t.body.appendChild(e)}let o=e(i),s=r;for(let e of Object.keys(o)){let n=o[e];this.renderValueRow(t.body,r,e,{read:()=>s[e],write:t=>{s[e]=t},options:n?.options,variants:n?.variants})}t.body.scrollTop=n}renderValueRow(e,n,r,i){let a=i.read(),o=i.options,s={get[r](){return i.read()},set[r](e){i.write(e)}},c=this.doc.createElement(`div`);b(c,{display:`flex`,gap:`6px`,alignItems:`center`,margin:`2px 0`});let l=this.doc.createElement(`div`);l.textContent=r,b(l,{minWidth:`84px`,opacity:`0.75`}),c.appendChild(l);let u=(e,t)=>{let i=this.doc.createElement(`input`);return i.type=`number`,i.value=String(e),b(i,K(`70px`)),this.trackEditing(i),i.addEventListener(`change`,()=>{let e=Number(i.value);Number.isFinite(e)?t(e):i.value=String(n[r])}),i};if(typeof a==`number`)c.appendChild(u(a,e=>{s[r]=e}));else if(typeof a==`boolean`){let e=this.doc.createElement(`input`);e.type=`checkbox`,e.checked=a,this.trackEditing(e),e.addEventListener(`change`,()=>{s[r]=e.checked}),c.appendChild(e)}else if(typeof a==`string`&&o&&o.length>0){let e=this.doc.createElement(`select`);for(let t of o.includes(a)?o:[a,...o]){let n=this.doc.createElement(`option`);n.value=t,n.textContent=t,t===a&&(n.selected=!0),e.appendChild(n)}e.value=a,this.trackEditing(e),e.addEventListener(`change`,()=>{s[r]=e.value}),b(e,K(`110px`)),c.appendChild(e)}else if(typeof a==`string`){let e=this.doc.createElement(`input`);e.type=`text`,e.value=a,this.trackEditing(e),b(e,K(`140px`)),e.addEventListener(`change`,()=>{s[r]=e.value}),c.appendChild(e)}else if(Array.isArray(a)&&a.length<=8&&a.every(e=>typeof e==`number`))for(let e=0;e<a.length;e++)c.appendChild(u(a[e],t=>{let n=[...s[r]];n[e]=t,s[r]=n}));else if(F(a)){let o=this.doc.createElement(`div`);b(o,{marginLeft:`10px`,paddingLeft:`8px`,borderLeft:`1px solid rgba(255,255,255,0.14)`});let s=i.variants?.tag,l=Object.keys(a);s&&!l.includes(s)&&l.unshift(s);let u=i.path??r;for(let e of l){let r=e===s;this.renderValueRow(o,n,e,{path:`${u}.${e}`,read:()=>i.read()[e]??(r?``:null),write:n=>{if(r&&i.variants){let e=i.variants.byTag[String(n)];if(e!==void 0){i.write(t(e));return}}i.write({...i.read(),[e]:n})},options:r&&i.variants?Object.keys(i.variants.byTag):void 0})}e.appendChild(c),e.appendChild(o);return}else{let o=JSON.stringify(t(a));if(o.length<=A){let e=this.doc.createElement(`div`);e.textContent=o,b(e,{opacity:`0.65`,whiteSpace:`pre-wrap`,wordBreak:`break-all`}),c.appendChild(e)}else{let t=i.path??r,s=this.detailOpen.get(n)?.has(t)??!1,l=this.doc.createElement(`div`);if(l.textContent=`${s?`▾`:`▸`} ${N(a)}`,b(l,{opacity:`0.75`,cursor:`pointer`,userSelect:`none`}),l.addEventListener(`click`,()=>{let e=this.detailOpen.get(n);e||(e=new Set,this.detailOpen.set(n,e)),s?e.delete(t):e.add(t),this.renderInspector()}),c.appendChild(l),e.appendChild(c),s){let t=this.doc.createElement(`div`);t.textContent=P(a,o),b(t,{opacity:`0.6`,whiteSpace:`pre-wrap`,wordBreak:`break-all`,marginLeft:`10px`,paddingLeft:`8px`,borderLeft:`1px solid rgba(255,255,255,0.14)`}),e.appendChild(t)}return}}e.appendChild(c)}trackEditing(e){e.addEventListener(`focus`,()=>{this.editing+=1}),e.addEventListener(`blur`,()=>{this.editing=Math.max(0,this.editing-1)})}pushLog(e){this.logRows.push(e),this.logRows.length>z&&this.logRows.splice(0,this.logRows.length-z),this.renderLogs()}async copyScene(){let e=await s(o(this.engine.scene??null));return this.toast(e?`scene JSON copied`:`could not reach the clipboard`),e}captureRegion(){this.capture||=(this.captureScale=globalThis.devicePixelRatio??1,this.frameSource?.().then(e=>{this.captureScale=e.width/Math.max(1,this.container.clientWidth||e.width)}).catch(()=>{}),k({doc:this.doc,container:this.container,scale:()=>this.captureScale,onCopy:e=>void this.copyRegion({x0:e.x,y0:e.y,x1:e.x+e.w,y1:e.y+e.h}),onClose:()=>{this.capture=null}}))}capture=null;captureScale=1;async copyRegion(e){let t=this.frameSource;if(!t)return this.toast(`no renderer to capture from`),!1;try{let n=await t(),r=n.width/Math.max(1,this.container.clientWidth||n.width),o=i(e,n.width,n.height,r),s=a(n.pixels,n.width,n.height,o),l=await c(this.doc,s);return this.toast(l?`copied ${s.width}×${s.height}`:`could not copy the image`),l}catch(e){return this.toast(`capture failed: ${e instanceof Error?e.message:String(e)}`),!1}}toast(e){let t=this.doc.createElement(`div`);t.textContent=e,b(t,{position:`absolute`,bottom:`16px`,left:`50%`,transform:`translateX(-50%)`,padding:`6px 12px`,borderRadius:`6px`,background:`rgba(18,20,26,0.92)`,color:`rgba(255,255,255,0.9)`,font:`12px ui-monospace, Menlo, monospace`,zIndex:`90`,pointerEvents:`none`}),this.container.appendChild(t),setTimeout(()=>t.remove(),1800)}setTimeScale(e){Number.isFinite(e)&&(this.engine.timeScale=Math.max(0,e),this.syncTime())}setPaused(e){e?(this.engine.timeScale>0&&(this.resumeScale=this.engine.timeScale),this.engine.timeScale=0):this.engine.timeScale=this.resumeScale>0?this.resumeScale:1,this.syncTime()}get paused(){return this.engine.timeScale===0}nextFrame(){this.paused||this.setPaused(!0),this.engine.step({ignorePause:!0}),this.syncTime()}syncTime(){let e=this.timeEls;if(!e)return;let t=this.engine.timeScale,n=String(Math.round(t*1e3)/1e3);this.editing===0&&(e.slider.value=String(Math.min(t,I)),e.box.value=n),e.readout.textContent=`timeScale ${n}${this.paused?` · paused`:``}`,e.pause.textContent=this.paused?`▶ Resume`:`⏸ Pause`}renderTime(){let e=this.panels.get(`time`);if(!e)return;H(e.body),this.timeEls=null;let t=this.doc.createElement(`div`);b(t,{marginBottom:`6px`,opacity:`0.85`}),e.body.appendChild(t);let n=this.doc.createElement(`input`);n.type=`range`,n.min=`0`,n.max=String(I),n.step=`0.05`,n.value=String(Math.min(this.engine.timeScale,I)),b(n,{width:`100%`,marginBottom:`6px`}),this.trackEditing(n),n.addEventListener(`input`,()=>this.setTimeScale(Number(n.value))),e.body.appendChild(n);let r=this.doc.createElement(`div`);b(r,{display:`flex`,gap:`6px`,alignItems:`center`,marginBottom:`8px`});let i=this.doc.createElement(`input`);i.type=`number`,i.min=`0`,i.step=`0.05`,i.value=String(this.engine.timeScale),b(i,K(`72px`)),this.trackEditing(i),i.addEventListener(`change`,()=>{let e=Number(i.value);Number.isFinite(e)&&this.setTimeScale(e),this.syncTimeAfterEdit()}),r.appendChild(i);for(let e of[.25,.5,1,2]){let t=this.doc.createElement(`div`);t.textContent=`${e}×`,b(t,{cursor:`pointer`,opacity:`0.7`,padding:`2px 4px`}),t.addEventListener(`click`,()=>this.setTimeScale(e)),r.appendChild(t)}e.body.appendChild(r);let a=this.doc.createElement(`div`);b(a,{display:`flex`,gap:`8px`});let o=this.doc.createElement(`div`);b(o,G()),o.addEventListener(`click`,()=>this.setPaused(!this.paused)),a.appendChild(o);let s=this.doc.createElement(`div`);s.textContent=`⏭ Next frame`,s.title=`Pauses, then advances one fixed step`,b(s,G()),s.addEventListener(`click`,()=>this.nextFrame()),a.appendChild(s),e.body.appendChild(a),this.timeEls={slider:n,box:i,readout:t,pause:o},this.syncTime()}syncTimeAfterEdit(){let e=this.timeEls;if(!e)return;let t=this.engine.timeScale;e.slider.value=String(Math.min(t,I)),e.box.value=String(Math.round(t*1e3)/1e3)}renderLogs(){let e=this.panels.get(`logs`);if(!e)return;H(e.body);let t=this.doc.createElement(`div`);b(t,{display:`flex`,gap:`8px`,marginBottom:`4px`,flexWrap:`wrap`});for(let e of[`debug`,`info`,`warn`,`error`]){let n=this.doc.createElement(`div`);n.textContent=`${this.levelEnabled[e]?`✓`:`·`}${e}`,b(n,{cursor:`pointer`,opacity:this.levelEnabled[e]?`1`:`0.45`}),n.addEventListener(`click`,()=>this.setLevelEnabled(e,!this.levelEnabled[e])),t.appendChild(n)}let n=this.doc.createElement(`div`);n.textContent=`${this.consoleCapture?`✓`:`·`}console`,b(n,{cursor:`pointer`,marginLeft:`auto`}),n.addEventListener(`click`,()=>this.setConsoleCapture(!this.consoleCapture)),t.appendChild(n),e.body.appendChild(t);let r={debug:`rgba(255,255,255,0.5)`,info:`rgba(255,255,255,0.85)`,warn:`#ffc861`,error:`#ff6b6b`};for(let t of this.logRows){if(!this.levelEnabled[t.level])continue;let n=this.doc.createElement(`div`);n.textContent=`[${t.source===`console`?`console`:t.level}] ${t.text}`,b(n,{color:r[t.level],whiteSpace:`pre-wrap`}),e.body.appendChild(n)}}};function H(e){for(let t of[...e.children])t.remove()}function U(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function W(e){if(typeof e==`string`)return e;if(e instanceof Error){let t=e.stack?.split(`
|
|
3
3
|
`)[1]?.trim();return`${e.name}: ${e.message}${t?` (${t})`:``}`}try{let t=JSON.stringify(e);return t===`{}`||t===void 0?String(e):t}catch{return String(e)}}function G(){return{background:`rgba(255,255,255,0.08)`,border:`1px solid rgba(255,255,255,0.2)`,borderRadius:`4px`,padding:`4px 8px`,cursor:`pointer`,userSelect:`none`}}function K(e){return{width:e,background:`rgba(255,255,255,0.08)`,border:`1px solid rgba(255,255,255,0.2)`,borderRadius:`4px`,color:`inherit`,font:`inherit`,padding:`2px 4px`}}export{R as attachDebugOverlay};
|