metamaker-for-three 0.1.8-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.
Files changed (51) hide show
  1. package/.env.dev +1 -0
  2. package/.env.mlib +1 -0
  3. package/.gitlab-ci.yml +1 -0
  4. package/.prettierrc.js +50 -0
  5. package/README.md +207 -0
  6. package/babel.config.js +3 -0
  7. package/code.jpg +0 -0
  8. package/examples/example.ts +624 -0
  9. package/libs/metamaker-for-three.js +1 -0
  10. package/package.json +89 -0
  11. package/public/SSSLUT.png +0 -0
  12. package/public/f9d25cc22be065191dca0f2ac7b248fd.zip +0 -0
  13. package/public/favicon.ico +0 -0
  14. package/public/index.html +31 -0
  15. package/public/models/gltf/xj/-43190.jpg +0 -0
  16. package/public/models/gltf/xj/-43240.jpg +0 -0
  17. package/public/models/gltf/xj/-43256.png +0 -0
  18. package/public/models/gltf/xj/-44804.jpg +0 -0
  19. package/public/models/gltf/xj/22344.jpg +0 -0
  20. package/public/models/gltf/xj/37430.jpg +0 -0
  21. package/public/models/gltf/xj/37432.jpg +0 -0
  22. package/public/models/gltf/xj/character.bin +0 -0
  23. package/public/models/gltf/xj/character.glb +0 -0
  24. package/public/models/gltf/xj/character.gltf +12110 -0
  25. package/public/models/gltf/xj/character.zip +0 -0
  26. package/src/assets/SSSLUT.png +0 -0
  27. package/src/assets/metacrypto.wasm +0 -0
  28. package/src/lib/core/index.ts +103 -0
  29. package/src/lib/core/utils/GLTFLoader.d.ts +319 -0
  30. package/src/lib/core/utils/GLTFLoader.js +3827 -0
  31. package/src/lib/core/utils/ResetMaterial.ts +264 -0
  32. package/src/lib/core/utils/convert.ts +124 -0
  33. package/src/lib/core/utils/downloadAnimation.ts +117 -0
  34. package/src/lib/core/utils/downloadData.ts +20 -0
  35. package/src/lib/core/utils/index.ts +59 -0
  36. package/src/lib/core/utils/metacrypto.js +49 -0
  37. package/src/lib/globals.d.ts +7 -0
  38. package/src/lib/index.ts +7 -0
  39. package/tsconfig.dist.json +7 -0
  40. package/tsconfig.json +33 -0
  41. package/types/core/index.d.ts +9 -0
  42. package/types/core/utils/GLTFLoader.d.ts +17 -0
  43. package/types/core/utils/ResetMaterial.d.ts +2 -0
  44. package/types/core/utils/convert.d.ts +13 -0
  45. package/types/core/utils/downloadAnimation.d.ts +10 -0
  46. package/types/core/utils/downloadData.d.ts +2 -0
  47. package/types/core/utils/index.d.ts +13 -0
  48. package/types/core/utils/metacrypto.d.ts +12 -0
  49. package/types/index.d.ts +5 -0
  50. package/vue.config.js +49 -0
  51. package/vue.config.lib.js +61 -0
