@combeenation/3d-viewer 5.2.0-alpha4 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/dist/lib-cjs/api/classes/dottedPath.js +1 -1
  2. package/dist/lib-cjs/api/classes/dottedPath.js.map +1 -1
  3. package/dist/lib-cjs/api/classes/element.js +3 -2
  4. package/dist/lib-cjs/api/classes/element.js.map +1 -1
  5. package/dist/lib-cjs/api/classes/parameter.d.ts +6 -3
  6. package/dist/lib-cjs/api/classes/parameter.js +8 -5
  7. package/dist/lib-cjs/api/classes/parameter.js.map +1 -1
  8. package/dist/lib-cjs/api/classes/placementAnimation.js +2 -1
  9. package/dist/lib-cjs/api/classes/placementAnimation.js.map +1 -1
  10. package/dist/lib-cjs/api/classes/variant.d.ts +1 -1
  11. package/dist/lib-cjs/api/classes/variant.js +7 -7
  12. package/dist/lib-cjs/api/classes/variant.js.map +1 -1
  13. package/dist/lib-cjs/api/classes/variantInstance.d.ts +0 -1
  14. package/dist/lib-cjs/api/classes/variantInstance.js +27 -23
  15. package/dist/lib-cjs/api/classes/variantInstance.js.map +1 -1
  16. package/dist/lib-cjs/api/classes/variantParameterizable.d.ts +2 -2
  17. package/dist/lib-cjs/api/classes/variantParameterizable.js +2 -2
  18. package/dist/lib-cjs/api/classes/viewer.d.ts +4 -2
  19. package/dist/lib-cjs/api/classes/viewer.js +6 -5
  20. package/dist/lib-cjs/api/classes/viewer.js.map +1 -1
  21. package/dist/lib-cjs/api/classes/viewerLight.js +14 -9
  22. package/dist/lib-cjs/api/classes/viewerLight.js.map +1 -1
  23. package/dist/lib-cjs/api/internal/sceneSetup.js +5 -4
  24. package/dist/lib-cjs/api/internal/sceneSetup.js.map +1 -1
  25. package/dist/lib-cjs/api/manager/animationManager.js +3 -3
  26. package/dist/lib-cjs/api/manager/animationManager.js.map +1 -1
  27. package/dist/lib-cjs/api/manager/gltfExportManager.d.ts +2 -2
  28. package/dist/lib-cjs/api/manager/gltfExportManager.js +5 -4
  29. package/dist/lib-cjs/api/manager/gltfExportManager.js.map +1 -1
  30. package/dist/lib-cjs/api/util/babylonHelper.js +20 -26
  31. package/dist/lib-cjs/api/util/babylonHelper.js.map +1 -1
  32. package/dist/lib-cjs/api/util/globalTypes.d.ts +11 -7
  33. package/dist/lib-cjs/api/util/resourceHelper.js +5 -3
  34. package/dist/lib-cjs/api/util/resourceHelper.js.map +1 -1
  35. package/dist/lib-cjs/api/util/sceneLoaderHelper.d.ts +2 -2
  36. package/dist/lib-cjs/api/util/sceneLoaderHelper.js +5 -7
  37. package/dist/lib-cjs/api/util/sceneLoaderHelper.js.map +1 -1
  38. package/dist/lib-cjs/api/util/stringHelper.d.ts +1 -1
  39. package/dist/lib-cjs/api/util/stringHelper.js +4 -2
  40. package/dist/lib-cjs/api/util/stringHelper.js.map +1 -1
  41. package/dist/lib-cjs/buildinfo.json +1 -1
  42. package/dist/lib-cjs/commonjs.tsconfig.tsbuildinfo +1 -0
  43. package/dist/lib-es6/api/classes/dottedPath.js +1 -1
  44. package/dist/lib-es6/api/classes/dottedPath.js.map +1 -1
  45. package/dist/lib-es6/api/classes/element.js +5 -4
  46. package/dist/lib-es6/api/classes/element.js.map +1 -1
  47. package/dist/lib-es6/api/classes/parameter.d.ts +6 -3
  48. package/dist/lib-es6/api/classes/parameter.js +8 -5
  49. package/dist/lib-es6/api/classes/parameter.js.map +1 -1
  50. package/dist/lib-es6/api/classes/placementAnimation.js +2 -1
  51. package/dist/lib-es6/api/classes/placementAnimation.js.map +1 -1
  52. package/dist/lib-es6/api/classes/variant.d.ts +1 -1
  53. package/dist/lib-es6/api/classes/variant.js +9 -9
  54. package/dist/lib-es6/api/classes/variant.js.map +1 -1
  55. package/dist/lib-es6/api/classes/variantInstance.d.ts +0 -1
  56. package/dist/lib-es6/api/classes/variantInstance.js +27 -23
  57. package/dist/lib-es6/api/classes/variantInstance.js.map +1 -1
  58. package/dist/lib-es6/api/classes/variantParameterizable.d.ts +2 -2
  59. package/dist/lib-es6/api/classes/variantParameterizable.js +2 -2
  60. package/dist/lib-es6/api/classes/viewer.d.ts +4 -2
  61. package/dist/lib-es6/api/classes/viewer.js +6 -5
  62. package/dist/lib-es6/api/classes/viewer.js.map +1 -1
  63. package/dist/lib-es6/api/classes/viewerLight.js +14 -9
  64. package/dist/lib-es6/api/classes/viewerLight.js.map +1 -1
  65. package/dist/lib-es6/api/internal/sceneSetup.js +5 -4
  66. package/dist/lib-es6/api/internal/sceneSetup.js.map +1 -1
  67. package/dist/lib-es6/api/manager/animationManager.js +3 -3
  68. package/dist/lib-es6/api/manager/animationManager.js.map +1 -1
  69. package/dist/lib-es6/api/manager/gltfExportManager.d.ts +2 -2
  70. package/dist/lib-es6/api/manager/gltfExportManager.js +5 -4
  71. package/dist/lib-es6/api/manager/gltfExportManager.js.map +1 -1
  72. package/dist/lib-es6/api/manager/sceneManager.js +1 -1
  73. package/dist/lib-es6/api/manager/sceneManager.js.map +1 -1
  74. package/dist/lib-es6/api/util/babylonHelper.js +20 -26
  75. package/dist/lib-es6/api/util/babylonHelper.js.map +1 -1
  76. package/dist/lib-es6/api/util/globalTypes.d.ts +11 -7
  77. package/dist/lib-es6/api/util/resourceHelper.js +5 -3
  78. package/dist/lib-es6/api/util/resourceHelper.js.map +1 -1
  79. package/dist/lib-es6/api/util/sceneLoaderHelper.d.ts +2 -2
  80. package/dist/lib-es6/api/util/sceneLoaderHelper.js +4 -6
  81. package/dist/lib-es6/api/util/sceneLoaderHelper.js.map +1 -1
  82. package/dist/lib-es6/api/util/stringHelper.d.ts +1 -1
  83. package/dist/lib-es6/api/util/stringHelper.js +4 -2
  84. package/dist/lib-es6/api/util/stringHelper.js.map +1 -1
  85. package/dist/lib-es6/buildinfo.json +1 -1
  86. package/dist/lib-es6/es6.tsconfig.tsbuildinfo +1 -0
  87. package/package.json +33 -30
  88. package/src/api/classes/dottedPath.ts +1 -1
  89. package/src/api/classes/element.ts +3 -2
  90. package/src/api/classes/parameter.ts +8 -5
  91. package/src/api/classes/placementAnimation.ts +2 -1
  92. package/src/api/classes/variant.ts +9 -9
  93. package/src/api/classes/variantInstance.ts +24 -24
  94. package/src/api/classes/variantParameterizable.ts +2 -2
  95. package/src/api/classes/viewer.ts +8 -7
  96. package/src/api/classes/viewerLight.ts +14 -9
  97. package/src/api/internal/debugViewer.ts +1 -1
  98. package/src/api/internal/sceneSetup.ts +6 -5
  99. package/src/api/manager/animationManager.ts +3 -3
  100. package/src/api/manager/gltfExportManager.ts +5 -4
  101. package/src/api/util/babylonHelper.ts +18 -36
  102. package/src/api/util/globalTypes.ts +11 -7
  103. package/src/api/util/resourceHelper.ts +5 -3
  104. package/src/api/util/sceneLoaderHelper.ts +3 -7
  105. package/src/api/util/stringHelper.ts +4 -4
  106. package/dist/lib-full/lens-rendering.js +0 -2
  107. package/dist/lib-full/lens-rendering.js.map +0 -1
  108. package/dist/lib-full/main.js +0 -3
  109. package/dist/lib-full/main.js.LICENSE.txt +0 -9
  110. package/dist/lib-full/main.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@combeenation/3d-viewer",
