@needle-tools/gltf-build-pipeline 2.13.0 → 2.13.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.
Files changed (103) hide show
  1. package/CHANGELOG.md +520 -517
  2. package/README.md +38 -38
  3. package/dist/cache/cache.d.ts +55 -55
  4. package/dist/cache/cache.js +326 -326
  5. package/dist/cache/index.d.ts +1 -1
  6. package/dist/cache/index.js +1 -1
  7. package/dist/cli/index.d.ts +2 -2
  8. package/dist/cli/index.js +198 -198
  9. package/dist/config/index.d.ts +53 -53
  10. package/dist/config/index.js +152 -152
  11. package/dist/constants.d.ts +7 -7
  12. package/dist/constants.js +7 -7
  13. package/dist/extensions/NEEDLE_compression_texture/NEEDLE_compression_texture.d.ts +24 -24
  14. package/dist/extensions/NEEDLE_compression_texture/NEEDLE_compression_texture.js +54 -54
  15. package/dist/extensions/NEEDLE_compression_texture/index.d.ts +1 -1
  16. package/dist/extensions/NEEDLE_compression_texture/index.js +1 -1
  17. package/dist/extensions/NEEDLE_mesh_compression/NEEDLE_mesh_compression.d.ts +27 -27
  18. package/dist/extensions/NEEDLE_mesh_compression/NEEDLE_mesh_compression.js +88 -88
  19. package/dist/extensions/NEEDLE_mesh_compression/index.d.ts +1 -1
  20. package/dist/extensions/NEEDLE_mesh_compression/index.js +1 -1
  21. package/dist/extensions/NEEDLE_opaque/NEEDLE_opaque.d.ts +27 -27
  22. package/dist/extensions/NEEDLE_opaque/NEEDLE_opaque.js +980 -980
  23. package/dist/extensions/NEEDLE_opaque/index.d.ts +3 -3
  24. package/dist/extensions/NEEDLE_opaque/index.js +30 -30
  25. package/dist/extensions/NEEDLE_progressive/NEEDLE_progressive.d.ts +48 -48
  26. package/dist/extensions/NEEDLE_progressive/NEEDLE_progressive.js +69 -69
  27. package/dist/extensions/NEEDLE_progressive/index.d.ts +1 -1
  28. package/dist/extensions/NEEDLE_progressive/index.js +1 -1
  29. package/dist/extensions/NEEDLE_progressive_mesh_settings/index.d.ts +23 -23
  30. package/dist/extensions/NEEDLE_progressive_mesh_settings/index.js +41 -41
  31. package/dist/extensions/NEEDLE_progressive_texture_settings/index.d.ts +25 -25
  32. package/dist/extensions/NEEDLE_progressive_texture_settings/index.js +38 -38
  33. package/dist/extensions/index.d.ts +7 -7
  34. package/dist/extensions/index.js +17 -17
  35. package/dist/extensions/utils.d.ts +6 -6
  36. package/dist/extensions/utils.js +72 -72
  37. package/dist/functions/weld.3.d.ts +76 -76
  38. package/dist/functions/weld.3.js +414 -414
  39. package/dist/index.d.ts +8 -8
  40. package/dist/index.js +8 -8
  41. package/dist/scripts/index.d.ts +2 -2
  42. package/dist/scripts/index.js +2 -2
  43. package/dist/scripts/pack-gltf.d.ts +15 -15
  44. package/dist/scripts/pack-gltf.js +135 -133
  45. package/dist/scripts/stats.d.ts +2 -2
  46. package/dist/scripts/stats.js +19 -19
  47. package/dist/transforms/index.d.ts +9 -9
  48. package/dist/transforms/index.js +9 -9
  49. package/dist/transforms/needle_animation_transform.d.ts +2 -2
  50. package/dist/transforms/needle_animation_transform.js +5 -5
  51. package/dist/transforms/needle_asset.d.ts +3 -3
  52. package/dist/transforms/needle_asset.js +50 -50
  53. package/dist/transforms/needle_common.d.ts +17 -17
  54. package/dist/transforms/needle_common.js +1 -1
  55. package/dist/transforms/needle_mesh_transform.d.ts +15 -15
  56. package/dist/transforms/needle_mesh_transform.js +223 -223
  57. package/dist/transforms/needle_progressive.d.ts +45 -45
  58. package/dist/transforms/needle_progressive.js +1043 -1043
  59. package/dist/transforms/needle_texture_transform.d.ts +13 -13
  60. package/dist/transforms/needle_texture_transform.js +257 -257
  61. package/dist/transforms/needle_toktx.d.ts +26 -26
  62. package/dist/transforms/needle_toktx.js +243 -243
  63. package/dist/transforms/needle_webp.d.ts +15 -15
  64. package/dist/transforms/needle_webp.js +53 -53
  65. package/dist/transforms/toktx.d.ts +52 -52
  66. package/dist/transforms/toktx.js +221 -221
  67. package/dist/transforms/toktx_types.d.ts +78 -78
  68. package/dist/transforms/toktx_types.js +62 -62
  69. package/dist/transforms/util.d.ts +21 -21
  70. package/dist/transforms/util.js +90 -90
  71. package/dist/utils/compression_utils.d.ts +2 -2
  72. package/dist/utils/compression_utils.js +6 -6
  73. package/dist/utils/fileutils.d.ts +19 -19
  74. package/dist/utils/fileutils.js +177 -177
  75. package/dist/utils/guid.d.ts +1 -1
  76. package/dist/utils/guid.js +5 -5
  77. package/dist/utils/index.d.ts +10 -10
  78. package/dist/utils/index.js +10 -10
  79. package/dist/utils/merge.d.ts +12 -12
  80. package/dist/utils/merge.js +31 -31
  81. package/dist/utils/mesh.d.ts +13 -13
  82. package/dist/utils/mesh.js +124 -124
  83. package/dist/utils/nodeio.d.ts +6 -6
  84. package/dist/utils/nodeio.js +86 -86
  85. package/dist/utils/stats.d.ts +70 -70
  86. package/dist/utils/stats.js +258 -258
  87. package/dist/utils/texture.d.ts +5 -5
  88. package/dist/utils/texture.js +14 -14
  89. package/dist/utils/validate.d.ts +5 -5
  90. package/dist/utils/validate.js +17 -17
  91. package/dist/utils/version.d.ts +1 -1
  92. package/dist/utils/version.gen.d.ts +1 -1
  93. package/dist/utils/version.gen.js +1 -1
  94. package/dist/utils/version.js +4 -4
  95. package/package.json +79 -79
  96. package/scripts/clear-caches.mjs +3 -3
  97. package/scripts/defaults.mjs +11 -11
  98. package/scripts/fileutils.mjs +5 -5
  99. package/scripts/index.mjs +41 -41
  100. package/scripts/limit-caches.mjs +3 -3
  101. package/scripts/make-progressive.mjs +16 -16
  102. package/scripts/pack-gltf.mjs +106 -106
  103. package/tsconfig.json +19 -19
