@configura/babylon-view 1.3.0-alpha.7 → 1.4.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -123,19 +123,39 @@ export class CfgMaterial {
123
123
  material.bumpTexture = texture;
124
124
  }
125
125
  }
126
+ /**
127
+ * This flag indicates that a material might contain semi or fully transparent pixels and
128
+ * that alpha blending / testing has been enabled.
129
+ *
130
+ * For a PBR material to be considered transparent it must fulfill the following:
131
+ * 1) An opacity section is defined.
132
+ * 2) The opacity section must specify a non-opaque blending mode.
133
+ * 3A) The "factor" must be < 1,
134
+ * 3B) OR an opacity texture is supplied,
135
+ * 3C) OR "useAlphaFromBase" is set and an albedo (base) texture exists.
136
+ */
126
137
  let transparent = false;
127
138
  if ((opacity === null || opacity === void 0 ? void 0 : opacity.mode) === "translucent" ||
128
139
  (opacity === null || opacity === void 0 ? void 0 : opacity.mode) === "mask" ||
129
140
  (opacity === null || opacity === void 0 ? void 0 : opacity.mode) === "translucentAndMask") {
130
141
  material.alpha = opacity.factor;
131
- const texture = findTexture(textures, opacity.texture);
132
- if (texture !== undefined) {
133
- material.opacityTexture = texture;
134
- texture.getAlphaFromRGB = opacity.channels === "r";
142
+ transparent = material.alpha < 1;
143
+ if (opacity.useAlphaFromBase === true) {
144
+ if (material.albedoTexture !== null) {
145
+ material.albedoTexture.hasAlpha = true; // Or alpha blending won't be enabled
146
+ material.useAlphaFromAlbedoTexture = true;
147
+ transparent = true;
148
+ }
135
149
  }
136
- // Only materials with alpha < 1 or and opacity texture can contain transparent pixels
137
- if (material.alpha < 1 || material.opacityTexture !== undefined) {
138
- transparent = true;
150
+ else {
151
+ const texture = findTexture(textures, opacity.texture);
152
+ if (texture !== undefined) {
153
+ material.opacityTexture = texture;
154
+ material.opacityTexture.getAlphaFromRGB = opacity.channels === "r";
155
+ transparent = true;
156
+ }
157
+ }
158
+ if (transparent) {
139
159
  // Enabling separateCullingPass will first render any back facing triangles, then
140
160
  // any front facing. This type of "back then front" rendering helps with some common
141
161
  // rendering issues for meshes with transparent materials.
@@ -1,5 +1,5 @@
1
1
  import { Camera } from "@babylonjs/core/Cameras/camera.js";
2
- import { ApplicationArea, CfgProduct, Model, MtrlApplication, PartsData } from "@configura/web-api";
2
+ import { ApplicationArea, CfgProduct } from "@configura/web-api";
3
3
  import { EventListener } from "@configura/web-utilities";
4
4
  import { CoordinatorWithMeta } from "../animation/coordinator/Coordinator.js";
5
5
  import { CameraCreator } from "../camera/CameraCreator.js";
@@ -19,13 +19,6 @@ export declare type SingleProductViewConstructorOptions<C extends Camera> = {
19
19
  sceneCreator?: SceneCreator;
20
20
  dummyMaterialCreator?: DummyMaterialCreator;
21
21
  };
22
- export declare type RootNodeSource = Model | File;
23
- export declare type CfgProductViewProductData = {
24
- mtrlApplications?: MtrlApplication[];
25
- sku: string;
26
- models?: RootNodeSource[];
27
- partsData: PartsData;
28
- };
29
22
  export declare class SingleProductView<C extends Camera = Camera, T extends SingleProductViewEventMap = SingleProductViewEventMap> extends BaseView<C, T> {
30
23
  private _currentProductNode;
31
24
  private _scheduledForRemoval;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@configura/babylon-view",
3
- "version": "1.3.0-alpha.7",
3
+ "version": "1.4.0-alpha.2",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -16,16 +16,16 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "@babylonjs/core": "4.2.0",
19
- "@configura/web-core": "^1.3.0-alpha.7",
20
- "@configura/web-utilities": "^1.3.0-alpha.7"
19
+ "@configura/web-core": "^1.4.0-alpha.2",
20
+ "@configura/web-utilities": "^1.4.0-alpha.2"
21
21
  },
22
22
  "devDependencies": {
23
- "@configura/web-api": "^1.3.0-alpha.7",
23
+ "@configura/web-api": "^1.4.0-alpha.2",
24
24
  "del-cli": "^3.0.0",
25
25
  "typescript": "4.2"
26
26
  },
27
27
  "publishConfig": {
28
28
  "access": "public"
29
29
  },
30
- "gitHead": "1c5c089a31e6662b6da365b7038254e70a1cc8ff"
30
+ "gitHead": "b0d5dbdefc93b2c87298b36d82f6dd32cc2c14e9"
31
31
  }