@scenoco-three/editor 0.6.0 → 0.7.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.
Files changed (76) hide show
  1. package/README.md +31 -44
  2. package/bin/serve.js +37 -0
  3. package/dist/editor.js +12521 -0
  4. package/package.json +26 -34
  5. package/dist/cli/index.d.ts +0 -2
  6. package/dist/cli/index.js +0 -56
  7. package/dist-app/assets/EffectComposer-lekj9UUq.js +0 -1
  8. package/dist-app/assets/GLTFLoader-C2lUhzim.js +0 -1
  9. package/dist-app/assets/OutputPass-DZtd342R.js +0 -72
  10. package/dist-app/assets/Pass-BP3b3hlf.js +0 -1
  11. package/dist-app/assets/RenderPass-BjVchlYg.js +0 -1
  12. package/dist-app/assets/ShaderPass-DMXLcV9X.js +0 -24
  13. package/dist-app/assets/SkeletonUtils-Cxy_owx9.js +0 -1
  14. package/dist-app/assets/index-AxOpglZ-.css +0 -1
  15. package/dist-app/assets/index-D-Iq7tix.js +0 -4135
  16. package/dist-app/assets/inter-CaiW00F8.js +0 -1
  17. package/dist-app/assets/registry-BOM35tSr.js +0 -1433
  18. package/dist-app/assets/worker-_Lh8Vt-i.js +0 -1270
  19. package/dist-app/examples/breakout/assets/geometry/ball.geometry.xml +0 -1
  20. package/dist-app/examples/breakout/assets/geometry/brick.geometry.xml +0 -1
  21. package/dist-app/examples/breakout/assets/geometry/floor-sensor.geometry.xml +0 -1
  22. package/dist-app/examples/breakout/assets/geometry/paddle.geometry.xml +0 -1
  23. package/dist-app/examples/breakout/assets/geometry/wall-side.geometry.xml +0 -1
  24. package/dist-app/examples/breakout/assets/geometry/wall-top.geometry.xml +0 -1
  25. package/dist-app/examples/breakout/assets/materials/ball.material.xml +0 -1
  26. package/dist-app/examples/breakout/assets/materials/brick-firm.material.xml +0 -1
  27. package/dist-app/examples/breakout/assets/materials/brick-hard.material.xml +0 -1
  28. package/dist-app/examples/breakout/assets/materials/brick-soft.material.xml +0 -1
  29. package/dist-app/examples/breakout/assets/materials/paddle.material.xml +0 -10
  30. package/dist-app/examples/breakout/assets/materials/wall.material.xml +0 -1
  31. package/dist-app/examples/breakout/assets/render/neon.render.xml +0 -14
  32. package/dist-app/examples/breakout/assets/scenes/arena.prefab.xml +0 -68
  33. package/dist-app/examples/breakout/assets/scenes/brick.prefab.xml +0 -15
  34. package/dist-app/examples/breakout/assets/scenes/hud.scene.xml +0 -56
  35. package/dist-app/examples/breakout/assets/scenes/level-1.scene.xml +0 -36
  36. package/dist-app/examples/breakout/assets/scenes/level-2.scene.xml +0 -36
  37. package/dist-app/examples/breakout/assets/scenes/level-3.scene.xml +0 -36
  38. package/dist-app/examples/castle/assets/geometry/capsule.geometry.xml +0 -3
  39. package/dist-app/examples/castle/assets/geometry/cone.geometry.xml +0 -2
  40. package/dist-app/examples/castle/assets/geometry/cube.geometry.xml +0 -3
  41. package/dist-app/examples/castle/assets/geometry/cylinder.geometry.xml +0 -3
  42. package/dist-app/examples/castle/assets/geometry/plane.geometry.xml +0 -4
  43. package/dist-app/examples/castle/assets/geometry/quad.geometry.xml +0 -3
  44. package/dist-app/examples/castle/assets/geometry/sphere.geometry.xml +0 -2
  45. package/dist-app/examples/castle/assets/materials/grass.material.xml +0 -1
  46. package/dist-app/examples/castle/assets/materials/roof.material.xml +0 -1
  47. package/dist-app/examples/castle/assets/materials/stone.material.xml +0 -1
  48. package/dist-app/examples/castle/assets/materials/wood.material.xml +0 -1
  49. package/dist-app/examples/castle/assets/scenes/main.scene.xml +0 -25
  50. package/dist-app/examples/collector/assets/geometry/capsule.geometry.xml +0 -3
  51. package/dist-app/examples/collector/assets/geometry/cone.geometry.xml +0 -2
  52. package/dist-app/examples/collector/assets/geometry/cube.geometry.xml +0 -3
  53. package/dist-app/examples/collector/assets/geometry/cylinder.geometry.xml +0 -3
  54. package/dist-app/examples/collector/assets/geometry/plane.geometry.xml +0 -4
  55. package/dist-app/examples/collector/assets/geometry/quad.geometry.xml +0 -3
  56. package/dist-app/examples/collector/assets/geometry/sphere.geometry.xml +0 -2
  57. package/dist-app/examples/collector/assets/materials/crate.material.xml +0 -1
  58. package/dist-app/examples/collector/assets/materials/depot.material.xml +0 -1
  59. package/dist-app/examples/collector/assets/materials/ground.material.xml +0 -1
  60. package/dist-app/examples/collector/assets/materials/player.material.xml +0 -1
  61. package/dist-app/examples/collector/assets/scenes/crate.prefab.xml +0 -9
  62. package/dist-app/examples/collector/assets/scenes/main.scene.xml +0 -83
  63. package/dist-app/examples/playable/assets/geometry/capsule.geometry.xml +0 -3
  64. package/dist-app/examples/playable/assets/geometry/cone.geometry.xml +0 -2
  65. package/dist-app/examples/playable/assets/geometry/cube.geometry.xml +0 -3
  66. package/dist-app/examples/playable/assets/geometry/cylinder.geometry.xml +0 -3
  67. package/dist-app/examples/playable/assets/geometry/plane.geometry.xml +0 -4
  68. package/dist-app/examples/playable/assets/geometry/quad.geometry.xml +0 -3
  69. package/dist-app/examples/playable/assets/geometry/sphere.geometry.xml +0 -2
  70. package/dist-app/examples/playable/assets/materials/ground.material.xml +0 -1
  71. package/dist-app/examples/playable/assets/materials/target.material.xml +0 -2
  72. package/dist-app/examples/playable/assets/scenes/main.scene.xml +0 -53
  73. package/dist-app/examples/playable/assets/scenes/target.prefab.xml +0 -9
  74. package/dist-app/examples.json +0 -68
  75. package/dist-app/index.html +0 -14
  76. package/dist-app/model.json +0 -1
