zincjs 3.0.0 → 3.0.1
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/README.md +27 -22
- package/build/zinc.js +2 -2
- package/build/zinc.js.map +1 -1
- package/package.json +4 -1
- package/src/controls.js +1332 -1241
- package/src/geometryCSG.js +111 -115
- package/src/glyphsetCSG.js +51 -55
- package/src/loaders/GLTFToZincJSLoader.js +31 -33
- package/src/loaders/JSONLoader.js +339 -449
- package/src/loaders/OBJLoader.js +654 -851
- package/src/loaders/STLLoader.js +271 -329
- package/src/loaders/niftiReader.js +90 -59
- package/src/loaders/primitivesLoader.js +55 -52
- package/src/minimap.js +63 -43
- package/src/primitives/geometry.js +40 -44
- package/src/primitives/glyph.js +16 -19
- package/src/primitives/glyphset.js +229 -185
- package/src/primitives/label.js +29 -31
- package/src/primitives/lines.js +20 -20
- package/src/primitives/lines2.js +33 -39
- package/src/primitives/lod.js +43 -43
- package/src/primitives/marker.js +31 -32
- package/src/primitives/markerCluster.js +32 -35
- package/src/primitives/pointset.js +86 -83
- package/src/primitives/texturePrimitive.js +9 -10
- package/src/primitives/textureSlides.js +84 -97
- package/src/primitives/textureVolume.js +46 -49
- package/src/primitives/tubeLines.js +108 -108
- package/src/primitives/zincObject.js +176 -184
- package/src/region.js +145 -155
- package/src/renderRequests.js +3 -3
- package/src/renderer.js +635 -620
- package/src/scene.js +479 -419
- package/src/sceneExporter.js +22 -17
- package/src/sceneLoader.js +542 -296
- package/src/shaders/rgbVolumeRender.js +11 -18
- package/src/shaders/textureArray.js +5 -12
- package/src/shaders/textureSlide.js +10 -17
- package/src/shaders/volumeRender.js +11 -18
- package/src/shaders/volumeRender_old.js +11 -18
- package/src/shaders/volumeTexture.js +7 -14
- package/src/textSprite.js +23 -19
- package/src/texture/texture.js +14 -15
- package/src/texture/textureArray.js +14 -16
- package/src/three/InstancedPoints.js +2 -9
- package/src/three/Loader.js +334 -315
- package/src/three/line/Line.js +165 -215
- package/src/three/line/LineSegments.js +40 -55
- package/src/three/line/LineSegments2.js +322 -366
- package/src/three/line/LineSegmentsGeometry.js +239 -280
- package/src/three-js-csg.js +260 -252
- package/src/tsl/glyphRenderMaterial.js +12 -3
- package/src/tsl/glyphTransform.js +51 -29
- package/src/tsl/textureSlides.js +23 -24
- package/src/utilities.js +309 -371
- package/src/videoHandler.js +76 -83
- package/src/workers/geometryCSG.worker.js +33 -36
- package/src/workers/geometryCSGInternal.js +39 -44
- package/src/zinc.js +4 -7
- package/vite.config.js +7 -7
package/src/sceneExporter.js
CHANGED
|
@@ -16,12 +16,11 @@ class GLTFMorphColourPlugin {
|
|
|
16
16
|
|
|
17
17
|
writeMesh(mesh, meshDef) {
|
|
18
18
|
const geometry = mesh.geometry;
|
|
19
|
-
const morphColours =
|
|
20
|
-
geometry.morphAttributes.color : undefined;
|
|
19
|
+
const morphColours =
|
|
20
|
+
geometry && geometry.morphAttributes ? geometry.morphAttributes.color : undefined;
|
|
21
21
|
const baseColour = geometry ? geometry.attributes.color : undefined;
|
|
22
22
|
const primitive = meshDef.primitives ? meshDef.primitives[0] : undefined;
|
|
23
|
-
if (!morphColours || !baseColour || !primitive || !primitive.targets)
|
|
24
|
-
return;
|
|
23
|
+
if (!morphColours || !baseColour || !primitive || !primitive.targets) return;
|
|
25
24
|
// All primitives of a mesh share the same targets array.
|
|
26
25
|
const targets = primitive.targets;
|
|
27
26
|
const itemSize = baseColour.itemSize;
|
|
@@ -36,12 +35,15 @@ class GLTFMorphColourPlugin {
|
|
|
36
35
|
for (let j = 0; j < count; j++) {
|
|
37
36
|
for (let a = 0; a < itemSize; a++) {
|
|
38
37
|
const value = attribute.getComponent(j, a);
|
|
39
|
-
array[j * itemSize + a] = geometry.morphTargetsRelative
|
|
40
|
-
|
|
38
|
+
array[j * itemSize + a] = geometry.morphTargetsRelative
|
|
39
|
+
? value
|
|
40
|
+
: value - baseColour.getComponent(j, a);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
targets[i].COLOR_0 = this.writer.processAccessor(
|
|
44
|
-
new BufferAttribute(array, itemSize),
|
|
44
|
+
new BufferAttribute(array, itemSize),
|
|
45
|
+
geometry,
|
|
46
|
+
);
|
|
45
47
|
}
|
|
46
48
|
}
|
|
47
49
|
}
|
|
@@ -65,7 +67,7 @@ const SceneExporter = function (sceneIn) {
|
|
|
65
67
|
return true;
|
|
66
68
|
};
|
|
67
69
|
|
|
68
|
-
|
|
70
|
+
this.exportGLTF = async (binary) => {
|
|
69
71
|
const rootRegion = scene.getRootRegion();
|
|
70
72
|
const zincObjects = rootRegion.getAllObjects(true);
|
|
71
73
|
const animations = [];
|
|
@@ -77,7 +79,9 @@ const SceneExporter = function (sceneIn) {
|
|
|
77
79
|
// The exporter resolves tracks against the scene root, but morph
|
|
78
80
|
// clips target '' (the mesh itself), so retarget them by uuid.
|
|
79
81
|
const clip = zincObject.animationClip[0].clone();
|
|
80
|
-
clip.tracks.forEach(track => {
|
|
82
|
+
clip.tracks.forEach((track) => {
|
|
83
|
+
track.name = mesh.uuid + track.name;
|
|
84
|
+
});
|
|
81
85
|
animations.push(clip);
|
|
82
86
|
}
|
|
83
87
|
}
|
|
@@ -93,26 +97,27 @@ const SceneExporter = function (sceneIn) {
|
|
|
93
97
|
//GLTFExporter only accepts plain typed arrays
|
|
94
98
|
const restoreIndexType = useStandardIndexType(scene.getThreeJSScene());
|
|
95
99
|
const exporter = new GLTFExporter();
|
|
96
|
-
exporter.register(writer => new GLTFMorphColourPlugin(writer));
|
|
100
|
+
exporter.register((writer) => new GLTFMorphColourPlugin(writer));
|
|
97
101
|
const options = { binary, animations, onlyVisible: true };
|
|
98
102
|
try {
|
|
99
103
|
return await new Promise((resolve, reject) => {
|
|
100
104
|
exporter.parse(
|
|
101
105
|
scene.getThreeJSScene(),
|
|
102
|
-
function (
|
|
106
|
+
function (gltf) {
|
|
103
107
|
resolve(gltf);
|
|
104
108
|
},
|
|
105
|
-
function (
|
|
106
|
-
console.error(
|
|
109
|
+
function (error) {
|
|
110
|
+
console.error('Unable to export GLTF.', error);
|
|
107
111
|
reject(error);
|
|
108
112
|
},
|
|
109
|
-
options
|
|
113
|
+
options,
|
|
114
|
+
);
|
|
110
115
|
});
|
|
111
116
|
} finally {
|
|
112
117
|
restoreIndexType();
|
|
113
|
-
glyphsetsToRestore.forEach(zincObject => zincObject.clearColorExportState());
|
|
118
|
+
glyphsetsToRestore.forEach((zincObject) => zincObject.clearColorExportState());
|
|
114
119
|
}
|
|
115
|
-
|
|
116
|
-
}
|
|
120
|
+
};
|
|
121
|
+
};
|
|
117
122
|
|
|
118
123
|
export { SceneExporter };
|