@ccp-nc/crystvis-js 0.5.0 → 0.6.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 (179) hide show
  1. package/.github/dependabot.yml +69 -0
  2. package/.github/workflows/dependency-review.yml +91 -0
  3. package/.github/workflows/security-scan.yml +113 -0
  4. package/.github/workflows/test.yml +191 -0
  5. package/.github/workflows/update-dependencies.yml +214 -0
  6. package/CHANGELOG.md +36 -0
  7. package/LICENSE +0 -0
  8. package/README.html +0 -0
  9. package/README.md +5 -1
  10. package/audit.txt +37 -0
  11. package/changes.txt +27 -0
  12. package/docs/.nojekyll +0 -0
  13. package/docs/data/search.json +1 -0
  14. package/docs/fonts/Inconsolata-Regular.ttf +0 -0
  15. package/docs/fonts/OpenSans-Regular.ttf +0 -0
  16. package/docs/fonts/WorkSans-Bold.ttf +0 -0
  17. package/docs/index.html +10 -0
  18. package/docs/lib_model.module_js-AtomImage.html +3 -0
  19. package/docs/lib_model.module_js-BondImage.html +3 -0
  20. package/docs/lib_model.module_js-Model.html +3 -0
  21. package/docs/lib_model.module_js.html +3 -0
  22. package/docs/lib_modelview.module_js-ModelView.html +12 -0
  23. package/docs/lib_modelview.module_js.html +3 -0
  24. package/docs/lib_visualizer.module_js-CrystVis.html +3 -0
  25. package/docs/lib_visualizer.module_js.html +3 -0
  26. package/docs/model.js.html +2160 -0
  27. package/docs/modelview.js.html +449 -0
  28. package/docs/scripts/core.js +726 -0
  29. package/docs/scripts/core.min.js +23 -0
  30. package/docs/scripts/resize.js +90 -0
  31. package/docs/scripts/search.js +265 -0
  32. package/docs/scripts/search.min.js +6 -0
  33. package/docs/scripts/third-party/Apache-License-2.0.txt +202 -0
  34. package/docs/scripts/third-party/fuse.js +9 -0
  35. package/docs/scripts/third-party/hljs-line-num-original.js +369 -0
  36. package/docs/scripts/third-party/hljs-line-num.js +1 -0
  37. package/docs/scripts/third-party/hljs-original.js +5171 -0
  38. package/docs/scripts/third-party/hljs.js +1 -0
  39. package/docs/scripts/third-party/popper.js +5 -0
  40. package/docs/scripts/third-party/tippy.js +1 -0
  41. package/docs/scripts/third-party/tocbot.js +672 -0
  42. package/docs/scripts/third-party/tocbot.min.js +1 -0
  43. package/docs/styles/clean-jsdoc-theme-base.css +1159 -0
  44. package/docs/styles/clean-jsdoc-theme-dark.css +412 -0
  45. package/docs/styles/clean-jsdoc-theme-light.css +482 -0
  46. package/docs/styles/clean-jsdoc-theme-scrollbar.css +30 -0
  47. package/docs/styles/clean-jsdoc-theme-without-scrollbar.min.css +1 -0
  48. package/docs/styles/clean-jsdoc-theme.min.css +1 -0
  49. package/docs/tutorial-Events.html +13 -0
  50. package/docs/tutorial-Queries.html +16 -0
  51. package/docs/tutorial-ThreejsMigration.html +25 -0
  52. package/docs/visualizer.js.html +574 -0
  53. package/docs-tutorials/Events.md +0 -0
  54. package/docs-tutorials/Queries.md +0 -0
  55. package/docs-tutorials/ThreejsMigration.md +96 -0
  56. package/eslint.config.js +41 -0
  57. package/fonts/OpenSans/OFL.txt +0 -0
  58. package/fonts/OpenSans/OpenSans-Italic-VariableFont_wdth,wght.ttf +0 -0
  59. package/fonts/OpenSans/OpenSans-VariableFont_wdth,wght.ttf +0 -0
  60. package/fonts/OpenSans/README.txt +0 -0
  61. package/fonts/OpenSans/static/OpenSans/OpenSans-Bold.ttf +0 -0
  62. package/fonts/OpenSans/static/OpenSans/OpenSans-BoldItalic.ttf +0 -0
  63. package/fonts/OpenSans/static/OpenSans/OpenSans-ExtraBold.ttf +0 -0
  64. package/fonts/OpenSans/static/OpenSans/OpenSans-ExtraBoldItalic.ttf +0 -0
  65. package/fonts/OpenSans/static/OpenSans/OpenSans-Italic.ttf +0 -0
  66. package/fonts/OpenSans/static/OpenSans/OpenSans-Light.ttf +0 -0
  67. package/fonts/OpenSans/static/OpenSans/OpenSans-LightItalic.ttf +0 -0
  68. package/fonts/OpenSans/static/OpenSans/OpenSans-Medium.ttf +0 -0
  69. package/fonts/OpenSans/static/OpenSans/OpenSans-MediumItalic.ttf +0 -0
  70. package/fonts/OpenSans/static/OpenSans/OpenSans-Regular.ttf +0 -0
  71. package/fonts/OpenSans/static/OpenSans/OpenSans-SemiBold.ttf +0 -0
  72. package/fonts/OpenSans/static/OpenSans/OpenSans-SemiBoldItalic.ttf +0 -0
  73. package/fonts/OpenSans/static/OpenSans_Condensed/OpenSans_Condensed-Bold.ttf +0 -0
  74. package/fonts/OpenSans/static/OpenSans_Condensed/OpenSans_Condensed-BoldItalic.ttf +0 -0
  75. package/fonts/OpenSans/static/OpenSans_Condensed/OpenSans_Condensed-ExtraBold.ttf +0 -0
  76. package/fonts/OpenSans/static/OpenSans_Condensed/OpenSans_Condensed-ExtraBoldItalic.ttf +0 -0
  77. package/fonts/OpenSans/static/OpenSans_Condensed/OpenSans_Condensed-Italic.ttf +0 -0
  78. package/fonts/OpenSans/static/OpenSans_Condensed/OpenSans_Condensed-Light.ttf +0 -0
  79. package/fonts/OpenSans/static/OpenSans_Condensed/OpenSans_Condensed-LightItalic.ttf +0 -0
  80. package/fonts/OpenSans/static/OpenSans_Condensed/OpenSans_Condensed-Medium.ttf +0 -0
  81. package/fonts/OpenSans/static/OpenSans_Condensed/OpenSans_Condensed-MediumItalic.ttf +0 -0
  82. package/fonts/OpenSans/static/OpenSans_Condensed/OpenSans_Condensed-Regular.ttf +0 -0
  83. package/fonts/OpenSans/static/OpenSans_Condensed/OpenSans_Condensed-SemiBold.ttf +0 -0
  84. package/fonts/OpenSans/static/OpenSans_Condensed/OpenSans_Condensed-SemiBoldItalic.ttf +0 -0
  85. package/fonts/OpenSans/static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-Bold.ttf +0 -0
  86. package/fonts/OpenSans/static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-BoldItalic.ttf +0 -0
  87. package/fonts/OpenSans/static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-ExtraBold.ttf +0 -0
  88. package/fonts/OpenSans/static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-ExtraBoldItalic.ttf +0 -0
  89. package/fonts/OpenSans/static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-Italic.ttf +0 -0
  90. package/fonts/OpenSans/static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-Light.ttf +0 -0
  91. package/fonts/OpenSans/static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-LightItalic.ttf +0 -0
  92. package/fonts/OpenSans/static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-Medium.ttf +0 -0
  93. package/fonts/OpenSans/static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-MediumItalic.ttf +0 -0
  94. package/fonts/OpenSans/static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-Regular.ttf +0 -0
  95. package/fonts/OpenSans/static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-SemiBold.ttf +0 -0
  96. package/fonts/OpenSans/static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-SemiBoldItalic.ttf +0 -0
  97. package/fonts/Rubik/OFL.txt +0 -0
  98. package/fonts/Rubik/README.txt +0 -0
  99. package/fonts/Rubik/Rubik-Italic-VariableFont_wght.ttf +0 -0
  100. package/fonts/Rubik/Rubik-VariableFont_wght.ttf +0 -0
  101. package/fonts/Rubik/static/Rubik-Black.ttf +0 -0
  102. package/fonts/Rubik/static/Rubik-BlackItalic.ttf +0 -0
  103. package/fonts/Rubik/static/Rubik-Bold.ttf +0 -0
  104. package/fonts/Rubik/static/Rubik-BoldItalic.ttf +0 -0
  105. package/fonts/Rubik/static/Rubik-ExtraBold.ttf +0 -0
  106. package/fonts/Rubik/static/Rubik-ExtraBoldItalic.ttf +0 -0
  107. package/fonts/Rubik/static/Rubik-Italic.ttf +0 -0
  108. package/fonts/Rubik/static/Rubik-Light.ttf +0 -0
  109. package/fonts/Rubik/static/Rubik-LightItalic.ttf +0 -0
  110. package/fonts/Rubik/static/Rubik-Medium.ttf +0 -0
  111. package/fonts/Rubik/static/Rubik-MediumItalic.ttf +0 -0
  112. package/fonts/Rubik/static/Rubik-Regular.ttf +0 -0
  113. package/fonts/Rubik/static/Rubik-SemiBold.ttf +0 -0
  114. package/fonts/Rubik/static/Rubik-SemiBoldItalic.ttf +0 -0
  115. package/index.html +0 -0
  116. package/index.js +0 -0
  117. package/jsconf.json +0 -0
  118. package/lib/assets/fonts/bmpfonts.in.js +0 -0
  119. package/lib/assets/fonts/bmpfonts.js +0 -0
  120. package/lib/assets/fonts/font.js +33 -3
  121. package/lib/assets/fonts/index.js +0 -0
  122. package/lib/assets/fonts/threebmfont.js +2 -12
  123. package/lib/data.js +0 -0
  124. package/lib/formats/cell.js +0 -0
  125. package/lib/formats/cif.js +0 -0
  126. package/lib/formats/magres.js +0 -0
  127. package/lib/formats/xyz.js +149 -52
  128. package/lib/loader.js +28 -7
  129. package/lib/model.js +10 -3
  130. package/lib/modelview.js +30 -0
  131. package/lib/nmrdata.js +0 -0
  132. package/lib/orbit.js +77 -1
  133. package/lib/primitives/atoms.js +12 -7
  134. package/lib/primitives/cell.js +1 -1
  135. package/lib/primitives/dither.js +1 -1
  136. package/lib/primitives/ellipsoid.js +22 -8
  137. package/lib/primitives/geometries.js +3 -3
  138. package/lib/primitives/isosurface.js +2 -6
  139. package/lib/primitives/shapes.js +1 -1
  140. package/lib/primitives/sprites.js +9 -2
  141. package/lib/query.js +3 -28
  142. package/lib/render.js +40 -9
  143. package/lib/selbox.js +0 -0
  144. package/lib/shaders/aura.frag +0 -1
  145. package/lib/shaders/aura.vert +0 -1
  146. package/lib/shaders/dither.frag +0 -0
  147. package/lib/shaders/dither.vert +0 -0
  148. package/lib/shaders/index.in.js +0 -0
  149. package/lib/shaders/index.js +4 -4
  150. package/lib/shaders/msdf300.frag +0 -2
  151. package/lib/shaders/msdf300.vert +0 -2
  152. package/lib/tensor.js +0 -1
  153. package/lib/visualizer.js +5 -4
  154. package/outdated.txt +12 -0
  155. package/package.json +21 -22
  156. package/scripts/build-bundle.js +6 -2
  157. package/scripts/build-resources.js +0 -0
  158. package/scripts/plugins-shim.js +0 -0
  159. package/test/data/CHA.cif +0 -0
  160. package/test/data/H2O.xyz +0 -0
  161. package/test/data/H2_bound.xyz +0 -0
  162. package/test/data/bohr.cell +0 -0
  163. package/test/data/ethanol.cell +0 -0
  164. package/test/data/ethanol_with_tensors.xyz +33 -0
  165. package/test/data/example_single.cif +0 -0
  166. package/test/data/frac.cell +0 -0
  167. package/test/data/org.cif +0 -0
  168. package/test/data/pyridine.xyz +0 -0
  169. package/test/data/si8.xyz +0 -0
  170. package/test/loader.js +168 -8
  171. package/test/model.js +2 -4
  172. package/test/test-html/examples.js +0 -0
  173. package/test/test-html/index.html +0 -0
  174. package/tools/compile_colors.py +0 -0
  175. package/tools/compile_periodic.py +0 -0
  176. package/tools/ptable.json +0 -0
  177. package/tools/test +0 -0
  178. package/.eslintrc.json +0 -16
  179. package/.github/workflows/test-mocha.yml +0 -30
