zincjs 1.0.13 → 1.0.15

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 (45) hide show
  1. package/build/zinc.frontend.js +1 -1
  2. package/build/zinc.js +43 -35
  3. package/build/zinc.js.map +1 -1
  4. package/package.json +3 -3
  5. package/src/assets/disc.png +0 -0
  6. package/src/assets/mapMarker.svg +11 -0
  7. package/src/controls.js +1594 -0
  8. package/src/geometryCSG.js +148 -0
  9. package/src/glyphsetCSG.js +84 -0
  10. package/src/loaders/GLTFToZincJSLoader.js +85 -0
  11. package/src/loaders/JSONLoader.js +697 -0
  12. package/src/loaders/OBJLoader.js +911 -0
  13. package/src/loaders/STLLoader.js +399 -0
  14. package/src/loaders/primitivesLoader.js +46 -0
  15. package/src/minimap.js +82 -0
  16. package/src/primitives/augmentShader.js +22 -0
  17. package/src/primitives/geometry.js +109 -0
  18. package/src/primitives/glyph.js +150 -0
  19. package/src/primitives/glyphset.js +657 -0
  20. package/src/primitives/label.js +51 -0
  21. package/src/primitives/lines.js +35 -0
  22. package/src/primitives/marker.js +88 -0
  23. package/src/primitives/pointset.js +53 -0
  24. package/src/primitives/texturePrimitive.js +16 -0
  25. package/src/primitives/textureSlides.js +118 -0
  26. package/src/primitives/zincObject.js +573 -0
  27. package/src/region.js +554 -0
  28. package/src/renderer.js +612 -0
  29. package/src/scene.js +963 -0
  30. package/src/sceneExporter.js +32 -0
  31. package/src/sceneLoader.js +842 -0
  32. package/src/texture/texture.js +57 -0
  33. package/src/texture/textureArray.js +85 -0
  34. package/src/three/GLTFExporter.js +2448 -0
  35. package/src/three/Geometry.js +2084 -0
  36. package/src/three/Loader.js +344 -0
  37. package/src/three/Points.js +223 -0
  38. package/src/three/line/Line.js +293 -0
  39. package/src/three/line/LineSegments.js +65 -0
  40. package/src/three-js-csg.js +564 -0
  41. package/src/utilities.js +321 -0
  42. package/src/videoHandler.js +92 -0
  43. package/src/workers/geometryCSG.worker.js +73 -0
  44. package/src/workers/geometryCSGInternal.js +58 -0
  45. package/src/zinc.js +38 -0
