bimatter-viewer-react 0.7.4 → 0.7.5

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.
@@ -0,0 +1,104 @@
1
+ import { a as e, f as t, g as n, h as r, i, m as a, p as o, r as s, s as c, u as l } from "./three.webgpu-7Fqpf016.js";
2
+ import { A as u, B as d, C as f, D as p, E as m, I as h, L as g, M as _, N as v, O as y, P as b, R as x, S, T as C, V as w, _ as T, a as E, b as D, c as O, d as k, f as A, g as j, h as M, i as N, j as P, k as F, m as I, n as L, o as R, p as z, r as B, s as V, t as H, u as U, v as W, w as G, x as K, y as q, z as J } from "./three.tsl-Dfou2CS1.js";
3
+ //#region node_modules/three/examples/jsm/tsl/display/GTAONode.js
4
+ var Y = /* @__PURE__ */ new i(), X = /* @__PURE__ */ new r(), Z = [
5
+ 60,
6
+ 300,
7
+ 180,
8
+ 240,
9
+ 120,
10
+ 0
11
+ ], Q, $ = class extends c {
12
+ static get type() {
13
+ return "GTAONode";
14
+ }
15
+ constructor(e, n, i) {
16
+ super("float"), this.depthNode = e, this.normalNode = n, this.resolutionScale = 1, this.updateBeforeType = N.FRAME, this._aoRenderTarget = new o(1, 1, {
17
+ depthBuffer: !1,
18
+ format: t
19
+ }), this._aoRenderTarget.texture.name = "GTAONode.AO", this.radius = h(.25), this.resolution = h(new r()), this.thickness = h(1), this.distanceExponent = h(1), this.distanceFallOff = h(1), this.scale = h(1), this.samples = h(16), this.useTemporalFiltering = !1, this._noiseNode = v(ee()), this._cameraProjectionMatrix = h(i.projectionMatrix), this._cameraProjectionMatrixInverse = h(i.projectionMatrixInverse), this._cameraNear = F("near", "float", i), this._cameraFar = F("far", "float", i), this._temporalDirection = h(0), this._material = new s(), this._material.name = "GTAO", this._textureNode = p(this, this._aoRenderTarget.texture);
20
+ }
21
+ getTextureNode() {
22
+ return this._textureNode;
23
+ }
24
+ setSize(e, t) {
25
+ e = Math.round(this.resolutionScale * e), t = Math.round(this.resolutionScale * t), this.resolution.value.set(e, t), this._aoRenderTarget.setSize(e, t);
26
+ }
27
+ updateBefore(t) {
28
+ let { renderer: n } = t;
29
+ if (Q = e.resetRendererState(n, Q), this.useTemporalFiltering === !0) {
30
+ let e = t.frameId;
31
+ this._temporalDirection.value = Z[e % 6] / 360;
32
+ } else this._temporalDirection.value = 0;
33
+ let r = n.getDrawingBufferSize(X);
34
+ this.setSize(r.width, r.height), Y.material = this._material, Y.name = "AO", n.setClearColor(16777215, 1), n.setRenderTarget(this._aoRenderTarget), Y.render(n), e.restoreRendererState(n, Q);
35
+ }
36
+ setup(e) {
37
+ let t = g(), n = (t) => {
38
+ let n = this.depthNode.sample(t).r;
39
+ return e.renderer.logarithmicDepthBuffer === !0 ? w(D(n, this._cameraNear, this._cameraFar), this._cameraNear, this._cameraFar) : n;
40
+ }, r = (e) => this._noiseNode.sample(e), i = (e) => this.normalNode === null ? j(e, this.depthNode.value, this._cameraProjectionMatrixInverse) : this.normalNode.sample(e).rgb.normalize(), a = H(() => {
41
+ let e = n(t).toVar();
42
+ e.greaterThanEqual(1).discard();
43
+ let a = W(t, e, this._cameraProjectionMatrixInverse).toVar(), o = i(t).toVar(), s = this.radius, c = b(this._noiseNode, 0), l = x(t.x, t.y.oneMinus());
44
+ l = l.mul(this.resolution.div(c));
45
+ let p = r(l), h = J(p.xyz.mul(2).sub(1).xy, 0).normalize(), g = K(h, J(h.y.mul(-1), h.x, 0), J(0, 0, 1)), v = this.samples.lessThan(30).select(3, 5).toVar(), C = O(this.samples, v.sub(1)).div(v).toVar(), w = M(0).toVar();
46
+ return B({
47
+ start: q(0),
48
+ end: v,
49
+ type: "int",
50
+ condition: "<"
51
+ }, ({ i: e }) => {
52
+ let t = M(e).div(M(v)).mul(E).add(this._temporalDirection).toVar(), r = d(k(t), u(t), 0, O(.5, G(.5, p.w)));
53
+ r.xyz = m(g.mul(r.xyz));
54
+ let i = m(a.xyz.negate()).toVar(), c = m(A(r.xyz, i)).toVar(), l = A(c, i), h = m(o.sub(c.mul(I(o, c)))), b = A(h, c).toVar(), D = x(I(i, b), I(i, b.negate())).toVar();
55
+ B({
56
+ end: C,
57
+ type: "int",
58
+ name: "j",
59
+ condition: "<"
60
+ }, ({ j: e }) => {
61
+ let t = r.xyz.mul(s).mul(r.w).mul(y(z(M(e).add(1), M(C)), this.distanceExponent)), o = T(a.add(t), this._cameraProjectionMatrix).toVar(), c = W(o, n(o).toVar(), this._cameraProjectionMatrixInverse).toVar().sub(a).toVar();
62
+ L(R(c.z).lessThan(this.thickness), () => {
63
+ let t = I(i, m(c));
64
+ D.x.addAssign(S(0, G(t.sub(D.x), f(1, M(2).div(M(e).add(2)), this.distanceFallOff))));
65
+ });
66
+ let l = T(a.sub(t), this._cameraProjectionMatrix).toVar(), u = W(l, n(l).toVar(), this._cameraProjectionMatrixInverse).toVar().sub(a).toVar();
67
+ L(R(u.z).lessThan(this.thickness), () => {
68
+ let t = I(i, m(u));
69
+ D.y.addAssign(S(0, G(t.sub(D.y), f(1, M(2).div(M(e).add(2)), this.distanceFallOff))));
70
+ });
71
+ });
72
+ let j = P(_(1, D.mul(D))).toVar(), N = I(h, l), F = I(h, i), H = G(.5, V(D.y).sub(V(D.x)).add(j.x.mul(D.x).sub(j.y.mul(D.y)))), U = G(.5, _(2, D.x.mul(D.x)).sub(D.y.mul(D.y))), K = N.mul(H).add(F.mul(U));
73
+ w.addAssign(K);
74
+ }), w.assign(U(w.div(v), 0, 1)), w.assign(y(w, this.scale)), w;
75
+ });
76
+ return this._material.fragmentNode = a().context(e.getSharedContext()), this._material.needsUpdate = !0, this._textureNode;
77
+ }
78
+ dispose() {
79
+ this._aoRenderTarget.dispose(), this._material.dispose();
80
+ }
81
+ };
82
+ function ee(e = 5) {
83
+ let t = Math.floor(e) % 2 == 0 ? Math.floor(e) + 1 : Math.floor(e), r = te(t), i = r.length, o = new Uint8Array(i * 4);
84
+ for (let e = 0; e < i; ++e) {
85
+ let t = r[e], a = 2 * Math.PI * t / i, s = new n(Math.cos(a), Math.sin(a), 0).normalize();
86
+ o[e * 4] = (s.x * .5 + .5) * 255, o[e * 4 + 1] = (s.y * .5 + .5) * 255, o[e * 4 + 2] = 127, o[e * 4 + 3] = 255;
87
+ }
88
+ let s = new l(o, t, t);
89
+ return s.wrapS = a, s.wrapT = a, s.needsUpdate = !0, s;
90
+ }
91
+ function te(e) {
92
+ let t = Math.floor(e) % 2 == 0 ? Math.floor(e) + 1 : Math.floor(e), n = t * t, r = Array(n).fill(0), i = Math.floor(t / 2), a = t - 1;
93
+ for (let e = 1; e <= n;) {
94
+ if (i === -1 && a === t ? (a = t - 2, i = 0) : (a === t && (a = 0), i < 0 && (i = t - 1)), r[i * t + a] !== 0) {
95
+ a -= 2, i++;
96
+ continue;
97
+ } else r[i * t + a] = e++;
98
+ a++, i--;
99
+ }
100
+ return r;
101
+ }
102
+ var ne = (e, t, n) => new $(C(e), C(t), n);
103
+ //#endregion
104
+ export { ne as ao, $ as default };
package/lib/Model.d.ts CHANGED
@@ -8,11 +8,12 @@ type ModelProps = {
8
8
  data: BmtModelData;
9
9
  materialMode?: ViewerMaterialMode;
10
10
  onUploadComplete?: (uploadedItemCount: number) => void;
11
+ onUploadProgress?: (uploadedItemCount: number, totalItemCount: number) => void;
11
12
  useWebGPU?: boolean;
12
13
  };
