@xeokit/xeokit-sdk 2.6.0-beta-14 → 2.6.0-beta-16

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xeokit/xeokit-sdk",
3
- "version": "2.6.0-beta-14",
3
+ "version": "2.6.0-beta-16",
4
4
  "description": "Web Programming Toolkit for 3D/2D BIM and AEC Graphics",
5
5
  "module": "./dist/xeokit-sdk.es.js",
6
6
  "main": "./dist/xeokit-sdk.cjs.js",
@@ -288,13 +288,16 @@ export class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
288
288
  this._currentAngleMeasurement = this.angleMeasurementsPlugin.createMeasurement({
289
289
  id: math.createUUID(),
290
290
  origin: {
291
- worldPos: mouseWorldPos
291
+ worldPos: mouseWorldPos,
292
+ entity: hoveredEntity
292
293
  },
293
294
  corner: {
294
- worldPos: mouseWorldPos
295
+ worldPos: mouseWorldPos,
296
+ entity: hoveredEntity
295
297
  },
296
298
  target: {
297
- worldPos: mouseWorldPos
299
+ worldPos: mouseWorldPos,
300
+ entity: hoveredEntity
298
301
  },
299
302
  approximate: true
300
303
  });
@@ -245,13 +245,16 @@ export class AngleMeasurementsTouchControl extends AngleMeasurementsControl {
245
245
  this._currentAngleMeasurement = plugin.createMeasurement({
246
246
  id: math.createUUID(),
247
247
  origin: {
248
- worldPos: snapPickResult.worldPos
248
+ worldPos: snapPickResult.worldPos,
249
+ entity: snapPickResult.entity
249
250
  },
250
251
  corner: {
251
- worldPos: snapPickResult.worldPos
252
+ worldPos: snapPickResult.worldPos,
253
+ entity: snapPickResult.entity
252
254
  },
253
255
  target: {
254
- worldPos: snapPickResult.worldPos
256
+ worldPos: snapPickResult.worldPos,
257
+ entity: snapPickResult.entity
255
258
  }
256
259
  });
257
260
  this._currentAngleMeasurement.clickable = false;
@@ -320,6 +323,7 @@ export class AngleMeasurementsTouchControl extends AngleMeasurementsControl {
320
323
  this.pointerCircle.start(snapPickResult.snappedCanvasPos);
321
324
  pointerWorldPos.set(snapPickResult.worldPos);
322
325
  this._currentAngleMeasurement.corner.worldPos = snapPickResult.worldPos;
326
+ this._currentAngleMeasurement.corner.entity = snapPickResult.entity;
323
327
  this._currentAngleMeasurement.originVisible = true;
324
328
  this._currentAngleMeasurement.originWireVisible = true;
325
329
  this._currentAngleMeasurement.cornerVisible = true;
@@ -341,6 +345,7 @@ export class AngleMeasurementsTouchControl extends AngleMeasurementsControl {
341
345
  this.pointerCircle.start(pickResult.canvasPos);
342
346
  pointerWorldPos.set(pickResult.worldPos);
343
347
  this._currentAngleMeasurement.corner.worldPos = pickResult.worldPos;
348
+ this._currentAngleMeasurement.corner.entity = pickResult.entity;
344
349
  this._currentAngleMeasurement.originVisible = true;
345
350
  this._currentAngleMeasurement.originWireVisible = true;
346
351
  this._currentAngleMeasurement.cornerVisible = true;
@@ -411,6 +416,7 @@ export class AngleMeasurementsTouchControl extends AngleMeasurementsControl {
411
416
  this.pointerCircle.start(snapPickResult.snappedCanvasPos);
412
417
  pointerWorldPos.set(snapPickResult.worldPos);
413
418
  this._currentAngleMeasurement.target.worldPos = snapPickResult.worldPos;
419
+ this._currentAngleMeasurement.target.entity = snapPickResult.entity;
414
420
  this._currentAngleMeasurement.originVisible = true;
415
421
  this._currentAngleMeasurement.originWireVisible = true;
416
422
  this._currentAngleMeasurement.cornerVisible = true;
@@ -432,6 +438,7 @@ export class AngleMeasurementsTouchControl extends AngleMeasurementsControl {
432
438
  this.pointerCircle.start(pickResult.canvasPos);
433
439
  pointerWorldPos.set(pickResult.worldPos);
434
440
  this._currentAngleMeasurement.target.worldPos = pickResult.worldPos;
441
+ this._currentAngleMeasurement.target.entity = pickResult.entity;
435
442
  this._currentAngleMeasurement.originVisible = true;
436
443
  this._currentAngleMeasurement.originWireVisible = true;
437
444
  this._currentAngleMeasurement.cornerVisible = true;
@@ -299,10 +299,12 @@ export class DistanceMeasurementsMouseControl extends DistanceMeasurementsContro
299
299
  this._currentDistanceMeasurement = distanceMeasurementsPlugin.createMeasurement({
300
300
  id: math.createUUID(),
301
301
  origin: {
302
- worldPos: pointerWorldPos.slice()
302
+ worldPos: pointerWorldPos.slice(),
303
+ entity: hoveredEntity
303
304
  },
304
305
  target: {
305
- worldPos: pointerWorldPos.slice()
306
+ worldPos: pointerWorldPos.slice(),
307
+ entity: hoveredEntity
306
308
  },
307
309
  approximate: true
308
310
  });
@@ -315,7 +317,7 @@ export class DistanceMeasurementsMouseControl extends DistanceMeasurementsContro
315
317
  this._currentDistanceMeasurement.clickable = false;
316
318
  this._currentDistanceMeasurement.origin.entity = hoveredEntity;
317
319
  hoveredEntity = null;
318
- this.fire("measurementStart", this._currentDistanceMeasurement);
320
+ this.distanceMeasurementsPlugin.fire("measurementStart", this._currentDistanceMeasurement);
319
321
  }
320
322
  }
321
323
  });
@@ -250,10 +250,12 @@ export class DistanceMeasurementsTouchControl extends DistanceMeasurementsContro
250
250
  this._currentDistanceMeasurement = plugin.createMeasurement({
251
251
  id: math.createUUID(),
252
252
  origin: {
253
- worldPos: pointerWorldPos
253
+ worldPos: pointerWorldPos,
254
+ entity: snapPickResult.entity
254
255
  },
255
256
  target: {
256
- worldPos: pointerWorldPos
257
+ worldPos: pointerWorldPos,
258
+ entity: snapPickResult.entity
257
259
  }
258
260
  });
259
261
  this._currentDistanceMeasurement.labelsVisible = false;
@@ -323,6 +325,7 @@ export class DistanceMeasurementsTouchControl extends DistanceMeasurementsContro
323
325
  this.pointerCircle.start(snapPickResult.snappedCanvasPos);
324
326
  pointerWorldPos.set(snapPickResult.worldPos);
325
327
  this._currentDistanceMeasurement.target.worldPos = snapPickResult.worldPos;
328
+ this._currentDistanceMeasurement.target.entity = snapPickResult.entity;
326
329
  this._currentDistanceMeasurement.targetVisible = true;
327
330
  this._currentDistanceMeasurement.wireVisible = true;
328
331
  this._currentDistanceMeasurement.labelsVisible = true;
@@ -340,6 +343,7 @@ export class DistanceMeasurementsTouchControl extends DistanceMeasurementsContro
340
343
  this.pointerCircle.start(pickResult.canvasPos);
341
344
  pointerWorldPos.set(pickResult.worldPos);
342
345
  this._currentDistanceMeasurement.target.worldPos = pickResult.worldPos;
346
+ this._currentDistanceMeasurement.target.entity = pickResult.entity;
343
347
  this._currentDistanceMeasurement.targetVisible = true;
344
348
  this._currentDistanceMeasurement.wireVisible = true;
345
349
  this._currentDistanceMeasurement.labelsVisible = true;
@@ -430,10 +434,12 @@ export class DistanceMeasurementsTouchControl extends DistanceMeasurementsContro
430
434
  this._currentDistanceMeasurement = plugin.createMeasurement({
431
435
  id: math.createUUID(),
432
436
  origin: {
433
- worldPos: snapPickResult.worldPos
437
+ worldPos: snapPickResult.worldPos,
438
+ entity: snapPickResult.entity
434
439
  },
435
440
  target: {
436
- worldPos: snapPickResult.worldPos
441
+ worldPos: snapPickResult.worldPos,
442
+ entity: snapPickResult.entity
437
443
  }
438
444
  });
439
445
  this._currentDistanceMeasurement.labelsVisible = false;
@@ -464,10 +470,12 @@ export class DistanceMeasurementsTouchControl extends DistanceMeasurementsContro
464
470
  this._currentDistanceMeasurement = plugin.createMeasurement({
465
471
  id: math.createUUID(),
466
472
  origin: {
467
- worldPos: pickResult.worldPos
473
+ worldPos: pickResult.worldPos,
474
+ entity: pickResult.entity
468
475
  },
469
476
  target: {
470
- worldPos: pickResult.worldPos
477
+ worldPos: pickResult.worldPos,
478
+ entity: pickResult.entity
471
479
  }
472
480
  });
473
481
  this._currentDistanceMeasurement.labelsVisible = false;
@@ -524,6 +532,7 @@ export class DistanceMeasurementsTouchControl extends DistanceMeasurementsContro
524
532
  this.pointerLens.snapped = true;
525
533
  }
