zincjs 1.0.13 → 1.0.15

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.
Files changed (45) hide show
  1. package/build/zinc.frontend.js +1 -1
  2. package/build/zinc.js +43 -35
  3. package/build/zinc.js.map +1 -1
  4. package/package.json +3 -3
  5. package/src/assets/disc.png +0 -0
  6. package/src/assets/mapMarker.svg +11 -0
  7. package/src/controls.js +1594 -0
  8. package/src/geometryCSG.js +148 -0
  9. package/src/glyphsetCSG.js +84 -0
  10. package/src/loaders/GLTFToZincJSLoader.js +85 -0
  11. package/src/loaders/JSONLoader.js +697 -0
  12. package/src/loaders/OBJLoader.js +911 -0
  13. package/src/loaders/STLLoader.js +399 -0
  14. package/src/loaders/primitivesLoader.js +46 -0
  15. package/src/minimap.js +82 -0
  16. package/src/primitives/augmentShader.js +22 -0
  17. package/src/primitives/geometry.js +109 -0
  18. package/src/primitives/glyph.js +150 -0
  19. package/src/primitives/glyphset.js +657 -0
  20. package/src/primitives/label.js +51 -0
  21. package/src/primitives/lines.js +35 -0
  22. package/src/primitives/marker.js +88 -0
  23. package/src/primitives/pointset.js +53 -0
  24. package/src/primitives/texturePrimitive.js +16 -0
  25. package/src/primitives/textureSlides.js +118 -0
  26. package/src/primitives/zincObject.js +573 -0
  27. package/src/region.js +554 -0
  28. package/src/renderer.js +612 -0
  29. package/src/scene.js +963 -0
  30. package/src/sceneExporter.js +32 -0
  31. package/src/sceneLoader.js +842 -0
  32. package/src/texture/texture.js +57 -0
  33. package/src/texture/textureArray.js +85 -0
  34. package/src/three/GLTFExporter.js +2448 -0
  35. package/src/three/Geometry.js +2084 -0
  36. package/src/three/Loader.js +344 -0
  37. package/src/three/Points.js +223 -0
  38. package/src/three/line/Line.js +293 -0
  39. package/src/three/line/LineSegments.js +65 -0
  40. package/src/three-js-csg.js +564 -0
  41. package/src/utilities.js +321 -0
  42. package/src/videoHandler.js +92 -0
  43. package/src/workers/geometryCSG.worker.js +73 -0
  44. package/src/workers/geometryCSGInternal.js +58 -0
  45. package/src/zinc.js +38 -0