@@ -0,0 +1,96 @@
1
+ # Three.js Migration Notes
2
+
3
+ ## Upgrade from Three.js 0.137 to 0.178
4
+
5
+ With the release of version 0.6.0, `crystvis-js` has been updated to use Three.js 0.178 (from the previous version 0.137). This represents a significant upgrade with several important changes that developers should be aware of.
6
+
7
+ ### Key Changes
8
+
9
+ 1. **Color Management**:
10
+ - Three.js has changed how colors are handled between versions
11
+ - Colors are now handled in the sRGB color space by default with more strict enforcement
12
+ - Color methods like `getHex()` now return values in sRGB color space
13
+ - Use `renderer.outputColorSpace = THREE.SRGBColorSpace` (replaces older `outputEncoding = THREE.sRGBEncoding`)
14
+
15
+ 2. **Shader Compatibility**:
16
+ - GLSL shaders now require explicit version declarations through the `glslVersion` parameter
17
+ - When using `RawShaderMaterial` with GLSL 3.0, you must specify `glslVersion: THREE.GLSL3`
18
+ - The `#version` directive should not be included manually in the shader code when using `glslVersion`, as Three.js will inject it automatically
19
+ - Including your own `#version` directive will cause a duplication error
20
+
21
+ 3. **Material Properties**:
22
+ - Material property handling has been updated
23
+ - Use `.set()` method for colors instead of direct assignment with `new THREE.Color()`
24
+ - Direct assignment with `=` may not trigger internal updates properly anymore
25
+ - Some material properties may require different configuration for the same visual result
26
+
27
+ ### Texture Handling
28
+
29
+ If your application uses textures (e.g., from loaded models or images), they now require explicit color space declaration:
30
+
31
+ ```javascript
32
+ // Old approach (pre-0.6.0)
33
+ texture.encoding = THREE.sRGBEncoding;
34
+
35
+ // New approach (0.6.0+)
36
+ texture.colorSpace = THREE.SRGBColorSpace;
37
+ ```
38
+
39
+ ### Breaking Changes
40
+
41
+ If you're extending `crystvis-js` or using it in a custom way, be aware of these breaking changes:
42
+
43
+ 1. **Color Setting**:
44
+ ```javascript
45
+ // Old approach (pre-0.6.0)
46
+ material.color = new THREE.Color(hexValue);
47
+
48
+ // New approach (0.6.0+)
49
+ material.color.set(hexValue);
50
+ ```
51
+
52
+ 2. **Shader Usage**:
53
+ ```javascript
54
+ // Old approach (pre-0.6.0)
55
+ new THREE.RawShaderMaterial({
56
+ vertexShader: shader,
57
+ fragmentShader: shader
58
+ });
59
+
60
+ // New approach (0.6.0+)
61
+ new THREE.RawShaderMaterial({
62
+ vertexShader: shader,
63
+ fragmentShader: shader,
64
+ glslVersion: THREE.GLSL3 // For GLSL 3.0 shaders
65
+ });
66
+ ```
67
+
68
+ 3. **Renderer Configuration**:
69
+ - The default rendering equations have changed slightly
70
+ - Materials may appear different (usually more physically accurate but sometimes duller)
71
+ - Lighting and material properties may need adjustment for the same visual appearance
72
+ - Explicitly use `renderer.outputColorSpace = THREE.SRGBColorSpace` as the new API (post-r139)
73
+ - Physically correct lighting model updates may affect appearance
74
+ - The default values of `material.toneMapped` or lighting intensities might need tuning
75
+
76
+ ### Recommendations
77
+
78
+ If you're using `crystvis-js` as a dependency:
79
+ - Update your code to use `.set()` for color changes
80
+ - If you're extending the library with custom shaders, ensure you set `glslVersion` correctly
81
+ - Test your visualizations thoroughly after upgrading
82
+
83
+ If you're maintaining a fork:
84
+ - Review all color operations in your codebase
85
+ - Check all shader implementations for version directive issues
86
+ - Consider adjusting material parameters to maintain consistent appearance
87
+
88
+ ## Future Compatibility
89
+
90
+ We will continue to update Three.js dependencies in future releases. To minimize migration issues:
91
+
92
+ 1. Avoid direct Three.js class extensions where possible
93
+ 2. Use the provided APIs rather than accessing Three.js objects directly
94
+ 3. When using Three.js directly, follow their recommended practices for forward compatibility
95
+
96
+ For questions or issues related to this migration, please open an issue on the [GitHub repository](https://github.com/ccp-nc/crystvis-js/issues).
@@ -0,0 +1,41 @@
1
+ import js from '@eslint/js';
2
+ import globals from 'globals';
3
+
4
+ const cleanedBrowserGlobals = Object.fromEntries(
5
+ Object.entries(globals.browser).filter(([key]) => !key.match(/\s/))
6
+ );
7
+
8
+ export default [
9
+ {
10
+ ignores: ['node_modules/', 'demo/', 'test/test-html/'],
11
+ },
12
+ js.configs.recommended,
13
+ {
14
+ languageOptions: {
15
+ ecmaVersion: 2021,
16
+ sourceType: 'module',
17
+ globals: {
18
+ ...cleanedBrowserGlobals,
19
+ ...globals.node,
20
+ },
21
+ parserOptions: {
22
+ ecmaVersion: 2021,
23
+ sourceType: 'module',
24
+ },
25
+ },
26
+ rules: {
27
+ 'no-unused-vars': ['error', { args: 'none' }],
28
+ },
29
+ },
30
+ {
31
+ files: ['test/**/*.js'],
32
+ languageOptions: {
33
+ globals: {
34
+ ...globals.mocha,
35
+ },
36
+ },
37
+ rules: {
38
+ 'no-unused-vars': ['warn', { args: 'none' }],
39
+ },
40
+ },
41
+ ];
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/index.html CHANGED
File without changes
package/index.js CHANGED
File without changes
package/jsconf.json CHANGED
File without changes
File without changes
File without changes
@@ -4,6 +4,13 @@
4
4
  * @fileoverview Contains a BitmapFont class designed to load bitmap fonts and ready them for use
5
5
  */
6
6
 
7
+ // Alpha test threshold for text material transparency
8
+ const ALPHA_TEST_THRESHOLD = 0.01;
9
+
10
+ // Luminance boost configuration constants
11
+ const LUMINANCE_BOOST_FACTOR = 1.2;
12
+ const LUMINANCE_BOOST_MAX = 0.95;
13
+
7
14
  import _ from 'lodash';
8
15
  import {
9
16
  loadFont,
@@ -42,12 +49,31 @@ class BitmapFont {
42
49
  if (shift instanceof Array) {
43
50
  shift = new THREE.Vector3(shift[0], shift[1], shift[2]);
44
51
  }
52
+
53
+ // Handle color conversion more explicitly to avoid colorspace issues
54
+ let textColor;
55
+ if (typeof color === 'number') {
56
+ // Convert hex color properly to ensure correct representation
57
+ textColor = new THREE.Color();
58
+ // Convert the hex number to a properly formatted hex string
59
+ const hexString = '#' + ('000000' + color.toString(16)).slice(-6);
60
+ textColor.set(hexString);
61
+ } else if (color instanceof THREE.Color) {
62
+ textColor = color.clone();
63
+ } else {
64
+ textColor = new THREE.Color(color);
65
+ }
66
+
67
+ // Boost color brightness for better visibility
68
+ const hsl = textColor.getHSL({}); // getHSL returns an object with h, s, l
69
+ hsl.l = Math.min(hsl.l * LUMINANCE_BOOST_FACTOR, LUMINANCE_BOOST_MAX);
70
+ textColor.setHSL(hsl.h, hsl.s, hsl.l);
45
71
 
46
72
  return new THREE.RawShaderMaterial({
47
73
  uniforms: {
48
74
  opacity: new THREE.Uniform(opacity),
49
75
  map: new THREE.Uniform(texture),
50
- color: new THREE.Uniform(new THREE.Color(color)),
76
+ color: new THREE.Uniform(textColor),
51
77
  fixRotation: new THREE.Uniform(fixRotation),
52
78
  fixScale: new THREE.Uniform(fixScale),
53
79
  targScale: new THREE.Uniform(targScale),
@@ -57,9 +83,13 @@ class BitmapFont {
57
83
  transparent: true,
58
84
  vertexShader: Shaders.msdfVertShader,
59
85
  fragmentShader: Shaders.msdfFragShader,
60
- depthTest: depthTest
86
+ depthTest: depthTest,
87
+ depthWrite: false,
88
+ glslVersion: THREE.GLSL3,
89
+ blendSrc: THREE.SrcAlphaFactor,
90
+ blendDst: THREE.OneMinusSrcAlphaFactor,
91
+ alphaTest: ALPHA_TEST_THRESHOLD
61
92
  });
62
-
63
93
  }
64
94
 
65
95
  getTextGeometry(text, options = {}) {
File without changes
@@ -4,20 +4,10 @@
4
4
  // variables to make these packages work...
5
5
  // it's ugly but there's no way out, it seems.
6
6
 
7
- import * as THREE from 'three';
8
- import {
9
- Buffer
10
- } from 'buffer';
7
+ import loadFontRaw from 'load-bmfont';
11
8
 
12
9
  const loadFont = function(fntfile, callback) {
13
- var oldBuffer = globalThis.Buffer;
14
- globalThis.Buffer = Buffer;
15
-
16
- const loadFontRaw = require('load-bmfont');
17
- loadFontRaw(fntfile, (...args) => {
18
- callback.apply(this, args);
19
- globalThis.Buffer = oldBuffer;
20
- });
10
+ loadFontRaw(fntfile, callback);
21
11
  };
22
12
 
23
13
  import createGeometry from '@jkshenton/three-bmfont-text';
package/lib/data.js CHANGED
File without changes
File without changes
File without changes
File without changes