526
534
  this._currentDistanceMeasurement.target.worldPos = snapPickResult.worldPos;
535
+ this._currentDistanceMeasurement.target.entity = snapPickResult.entity;
527
536
  this._currentDistanceMeasurement.targetVisible = true;
528
537
  this._currentDistanceMeasurement.wireVisible = true;
529
538
  this._currentDistanceMeasurement.labelsVisible = true;
@@ -538,6 +547,7 @@ export class DistanceMeasurementsTouchControl extends DistanceMeasurementsContro
538
547
  this.pointerLens.snapped = false;
539
548
  }
540
549
  this._currentDistanceMeasurement.target.worldPos = pickResult.worldPos;
550
+ this._currentDistanceMeasurement.target.entity = pickResult.entity;
541
551
  this._currentDistanceMeasurement.targetVisible = true;
542
552
  this._currentDistanceMeasurement.wireVisible = true;
543
553
  this._currentDistanceMeasurement.labelsVisible = true;
@@ -596,10 +606,12 @@ export class DistanceMeasurementsTouchControl extends DistanceMeasurementsContro
596
606
  this._currentDistanceMeasurement = plugin.createMeasurement({
597
607
  id: math.createUUID(),
598
608
  origin: {
599
- worldPos: pickResult.worldPos
609
+ worldPos: pickResult.worldPos,
610
+ entity: pickResult.entity
600
611
  },
601
612
  target: {
602
- worldPos: pickResult.worldPos
613
+ worldPos: pickResult.worldPos,
614
+ entity: pickResult.entity
603
615
  }
604
616
  });