3
- "version": "5.2.0-alpha4",
3
+ "version": "6.0.0",
4
4
  "description": "Combeenation 3D Viewer",
5
5
  "homepage": "https://github.com/Combeenation/3d-viewer#readme",
6
6
  "bugs": {
@@ -26,13 +26,14 @@
26
26
  "scripts": {
27
27
  "bundle-analyzer": "npm run generate-profile && webpack-bundle-analyzer dist/webpack-stats.json dist/lib-full",
28
28
  "dev": "cross-env NODE_ENV='dev' webpack serve --config build/webpack.conf.js --progress --hot",
29
- "dist-cjs": "tsc --project commonjs.tsconfig.json && npm run replace-version",
30
- "dist-es6": "tsc --project es6.tsconfig.json && npm run replace-version",
31
- "dist-full": "cross-env NODE_ENV='production' webpack --config build/webpack.conf.js --progress && npm run replace-version",
29
+ "dist-cjs": "npm run lint && tsc --project commonjs.tsconfig.json && npm run replace-version",
30
+ "dist-es6": "npm run lint && tsc --project es6.tsconfig.json && npm run replace-version",
31
+ "dist-full": "npm run lint && cross-env NODE_ENV='production' webpack --config build/webpack.conf.js --progress && npm run replace-version",
32
32
  "docs-local": "typedoc --tsconfig tsconfig.json --media doc/assets --out docs-local",
33
33
  "docs-publish": "typedoc --tsconfig tsconfig.json --media doc/assets --out docs",
34
34
  "format": "prettier --write .",
35
35
  "generate-profile": "cross-env NODE_ENV='dev' webpack --config build/webpack.conf.js --profile --json > dist/webpack-stats.json",
36
+ "lint": "eslint src/**",
36
37
  "pack": "npm run dist-cjs && npm pack",
37
38
  "pack-to-cjs": "npm run dist-cjs && npm pack --pack-destination=\"../custom-js/Swissmobilia/moebelsystem\"",
38
39
  "pub-alpha": "npm run dist-cjs && npm publish --tag alpha",
@@ -44,33 +45,35 @@
44
45
  },
45
46
  "prettier": "@combeenation/prettier-config",
46
47
  "dependencies": {
47
- "@babylonjs/core": "5.25.0",
48
- "@babylonjs/loaders": "5.25.0",
49
- "@babylonjs/materials": "5.25.0",
50
- "@babylonjs/serializers": "5.25.0",
51
- "eventemitter3": "^4.0.7",
52
- "gsap": "^3.11.2",
53
- "lodash-es": "^4.17.21"
48
+ "@babylonjs/core": "5.27.1",
49
+ "@babylonjs/loaders": "5.27.1",
50
+ "@babylonjs/materials": "5.27.1",
51
+ "@babylonjs/serializers": "5.27.1",
52
+ "eventemitter3": "4.0.7",
53
+ "gsap": "3.11.2",
54
+ "lodash-es": "4.17.21"
54
55
  },
55
56
  "devDependencies": {
56
- "@combeenation/prettier-config": "^0.0.3",
57
- "@combeenation/ts-config": "^0.0.2",
58
- "@knodes/typedoc-plugin-pages": "^0.23.1",
59
- "@types/lodash-es": "^4.17.6",
60
- "clean-webpack-plugin": "^4.0.0",
61
- "cross-env": "^7.0.3",
62
- "html-webpack-plugin": "^5.5.0",
63
- "prettier": "^2.7.1",
64
- "replace": "^1.2.1",
65
- "terser-webpack-plugin": "^5.3.6",
66
- "ts-loader": "^9.4.1",
67
- "typedoc": "^0.23.15",
68
- "typedoc-plugin-merge-modules": "^4.0.1",
69
- "typescript": "^4.8.4",
70
- "webpack": "^5.74.0",
71
- "webpack-bundle-analyzer": "^4.6.1",
72
- "webpack-cli": "^4.10.0",
73
- "webpack-dev-server": "^4.11.1",
74
- "webpack-merge": "^5.8.0"
57
+ "@combeenation/eslint-config": "0.0.5",
58
+ "@combeenation/prettier-config": "0.0.3",
59
+ "@combeenation/ts-config": "0.0.2",
60
+ "@knodes/typedoc-plugin-pages": "0.23.1",
61
+ "@types/lodash-es": "4.17.6",
62
+ "clean-webpack-plugin": "4.0.0",
63
+ "cross-env": "7.0.3",
64
+ "eslint": "8.25.0",
65
+ "html-webpack-plugin": "5.5.0",
66
+ "prettier": "2.7.1",
67
+ "replace": "1.2.1",
68
+ "terser-webpack-plugin": "5.3.6",
69
+ "ts-loader": "9.4.1",
70
+ "typedoc": "0.23.15",
71
+ "typedoc-plugin-merge-modules": "4.0.1",
72
+ "typescript": "4.8.4",
73
+ "webpack": "5.74.0",
74
+ "webpack-bundle-analyzer": "4.6.1",
75
+ "webpack-cli": "4.10.0",
76
+ "webpack-dev-server": "4.11.1",
77
+ "webpack-merge": "5.8.0"
75
78
  }
76
79
  }