13
14
  export declare function parseModelMatrix(matrix?: string): Matrix4 | null;
14
15
  export declare function getModelCoordinationMatrix(data: BmtModelData): Matrix4 | null;
15
16
  export declare function getModelCoordinationMatrixSource(data: BmtModelData): string | undefined;
16
- declare function Model({ colorPaletteTexture, coordinationMatrix, modelID, data, materialMode: materialModeOverride, onUploadComplete, useWebGPU, }: ModelProps): import("react/jsx-runtime").JSX.Element;
17
+ declare function Model({ colorPaletteTexture, coordinationMatrix, modelID, data, materialMode: materialModeOverride, onUploadComplete, onUploadProgress, useWebGPU, }: ModelProps): import("react/jsx-runtime").JSX.Element;
17
18
  declare const _default: import("react").MemoExoticComponent<typeof Model>;
18
19
  export default _default;
@@ -16,9 +16,10 @@ type ModelUploadQueueProps = {
16
16
  items: UploadMeshData[];
17
17
  materialMode: ViewerMaterialMode;
18
18
  onUploadComplete?: (uploadedItemCount: number) => void;
19
+ onUploadProgress?: (uploadedItemCount: number, totalItemCount: number) => void;
19
20
  uploadMode: ViewerUploadMode;
20
21
  useDoubleSideMaterial: boolean;
21
22
  useWebGPU: boolean;
22
23
  };
