@combeenation/3d-viewer 5.1.2 → 5.2.0-alpha1
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 +111 -111
- package/dist/lib-cjs/buildinfo.json +3 -3
- package/dist/lib-cjs/commonjs.tsconfig.tsbuildinfo +1 -0
- package/dist/lib-cjs/{api → src/api}/classes/animationInterface.d.ts +8 -8
- package/dist/lib-cjs/src/api/classes/animationInterface.js +3 -0
- package/dist/lib-cjs/src/api/classes/animationInterface.js.map +1 -0
- package/dist/{lib-es6 → lib-cjs/src}/api/classes/dottedPath.d.ts +79 -79
- package/dist/lib-cjs/src/api/classes/dottedPath.js +167 -0
- package/dist/lib-cjs/src/api/classes/dottedPath.js.map +1 -0
- package/dist/lib-cjs/{api → src/api}/classes/element.d.ts +149 -149
- package/dist/lib-cjs/src/api/classes/element.js +669 -0
- package/dist/lib-cjs/src/api/classes/element.js.map +1 -0
- package/dist/{lib-es6 → lib-cjs/src}/api/classes/event.d.ts +326 -326
- package/dist/lib-cjs/src/api/classes/event.js +350 -0
- package/dist/lib-cjs/src/api/classes/event.js.map +1 -0
- package/dist/{lib-es6 → lib-cjs/src}/api/classes/eventBroadcaster.d.ts +26 -26
- package/dist/lib-cjs/src/api/classes/eventBroadcaster.js +50 -0
- package/dist/lib-cjs/src/api/classes/eventBroadcaster.js.map +1 -0
- package/dist/{lib-es6 → lib-cjs/src}/api/classes/parameter.d.ts +336 -336
- package/dist/lib-cjs/src/api/classes/parameter.js +462 -0
- package/dist/lib-cjs/src/api/classes/parameter.js.map +1 -0
- package/dist/lib-cjs/{api → src/api}/classes/parameterObservable.d.ts +36 -36
- package/dist/lib-cjs/src/api/classes/parameterObservable.js +98 -0
- package/dist/lib-cjs/src/api/classes/parameterObservable.js.map +1 -0
- package/dist/lib-cjs/{api → src/api}/classes/parameterizable.d.ts +15 -15
- package/dist/lib-cjs/src/api/classes/parameterizable.js +103 -0
- package/dist/lib-cjs/src/api/classes/parameterizable.js.map +1 -0
- package/dist/lib-cjs/{api → src/api}/classes/placementAnimation.d.ts +45 -44
- package/dist/lib-cjs/{api → src/api}/classes/placementAnimation.js +175 -163
- package/dist/lib-cjs/src/api/classes/placementAnimation.js.map +1 -0
- package/dist/{lib-es6 → lib-cjs/src}/api/classes/variant.d.ts +234 -234
- package/dist/lib-cjs/src/api/classes/variant.js +837 -0
- package/dist/lib-cjs/src/api/classes/variant.js.map +1 -0
- package/dist/lib-cjs/{api → src/api}/classes/variantInstance.d.ts +45 -45
- package/dist/lib-cjs/src/api/classes/variantInstance.js +102 -0
- package/dist/lib-cjs/src/api/classes/variantInstance.js.map +1 -0
- package/dist/{lib-es6 → lib-cjs/src}/api/classes/variantParameterizable.d.ts +17 -17
- package/dist/lib-cjs/src/api/classes/variantParameterizable.js +89 -0
- package/dist/lib-cjs/src/api/classes/variantParameterizable.js.map +1 -0
- package/dist/lib-cjs/{api → src/api}/classes/viewer.d.ts +187 -184
- package/dist/lib-cjs/src/api/classes/viewer.js +594 -0
- package/dist/lib-cjs/src/api/classes/viewer.js.map +1 -0
- package/dist/lib-cjs/{api → src/api}/classes/viewerLight.d.ts +66 -66
- package/dist/lib-cjs/src/api/classes/viewerLight.js +344 -0
- package/dist/lib-cjs/src/api/classes/viewerLight.js.map +1 -0
- package/dist/{lib-es6 → lib-cjs/src}/api/internal/lensRendering.d.ts +8 -8
- package/dist/lib-cjs/{api → src/api}/internal/lensRendering.js +11 -11
- package/dist/lib-cjs/src/api/internal/lensRendering.js.map +1 -0
- package/dist/{lib-es6 → lib-cjs/src}/api/internal/sceneSetup.d.ts +13 -13
- package/dist/lib-cjs/src/api/internal/sceneSetup.js +226 -0
- package/dist/lib-cjs/src/api/internal/sceneSetup.js.map +1 -0
- package/dist/lib-cjs/{api → src/api}/manager/animationManager.d.ts +30 -29
- package/dist/lib-cjs/src/api/manager/animationManager.js +127 -0
- package/dist/lib-cjs/src/api/manager/animationManager.js.map +1 -0
- package/dist/lib-cjs/{api → src/api}/manager/gltfExportManager.d.ts +65 -65
- package/dist/lib-cjs/src/api/manager/gltfExportManager.js +197 -0
- package/dist/lib-cjs/src/api/manager/gltfExportManager.js.map +1 -0
- package/dist/lib-cjs/{api → src/api}/manager/sceneManager.d.ts +31 -31
- package/dist/lib-cjs/src/api/manager/sceneManager.js +128 -0
- package/dist/lib-cjs/src/api/manager/sceneManager.js.map +1 -0
- package/dist/{lib-es6 → lib-cjs/src}/api/manager/variantInstanceManager.d.ts +92 -92
- package/dist/lib-cjs/src/api/manager/variantInstanceManager.js +261 -0
- package/dist/lib-cjs/src/api/manager/variantInstanceManager.js.map +1 -0
- package/dist/{lib-es6 → lib-cjs/src}/api/store/specStorage.d.ts +24 -24
- package/dist/lib-cjs/{api → src/api}/store/specStorage.js +50 -51
- package/dist/lib-cjs/src/api/store/specStorage.js.map +1 -0
- package/dist/{lib-es6 → lib-cjs/src}/api/util/babylonHelper.d.ts +174 -174
- package/dist/lib-cjs/{api → src/api}/util/babylonHelper.js +591 -611
- package/dist/lib-cjs/src/api/util/babylonHelper.js.map +1 -0
- package/dist/{lib-es6 → lib-cjs/src}/api/util/globalTypes.d.ts +366 -366
- package/dist/lib-cjs/src/api/util/globalTypes.js +2 -0
- package/dist/lib-cjs/src/api/util/globalTypes.js.map +1 -0
- package/dist/lib-cjs/{api → src/api}/util/resourceHelper.d.ts +58 -58
- package/dist/lib-cjs/src/api/util/resourceHelper.js +202 -0
- package/dist/lib-cjs/src/api/util/resourceHelper.js.map +1 -0
- package/dist/lib-cjs/{api → src/api}/util/sceneLoaderHelper.d.ts +35 -35
- package/dist/lib-cjs/{api → src/api}/util/sceneLoaderHelper.js +141 -140
- package/dist/lib-cjs/src/api/util/sceneLoaderHelper.js.map +1 -0
- package/dist/{lib-es6 → lib-cjs/src}/api/util/stringHelper.d.ts +9 -9
- package/dist/lib-cjs/{api → src/api}/util/stringHelper.js +23 -25
- package/dist/lib-cjs/src/api/util/stringHelper.js.map +1 -0
- package/dist/{lib-es6 → lib-cjs/src}/api/util/structureHelper.d.ts +9 -9
- package/dist/lib-cjs/{api → src/api}/util/structureHelper.js +48 -48
- package/dist/lib-cjs/src/api/util/structureHelper.js.map +1 -0
- package/dist/lib-cjs/{index.d.ts → src/index.d.ts} +51 -49
- package/dist/lib-cjs/{index.js → src/index.js} +110 -89
- package/dist/lib-cjs/src/index.js.map +1 -0
- package/dist/lib-es6/buildinfo.json +3 -3
- package/dist/lib-es6/es6.tsconfig.tsbuildinfo +1 -0
- package/dist/lib-es6/{api → src/api}/classes/animationInterface.d.ts +8 -8
- package/dist/lib-es6/src/api/classes/animationInterface.js +2 -0
- package/dist/lib-es6/src/api/classes/animationInterface.js.map +1 -0
- package/dist/{lib-cjs → lib-es6/src}/api/classes/dottedPath.d.ts +79 -79
- package/dist/lib-es6/src/api/classes/dottedPath.js +163 -0
- package/dist/lib-es6/src/api/classes/dottedPath.js.map +1 -0
- package/dist/lib-es6/{api → src/api}/classes/element.d.ts +149 -149
- package/dist/lib-es6/src/api/classes/element.js +665 -0
- package/dist/lib-es6/src/api/classes/element.js.map +1 -0
- package/dist/{lib-cjs → lib-es6/src}/api/classes/event.d.ts +326 -326
- package/dist/lib-es6/src/api/classes/event.js +346 -0
- package/dist/lib-es6/src/api/classes/event.js.map +1 -0
- package/dist/{lib-cjs → lib-es6/src}/api/classes/eventBroadcaster.d.ts +26 -26
- package/dist/lib-es6/src/api/classes/eventBroadcaster.js +43 -0
- package/dist/lib-es6/src/api/classes/eventBroadcaster.js.map +1 -0
- package/dist/{lib-cjs → lib-es6/src}/api/classes/parameter.d.ts +336 -336
- package/dist/lib-es6/src/api/classes/parameter.js +458 -0
- package/dist/lib-es6/src/api/classes/parameter.js.map +1 -0
- package/dist/lib-es6/{api → src/api}/classes/parameterObservable.d.ts +36 -36
- package/dist/lib-es6/src/api/classes/parameterObservable.js +94 -0
- package/dist/lib-es6/src/api/classes/parameterObservable.js.map +1 -0
- package/dist/lib-es6/{api → src/api}/classes/parameterizable.d.ts +15 -15
- package/dist/lib-es6/src/api/classes/parameterizable.js +99 -0
- package/dist/lib-es6/src/api/classes/parameterizable.js.map +1 -0
- package/dist/lib-es6/{api → src/api}/classes/placementAnimation.d.ts +45 -44
- package/dist/lib-es6/{api → src/api}/classes/placementAnimation.js +171 -160
- package/dist/lib-es6/src/api/classes/placementAnimation.js.map +1 -0
- package/dist/{lib-cjs → lib-es6/src}/api/classes/variant.d.ts +234 -234
- package/dist/lib-es6/src/api/classes/variant.js +833 -0
- package/dist/lib-es6/src/api/classes/variant.js.map +1 -0
- package/dist/lib-es6/{api → src/api}/classes/variantInstance.d.ts +45 -45
- package/dist/lib-es6/src/api/classes/variantInstance.js +98 -0
- package/dist/lib-es6/src/api/classes/variantInstance.js.map +1 -0
- package/dist/{lib-cjs → lib-es6/src}/api/classes/variantParameterizable.d.ts +17 -17
- package/dist/lib-es6/src/api/classes/variantParameterizable.js +85 -0
- package/dist/lib-es6/src/api/classes/variantParameterizable.js.map +1 -0
- package/dist/lib-es6/{api → src/api}/classes/viewer.d.ts +187 -184
- package/dist/lib-es6/src/api/classes/viewer.js +587 -0
- package/dist/lib-es6/src/api/classes/viewer.js.map +1 -0
- package/dist/lib-es6/{api → src/api}/classes/viewerLight.d.ts +66 -66
- package/dist/lib-es6/src/api/classes/viewerLight.js +317 -0
- package/dist/lib-es6/src/api/classes/viewerLight.js.map +1 -0
- package/dist/{lib-cjs → lib-es6/src}/api/internal/lensRendering.d.ts +8 -8
- package/dist/lib-es6/{api → src/api}/internal/lensRendering.js +8 -8
- package/dist/lib-es6/src/api/internal/lensRendering.js.map +1 -0
- package/dist/{lib-cjs → lib-es6/src}/api/internal/sceneSetup.d.ts +13 -13
- package/dist/lib-es6/src/api/internal/sceneSetup.js +198 -0
- package/dist/lib-es6/src/api/internal/sceneSetup.js.map +1 -0
- package/dist/lib-es6/{api → src/api}/manager/animationManager.d.ts +30 -29
- package/dist/lib-es6/src/api/manager/animationManager.js +123 -0
- package/dist/lib-es6/src/api/manager/animationManager.js.map +1 -0
- package/dist/lib-es6/{api → src/api}/manager/gltfExportManager.d.ts +65 -65
- package/dist/lib-es6/{api → src/api}/manager/gltfExportManager.js +192 -220
- package/dist/lib-es6/src/api/manager/gltfExportManager.js.map +1 -0
- package/dist/lib-es6/{api → src/api}/manager/sceneManager.d.ts +31 -31
- package/dist/lib-es6/src/api/manager/sceneManager.js +124 -0
- package/dist/lib-es6/src/api/manager/sceneManager.js.map +1 -0
- package/dist/{lib-cjs → lib-es6/src}/api/manager/variantInstanceManager.d.ts +92 -92
- package/dist/lib-es6/src/api/manager/variantInstanceManager.js +257 -0
- package/dist/lib-es6/src/api/manager/variantInstanceManager.js.map +1 -0
- package/dist/{lib-cjs → lib-es6/src}/api/store/specStorage.d.ts +24 -24
- package/dist/lib-es6/{api → src/api}/store/specStorage.js +46 -48
- package/dist/lib-es6/src/api/store/specStorage.js.map +1 -0
- package/dist/{lib-cjs → lib-es6/src}/api/util/babylonHelper.d.ts +174 -174
- package/dist/lib-es6/{api → src/api}/util/babylonHelper.js +561 -581
- package/dist/lib-es6/src/api/util/babylonHelper.js.map +1 -0
- package/dist/{lib-cjs → lib-es6/src}/api/util/globalTypes.d.ts +366 -366
- package/dist/lib-es6/src/api/util/globalTypes.js +2 -0
- package/dist/lib-es6/src/api/util/globalTypes.js.map +1 -0
- package/dist/lib-es6/{api → src/api}/util/resourceHelper.d.ts +58 -58
- package/dist/lib-es6/src/api/util/resourceHelper.js +192 -0
- package/dist/lib-es6/src/api/util/resourceHelper.js.map +1 -0
- package/dist/lib-es6/{api → src/api}/util/sceneLoaderHelper.d.ts +35 -35
- package/dist/lib-es6/{api → src/api}/util/sceneLoaderHelper.js +131 -133
- package/dist/lib-es6/src/api/util/sceneLoaderHelper.js.map +1 -0
- package/dist/{lib-cjs → lib-es6/src}/api/util/stringHelper.d.ts +9 -9
- package/dist/lib-es6/{api → src/api}/util/stringHelper.js +19 -21
- package/dist/lib-es6/src/api/util/stringHelper.js.map +1 -0
- package/dist/{lib-cjs → lib-es6/src}/api/util/structureHelper.d.ts +9 -9
- package/dist/lib-es6/{api → src/api}/util/structureHelper.js +45 -45
- package/dist/lib-es6/src/api/util/structureHelper.js.map +1 -0
- package/dist/lib-es6/{index.js → src/index.d.ts} +51 -51
- package/dist/lib-es6/{index.d.ts → src/index.js} +49 -49
- package/dist/lib-es6/src/index.js.map +1 -0
- package/dist/lib-full/lens-rendering.js +2 -0
- package/dist/lib-full/lens-rendering.js.map +1 -0
- package/dist/lib-full/main.js +3 -0
- package/dist/lib-full/main.js.LICENSE.txt +9 -0
- package/dist/lib-full/main.js.map +1 -0
- package/package.json +76 -88
- package/src/api/classes/animationInterface.ts +10 -10
- package/src/api/classes/dottedPath.ts +181 -181
- package/src/api/classes/element.ts +716 -716
- package/src/api/classes/event.ts +367 -367
- package/src/api/classes/eventBroadcaster.ts +52 -52
- package/src/api/classes/parameter.ts +494 -494
- package/src/api/classes/parameterObservable.ts +100 -100
- package/src/api/classes/parameterizable.ts +87 -87
- package/src/api/classes/placementAnimation.ts +161 -160
- package/src/api/classes/variant.ts +904 -905
- package/src/api/classes/variantInstance.ts +97 -97
- package/src/api/classes/variantParameterizable.ts +85 -85
- package/src/api/classes/viewer.ts +669 -668
- package/src/api/classes/viewerLight.ts +334 -334
- package/src/api/internal/debugViewer.ts +90 -90
- package/src/api/internal/lensRendering.ts +9 -10
- package/src/api/internal/sceneSetup.ts +204 -204
- package/src/api/manager/animationManager.ts +143 -142
- package/src/api/manager/gltfExportManager.ts +191 -191
- package/src/api/manager/sceneManager.ts +127 -127
- package/src/api/manager/variantInstanceManager.ts +265 -265
- package/src/api/store/specStorage.ts +51 -51
- package/src/api/util/babylonHelper.ts +663 -663
- package/src/api/util/globalTypes.ts +413 -413
- package/src/api/util/resourceHelper.ts +189 -189
- package/src/api/util/sceneLoaderHelper.ts +148 -147
- package/src/api/util/stringHelper.ts +23 -23
- package/src/api/util/structureHelper.ts +49 -49
- package/src/dev.ts +61 -64
- package/src/index.ts +96 -94
- package/src/types.d.ts +28 -28
- package/dist/lib-cjs/api/classes/animationInterface.js +0 -2
- package/dist/lib-cjs/api/classes/animationInterface.js.map +0 -1
- package/dist/lib-cjs/api/classes/dottedPath.js +0 -188
- package/dist/lib-cjs/api/classes/dottedPath.js.map +0 -1
- package/dist/lib-cjs/api/classes/element.js +0 -824
- package/dist/lib-cjs/api/classes/element.js.map +0 -1
- package/dist/lib-cjs/api/classes/elementParameterizable.d.ts +0 -14
- package/dist/lib-cjs/api/classes/elementParameterizable.js +0 -135
- package/dist/lib-cjs/api/classes/elementParameterizable.js.map +0 -1
- package/dist/lib-cjs/api/classes/event.js +0 -372
- package/dist/lib-cjs/api/classes/event.js.map +0 -1
- package/dist/lib-cjs/api/classes/eventBroadcaster.js +0 -54
- package/dist/lib-cjs/api/classes/eventBroadcaster.js.map +0 -1
- package/dist/lib-cjs/api/classes/parameter.js +0 -472
- package/dist/lib-cjs/api/classes/parameter.js.map +0 -1
- package/dist/lib-cjs/api/classes/parameterObservable.js +0 -102
- package/dist/lib-cjs/api/classes/parameterObservable.js.map +0 -1
- package/dist/lib-cjs/api/classes/parameterizable.js +0 -150
- package/dist/lib-cjs/api/classes/parameterizable.js.map +0 -1
- package/dist/lib-cjs/api/classes/placementAnimation.js.map +0 -1
- package/dist/lib-cjs/api/classes/variant.js +0 -1204
- package/dist/lib-cjs/api/classes/variant.js.map +0 -1
- package/dist/lib-cjs/api/classes/variantInstance.js +0 -109
- package/dist/lib-cjs/api/classes/variantInstance.js.map +0 -1
- package/dist/lib-cjs/api/classes/variantParameterizable.js +0 -100
- package/dist/lib-cjs/api/classes/variantParameterizable.js.map +0 -1
- package/dist/lib-cjs/api/classes/viewer.js +0 -732
- package/dist/lib-cjs/api/classes/viewer.js.map +0 -1
- package/dist/lib-cjs/api/classes/viewerLight.js +0 -393
- package/dist/lib-cjs/api/classes/viewerLight.js.map +0 -1
- package/dist/lib-cjs/api/internal/debugViewer.d.ts +0 -13
- package/dist/lib-cjs/api/internal/debugViewer.js +0 -87
- package/dist/lib-cjs/api/internal/debugViewer.js.map +0 -1
- package/dist/lib-cjs/api/internal/lensRendering.js.map +0 -1
- package/dist/lib-cjs/api/internal/sceneSetup.js +0 -239
- package/dist/lib-cjs/api/internal/sceneSetup.js.map +0 -1
- package/dist/lib-cjs/api/manager/animationManager.js +0 -131
- package/dist/lib-cjs/api/manager/animationManager.js.map +0 -1
- package/dist/lib-cjs/api/manager/gltfExportManager.js +0 -224
- package/dist/lib-cjs/api/manager/gltfExportManager.js.map +0 -1
- package/dist/lib-cjs/api/manager/sceneManager.js +0 -153
- package/dist/lib-cjs/api/manager/sceneManager.js.map +0 -1
- package/dist/lib-cjs/api/manager/variantInstanceManager.js +0 -336
- package/dist/lib-cjs/api/manager/variantInstanceManager.js.map +0 -1
- package/dist/lib-cjs/api/store/specStorage.js.map +0 -1
- package/dist/lib-cjs/api/util/babylonHelper.js.map +0 -1
- package/dist/lib-cjs/api/util/globalTypes.js +0 -2
- package/dist/lib-cjs/api/util/globalTypes.js.map +0 -1
- package/dist/lib-cjs/api/util/resourceHelper.js +0 -258
- package/dist/lib-cjs/api/util/resourceHelper.js.map +0 -1
- package/dist/lib-cjs/api/util/sceneLoaderHelper.js.map +0 -1
- package/dist/lib-cjs/api/util/stringHelper.js.map +0 -1
- package/dist/lib-cjs/api/util/structureHelper.js.map +0 -1
- package/dist/lib-cjs/index.js.map +0 -1
- package/dist/lib-es6/api/classes/animationInterface.js +0 -2
- package/dist/lib-es6/api/classes/animationInterface.js.map +0 -1
- package/dist/lib-es6/api/classes/dottedPath.js +0 -185
- package/dist/lib-es6/api/classes/dottedPath.js.map +0 -1
- package/dist/lib-es6/api/classes/element.js +0 -821
- package/dist/lib-es6/api/classes/element.js.map +0 -1
- package/dist/lib-es6/api/classes/event.js +0 -369
- package/dist/lib-es6/api/classes/event.js.map +0 -1
- package/dist/lib-es6/api/classes/eventBroadcaster.js +0 -51
- package/dist/lib-es6/api/classes/eventBroadcaster.js.map +0 -1
- package/dist/lib-es6/api/classes/parameter.js +0 -469
- package/dist/lib-es6/api/classes/parameter.js.map +0 -1
- package/dist/lib-es6/api/classes/parameterObservable.js +0 -99
- package/dist/lib-es6/api/classes/parameterObservable.js.map +0 -1
- package/dist/lib-es6/api/classes/parameterizable.js +0 -147
- package/dist/lib-es6/api/classes/parameterizable.js.map +0 -1
- package/dist/lib-es6/api/classes/placementAnimation.js.map +0 -1
- package/dist/lib-es6/api/classes/variant.js +0 -1199
- package/dist/lib-es6/api/classes/variant.js.map +0 -1
- package/dist/lib-es6/api/classes/variantInstance.js +0 -106
- package/dist/lib-es6/api/classes/variantInstance.js.map +0 -1
- package/dist/lib-es6/api/classes/variantParameterizable.js +0 -97
- package/dist/lib-es6/api/classes/variantParameterizable.js.map +0 -1
- package/dist/lib-es6/api/classes/viewer.js +0 -729
- package/dist/lib-es6/api/classes/viewer.js.map +0 -1
- package/dist/lib-es6/api/classes/viewerLight.js +0 -390
- package/dist/lib-es6/api/classes/viewerLight.js.map +0 -1
- package/dist/lib-es6/api/internal/debugViewer.d.ts +0 -13
- package/dist/lib-es6/api/internal/debugViewer.js +0 -84
- package/dist/lib-es6/api/internal/debugViewer.js.map +0 -1
- package/dist/lib-es6/api/internal/lensRendering.js.map +0 -1
- package/dist/lib-es6/api/internal/sceneSetup.js +0 -234
- package/dist/lib-es6/api/internal/sceneSetup.js.map +0 -1
- package/dist/lib-es6/api/manager/animationManager.js +0 -128
- package/dist/lib-es6/api/manager/animationManager.js.map +0 -1
- package/dist/lib-es6/api/manager/gltfExportManager.js.map +0 -1
- package/dist/lib-es6/api/manager/sceneManager.js +0 -150
- package/dist/lib-es6/api/manager/sceneManager.js.map +0 -1
- package/dist/lib-es6/api/manager/variantInstanceManager.js +0 -333
- package/dist/lib-es6/api/manager/variantInstanceManager.js.map +0 -1
- package/dist/lib-es6/api/store/specStorage.js.map +0 -1
- package/dist/lib-es6/api/util/babylonHelper.js.map +0 -1
- package/dist/lib-es6/api/util/globalTypes.js +0 -2
- package/dist/lib-es6/api/util/globalTypes.js.map +0 -1
- package/dist/lib-es6/api/util/resourceHelper.js +0 -248
- package/dist/lib-es6/api/util/resourceHelper.js.map +0 -1
- package/dist/lib-es6/api/util/sceneLoaderHelper.js.map +0 -1
- package/dist/lib-es6/api/util/stringHelper.js.map +0 -1
- package/dist/lib-es6/api/util/structureHelper.js.map +0 -1
- package/dist/lib-es6/index.js.map +0 -1
- package/dist/webpack-stats.json +0 -0
- package/src/buildinfo.json +0 -3
- package/src/commonjs.tsconfig.json +0 -10
- package/src/declaration.tsconfig.json +0 -8
- package/src/es6.tsconfig.json +0 -10
- package/src/pagesconfig.json +0 -81
- package/src/tsconfig.json +0 -33
- package/src/tsconfig.types.json +0 -9
|
@@ -0,0 +1,665 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { activateTransformNode as activate, addToHighlightLayer, addToShadowGenerator, assertTransformNode, cloneTransformNode, cloneTransformNodeMaterial, deactivateTransformNode as deactivate, getClientRectFromMesh, injectNodeMetadata, mapToDottedNodes, removeFromHighlightLayer, removeFromShadowGenerator, setMaterial, setMaterialColor, setMaterialMetallness, setMaterialRoughness, setMaterialTexture, setReceiveShadows, transformTransformNode, } from '../util/babylonHelper';
|
|
11
|
+
import { createImageFromImgSrc, createImageFromSvg } from '../util/resourceHelper';
|
|
12
|
+
import { addMissingMaterialObserver } from '../util/sceneLoaderHelper';
|
|
13
|
+
import { VariantParameterizable } from './../classes/variantParameterizable';
|
|
14
|
+
import { DottedPath } from './dottedPath';
|
|
15
|
+
import { Parameter } from './parameter';
|
|
16
|
+
import { HighlightLayer } from '@babylonjs/core/Layers/highlightLayer';
|
|
17
|
+
import { PBRMaterial } from '@babylonjs/core/Materials/PBR/pbrMaterial';
|
|
18
|
+
import { DynamicTexture } from '@babylonjs/core/Materials/Textures/dynamicTexture';
|
|
19
|
+
import { Material } from '@babylonjs/core/Materials/material';
|
|
20
|
+
import { Color3 } from '@babylonjs/core/Maths/math.color';
|
|
21
|
+
import { AbstractMesh } from '@babylonjs/core/Meshes/abstractMesh';
|
|
22
|
+
import { InstancedMesh } from '@babylonjs/core/Meshes/instancedMesh';
|
|
23
|
+
import { Mesh } from '@babylonjs/core/Meshes/mesh';
|
|
24
|
+
import { TransformNode } from '@babylonjs/core/Meshes/transformNode';
|
|
25
|
+
import { has, isArray, isNumber, isPlainObject, merge, union } from 'lodash-es';
|
|
26
|
+
/**
|
|
27
|
+
* An {@link Element} of a {@link Variant}. Acts as a container for diverse definitions. Lives only in the context of a
|
|
28
|
+
* {@link Variant}.
|
|
29
|
+
*
|
|
30
|
+
* When used in typings, refer to via its alias {@link VariantElement} to prevent name clashes with the web APIs
|
|
31
|
+
* [Element](https://developer.mozilla.org/en-US/docs/Web/API/Element) class
|
|
32
|
+
*/
|
|
33
|
+
export class Element extends VariantParameterizable {
|
|
34
|
+
/**
|
|
35
|
+
* Constructor.
|
|
36
|
+
*/
|
|
37
|
+
constructor(variant, name) {
|
|
38
|
+
var _a;
|
|
39
|
+
super(variant, name);
|
|
40
|
+
this.variant = variant;
|
|
41
|
+
this.name = name;
|
|
42
|
+
this.nodes = [];
|
|
43
|
+
this._dottedNodes = new Map();
|
|
44
|
+
if ((_a = process.env.NODE_ENV) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes('dev')) {
|
|
45
|
+
this.assertPathDefinitions();
|
|
46
|
+
}
|
|
47
|
+
const nodes = this.variant.inheritedNodes.map(node => cloneTransformNode(node, this.filterNode.bind(this)));
|
|
48
|
+
this.nodes = nodes.filter(node => !!node);
|
|
49
|
+
this._dottedNodes = mapToDottedNodes(this.nodes, node => node instanceof TransformNode);
|
|
50
|
+
this.addMissingMaterialObservers();
|
|
51
|
+
this.addParameterObservers();
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Creates an {@link Element} with given name.
|
|
55
|
+
*/
|
|
56
|
+
static create(variant, name) {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
return new Element(variant, name);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The {@link DottedPath} in the built tree of {@link Element}s.
|
|
63
|
+
* E.g. "_.top-1.sub-2.sub-sub-3.el-1"
|
|
64
|
+
*/
|
|
65
|
+
get dottedPath() {
|
|
66
|
+
return DottedPath.create(this.variant.dottedPath).addPart(this.name);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The id representing a {@link DottedPath}.
|
|
70
|
+
*/
|
|
71
|
+
get id() {
|
|
72
|
+
const dottedPath = DottedPath.create(this.dottedPath);
|
|
73
|
+
dottedPath.shiftPart(); // remove root
|
|
74
|
+
return dottedPath.path;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The {@link ElementDefinition} of the {@link Element}.
|
|
78
|
+
*/
|
|
79
|
+
get definition() {
|
|
80
|
+
const definition = this.variant.structureJson.elements[this.name];
|
|
81
|
+
if (isArray(definition)) {
|
|
82
|
+
return {
|
|
83
|
+
paths: {
|
|
84
|
+
include: definition,
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
return definition;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The {@link PathDefinitions} of the {@link Element}.
|
|
92
|
+
*/
|
|
93
|
+
get pathDefinitions() {
|
|
94
|
+
return this.definition.paths;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* The {@link TraceableDefinitions} of the {@link Element}.
|
|
98
|
+
*/
|
|
99
|
+
get traceableDefinitions() {
|
|
100
|
+
return this.definition.traceables || {};
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* The {@link PaintableDefinition} of the {@link Element}.
|
|
104
|
+
*/
|
|
105
|
+
get paintableDefinitions() {
|
|
106
|
+
return this.definition.paintables || {};
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* The inherited {@link ParameterBag}.
|
|
110
|
+
* Merges the {@link Variant}'s parameters and those from the {@link Element}.
|
|
111
|
+
*/
|
|
112
|
+
get inheritedParameters() {
|
|
113
|
+
return merge({}, this.variant.inheritedParameters, this.parameters);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* The actual {@link Mesh}es that make up this {@link Element}.
|
|
117
|
+
* Handy for e.g. creating a bounding box around an entire element.
|
|
118
|
+
*/
|
|
119
|
+
get meshesFlat() {
|
|
120
|
+
const flatMeshes = this.nodes.reduce((accFlatMeshes, curNode) => {
|
|
121
|
+
const currMeshes = curNode.getChildMeshes(false, n => n instanceof Mesh);
|
|
122
|
+
return [...accFlatMeshes, ...currMeshes];
|
|
123
|
+
}, []);
|
|
124
|
+
return flatMeshes;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* The actual {@link AbstractMesh}es that make up this {@link Element}.
|
|
128
|
+
* I.e. (real) Meshes as well as InstancedMeshes.
|
|
129
|
+
*/
|
|
130
|
+
get abstractMeshesFlat() {
|
|
131
|
+
const allAbstractMeshes = this.nodes.reduce((acc, currNode) => {
|
|
132
|
+
const currAbstractMeshes = currNode.getChildMeshes(false, n => n instanceof AbstractMesh);
|
|
133
|
+
if (currNode instanceof AbstractMesh) {
|
|
134
|
+
currAbstractMeshes.unshift(currNode);
|
|
135
|
+
}
|
|
136
|
+
return [...acc, ...currAbstractMeshes];
|
|
137
|
+
}, []); // initial accumulator value
|
|
138
|
+
return allAbstractMeshes;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* The meshes of this {@link Element}.
|
|
142
|
+
*/
|
|
143
|
+
get meshes() {
|
|
144
|
+
return this.nodes.filter(node => node instanceof Mesh);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* @protected
|
|
148
|
+
*/
|
|
149
|
+
set highlightLayer(layer) {
|
|
150
|
+
this._highlightLayer = layer;
|
|
151
|
+
}
|
|
152
|
+
get highlightLayer() {
|
|
153
|
+
return this._highlightLayer;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Destroys this {@link Element} and dispose all nodes.
|
|
157
|
+
*/
|
|
158
|
+
destroy() {
|
|
159
|
+
this.nodes.forEach(node => {
|
|
160
|
+
node.dispose();
|
|
161
|
+
});
|
|
162
|
+
return this;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Gets a node by its {@link DottedPath}.
|
|
166
|
+
*/
|
|
167
|
+
getNode(dottedPath) {
|
|
168
|
+
const _dottedPath = DottedPath.create(dottedPath);
|
|
169
|
+
const keys = Array.from(this._dottedNodes.keys()).map(dp => dp.path);
|
|
170
|
+
const values = Array.from(this._dottedNodes.values());
|
|
171
|
+
const node = values[keys.indexOf(_dottedPath.path)];
|
|
172
|
+
if (!node) {
|
|
173
|
+
throw new Error(`Node with path "${_dottedPath.path}" does not exist for element "${this.id}".`);
|
|
174
|
+
}
|
|
175
|
+
return node;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Gets a mesh by its {@link DottedPath}.
|
|
179
|
+
*/
|
|
180
|
+
getMesh(dottedPath) {
|
|
181
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
182
|
+
const node = yield this.getNode(dottedPath);
|
|
183
|
+
if (node instanceof Mesh) {
|
|
184
|
+
return node;
|
|
185
|
+
}
|
|
186
|
+
return null;
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Gets a {@link PaintableDefinition} by its name.
|
|
191
|
+
*/
|
|
192
|
+
getPaintableDefinition(name) {
|
|
193
|
+
if (!this.paintableDefinitions || !this.paintableDefinitions[name]) {
|
|
194
|
+
throw new Error(`No paintable "${name}" defined for element "${this.id}".`);
|
|
195
|
+
}
|
|
196
|
+
return this.paintableDefinitions[name];
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Gets a {@link TraceableDefinition} by its name.
|
|
200
|
+
*/
|
|
201
|
+
getTraceableDefinition(name) {
|
|
202
|
+
if (!this.traceableDefinitions || !this.traceableDefinitions[name]) {
|
|
203
|
+
throw new Error(`No traceable "${name}" defined to add observer in element "${this.id}".`);
|
|
204
|
+
}
|
|
205
|
+
return this.traceableDefinitions[name];
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Gets the paintable Node by its name.
|
|
209
|
+
*/
|
|
210
|
+
getPaintableNode(name) {
|
|
211
|
+
return this.getNode(this.getPaintableDefinition(name).path);
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Gets the traceable Node by its name.
|
|
215
|
+
*/
|
|
216
|
+
getTraceableNode(name) {
|
|
217
|
+
return this.getNode(this.getTraceableDefinition(name).path);
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* @see {@link VariantParameterizable.commitParameters}
|
|
221
|
+
* @emit {@link Event.ELEMENT_PARAMETER_COMMITTED}
|
|
222
|
+
*/
|
|
223
|
+
commitParameters(parameters) {
|
|
224
|
+
const _super = Object.create(null, {
|
|
225
|
+
commitParameters: { get: () => super.commitParameters }
|
|
226
|
+
});
|
|
227
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
228
|
+
return _super.commitParameters.call(this, parameters);
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Adds an observer function for camera matrix changes.
|
|
233
|
+
* The `observer` gets 2 parameters: the `AbstractMesh` and a `ClientRect` object.
|
|
234
|
+
*/
|
|
235
|
+
addTraceableObserver(traceable, observer, payload) {
|
|
236
|
+
if (payload && !(payload instanceof HTMLElement)) {
|
|
237
|
+
throw new Error(`Payload for camera observer must be an instance of "HTMLElement" in element "${this.id}".`);
|
|
238
|
+
}
|
|
239
|
+
if (!this.traceableDefinitions || !this.traceableDefinitions[traceable]) {
|
|
240
|
+
throw new Error(`No traceable "${traceable}" defined to add observer in element "${this.id}".`);
|
|
241
|
+
}
|
|
242
|
+
const node = this.getTraceableNode(traceable);
|
|
243
|
+
if (!(node instanceof AbstractMesh)) {
|
|
244
|
+
throw new Error(`The path must be an instance of "AbstractMesh" for camera observer in element "${this.id}".`);
|
|
245
|
+
}
|
|
246
|
+
this.variant.viewer.sceneManager.activeCamera.onViewMatrixChangedObservable.add((eventData, eventState) => {
|
|
247
|
+
const position = getClientRectFromMesh(node, this.variant.viewer.scene, this.variant.viewer.canvas);
|
|
248
|
+
if (payload) {
|
|
249
|
+
payload.style.top = `${position.top}px`;
|
|
250
|
+
payload.style.left = `${position.left}px`;
|
|
251
|
+
}
|
|
252
|
+
observer(node, position);
|
|
253
|
+
});
|
|
254
|
+
return this;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Draws a `ImageBitmap` or `OffscreenCanvas` onto a `paintable` defined via {@link PaintableDefinition}.
|
|
258
|
+
*/
|
|
259
|
+
drawPaintable(paintable, imageSource) {
|
|
260
|
+
// node and material checks and preperation
|
|
261
|
+
const node = this.getPaintableNode(paintable);
|
|
262
|
+
if (!(node instanceof AbstractMesh)) {
|
|
263
|
+
throw new Error(`The path must be an instance of "AbstractMesh" for paintable "${paintable}" ` + `in element "${this.id}".`);
|
|
264
|
+
}
|
|
265
|
+
if (node.material && this.variant.viewer.cloneMaterialsOnMutation) {
|
|
266
|
+
if (node.material && !has(node.metadata, 'dirty.material')) {
|
|
267
|
+
cloneTransformNodeMaterial(node);
|
|
268
|
+
}
|
|
269
|
+
if (!has(node.metadata, 'dirty.material.texture')) {
|
|
270
|
+
// inject initial value and mark as dirty
|
|
271
|
+
injectNodeMetadata(node, { dirty: { material: { texture: true } } });
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
else if (!node.material) {
|
|
275
|
+
// paintables should also work if no material is assigned to the node per default
|
|
276
|
+
// in this case a certain fallback material with fitting default values is defined
|
|
277
|
+
const pbrMat = new PBRMaterial(`${this.id}.${paintable}.material`, this.variant.viewer.scene);
|
|
278
|
+
pbrMat.roughness = 1.0;
|
|
279
|
+
pbrMat.metallic = 1.0;
|
|
280
|
+
node.material = pbrMat;
|
|
281
|
+
}
|
|
282
|
+
// TODO: Not sure if this really should be overwritten every time the paintable is redrawn.
|
|
283
|
+
// Maybe the 3D artist had something in mind when setting a certain transparency mode, which would get overwritten in this case.
|
|
284
|
+
// Applying it as a default if no material is set is fine though (see roughness/metallic some lines above).
|
|
285
|
+
// Removing this line will most likely break existing configurators, so be cautios!
|
|
286
|
+
node.material.transparencyMode = Material.MATERIAL_ALPHATESTANDBLEND;
|
|
287
|
+
// consider width and height of the paintable
|
|
288
|
+
const widthAndHeight = {
|
|
289
|
+
width: imageSource.width,
|
|
290
|
+
height: imageSource.height,
|
|
291
|
+
};
|
|
292
|
+
const paintableDefinition = this.getPaintableDefinition(paintable);
|
|
293
|
+
if (isNumber(paintableDefinition.textureOptions)) {
|
|
294
|
+
widthAndHeight.width = paintableDefinition.textureOptions;
|
|
295
|
+
widthAndHeight.height = paintableDefinition.textureOptions;
|
|
296
|
+
}
|
|
297
|
+
else if (isPlainObject(paintableDefinition.textureOptions)) {
|
|
298
|
+
widthAndHeight.width = paintableDefinition.textureOptions.width;
|
|
299
|
+
widthAndHeight.height = paintableDefinition.textureOptions.height;
|
|
300
|
+
}
|
|
301
|
+
// create dynamic texture on which the image can be drawn
|
|
302
|
+
const texture = new DynamicTexture(`${this.id}.${paintable}.texture`, widthAndHeight, this.variant.viewer.scene, false);
|
|
303
|
+
// draw image on texture
|
|
304
|
+
const ctx = texture.getContext();
|
|
305
|
+
ctx.drawImage(imageSource, 0, 0);
|
|
306
|
+
texture.update(false);
|
|
307
|
+
// finally apply the texture on the desired node material
|
|
308
|
+
setMaterialTexture(node, texture, false);
|
|
309
|
+
return this;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Draws a SVG string onto a `paintable` defined via {@link PaintableDefinition}.
|
|
313
|
+
*/
|
|
314
|
+
drawPaintableFromSvg(paintable, svgSource) {
|
|
315
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
316
|
+
const image = yield createImageFromSvg(svgSource);
|
|
317
|
+
return this.drawPaintable(paintable, image);
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Draws an Image from source (URL/URI) onto a `paintable` defined via {@link PaintableDefinition}.
|
|
322
|
+
*/
|
|
323
|
+
drawPaintableFromImgSrc(paintable, imgSource) {
|
|
324
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
325
|
+
const image = yield createImageFromImgSrc(imgSource);
|
|
326
|
+
return this.drawPaintable(paintable, image);
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Adds observers for loading missing materials where needed
|
|
331
|
+
*/
|
|
332
|
+
addMissingMaterialObservers() {
|
|
333
|
+
for (const abstractMesh of this.abstractMeshesFlat) {
|
|
334
|
+
addMissingMaterialObserver(abstractMesh);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Adds the default {@link ParameterObserver}s which are called every time {@link commitParameters} is called.
|
|
339
|
+
*/
|
|
340
|
+
addParameterObservers() {
|
|
341
|
+
this._parameterObservers.set(Parameter.VISIBLE, [
|
|
342
|
+
(element, oldValue, newValue) => __awaiter(this, void 0, void 0, function* () {
|
|
343
|
+
let visible;
|
|
344
|
+
try {
|
|
345
|
+
visible = Parameter.parseBoolean(newValue);
|
|
346
|
+
}
|
|
347
|
+
catch (e) {
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
if (visible === true) {
|
|
351
|
+
element.nodes.forEach(node => {
|
|
352
|
+
injectNodeMetadata(node, { visibility: node.isEnabled() });
|
|
353
|
+
activate(node);
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
else if (visible === false) {
|
|
357
|
+
element.nodes.forEach(node => {
|
|
358
|
+
injectNodeMetadata(node, { visibility: node.isEnabled() });
|
|
359
|
+
deactivate(node);
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
}),
|
|
363
|
+
]);
|
|
364
|
+
this._parameterObservers.set(Parameter.SCALING, [
|
|
365
|
+
(element, oldValue, newValue) => __awaiter(this, void 0, void 0, function* () {
|
|
366
|
+
// we have to deal just with root nodes here due to relative impacts in a node tree
|
|
367
|
+
element.nodes.forEach(node => transformTransformNode(node, {
|
|
368
|
+
scaling: Parameter.parseVector(newValue),
|
|
369
|
+
position: Parameter.parseVector(element.inheritedParameters[Parameter.POSITION] || '(0, 0, 0)'),
|
|
370
|
+
rotation: Parameter.parseRotation(element.inheritedParameters[Parameter.ROTATION] || '(0, 0, 0)'),
|
|
371
|
+
}));
|
|
372
|
+
}),
|
|
373
|
+
]);
|
|
374
|
+
this._parameterObservers.set(Parameter.POSITION, [
|
|
375
|
+
(element, oldValue, newValue) => __awaiter(this, void 0, void 0, function* () {
|
|
376
|
+
// we have to deal just with root nodes here due to relative impacts in a node tree
|
|
377
|
+
element.nodes.forEach(node => transformTransformNode(node, {
|
|
378
|
+
scaling: Parameter.parseVector(element.inheritedParameters[Parameter.SCALING] || '(1, 1, 1)'),
|
|
379
|
+
position: Parameter.parseVector(newValue),
|
|
380
|
+
rotation: Parameter.parseRotation(element.inheritedParameters[Parameter.ROTATION] || '(0, 0, 0)'),
|
|
381
|
+
}));
|
|
382
|
+
}),
|
|
383
|
+
]);
|
|
384
|
+
this._parameterObservers.set(Parameter.ROTATION, [
|
|
385
|
+
(element, oldValue, newValue) => __awaiter(this, void 0, void 0, function* () {
|
|
386
|
+
// we have to deal just with root nodes here due to relative impacts in a node tree
|
|
387
|
+
element.nodes.forEach(node => transformTransformNode(node, {
|
|
388
|
+
scaling: Parameter.parseVector(element.inheritedParameters[Parameter.SCALING] || '(1, 1, 1)'),
|
|
389
|
+
position: Parameter.parseVector(element.inheritedParameters[Parameter.POSITION] || '(0, 0, 0)'),
|
|
390
|
+
rotation: Parameter.parseRotation(newValue),
|
|
391
|
+
}));
|
|
392
|
+
}),
|
|
393
|
+
]);
|
|
394
|
+
this._parameterObservers.set(Parameter.MATERIAL, [
|
|
395
|
+
(element, oldValue, newValue) => __awaiter(this, void 0, void 0, function* () {
|
|
396
|
+
const materialName = newValue.toString();
|
|
397
|
+
element.nodes.forEach(node => {
|
|
398
|
+
assertTransformNode(node, (node) => {
|
|
399
|
+
if (node instanceof InstancedMesh) {
|
|
400
|
+
throw new Error(`Changing parameter "${Parameter.MATERIAL}" ` +
|
|
401
|
+
`of an InstancedMesh is not supported. ` +
|
|
402
|
+
`Tried to change node "${node.id}" on element "${element.id}".`);
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
setMaterial(element.variant, node, materialName);
|
|
406
|
+
});
|
|
407
|
+
}),
|
|
408
|
+
]);
|
|
409
|
+
this._parameterObservers.set(Parameter.MATERIAL_COLOR, [
|
|
410
|
+
(element, oldValue, newValue) => __awaiter(this, void 0, void 0, function* () {
|
|
411
|
+
const color = Parameter.parseColor(newValue);
|
|
412
|
+
element.nodes.forEach(node => {
|
|
413
|
+
assertTransformNode(node, (node) => {
|
|
414
|
+
if (node instanceof InstancedMesh) {
|
|
415
|
+
throw new Error(`Changing parameter "${Parameter.MATERIAL_COLOR}" ` +
|
|
416
|
+
`of an InstancedMesh is not supported. ` +
|
|
417
|
+
`Tried to change node "${node.id}" on element "${element.id}".`);
|
|
418
|
+
}
|
|
419
|
+
});
|
|
420
|
+
if (this.variant.viewer.cloneMaterialsOnMutation) {
|
|
421
|
+
if (!has(node.metadata, 'dirty.material')) {
|
|
422
|
+
cloneTransformNodeMaterial(node);
|
|
423
|
+
}
|
|
424
|
+
if (!has(node.metadata, 'dirty.material.color')) {
|
|
425
|
+
// inject initial value and mark as dirty
|
|
426
|
+
injectNodeMetadata(node, { dirty: { material: { color: oldValue } } });
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
setMaterialColor(node, color);
|
|
430
|
+
});
|
|
431
|
+
}),
|
|
432
|
+
]);
|
|
433
|
+
this._parameterObservers.set(Parameter.MATERIAL_METALLNESS, [
|
|
434
|
+
(element, oldValue, newValue) => __awaiter(this, void 0, void 0, function* () {
|
|
435
|
+
const metallness = Parameter.parseNumber(newValue);
|
|
436
|
+
element.nodes.forEach(node => {
|
|
437
|
+
assertTransformNode(node, (node) => {
|
|
438
|
+
if (node instanceof InstancedMesh) {
|
|
439
|
+
throw new Error(`Changing parameter "${Parameter.MATERIAL_METALLNESS}" ` +
|
|
440
|
+
`of an InstancedMesh is not supported. ` +
|
|
441
|
+
`Tried to change node "${node.id}" on element "${element.id}".`);
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
if (this.variant.viewer.cloneMaterialsOnMutation) {
|
|
445
|
+
if (!has(node.metadata, 'dirty.material')) {
|
|
446
|
+
cloneTransformNodeMaterial(node);
|
|
447
|
+
}
|
|
448
|
+
if (!has(node.metadata, 'dirty.material.metallness')) {
|
|
449
|
+
// inject initial value and mark as dirty
|
|
450
|
+
injectNodeMetadata(node, { dirty: { material: { metallness: oldValue } } });
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
setMaterialMetallness(node, metallness);
|
|
454
|
+
});
|
|
455
|
+
}),
|
|
456
|
+
]);
|
|
457
|
+
this._parameterObservers.set(Parameter.MATERIAL_ROUGHNESS, [
|
|
458
|
+
(element, oldValue, newValue) => __awaiter(this, void 0, void 0, function* () {
|
|
459
|
+
const roughness = Parameter.parseNumber(newValue);
|
|
460
|
+
element.nodes.forEach(node => {
|
|
461
|
+
assertTransformNode(node, (node) => {
|
|
462
|
+
if (node instanceof InstancedMesh) {
|
|
463
|
+
throw new Error(`Changing parameter "${Parameter.MATERIAL_ROUGHNESS}" ` +
|
|
464
|
+
`of an InstancedMesh is not supported. ` +
|
|
465
|
+
`Tried to change node "${node.id}" on element "${element.id}".`);
|
|
466
|
+
}
|
|
467
|
+
});
|
|
468
|
+
if (this.variant.viewer.cloneMaterialsOnMutation) {
|
|
469
|
+
if (!has(node.metadata, 'dirty.material')) {
|
|
470
|
+
cloneTransformNodeMaterial(node);
|
|
471
|
+
}
|
|
472
|
+
if (!has(node.metadata, 'dirty.material.roughness')) {
|
|
473
|
+
// inject initial value and mark as dirty
|
|
474
|
+
injectNodeMetadata(node, { dirty: { material: { roughness: oldValue } } });
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
setMaterialRoughness(node, roughness);
|
|
478
|
+
});
|
|
479
|
+
}),
|
|
480
|
+
]);
|
|
481
|
+
this._parameterObservers.set(Parameter.HIGHLIGHT_COLOR, [
|
|
482
|
+
(element, oldValue, newValue) => __awaiter(this, void 0, void 0, function* () {
|
|
483
|
+
var _a;
|
|
484
|
+
// trigger Parameter.HIGHLIGHTED observers
|
|
485
|
+
(_a = this._parameterObservers.get(Parameter.HIGHLIGHTED)) === null || _a === void 0 ? void 0 : _a.forEach(observer => {
|
|
486
|
+
observer(element, !!element.highlighted, !!element.highlighted);
|
|
487
|
+
});
|
|
488
|
+
}),
|
|
489
|
+
]);
|
|
490
|
+
this._parameterObservers.set(Parameter.HIGHLIGHT_ENABLED, [
|
|
491
|
+
(element, oldValue, newValue) => __awaiter(this, void 0, void 0, function* () {
|
|
492
|
+
var _b;
|
|
493
|
+
let curr;
|
|
494
|
+
try {
|
|
495
|
+
curr = Parameter.parseBoolean(newValue);
|
|
496
|
+
}
|
|
497
|
+
catch (e) {
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
switch (curr) {
|
|
501
|
+
case true:
|
|
502
|
+
if (element._highlightLayer) {
|
|
503
|
+
break;
|
|
504
|
+
}
|
|
505
|
+
element.highlightLayer = new HighlightLayer(DottedPath.create(element.id).addPart('highlight').path, element.variant.viewer.scene);
|
|
506
|
+
break;
|
|
507
|
+
case false:
|
|
508
|
+
(_b = element.highlightLayer) === null || _b === void 0 ? void 0 : _b.dispose();
|
|
509
|
+
break;
|
|
510
|
+
}
|
|
511
|
+
}),
|
|
512
|
+
]);
|
|
513
|
+
this._parameterObservers.set(Parameter.HIGHLIGHTED, [
|
|
514
|
+
(element, oldValue, newValue) => __awaiter(this, void 0, void 0, function* () {
|
|
515
|
+
var _c;
|
|
516
|
+
if (!element.inheritedParameters[Parameter.HIGHLIGHT_ENABLED]) {
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
519
|
+
// trigger Parameter.HIGHLIGHT_ENABLED observers to ensure HighlightLayer
|
|
520
|
+
(_c = this._parameterObservers.get(Parameter.HIGHLIGHT_ENABLED)) === null || _c === void 0 ? void 0 : _c.forEach(observer => {
|
|
521
|
+
observer(element, this.parameters[Parameter.HIGHLIGHT_ENABLED], true);
|
|
522
|
+
});
|
|
523
|
+
let highlighted;
|
|
524
|
+
try {
|
|
525
|
+
highlighted = Parameter.parseBoolean(newValue);
|
|
526
|
+
}
|
|
527
|
+
catch (e) {
|
|
528
|
+
return;
|
|
529
|
+
}
|
|
530
|
+
// Add/Remove meshes to previously created highlight layers.
|
|
531
|
+
if (highlighted === true) {
|
|
532
|
+
element.nodes.forEach(node => {
|
|
533
|
+
assertTransformNode(node, (node) => {
|
|
534
|
+
if (node instanceof InstancedMesh) {
|
|
535
|
+
throw new Error(`Changing parameter "${Parameter.HIGHLIGHTED}" ` +
|
|
536
|
+
`of an InstancedMesh is not supported. ` +
|
|
537
|
+
`Tried to change node "${node.id}" on element "${element.id}".`);
|
|
538
|
+
}
|
|
539
|
+
});
|
|
540
|
+
let color = Color3.Green();
|
|
541
|
+
if (element.inheritedParameters[Parameter.HIGHLIGHT_COLOR]) {
|
|
542
|
+
color = Parameter.parseColor(element.inheritedParameters[Parameter.HIGHLIGHT_COLOR]);
|
|
543
|
+
}
|
|
544
|
+
if (typeof element._highlightLayer !== 'undefined') {
|
|
545
|
+
addToHighlightLayer(element._highlightLayer, color, node);
|
|
546
|
+
}
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
else if (highlighted === false) {
|
|
550
|
+
element.nodes.forEach(node => {
|
|
551
|
+
if (typeof element._highlightLayer !== 'undefined') {
|
|
552
|
+
removeFromHighlightLayer(element._highlightLayer, node);
|
|
553
|
+
}
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
}),
|
|
557
|
+
]);
|
|
558
|
+
this._parameterObservers.set(Parameter.CAST_SHADOW, [
|
|
559
|
+
(element, oldValue, newValue) => __awaiter(this, void 0, void 0, function* () {
|
|
560
|
+
let castShadow;
|
|
561
|
+
try {
|
|
562
|
+
castShadow = Parameter.parseBoolean(newValue);
|
|
563
|
+
}
|
|
564
|
+
catch (e) {
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
567
|
+
let lightCsl = element.inheritedParameters[Parameter.CAST_SHADOW_FROM_LIGHTS];
|
|
568
|
+
if (!lightCsl) {
|
|
569
|
+
lightCsl = element.variant.inheritedViewerLights.map(l => l.name).join(',');
|
|
570
|
+
}
|
|
571
|
+
if (castShadow === true) {
|
|
572
|
+
yield this.castShadowValueHandler(lightCsl, addToShadowGenerator);
|
|
573
|
+
}
|
|
574
|
+
if (castShadow === false) {
|
|
575
|
+
yield this.castShadowValueHandler(lightCsl, removeFromShadowGenerator);
|
|
576
|
+
}
|
|
577
|
+
}),
|
|
578
|
+
]);
|
|
579
|
+
this._parameterObservers.set(Parameter.CAST_SHADOW_FROM_LIGHTS, [
|
|
580
|
+
(element, oldValue, newValue) => __awaiter(this, void 0, void 0, function* () {
|
|
581
|
+
// TODO: Possible performance issue in combination with CAST_SHADOW, since both observers are initially called
|
|
582
|
+
// when CAST_SHADOW and CAST_SHADOW_FROM_LIGHTS are defined in the spec.
|
|
583
|
+
const lightCsl = element.variant.inheritedViewerLights.map(l => l.name).join(',');
|
|
584
|
+
// cleanup all shadow generators
|
|
585
|
+
yield this.castShadowValueHandler(lightCsl, removeFromShadowGenerator);
|
|
586
|
+
if (element.castShadow === true) {
|
|
587
|
+
// if newValue is undefined or '' then set newValue to lightCsl (use all lights)
|
|
588
|
+
if (!newValue) {
|
|
589
|
+
newValue = lightCsl;
|
|
590
|
+
}
|
|
591
|
+
yield this.castShadowValueHandler(newValue, addToShadowGenerator);
|
|
592
|
+
}
|
|
593
|
+
}),
|
|
594
|
+
]);
|
|
595
|
+
this._parameterObservers.set(Parameter.RECEIVE_SHADOWS, [
|
|
596
|
+
(element, oldValue, newValue) => __awaiter(this, void 0, void 0, function* () {
|
|
597
|
+
element.nodes.forEach(node => setReceiveShadows(node, Parameter.parseBoolean(newValue)));
|
|
598
|
+
}),
|
|
599
|
+
]);
|
|
600
|
+
return this;
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
* Filter for nodes that are not defined or excluded in the `pathDefinitions`.
|
|
604
|
+
*/
|
|
605
|
+
filterNode(node) {
|
|
606
|
+
let includeTokens = [];
|
|
607
|
+
this.pathDefinitions.include.forEach(dottedPath => {
|
|
608
|
+
includeTokens = union(includeTokens, DottedPath.create(dottedPath).leafTokens);
|
|
609
|
+
});
|
|
610
|
+
const shallKeep = (dp) => {
|
|
611
|
+
const isDirectlyIncluded = !!includeTokens.find(_dp => _dp === dp.path);
|
|
612
|
+
const isSubOfIncluded = !!this.pathDefinitions.include.find(_dp => {
|
|
613
|
+
return dp.path.startsWith(`${_dp}${DottedPath.DELIMITER}`);
|
|
614
|
+
});
|
|
615
|
+
return isDirectlyIncluded || isSubOfIncluded;
|
|
616
|
+
};
|
|
617
|
+
const shallExclude = (dp) => {
|
|
618
|
+
if (!this.pathDefinitions.exclude) {
|
|
619
|
+
return false;
|
|
620
|
+
}
|
|
621
|
+
return !!this.pathDefinitions.exclude.find(_dp => dp.path === _dp);
|
|
622
|
+
};
|
|
623
|
+
return shallKeep(node.metadata.dottedPath) && !shallExclude(node.metadata.dottedPath);
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* Asserts whether all {@link pathDefinitions} link to a valid `Node` path.
|
|
627
|
+
* @protected
|
|
628
|
+
*/
|
|
629
|
+
assertPathDefinitions() {
|
|
630
|
+
var _a;
|
|
631
|
+
const dottedNodes = this.variant.inheritedDottedNodes;
|
|
632
|
+
if (dottedNodes.size === 0) {
|
|
633
|
+
throw new Error(`There are no mapped nodes for element "${this.id}".`);
|
|
634
|
+
}
|
|
635
|
+
const include = this.pathDefinitions.include.map(path => DottedPath.create(path).path);
|
|
636
|
+
const exclude = (_a = this.pathDefinitions.exclude) === null || _a === void 0 ? void 0 : _a.map(path => DottedPath.create(path).path);
|
|
637
|
+
const keys = Array.from(dottedNodes.keys()).map(dottedPath => dottedPath.path);
|
|
638
|
+
union(include, exclude).forEach(path => {
|
|
639
|
+
if (keys.indexOf(path) === -1) {
|
|
640
|
+
throw new Error(`Node with path "${path}" does not exist for element "${this.id}".`);
|
|
641
|
+
}
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* Handles callback for given light parameter.
|
|
646
|
+
*/
|
|
647
|
+
castShadowValueHandler(lightCsl, mutator) {
|
|
648
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
649
|
+
let lights = [];
|
|
650
|
+
for (const lightName of Parameter.parseCommaSeparatedList(lightCsl)) {
|
|
651
|
+
const viewerLight = yield this.variant.getViewerLight(lightName);
|
|
652
|
+
if (viewerLight) {
|
|
653
|
+
lights.push(viewerLight.light);
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
const shadowGenerators = lights.map(light => light === null || light === void 0 ? void 0 : light.getShadowGenerator()).filter(Boolean);
|
|
657
|
+
shadowGenerators.forEach(generator => {
|
|
658
|
+
this.nodes.forEach(node => {
|
|
659
|
+
mutator(generator, node);
|
|
660
|
+
});
|
|
661
|
+
});
|
|
662
|
+
});
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
//# sourceMappingURL=element.js.map
|