@@ -0,0 +1,9 @@
1
+ import * as THREE from "three";
2
+ import { resetPolygonOffset } from "./utils/ResetMaterial";
3
+ import { downloadAnimation, loadAnimationData } from "./utils/downloadAnimation";
4
+ import Convert from "./utils/convert";
5
+ declare function loadGLTFModel(url: string): Promise<THREE.Group>;
6
+ declare function parseGLTFModel(buffer: ArrayBuffer): Promise<THREE.Group>;
7
+ declare function loadTTSTeethAnimation(url: string): Promise<THREE.AnimationClip>;
8
+ declare function loadTTSEmoAnimation(url: string): Promise<THREE.AnimationClip>;
9
+ export { Convert, loadAnimationData, downloadAnimation, loadGLTFModel, parseGLTFModel, loadTTSTeethAnimation, loadTTSEmoAnimation, resetPolygonOffset };
@@ -0,0 +1,17 @@
1
+ export class GLTFLoader extends Loader {
2
+ constructor(manager: any);
3
+ dracoLoader: any;
4
+ ktx2Loader: any;
5
+ meshoptDecoder: any;
6
+ pluginCallbacks: any[];
7
+ load(url: any, onLoad: any, onProgress: any, onError: any): void;
8
+ setDRACOLoader(dracoLoader: any): GLTFLoader;
9
+ setDDSLoader(): void;
10
+ setKTX2Loader(ktx2Loader: any): GLTFLoader;
11
+ setMeshoptDecoder(meshoptDecoder: any): GLTFLoader;
12
+ register(callback: any): GLTFLoader;
13
+ unregister(callback: any): GLTFLoader;
14
+ parse(data: any, path: any, onLoad: any, onError: any): void;
15
+ parseAsync(data: any, path: any): Promise<any>;
16
+ }
17
+ import { Loader } from "three/src/loaders/Loader";
@@ -0,0 +1,2 @@
1
+ export declare function resetPolygonOffset(model: any, camera: any): void;
2
+ export declare function resetMaterial(model: any): void;
@@ -0,0 +1,13 @@
1
+ import * as THREE from "three";
2
+ export declare let bodyMeshName: any;
3
+ export declare let Tooth_downMeshName: any;
4
+ export declare function setBodyMorphTargetDictionary(name: any, map: any): void;
5
+ export declare function setTeethMorphTargetDictionary(name: any, map: any): void;
6
+ /**
7
+ *
8
+ * @param { object } fp 动画文件json结构的描述
9
+ * @param {boolean} isEmotion 是否为表情类型的动画
10
+ * @returns { AnimationClip }
11
+ * @desc 通过将JSON结构的描述转化为 THREEJS 的AnimationClip
12
+ */
13
+ export default function Convert(fp: any, isEmotion?: boolean): THREE.AnimationClip;
@@ -0,0 +1,10 @@
1
+ import * as THREE from "three";
2
+ export declare function downloadAnimation(animationName: any, geometryName: any): Promise<THREE.AnimationClip>;
3
+ /**
4
+ *
5
+ * @param animateName 动画名称
6
+ * @param baseUrl 地址前缀
7
+ * @returns {Promise<object>}
8
+ * 通过动画名称加载动画的描述,得到的是JSON结构的数据
9
+ */
10
+ export declare const loadAnimationData: (animateName: string, baseUrl?: string) => Promise<object>;
@@ -0,0 +1,2 @@
1
+ declare const downloadData: (url: any, type: any) => Promise<unknown>;
2
+ export { downloadData };
@@ -0,0 +1,13 @@
1
+ /**
2
+ *
3
+ * @param { string } name 文件名称
4
+ * @returns { string } 后缀名
5
+ */
6
+ export declare const getSuffixName: (name: any) => any;
7
+ export declare function Uint8ArrayToString(fileData: any): string;
8
+ export declare function largeUint8ArrayToString(uint8arr: any): Promise<string>;
9
+ export declare const b64toBlob: (b64Data: any, contentType?: string, sliceSize?: number) => Blob;
10
+ export declare const splitb64: (str: string) => {
11
+ b64Data: string;
12
+ contentType: string;
13
+ };
@@ -0,0 +1,12 @@
1
+ export default cryptoModule;
2
+ declare let cryptoModule: CryptoModule;
3
+ declare class CryptoModule {
4
+ initPromise: Promise<any>;
5
+ info: {
6
+ wasi_snapshot_preview1: {
7
+ proc_exit: () => void;
8
+ };
9
+ };
10
+ loadWasm(): void;
11
+ decryptData(data: any): Promise<Uint8Array>;
12
+ }
@@ -0,0 +1,5 @@
1
+ import * as core from "./core";
2
+ declare const MMFT: {
3
+ core: typeof core;
4
+ };
5
+ export default MMFT;
package/vue.config.js ADDED
@@ -0,0 +1,49 @@
1
+ const { defineConfig } = require("@vue/cli-service");
2
+
3
+ const path = require("path");
4
+
5
+ if (process.env.VUE_BUILD_APP == "mlib") {
6
+ module.exports = require("./vue.config.lib");
7
+ } else {
8
+ module.exports = defineConfig({
9
+ transpileDependencies: true,
10
+ pages: {
11
+ index: "./examples/example.ts",
12
+ },
13
+ configureWebpack: (config) => {
14
+ const wasmExtensionRegExp = /\.wasm$/;
15
+ // config.module.rules.push({
16
+ // test: /\.worker\.js$/, // 以.worker.js结尾的文件将被worker-loader加载
17
+ // use: { loader: "worker-loader" },
18
+ // });
19
+ config.devtool = "source-map";
20
+
21
+ config.resolve.extensions.push(".wasm");
22
+
23
+ config.module.rules.forEach((rule) => {
24
+ (rule.oneOf || []).forEach((oneOf) => {
25
+ if (oneOf.loader && oneOf.loader.indexOf("file-loader") >= 0) {
26
+ // make file-loader ignore WASM files
27
+
28
+ oneOf.exclude.push(wasmExtensionRegExp);
29
+ }
30
+ });
31
+ });
32
+
33
+ config.module.rules.forEach((rule) => {
34
+ if (rule.__ruleNames[0] == "images") {
35
+ rule.type = "asset/inline";
36
+ rule.parser = { dataUrlCondition: { maxSize: 1024 * 412 } };
37
+ delete rule.generator;
38
+ }
39
+ });
40
+
41
+ config.module.rules.push({
42
+ test: wasmExtensionRegExp,
43
+ include: path.resolve(__dirname, "src"),
44
+
45
+ use: [{ loader: require.resolve("wasm-loader"), options: {} }],
46
+ });
47
+ },
48
+ });
49
+ }
@@ -0,0 +1,61 @@
1
+ const { defineConfig } = require("@vue/cli-service");
2
+
3
+ const path = require("path");
4
+
5
+ module.exports = defineConfig({
6
+ transpileDependencies: true,
7
+ lintOnSave: false,
8
+ outputDir: "./libs",
9
+ configureWebpack: (config) => {
10
+ config.entry = "./src/lib/index.ts";
11
+ config.mode = "production";
12
+ const wasmExtensionRegExp = /\.wasm$/;
13
+ config.devtool = false;
14
+
15
+ config.resolve.extensions.push(".wasm");
16
+ config.module.rules.forEach((rule) => {
17
+ (rule.oneOf || []).forEach((oneOf) => {
18
+ if (oneOf.loader && oneOf.loader.indexOf("file-loader") >= 0) {
19
+ oneOf.exclude.push(wasmExtensionRegExp);
20
+ }
21
+ });
22
+ });
23
+ config.module.rules.forEach((rule) => {
24
+ if (rule.__ruleNames[0] == "images") {
25
+ rule.type = "asset/inline";
26
+ rule.parser = { dataUrlCondition: { maxSize: 1024 * 412 } };
27
+ delete rule.generator;
28
+ }
29
+ });
30
+ config.module.rules.push({
31
+ test: wasmExtensionRegExp,
32
+ include: path.resolve(__dirname, "src"),
33
+ use: [{ loader: require.resolve("wasm-loader"), options: {} }],
34
+ });
35
+
36
+ config.output.filename = "metamaker-for-three.js";
37
+ config.output.library = {
38
+ root: "_MMFT",
39
+ amd: "_MMFT",
40
+ commonjs: "_MMFT",
41
+ };
42
+ config.output.libraryExport = "default";
43
+ config.output.libraryTarget = "umd";
44
+ config.externals = {
45
+ three: {
46
+ root: "THREE",
47
+ amd: "three",
48
+ commonjs2: "three",
49
+ commonjs: "three",
50
+ },
51
+ };
52
+ config.optimization.minimizer[0].options.minimizer.options.compress.drop_console = true;
53
+ delete config.optimization.splitChunks;
54
+ config.plugins = config.plugins.filter((plugin) => {
55
+ return (
56
+ plugin.__pluginConstructorName != "HtmlWebpackPlugin" &&
57
+ plugin.__pluginConstructorName != "CopyPlugin"
58
+ );
59
+ });
60
+ },
61
+ });