@@ -1,152 +1,152 @@
1
- import { Logger, Verbosity } from "@gltf-transform/core";
2
- import { existsSync, readFileSync, statSync } from "fs";
3
- import path, { dirname, resolve } from "path";
4
- export const UsecaseOptions = ["product", "world"];
5
- const defaultConfig = {
6
- usecase: "default",
7
- };
8
- /**
9
- * Create a config object with the given usecase.
10
- */
11
- export function createConfig(usecase) {
12
- if (!UsecaseOptions.includes(usecase)) {
13
- throw new Error(`Invalid usecase: \"${usecase}\". Valid usecases: ${UsecaseOptions.join(", ")}`);
14
- }
15
- return {
16
- usecase: usecase
17
- };
18
- }
19
- /**
20
- * Get the config object either provided by a CLI path or a needle.config.json file in the parent directory.
21
- *
22
- * @example CLI argument where the path points to a json file containing the config as `Config`
23
- * ```sh
24
- * node script.js --config path/to/my-optimization-config.json
25
- * ```
26
- *
27
- * @example needle.config.json - the usecase can be provided as a string
28
- * ```json
29
- * {
30
- * "optimization": "product"
31
- * }
32
- * ```
33
- *
34
- * @example needle.config.json - the whole config object can be provided
35
- * ```json
36
- * {
37
- * "optimization": {
38
- * "usecase": "product"
39
- * }
40
- * }
41
- * ```
42
- *
43
- *
44
- */
45
- export function getConfig(configPath, fallbackSearchDirectory, opts) {
46
- let logger = opts?.logger;
47
- if (!logger) {
48
- logger = new Logger(Verbosity.WARN);
49
- }
50
- if (configPath != null) {
51
- configPath = resolve(process.cwd(), configPath);
52
- if (!existsSync(configPath)) {
53
- throw new Error(`No config found at \"${configPath}\"`);
54
- }
55
- const isDirectory = statSync(configPath).isDirectory();
56
- if (isDirectory) {
57
- const res = searchConfig(configPath, logger);
58
- if (res) {
59
- return res;
60
- }
61
- else {
62
- throw new Error(`No config found in directory \"${configPath}\"`);
63
- }
64
- }
65
- const res = resolveConfig(configPath, readFileSync(configPath, "utf8"), logger);
66
- if (res) {
67
- return res;
68
- }
69
- else {
70
- throw new Error(`Failed parsing config at \"${configPath}\"`);
71
- }
72
- }
73
- if (_cachedConfig !== undefined) {
74
- return _cachedConfig;
75
- }
76
- // Resolve the config once and cache it
77
- // Check if a needle.config.json exists in the directory from which the script is run (or any parent directory)
78
- if (fallbackSearchDirectory) {
79
- const result = searchConfig(fallbackSearchDirectory, logger);
80
- if (result) {
81
- _cachedConfig = { ...defaultConfig, ...result };
82
- logger.info("Using config with usecase: " + _cachedConfig.usecase);
83
- }
84
- }
85
- // If no config was found, use the default config
86
- if (!_cachedConfig) {
87
- logger.info("No config found. Using default config.");
88
- _cachedConfig = defaultConfig;
89
- }
90
- return _cachedConfig;
91
- }
92
- let _cachedConfig = undefined;
93
- export function searchConfig(directory, logger) {
94
- if (statSync(directory).isFile()) {
95
- directory = dirname(directory);
96
- }
97
- directory = directory.replaceAll("\\", "/");
98
- while (directory.length > 0) {
99
- const configPath = path.join(directory, "needle.config.json");
100
- if (existsSync(configPath)) {
101
- const content = readFileSync(configPath, "utf8");
102
- const config = resolveConfig(configPath, content, logger);
103
- if (config) {
104
- return config;
105
- }
106
- }
107
- const lastSlash = directory.lastIndexOf("/");
108
- if (lastSlash < 0) {
109
- break;
110
- }
111
- directory = directory.slice(0, lastSlash);
112
- }
113
- return null;
114
- }
115
- function resolveConfig(filename, content, logger) {
116
- // Handle config being part of `needle.config.json`
117
- if (filename.endsWith("needle.config.json")) {
118
- try {
119
- const config = JSON.parse(content);
120
- if (config.gltf) {
121
- logger.info("Found \"gltf\" config at \"" + filename + "\".");
122
- // If the optimization config is a string, it's the usecase
123
- if (typeof config.gltf === "string") {
124
- return createConfig(config.gltf);
125
- }
126
- return config.gltf;
127
- }
128
- else {
129
- logger.info("No \"gltf\" config found in needle.config.json. Using default config.");
130
- return null;
131
- }
132
- }
133
- catch (err) {
134
- logger.error(`Failed parsing config \"${err.message}\" at ${filename}`);
135
- }
136
- }
137
- // Handle config being the content of the file
138
- else if (content.trimStart().startsWith("{")) {
139
- try {
140
- return JSON.parse(content);
141
- }
142
- catch (err) {
143
- if (err instanceof Error)
144
- logger.error(`Failed parsing config \"${err.message}\" at ${filename}`);
145
- else
146
- logger.error(`Failed parsing config \"${err}\" at ${filename}`);
147
- }
148
- }
149
- else {
150
- logger.error("Invalid config file format. Expected JSON object at " + filename);
151
- }
152
- }
1
+ import { Logger, Verbosity } from "@gltf-transform/core";
2
+ import { existsSync, readFileSync, statSync } from "fs";
3
+ import path, { dirname, resolve } from "path";
4
+ export const UsecaseOptions = ["product", "world"];
5
+ const defaultConfig = {
6
+ usecase: "default",
7
+ };
8
+ /**
9
+ * Create a config object with the given usecase.
10
+ */
11
+ export function createConfig(usecase) {
12
+ if (!UsecaseOptions.includes(usecase)) {
13
+ throw new Error(`Invalid usecase: \"${usecase}\". Valid usecases: ${UsecaseOptions.join(", ")}`);
14
+ }
15
+ return {
16
+ usecase: usecase
17
+ };
18
+ }
19
+ /**
20
+ * Get the config object either provided by a CLI path or a needle.config.json file in the parent directory.
21
+ *
22
+ * @example CLI argument where the path points to a json file containing the config as `Config`
23
+ * ```sh
24
+ * node script.js --config path/to/my-optimization-config.json
25
+ * ```
26
+ *
27
+ * @example needle.config.json - the usecase can be provided as a string
28
+ * ```json
29
+ * {
30
+ * "optimization": "product"
31
+ * }
32
+ * ```
33
+ *
34
+ * @example needle.config.json - the whole config object can be provided
35
+ * ```json
36
+ * {
37
+ * "optimization": {
38
+ * "usecase": "product"
39
+ * }
40
+ * }
41
+ * ```
42
+ *
43
+ *
44
+ */
45
+ export function getConfig(configPath, fallbackSearchDirectory, opts) {
46
+ let logger = opts?.logger;
47
+ if (!logger) {
48
+ logger = new Logger(Verbosity.WARN);
49
+ }
50
+ if (configPath != null) {
51
+ configPath = resolve(process.cwd(), configPath);
52
+ if (!existsSync(configPath)) {
53
+ throw new Error(`No config found at \"${configPath}\"`);
54
+ }
55
+ const isDirectory = statSync(configPath).isDirectory();
56
+ if (isDirectory) {
57
+ const res = searchConfig(configPath, logger);
58
+ if (res) {
59
+ return res;
60
+ }
61
+ else {
62
+ throw new Error(`No config found in directory \"${configPath}\"`);
63
+ }
64
+ }
65
+ const res = resolveConfig(configPath, readFileSync(configPath, "utf8"), logger);
66
+ if (res) {
67
+ return res;
68
+ }
69
+ else {
70
+ throw new Error(`Failed parsing config at \"${configPath}\"`);
71
+ }
72
+ }
73
+ if (_cachedConfig !== undefined) {
74
+ return _cachedConfig;
75
+ }
76
+ // Resolve the config once and cache it
77
+ // Check if a needle.config.json exists in the directory from which the script is run (or any parent directory)
78
+ if (fallbackSearchDirectory) {
79
+ const result = searchConfig(fallbackSearchDirectory, logger);
80
+ if (result) {
81
+ _cachedConfig = { ...defaultConfig, ...result };
82
+ logger.info("Using config with usecase: " + _cachedConfig.usecase);
83
+ }
84
+ }
85
+ // If no config was found, use the default config
86
+ if (!_cachedConfig) {
87
+ logger.info("No config found. Using default config.");
88
+ _cachedConfig = defaultConfig;
89
+ }
90
+ return _cachedConfig;
91
+ }
92
+ let _cachedConfig = undefined;
93
+ export function searchConfig(directory, logger) {
94
+ if (statSync(directory).isFile()) {
95
+ directory = dirname(directory);
96
+ }
97
+ directory = directory.replaceAll("\\", "/");
98
+ while (directory.length > 0) {
99
+ const configPath = path.join(directory, "needle.config.json");
100
+ if (existsSync(configPath)) {
101
+ const content = readFileSync(configPath, "utf8");
102
+ const config = resolveConfig(configPath, content, logger);
103
+ if (config) {
104
+ return config;
105
+ }
106
+ }
107
+ const lastSlash = directory.lastIndexOf("/");
108
+ if (lastSlash < 0) {
109
+ break;
110
+ }
111
+ directory = directory.slice(0, lastSlash);
112
+ }
113
+ return null;
114
+ }
115
+ function resolveConfig(filename, content, logger) {
116
+ // Handle config being part of `needle.config.json`
117
+ if (filename.endsWith("needle.config.json")) {
118
+ try {
119
+ const config = JSON.parse(content);
120
+ if (config.gltf) {
121
+ logger.info("Found \"gltf\" config at \"" + filename + "\".");
122
+ // If the optimization config is a string, it's the usecase
123
+ if (typeof config.gltf === "string") {
124
+ return createConfig(config.gltf);
125
+ }
126
+ return config.gltf;
127
+ }
128
+ else {
129
+ logger.info("No \"gltf\" config found in needle.config.json. Using default config.");
130
+ return null;
131
+ }
132
+ }
133
+ catch (err) {
134
+ logger.error(`Failed parsing config \"${err.message}\" at ${filename}`);
135
+ }
136
+ }
137
+ // Handle config being the content of the file
138
+ else if (content.trimStart().startsWith("{")) {
139
+ try {
140
+ return JSON.parse(content);
141
+ }
142
+ catch (err) {
143
+ if (err instanceof Error)
144
+ logger.error(`Failed parsing config \"${err.message}\" at ${filename}`);
145
+ else
146
+ logger.error(`Failed parsing config \"${err}\" at ${filename}`);
147
+ }
148
+ }
149
+ else {
150
+ logger.error("Invalid config file format. Expected JSON object at " + filename);
151
+ }
152
+ }
@@ -1,7 +1,7 @@
1
- export declare const ERROR_CODES: {
2
- UNKNOWN_ERROR: number;
3
- PACKING_FAILED: number;
4
- PROGRESSIVE_FAILED: number;
5
- INVALID_ARGS: number;
6
- LOST_FILE: number;
7
- };
1
+ export declare const ERROR_CODES: {
2
+ UNKNOWN_ERROR: number;
3
+ PACKING_FAILED: number;
4
+ PROGRESSIVE_FAILED: number;
5
+ INVALID_ARGS: number;
6
+ LOST_FILE: number;
7
+ };
package/dist/constants.js CHANGED
@@ -1,7 +1,7 @@
1
- export const ERROR_CODES = {
2
- UNKNOWN_ERROR: 1,
3
- PACKING_FAILED: 2,
4
- PROGRESSIVE_FAILED: 3,
5
- INVALID_ARGS: 4,
6
- LOST_FILE: 5,
7
- };
1
+ export const ERROR_CODES = {
2
+ UNKNOWN_ERROR: 1,
3
+ PACKING_FAILED: 2,
4
+ PROGRESSIVE_FAILED: 3,
5
+ INVALID_ARGS: 4,
6
+ LOST_FILE: 5,
7
+ };
@@ -1,24 +1,24 @@
1
- import { Extension, ExtensionProperty, PropertyType, ReaderContext, WriterContext } from "@gltf-transform/core";
2
- export declare const EXTENSION_NAME = "NEEDLE_compression_texture";
3
- export declare interface NEEDLE_compression_texture_schema {
4
- mode: "none" | "auto" | "webp" | "UASTC" | "ETC1S" | "world" | "product";
5
- slot: string;
6
- /** quality in range of 0 - 1 */
7
- quality: number;
8
- maxSize: number;
9
- }
10
- export declare class NEEDLE_compression_texture extends Extension {
11
- static EXTENSION_NAME: string;
12
- extensionName: string;
13
- create(toktxInfo: NEEDLE_compression_texture_schema): NEEDLE_compression_texture_property;
14
- read(context: ReaderContext): this;
15
- write(context: WriterContext): this;
16
- }
17
- export declare class NEEDLE_compression_texture_property extends ExtensionProperty {
18
- static EXTENSION_NAME: string;
19
- extensionName: string;
20
- parentTypes: PropertyType[];
21
- propertyType: any;
22
- init(): void;
23
- model: NEEDLE_compression_texture_schema;
24
- }
1
+ import { Extension, ExtensionProperty, PropertyType, ReaderContext, WriterContext } from "@gltf-transform/core";
2
+ export declare const EXTENSION_NAME = "NEEDLE_compression_texture";
3
+ export declare interface NEEDLE_compression_texture_schema {
4
+ mode: "none" | "auto" | "webp" | "UASTC" | "ETC1S" | "world" | "product";
5
+ slot: string;
6
+ /** quality in range of 0 - 1 */
7
+ quality: number;
8
+ maxSize: number;
9
+ }
10
+ export declare class NEEDLE_compression_texture extends Extension {
11
+ static EXTENSION_NAME: string;
12
+ extensionName: string;
13
+ create(toktxInfo: NEEDLE_compression_texture_schema): NEEDLE_compression_texture_property;
14
+ read(context: ReaderContext): this;
15
+ write(context: WriterContext): this;
16
+ }
17
+ export declare class NEEDLE_compression_texture_property extends ExtensionProperty {
18
+ static EXTENSION_NAME: string;
19
+ extensionName: string;
20
+ parentTypes: PropertyType[];
21
+ propertyType: any;
22
+ init(): void;
23
+ model: NEEDLE_compression_texture_schema;
24
+ }
@@ -1,54 +1,54 @@
1
- import { Extension, ExtensionProperty, PropertyType } from "@gltf-transform/core";
2
- import { getTextureDefinition } from "../utils.js";
3
- export const EXTENSION_NAME = "NEEDLE_compression_texture";
4
- const debugLog = false;
5
- export class NEEDLE_compression_texture extends Extension {
6
- static EXTENSION_NAME = EXTENSION_NAME;
7
- extensionName = EXTENSION_NAME;
8
- create(toktxInfo) {
9
- const ext = new NEEDLE_compression_texture_property(this.document.getGraph(), "");
10
- ext.model = toktxInfo;
11
- return ext;
12
- }
13
- read(context) {
14
- if (debugLog)
15
- console.log("READ " + EXTENSION_NAME);
16
- if (!context.jsonDoc.json.textures)
17
- return this;
18
- context.textures?.forEach((tex, _) => {
19
- const textureDefinition = getTextureDefinition(context, tex);
20
- if (textureDefinition?.extensions && textureDefinition.extensions[EXTENSION_NAME]) {
21
- const prop = new NEEDLE_compression_texture_property(this.document.getGraph(), EXTENSION_NAME);
22
- prop.model = textureDefinition.extensions[EXTENSION_NAME];
23
- tex.setExtension(EXTENSION_NAME, prop);
24
- }
25
- });
26
- return this;
27
- }
28
- write(context) {
29
- if (debugLog)
30
- console.log("WRITE " + EXTENSION_NAME);
31
- const root = this.document.getRoot();
32
- const textures = root.listTextures();
33
- for (const tex of textures) {
34
- const ext = tex.getExtension(EXTENSION_NAME);
35
- if (ext) {
36
- const def = getTextureDefinition(context, tex);
37
- if (def) {
38
- def.extensions = def.extensions || {};
39
- def.extensions[EXTENSION_NAME] = ext.model;
40
- }
41
- }
42
- }
43
- return this;
44
- }
45
- }
46
- export class NEEDLE_compression_texture_property extends ExtensionProperty {
47
- static EXTENSION_NAME = EXTENSION_NAME;
48
- init() {
49
- this.extensionName = EXTENSION_NAME;
50
- this.parentTypes = [PropertyType.TEXTURE];
51
- this.propertyType = EXTENSION_NAME;
52
- }
53
- model;
54
- }
1
+ import { Extension, ExtensionProperty, PropertyType } from "@gltf-transform/core";
2
+ import { getTextureDefinition } from "../utils.js";
3
+ export const EXTENSION_NAME = "NEEDLE_compression_texture";
4
+ const debugLog = false;
5
+ export class NEEDLE_compression_texture extends Extension {
6
+ static EXTENSION_NAME = EXTENSION_NAME;
7
+ extensionName = EXTENSION_NAME;
8
+ create(toktxInfo) {
9
+ const ext = new NEEDLE_compression_texture_property(this.document.getGraph(), "");
10
+ ext.model = toktxInfo;
11
+ return ext;
12
+ }
13
+ read(context) {
14
+ if (debugLog)
15
+ console.log("READ " + EXTENSION_NAME);
16
+ if (!context.jsonDoc.json.textures)
17
+ return this;
18
+ context.textures?.forEach((tex, _) => {
19
+ const textureDefinition = getTextureDefinition(context, tex);
20
+ if (textureDefinition?.extensions && textureDefinition.extensions[EXTENSION_NAME]) {
21
+ const prop = new NEEDLE_compression_texture_property(this.document.getGraph(), EXTENSION_NAME);
22
+ prop.model = textureDefinition.extensions[EXTENSION_NAME];
23
+ tex.setExtension(EXTENSION_NAME, prop);
24
+ }
25
+ });
26
+ return this;
27
+ }
28
+ write(context) {
29
+ if (debugLog)
30
+ console.log("WRITE " + EXTENSION_NAME);
31
+ const root = this.document.getRoot();
32
+ const textures = root.listTextures();
33
+ for (const tex of textures) {
34
+ const ext = tex.getExtension(EXTENSION_NAME);
35
+ if (ext) {
36
+ const def = getTextureDefinition(context, tex);
37
+ if (def) {
38
+ def.extensions = def.extensions || {};
39
+ def.extensions[EXTENSION_NAME] = ext.model;
40
+ }
41
+ }
42
+ }
43
+ return this;
44
+ }
45
+ }
46
+ export class NEEDLE_compression_texture_property extends ExtensionProperty {
47
+ static EXTENSION_NAME = EXTENSION_NAME;
48
+ init() {
49
+ this.extensionName = EXTENSION_NAME;
50
+ this.parentTypes = [PropertyType.TEXTURE];
51
+ this.propertyType = EXTENSION_NAME;
52
+ }
53
+ model;
54
+ }
@@ -1 +1 @@
1
- export * from "./NEEDLE_compression_texture.js";
1
+ export * from "./NEEDLE_compression_texture.js";
@@ -1 +1 @@
1
- export * from "./NEEDLE_compression_texture.js";
1
+ export * from "./NEEDLE_compression_texture.js";
@@ -1,27 +1,27 @@
1
- import { Extension, ExtensionProperty, PropertyType, ReaderContext, WriterContext } from "@gltf-transform/core";
2
- export declare class NEEDLE_mesh_compression_model_root {
3
- compression: "none" | "draco" | "meshopt";
4
- constructor(compression: "none" | "draco" | "meshopt");
5
- }
6
- export declare class NEEDLE_mesh_compression_model {
7
- useSimplifier: boolean;
8
- error: number;
9
- ratio: number;
10
- lockBorder: boolean;
11
- }
12
- export declare class NEEDLE_mesh_compression extends Extension {
13
- static EXTENSION_NAME: string;
14
- extensionName: string;
15
- create(model: NEEDLE_mesh_compression_model | NEEDLE_mesh_compression_model_root): NEEDLE_mesh_compression_property;
16
- read(context: ReaderContext): this;
17
- write(ctx: WriterContext): this;
18
- }
19
- export declare class NEEDLE_mesh_compression_property extends ExtensionProperty {
20
- static EXTENSION_NAME: string;
21
- readonly extensionName: string;
22
- parentTypes: PropertyType[];
23
- propertyType: string;
24
- init(): void;
25
- model: NEEDLE_mesh_compression_model | NEEDLE_mesh_compression_model_root;
26
- copy(other: this, resolve?: (property: ExtensionProperty) => ExtensionProperty): this;
27
- }
1
+ import { Extension, ExtensionProperty, PropertyType, ReaderContext, WriterContext } from "@gltf-transform/core";
2
+ export declare class NEEDLE_mesh_compression_model_root {
3
+ compression: "none" | "draco" | "meshopt";
4
+ constructor(compression: "none" | "draco" | "meshopt");
5
+ }
6
+ export declare class NEEDLE_mesh_compression_model {
7
+ useSimplifier: boolean;
8
+ error: number;
9
+ ratio: number;
10
+ lockBorder: boolean;
11
+ }
12
+ export declare class NEEDLE_mesh_compression extends Extension {
13
+ static EXTENSION_NAME: string;
14
+ extensionName: string;
15
+ create(model: NEEDLE_mesh_compression_model | NEEDLE_mesh_compression_model_root): NEEDLE_mesh_compression_property;
16
+ read(context: ReaderContext): this;
17
+ write(ctx: WriterContext): this;
18
+ }
19
+ export declare class NEEDLE_mesh_compression_property extends ExtensionProperty {
20
+ static EXTENSION_NAME: string;
21
+ readonly extensionName: string;
22
+ parentTypes: PropertyType[];
23
+ propertyType: string;
24
+ init(): void;
25
+ model: NEEDLE_mesh_compression_model | NEEDLE_mesh_compression_model_root;
26
+ copy(other: this, resolve?: (property: ExtensionProperty) => ExtensionProperty): this;
27
+ }