@judah-silva/rnacanvas 0.0.3 → 0.0.4

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 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._quat.setToQuaternion(quat.quaternion);
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
- this._quat.setToQuaternion(this._node.rotationQuaternion);
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;
@@ -1436,8 +1425,10 @@ function Canvas({
1436
1425
  scene.current?.add(motifMesh);
1437
1426
  if (motifProps[index].position) positions[index] = motifProps[index].position.clone();
1438
1427
  motifMesh.setPosition(positions[index].x, positions[index].y, positions[index].z);
1439
- if (motifProps[index].rotation) motifMesh.quat.setToQuaternion(motifProps[index].rotation.quaternion);
1440
- motifMesh.multiplyScalar(canvasRef.current.width / 250);
1428
+ if (motifProps[index].rotation) motifMesh.setQuaternion(motifProps[index].rotation);
1429
+ let scale = canvasRef.current.width / 250;
1430
+ if (motifProps[index].scale) scale = motifProps[index].scale;
1431
+ motifMesh.multiplyScalar(scale);
1441
1432
  });
1442
1433
  const eventManager = scene.current?.eventManager;
1443
1434
  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, Quaternion as Quaternion3, Scene as Scene2, Space, Vector3 as Vector32 } from "@babylonjs/core";
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._quat.setToQuaternion(quat.quaternion);
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
- this._quat.setToQuaternion(this._node.rotationQuaternion);
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;
@@ -1379,8 +1368,10 @@ function Canvas({
1379
1368
  scene.current?.add(motifMesh);
1380
1369
  if (motifProps[index].position) positions[index] = motifProps[index].position.clone();
1381
1370
  motifMesh.setPosition(positions[index].x, positions[index].y, positions[index].z);
1382
- if (motifProps[index].rotation) motifMesh.quat.setToQuaternion(motifProps[index].rotation.quaternion);
1383
- motifMesh.multiplyScalar(canvasRef.current.width / 250);
1371
+ if (motifProps[index].rotation) motifMesh.setQuaternion(motifProps[index].rotation);
1372
+ let scale = canvasRef.current.width / 250;
1373
+ if (motifProps[index].scale) scale = motifProps[index].scale;
1374
+ motifMesh.multiplyScalar(scale);
1384
1375
  });
1385
1376
  const eventManager = scene.current?.eventManager;
1386
1377
  eventManager.on(Events.EventType.OBJECT_SELECTED, onSelectMotif);
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@judah-silva/rnacanvas",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "A 3D Canvas for displaying and interacting with custom RNA models. Powered by BabylonJS.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",