@@ -0,0 +1,150 @@
1
+ const THREE = require('three');
2
+
3
+ /**
4
+ * Zinc representation of glyph graphic, it contains the colours,
5
+ * geometry and transformation of the glyph.
6
+ *
7
+ * @param {THREE.Geometry} geometry - Geometry of the glyph.
8
+ * @param {THREE.material} materialIn - Material of the glyph.
9
+ * @param {Number} idIn - Id of the glyph.
10
+ *
11
+ * @class
12
+ * @author Alan Wu
13
+ * @return {Zinc.Glyph}
14
+ */
15
+ const Glyph = function(geometry, materialIn, idIn, glyphsetIn) {
16
+ (require('./zincObject').ZincObject).call(this);
17
+ let material = undefined;
18
+ if (materialIn) {
19
+ material = materialIn.clone();
20
+ material.vertexColors = THREE.FaceColors;
21
+ }
22
+ const parent = glyphsetIn;
23
+ this.id = idIn;
24
+ let label = undefined;
25
+ let labelString = undefined;
26
+ const group = new THREE.Group();
27
+ this.isGlyph = true;
28
+
29
+ this.fromMesh = meshIn => {
30
+ if (meshIn && meshIn.isMesh) {
31
+ this.morph = meshIn.clone();
32
+ this.morph.userData = this;
33
+ group.add(this.morph);
34
+ return true;
35
+ }
36
+ return false;
37
+ }
38
+
39
+ if (geometry && material) {
40
+ this.fromMesh(new THREE.Mesh( geometry, material ));
41
+ }
42
+
43
+ this.getGlyphset = function() {
44
+ return parent;
45
+ }
46
+
47
+ this.setLabel = text => {
48
+ if (text && (typeof text === 'string' || text instanceof String)) {
49
+ labelString = text;
50
+ if (this.morph)
51
+ this.morph.name = text;
52
+ }
53
+ if (label)
54
+ this.showLabel();
55
+ }
56
+
57
+ this.showLabel = (colour) => {
58
+ if (label) {
59
+ position = label.getPosition();
60
+ group.remove(label.getSprite());
61
+ label.dispose();
62
+ label = undefined;
63
+ }
64
+ if (labelString && (typeof labelString === 'string' || labelString instanceof String)) {
65
+ let position = [0, 0, 0];
66
+ label = new (require('./label').Label)(labelString, colour);
67
+ label.setPosition(position[0], position[1], position[2]);
68
+ group.add(label.getSprite());
69
+ }
70
+ }
71
+
72
+ /**
73
+ * Get the group containing the label and mesh.
74
+ * @return {THREE.Group}
75
+ */
76
+ this.getGroup = () => {
77
+ return group;
78
+ }
79
+
80
+ /**
81
+ * Get the label of this glyph
82
+ * @return {Label}
83
+ */
84
+ this.getLabel = () => {
85
+ return labelString;
86
+ }
87
+
88
+ /**
89
+ * Get the mesh of this glyph.
90
+ * @return {THREE.Mesh}
91
+ */
92
+ this.getMesh = () => {
93
+ return this.morph;
94
+ }
95
+
96
+ /**
97
+ * Set the transformation of this glyph.
98
+ * @param {Array} position - Three components vectors containing position of the
99
+ * transformation.
100
+ * @param {Array} axis1 - Three components vectors containing axis1 rotation of the
101
+ * transformation.
102
+ * @param {Array} axis2 - Three components vectors containing axis2 rotation of the
103
+ * transformation.
104
+ * @param {Array} position - Three components vectors containing axis3 rotation of the
105
+ * transformation.
106
+ */
107
+ this.setTransformation = (position, axis1, axis2, axis3) => {
108
+ if (this.morph) {
109
+ this.morph.matrix.elements[0] = axis1[0];
110
+ this.morph.matrix.elements[1] = axis1[1];
111
+ this.morph.matrix.elements[2] = axis1[2];
112
+ this.morph.matrix.elements[3] = 0.0;
113
+ this.morph.matrix.elements[4] = axis2[0];
114
+ this.morph.matrix.elements[5] = axis2[1];
115
+ this.morph.matrix.elements[6] = axis2[2];
116
+ this.morph.matrix.elements[7] = 0.0;
117
+ this.morph.matrix.elements[8] = axis3[0];
118
+ this.morph.matrix.elements[9] = axis3[1];
119
+ this.morph.matrix.elements[10] = axis3[2];
120
+ this.morph.matrix.elements[11] = 0.0;
121
+ this.morph.matrix.elements[12] = position[0];
122
+ this.morph.matrix.elements[13] = position[1];
123
+ this.morph.matrix.elements[14] = position[2];
124
+ this.morph.matrix.elements[15] = 1.0;
125
+ this.morph.matrixAutoUpdate = false;
126
+ }
127
+ if (label)
128
+ label.setPosition(position[0], position[1], position[2]);
129
+ }
130
+
131
+ this.setColour = (color) => {
132
+ if (label)
133
+ label.setColour(color);
134
+ if (this.secondaryMesh && this.secondaryMesh.material)
135
+ this.secondaryMesh.material.color = colour;
136
+ this.geometry.colorsNeedUpdate = true;
137
+ }
138
+
139
+ /**
140
+ * Clear and free its memory.
141
+ */
142
+ this.dispose = () => {
143
+ if (this.material)
144
+ this.material.dispose();
145
+ this.morph = undefined;
146
+ }
147
+ }
148
+
149
+ Glyph.prototype = Object.create((require('./zincObject').ZincObject).prototype);
150
+ exports.Glyph = Glyph;