zincjs 1.20.1 → 2.0.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.js +292 -2648
- package/build/zinc.js.map +1 -1
- package/package.json +17 -20
- package/src/controls.js +33 -25
- package/src/geometryCSG.js +25 -23
- package/src/glyphsetCSG.js +15 -13
- package/src/loaders/GLTFToZincJSLoader.js +11 -9
- package/src/loaders/JSONLoader.js +14 -14
- package/src/loaders/niftiReader.js +0 -3
- package/src/loaders/primitivesLoader.js +4 -3
- package/src/minimap.js +6 -4
- package/src/primitives/augmentShader.js +3 -1
- package/src/primitives/geometry.js +16 -14
- package/src/primitives/glyph.js +7 -5
- package/src/primitives/glyphset.js +9 -7
- package/src/primitives/label.js +5 -2
- package/src/primitives/lines.js +13 -10
- package/src/primitives/lines2.js +8 -9
- package/src/primitives/lod.js +9 -9
- package/src/primitives/marker.js +22 -16
- package/src/primitives/markerCluster.js +14 -12
- package/src/primitives/pointset.js +8 -8
- package/src/primitives/texturePrimitive.js +7 -6
- package/src/primitives/textureSlides.js +8 -6
- package/src/primitives/textureVolume.js +8 -6
- package/src/primitives/tubeLines.js +14 -13
- package/src/primitives/zincObject.js +13 -9
- package/src/region.js +65 -66
- package/src/renderer.js +8 -5
- package/src/scene.js +26 -16
- package/src/sceneExporter.js +3 -3
- package/src/sceneLoader.js +109 -88
- package/src/shaders/rgbVolumeRender.js +8 -7
- package/src/shaders/textureArray.js +8 -7
- package/src/shaders/textureSlide.js +7 -6
- package/src/shaders/volumeRender.js +8 -7
- package/src/shaders/volumeRender_old.js +8 -7
- package/src/shaders/volumeTexture.js +9 -8
- package/src/texture/texture.js +9 -9
- package/src/texture/textureArray.js +5 -4
- package/src/three/Loader.js +0 -2
- package/src/three/Points.js +2 -2
- package/src/three-js-csg.js +538 -538
- package/src/utilities.js +49 -41
- package/src/videoHandler.js +11 -9
- package/src/workers/geometryCSG.worker.js +68 -67
- package/src/workers/geometryCSGInternal.js +12 -11
- package/src/zinc.js +49 -25
- package/vite.config.js +29 -0
- package/build/zinc.frontend.js +0 -3
package/src/utilities.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { Geometry as THREEGeometry } from './three/Geometry';
|
|
3
|
+
import SpriteTextModule from 'three-spritetext';
|
|
4
|
+
const SpriteText = SpriteTextModule.default || SpriteTextModule;
|
|
5
|
+
import Zinc from './zinc';
|
|
6
|
+
import discPNG from './assets/disc.png';
|
|
4
7
|
|
|
5
8
|
function resolveURL(url) {
|
|
6
9
|
let actualURL = url;
|
|
7
|
-
let prefix =
|
|
10
|
+
let prefix = Zinc.modelPrefix;
|
|
8
11
|
|
|
9
12
|
if (prefix) {
|
|
10
13
|
if (prefix[prefix.length -1] != '/')
|
|
@@ -84,23 +87,20 @@ function getBoundingBox(mesh, cachedBox, b1, v1, v2) {
|
|
|
84
87
|
//Convenient function
|
|
85
88
|
function loadExternalFile(url, data, callback, errorCallback) {
|
|
86
89
|
// Set up an asynchronous request
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
request.send(null);
|
|
90
|
+
fetch(resolveURL(url))
|
|
91
|
+
.then((response) => {
|
|
92
|
+
if (!response.ok) {
|
|
93
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
94
|
+
}
|
|
95
|
+
return response.text();
|
|
96
|
+
})
|
|
97
|
+
.then((responseText) => {
|
|
98
|
+
callback(responseText, data);
|
|
99
|
+
})
|
|
100
|
+
.catch((error) => {
|
|
101
|
+
console.error(`Fetch string payload retrieval failed for: ${requestURL}`, error);
|
|
102
|
+
errorCallback(url);
|
|
103
|
+
});
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
function loadExternalFiles(urls, callback, errorCallback) {
|
|
@@ -126,7 +126,7 @@ function loadExternalFiles(urls, callback, errorCallback) {
|
|
|
126
126
|
|
|
127
127
|
|
|
128
128
|
//Get the colours at index
|
|
129
|
-
|
|
129
|
+
const getColorsRGB = (colors, index) => {
|
|
130
130
|
const index_in_colors = Math.floor(index/3);
|
|
131
131
|
const remainder = index%3;
|
|
132
132
|
let hex_value = 0;
|
|
@@ -146,7 +146,7 @@ exports.getColorsRGB = (colors, index) => {
|
|
|
146
146
|
return [mycolor.r, mycolor.g, mycolor.b];
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
|
|
149
|
+
const updateMorphColorAttribute = function(targetGeometry, morph) {
|
|
150
150
|
if (morph && targetGeometry && targetGeometry.morphAttributes &&
|
|
151
151
|
targetGeometry.morphAttributes[ "color" ]) {
|
|
152
152
|
const morphColors = targetGeometry.morphAttributes[ "color" ];
|
|
@@ -173,7 +173,7 @@ exports.updateMorphColorAttribute = function(targetGeometry, morph) {
|
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
|
|
176
|
-
|
|
176
|
+
const toBufferGeometry = (geometryIn, options) => {
|
|
177
177
|
let geometry = undefined;
|
|
178
178
|
if (geometryIn instanceof THREEGeometry) {
|
|
179
179
|
if (options.localTimeEnabled && !geometryIn.morphNormalsReady &&
|
|
@@ -194,11 +194,10 @@ exports.toBufferGeometry = (geometryIn, options) => {
|
|
|
194
194
|
return geometry;
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
-
|
|
197
|
+
const copyMorphColorsToBufferGeometry = (geometry, bufferGeometry) => {
|
|
198
198
|
if (geometry && geometry.morphColors && geometry.morphColors.length > 0 ) {
|
|
199
199
|
let array = [];
|
|
200
200
|
let morphColors = geometry.morphColors;
|
|
201
|
-
const getColorsRGB = require("./utilities").getColorsRGB;
|
|
202
201
|
for ( var i = 0, l = morphColors.length; i < l; i ++ ) {
|
|
203
202
|
let morphColor = morphColors[ i ];
|
|
204
203
|
let colorArray = [];
|
|
@@ -224,7 +223,6 @@ const copyMorphColorsToIndexedBufferGeometry = (geometry, bufferGeometry) => {
|
|
|
224
223
|
if (geometry && geometry.morphColors && geometry.morphColors.length > 0 ) {
|
|
225
224
|
let array = [];
|
|
226
225
|
let morphColors = geometry.morphColors;
|
|
227
|
-
const getColorsRGB = require("./utilities").getColorsRGB;
|
|
228
226
|
for ( let i = 0, l = morphColors.length; i < l; i ++ ) {
|
|
229
227
|
const morphColor = morphColors[ i ];
|
|
230
228
|
const colorArray = [];
|
|
@@ -343,7 +341,7 @@ function mergeAttributes( attributes ) {
|
|
|
343
341
|
* @param {boolean} [useGroups=false] - Whether to use groups or not.
|
|
344
342
|
* @return {?BufferGeometry} The merged geometry. Returns `null` if the merge does not succeed.
|
|
345
343
|
*/
|
|
346
|
-
|
|
344
|
+
const mergeGeometries = ( geometries, useGroups = false ) => {
|
|
347
345
|
|
|
348
346
|
const isIndexed = geometries[ 0 ].index !== null;
|
|
349
347
|
|
|
@@ -534,7 +532,7 @@ exports.mergeGeometries = ( geometries, useGroups = false ) => {
|
|
|
534
532
|
|
|
535
533
|
}
|
|
536
534
|
|
|
537
|
-
|
|
535
|
+
const mergeVertices = ( geometry, tolerance = 1e-4 ) => {
|
|
538
536
|
|
|
539
537
|
tolerance = Math.max( tolerance, Number.EPSILON );
|
|
540
538
|
|
|
@@ -742,7 +740,7 @@ function createBufferGeometry(length, coords) {
|
|
|
742
740
|
|
|
743
741
|
function getCircularTexture() {
|
|
744
742
|
const image = new Image();
|
|
745
|
-
image.src =
|
|
743
|
+
image.src = discPNG;
|
|
746
744
|
const texture = new THREE.Texture();
|
|
747
745
|
texture.image = image;
|
|
748
746
|
texture.needsUpdate = true;
|
|
@@ -844,14 +842,24 @@ function removeVertexAtIndex(geometry, index, maintainLength) {
|
|
|
844
842
|
|
|
845
843
|
}
|
|
846
844
|
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
845
|
+
|
|
846
|
+
export {
|
|
847
|
+
copyMorphColorsToBufferGeometry,
|
|
848
|
+
createBufferGeometry,
|
|
849
|
+
createNewSpriteText,
|
|
850
|
+
createNewURL,
|
|
851
|
+
getBoundingBox,
|
|
852
|
+
getCircularTexture,
|
|
853
|
+
getColorsRGB,
|
|
854
|
+
isRegionGroup,
|
|
855
|
+
loadExternalFile,
|
|
856
|
+
loadExternalFiles,
|
|
857
|
+
mergeGeometries,
|
|
858
|
+
mergeVertices,
|
|
859
|
+
PhongToToon,
|
|
860
|
+
removeVertexAtIndex,
|
|
861
|
+
resolveURL,
|
|
862
|
+
updateMorphColorAttribute,
|
|
863
|
+
toBufferGeometry,
|
|
864
|
+
};
|
|
865
|
+
|
package/src/videoHandler.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
import * as THREE from 'three';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Provide basic functionality to display video as texture.
|
|
5
5
|
* VideoTexture is used for creating and updating a video projected onto a Three.js texture
|
|
6
|
-
*
|
|
6
|
+
*
|
|
7
7
|
* @class
|
|
8
8
|
* @param {Object} containerIn - Container to create the renderer on.
|
|
9
9
|
* @author Alan Wu
|
|
10
10
|
* @return {VideoHandler}
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
const VideoHandler = function(srcIn) {
|
|
13
13
|
|
|
14
14
|
var _this = this;
|
|
15
15
|
this.video = undefined;
|
|
@@ -22,7 +22,7 @@ exports.VideoHandler = function(srcIn) {
|
|
|
22
22
|
var lastPlayPos = 0;
|
|
23
23
|
var currentPlayPos = 0;
|
|
24
24
|
var bufferingDetected = false;
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
var checkBuffering = function(delta, playAnimation) {
|
|
27
27
|
currentPlayPos = _this.video.currentTime;
|
|
28
28
|
|
|
@@ -54,7 +54,7 @@ exports.VideoHandler = function(srcIn) {
|
|
|
54
54
|
_this.video.src = src;
|
|
55
55
|
_this.video.load();
|
|
56
56
|
_this.video.loop = true;
|
|
57
|
-
|
|
57
|
+
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -76,7 +76,7 @@ exports.VideoHandler = function(srcIn) {
|
|
|
76
76
|
_this.video.currentTime = 0;
|
|
77
77
|
return _this.videoTexture;
|
|
78
78
|
}
|
|
79
|
-
|
|
79
|
+
|
|
80
80
|
this.getCurrentTime = function(duration) {
|
|
81
81
|
if (_this.video)
|
|
82
82
|
return duration * (_this.video.currentTime / _this.video.duration);
|
|
@@ -91,8 +91,10 @@ exports.VideoHandler = function(srcIn) {
|
|
|
91
91
|
}
|
|
92
92
|
return false;
|
|
93
93
|
}
|
|
94
|
-
|
|
95
|
-
//this should be handle by scene... check the sync at
|
|
94
|
+
|
|
95
|
+
//this should be handle by scene... check the sync at
|
|
96
96
|
initialise();
|
|
97
97
|
|
|
98
|
-
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export { VideoHandler }
|
|
@@ -1,73 +1,74 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
|
|
2
|
+
import { Geometry } from '../primitives/geometry';
|
|
3
|
+
import { GeometryCSGInternal } from './geometryCSGInternal';
|
|
4
|
+
import * as THREE from 'three';
|
|
5
|
+
|
|
3
6
|
const JSONLoader = THREE.BufferGeometryLoader;
|
|
7
|
+
let core = undefined;
|
|
8
|
+
|
|
9
|
+
var geometryFromJSON = function(object) {
|
|
10
|
+
var JSONParser = new JSONLoader();
|
|
11
|
+
var geometry = JSONParser.parse(object);
|
|
12
|
+
var material = new THREE.MeshPhongMaterial();
|
|
13
|
+
var mesh = new THREE.Mesh(geometry.geometry, material);
|
|
14
|
+
var host = new Geometry();
|
|
15
|
+
host.setMorph(mesh);
|
|
16
|
+
return host;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
var initialise = function(object) {
|
|
20
|
+
var host = geometryFromJSON(object);
|
|
21
|
+
core = new GeometryCSGInternal(host);
|
|
22
|
+
self.postMessage({action:"message", message: "Initialised"});
|
|
23
|
+
}
|
|
4
24
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
25
|
+
var intersect = function(object) {
|
|
26
|
+
if (core) {
|
|
27
|
+
var guest = geometryFromJSON(object);
|
|
28
|
+
var result = core.intersect(guest);
|
|
29
|
+
var json = result.toBufferGeometry().toJSON();
|
|
30
|
+
self.postMessage({action: "result", object: json});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
var subtract = function(object) {
|
|
35
|
+
if (core) {
|
|
36
|
+
var guest = geometryFromJSON(object);
|
|
37
|
+
var result = core.subtract(guest);
|
|
38
|
+
var json = result.toBufferGeometry().toJSON();
|
|
39
|
+
self.postMessage({action: "result", object: json});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
var union = function(object) {
|
|
44
|
+
if (core) {
|
|
45
|
+
var guest = geometryFromJSON(object);
|
|
46
|
+
var result = core.union(guest);
|
|
47
|
+
var json = result.toBufferGeometry().toJSON();
|
|
48
|
+
self.postMessage({action: "result", object: json});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
self.addEventListener('message',function (ev){
|
|
53
|
+
switch (ev.data.action) {
|
|
54
|
+
case 'initialise':
|
|
55
|
+
initialise(ev.data.object);
|
|
56
|
+
break;
|
|
57
|
+
case 'intersect':
|
|
58
|
+
intersect(ev.data.object);
|
|
59
|
+
break;
|
|
60
|
+
case 'subtract':
|
|
61
|
+
subtract(ev.data.object);
|
|
62
|
+
break;
|
|
63
|
+
case 'union':
|
|
64
|
+
union(ev.data.object);
|
|
65
|
+
break;
|
|
66
|
+
default:
|
|
67
|
+
throw 'Cannot handle specified action.';
|
|
68
|
+
}
|
|
69
|
+
});
|
|
17
70
|
|
|
18
|
-
var initialise = function(object) {
|
|
19
|
-
var host = geometryFromJSON(object);
|
|
20
|
-
core = new (require('./geometryCSGInternal').GeometryCSGInternal)(host);
|
|
21
|
-
self.postMessage({action:"message", message: "Initialised"});
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
var intersect = function(object) {
|
|
25
|
-
if (core) {
|
|
26
|
-
var guest = geometryFromJSON(object);
|
|
27
|
-
var result = core.intersect(guest);
|
|
28
|
-
var json = result.toBufferGeometry().toJSON();
|
|
29
|
-
self.postMessage({action: "result", object: json});
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
var subtract = function(object) {
|
|
34
|
-
if (core) {
|
|
35
|
-
var guest = geometryFromJSON(object);
|
|
36
|
-
var result = core.subtract(guest);
|
|
37
|
-
var json = result.toBufferGeometry().toJSON();
|
|
38
|
-
self.postMessage({action: "result", object: json});
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
var union = function(object) {
|
|
43
|
-
if (core) {
|
|
44
|
-
var guest = geometryFromJSON(object);
|
|
45
|
-
var result = core.union(guest);
|
|
46
|
-
var json = result.toBufferGeometry().toJSON();
|
|
47
|
-
self.postMessage({action: "result", object: json});
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
self.addEventListener('message',function (ev){
|
|
52
|
-
switch (ev.data.action) {
|
|
53
|
-
case 'initialise':
|
|
54
|
-
initialise(ev.data.object);
|
|
55
|
-
break;
|
|
56
|
-
case 'intersect':
|
|
57
|
-
intersect(ev.data.object);
|
|
58
|
-
break;
|
|
59
|
-
case 'subtract':
|
|
60
|
-
subtract(ev.data.object);
|
|
61
|
-
break;
|
|
62
|
-
case 'union':
|
|
63
|
-
union(ev.data.object);
|
|
64
|
-
break;
|
|
65
|
-
default:
|
|
66
|
-
throw 'Cannot handle specified action.';
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
|
|
70
71
|
//var test = ev.data;
|
|
71
72
|
//self.postMessage(test, [test]);
|
|
72
|
-
|
|
73
|
+
|
|
73
74
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { ThreeBSPWrapper } from '../three-js-csg';
|
|
3
|
+
const ThreeBSP = ThreeBSPWrapper(THREE);
|
|
4
|
+
|
|
5
5
|
|
|
6
6
|
const GeometryCSGInternal = function (hostIn) {
|
|
7
7
|
//ZincGeoemtry of the main geometry
|
|
@@ -9,17 +9,17 @@ const GeometryCSGInternal = function (hostIn) {
|
|
|
9
9
|
if (hostIn && hostIn.isGeometry)
|
|
10
10
|
host = hostIn;
|
|
11
11
|
let hostCSG = undefined;
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
this.setGeometry = hostIn => {
|
|
14
14
|
if (hostIn && hostIn.isGeometry)
|
|
15
15
|
host = hostIn;
|
|
16
16
|
hostCSG = undefined;
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
this.setCSG = csg => {
|
|
20
20
|
hostCSG = csg;
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
const prepareCSG = guestGeometry => {
|
|
24
24
|
if (host && host.morph && guestGeometry && guestGeometry.morph) {
|
|
25
25
|
if (hostCSG === undefined)
|
|
@@ -29,7 +29,7 @@ const GeometryCSGInternal = function (hostIn) {
|
|
|
29
29
|
}
|
|
30
30
|
return undefined;
|
|
31
31
|
};
|
|
32
|
-
|
|
32
|
+
|
|
33
33
|
this.intersect = guestGeometry => {
|
|
34
34
|
const guestCSG = prepareCSG(guestGeometry);
|
|
35
35
|
if (hostCSG && guestCSG) {
|
|
@@ -37,7 +37,7 @@ const GeometryCSGInternal = function (hostIn) {
|
|
|
37
37
|
}
|
|
38
38
|
return undefined;
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
|
|
41
41
|
this.subtract = guestGeometry => {
|
|
42
42
|
const guestCSG = prepareCSG(guestGeometry);
|
|
43
43
|
if (hostCSG && guestCSG) {
|
|
@@ -45,7 +45,7 @@ const GeometryCSGInternal = function (hostIn) {
|
|
|
45
45
|
}
|
|
46
46
|
return undefined;
|
|
47
47
|
}
|
|
48
|
-
|
|
48
|
+
|
|
49
49
|
this.union = guestGeometry => {
|
|
50
50
|
const guestCSG = prepareCSG(guestGeometry);
|
|
51
51
|
if (hostCSG && guestCSG) {
|
|
@@ -55,4 +55,5 @@ const GeometryCSGInternal = function (hostIn) {
|
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
export { GeometryCSGInternal };
|
|
59
|
+
|
package/src/zinc.js
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import PACKAGE from '../package.json';
|
|
3
|
+
|
|
4
|
+
// Import all internal primitives and modules
|
|
5
|
+
import { Geometry } from './primitives/geometry';
|
|
6
|
+
import { Glyph } from './primitives/glyph';
|
|
7
|
+
import { Glyphset } from './primitives/glyphset';
|
|
8
|
+
import { Pointset } from './primitives/pointset';
|
|
9
|
+
import { Label } from './primitives/label';
|
|
10
|
+
import { Lines } from './primitives/lines';
|
|
11
|
+
import { TextureArray } from './texture/textureArray';
|
|
12
|
+
import { TextureSlides } from './primitives/textureSlides';
|
|
13
|
+
import { Renderer } from './renderer';
|
|
14
|
+
import { Scene } from './scene';
|
|
15
|
+
//import { GeometryCSG } from './geometryCSG';
|
|
16
|
+
//import { GlyphsetCSG } from './glyphsetCSG';
|
|
17
|
+
import {
|
|
18
|
+
Viewport,
|
|
19
|
+
CameraControls,
|
|
20
|
+
SmoothCameraTransition,
|
|
21
|
+
RayCaster,
|
|
22
|
+
CameraAutoTumble,
|
|
23
|
+
StereoEffect
|
|
24
|
+
} from './controls';
|
|
25
|
+
import { loadExternalFile, loadExternalFiles } from './utilities';
|
|
26
|
+
|
|
3
27
|
const version = PACKAGE.version;
|
|
4
28
|
|
|
5
29
|
/**
|
|
@@ -8,33 +32,33 @@ const version = PACKAGE.version;
|
|
|
8
32
|
* @namespace
|
|
9
33
|
* @author Alan Wu
|
|
10
34
|
*/
|
|
11
|
-
|
|
12
35
|
const Zinc = function() {
|
|
13
36
|
this.Revision = version;
|
|
14
37
|
this.defaultMaterialColor = 0xFFFFFF;
|
|
15
38
|
this.defaultOpacity = 1.0;
|
|
16
39
|
this.modelPrefix = undefined;
|
|
17
|
-
|
|
18
|
-
this.
|
|
19
|
-
this.
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
22
|
-
this.
|
|
23
|
-
this.
|
|
24
|
-
this.
|
|
25
|
-
this.
|
|
26
|
-
this.
|
|
27
|
-
this.
|
|
28
|
-
this.
|
|
29
|
-
this.
|
|
30
|
-
this.
|
|
31
|
-
this.
|
|
32
|
-
this.
|
|
33
|
-
this.
|
|
34
|
-
this.
|
|
35
|
-
this.
|
|
36
|
-
this.
|
|
37
|
-
this.
|
|
40
|
+
// Assign hoisted modules to the instance
|
|
41
|
+
this.Geometry = Geometry;
|
|
42
|
+
this.Glyph = Glyph;
|
|
43
|
+
this.Glyphset = Glyphset;
|
|
44
|
+
this.Pointset = Pointset;
|
|
45
|
+
this.Label = Label;
|
|
46
|
+
this.Lines = Lines;
|
|
47
|
+
this.TextureArray = TextureArray;
|
|
48
|
+
this.TextureSlides = TextureSlides;
|
|
49
|
+
this.Renderer = Renderer;
|
|
50
|
+
this.Scene = Scene;
|
|
51
|
+
//this.GeometryCSG = GeometryCSG;
|
|
52
|
+
//this.GlyphsetCSG = GlyphsetCSG;
|
|
53
|
+
this.Viewport = Viewport;
|
|
54
|
+
this.CameraControls = CameraControls;
|
|
55
|
+
this.SmoothCameraTransition = SmoothCameraTransition;
|
|
56
|
+
this.RayCaster = RayCaster;
|
|
57
|
+
this.CameraAutoTumble = CameraAutoTumble;
|
|
58
|
+
this.StereoEffect = StereoEffect;
|
|
59
|
+
this.loadExternalFile = loadExternalFile;
|
|
60
|
+
this.loadExternalFiles = loadExternalFiles;
|
|
61
|
+
this.THREE = THREE;
|
|
38
62
|
};
|
|
39
63
|
|
|
40
|
-
|
|
64
|
+
export default new Zinc();
|
package/vite.config.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
build: {
|
|
6
|
+
sourcemap: true,
|
|
7
|
+
outDir: 'build',
|
|
8
|
+
minify: true,
|
|
9
|
+
lib: {
|
|
10
|
+
entry: path.resolve(__dirname, 'src/zinc.js'),
|
|
11
|
+
name: 'Zinc',
|
|
12
|
+
fileName: () => 'zinc.js',
|
|
13
|
+
formats: ['es', 'umd'],
|
|
14
|
+
},
|
|
15
|
+
rollupOptions: {
|
|
16
|
+
external: (id) => !id.startsWith('.') && !path.isAbsolute(id) && !id.includes('package.json'),
|
|
17
|
+
output: {
|
|
18
|
+
extend: true,
|
|
19
|
+
globals: {
|
|
20
|
+
'css-element-queries': 'cssElememtQueries',
|
|
21
|
+
three: 'THREE',
|
|
22
|
+
'three-spritetext': 'SpriteText',
|
|
23
|
+
'three/examples/jsm/loaders/GLTFLoader': 'GLTFLoader'
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
assetsInlineLimit: 8192,
|
|
28
|
+
},
|
|
29
|
+
});
|