605
617
  this._currentDistanceMeasurement.labelsVisible = false;
@@ -611,6 +623,7 @@ export class DistanceMeasurementsTouchControl extends DistanceMeasurementsContro
611
623
  this._currentDistanceMeasurement.targetVisible = false;
612
624
  this._currentDistanceMeasurement.clickable = false;
613
625
  this._touchState = WAITING_FOR_TARGET_TOUCH_START;
626
+ this.distanceMeasurementsPlugin.fire("measurementStart", this._currentDistanceMeasurement);
614
627
  // console.log("touchend: this._touchState= WAITING_FOR_ORIGIN_QUICK_TOUCH_END -> WAITING_FOR_ORIGIN_TOUCH_START")
615
628
  } else {
616
629
  if (this._currentDistanceMeasurement) {
@@ -656,6 +669,7 @@ export class DistanceMeasurementsTouchControl extends DistanceMeasurementsContro
656
669
  });
657
670
  if (pickResult && pickResult.worldPos) {
658
671
  this._currentDistanceMeasurement.target.worldPos = pickResult.worldPos;
672
+ this._currentDistanceMeasurement.target.entity = pickResult.entity;
659
673
  this._currentDistanceMeasurement.targetVisible = true;
660
674
  this._currentDistanceMeasurement.wireVisible = true;
661
675
  this._currentDistanceMeasurement.labelsVisible = true;
@@ -244,7 +244,7 @@ class GLTFLoaderPlugin extends Plugin {
244
244
  * @param {Boolean} [params.saoEnabled=true] Indicates if Scalable Ambient Obscurance (SAO) is enabled for the model. SAO is configured by the Scene's {@link SAO} component. Only works when {@link SAO#enabled} is also ````true````
245
245
  * @param {Boolean} [params.pbrEnabled=true] Indicates if physically-based rendering (PBR) is enabled for the model. Overrides ````colorTextureEnabled````. Only works when {@link Scene#pbrEnabled} is also ````true````.
246
246
  * @param {Boolean} [params.colorTextureEnabled=true] Indicates if base color texture rendering is enabled for the model. Overridden by ````pbrEnabled````. Only works when {@link Scene#colorTextureEnabled} is also ````true````.
247
- * @param {Boolean} [params.backfaces=false] When true, allows visible backfaces, wherever specified in the glTF. When false, ignores backfaces.
247
+ * @param {Boolean} [params.backfaces=true] When true, always show backfaces, even on objects for which the glTF material is single-sided. When false, only show backfaces on geometries whenever the glTF material is double-sided.
248
248
  * @param {Number} [params.edgeThreshold=10] When xraying, highlighting, selecting or edging, this is the threshold angle between normals of adjacent triangles, below which their shared wireframe edge is not drawn.
249
249
  * @param {Boolean} [params.dtxEnabled=true] When ````true```` (default) use data textures (DTX), where appropriate, to
250
250
  * represent the returned model. Set false to always use vertex buffer objects (VBOs). Note that DTX is only applicable
@@ -145,6 +145,7 @@ function parseGLTF(plugin, src, gltf, metaModelJSON, options, sceneModel, ok) {
145
145
  loadBuffer: options.loadBuffer,
146
146
  basePath: options.basePath,
147
147
  handlenode: options.handlenode,
148
+ backfaces: !!options.backfaces,
148
149
  gltfData: gltfData,
149
150
  scene: sceneModel.scene,
150
151
  plugin: plugin,
@@ -353,7 +354,8 @@ function loadMaterialAttributes(ctx, material) { // Substitute RGBA for material
353
354
  color: new Float32Array([1, 1, 1, 1]),
354
355
  opacity: 1,
355
356
  metallic: 0,
356
- roughness: 1
357
+ roughness: 1,
358
+ doubleSided : true
357
359
  };
358
360
  if (extensions) {
359
361
  const specularPBR = extensions["KHR_materials_pbrSpecularGlossiness"];
@@ -404,6 +406,7 @@ function loadMaterialAttributes(ctx, material) { // Substitute RGBA for material
404
406
  materialAttributes.roughness = roughnessFactor;
405
407
  }
406
408
  }
409
+ materialAttributes.doubleSided = (material.doubleSided !== false);
407
410
  return materialAttributes;
408
411
  }
409
412
 
@@ -517,6 +520,20 @@ function loadNode(ctx, node, depth, matrix) {
517
520
  id: sceneModel.id + "." + ctx.numObjects++
518
521
  };
519
522
 
523
+ const material = primitive.material;
524
+ if (material) {
525
+ meshCfg.textureSetId = material._textureSetId;
526
+ meshCfg.color = material._attributes.color;
527
+ meshCfg.opacity = material._attributes.opacity;
528
+ meshCfg.metallic = material._attributes.metallic;
529
+ meshCfg.roughness = material._attributes.roughness;
530
+ } else {
531
+ meshCfg.color = new Float32Array([1.0, 1.0, 1.0]);
532
+ meshCfg.opacity = 1.0;
533
+ }
534
+
535
+ const backfaces = ((ctx.backfaces !== false) || (material.doubleSided !== false));
536
+
520
537
  switch (primitive.mode) {
521
538
  case 0: // POINTS
522
539
  meshCfg.primitive = "points";
@@ -531,16 +548,16 @@ function loadNode(ctx, node, depth, matrix) {
531
548
  meshCfg.primitive = "lines";
532
549
  break;
533
550
  case 4: // TRIANGLES
534
- meshCfg.primitive = "triangles";
551
+ meshCfg.primitive = backfaces ? "triangles" : "solid";
535
552
  break;
536
553
  case 5: // TRIANGLE_STRIP
537
- meshCfg.primitive = "triangles";
554
+ meshCfg.primitive = backfaces ? "triangles" : "solid";
538
555
  break;
539
556
  case 6: // TRIANGLE_FAN
540
- meshCfg.primitive = "triangles";
557
+ meshCfg.primitive = backfaces ? "triangles" : "solid";
541
558
  break;
542
559
  default:
543
- meshCfg.primitive = "triangles";
560
+ meshCfg.primitive = backfaces ? "triangles" : "solid";
544
561
  }
545
562
 
546
563
  const POSITION = primitive.attributes.POSITION;
@@ -569,17 +586,6 @@ function loadNode(ctx, node, depth, matrix) {
569
586
  meshCfg.origin = origin;
570
587
  }
571
588
 
572
- const material = primitive.material;
573
- if (material) {
574
- meshCfg.textureSetId = material._textureSetId;
575
- meshCfg.color = material._attributes.color;
576
- meshCfg.opacity = material._attributes.opacity;
577
- meshCfg.metallic = material._attributes.metallic;
578
- meshCfg.roughness = material._attributes.roughness;
579
- } else {
580
- meshCfg.color = new Float32Array([1.0, 1.0, 1.0]);
581
- meshCfg.opacity = 1.0;
582
- }
583
589
  // if (createEntity) {
584
590
  // if (createEntity.colorize) {
585
591
  // meshCfg.color = createEntity.colorize;
@@ -202,6 +202,7 @@ class PickController {
202
202
  if (this.snappedOrPicked) {
203
203
  if (this.snapPickResult) {
204
204
  const pickResult = new PickResult();
205
+ pickResult.entity = this.snapPickResult.entity;
205
206
  pickResult.snappedToVertex = this.snapPickResult.snappedToVertex;
206
207
  pickResult.snappedToEdge = this.snapPickResult.snappedToEdge;
207
208
  pickResult.worldPos = this.snapPickResult.worldPos;
@@ -156,7 +156,7 @@ class MousePanRotateDollyHandler {
156
156
  }
157
157
  });
158
158
 
159
- document.addEventListener("mousemove", this._documentMouseMoveHandler = () => {
159
+ document.addEventListener("mousemove", this._documentMouseMoveHandler = (e) => {
160
160
 
161
161
  if (!(configs.active && configs.pointerEnabled)) {
162
162
  return;
@@ -177,10 +177,10 @@ class MousePanRotateDollyHandler {
177
177
 
178
178
  const panning = keyDown[scene.input.KEY_SHIFT] || configs.planView || (!configs.panRightClick && mouseDownMiddle) || (configs.panRightClick && mouseDownRight);
179
179
 
180
- if (panning) {
180
+ const xDelta = document.pointerLockElement ? e.movementX : (x - lastX);
181
+ const yDelta = document.pointerLockElement ? e.movementY : (y - lastY);
181
182
 
182
- const xPanDelta = (x - lastX);
183
- const yPanDelta = (y - lastY);
183
+ if (panning) {
184
184
 
185
185
  const camera = scene.camera;
186
186
 
@@ -191,13 +191,13 @@ class MousePanRotateDollyHandler {
191
191
  const depth = Math.abs(mouseDownPicked ? math.lenVec3(math.subVec3(pickedWorldPos, scene.camera.eye, [])) : scene.camera.eyeLookDist);
192
192
  const targetDistance = depth * Math.tan((camera.perspective.fov / 2) * Math.PI / 180.0);
193
193
 
194
- updates.panDeltaX += (1.5 * xPanDelta * targetDistance / canvasHeight);
195
- updates.panDeltaY += (1.5 * yPanDelta * targetDistance / canvasHeight);
194
+ updates.panDeltaX += (1.5 * xDelta * targetDistance / canvasHeight);
195
+ updates.panDeltaY += (1.5 * yDelta * targetDistance / canvasHeight);
196
196
 
197
197
  } else {
198
198
 
199
- updates.panDeltaX += 0.5 * camera.ortho.scale * (xPanDelta / canvasHeight);
200
- updates.panDeltaY += 0.5 * camera.ortho.scale * (yPanDelta / canvasHeight);
199
+ updates.panDeltaX += 0.5 * camera.ortho.scale * (xDelta / canvasHeight);
200
+ updates.panDeltaY += 0.5 * camera.ortho.scale * (yDelta / canvasHeight);
201
201
  }
202
202
 
203
203
  } else if (mouseDownLeft && !mouseDownMiddle && !mouseDownRight) {
@@ -205,12 +205,12 @@ class MousePanRotateDollyHandler {
205
205
  if (!configs.planView) { // No rotating in plan-view mode
206
206
 
207
207
  if (configs.firstPerson) {
208
- updates.rotateDeltaY -= ((x - lastX) / canvasWidth) * configs.dragRotationRate / 2;
209
- updates.rotateDeltaX += ((y - lastY) / canvasHeight) * (configs.dragRotationRate / 4);
208
+ updates.rotateDeltaY -= (xDelta / canvasWidth) * configs.dragRotationRate / 2;
209
+ updates.rotateDeltaX += (yDelta / canvasHeight) * (configs.dragRotationRate / 4);
210
210
 
211
211
  } else {
212
- updates.rotateDeltaY -= ((x - lastX) / canvasWidth) * (configs.dragRotationRate * 1.5);
213
- updates.rotateDeltaX += ((y - lastY) / canvasHeight) * (configs.dragRotationRate * 1.5);
212
+ updates.rotateDeltaY -= (xDelta / canvasWidth) * (configs.dragRotationRate * 1.5);
213
+ updates.rotateDeltaX += (yDelta / canvasHeight) * (configs.dragRotationRate * 1.5);
214
214
  }
215
215
  }
216
216
  }
@@ -18,4 +18,5 @@ export * from "./utils/index.js";
18
18
  export * from "./Component.js";
19
19
  export * from "./utils.js";
20
20
  export * from "./stats.js";
21
- export * from "./constants/constants.js";
21
+ export * from "./constants/constants.js";
22
+ export * from "./webgl/PickResult.js";
@@ -2669,7 +2669,7 @@ export class SceneModel extends Component {
2669
2669
  return;
2670
2670
  }
2671
2671
  let parentTransform;
2672
- if (this.parentTransformId) {
2672
+ if (cfg.parentTransformId) {
2673
2673
  parentTransform = this._transforms[cfg.parentTransformId];
2674
2674
  if (!parentTransform) {
2675
2675
  this.error("[createTransform] SceneModel.createTransform() config missing: id");