zincjs 2.4.1-beta.0 → 2.4.1-beta.2
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 +2 -2
- package/build/zinc.js.map +1 -1
- package/package.json +4 -4
- package/src/loaders/JSONLoader.js +18 -0
- package/src/primitives/label.js +4 -0
- package/src/renderer.js +19 -4
- package/src/utilities.js +4 -0
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zincjs",
|
|
3
|
-
"version": "2.4.1-beta.
|
|
3
|
+
"version": "2.4.1-beta.2",
|
|
4
4
|
"description": "ZincJS (Web-based-Zinc-Visualisation)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "build/zinc.js",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": "^24.20.0"
|
|
9
|
+
},
|
|
7
10
|
"directories": {
|
|
8
11
|
"doc": "docs"
|
|
9
12
|
},
|
|
@@ -45,9 +48,6 @@
|
|
|
45
48
|
"url": "https://github.com/alan-wu/ZincJS/issues"
|
|
46
49
|
},
|
|
47
50
|
"homepage": "http://alan-wu.github.io/ZincJS/",
|
|
48
|
-
"engines": {
|
|
49
|
-
"node": "24.20.0"
|
|
50
|
-
},
|
|
51
51
|
"allowScripts": {
|
|
52
52
|
"msw@2.14.6": true
|
|
53
53
|
},
|
|
@@ -490,6 +490,24 @@ Object.assign( JSONLoader.prototype, {
|
|
|
490
490
|
|
|
491
491
|
geometry.morphAttributes.color = morphColorAttributes;
|
|
492
492
|
|
|
493
|
+
//Support cases where only morphColorAttributes is available
|
|
494
|
+
//without morphPositionAttributes
|
|
495
|
+
if ( geometry.morphAttributes.position === undefined ) {
|
|
496
|
+
|
|
497
|
+
const basePosition = geometry.getAttribute( 'position' );
|
|
498
|
+
|
|
499
|
+
geometry.morphAttributes.position = morphColorAttributes.map( ( colorAttribute ) => {
|
|
500
|
+
|
|
501
|
+
const positionAttribute = new BufferAttribute( basePosition.array, basePosition.itemSize );
|
|
502
|
+
|
|
503
|
+
positionAttribute.name = colorAttribute.name;
|
|
504
|
+
|
|
505
|
+
return positionAttribute;
|
|
506
|
+
|
|
507
|
+
} );
|
|
508
|
+
|
|
509
|
+
}
|
|
510
|
+
|
|
493
511
|
}
|
|
494
512
|
|
|
495
513
|
geometry.computeBoundingBox();
|
package/src/primitives/label.js
CHANGED
|
@@ -28,6 +28,10 @@ const Label = function (textIn, colourIn) {
|
|
|
28
28
|
sprite.fontFace = "Asap";
|
|
29
29
|
sprite.fontSize = 90;
|
|
30
30
|
sprite.fontWeight = fontWeight;
|
|
31
|
+
const canvasTexture = sprite.material.map; // Snag the canvas texture generated by the library
|
|
32
|
+
sprite.material = new THREE.SpriteNodeMaterial({
|
|
33
|
+
map: canvasTexture,
|
|
34
|
+
});
|
|
31
35
|
sprite.material.map.generateMipmaps = true;
|
|
32
36
|
sprite.material.map.anisotropy = 4;
|
|
33
37
|
sprite.material.minFilter = THREE.LinearMipmapLinearFilter; // Smooth downscaling
|
package/src/renderer.js
CHANGED
|
@@ -23,7 +23,7 @@ const Renderer = function (containerIn) {
|
|
|
23
23
|
let currentScene = undefined;
|
|
24
24
|
|
|
25
25
|
//myGezincGeometriestains a tuple of the threejs mesh, timeEnabled, morphColour flag, unique id and morph
|
|
26
|
-
const clock = new THREE.
|
|
26
|
+
const clock = new THREE.Timer();
|
|
27
27
|
this.playAnimation = true;
|
|
28
28
|
/* default animation update rate, rate is 1000 and duration
|
|
29
29
|
is default to 6000, 6s to finish a full animation */
|
|
@@ -131,7 +131,22 @@ const Renderer = function (containerIn) {
|
|
|
131
131
|
container = undefined;
|
|
132
132
|
canvas = parameters["canvas"];
|
|
133
133
|
}
|
|
134
|
-
//
|
|
134
|
+
//WebGPURenderer otherwise requests a device with the default
|
|
135
|
+
//maxTextureArrayLayers (256 on many adapters), which is too low for
|
|
136
|
+
//some currnetly sypported scaffold. We will request the highest possible
|
|
137
|
+
//on the device
|
|
138
|
+
if (parameters.device === undefined && parameters.requiredLimits === undefined &&
|
|
139
|
+
typeof navigator !== 'undefined' && navigator.gpu) {
|
|
140
|
+
try {
|
|
141
|
+
const adapter = await navigator.gpu.requestAdapter({ powerPreference: parameters.powerPreference });
|
|
142
|
+
if (adapter) {
|
|
143
|
+
parameters.requiredLimits = { maxTextureArrayLayers: adapter.limits.maxTextureArrayLayers };
|
|
144
|
+
}
|
|
145
|
+
} catch (err) {
|
|
146
|
+
//Fall through and let WebGPURenderer's own adapter/device request
|
|
147
|
+
//use its defaults.
|
|
148
|
+
}
|
|
149
|
+
}
|
|
135
150
|
renderer = new THREE.WebGPURenderer(parameters);
|
|
136
151
|
await renderer.init();
|
|
137
152
|
|
|
@@ -345,7 +360,6 @@ const Renderer = function (containerIn) {
|
|
|
345
360
|
*/
|
|
346
361
|
this.stopAnimate = () => {
|
|
347
362
|
if (isRendering) {
|
|
348
|
-
clock.stop();
|
|
349
363
|
isRendering = false;
|
|
350
364
|
}
|
|
351
365
|
}
|
|
@@ -355,7 +369,7 @@ const Renderer = function (containerIn) {
|
|
|
355
369
|
*/
|
|
356
370
|
this.animate = () => {
|
|
357
371
|
if (!isRendering) {
|
|
358
|
-
clock.
|
|
372
|
+
clock.reset();
|
|
359
373
|
isRendering = true;
|
|
360
374
|
runAnimation();
|
|
361
375
|
}
|
|
@@ -553,6 +567,7 @@ const Renderer = function (containerIn) {
|
|
|
553
567
|
sensor = new ResizeSensor(canvas, this.onWindowResize);
|
|
554
568
|
}
|
|
555
569
|
}
|
|
570
|
+
clock.update();
|
|
556
571
|
const delta = clock.getDelta();
|
|
557
572
|
currentScene.renderGeometries(playRate, delta, this.playAnimation);
|
|
558
573
|
for(let i = 0; i < additionalActiveScenes.length; i++) {
|
package/src/utilities.js
CHANGED
|
@@ -712,6 +712,10 @@ function createNewSpriteText(text, height, colour, font, pixel, weight) {
|
|
|
712
712
|
sprite.fontFace = font;
|
|
713
713
|
sprite.fontSize = pixel;
|
|
714
714
|
sprite.fontWeight = weight;
|
|
715
|
+
const canvasTexture = sprite.material.map; // Snag the canvas texture generated by the library
|
|
716
|
+
sprite.material = new THREE.SpriteNodeMaterial({
|
|
717
|
+
map: canvasTexture,
|
|
718
|
+
});
|
|
715
719
|
sprite.material.map.generateMipmaps = true;
|
|
716
720
|
sprite.material.map.anisotropy = 4;
|
|
717
721
|
sprite.material.sizeAttenuation = false;
|