@combeenation/3d-viewer 9.3.0 → 10.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@combeenation/3d-viewer",
3
- "version": "9.3.0",
3
+ "version": "10.0.0",
4
4
  "description": "Combeenation 3D Viewer",
5
5
  "homepage": "https://github.com/Combeenation/3d-viewer#readme",
6
6
  "bugs": {
@@ -26,14 +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
  "clean-dist": "rimraf dist",
29
- "dev": "cross-env NODE_ENV='dev' webpack serve --config build/webpack.conf.js --progress --hot",
29
+ "dev": "cross-env NODE_ENV='development' webpack serve --config build/webpack.debug.conf.js --progress --hot",
30
30
  "dist-cjs": "npm run clean-dist && npm run lint && tsc --project commonjs.tsconfig.json && npm run replace-version",
31
- "dist-es6": "npm run clean-dist && npm run lint && tsc --project es6.tsconfig.json && npm run replace-version",
32
- "dist-full": "npm run clean-dist && npm run lint && cross-env NODE_ENV='production' webpack --config build/webpack.conf.js --progress && npm run replace-version",
31
+ "dist-full-dev": "npm run clean-dist && npm run lint && cross-env NODE_ENV='development' webpack --config build/webpack.build.conf.js --progress && npm run replace-version",
32
+ "dist-full-prod": "npm run clean-dist && npm run lint && cross-env NODE_ENV='production' webpack --config build/webpack.build.conf.js --progress && npm run replace-version",
33
33
  "docs-local": "typedoc --tsconfig tsconfig.json --media doc/assets --out docs-local",
34
34
  "docs-publish": "typedoc --tsconfig tsconfig.json --media doc/assets --out docs",
35
35
  "format": "prettier --write ./src",
36
- "generate-profile": "cross-env NODE_ENV='dev' webpack --config build/webpack.conf.js --profile --json > dist/webpack-stats.json",
36
+ "generate-profile": "cross-env NODE_ENV='development' webpack --config build/webpack.build.conf.js --profile --json > dist/webpack-stats.json",
37
37
  "lint": "eslint src/**",
38
38
  "pack": "npm run dist-cjs && npm pack",
39
39
  "pack-to-cjs": "npm run dist-cjs && npm pack --pack-destination=\"/mnt/c/Data/dev/custom-js/MichaelTest/TextureLoadEventsTest/\"",
@@ -47,8 +47,10 @@
47
47
  "prettier": "@combeenation/prettier-config",
48
48
  "dependencies": {
49
49
  "@babylonjs/core": "5.27.1",
50
+ "@babylonjs/inspector": "5.27.1",
50
51
  "@babylonjs/loaders": "5.27.1",
51
52
  "@babylonjs/materials": "5.27.1",
53
+ "@babylonjs/node-editor": "5.27.1",
52
54
  "@babylonjs/serializers": "5.27.1",
53
55
  "eventemitter3": "4.0.7",
54
56
  "gsap": "3.11.2",
@@ -57,7 +57,7 @@ export class Element extends VariantParameterizable {
57
57
  */
58
58
  protected constructor(public readonly variant: Variant, public readonly name: string) {
59
59
  super(variant, name);
60
- if (process.env.NODE_ENV?.toLowerCase().includes('dev')) {
60
+ if (process.env.NODE_ENV === 'development') {
61
61
  this.assertPathDefinitions();
62
62
  }
63
63
  const nodes = this.variant.inheritedNodes.map(node => {
@@ -7,7 +7,7 @@ import { TagManager } from '../manager/tagManager';
7
7
  import { VariantInstanceManager } from '../manager/variantInstanceManager';
8
8
  import { SpecStorage } from '../store/specStorage';
9
9
  import { backgroundDomeName, envHelperMetadataName } from '../util/babylonHelper';
10
- import { debounce, loadJavascript, loadJson } from '../util/resourceHelper';
10
+ import { debounce, loadJson } from '../util/resourceHelper';
11
11
  import { getCustomCbnBabylonLoaderPlugin } from '../util/sceneLoaderHelper';
12
12
  import { replaceDots } from '../util/stringHelper';
13
13
  import { isNodeIncludedInExclusionList } from '../util/structureHelper';
@@ -20,7 +20,6 @@ import { VariantInstance } from './variantInstance';
20
20
  import { ArcRotateCamera } from '@babylonjs/core/Cameras/arcRotateCamera';
21
21
  import { PickingInfo } from '@babylonjs/core/Collisions/pickingInfo';
22
22
  import { BoundingInfo } from '@babylonjs/core/Culling/boundingInfo';
23
- import { DebugLayer } from '@babylonjs/core/Debug/debugLayer';
24
23
  import { Engine } from '@babylonjs/core/Engines/engine';
25
24
  import { IPointerEvent } from '@babylonjs/core/Events/deviceInputEvents';
26
25
  import { EnvironmentHelper } from '@babylonjs/core/Helpers/environmentHelper';
@@ -66,8 +65,6 @@ export class Viewer extends EventBroadcaster {
66
65
 
67
66
  protected _isRenderLoopPaused: boolean = false;
68
67
 
69
- protected _inspectorLoaded: boolean = false;
70
-
71
68
  protected _nodeNamingStrategyHandler: NodeNamingStrategyHandler | null = null;
72
69
 
73
70
  static version = buildInfo.version;
@@ -341,23 +338,42 @@ export class Viewer extends EventBroadcaster {
341
338
 
342
339
  /**
343
340
  * Enables the Babylon.js [Inspector](https://doc.babylonjs.com/toolsAndResources/tools/inspector).\
344
- * Due to the additional size of the inspector, the CDN version is used instead of shipping the required code with
345
- * the viewer.\
346
- * This means that the code will be downloaded only when needed and calling `enableDebugLayer` can take a little while
347
- * depending on your internet connection etc.
348
- */
349
- public async enableDebugLayer(options?: IInspectorOptions) {
350
- if (!this._inspectorLoaded) {
351
- // CDN version of inspector requires the Babylon.js core to be available as CDN module as well
352
- await loadJavascript('https://cdn.jsdelivr.net/npm/babylonjs@5.6.0/babylon.min.js');
341
+ * Due to the additional size of the inspector, this function is only available in "development" builds!
342
+ *
343
+ * @returns Signalizes if inspector could be loaded
344
+ */
345
+ public async enableDebugLayer(options?: IInspectorOptions): Promise<boolean> {
346
+ if (process.env.NODE_ENV === 'development') {
347
+ const inspModule = await import(/* webpackChunkName: "inspector"*/ '@babylonjs/inspector');
348
+
349
+ if (!options && window.Cbn) {
350
+ // special case for usage in Combeenation configurator:
351
+ // if no options are set the inspector will be rendered into the parent element of the configurator
352
+ // in this way the configurator layout itself will not be affected by the inspector
353
+ const cfgrParentEl = window.Cbn.utils.Viewer3dHelper.getCfgrParentDomElementForInspector();
354
+ inspModule.Inspector.Show(this.scene, { globalRoot: cfgrParentEl });
355
+ } else {
356
+ inspModule.Inspector.Show(this.scene, options ?? {});
357
+ }
353
358
 
354
- DebugLayer.InspectorURL =
355
- 'https://cdn.jsdelivr.net/npm/babylonjs-inspector@5.6.0/babylon.inspector.bundle.max.min.js';
359
+ // load additional packages for certain inspector features like "node material editor"
360
+ // this is done after showing the debug layer to save time
361
+ await import(/* webpackChunkName: "node-material-editor" */ '@babylonjs/node-editor');
356
362
 
357
- this._inspectorLoaded = true;
358
- }
363
+ return true;
364
+ } else {
365
+ // inspector not available, set according warning message in console
366
+ if (window.Cbn) {
367
+ console.warn(`Inspector not loaded.
368
+ The inspector can only be used in development builds (e.g. during development with watch mode, in the configurator preview, ...)
369
+ but not in production (e.g. production build of Custom JS, published configurator, ...).`);
370
+ } else {
371
+ console.warn(`Inspector not loaded.
372
+ The inspector can only be used in development builds.`);
373
+ }
359
374
 
360
- await this.scene.debugLayer.show(options);
375
+ return false;
376
+ }
361
377
  }
362
378
 
363
379
  /**
@@ -230,7 +230,6 @@ export class ViewerLight extends VariantParameterizable {
230
230
  if (!parameters['direction']) {
231
231
  throw new Error(`The ViewerLight "${lightId}" of type "${definition.type}" needs a "direction".`);
232
232
  }
233
- // @ts-ignore es6 build doesn't allow dynamic imports
234
233
  const hemisphericLightModule = await import(
235
234
  /* webpackChunkName: "hemispheric-light" */ '@babylonjs/core/Lights/hemisphericLight'
236
235
  );
@@ -238,7 +237,6 @@ export class ViewerLight extends VariantParameterizable {
238
237
  break;
239
238
  }
240
239
  case 'point': {
241
- // @ts-ignore es6 build doesn't allow dynamic imports
242
240
  const pointLightModule = await import(
243
241
  /* webpackChunkName: "point-light" */ '@babylonjs/core/Lights/pointLight'
244
242
  );
@@ -253,7 +251,6 @@ export class ViewerLight extends VariantParameterizable {
253
251
  if (!parameters['direction']) {
254
252
  throw new Error(`The ViewerLight "${lightId}" of type "${definition.type}" needs a "direction".`);
255
253
  }
256
- // @ts-ignore es6 build doesn't allow dynamic imports
257
254
  const directionalLightModule = await import(
258
255
  /* webpackChunkName: "directional-light" */ '@babylonjs/core/Lights/directionalLight'
259
256
  );
@@ -270,7 +267,6 @@ export class ViewerLight extends VariantParameterizable {
270
267
  if (!parameters['exponent']) {
271
268
  throw new Error(`The ViewerLight "${lightId}" of type "${definition.type}" needs an "exponent".`);
272
269
  }
273
- // @ts-ignore es6 build doesn't allow dynamic imports
274
270
  const spotLightModule = await import(/* webpackChunkName: "spot-light" */ '@babylonjs/core/Lights/spotLight');
275
271
  babylonLight = new spotLightModule.SpotLight(
276
272
  lightId,
@@ -79,7 +79,6 @@ const processCamera = async function (scene: Scene, name: string, cameraSetup: C
79
79
  }
80
80
  switch (cameraSetup.type) {
81
81
  case 'arc': {
82
- // @ts-ignore es6 build doesn't allow dynamic imports
83
82
  const arcCameraModule = await import(
84
83
  /* webpackChunkName: "arc-rotate-camera" */ '@babylonjs/core/Cameras/arcRotateCamera'
85
84
  );
@@ -168,7 +167,6 @@ const sceneSetup = async function (engine: Engine, sceneJson: SceneJson): Promis
168
167
  scene.imageProcessingConfiguration.exposure = sceneJson.scene.globals['camera-settings']!.exposure;
169
168
  }
170
169
  if (sceneJson.scene.globals['camera-settings']!.dof && sceneJson.scene.globals['camera-settings']!.dof.enabled) {
171
- // @ts-ignore es6 build doesn't allow dynamic imports
172
170
  const module = await import(/* webpackChunkName: "lens-rendering" */ './lensRendering');
173
171
  new module.LensRenderingPipeline(
174
172
  'lens-rendering',
package/src/dev.ts CHANGED
@@ -36,6 +36,14 @@ window.Cbn = {
36
36
  },
37
37
  reportDuplicateNodeName(nodeNameOrArrayOfNodeNames: string | string[]): void {},
38
38
  },
39
+ utils: {
40
+ Viewer3dHelper: {
41
+ getCfgrParentDomElementForInspector() {
42
+ // render in parent of viewer
43
+ return document.querySelector<HTMLElement>('display-container') ?? undefined;
44
+ },
45
+ },
46
+ },
39
47
  };
40
48
 
41
49
  async function main() {
package/src/types.d.ts CHANGED
@@ -34,5 +34,16 @@ interface Window {
34
34
  */
35
35
  reportDuplicateNodeName(nodeNameOrArrayOfNodeNames: string | string[]): void;
36
36
  };
37
+ utils: {
38
+ Viewer3dHelper: {
39
+ /**
40
+ * Returns parent DOM element of a Combeenation configurator, which can be used as root for the inspector.
41
+ * Also adjusts styling of some configurator parent sub elements to fix the inspector layout.
42
+ *
43
+ * @return
44
+ */
45
+ getCfgrParentDomElementForInspector(): HTMLElement | undefined;
46
+ };
47
+ };
37
48
  };
38
49
  }