incanto 0.4.2 → 0.4.3

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.d.ts CHANGED
@@ -573,7 +573,7 @@ declare class Billboard3D extends Node3D {
573
573
  static override readonly typeName: string;
574
574
  static override readonly props: PropSchema;
575
575
  /** `"screen"` copy the camera orientation (screen-aligned) · `"y"` upright
576
- * yaw-to-camera · `"none"` billboarding off (authored rotation applies). */
576
+ * screen-aligned yaw (no off-center roll) · `"none"` off (authored rotation applies). */
577
577
  mode: BillboardGroupMode;
578
578
  /** Last successfully billboarded WORLD orientation — reapplied on the frames
579
579
  * where `"y"` has no answer (camera dead overhead), because `_syncObject3D`
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-CMS7DiPi.js";
2
- import { C as terrainThemeLayers, D as RigidBody3D, E as PhysicsBody3D, F as rigPose, M as cameraRelative, N as keyboardIntensity, O as StaticBody3D, P as movementState, S as TERRAIN_THEMES, T as CharacterBody3D, _ as CharacterController3D, a as VoxelGrid3D, b as Terrain3D, c as ModelInstance3D, d as OmniLight3D, f as Foliage3D, g as FLOWER_VARIETIES, h as resolveFlowerDensity, i as VOXEL_PALETTE, j as QUARTER_PITCH, k as Node3D, 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 Area3D, x as DEFAULT_TERRAIN_TEXTURE_BASE, y as Billboard3D } from "./register-02aSywx2.js";
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-DiTq3-fQ.js";
2
+ import { C as terrainThemeLayers, D as RigidBody3D, E as PhysicsBody3D, F as rigPose, M as cameraRelative, N as keyboardIntensity, O as StaticBody3D, P as movementState, S as TERRAIN_THEMES, T as CharacterBody3D, _ as CharacterController3D, a as VoxelGrid3D, b as Terrain3D, c as ModelInstance3D, d as OmniLight3D, f as Foliage3D, g as FLOWER_VARIETIES, h as resolveFlowerDensity, i as VOXEL_PALETTE, j as QUARTER_PITCH, k as Node3D, 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 Area3D, x as DEFAULT_TERRAIN_TEXTURE_BASE, y as Billboard3D } from "./register-BRy8FNox.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-CXOBOUKG.js";
4
+ import { n as enablePhysics3D, t as Physics3D } from "./physics-3d-DmNCeh58.js";
5
5
  export { Area3D, AssetStore3D, Billboard3D, 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 { E as PhysicsBody3D, c as ModelInstance3D, k as Node3D, t as registerNodes3D, u as DirectionalLight3D, v as Camera3D } from "./register-02aSywx2.js";
10
- import { n as enablePhysics3D } from "./physics-3d-CXOBOUKG.js";
9
+ import { E as PhysicsBody3D, c as ModelInstance3D, k as Node3D, t as registerNodes3D, u as DirectionalLight3D, v as Camera3D } from "./register-BRy8FNox.js";
10
+ import { n as enablePhysics3D } from "./physics-3d-DmNCeh58.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.4.2";
60
+ const VERSION = "0.4.3";
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 { A as validateCollider3D, D as RigidBody3D, E as PhysicsBody3D, T as CharacterBody3D, b as Terrain3D, k as Node3D, w as Area3D } from "./register-02aSywx2.js";
4
+ import { A as validateCollider3D, D as RigidBody3D, E as PhysicsBody3D, T as CharacterBody3D, b as Terrain3D, k as Node3D, w as Area3D } from "./register-BRy8FNox.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-CMS7DiPi.js").then((n) => n.n)).createGame3D(o) : async (o) => (await import("./create-game-CZHROKcT.js").then((n) => n.n)).createGame2D(o)))(opts);
159
+ const next = await (_gameFactory ?? (mode === "3d" ? async (o) => (await import("./create-game-DiTq3-fQ.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;
@@ -1362,7 +1362,8 @@ const SHADOW_CONTACT_PUSH = .5;
1362
1362
  *
1363
1363
  * - `texture`: image URL (sRGB), empty = hidden
1364
1364
  * - `size [w,h]`: quad size in world metres
1365
- * - `billboard`: `"y"` upright yaw-to-camera · `"full"` face camera · `"none"` fixed
1365
+ * - `billboard`: `"y"` upright, screen-aligned yaw (shares the camera heading, so
1366
+ * off-center sprites never roll) · `"full"` face camera · `"none"` fixed
1366
1367
  * - `anchor [ax,ay]`: pivot in 0..1 that sits at the node origin; `[0.5,0]` = feet
1367
1368
  * - `pixelArt`: nearest-filter for crisp pixels · `alphaTest`: cutout that depth-sorts
1368
1369
  */
@@ -1395,7 +1396,7 @@ var Sprite3D = class extends Node3D {
1395
1396
  texture = "";
1396
1397
  /** Quad `[width, height]` in world units (metres). */
1397
1398
  size = [1, 1];
1398
- /** `"y"` upright yaw-to-camera · `"full"` face camera · `"none"` fixed. */
1399
+ /** `"y"` upright, screen-aligned yaw (no off-center roll) · `"full"` face camera · `"none"` fixed. */
1399
1400
  billboard = "y";
1400
1401
  /** Pivot in 0..1 of the sprite that sits at the node origin; `[0.5,0]` = feet. */
1401
1402
  anchor = [.5, 0];
@@ -1538,7 +1539,11 @@ var Sprite3D = class extends Node3D {
1538
1539
  * caster at the light. Headless runs have no Renderer3D and never call this, so
1539
1540
  * plain trees pay nothing. */
1540
1541
  _onRender3D(ctx) {
1541
- if (this.billboard !== "none") this._faceToward(this._quad(), ctx.camera.position);
1542
+ if (this.billboard === "y") {
1543
+ ctx.camera.getWorldDirection(_dir$1);
1544
+ _dir$1.y = 0;
1545
+ if (_dir$1.lengthSq() >= 1e-6) this._faceDir(this._quad(), _dir$1.negate());
1546
+ } else if (this.billboard === "full") this._faceToward(this._quad(), ctx.camera.position);
1542
1547
  const caster = this.shadowMesh;
1543
1548
  if (caster?.castShadow && ctx.sunDir) {
1544
1549
  this._faceDir(caster, ctx.sunDir);
@@ -1697,8 +1702,6 @@ function resolveFrames(frames, name) {
1697
1702
  //#region src/3d/nodes/billboard-3d.ts
1698
1703
  const _parentQ = new Quaternion();
1699
1704
  const _rotQ = new Quaternion();
1700
- const _pos = new Vector3();
1701
- const _camPos = new Vector3();
1702
1705
  const _dir = new Vector3();
1703
1706
  const Z_AXIS = new Vector3(0, 0, 1);
1704
1707
  /** Valid `Billboard3D.mode` values — drives the prop options AND validateJson. */
@@ -1736,7 +1739,7 @@ var Billboard3D = class extends Node3D {
1736
1739
  options: BILLBOARD_GROUP_MODES
1737
1740
  } };
1738
1741
  /** `"screen"` copy the camera orientation (screen-aligned) · `"y"` upright
1739
- * yaw-to-camera · `"none"` billboarding off (authored rotation applies). */
1742
+ * screen-aligned yaw (no off-center roll) · `"none"` off (authored rotation applies). */
1740
1743
  mode = "screen";
1741
1744
  /** Last successfully billboarded WORLD orientation — reapplied on the frames
1742
1745
  * where `"y"` has no answer (camera dead overhead), because `_syncObject3D`
@@ -1759,11 +1762,9 @@ var Billboard3D = class extends Node3D {
1759
1762
  const o = this._ensureObject3D();
1760
1763
  if (this.mode === "screen") ctx.camera.getWorldQuaternion(_rotQ);
1761
1764
  else {
1762
- o.getWorldPosition(_pos);
1763
- ctx.camera.getWorldPosition(_camPos);
1764
- _dir.copy(_camPos).sub(_pos);
1765
+ ctx.camera.getWorldDirection(_dir);
1765
1766
  _dir.y = 0;
1766
- if (_dir.lengthSq() >= 1e-12) _rotQ.setFromUnitVectors(Z_AXIS, _dir.normalize());
1767
+ if (_dir.lengthSq() >= 1e-6) _rotQ.setFromUnitVectors(Z_AXIS, _dir.negate().normalize());
1767
1768
  else if (this._lastDesired) _rotQ.copy(this._lastDesired);
1768
1769
  else return;
1769
1770
  }
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-02aSywx2.js";
8
+ import { t as registerNodes3D } from "./register-BRy8FNox.js";
9
9
  import { t as registerNodesNet } from "./register-B0gq63VW.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-CXOBOUKG.js").then((n) => n.r);
135
+ const { enablePhysics3D } = await import("./physics-3d-DmNCeh58.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-CXOBOUKG.js").then((n) => n.r);
240
+ const { enablePhysics3D } = await import("./physics-3d-DmNCeh58.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-DsM2Yp9F.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;reconnecting=!1;disposed=!1;constructor(e,t){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{await this.rawConnect();for(let e of this.active.values())e.off(),e.off=e.make()}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{t as createAgent8Server};
1
+ import{t as e}from"./index-N8se-PhP.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;reconnecting=!1;disposed=!1;constructor(e,t){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{await this.rawConnect();for(let e of this.active.values())e.off(),e.off=e.make()}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{t as createAgent8Server};