@judah-silva/rnacanvas 0.0.3 → 0.0.5
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/index.d.mts +0 -2
- package/dist/index.d.ts +0 -2
- package/dist/index.js +13 -19
- package/dist/index.mjs +14 -20
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -104,7 +104,6 @@ interface userData {
|
|
|
104
104
|
*/
|
|
105
105
|
declare class Motif extends Group<Residue> {
|
|
106
106
|
userData: userData;
|
|
107
|
-
private _quat;
|
|
108
107
|
constructor(name: string);
|
|
109
108
|
addChild(child: Residue): void;
|
|
110
109
|
setPosition(x: number, y: number, z: number): void;
|
|
@@ -113,7 +112,6 @@ declare class Motif extends Group<Residue> {
|
|
|
113
112
|
rotateByQuaternion(quat: Quat): void;
|
|
114
113
|
setQuaternion(quat: Quat): void;
|
|
115
114
|
multiplyScalar(scalar: number): void;
|
|
116
|
-
private _nanCheck;
|
|
117
115
|
get uuid(): string;
|
|
118
116
|
get quat(): Quat;
|
|
119
117
|
get scale(): number;
|
package/dist/index.d.ts
CHANGED
|
@@ -104,7 +104,6 @@ interface userData {
|
|
|
104
104
|
*/
|
|
105
105
|
declare class Motif extends Group<Residue> {
|
|
106
106
|
userData: userData;
|
|
107
|
-
private _quat;
|
|
108
107
|
constructor(name: string);
|
|
109
108
|
addChild(child: Residue): void;
|
|
110
109
|
setPosition(x: number, y: number, z: number): void;
|
|
@@ -113,7 +112,6 @@ declare class Motif extends Group<Residue> {
|
|
|
113
112
|
rotateByQuaternion(quat: Quat): void;
|
|
114
113
|
setQuaternion(quat: Quat): void;
|
|
115
114
|
multiplyScalar(scalar: number): void;
|
|
116
|
-
private _nanCheck;
|
|
117
115
|
get uuid(): string;
|
|
118
116
|
get quat(): Quat;
|
|
119
117
|
get scale(): number;
|
package/dist/index.js
CHANGED
|
@@ -218,12 +218,10 @@ var Matrix4 = class {
|
|
|
218
218
|
// src/3D/Motif.ts
|
|
219
219
|
var Motif = class extends Group {
|
|
220
220
|
userData;
|
|
221
|
-
_quat;
|
|
222
221
|
constructor(name) {
|
|
223
222
|
const tempEngine = new import_core5.NullEngine();
|
|
224
223
|
const tempScene = new import_core5.Scene(tempEngine);
|
|
225
224
|
super(name, tempScene);
|
|
226
|
-
this._quat = new Quat();
|
|
227
225
|
this.userData = {
|
|
228
226
|
atomInfo: [],
|
|
229
227
|
fileName: ""
|
|
@@ -251,20 +249,18 @@ var Motif = class extends Group {
|
|
|
251
249
|
axis.y,
|
|
252
250
|
axis.z
|
|
253
251
|
), angle, import_core5.Space.WORLD);
|
|
254
|
-
this._nanCheck();
|
|
255
252
|
}
|
|
256
253
|
rotateByQuaternion(quat) {
|
|
257
254
|
if (this._node.rotationQuaternion === null) {
|
|
258
255
|
this._node.rotationQuaternion = this._node.rotation.toQuaternion();
|
|
259
256
|
}
|
|
260
257
|
quat.quaternion.multiplyToRef(this._node.rotationQuaternion, this._node.rotationQuaternion);
|
|
261
|
-
this._nanCheck();
|
|
262
258
|
}
|
|
263
259
|
setQuaternion(quat) {
|
|
264
260
|
if (this._node.rotationQuaternion === null) {
|
|
265
261
|
this._node.rotationQuaternion = this._node.rotation.toQuaternion();
|
|
266
262
|
}
|
|
267
|
-
this.
|
|
263
|
+
this._node.rotationQuaternion.set(quat.x, quat.y, quat.z, quat.w);
|
|
268
264
|
}
|
|
269
265
|
multiplyScalar(scalar) {
|
|
270
266
|
this._node.scaling = new import_core5.Vector3(
|
|
@@ -273,12 +269,6 @@ var Motif = class extends Group {
|
|
|
273
269
|
this._node.scaling.z * scalar
|
|
274
270
|
);
|
|
275
271
|
}
|
|
276
|
-
_nanCheck() {
|
|
277
|
-
if (Number.isNaN(this._quat.quaternion.w) || Number.isNaN(this._quat.quaternion.x) || Number.isNaN(this._quat.quaternion.y) || Number.isNaN(this._quat.quaternion.z)) {
|
|
278
|
-
this._quat.setToQuaternion(import_core5.Quaternion.Identity());
|
|
279
|
-
throw new Error(`Quaternion is NaN for motif ${this._node.name}`);
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
272
|
get uuid() {
|
|
283
273
|
return this._node.uniqueId.toString();
|
|
284
274
|
}
|
|
@@ -286,8 +276,7 @@ var Motif = class extends Group {
|
|
|
286
276
|
if (this._node.rotationQuaternion === null) {
|
|
287
277
|
this._node.rotationQuaternion = this._node.rotation.toQuaternion();
|
|
288
278
|
}
|
|
289
|
-
|
|
290
|
-
return this._quat;
|
|
279
|
+
return new Quat().setToQuaternion(this._node.rotationQuaternion);
|
|
291
280
|
}
|
|
292
281
|
get scale() {
|
|
293
282
|
return this._node.scaling.x;
|
|
@@ -1174,7 +1163,7 @@ function Canvas({
|
|
|
1174
1163
|
const [kabschRMSD, setKabschRMSD] = (0, import_react.useState)([]);
|
|
1175
1164
|
const [lockedMotifIds, setLockedMotifIds] = (0, import_react.useState)([]);
|
|
1176
1165
|
const addMotif = (motif) => {
|
|
1177
|
-
if (
|
|
1166
|
+
if (selectedMotifMeshState.current.has(motif)) {
|
|
1178
1167
|
return;
|
|
1179
1168
|
}
|
|
1180
1169
|
const newSet = /* @__PURE__ */ new Set();
|
|
@@ -1187,12 +1176,13 @@ function Canvas({
|
|
|
1187
1176
|
selectedMotifMeshState.current.add(motif);
|
|
1188
1177
|
};
|
|
1189
1178
|
const removeMotif = (motif) => {
|
|
1190
|
-
if (!
|
|
1179
|
+
if (!selectedMotifMeshState.current.has(motif)) {
|
|
1191
1180
|
return;
|
|
1192
1181
|
}
|
|
1182
|
+
console.log("removing motif: ", motif);
|
|
1193
1183
|
selectedMotifMeshState.current.delete(motif);
|
|
1194
1184
|
setSelectedmotifIds((prevState) => {
|
|
1195
|
-
const newState = prevState;
|
|
1185
|
+
const newState = new Set(prevState);
|
|
1196
1186
|
newState.delete(motif.uuid);
|
|
1197
1187
|
return newState;
|
|
1198
1188
|
});
|
|
@@ -1328,13 +1318,15 @@ function Canvas({
|
|
|
1328
1318
|
if (!event.rotationAxis.equals(Vec3.Zero) || !event.translationDirection.equals(Vec3.Zero)) {
|
|
1329
1319
|
return;
|
|
1330
1320
|
}
|
|
1331
|
-
if (!/^[
|
|
1321
|
+
if (!/^[1-9]$/.test(event.key) || Number(event.key) > motifs.length) {
|
|
1332
1322
|
return;
|
|
1333
1323
|
}
|
|
1334
1324
|
const motif = motifs[Number(event.key) - 1];
|
|
1335
1325
|
if (selectedMotifMeshState.current.has(motif)) {
|
|
1326
|
+
console.log("removing motif");
|
|
1336
1327
|
removeMotif(motif);
|
|
1337
1328
|
} else {
|
|
1329
|
+
console.log("adding motif");
|
|
1338
1330
|
addMotif(motif);
|
|
1339
1331
|
}
|
|
1340
1332
|
}
|
|
@@ -1436,8 +1428,10 @@ function Canvas({
|
|
|
1436
1428
|
scene.current?.add(motifMesh);
|
|
1437
1429
|
if (motifProps[index].position) positions[index] = motifProps[index].position.clone();
|
|
1438
1430
|
motifMesh.setPosition(positions[index].x, positions[index].y, positions[index].z);
|
|
1439
|
-
if (motifProps[index].rotation) motifMesh.
|
|
1440
|
-
|
|
1431
|
+
if (motifProps[index].rotation) motifMesh.setQuaternion(motifProps[index].rotation);
|
|
1432
|
+
let scale = canvasRef.current.width / 250;
|
|
1433
|
+
if (motifProps[index].scale) scale = motifProps[index].scale;
|
|
1434
|
+
motifMesh.multiplyScalar(scale);
|
|
1441
1435
|
});
|
|
1442
1436
|
const eventManager = scene.current?.eventManager;
|
|
1443
1437
|
eventManager.on(Events.EventType.OBJECT_SELECTED, onSelectMotif);
|
package/dist/index.mjs
CHANGED
|
@@ -27,7 +27,7 @@ var Group = class {
|
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
// src/3D/Motif.ts
|
|
30
|
-
import { NullEngine,
|
|
30
|
+
import { NullEngine, Scene as Scene2, Space, Vector3 as Vector32 } from "@babylonjs/core";
|
|
31
31
|
|
|
32
32
|
// src/Math/Vec3.ts
|
|
33
33
|
import { Quaternion, Vector3 } from "@babylonjs/core";
|
|
@@ -161,12 +161,10 @@ var Matrix4 = class {
|
|
|
161
161
|
// src/3D/Motif.ts
|
|
162
162
|
var Motif = class extends Group {
|
|
163
163
|
userData;
|
|
164
|
-
_quat;
|
|
165
164
|
constructor(name) {
|
|
166
165
|
const tempEngine = new NullEngine();
|
|
167
166
|
const tempScene = new Scene2(tempEngine);
|
|
168
167
|
super(name, tempScene);
|
|
169
|
-
this._quat = new Quat();
|
|
170
168
|
this.userData = {
|
|
171
169
|
atomInfo: [],
|
|
172
170
|
fileName: ""
|
|
@@ -194,20 +192,18 @@ var Motif = class extends Group {
|
|
|
194
192
|
axis.y,
|
|
195
193
|
axis.z
|
|
196
194
|
), angle, Space.WORLD);
|
|
197
|
-
this._nanCheck();
|
|
198
195
|
}
|
|
199
196
|
rotateByQuaternion(quat) {
|
|
200
197
|
if (this._node.rotationQuaternion === null) {
|
|
201
198
|
this._node.rotationQuaternion = this._node.rotation.toQuaternion();
|
|
202
199
|
}
|
|
203
200
|
quat.quaternion.multiplyToRef(this._node.rotationQuaternion, this._node.rotationQuaternion);
|
|
204
|
-
this._nanCheck();
|
|
205
201
|
}
|
|
206
202
|
setQuaternion(quat) {
|
|
207
203
|
if (this._node.rotationQuaternion === null) {
|
|
208
204
|
this._node.rotationQuaternion = this._node.rotation.toQuaternion();
|
|
209
205
|
}
|
|
210
|
-
this.
|
|
206
|
+
this._node.rotationQuaternion.set(quat.x, quat.y, quat.z, quat.w);
|
|
211
207
|
}
|
|
212
208
|
multiplyScalar(scalar) {
|
|
213
209
|
this._node.scaling = new Vector32(
|
|
@@ -216,12 +212,6 @@ var Motif = class extends Group {
|
|
|
216
212
|
this._node.scaling.z * scalar
|
|
217
213
|
);
|
|
218
214
|
}
|
|
219
|
-
_nanCheck() {
|
|
220
|
-
if (Number.isNaN(this._quat.quaternion.w) || Number.isNaN(this._quat.quaternion.x) || Number.isNaN(this._quat.quaternion.y) || Number.isNaN(this._quat.quaternion.z)) {
|
|
221
|
-
this._quat.setToQuaternion(Quaternion3.Identity());
|
|
222
|
-
throw new Error(`Quaternion is NaN for motif ${this._node.name}`);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
215
|
get uuid() {
|
|
226
216
|
return this._node.uniqueId.toString();
|
|
227
217
|
}
|
|
@@ -229,8 +219,7 @@ var Motif = class extends Group {
|
|
|
229
219
|
if (this._node.rotationQuaternion === null) {
|
|
230
220
|
this._node.rotationQuaternion = this._node.rotation.toQuaternion();
|
|
231
221
|
}
|
|
232
|
-
|
|
233
|
-
return this._quat;
|
|
222
|
+
return new Quat().setToQuaternion(this._node.rotationQuaternion);
|
|
234
223
|
}
|
|
235
224
|
get scale() {
|
|
236
225
|
return this._node.scaling.x;
|
|
@@ -1117,7 +1106,7 @@ function Canvas({
|
|
|
1117
1106
|
const [kabschRMSD, setKabschRMSD] = useState([]);
|
|
1118
1107
|
const [lockedMotifIds, setLockedMotifIds] = useState([]);
|
|
1119
1108
|
const addMotif = (motif) => {
|
|
1120
|
-
if (
|
|
1109
|
+
if (selectedMotifMeshState.current.has(motif)) {
|
|
1121
1110
|
return;
|
|
1122
1111
|
}
|
|
1123
1112
|
const newSet = /* @__PURE__ */ new Set();
|
|
@@ -1130,12 +1119,13 @@ function Canvas({
|
|
|
1130
1119
|
selectedMotifMeshState.current.add(motif);
|
|
1131
1120
|
};
|
|
1132
1121
|
const removeMotif = (motif) => {
|
|
1133
|
-
if (!
|
|
1122
|
+
if (!selectedMotifMeshState.current.has(motif)) {
|
|
1134
1123
|
return;
|
|
1135
1124
|
}
|
|
1125
|
+
console.log("removing motif: ", motif);
|
|
1136
1126
|
selectedMotifMeshState.current.delete(motif);
|
|
1137
1127
|
setSelectedmotifIds((prevState) => {
|
|
1138
|
-
const newState = prevState;
|
|
1128
|
+
const newState = new Set(prevState);
|
|
1139
1129
|
newState.delete(motif.uuid);
|
|
1140
1130
|
return newState;
|
|
1141
1131
|
});
|
|
@@ -1271,13 +1261,15 @@ function Canvas({
|
|
|
1271
1261
|
if (!event.rotationAxis.equals(Vec3.Zero) || !event.translationDirection.equals(Vec3.Zero)) {
|
|
1272
1262
|
return;
|
|
1273
1263
|
}
|
|
1274
|
-
if (!/^[
|
|
1264
|
+
if (!/^[1-9]$/.test(event.key) || Number(event.key) > motifs.length) {
|
|
1275
1265
|
return;
|
|
1276
1266
|
}
|
|
1277
1267
|
const motif = motifs[Number(event.key) - 1];
|
|
1278
1268
|
if (selectedMotifMeshState.current.has(motif)) {
|
|
1269
|
+
console.log("removing motif");
|
|
1279
1270
|
removeMotif(motif);
|
|
1280
1271
|
} else {
|
|
1272
|
+
console.log("adding motif");
|
|
1281
1273
|
addMotif(motif);
|
|
1282
1274
|
}
|
|
1283
1275
|
}
|
|
@@ -1379,8 +1371,10 @@ function Canvas({
|
|
|
1379
1371
|
scene.current?.add(motifMesh);
|
|
1380
1372
|
if (motifProps[index].position) positions[index] = motifProps[index].position.clone();
|
|
1381
1373
|
motifMesh.setPosition(positions[index].x, positions[index].y, positions[index].z);
|
|
1382
|
-
if (motifProps[index].rotation) motifMesh.
|
|
1383
|
-
|
|
1374
|
+
if (motifProps[index].rotation) motifMesh.setQuaternion(motifProps[index].rotation);
|
|
1375
|
+
let scale = canvasRef.current.width / 250;
|
|
1376
|
+
if (motifProps[index].scale) scale = motifProps[index].scale;
|
|
1377
|
+
motifMesh.multiplyScalar(scale);
|
|
1384
1378
|
});
|
|
1385
1379
|
const eventManager = scene.current?.eventManager;
|
|
1386
1380
|
eventManager.on(Events.EventType.OBJECT_SELECTED, onSelectMotif);
|
package/package.json
CHANGED