copper3d 1.15.15 → 1.15.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.
@@ -38478,6 +38478,69 @@ function switchEraserSize(size, urls) {
38478
38478
  }
38479
38479
  }
38480
38480
  return url;
38481
+ }
38482
+ /**
38483
+ * Cubic-Lagrange basis function
38484
+ * @param x
38485
+ * @returns
38486
+ */
38487
+ function L3(x) {
38488
+ let L1 = 1 - x;
38489
+ let L2 = x;
38490
+ let sc = 9 / 2;
38491
+ return [
38492
+ 0.5 * L1 * (3 * L1 - 1) * (3 * L1 - 2),
38493
+ sc * L1 * L2 * (3 * L1 - 1),
38494
+ sc * L1 * L2 * (3 * L2 - 1),
38495
+ 0.5 * L2 * (3 * L2 - 1) * (3 * L2 - 2),
38496
+ ];
38497
+ }
38498
+ /**
38499
+ * To calculate the weights for each element of Xi using the cubic Lagrange basis functions.
38500
+ * @param Xi
38501
+ * @returns
38502
+ */
38503
+ function getWightsL3L3L3(Xi) {
38504
+ let W0, W1, W2;
38505
+ W0 = L3(Xi[0]);
38506
+ W1 = L3(Xi[1]);
38507
+ W2 = L3(Xi[2]);
38508
+ let w = [];
38509
+ for (let k2 in W2) {
38510
+ for (let k1 in W1) {
38511
+ for (let k0 in W0) {
38512
+ w.push(W0[k0] * W1[k1] * W2[k2]);
38513
+ }
38514
+ }
38515
+ }
38516
+ return w;
38517
+ }
38518
+ /**
38519
+ * Euclidean distance n dimensions
38520
+ * @param x0
38521
+ * @param x1
38522
+ * @returns
38523
+ */
38524
+ function calcDistance(x0, x1) {
38525
+ let dx2 = 0;
38526
+ for (let i = 0; i < x0.length; i++) {
38527
+ let dx = x0[i] - x1[i];
38528
+ dx2 += dx * dx;
38529
+ }
38530
+ return Math.sqrt(dx2);
38531
+ }
38532
+ function perturbRandom(x, dx) {
38533
+ let xp = [];
38534
+ for (let i = 0; i < x.length; i++) {
38535
+ xp.push(x[i] + 2 * dx * (Math.random() - 0.5));
38536
+ if (xp[i] < 0) {
38537
+ xp[i] = 0;
38538
+ }
38539
+ else if (xp[i] > 1) {
38540
+ xp[i] = 1;
38541
+ }
38542
+ }
38543
+ return xp;
38481
38544
  }
38482
38545
 
38483
38546
  /* eslint no-bitwise: 0 */