23
- export declare function ModelUploadQueue({ colorPaletteTexture, groupRef, items, materialMode, onUploadComplete, uploadMode, useDoubleSideMaterial, useWebGPU, }: ModelUploadQueueProps): null;
24
+ export declare function ModelUploadQueue({ colorPaletteTexture, groupRef, items, materialMode, onUploadComplete, onUploadProgress, uploadMode, useDoubleSideMaterial, useWebGPU, }: ModelUploadQueueProps): null;
24
25
  export {};
@@ -5,5 +5,5 @@ type SelectablePreselection = {
5
5
  elementID: number;
6
6
  modelID: number;
7
7
  } | null;
8
- export default function useSelector(modelRef: ViewerModelRef, controlRef: ViewerControlsRef, cameraUtils: CameraUtilsApi, setSelectionOrbitPoint?: (point: Vector3) => void, getExtraSelectableObjects?: () => Object3D[], setExtraPreselection?: (preselection: SelectablePreselection) => void): void;
8
+ export default function useSelector(modelRef: ViewerModelRef, controlRef: ViewerControlsRef, cameraUtils: CameraUtilsApi, setSelectionOrbitPoint?: (point: Vector3) => void, getExtraSelectableObjects?: () => Object3D[], setExtraPreselection?: (preselection: SelectablePreselection) => void, isPreselectionReady?: () => boolean, controlsVersion?: number): void;
9
9
  export {};
