@vctrl/hooks 0.9.5 → 0.11.1
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/CHANGELOG.md +210 -0
- package/README.md +202 -383
- package/package.json +66 -55
- package/project.json +55 -0
- package/src/index.ts +38 -0
- package/src/use-export-model/use-export-model.ts +113 -0
- package/src/use-load-model/event-system.ts +46 -0
- package/src/use-load-model/index.ts +15 -0
- package/src/use-load-model/model-context.tsx +174 -0
- package/src/use-load-model/state.ts +75 -0
- package/src/use-load-model/types.ts +284 -0
- package/src/use-load-model/use-load-model.ts +682 -0
- package/src/use-load-model/utils/calculate-referenced-bytes.ts +123 -0
- package/src/use-load-model/utils/index.ts +7 -0
- package/src/use-load-model/utils/read-directory.ts +35 -0
- package/src/use-load-model/utils/reconstruct-files.ts +85 -0
- package/src/use-load-model/utils/resolve-scene-payload.ts +151 -0
- package/{use-optimize-model/index.d.ts → src/use-optimize-model/index.ts} +2 -1
- package/src/use-optimize-model/state.ts +40 -0
- package/src/use-optimize-model/types.ts +37 -0
- package/src/use-optimize-model/use-calc-optimization-info.ts +97 -0
- package/src/use-optimize-model/use-optimize-model.ts +467 -0
- package/src/use-optimize-model/utils/index.ts +29 -0
- package/src/use-optimize-model/utils/texture-optimization.ts +292 -0
- package/src/use-optimize-model/utils/validation.ts +62 -0
- package/src/utils/server-communication.ts +351 -0
- package/tsconfig.json +21 -0
- package/tsconfig.lib.json +16 -0
- package/vite.config.ts +77 -0
- package/GLTFExporter-BmLF430n.cjs +0 -18
- package/GLTFExporter-C4hCeb4H.js +0 -1263
- package/index.cjs.js +0 -1
- package/index.d.ts +0 -3
- package/index.es.js +0 -12
- package/model-context-CQJta_vi.cjs +0 -9
- package/model-context-D1Q8WdpT.js +0 -3431
- package/use-export-model/types.d.ts +0 -19
- package/use-export-model/use-export-model.d.ts +0 -14
- package/use-export-model/utils/data-uri-to-blob.d.ts +0 -9
- package/use-export-model/utils/export-handlers.d.ts +0 -23
- package/use-export-model/utils/file-helpers.d.ts +0 -17
- package/use-export-model/utils/index.d.ts +0 -3
- package/use-export-model-AFharGg5.js +0 -77
- package/use-export-model-CWcKp4A3.cjs +0 -1
- package/use-export-model.cjs.js +0 -1
- package/use-export-model.es.js +0 -4
- package/use-load-model/event-system.d.ts +0 -7
- package/use-load-model/file-type-hooks/index.d.ts +0 -2
- package/use-load-model/file-type-hooks/use-load-binary.d.ts +0 -11
- package/use-load-model/file-type-hooks/use-load-gltf.d.ts +0 -5
- package/use-load-model/index.d.ts +0 -3
- package/use-load-model/loaders/create-gltf-loader.d.ts +0 -3
- package/use-load-model/loaders/create-usdz-loader.d.ts +0 -3
- package/use-load-model/loaders/index.d.ts +0 -2
- package/use-load-model/model-context.d.ts +0 -78
- package/use-load-model/state.d.ts +0 -19
- package/use-load-model/types.d.ts +0 -51
- package/use-load-model/use-load-model.d.ts +0 -74
- package/use-load-model/utils/array-buffer-to-base64.d.ts +0 -2
- package/use-load-model/utils/index.d.ts +0 -2
- package/use-load-model/utils/read-directory.d.ts +0 -8
- package/use-load-model.cjs.js +0 -1
- package/use-load-model.es.js +0 -8
- package/use-optimize-model/state.d.ts +0 -13
- package/use-optimize-model/types.d.ts +0 -37
- package/use-optimize-model/use-optimize-model.d.ts +0 -29
- package/use-optimize-model-Cqkp__Vi.cjs +0 -1
- package/use-optimize-model-DZWIb_40.js +0 -127
- package/use-optimize-model.cjs.js +0 -1
- package/use-optimize-model.es.js +0 -4
- /package/{use-export-model/index.d.ts → src/use-export-model/index.ts} +0 -0
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { useReducer as M, useRef as d, useCallback as n } from "react";
|
|
2
|
-
import { G as _ } from "./GLTFExporter-C4hCeb4H.js";
|
|
3
|
-
import { WebIO as b } from "@gltf-transform/core";
|
|
4
|
-
import { inspect as y, weld as B, simplify as U, dedup as F, quantize as H, normals as K, textureCompress as q } from "@gltf-transform/functions";
|
|
5
|
-
import { KHRMeshQuantization as G, KHRMaterialsVolume as k, KHRMaterialsTransmission as I } from "@gltf-transform/extensions";
|
|
6
|
-
import { MeshoptSimplifier as Q } from "meshoptimizer";
|
|
7
|
-
const f = {
|
|
8
|
-
modelDoc: null,
|
|
9
|
-
modelReport: null,
|
|
10
|
-
error: null,
|
|
11
|
-
loading: !1
|
|
12
|
-
}, V = (i, t) => {
|
|
13
|
-
switch (t.type) {
|
|
14
|
-
case "LOAD_START":
|
|
15
|
-
return { ...i, loading: !0, error: null };
|
|
16
|
-
case "LOAD_SUCCESS":
|
|
17
|
-
return {
|
|
18
|
-
...i,
|
|
19
|
-
loading: !1,
|
|
20
|
-
modelDoc: t.payload.modelDoc,
|
|
21
|
-
modelReport: t.payload.modelReport
|
|
22
|
-
};
|
|
23
|
-
case "LOAD_ERROR":
|
|
24
|
-
return { ...i, loading: !1, error: t.payload };
|
|
25
|
-
case "RESET":
|
|
26
|
-
return { ...f };
|
|
27
|
-
default:
|
|
28
|
-
return i;
|
|
29
|
-
}
|
|
30
|
-
}, P = () => {
|
|
31
|
-
const [i, t] = M(V, f), { modelDoc: s, modelReport: a, error: R, loading: S } = i, O = d(new _()), u = d(
|
|
32
|
-
new b().registerExtensions([
|
|
33
|
-
G,
|
|
34
|
-
k,
|
|
35
|
-
I
|
|
36
|
-
])
|
|
37
|
-
), z = n(async (r) => {
|
|
38
|
-
t({ type: "LOAD_START" });
|
|
39
|
-
try {
|
|
40
|
-
const e = { binary: !0 }, l = await O.current.parseAsync(r, e), c = new Uint8Array(l), p = await u.current.readBinary(c), m = y(p);
|
|
41
|
-
t({
|
|
42
|
-
type: "LOAD_SUCCESS",
|
|
43
|
-
payload: { modelDoc: p, modelReport: m }
|
|
44
|
-
});
|
|
45
|
-
} catch (e) {
|
|
46
|
-
t({ type: "LOAD_ERROR", payload: e }), console.error("Error loading model:", e);
|
|
47
|
-
}
|
|
48
|
-
}, []), o = n(
|
|
49
|
-
async (r) => {
|
|
50
|
-
if (s)
|
|
51
|
-
try {
|
|
52
|
-
await s.transform(...r);
|
|
53
|
-
const e = y(s);
|
|
54
|
-
t({
|
|
55
|
-
type: "LOAD_SUCCESS",
|
|
56
|
-
payload: { modelDoc: s, modelReport: e }
|
|
57
|
-
});
|
|
58
|
-
} catch (e) {
|
|
59
|
-
console.error("Error applying transforms:", e);
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
[s]
|
|
63
|
-
), w = n(
|
|
64
|
-
async (r) => {
|
|
65
|
-
const { ratio: e = 0.5, error: l = 1e-3 } = r || {};
|
|
66
|
-
await o([
|
|
67
|
-
B(),
|
|
68
|
-
U({
|
|
69
|
-
simplifier: Q,
|
|
70
|
-
ratio: e,
|
|
71
|
-
error: l
|
|
72
|
-
})
|
|
73
|
-
]);
|
|
74
|
-
},
|
|
75
|
-
[o]
|
|
76
|
-
), E = n(
|
|
77
|
-
async (r) => {
|
|
78
|
-
await o([F(r)]);
|
|
79
|
-
},
|
|
80
|
-
[o]
|
|
81
|
-
), g = n(
|
|
82
|
-
async (r) => {
|
|
83
|
-
await o([H(r)]);
|
|
84
|
-
},
|
|
85
|
-
[o]
|
|
86
|
-
), D = n(
|
|
87
|
-
async (r) => {
|
|
88
|
-
await o([K(r)]);
|
|
89
|
-
},
|
|
90
|
-
[o]
|
|
91
|
-
), A = n(
|
|
92
|
-
async (r) => {
|
|
93
|
-
r && await o([q(r)]);
|
|
94
|
-
},
|
|
95
|
-
[o]
|
|
96
|
-
), h = n(async () => {
|
|
97
|
-
if (!s) return null;
|
|
98
|
-
try {
|
|
99
|
-
return await u.current.writeBinary(s);
|
|
100
|
-
} catch (r) {
|
|
101
|
-
return console.error("Error getting model binary:", r), null;
|
|
102
|
-
}
|
|
103
|
-
}, [s]), x = n(() => {
|
|
104
|
-
if (!a) return null;
|
|
105
|
-
const r = (m) => m.reduce((C, L) => C + L.size, 0), e = r(a.meshes.properties), l = r(a.textures.properties), c = e + l, p = `${(c / (1024 * 1024)).toFixed(2)} MB`;
|
|
106
|
-
return { fileSize: c, displayFileSize: p };
|
|
107
|
-
}, [a]), T = n(() => {
|
|
108
|
-
t({ type: "RESET" });
|
|
109
|
-
}, []);
|
|
110
|
-
return {
|
|
111
|
-
load: z,
|
|
112
|
-
getModel: h,
|
|
113
|
-
getSize: x,
|
|
114
|
-
report: a,
|
|
115
|
-
simplifyOptimization: w,
|
|
116
|
-
dedupOptimization: E,
|
|
117
|
-
quantizeOptimization: g,
|
|
118
|
-
normalsOptimization: D,
|
|
119
|
-
texturesOptimization: A,
|
|
120
|
-
reset: T,
|
|
121
|
-
error: R,
|
|
122
|
-
loading: S
|
|
123
|
-
};
|
|
124
|
-
};
|
|
125
|
-
export {
|
|
126
|
-
P as u
|
|
127
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./use-optimize-model-Cqkp__Vi.cjs");exports.useOptimizeModel=e.useOptimizeModel;
|
package/use-optimize-model.es.js
DELETED
|
File without changes
|