@@ -45518,14 +45581,14 @@ class Copper3dTrackballControls extends EventDispatcher {
45518
45581
  function onMouseDown(event) {
45519
45582
  if (_state === STATE.NONE) {
45520
45583
  switch (event.button) {
45521
- case scope.mouseButtons.LEFT:
45522
- _state = STATE.ROTATE;
45584
+ case 0: // mouse left
45585
+ _state = scope.mouseButtons.LEFT;
45523
45586
  break;
45524
- case scope.mouseButtons.MIDDLE:
45525
- _state = STATE.ZOOM;
45587
+ case 1: // mouse wheel
45588
+ _state = scope.mouseButtons.MIDDLE;
45526
45589
  break;
45527
- case scope.mouseButtons.RIGHT:
45528
- _state = STATE.PAN;
45590
+ case 2: // mouse right
45591
+ _state = scope.mouseButtons.RIGHT;
45529
45592
  break;
45530
45593
  }
45531
45594
  }
@@ -56552,10 +56615,6 @@ class copperRenderer extends baseRenderer {
56552
56615
  this.interval = 1 / this.fps;
56553
56616
  this.preRenderCallbackFunctions = [];
56554
56617
  this.animate = (time) => {
56555
- // if (this.start) {
56556
- // this.fpsCap = createFpsCap(this.render, 10);
56557
- // this.start = false;
56558
- // }
56559
56618
  var _a, _b, _c;
56560
56619
  switch ((_a = this.options) === null || _a === void 0 ? void 0 : _a.fpsMode) {
56561
56620
  case "1":
@@ -70101,8 +70160,214 @@ class nrrd_tools {
70101
70160
  }
70102
70161
  }
70103
70162
 
70163
+ class Node {
70164
+ constructor(id, p) {
70165
+ this.elements = [];
70166
+ this.id = id;
70167
+ this.p = p;
70168
+ }
70169
+ }
70170
+ class Element {
70171
+ constructor(id, basis, nodes) {
70172
+ this.id = id;
70173
+ this.basis = basis;
70174
+ this.nodes = nodes;
70175
+ }
70176
+ }
70177
+ class MeshNodeTool {
70178
+ constructor() {
70179
+ this.nodes = {};
70180
+ this.elements = {};
70181
+ }
70182
+ addNode(id, p) {
70183
+ this.nodes[id] = new Node(id, p);
70184
+ }
70185
+ addElement(id, basis, nodeIds) {
70186
+ let nodes = [];
70187
+ for (let nid in nodeIds) {
70188
+ let enid = nodeIds[nid];
70189
+ nodes.push(this.nodes[enid]);
70190
+ }
70191
+ let element = new Element(id, basis, nodes);
70192
+ this.elements[id] = element;
70193
+ for (let idx in element.nodes) {
70194
+ element.nodes[idx].elements.push(element);
70195
+ }
70196
+ }
70197
+ loadMesh(json) {
70198
+ for (let nid in json.nodes) {
70199
+ this.addNode(nid, json.nodes[nid]);
70200
+ }
70201
+ for (let eid in json.elements) {
70202
+ let elem = json.elements[eid];
70203
+ this.addElement(eid, elem.basis, elem.nodes);
70204
+ }
70205
+ }
70206
+ evaluate(elementId, xi) {
70207
+ let w = getWightsL3L3L3(xi);
70208
+ return evaluateElement(this.elements[elementId], w);
70209
+ }
70210
+ find(point, startingNodeId) {
70211
+ let pt = [point.x, point.y, point.z];
70212
+ let nodeMaterialPoints = this.getNodeMaterialPoints(startingNodeId);
70213
+ for (let i in nodeMaterialPoints) {
70214
+ let mpt = nodeMaterialPoints[i];
70215
+ let x = this.evaluate(mpt.elementId, mpt.xi);
70216
+ let r = calcDistance(x, pt);
70217
+ mpt.error = r;
70218
+ }
70219
+ let t0 = new Date().getTime();
70220
+ let n = 0;
70221
+ for (let step = 0; step < 10000; step++) {
70222
+ for (let i in nodeMaterialPoints) {
70223
+ let mpt = nodeMaterialPoints[i];
70224
+ let xi = perturbRandom(mpt.xi, 0.1);
70225
+ let x = this.evaluate(mpt.elementId, xi);
70226
+ let r = calcDistance(x, pt);
70227
+ if (r < mpt.error) {
70228
+ mpt.error = r;
70229
+ mpt.xi = xi;
70230
+ if (r < 1.0) {
70231
+ console.log("Time: (" +
70232
+ n +
70233
+ ") " +
70234
+ (new Date().getTime() - t0) +
70235
+ "ms Error: " +
70236
+ r);
70237
+ return mpt;
70238
+ }
70239
+ }
70240
+ }
70241
+ n = step;
70242
+ }
70243
+ let bestIndex = 0;
70244
+ let bestError = nodeMaterialPoints[0].error;
70245
+ for (let i in nodeMaterialPoints) {
70246
+ let mpt = nodeMaterialPoints[i];
70247
+ if (mpt.error < bestError) {
70248
+ bestIndex = Number(i);
70249
+ bestError = mpt.error;
70250
+ }
70251
+ }
70252
+ let mpt = nodeMaterialPoints[bestIndex];
70253
+ console.log("Time: (" +
70254
+ n +
70255
+ ") " +
70256
+ (new Date().getTime() - t0) +
70257
+ "ms Error: " +
70258
+ mpt.error);
70259
+ return mpt;
70260
+ }
70261
+ search(point, startingNodeId, tol) {
70262
+ let pt = [point.x, point.y, point.z];
70263
+ let nodeMaterialPoints = this.getNodeMaterialPoints(startingNodeId);
70264
+ for (let i in nodeMaterialPoints) {
70265
+ let mpt = nodeMaterialPoints[i];
70266
+ let x = this.evaluate(mpt.elementId, mpt.xi);
70267
+ mpt.error = calcDistance(x, pt);
70268
+ }
70269
+ let t0 = new Date().getTime();
70270
+ let xiStepSize = [0.1, 0.01, 0.001];
70271
+ for (let i in nodeMaterialPoints) {
70272
+ let mpt = nodeMaterialPoints[i];
70273
+ let numDims = mpt.xi.length;
70274
+ let nIter = 0;
70275
+ let go = true;
70276
+ while (go || nIter < 10) {
70277
+ let minErr = 1 * mpt.error;
70278
+ let minXi;
70279
+ for (let xiIdx in xiStepSize) {
70280
+ let dXi = xiStepSize[xiIdx];
70281
+ for (let dim = 0; dim < numDims; dim++) {
70282
+ let xi = mpt.xi.slice();
70283
+ xi[dim] += dXi;
70284
+ if (xi[dim] >= 0 && xi[dim] <= 1) {
70285
+ let x = this.evaluate(mpt.elementId, mpt.xi);
70286
+ let err = calcDistance(x, pt);
70287
+ if (err < minErr) {
70288
+ minErr = err;
70289
+ minXi = xi;
70290
+ if (err < tol) {
70291
+ mpt.error = err;
70292
+ mpt.xi = xi;
70293
+ console.log("Time 1: " +
70294
+ (new Date().getTime() - t0) +
70295
+ "ms Error: " +
70296
+ mpt.error);
70297
+ return mpt;
70298
+ }
70299
+ }
70300
+ }
70301
+ xi = mpt.xi.slice();
70302
+ xi[dim] -= dXi;
70303
+ if (xi[dim] >= 0 && xi[dim] <= 1) {
70304
+ let x = this.evaluate(mpt.elementId, mpt.xi);
70305
+ let err = calcDistance(x, pt);
70306
+ if (err < minErr) {
70307
+ minErr = err;
70308
+ minXi = xi;
70309
+ if (err < tol) {
70310
+ mpt.error = err;
70311
+ mpt.xi = xi;
70312
+ console.log("Time 2: " +
70313
+ (new Date().getTime() - t0) +
70314
+ "ms Error: " +
70315
+ mpt.error);
70316
+ return mpt;
70317
+ }
70318
+ }
70319
+ }
70320
+ }
70321
+ }
70322
+ if (minXi === null || minXi === undefined) {
70323
+ go = false;
70324
+ }
70325
+ else {
70326
+ mpt.xi = minXi;
70327
+ mpt.error = minErr;
70328
+ }
70329
+ nIter++;
70330
+ }
70331
+ }
70332
+ let bestIndex = 0;
70333
+ let bestError = nodeMaterialPoints[0].error;
70334
+ for (let i in nodeMaterialPoints) {
70335
+ let mpt = nodeMaterialPoints[i];
70336
+ if (mpt.error < bestError) {
70337
+ bestIndex = Number(i);
70338
+ bestError = mpt.error;
70339
+ }
70340
+ }
70341
+ let mpt = nodeMaterialPoints[bestIndex];
70342
+ console.log("Time 3: " + (new Date().getTime() - t0) + "ms Error: " + mpt.error);
70343
+ return mpt;
70344
+ }
70345
+ getNodeMaterialPoints(nodeId) {
70346
+ let materialPoints = [];
70347
+ let node = this.nodes[nodeId];
70348
+ for (let eid in node.elements) {
70349
+ let element = node.elements[eid];
70350
+ let nodeIdx = element.nodes.indexOf(node);
70351
+ let xi0 = (nodeIdx % 4) / 3;
70352
+ let xi1 = Math.floor((nodeIdx % 16) / 4) / 3;
70353
+ let xi2 = Math.floor(nodeIdx / 16) / 3;
70354
+ materialPoints.push({ elementId: element.id, xi: [xi0, xi1, xi2] });
70355
+ }
70356
+ return materialPoints;
70357
+ }
70358
+ }
70359
+ function evaluateElement(element, weights) {
70360
+ let x = [0, 0, 0];
70361
+ for (let f = 0; f < 3; f++) {
70362
+ for (let i = 0; i < weights.length; i++) {
70363
+ x[f] += weights[i] * element.nodes[i].p[f];
70364
+ }
70365
+ }
70366
+ return x;
70367
+ }
70368
+
70104
70369
  // import * as kiwrious from "copper3d_plugin_heart_k";
70105
- const REVISION = "v1.15.15";
70106
- console.log("%cCopper3D Visualisation %cBeta:v1.15.15", "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
70370
+ const REVISION = "v1.15.17";
70371
+ console.log("%cCopper3D Visualisation %cBeta:v1.15.17", "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
70107
70372
 
70108
- export { CameraViewPoint, Copper3dTrackballControls, REVISION, addBoxHelper, addLabelToScene, configKiwriousHeart, convert3DPostoScreenPos, convertScreenPosto3DPos, copperMScene, copperMSceneRenderer, copperRenderer, copperRendererOnDemond, copperScene, copperSceneOnDemond, createTexture2D_NRRD, fullScreenListenner, kiwrious, loading, nrrd_tools, setHDRFilePath };
70373
+ export { CameraViewPoint, Copper3dTrackballControls, MeshNodeTool, REVISION, addBoxHelper, addLabelToScene, configKiwriousHeart, convert3DPostoScreenPos, convertScreenPosto3DPos, copperMScene, copperMSceneRenderer, copperRenderer, copperRendererOnDemond, copperScene, copperSceneOnDemond, createTexture2D_NRRD, fullScreenListenner, kiwrious, loading, nrrd_tools, setHDRFilePath };
@@ -38486,6 +38486,69 @@
38486
38486
  }
38487
38487
  }
38488
38488
  return url;
38489
+ }
38490
+ /**
38491
+ * Cubic-Lagrange basis function
38492
+ * @param x
38493
+ * @returns
38494
+ */
38495
+ function L3(x) {
38496
+ let L1 = 1 - x;
38497
+ let L2 = x;
38498
+ let sc = 9 / 2;
38499
+ return [
38500
+ 0.5 * L1 * (3 * L1 - 1) * (3 * L1 - 2),
38501
+ sc * L1 * L2 * (3 * L1 - 1),
38502
+ sc * L1 * L2 * (3 * L2 - 1),
38503
+ 0.5 * L2 * (3 * L2 - 1) * (3 * L2 - 2),
38504
+ ];
38505
+ }
38506
+ /**
38507
+ * To calculate the weights for each element of Xi using the cubic Lagrange basis functions.
38508
+ * @param Xi
38509
+ * @returns
38510
+ */
38511
+ function getWightsL3L3L3(Xi) {
38512
+ let W0, W1, W2;
38513
+ W0 = L3(Xi[0]);
38514
+ W1 = L3(Xi[1]);
38515
+ W2 = L3(Xi[2]);
38516
+ let w = [];
38517
+ for (let k2 in W2) {
38518
+ for (let k1 in W1) {
38519
+ for (let k0 in W0) {
38520
+ w.push(W0[k0] * W1[k1] * W2[k2]);
38521
+ }
38522
+ }
38523
+ }
38524
+ return w;
38525
+ }
38526
+ /**
38527
+ * Euclidean distance n dimensions
38528
+ * @param x0
38529
+ * @param x1
38530
+ * @returns
38531
+ */
38532
+ function calcDistance(x0, x1) {
38533
+ let dx2 = 0;
38534
+ for (let i = 0; i < x0.length; i++) {
38535
+ let dx = x0[i] - x1[i];
38536
+ dx2 += dx * dx;
38537
+ }
38538
+ return Math.sqrt(dx2);
38539
+ }
38540
+ function perturbRandom(x, dx) {
38541
+ let xp = [];
38542
+ for (let i = 0; i < x.length; i++) {
38543
+ xp.push(x[i] + 2 * dx * (Math.random() - 0.5));
38544
+ if (xp[i] < 0) {
38545
+ xp[i] = 0;
38546
+ }
38547
+ else if (xp[i] > 1) {
38548
+ xp[i] = 1;
38549
+ }
38550
+ }
38551
+ return xp;
38489
38552
  }
38490
38553
 
38491
38554
  /* eslint no-bitwise: 0 */
@@ -45526,14 +45589,14 @@
45526
45589
  function onMouseDown(event) {
45527
45590
  if (_state === STATE.NONE) {
45528
45591
  switch (event.button) {
45529
- case scope.mouseButtons.LEFT:
45530
- _state = STATE.ROTATE;
45592
+ case 0: // mouse left
45593
+ _state = scope.mouseButtons.LEFT;
45531
45594
  break;
45532
- case scope.mouseButtons.MIDDLE:
45533
- _state = STATE.ZOOM;
45595
+ case 1: // mouse wheel
45596
+ _state = scope.mouseButtons.MIDDLE;
45534
45597
  break;
45535
- case scope.mouseButtons.RIGHT:
45536
- _state = STATE.PAN;
45598
+ case 2: // mouse right
45599
+ _state = scope.mouseButtons.RIGHT;
45537
45600
  break;
45538
45601
  }
45539
45602
  }
@@ -56560,10 +56623,6 @@
56560
56623
  this.interval = 1 / this.fps;
56561
56624
  this.preRenderCallbackFunctions = [];
56562
56625
  this.animate = (time) => {
56563
- // if (this.start) {
56564
- // this.fpsCap = createFpsCap(this.render, 10);
56565
- // this.start = false;
56566
- // }
56567
56626
  var _a, _b, _c;
56568
56627
  switch ((_a = this.options) === null || _a === void 0 ? void 0 : _a.fpsMode) {
56569
56628
  case "1":
@@ -70109,12 +70168,219 @@
70109
70168
  }
70110
70169
  }
70111
70170
 
70171
+ class Node {
70172
+ constructor(id, p) {
70173
+ this.elements = [];
70174
+ this.id = id;
70175
+ this.p = p;
70176
+ }
70177
+ }
70178
+ class Element {
70179
+ constructor(id, basis, nodes) {
70180
+ this.id = id;
70181
+ this.basis = basis;
70182
+ this.nodes = nodes;
70183
+ }
70184
+ }
70185
+ class MeshNodeTool {
70186
+ constructor() {
70187
+ this.nodes = {};
70188
+ this.elements = {};
70189
+ }
70190
+ addNode(id, p) {
70191
+ this.nodes[id] = new Node(id, p);
70192
+ }
70193
+ addElement(id, basis, nodeIds) {
70194
+ let nodes = [];
70195
+ for (let nid in nodeIds) {
70196
+ let enid = nodeIds[nid];
70197
+ nodes.push(this.nodes[enid]);
70198
+ }
70199
+ let element = new Element(id, basis, nodes);
70200
+ this.elements[id] = element;
70201
+ for (let idx in element.nodes) {
70202
+ element.nodes[idx].elements.push(element);
70203
+ }
70204
+ }
70205
+ loadMesh(json) {
70206
+ for (let nid in json.nodes) {
70207
+ this.addNode(nid, json.nodes[nid]);
70208
+ }
70209
+ for (let eid in json.elements) {
70210
+ let elem = json.elements[eid];
70211
+ this.addElement(eid, elem.basis, elem.nodes);
70212
+ }
70213
+ }
70214
+ evaluate(elementId, xi) {
70215
+ let w = getWightsL3L3L3(xi);
70216
+ return evaluateElement(this.elements[elementId], w);
70217
+ }
70218
+ find(point, startingNodeId) {
70219
+ let pt = [point.x, point.y, point.z];
70220
+ let nodeMaterialPoints = this.getNodeMaterialPoints(startingNodeId);
70221
+ for (let i in nodeMaterialPoints) {
70222
+ let mpt = nodeMaterialPoints[i];
70223
+ let x = this.evaluate(mpt.elementId, mpt.xi);
70224
+ let r = calcDistance(x, pt);
70225
+ mpt.error = r;
70226
+ }
70227
+ let t0 = new Date().getTime();
70228
+ let n = 0;
70229
+ for (let step = 0; step < 10000; step++) {
70230
+ for (let i in nodeMaterialPoints) {
70231
+ let mpt = nodeMaterialPoints[i];
70232
+ let xi = perturbRandom(mpt.xi, 0.1);
70233
+ let x = this.evaluate(mpt.elementId, xi);
70234
+ let r = calcDistance(x, pt);
70235
+ if (r < mpt.error) {
70236
+ mpt.error = r;
70237
+ mpt.xi = xi;
70238
+ if (r < 1.0) {
70239
+ console.log("Time: (" +
70240
+ n +
70241
+ ") " +
70242
+ (new Date().getTime() - t0) +
70243
+ "ms Error: " +
70244
+ r);
70245
+ return mpt;
70246
+ }
70247
+ }
70248
+ }
70249
+ n = step;
70250
+ }
70251
+ let bestIndex = 0;
70252
+ let bestError = nodeMaterialPoints[0].error;
70253
+ for (let i in nodeMaterialPoints) {
70254
+ let mpt = nodeMaterialPoints[i];
70255
+ if (mpt.error < bestError) {
70256
+ bestIndex = Number(i);
70257
+ bestError = mpt.error;
70258
+ }
70259
+ }
70260
+ let mpt = nodeMaterialPoints[bestIndex];
70261
+ console.log("Time: (" +
70262
+ n +
70263
+ ") " +
70264
+ (new Date().getTime() - t0) +
70265
+ "ms Error: " +
70266
+ mpt.error);
70267
+ return mpt;
70268
+ }
70269
+ search(point, startingNodeId, tol) {
70270
+ let pt = [point.x, point.y, point.z];
70271
+ let nodeMaterialPoints = this.getNodeMaterialPoints(startingNodeId);
70272
+ for (let i in nodeMaterialPoints) {
70273
+ let mpt = nodeMaterialPoints[i];
70274
+ let x = this.evaluate(mpt.elementId, mpt.xi);
70275
+ mpt.error = calcDistance(x, pt);
70276
+ }
70277
+ let t0 = new Date().getTime();
70278
+ let xiStepSize = [0.1, 0.01, 0.001];
70279
+ for (let i in nodeMaterialPoints) {
70280
+ let mpt = nodeMaterialPoints[i];
70281
+ let numDims = mpt.xi.length;
70282
+ let nIter = 0;
70283
+ let go = true;
70284
+ while (go || nIter < 10) {
70285
+ let minErr = 1 * mpt.error;
70286
+ let minXi;
70287
+ for (let xiIdx in xiStepSize) {
70288
+ let dXi = xiStepSize[xiIdx];
70289
+ for (let dim = 0; dim < numDims; dim++) {
70290
+ let xi = mpt.xi.slice();
70291
+ xi[dim] += dXi;
70292
+ if (xi[dim] >= 0 && xi[dim] <= 1) {
70293
+ let x = this.evaluate(mpt.elementId, mpt.xi);
70294
+ let err = calcDistance(x, pt);
70295
+ if (err < minErr) {
70296
+ minErr = err;
70297
+ minXi = xi;
70298
+ if (err < tol) {
70299
+ mpt.error = err;
70300
+ mpt.xi = xi;
70301
+ console.log("Time 1: " +
70302
+ (new Date().getTime() - t0) +
70303
+ "ms Error: " +
70304
+ mpt.error);
70305
+ return mpt;
70306
+ }
70307
+ }
70308
+ }
70309
+ xi = mpt.xi.slice();
70310
+ xi[dim] -= dXi;
70311
+ if (xi[dim] >= 0 && xi[dim] <= 1) {
70312
+ let x = this.evaluate(mpt.elementId, mpt.xi);
70313
+ let err = calcDistance(x, pt);
70314
+ if (err < minErr) {
70315
+ minErr = err;
70316
+ minXi = xi;
70317
+ if (err < tol) {
70318
+ mpt.error = err;
70319
+ mpt.xi = xi;
70320
+ console.log("Time 2: " +
70321
+ (new Date().getTime() - t0) +
70322
+ "ms Error: " +
70323
+ mpt.error);
70324
+ return mpt;
70325
+ }
70326
+ }
70327
+ }
70328
+ }
70329
+ }
70330
+ if (minXi === null || minXi === undefined) {
70331
+ go = false;
70332
+ }
70333
+ else {
70334
+ mpt.xi = minXi;
70335
+ mpt.error = minErr;
70336
+ }
70337
+ nIter++;
70338
+ }
70339
+ }
70340
+ let bestIndex = 0;
70341
+ let bestError = nodeMaterialPoints[0].error;
70342
+ for (let i in nodeMaterialPoints) {
70343
+ let mpt = nodeMaterialPoints[i];
70344
+ if (mpt.error < bestError) {
70345
+ bestIndex = Number(i);
70346
+ bestError = mpt.error;
70347
+ }
70348
+ }
70349
+ let mpt = nodeMaterialPoints[bestIndex];
70350
+ console.log("Time 3: " + (new Date().getTime() - t0) + "ms Error: " + mpt.error);
70351
+ return mpt;
70352
+ }
70353
+ getNodeMaterialPoints(nodeId) {
70354
+ let materialPoints = [];
70355
+ let node = this.nodes[nodeId];
70356
+ for (let eid in node.elements) {
70357
+ let element = node.elements[eid];
70358
+ let nodeIdx = element.nodes.indexOf(node);
70359
+ let xi0 = (nodeIdx % 4) / 3;
70360
+ let xi1 = Math.floor((nodeIdx % 16) / 4) / 3;
70361
+ let xi2 = Math.floor(nodeIdx / 16) / 3;
70362
+ materialPoints.push({ elementId: element.id, xi: [xi0, xi1, xi2] });
70363
+ }
70364
+ return materialPoints;
70365
+ }
70366
+ }
70367
+ function evaluateElement(element, weights) {
70368
+ let x = [0, 0, 0];
70369
+ for (let f = 0; f < 3; f++) {
70370
+ for (let i = 0; i < weights.length; i++) {
70371
+ x[f] += weights[i] * element.nodes[i].p[f];
70372
+ }
70373
+ }
70374
+ return x;
70375
+ }
70376
+
70112
70377
  // import * as kiwrious from "copper3d_plugin_heart_k";
70113
- const REVISION = "v1.15.15";
70114
- console.log("%cCopper3D Visualisation %cBeta:v1.15.15", "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
70378
+ const REVISION = "v1.15.17";
70379
+ console.log("%cCopper3D Visualisation %cBeta:v1.15.17", "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
70115
70380
 
70116
70381
  exports.CameraViewPoint = CameraViewPoint;
70117
70382
  exports.Copper3dTrackballControls = Copper3dTrackballControls;
70383
+ exports.MeshNodeTool = MeshNodeTool;
70118
70384
  exports.REVISION = REVISION;
70119
70385
  exports.addBoxHelper = addBoxHelper;
70120
70386
  exports.addLabelToScene = addLabelToScene;
package/dist/index.d.ts CHANGED
@@ -14,8 +14,9 @@ import { configKiwriousHeart } from "./Utils/kiwrious/configKiwrious";
14
14
  import kiwrious from "./Utils/kiwrious/configKiwrious";
15
15
  import { nrrd_tools } from "./Utils/nrrd_tool";
16
16
  import { Copper3dTrackballControls } from "./Controls/Copper3dTrackballControls";
17
+ import { MeshNodeTool } from "./Utils/MeshNodeTool";
17
18
  import { nrrdMeshesType, nrrdSliceType, SensorDecodedValue_kiwrious, SensorReadResult_kiwrious, HeartRateResult_kiwrious, loadingBarType, paintImageType, exportPaintImageType, IOptVTKLoader } from "./types/types";
18
19
  import "./css/style.css";
19
- export declare const REVISION = "v1.15.15";
20
- export { copperRenderer, copperRendererOnDemond, copperMSceneRenderer, setHDRFilePath, addLabelToScene, convert3DPostoScreenPos, convertScreenPosto3DPos, addBoxHelper, fullScreenListenner, configKiwriousHeart, copperScene, copperSceneOnDemond, copperMScene, CameraViewPoint, kiwrious, nrrd_tools, loading, Copper3dTrackballControls, createTexture2D_NRRD, };
20
+ export declare const REVISION = "v1.15.17";
21
+ export { copperRenderer, copperRendererOnDemond, copperMSceneRenderer, setHDRFilePath, addLabelToScene, convert3DPostoScreenPos, convertScreenPosto3DPos, addBoxHelper, fullScreenListenner, configKiwriousHeart, copperScene, copperSceneOnDemond, copperMScene, CameraViewPoint, kiwrious, nrrd_tools, loading, Copper3dTrackballControls, createTexture2D_NRRD, MeshNodeTool, };
21
22
  export type { positionType, screenPosType, optsType, nrrdMeshesType, nrrdSliceType, SensorDecodedValue_kiwrious, SensorReadResult_kiwrious, HeartRateResult_kiwrious, loadingBarType, paintImageType, exportPaintImageType, IOptVTKLoader, };
package/dist/index.js CHANGED
@@ -15,8 +15,9 @@ import { configKiwriousHeart } from "./Utils/kiwrious/configKiwrious";
15
15
  import kiwrious from "./Utils/kiwrious/configKiwrious";
16
16
  import { nrrd_tools } from "./Utils/nrrd_tool";
17
17
  import { Copper3dTrackballControls } from "./Controls/Copper3dTrackballControls";
18
+ import { MeshNodeTool } from "./Utils/MeshNodeTool";
18
19
  import "./css/style.css";
19
- export const REVISION = "v1.15.15";
20
- console.log("%cCopper3D Visualisation %cBeta:v1.15.15", "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
21
- export { copperRenderer, copperRendererOnDemond, copperMSceneRenderer, setHDRFilePath, addLabelToScene, convert3DPostoScreenPos, convertScreenPosto3DPos, addBoxHelper, fullScreenListenner, configKiwriousHeart, copperScene, copperSceneOnDemond, copperMScene, CameraViewPoint, kiwrious, nrrd_tools, loading, Copper3dTrackballControls, createTexture2D_NRRD, };
20
+ export const REVISION = "v1.15.17";
21
+ console.log("%cCopper3D Visualisation %cBeta:v1.15.17", "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
22
+ export { copperRenderer, copperRendererOnDemond, copperMSceneRenderer, setHDRFilePath, addLabelToScene, convert3DPostoScreenPos, convertScreenPosto3DPos, addBoxHelper, fullScreenListenner, configKiwriousHeart, copperScene, copperSceneOnDemond, copperMScene, CameraViewPoint, kiwrious, nrrd_tools, loading, Copper3dTrackballControls, createTexture2D_NRRD, MeshNodeTool, };
22
23
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,OAAO,cAAc,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,WAAW,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EACL,eAAe,EAGf,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAY,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,sBAAsB,MAAM,mCAAmC,CAAC;AACvE,OAAO,mBAAmB,MAAM,6BAA6B,CAAC;AAC9D,OAAO,oBAAoB,MAAM,iCAAiC,CAAC;AACnE,OAAO,YAAY,MAAM,sBAAsB,CAAC;AAEhD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,QAAQ,MAAM,iCAAiC,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAcjF,OAAO,iBAAiB,CAAC;AAEzB,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAAC;AAEnC,OAAO,CAAC,GAAG,CACT,0CAA0C,EAC1C,8CAA8C,EAC9C,8CAA8C,CAC/C,CAAC;AAEF,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,uBAAuB,EACvB,uBAAuB,EACvB,YAAY,EACZ,mBAAmB,EACnB,mBAAmB,EACnB,WAAW,EACX,mBAAmB,EACnB,YAAY,EACZ,eAAe,EACf,QAAQ,EACR,UAAU,EACV,OAAO,EACP,yBAAyB,EACzB,oBAAoB,GACrB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,OAAO,cAAc,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,WAAW,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EACL,eAAe,EAGf,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAY,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,sBAAsB,MAAM,mCAAmC,CAAC;AACvE,OAAO,mBAAmB,MAAM,6BAA6B,CAAC;AAC9D,OAAO,oBAAoB,MAAM,iCAAiC,CAAC;AACnE,OAAO,YAAY,MAAM,sBAAsB,CAAC;AAEhD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,QAAQ,MAAM,iCAAiC,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAEjF,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAcpD,OAAO,iBAAiB,CAAC;AAEzB,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAAC;AAEnC,OAAO,CAAC,GAAG,CACT,0CAA0C,EAC1C,8CAA8C,EAC9C,8CAA8C,CAC/C,CAAC;AAEF,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,uBAAuB,EACvB,uBAAuB,EACvB,YAAY,EACZ,mBAAmB,EACnB,mBAAmB,EACnB,WAAW,EACX,mBAAmB,EACnB,YAAY,EACZ,eAAe,EACf,QAAQ,EACR,UAAU,EACV,OAAO,EACP,yBAAyB,EACzB,oBAAoB,EACpB,YAAY,GACb,CAAC"}
@@ -23,9 +23,9 @@ declare class Copper3dTrackballControls extends EventDispatcher {
23
23
  maxZoom: number;
24
24
  keys: ["KeyA", "KeyS", "KeyD"];
25
25
  mouseButtons: {
26
- LEFT: MOUSE.ROTATE;
26
+ LEFT: MOUSE.ROTATE | MOUSE.PAN | -1;
27
27
  MIDDLE: MOUSE.DOLLY;
28
- RIGHT: MOUSE.PAN;
28
+ RIGHT: MOUSE.ROTATE | MOUSE.PAN | -1;
29
29
  };
30
30
  target: Vector3;
31
31
  target0: Vector3;