zincjs 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/README.md +27 -22
- package/build/zinc.js +2 -2
- package/build/zinc.js.map +1 -1
- package/package.json +4 -1
- package/src/controls.js +1332 -1241
- package/src/geometryCSG.js +111 -115
- package/src/glyphsetCSG.js +51 -55
- package/src/loaders/GLTFToZincJSLoader.js +31 -33
- package/src/loaders/JSONLoader.js +339 -449
- package/src/loaders/OBJLoader.js +654 -851
- package/src/loaders/STLLoader.js +271 -329
- package/src/loaders/niftiReader.js +90 -59
- package/src/loaders/primitivesLoader.js +55 -52
- package/src/minimap.js +63 -43
- package/src/primitives/geometry.js +40 -44
- package/src/primitives/glyph.js +16 -19
- package/src/primitives/glyphset.js +229 -185
- package/src/primitives/label.js +29 -31
- package/src/primitives/lines.js +20 -20
- package/src/primitives/lines2.js +33 -39
- package/src/primitives/lod.js +43 -43
- package/src/primitives/marker.js +31 -32
- package/src/primitives/markerCluster.js +32 -35
- package/src/primitives/pointset.js +86 -83
- package/src/primitives/texturePrimitive.js +9 -10
- package/src/primitives/textureSlides.js +84 -97
- package/src/primitives/textureVolume.js +46 -49
- package/src/primitives/tubeLines.js +108 -108
- package/src/primitives/zincObject.js +176 -184
- package/src/region.js +145 -155
- package/src/renderRequests.js +3 -3
- package/src/renderer.js +649 -629
- package/src/scene.js +502 -430
- package/src/sceneExporter.js +22 -17
- package/src/sceneLoader.js +542 -296
- package/src/shaders/rgbVolumeRender.js +11 -18
- package/src/shaders/textureArray.js +5 -12
- package/src/shaders/textureSlide.js +10 -17
- package/src/shaders/volumeRender.js +11 -18
- package/src/shaders/volumeRender_old.js +11 -18
- package/src/shaders/volumeTexture.js +7 -14
- package/src/textSprite.js +23 -19
- package/src/texture/texture.js +14 -15
- package/src/texture/textureArray.js +14 -16
- package/src/three/InstancedPoints.js +2 -9
- package/src/three/Loader.js +334 -315
- package/src/three/line/Line.js +165 -215
- package/src/three/line/LineSegments.js +40 -55
- package/src/three/line/LineSegments2.js +322 -366
- package/src/three/line/LineSegmentsGeometry.js +239 -280
- package/src/three-js-csg.js +260 -252
- package/src/tsl/glyphRenderMaterial.js +12 -3
- package/src/tsl/glyphTransform.js +51 -29
- package/src/tsl/textureSlides.js +23 -24
- package/src/utilities.js +309 -371
- package/src/videoHandler.js +76 -83
- package/src/workers/geometryCSG.worker.js +33 -36
- package/src/workers/geometryCSGInternal.js +39 -44
- package/src/zinc.js +4 -7
- package/vite.config.js +7 -7
package/src/scene.js
CHANGED
|
@@ -10,24 +10,20 @@ import { SceneLoader } from './sceneLoader';
|
|
|
10
10
|
import { Viewport } from './controls';
|
|
11
11
|
import { createPointQuadGeometry } from './primitives/pointset';
|
|
12
12
|
import { createInstancedPointsMaterial } from './tsl/pointsMaterial';
|
|
13
|
-
import {
|
|
14
|
-
createBufferGeometry,
|
|
15
|
-
createNewSpriteText,
|
|
16
|
-
getCircularTexture
|
|
17
|
-
} from './utilities';
|
|
13
|
+
import { createBufferGeometry, createNewSpriteText, getCircularTexture } from './utilities';
|
|
18
14
|
|
|
19
15
|
let uniqueiId = 0;
|
|
20
16
|
|
|
21
17
|
const getUniqueId = function () {
|
|
22
|
-
return
|
|
23
|
-
}
|
|
18
|
+
return 'sc' + uniqueiId++;
|
|
19
|
+
};
|
|
24
20
|
|
|
25
|
-
const defaultMetadata = function() {
|
|
21
|
+
const defaultMetadata = function () {
|
|
26
22
|
return {
|
|
27
|
-
Duration:
|
|
28
|
-
OriginalDuration:
|
|
29
|
-
TimeStamps: {}
|
|
30
|
-
}
|
|
23
|
+
Duration: '6 secs',
|
|
24
|
+
OriginalDuration: '-',
|
|
25
|
+
TimeStamps: {},
|
|
26
|
+
};
|
|
31
27
|
};
|
|
32
28
|
|
|
33
29
|
const defaultDuration = 6000;
|
|
@@ -97,10 +93,10 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
97
93
|
y_offset: 16,
|
|
98
94
|
width: 128,
|
|
99
95
|
height: 128,
|
|
100
|
-
align:
|
|
101
|
-
updateRequired: true
|
|
96
|
+
align: 'top-right',
|
|
97
|
+
updateRequired: true,
|
|
102
98
|
};
|
|
103
|
-
let scissor = {x: 0,
|
|
99
|
+
let scissor = { x: 0, y: 0 };
|
|
104
100
|
let metadata = defaultMetadata();
|
|
105
101
|
let _markerTarget = new THREE.Vector2();
|
|
106
102
|
let pickableObjectsList = [];
|
|
@@ -112,26 +108,22 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
112
108
|
let axisDisplay = {
|
|
113
109
|
main: [],
|
|
114
110
|
mini: [],
|
|
115
|
-
}
|
|
116
|
-
const _v3 = new THREE.Vector3(
|
|
111
|
+
};
|
|
112
|
+
const _v3 = new THREE.Vector3(0, 0, 0);
|
|
117
113
|
|
|
118
114
|
const getDrawingWidth = () => {
|
|
119
115
|
if (container)
|
|
120
|
-
if (typeof container.clientWidth !==
|
|
121
|
-
|
|
122
|
-
else
|
|
123
|
-
return container.width;
|
|
116
|
+
if (typeof container.clientWidth !== 'undefined') return container.clientWidth;
|
|
117
|
+
else return container.width;
|
|
124
118
|
return 0;
|
|
125
|
-
}
|
|
119
|
+
};
|
|
126
120
|
|
|
127
121
|
const getDrawingHeight = () => {
|
|
128
122
|
if (container)
|
|
129
|
-
if (typeof container.clientHeight !==
|
|
130
|
-
|
|
131
|
-
else
|
|
132
|
-
return container.height;
|
|
123
|
+
if (typeof container.clientHeight !== 'undefined') return container.clientHeight;
|
|
124
|
+
else return container.height;
|
|
133
125
|
return 0;
|
|
134
|
-
}
|
|
126
|
+
};
|
|
135
127
|
|
|
136
128
|
/**
|
|
137
129
|
* This function returns a three component array, which contains
|
|
@@ -141,7 +133,7 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
141
133
|
*/
|
|
142
134
|
this.getDownloadProgress = () => {
|
|
143
135
|
return sceneLoader.getDownloadProgress();
|
|
144
|
-
}
|
|
136
|
+
};
|
|
145
137
|
|
|
146
138
|
//called from Renderer when panel has been resized
|
|
147
139
|
this.onWindowResize = () => {
|
|
@@ -152,7 +144,7 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
152
144
|
this.minimapScissor.updateRequired = true;
|
|
153
145
|
zincCameraControls.onResize();
|
|
154
146
|
zincCameraControls.calculateHeightPerPixelAtZeroDepth(wHeight);
|
|
155
|
-
}
|
|
147
|
+
};
|
|
156
148
|
|
|
157
149
|
/**
|
|
158
150
|
* Reset the viewport of this scene to its original state.
|
|
@@ -161,19 +153,24 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
161
153
|
needsRender = true;
|
|
162
154
|
this.onWindowResize();
|
|
163
155
|
zincCameraControls.resetView();
|
|
164
|
-
}
|
|
156
|
+
};
|
|
165
157
|
|
|
166
158
|
/**
|
|
167
159
|
* Set the zoom level by unit scroll rate
|
|
168
160
|
*/
|
|
169
|
-
this.changeZoomByScrollRateUnit = unit => {
|
|
161
|
+
this.changeZoomByScrollRateUnit = (unit) => {
|
|
170
162
|
needsRender = true;
|
|
171
163
|
zincCameraControls.changeZoomByScrollRateUnit(unit);
|
|
172
|
-
}
|
|
164
|
+
};
|
|
173
165
|
|
|
174
166
|
//Setup the camera for this scene, it also initialise the lighting
|
|
175
167
|
const setupCamera = () => {
|
|
176
|
-
this.camera = new THREE.PerspectiveCamera(
|
|
168
|
+
this.camera = new THREE.PerspectiveCamera(
|
|
169
|
+
40,
|
|
170
|
+
getDrawingWidth() / getDrawingHeight(),
|
|
171
|
+
0.0,
|
|
172
|
+
10.0,
|
|
173
|
+
);
|
|
177
174
|
this.ambient = new THREE.AmbientLight(0xffffff, 0.2);
|
|
178
175
|
scene.add(this.ambient);
|
|
179
176
|
|
|
@@ -195,13 +192,13 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
195
192
|
*
|
|
196
193
|
* @param {Zinc.Viewport} viewData - Viewport data to be loaded.
|
|
197
194
|
*/
|
|
198
|
-
this.loadView = settings => {
|
|
195
|
+
this.loadView = (settings) => {
|
|
199
196
|
needsRender = true;
|
|
200
197
|
const viewPort = new Viewport();
|
|
201
198
|
viewPort.setFromObject(settings);
|
|
202
199
|
zincCameraControls.setCurrentCameraSettings(viewPort);
|
|
203
200
|
return true;
|
|
204
|
-
}
|
|
201
|
+
};
|
|
205
202
|
|
|
206
203
|
/**
|
|
207
204
|
* Set up multiple views.
|
|
@@ -215,7 +212,7 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
215
212
|
zincCameraControls.addViewport(name, viewport);
|
|
216
213
|
}
|
|
217
214
|
zincCameraControls.setDefaultViewport(defaultView);
|
|
218
|
-
}
|
|
215
|
+
};
|
|
219
216
|
|
|
220
217
|
/**
|
|
221
218
|
* Get the bounding box of all the object in this scene only.
|
|
@@ -224,7 +221,7 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
224
221
|
*/
|
|
225
222
|
this.getBoundingBox = () => {
|
|
226
223
|
return rootRegion.getBoundingBox(true);
|
|
227
|
-
}
|
|
224
|
+
};
|
|
228
225
|
|
|
229
226
|
/**
|
|
230
227
|
* Adjust the viewport to display the desired volume provided by the bounding box.
|
|
@@ -232,7 +229,7 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
232
229
|
* @param {THREE.Box3} boundingBox - The bounding box which describes the volume of
|
|
233
230
|
* which we the viewport should be displaying.
|
|
234
231
|
*/
|
|
235
|
-
this.viewAllWithBoundingBox = boundingBox => {
|
|
232
|
+
this.viewAllWithBoundingBox = (boundingBox) => {
|
|
236
233
|
needsRender = true;
|
|
237
234
|
if (boundingBox) {
|
|
238
235
|
const viewport = zincCameraControls.getViewportFromBoundingBox(boundingBox, 1.0);
|
|
@@ -240,7 +237,7 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
240
237
|
zincCameraControls.calculateHeightPerPixelAtZeroDepth(getDrawingHeight());
|
|
241
238
|
markerCluster.markerUpdateRequired = true;
|
|
242
239
|
}
|
|
243
|
-
}
|
|
240
|
+
};
|
|
244
241
|
|
|
245
242
|
/**
|
|
246
243
|
* Adjust zoom distance to include all primitives in scene only.
|
|
@@ -250,7 +247,7 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
250
247
|
const boundingBox = this.getBoundingBox();
|
|
251
248
|
this.viewAllWithBoundingBox(boundingBox);
|
|
252
249
|
markerCluster.markerUpdateRequired = true;
|
|
253
|
-
}
|
|
250
|
+
};
|
|
254
251
|
|
|
255
252
|
/**
|
|
256
253
|
* A function which iterates through the list of geometries and call the callback
|
|
@@ -258,9 +255,9 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
258
255
|
* @param {Function} callbackFunction - Callback function with the geometry
|
|
259
256
|
* as an argument.
|
|
260
257
|
*/
|
|
261
|
-
this.forEachGeometry = callbackFunction => {
|
|
258
|
+
this.forEachGeometry = (callbackFunction) => {
|
|
262
259
|
rootRegion.forEachGeometry(callbackFunction, true);
|
|
263
|
-
}
|
|
260
|
+
};
|
|
264
261
|
|
|
265
262
|
/**
|
|
266
263
|
* A function which iterates through the list of glyphsets and call the callback
|
|
@@ -268,9 +265,9 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
268
265
|
* @param {Function} callbackFunction - Callback function with the glyphset
|
|
269
266
|
* as an argument.
|
|
270
267
|
*/
|
|
271
|
-
this.forEachGlyphset = callbackFunction => {
|
|
268
|
+
this.forEachGlyphset = (callbackFunction) => {
|
|
272
269
|
rootRegion.forEachGlyphset(callbackFunction, true);
|
|
273
|
-
}
|
|
270
|
+
};
|
|
274
271
|
|
|
275
272
|
/**
|
|
276
273
|
* A function which iterates through the list of pointsets and call the callback
|
|
@@ -278,19 +275,19 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
278
275
|
* @param {Function} callbackFunction - Callback function with the pointset
|
|
279
276
|
* as an argument.
|
|
280
277
|
*/
|
|
281
|
-
this.forEachPointset = callbackFunction => {
|
|
278
|
+
this.forEachPointset = (callbackFunction) => {
|
|
282
279
|
rootRegion.forEachPointset(callbackFunction, true);
|
|
283
|
-
}
|
|
280
|
+
};
|
|
284
281
|
|
|
285
282
|
/**
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
this.forEachLine = callbackFunction => {
|
|
283
|
+
* A function which iterates through the list of lines and call the callback
|
|
284
|
+
* function with the lines as the argument.
|
|
285
|
+
* @param {Function} callbackFunction - Callback function with the lines
|
|
286
|
+
* as an argument.
|
|
287
|
+
*/
|
|
288
|
+
this.forEachLine = (callbackFunction) => {
|
|
292
289
|
rootRegion.forEachLine(callbackFunction, true);
|
|
293
|
-
}
|
|
290
|
+
};
|
|
294
291
|
|
|
295
292
|
/**
|
|
296
293
|
* Find and return all geometries in this scene with the matching GroupName.
|
|
@@ -298,9 +295,9 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
298
295
|
* @param {String} GroupName - Groupname to match with.
|
|
299
296
|
* @returns {Array}
|
|
300
297
|
*/
|
|
301
|
-
this.findGeometriesWithGroupName = GroupName => {
|
|
298
|
+
this.findGeometriesWithGroupName = (GroupName) => {
|
|
302
299
|
return rootRegion.findGeometriesWithGroupName(GroupName, true);
|
|
303
|
-
}
|
|
300
|
+
};
|
|
304
301
|
|
|
305
302
|
/**
|
|
306
303
|
* Find and return all pointsets in this scene with the matching GroupName.
|
|
@@ -308,18 +305,18 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
308
305
|
* @param {String} GroupName - Groupname to match with.
|
|
309
306
|
* @returns {Array}
|
|
310
307
|
*/
|
|
311
|
-
this.findPointsetsWithGroupName = GroupName => {
|
|
308
|
+
this.findPointsetsWithGroupName = (GroupName) => {
|
|
312
309
|
return rootRegion.findPointsetsWithGroupName(GroupName, true);
|
|
313
|
-
}
|
|
310
|
+
};
|
|
314
311
|
/**
|
|
315
312
|
* Find and return all glyphsets in this scene with the matching GroupName.
|
|
316
313
|
*
|
|
317
314
|
* @param {String} GroupName - Groupname to match with.
|
|
318
315
|
* @returns {Array}
|
|
319
316
|
*/
|
|
320
|
-
this.findGlyphsetsWithGroupName = GroupName => {
|
|
317
|
+
this.findGlyphsetsWithGroupName = (GroupName) => {
|
|
321
318
|
return rootRegion.findGlyphsetsWithGroupName(GroupName, true);
|
|
322
|
-
}
|
|
319
|
+
};
|
|
323
320
|
|
|
324
321
|
/**
|
|
325
322
|
* Find and return all lines in this scene with the matching GroupName.
|
|
@@ -327,9 +324,9 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
327
324
|
* @param {String} GroupName - Groupname to match with.
|
|
328
325
|
* @returns {Array}
|
|
329
326
|
*/
|
|
330
|
-
this.findLinesWithGroupName = GroupName => {
|
|
327
|
+
this.findLinesWithGroupName = (GroupName) => {
|
|
331
328
|
return rootRegion.findLinesWithGroupName(GroupName, true);
|
|
332
|
-
}
|
|
329
|
+
};
|
|
333
330
|
|
|
334
331
|
/**
|
|
335
332
|
* Find a list of objects with the specified name, this will
|
|
@@ -339,13 +336,13 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
339
336
|
* @param {String} GroupName - Groupname to match with.
|
|
340
337
|
* @returns {Array}
|
|
341
338
|
*/
|
|
342
|
-
this.findObjectsWithGroupName = GroupName => {
|
|
339
|
+
this.findObjectsWithGroupName = (GroupName) => {
|
|
343
340
|
return rootRegion.findObjectsWithGroupName(GroupName, true);
|
|
344
|
-
}
|
|
341
|
+
};
|
|
345
342
|
|
|
346
|
-
this.findObjectsWithAnatomicalId = anatomicalId => {
|
|
343
|
+
this.findObjectsWithAnatomicalId = (anatomicalId) => {
|
|
347
344
|
return rootRegion.findObjectsWithAnatomicalId(anatomicalId, true);
|
|
348
|
-
}
|
|
345
|
+
};
|
|
349
346
|
|
|
350
347
|
/**
|
|
351
348
|
* Get the bounding box of all zinc objects in list.
|
|
@@ -353,19 +350,17 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
353
350
|
* @param {Array} objectsArray - Groupname to match with.
|
|
354
351
|
* @returns {THREE.Box3}
|
|
355
352
|
*/
|
|
356
|
-
this.getBoundingBoxOfZincObjects = objectsArray => {
|
|
353
|
+
this.getBoundingBoxOfZincObjects = (objectsArray) => {
|
|
357
354
|
let boundingBox = undefined;
|
|
358
355
|
for (let i = 0; i < objectsArray.length; i++) {
|
|
359
356
|
let box = objectsArray[i].getBoundingBox();
|
|
360
357
|
if (box) {
|
|
361
|
-
if (!boundingBox)
|
|
362
|
-
|
|
363
|
-
else
|
|
364
|
-
boundingBox.union(box);
|
|
358
|
+
if (!boundingBox) boundingBox = box;
|
|
359
|
+
else boundingBox.union(box);
|
|
365
360
|
}
|
|
366
361
|
}
|
|
367
362
|
return boundingBox;
|
|
368
|
-
}
|
|
363
|
+
};
|
|
369
364
|
|
|
370
365
|
/**
|
|
371
366
|
* Convert the vector3 into screen coordinates.
|
|
@@ -375,16 +370,16 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
375
370
|
* @param {Array} objectsArray - Groupname to match with.
|
|
376
371
|
* @returns {THREE.Vector3}
|
|
377
372
|
*/
|
|
378
|
-
this.vectorToScreenXY = point => {
|
|
373
|
+
this.vectorToScreenXY = (point) => {
|
|
379
374
|
point.project(this.camera);
|
|
380
375
|
let width = getDrawingWidth();
|
|
381
376
|
let height = getDrawingHeight();
|
|
382
|
-
let widthHalf =
|
|
383
|
-
let heightHalf =
|
|
384
|
-
point.x =
|
|
385
|
-
point.y = -
|
|
377
|
+
let widthHalf = width / 2;
|
|
378
|
+
let heightHalf = height / 2;
|
|
379
|
+
point.x = point.x * widthHalf + widthHalf;
|
|
380
|
+
point.y = -(point.y * heightHalf) + heightHalf;
|
|
386
381
|
return point;
|
|
387
|
-
}
|
|
382
|
+
};
|
|
388
383
|
|
|
389
384
|
/**
|
|
390
385
|
* Get the screen coordinate of the centroid of provided list of objects.
|
|
@@ -392,7 +387,7 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
392
387
|
* @param {Array} zincObjects - List of {@link ZincObject}.
|
|
393
388
|
* @returns {THREE.Vector3}
|
|
394
389
|
*/
|
|
395
|
-
this.getObjectsScreenXY = zincObjects => {
|
|
390
|
+
this.getObjectsScreenXY = (zincObjects) => {
|
|
396
391
|
if (zincObjects && zincObjects.length > 0) {
|
|
397
392
|
let boundingBox = this.getBoundingBoxOfZincObjects(zincObjects);
|
|
398
393
|
const center = new THREE.Vector3();
|
|
@@ -400,7 +395,7 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
400
395
|
return this.vectorToScreenXY(center);
|
|
401
396
|
}
|
|
402
397
|
return undefined;
|
|
403
|
-
}
|
|
398
|
+
};
|
|
404
399
|
|
|
405
400
|
/**
|
|
406
401
|
* Get the screen coordinate of the centroid of all objects
|
|
@@ -409,7 +404,7 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
409
404
|
* @param {String} name - List of {@link ZincObject}.
|
|
410
405
|
* @returns {THREE.Vector3}
|
|
411
406
|
*/
|
|
412
|
-
this.getNamedObjectsScreenXY = name => {
|
|
407
|
+
this.getNamedObjectsScreenXY = (name) => {
|
|
413
408
|
let zincObjects = this.findObjectsWithGroupName(name);
|
|
414
409
|
return this.getObjectsScreenXY(zincObjects);
|
|
415
410
|
};
|
|
@@ -420,14 +415,13 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
420
415
|
* @param {ZincObject} - zinc object ot be added.
|
|
421
416
|
* @returns {THREE.Vector3}
|
|
422
417
|
*/
|
|
423
|
-
this.addZincObject = zincObject => {
|
|
418
|
+
this.addZincObject = (zincObject) => {
|
|
424
419
|
needsRender = true;
|
|
425
420
|
if (zincObject) {
|
|
426
421
|
rootRegion.addZincObject(zincObject);
|
|
427
|
-
if (zincCameraControls)
|
|
428
|
-
zincCameraControls.calculateMaxAllowedDistance(this);
|
|
422
|
+
if (zincCameraControls) zincCameraControls.calculateMaxAllowedDistance(this);
|
|
429
423
|
}
|
|
430
|
-
}
|
|
424
|
+
};
|
|
431
425
|
|
|
432
426
|
/**
|
|
433
427
|
* Load a glyphset into this scene object.
|
|
@@ -441,7 +435,7 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
441
435
|
*/
|
|
442
436
|
this.loadGlyphsetURL = (metaurl, glyphurl, groupName, finishCallback) => {
|
|
443
437
|
sceneLoader.loadGlyphsetURL(rootRegion, metaurl, glyphurl, groupName, finishCallback);
|
|
444
|
-
}
|
|
438
|
+
};
|
|
445
439
|
|
|
446
440
|
/**
|
|
447
441
|
* Load a pointset into this scene object.
|
|
@@ -455,36 +449,43 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
455
449
|
* once the glyphset is succssfully load in.
|
|
456
450
|
*/
|
|
457
451
|
this.loadPointsetURL = (url, timeEnabled, morphColour, groupName, finishCallback) => {
|
|
458
|
-
sceneLoader.loadPointsetURL(
|
|
459
|
-
|
|
452
|
+
sceneLoader.loadPointsetURL(
|
|
453
|
+
rootRegion,
|
|
454
|
+
url,
|
|
455
|
+
timeEnabled,
|
|
456
|
+
morphColour,
|
|
457
|
+
groupName,
|
|
458
|
+
finishCallback,
|
|
459
|
+
);
|
|
460
|
+
};
|
|
460
461
|
|
|
461
462
|
/**
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
463
|
+
* Load lines into this scene object.
|
|
464
|
+
*
|
|
465
|
+
* @param {String} metaurl - Provide informations such as transformations, colours
|
|
466
|
+
* and others for each of the glyph in the glyphsset.
|
|
467
|
+
* @param {Boolean} timeEnabled - Indicate if morphing is enabled.
|
|
468
|
+
* @param {Boolean} morphColour - Indicate if color morphing is enabled.
|
|
469
|
+
* @param {STRING} groupName - name to assign the pointset's groupname to.
|
|
470
|
+
* @param {Function} finishCallback - Callback function which will be called
|
|
471
|
+
* once the glyphset is succssfully load in.
|
|
472
|
+
*/
|
|
472
473
|
this.loadLinesURL = (url, timeEnabled, morphColour, groupName, finishCallback) => {
|
|
473
474
|
sceneLoader.loadLinesURL(rootRegion, url, timeEnabled, morphColour, groupName, finishCallback);
|
|
474
|
-
}
|
|
475
|
+
};
|
|
475
476
|
|
|
476
477
|
/**
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
478
|
+
* Read a STL file into this scene, the geometry will be presented as
|
|
479
|
+
* {@link Zinc.Geometry}.
|
|
480
|
+
*
|
|
481
|
+
* @param {STRING} url - location to the STL file.
|
|
482
|
+
* @param {STRING} groupName - name to assign the geometry's groupname to.
|
|
483
|
+
* @param {Function} finishCallback - Callback function which will be called
|
|
484
|
+
* once the STL geometry is succssfully loaded.
|
|
485
|
+
*/
|
|
485
486
|
this.loadSTL = (url, groupName, finishCallback) => {
|
|
486
487
|
sceneLoader.loadSTL(rootRegion, url, groupName, finishCallback);
|
|
487
|
-
}
|
|
488
|
+
};
|
|
488
489
|
|
|
489
490
|
/**
|
|
490
491
|
* Read a OBJ file into this scene, the geometry will be presented as
|
|
@@ -497,7 +498,7 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
497
498
|
*/
|
|
498
499
|
this.loadOBJ = (url, groupName, finishCallback) => {
|
|
499
500
|
sceneLoader.loadOBJ(rootRegion, url, groupName, finishCallback);
|
|
500
|
-
}
|
|
501
|
+
};
|
|
501
502
|
|
|
502
503
|
/**
|
|
503
504
|
* Load a metadata file from the provided URL into this scene. Once
|
|
@@ -507,11 +508,11 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
507
508
|
* @param {Function} finishCallback - Callback function which will be called
|
|
508
509
|
* for each glyphset and geometry that has been written in.
|
|
509
510
|
* @param {options} Optional settings, it can be used to ignore some regions/groups
|
|
510
|
-
|
|
511
|
+
* in the metadata file. Only supports version 1 at this moment.
|
|
511
512
|
*/
|
|
512
513
|
this.loadMetadataURL = (url, finishCallback, allCompletedCallback, options) => {
|
|
513
514
|
sceneLoader.loadMetadataURL(rootRegion, url, finishCallback, allCompletedCallback, options);
|
|
514
|
-
}
|
|
515
|
+
};
|
|
515
516
|
|
|
516
517
|
/**
|
|
517
518
|
* Load a legacy model(s) format with the provided URLs and parameters. This only loads the geometry
|
|
@@ -520,16 +521,23 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
520
521
|
* @deprecated
|
|
521
522
|
*/
|
|
522
523
|
this.loadModelsURL = (urls, colours, opacities, timeEnabled, morphColour, finishCallback) => {
|
|
523
|
-
sceneLoader.loadModelsURL(
|
|
524
|
-
|
|
524
|
+
sceneLoader.loadModelsURL(
|
|
525
|
+
rootRegion.urls,
|
|
526
|
+
colours,
|
|
527
|
+
opacities,
|
|
528
|
+
timeEnabled,
|
|
529
|
+
morphColour,
|
|
530
|
+
finishCallback,
|
|
531
|
+
);
|
|
532
|
+
};
|
|
525
533
|
|
|
526
534
|
/**
|
|
527
535
|
* Load the viewport from an external location provided by the url.
|
|
528
536
|
* @param {String} URL - address to the file containing viewport information.
|
|
529
537
|
*/
|
|
530
|
-
this.loadViewURL = url => {
|
|
538
|
+
this.loadViewURL = (url) => {
|
|
531
539
|
sceneLoader.loadViewURL(url);
|
|
532
|
-
}
|
|
540
|
+
};
|
|
533
541
|
|
|
534
542
|
/**
|
|
535
543
|
* Load a legacy file format containing the viewport and its meta file from an external
|
|
@@ -541,38 +549,38 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
541
549
|
*/
|
|
542
550
|
this.loadFromViewURL = (jsonFilePrefix, finishCallback) => {
|
|
543
551
|
sceneLoader.loadFromViewURL(jsonFilePrefix, finishCallback);
|
|
544
|
-
}
|
|
552
|
+
};
|
|
545
553
|
|
|
546
554
|
/**
|
|
547
555
|
* Load GLTF into this scene object.
|
|
548
556
|
*/
|
|
549
557
|
this.loadGLTF = (url, finishCallback, allCompletedCallback, options) => {
|
|
550
558
|
sceneLoader.loadGLTF(rootRegion, url, finishCallback, allCompletedCallback, options);
|
|
551
|
-
}
|
|
559
|
+
};
|
|
552
560
|
|
|
553
561
|
//Update the directional light for this scene.
|
|
554
562
|
this.updateDirectionalLight = () => {
|
|
555
563
|
needsRender = true;
|
|
556
564
|
zincCameraControls.updateDirectionalLight();
|
|
557
|
-
}
|
|
565
|
+
};
|
|
558
566
|
|
|
559
567
|
/**
|
|
560
568
|
* Add any {THREE.Object} into this scene.
|
|
561
569
|
* @param {THREE.Object} object - to be addded into this scene.
|
|
562
570
|
*/
|
|
563
|
-
this.addObject = object => {
|
|
571
|
+
this.addObject = (object) => {
|
|
564
572
|
needsRender = true;
|
|
565
573
|
scene.add(object);
|
|
566
|
-
}
|
|
574
|
+
};
|
|
567
575
|
|
|
568
576
|
/**
|
|
569
577
|
* Remove any {THREE.Object} from this scene.
|
|
570
578
|
* @param {THREE.Object} object - to be removed from this scene.
|
|
571
579
|
*/
|
|
572
|
-
this.removeObject = object => {
|
|
580
|
+
this.removeObject = (object) => {
|
|
573
581
|
needsRender = true;
|
|
574
582
|
scene.remove(object);
|
|
575
|
-
}
|
|
583
|
+
};
|
|
576
584
|
|
|
577
585
|
/**
|
|
578
586
|
* Get the current time of the scene.
|
|
@@ -583,11 +591,10 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
583
591
|
return videoHandler.getCurrentTime(duration);
|
|
584
592
|
}
|
|
585
593
|
const time = rootRegion.getCurrentTime();
|
|
586
|
-
if (time !== -1)
|
|
587
|
-
return time;
|
|
594
|
+
if (time !== -1) return time;
|
|
588
595
|
|
|
589
596
|
return 0;
|
|
590
|
-
}
|
|
597
|
+
};
|
|
591
598
|
|
|
592
599
|
/**
|
|
593
600
|
* Set the current time of all the geometries and glyphsets of this scene.
|
|
@@ -599,7 +606,7 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
599
606
|
videoHandler.setMorphTime(time, duration);
|
|
600
607
|
}
|
|
601
608
|
rootRegion.setMorphTime(time, true);
|
|
602
|
-
}
|
|
609
|
+
};
|
|
603
610
|
|
|
604
611
|
/**
|
|
605
612
|
* Check if any object in this scene is time varying.
|
|
@@ -608,20 +615,34 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
608
615
|
*/
|
|
609
616
|
this.isTimeVarying = () => {
|
|
610
617
|
if (videoHandler && videoHandler.video && !videoHandler.video.error) {
|
|
611
|
-
|
|
618
|
+
return true;
|
|
612
619
|
}
|
|
613
620
|
return rootRegion.isTimeVarying();
|
|
614
|
-
}
|
|
621
|
+
};
|
|
615
622
|
|
|
616
623
|
/**
|
|
617
624
|
* Update geometries and glyphsets based on the calculated time.
|
|
618
625
|
* @private
|
|
619
626
|
*/
|
|
620
|
-
this.renderGeometries = (playRate, delta, playAnimation, sharedCamera) => {
|
|
627
|
+
this.renderGeometries = (playRate, delta, playAnimation, sharedCamera, forceUpdate) => {
|
|
621
628
|
//Anything requested since the last frame
|
|
622
629
|
let changed = needsRender;
|
|
623
630
|
needsRender = false;
|
|
624
631
|
cameraUpdated = false;
|
|
632
|
+
//These are plain properties, check if they have changed before
|
|
633
|
+
//the objects are updated so markers are toggled on this frame
|
|
634
|
+
if (
|
|
635
|
+
lastDisplayState.displayMarkers !== this.displayMarkers ||
|
|
636
|
+
lastDisplayState.displayMinimap !== this.displayMinimap ||
|
|
637
|
+
lastDisplayState.displayMiniAxes !== this.displayMiniAxes ||
|
|
638
|
+
lastDisplayState.playAnimation !== playAnimation
|
|
639
|
+
) {
|
|
640
|
+
lastDisplayState.displayMarkers = this.displayMarkers;
|
|
641
|
+
lastDisplayState.displayMinimap = this.displayMinimap;
|
|
642
|
+
lastDisplayState.displayMiniAxes = this.displayMiniAxes;
|
|
643
|
+
lastDisplayState.playAnimation = playAnimation;
|
|
644
|
+
changed = true;
|
|
645
|
+
}
|
|
625
646
|
//Additional active scenes are displayed with the current scene's camera
|
|
626
647
|
const cameraControls = sharedCamera ? sharedCamera.controls : zincCameraControls;
|
|
627
648
|
//Reused on every frame to avoid allocations
|
|
@@ -629,7 +650,7 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
629
650
|
options.camera = cameraControls;
|
|
630
651
|
//Global markers flag, marker can be set at individual zinc object level
|
|
631
652
|
//overriding this flag.
|
|
632
|
-
options.displayMarkers =
|
|
653
|
+
options.displayMarkers = this.displayMarkers;
|
|
633
654
|
options.markerCluster = markerCluster;
|
|
634
655
|
options.markersList = markerCluster.markers;
|
|
635
656
|
options.ndcToBeUpdated = sharedCamera ? sharedCamera.updated : false;
|
|
@@ -638,72 +659,71 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
638
659
|
if (playAnimation) {
|
|
639
660
|
options.markerCluster.markerUpdateRequired = true;
|
|
640
661
|
}
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
662
|
+
if (videoHandler) {
|
|
663
|
+
if (videoHandler.isReadyToPlay()) {
|
|
664
|
+
if (playAnimation) {
|
|
644
665
|
videoHandler.video.play();
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
const currentTime =
|
|
649
|
-
videoHandler.getVideoDuration() * duration;
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
666
|
+
} else {
|
|
667
|
+
videoHandler.video.pause();
|
|
668
|
+
}
|
|
669
|
+
const currentTime =
|
|
670
|
+
(videoHandler.video.currentTime / videoHandler.getVideoDuration()) * duration;
|
|
671
|
+
if (0 == sceneLoader.toBeDownloaded) {
|
|
672
|
+
if (!sharedCamera) {
|
|
673
|
+
zincCameraControls.setTime(currentTime);
|
|
674
|
+
options.ndcToBeUpdated = zincCameraControls.update(0);
|
|
654
675
|
if (options.ndcToBeUpdated) {
|
|
655
676
|
zincCameraControls.calculateHeightPerPixelAtZeroDepth(getDrawingHeight());
|
|
656
677
|
}
|
|
657
678
|
}
|
|
658
679
|
rootRegion.setMorphTime(currentTime, true);
|
|
659
680
|
rootRegion.renderGeometries(0, 0, playAnimation, cameraControls, options, true);
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
if (0 == sceneLoader.toBeDownloaded) {
|
|
681
|
+
} else if (!sharedCamera && zincCameraControls.update(0)) {
|
|
682
|
+
changed = true;
|
|
683
|
+
cameraUpdated = true;
|
|
684
|
+
}
|
|
685
|
+
//console.log(videoHandler.video.currentTime / videoHandler.getVideoDuration() * 6000);
|
|
686
|
+
}
|
|
687
|
+
//The video texture changes while playing or loading
|
|
688
|
+
if (playAnimation || !videoHandler.isReadyToPlay()) changed = true;
|
|
689
|
+
} else {
|
|
690
|
+
if (0 == sceneLoader.toBeDownloaded) {
|
|
671
691
|
if (!sharedCamera) {
|
|
672
692
|
options.ndcToBeUpdated = zincCameraControls.update(delta);
|
|
673
693
|
if (options.ndcToBeUpdated) {
|
|
674
694
|
zincCameraControls.calculateHeightPerPixelAtZeroDepth(getDrawingHeight());
|
|
675
695
|
}
|
|
676
696
|
}
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
697
|
+
//Walking every object is costly for large scenes, only do it when
|
|
698
|
+
//something may have changed, LOD and markers depend on the camera
|
|
699
|
+
if (
|
|
700
|
+
forceUpdate ||
|
|
701
|
+
changed ||
|
|
702
|
+
options.ndcToBeUpdated ||
|
|
703
|
+
playAnimation ||
|
|
704
|
+
//Clusters are recalculated during the walk
|
|
705
|
+
(markerCluster.isEnabled() && markerCluster.markerUpdateRequired)
|
|
706
|
+
) {
|
|
707
|
+
rootRegion.renderGeometries(playRate, delta, playAnimation, cameraControls, options, true);
|
|
708
|
+
}
|
|
709
|
+
} else if (!sharedCamera && zincCameraControls.update(0)) {
|
|
710
|
+
changed = true;
|
|
711
|
+
cameraUpdated = true;
|
|
712
|
+
}
|
|
693
713
|
}
|
|
694
714
|
//The flag is only cleared when the minimap is drawn
|
|
695
|
-
if (this.minimapScissor.updateRequired &&
|
|
696
|
-
(this.displayMinimap || this.displayMiniAxes)) {
|
|
715
|
+
if (this.minimapScissor.updateRequired && (this.displayMinimap || this.displayMiniAxes)) {
|
|
697
716
|
changed = true;
|
|
698
717
|
}
|
|
699
|
-
if (!sharedCamera && options.ndcToBeUpdated)
|
|
700
|
-
|
|
701
|
-
|
|
718
|
+
if (!sharedCamera && options.ndcToBeUpdated) cameraUpdated = true;
|
|
719
|
+
if (
|
|
720
|
+
options.ndcToBeUpdated ||
|
|
702
721
|
(playAnimation && this.isTimeVarying()) ||
|
|
703
722
|
//Objects appear as they are loaded
|
|
704
723
|
sceneLoader.toBeDownloaded > 0 ||
|
|
705
724
|
//Clusters are recalculated on a later frame
|
|
706
|
-
(markerCluster.isEnabled() && markerCluster.markerUpdateRequired)
|
|
725
|
+
(markerCluster.isEnabled() && markerCluster.markerUpdateRequired)
|
|
726
|
+
) {
|
|
707
727
|
changed = true;
|
|
708
728
|
}
|
|
709
729
|
//Changes made during this frame, e.g. LOD switching
|
|
@@ -712,7 +732,7 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
712
732
|
needsRender = false;
|
|
713
733
|
}
|
|
714
734
|
return changed;
|
|
715
|
-
}
|
|
735
|
+
};
|
|
716
736
|
|
|
717
737
|
/**
|
|
718
738
|
* Request this scene to be drawn on the next frame, this is only
|
|
@@ -721,7 +741,7 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
721
741
|
*/
|
|
722
742
|
this.invalidate = () => {
|
|
723
743
|
needsRender = true;
|
|
724
|
-
}
|
|
744
|
+
};
|
|
725
745
|
|
|
726
746
|
/**
|
|
727
747
|
* Check if the camera of this scene has been updated during the last
|
|
@@ -732,7 +752,7 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
732
752
|
*/
|
|
733
753
|
this.isCameraUpdated = () => {
|
|
734
754
|
return cameraUpdated;
|
|
735
|
-
}
|
|
755
|
+
};
|
|
736
756
|
|
|
737
757
|
/**
|
|
738
758
|
* Return the internal {THREE.Scene}.
|
|
@@ -740,67 +760,78 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
740
760
|
*/
|
|
741
761
|
this.getThreeJSScene = () => {
|
|
742
762
|
return scene;
|
|
743
|
-
}
|
|
763
|
+
};
|
|
744
764
|
|
|
745
765
|
this.setVideoHandler = (videoHandlerIn) => {
|
|
746
766
|
needsRender = true;
|
|
747
|
-
if (!videoHandler)
|
|
748
|
-
|
|
749
|
-
}
|
|
767
|
+
if (!videoHandler) videoHandler = videoHandlerIn;
|
|
768
|
+
};
|
|
750
769
|
|
|
751
770
|
/**
|
|
752
771
|
* Set a group of scenes into this parent scene. This group of
|
|
753
772
|
* scenes will also be rendered when this scene is rendered.
|
|
754
773
|
* @private
|
|
755
774
|
*/
|
|
756
|
-
this.setAdditionalScenesGroup = scenesGroup => {
|
|
775
|
+
this.setAdditionalScenesGroup = (scenesGroup) => {
|
|
757
776
|
scene.add(scenesGroup);
|
|
758
|
-
}
|
|
777
|
+
};
|
|
759
778
|
|
|
760
|
-
let getWindowsPosition = (
|
|
761
|
-
|
|
779
|
+
let getWindowsPosition = (
|
|
780
|
+
align,
|
|
781
|
+
x_offset,
|
|
782
|
+
y_offset,
|
|
783
|
+
width,
|
|
784
|
+
height,
|
|
785
|
+
renderer_width,
|
|
786
|
+
renderer_height,
|
|
787
|
+
) => {
|
|
762
788
|
let x = 0;
|
|
763
789
|
let y = 0;
|
|
764
|
-
if (align.includes(
|
|
790
|
+
if (align.includes('top')) {
|
|
765
791
|
y = renderer_height - height - y_offset;
|
|
766
|
-
} else if (align.includes(
|
|
792
|
+
} else if (align.includes('bottom')) {
|
|
767
793
|
y = y_offset;
|
|
768
794
|
} else {
|
|
769
795
|
y = Math.floor((renderer_height - height) / 2.0);
|
|
770
796
|
}
|
|
771
|
-
if (align.includes(
|
|
797
|
+
if (align.includes('left')) {
|
|
772
798
|
x = x_offset;
|
|
773
|
-
} else if (align.includes(
|
|
774
|
-
x = renderer_width - x_offset- width;
|
|
799
|
+
} else if (align.includes('right')) {
|
|
800
|
+
x = renderer_width - x_offset - width;
|
|
775
801
|
} else {
|
|
776
802
|
x = Math.floor((renderer_width - width) / 2.0);
|
|
777
803
|
}
|
|
778
|
-
return {x: x, y: y};
|
|
779
|
-
}
|
|
804
|
+
return { x: x, y: y };
|
|
805
|
+
};
|
|
780
806
|
|
|
781
|
-
const renderMinimap = renderer => {
|
|
807
|
+
const renderMinimap = (renderer) => {
|
|
782
808
|
if (this.displayMinimap || this.displayMiniAxes) {
|
|
783
809
|
renderer.setScissorTest(true);
|
|
784
810
|
renderer.getSize(_markerTarget);
|
|
785
811
|
if (this.minimapScissor.updateRequired) {
|
|
786
|
-
scissor = getWindowsPosition(
|
|
812
|
+
scissor = getWindowsPosition(
|
|
813
|
+
this.minimapScissor.align,
|
|
787
814
|
this.minimapScissor.x_offset,
|
|
788
815
|
this.minimapScissor.y_offset,
|
|
789
816
|
this.minimapScissor.width,
|
|
790
817
|
this.minimapScissor.height,
|
|
791
|
-
_markerTarget.x,
|
|
818
|
+
_markerTarget.x,
|
|
819
|
+
_markerTarget.y,
|
|
820
|
+
);
|
|
792
821
|
this.minimapScissor.updateRequired = false;
|
|
793
822
|
}
|
|
794
823
|
renderer.setScissor(
|
|
795
824
|
scissor.x,
|
|
796
825
|
scissor.y,
|
|
797
826
|
this.minimapScissor.width,
|
|
798
|
-
this.minimapScissor.height
|
|
827
|
+
this.minimapScissor.height,
|
|
828
|
+
);
|
|
799
829
|
renderer.setViewport(
|
|
800
830
|
scissor.x,
|
|
801
831
|
scissor.y,
|
|
802
832
|
this.minimapScissor.width,
|
|
803
|
-
this.minimapScissor.height
|
|
833
|
+
this.minimapScissor.height,
|
|
834
|
+
);
|
|
804
835
|
minimap.updateCamera();
|
|
805
836
|
if (this.displayMiniAxes) {
|
|
806
837
|
renderer.render(miniAxesScene, minimap.camera);
|
|
@@ -812,22 +843,21 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
812
843
|
renderer.setScissorTest(false);
|
|
813
844
|
renderer.setViewport(0, 0, _markerTarget.x, _markerTarget.y);
|
|
814
845
|
}
|
|
815
|
-
}
|
|
846
|
+
};
|
|
816
847
|
|
|
817
848
|
/**
|
|
818
849
|
* Render the scene.
|
|
819
850
|
* @private
|
|
820
851
|
*/
|
|
821
|
-
this.render = renderer => {
|
|
822
|
-
if (this.autoClearFlag)
|
|
823
|
-
renderer.clear();
|
|
852
|
+
this.render = (renderer) => {
|
|
853
|
+
if (this.autoClearFlag) renderer.clear();
|
|
824
854
|
if (stereoEffectFlag && stereoEffect) {
|
|
825
855
|
stereoEffect.render(scene, this.camera);
|
|
826
856
|
} else {
|
|
827
857
|
renderer.render(scene, this.camera);
|
|
828
858
|
renderMinimap(renderer);
|
|
829
859
|
}
|
|
830
|
-
}
|
|
860
|
+
};
|
|
831
861
|
|
|
832
862
|
/**
|
|
833
863
|
* Enable or disable interactive control, this is on by default.
|
|
@@ -835,12 +865,10 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
835
865
|
* @param {Boolean} flag - Indicate either interactive control
|
|
836
866
|
* should be enabled or disabled.
|
|
837
867
|
*/
|
|
838
|
-
this.setInteractiveControlEnable = flag => {
|
|
839
|
-
if (flag == true)
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
zincCameraControls.disable();
|
|
843
|
-
}
|
|
868
|
+
this.setInteractiveControlEnable = (flag) => {
|
|
869
|
+
if (flag == true) zincCameraControls.enable();
|
|
870
|
+
else zincCameraControls.disable();
|
|
871
|
+
};
|
|
844
872
|
|
|
845
873
|
/**
|
|
846
874
|
* Get the camera control of this scene.
|
|
@@ -848,7 +876,7 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
848
876
|
*/
|
|
849
877
|
this.getZincCameraControls = () => {
|
|
850
878
|
return zincCameraControls;
|
|
851
|
-
}
|
|
879
|
+
};
|
|
852
880
|
|
|
853
881
|
/**
|
|
854
882
|
* Get the internal {THREE.Scene}.
|
|
@@ -856,20 +884,20 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
856
884
|
*/
|
|
857
885
|
this.getThreeJSScene = () => {
|
|
858
886
|
return scene;
|
|
859
|
-
}
|
|
887
|
+
};
|
|
860
888
|
|
|
861
889
|
/**
|
|
862
890
|
* Set the default duration value for geometries and glyphsets
|
|
863
891
|
* that are to be loaded into this scene.
|
|
864
892
|
* @param {Number} durationIn - duration of the scene.
|
|
865
893
|
*/
|
|
866
|
-
this.setDuration = durationIn => {
|
|
894
|
+
this.setDuration = (durationIn) => {
|
|
867
895
|
needsRender = true;
|
|
868
896
|
rootRegion.setDuration(durationIn);
|
|
869
897
|
duration = durationIn;
|
|
870
898
|
zincCameraControls.setPathDuration(durationIn);
|
|
871
899
|
sceneLoader.duration = durationIn;
|
|
872
|
-
}
|
|
900
|
+
};
|
|
873
901
|
|
|
874
902
|
/**
|
|
875
903
|
* Get the default duration value.
|
|
@@ -877,14 +905,14 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
877
905
|
*/
|
|
878
906
|
this.getDuration = () => {
|
|
879
907
|
return duration;
|
|
880
|
-
}
|
|
908
|
+
};
|
|
881
909
|
|
|
882
910
|
/**
|
|
883
911
|
* Enable or disable stereo effect of this scene.
|
|
884
912
|
* @param {Boolean} stereoFlag - Indicate either stereo effect control
|
|
885
913
|
* should be enabled or disabled.
|
|
886
914
|
*/
|
|
887
|
-
this.setStereoEffectEnable = stereoFlag => {
|
|
915
|
+
this.setStereoEffectEnable = (stereoFlag) => {
|
|
888
916
|
needsRender = true;
|
|
889
917
|
if (stereoFlag == true) {
|
|
890
918
|
if (!stereoEffect) {
|
|
@@ -894,17 +922,16 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
894
922
|
rendererIn.setSize(getDrawingWidth(), getDrawingHeight());
|
|
895
923
|
this.camera.updateProjectionMatrix();
|
|
896
924
|
stereoEffectFlag = stereoFlag;
|
|
897
|
-
}
|
|
898
|
-
|
|
925
|
+
};
|
|
899
926
|
|
|
900
927
|
/**
|
|
901
928
|
* Check rather object is in scene.
|
|
902
929
|
*
|
|
903
930
|
* @return {Boolean}
|
|
904
931
|
*/
|
|
905
|
-
this.objectIsInScene = zincObject => {
|
|
932
|
+
this.objectIsInScene = (zincObject) => {
|
|
906
933
|
return rootRegion.objectIsInRegion(zincObject, true);
|
|
907
|
-
}
|
|
934
|
+
};
|
|
908
935
|
|
|
909
936
|
/**
|
|
910
937
|
* Rotate the camera view to view the entirety of the
|
|
@@ -919,10 +946,16 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
919
946
|
if (boundingBox) {
|
|
920
947
|
boundingBox.getCenter(_v3);
|
|
921
948
|
const viewport = this.getZincCameraControls().getCurrentViewport();
|
|
922
|
-
const target = new THREE.Vector3(
|
|
923
|
-
viewport.targetPosition[
|
|
924
|
-
|
|
925
|
-
viewport.
|
|
949
|
+
const target = new THREE.Vector3(
|
|
950
|
+
viewport.targetPosition[0],
|
|
951
|
+
viewport.targetPosition[1],
|
|
952
|
+
viewport.targetPosition[2],
|
|
953
|
+
);
|
|
954
|
+
const eyePosition = new THREE.Vector3(
|
|
955
|
+
viewport.eyePosition[0],
|
|
956
|
+
viewport.eyePosition[1],
|
|
957
|
+
viewport.eyePosition[2],
|
|
958
|
+
);
|
|
926
959
|
const newVec1 = new THREE.Vector3();
|
|
927
960
|
const newVec2 = new THREE.Vector3();
|
|
928
961
|
newVec1.subVectors(target, eyePosition).normalize();
|
|
@@ -931,16 +964,14 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
931
964
|
newVec3.crossVectors(newVec1, newVec2);
|
|
932
965
|
const angle = newVec1.angleTo(newVec2);
|
|
933
966
|
if (transitionTime > 0) {
|
|
934
|
-
this.getZincCameraControls().rotateCameraTransition(newVec3,
|
|
935
|
-
angle, transitionTime);
|
|
967
|
+
this.getZincCameraControls().rotateCameraTransition(newVec3, angle, transitionTime);
|
|
936
968
|
this.getZincCameraControls().enableCameraTransition();
|
|
937
969
|
} else {
|
|
938
970
|
this.getZincCameraControls().rotateAboutLookAtpoint(newVec3, angle);
|
|
939
971
|
}
|
|
940
972
|
markerCluster.markerUpdateRequired = true;
|
|
941
973
|
}
|
|
942
|
-
}
|
|
943
|
-
|
|
974
|
+
};
|
|
944
975
|
|
|
945
976
|
/**
|
|
946
977
|
* Translate the camera view to the center of the
|
|
@@ -953,15 +984,17 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
953
984
|
this.translateBoundingBoxToCameraView = (boundingBox, scaleRadius, transitionTime) => {
|
|
954
985
|
if (boundingBox) {
|
|
955
986
|
const oldViewport = this.getZincCameraControls().getCurrentViewport();
|
|
956
|
-
const viewport = this.getZincCameraControls().getViewportFromBoundingBox(
|
|
987
|
+
const viewport = this.getZincCameraControls().getViewportFromBoundingBox(
|
|
988
|
+
boundingBox,
|
|
989
|
+
scaleRadius,
|
|
990
|
+
);
|
|
957
991
|
if (transitionTime > 0) {
|
|
958
|
-
this.getZincCameraControls().cameraTransition(oldViewport,
|
|
959
|
-
viewport, transitionTime);
|
|
992
|
+
this.getZincCameraControls().cameraTransition(oldViewport, viewport, transitionTime);
|
|
960
993
|
this.getZincCameraControls().enableCameraTransition();
|
|
961
994
|
}
|
|
962
995
|
markerCluster.markerUpdateRequired = true;
|
|
963
996
|
}
|
|
964
|
-
}
|
|
997
|
+
};
|
|
965
998
|
|
|
966
999
|
/**
|
|
967
1000
|
* Transition the camera into viewing the zinc object with a
|
|
@@ -975,23 +1008,29 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
975
1008
|
const boundingBox = zincObject.getBoundingBox();
|
|
976
1009
|
this.alignBoundingBoxToCameraView(boundingBox, transitionTime);
|
|
977
1010
|
}
|
|
978
|
-
}
|
|
1011
|
+
};
|
|
979
1012
|
|
|
980
1013
|
/**
|
|
981
1014
|
* Set the camera to point to the centroid of the zinc object.
|
|
982
1015
|
*
|
|
983
1016
|
* @param {ZincObject} zincObject - the bounding box to target
|
|
984
1017
|
*/
|
|
985
|
-
this.setCameraTargetToObject = zincObject => {
|
|
1018
|
+
this.setCameraTargetToObject = (zincObject) => {
|
|
986
1019
|
needsRender = true;
|
|
987
1020
|
if (this.objectIsInScene(zincObject)) {
|
|
988
1021
|
const boundingBox = zincObject.getBoundingBox();
|
|
989
1022
|
const viewport = this.getZincCameraControls().getCurrentViewport();
|
|
990
1023
|
boundingBox.getCenter(_v3);
|
|
991
|
-
const target = new THREE.Vector3(
|
|
992
|
-
viewport.targetPosition[
|
|
993
|
-
|
|
994
|
-
viewport.
|
|
1024
|
+
const target = new THREE.Vector3(
|
|
1025
|
+
viewport.targetPosition[0],
|
|
1026
|
+
viewport.targetPosition[1],
|
|
1027
|
+
viewport.targetPosition[2],
|
|
1028
|
+
);
|
|
1029
|
+
const eyePosition = new THREE.Vector3(
|
|
1030
|
+
viewport.eyePosition[0],
|
|
1031
|
+
viewport.eyePosition[1],
|
|
1032
|
+
viewport.eyePosition[2],
|
|
1033
|
+
);
|
|
995
1034
|
const newVec1 = new THREE.Vector3();
|
|
996
1035
|
const newVec2 = new THREE.Vector3();
|
|
997
1036
|
newVec1.subVectors(eyePosition, target);
|
|
@@ -1005,7 +1044,7 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
1005
1044
|
this.getZincCameraControls().setCurrentCameraSettings(viewport);
|
|
1006
1045
|
markerCluster.markerUpdateRequired = true;
|
|
1007
1046
|
}
|
|
1008
|
-
}
|
|
1047
|
+
};
|
|
1009
1048
|
|
|
1010
1049
|
/**
|
|
1011
1050
|
* Check if stereo effect is enabled.
|
|
@@ -1013,21 +1052,21 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
1013
1052
|
*/
|
|
1014
1053
|
this.isStereoEffectEnable = () => {
|
|
1015
1054
|
return stereoEffectFlag;
|
|
1016
|
-
}
|
|
1055
|
+
};
|
|
1017
1056
|
|
|
1018
1057
|
/**
|
|
1019
1058
|
* Remove a ZincObject from this scene if it presents. This will eventually
|
|
1020
1059
|
* destroy the object and free up the memory.
|
|
1021
1060
|
* @param {Zinc.Object} zincObject - object to be removed from this scene.
|
|
1022
1061
|
*/
|
|
1023
|
-
this.removeZincObject = zincObject => {
|
|
1062
|
+
this.removeZincObject = (zincObject) => {
|
|
1024
1063
|
needsRender = true;
|
|
1025
1064
|
rootRegion.removeZincObject(zincObject);
|
|
1026
1065
|
if (zincCameraControls) {
|
|
1027
1066
|
zincCameraControls.calculateMaxAllowedDistance(this);
|
|
1028
1067
|
}
|
|
1029
1068
|
markerCluster.markerUpdateRequired = true;
|
|
1030
|
-
}
|
|
1069
|
+
};
|
|
1031
1070
|
|
|
1032
1071
|
/**
|
|
1033
1072
|
* Update pickable objects list
|
|
@@ -1039,7 +1078,7 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
1039
1078
|
}
|
|
1040
1079
|
rootRegion.getPickableThreeJSObjects(pickableObjectsList, true);
|
|
1041
1080
|
this.forcePickableObjectsUpdate = false;
|
|
1042
|
-
}
|
|
1081
|
+
};
|
|
1043
1082
|
|
|
1044
1083
|
/**
|
|
1045
1084
|
* Get all pickable objects.
|
|
@@ -1047,12 +1086,11 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
1047
1086
|
this.getPickableThreeJSObjects = () => {
|
|
1048
1087
|
//The list will only be updated if changes have been made
|
|
1049
1088
|
//in region or a flag has been raise
|
|
1050
|
-
if (this.forcePickableObjectsUpdate ||
|
|
1051
|
-
rootRegion.checkPickableUpdateRequred(true)) {
|
|
1089
|
+
if (this.forcePickableObjectsUpdate || rootRegion.checkPickableUpdateRequred(true)) {
|
|
1052
1090
|
this.updatePickableThreeJSObjects();
|
|
1053
1091
|
}
|
|
1054
1092
|
return pickableObjectsList;
|
|
1055
|
-
}
|
|
1093
|
+
};
|
|
1056
1094
|
|
|
1057
1095
|
/**
|
|
1058
1096
|
* Get the Normalised coordinates on minimap if mouse event is
|
|
@@ -1063,29 +1101,28 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
1063
1101
|
const target = new THREE.Vector2();
|
|
1064
1102
|
renderer.getSize(target);
|
|
1065
1103
|
let offsetY = target.y - event.clientY;
|
|
1066
|
-
if (
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1104
|
+
if (
|
|
1105
|
+
scissor.x + this.minimapScissor.width > event.clientX &&
|
|
1106
|
+
event.clientX > scissor.x &&
|
|
1107
|
+
scissor.y + this.minimapScissor.height > offsetY &&
|
|
1108
|
+
offsetY > scissor.y
|
|
1109
|
+
) {
|
|
1110
|
+
let x = ((event.clientX - scissor.x) / this.minimapScissor.width) * 2.0 - 1.0;
|
|
1111
|
+
let y = ((offsetY - scissor.y) / this.minimapScissor.height) * 2.0 - 1.0;
|
|
1112
|
+
return { x: x, y: y };
|
|
1075
1113
|
}
|
|
1076
1114
|
}
|
|
1077
1115
|
return undefined;
|
|
1078
|
-
}
|
|
1116
|
+
};
|
|
1079
1117
|
|
|
1080
1118
|
/**
|
|
1081
1119
|
* Get the coordinates difference of the current viewing
|
|
1082
1120
|
* point and projected coordinates.
|
|
1083
1121
|
*/
|
|
1084
1122
|
this.getMinimapDiffFromNormalised = (x, y) => {
|
|
1085
|
-
if (minimap)
|
|
1086
|
-
return minimap.getDiffFromNormalised(x, y);
|
|
1123
|
+
if (minimap) return minimap.getDiffFromNormalised(x, y);
|
|
1087
1124
|
return undefined;
|
|
1088
|
-
}
|
|
1125
|
+
};
|
|
1089
1126
|
|
|
1090
1127
|
/**
|
|
1091
1128
|
* Check if the renderer is running on the WebGL 2 fallback backend.
|
|
@@ -1094,7 +1131,7 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
1094
1131
|
*/
|
|
1095
1132
|
this.isWebGL2 = () => {
|
|
1096
1133
|
return rendererIn?.backend?.isWebGLBackend === true;
|
|
1097
|
-
}
|
|
1134
|
+
};
|
|
1098
1135
|
|
|
1099
1136
|
/**
|
|
1100
1137
|
* Check if the renderer is running on the WebGPU backend.
|
|
@@ -1103,7 +1140,7 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
1103
1140
|
*/
|
|
1104
1141
|
this.isWebGPU = () => {
|
|
1105
1142
|
return rendererIn?.backend?.isWebGPUBackend === true;
|
|
1106
|
-
}
|
|
1143
|
+
};
|
|
1107
1144
|
|
|
1108
1145
|
/**
|
|
1109
1146
|
* Get the THREE.WebGPURenderer this scene is being drawn with, for code
|
|
@@ -1113,7 +1150,7 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
1113
1150
|
*/
|
|
1114
1151
|
this.getRenderer = () => {
|
|
1115
1152
|
return rendererIn;
|
|
1116
|
-
}
|
|
1153
|
+
};
|
|
1117
1154
|
|
|
1118
1155
|
/**
|
|
1119
1156
|
* Remove all objects that are created with ZincJS APIs and it will free the memory allocated.
|
|
@@ -1130,60 +1167,60 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
1130
1167
|
zincCameraControls.calculateMaxAllowedDistance(this);
|
|
1131
1168
|
}
|
|
1132
1169
|
markerCluster.markerUpdateRequired = true;
|
|
1133
|
-
}
|
|
1170
|
+
};
|
|
1134
1171
|
|
|
1135
1172
|
/**
|
|
1136
1173
|
* All time stamp to the metadata TimeStamps field.
|
|
1137
1174
|
*/
|
|
1138
1175
|
this.addMetadataTimeStamp = (key, time) => {
|
|
1139
|
-
metadata[
|
|
1140
|
-
}
|
|
1176
|
+
metadata['TimeStamps'][key] = convertDurationObjectTomSec(time);
|
|
1177
|
+
};
|
|
1141
1178
|
|
|
1142
1179
|
/**
|
|
1143
1180
|
* Get a specific metadata field.
|
|
1144
1181
|
*/
|
|
1145
|
-
this.getMetadataTag = key => {
|
|
1182
|
+
this.getMetadataTag = (key) => {
|
|
1146
1183
|
return metadata[key];
|
|
1147
|
-
}
|
|
1184
|
+
};
|
|
1148
1185
|
|
|
1149
1186
|
/**
|
|
1150
1187
|
* Get all metadata set for the scene.
|
|
1151
1188
|
*/
|
|
1152
1189
|
this.getMetadata = () => {
|
|
1153
1190
|
return metadata;
|
|
1154
|
-
}
|
|
1191
|
+
};
|
|
1155
1192
|
|
|
1156
1193
|
/**
|
|
1157
1194
|
* Set a specific metadata field.
|
|
1158
1195
|
*/
|
|
1159
1196
|
this.setMetadataTag = (key, value) => {
|
|
1160
1197
|
metadata[key] = value;
|
|
1161
|
-
}
|
|
1198
|
+
};
|
|
1162
1199
|
|
|
1163
1200
|
/**
|
|
1164
1201
|
* Remove a specific metadata field.
|
|
1165
1202
|
*/
|
|
1166
|
-
this.removeMetadataTag = key => {
|
|
1203
|
+
this.removeMetadataTag = (key) => {
|
|
1167
1204
|
delete metadata[key];
|
|
1168
|
-
}
|
|
1205
|
+
};
|
|
1169
1206
|
|
|
1170
1207
|
/**
|
|
1171
1208
|
* Reset all metadata fields to original value.
|
|
1172
1209
|
*/
|
|
1173
1210
|
this.resetMetadata = () => {
|
|
1174
1211
|
metadata = defaultMetadata();
|
|
1175
|
-
}
|
|
1212
|
+
};
|
|
1176
1213
|
|
|
1177
1214
|
/**
|
|
1178
1215
|
* Reset duration of scene to default value.
|
|
1179
1216
|
*/
|
|
1180
1217
|
this.resetDuration = () => {
|
|
1181
1218
|
this.setDuration(defaultDuration);
|
|
1182
|
-
}
|
|
1219
|
+
};
|
|
1183
1220
|
|
|
1184
1221
|
// Turn the object into a readable string {years: years,months: months,
|
|
1185
1222
|
// weeks: weeks, days: days, hours: hours, mins: mins, secs: secs }
|
|
1186
|
-
const convertDurationObjectToString = duration => {
|
|
1223
|
+
const convertDurationObjectToString = (duration) => {
|
|
1187
1224
|
return [
|
|
1188
1225
|
...(duration.years ? [`${duration.years}years`] : []),
|
|
1189
1226
|
...(duration.months ? [`${duration.months}months`] : []),
|
|
@@ -1193,37 +1230,45 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
1193
1230
|
...(duration.mins ? [`${duration.mins}mins`] : []),
|
|
1194
1231
|
...(duration.secs ? [`${duration.secs}secs`] : []),
|
|
1195
1232
|
].join(' ');
|
|
1196
|
-
}
|
|
1233
|
+
};
|
|
1197
1234
|
|
|
1198
1235
|
// Turn the object into a number representing milliesecond {years: years,months: months,
|
|
1199
1236
|
// weeks: weeks, days: days, hours: hours, mins: mins, secs: secs }
|
|
1200
|
-
const convertDurationObjectTomSec = duration => {
|
|
1201
|
-
return duration.years
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1237
|
+
const convertDurationObjectTomSec = (duration) => {
|
|
1238
|
+
return duration.years
|
|
1239
|
+
? duration.years * 31536000000
|
|
1240
|
+
: 0 + duration.months
|
|
1241
|
+
? duration.months * 2592000000
|
|
1242
|
+
: 0 + duration.weeks
|
|
1243
|
+
? duration.weeks * 604800000
|
|
1244
|
+
: 0 + duration.days
|
|
1245
|
+
? duration.days * 86400000
|
|
1246
|
+
: 0 + duration.hours
|
|
1247
|
+
? duration.hours * 3600000
|
|
1248
|
+
: 0 + duration.mins
|
|
1249
|
+
? duration.mins * 60000
|
|
1250
|
+
: 0 + duration.secs
|
|
1251
|
+
? duration.secs * 1000
|
|
1252
|
+
: 0;
|
|
1253
|
+
};
|
|
1209
1254
|
|
|
1210
1255
|
// Set the readable duration and timer using an object
|
|
1211
1256
|
// with the following format {years: years,months: months, weeks: weeks, days: days,
|
|
1212
1257
|
// hours: hours, mins: mins, secs: secs }
|
|
1213
|
-
this.setDurationFromObject = duration => {
|
|
1258
|
+
this.setDurationFromObject = (duration) => {
|
|
1214
1259
|
const string = convertDurationObjectToString(duration);
|
|
1215
1260
|
const millisec = convertDurationObjectTomSec(duration);
|
|
1216
|
-
this.setMetadataTag(
|
|
1261
|
+
this.setMetadataTag('Duration', string);
|
|
1217
1262
|
this.setDuration(millisec);
|
|
1218
|
-
}
|
|
1263
|
+
};
|
|
1219
1264
|
|
|
1220
1265
|
// Set the readable original duration using an object
|
|
1221
1266
|
// with the following format {years: years,months: months, weeks: weeks, days: days,
|
|
1222
1267
|
// hours: hours, mins: mins, secs: secs }
|
|
1223
|
-
this.setOriginalDurationFromObject = duration => {
|
|
1268
|
+
this.setOriginalDurationFromObject = (duration) => {
|
|
1224
1269
|
const string = convertDurationObjectToString(duration);
|
|
1225
|
-
this.setMetadataTag(
|
|
1226
|
-
}
|
|
1270
|
+
this.setMetadataTag('OriginalDuration', string);
|
|
1271
|
+
};
|
|
1227
1272
|
|
|
1228
1273
|
/**
|
|
1229
1274
|
* Export the scene in GLTF format, it can either return it in
|
|
@@ -1237,7 +1282,7 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
1237
1282
|
this.exportGLTF = (binary) => {
|
|
1238
1283
|
const exporter = new SceneExporter(this);
|
|
1239
1284
|
return exporter.exportGLTF(binary);
|
|
1240
|
-
}
|
|
1285
|
+
};
|
|
1241
1286
|
|
|
1242
1287
|
/**
|
|
1243
1288
|
* Get the root region of the scene.
|
|
@@ -1246,118 +1291,118 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
1246
1291
|
*/
|
|
1247
1292
|
this.getRootRegion = () => {
|
|
1248
1293
|
return rootRegion;
|
|
1249
|
-
}
|
|
1294
|
+
};
|
|
1250
1295
|
|
|
1251
1296
|
/**
|
|
1252
1297
|
* Create points in region specified in the path
|
|
1253
1298
|
*
|
|
1254
1299
|
*/
|
|
1255
|
-
this.createLines = (
|
|
1300
|
+
this.createLines = (regionPath, groupName, coords, colour) => {
|
|
1256
1301
|
let region = rootRegion.findChildFromPath(regionPath);
|
|
1257
1302
|
if (region === undefined) {
|
|
1258
1303
|
region = rootRegion.createChildFromPath(regionPath);
|
|
1259
1304
|
}
|
|
1260
1305
|
return region.createLines(groupName, coords, colour);
|
|
1261
|
-
}
|
|
1306
|
+
};
|
|
1262
1307
|
|
|
1263
1308
|
/**
|
|
1264
1309
|
* Create points in region specified in the path
|
|
1265
1310
|
*
|
|
1266
1311
|
*/
|
|
1267
|
-
this.createPoints = (
|
|
1312
|
+
this.createPoints = (regionPath, groupName, coords, labels, colour) => {
|
|
1268
1313
|
let region = rootRegion.findChildFromPath(regionPath);
|
|
1269
1314
|
if (region === undefined) {
|
|
1270
1315
|
region = rootRegion.createChildFromPath(regionPath);
|
|
1271
1316
|
}
|
|
1272
1317
|
return region.createPoints(groupName, coords, labels, colour);
|
|
1273
|
-
}
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
/**
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1318
|
+
};
|
|
1319
|
+
|
|
1320
|
+
/**
|
|
1321
|
+
* Add a callback function which will be called everytime zinc object is added.
|
|
1322
|
+
* @param {Function} callbackFunction - callbackFunction to be added.
|
|
1323
|
+
*
|
|
1324
|
+
* @return {Number}
|
|
1325
|
+
*/
|
|
1326
|
+
this.addZincObjectAddedCallbacks = (callbackFunction) => {
|
|
1327
|
+
zincObjectAddedCallbacks_id = zincObjectAddedCallbacks_id + 1;
|
|
1328
|
+
zincObjectAddedCallbacks[zincObjectAddedCallbacks_id] = callbackFunction;
|
|
1329
|
+
return zincObjectAddedCallbacks_id;
|
|
1330
|
+
};
|
|
1331
|
+
|
|
1332
|
+
/**
|
|
1333
|
+
* Add a callback function which will be called everytime zinc object is removed.
|
|
1334
|
+
* @param {Function} callbackFunction - callbackFunction to be added.
|
|
1335
|
+
*
|
|
1336
|
+
* @return {Number}
|
|
1337
|
+
*/
|
|
1338
|
+
this.addZincObjectRemovedCallbacks = (callbackFunction) => {
|
|
1339
|
+
zincObjectRemovedCallbacks_id = zincObjectRemovedCallbacks_id + 1;
|
|
1340
|
+
zincObjectRemovedCallbacks[zincObjectRemovedCallbacks_id] = callbackFunction;
|
|
1341
|
+
return zincObjectRemovedCallbacks_id;
|
|
1342
|
+
};
|
|
1343
|
+
|
|
1344
|
+
/**
|
|
1345
|
+
* Remove a callback function that is previously added to the scene.
|
|
1346
|
+
* @param {Number} id - identifier of the previously added callback function.
|
|
1347
|
+
*/
|
|
1348
|
+
this.removeZincObjectAddedCallbacks = (id) => {
|
|
1349
|
+
if (id in zincObjectAddedCallbacks_id) {
|
|
1350
|
+
delete zincObjectAddedCallbacks[id];
|
|
1351
|
+
}
|
|
1352
|
+
};
|
|
1353
|
+
|
|
1354
|
+
/**
|
|
1355
|
+
* Remove a callback function that is previously added to the scene.
|
|
1356
|
+
* @param {Number} id - identifier of the previously added callback function.
|
|
1357
|
+
*/
|
|
1358
|
+
this.removeZincObjectRemovedCallbacks = (id) => {
|
|
1359
|
+
if (id in zincObjectRemovedCallbacks_id) {
|
|
1360
|
+
delete zincObjectRemovedCallbacks[id];
|
|
1361
|
+
}
|
|
1362
|
+
};
|
|
1363
|
+
|
|
1364
|
+
/**
|
|
1365
|
+
* Clear all zinc object callback function
|
|
1366
|
+
*/
|
|
1367
|
+
this.clearZincObjectAddedCallbacks = () => {
|
|
1368
|
+
zincObjectAddedCallbacks = {};
|
|
1324
1369
|
zincObjectAddedCallbacks_id = 0;
|
|
1325
|
-
|
|
1370
|
+
};
|
|
1326
1371
|
|
|
1327
1372
|
/**
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1373
|
+
* Clear all zinc object callback function
|
|
1374
|
+
*/
|
|
1375
|
+
this.clearZincObjectRemovedCallbacks = () => {
|
|
1376
|
+
zincObjectRemovedCallbacks = {};
|
|
1332
1377
|
zincObjectRemovedCallbacks_id = 0;
|
|
1333
|
-
|
|
1378
|
+
};
|
|
1334
1379
|
|
|
1335
1380
|
/**
|
|
1336
|
-
|
|
1337
|
-
|
|
1381
|
+
* Used to trigger zinc object added callback
|
|
1382
|
+
*/
|
|
1338
1383
|
this.triggerObjectAddedCallback = (zincObject) => {
|
|
1339
1384
|
for (let key in zincObjectAddedCallbacks) {
|
|
1340
1385
|
if (zincObjectAddedCallbacks.hasOwnProperty(key)) {
|
|
1341
1386
|
zincObjectAddedCallbacks[key](zincObject);
|
|
1342
1387
|
}
|
|
1343
1388
|
}
|
|
1344
|
-
}
|
|
1389
|
+
};
|
|
1345
1390
|
|
|
1346
1391
|
/**
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
this.triggerObjectRemovedCallback= (zincObject) => {
|
|
1392
|
+
* Used to trigger zinc object removed callback
|
|
1393
|
+
*/
|
|
1394
|
+
this.triggerObjectRemovedCallback = (zincObject) => {
|
|
1350
1395
|
for (let key in zincObjectRemovedCallbacks) {
|
|
1351
1396
|
if (zincObjectRemovedCallbacks.hasOwnProperty(key)) {
|
|
1352
1397
|
zincObjectRemovedCallbacks[key](zincObject);
|
|
1353
1398
|
}
|
|
1354
1399
|
}
|
|
1355
|
-
}
|
|
1400
|
+
};
|
|
1356
1401
|
|
|
1357
1402
|
/*
|
|
1358
|
-
|
|
1403
|
+
* Add temporary points to the scene which can be removed
|
|
1359
1404
|
* with clearTemporaryPrimitives method.
|
|
1360
|
-
|
|
1405
|
+
*/
|
|
1361
1406
|
this.addTemporaryPoints = (coords, colour) => {
|
|
1362
1407
|
needsRender = true;
|
|
1363
1408
|
const geometry = createPointQuadGeometry(coords.length);
|
|
@@ -1376,36 +1421,35 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
1376
1421
|
instancePosition.needsUpdate = true;
|
|
1377
1422
|
tempGroup.add(point);
|
|
1378
1423
|
return point;
|
|
1379
|
-
}
|
|
1424
|
+
};
|
|
1380
1425
|
|
|
1381
1426
|
/*
|
|
1382
|
-
|
|
1427
|
+
* Add temporary lines to the scene which can be removed
|
|
1383
1428
|
* with clearTemporaryPrimitives method.
|
|
1384
|
-
|
|
1429
|
+
*/
|
|
1385
1430
|
this.addTemporaryLines = (coords, colour) => {
|
|
1386
1431
|
needsRender = true;
|
|
1387
1432
|
const geometry = createBufferGeometry(coords.length, coords);
|
|
1388
|
-
const material = new THREE.LineBasicMaterial({color:colour});
|
|
1433
|
+
const material = new THREE.LineBasicMaterial({ color: colour });
|
|
1389
1434
|
const line = new LineSegments(geometry, material);
|
|
1390
1435
|
tempGroup.add(line);
|
|
1391
1436
|
return line;
|
|
1392
|
-
}
|
|
1393
|
-
|
|
1437
|
+
};
|
|
1394
1438
|
|
|
1395
1439
|
/*
|
|
1396
|
-
|
|
1397
|
-
|
|
1440
|
+
* Display frustum
|
|
1441
|
+
*/
|
|
1398
1442
|
this.enableFrustumDisplay = () => {
|
|
1399
1443
|
needsRender = true;
|
|
1400
1444
|
if (this.camera && !cameraHelper) {
|
|
1401
1445
|
cameraHelper = new THREE.CameraHelper(this.camera);
|
|
1402
1446
|
scene.add(cameraHelper);
|
|
1403
1447
|
}
|
|
1404
|
-
}
|
|
1448
|
+
};
|
|
1405
1449
|
|
|
1406
1450
|
/*
|
|
1407
|
-
|
|
1408
|
-
|
|
1451
|
+
* Hide frustum
|
|
1452
|
+
*/
|
|
1409
1453
|
this.disableFrustumDisplay = () => {
|
|
1410
1454
|
needsRender = true;
|
|
1411
1455
|
if (cameraHelper) {
|
|
@@ -1413,41 +1457,47 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
1413
1457
|
cameraHelper.dispose();
|
|
1414
1458
|
cameraHelper = undefined;
|
|
1415
1459
|
}
|
|
1416
|
-
}
|
|
1460
|
+
};
|
|
1417
1461
|
|
|
1418
1462
|
/*
|
|
1419
|
-
|
|
1420
|
-
|
|
1463
|
+
* Remove object from temporary objects list
|
|
1464
|
+
*/
|
|
1421
1465
|
this.removeTemporaryPrimitive = (object) => {
|
|
1422
1466
|
needsRender = true;
|
|
1423
1467
|
tempGroup.remove(object);
|
|
1424
1468
|
object.geometry.dispose();
|
|
1425
1469
|
object.material.dispose();
|
|
1426
|
-
}
|
|
1470
|
+
};
|
|
1427
1471
|
|
|
1428
1472
|
/*
|
|
1429
|
-
|
|
1473
|
+
* Remove all temporary primitives.
|
|
1430
1474
|
* Return number of primitives removed;
|
|
1431
|
-
|
|
1475
|
+
*/
|
|
1432
1476
|
this.clearTemporaryPrimitives = () => {
|
|
1433
1477
|
needsRender = true;
|
|
1434
1478
|
let i = 0;
|
|
1435
1479
|
const children = tempGroup.children;
|
|
1436
|
-
children.forEach(child => {
|
|
1480
|
+
children.forEach((child) => {
|
|
1437
1481
|
child.geometry.dispose();
|
|
1438
1482
|
child.material.dispose();
|
|
1439
1483
|
i++;
|
|
1440
1484
|
});
|
|
1441
1485
|
tempGroup.clear();
|
|
1442
1486
|
return i;
|
|
1443
|
-
}
|
|
1487
|
+
};
|
|
1444
1488
|
|
|
1445
1489
|
/*
|
|
1446
|
-
|
|
1490
|
+
* Create primitive based on the bounding box of scene and
|
|
1447
1491
|
* add to specify region and group name.
|
|
1448
|
-
|
|
1449
|
-
this.addBoundingBoxPrimitive = (
|
|
1450
|
-
|
|
1492
|
+
*/
|
|
1493
|
+
this.addBoundingBoxPrimitive = (
|
|
1494
|
+
regionPath,
|
|
1495
|
+
group,
|
|
1496
|
+
colour,
|
|
1497
|
+
opacity,
|
|
1498
|
+
visibility,
|
|
1499
|
+
boundingBox = undefined,
|
|
1500
|
+
) => {
|
|
1451
1501
|
needsRender = true;
|
|
1452
1502
|
let region = rootRegion.findChildFromPath(regionPath);
|
|
1453
1503
|
if (region === undefined) {
|
|
@@ -1458,21 +1508,32 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
1458
1508
|
const dim = _v3.subVectors(box.max, box.min);
|
|
1459
1509
|
const boxGeo = new THREE.BoxGeometry(dim.x, dim.y, dim.z);
|
|
1460
1510
|
const primitive = region.createGeometryFromThreeJSGeometry(
|
|
1461
|
-
group,
|
|
1462
|
-
|
|
1511
|
+
group,
|
|
1512
|
+
boxGeo,
|
|
1513
|
+
colour,
|
|
1514
|
+
opacity,
|
|
1515
|
+
visibility,
|
|
1516
|
+
10000,
|
|
1517
|
+
);
|
|
1518
|
+
dim.addVectors(box.min, box.max).multiplyScalar(0.5);
|
|
1463
1519
|
primitive.setPosition(dim.x, dim.y, dim.z);
|
|
1464
1520
|
return primitive;
|
|
1465
|
-
}
|
|
1521
|
+
};
|
|
1466
1522
|
|
|
1467
1523
|
/*
|
|
1468
|
-
|
|
1524
|
+
* Create primitive based on the bounding box of scene and
|
|
1469
1525
|
* add to specify region and group name.
|
|
1470
|
-
|
|
1471
|
-
this.addSlicesPrimitive = (
|
|
1472
|
-
|
|
1526
|
+
*/
|
|
1527
|
+
this.addSlicesPrimitive = (
|
|
1528
|
+
regionPath,
|
|
1529
|
+
groups,
|
|
1530
|
+
colours,
|
|
1531
|
+
opacity,
|
|
1532
|
+
visibility,
|
|
1533
|
+
boundingBox = undefined,
|
|
1534
|
+
) => {
|
|
1473
1535
|
needsRender = true;
|
|
1474
|
-
if (groups && groups.length >= 3 &&
|
|
1475
|
-
colours && colours.length >= 3) {
|
|
1536
|
+
if (groups && groups.length >= 3 && colours && colours.length >= 3) {
|
|
1476
1537
|
let region = rootRegion.findChildFromPath(regionPath);
|
|
1477
1538
|
if (region === undefined) {
|
|
1478
1539
|
region = rootRegion.createChildFromPath(regionPath);
|
|
@@ -1480,49 +1541,55 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
1480
1541
|
const box = boundingBox ? boundingBox : this.getBoundingBox();
|
|
1481
1542
|
_v3.set(0.0, 0.0, 0.0);
|
|
1482
1543
|
const dim = _v3.subVectors(box.max, box.min);
|
|
1483
|
-
const directions = [
|
|
1544
|
+
const directions = ['x', 'y', 'z'];
|
|
1484
1545
|
const primitives = [];
|
|
1485
1546
|
let index = 0;
|
|
1486
1547
|
directions.forEach((direction) => {
|
|
1487
1548
|
let planeGeo = undefined;
|
|
1488
|
-
switch(direction) {
|
|
1549
|
+
switch (direction) {
|
|
1489
1550
|
//YZ plane
|
|
1490
|
-
case
|
|
1551
|
+
case 'x':
|
|
1491
1552
|
planeGeo = new THREE.PlaneGeometry(dim.z, dim.y);
|
|
1492
1553
|
planeGeo.rotateY(Math.PI / 2);
|
|
1493
1554
|
// code block
|
|
1494
1555
|
break;
|
|
1495
1556
|
//XZ plane
|
|
1496
|
-
case
|
|
1557
|
+
case 'y':
|
|
1497
1558
|
planeGeo = new THREE.PlaneGeometry(dim.x, dim.z);
|
|
1498
1559
|
planeGeo.rotateX(Math.PI / 2);
|
|
1499
1560
|
// code block
|
|
1500
1561
|
break;
|
|
1501
1562
|
//XY plane
|
|
1502
|
-
case
|
|
1563
|
+
case 'z':
|
|
1503
1564
|
planeGeo = new THREE.PlaneGeometry(dim.x, dim.y);
|
|
1504
|
-
|
|
1565
|
+
// code block
|
|
1505
1566
|
break;
|
|
1506
1567
|
default:
|
|
1507
1568
|
break;
|
|
1508
1569
|
}
|
|
1509
1570
|
const primitive = region.createGeometryFromThreeJSGeometry(
|
|
1510
|
-
groups[index],
|
|
1571
|
+
groups[index],
|
|
1572
|
+
planeGeo,
|
|
1573
|
+
colours[index],
|
|
1574
|
+
opacity,
|
|
1575
|
+
visibility,
|
|
1576
|
+
10001,
|
|
1577
|
+
);
|
|
1511
1578
|
primitives.push(primitive);
|
|
1512
1579
|
index++;
|
|
1513
1580
|
});
|
|
1514
1581
|
|
|
1515
|
-
dim.addVectors(box.min, box.max).multiplyScalar(
|
|
1582
|
+
dim.addVectors(box.min, box.max).multiplyScalar(0.5);
|
|
1516
1583
|
primitives.forEach((primitive) => {
|
|
1517
1584
|
primitive.setPosition(dim.x, dim.y, dim.z);
|
|
1518
1585
|
});
|
|
1519
1586
|
return primitives;
|
|
1520
1587
|
}
|
|
1521
|
-
}
|
|
1588
|
+
};
|
|
1522
1589
|
|
|
1523
1590
|
/*
|
|
1524
|
-
|
|
1525
|
-
|
|
1591
|
+
* Enable marker cluster to work with markers
|
|
1592
|
+
*/
|
|
1526
1593
|
this.enableMarkerCluster = (flag) => {
|
|
1527
1594
|
needsRender = true;
|
|
1528
1595
|
if (flag) {
|
|
@@ -1533,17 +1600,17 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
1533
1600
|
markerCluster.disable();
|
|
1534
1601
|
}
|
|
1535
1602
|
this.forcePickableObjectsUpdate = true;
|
|
1536
|
-
}
|
|
1603
|
+
};
|
|
1537
1604
|
|
|
1538
1605
|
/*
|
|
1539
|
-
|
|
1540
|
-
|
|
1606
|
+
* Destory static axis display object
|
|
1607
|
+
*/
|
|
1541
1608
|
this.destroyAxisDisplay = () => {
|
|
1542
1609
|
needsRender = true;
|
|
1543
1610
|
this.displayMiniAxes = false;
|
|
1544
1611
|
if (axisDisplay.main) {
|
|
1545
1612
|
this.enableAxisDisplay(false, false);
|
|
1546
|
-
axisDisplay.main.forEach(axis => {
|
|
1613
|
+
axisDisplay.main.forEach((axis) => {
|
|
1547
1614
|
if (axis.dispose) {
|
|
1548
1615
|
axis.dispose();
|
|
1549
1616
|
}
|
|
@@ -1551,7 +1618,7 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
1551
1618
|
}
|
|
1552
1619
|
if (axisDisplay.mini) {
|
|
1553
1620
|
this.enableAxisDisplay(false, true);
|
|
1554
|
-
axisDisplay.mini.forEach(axis => {
|
|
1621
|
+
axisDisplay.mini.forEach((axis) => {
|
|
1555
1622
|
if (axis.dispose) {
|
|
1556
1623
|
axis.dispose();
|
|
1557
1624
|
}
|
|
@@ -1561,33 +1628,33 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
1561
1628
|
main: [],
|
|
1562
1629
|
mini: [],
|
|
1563
1630
|
};
|
|
1564
|
-
}
|
|
1631
|
+
};
|
|
1565
1632
|
|
|
1566
1633
|
/*
|
|
1567
|
-
|
|
1568
|
-
|
|
1634
|
+
* Create static axis display object
|
|
1635
|
+
*/
|
|
1569
1636
|
this.createAxisDisplay = (fitBoundingBox = false) => {
|
|
1570
1637
|
needsRender = true;
|
|
1571
1638
|
this.destroyAxisDisplay();
|
|
1572
1639
|
const XYZ = [
|
|
1573
1640
|
{
|
|
1574
|
-
name:
|
|
1641
|
+
name: 'x',
|
|
1575
1642
|
dir: new THREE.Vector3(1, 0, 0),
|
|
1576
|
-
colour:
|
|
1577
|
-
hex:
|
|
1643
|
+
colour: 'red',
|
|
1644
|
+
hex: 0xff5555,
|
|
1578
1645
|
},
|
|
1579
1646
|
{
|
|
1580
|
-
name:
|
|
1647
|
+
name: 'y',
|
|
1581
1648
|
dir: new THREE.Vector3(0, 1, 0),
|
|
1582
|
-
colour:
|
|
1583
|
-
hex:
|
|
1649
|
+
colour: 'green',
|
|
1650
|
+
hex: 0x55ff55,
|
|
1584
1651
|
},
|
|
1585
1652
|
{
|
|
1586
|
-
name:
|
|
1653
|
+
name: 'z',
|
|
1587
1654
|
dir: new THREE.Vector3(0, 0, 1),
|
|
1588
|
-
colour:
|
|
1589
|
-
hex:
|
|
1590
|
-
}
|
|
1655
|
+
colour: 'blue',
|
|
1656
|
+
hex: 0x5555ff,
|
|
1657
|
+
},
|
|
1591
1658
|
];
|
|
1592
1659
|
const boundingBox = this.getBoundingBox();
|
|
1593
1660
|
const size = boundingBox.min.distanceTo(boundingBox.max);
|
|
@@ -1598,7 +1665,12 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
1598
1665
|
XYZ.forEach((xyzObj) => {
|
|
1599
1666
|
const arrowHelper = new THREE.ArrowHelper(xyzObj.dir, origin, size, xyzObj.hex);
|
|
1600
1667
|
axisDisplay.main.push(arrowHelper);
|
|
1601
|
-
const miniArrowHelper = new THREE.ArrowHelper(
|
|
1668
|
+
const miniArrowHelper = new THREE.ArrowHelper(
|
|
1669
|
+
xyzObj.dir,
|
|
1670
|
+
boundingBox.getCenter(_v3),
|
|
1671
|
+
size / 2,
|
|
1672
|
+
xyzObj.hex,
|
|
1673
|
+
);
|
|
1602
1674
|
axisDisplay.mini.push(miniArrowHelper);
|
|
1603
1675
|
|
|
1604
1676
|
/*
|
|
@@ -1608,30 +1680,30 @@ const Scene = function (containerIn, rendererIn) {
|
|
|
1608
1680
|
axisDisplay.mini.push(miniLabel);
|
|
1609
1681
|
*/
|
|
1610
1682
|
|
|
1611
|
-
const axesLabel = createNewSpriteText(xyzObj.name, 0.036, xyzObj.colour,
|
|
1683
|
+
const axesLabel = createNewSpriteText(xyzObj.name, 0.036, xyzObj.colour, 'Asap', 120, 700);
|
|
1612
1684
|
const position = xyzObj.dir.clone().multiplyScalar(size).add(origin);
|
|
1613
1685
|
axesLabel.position.set(position.x, position.y, position.z);
|
|
1614
1686
|
axisDisplay.main.push(axesLabel);
|
|
1615
|
-
})
|
|
1616
|
-
}
|
|
1687
|
+
});
|
|
1688
|
+
};
|
|
1617
1689
|
|
|
1618
1690
|
/*
|
|
1619
|
-
|
|
1691
|
+
* Enable static axis display, createAxisDisplay must be called
|
|
1620
1692
|
* before the axis can be display.
|
|
1621
|
-
|
|
1693
|
+
*/
|
|
1622
1694
|
this.enableAxisDisplay = (enable, miniaxes = false) => {
|
|
1623
1695
|
needsRender = true;
|
|
1624
1696
|
if (miniaxes && axisDisplay?.mini?.length) {
|
|
1625
1697
|
this.displayMiniAxes = enable;
|
|
1626
|
-
axisDisplay.mini.forEach(axis => {
|
|
1698
|
+
axisDisplay.mini.forEach((axis) => {
|
|
1627
1699
|
enable ? miniAxesScene.add(axis) : miniAxesScene.remove(axis);
|
|
1628
1700
|
});
|
|
1629
1701
|
} else if (!miniaxes && axisDisplay.main) {
|
|
1630
|
-
axisDisplay.main.forEach(axis => {
|
|
1702
|
+
axisDisplay.main.forEach((axis) => {
|
|
1631
1703
|
enable ? scene.add(axis) : scene.remove(axis);
|
|
1632
1704
|
});
|
|
1633
1705
|
}
|
|
1634
|
-
}
|
|
1635
|
-
}
|
|
1706
|
+
};
|
|
1707
|
+
};
|
|
1636
1708
|
|
|
1637
1709
|
export { Scene };
|