zincjs 1.6.0 → 1.7.0
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 +52 -54
- package/build/zinc.js.map +1 -1
- package/package.json +1 -1
- package/src/assets/mapMarker.svg +33 -10
- package/src/primitives/marker.js +31 -2
- package/src/primitives/markerCluster.js +9 -19
- package/src/primitives/texturePrimitive.js +0 -1
- package/src/primitives/zincObject.js +6 -2
- package/src/region.js +12 -10
- package/src/utilities.js +13 -0
package/package.json
CHANGED
package/src/assets/mapMarker.svg
CHANGED
|
@@ -1,11 +1,34 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="
|
|
2
|
-
<!-- Generator: Adobe Illustrator 18.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
|
3
2
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
4
|
-
<svg
|
|
5
|
-
|
|
6
|
-
<
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
</g>
|
|
11
|
-
|
|
3
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="365" height="560" viewBox="0 0 365 560" xml:space="preserve">
|
|
4
|
+
<desc>Created with Fabric.js 5.2.4</desc>
|
|
5
|
+
<defs>
|
|
6
|
+
</defs>
|
|
7
|
+
<rect x="0" y="0" width="100%" height="100%" fill="transparent"></rect>
|
|
8
|
+
<g transform="matrix(0 0 0 0 0 0)" id="808ed283-2524-440f-88ae-3bdb47bb5749" >
|
|
9
|
+
</g>
|
|
10
|
+
<g transform="matrix(1 0 0 1 182.5 280)" id="db30413d-5bff-4b98-ab59-464497ee199e" >
|
|
11
|
+
<rect style="stroke: none; stroke-width: 1; stroke-dasharray: none; stroke-linecap: butt; stroke-dashoffset: 0; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(255,255,255); fill-rule: nonzero; opacity: 1; visibility: hidden;" vector-effect="non-scaling-stroke" x="-182.5" y="-280" rx="0" ry="0" width="365" height="560" />
|
|
12
|
+
</g>
|
|
13
|
+
<g transform="matrix(0 0 0 0 0 97.5)" >
|
|
14
|
+
<g style="" >
|
|
15
|
+
</g>
|
|
16
|
+
</g>
|
|
17
|
+
<g transform="matrix(0 0 0 0 0 97.5)" >
|
|
18
|
+
<g style="" >
|
|
19
|
+
</g>
|
|
20
|
+
</g>
|
|
21
|
+
<g transform="matrix(0.99 0 0 0.99 182.5 280)" >
|
|
22
|
+
<g style="" vector-effect="non-scaling-stroke" >
|
|
23
|
+
<g transform="matrix(1 0 0 1 0 0)" >
|
|
24
|
+
<rect style="stroke: none; stroke-width: 1; stroke-dasharray: none; stroke-linecap: butt; stroke-dashoffset: 0; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(255,255,255); fill-rule: nonzero; opacity: 1; visibility: hidden;" vector-effect="non-scaling-stroke" x="-540" y="-540" rx="0" ry="0" width="1080" height="1080" />
|
|
25
|
+
</g>
|
|
26
|
+
<g transform="matrix(1 0 0 1 0 0)" >
|
|
27
|
+
<path style="stroke: rgb(0,0,0); stroke-width: 0; stroke-dasharray: none; stroke-linecap: butt; stroke-dashoffset: 0; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(0,89,116); fill-rule: nonzero; opacity: 1;" vector-effect="non-scaling-stroke" transform=" translate(-182.9, -279.85)" d="M 182.9 551.7 C 182.9 551.8000000000001 183.1 552 183.1 552 C 183.1 552 358.3 283 358.3 194.6 C 358.3 64.5 269.5 7.900000000000006 182.9 7.699999999999989 C 96.3 7.9 7.5 64.5 7.5 194.6 C 7.5 283 182.8 552 182.8 552 C 182.8 552 182.9 551.7 182.9 551.7 z M 122.2 187.2 C 122.2 153.6 149.4 126.39999999999999 183 126.39999999999999 C 216.6 126.39999999999999 243.8 153.6 243.8 187.2 C 243.8 220.79999999999998 216.5 248 182.9 248 C 149.4 248 122.2 220.8 122.2 187.2 z" stroke-linecap="round" />
|
|
28
|
+
</g>
|
|
29
|
+
<g transform="matrix(3.82 0 0 3.82 0 -100.77)" >
|
|
30
|
+
<circle style="stroke: rgb(0,0,0); stroke-width: 0; stroke-dasharray: none; stroke-linecap: butt; stroke-dashoffset: 0; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(255,255,255); fill-rule: nonzero; opacity: 1;" vector-effect="non-scaling-stroke" cx="0" cy="0" r="35" />
|
|
31
|
+
</g>
|
|
32
|
+
</g>
|
|
33
|
+
</g>
|
|
34
|
+
</svg>
|
package/src/primitives/marker.js
CHANGED
|
@@ -4,7 +4,7 @@ markerImage.src = require("../assets/mapMarker.svg");
|
|
|
4
4
|
const texture = new THREE.Texture();
|
|
5
5
|
texture.image = markerImage;
|
|
6
6
|
texture.needsUpdate = true;
|
|
7
|
-
const size = [0.
|
|
7
|
+
const size = [0.02, 0.03, 1];
|
|
8
8
|
const spriteMaterial = new THREE.SpriteMaterial({
|
|
9
9
|
map: texture,
|
|
10
10
|
alphaTest: 0.5,
|
|
@@ -12,7 +12,8 @@ const spriteMaterial = new THREE.SpriteMaterial({
|
|
|
12
12
|
depthTest: false,
|
|
13
13
|
depthWrite: false,
|
|
14
14
|
sizeAttenuation: false
|
|
15
|
-
});
|
|
15
|
+
});
|
|
16
|
+
const createNewSpriteText = require('../utilities').createNewSpriteText;
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* A special graphics type with a tear drop shape.
|
|
@@ -33,6 +34,8 @@ const Marker = function(zincObject) {
|
|
|
33
34
|
this.isMarker = true;
|
|
34
35
|
let enabled = false;
|
|
35
36
|
this.ndc = new THREE.Vector3();
|
|
37
|
+
let number = undefined;
|
|
38
|
+
let label = undefined;
|
|
36
39
|
|
|
37
40
|
let initialise = () => {
|
|
38
41
|
sprite = new THREE.Sprite(spriteMaterial);
|
|
@@ -93,12 +96,38 @@ const Marker = function(zincObject) {
|
|
|
93
96
|
sprite.clear();
|
|
94
97
|
sprite = undefined;
|
|
95
98
|
}
|
|
99
|
+
if (label) {
|
|
100
|
+
label.material.map.dispose();
|
|
101
|
+
label.material.dispose();
|
|
102
|
+
label = undefined;
|
|
103
|
+
}
|
|
96
104
|
}
|
|
97
105
|
|
|
98
106
|
this.isEnabled = () => {
|
|
99
107
|
return enabled;
|
|
100
108
|
}
|
|
101
109
|
|
|
110
|
+
this.setNumber = (numberIn) => {
|
|
111
|
+
if (!numberIn || (number != numberIn)) {
|
|
112
|
+
//remove label
|
|
113
|
+
if (label) {
|
|
114
|
+
this.morph.remove(label);
|
|
115
|
+
label.material.map.dispose();
|
|
116
|
+
label.material.dispose();
|
|
117
|
+
label = undefined;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (!label && numberIn) {
|
|
121
|
+
label = createNewSpriteText(numberIn, 0.012, "black", "Asap", 50, 500);
|
|
122
|
+
this.morph.add(label);
|
|
123
|
+
}
|
|
124
|
+
number = numberIn;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
this.getNumber = () => {
|
|
128
|
+
return number ? number : 1;
|
|
129
|
+
}
|
|
130
|
+
|
|
102
131
|
/**
|
|
103
132
|
* Set the visibility of this Geometry.
|
|
104
133
|
*
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const THREE = require('three');
|
|
2
|
-
const SpriteText = require('three-spritetext').default;
|
|
3
2
|
const markerImage = new Image(128, 128);
|
|
4
3
|
markerImage.src = require("../assets/mapMarkerOrange.svg");
|
|
5
4
|
const texture = new THREE.Texture();
|
|
@@ -14,18 +13,7 @@ const spriteMaterial = new THREE.SpriteMaterial({
|
|
|
14
13
|
depthWrite: false,
|
|
15
14
|
sizeAttenuation: false
|
|
16
15
|
});
|
|
17
|
-
|
|
18
|
-
const createNewLabel = (text, height, colour, font, pixel, weight) => {
|
|
19
|
-
const sprite = new SpriteText(text, height, colour, font, pixel, weight);
|
|
20
|
-
sprite.material.sizeAttenuation = false;
|
|
21
|
-
sprite.material.alphaTest = 0.5;
|
|
22
|
-
sprite.material.transparent = true;
|
|
23
|
-
sprite.material.depthWrite = false;
|
|
24
|
-
sprite.material.depthTest = false;
|
|
25
|
-
sprite.center.set(0.5, -1.2);
|
|
26
|
-
sprite.renderOrder = 10000;
|
|
27
|
-
return sprite;
|
|
28
|
-
}
|
|
16
|
+
const createNewSpriteText = require('../utilities').createNewSpriteText;
|
|
29
17
|
|
|
30
18
|
/**
|
|
31
19
|
* A special graphics type with a tear drop shape.
|
|
@@ -93,25 +81,25 @@ const MarkerCluster = function(sceneIn) {
|
|
|
93
81
|
"group": localGroup,
|
|
94
82
|
"marker": sprite,
|
|
95
83
|
"label": undefined,
|
|
96
|
-
"
|
|
84
|
+
"number": 0,
|
|
97
85
|
"min": [0, 0, 0],
|
|
98
86
|
"max": [1, 1, 1],
|
|
99
87
|
};
|
|
100
88
|
}
|
|
101
89
|
|
|
102
|
-
const activateSpriteForCluster = (sprite, cluster,
|
|
90
|
+
const activateSpriteForCluster = (sprite, cluster, number) => {
|
|
103
91
|
sprite.group.visible = true;
|
|
104
92
|
sprite.group.position.set(
|
|
105
93
|
cluster.coords[0], cluster.coords[1], cluster.coords[2]
|
|
106
94
|
);
|
|
107
|
-
if (sprite.label === undefined || (
|
|
95
|
+
if (sprite.label === undefined || (number !== sprite.number)) {
|
|
108
96
|
if (sprite.label) {
|
|
109
97
|
sprite.group.remove(sprite.label);
|
|
110
98
|
sprite.label.material.map.dispose();
|
|
111
99
|
sprite.label.material.dispose();
|
|
112
100
|
}
|
|
113
|
-
sprite.label =
|
|
114
|
-
sprite.
|
|
101
|
+
sprite.label = createNewSpriteText(number, 0.012, "black", "Asap", 50, 500);
|
|
102
|
+
sprite.number = number;
|
|
115
103
|
sprite.group.add(sprite.label);
|
|
116
104
|
}
|
|
117
105
|
sprite.min = cluster.min;
|
|
@@ -122,16 +110,18 @@ const MarkerCluster = function(sceneIn) {
|
|
|
122
110
|
let currentIndex = 0;
|
|
123
111
|
clusters.forEach((cluster) => {
|
|
124
112
|
const length = cluster.members.length;
|
|
113
|
+
let number = 0;
|
|
125
114
|
if (length === 1) {
|
|
126
115
|
cluster.members[0].setVisibility(true);
|
|
127
116
|
} else {
|
|
128
117
|
cluster.members.forEach((marker) => {
|
|
118
|
+
number += marker.getNumber();
|
|
129
119
|
marker.setVisibility(false);
|
|
130
120
|
});
|
|
131
121
|
if (!sprites[currentIndex]) {
|
|
132
122
|
sprites.push(createNewSprite(currentIndex));
|
|
133
123
|
}
|
|
134
|
-
activateSpriteForCluster(sprites[currentIndex], cluster,
|
|
124
|
+
activateSpriteForCluster(sprites[currentIndex], cluster, number);
|
|
135
125
|
currentIndex++;
|
|
136
126
|
}
|
|
137
127
|
});
|
|
@@ -25,7 +25,6 @@ const TexturePrimitive = function (textureIn) {
|
|
|
25
25
|
const texture = new (require('../texture/textureArray').TextureArray)();
|
|
26
26
|
const imgArray = [];
|
|
27
27
|
textureData.images.source.forEach(img => {
|
|
28
|
-
console.log(resolveURL(img))
|
|
29
28
|
imgArray.push(resolveURL(img));
|
|
30
29
|
});
|
|
31
30
|
const _this = this;
|
|
@@ -41,6 +41,7 @@ const ZincObject = function() {
|
|
|
41
41
|
this.userData = {};
|
|
42
42
|
this.videoHandler = undefined;
|
|
43
43
|
this.marker = undefined;
|
|
44
|
+
this.markerNumber = undefined;
|
|
44
45
|
this.markerUpdateRequired = true;
|
|
45
46
|
this.closestVertexIndex = -1;
|
|
46
47
|
this.boundingBoxUpdateRequired = true;
|
|
@@ -251,7 +252,6 @@ ZincObject.prototype.setMorphTime = function(time) {
|
|
|
251
252
|
}
|
|
252
253
|
if (timeChanged) {
|
|
253
254
|
this.boundingBoxUpdateRequired = true;
|
|
254
|
-
const morph = this._lod.getCurrentMorph();
|
|
255
255
|
this._lod.updateMorphColorAttribute(true);
|
|
256
256
|
if (this.timeEnabled)
|
|
257
257
|
this.markerUpdateRequired = true;
|
|
@@ -548,6 +548,7 @@ ZincObject.prototype.updateMarker = function(playAnimation, options) {
|
|
|
548
548
|
this.marker.enable();
|
|
549
549
|
this.group.add(this.marker.morph);
|
|
550
550
|
}
|
|
551
|
+
this.marker.setNumber(this.markerNumber);
|
|
551
552
|
if (options && options.camera && (ndcToBeUpdated ||
|
|
552
553
|
options.markerCluster.markerUpdateRequired)) {
|
|
553
554
|
this.marker.updateNDC(options.camera.cameraObject);
|
|
@@ -619,7 +620,7 @@ ZincObject.prototype.getClosestVertexDOMElementCoords = function(scene) {
|
|
|
619
620
|
*
|
|
620
621
|
* @return {Boolean}
|
|
621
622
|
*/
|
|
622
|
-
ZincObject.prototype.setMarkerMode = function(mode) {
|
|
623
|
+
ZincObject.prototype.setMarkerMode = function(mode, options) {
|
|
623
624
|
if (mode !== this.markerMode) {
|
|
624
625
|
if (mode === "on" || mode === "off") {
|
|
625
626
|
this.markerMode = mode;
|
|
@@ -630,6 +631,9 @@ ZincObject.prototype.getClosestVertexDOMElementCoords = function(scene) {
|
|
|
630
631
|
this.region.pickableUpdateRequired = true;
|
|
631
632
|
}
|
|
632
633
|
}
|
|
634
|
+
if (options) {
|
|
635
|
+
this.markerNumber = options.number;
|
|
636
|
+
}
|
|
633
637
|
}
|
|
634
638
|
|
|
635
639
|
//Update the geometry and colours depending on the morph.
|
package/src/region.js
CHANGED
|
@@ -750,16 +750,18 @@ let Region = function (parentIn, sceneIn) {
|
|
|
750
750
|
//process markers visibility and size, as long as there are more than
|
|
751
751
|
//one entry in markersList is greater than 1, markers have been enabled.
|
|
752
752
|
if (options && (playAnimation === false) &&
|
|
753
|
-
options
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
753
|
+
options.markerCluster?.markerUpdateRequired) {
|
|
754
|
+
/**
|
|
755
|
+
const markerDepths = Object.values(options.markersList)
|
|
756
|
+
.map((marker) => marker.ndc.z);
|
|
757
|
+
if (markerDepths.length > 1) {
|
|
758
|
+
const min = Math.min(...markerDepths);
|
|
759
|
+
const max = Math.max(...markerDepths);
|
|
760
|
+
allObjects.forEach(zincObject => {
|
|
761
|
+
zincObject.processMarkerVisual(min, max);
|
|
762
|
+
});
|
|
763
|
+
}
|
|
764
|
+
*/
|
|
763
765
|
options.markerCluster.calculate();
|
|
764
766
|
}
|
|
765
767
|
}
|
package/src/utilities.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const THREE = require('three');
|
|
2
2
|
const THREEGeometry = require('./three/Geometry').Geometry;
|
|
3
|
+
const SpriteText = require('three-spritetext').default;
|
|
3
4
|
|
|
4
5
|
function resolveURL(url) {
|
|
5
6
|
let actualURL = url;
|
|
@@ -439,6 +440,17 @@ function getCircularTexture() {
|
|
|
439
440
|
return texture;
|
|
440
441
|
}
|
|
441
442
|
|
|
443
|
+
function createNewSpriteText(text, height, colour, font, pixel, weight) {
|
|
444
|
+
const sprite = new SpriteText(text, height, colour, font, pixel, weight);
|
|
445
|
+
sprite.material.sizeAttenuation = false;
|
|
446
|
+
sprite.material.alphaTest = 0.5;
|
|
447
|
+
sprite.material.transparent = true;
|
|
448
|
+
sprite.material.depthWrite = false;
|
|
449
|
+
sprite.material.depthTest = false;
|
|
450
|
+
sprite.center.set(0.5, -1.2);
|
|
451
|
+
sprite.renderOrder = 10000;
|
|
452
|
+
return sprite;
|
|
453
|
+
}
|
|
442
454
|
|
|
443
455
|
exports.getBoundingBox = getBoundingBox;
|
|
444
456
|
exports.createNewURL = createNewURL;
|
|
@@ -448,3 +460,4 @@ exports.resolveURL = resolveURL;
|
|
|
448
460
|
exports.loadExternalFile = loadExternalFile;
|
|
449
461
|
exports.loadExternalFiles = loadExternalFiles;
|
|
450
462
|
exports.PhongToToon = PhongToToon;
|
|
463
|
+
exports.createNewSpriteText = createNewSpriteText;
|