@tomorrowevening/hermes 0.1.15 → 0.1.17

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/hermes.es.js CHANGED
@@ -1895,7 +1895,7 @@ class ZP extends pg {
1895
1895
  data: JSON.stringify({ group: e, prop: t, value: s })
1896
1896
  });
1897
1897
  }
1898
- addSpline(e) {
1898
+ addSplineCurve(e) {
1899
1899
  setTimeout(() => {
1900
1900
  this.send({
1901
1901
  event: "addSpline",
@@ -1904,6 +1904,15 @@ class ZP extends pg {
1904
1904
  });
1905
1905
  }, 1);
1906
1906
  }
1907
+ addSplineObject(e) {
1908
+ setTimeout(() => {
1909
+ this.send({
1910
+ event: "addSpline",
1911
+ target: "editor",
1912
+ data: JSON.stringify(e)
1913
+ });
1914
+ }, 1);
1915
+ }
1907
1916
  // Renderer
1908
1917
  setRenderer(e, t = null) {
1909
1918
  if (this.renderer = e, this.canvas = e.domElement, this.inputElement = t !== null ? t : this.canvas, !this.debug) return;
@@ -42815,13 +42824,13 @@ class kh extends Er {
42815
42824
  };
42816
42825
  addNextPt = () => {
42817
42826
  const e = this.draggable.children.length, t = e > 1 ? this.draggable.children[e - 1].position.clone() : new Z(), s = this.addPoint(t);
42818
- this.group.current?.setField("Current Point", s.position);
42827
+ this.updateField(s.position);
42819
42828
  };
42820
42829
  removePoint = (e) => {
42821
42830
  if (this._transform?.object === e) {
42822
42831
  this._transform?.detach();
42823
42832
  const t = this.draggable.children[this.draggable.children.length - 1];
42824
- this._transform?.attach(t), this.group.current?.setField("Current Point", t.position);
42833
+ this._transform?.attach(t), this.updateField(t.position);
42825
42834
  }
42826
42835
  di(e), this.updateSpline();
42827
42836
  };
@@ -42839,6 +42848,9 @@ class kh extends Er {
42839
42848
  updateSpline = () => {
42840
42849
  this.points.length < 2 || (this.curve = new ep(this.points, this.closed, this.curveType, this.tension), this.line.geometry.dispose(), this.line.geometry = new zi().setFromPoints(this.curve.getPoints(this.subdivide)), this.curvePos.position.copy(this.getPointAt(this._curvePercentage)));
42841
42850
  };
42851
+ updateField(e) {
42852
+ this.group.current?.setField("Current Point", e);
42853
+ }
42842
42854
  // Handlers
42843
42855
  onMouseClick = (e) => {
42844
42856
  if (!ut.instance || !ut.instance.currentWindow || this._transform && !this._transform.getHelper().visible) return;
@@ -42847,7 +42859,7 @@ class kh extends Er {
42847
42859
  const i = this.raycaster.intersectObjects(this.draggable.children, !1);
42848
42860
  if (i.length > 0) {
42849
42861
  const n = i[0].object;
42850
- n !== this._transform?.object && (this._transform?.attach(n), this.group.current?.setField("Current Point", n.position));
42862
+ n !== this._transform?.object && (this._transform?.attach(n), this.updateField(n.position));
42851
42863
  }
42852
42864
  };
42853
42865
  // Getters
@@ -42888,19 +42900,19 @@ class kh extends Er {
42888
42900
  updateCurrentPoint() {
42889
42901
  if (this._transform?.object && this.group) {
42890
42902
  const e = this._transform?.object;
42891
- e.name.search("point") > -1 && this.group.current?.setField("Current Point", e.position);
42903
+ e.name.search("point") > -1 && this.updateField(e.position);
42892
42904
  }
42893
42905
  }
42894
42906
  onUpdateTransform = () => {
42895
42907
  this.updateCurrentPoint(), this.updateSpline();
42896
42908
  };
42897
- initDebug(e) {
42898
- const t = this.draggable.children;
42899
- this.parentGroup = e, this._transform = _t.instance.add(this.name), this._transform.camera = this._camera, this._transform.addEventListener("objectChange", this.onUpdateTransform), t.length > 0 && this._transform.attach(t[t.length - 1]), ut.instance?.helpersContainer.add(this._transform.getHelper());
42900
- const s = t.length > 0 ? t[t.length - 1].position : { x: 0, y: 0, z: 0 };
42909
+ initDebug(e, t) {
42910
+ const s = this.draggable.children;
42911
+ this.visible = t, this.parentGroup = e, this._transform = _t.instance.add(this.name), this._transform.camera = this._camera, this._transform.addEventListener("objectChange", this.onUpdateTransform), s.length > 0 && this._transform.attach(s[s.length - 1]), ut.instance?.helpersContainer.add(this._transform.getHelper());
42912
+ const i = s.length > 0 ? s[s.length - 1].position : { x: 0, y: 0, z: 0 };
42901
42913
  this.group = e.addGroup({
42902
42914
  title: this.name,
42903
- expanded: !0,
42915
+ expanded: t,
42904
42916
  items: [
42905
42917
  {
42906
42918
  prop: "Closed",
@@ -43007,43 +43019,43 @@ class kh extends Er {
43007
43019
  {
43008
43020
  prop: "Current Point",
43009
43021
  type: "grid3",
43010
- value: s
43022
+ value: i
43011
43023
  }
43012
43024
  ],
43013
- onUpdate: (i, n) => {
43014
- switch (i) {
43025
+ onUpdate: (n, r) => {
43026
+ switch (n) {
43015
43027
  case "Closed":
43016
- this.closed = n, this.updateSpline();
43028
+ this.closed = r, this.updateSpline();
43017
43029
  break;
43018
43030
  case "Visible":
43019
- this.visible = n;
43031
+ this.visible = r;
43020
43032
  break;
43021
43033
  case "Color":
43022
- this.lineMaterial.color.setStyle(n), this.draggedMat.color.setStyle(n);
43034
+ this.lineMaterial.color.setStyle(r), this.draggedMat.color.setStyle(r);
43023
43035
  break;
43024
43036
  case "Curve":
43025
- this.curveType = n, this.updateSpline();
43037
+ this.curveType = r, this.updateSpline();
43026
43038
  break;
43027
43039
  case "Draggable Scale":
43028
- this.draggableScale = n;
43040
+ this.draggableScale = r;
43029
43041
  break;
43030
43042
  case "Subdivide":
43031
- this.subdivide = n, this.updateSpline();
43043
+ this.subdivide = r, this.updateSpline();
43032
43044
  break;
43033
43045
  case "Tension":
43034
- this.tension = n, this.updateSpline();
43046
+ this.tension = r, this.updateSpline();
43035
43047
  break;
43036
43048
  case "New Pt Offset":
43037
- this.offset = n;
43049
+ this.offset = r;
43038
43050
  break;
43039
43051
  case "Curve At":
43040
- this.curvePos.position.copy(this.getPointAt(n));
43052
+ this.curvePos.position.copy(this.getPointAt(r));
43041
43053
  break;
43042
43054
  case "Show Position":
43043
- this.curvePos.visible = n;
43055
+ this.curvePos.visible = r;
43044
43056
  break;
43045
43057
  case "Show Points":
43046
- this.draggable.visible = n;
43058
+ this.draggable.visible = r;
43047
43059
  break;
43048
43060
  case "Toggle Transform":
43049
43061
  this._transform && (this._transform.getHelper().visible = !this._transform.getHelper().visible);
@@ -43062,14 +43074,14 @@ class kh extends Er {
43062
43074
  break;
43063
43075
  case "Current Point":
43064
43076
  if (this.group.current && this._transform?.object) {
43065
- const r = this._transform?.object;
43066
- r.name.search("point") > -1 && (r.position.copy(n), this.updateSpline());
43077
+ const o = this._transform?.object;
43078
+ o.name.search("point") > -1 && (o.position.copy(r), this.updateSpline());
43067
43079
  }
43068
43080
  break;
43069
43081
  }
43070
43082
  }
43071
- }), this.draggable.children.forEach((i) => {
43072
- this.debugPoint(i);
43083
+ }), this.draggable.children.forEach((n) => {
43084
+ this.debugPoint(n);
43073
43085
  });
43074
43086
  }
43075
43087
  debugPoint = (e) => {
@@ -43159,12 +43171,12 @@ class rP extends Er {
43159
43171
  dispose() {
43160
43172
  this.three.removeEventListener(ce.ADD_SPLINE, this.onAddSpline), _e.removeEditorGroup(this.name);
43161
43173
  }
43162
- addSpline(e) {
43163
- e.draggableScale = this.defaultScale, e.hideTransform(), this.group?.current !== null && e.initDebug(this.group.current), this.add(e), this.currentSpline = e;
43174
+ addSpline(e, t) {
43175
+ e.draggableScale = this.defaultScale, e.hideTransform(), this.group?.current !== null && e.initDebug(this.group.current, t), this.add(e), this.currentSpline = e;
43164
43176
  }
43165
43177
  createSpline = (e = []) => {
43166
43178
  const t = `Spline ${Jo + 1}`, s = new kh(t, this._camera);
43167
- return s.addPoints(e), this.addSpline(s), Jo++, s;
43179
+ return s.addPoints(e), this.addSpline(s, !0), Jo++, s;
43168
43180
  };
43169
43181
  createSplineFromArray = (e) => {
43170
43182
  const t = [];
@@ -43179,7 +43191,7 @@ class rP extends Er {
43179
43191
  t.push(new Z(i[0], i[1], i[2]));
43180
43192
  });
43181
43193
  const s = new kh(e.name, this._camera);
43182
- return s.closed = e.closed, s.subdivide = e.subdivide, s.tension = e.tension, s.type = e.type, s.addPoints(t), s.updateSpline(), this.addSpline(s), s;
43194
+ return s.closed = e.closed, s.subdivide = e.subdivide, s.tension = e.tension, s.type = e.type, s.addPoints(t), s.updateSpline(), this.addSpline(s, !1), s;
43183
43195
  };
43184
43196
  showPoints = (e = !0) => {
43185
43197
  this.children.forEach((t) => {
@@ -43187,12 +43199,12 @@ class rP extends Er {
43187
43199
  });
43188
43200
  };
43189
43201
  onAddSpline = (e) => {
43190
- const t = JSON.parse(e.value), s = `Spline ${Jo + 1}`, i = [];
43202
+ const t = JSON.parse(e.value), s = t.name !== void 0 ? t.name : `Spline ${Jo + 1}`, i = new kh(s, this.camera);
43203
+ t.tension !== void 0 && (i.tension = t.tension), t.closed !== void 0 && (i.closed = t.closed), t.subdivide !== void 0 && (i.subdivide = t.subdivide), t.type !== void 0 && (i.curveType = t.type);
43204
+ const n = [];
43191
43205
  t.points.forEach((r) => {
43192
- i.push(new Z(r[0], r[1], r[2]));
43193
- });
43194
- const n = new kh(s, this.camera);
43195
- n.addPoints(i), this.addSpline(n), Jo++;
43206
+ n.push(new Z(r[0], r[1], r[2]));
43207
+ }), i.addPoints(n), this.addSpline(i, !1), Jo++;
43196
43208
  };
43197
43209
  isMouseDown = !1;
43198
43210
  enableClickToDraw() {
@@ -43229,7 +43241,7 @@ class rP extends Er {
43229
43241
  onMouseMove = (e) => {
43230
43242
  if (!this.isMouseDown) return;
43231
43243
  const s = e.target.getBoundingClientRect(), i = (e.clientX - s.left) / s.width * 2 - 1, n = -((e.clientY - s.top) / s.height) * 2 + 1, r = this.mouseToSplinePos(i, n, s.width, s.height);
43232
- this.currentSpline?.updateLastPoint(r);
43244
+ this.currentSpline?.updateLastPoint(r), this.currentSpline?.updateField(r);
43233
43245
  };
43234
43246
  onMouseUp = () => {
43235
43247
  this.isMouseDown = !1;
package/package.json CHANGED
@@ -1,79 +1,79 @@
1
- {
2
- "name": "@tomorrowevening/hermes",
3
- "author": "Colin Duffy <http://tomorrowevening.com/>",
4
- "description": "An extendable set of Web Tools controlled via a separate window for non-intereference with content.",
5
- "license": "GPL-3.0-or-later",
6
- "main": "./dist/hermes.cjs.js",
7
- "module": "./dist/hermes.esm.js",
8
- "types": "./types/index.d.ts",
9
- "type": "module",
10
- "version": "0.1.15",
11
- "homepage": "https://github.com/tomorrowevening/hermes#readme",
12
- "bugs": {
13
- "url": "https://github.com/tomorrowevening/hermes/issues"
14
- },
15
- "keywords": [
16
- "Editor",
17
- "Remote",
18
- "TheatreJS",
19
- "ThreeJS"
20
- ],
21
- "files": [
22
- "dist/hermes.es.js",
23
- "dist/hermes.cjs.js",
24
- "dist/hermes.css",
25
- "types/**/*.d.ts"
26
- ],
27
- "exports": {
28
- ".": {
29
- "types": "./types/index.d.ts",
30
- "import": "./dist/hermes.es.js",
31
- "require": "./dist/hermes.cjs.js"
32
- },
33
- "./hermes.css": "./dist/hermes.css"
34
- },
35
- "repository": {
36
- "type": "git",
37
- "url": "git+https://github.com/tomorrowevening/hermes.git"
38
- },
39
- "scripts": {
40
- "server": "node server/index.mjs",
41
- "clean": "rm -r dist && rm -r types",
42
- "dev": "vite",
43
- "declare": "tsc --declaration --emitDeclarationOnly --declarationDir types",
44
- "buildLib": "yarn declare && vite build",
45
- "buildExample": "vite build --config vite.config.example.ts",
46
- "build": "yarn buildLib && yarn buildExample",
47
- "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
48
- "preview": "vite preview"
49
- },
50
- "devDependencies": {
51
- "@theatre/core": "^0.7.2",
52
- "@theatre/studio": "^0.7.2",
53
- "@types/react": "^18.2.15",
54
- "@types/react-dom": "^18.2.7",
55
- "@types/three": "^0.177.0",
56
- "@typescript-eslint/eslint-plugin": "^6.4.0",
57
- "@typescript-eslint/parser": "^6.4.0",
58
- "@vitejs/plugin-react": "^4.0.3",
59
- "camera-controls": "^2.9.0",
60
- "detect-gpu": "^5.0.70",
61
- "eslint": "^8.45.0",
62
- "eslint-plugin-react": "^7.33.2",
63
- "eslint-plugin-react-hooks": "^4.6.0",
64
- "eslint-plugin-react-refresh": "^0.4.3",
65
- "glslify": "^7.1.1",
66
- "glslify-loader": "^2.0.0",
67
- "path": "^0.12.7",
68
- "postprocessing": "^6.37.6",
69
- "react": "^18.2.0",
70
- "react-dom": "^18.2.0",
71
- "sass": "^1.89.2",
72
- "stats-gl": "^3.6.0",
73
- "three": "^0.177.0",
74
- "typescript": "^5.0.2",
75
- "vite": "^6.3.5",
76
- "vite-plugin-glsl": "1.2.1",
77
- "ws": "^8.16.0"
78
- }
79
- }
1
+ {
2
+ "name": "@tomorrowevening/hermes",
3
+ "author": "Colin Duffy <http://tomorrowevening.com/>",
4
+ "description": "An extendable set of Web Tools controlled via a separate window for non-intereference with content.",
5
+ "license": "GPL-3.0-or-later",
6
+ "main": "./dist/hermes.cjs.js",
7
+ "module": "./dist/hermes.esm.js",
8
+ "types": "./types/index.d.ts",
9
+ "type": "module",
10
+ "version": "0.1.17",
11
+ "homepage": "https://github.com/tomorrowevening/hermes#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/tomorrowevening/hermes/issues"
14
+ },
15
+ "keywords": [
16
+ "Editor",
17
+ "Remote",
18
+ "TheatreJS",
19
+ "ThreeJS"
20
+ ],
21
+ "files": [
22
+ "dist/hermes.es.js",
23
+ "dist/hermes.cjs.js",
24
+ "dist/hermes.css",
25
+ "types/**/*.d.ts"
26
+ ],
27
+ "exports": {
28
+ ".": {
29
+ "types": "./types/index.d.ts",
30
+ "import": "./dist/hermes.es.js",
31
+ "require": "./dist/hermes.cjs.js"
32
+ },
33
+ "./hermes.css": "./dist/hermes.css"
34
+ },
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "git+https://github.com/tomorrowevening/hermes.git"
38
+ },
39
+ "scripts": {
40
+ "server": "node server/index.mjs",
41
+ "clean": "rm -r dist && rm -r types",
42
+ "dev": "vite",
43
+ "declare": "tsc --declaration --emitDeclarationOnly --declarationDir types",
44
+ "buildLib": "yarn declare && vite build",
45
+ "buildExample": "vite build --config vite.config.example.ts",
46
+ "build": "yarn buildLib && yarn buildExample",
47
+ "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
48
+ "preview": "vite preview"
49
+ },
50
+ "devDependencies": {
51
+ "@theatre/core": "^0.7.2",
52
+ "@theatre/studio": "^0.7.2",
53
+ "@types/react": "^18.2.15",
54
+ "@types/react-dom": "^18.2.7",
55
+ "@types/three": "^0.177.0",
56
+ "@typescript-eslint/eslint-plugin": "^6.4.0",
57
+ "@typescript-eslint/parser": "^6.4.0",
58
+ "@vitejs/plugin-react": "^4.0.3",
59
+ "camera-controls": "^2.9.0",
60
+ "detect-gpu": "^5.0.70",
61
+ "eslint": "^8.45.0",
62
+ "eslint-plugin-react": "^7.33.2",
63
+ "eslint-plugin-react-hooks": "^4.6.0",
64
+ "eslint-plugin-react-refresh": "^0.4.3",
65
+ "glslify": "^7.1.1",
66
+ "glslify-loader": "^2.0.0",
67
+ "path": "^0.12.7",
68
+ "postprocessing": "^6.37.6",
69
+ "react": "^18.2.0",
70
+ "react-dom": "^18.2.0",
71
+ "sass": "^1.89.2",
72
+ "stats-gl": "^3.6.0",
73
+ "three": "^0.177.0",
74
+ "typescript": "^5.0.2",
75
+ "vite": "^6.3.5",
76
+ "vite-plugin-glsl": "1.2.1",
77
+ "ws": "^8.16.0"
78
+ }
79
+ }
@@ -54,7 +54,8 @@ export default class RemoteThree extends BaseRemote implements EventDispatcher<T
54
54
  addGroup(data: GroupData): void;
55
55
  removeGroup(name: string): void;
56
56
  updateGroup(group: string, prop: string, value: any): void;
57
- addSpline(spline: Curve<any>): void;
57
+ addSplineCurve(spline: Curve<any>): void;
58
+ addSplineObject(spline: any): void;
58
59
  setRenderer(value: any, inputElement?: any): void;
59
60
  updateRenderer(data: any): void;
60
61
  addScene(value: Scene): void;
@@ -35,6 +35,7 @@ export default class Spline extends Object3D {
35
35
  removeSelectedPt: () => void;
36
36
  updateLastPoint(value: Vector3): void;
37
37
  updateSpline: () => void;
38
+ updateField(position: Vector3): void;
38
39
  private onMouseClick;
39
40
  getPointAt(percentage: number): Vector3;
40
41
  getTangentAt(percentage: number): Vector3;
@@ -48,6 +49,6 @@ export default class Spline extends Object3D {
48
49
  set curvePercentage(value: number);
49
50
  private updateCurrentPoint;
50
51
  private onUpdateTransform;
51
- initDebug(parentGroup: InspectorGroup): void;
52
+ initDebug(parentGroup: InspectorGroup, visible: boolean): void;
52
53
  private debugPoint;
53
54
  }
@@ -19,7 +19,7 @@ export default class SplineEditor extends Object3D {
19
19
  constructor(camera: Camera, three: RemoteThree);
20
20
  initDebug(): void;
21
21
  dispose(): void;
22
- addSpline(spline: Spline): void;
22
+ addSpline(spline: Spline, visible: boolean): void;
23
23
  createSpline: (defaultPoints?: Array<Vector3>) => Spline;
24
24
  createSplineFromArray: (points: Array<number[]>) => Spline;
25
25
  createSplineFromCatmullRom: (curve: CatmullRomCurve3) => Spline;