mascot-vis 3.0.0 → 3.0.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/dist/mascot-esm.js +186 -0
- package/package.json +3 -6
- package/dist/mascot-es.js +0 -27745
- package/dist/mascot-min.js +0 -186
- package/dist/mascot-umd.js +0 -27781
- package/js/depGraphVis.js +0 -66
- package/src-new-ts/action/createElement.ts +0 -91
- package/src-new-ts/action/encode.js +0 -20
- package/src-new-ts/action/repeat.js +0 -128
- package/src-new-ts/action/traverseScene.js +0 -41
- package/src-new-ts/data/Network.js +0 -2
- package/src-new-ts/data/Scope.js +0 -135
- package/src-new-ts/data/Table.js +0 -263
- package/src-new-ts/data/Tree.js +0 -3
- package/src-new-ts/data/field.ts +0 -115
- package/src-new-ts/data/import.ts +0 -96
- package/src-new-ts/data/predicate.ts +0 -82
- package/src-new-ts/depgraph/DepGraph.js +0 -178
- package/src-new-ts/depgraph/Edge.js +0 -9
- package/src-new-ts/depgraph/SceneGraph2DepGraph.js +0 -110
- package/src-new-ts/depgraph/Signal.js +0 -12
- package/src-new-ts/depgraph/operator/BoundsEvaluator.js +0 -30
- package/src-new-ts/depgraph/operator/Dataflow.js +0 -41
- package/src-new-ts/depgraph/operator/DomainBuilder.js +0 -50
- package/src-new-ts/depgraph/updateDepGraph.js +0 -45
- package/src-new-ts/depgraph/variable/BoundsVar.js +0 -81
- package/src-new-ts/depgraph/variable/ChannelVar.js +0 -17
- package/src-new-ts/depgraph/variable/DataScopeVar.js +0 -12
- package/src-new-ts/depgraph/variable/DomainVar.js +0 -15
- package/src-new-ts/depgraph/variable/FieldVar.js +0 -17
- package/src-new-ts/depgraph/variable/LayoutParameter.js +0 -8
- package/src-new-ts/depgraph/variable/ScaleVar.js +0 -13
- package/src-new-ts/depgraph/variable/Variable.js +0 -39
- package/src-new-ts/element/gradient/LinearGradient.js +0 -37
- package/src-new-ts/element/group/Collection.js +0 -109
- package/src-new-ts/element/group/Group.js +0 -307
- package/src-new-ts/element/group/Scene.js +0 -98
- package/src-new-ts/element/mark/CircleMark.ts +0 -85
- package/src-new-ts/element/mark/Mark.ts +0 -233
- package/src-new-ts/element/mark/PathMark.js +0 -483
- package/src-new-ts/element/mark/Segment.js +0 -29
- package/src-new-ts/element/mark/Vertex.js +0 -118
- package/src-new-ts/encode/Scale.ts +0 -115
- package/src-new-ts/index.ts +0 -19
- package/src-new-ts/layout/Layout.ts +0 -3
- package/src-new-ts/render/CanvasRenderer.ts +0 -24
- package/src-new-ts/render/SVGRenderer.js +0 -316
- package/src-new-ts/util.ts +0 -3
- package/src-old/action/Classify.js +0 -53
- package/src-old/action/Densify.js +0 -199
- package/src-old/action/Partition.js +0 -531
- package/src-old/action/Repeat.js +0 -106
- package/src-old/action/Repopulate.js +0 -44
- package/src-old/action/Stratify.js +0 -156
- package/src-old/basic/Gradient.js +0 -37
- package/src-old/basic/Point.js +0 -51
- package/src-old/basic/Rectangle.js +0 -63
- package/src-old/bind/bindToAngle.js +0 -56
- package/src-old/bind/bindToAreaMark.js +0 -360
- package/src-old/bind/bindToColor.js +0 -114
- package/src-old/bind/bindToLink.js +0 -81
- package/src-old/bind/bindToPosition.js +0 -283
- package/src-old/bind/bindToRadialDistance.js +0 -62
- package/src-old/bind/bindToSize.js +0 -235
- package/src-old/bind/bindToText.js +0 -60
- package/src-old/bind/bindToThickness.js +0 -100
- package/src-old/constraint/AffixConstraint.js +0 -129
- package/src-old/constraint/AlignConstraint.js +0 -58
- package/src-old/core/Encoding.js +0 -336
- package/src-old/core/Scale.js +0 -322
- package/src-old/core/SceneLoader.js +0 -290
- package/src-old/core/SceneValidator.js +0 -232
- package/src-old/core/SpecExecutor.js +0 -113
- package/src-old/core/SpecGenerator.js +0 -350
- package/src-old/data/DataImporter.js +0 -64
- package/src-old/data/DataScope.js +0 -124
- package/src-old/data/DataTable.js +0 -338
- package/src-old/data/Network.js +0 -106
- package/src-old/data/Tree.js +0 -251
- package/src-old/data/transform/Bin.js +0 -46
- package/src-old/data/transform/Filter.js +0 -48
- package/src-old/data/transform/Groupby.js +0 -18
- package/src-old/data/transform/KDE.js +0 -58
- package/src-old/data/transform/Sort.js +0 -14
- package/src-old/data/transform/Split.js +0 -5
- package/src-old/data/transform/partition.js +0 -46
- package/src-old/history/UndoRedoStack +0 -0
- package/src-old/index.js +0 -271
- package/src-old/indexSVG.js +0 -259
- package/src-old/interaction/Interaction.js +0 -91
- package/src-old/interaction/MouseEvent.js +0 -8
- package/src-old/interaction/Selection.js +0 -9
- package/src-old/interaction/brush.js +0 -362
- package/src-old/item/Segment.js +0 -29
- package/src-old/item/Vertex.js +0 -118
- package/src-old/item/composite/Collection.js +0 -106
- package/src-old/item/composite/Glyph.js +0 -19
- package/src-old/item/composite/Group.js +0 -310
- package/src-old/item/composite/Scene.js +0 -1251
- package/src-old/item/mark/ArcPath.js +0 -181
- package/src-old/item/mark/AreaPath.js +0 -78
- package/src-old/item/mark/CirclePath.js +0 -102
- package/src-old/item/mark/EllipsePath.js +0 -5
- package/src-old/item/mark/Image.js +0 -101
- package/src-old/item/mark/LinkPath.js +0 -118
- package/src-old/item/mark/Mark.js +0 -163
- package/src-old/item/mark/Path.js +0 -494
- package/src-old/item/mark/PointText.js +0 -201
- package/src-old/item/mark/PolygonPath.js +0 -64
- package/src-old/item/mark/RectPath.js +0 -88
- package/src-old/item/mark/RingPath.js +0 -92
- package/src-old/item/refs/Axis.js +0 -362
- package/src-old/item/refs/EncodingAxis.js +0 -515
- package/src-old/item/refs/Gridlines.js +0 -144
- package/src-old/item/refs/LayoutAxis.js +0 -316
- package/src-old/item/refs/Legend.js +0 -273
- package/src-old/layout/Circular.js +0 -95
- package/src-old/layout/Force.js +0 -52
- package/src-old/layout/Grid.js +0 -423
- package/src-old/layout/Layout.js +0 -13
- package/src-old/layout/Packing.js +0 -56
- package/src-old/layout/Stack.js +0 -264
- package/src-old/layout/Strata.js +0 -88
- package/src-old/layout/Sugiyama.js +0 -59
- package/src-old/layout/TidyTree.js +0 -105
- package/src-old/layout/Treemap.js +0 -87
- package/src-old/renderer/SVGInteractionHandler.js +0 -241
- package/src-old/renderer/SVGRenderer.js +0 -325
- package/src-old/renderer/WebGLRenderer.js +0 -1097
- package/src-old/renderer/WebGLRenderer2.js +0 -249
- package/src-old/renderer/threejs/Line2.js +0 -18
- package/src-old/renderer/threejs/LineGeometry.js +0 -77
- package/src-old/renderer/threejs/LineMaterial.js +0 -605
- package/src-old/renderer/threejs/LineSegments2.js +0 -281
- package/src-old/renderer/threejs/LineSegmentsGeometry.js +0 -226
- package/src-old/renderer/threejs/Wireframe.js +0 -51
- package/src-old/renderer/threejs/WireframeGeometry2.js +0 -16
- package/src-old/scale/areaSize.js +0 -0
- package/src-old/scale/domain.js +0 -38
- package/src-old/util/Constants.js +0 -180
- package/src-old/util/DataUtil.js +0 -35
- package/src-old/util/ItemUtil.js +0 -586
- package/src-old/util/Numerical.js +0 -33
- package/tests/demo-tests/README.md +0 -80
- package/tests/demo-tests/SVG2PNG.js +0 -56
- package/tests/demo-tests/demos2CanvasPNGs.js +0 -69
- package/tests/demo-tests/demos2ScenesSVGs.js +0 -100
- package/tests/demo-tests/pathElementWorker.js +0 -91
- package/tests/demo-tests/pixelTest.js +0 -62
- package/tests/demo-tests/renderDemos.html +0 -132
- package/tests/demo-tests/serializationTest.js +0 -36
- package/tests/demo-tests/serializeDemos.html +0 -134
- package/tests/unit-tests/README.md +0 -4
- package/tests/unit-tests/jasmine-browser.json +0 -21
- package/tests/unit-tests/jasmine.json +0 -14
- package/tests/unit-tests/testSpec.js +0 -274
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
import * as THREE from 'three';
|
|
2
|
-
import LineSegmentsGeometry from './LineSegmentsGeometry';
|
|
3
|
-
import LineMaterial from './LineMaterial';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const _start = new THREE.Vector3();
|
|
7
|
-
|
|
8
|
-
const _end = new THREE.Vector3();
|
|
9
|
-
|
|
10
|
-
const _start4 = new THREE.Vector4();
|
|
11
|
-
|
|
12
|
-
const _end4 = new THREE.Vector4();
|
|
13
|
-
|
|
14
|
-
const _ssOrigin = new THREE.Vector4();
|
|
15
|
-
|
|
16
|
-
const _ssOrigin3 = new THREE.Vector3();
|
|
17
|
-
|
|
18
|
-
const _mvMatrix = new THREE.Matrix4();
|
|
19
|
-
|
|
20
|
-
const _line = new THREE.Line3();
|
|
21
|
-
|
|
22
|
-
const _closestPoint = new THREE.Vector3();
|
|
23
|
-
|
|
24
|
-
const _box = new THREE.Box3();
|
|
25
|
-
|
|
26
|
-
const _sphere = new THREE.Sphere();
|
|
27
|
-
|
|
28
|
-
const _clipToWorldVector = new THREE.Vector4();
|
|
29
|
-
|
|
30
|
-
export default class LineSegments2 extends THREE.Mesh {
|
|
31
|
-
|
|
32
|
-
constructor( geometry = new LineSegmentsGeometry(), material = new LineMaterial( {
|
|
33
|
-
color: Math.random() * 0xffffff
|
|
34
|
-
} ) ) {
|
|
35
|
-
|
|
36
|
-
super( geometry, material );
|
|
37
|
-
this.type = 'LineSegments2';
|
|
38
|
-
|
|
39
|
-
} // for backwards-compatability, but could be a method of THREE.LineSegmentsGeometry...
|
|
40
|
-
|
|
41
|
-
computeLineDistances() {
|
|
42
|
-
|
|
43
|
-
const geometry = this.geometry;
|
|
44
|
-
const instanceStart = geometry.attributes.instanceStart;
|
|
45
|
-
const instanceEnd = geometry.attributes.instanceEnd;
|
|
46
|
-
const lineDistances = new Float32Array( 2 * instanceStart.count );
|
|
47
|
-
|
|
48
|
-
for ( let i = 0, j = 0, l = instanceStart.count; i < l; i ++, j += 2 ) {
|
|
49
|
-
|
|
50
|
-
_start.fromBufferAttribute( instanceStart, i );
|
|
51
|
-
|
|
52
|
-
_end.fromBufferAttribute( instanceEnd, i );
|
|
53
|
-
|
|
54
|
-
lineDistances[ j ] = j === 0 ? 0 : lineDistances[ j - 1 ];
|
|
55
|
-
lineDistances[ j + 1 ] = lineDistances[ j ] + _start.distanceTo( _end );
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const instanceDistanceBuffer = new THREE.InstancedInterleavedBuffer( lineDistances, 2, 1 ); // d0, d1
|
|
60
|
-
|
|
61
|
-
geometry.setAttribute( 'instanceDistanceStart', new THREE.InterleavedBufferAttribute( instanceDistanceBuffer, 1, 0 ) ); // d0
|
|
62
|
-
|
|
63
|
-
geometry.setAttribute( 'instanceDistanceEnd', new THREE.InterleavedBufferAttribute( instanceDistanceBuffer, 1, 1 ) ); // d1
|
|
64
|
-
|
|
65
|
-
return this;
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
raycast( raycaster, intersects ) {
|
|
70
|
-
|
|
71
|
-
if ( raycaster.camera === null ) {
|
|
72
|
-
|
|
73
|
-
console.error( 'LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2.' );
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const threshold = raycaster.params.Line2 !== undefined ? raycaster.params.Line2.threshold || 0 : 0;
|
|
78
|
-
const ray = raycaster.ray;
|
|
79
|
-
const camera = raycaster.camera;
|
|
80
|
-
const projectionMatrix = camera.projectionMatrix;
|
|
81
|
-
const matrixWorld = this.matrixWorld;
|
|
82
|
-
const geometry = this.geometry;
|
|
83
|
-
const material = this.material;
|
|
84
|
-
const resolution = material.resolution;
|
|
85
|
-
const lineWidth = material.linewidth + threshold;
|
|
86
|
-
const instanceStart = geometry.attributes.instanceStart;
|
|
87
|
-
const instanceEnd = geometry.attributes.instanceEnd; // camera forward is negative
|
|
88
|
-
|
|
89
|
-
const near = - camera.near; // clip space is [ - 1, 1 ] so multiply by two to get the full
|
|
90
|
-
// width in clip space
|
|
91
|
-
|
|
92
|
-
const ssMaxWidth = 2.0 * Math.max( lineWidth / resolution.width, lineWidth / resolution.height ); //
|
|
93
|
-
// check if we intersect the sphere bounds
|
|
94
|
-
|
|
95
|
-
if ( geometry.boundingSphere === null ) {
|
|
96
|
-
|
|
97
|
-
geometry.computeBoundingSphere();
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
_sphere.copy( geometry.boundingSphere ).applyMatrix4( matrixWorld );
|
|
102
|
-
|
|
103
|
-
const distanceToSphere = Math.max( camera.near, _sphere.distanceToPoint( ray.origin ) ); // get the w component to scale the world space line width
|
|
104
|
-
|
|
105
|
-
_clipToWorldVector.set( 0, 0, - distanceToSphere, 1.0 ).applyMatrix4( camera.projectionMatrix );
|
|
106
|
-
|
|
107
|
-
_clipToWorldVector.multiplyScalar( 1.0 / _clipToWorldVector.w );
|
|
108
|
-
|
|
109
|
-
_clipToWorldVector.applyMatrix4( camera.projectionMatrixInverse ); // increase the sphere bounds by the worst case line screen space width
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
const sphereMargin = Math.abs( ssMaxWidth / _clipToWorldVector.w ) * 0.5;
|
|
113
|
-
_sphere.radius += sphereMargin;
|
|
114
|
-
|
|
115
|
-
if ( raycaster.ray.intersectsSphere( _sphere ) === false ) {
|
|
116
|
-
|
|
117
|
-
return;
|
|
118
|
-
|
|
119
|
-
} //
|
|
120
|
-
// check if we intersect the box bounds
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
if ( geometry.boundingBox === null ) {
|
|
124
|
-
|
|
125
|
-
geometry.computeBoundingBox();
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
_box.copy( geometry.boundingBox ).applyMatrix4( matrixWorld );
|
|
130
|
-
|
|
131
|
-
const distanceToBox = Math.max( camera.near, _box.distanceToPoint( ray.origin ) ); // get the w component to scale the world space line width
|
|
132
|
-
|
|
133
|
-
_clipToWorldVector.set( 0, 0, - distanceToBox, 1.0 ).applyMatrix4( camera.projectionMatrix );
|
|
134
|
-
|
|
135
|
-
_clipToWorldVector.multiplyScalar( 1.0 / _clipToWorldVector.w );
|
|
136
|
-
|
|
137
|
-
_clipToWorldVector.applyMatrix4( camera.projectionMatrixInverse ); // increase the sphere bounds by the worst case line screen space width
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
const boxMargin = Math.abs( ssMaxWidth / _clipToWorldVector.w ) * 0.5;
|
|
141
|
-
_box.max.x += boxMargin;
|
|
142
|
-
_box.max.y += boxMargin;
|
|
143
|
-
_box.max.z += boxMargin;
|
|
144
|
-
_box.min.x -= boxMargin;
|
|
145
|
-
_box.min.y -= boxMargin;
|
|
146
|
-
_box.min.z -= boxMargin;
|
|
147
|
-
|
|
148
|
-
if ( raycaster.ray.intersectsBox( _box ) === false ) {
|
|
149
|
-
|
|
150
|
-
return;
|
|
151
|
-
|
|
152
|
-
} //
|
|
153
|
-
// pick a point 1 unit out along the ray to avoid the ray origin
|
|
154
|
-
// sitting at the camera origin which will cause "w" to be 0 when
|
|
155
|
-
// applying the projection matrix.
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
ray.at( 1, _ssOrigin ); // ndc space [ - 1.0, 1.0 ]
|
|
159
|
-
|
|
160
|
-
_ssOrigin.w = 1;
|
|
161
|
-
|
|
162
|
-
_ssOrigin.applyMatrix4( camera.matrixWorldInverse );
|
|
163
|
-
|
|
164
|
-
_ssOrigin.applyMatrix4( projectionMatrix );
|
|
165
|
-
|
|
166
|
-
_ssOrigin.multiplyScalar( 1 / _ssOrigin.w ); // screen space
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
_ssOrigin.x *= resolution.x / 2;
|
|
170
|
-
_ssOrigin.y *= resolution.y / 2;
|
|
171
|
-
_ssOrigin.z = 0;
|
|
172
|
-
|
|
173
|
-
_ssOrigin3.copy( _ssOrigin );
|
|
174
|
-
|
|
175
|
-
_mvMatrix.multiplyMatrices( camera.matrixWorldInverse, matrixWorld );
|
|
176
|
-
|
|
177
|
-
for ( let i = 0, l = instanceStart.count; i < l; i ++ ) {
|
|
178
|
-
|
|
179
|
-
_start4.fromBufferAttribute( instanceStart, i );
|
|
180
|
-
|
|
181
|
-
_end4.fromBufferAttribute( instanceEnd, i );
|
|
182
|
-
|
|
183
|
-
_start4.w = 1;
|
|
184
|
-
_end4.w = 1; // camera space
|
|
185
|
-
|
|
186
|
-
_start4.applyMatrix4( _mvMatrix );
|
|
187
|
-
|
|
188
|
-
_end4.applyMatrix4( _mvMatrix ); // skip the segment if it's entirely behind the camera
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
var isBehindCameraNear = _start4.z > near && _end4.z > near;
|
|
192
|
-
|
|
193
|
-
if ( isBehindCameraNear ) {
|
|
194
|
-
|
|
195
|
-
continue;
|
|
196
|
-
|
|
197
|
-
} // trim the segment if it extends behind camera near
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
if ( _start4.z > near ) {
|
|
201
|
-
|
|
202
|
-
const deltaDist = _start4.z - _end4.z;
|
|
203
|
-
const t = ( _start4.z - near ) / deltaDist;
|
|
204
|
-
|
|
205
|
-
_start4.lerp( _end4, t );
|
|
206
|
-
|
|
207
|
-
} else if ( _end4.z > near ) {
|
|
208
|
-
|
|
209
|
-
const deltaDist = _end4.z - _start4.z;
|
|
210
|
-
const t = ( _end4.z - near ) / deltaDist;
|
|
211
|
-
|
|
212
|
-
_end4.lerp( _start4, t );
|
|
213
|
-
|
|
214
|
-
} // clip space
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
_start4.applyMatrix4( projectionMatrix );
|
|
218
|
-
|
|
219
|
-
_end4.applyMatrix4( projectionMatrix ); // ndc space [ - 1.0, 1.0 ]
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
_start4.multiplyScalar( 1 / _start4.w );
|
|
223
|
-
|
|
224
|
-
_end4.multiplyScalar( 1 / _end4.w ); // screen space
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
_start4.x *= resolution.x / 2;
|
|
228
|
-
_start4.y *= resolution.y / 2;
|
|
229
|
-
_end4.x *= resolution.x / 2;
|
|
230
|
-
_end4.y *= resolution.y / 2; // create 2d segment
|
|
231
|
-
|
|
232
|
-
_line.start.copy( _start4 );
|
|
233
|
-
|
|
234
|
-
_line.start.z = 0;
|
|
235
|
-
|
|
236
|
-
_line.end.copy( _end4 );
|
|
237
|
-
|
|
238
|
-
_line.end.z = 0; // get closest point on ray to segment
|
|
239
|
-
|
|
240
|
-
const param = _line.closestPointToPointParameter( _ssOrigin3, true );
|
|
241
|
-
|
|
242
|
-
_line.at( param, _closestPoint ); // check if the intersection point is within clip space
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
const zPos = THREE.MathUtils.lerp( _start4.z, _end4.z, param );
|
|
246
|
-
const isInClipSpace = zPos >= - 1 && zPos <= 1;
|
|
247
|
-
const isInside = _ssOrigin3.distanceTo( _closestPoint ) < lineWidth * 0.5;
|
|
248
|
-
|
|
249
|
-
if ( isInClipSpace && isInside ) {
|
|
250
|
-
|
|
251
|
-
_line.start.fromBufferAttribute( instanceStart, i );
|
|
252
|
-
|
|
253
|
-
_line.end.fromBufferAttribute( instanceEnd, i );
|
|
254
|
-
|
|
255
|
-
_line.start.applyMatrix4( matrixWorld );
|
|
256
|
-
|
|
257
|
-
_line.end.applyMatrix4( matrixWorld );
|
|
258
|
-
|
|
259
|
-
const pointOnLine = new THREE.Vector3();
|
|
260
|
-
const point = new THREE.Vector3();
|
|
261
|
-
ray.distanceSqToSegment( _line.start, _line.end, point, pointOnLine );
|
|
262
|
-
intersects.push( {
|
|
263
|
-
point: point,
|
|
264
|
-
pointOnLine: pointOnLine,
|
|
265
|
-
distance: ray.origin.distanceTo( point ),
|
|
266
|
-
object: this,
|
|
267
|
-
face: null,
|
|
268
|
-
faceIndex: i,
|
|
269
|
-
uv: null,
|
|
270
|
-
uv2: null
|
|
271
|
-
} );
|
|
272
|
-
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
LineSegments2.prototype.LineSegments2 = true;
|
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
import * as THREE from 'three';
|
|
2
|
-
|
|
3
|
-
const _box = new THREE.Box3();
|
|
4
|
-
|
|
5
|
-
const _vector = new THREE.Vector3();
|
|
6
|
-
|
|
7
|
-
export default class LineSegmentsGeometry extends THREE.InstancedBufferGeometry {
|
|
8
|
-
|
|
9
|
-
constructor() {
|
|
10
|
-
|
|
11
|
-
super();
|
|
12
|
-
this.type = 'LineSegmentsGeometry';
|
|
13
|
-
const positions = [ - 1, 2, 0, 1, 2, 0, - 1, 1, 0, 1, 1, 0, - 1, 0, 0, 1, 0, 0, - 1, - 1, 0, 1, - 1, 0 ];
|
|
14
|
-
const uvs = [ - 1, 2, 1, 2, - 1, 1, 1, 1, - 1, - 1, 1, - 1, - 1, - 2, 1, - 2 ];
|
|
15
|
-
const index = [ 0, 2, 1, 2, 3, 1, 2, 4, 3, 4, 5, 3, 4, 6, 5, 6, 7, 5 ];
|
|
16
|
-
this.setIndex( index );
|
|
17
|
-
this.setAttribute( 'position', new THREE.Float32BufferAttribute( positions, 3 ) );
|
|
18
|
-
this.setAttribute( 'uv', new THREE.Float32BufferAttribute( uvs, 2 ) );
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
applyMatrix4( matrix ) {
|
|
23
|
-
|
|
24
|
-
const start = this.attributes.instanceStart;
|
|
25
|
-
const end = this.attributes.instanceEnd;
|
|
26
|
-
|
|
27
|
-
if ( start !== undefined ) {
|
|
28
|
-
|
|
29
|
-
start.applyMatrix4( matrix );
|
|
30
|
-
end.applyMatrix4( matrix );
|
|
31
|
-
start.needsUpdate = true;
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if ( this.boundingBox !== null ) {
|
|
36
|
-
|
|
37
|
-
this.computeBoundingBox();
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if ( this.boundingSphere !== null ) {
|
|
42
|
-
|
|
43
|
-
this.computeBoundingSphere();
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return this;
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
setPositions( array ) {
|
|
52
|
-
|
|
53
|
-
let lineSegments;
|
|
54
|
-
|
|
55
|
-
if ( array instanceof Float32Array ) {
|
|
56
|
-
|
|
57
|
-
lineSegments = array;
|
|
58
|
-
|
|
59
|
-
} else if ( Array.isArray( array ) ) {
|
|
60
|
-
|
|
61
|
-
lineSegments = new Float32Array( array );
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const instanceBuffer = new THREE.InstancedInterleavedBuffer( lineSegments, 6, 1 ); // xyz, xyz
|
|
66
|
-
|
|
67
|
-
this.setAttribute( 'instanceStart', new THREE.InterleavedBufferAttribute( instanceBuffer, 3, 0 ) ); // xyz
|
|
68
|
-
|
|
69
|
-
this.setAttribute( 'instanceEnd', new THREE.InterleavedBufferAttribute( instanceBuffer, 3, 3 ) ); // xyz
|
|
70
|
-
//
|
|
71
|
-
|
|
72
|
-
this.computeBoundingBox();
|
|
73
|
-
this.computeBoundingSphere();
|
|
74
|
-
return this;
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
setColors( array ) {
|
|
79
|
-
|
|
80
|
-
let colors;
|
|
81
|
-
|
|
82
|
-
if ( array instanceof Float32Array ) {
|
|
83
|
-
|
|
84
|
-
colors = array;
|
|
85
|
-
|
|
86
|
-
} else if ( Array.isArray( array ) ) {
|
|
87
|
-
|
|
88
|
-
colors = new Float32Array( array );
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const instanceColorBuffer = new THREE.InstancedInterleavedBuffer( colors, 6, 1 ); // rgb, rgb
|
|
93
|
-
|
|
94
|
-
this.setAttribute( 'instanceColorStart', new THREE.InterleavedBufferAttribute( instanceColorBuffer, 3, 0 ) ); // rgb
|
|
95
|
-
|
|
96
|
-
this.setAttribute( 'instanceColorEnd', new THREE.InterleavedBufferAttribute( instanceColorBuffer, 3, 3 ) ); // rgb
|
|
97
|
-
|
|
98
|
-
return this;
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
fromWireframeGeometry( geometry ) {
|
|
103
|
-
|
|
104
|
-
this.setPositions( geometry.attributes.position.array );
|
|
105
|
-
return this;
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
fromEdgesGeometry( geometry ) {
|
|
110
|
-
|
|
111
|
-
this.setPositions( geometry.attributes.position.array );
|
|
112
|
-
return this;
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
fromMesh( mesh ) {
|
|
117
|
-
|
|
118
|
-
this.fromWireframeGeometry( new THREE.WireframeGeometry( mesh.geometry ) ); // set colors, maybe
|
|
119
|
-
|
|
120
|
-
return this;
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
fromLineSegments( lineSegments ) {
|
|
125
|
-
|
|
126
|
-
const geometry = lineSegments.geometry;
|
|
127
|
-
|
|
128
|
-
if ( geometry.isGeometry ) {
|
|
129
|
-
|
|
130
|
-
console.error( 'THREE.LineSegmentsGeometry no longer supports Geometry. Use THREE.BufferGeometry instead.' );
|
|
131
|
-
return;
|
|
132
|
-
|
|
133
|
-
} else if ( geometry.isBufferGeometry ) {
|
|
134
|
-
|
|
135
|
-
this.setPositions( geometry.attributes.position.array ); // assumes non-indexed
|
|
136
|
-
|
|
137
|
-
} // set colors, maybe
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
return this;
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
computeBoundingBox() {
|
|
145
|
-
|
|
146
|
-
if ( this.boundingBox === null ) {
|
|
147
|
-
|
|
148
|
-
this.boundingBox = new THREE.Box3();
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
const start = this.attributes.instanceStart;
|
|
153
|
-
const end = this.attributes.instanceEnd;
|
|
154
|
-
|
|
155
|
-
if ( start !== undefined && end !== undefined ) {
|
|
156
|
-
|
|
157
|
-
this.boundingBox.setFromBufferAttribute( start );
|
|
158
|
-
|
|
159
|
-
_box.setFromBufferAttribute( end );
|
|
160
|
-
|
|
161
|
-
this.boundingBox.union( _box );
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
computeBoundingSphere() {
|
|
168
|
-
|
|
169
|
-
if ( this.boundingSphere === null ) {
|
|
170
|
-
|
|
171
|
-
this.boundingSphere = new THREE.Sphere();
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
if ( this.boundingBox === null ) {
|
|
176
|
-
|
|
177
|
-
this.computeBoundingBox();
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
const start = this.attributes.instanceStart;
|
|
182
|
-
const end = this.attributes.instanceEnd;
|
|
183
|
-
|
|
184
|
-
if ( start !== undefined && end !== undefined ) {
|
|
185
|
-
|
|
186
|
-
const center = this.boundingSphere.center;
|
|
187
|
-
this.boundingBox.getCenter( center );
|
|
188
|
-
let maxRadiusSq = 0;
|
|
189
|
-
|
|
190
|
-
for ( let i = 0, il = start.count; i < il; i ++ ) {
|
|
191
|
-
|
|
192
|
-
_vector.fromBufferAttribute( start, i );
|
|
193
|
-
|
|
194
|
-
maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector ) );
|
|
195
|
-
|
|
196
|
-
_vector.fromBufferAttribute( end, i );
|
|
197
|
-
|
|
198
|
-
maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector ) );
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
this.boundingSphere.radius = Math.sqrt( maxRadiusSq );
|
|
203
|
-
|
|
204
|
-
if ( isNaN( this.boundingSphere.radius ) ) {
|
|
205
|
-
|
|
206
|
-
console.error( 'THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.', this );
|
|
207
|
-
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
toJSON() { // todo
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
applyMatrix( matrix ) {
|
|
218
|
-
|
|
219
|
-
console.warn( 'THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4().' );
|
|
220
|
-
return this.applyMatrix4( matrix );
|
|
221
|
-
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
LineSegmentsGeometry.prototype.isLineSegmentsGeometry = true;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import * as THREE from 'three';
|
|
2
|
-
import LineSegmentsGeometry from './LineSegmentsGeometry';
|
|
3
|
-
import LineMaterial from './LineMaterial';
|
|
4
|
-
|
|
5
|
-
const _start = new THREE.Vector3();
|
|
6
|
-
|
|
7
|
-
const _end = new THREE.Vector3();
|
|
8
|
-
|
|
9
|
-
export default class Wireframe extends THREE.Mesh {
|
|
10
|
-
|
|
11
|
-
constructor( geometry = new LineSegmentsGeometry(), material = new LineMaterial( {
|
|
12
|
-
color: Math.random() * 0xffffff
|
|
13
|
-
} ) ) {
|
|
14
|
-
|
|
15
|
-
super( geometry, material );
|
|
16
|
-
this.type = 'Wireframe';
|
|
17
|
-
|
|
18
|
-
} // for backwards-compatability, but could be a method of THREE.LineSegmentsGeometry...
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
computeLineDistances() {
|
|
22
|
-
|
|
23
|
-
const geometry = this.geometry;
|
|
24
|
-
const instanceStart = geometry.attributes.instanceStart;
|
|
25
|
-
const instanceEnd = geometry.attributes.instanceEnd;
|
|
26
|
-
const lineDistances = new Float32Array( 2 * instanceStart.count );
|
|
27
|
-
|
|
28
|
-
for ( let i = 0, j = 0, l = instanceStart.count; i < l; i ++, j += 2 ) {
|
|
29
|
-
|
|
30
|
-
_start.fromBufferAttribute( instanceStart, i );
|
|
31
|
-
|
|
32
|
-
_end.fromBufferAttribute( instanceEnd, i );
|
|
33
|
-
|
|
34
|
-
lineDistances[ j ] = j === 0 ? 0 : lineDistances[ j - 1 ];
|
|
35
|
-
lineDistances[ j + 1 ] = lineDistances[ j ] + _start.distanceTo( _end );
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const instanceDistanceBuffer = new THREE.InstancedInterleavedBuffer( lineDistances, 2, 1 ); // d0, d1
|
|
40
|
-
|
|
41
|
-
geometry.setAttribute( 'instanceDistanceStart', new THREE.InterleavedBufferAttribute( instanceDistanceBuffer, 1, 0 ) ); // d0
|
|
42
|
-
|
|
43
|
-
geometry.setAttribute( 'instanceDistanceEnd', new THREE.InterleavedBufferAttribute( instanceDistanceBuffer, 1, 1 ) ); // d1
|
|
44
|
-
|
|
45
|
-
return this;
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
Wireframe.prototype.isWireframe = true;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import * as THREE from 'three';
|
|
2
|
-
import LineSegmentsGeometry from './LineSegmentsGeometry';
|
|
3
|
-
|
|
4
|
-
export default class WireframeGeometry2 extends LineSegmentsGeometry {
|
|
5
|
-
|
|
6
|
-
constructor( geometry ) {
|
|
7
|
-
|
|
8
|
-
super();
|
|
9
|
-
this.type = 'WireframeGeometry2';
|
|
10
|
-
this.fromWireframeGeometry( new THREE.WireframeGeometry( geometry ) ); // set colors, maybe
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
WireframeGeometry2.prototype.isWireframeGeometry2 = true;
|
|
File without changes
|
package/src-old/scale/domain.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { DataType } from "../util/Constants";
|
|
2
|
-
|
|
3
|
-
export function scaleQuery(items, field, fieldType, aggregator) {
|
|
4
|
-
let data = [], itm = items[0];
|
|
5
|
-
let dataScopes = ((itm.type == "vertex" || itm.type == "segment") && !itm.dataScope) ?
|
|
6
|
-
items.map(d => d.parent.dataScope) : items.map(d => d.dataScope);
|
|
7
|
-
|
|
8
|
-
switch (fieldType) {
|
|
9
|
-
case DataType.Boolean:
|
|
10
|
-
break;
|
|
11
|
-
|
|
12
|
-
case DataType.Date:
|
|
13
|
-
data = dataScopes.map(d => d.getFieldValue(field));
|
|
14
|
-
break;
|
|
15
|
-
|
|
16
|
-
case DataType.String:
|
|
17
|
-
try {
|
|
18
|
-
data = dataScopes.map(d => d.getFieldValue(field));
|
|
19
|
-
} catch (error) {
|
|
20
|
-
throw new Error("Cannot bind to " + field + " : " + error);
|
|
21
|
-
}
|
|
22
|
-
break;
|
|
23
|
-
|
|
24
|
-
default: //integer or number
|
|
25
|
-
data = dataScopes.map(d => d.aggregateNumericalField(field, aggregator));
|
|
26
|
-
break;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return data;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function scaleDomain() {
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function scaleRange() {
|
|
37
|
-
|
|
38
|
-
}
|