zincjs 2.4.0 → 2.4.1-beta.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 +3 -486
- package/build/zinc.js.map +1 -1
- package/package.json +3 -4
- package/src/controls.js +1 -1
- package/src/geometryCSG.js +1 -1
- package/src/glyphsetCSG.js +1 -1
- package/src/loaders/GLTFToZincJSLoader.js +1 -1
- package/src/loaders/JSONLoader.js +204 -377
- package/src/loaders/OBJLoader.js +1 -1
- package/src/loaders/STLLoader.js +1 -1
- package/src/loaders/niftiReader.js +6 -4
- package/src/loaders/primitivesLoader.js +7 -9
- package/src/minimap.js +1 -1
- package/src/primitives/geometry.js +11 -29
- package/src/primitives/glyph.js +1 -1
- package/src/primitives/glyphset.js +2 -4
- package/src/primitives/label.js +1 -1
- package/src/primitives/lines.js +12 -5
- package/src/primitives/lines2.js +4 -8
- package/src/primitives/lod.js +9 -3
- package/src/primitives/marker.js +1 -1
- package/src/primitives/markerCluster.js +1 -1
- package/src/primitives/pointset.js +368 -52
- package/src/primitives/textureSlides.js +59 -16
- package/src/primitives/textureVolume.js +1 -1
- package/src/primitives/tubeLines.js +20 -3
- package/src/primitives/zincObject.js +13 -1
- package/src/region.js +1 -1
- package/src/renderer.js +17 -13
- package/src/scene.js +20 -8
- package/src/sceneLoader.js +1 -1
- package/src/shaders/rgbVolumeRender.js +1 -1
- package/src/shaders/textureSlide.js +1 -1
- package/src/texture/texture.js +1 -1
- package/src/texture/textureArray.js +9 -2
- package/src/three/GLTFExporter.js +55 -2
- package/src/three/InstancedPoints.js +73 -0
- package/src/three/Loader.js +1 -1
- package/src/three/line/Line.js +1 -1
- package/src/three/line/LineSegments.js +1 -1
- package/src/three/line/LineSegments2.js +24 -39
- package/src/three/line/LineSegmentsGeometry.js +1 -1
- package/src/tls/morphColorMaterial.js +65 -0
- package/src/tls/pointsMaterial.js +79 -0
- package/src/tls/textureSlides.js +126 -0
- package/src/utilities.js +47 -70
- package/src/videoHandler.js +1 -2
- package/src/workers/geometryCSG.worker.js +1 -1
- package/src/workers/geometryCSGInternal.js +1 -1
- package/src/zinc.js +1 -1
- package/vite.config.js +3 -1
- package/src/primitives/augmentShader.js +0 -45
- package/src/three/Geometry.js +0 -2176
- package/src/three/Points.js +0 -224
- package/src/three/line/LineMaterial.js +0 -726
package/src/loaders/OBJLoader.js
CHANGED
package/src/loaders/STLLoader.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as nifti from 'nifti-reader-js';
|
|
2
|
-
import * as THREE from 'three';
|
|
2
|
+
import * as THREE from 'three/webgpu';
|
|
3
3
|
import { TextureArray } from '../texture/textureArray';
|
|
4
4
|
import { TextureSlides } from '../primitives/textureSlides';
|
|
5
5
|
|
|
@@ -228,12 +228,13 @@ function getTransformationFromHeader(header, options) {
|
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
function createDataTexture(data, width, height, depth, isRGB) {
|
|
231
|
-
const dataTexture = new THREE.
|
|
231
|
+
const dataTexture = new THREE.Data3DTexture(
|
|
232
232
|
data, width, height, depth);
|
|
233
233
|
dataTexture.anisotropy = 4;
|
|
234
234
|
if (!isRGB) {
|
|
235
235
|
dataTexture.format = THREE.RedFormat;
|
|
236
236
|
}
|
|
237
|
+
dataTexture.colorSpace = THREE.SRGBColorSpace;
|
|
237
238
|
dataTexture.minFilter = THREE.NearestFilter;
|
|
238
239
|
dataTexture.magFilter = THREE.NearestFilter;
|
|
239
240
|
dataTexture.needsUpdate = true;
|
|
@@ -243,8 +244,9 @@ function createDataTexture(data, width, height, depth, isRGB) {
|
|
|
243
244
|
function createTextureArray(sources) {
|
|
244
245
|
if (sources?.data) {
|
|
245
246
|
const tArray = new TextureArray();
|
|
246
|
-
|
|
247
|
-
|
|
247
|
+
const dataTexutre = new createDataTexture(
|
|
248
|
+
sources.data, sources.width, sources.height, sources.depth);
|
|
249
|
+
tArray.setDataTexture(dataTexutre);
|
|
248
250
|
tArray.size = {
|
|
249
251
|
width: sources.width,
|
|
250
252
|
height: sources.height,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { JSONLoader } from './JSONLoader';
|
|
2
|
-
import
|
|
2
|
+
import { mergeGeometries as mergeBufferGeometries } from '../utilities';
|
|
3
|
+
import * as THREE from 'three/webgpu';
|
|
3
4
|
const FileLoader = THREE.FileLoader;
|
|
4
5
|
|
|
5
6
|
const mergeGlyphData = (glyphData) => {
|
|
@@ -30,16 +31,13 @@ const mergeGlyphData = (glyphData) => {
|
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
const mergeGeometries = (geometries) => {
|
|
33
|
-
const merge = (geometry1, geometry2) => {
|
|
34
|
-
geometry1.merge(geometry2);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
34
|
if (geometries && geometries.length > 0) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
merge(geometries[0], geometry2[0]);
|
|
35
|
+
if (geometries.length === 1) {
|
|
36
|
+
return geometries[0];
|
|
41
37
|
}
|
|
42
|
-
|
|
38
|
+
const merged = mergeBufferGeometries(geometries);
|
|
39
|
+
geometries.forEach((geometry) => geometry.dispose());
|
|
40
|
+
return merged;
|
|
43
41
|
}
|
|
44
42
|
return undefined;
|
|
45
43
|
}
|
package/src/minimap.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as THREE from 'three';
|
|
1
|
+
import * as THREE from 'three/webgpu';
|
|
2
2
|
import { toBufferGeometry } from '../utilities';
|
|
3
|
-
import {
|
|
3
|
+
import { applyMorphColorNode } from '../tls/morphColorMaterial';
|
|
4
4
|
import { ZincObject} from './zincObject';
|
|
5
5
|
|
|
6
6
|
const createMeshForGeometry = (geometryIn, materialIn, options) => {
|
|
@@ -24,10 +24,16 @@ const createMeshForGeometry = (geometryIn, materialIn, options) => {
|
|
|
24
24
|
side : THREE.DoubleSide
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
|
-
//material = PhongToToon(material);
|
|
28
27
|
if (options.localMorphColour && geometry.morphAttributes[ "color" ]) {
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
//Force vertexColors off (even if materialIn already had it true) -
|
|
29
|
+
//NodeMaterial would otherwise multiply our morph colour blend by
|
|
30
|
+
//the static, non-morph 'color' attribute (vertexColor() in
|
|
31
|
+
//setupDiffuseColor), which zeroes out whatever channel that static
|
|
32
|
+
//colour never needed (e.g. blue on an originally pure-red vertex),
|
|
33
|
+
//turning parts of the blend black instead of the intended hue.
|
|
34
|
+
//applyMorphColorNode's colorNode fully replaces vertex colouring.
|
|
35
|
+
material.vertexColors = false;
|
|
36
|
+
material = applyMorphColorNode(material);
|
|
31
37
|
}
|
|
32
38
|
} else {
|
|
33
39
|
let videoTexture = geometry._video.createCanvasVideoTexture();
|
|
@@ -79,30 +85,6 @@ const Geometry = function () {
|
|
|
79
85
|
this.setMesh(mesh, options.localTimeEnabled, options.localMorphColour);
|
|
80
86
|
}
|
|
81
87
|
|
|
82
|
-
/**
|
|
83
|
-
* Calculate the UV for texture rendering.
|
|
84
|
-
*/
|
|
85
|
-
this.calculateUVs = () => {
|
|
86
|
-
//Multilayers
|
|
87
|
-
this.geometry.computeBoundingBox();
|
|
88
|
-
const max = this.geometry.boundingBox.max, min = this.geometry.boundingBox.min;
|
|
89
|
-
const offset = new THREE.Vector2(0 - min.x, 0 - min.y);
|
|
90
|
-
const range = new THREE.Vector2(max.x - min.x, max.y - min.y);
|
|
91
|
-
this.geometry.faceVertexUvs[0] = [];
|
|
92
|
-
for (let i = 0; i < this.geometry.faces.length ; i++) {
|
|
93
|
-
const v1 = this.geometry.vertices[this.geometry.faces[i].a];
|
|
94
|
-
const v2 = this.geometry.vertices[this.geometry.faces[i].b];
|
|
95
|
-
const v3 = this.geometry.vertices[this.geometry.faces[i].c];
|
|
96
|
-
geometry.faceVertexUvs[0].push(
|
|
97
|
-
[
|
|
98
|
-
new THREE.Vector2((v1.x + offset.x)/range.x ,(v1.y + offset.y)/range.y),
|
|
99
|
-
new THREE.Vector2((v2.x + offset.x)/range.x ,(v2.y + offset.y)/range.y),
|
|
100
|
-
new THREE.Vector2((v3.x + offset.x)/range.x ,(v3.y + offset.y)/range.y)
|
|
101
|
-
]);
|
|
102
|
-
}
|
|
103
|
-
geometry.uvsNeedUpdate = true;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
88
|
/**
|
|
107
89
|
* Handle transparent mesh, create a clone for backside rendering if it is
|
|
108
90
|
* transparent.
|
package/src/primitives/glyph.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as THREE from 'three';
|
|
1
|
+
import * as THREE from 'three/webgpu';
|
|
2
2
|
import { Glyph } from './glyph';
|
|
3
3
|
import { ZincObject } from './zincObject';
|
|
4
4
|
import { JSONLoader } from '../loaders/JSONLoader';
|
|
@@ -521,11 +521,9 @@ const Glyphset = function () {
|
|
|
521
521
|
|
|
522
522
|
var meshloader = (finishCallback, displayLabels) => {
|
|
523
523
|
return (geometry, materials) => {
|
|
524
|
-
|
|
525
|
-
this.geometry.copy(tempGeometry);
|
|
524
|
+
this.geometry.copy(geometry);
|
|
526
525
|
this.geometry.computeBoundingSphere();
|
|
527
526
|
this.geometry.computeBoundingBox();
|
|
528
|
-
tempGeometry.dispose();
|
|
529
527
|
if (materials && materials[0])
|
|
530
528
|
this.morph.material = materials[0];
|
|
531
529
|
createGlyphs(displayLabels);
|
package/src/primitives/label.js
CHANGED
package/src/primitives/lines.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as THREE from 'three';
|
|
1
|
+
import * as THREE from 'three/webgpu';
|
|
2
2
|
import { toBufferGeometry } from '../utilities';
|
|
3
|
-
import {
|
|
3
|
+
import { applyMorphColorNode } from '../tls/morphColorMaterial';
|
|
4
4
|
import { LineSegments } from '../three/line/LineSegments';
|
|
5
5
|
import { ZincObject } from './zincObject';
|
|
6
6
|
|
|
@@ -30,10 +30,17 @@ const Lines = function () {
|
|
|
30
30
|
*/
|
|
31
31
|
this.createLineSegment = (geometryIn, materialIn, options) => {
|
|
32
32
|
if (geometryIn && materialIn) {
|
|
33
|
-
let geometry = toBufferGeometry(geometryIn, options);
|
|
33
|
+
let geometry = toBufferGeometry(geometryIn, options );
|
|
34
34
|
if (options.localMorphColour && geometry.morphAttributes[ "color" ]) {
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
//Force vertexColors off (even if the caller/material already set
|
|
36
|
+
//it true from the file's declared material) - NodeMaterial would
|
|
37
|
+
//otherwise multiply our morph colour blend by the static,
|
|
38
|
+
//non-morph 'color' attribute (vertexColor() in setupDiffuseColor),
|
|
39
|
+
//zeroing out whatever channel that static colour never needed and
|
|
40
|
+
//turning parts of the blend black instead of the intended hue.
|
|
41
|
+
//applyMorphColorNode's colorNode fully replaces vertex colouring.
|
|
42
|
+
materialIn.vertexColors = false;
|
|
43
|
+
materialIn = applyMorphColorNode(materialIn);
|
|
37
44
|
}
|
|
38
45
|
let line = new LineSegments(geometry, materialIn);
|
|
39
46
|
this.setMesh(line, options.localTimeEnabled, options.localMorphColour);
|
package/src/primitives/lines2.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import * as THREE from 'three';
|
|
1
|
+
import * as THREE from 'three/webgpu';
|
|
2
2
|
import { Lines } from './lines';
|
|
3
3
|
import { LineSegments2 } from '../three/line/LineSegments2';
|
|
4
|
-
import { LineMaterial } from '../three/line/LineMaterial';
|
|
4
|
+
//import { LineMaterial } from '../three/line/LineMaterial';
|
|
5
5
|
import { LineSegmentsGeometry } from '../three/line/LineSegmentsGeometry';
|
|
6
|
+
|
|
6
7
|
/**
|
|
7
8
|
* Provides an object which stores lines.
|
|
8
9
|
* This is created when a valid json file containing lines is read into a {@link Zinc.Scene}
|
|
@@ -157,13 +158,12 @@ const Lines2 = function () {
|
|
|
157
158
|
this.addVertices(coords);
|
|
158
159
|
let mesh = this.getMorph();
|
|
159
160
|
if (!mesh) {
|
|
160
|
-
const material = new
|
|
161
|
+
const material = new THREE.Line2NodeMaterial( {
|
|
161
162
|
color: colour,
|
|
162
163
|
linewidth:1,
|
|
163
164
|
vertexColors: false,
|
|
164
165
|
worldUnits: false,
|
|
165
166
|
});
|
|
166
|
-
material.resolution.set( window.innerWidth, window.innerHeight );
|
|
167
167
|
const options = { localTimeEnabled: false, localMorphColour: false};
|
|
168
168
|
this.createLineSegment(positions, material, options);
|
|
169
169
|
}
|
|
@@ -171,10 +171,6 @@ const Lines2 = function () {
|
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
this.render = (delta, playAnimation, cameraControls, options) => {
|
|
175
|
-
const material = this.getMorph().material;
|
|
176
|
-
material.resolution.set( window.innerWidth, window.innerHeight );
|
|
177
|
-
}
|
|
178
174
|
}
|
|
179
175
|
|
|
180
176
|
Lines2.prototype = Object.create(Lines.prototype);
|
package/src/primitives/lod.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as THREE from 'three';
|
|
1
|
+
import * as THREE from 'three/webgpu';
|
|
2
2
|
import { toBufferGeometry, updateMorphColorAttribute } from '../utilities';
|
|
3
3
|
import { LineSegments } from '../three/line/LineSegments';
|
|
4
4
|
|
|
@@ -216,6 +216,7 @@ const LOD = function (parent) {
|
|
|
216
216
|
const options = {
|
|
217
217
|
localTimeEnabled: this._parent.timeEnabled,
|
|
218
218
|
localMorphColour: this._parent.morphColour,
|
|
219
|
+
isLines: this._parent.isLines,
|
|
219
220
|
}
|
|
220
221
|
const geometry = toBufferGeometry(geometryIn, options);
|
|
221
222
|
let mesh = undefined;
|
|
@@ -234,8 +235,13 @@ const LOD = function (parent) {
|
|
|
234
235
|
this.updateMorphColorAttribute = (currentOnly) => {
|
|
235
236
|
//Multilayers - set all
|
|
236
237
|
if (this._material) {
|
|
237
|
-
|
|
238
|
-
|
|
238
|
+
//Gate on our own morphColorMix uniform rather than
|
|
239
|
+
//material.vertexColors - that flag is deliberately left false for
|
|
240
|
+
//morph colour materials now (see applyMorphColorNode's callers), so
|
|
241
|
+
//NodeMaterial doesn't multiply the blend by the static 'color'
|
|
242
|
+
//attribute on top of it.
|
|
243
|
+
if (this._material.userData && this._material.userData.uniforms &&
|
|
244
|
+
this._material.userData.uniforms.morphColorMix) {
|
|
239
245
|
if (currentOnly) {
|
|
240
246
|
const morph = this.getCurrentMorph();
|
|
241
247
|
updateMorphColorAttribute(morph.geometry, morph);
|
package/src/primitives/marker.js
CHANGED