package/README.md CHANGED
@@ -1,50 +1,37 @@
1
1
  # @scenoco-three/editor
2
2
 
3
- The **standalone editor** for [SceNoCo](https://github.com/RomaRogov/scenoco-three) scenes: a
4
- static site with a tree, an inspector, transform gizmos and comment-preserving saves. It needs
5
- nothing from a project and nothing from a server: it opens a scene from a folder on your machine
6
- or from a URL, builds it live in the page, and writes your changes back into the XML.
7
-
8
- It is what the repository publishes to GitHub Pages, and what `npx scenoco-editor` serves locally.
9
-
10
- ## Opening a scene
11
-
12
- **A folder.** A scene is never one file — its geometry, materials and prefabs are files beside it
13
- — so the editor opens a folder (Chrome and Edge, through the File System Access API), lists every
14
- scene and prefab in it, and saves back to disk.
15
-
16
- **A URL.** Any `.scene.xml` or `.prefab.xml` on the web; what it refers to is fetched relative to
17
- it. Read-only, since the web is.
18
-
19
- The examples the site carries are offered underneath either way.
20
-
21
- ## What it builds, and what it cannot
22
-
23
- The page parses the document with the compiler's own parser (`@scenoco-three/compiler/browser`)
24
- and builds the scene from the same vocabulary the compiler uses: three's classes and the tag
25
- packages the site carries (collision, ui, postfx, audio, particles, box2d). Nodes, assets,
26
- references, placement, prefabs and overrides are all live, stamped with the parser's positions,
27
- so the tree, the inspector and the gizmos find every element.
28
-
29
- It does not run anything, and has no Play. A component or a system is a project's own
30
- TypeScript, and there is no TypeScript in a static page — so this is an editor of documents:
31
- move things, arrange the hierarchy, set attributes, save. What it could not build it says rather
32
- than drops. To see a scene *run*, an agent uses the observer, and a person runs the game.
33
-
34
- ## CLI
3
+ A visual editor for SceNoCo scenes that is never part of the project. Part of
4
+ [SceNoCo](https://github.com/RomaRogov/scenoco-three).
35
5
 
36
6
  ```bash
37
- npx scenoco-editor # serve the site locally and open it
38
- npx scenoco-editor --port 5177 --no-open
7
+ npm run dev # the game's own dev server, as always
8
+ npx scenoco-editor # the editor's interface, on http://localhost:5185
39
9
  ```
40
10
 
41
- ## Building the site
42
-
43
- ```bash
44
- npm run build:app # static/public (the vocabulary, the examples) + dist-app/
45
- npm run preview:app
46
- ```
47
-
48
- ## License
49
-
50
- MIT
11
+ Then open the game with `?edit` — `http://localhost:5173/?edit` — or any scene or prefab function
12
+ with `?edit&scene=/src/scenes/levels.tsx%23Level2`.
13
+
14
+ - **The game builds the scene.** In development, `play()` sees `?edit`, builds the scene with the
15
+ game's own code on the game's own server, and holds it still: no behaviour wakes. Then it loads
16
+ this package's interface from its URL (`?edit=<url>` to load it from elsewhere).
17
+ - **What you see is live.** A tree of the scene, an inspector — transform, the element's own
18
+ attributes, the geometry's and material's, every behaviour's fields — and a move / rotate / scale
19
+ gizmo, with Global or Local handles. A change is applied to the live object the way the scene sets it.
20
+ - **Made for a finger as much as a mouse.** On a phone held upright the node list and the inspector
21
+ are bottom sheets, one at a time; turned sideways, or on a screen, they are side columns that can
22
+ both be open. Drag the letter beside a number to scrub it: the scene follows the drag, and the
23
+ file is written once, when it ends.
24
+ - **What you change is written back, and nothing else is.** The project's `scenoco()` Vite plugin
25
+ writes one attribute into the `.tsx` file the element came from, splicing its text; comments,
26
+ layout and every other attribute stay byte for byte. A value it cannot see through — a
27
+ `material={paint.wall}`, a ref — is shown, not edited. Rotations show in degrees and are written
28
+ in radians; numbers are rounded to four decimals.
29
+
30
+ - **Undo puts the text back.** ⌘Z / Ctrl+Z and ⇧⌘Z / Ctrl+Y restore an attribute exactly as it
31
+ was written — `-Math.PI / 2` too — and survive the reload that removing an attribute needs.
32
+ - **A file changed behind its back is refused.** Every write names the element it means as the
33
+ editor last read it; if the file was edited elsewhere since, nothing is written and the editor
34
+ says to reload.
35
+
36
+ What it does not do yet: add or remove elements, or show what behaviours spawn at runtime
37
+ (nothing runs while editing — `BrickField`'s bricks are not there).
package/bin/serve.js ADDED
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * `scenoco-editor [--port 5185]` — serves the editor's interface for a game's page to load.
4
+ *
5
+ * Start the game's own dev server as usual, run this beside it, and open the game with `?edit`:
6
+ * the page builds the scene, holds it still, and imports the interface from here. Nothing about
7
+ * the editor is installed in the project.
8
+ */
9
+ import { createReadStream, existsSync } from 'node:fs';
10
+ import { createServer } from 'node:http';
11
+ import { fileURLToPath } from 'node:url';
12
+
13
+ const argv = process.argv.slice(2);
14
+ if (argv.includes('-h') || argv.includes('--help')) {
15
+ console.log('scenoco-editor [--port <n>]\n\nServes the editor for a game page opened with ?edit (port 5185 by default).');
16
+ process.exit(0);
17
+ }
18
+ const port = Number(argv[argv.indexOf('--port') + 1] || 0) || 5185;
19
+ const file = fileURLToPath(new URL('../dist/editor.js', import.meta.url));
20
+ if (!existsSync(file)) {
21
+ console.error('scenoco-editor: this package has no dist/editor.js — run `npm run build` in packages/editor');
22
+ process.exit(1);
23
+ }
24
+
25
+ createServer((req, res) => {
26
+ // The game's page is on another port, so the module needs CORS to load at all.
27
+ res.setHeader('Access-Control-Allow-Origin', '*');
28
+ if (new URL(req.url ?? '/', 'http://x').pathname !== '/editor.js') {
29
+ res.statusCode = 404;
30
+ return res.end('Open your game with ?edit — it loads /editor.js from here.');
31
+ }
32
+ res.setHeader('Content-Type', 'text/javascript');
33
+ res.setHeader('Cache-Control', 'no-store');
34
+ createReadStream(file).pipe(res);
35
+ }).listen(port, () => {
36
+ console.log(`scenoco-editor: serving on http://localhost:${port}/editor.js — open your game with ?edit`);
37
+ });