incanto 0.1.0 → 0.2.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/3d.js +3 -3
- package/dist/{create-game-BdjpTHrW.js → create-game-lRYYrZiS.js} +2 -2
- package/dist/index.js +1 -1
- package/dist/{physics-3d-Dl67vOLT.js → physics-3d-CVsApTlL.js} +1 -1
- package/dist/react.js +1 -1
- package/dist/{register-CNlYAS1_.js → register-DT6wwm-n.js} +247 -1
- package/dist/test.js +3 -3
- package/editor/assets/{agent8-Bp7QFI7v.js → agent8-s6GYm1qu.js} +1 -1
- package/editor/assets/{index-Dl2pjA8e.js → index-CxJ6dZLb.js} +78 -78
- package/editor/index.html +1 -1
- package/package.json +1 -1
- package/schemas/scene.schema.json +293 -0
- package/skills/incanto-building-3d-games.md +41 -0
- package/skills/incanto-node-reference.md +45 -0
package/dist/3d.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as Environment3D, c as sunDirectionFromElevationAzimuth, i as syncTree, l as sunDirectionFromSky, o as horizonColorFromSky, r as Renderer3D, s as parseEnvironment3D, t as createGame3D, u as AssetStore3D } from "./create-game-
|
|
2
|
-
import { A as QUARTER_PITCH, C as Area3D, D as StaticBody3D, E as RigidBody3D, M as keyboardIntensity, N as movementState, O as Node3D, P as rigPose, S as terrainThemeLayers, T as PhysicsBody3D, _ as CharacterController3D, a as VoxelGrid3D, b as DEFAULT_TERRAIN_TEXTURE_BASE, c as ModelInstance3D, d as OmniLight3D, f as Foliage3D, g as FLOWER_VARIETIES, h as resolveFlowerDensity, i as VOXEL_PALETTE, j as cameraRelative, l as MeshInstance3D, m as Flowers3D, n as Water3D, o as Tree3D, p as DENSITY_PRESETS, r as WATER_MAX_RIPPLES, s as Particles3D, t as registerNodes3D, u as DirectionalLight3D, v as Camera3D, w as CharacterBody3D, x as TERRAIN_THEMES, y as Terrain3D } from "./register-
|
|
1
|
+
import { a as Environment3D, c as sunDirectionFromElevationAzimuth, i as syncTree, l as sunDirectionFromSky, o as horizonColorFromSky, r as Renderer3D, s as parseEnvironment3D, t as createGame3D, u as AssetStore3D } from "./create-game-lRYYrZiS.js";
|
|
2
|
+
import { A as QUARTER_PITCH, C as Area3D, D as StaticBody3D, E as RigidBody3D, M as keyboardIntensity, N as movementState, O as Node3D, P as rigPose, S as terrainThemeLayers, T as PhysicsBody3D, _ as CharacterController3D, a as VoxelGrid3D, b as DEFAULT_TERRAIN_TEXTURE_BASE, c as ModelInstance3D, d as OmniLight3D, f as Foliage3D, g as FLOWER_VARIETIES, h as resolveFlowerDensity, i as VOXEL_PALETTE, j as cameraRelative, l as MeshInstance3D, m as Flowers3D, n as Water3D, o as Tree3D, p as DENSITY_PRESETS, r as WATER_MAX_RIPPLES, s as Particles3D, t as registerNodes3D, u as DirectionalLight3D, v as Camera3D, w as CharacterBody3D, x as TERRAIN_THEMES, y as Terrain3D } from "./register-DT6wwm-n.js";
|
|
3
3
|
import { n as splatWeights, t as buildHeightmap } from "./heightmap-CroQPEER.js";
|
|
4
|
-
import { n as enablePhysics3D, t as Physics3D } from "./physics-3d-
|
|
4
|
+
import { n as enablePhysics3D, t as Physics3D } from "./physics-3d-CVsApTlL.js";
|
|
5
5
|
export { Area3D, AssetStore3D, Camera3D, CharacterBody3D, CharacterController3D, DEFAULT_TERRAIN_TEXTURE_BASE, DirectionalLight3D, Environment3D, DENSITY_PRESETS as FLOWER_DENSITY_PRESETS, FLOWER_VARIETIES, Flowers3D, Foliage3D, MeshInstance3D, ModelInstance3D, Node3D, OmniLight3D, Particles3D, Physics3D, PhysicsBody3D, QUARTER_PITCH, Renderer3D, RigidBody3D, StaticBody3D, TERRAIN_THEMES, Terrain3D, Tree3D, VOXEL_PALETTE, VoxelGrid3D, WATER_MAX_RIPPLES, Water3D, buildHeightmap, cameraRelative, createGame3D, enablePhysics3D, horizonColorFromSky, keyboardIntensity, movementState, parseEnvironment3D, registerNodes3D, resolveFlowerDensity, rigPose, splatWeights, sunDirectionFromElevationAzimuth, sunDirectionFromSky, syncTree, terrainThemeLayers };
|
|
@@ -6,8 +6,8 @@ import { r as AudioPlayer } from "./register-BuUV1_KB.js";
|
|
|
6
6
|
import { i as resolveRendering, n as attachTouchControls } from "./touch-031PxtCR.js";
|
|
7
7
|
import { n as registerGameplayBehaviors } from "./gameplay-Ccruc3Wd.js";
|
|
8
8
|
import { t as debugSources } from "./debug-draw-CZmOYjL2.js";
|
|
9
|
-
import { O as Node3D, T as PhysicsBody3D, c as ModelInstance3D, t as registerNodes3D, u as DirectionalLight3D, v as Camera3D } from "./register-
|
|
10
|
-
import { n as enablePhysics3D } from "./physics-3d-
|
|
9
|
+
import { O as Node3D, T as PhysicsBody3D, c as ModelInstance3D, t as registerNodes3D, u as DirectionalLight3D, v as Camera3D } from "./register-DT6wwm-n.js";
|
|
10
|
+
import { n as enablePhysics3D } from "./physics-3d-CVsApTlL.js";
|
|
11
11
|
import { ACESFilmicToneMapping, AmbientLight, BufferAttribute, BufferGeometry, Color, DepthTexture, EquirectangularReflectionMapping, FloatType, Fog, LineBasicMaterial, LineSegments, Matrix4, Mesh, PCFShadowMap, PMREMGenerator, PerspectiveCamera, PlaneGeometry, Quaternion, Raycaster, Scene, ShaderMaterial, Vector2, Vector3, WebGLRenderTarget, WebGLRenderer } from "three";
|
|
12
12
|
import { VRMLoaderPlugin, VRMUtils } from "@pixiv/three-vrm";
|
|
13
13
|
import { GLTFLoader } from "three/addons/loaders/GLTFLoader.js";
|
package/dist/index.js
CHANGED
|
@@ -57,6 +57,6 @@ function newUid() {
|
|
|
57
57
|
//#endregion
|
|
58
58
|
//#region src/index.ts
|
|
59
59
|
/** Engine version. Kept in sync with package.json by the release pipeline. */
|
|
60
|
-
const VERSION = "0.
|
|
60
|
+
const VERSION = "0.2.0";
|
|
61
61
|
//#endregion
|
|
62
62
|
export { AudioBuses, AudioPlayer, Behavior, CONST_REF_KEY, Engine, IncantoError, InputMap, LogManager, MusicManager, Node, PARTICLE_PRESETS, PARTICLE_PRESET_NAMES, ParticleSim, ROLLOFF_MODELS, Rng, SCENE_FORMAT, SFX_PRESETS, SFX_PRESET_NAMES, Scene, SceneTree, SfxEngine, Signal, Timer, TouchControls, VERSION, WebAudioMusicBackend, applyParticlePreset, assetUrls, attachTouchControls, clearBehaviors, clearRegistry, computeViewport, createNode, createNoise2D, crossfadeGains, duplicateNode, fadeGain, getBehavior, getNodeSchema, getNodeSignals, getNodeType, isAudioContextAvailable, isConstRef, joystickVector, jsonClone, jsonEquals, jsonKind, loadScene, mergeStaticSignals, newUid, parseNodePath, preloadUrls, registerBehavior, registerCoreNodes, registerNode, registeredBehaviors, registeredTypes, resolveConstants, resolveRendering, resolveViewport, serializeNode, spatialGain, spatialPan, synthSfx };
|
|
@@ -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 { C as Area3D, E as RigidBody3D, O as Node3D, T as PhysicsBody3D, k as validateCollider3D, w as CharacterBody3D, y as Terrain3D } from "./register-
|
|
4
|
+
import { C as Area3D, E as RigidBody3D, O as Node3D, T as PhysicsBody3D, k as validateCollider3D, w as CharacterBody3D, y as Terrain3D } from "./register-DT6wwm-n.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.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-lRYYrZiS.js").then((n) => n.n)).createGame3D(o) : async (o) => (await import("./create-game-CZHROKcT.js").then((n) => n.n)).createGame2D(o)))(opts);
|
|
160
160
|
if (disposed) {
|
|
161
161
|
next.dispose();
|
|
162
162
|
return;
|
|
@@ -6,7 +6,7 @@ import { t as registerCoreNodes } from "./register-BuUV1_KB.js";
|
|
|
6
6
|
import { i as getNodeSchema, l as registerNode } from "./registry-BVJ2HbCn.js";
|
|
7
7
|
import { t as createNoise2D } from "./noise-CGUMx44x.js";
|
|
8
8
|
import { n as splatWeights, t as buildHeightmap } from "./heightmap-CroQPEER.js";
|
|
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, MeshDepthMaterial, MeshStandardMaterial, NoBlending, NormalBlending, Object3D, PerspectiveCamera, Plane, PlaneGeometry, PointLight, Points, PointsMaterial, Quaternion, QuaternionKeyframeTrack, RGBAFormat, RepeatWrapping, SRGBColorSpace, ShaderChunk, ShaderMaterial, Sphere, SphereGeometry, Texture, TextureLoader, UniformsLib, UniformsUtils, Vector2, Vector3, Vector4, VectorKeyframeTrack, WebGLCubeRenderTarget, WebGLRenderTarget } from "three";
|
|
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, MeshStandardMaterial, NearestFilter, NoBlending, NormalBlending, Object3D, PerspectiveCamera, Plane, PlaneGeometry, PointLight, Points, PointsMaterial, Quaternion, QuaternionKeyframeTrack, 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";
|
|
11
11
|
//#region src/3d/camera-rig.ts
|
|
12
12
|
const QUARTER_PITCH = Math.atan(1 / Math.SQRT2);
|
|
@@ -1317,6 +1317,250 @@ function validateLayer(nodeName, layer, index) {
|
|
|
1317
1317
|
}
|
|
1318
1318
|
}
|
|
1319
1319
|
//#endregion
|
|
1320
|
+
//#region src/3d/nodes/sprite-3d.ts
|
|
1321
|
+
/** Shared unit quad — sprites are sized via the quad's scale, never THREE.Sprite. */
|
|
1322
|
+
const UNIT_PLANE = new PlaneGeometry(1, 1);
|
|
1323
|
+
const Z_AXIS = new Vector3(0, 0, 1);
|
|
1324
|
+
const _spritePos = new Vector3();
|
|
1325
|
+
const _dir = new Vector3();
|
|
1326
|
+
const _target = new Quaternion();
|
|
1327
|
+
const _parent = new Quaternion();
|
|
1328
|
+
/**
|
|
1329
|
+
* Sprite3D — a 2D texture drawn as a camera-facing billboard quad inside a 3D
|
|
1330
|
+
* scene (the 2.5D look: Octopath, Don't Starve). The visual is an inner quad
|
|
1331
|
+
* CHILD of the node's backing object, so node children inherit neither the
|
|
1332
|
+
* texture sizing nor the billboard rotation. Unlit (`MeshBasicMaterial`) —
|
|
1333
|
+
* sprites are pre-shaded art, not lit geometry.
|
|
1334
|
+
*
|
|
1335
|
+
* - `texture`: image URL (sRGB), empty = hidden
|
|
1336
|
+
* - `size [w,h]`: quad size in world metres
|
|
1337
|
+
* - `billboard`: `"y"` upright yaw-to-camera · `"full"` face camera · `"none"` fixed
|
|
1338
|
+
* - `anchor [ax,ay]`: pivot in 0..1 that sits at the node origin; `[0.5,0]` = feet
|
|
1339
|
+
* - `pixelArt`: nearest-filter for crisp pixels · `alphaTest`: cutout that depth-sorts
|
|
1340
|
+
*/
|
|
1341
|
+
var Sprite3D = class extends Node3D {
|
|
1342
|
+
static typeName = "Sprite3D";
|
|
1343
|
+
static props = {
|
|
1344
|
+
texture: { default: "" },
|
|
1345
|
+
size: { default: [1, 1] },
|
|
1346
|
+
billboard: {
|
|
1347
|
+
default: "y",
|
|
1348
|
+
options: [
|
|
1349
|
+
"y",
|
|
1350
|
+
"full",
|
|
1351
|
+
"none"
|
|
1352
|
+
]
|
|
1353
|
+
},
|
|
1354
|
+
anchor: { default: [.5, 0] },
|
|
1355
|
+
tint: { default: "#ffffff" },
|
|
1356
|
+
opacity: { default: 1 },
|
|
1357
|
+
flipX: { default: false },
|
|
1358
|
+
pixelArt: { default: true },
|
|
1359
|
+
alphaTest: { default: .5 }
|
|
1360
|
+
};
|
|
1361
|
+
/** Image URL (sampled sRGB, tinted by `tint`). Empty = hidden. */
|
|
1362
|
+
texture = "";
|
|
1363
|
+
/** Quad `[width, height]` in world units (metres). */
|
|
1364
|
+
size = [1, 1];
|
|
1365
|
+
/** `"y"` upright yaw-to-camera · `"full"` face camera · `"none"` fixed. */
|
|
1366
|
+
billboard = "y";
|
|
1367
|
+
/** Pivot in 0..1 of the sprite that sits at the node origin; `[0.5,0]` = feet. */
|
|
1368
|
+
anchor = [.5, 0];
|
|
1369
|
+
tint = "#ffffff";
|
|
1370
|
+
opacity = 1;
|
|
1371
|
+
flipX = false;
|
|
1372
|
+
/** Nearest-filter the texture for crisp pixel art (vs smooth linear). */
|
|
1373
|
+
pixelArt = true;
|
|
1374
|
+
/** Discard texels below this alpha — a crisp cutout that depth-sorts in 3D. */
|
|
1375
|
+
alphaTest = .5;
|
|
1376
|
+
quadMesh = null;
|
|
1377
|
+
textureRef = "";
|
|
1378
|
+
loadedTexture = null;
|
|
1379
|
+
/** @internal The drawable quad (lazily created, attached under the backing object). */
|
|
1380
|
+
_quad() {
|
|
1381
|
+
if (!this.quadMesh) {
|
|
1382
|
+
this.quadMesh = new Mesh(UNIT_PLANE, new MeshBasicMaterial({
|
|
1383
|
+
transparent: false,
|
|
1384
|
+
depthWrite: true
|
|
1385
|
+
}));
|
|
1386
|
+
this._ensureObject3D().add(this.quadMesh);
|
|
1387
|
+
}
|
|
1388
|
+
return this.quadMesh;
|
|
1389
|
+
}
|
|
1390
|
+
/** Override point: AnimatedSprite3D substitutes its frame window here. */
|
|
1391
|
+
resolveTexture() {
|
|
1392
|
+
if (!this.texture) return null;
|
|
1393
|
+
if (this.textureRef !== this.texture) {
|
|
1394
|
+
this.loadedTexture?.dispose();
|
|
1395
|
+
this.loadedTexture = null;
|
|
1396
|
+
this.textureRef = this.texture;
|
|
1397
|
+
if (typeof document !== "undefined") {
|
|
1398
|
+
const tex = new TextureLoader().load(this.texture);
|
|
1399
|
+
tex.colorSpace = SRGBColorSpace;
|
|
1400
|
+
const filter = this.pixelArt ? NearestFilter : LinearFilter;
|
|
1401
|
+
tex.magFilter = filter;
|
|
1402
|
+
tex.minFilter = filter;
|
|
1403
|
+
this.loadedTexture = tex;
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
return this.loadedTexture;
|
|
1407
|
+
}
|
|
1408
|
+
_syncObject3D(alpha = 1) {
|
|
1409
|
+
super._syncObject3D(alpha);
|
|
1410
|
+
const quad = this._quad();
|
|
1411
|
+
const mat = quad.material;
|
|
1412
|
+
const w = this.size[0] ?? 1;
|
|
1413
|
+
const h = this.size[1] ?? 1;
|
|
1414
|
+
quad.scale.set(this.flipX ? -w : w, h, 1);
|
|
1415
|
+
const ax = this.anchor[0] ?? .5;
|
|
1416
|
+
const ay = this.anchor[1] ?? 0;
|
|
1417
|
+
quad.position.set((.5 - ax) * w, (.5 - ay) * h, 0);
|
|
1418
|
+
const tex = this.resolveTexture();
|
|
1419
|
+
if (mat.map !== tex) {
|
|
1420
|
+
mat.map = tex;
|
|
1421
|
+
mat.needsUpdate = true;
|
|
1422
|
+
}
|
|
1423
|
+
quad.visible = tex !== null;
|
|
1424
|
+
mat.color.set(this.tint);
|
|
1425
|
+
mat.opacity = this.opacity;
|
|
1426
|
+
mat.transparent = this.opacity < 1;
|
|
1427
|
+
mat.alphaTest = this.alphaTest;
|
|
1428
|
+
quad.renderOrder = this.renderOrder;
|
|
1429
|
+
}
|
|
1430
|
+
/** @internal Billboard the quad toward the live camera. Headless runs have no
|
|
1431
|
+
* Renderer3D and never call this, so plain trees pay nothing. */
|
|
1432
|
+
_onRender3D(ctx) {
|
|
1433
|
+
if (this.billboard === "none") return;
|
|
1434
|
+
const quad = this._quad();
|
|
1435
|
+
quad.getWorldPosition(_spritePos);
|
|
1436
|
+
_dir.copy(ctx.camera.position).sub(_spritePos);
|
|
1437
|
+
if (this.billboard === "y") _dir.y = 0;
|
|
1438
|
+
if (_dir.lengthSq() < 1e-12) return;
|
|
1439
|
+
_dir.normalize();
|
|
1440
|
+
_target.setFromUnitVectors(Z_AXIS, _dir);
|
|
1441
|
+
quad.parent?.getWorldQuaternion(_parent);
|
|
1442
|
+
quad.quaternion.copy(_parent.invert()).multiply(_target);
|
|
1443
|
+
}
|
|
1444
|
+
free() {
|
|
1445
|
+
this.loadedTexture?.dispose();
|
|
1446
|
+
this.loadedTexture = null;
|
|
1447
|
+
super.free();
|
|
1448
|
+
}
|
|
1449
|
+
};
|
|
1450
|
+
//#endregion
|
|
1451
|
+
//#region src/3d/nodes/animated-sprite-3d.ts
|
|
1452
|
+
/**
|
|
1453
|
+
* AnimatedSprite3D — a billboard {@link Sprite3D} whose texture is a spritesheet
|
|
1454
|
+
* frame. Pure-JSON animation map; frame selection is a UV window on a per-node
|
|
1455
|
+
* clone of the sheet texture. Frames advance in `update(dt)` — deterministic and
|
|
1456
|
+
* headless-testable; the UV dressing is GPU-only and skipped without a DOM.
|
|
1457
|
+
*/
|
|
1458
|
+
var AnimatedSprite3D = class extends Sprite3D {
|
|
1459
|
+
static typeName = "AnimatedSprite3D";
|
|
1460
|
+
static signals = ["animationFinished"];
|
|
1461
|
+
static props = {
|
|
1462
|
+
sheet: { default: "" },
|
|
1463
|
+
frameWidth: { default: 0 },
|
|
1464
|
+
frameHeight: { default: 0 },
|
|
1465
|
+
animations: { default: {} },
|
|
1466
|
+
autoplay: { default: "" }
|
|
1467
|
+
};
|
|
1468
|
+
/** Spritesheet image URL. */
|
|
1469
|
+
sheet = "";
|
|
1470
|
+
/** Frame cell size within the sheet, in pixels. */
|
|
1471
|
+
frameWidth = 0;
|
|
1472
|
+
frameHeight = 0;
|
|
1473
|
+
animations = {};
|
|
1474
|
+
autoplay = "";
|
|
1475
|
+
playing = false;
|
|
1476
|
+
/** Absolute frame index within the sheet. */
|
|
1477
|
+
currentFrame = 0;
|
|
1478
|
+
currentAnimation = "";
|
|
1479
|
+
frameList = [];
|
|
1480
|
+
frameIndex = 0;
|
|
1481
|
+
frameTime = 0;
|
|
1482
|
+
sheetTexture = null;
|
|
1483
|
+
loadedSheetRef = "";
|
|
1484
|
+
play(name) {
|
|
1485
|
+
const def = this.animations[name];
|
|
1486
|
+
if (!def) throw new IncantoError("UNKNOWN_ANIMATION", `No animation '${name}' on '${this.name}'. Available: [${Object.keys(this.animations).join(", ")}].`);
|
|
1487
|
+
this.currentAnimation = name;
|
|
1488
|
+
this.frameList = resolveFrames(def.frames, name);
|
|
1489
|
+
this.frameIndex = 0;
|
|
1490
|
+
this.currentFrame = this.frameList[0] ?? 0;
|
|
1491
|
+
this.frameTime = 0;
|
|
1492
|
+
this.playing = true;
|
|
1493
|
+
}
|
|
1494
|
+
stop() {
|
|
1495
|
+
this.playing = false;
|
|
1496
|
+
}
|
|
1497
|
+
onReady() {
|
|
1498
|
+
if (this.autoplay) this.play(this.autoplay);
|
|
1499
|
+
}
|
|
1500
|
+
update(dt) {
|
|
1501
|
+
if (!this.playing || this.currentAnimation === "") return;
|
|
1502
|
+
const def = this.animations[this.currentAnimation];
|
|
1503
|
+
if (!def || !Number.isFinite(def.fps) || def.fps <= 0) return;
|
|
1504
|
+
const perFrame = 1 / def.fps;
|
|
1505
|
+
this.frameTime += dt;
|
|
1506
|
+
while (this.frameTime >= perFrame) {
|
|
1507
|
+
this.frameTime -= perFrame;
|
|
1508
|
+
this.frameIndex += 1;
|
|
1509
|
+
if (this.frameIndex >= this.frameList.length) if (def.loop) this.frameIndex = 0;
|
|
1510
|
+
else {
|
|
1511
|
+
this.frameIndex = this.frameList.length - 1;
|
|
1512
|
+
this.playing = false;
|
|
1513
|
+
this.emit("animationFinished", this.currentAnimation);
|
|
1514
|
+
break;
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1517
|
+
this.currentFrame = this.frameList[this.frameIndex] ?? 0;
|
|
1518
|
+
}
|
|
1519
|
+
resolveTexture() {
|
|
1520
|
+
if (!this.sheet || this.frameWidth <= 0 || this.frameHeight <= 0) return null;
|
|
1521
|
+
if (this.loadedSheetRef !== this.sheet) {
|
|
1522
|
+
this.sheetTexture?.dispose();
|
|
1523
|
+
this.sheetTexture = null;
|
|
1524
|
+
this.loadedSheetRef = this.sheet;
|
|
1525
|
+
if (typeof document !== "undefined") {
|
|
1526
|
+
const tex = new TextureLoader().load(this.sheet);
|
|
1527
|
+
tex.colorSpace = SRGBColorSpace;
|
|
1528
|
+
const filter = this.pixelArt ? NearestFilter : LinearFilter;
|
|
1529
|
+
tex.magFilter = filter;
|
|
1530
|
+
tex.minFilter = filter;
|
|
1531
|
+
this.sheetTexture = tex;
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
const tex = this.sheetTexture;
|
|
1535
|
+
if (!tex) return null;
|
|
1536
|
+
const image = tex.image;
|
|
1537
|
+
if (!image?.width || !image.height) return tex;
|
|
1538
|
+
const cols = Math.max(1, Math.floor(image.width / this.frameWidth));
|
|
1539
|
+
const col = this.currentFrame % cols;
|
|
1540
|
+
const row = Math.floor(this.currentFrame / cols);
|
|
1541
|
+
tex.repeat.set(this.frameWidth / image.width, this.frameHeight / image.height);
|
|
1542
|
+
tex.offset.set(col * this.frameWidth / image.width, 1 - (row + 1) * this.frameHeight / image.height);
|
|
1543
|
+
return tex;
|
|
1544
|
+
}
|
|
1545
|
+
free() {
|
|
1546
|
+
this.sheetTexture?.dispose();
|
|
1547
|
+
this.sheetTexture = null;
|
|
1548
|
+
super.free();
|
|
1549
|
+
}
|
|
1550
|
+
};
|
|
1551
|
+
function resolveFrames(frames, name) {
|
|
1552
|
+
if (!Array.isArray(frames) || frames.length === 0) throw new IncantoError("BAD_FORMAT", `Animation '${name}': "frames" must be a non-empty array.`);
|
|
1553
|
+
if (frames.length === 2) {
|
|
1554
|
+
const [start, end] = frames;
|
|
1555
|
+
if (end >= start) {
|
|
1556
|
+
const out = [];
|
|
1557
|
+
for (let f = start; f <= end; f++) out.push(f);
|
|
1558
|
+
return out;
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
return [...frames];
|
|
1562
|
+
}
|
|
1563
|
+
//#endregion
|
|
1320
1564
|
//#region src/3d/nodes/camera-3d.ts
|
|
1321
1565
|
/**
|
|
1322
1566
|
* A perspective camera. Mark exactly one camera `current: true`; with none
|
|
@@ -10614,6 +10858,8 @@ function registerNodes3D() {
|
|
|
10614
10858
|
registerNode(Node3D);
|
|
10615
10859
|
registerNode(Particles3D);
|
|
10616
10860
|
registerNode(MeshInstance3D);
|
|
10861
|
+
registerNode(Sprite3D);
|
|
10862
|
+
registerNode(AnimatedSprite3D);
|
|
10617
10863
|
registerNode(CharacterController3D);
|
|
10618
10864
|
registerNode(VoxelGrid3D);
|
|
10619
10865
|
registerNode(Terrain3D);
|
package/dist/test.js
CHANGED
|
@@ -5,7 +5,7 @@ import { n as jsonEquals, t as jsonClone } from "./json-BLk7H2Qa.js";
|
|
|
5
5
|
import { i as getNodeSchema, s as mergeStaticProps } from "./registry-BVJ2HbCn.js";
|
|
6
6
|
import { n as registerGameplayBehaviors } from "./gameplay-Ccruc3Wd.js";
|
|
7
7
|
import { t as registerNodes2D } from "./register-DPEV9_9t.js";
|
|
8
|
-
import { t as registerNodes3D } from "./register-
|
|
8
|
+
import { t as registerNodes3D } from "./register-DT6wwm-n.js";
|
|
9
9
|
import { t as registerNodesNet } from "./register-Dasmnurl.js";
|
|
10
10
|
//#region src/test/index.ts
|
|
11
11
|
/**
|
|
@@ -132,7 +132,7 @@ async function runScript(json, opts) {
|
|
|
132
132
|
const { enablePhysics2D } = await import("./physics-2d-KuMWPTf6.js").then((n) => n.r);
|
|
133
133
|
await enablePhysics2D(engine);
|
|
134
134
|
} else if (physics === "3d" || physics === "auto" && scene.dimension === "3d") {
|
|
135
|
-
const { enablePhysics3D } = await import("./physics-3d-
|
|
135
|
+
const { enablePhysics3D } = await import("./physics-3d-CVsApTlL.js").then((n) => n.r);
|
|
136
136
|
await enablePhysics3D(engine);
|
|
137
137
|
}
|
|
138
138
|
const failures = [];
|
|
@@ -237,7 +237,7 @@ async function createPlaySession(json, opts = {}) {
|
|
|
237
237
|
const { enablePhysics2D } = await import("./physics-2d-KuMWPTf6.js").then((n) => n.r);
|
|
238
238
|
await enablePhysics2D(engine);
|
|
239
239
|
} else if (physics === "3d" || physics === "auto" && scene.dimension === "3d") {
|
|
240
|
-
const { enablePhysics3D } = await import("./physics-3d-
|
|
240
|
+
const { enablePhysics3D } = await import("./physics-3d-CVsApTlL.js").then((n) => n.r);
|
|
241
241
|
await enablePhysics3D(engine);
|
|
242
242
|
}
|
|
243
243
|
const stepMs = 1e3 / (opts.fixedHz ?? 60);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./index-
|
|
1
|
+
import{t as e}from"./index-CxJ6dZLb.js";async function t(t){return new n((await e(()=>import(`./GameServer-C56iOUgF.js`),[],import.meta.url)).GameServer,t)}var n=class{raw;active=new Map;constructor(e,t){this.raw=new e({...t})}get account(){return this.raw.account}get connected(){return this.raw.connected}connect(){return this.rawConnect()}rawConnect(){return this.raw.connect({onDisconnect:()=>void this.reconnect()})}disconnect(){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(){await this.rawConnect();for(let e of this.active.values())e.off(),e.off=e.make()}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{t as createAgent8Server};
|