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.
Files changed (60) hide show
  1. package/README.md +27 -22
  2. package/build/zinc.js +2 -2
  3. package/build/zinc.js.map +1 -1
  4. package/package.json +4 -1
  5. package/src/controls.js +1332 -1241
  6. package/src/geometryCSG.js +111 -115
  7. package/src/glyphsetCSG.js +51 -55
  8. package/src/loaders/GLTFToZincJSLoader.js +31 -33
  9. package/src/loaders/JSONLoader.js +339 -449
  10. package/src/loaders/OBJLoader.js +654 -851
  11. package/src/loaders/STLLoader.js +271 -329
  12. package/src/loaders/niftiReader.js +90 -59
  13. package/src/loaders/primitivesLoader.js +55 -52
  14. package/src/minimap.js +63 -43
  15. package/src/primitives/geometry.js +40 -44
  16. package/src/primitives/glyph.js +16 -19
  17. package/src/primitives/glyphset.js +229 -185
  18. package/src/primitives/label.js +29 -31
  19. package/src/primitives/lines.js +20 -20
  20. package/src/primitives/lines2.js +33 -39
  21. package/src/primitives/lod.js +43 -43
  22. package/src/primitives/marker.js +31 -32
  23. package/src/primitives/markerCluster.js +32 -35
  24. package/src/primitives/pointset.js +86 -83
  25. package/src/primitives/texturePrimitive.js +9 -10
  26. package/src/primitives/textureSlides.js +84 -97
  27. package/src/primitives/textureVolume.js +46 -49
  28. package/src/primitives/tubeLines.js +108 -108
  29. package/src/primitives/zincObject.js +176 -184
  30. package/src/region.js +145 -155
  31. package/src/renderRequests.js +3 -3
  32. package/src/renderer.js +635 -620
  33. package/src/scene.js +479 -419
  34. package/src/sceneExporter.js +22 -17
  35. package/src/sceneLoader.js +542 -296
  36. package/src/shaders/rgbVolumeRender.js +11 -18
  37. package/src/shaders/textureArray.js +5 -12
  38. package/src/shaders/textureSlide.js +10 -17
  39. package/src/shaders/volumeRender.js +11 -18
  40. package/src/shaders/volumeRender_old.js +11 -18
  41. package/src/shaders/volumeTexture.js +7 -14
  42. package/src/textSprite.js +23 -19
  43. package/src/texture/texture.js +14 -15
  44. package/src/texture/textureArray.js +14 -16
  45. package/src/three/InstancedPoints.js +2 -9
  46. package/src/three/Loader.js +334 -315
  47. package/src/three/line/Line.js +165 -215
  48. package/src/three/line/LineSegments.js +40 -55
  49. package/src/three/line/LineSegments2.js +322 -366
  50. package/src/three/line/LineSegmentsGeometry.js +239 -280
  51. package/src/three-js-csg.js +260 -252
  52. package/src/tsl/glyphRenderMaterial.js +12 -3
  53. package/src/tsl/glyphTransform.js +51 -29
  54. package/src/tsl/textureSlides.js +23 -24
  55. package/src/utilities.js +309 -371
  56. package/src/videoHandler.js +76 -83
  57. package/src/workers/geometryCSG.worker.js +33 -36
  58. package/src/workers/geometryCSGInternal.js +39 -44
  59. package/src/zinc.js +4 -7
  60. package/vite.config.js +7 -7
@@ -16,12 +16,11 @@ class GLTFMorphColourPlugin {
16
16
 
17
17
  writeMesh(mesh, meshDef) {
18
18
  const geometry = mesh.geometry;
19
- const morphColours = geometry && geometry.morphAttributes ?
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
- value : value - baseColour.getComponent(j, a);
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), geometry);
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
- this.exportGLTF = async (binary) => {
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 => { track.name = mesh.uuid + track.name; });
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 ( gltf ) {
106
+ function (gltf) {
103
107
  resolve(gltf);
104
108
  },
105
- function ( error ) {
106
- console.error("Unable to export GLTF.", 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 };