@@ -0,0 +1,293 @@
1
+ import {
2
+ BufferGeometry,
3
+ Float32BufferAttribute,
4
+ LineBasicMaterial,
5
+ Matrix4,
6
+ Object3D,
7
+ Ray,
8
+ Sphere,
9
+ Vector3
10
+ } from 'three';
11
+
12
+
13
+ const _start = /*@__PURE__*/ new Vector3();
14
+ const _end = /*@__PURE__*/ new Vector3();
15
+ const _inverseMatrix = /*@__PURE__*/ new Matrix4();
16
+ const _ray = /*@__PURE__*/ new Ray();
17
+ const _sphere = /*@__PURE__*/ new Sphere();
18
+ const _morphA = /*@__PURE__*/ new Vector3();
19
+ const _morphB = /*@__PURE__*/ new Vector3();
20
+ const _tempA = /*@__PURE__*/ new Vector3();
21
+ const _tempB = /*@__PURE__*/ new Vector3();
22
+
23
+ class Line extends Object3D {
24
+
25
+ constructor( geometry = new BufferGeometry(), material = new LineBasicMaterial() ) {
26
+
27
+ super();
28
+
29
+ this.type = 'Line';
30
+
31
+ this.geometry = geometry;
32
+ this.material = material;
33
+
34
+ this.updateMorphTargets();
35
+
36
+ }
37
+
38
+ copy( source ) {
39
+
40
+ super.copy( source );
41
+
42
+ this.material = source.material;
43
+ this.geometry = source.geometry;
44
+
45
+ return this;
46
+
47
+ }
48
+
49
+ computeLineDistances() {
50
+
51
+ const geometry = this.geometry;
52
+
53
+ if ( geometry.isBufferGeometry ) {
54
+
55
+ // we assume non-indexed geometry
56
+
57
+ if ( geometry.index === null ) {
58
+
59
+ const positionAttribute = geometry.attributes.position;
60
+ const lineDistances = [ 0 ];
61
+
62
+ for ( let i = 1, l = positionAttribute.count; i < l; i ++ ) {
63
+
64
+ _start.fromBufferAttribute( positionAttribute, i - 1 );
65
+ _end.fromBufferAttribute( positionAttribute, i );
66
+
67
+ lineDistances[ i ] = lineDistances[ i - 1 ];
68
+ lineDistances[ i ] += _start.distanceTo( _end );
69
+
70
+ }
71
+
72
+ geometry.setAttribute( 'lineDistance', new Float32BufferAttribute( lineDistances, 1 ) );
73
+
74
+ } else {
75
+
76
+ console.warn( 'THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.' );
77
+
78
+ }
79
+
80
+ } else if ( geometry.isGeometry ) {
81
+
82
+ console.error( 'THREE.Line.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.' );
83
+
84
+ }
85
+
86
+ return this;
87
+
88
+ }
89
+
90
+ raycast( raycaster, intersects ) {
91
+
92
+ const geometry = this.geometry;
93
+ const matrixWorld = this.matrixWorld;
94
+ const threshold = raycaster.params.Line.threshold;
95
+ const drawRange = geometry.drawRange;
96
+ const morphPosition = geometry.morphAttributes.position;
97
+
98
+ // Checking boundingSphere distance to ray
99
+
100
+ if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
101
+
102
+ _sphere.copy( geometry.boundingSphere );
103
+ _sphere.applyMatrix4( matrixWorld );
104
+ _sphere.radius += threshold;
105
+
106
+ if ( raycaster.ray.intersectsSphere( _sphere ) === false ) return;
107
+
108
+ //
109
+
110
+ _inverseMatrix.copy( matrixWorld ).invert();
111
+ _ray.copy( raycaster.ray ).applyMatrix4( _inverseMatrix );
112
+
113
+ const localThreshold = threshold / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 );
114
+ const localThresholdSq = localThreshold * localThreshold;
115
+
116
+ const vStart = new Vector3();
117
+ const vEnd = new Vector3();
118
+ const interSegment = new Vector3();
119
+ const interRay = new Vector3();
120
+ const step = this.isLineSegments ? 2 : 1;
121
+
122
+ if ( geometry.isBufferGeometry ) {
123
+
124
+ const index = geometry.index;
125
+ const attributes = geometry.attributes;
126
+ const positionAttribute = attributes.position;
127
+
128
+ if ( index !== null ) {
129
+
130
+ const start = Math.max( 0, drawRange.start );
131
+ const end = Math.min( index.count, ( drawRange.start + drawRange.count ) );
132
+
133
+ for ( let i = start, l = end - 1; i < l; i += step ) {
134
+
135
+ const a = index.getX( i );
136
+ const b = index.getX( i + 1 );
137
+
138
+ calculatePosition( vStart, vEnd, this, positionAttribute, morphPosition, a, b );
139
+
140
+ const distSq = _ray.distanceSqToSegment( vStart, vEnd, interRay, interSegment );
141
+
142
+ if ( distSq > localThresholdSq ) continue;
143
+
144
+ interRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation
145
+
146
+ const distance = raycaster.ray.origin.distanceTo( interRay );
147
+
148
+ if ( distance < raycaster.near || distance > raycaster.far ) continue;
149
+
150
+ intersects.push( {
151
+
152
+ distance: distance,
153
+ // What do we want? intersection point on the ray or on the segment??
154
+ // point: raycaster.ray.at( distance ),
155
+ point: interSegment.clone().applyMatrix4( this.matrixWorld ),
156
+ index: i,
157
+ face: null,
158
+ faceIndex: null,
159
+ object: this
160
+
161
+ } );
162
+
163
+ }
164
+
165
+ } else {
166
+
167
+ const start = Math.max( 0, drawRange.start );
168
+ const end = Math.min( positionAttribute.count, ( drawRange.start + drawRange.count ) );
169
+
170
+ for ( let i = start, l = end - 1; i < l; i += step ) {
171
+
172
+ calculatePosition( vStart, vEnd, this, positionAttribute, morphPosition, i, i+1 );
173
+
174
+ const distSq = _ray.distanceSqToSegment( vStart, vEnd, interRay, interSegment );
175
+
176
+ if ( distSq > localThresholdSq ) continue;
177
+
178
+ interRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation
179
+
180
+ const distance = raycaster.ray.origin.distanceTo( interRay );
181
+
182
+ if ( distance < raycaster.near || distance > raycaster.far ) continue;
183
+
184
+ intersects.push( {
185
+
186
+ distance: distance,
187
+ // What do we want? intersection point on the ray or on the segment??
188
+ // point: raycaster.ray.at( distance ),
189
+ point: interSegment.clone().applyMatrix4( this.matrixWorld ),
190
+ index: i,
191
+ face: null,
192
+ faceIndex: null,
193
+ object: this
194
+
195
+ } );
196
+
197
+ }
198
+
199
+ }
200
+
201
+ } else if ( geometry.isGeometry ) {
202
+
203
+ console.error( 'THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.' );
204
+
205
+ }
206
+
207
+ }
208
+
209
+ updateMorphTargets() {
210
+
211
+ const geometry = this.geometry;
212
+
213
+ if ( geometry.isBufferGeometry ) {
214
+
215
+ const morphAttributes = geometry.morphAttributes;
216
+ const keys = Object.keys( morphAttributes );
217
+
218
+ if ( keys.length > 0 ) {
219
+
220
+ const morphAttribute = morphAttributes[ keys[ 0 ] ];
221
+
222
+ if ( morphAttribute !== undefined ) {
223
+
224
+ this.morphTargetInfluences = [];
225
+ this.morphTargetDictionary = {};
226
+
227
+ for ( let m = 0, ml = morphAttribute.length; m < ml; m ++ ) {
228
+
229
+ const name = morphAttribute[ m ].name || String( m );
230
+
231
+ this.morphTargetInfluences.push( 0 );
232
+ this.morphTargetDictionary[ name ] = m;
233
+
234
+ }
235
+
236
+ }
237
+
238
+ }
239
+
240
+ } else {
241
+
242
+ const morphTargets = geometry.morphTargets;
243
+
244
+ if ( morphTargets !== undefined && morphTargets.length > 0 ) {
245
+
246
+ console.error( 'THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.' );
247
+
248
+ }
249
+
250
+ }
251
+
252
+ }
253
+
254
+ }
255
+
256
+ function calculatePosition( vStart, vEnd, object, position, morphPosition, a, b ) {
257
+
258
+ vStart.fromBufferAttribute( position, a );
259
+ vEnd.fromBufferAttribute( position, b );
260
+
261
+ var morphInfluences = object.morphTargetInfluences;
262
+
263
+ if ( object.material.morphTargets && morphPosition && morphInfluences ) {
264
+
265
+ _morphA.set( 0, 0, 0 );
266
+ _morphB.set( 0, 0, 0 );
267
+
268
+ for ( var i = 0, il = morphPosition.length; i < il; i ++ ) {
269
+
270
+ var influence = morphInfluences[ i ];
271
+ var morphAttribute = morphPosition[ i ];
272
+
273
+ if ( influence === 0 ) continue;
274
+
275
+ _tempA.fromBufferAttribute( morphAttribute, a );
276
+ _tempB.fromBufferAttribute( morphAttribute, b );
277
+
278
+ _morphA.addScaledVector( _tempA.sub( vStart ), influence );
279
+ _morphB.addScaledVector( _tempB.sub( vEnd ), influence );
280
+
281
+ }
282
+
283
+ vStart.add( _morphA );
284
+ vEnd.add( _morphB );
285
+
286
+ }
287
+
288
+ }
289
+
290
+ Line.prototype.isLine = true;
291
+
292
+
293
+ export { Line };
@@ -0,0 +1,65 @@
1
+ import { Line } from './Line.js';
2
+ import {
3
+ Float32BufferAttribute,
4
+ Vector3
5
+ } from 'three';
6
+
7
+ const _start = /*@__PURE__*/ new Vector3();
8
+ const _end = /*@__PURE__*/ new Vector3();
9
+
10
+ class LineSegments extends Line {
11
+
12
+ constructor( geometry, material ) {
13
+
14
+ super( geometry, material );
15
+
16
+ this.type = 'LineSegments';
17
+
18
+ }
19
+
20
+ computeLineDistances() {
21
+
22
+ const geometry = this.geometry;
23
+
24
+ if ( geometry.isBufferGeometry ) {
25
+
26
+ // we assume non-indexed geometry
27
+
28
+ if ( geometry.index === null ) {
29
+
30
+ const positionAttribute = geometry.attributes.position;
31
+ const lineDistances = [];
32
+
33
+ for ( let i = 0, l = positionAttribute.count; i < l; i += 2 ) {
34
+
35
+ _start.fromBufferAttribute( positionAttribute, i );
36
+ _end.fromBufferAttribute( positionAttribute, i + 1 );
37
+
38
+ lineDistances[ i ] = ( i === 0 ) ? 0 : lineDistances[ i - 1 ];
39
+ lineDistances[ i + 1 ] = lineDistances[ i ] + _start.distanceTo( _end );
40
+
41
+ }
42
+
43
+ geometry.setAttribute( 'lineDistance', new Float32BufferAttribute( lineDistances, 1 ) );
44
+
45
+ } else {
46
+
47
+ console.warn( 'THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.' );
48
+
49
+ }
50
+
51
+ } else if ( geometry.isGeometry ) {
52
+
53
+ console.error( 'THREE.LineSegments.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.' );
54
+
55
+ }
56
+
57
+ return this;
58
+
59
+ }
60
+
61
+ }
62
+
63
+ LineSegments.prototype.isLineSegments = true;
64
+
65
+ export { LineSegments };