zincjs 2.3.0 → 2.3.1-beta.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/build/zinc.js +268 -71
- package/build/zinc.js.map +1 -1
- package/package.json +2 -2
- package/src/loaders/niftiReader.js +1 -1
- package/src/minimap.js +2 -2
- package/src/primitives/augmentShader.js +39 -22
- package/src/primitives/geometry.js +24 -29
- package/src/primitives/glyphset.js +2 -2
- package/src/primitives/lines.js +4 -2
- package/src/primitives/marker.js +4 -5
- package/src/primitives/markerCluster.js +8 -8
- package/src/primitives/pointset.js +7 -2
- package/src/primitives/zincObject.js +0 -1
- package/src/region.js +0 -2
- package/src/renderer.js +6 -1
- package/src/scene.js +1 -3
- package/src/sceneLoader.js +10 -6
- package/src/texture/textureArray.js +1 -1
- package/src/three/Geometry.js +45 -34
- package/src/three/Loader.js +1 -0
- package/src/three/line/Line.js +2 -2
- package/src/three/line/LineMaterial.js +432 -212
- package/src/three/line/LineSegments2.js +299 -151
- package/src/three/line/LineSegmentsGeometry.js +68 -20
- package/src/utilities.js +63 -3
- package/src/videoHandler.js +4 -1
package/src/three/Geometry.js
CHANGED
|
@@ -13,6 +13,12 @@ import {
|
|
|
13
13
|
Vector2,
|
|
14
14
|
Vector3
|
|
15
15
|
} from 'three';
|
|
16
|
+
import {
|
|
17
|
+
copyColorsArray,
|
|
18
|
+
copyVector2sArray,
|
|
19
|
+
copyVector3sArray,
|
|
20
|
+
copyVector4sArray
|
|
21
|
+
} from "../utilities";
|
|
16
22
|
|
|
17
23
|
const _m1 = new Matrix4();
|
|
18
24
|
const _obj = new Object3D();
|
|
@@ -585,9 +591,9 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
|
|
|
585
591
|
this.morphTargets[i].normals = new Array( this.vertices.length );
|
|
586
592
|
|
|
587
593
|
for ( let v = 0; v < vertexNormals.length; v ++ ) {
|
|
588
|
-
|
|
594
|
+
|
|
589
595
|
this.morphTargets[i].normals[ v ] = vertexNormals[v].clone();
|
|
590
|
-
|
|
596
|
+
|
|
591
597
|
}
|
|
592
598
|
}
|
|
593
599
|
|
|
@@ -668,25 +674,25 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
|
|
|
668
674
|
for ( let k = 0, kl = morphTarget2.vertices.length; k < kl; k ++ ) {
|
|
669
675
|
|
|
670
676
|
const vertex = morphTarget2.vertices[ k ];
|
|
671
|
-
|
|
677
|
+
|
|
672
678
|
const vertexCopy = vertex.clone();
|
|
673
|
-
|
|
679
|
+
|
|
674
680
|
if ( matrix !== undefined ) vertexCopy.applyMatrix4( matrix );
|
|
675
|
-
|
|
681
|
+
|
|
676
682
|
morphTarget1.vertices.push( vertexCopy );
|
|
677
|
-
|
|
683
|
+
|
|
678
684
|
}
|
|
679
685
|
|
|
680
686
|
if ( morphTarget1.normals && morphTarget2.normals ) {
|
|
681
|
-
|
|
687
|
+
|
|
682
688
|
for ( let k = 0; k < morphTarget2.normals.length; k = k + 3) {
|
|
683
689
|
|
|
684
690
|
_temp.set(morphTarget2.normals2[k], morphTarget2.normals2[k + 1], morphTarget2.normals2[k + 2]);
|
|
685
|
-
|
|
691
|
+
|
|
686
692
|
if ( matrix !== undefined ) _temp.applyMatrix4( matrix );
|
|
687
|
-
|
|
693
|
+
|
|
688
694
|
morphTarget1.normals.push(_temp.x, _temp.y, _temp.z);
|
|
689
|
-
|
|
695
|
+
|
|
690
696
|
}
|
|
691
697
|
|
|
692
698
|
}
|
|
@@ -705,7 +711,7 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
|
|
|
705
711
|
for ( let k = 0, kl = morphColor2.colors; k < kl; k ++ ) {
|
|
706
712
|
|
|
707
713
|
morphColor1.colors.push( morphColor2.colors[ k ].clone() );
|
|
708
|
-
|
|
714
|
+
|
|
709
715
|
}
|
|
710
716
|
|
|
711
717
|
}
|
|
@@ -1519,33 +1525,33 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
|
|
|
1519
1525
|
const buffergeometry = new BufferGeometry();
|
|
1520
1526
|
|
|
1521
1527
|
const positions = new Float32Array( geometry.vertices.length * 3 );
|
|
1522
|
-
buffergeometry.setAttribute( 'position', new BufferAttribute( positions, 3 )
|
|
1528
|
+
buffergeometry.setAttribute( 'position', copyVector3sArray(new BufferAttribute( positions, 3 ), geometry.vertices ) );
|
|
1523
1529
|
|
|
1524
1530
|
if ( geometry.normals.length > 0 ) {
|
|
1525
1531
|
|
|
1526
1532
|
const normals = new Float32Array( geometry.normals.length * 3 );
|
|
1527
|
-
buffergeometry.setAttribute( 'normal', new BufferAttribute( normals, 3 )
|
|
1533
|
+
buffergeometry.setAttribute( 'normal', copyVector3sArray(new BufferAttribute( normals, 3 ), geometry.normals ) );
|
|
1528
1534
|
|
|
1529
1535
|
}
|
|
1530
1536
|
|
|
1531
1537
|
if ( geometry.colors.length > 0 ) {
|
|
1532
1538
|
|
|
1533
1539
|
const colors = new Float32Array( geometry.colors.length * 3 );
|
|
1534
|
-
buffergeometry.setAttribute( 'color', new BufferAttribute( colors, 3 )
|
|
1540
|
+
buffergeometry.setAttribute( 'color', copyVector3sArray(new BufferAttribute( colors, 3 ), geometry.colors ) );
|
|
1535
1541
|
|
|
1536
1542
|
}
|
|
1537
1543
|
|
|
1538
1544
|
if ( geometry.uvs.length > 0 ) {
|
|
1539
1545
|
|
|
1540
1546
|
const uvs = new Float32Array( geometry.uvs.length * 2 );
|
|
1541
|
-
buffergeometry.setAttribute( 'uv', new BufferAttribute( uvs, 2 )
|
|
1547
|
+
buffergeometry.setAttribute( 'uv', copyVector2sArray(new BufferAttribute( uvs, 2 ), geometry.uvs ) );
|
|
1542
1548
|
|
|
1543
1549
|
}
|
|
1544
1550
|
|
|
1545
1551
|
if ( geometry.uvs2.length > 0 ) {
|
|
1546
1552
|
|
|
1547
1553
|
const uvs2 = new Float32Array( geometry.uvs2.length * 2 );
|
|
1548
|
-
buffergeometry.setAttribute( 'uv2', new BufferAttribute( uvs2, 2 )
|
|
1554
|
+
buffergeometry.setAttribute( 'uv2', copyVector2sArray(new BufferAttribute( uvs2, 2 ), geometry.uvs2 ) );
|
|
1549
1555
|
|
|
1550
1556
|
}
|
|
1551
1557
|
|
|
@@ -1567,7 +1573,7 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
|
|
|
1567
1573
|
const attribute = new Float32BufferAttribute( morphTarget.data.length * 3, 3 );
|
|
1568
1574
|
attribute.name = morphTarget.name;
|
|
1569
1575
|
|
|
1570
|
-
array.push(
|
|
1576
|
+
array.push( copyVector3sArray(attribute, morphTarget.data ) );
|
|
1571
1577
|
|
|
1572
1578
|
}
|
|
1573
1579
|
|
|
@@ -1580,14 +1586,16 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
|
|
|
1580
1586
|
if ( geometry.skinIndices.length > 0 ) {
|
|
1581
1587
|
|
|
1582
1588
|
const skinIndices = new Float32BufferAttribute( geometry.skinIndices.length * 4, 4 );
|
|
1583
|
-
|
|
1589
|
+
copyVector4sArray(skinIndices, geometry.skinIndices);
|
|
1590
|
+
buffergeometry.setAttribute( 'skinIndex', skinIndices);
|
|
1584
1591
|
|
|
1585
1592
|
}
|
|
1586
1593
|
|
|
1587
1594
|
if ( geometry.skinWeights.length > 0 ) {
|
|
1588
1595
|
|
|
1589
1596
|
const skinWeights = new Float32BufferAttribute( geometry.skinWeights.length * 4, 4 );
|
|
1590
|
-
|
|
1597
|
+
copyVector4sArray(skinWeights, geometry.skinWeights);
|
|
1598
|
+
buffergeometry.setAttribute( 'skinWeight', skinWeights );
|
|
1591
1599
|
|
|
1592
1600
|
}
|
|
1593
1601
|
|
|
@@ -1616,7 +1624,7 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
|
|
|
1616
1624
|
const buffergeometry = new BufferGeometry();
|
|
1617
1625
|
|
|
1618
1626
|
const positions = new Float32Array( this.vertices.length * 3 );
|
|
1619
|
-
buffergeometry.setAttribute( 'position', new BufferAttribute( positions, 3 )
|
|
1627
|
+
buffergeometry.setAttribute( 'position', copyVector3sArray(new BufferAttribute( positions, 3 ), this.vertices ) );
|
|
1620
1628
|
|
|
1621
1629
|
if ( this.normals.length > 0 ) {
|
|
1622
1630
|
const normals = new Float32Array( this.normals.length );
|
|
@@ -1641,7 +1649,7 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
|
|
|
1641
1649
|
colorArray.push(new Color( this.colors[ i ] ));
|
|
1642
1650
|
}
|
|
1643
1651
|
const colors = new Float32Array( colorArray.length * 3 );
|
|
1644
|
-
buffergeometry.setAttribute( 'color', new BufferAttribute( colors, 3 )
|
|
1652
|
+
buffergeometry.setAttribute( 'color', copyColorsArray(new BufferAttribute( colors, 3 ), colorArray ) );
|
|
1645
1653
|
|
|
1646
1654
|
} else {
|
|
1647
1655
|
|
|
@@ -1650,7 +1658,7 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
|
|
|
1650
1658
|
colorsArray[i] = 1.0;
|
|
1651
1659
|
}
|
|
1652
1660
|
buffergeometry.setAttribute( 'color', new BufferAttribute( colorsArray, 3 ) );
|
|
1653
|
-
|
|
1661
|
+
|
|
1654
1662
|
}
|
|
1655
1663
|
|
|
1656
1664
|
if (this.faces.length > 0) {
|
|
@@ -1664,17 +1672,17 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
|
|
|
1664
1672
|
indices.push(this.faces[i].a, this.faces[i].b, this.faces[i].c);
|
|
1665
1673
|
|
|
1666
1674
|
const vertexColors = this.faces[i].vertexColors;
|
|
1667
|
-
|
|
1675
|
+
|
|
1668
1676
|
if ( vertexColors.length === 3 ) {
|
|
1669
|
-
|
|
1677
|
+
|
|
1670
1678
|
colors.push( vertexColors[ 0 ], vertexColors[ 1 ], vertexColors[ 2 ] );
|
|
1671
|
-
|
|
1679
|
+
|
|
1672
1680
|
} else {
|
|
1673
|
-
|
|
1681
|
+
|
|
1674
1682
|
const color = this.faces[i].color;
|
|
1675
|
-
|
|
1683
|
+
|
|
1676
1684
|
colors.push( color, color, color );
|
|
1677
|
-
|
|
1685
|
+
|
|
1678
1686
|
}
|
|
1679
1687
|
|
|
1680
1688
|
}
|
|
@@ -1683,7 +1691,7 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
|
|
|
1683
1691
|
|
|
1684
1692
|
// const colorsArray = new Float32Array( colors.length * 3 );
|
|
1685
1693
|
// buffergeometry.setAttribute( 'color', new BufferAttribute( colorsArray, 3 ).copyColorsArray( colors ) );
|
|
1686
|
-
|
|
1694
|
+
|
|
1687
1695
|
// }
|
|
1688
1696
|
|
|
1689
1697
|
buffergeometry.setIndex( indices );
|
|
@@ -1706,7 +1714,7 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
|
|
|
1706
1714
|
const attribute = new Float32BufferAttribute( morphTarget.vertices.length * 3, 3 );
|
|
1707
1715
|
attribute.name = morphTarget.name;
|
|
1708
1716
|
|
|
1709
|
-
array.push(
|
|
1717
|
+
array.push( copyVector3sArray(attribute, morphTarget.vertices ) );
|
|
1710
1718
|
|
|
1711
1719
|
if (morphTarget.normals) {
|
|
1712
1720
|
|
|
@@ -1714,8 +1722,8 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
|
|
|
1714
1722
|
const attribute = new Float32BufferAttribute( morphTarget.normals.length * 3, 3 );
|
|
1715
1723
|
attribute.name = morphTarget.name;
|
|
1716
1724
|
|
|
1717
|
-
normalsArray.push(
|
|
1718
|
-
|
|
1725
|
+
normalsArray.push( copyVector3sArray(attribute, morphTarget.normals ) );
|
|
1726
|
+
|
|
1719
1727
|
}
|
|
1720
1728
|
|
|
1721
1729
|
}
|
|
@@ -1795,10 +1803,13 @@ Geometry.createBufferGeometryFromObject = function ( object ) {
|
|
|
1795
1803
|
if ( object.isPoints || object.isLine ) {
|
|
1796
1804
|
|
|
1797
1805
|
const positions = new Float32BufferAttribute( geometry.vertices.length * 3, 3 );
|
|
1806
|
+
copyVector3sArray(positions, geometry.vertices );
|
|
1807
|
+
|
|
1798
1808
|
const colors = new Float32BufferAttribute( geometry.colors.length * 3, 3 );
|
|
1809
|
+
copyColorsArray(colors, geometry.colors);
|
|
1799
1810
|
|
|
1800
|
-
buffergeometry.setAttribute( 'position', positions
|
|
1801
|
-
buffergeometry.setAttribute( 'color', colors
|
|
1811
|
+
buffergeometry.setAttribute( 'position', positions );
|
|
1812
|
+
buffergeometry.setAttribute( 'color', colors );
|
|
1802
1813
|
|
|
1803
1814
|
if ( geometry.lineDistances && geometry.lineDistances.length === geometry.vertices.length ) {
|
|
1804
1815
|
|
package/src/three/Loader.js
CHANGED
package/src/three/line/Line.js
CHANGED
|
@@ -134,7 +134,7 @@ class Line extends Object3D {
|
|
|
134
134
|
|
|
135
135
|
const a = index.getX( i );
|
|
136
136
|
const b = index.getX( i + 1 );
|
|
137
|
-
|
|
137
|
+
|
|
138
138
|
calculatePosition( vStart, vEnd, this, positionAttribute, morphPosition, a, b );
|
|
139
139
|
|
|
140
140
|
const distSq = _ray.distanceSqToSegment( vStart, vEnd, interRay, interSegment );
|
|
@@ -260,7 +260,7 @@ function calculatePosition( vStart, vEnd, object, position, morphPosition, a, b
|
|
|
260
260
|
|
|
261
261
|
var morphInfluences = object.morphTargetInfluences;
|
|
262
262
|
|
|
263
|
-
if (
|
|
263
|
+
if ( morphPosition && morphInfluences ) {
|
|
264
264
|
|
|
265
265
|
_morphA.set( 0, 0, 0 );
|
|
266
266
|
_morphB.set( 0, 0, 0 );
|