@@ -1,6 +1,6 @@
1
1
  import type { ColorRepresentation, Group } from "three";
2
2
  import type { SelectedStore, UserDevice, ViewerGridAxesVisibility, ViewerGridAxisSide, ViewerLightingSettings, ViewerLightingSettingsUpdate, ViewerPostproductionActivePassFilter, ViewerStoreApi } from "../store/ViewerStore";
3
- import type { ViewerPostproductionPassType } from "../types";
3
+ import type { ViewerCameraProjection, ViewerPostproductionPassType } from "../types";
4
4
  import { type ViewerPropertiesApi } from "./ViewerPropertiesApi";
5
5
  import type { ViewerClippingApi } from "../utils/ClippingUtils";
6
6
  import type { ViewerColorConfigByModel, ViewerModelColorConfig } from "../utils/ColorsUtils/useElementColors";
@@ -14,6 +14,7 @@ export type { ViewerClippingApi, ViewerClippingVector3Input, } from "../utils/Cl
14
14
  export type { ViewerColorConfigByModel, ViewerModelColorConfig, } from "../utils/ColorsUtils/useElementColors";
15
15
  export type { ViewerDimensionsApi } from "../utils/DimentionsUtils";
16
16
  export type { ViewerCameraGetIntersection } from "../Camera/useCameraUtils";
17
+ export type { ViewerCameraProjection } from "../types";
17
18
  export type ViewerSelection = Record<number, number[]>;
18
19
  export type ViewerGeometryUtilsApi = {
19
20
  getAllIds: () => number[];
@@ -73,6 +74,9 @@ export type ViewerUtilsApi = {
73
74
  export type ViewerCameraApi = {
74
75
  fitCamera: () => void;
75
76
  getIntersection: ViewerCameraGetIntersection;
77
+ getProjection: () => ViewerCameraProjection;
78
+ setProjection: (projection: ViewerCameraProjection) => void;
79
+ toggleProjection: () => ViewerCameraProjection;
76
80
  };
77
81
  export type ViewerBmtConverterOptions = Pick<BmtConverterOptions, "activeView" | "fileName" | "fileNames" | "filterElement" | "useIfcColors" | "useIfcElementAssembly" | "useIfcSpace" | "useMinVersion">;
78
82
  export type ViewerConverterApi = {
package/lib/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { default as Viewer } from "./Viewer";
2
2
  export type { ViewerModelsData, ViewerProps } from "./Viewer";
3
- export type { ViewerMaterialMode, ViewerPostproductionPassType, ViewerUploadMode, } from "./types";
3
+ export type { ViewerCameraProjection, ViewerMaterialMode, ViewerPostproductionPassType, ViewerUploadMode, } from "./types";
4
4
  export type { ViewerApi, ViewerCameraApi, ViewerCameraGetIntersection, ViewerClippingApi, ViewerClippingVector3Input, ViewerColorsApi, ViewerBmtConverterOptions, ViewerConverterApi, ViewerDimensionsApi, ViewerGeometryUtilsApi, ViewerLoadModelsOptions, ViewerModelsApi, ViewerPostproductionApi, ViewerSelection, ViewerSelectorApi, ViewerUtilsApi, } from "./api/ViewerApi";
5
5
  export type { ViewerModelLevel, ViewerModelLevelsByModel, ViewerPropertiesApi, ViewerPropertiesExcelOptions, } from "./api/ViewerPropertiesApi";
6
6
  export { BMTLoader } from "./Loaders/BmtLoader";