@mavonengine/cli 0.0.9 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -547,6 +547,137 @@ export default defineClientPlugin({
547
547
  })
548
548
  ```
549
549
 
550
+ ### Particle effects
551
+
552
+ A plugin can add particle effects from `setup` with `ctx.registerParticle`. They show in the editor's Particles tab with the plugin's name, can be placed in scenes (a `ParticleEffect` object) and are played by logic graphs (Spawn Effect, Play / Stop / Burst Effect). Their name in scene files and graphs is `<package>:<name>`, which `registerParticle` returns. Build them from the engine's emitters: `PooledEmitter` simulates particles with gravity, drag, wind, bouncing and settling, and only needs to know where each one starts. Load textures from the plugin's assets with `ctx.assetUrl()`. Particle effects only exist on the client:
553
+
554
+ ```ts
555
+ // client.ts
556
+ import type { PooledParticle } from '@mavonengine/core/Particles/System/PooledEmitter'
557
+ import type { Vector3 } from 'three'
558
+ import ParticleEffect from '@mavonengine/core/Particles/System/ParticleEffect'
559
+ import PooledEmitter from '@mavonengine/core/Particles/System/PooledEmitter'
560
+ import { defineClientPlugin } from '@mavonengine/core/Plugins/types'
561
+
562
+ class HailEmitter extends PooledEmitter {
563
+ constructor(position: Vector3) {
564
+ super(position, {
565
+ maxParticles: 400,
566
+ rate: 120,
567
+ lifetime: [4, 4],
568
+ size: [0.05, 0.05],
569
+ color: [0xE8F0FF, 0xE8F0FF],
570
+ gravity: 9.8,
571
+ bounce: 0.3,
572
+ restFor: [1, 2],
573
+ })
574
+ }
575
+
576
+ protected spawn(particle: PooledParticle) {
577
+ particle.position.set((Math.random() - 0.5) * 20, 12, (Math.random() - 0.5) * 20)
578
+ }
579
+ }
580
+
581
+ class Hail extends ParticleEffect {
582
+ constructor(position: Vector3) {
583
+ super()
584
+ this.emitters.push(new HailEmitter(position))
585
+ }
586
+ }
587
+
588
+ export default defineClientPlugin({
589
+ setup(ctx) {
590
+ // 'my-custom-plugin:Hail'
591
+ ctx.registerParticle('Hail', {
592
+ preview: {
593
+ cameraPosition: [0, 4, 12],
594
+ cameraTarget: [0, 2, 0]
595
+ },
596
+ spawn: position => new Hail(position),
597
+ icon: ctx.assetUrl('icons/hail.svg'),
598
+ })
599
+ },
600
+ })
601
+ ```
602
+
603
+ ### Brushes
604
+
605
+ The editor's Brushes panel comes with sculpt brushes (raise, lower, smooth, flatten, noise) for a `Terrain`, paint brushes for its material layers, and scatter brushes that paint models onto anything. A plugin can add to both kinds.
606
+
607
+ **Scatter brushes** are files: put `<name>.brush.json` files (made in the Brushes panel, which saves them to the project's `brushes/`) in a `brushes/` directory in the package. They go by `<package>:<name>` and are listed read-only next to the project's; *Copy* makes an editable copy.
608
+
609
+ **Brush tools** are code: register them from `setup` with `ctx.registerBrush`. A brush gets one stroke at a time (the editor spaces the stamps along the drag) and returns how to undo it. Its key is `<package>:<name>`. Its `options` show in the panel and reach the stroke as `context.options`:
610
+
611
+ ```ts
612
+ // client.ts
613
+ import { defineClientPlugin } from '@mavonengine/core/Plugins/types'
614
+ import { restoreHeights, sculpt, snapshotHeights } from '@mavonengine/core/Terrain/sculpt'
615
+
616
+ export default defineClientPlugin({
617
+ setup(ctx) {
618
+ ctx.registerBrush({
619
+ name: 'crater',
620
+ label: 'Crater',
621
+ group: 'Sculpt',
622
+ target: 'terrain',
623
+ options: [
624
+ {
625
+ type: 'slider',
626
+ key: 'depth',
627
+ label: 'depth',
628
+ min: 0.1,
629
+ max: 5,
630
+ step: 0.1,
631
+ default: 1
632
+ }
633
+ ],
634
+ begin(hit, context) {
635
+ const terrain = hit.terrain
636
+ if (!terrain)
637
+ return undefined
638
+ const region = {
639
+ col0: 0,
640
+ row0: 0,
641
+ col1: terrain.heightmap.resolution - 1,
642
+ row1: terrain.heightmap.resolution - 1
643
+ }
644
+ const before = snapshotHeights(terrain.heightmap, region)
645
+ return {
646
+ stamp(at, context) {
647
+ const local = terrain.toLocal(at.point)
648
+ const changed = sculpt(terrain.heightmap, {
649
+ mode: 'lower',
650
+ x: local.x,
651
+ z: local.z,
652
+ radius: context.settings.radius,
653
+ falloff: 1,
654
+ strength: Number(context.options.depth) / 5
655
+ })
656
+ if (changed)
657
+ terrain.heightsChanged(changed)
658
+ },
659
+ end() {
660
+ const after = snapshotHeights(terrain.heightmap, region)
661
+ terrain.commit()
662
+ const put = (heights: Float32Array) => {
663
+ restoreHeights(terrain.heightmap, region, heights)
664
+ terrain.heightsChanged()
665
+ terrain.commit()
666
+ }
667
+ return {
668
+ undo: () => put(before),
669
+ redo: () => put(after)
670
+ }
671
+ },
672
+ }
673
+ },
674
+ })
675
+ },
676
+ })
677
+ ```
678
+
679
+ A brush with `target: 'surface'` hits any mesh, not just terrains; `context.surfaceBelow(point)`, `context.scatterLayer(true)` and `context.scatterBrush` give what the built-in scatter brushes use.
680
+
550
681
  ### Dev entries
551
682
 
552
683
  A plugin's `dev` entry runs in the client's Vite dev server, only in dev: tooling for the editor that has to work with the project's files, like downloading something and writing it into `client/public/`. It is never part of a build, and the game server never loads it.
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  DEFAULT_DOCS_URL,
4
4
  version
5
- } from "./chunk-KNBPVBMA.js";
5
+ } from "./chunk-SUUIEUSM.js";
6
6
  import {
7
7
  READ_ONLY
8
8
  } from "./chunk-WMXVMJDM.js";
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // package.json
4
- var version = "0.0.9";
4
+ var version = "0.0.11";
5
5
 
6
6
  // src/mcp/config.ts
7
7
  import { existsSync, readFileSync, writeFileSync } from "fs";
@@ -2,10 +2,10 @@
2
2
  import {
3
3
  DocsClient,
4
4
  registerDocsTools
5
- } from "./chunk-UD5YAJCQ.js";
5
+ } from "./chunk-55NHDWIH.js";
6
6
  import {
7
7
  DEFAULT_DOCS_URL
8
- } from "./chunk-KNBPVBMA.js";
8
+ } from "./chunk-SUUIEUSM.js";
9
9
  import "./chunk-WMXVMJDM.js";
10
10
  import "./chunk-K3NQKI34.js";
11
11
  export {
package/dist/index.js CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  MCP_CONFIG_FILE,
12
12
  version,
13
13
  writeMcpConfig
14
- } from "./chunk-KNBPVBMA.js";
14
+ } from "./chunk-SUUIEUSM.js";
15
15
  import {
16
16
  __export
17
17
  } from "./chunk-K3NQKI34.js";
@@ -4172,7 +4172,7 @@ import process4 from "process";
4172
4172
  import { Readable, Transform } from "stream";
4173
4173
  import { pipeline } from "stream/promises";
4174
4174
  import AdmZip from "adm-zip";
4175
- var TEMPLATE_URL = "https://github.com/MavonEngine/Core/archive/refs/tags/0.0.23-alpha.zip";
4175
+ var TEMPLATE_URL = "https://github.com/MavonEngine/Core/archive/refs/tags/0.0.25-alpha.zip";
4176
4176
  var TEMPLATE_SUBPATH = "packages/multiplayer-template";
4177
4177
  var PROJECT_NAME_RE = /^[\w@./-][\w@./\- ]*$/;
4178
4178
  var NAME_SEPARATORS_RE = /[-_\s]+/;
@@ -6475,7 +6475,7 @@ var GameServerClient = class {
6475
6475
  }
6476
6476
  /** The game tabs open in a browser, through the dev bridge */
6477
6477
  clients() {
6478
- return this.bridge("__mavonengine/clients", {});
6478
+ return this.bridge("__mavonengine/clients", {}, 1e4);
6479
6479
  }
6480
6480
  /**
6481
6481
  * Ask one tab. `clientId` defaults to the only open tab (or the only one not running the editor)
@@ -6637,8 +6637,8 @@ function parseMcpArgs(args, env = process11.env) {
6637
6637
  async function runMcpCommand({ client, docsUrl, pluginsUrl, readOnly }) {
6638
6638
  const [{ StdioServerTransport }, { createMcpServer }, { DocsClient }, { ProjectPluginTools }] = await Promise.all([
6639
6639
  import("@modelcontextprotocol/sdk/server/stdio.js"),
6640
- import("./server-2C6FBJKE.js"),
6641
- import("./docs-E733ATRT.js"),
6640
+ import("./server-3AH3TUK7.js"),
6641
+ import("./docs-Z3CC3A2Y.js"),
6642
6642
  import("./projectPluginTools-QWULLUMD.js")
6643
6643
  ]);
6644
6644
  const docs = docsUrl ? new DocsClient(docsUrl) : void 0;
@@ -5,10 +5,10 @@ import {
5
5
  } from "./chunk-GOPDTCJD.js";
6
6
  import {
7
7
  registerDocsTools
8
- } from "./chunk-UD5YAJCQ.js";
8
+ } from "./chunk-55NHDWIH.js";
9
9
  import {
10
10
  version
11
- } from "./chunk-KNBPVBMA.js";
11
+ } from "./chunk-SUUIEUSM.js";
12
12
  import {
13
13
  LOG_LEVELS,
14
14
  READ_ONLY,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mavonengine/cli",
3
3
  "type": "module",
4
- "version": "0.0.9",
4
+ "version": "0.0.11",
5
5
  "description": "MavonEngine command line tools",
6
6
  "license": "MIT",
7
7
  "keywords": [
@@ -39,11 +39,11 @@
39
39
  },
40
40
  "devDependencies": {
41
41
  "@mavonengine/core": "*",
42
- "@types/adm-zip": "^0.5.7",
43
- "@types/node": "^24.0.0",
42
+ "@types/adm-zip": "^0.6.0",
43
+ "@types/node": "^22.20.7",
44
44
  "@vitest/coverage-v8": "^5.1.0",
45
45
  "tsup": "^9.0.0",
46
46
  "typescript": "7.0.2",
47
- "vitest": "^5.1.1"
47
+ "vitest": "^5.1.2"
48
48
  }
49
49
  }