zincjs 1.8.2 → 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/build/zinc.frontend.js +1 -1
- package/build/zinc.js +18 -9
- package/build/zinc.js.map +1 -1
- package/package.json +1 -1
- package/src/controls.js +4 -2
- package/src/primitives/markerCluster.js +9 -0
- package/src/primitives/textureSlides.js +29 -2
- package/src/scene.js +55 -1
- package/src/shaders/textureSlide.js +4 -5
package/package.json
CHANGED
package/src/controls.js
CHANGED
|
@@ -227,7 +227,8 @@ const CameraControls = function ( object, domElement, renderer, scene ) {
|
|
|
227
227
|
|
|
228
228
|
this.getVisibleHeightAtZDepth = ( depth ) => {
|
|
229
229
|
// compensate for cameras not positioned at z=0
|
|
230
|
-
|
|
230
|
+
|
|
231
|
+
const cameraOffset = this.cameraObject.position.distanceTo(this.cameraObject.target);
|
|
231
232
|
if ( depth < cameraOffset ) depth -= cameraOffset;
|
|
232
233
|
else depth += cameraOffset;
|
|
233
234
|
|
|
@@ -1535,7 +1536,8 @@ const RayCaster = function (sceneIn, hostSceneIn, callbackFunctionIn, hoverCallb
|
|
|
1535
1536
|
const length = pickedObjects.length;
|
|
1536
1537
|
for (let i = 0; i < length; i++) {
|
|
1537
1538
|
let zincObject = pickedObjects[i].object ? pickedObjects[i].object.userData : undefined;
|
|
1538
|
-
if (zincObject && zincObject.isMarkerCluster && zincObject.visible
|
|
1539
|
+
if (zincObject && zincObject.isMarkerCluster && zincObject.visible
|
|
1540
|
+
&& zincObject.clusterIsVisible(pickedObjects[i].object.clusterIndex)) {
|
|
1539
1541
|
zincObject.zoomToCluster(pickedObjects[i].object.clusterIndex);
|
|
1540
1542
|
return;
|
|
1541
1543
|
}
|
|
@@ -218,6 +218,15 @@ const MarkerCluster = function(sceneIn) {
|
|
|
218
218
|
this.markerUpdateRequired = true;
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
|
+
|
|
222
|
+
this.clusterIsVisible = (index) => {
|
|
223
|
+
if (index !== undefined && index > -1) {
|
|
224
|
+
if (sprites[index]) {
|
|
225
|
+
return sprites[index].group?.visible;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return false;
|
|
229
|
+
}
|
|
221
230
|
}
|
|
222
231
|
|
|
223
232
|
MarkerCluster.prototype = Object.create((require('./zincObject').ZincObject).prototype);
|
|
@@ -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
|
-
|
|
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.
|
|
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
|
-
|
|
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
|
|