@@ -107,7 +107,7 @@ export class DottedPath {
107
107
  * ["part1", "part1.part2", "part1.part2.part_3"]
108
108
  */
109
109
  get leafTokens(): string[] {
110
- let parents: string[] = [];
110
+ const parents: string[] = [];
111
111
  return this.parts.map(part => {
112
112
  parents.push(part);
113
113
  return DottedPath.create(parents).path;
@@ -313,7 +313,8 @@ export class Element extends VariantParameterizable {
313
313
  }
314
314
 
315
315
  // TODO: Not sure if this really should be overwritten every time the paintable is redrawn.
316
- // Maybe the 3D artist had something in mind when setting a certain transparency mode, which would get overwritten in this case.
316
+ // Maybe the 3D artist had something in mind when setting a certain transparency mode, which would get overwritten
317
+ // in this case.
317
318
  // Applying it as a default if no material is set is fine though (see roughness/metallic some lines above).
318
319
  // Removing this line will most likely break existing configurators, so be cautios!
319
320
  node.material.transparencyMode = Material.MATERIAL_ALPHATESTANDBLEND;
@@ -699,7 +700,7 @@ export class Element extends VariantParameterizable {
699
700
  * Handles callback for given light parameter.
700
701
  */
701
702
  private async castShadowValueHandler(lightCsl: ParameterValue, mutator: CallableFunction) {
702
- let lights: Light[] = [];
703
+ const lights: Light[] = [];
703
704
  for (const lightName of Parameter.parseCommaSeparatedList(lightCsl)) {
704
705
  const viewerLight = await this.variant.getViewerLight(lightName);
705
706
  if (viewerLight) {
@@ -283,9 +283,11 @@ export class Parameter {
283
283
  public static readonly ENVIRONMENT_INTENSITY = 'environment.intensity';
284
284
 
285
285
  /**
286
- * Background texture on a [PhotoDome](https://doc.babylonjs.com/divingDeeper/environment/360PhotoDome). Just background, no IBL or reflection.
286
+ * Background texture on a [PhotoDome](https://doc.babylonjs.com/divingDeeper/environment/360PhotoDome).
287
+ * Just background, no IBL or reflection.
287
288
  *
288
- * Recommended format is `*.jpg`. HDR files are not supported as background but can be converted to `*.jpg` using tools like Photoshop, Gimp or various free online converters.
289
+ * Recommended format is `*.jpg`. HDR files are not supported as background but can be converted to `*.jpg` using
290
+ * tools like Photoshop, Gimp or various free online converters.
289
291
  *
290
292
  * See [environment page](./../pages/Documentation/Environment.html) for details on how to use this.
291
293
  *
@@ -401,7 +403,7 @@ export class Parameter {
401
403
  let cleanedValue = value.split(' ').join('');
402
404
  if (cleanedValue.startsWith('(') && cleanedValue.endsWith(')')) {
403
405
  cleanedValue = cleanedValue.substring(1, cleanedValue.length - 1);
404
- let [x, y, z] = cleanedValue.split(',').map(value => parseFloat(value));
406
+ const [x, y, z] = cleanedValue.split(',').map(value => parseFloat(value));
405
407
  return new Vector3(x, y, z);
406
408
  } else {
407
409
  throw new Error(`Unable to parse "${value}" to a Vector: expected "(x,y,z)".`);
@@ -457,14 +459,15 @@ export class Parameter {
457
459
  }
458
460
  if (cleanedValue.startsWith('(') && cleanedValue.endsWith(')')) {
459
461
  cleanedValue = cleanedValue.substring(1, cleanedValue.length - 1);
460
- let [r, g, b] = cleanedValue.split(',').map(value => parseFloat(value));
462
+ const [r, g, b] = cleanedValue.split(',').map(value => parseFloat(value));
461
463
  return Color3.FromInts(r, g, b);
462
464
  }
463
465
  throw new Error(`Unable to parse "${value}" to a Color: expected "#rrggbb" or "(r,g,b)".`);
464
466
  }
465
467
 
466
468
  /**
467
- * Parses a `boolean` string (`'true'`/`'1'` or `'false'`/`'0'`) or `number` (`1` or `0`) to a `boolean` or `undefined`.
469
+ * Parses a `boolean` string (`'true'`/`'1'` or `'false'`/`'0'`) or `number` (`1` or `0`) to a `boolean` or
470
+ * `undefined`.
468
471
  */
469
472
  public static parseBoolean(value: ParameterValue): boolean {
470
473
  if (value.toString() === 'true' || value.toString() === '1') {
@@ -130,7 +130,8 @@ export class PlacementAnimation implements AnimationInterface {
130
130
  delete this._placementDefinition.position;
131
131
  ghostCam.dispose();
132
132
  } else if (this._animationDefinition.shortestWay && this._placementDefinition.alpha !== undefined) {
133
- // transform the target's alpha value into the same turn as the current camera position to avoid movements > 360 degrees
133
+ // transform the target's alpha value into the same turn as the current camera position to avoid movements
134
+ // > 360 degrees
134
135
  const alphaGap = this.mutable.alpha - this._placementDefinition.alpha;
135
136
  const cntTurns = Math.round(alphaGap / (2 * Math.PI));
136
137
  this._placementDefinition.alpha += 2 * Math.PI * cntTurns;
@@ -1,6 +1,6 @@
1
1
  import { deactivateTransformNode, getDottedPathForNode, injectNodeMetadata } from '../util/babylonHelper';
2
2
  import { loadJson, mergeMaps } from '../util/resourceHelper';
3
- import { getMaterialFromCbnAssets } from '../util/sceneLoaderHelper';
3
+ import { createMaterialFromCbnAssets } from '../util/sceneLoaderHelper';
4
4
  import { DottedPath } from './dottedPath';
5
5
  import { Element } from './element';
6
6
  import { Event } from './event';
@@ -30,7 +30,7 @@ import '@babylonjs/loaders/glTF/2.0/Extensions/KHR_materials_variants';
30
30
  import '@babylonjs/loaders/glTF/2.0/Extensions/KHR_texture_basisu';
31
31
  import '@babylonjs/loaders/glTF/2.0/Extensions/KHR_texture_transform';
32
32
  import '@babylonjs/loaders/glTF/2.0/glTFLoader';
33
- import { cloneDeep, concat, get, has, isElement, isEmpty, isEqual, isString, merge, reject, set } from 'lodash-es';
33
+ import { cloneDeep, concat, get, isEmpty, isEqual, isString, merge, set } from 'lodash-es';
34
34
 
35
35
  /**
36
36
  * A concrete "Variant". Most of these are handled by either the {@link Viewer} or {@link VariantInstance}.
@@ -265,7 +265,7 @@ export class Variant extends Parameterizable {
265
265
  * The {@link ParameterDeclarations} inherited from this {@link Variant}'s parents.
266
266
  */
267
267
  get inheritedParameterDeclaration(): ParameterDeclarations {
268
- let declaration = {};
268
+ const declaration = {};
269
269
  this.ancestors.forEach(ancestor => {
270
270
  merge(declaration, ancestor.parameterDeclaration);
271
271
  });
@@ -276,7 +276,7 @@ export class Variant extends Parameterizable {
276
276
  * The {@link ParameterBag} inherited from this {@link Variant}'s parents.
277
277
  */
278
278
  get inheritedParameters(): ParameterBag {
279
- let parameters = {};
279
+ const parameters = {};
280
280
  this.ancestors.forEach(ancestor => {
281
281
  merge(parameters, ancestor.parameters);
282
282
  });
@@ -424,7 +424,7 @@ export class Variant extends Parameterizable {
424
424
  /**
425
425
  * Gets the Material defined in one of the variants glTFs by its id.
426
426
  */
427
- public getMaterial(id: string): Material {
427
+ public getOrCreateMaterial(id: string): Material {
428
428
  const scene = this.viewer.scene;
429
429
 
430
430
  for (const material of this.inheritedMaterials) {
@@ -438,7 +438,7 @@ export class Variant extends Parameterizable {
438
438
  return material;
439
439
  }
440
440
  }
441
- const cbnAssetMaterial = getMaterialFromCbnAssets(id, scene);
441
+ const cbnAssetMaterial = createMaterialFromCbnAssets(id, scene);
442
442
  if (cbnAssetMaterial) {
443
443
  return cbnAssetMaterial;
444
444
  }
@@ -727,7 +727,7 @@ export class Variant extends Parameterizable {
727
727
  protected async commitParameterToElements(parameter: string, value: ParameterValue): Promise<Variant> {
728
728
  const promises = [];
729
729
  for (const element of this.elements) {
730
- const paramShowsElement = Parameter.VISIBLE === parameter && value;
730
+ const paramShowsVariant = Parameter.VISIBLE === parameter && value;
731
731
 
732
732
  // Fixes https://combeenation.youtrack.cloud/issue/CB-7773
733
733
  // Don't enable/show the variants element if it is explicitly hidden via its element parameters.
@@ -750,7 +750,7 @@ export class Variant extends Parameterizable {
750
750
  const elVisibleParamValue = this.inheritedParameters[elVisibleParamPath];
751
751
  const elVisibleParamValueParsed = elVisibleParamValue && Parameter.parseBoolean(elVisibleParamValue);
752
752
  const elIsHiddenViaParams = elVisibleParamValueParsed === false;
753
- if (paramShowsElement && elIsHiddenViaParams) continue;
753
+ if (paramShowsVariant && elIsHiddenViaParams) continue;
754
754
 
755
755
  // To discuss: Is this a viable solution or is it too hacky to apply the elements material param, when the param
756
756
  // at hand is actually the visible param?
@@ -759,7 +759,7 @@ export class Variant extends Parameterizable {
759
759
  // is never shown when "overwritten" by elements material param.
760
760
  const elMaterialParamPath = DottedPath.create([element.name, Parameter.MATERIAL]).toString();
761
761
  const elMaterialParamValue = this.inheritedParameters[elMaterialParamPath];
762
- if (paramShowsElement && elMaterialParamValue) {
762
+ if (paramShowsVariant && elMaterialParamValue) {
763
763
  // To discuss: Should we rather use `this.commitParametersToElements` here?
764
764
  // I'm not really sure about the actual differences, both seem to do the job 🤷‍♂️
765
765
  // To discuss: Should we actively `await` this (as is) or should we also push the resulting promise into the
@@ -19,33 +19,33 @@ export class VariantInstance extends EventBroadcaster {
19
19
  /**
20
20
  * WORK IN PROGRESS
21
21
  */
22
- public translate(
23
- joint: DottedPathArgument,
24
- variantInstance: VariantInstance,
25
- variantInstanceJoint: DottedPathArgument
26
- ): VariantInstance {
27
- /*
28
- joint = DottedPath.create( joint );
29
- variantInstanceJoint = DottedPath.create( variantInstanceJoint );
30
- const jointNode = variantInstance.variant.getNode( joint.path );
31
- const variantInstanceJointNode = variantInstance.variant.getNode( variantInstanceJoint.path );
32
- const differenceVector = variantInstanceJointNode.getAbsolutePosition().subtract( jointNode.getAbsolutePosition() );
33
- const differenceVectorRotation = variantInstanceJointNode.rotation.subtract( jointNode.rotation );
22
+ /*
23
+ public translate(
24
+ joint: DottedPathArgument,
25
+ variantInstance: VariantInstance,
26
+ variantInstanceJoint: DottedPathArgument
27
+ ): VariantInstance {
28
+ joint = DottedPath.create( joint );
29
+ variantInstanceJoint = DottedPath.create( variantInstanceJoint );
30
+ const jointNode = variantInstance.variant.getNode( joint.path );
31
+ const variantInstanceJointNode = variantInstance.variant.getNode( variantInstanceJoint.path );
32
+ const differenceVector = variantInstanceJointNode.getAbsolutePosition().subtract( jointNode.getAbsolutePosition() );
33
+ const differenceVectorRotation = variantInstanceJointNode.rotation.subtract( jointNode.rotation );
34
34
 
35
- console.log( variantInstanceJointNode.rotationQuaternion, 'ROTATION' );
35
+ console.log( variantInstanceJointNode.rotationQuaternion, 'ROTATION' );
36
36
 
37
- this.variant.nodes.forEach( node => {
38
- node.translate( Axis.X, differenceVector.x, Space.WORLD );
39
- node.translate( Axis.Y, differenceVector.y, Space.WORLD );
40
- node.translate( Axis.Z, differenceVector.z, Space.WORLD );
37
+ this.variant.nodes.forEach( node => {
38
+ node.translate( Axis.X, differenceVector.x, Space.WORLD );
39
+ node.translate( Axis.Y, differenceVector.y, Space.WORLD );
40
+ node.translate( Axis.Z, differenceVector.z, Space.WORLD );
41
41
 
42
- node.rotateAround( Axis.Y, differenceVectorRotation, 20 );
43
- // node.rotate(Axis.Y, differenceVectorRotation.y, Space.WORLD );
44
- // node.rotate(Axis.Z, differenceVectorRotation.z, Space.WORLD );
45
- } );
46
- */
47
- return this;
48
- }
42
+ node.rotateAround( Axis.Y, differenceVectorRotation, 20 );
43
+ // node.rotate(Axis.Y, differenceVectorRotation.y, Space.WORLD );
44
+ // node.rotate(Axis.Z, differenceVectorRotation.z, Space.WORLD );
45
+ } );
46
+ return this;
47
+ }
48
+ */
49
49
 
50
50
  /**
51
51
  * A proxy for {@link Variant.getElement}.
@@ -37,8 +37,8 @@ export abstract class VariantParameterizable extends Parameterizable {
37
37
  }
38
38
 
39
39
  /**
40
- * Places the given {@link ParameterBag} in the {@link VariantParameterizable}'s parameters, replaces all patterns in the
41
- * {@link StructureJson} and broadcasts all {@link ParameterObserver}s.
40
+ * Places the given {@link ParameterBag} in the {@link VariantParameterizable}'s parameters, replaces all patterns in
41
+ * the {@link StructureJson} and broadcasts all {@link ParameterObserver}s.
42
42
  */
43
43
  public async commitParameters(parameters?: ParameterBag): Promise<VariantParameterizable> {
44
44
  if (!parameters) {
@@ -209,8 +209,10 @@ export class Viewer extends EventBroadcaster {
209
209
 
210
210
  /**
211
211
  * Enables the BabylonJS [Inspector](https://doc.babylonjs.com/toolsAndResources/tools/inspector).\
212
- * Due to the additional size of the inspector, the CDN version is used instead of shipping the required code with the viewer.\
213
- * This means that the code will be downloaded only when needed and calling `enableDebugLayer` can take a little while depending on your internet connection etc.
212
+ * Due to the additional size of the inspector, the CDN version is used instead of shipping the required code with
213
+ * the viewer.\
214
+ * This means that the code will be downloaded only when needed and calling `enableDebugLayer` can take a little while
215
+ * depending on your internet connection etc.
214
216
  */
215
217
  public async enableDebugLayer(options?: IInspectorOptions) {
216
218
  if (!this._inspectorLoaded) {
@@ -451,10 +453,8 @@ export class Viewer extends EventBroadcaster {
451
453
  const plane = Mesh.CreatePlane('TextPlane', size, scene, true);
452
454
  plane.material = new StandardMaterial('TextPlaneMaterial', scene);
453
455
  plane.material.backFaceCulling = false;
454
- // @ts-ignore
455
- plane.material.specularColor = new Color3(0, 0, 0);
456
- // @ts-ignore
457
- plane.material.diffuseTexture = dynamicTexture;
456
+ (plane.material as StandardMaterial).specularColor = new Color3(0, 0, 0);
457
+ (plane.material as StandardMaterial).diffuseTexture = dynamicTexture;
458
458
  return plane;
459
459
  };
460
460
 
@@ -613,7 +613,8 @@ export class Viewer extends EventBroadcaster {
613
613
 
614
614
  // `minZ` is the camera distance beyond which the mesh will be clipped
615
615
  // this should be very low, but can't be zero
616
- // a good value seems to be 1% of the bounding box size (= radius), whereas the value shouldn't go above 1, which is also the default value
616
+ // a good value seems to be 1% of the bounding box size (= radius), whereas the value shouldn't go above 1, which is
617
+ // also the default value
617
618
  const radius = boundingBox.getBoundingInfo().boundingSphere.radius;
618
619
  helperCamera.minZ = Math.min(radius / 100, 1);
619
620
 
@@ -211,7 +211,7 @@ export class ViewerLight extends VariantParameterizable {
211
211
  let lightId = this.id;
212
212
  let babylonLight;
213
213
  switch (definition.type) {
214
- case 'baked':
214
+ case 'baked': {
215
215
  if (!definition['path']) {
216
216
  throw new Error(`The light "${lightId}" of type "${definition.type}" needs a "path".`);
217
217
  }
@@ -225,18 +225,20 @@ export class ViewerLight extends VariantParameterizable {
225
225
  throw new Error(`No light found for path "${definition['path']}" in ViewerLight "${lightId}".`);
226
226
  }
227
227
  break;
228
- case 'hemispheric':
228
+ }
229
+ case 'hemispheric': {
229
230
  if (!parameters['direction']) {
230
231
  throw new Error(`The ViewerLight "${lightId}" of type "${definition.type}" needs a "direction".`);
231
232
  }
232
- // @ts-ignore
233
+ // @ts-ignore es6 build doesn't allow dynamic imports
233
234
  const hemisphericLightModule = await import(
234
235
  /* webpackChunkName: "hemispheric-light" */ '@babylonjs/core/Lights/hemisphericLight'
235
236
  );
236
237
  babylonLight = new hemisphericLightModule.HemisphericLight(lightId, parameters['direction'], scene);
237
238
  break;
238
- case 'point':
239
- // @ts-ignore
239
+ }
240
+ case 'point': {
241
+ // @ts-ignore es6 build doesn't allow dynamic imports
240
242
  const pointLightModule = await import(
241
243
  /* webpackChunkName: "point-light" */ '@babylonjs/core/Lights/pointLight'
242
244
  );
@@ -246,17 +248,19 @@ export class ViewerLight extends VariantParameterizable {
246
248
  scene
247
249
  );
248
250
  break;
249
- case 'directional':
251
+ }
252
+ case 'directional': {
250
253
  if (!parameters['direction']) {
251
254
  throw new Error(`The ViewerLight "${lightId}" of type "${definition.type}" needs a "direction".`);
252
255
  }
253
- // @ts-ignore
256
+ // @ts-ignore es6 build doesn't allow dynamic imports
254
257
  const directionalLightModule = await import(
255
258
  /* webpackChunkName: "directional-light" */ '@babylonjs/core/Lights/directionalLight'
256
259
  );
257
260
  babylonLight = new directionalLightModule.DirectionalLight(lightId, parameters['direction'], scene);
258
261
  break;
259
- case 'spot':
262
+ }
263
+ case 'spot': {
260
264
  if (!parameters['direction']) {
261
265
  throw new Error(`The ViewerLight "${lightId}" of type "${definition.type}" needs a "direction".`);
262
266
  }
@@ -266,7 +270,7 @@ export class ViewerLight extends VariantParameterizable {
266
270
  if (!parameters['exponent']) {
267
271
  throw new Error(`The ViewerLight "${lightId}" of type "${definition.type}" needs an "exponent".`);
268
272
  }
269
- // @ts-ignore
273
+ // @ts-ignore es6 build doesn't allow dynamic imports
270
274
  const spotLightModule = await import(/* webpackChunkName: "spot-light" */ '@babylonjs/core/Lights/spotLight');
271
275
  babylonLight = new spotLightModule.SpotLight(
272
276
  lightId,
@@ -277,6 +281,7 @@ export class ViewerLight extends VariantParameterizable {
277
281
  scene
278
282
  );
279
283
  break;
284
+ }
280
285
  default:
281
286
  throw new Error(`The type "${definition.type}" for ViewerLight "${lightId}" is not implemented (yet).`);
282
287
  }
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * @internal
3
3
  */
4
+ /// <reference path="../util/globalTypes.ts" />
4
5
  import { Event } from '../classes/event';
5
- import { VariantInstance } from '../classes/variantInstance';
6
6
  import { Viewer } from '../classes/viewer';
7
7
  import { Scene } from '@babylonjs/core/scene';
8
8
 
@@ -9,7 +9,7 @@ import { GroundMesh } from '@babylonjs/core/Meshes/groundMesh';
9
9
  import { MeshBuilder } from '@babylonjs/core/Meshes/meshBuilder';
10
10
  import { DefaultRenderingPipeline } from '@babylonjs/core/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline';
11
11
  import { Scene } from '@babylonjs/core/scene';
12
- import { get, isEmpty, set } from 'lodash-es';
12
+ import { get, isEmpty } from 'lodash-es';
13
13
 
14
14
  const defaultSceneClearColor = new Color4(0, 0, 0, 0);
15
15
  const defaultEnvHelperColor = new Color4(1, 1, 1, 0);
@@ -78,8 +78,8 @@ const processCamera = async function (scene: Scene, name: string, cameraSetup: C
78
78
  target = Parameter.parseVector(cameraSetup.target);
79
79
  }
80
80
  switch (cameraSetup.type) {
81
- case 'arc':
82
- // @ts-ignore
81
+ case 'arc': {
82
+ // @ts-ignore es6 build doesn't allow dynamic imports
83
83
  const arcCameraModule = await import(
84
84
  /* webpackChunkName: "arc-rotate-camera" */ '@babylonjs/core/Cameras/arcRotateCamera'
85
85
  );
@@ -90,6 +90,7 @@ const processCamera = async function (scene: Scene, name: string, cameraSetup: C
90
90
  radius: 2,
91
91
  };
92
92
  break;
93
+ }
93
94
  }
94
95
  if (cameraSetup.active) {
95
96
  camera.attachControl(scene.getEngine().getRenderingCanvas()!, true);
@@ -112,7 +113,7 @@ const sceneSetup = async function (engine: Engine, sceneJson: SceneJson): Promis
112
113
  const cameras: Camera[] = [];
113
114
  const cameraDefinitions = get(sceneJson.scene, 'cameras') as CameraDefinitions;
114
115
  if (!isEmpty(cameraDefinitions)) {
115
- for (let cameraName in cameraDefinitions) {
116
+ for (const cameraName in cameraDefinitions) {
116
117
  cameras.push(await processCamera(scene, cameraName, cameraDefinitions[cameraName]));
117
118
  }
118
119
  } else {
@@ -167,7 +168,7 @@ const sceneSetup = async function (engine: Engine, sceneJson: SceneJson): Promis
167
168
  scene.imageProcessingConfiguration.exposure = sceneJson.scene.globals['camera-settings']!.exposure;
168
169
  }
169
170
  if (sceneJson.scene.globals['camera-settings']!.dof && sceneJson.scene.globals['camera-settings']!.dof.enabled) {
170
- //@ts-ignore
171
+ // @ts-ignore es6 build doesn't allow dynamic imports
171
172
  const module = await import(/* webpackChunkName: "lens-rendering" */ './lensRendering');
172
173
  new module.LensRenderingPipeline(
173
174
  'lens-rendering',
@@ -30,7 +30,7 @@ export class AnimationManager {
30
30
  */
31
31
  public resetCamera(animate: boolean = false) {
32
32
  //TODO currently only works for arcrotate. are there any other cameras?
33
- let activeCamera = this.scene.activeCamera as Nullable<ArcRotateCamera>;
33
+ const activeCamera = this.scene.activeCamera as Nullable<ArcRotateCamera>;
34
34
  if (!activeCamera) {
35
35
  throw new Error('There is no active camera');
36
36
  }
@@ -52,7 +52,7 @@ export class AnimationManager {
52
52
  * @deprecated Use viewer.moveCameraTo().
53
53
  */
54
54
  public animateArcRotateCamera(targetAlpha: number, targetBeta: number, targetRadius: number) {
55
- let activeCamera = this.scene.activeCamera as Nullable<ArcRotateCamera>;
55
+ const activeCamera = this.scene.activeCamera as Nullable<ArcRotateCamera>;
56
56
  if (!activeCamera) {
57
57
  throw new Error('There is no active camera');
58
58
  }
@@ -111,7 +111,7 @@ export class AnimationManager {
111
111
  activeCamera.animations.push(betaAnimation);
112
112
  activeCamera.animations.push(radiusAnimation);
113
113
 
114
- let animation = this.scene.beginAnimation(activeCamera, 0, 100, false, 10);
114
+ const animation = this.scene.beginAnimation(activeCamera, 0, 100, false, 10);
115
115
  animation.disposeOnEnd = true;
116
116
  }
117
117
 
@@ -23,7 +23,7 @@ export class GltfExportManager {
23
23
  * Exports selected nodes to a file.
24
24
  * @param filename optional name of the exported .GLB file.
25
25
  * @param exportOptions export options to be merged with default options.
26
- * @param excluded optional list of geometry (meshes, elements, variants, variantInstances) to be excluded from export.
26
+ * @param excluded optional list of geometry (meshes, elements, variants, variantInstances) to be excluded from export
27
27
  */
28
28
  public async exportGlb(
29
29
  filename = 'glb-export.glb',
@@ -55,7 +55,7 @@ export class GltfExportManager {
55
55
  * Exports selected nodes to GLTF. This may result in more than one file, since textures are exported separately.
56
56
  * @param filename name of the main (text-based) .GLTF file referring to separate texture files.
57
57
  * @param exportOptions export options to be merged with default options.
58
- * @param excluded optional list of geometry (meshes, elements, variants, variantInstances) to be excluded from export.
58
+ * @param excluded optional list of geometry (meshes, elements, variants, variantInstances) to be excluded from export
59
59
  */
60
60
  public async exportGltfToFile(filename: string, exportOptions: IExportOptions = {}, excluded?: ExcludedGeometryList) {
61
61
  this.exportPreProcess();
@@ -134,7 +134,8 @@ export class GltfExportManager {
134
134
  if (!(n.material instanceof PBRMaterial)) continue;
135
135
  if (!(n.material as PBRMaterial).subSurface.isRefractionEnabled) continue;
136
136
  if ((n.material as PBRMaterial).transparencyMode !== PBRMaterial.PBRMATERIAL_OPAQUE) continue;
137
- // if we're here, we have a node holding a material with set refraction whose transparencyMode is set to PBRMATERIAL_OPAQUE
137
+ // if we're here, we have a node holding a material with set refraction whose transparencyMode is set to
138
+ // PBRMATERIAL_OPAQUE
138
139
  n.material = this.createRefractionMaterialReplacement(n.material);
139
140
  }
140
141
  }
@@ -168,7 +169,7 @@ export class GltfExportManager {
168
169
  if (this.isMaterialClonedForExport(mat)) return mat;
169
170
 
170
171
  // change material according to https://www.notion.so/combeenation/Glas-materials-don-t-look-glasy-after-export-d5fda2c6515e4420a8772744d3e6b460
171
- let clonedMaterial = mat.clone(mat.name); // clone material. clone uses same name
172
+ const clonedMaterial = mat.clone(mat.name); // clone material. clone uses same name
172
173
  clonedMaterial.metadata = { ...mat.metadata, clonedFrom: mat.uniqueId }; // create shallow copy of metadata on clone. see https://forum.babylonjs.com/t/the-metadata-of-the-mesh-cloned-by-the-instantiatemodelstoscene-method-is-a-shallow-copy/21563
173
174
  clonedMaterial.refractionTexture = null;
174
175
  clonedMaterial.metallicReflectanceTexture = null; // is this the correct one for metallic roughness?