zincjs 1.8.3 → 1.8.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zincjs",
3
- "version": "1.8.3",
3
+ "version": "1.8.4",
4
4
  "description": "ZincJS (Web-based-Zinc-Visualisation)",
5
5
  "main": "build/zinc.js",
6
6
  "directories": {
@@ -19,7 +19,7 @@ const TextureSlides = function (textureIn) {
19
19
  this.morph = new THREE.Group();
20
20
  this.group = this.morph;
21
21
  this.morph.userData = this;
22
- let flipY = true;
22
+ let flipY = true;
23
23
 
24
24
  /**
25
25
  @typedef SLIDE_SETTINGS
@@ -51,18 +51,30 @@ const TextureSlides = function (textureIn) {
51
51
  const setUniformSlideSettingsOfMesh = (mesh, settings) => {
52
52
  const material = mesh.material;
53
53
  const uniforms = material.uniforms;
54
+ mesh.rotation.x = 0;
55
+ mesh.rotation.y = 0;
56
+ mesh.rotation.z = 0;
57
+ mesh.position.x = 0;
58
+ mesh.position.y = 0;
59
+ mesh.position.z = 0;
54
60
  switch (settings.direction) {
55
61
  case "x":
62
+ const rotation = flipY ? -Math.PI / 2 : Math.PI / 2;
63
+ mesh.rotation.y = rotation;
56
64
  uniforms.direction.value = 1;
57
65
  uniforms.slide.value.set(settings.value, 0, 0);
66
+ mesh.position.x = settings.value;
58
67
  break;
59
68
  case "y":
69
+ mesh.rotation.x = Math.PI / 2;
60
70
  uniforms.direction.value = 2;
61
71
  uniforms.slide.value.set(0, settings.value, 0);
72
+ mesh.position.y = settings.value;
62
73
  break;
63
74
  case "z":
64
75
  uniforms.direction.value = 3;
65
76
  uniforms.slide.value.set(0, 0, settings.value);
77
+ mesh.position.z = settings.value;
66
78
  break;
67
79
  default:
68
80
  break;
@@ -113,6 +125,8 @@ const TextureSlides = function (textureIn) {
113
125
  const material = this.texture.getMaterial(options);
114
126
  material.needsUpdate = true;
115
127
  const mesh = new THREE.Mesh(geometry, material);
128
+ mesh.name = this.groupName;
129
+ mesh.userData = this;
116
130
  const slideSettings = {
117
131
  value: settings.value,
118
132
  direction: settings.direction,
@@ -131,12 +145,25 @@ const TextureSlides = function (textureIn) {
131
145
  /**
132
146
  * Return a copy of texture settings used by this object.
133
147
  *
134
- * @return {SLIDE_SETTINGS} - Returned the list of settings..
148
+ * @return {SLIDE_SETTINGS} - Returned the list of settings.
135
149
  */
136
150
  this.getTextureSettings = () => {
137
151
  return [...textureSettings];
138
152
  }
139
153
 
154
+ /**
155
+ * Return a copy of texture settings with corresponding id used by this object.
156
+ *
157
+ * @return {SLIDE_SETTINGS} - Returned a copy of settings with corresponding id.
158
+ */
159
+ this.getTextureSettingsWithId = (id) => {
160
+ for (let i = 0; i < textureSettings.length; i++) {
161
+ if (id === textureSettings[i].id) {
162
+ return {...textureSettings[i]};
163
+ }
164
+ }
165
+ }
166
+
140
167
  /**
141
168
  * Get the array of slides, return them in an array
142
169
  *
package/src/scene.js CHANGED
@@ -1270,13 +1270,67 @@ exports.Scene = function (containerIn, rendererIn) {
1270
1270
  const box = boundingBox ? boundingBox : this.getBoundingBox();
1271
1271
  const dim = new THREE.Vector3().subVectors(box.max, box.min);
1272
1272
  const boxGeo = new THREE.BoxGeometry(dim.x, dim.y, dim.z);
1273
- dim.addVectors(box.min, box.max).multiplyScalar( 0.5 );
1274
1273
  const primitive = region.createGeometryFromThreeJSGeometry(
1275
1274
  group, boxGeo, colour, opacity, visibility, 10000);
1275
+ dim.addVectors(box.min, box.max).multiplyScalar( 0.5 );
1276
1276
  primitive.setPosition(dim.x, dim.y, dim.z);
1277
1277
  return primitive;
1278
1278
  }
1279
1279
 
1280
+ /*
1281
+ * Create primitive based on the bounding box of scene and
1282
+ * add to specify region and group name.
1283
+ */
1284
+ this.addSlicesPrimitive = (regionPath, groups, colours, opacity,
1285
+ visibility, boundingBox = undefined) => {
1286
+ if (groups && groups.length >= 3 &&
1287
+ colours && colours.length >= 3) {
1288
+ let region = rootRegion.findChildFromPath(regionPath);
1289
+ if (region === undefined) {
1290
+ region = rootRegion.createChildFromPath(regionPath);
1291
+ }
1292
+ const box = boundingBox ? boundingBox : this.getBoundingBox();
1293
+ const dim = new THREE.Vector3().subVectors(box.max, box.min);
1294
+ const directions = ["x", "y", "z"];
1295
+ const primitives = [];
1296
+ let index = 0;
1297
+ directions.forEach((direction) => {
1298
+ let planeGeo = undefined;
1299
+ switch(direction) {
1300
+ //YZ plane
1301
+ case "x":
1302
+ planeGeo = new THREE.PlaneGeometry(dim.z, dim.y);
1303
+ planeGeo.rotateY(Math.PI / 2);
1304
+ // code block
1305
+ break;
1306
+ //XZ plane
1307
+ case "y":
1308
+ planeGeo = new THREE.PlaneGeometry(dim.x, dim.z);
1309
+ planeGeo.rotateX(Math.PI / 2);
1310
+ // code block
1311
+ break;
1312
+ //XY plane
1313
+ case "z":
1314
+ planeGeo = new THREE.PlaneGeometry(dim.x, dim.y);
1315
+ // code block
1316
+ break;
1317
+ default:
1318
+ break;
1319
+ }
1320
+ const primitive = region.createGeometryFromThreeJSGeometry(
1321
+ groups[index], planeGeo, colours[index], opacity, visibility, 10001);
1322
+ primitives.push(primitive);
1323
+ index++;
1324
+ });
1325
+
1326
+ dim.addVectors(box.min, box.max).multiplyScalar( 0.5 );
1327
+ primitives.forEach((primitive) => {
1328
+ primitive.setPosition(dim.x, dim.y, dim.z);
1329
+ });
1330
+ return primitives;
1331
+ }
1332
+ }
1333
+
1280
1334
  /*
1281
1335
  * Enable marker cluster to work with markers
1282
1336
  */
@@ -34,18 +34,17 @@ uniform bool flipY;
34
34
  void main() {
35
35
 
36
36
  vec3 slidePos = position.xyz;
37
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position.xyz, 1.0 );
37
38
 
38
39
  if (direction == 1)
39
- slidePos = vec3(slide.x, position.x, position.y);
40
+ slidePos = vec3(slide.x, position.y, position.x);
40
41
  if (direction == 2)
41
42
  slidePos = vec3(position.x, slide.y, position.y);
42
43
  if (direction == 3)
43
44
  slidePos = vec3(position.x, position.y, slide.z);
44
45
 
45
- gl_Position = projectionMatrix * modelViewMatrix * vec4( slidePos, 1.0 );
46
-
47
- if (flipY)
48
- slidePos.y = 1.0 - slidePos.y;
46
+ if (flipY)
47
+ slidePos.y = 1.0 - slidePos.y;
49
48
 
50
49
  vUw.xyz = vec3(slidePos.x, slidePos.y, slidePos.z * depth);
51
50