selva-compute 1.0.0 → 1.1.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.
- package/README.md +1 -78
- package/dist/{chunk-P57VU27W.cjs → chunk-FNWG34KH.cjs} +2 -2
- package/dist/chunk-FNWG34KH.cjs.map +1 -0
- package/dist/chunk-G6W5VE7C.cjs +2 -0
- package/dist/chunk-G6W5VE7C.cjs.map +1 -0
- package/dist/chunk-I3OX3G7J.js +2 -0
- package/dist/chunk-I3OX3G7J.js.map +1 -0
- package/dist/{chunk-5DJRUPGI.cjs → chunk-M2HPEWXH.cjs} +2 -2
- package/dist/chunk-M2HPEWXH.cjs.map +1 -0
- package/dist/{chunk-AEQTQHPY.js → chunk-QFHFH5BS.js} +2 -2
- package/dist/chunk-QFHFH5BS.js.map +1 -0
- package/dist/{chunk-24EXIE4G.js → chunk-VGM4KAFN.js} +2 -2
- package/dist/chunk-VGM4KAFN.js.map +1 -0
- package/dist/core.cjs +1 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +1 -1
- package/dist/grasshopper.cjs +1 -1
- package/dist/grasshopper.cjs.map +1 -1
- package/dist/grasshopper.d.cts +93 -7
- package/dist/grasshopper.d.ts +93 -7
- package/dist/grasshopper.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -4
- package/dist/index.d.ts +2 -4
- package/dist/index.js +1 -1
- package/dist/{schemas-5LuPKgX2.d.cts → schemas-CQEJ5EZy.d.cts} +1 -1
- package/dist/{schemas-5LuPKgX2.d.ts → schemas-CQEJ5EZy.d.ts} +1 -1
- package/dist/visualization.cjs +1 -1
- package/dist/visualization.cjs.map +1 -1
- package/dist/visualization.d.cts +1 -1
- package/dist/visualization.d.ts +1 -1
- package/dist/visualization.js +1 -1
- package/dist/visualization.js.map +1 -1
- package/package.json +118 -116
- package/dist/chunk-24EXIE4G.js.map +0 -1
- package/dist/chunk-5DJRUPGI.cjs.map +0 -1
- package/dist/chunk-AEQTQHPY.js.map +0 -1
- package/dist/chunk-JJLRDYYP.js +0 -2
- package/dist/chunk-JJLRDYYP.js.map +0 -1
- package/dist/chunk-OXD76DAK.js +0 -2
- package/dist/chunk-OXD76DAK.js.map +0 -1
- package/dist/chunk-P57VU27W.cjs.map +0 -1
- package/dist/chunk-PNG3L5TM.cjs +0 -2
- package/dist/chunk-PNG3L5TM.cjs.map +0 -1
- package/dist/chunk-TVCJBLSW.cjs +0 -2
- package/dist/chunk-TVCJBLSW.cjs.map +0 -1
- package/dist/files.cjs +0 -2
- package/dist/files.cjs.map +0 -1
- package/dist/files.d.cts +0 -34
- package/dist/files.d.ts +0 -34
- package/dist/files.js +0 -2
- package/dist/files.js.map +0 -1
- package/dist/types-SwbLAMW8.d.cts +0 -27
- package/dist/types-SwbLAMW8.d.ts +0 -27
package/dist/core.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as ComputeConfig,
|
|
2
|
-
export { R as RhinoModelUnit } from './schemas-
|
|
1
|
+
import { C as ComputeConfig, d as GrasshopperComputeConfig, c as GrasshopperComputeResponse, g as IoResponseSchema } from './schemas-CQEJ5EZy.cjs';
|
|
2
|
+
export { R as RhinoModelUnit } from './schemas-CQEJ5EZy.cjs';
|
|
3
3
|
export { C as ComputeServerStats, R as RhinoComputeError } from './base-DbB0Ggdq.cjs';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/core.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as ComputeConfig,
|
|
2
|
-
export { R as RhinoModelUnit } from './schemas-
|
|
1
|
+
import { C as ComputeConfig, d as GrasshopperComputeConfig, c as GrasshopperComputeResponse, g as IoResponseSchema } from './schemas-CQEJ5EZy.js';
|
|
2
|
+
export { R as RhinoModelUnit } from './schemas-CQEJ5EZy.js';
|
|
3
3
|
export { C as ComputeServerStats, R as RhinoComputeError } from './base-DbB0Ggdq.js';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/core.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{d as a,f as b,j as c,k as d,l as e,n as f,o as g}from"./chunk-
|
|
1
|
+
import{d as a,f as b,j as c,k as d,l as e,n as f,o as g}from"./chunk-VGM4KAFN.js";export{g as ComputeServerStats,b as ErrorCodes,a as RhinoComputeError,e as enableDebugLogging,f as fetchRhinoCompute,c as getLogger,d as setLogger};
|
|
2
2
|
//# sourceMappingURL=core.js.map
|
package/dist/grasshopper.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkG6W5VE7Ccjs = require('./chunk-G6W5VE7C.cjs');require('./chunk-M2HPEWXH.cjs');var _chunkFNWG34KHcjs = require('./chunk-FNWG34KH.cjs');exports.GrasshopperClient = _chunkG6W5VE7Ccjs.a; exports.GrasshopperResponseProcessor = _chunkG6W5VE7Ccjs.d; exports.RhinoComputeError = _chunkFNWG34KHcjs.d; exports.TreeBuilder = _chunkG6W5VE7Ccjs.j; exports.downloadFileData = _chunkG6W5VE7Ccjs.c; exports.extractFilesFromComputeResponse = _chunkG6W5VE7Ccjs.b; exports.fetchDefinitionIO = _chunkG6W5VE7Ccjs.h; exports.fetchParsedDefinitionIO = _chunkG6W5VE7Ccjs.i; exports.processInput = _chunkG6W5VE7Ccjs.f; exports.processInputs = _chunkG6W5VE7Ccjs.g; exports.solveGrasshopperDefinition = _chunkG6W5VE7Ccjs.e;
|
|
2
2
|
//# sourceMappingURL=grasshopper.cjs.map
|
package/dist/grasshopper.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/selva-compute/selva-compute/dist/grasshopper.cjs"],"names":[],"mappings":"AAAA,iIAAuG,gCAA6B,wDAAyC,kjBAA6R","file":"/home/runner/work/selva-compute/selva-compute/dist/grasshopper.cjs"}
|
package/dist/grasshopper.d.cts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { C as ComputeServerStats } from './base-DbB0Ggdq.cjs';
|
|
2
2
|
export { R as RhinoComputeError } from './base-DbB0Ggdq.cjs';
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
3
|
+
import { e as DataTreeDefault, O as OutputParamSchema, I as InputParamSchema, d as GrasshopperComputeConfig, b as DataTree, c as GrasshopperComputeResponse, C as ComputeConfig, D as DataTreePath } from './schemas-CQEJ5EZy.cjs';
|
|
4
|
+
export { a as DataItem, G as GrasshopperRequestSchema, f as InnerTreeData, R as RhinoModelUnit } from './schemas-CQEJ5EZy.cjs';
|
|
5
5
|
import * as THREE from 'three';
|
|
6
|
-
import { a as FileBaseInfo } from './types-SwbLAMW8.cjs';
|
|
7
6
|
import { M as MeshExtractionOptions } from './types-r00wVwfo.cjs';
|
|
8
7
|
|
|
9
8
|
/**
|
|
@@ -181,6 +180,64 @@ declare class GrasshopperClient {
|
|
|
181
180
|
private normalizeComputeConfig;
|
|
182
181
|
}
|
|
183
182
|
|
|
183
|
+
/**
|
|
184
|
+
* Represents raw file data from Grasshopper/Rhino Compute response.
|
|
185
|
+
*
|
|
186
|
+
* This type encapsulates file output from compute operations, with metadata
|
|
187
|
+
* for processing (decoding, naming, organization). Files are typically combined
|
|
188
|
+
* with additional files and packaged into a ZIP archive for download.
|
|
189
|
+
*
|
|
190
|
+
* @see {@link ProcessedFile} for the normalized format after processing
|
|
191
|
+
* @see {@link extractFilesFromComputeResponse} for extraction from compute responses
|
|
192
|
+
*/
|
|
193
|
+
type FileData = {
|
|
194
|
+
/** Base filename without extension (e.g., "model") */
|
|
195
|
+
fileName: string;
|
|
196
|
+
/** File content as a base64-encoded or plain string, depending on {@link IsBase64Encoded} */
|
|
197
|
+
data: string;
|
|
198
|
+
/** File extension including the dot (e.g., ".3dm", ".json"). Appended to {@link FileName} to create the full filename */
|
|
199
|
+
fileType: string;
|
|
200
|
+
/** Whether {@link Data} is base64-encoded. If true, must be decoded to binary before use. If false, can be used as a plain text string */
|
|
201
|
+
isBase64Encoded: boolean;
|
|
202
|
+
/** Directory path for organizing the file in archive structures (e.g., ZIP). Typically empty string for root-level files, or a path like "subfolder/nested" */
|
|
203
|
+
subFolder: string;
|
|
204
|
+
};
|
|
205
|
+
/**
|
|
206
|
+
* Represents a normalized, processed file ready for consumption or archival.
|
|
207
|
+
*
|
|
208
|
+
* This is the unified intermediate format produced by processing both {@link FileData}
|
|
209
|
+
* and {@link FileBaseInfo}. Files in this format are ready to be packaged into archives
|
|
210
|
+
* (e.g., ZIP files) or returned to callers for programmatic use.
|
|
211
|
+
*
|
|
212
|
+
* @see {@link FileData} for raw compute response files
|
|
213
|
+
* @see {@link FileBaseInfo} for external file references
|
|
214
|
+
*/
|
|
215
|
+
type ProcessedFile = {
|
|
216
|
+
/** Full filename including extension (e.g., "model.3dm") */
|
|
217
|
+
fileName: string;
|
|
218
|
+
/** File content as either binary data or text. Binary format (Uint8Array) is used for decoded base64 or fetched binary files; text format is used for plain text content */
|
|
219
|
+
content: Uint8Array | string;
|
|
220
|
+
/** File path for archive organization (e.g., "subfolder/model.3dm"). Used when creating ZIP archives or other hierarchical structures */
|
|
221
|
+
path: string;
|
|
222
|
+
};
|
|
223
|
+
/**
|
|
224
|
+
* Represents a reference to an external file to be included in file operations.
|
|
225
|
+
*
|
|
226
|
+
* This type is used to specify additional files (beyond compute response files)
|
|
227
|
+
* that should be fetched and included when processing files. The file is fetched
|
|
228
|
+
* from the provided URL and processed as a {@link ProcessedFile}.
|
|
229
|
+
*
|
|
230
|
+
*
|
|
231
|
+
* @see {@link FileData} for files from compute responses
|
|
232
|
+
* @see {@link processFiles} for how FileBaseInfo is processed (fetched and converted)
|
|
233
|
+
*/
|
|
234
|
+
type FileBaseInfo = {
|
|
235
|
+
/** Destination filename for the file in the archive or result set (e.g., "additional-data.json") */
|
|
236
|
+
fileName: string;
|
|
237
|
+
/** URL to fetch the file from. Must be accessible from the runtime environment */
|
|
238
|
+
filePath: string;
|
|
239
|
+
};
|
|
240
|
+
|
|
184
241
|
interface ParsedContext {
|
|
185
242
|
[key: string]: any;
|
|
186
243
|
}
|
|
@@ -336,8 +393,7 @@ declare class GrasshopperResponseProcessor {
|
|
|
336
393
|
* - A base64-encoded string of the .gh file
|
|
337
394
|
* - A plain string (will be base64-encoded)
|
|
338
395
|
* - A Uint8Array of the .gh file (will be base64-encoded)
|
|
339
|
-
* @param config - Compute configuration (server URL, API key, etc.)
|
|
340
|
-
* @param options - Optional compute options (timeout, cachesolve, model units, tolerances, etc.).
|
|
396
|
+
* @param config - Compute configuration (server URL, API key, etc. along with optional timeout, units, etc.)
|
|
341
397
|
* @returns An object containing the compute result and extracted file data.
|
|
342
398
|
*
|
|
343
399
|
* @example
|
|
@@ -476,7 +532,6 @@ declare function processInput(rawInput: InputParamSchema): InputParam;
|
|
|
476
532
|
* ```
|
|
477
533
|
*
|
|
478
534
|
* @see {@link processInput} for individual input processing logic
|
|
479
|
-
* @see {@link preProcessRawInput} for default value normalization
|
|
480
535
|
*/
|
|
481
536
|
declare function processInputs(rawInputs: InputParamSchema[]): InputParam[];
|
|
482
537
|
|
|
@@ -738,4 +793,35 @@ declare class TreeBuilder {
|
|
|
738
793
|
private static clampValue;
|
|
739
794
|
}
|
|
740
795
|
|
|
741
|
-
|
|
796
|
+
/**
|
|
797
|
+
* Extracts and processes files from compute response data without downloading them.
|
|
798
|
+
* Returns an array of ProcessedFile objects that can be used programmatically.
|
|
799
|
+
*
|
|
800
|
+
* @param downloadableFiles - An array of FileData items from the compute response.
|
|
801
|
+
* @param additionalFiles - Optional additional files to include (fetched from URLs).
|
|
802
|
+
* @returns A Promise resolving to an array of ProcessedFile objects.
|
|
803
|
+
* @throws Will throw an error if file processing fails.
|
|
804
|
+
*
|
|
805
|
+
* @example
|
|
806
|
+
* const files = await extractFilesFromComputeResponse(fileData);
|
|
807
|
+
* files.forEach(file => {
|
|
808
|
+
* console.log(`File: ${file.fileName}, Size: ${file.content.length}`);
|
|
809
|
+
* });
|
|
810
|
+
*/
|
|
811
|
+
declare const extractFilesFromComputeResponse: (downloadableFiles: FileData[], additionalFiles?: FileBaseInfo[] | FileBaseInfo | null) => Promise<ProcessedFile[]>;
|
|
812
|
+
/**
|
|
813
|
+
* Downloads files from a compute response as a ZIP archive.
|
|
814
|
+
* Packages multiple files into a single ZIP file and triggers a browser download.
|
|
815
|
+
*
|
|
816
|
+
* @param downloadableFiles - An array of FileData items from the compute response.
|
|
817
|
+
* @param additionalFiles - Optional additional files to include in the ZIP (fetched from URLs).
|
|
818
|
+
* @param fileFoldername - The name of the ZIP file (without extension).
|
|
819
|
+
* @throws Will throw an error if the file handling or download fails.
|
|
820
|
+
*
|
|
821
|
+
* @example
|
|
822
|
+
* await downloadDataFromComputeResponse(fileData, null, 'my-export');
|
|
823
|
+
* // Downloads 'my-export.zip'
|
|
824
|
+
*/
|
|
825
|
+
declare const downloadFileData: (downloadableFiles: FileData[], fileFoldername: string, additionalFiles?: FileBaseInfo[] | FileBaseInfo | null) => Promise<void>;
|
|
826
|
+
|
|
827
|
+
export { type BooleanInputType, ComputeConfig, DataTree, DataTreeDefault, DataTreePath, type DataTreeValue, type DefaultValue, type FileBaseInfo, type FileData, type FileInputType, type GeometryInputType, type GetValuesOptions, type GetValuesResult, GrasshopperClient, GrasshopperComputeConfig, GrasshopperComputeResponse, type GrasshopperParsedIO, type GrasshopperParsedIORaw, GrasshopperResponseProcessor, type InputParam, InputParamSchema, type NumericInputType, OutputParamSchema, type OutputType, type ParsedContext, type ProcessedFile, type TextInputType, TreeBuilder, type ValueListInputType, downloadFileData, extractFilesFromComputeResponse, fetchDefinitionIO, fetchParsedDefinitionIO, processInput, processInputs, solveGrasshopperDefinition };
|
package/dist/grasshopper.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { C as ComputeServerStats } from './base-DbB0Ggdq.js';
|
|
2
2
|
export { R as RhinoComputeError } from './base-DbB0Ggdq.js';
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
3
|
+
import { e as DataTreeDefault, O as OutputParamSchema, I as InputParamSchema, d as GrasshopperComputeConfig, b as DataTree, c as GrasshopperComputeResponse, C as ComputeConfig, D as DataTreePath } from './schemas-CQEJ5EZy.js';
|
|
4
|
+
export { a as DataItem, G as GrasshopperRequestSchema, f as InnerTreeData, R as RhinoModelUnit } from './schemas-CQEJ5EZy.js';
|
|
5
5
|
import * as THREE from 'three';
|
|
6
|
-
import { a as FileBaseInfo } from './types-SwbLAMW8.js';
|
|
7
6
|
import { M as MeshExtractionOptions } from './types-r00wVwfo.js';
|
|
8
7
|
|
|
9
8
|
/**
|
|
@@ -181,6 +180,64 @@ declare class GrasshopperClient {
|
|
|
181
180
|
private normalizeComputeConfig;
|
|
182
181
|
}
|
|
183
182
|
|
|
183
|
+
/**
|
|
184
|
+
* Represents raw file data from Grasshopper/Rhino Compute response.
|
|
185
|
+
*
|
|
186
|
+
* This type encapsulates file output from compute operations, with metadata
|
|
187
|
+
* for processing (decoding, naming, organization). Files are typically combined
|
|
188
|
+
* with additional files and packaged into a ZIP archive for download.
|
|
189
|
+
*
|
|
190
|
+
* @see {@link ProcessedFile} for the normalized format after processing
|
|
191
|
+
* @see {@link extractFilesFromComputeResponse} for extraction from compute responses
|
|
192
|
+
*/
|
|
193
|
+
type FileData = {
|
|
194
|
+
/** Base filename without extension (e.g., "model") */
|
|
195
|
+
fileName: string;
|
|
196
|
+
/** File content as a base64-encoded or plain string, depending on {@link IsBase64Encoded} */
|
|
197
|
+
data: string;
|
|
198
|
+
/** File extension including the dot (e.g., ".3dm", ".json"). Appended to {@link FileName} to create the full filename */
|
|
199
|
+
fileType: string;
|
|
200
|
+
/** Whether {@link Data} is base64-encoded. If true, must be decoded to binary before use. If false, can be used as a plain text string */
|
|
201
|
+
isBase64Encoded: boolean;
|
|
202
|
+
/** Directory path for organizing the file in archive structures (e.g., ZIP). Typically empty string for root-level files, or a path like "subfolder/nested" */
|
|
203
|
+
subFolder: string;
|
|
204
|
+
};
|
|
205
|
+
/**
|
|
206
|
+
* Represents a normalized, processed file ready for consumption or archival.
|
|
207
|
+
*
|
|
208
|
+
* This is the unified intermediate format produced by processing both {@link FileData}
|
|
209
|
+
* and {@link FileBaseInfo}. Files in this format are ready to be packaged into archives
|
|
210
|
+
* (e.g., ZIP files) or returned to callers for programmatic use.
|
|
211
|
+
*
|
|
212
|
+
* @see {@link FileData} for raw compute response files
|
|
213
|
+
* @see {@link FileBaseInfo} for external file references
|
|
214
|
+
*/
|
|
215
|
+
type ProcessedFile = {
|
|
216
|
+
/** Full filename including extension (e.g., "model.3dm") */
|
|
217
|
+
fileName: string;
|
|
218
|
+
/** File content as either binary data or text. Binary format (Uint8Array) is used for decoded base64 or fetched binary files; text format is used for plain text content */
|
|
219
|
+
content: Uint8Array | string;
|
|
220
|
+
/** File path for archive organization (e.g., "subfolder/model.3dm"). Used when creating ZIP archives or other hierarchical structures */
|
|
221
|
+
path: string;
|
|
222
|
+
};
|
|
223
|
+
/**
|
|
224
|
+
* Represents a reference to an external file to be included in file operations.
|
|
225
|
+
*
|
|
226
|
+
* This type is used to specify additional files (beyond compute response files)
|
|
227
|
+
* that should be fetched and included when processing files. The file is fetched
|
|
228
|
+
* from the provided URL and processed as a {@link ProcessedFile}.
|
|
229
|
+
*
|
|
230
|
+
*
|
|
231
|
+
* @see {@link FileData} for files from compute responses
|
|
232
|
+
* @see {@link processFiles} for how FileBaseInfo is processed (fetched and converted)
|
|
233
|
+
*/
|
|
234
|
+
type FileBaseInfo = {
|
|
235
|
+
/** Destination filename for the file in the archive or result set (e.g., "additional-data.json") */
|
|
236
|
+
fileName: string;
|
|
237
|
+
/** URL to fetch the file from. Must be accessible from the runtime environment */
|
|
238
|
+
filePath: string;
|
|
239
|
+
};
|
|
240
|
+
|
|
184
241
|
interface ParsedContext {
|
|
185
242
|
[key: string]: any;
|
|
186
243
|
}
|
|
@@ -336,8 +393,7 @@ declare class GrasshopperResponseProcessor {
|
|
|
336
393
|
* - A base64-encoded string of the .gh file
|
|
337
394
|
* - A plain string (will be base64-encoded)
|
|
338
395
|
* - A Uint8Array of the .gh file (will be base64-encoded)
|
|
339
|
-
* @param config - Compute configuration (server URL, API key, etc.)
|
|
340
|
-
* @param options - Optional compute options (timeout, cachesolve, model units, tolerances, etc.).
|
|
396
|
+
* @param config - Compute configuration (server URL, API key, etc. along with optional timeout, units, etc.)
|
|
341
397
|
* @returns An object containing the compute result and extracted file data.
|
|
342
398
|
*
|
|
343
399
|
* @example
|
|
@@ -476,7 +532,6 @@ declare function processInput(rawInput: InputParamSchema): InputParam;
|
|
|
476
532
|
* ```
|
|
477
533
|
*
|
|
478
534
|
* @see {@link processInput} for individual input processing logic
|
|
479
|
-
* @see {@link preProcessRawInput} for default value normalization
|
|
480
535
|
*/
|
|
481
536
|
declare function processInputs(rawInputs: InputParamSchema[]): InputParam[];
|
|
482
537
|
|
|
@@ -738,4 +793,35 @@ declare class TreeBuilder {
|
|
|
738
793
|
private static clampValue;
|
|
739
794
|
}
|
|
740
795
|
|
|
741
|
-
|
|
796
|
+
/**
|
|
797
|
+
* Extracts and processes files from compute response data without downloading them.
|
|
798
|
+
* Returns an array of ProcessedFile objects that can be used programmatically.
|
|
799
|
+
*
|
|
800
|
+
* @param downloadableFiles - An array of FileData items from the compute response.
|
|
801
|
+
* @param additionalFiles - Optional additional files to include (fetched from URLs).
|
|
802
|
+
* @returns A Promise resolving to an array of ProcessedFile objects.
|
|
803
|
+
* @throws Will throw an error if file processing fails.
|
|
804
|
+
*
|
|
805
|
+
* @example
|
|
806
|
+
* const files = await extractFilesFromComputeResponse(fileData);
|
|
807
|
+
* files.forEach(file => {
|
|
808
|
+
* console.log(`File: ${file.fileName}, Size: ${file.content.length}`);
|
|
809
|
+
* });
|
|
810
|
+
*/
|
|
811
|
+
declare const extractFilesFromComputeResponse: (downloadableFiles: FileData[], additionalFiles?: FileBaseInfo[] | FileBaseInfo | null) => Promise<ProcessedFile[]>;
|
|
812
|
+
/**
|
|
813
|
+
* Downloads files from a compute response as a ZIP archive.
|
|
814
|
+
* Packages multiple files into a single ZIP file and triggers a browser download.
|
|
815
|
+
*
|
|
816
|
+
* @param downloadableFiles - An array of FileData items from the compute response.
|
|
817
|
+
* @param additionalFiles - Optional additional files to include in the ZIP (fetched from URLs).
|
|
818
|
+
* @param fileFoldername - The name of the ZIP file (without extension).
|
|
819
|
+
* @throws Will throw an error if the file handling or download fails.
|
|
820
|
+
*
|
|
821
|
+
* @example
|
|
822
|
+
* await downloadDataFromComputeResponse(fileData, null, 'my-export');
|
|
823
|
+
* // Downloads 'my-export.zip'
|
|
824
|
+
*/
|
|
825
|
+
declare const downloadFileData: (downloadableFiles: FileData[], fileFoldername: string, additionalFiles?: FileBaseInfo[] | FileBaseInfo | null) => Promise<void>;
|
|
826
|
+
|
|
827
|
+
export { type BooleanInputType, ComputeConfig, DataTree, DataTreeDefault, DataTreePath, type DataTreeValue, type DefaultValue, type FileBaseInfo, type FileData, type FileInputType, type GeometryInputType, type GetValuesOptions, type GetValuesResult, GrasshopperClient, GrasshopperComputeConfig, GrasshopperComputeResponse, type GrasshopperParsedIO, type GrasshopperParsedIORaw, GrasshopperResponseProcessor, type InputParam, InputParamSchema, type NumericInputType, OutputParamSchema, type OutputType, type ParsedContext, type ProcessedFile, type TextInputType, TreeBuilder, type ValueListInputType, downloadFileData, extractFilesFromComputeResponse, fetchDefinitionIO, fetchParsedDefinitionIO, processInput, processInputs, solveGrasshopperDefinition };
|
package/dist/grasshopper.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as b,b as c,c as d,d as e,e as f,f as g,g as h,h as i}from"./chunk-
|
|
1
|
+
import{a as b,b as c,c as d,d as e,e as f,f as g,g as h,h as i,i as j,j as k}from"./chunk-I3OX3G7J.js";import"./chunk-QFHFH5BS.js";import{d as a}from"./chunk-VGM4KAFN.js";export{b as GrasshopperClient,e as GrasshopperResponseProcessor,a as RhinoComputeError,k as TreeBuilder,d as downloadFileData,c as extractFilesFromComputeResponse,i as fetchDefinitionIO,j as fetchParsedDefinitionIO,g as processInput,h as processInputs,f as solveGrasshopperDefinition};
|
|
2
2
|
//# sourceMappingURL=grasshopper.js.map
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkG6W5VE7Ccjs = require('./chunk-G6W5VE7C.cjs');require('./chunk-M2HPEWXH.cjs');var _chunkFNWG34KHcjs = require('./chunk-FNWG34KH.cjs');exports.ComputeServerStats = _chunkFNWG34KHcjs.o; exports.ErrorCodes = _chunkFNWG34KHcjs.f; exports.GrasshopperClient = _chunkG6W5VE7Ccjs.a; exports.GrasshopperResponseProcessor = _chunkG6W5VE7Ccjs.d; exports.RhinoComputeError = _chunkFNWG34KHcjs.d; exports.TreeBuilder = _chunkG6W5VE7Ccjs.j; exports.downloadFileData = _chunkG6W5VE7Ccjs.c; exports.enableDebugLogging = _chunkFNWG34KHcjs.l; exports.extractFilesFromComputeResponse = _chunkG6W5VE7Ccjs.b; exports.fetchDefinitionIO = _chunkG6W5VE7Ccjs.h; exports.fetchParsedDefinitionIO = _chunkG6W5VE7Ccjs.i; exports.fetchRhinoCompute = _chunkFNWG34KHcjs.n; exports.getLogger = _chunkFNWG34KHcjs.j; exports.processInput = _chunkG6W5VE7Ccjs.f; exports.processInputs = _chunkG6W5VE7Ccjs.g; exports.setLogger = _chunkFNWG34KHcjs.k; exports.solveGrasshopperDefinition = _chunkG6W5VE7Ccjs.e;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/selva-compute/selva-compute/dist/index.cjs"],"names":[],"mappings":"AAAA,iIAAuG,gCAA6B,wDAAmF,m0BAAkZ","file":"/home/runner/work/selva-compute/selva-compute/dist/index.cjs"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
export { ErrorCode, ErrorCodes, Logger, enableDebugLogging, fetchRhinoCompute, getLogger, setLogger } from './core.cjs';
|
|
2
2
|
export { C as ComputeServerStats, R as RhinoComputeError } from './base-DbB0Ggdq.cjs';
|
|
3
|
-
export { C as ComputeConfig,
|
|
4
|
-
export { BooleanInputType, DataTreeValue, GeometryInputType, GrasshopperClient, GrasshopperParsedIO, GrasshopperResponseProcessor, InputParam, NumericInputType, OutputType, TextInputType, TreeBuilder, ValueListInputType, fetchDefinitionIO, fetchParsedDefinitionIO, processInput, processInputs, solveGrasshopperDefinition } from './grasshopper.cjs';
|
|
5
|
-
export { a as FileBaseInfo, F as FileData, P as ProcessedFile } from './types-SwbLAMW8.cjs';
|
|
6
|
-
export { downloadFileData, extractFilesFromComputeResponse } from './files.cjs';
|
|
3
|
+
export { C as ComputeConfig, a as DataItem, b as DataTree, e as DataTreeDefault, D as DataTreePath, d as GrasshopperComputeConfig, c as GrasshopperComputeResponse, G as GrasshopperRequestSchema, f as InnerTreeData, I as InputParamSchema, O as OutputParamSchema, R as RhinoModelUnit } from './schemas-CQEJ5EZy.cjs';
|
|
4
|
+
export { BooleanInputType, DataTreeValue, DefaultValue, FileBaseInfo, FileData, FileInputType, GeometryInputType, GetValuesOptions, GetValuesResult, GrasshopperClient, GrasshopperParsedIO, GrasshopperParsedIORaw, GrasshopperResponseProcessor, InputParam, NumericInputType, OutputType, ParsedContext, ProcessedFile, TextInputType, TreeBuilder, ValueListInputType, downloadFileData, extractFilesFromComputeResponse, fetchDefinitionIO, fetchParsedDefinitionIO, processInput, processInputs, solveGrasshopperDefinition } from './grasshopper.cjs';
|
|
7
5
|
import 'three';
|
|
8
6
|
import './types-r00wVwfo.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
export { ErrorCode, ErrorCodes, Logger, enableDebugLogging, fetchRhinoCompute, getLogger, setLogger } from './core.js';
|
|
2
2
|
export { C as ComputeServerStats, R as RhinoComputeError } from './base-DbB0Ggdq.js';
|
|
3
|
-
export { C as ComputeConfig,
|
|
4
|
-
export { BooleanInputType, DataTreeValue, GeometryInputType, GrasshopperClient, GrasshopperParsedIO, GrasshopperResponseProcessor, InputParam, NumericInputType, OutputType, TextInputType, TreeBuilder, ValueListInputType, fetchDefinitionIO, fetchParsedDefinitionIO, processInput, processInputs, solveGrasshopperDefinition } from './grasshopper.js';
|
|
5
|
-
export { a as FileBaseInfo, F as FileData, P as ProcessedFile } from './types-SwbLAMW8.js';
|
|
6
|
-
export { downloadFileData, extractFilesFromComputeResponse } from './files.js';
|
|
3
|
+
export { C as ComputeConfig, a as DataItem, b as DataTree, e as DataTreeDefault, D as DataTreePath, d as GrasshopperComputeConfig, c as GrasshopperComputeResponse, G as GrasshopperRequestSchema, f as InnerTreeData, I as InputParamSchema, O as OutputParamSchema, R as RhinoModelUnit } from './schemas-CQEJ5EZy.js';
|
|
4
|
+
export { BooleanInputType, DataTreeValue, DefaultValue, FileBaseInfo, FileData, FileInputType, GeometryInputType, GetValuesOptions, GetValuesResult, GrasshopperClient, GrasshopperParsedIO, GrasshopperParsedIORaw, GrasshopperResponseProcessor, InputParam, NumericInputType, OutputType, ParsedContext, ProcessedFile, TextInputType, TreeBuilder, ValueListInputType, downloadFileData, extractFilesFromComputeResponse, fetchDefinitionIO, fetchParsedDefinitionIO, processInput, processInputs, solveGrasshopperDefinition } from './grasshopper.js';
|
|
7
5
|
import 'three';
|
|
8
6
|
import './types-r00wVwfo.js';
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as x,b as c,c as d,
|
|
1
|
+
import{a as x,b as a,c as b,d as c,e as d,f as g,g as h,h as i,i as j,j as k}from"./chunk-I3OX3G7J.js";import"./chunk-QFHFH5BS.js";import{d as o,f as r,j as e,k as f,l as m,n as p,o as t}from"./chunk-VGM4KAFN.js";export{t as ComputeServerStats,r as ErrorCodes,x as GrasshopperClient,c as GrasshopperResponseProcessor,o as RhinoComputeError,k as TreeBuilder,b as downloadFileData,m as enableDebugLogging,a as extractFilesFromComputeResponse,i as fetchDefinitionIO,j as fetchParsedDefinitionIO,p as fetchRhinoCompute,e as getLogger,g as processInput,h as processInputs,f as setLogger,d as solveGrasshopperDefinition};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -199,4 +199,4 @@ interface InputParamSchema {
|
|
|
199
199
|
groupName?: string | null;
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
-
export type { ComputeConfig as C,
|
|
202
|
+
export type { ComputeConfig as C, DataTreePath as D, GrasshopperRequestSchema as G, InputParamSchema as I, OutputParamSchema as O, RhinoModelUnit as R, DataItem as a, DataTree as b, GrasshopperComputeResponse as c, GrasshopperComputeConfig as d, DataTreeDefault as e, InnerTreeData as f, IoResponseSchema as g };
|
|
@@ -199,4 +199,4 @@ interface InputParamSchema {
|
|
|
199
199
|
groupName?: string | null;
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
-
export type { ComputeConfig as C,
|
|
202
|
+
export type { ComputeConfig as C, DataTreePath as D, GrasshopperRequestSchema as G, InputParamSchema as I, OutputParamSchema as O, RhinoModelUnit as R, DataItem as a, DataTree as b, GrasshopperComputeResponse as c, GrasshopperComputeConfig as d, DataTreeDefault as e, InnerTreeData as f, IoResponseSchema as g };
|
package/dist/visualization.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunk5DJRUPGIcjs = require('./chunk-5DJRUPGI.cjs');var _chunkP57VU27Wcjs = require('./chunk-P57VU27W.cjs');var _three = require('three'); var i = _interopRequireWildcard(_three); var R = _interopRequireWildcard(_three); var m = _interopRequireWildcard(_three); var w = _interopRequireWildcard(_three);var _OrbitControlsjs = require('three/addons/controls/OrbitControls.js');var _RGBELoaderjs = require('three/addons/loaders/RGBELoader.js');var k=new i.Vector3(0,0,1),_= exports.initThree =function(e,r){let t=Z(r||{}),n=J(t),o=re(t),a=oe(e,t),s=se(o,e,t);ee(n,t),te(n,t),_optionalChain([t, 'access', _2 => _2.floor, 'optionalAccess', _3 => _3.enabled])&&ne(n,t);let l=t.events.enableEventHandlers!==!1?ae(e,n,o,s,t):{dispose:()=>{},fitToView:()=>{},clearSelection:()=>{}},{resize:c,dispose:T}=Q(e,a,o),{animate:h,dispose:u}=X(a,n,o,s);h();let p=_optionalChain([t, 'access', _4 => _4.environment, 'optionalAccess', _5 => _5.sceneUp])||k;return n.up.set(p.x,p.y,p.z),{scene:n,camera:o,controls:s,renderer:a,dispose:()=>{u(),T(),l.dispose(),s.dispose(),a.dispose(),n.traverse(f=>{f instanceof i.Mesh&&(_optionalChain([f, 'access', _6 => _6.geometry, 'optionalAccess', _7 => _7.dispose, 'call', _8 => _8()]),Array.isArray(f.material)?f.material.forEach(H=>H.dispose()):_optionalChain([f, 'access', _9 => _9.material, 'optionalAccess', _10 => _10.dispose, 'call', _11 => _11()]))})},resize:c,fitToView:l.fitToView,clearSelection:l.clearSelection}};function Z(e){let r=e.sceneScale||"m",n={mm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:10,lightHeight:20,minDistance:.1,shadowSize:100,scaleFactor:1e3},cm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:25,lightHeight:50,minDistance:.1,shadowSize:100,scaleFactor:100},m:{cameraDistance:10,near:.01,far:2e3,floorSize:50,lightDistance:25,lightHeight:50,minDistance:.001,shadowSize:100,scaleFactor:1},inches:{cameraDistance:15,near:.1,far:2e3,floorSize:80,lightDistance:20,lightHeight:40,minDistance:.1,shadowSize:80,scaleFactor:39.37},feet:{cameraDistance:8,near:.1,far:2e3,floorSize:40,lightDistance:15,lightHeight:30,minDistance:.1,shadowSize:60,scaleFactor:3.28084}}[r];return{sceneScale:r,camera:{position:_optionalChain([e, 'access', _12 => _12.camera, 'optionalAccess', _13 => _13.position])||new i.Vector3(-n.cameraDistance,n.cameraDistance,n.cameraDistance),fov:_optionalChain([e, 'access', _14 => _14.camera, 'optionalAccess', _15 => _15.fov])||20,near:_optionalChain([e, 'access', _16 => _16.camera, 'optionalAccess', _17 => _17.near])||n.near,far:_optionalChain([e, 'access', _18 => _18.camera, 'optionalAccess', _19 => _19.far])||n.far,target:_optionalChain([e, 'access', _20 => _20.camera, 'optionalAccess', _21 => _21.target])||new i.Vector3(0,0,0)},lighting:{enableSunlight:_nullishCoalesce(_optionalChain([e, 'access', _22 => _22.lighting, 'optionalAccess', _23 => _23.enableSunlight]), () => (!0)),sunlightIntensity:_optionalChain([e, 'access', _24 => _24.lighting, 'optionalAccess', _25 => _25.sunlightIntensity])||1,sunlightPosition:_optionalChain([e, 'access', _26 => _26.lighting, 'optionalAccess', _27 => _27.sunlightPosition])||new i.Vector3(n.lightDistance,n.lightHeight,n.lightDistance),ambientLightColor:_optionalChain([e, 'access', _28 => _28.lighting, 'optionalAccess', _29 => _29.ambientLightColor])||new i.Color(4210752),ambientLightIntensity:_optionalChain([e, 'access', _30 => _30.lighting, 'optionalAccess', _31 => _31.ambientLightIntensity])||1,sunlightColor:_optionalChain([e, 'access', _32 => _32.lighting, 'optionalAccess', _33 => _33.sunlightColor])||16777215},environment:{hdrPath:_optionalChain([e, 'access', _34 => _34.environment, 'optionalAccess', _35 => _35.hdrPath])||"/baseHDR.hdr",backgroundColor:_optionalChain([e, 'access', _36 => _36.environment, 'optionalAccess', _37 => _37.backgroundColor])||new i.Color(15790320),enableEnvironmentLighting:_nullishCoalesce(_optionalChain([e, 'access', _38 => _38.environment, 'optionalAccess', _39 => _39.enableEnvironmentLighting]), () => (!0)),sceneUp:_optionalChain([e, 'access', _40 => _40.environment, 'optionalAccess', _41 => _41.sceneUp])||k,showEnvironment:_nullishCoalesce(_optionalChain([e, 'access', _42 => _42.environment, 'optionalAccess', _43 => _43.showEnvironment]), () => (!1))},floor:{enabled:_nullishCoalesce(_optionalChain([e, 'access', _44 => _44.floor, 'optionalAccess', _45 => _45.enabled]), () => (!1)),size:_optionalChain([e, 'access', _46 => _46.floor, 'optionalAccess', _47 => _47.size])||n.floorSize,color:_optionalChain([e, 'access', _48 => _48.floor, 'optionalAccess', _49 => _49.color])||new i.Color(8421504),roughness:_optionalChain([e, 'access', _50 => _50.floor, 'optionalAccess', _51 => _51.roughness])||.7,metalness:_optionalChain([e, 'access', _52 => _52.floor, 'optionalAccess', _53 => _53.metalness])||0,receiveShadow:_nullishCoalesce(_optionalChain([e, 'access', _54 => _54.floor, 'optionalAccess', _55 => _55.receiveShadow]), () => (!0))},render:{enableShadows:_nullishCoalesce(_optionalChain([e, 'access', _56 => _56.render, 'optionalAccess', _57 => _57.enableShadows]), () => (!0)),shadowMapSize:_optionalChain([e, 'access', _58 => _58.render, 'optionalAccess', _59 => _59.shadowMapSize])||2048,antialias:_nullishCoalesce(_optionalChain([e, 'access', _60 => _60.render, 'optionalAccess', _61 => _61.antialias]), () => (!0)),pixelRatio:_optionalChain([e, 'access', _62 => _62.render, 'optionalAccess', _63 => _63.pixelRatio])||Math.min(window.devicePixelRatio,2),toneMapping:_optionalChain([e, 'access', _64 => _64.render, 'optionalAccess', _65 => _65.toneMapping])||i.NeutralToneMapping,toneMappingExposure:_optionalChain([e, 'access', _66 => _66.render, 'optionalAccess', _67 => _67.toneMappingExposure])||1,preserveDrawingBuffer:_nullishCoalesce(_optionalChain([e, 'access', _68 => _68.render, 'optionalAccess', _69 => _69.preserveDrawingBuffer]), () => (!1))},controls:{enableDamping:_nullishCoalesce(_optionalChain([e, 'access', _70 => _70.controls, 'optionalAccess', _71 => _71.enableDamping]), () => (!1)),dampingFactor:_optionalChain([e, 'access', _72 => _72.controls, 'optionalAccess', _73 => _73.dampingFactor])||.05,autoRotate:_nullishCoalesce(_optionalChain([e, 'access', _74 => _74.controls, 'optionalAccess', _75 => _75.autoRotate]), () => (!1)),autoRotateSpeed:_optionalChain([e, 'access', _76 => _76.controls, 'optionalAccess', _77 => _77.autoRotateSpeed])||.5,enableZoom:_nullishCoalesce(_optionalChain([e, 'access', _78 => _78.controls, 'optionalAccess', _79 => _79.enableZoom]), () => (!0)),enablePan:_nullishCoalesce(_optionalChain([e, 'access', _80 => _80.controls, 'optionalAccess', _81 => _81.enablePan]), () => (!0)),minDistance:_optionalChain([e, 'access', _82 => _82.controls, 'optionalAccess', _83 => _83.minDistance])||n.minDistance,maxDistance:_optionalChain([e, 'access', _84 => _84.controls, 'optionalAccess', _85 => _85.maxDistance])||1/0},events:{onBackgroundClicked:_optionalChain([e, 'access', _86 => _86.events, 'optionalAccess', _87 => _87.onBackgroundClicked]),onObjectSelected:_optionalChain([e, 'access', _88 => _88.events, 'optionalAccess', _89 => _89.onObjectSelected]),onMeshMetadataClicked:_optionalChain([e, 'access', _90 => _90.events, 'optionalAccess', _91 => _91.onMeshMetadataClicked]),selectionColor:_optionalChain([e, 'access', _92 => _92.events, 'optionalAccess', _93 => _93.selectionColor])||"#ff0000",enableEventHandlers:_nullishCoalesce(_optionalChain([e, 'access', _94 => _94.events, 'optionalAccess', _95 => _95.enableEventHandlers]), () => (!0)),enableKeyboardControls:_nullishCoalesce(_optionalChain([e, 'access', _96 => _96.events, 'optionalAccess', _97 => _97.enableKeyboardControls]), () => (!0)),enableClickToFocus:_nullishCoalesce(_optionalChain([e, 'access', _98 => _98.events, 'optionalAccess', _99 => _99.enableClickToFocus]), () => (!0))}}}function J(e){let r=new i.Scene;r.children.forEach(n=>{n.userData.id!=="floor"&&r.remove(n)});let t=typeof e.environment.backgroundColor=="string"?new i.Color(e.environment.backgroundColor):e.environment.backgroundColor;return r.background=t||null,r}function X(e,r,t,n){let o=null,a=function(){o=requestAnimationFrame(a),n.enableDamping&&n.update(),e.render(r,t)};return{animate:a,dispose:()=>{o!==null&&(cancelAnimationFrame(o),o=null)}}}function Q(e,r,t){let n=e.parentElement,o,a=null,s=()=>n?{width:n.clientWidth,height:n.clientHeight}:{width:window.innerWidth,height:window.innerHeight},l=()=>{o&&clearTimeout(o),o=setTimeout(()=>{let{width:T,height:h}=s();(r.domElement.width!==T||r.domElement.height!==h)&&(r.setSize(T,h,!1),t.aspect=T/h,t.updateProjectionMatrix())},16)};return n&&typeof ResizeObserver<"u"?(a=new ResizeObserver(l),a.observe(n)):window.addEventListener("resize",l),{resize:l,dispose:()=>{o&&clearTimeout(o),a?a.disconnect():window.removeEventListener("resize",l)}}}function ee(e,r){r.environment.enableEnvironmentLighting&&new (0, _RGBELoaderjs.RGBELoader)().load(r.environment.hdrPath||"/baseHDR.hdr",function(t){t.mapping=i.EquirectangularReflectionMapping,e.environment=t,r.environment.showEnvironment&&(e.background=t)},void 0,function(t){_chunkP57VU27Wcjs.j.call(void 0, ).warn("HDR texture could not be loaded, falling back to basic lighting:",t);let n=new i.AmbientLight(4210752,.4);e.add(n)})}function te(e,r){let t=new i.AmbientLight(r.lighting.ambientLightColor,r.lighting.ambientLightIntensity);if(e.add(t),r.lighting.enableSunlight){let n=new i.DirectionalLight(_nullishCoalesce(r.lighting.sunlightColor, () => (16777215)),r.lighting.sunlightIntensity),o=r.lighting.sunlightPosition;if(o&&n.position.set(o.x,o.y,o.z),r.render.enableShadows){n.castShadow=!0;let a=r.sceneScale==="mm"?.1:r.sceneScale==="cm"?10:100;n.shadow.camera.left=-a,n.shadow.camera.right=a,n.shadow.camera.top=a,n.shadow.camera.bottom=-a;let s=r.sceneScale==="mm"?.001:r.sceneScale==="cm"?.1:.5,l=r.sceneScale==="mm"?1:r.sceneScale==="cm"?100:500;n.shadow.camera.near=s,n.shadow.camera.far=l,n.shadow.mapSize.width=r.render.shadowMapSize||2048,n.shadow.mapSize.height=r.render.shadowMapSize||2048,n.shadow.bias=-1e-4,n.shadow.normalBias=.02}e.add(n)}}function ne(e,r){let t=r.floor.size,n=new i.PlaneGeometry(t,t),o=typeof r.floor.color=="string"?new i.Color(r.floor.color):r.floor.color,a=new i.MeshStandardMaterial({color:o,roughness:r.floor.roughness,metalness:r.floor.metalness,side:i.DoubleSide}),s=new i.Mesh(n,a);s.userData.id="floor",s.name="floor",s.rotation.x=-Math.PI/2,s.position.y=0,r.floor.receiveShadow&&r.render.enableShadows&&(s.receiveShadow=!0),e.add(s)}function re(e){let t=_optionalChain([document, 'access', _100 => _100.querySelector, 'call', _101 => _101("canvas"), 'optionalAccess', _102 => _102.parentElement]),n=t?t.clientWidth:window.innerWidth,o=t?t.clientHeight:window.innerHeight,a=new i.PerspectiveCamera(e.camera.fov,n/o,e.camera.near,e.camera.far),s=e.camera.position;return s&&a.position.set(s.x,s.y,s.z),a}function oe(e,r){let t=new i.WebGLRenderer({antialias:r.render.antialias,canvas:e,alpha:!0,powerPreference:"high-performance",preserveDrawingBuffer:r.render.preserveDrawingBuffer,logarithmicDepthBuffer:!0}),n=e.parentElement,o=n?n.clientWidth:window.innerWidth,a=n?n.clientHeight:window.innerHeight;return n&&(e.style.width="100%",e.style.height="100%",e.style.display="block"),t.setSize(o,a,!1),t.setPixelRatio(r.render.pixelRatio||Math.min(window.devicePixelRatio,2)),r.render.enableShadows&&(t.shadowMap.enabled=!0,t.shadowMap.type=i.VSMShadowMap),t.toneMapping=r.render.toneMapping||i.ACESFilmicToneMapping,t.toneMappingExposure=r.render.toneMappingExposure||1,t.outputColorSpace=i.SRGBColorSpace,t.sortObjects=!0,t}function ae(e,r,t,n,o){let a=new Set,s=new Map,l=new i.Raycaster,c=new i.Vector2,T=new i.Vector2,h=()=>{let d=new i.Box3;if(r.traverse(B=>{B.visible&&B.userData.id!=="floor"&&B instanceof i.Mesh&&d.expandByObject(B)}),d.isEmpty()){_chunkP57VU27Wcjs.j.call(void 0, ).warn("No objects to fit to view");return}let b=d.getCenter(new i.Vector3),g=d.getSize(new i.Vector3),v=Math.max(g.x,g.y,g.z),y=t.fov*(Math.PI/180),S=v/(2*Math.tan(y/2));S*=1.5;let $=t.position.clone().sub(n.target).normalize();t.position.copy(b.clone().add($.multiplyScalar(S))),n.target.copy(b),n.update()},u=typeof o.events.selectionColor=="string"?new i.Color(o.events.selectionColor):o.events.selectionColor instanceof i.Color?o.events.selectionColor:new i.Color("#ff0000"),p=()=>{a.forEach(d=>{d instanceof i.Mesh&&s.has(d)&&(d.material=s.get(d),s.delete(d))}),a.clear()},x=d=>{T.set(d.clientX,d.clientY)},f=d=>{let b=new i.Vector2(d.clientX,d.clientY);if(T.distanceTo(b)>5)return;let g=e.getBoundingClientRect();c.x=(d.clientX-g.left)/g.width*2-1,c.y=-((d.clientY-g.top)/g.height)*2+1,l.setFromCamera(c,t);let v=l.intersectObjects(r.children,!0);if(v.length>0){let y=v[0].object;if(!a.has(y)){if(p(),a.add(y),y instanceof i.Mesh&&y.material instanceof i.Material){s.set(y,y.material);let S=y.material.clone();S.emissive=u.clone(),y.material=S}_optionalChain([o, 'access', _103 => _103.events, 'optionalAccess', _104 => _104.onObjectSelected, 'optionalCall', _105 => _105(y)]),y instanceof i.Mesh&&Object.keys(y.userData).length>0&&_optionalChain([o, 'access', _106 => _106.events, 'optionalAccess', _107 => _107.onMeshMetadataClicked, 'optionalCall', _108 => _108(y.userData)])}}else p(),_optionalChain([o, 'access', _109 => _109.events, 'optionalAccess', _110 => _110.onBackgroundClicked, 'optionalCall', _111 => _111({x:c.x,y:c.y})])},H=d=>{if(_optionalChain([o, 'access', _112 => _112.events, 'optionalAccess', _113 => _113.enableKeyboardControls]))switch(d.key.toLowerCase()){case"f":d.preventDefault(),h();break;case"escape":d.preventDefault(),p();break;case" ":d.preventDefault(),h();break}};return _optionalChain([o, 'access', _114 => _114.events, 'optionalAccess', _115 => _115.enableClickToFocus])&&(e.addEventListener("mousedown",x),e.addEventListener("click",f)),_optionalChain([o, 'access', _116 => _116.events, 'optionalAccess', _117 => _117.enableKeyboardControls])&&(e.setAttribute("tabindex","0"),e.addEventListener("keydown",H)),{dispose:()=>{e.removeEventListener("mousedown",x),e.removeEventListener("click",f),e.removeEventListener("keydown",H),p()},fitToView:h,clearSelection:p}}function se(e,r,t){let n=new (0, _OrbitControlsjs.OrbitControls)(e,r),o=t.camera.target;return o&&n.target.set(o.x,o.y,o.z),n.enableDamping=t.controls.enableDamping||!1,n.dampingFactor=t.controls.dampingFactor||.05,n.autoRotate=t.controls.autoRotate||!1,n.autoRotateSpeed=t.controls.autoRotateSpeed||.5,n.enableZoom=t.controls.enableZoom||!0,n.enablePan=t.controls.enablePan||!0,n.minDistance=t.controls.minDistance||.001,n.maxDistance=t.controls.maxDistance||1/0,n.screenSpacePanning=!1,n.maxPolarAngle=Math.PI,n.update(),n}function N(e,r,t,n,o){if(ie(e),r.length===0)return;let a=new R.Box3;r.forEach(h=>{e.add(h);let u=new R.Box3().setFromObject(h);a.union(u)});let s=a.getCenter(new R.Vector3),l=a.getSize(new R.Vector3),c=Math.max(l.x,l.y,l.z);if(c/Math.min(l.x||1,l.y||1,l.z||1)>100||c>1e4?(t.near=c*1e-4,t.far=c*100):c>1e3?(t.near=c*.001,t.far=c*50):(t.near=Math.max(.01,c*.01),t.far=Math.max(2e3,c*20)),t.updateProjectionMatrix(),o)n.minDistance=t.near*2,n.maxDistance=t.far*.9;else{let h=c*4;t.position.set(s.x+h*.8,s.y+h,s.z+h*1.2),n.target=s,n.minDistance=t.near*2,n.maxDistance=t.far*.9,n.update()}}function I(e){if(!e||typeof e!="string")return _chunkP57VU27Wcjs.j.call(void 0, ).warn(`Invalid color input: ${e}, using white`),new R.Color(16777215);let r=e.trim();if(r.startsWith("#")||/^[0-9A-Fa-f]{6}$/.test(r))try{let t=r.startsWith("#")?r:`#${r}`;return new R.Color(t)}catch (e2){return _chunkP57VU27Wcjs.j.call(void 0, ).warn(`Invalid hex color: ${e}, using white`),new R.Color(16777215)}if(r.includes(",")){let t=r.split(",").map(n=>parseInt(n.trim(),10));if(t.length===3&&t.every(n=>!isNaN(n)&&n>=0&&n<=255))return new R.Color(t[0]/255,t[1]/255,t[2]/255)}try{return new R.Color(r.toLowerCase())}catch (e3){return _chunkP57VU27Wcjs.j.call(void 0, ).warn(`Invalid color string: ${e}, using white`),new R.Color(16777215)}}function D(e,r){e.forEach(t=>{t.position.y-=r})}function A(e){let r=new R.Box3;return e.forEach(t=>{t.geometry.computeBoundingBox(),t.geometry.boundingBox&&r.union(t.geometry.boundingBox)}),r}function ie(e){let r=[];e.traverse(t=>{t instanceof R.Mesh&&t.userData.id!=="floor"&&r.push(t)}),r.forEach(t=>{t instanceof R.Mesh&&(_optionalChain([t, 'access', _118 => _118.geometry, 'optionalAccess', _119 => _119.dispose, 'call', _120 => _120()]),(Array.isArray(t.material)?t.material:[t.material]).forEach(o=>{Object.values(o).forEach(a=>{a instanceof R.Texture&&a.dispose()}),o.dispose()})),t.removeFromParent()})}var L={};_chunkP57VU27Wcjs.a.call(void 0, L,{CONCRETE_MATERIAL:()=>fe,EMISSIVE_MATERIAL:()=>ce,GLASS_MATERIAL:()=>he,METAL_MATERIAL:()=>le,PLASTIC_MATERIAL:()=>de,RUBBER_MATERIAL:()=>me,WOOD_MATERIAL:()=>ue});var ce=new m.MeshPhysicalMaterial({color:0,emissive:new m.Color(16777215),emissiveIntensity:5,metalness:0,roughness:.2,clearcoat:.3,clearcoatRoughness:.2,depthWrite:!0,depthTest:!0,transparent:!1,alphaTest:0,polygonOffset:!0,side:m.FrontSide,dithering:!0}),le=new m.MeshPhysicalMaterial({color:new m.Color(0),metalness:.9,roughness:.3,envMapIntensity:1.2,clearcoat:.3,clearcoatRoughness:.2,reflectivity:1,ior:2.5,thickness:1,depthWrite:!0,transparent:!1,alphaTest:0,depthTest:!0,polygonOffset:!0,side:m.FrontSide,dithering:!0}),fe=new m.MeshPhysicalMaterial({color:new m.Color(13421772),metalness:0,roughness:.92,envMapIntensity:.15,clearcoat:.05,clearcoatRoughness:.9,reflectivity:.15,transmission:0,ior:1.45,thickness:0,depthWrite:!0,transparent:!1,alphaTest:.5,depthTest:!0,polygonOffset:!0,side:m.FrontSide,dithering:!0}),de=new m.MeshPhysicalMaterial({color:new m.Color(16777215),metalness:0,roughness:.3,envMapIntensity:.5,clearcoat:.5,clearcoatRoughness:.1,reflectivity:.5,ior:1.4,transmission:0,transparent:!1,depthWrite:!0,side:m.FrontSide,dithering:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),he=new m.MeshPhysicalMaterial({color:new m.Color(16777215),metalness:0,roughness:0,transmission:.95,transparent:!0,opacity:.3,envMapIntensity:1,clearcoat:1,clearcoatRoughness:0,ior:1.52,reflectivity:.9,thickness:1,side:m.DoubleSide,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),me=new m.MeshPhysicalMaterial({color:new m.Color(1710618),metalness:0,roughness:.9,envMapIntensity:.2,clearcoat:.1,clearcoatRoughness:.8,reflectivity:.2,ior:1.3,transmission:0,depthWrite:!0,side:m.FrontSide,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),ue=new m.MeshPhysicalMaterial({color:new m.Color(8934707),metalness:0,roughness:.7,envMapIntensity:.3,clearcoat:.3,clearcoatRoughness:.4,reflectivity:.3,ior:1.3,transmission:0,depthWrite:!0,side:m.FrontSide,dithering:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1});var _fflate = require('fflate'); var U = _interopRequireWildcard(_fflate);_chunkP57VU27Wcjs.i.call(void 0, );async function W(e){return new Promise((r,t)=>{try{let n=()=>{try{let o=_chunk5DJRUPGIcjs.c.call(void 0, e),a=U.gunzipSync(o),s=Ee(a);r(s)}catch(o){t(new (0, _chunkP57VU27Wcjs.d)(o instanceof _chunkP57VU27Wcjs.d?o.message:`Failed to decompress batched data: ${o instanceof Error?o.message:String(o)}`,o instanceof _chunkP57VU27Wcjs.d?o.code:_chunkP57VU27Wcjs.f.VALIDATION_ERROR,{context:{base64StringLength:e.length},originalError:o instanceof Error?o:new Error(String(o))}))}};"requestIdleCallback"in globalThis?globalThis.requestIdleCallback(n,{timeout:5e3}):setTimeout(n,0)}catch(n){t(new (0, _chunkP57VU27Wcjs.d)(`Failed to schedule decompression: ${n instanceof Error?n.message:String(n)}`,_chunkP57VU27Wcjs.f.VALIDATION_ERROR,{originalError:n instanceof Error?n:new Error(String(n))}))}})}function Ee(e){let r=new DataView(e.buffer,e.byteOffset,e.byteLength),t=0;if(t+4>r.byteLength)throw new (0, _chunkP57VU27Wcjs.d)("Insufficient data to read the number of vertex floats.",_chunkP57VU27Wcjs.f.VALIDATION_ERROR,{context:{expectedBytes:4,availableBytes:r.byteLength,offset:t}});let n=r.getUint32(t,!0);if(t+=4,n%3!==0)throw new (0, _chunkP57VU27Wcjs.d)("Invalid number of vertex floats; should be divisible by 3.",_chunkP57VU27Wcjs.f.VALIDATION_ERROR,{context:{numVertexFloats:n,remainder:n%3,totalBytes:r.byteLength}});let o=n*Float32Array.BYTES_PER_ELEMENT;if(t+o>r.byteLength)throw new (0, _chunkP57VU27Wcjs.d)("Insufficient data to read vertices.",_chunkP57VU27Wcjs.f.VALIDATION_ERROR,{context:{expectedBytes:o,availableBytes:r.byteLength-t,offset:t}});let a=new Float32Array(e.buffer,e.byteOffset+t,n);if(t+=o,t+4>r.byteLength)throw new (0, _chunkP57VU27Wcjs.d)("Insufficient data to read the number of face indices.",_chunkP57VU27Wcjs.f.VALIDATION_ERROR,{context:{expectedBytes:4,availableBytes:r.byteLength-t,offset:t}});let s=r.getUint32(t,!0);t+=4;let l=s*Uint32Array.BYTES_PER_ELEMENT;if(t+l>r.byteLength)throw new (0, _chunkP57VU27Wcjs.d)("Insufficient data to read face indices.",_chunkP57VU27Wcjs.f.VALIDATION_ERROR,{context:{expectedBytes:l,availableBytes:r.byteLength-t,offset:t}});let c=new Uint32Array(e.buffer,e.byteOffset+t,s);return{vertices:a,faces:c}}async function z(e,r){let{mergeByMaterial:t=!0,applyTransforms:n=!0,debug:o=!1}=_nullishCoalesce(r, () => ({})),a=o?performance.now():0,s=0;try{let l=performance.now(),c=JSON.parse(e);return s=performance.now()-l,await F(c,{mergeByMaterial:t,applyTransforms:n,debug:o,parseTime:s,perfStart:a})}catch(l){return _chunkP57VU27Wcjs.j.call(void 0, ).error("Error parsing mesh batch:",l),[]}}async function F(e,r){let{mergeByMaterial:t=!0,applyTransforms:n=!0,scaleFactor:o=1,debug:a=!1,parseTime:s=0,perfStart:l=a?performance.now():0}=_nullishCoalesce(r, () => ({})),c=0,T=0;try{let h=performance.now(),{vertices:u,faces:p}=await W(e.compressedData);c=performance.now()-h;let x=(e.compressedData.length*.75/1024/1024).toFixed(2),f=((u.byteLength+p.byteLength)/1024/1024).toFixed(2),H=((1-parseFloat(x)/parseFloat(f))*100).toFixed(1);a&&(_chunkP57VU27Wcjs.j.call(void 0, ).debug("Mesh Batch Stats:"),_chunkP57VU27Wcjs.j.call(void 0, ).debug(` Materials: ${e.materials.length} | Groups: ${e.groups.length}`),_chunkP57VU27Wcjs.j.call(void 0, ).debug(` Vertices: ${(u.length/3).toLocaleString()} | Faces: ${(p.length/3).toLocaleString()}`),_chunkP57VU27Wcjs.j.call(void 0, ).debug(` Compressed: ${x} MB | Uncompressed: ${f} MB`),_chunkP57VU27Wcjs.j.call(void 0, ).debug(` Compression Ratio: ${H}%`)),n&&Te(u);let O=performance.now(),d=e.materials.map(pe),b=[];for(let g of e.groups)if(t&&g.meshes.length>1){let v=ge(g,u,p,d);b.push(v)}else{let v=Re(g,u,p,d);b.push(...v)}if(o!==1)for(let g of b)g.scale.set(o,o,o);if(T=performance.now()-O,a){let g=performance.now()-l;_chunkP57VU27Wcjs.j.call(void 0, ).debug("Performance:"),s>0&&_chunkP57VU27Wcjs.j.call(void 0, ).debug(` Parse JSON: ${s.toFixed(2)}ms`),_chunkP57VU27Wcjs.j.call(void 0, ).debug(` Decompress: ${c.toFixed(2)}ms`),_chunkP57VU27Wcjs.j.call(void 0, ).debug(` Create Meshes: ${T.toFixed(2)}ms`),_chunkP57VU27Wcjs.j.call(void 0, ).debug(` Total: ${g.toFixed(2)}ms`)}return b}catch(h){return _chunkP57VU27Wcjs.j.call(void 0, ).error("Error parsing mesh batch object:",h),[]}}function pe(e){let r=I(e.color);return new w.MeshPhysicalMaterial({color:r,metalness:e.metalness,roughness:e.roughness,opacity:e.opacity,transparent:e.transparent,side:w.DoubleSide,polygonOffset:!0,polygonOffsetFactor:.5,polygonOffsetUnits:.5,depthWrite:!0,depthTest:!0})}function ge(e,r,t,n){let o=new w.BufferGeometry,a=0,s=0;for(let f of e.meshes)a+=f.vertexCount,s+=f.faceCount;let l=new Float32Array(a),c=new Uint32Array(s),T=0,h=0;for(let f of e.meshes){l.set(r.subarray(f.vertexOffset,f.vertexOffset+f.vertexCount),T);let H=t.subarray(f.faceOffset,f.faceOffset+f.faceCount),O=Math.floor(f.vertexOffset/3),b=Math.floor(T/3)-O;for(let g=0;g<H.length;g++)c[h+g]=H[g]+b;T+=f.vertexCount,h+=f.faceCount}o.setAttribute("position",new w.BufferAttribute(l,3)),o.setIndex(new w.BufferAttribute(c,1)),o.computeVertexNormals();let u=new w.Mesh(o,n[e.materialId]),p=e.meshes.map(f=>f.name).filter(f=>f&&f.length>0);u.name=p.length>0?p[0]:`merged_material_${e.materialId}`,u.castShadow=!0,u.receiveShadow=!0;let x=e.meshes.map(f=>f.metadata).filter(f=>f);return x.length>0&&(u.userData.mergedMetadata=x),u}function Re(e,r,t,n){let o=[];for(let a of e.meshes){let s=new w.BufferGeometry,l=r.subarray(a.vertexOffset,a.vertexOffset+a.vertexCount),c=t.subarray(a.faceOffset,a.faceOffset+a.faceCount),T=Math.floor(a.vertexOffset/3),h=new Uint32Array(c.length);for(let p=0;p<c.length;p++)h[p]=c[p]-T;s.setAttribute("position",new w.BufferAttribute(l,3)),s.setIndex(new w.BufferAttribute(h,1)),s.computeVertexNormals();let u=new w.Mesh(s,n[e.materialId]);u.name=a.name,a.metadata&&(u.userData={...u.userData,...a.metadata}),u.castShadow=!0,u.receiveShadow=!0,o.push(u)}return o}function Te(e){let r=Math.cos(-Math.PI/2),t=Math.sin(-Math.PI/2);for(let n=0;n<e.length;n+=3){let o=e[n],a=e[n+1],s=e[n+2];e[n]=o,e[n+1]=a*r-s*t,e[n+2]=a*t+s*r}}var P={Millimeters:1/1e3,Centimeters:1/100,Meters:1,Inches:1/39.37,Feet:1/3.28084},we="Display";async function G(e,r){let t=performance.now(),n=[],{allowScaling:o=!0,allowAutoPosition:a=!0,debug:s=!1,parsing:l={}}=_nullishCoalesce(r, () => ({}));try{let c=o?ye(e.modelunits):1;return await be(e,n,c,l,s),a&&xe(n),n}catch(c){throw He(c,n),c}finally{s&&Ce(t)}}function ye(e){return _nullishCoalesce(P[e], () => (1))}async function be(e,r,t,n,o){for(let a of e.values){let s=a.InnerTree;for(let l in s){let c=s[l];c&&await Me(c,r,t,n,o)}}}async function Me(e,r,t,n,o){for(let a of e)if(a.type.includes(we)){let s={mergeByMaterial:!0,applyTransforms:!0,debug:!1,...n},l=await z(a.data,s);if(t!==1)for(let c of l)c.scale.set(t,t,t);r.push(...l),o&&_chunkP57VU27Wcjs.j.call(void 0, ).debug(`Extracted ${l.length} meshes from batch`)}}function xe(e){if(e.length===0)return;let t=A(e).min.y;D(e,t)}function He(e,r){_chunkP57VU27Wcjs.j.call(void 0, ).error("An unexpected error occurred:",e),ve(r)}function ve(e){for(let r of e)r.geometry&&r.geometry.dispose(),r.material&&(Array.isArray(r.material)?r.material.forEach(t=>t.dispose()):r.material.dispose())}function Ce(e){let r=performance.now()-e;_chunkP57VU27Wcjs.j.call(void 0, ).info("Time to process meshes:",`${r.toFixed(2)}ms`)}exports.Materials = L; exports.SCALE_FACTORS = P; exports.getThreeMeshesFromComputeResponse = G; exports.initThree = _; exports.parseMeshBatchObject = F; exports.updateScene = N;
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkM2HPEWXHcjs = require('./chunk-M2HPEWXH.cjs');var _chunkFNWG34KHcjs = require('./chunk-FNWG34KH.cjs');var _three = require('three'); var i = _interopRequireWildcard(_three); var R = _interopRequireWildcard(_three); var m = _interopRequireWildcard(_three); var w = _interopRequireWildcard(_three);var _OrbitControlsjs = require('three/addons/controls/OrbitControls.js');var _RGBELoaderjs = require('three/addons/loaders/RGBELoader.js');var k=new i.Vector3(0,0,1),_= exports.initThree =function(e,r){let t=Z(r||{}),n=J(t),o=re(t),a=oe(e,t),s=se(o,e,t);ee(n,t),te(n,t),_optionalChain([t, 'access', _2 => _2.floor, 'optionalAccess', _3 => _3.enabled])&&ne(n,t);let l=t.events.enableEventHandlers!==!1?ae(e,n,o,s,t):{dispose:()=>{},fitToView:()=>{},clearSelection:()=>{}},{resize:c,dispose:T}=Q(e,a,o),{animate:h,dispose:u}=X(a,n,o,s);h();let p=_optionalChain([t, 'access', _4 => _4.environment, 'optionalAccess', _5 => _5.sceneUp])||k;return n.up.set(p.x,p.y,p.z),{scene:n,camera:o,controls:s,renderer:a,dispose:()=>{u(),T(),l.dispose(),s.dispose(),a.dispose(),n.traverse(f=>{f instanceof i.Mesh&&(_optionalChain([f, 'access', _6 => _6.geometry, 'optionalAccess', _7 => _7.dispose, 'call', _8 => _8()]),Array.isArray(f.material)?f.material.forEach(H=>H.dispose()):_optionalChain([f, 'access', _9 => _9.material, 'optionalAccess', _10 => _10.dispose, 'call', _11 => _11()]))})},resize:c,fitToView:l.fitToView,clearSelection:l.clearSelection}};function Z(e){let r=e.sceneScale||"m",n={mm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:10,lightHeight:20,minDistance:.1,shadowSize:100,scaleFactor:1e3},cm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:25,lightHeight:50,minDistance:.1,shadowSize:100,scaleFactor:100},m:{cameraDistance:10,near:.01,far:2e3,floorSize:50,lightDistance:25,lightHeight:50,minDistance:.001,shadowSize:100,scaleFactor:1},inches:{cameraDistance:15,near:.1,far:2e3,floorSize:80,lightDistance:20,lightHeight:40,minDistance:.1,shadowSize:80,scaleFactor:39.37},feet:{cameraDistance:8,near:.1,far:2e3,floorSize:40,lightDistance:15,lightHeight:30,minDistance:.1,shadowSize:60,scaleFactor:3.28084}}[r];return{sceneScale:r,camera:{position:_optionalChain([e, 'access', _12 => _12.camera, 'optionalAccess', _13 => _13.position])||new i.Vector3(-n.cameraDistance,n.cameraDistance,n.cameraDistance),fov:_optionalChain([e, 'access', _14 => _14.camera, 'optionalAccess', _15 => _15.fov])||20,near:_optionalChain([e, 'access', _16 => _16.camera, 'optionalAccess', _17 => _17.near])||n.near,far:_optionalChain([e, 'access', _18 => _18.camera, 'optionalAccess', _19 => _19.far])||n.far,target:_optionalChain([e, 'access', _20 => _20.camera, 'optionalAccess', _21 => _21.target])||new i.Vector3(0,0,0)},lighting:{enableSunlight:_nullishCoalesce(_optionalChain([e, 'access', _22 => _22.lighting, 'optionalAccess', _23 => _23.enableSunlight]), () => (!0)),sunlightIntensity:_optionalChain([e, 'access', _24 => _24.lighting, 'optionalAccess', _25 => _25.sunlightIntensity])||1,sunlightPosition:_optionalChain([e, 'access', _26 => _26.lighting, 'optionalAccess', _27 => _27.sunlightPosition])||new i.Vector3(n.lightDistance,n.lightHeight,n.lightDistance),ambientLightColor:_optionalChain([e, 'access', _28 => _28.lighting, 'optionalAccess', _29 => _29.ambientLightColor])||new i.Color(4210752),ambientLightIntensity:_optionalChain([e, 'access', _30 => _30.lighting, 'optionalAccess', _31 => _31.ambientLightIntensity])||1,sunlightColor:_optionalChain([e, 'access', _32 => _32.lighting, 'optionalAccess', _33 => _33.sunlightColor])||16777215},environment:{hdrPath:_optionalChain([e, 'access', _34 => _34.environment, 'optionalAccess', _35 => _35.hdrPath])||"/baseHDR.hdr",backgroundColor:_optionalChain([e, 'access', _36 => _36.environment, 'optionalAccess', _37 => _37.backgroundColor])||new i.Color(15790320),enableEnvironmentLighting:_nullishCoalesce(_optionalChain([e, 'access', _38 => _38.environment, 'optionalAccess', _39 => _39.enableEnvironmentLighting]), () => (!0)),sceneUp:_optionalChain([e, 'access', _40 => _40.environment, 'optionalAccess', _41 => _41.sceneUp])||k,showEnvironment:_nullishCoalesce(_optionalChain([e, 'access', _42 => _42.environment, 'optionalAccess', _43 => _43.showEnvironment]), () => (!1))},floor:{enabled:_nullishCoalesce(_optionalChain([e, 'access', _44 => _44.floor, 'optionalAccess', _45 => _45.enabled]), () => (!1)),size:_optionalChain([e, 'access', _46 => _46.floor, 'optionalAccess', _47 => _47.size])||n.floorSize,color:_optionalChain([e, 'access', _48 => _48.floor, 'optionalAccess', _49 => _49.color])||new i.Color(8421504),roughness:_optionalChain([e, 'access', _50 => _50.floor, 'optionalAccess', _51 => _51.roughness])||.7,metalness:_optionalChain([e, 'access', _52 => _52.floor, 'optionalAccess', _53 => _53.metalness])||0,receiveShadow:_nullishCoalesce(_optionalChain([e, 'access', _54 => _54.floor, 'optionalAccess', _55 => _55.receiveShadow]), () => (!0))},render:{enableShadows:_nullishCoalesce(_optionalChain([e, 'access', _56 => _56.render, 'optionalAccess', _57 => _57.enableShadows]), () => (!0)),shadowMapSize:_optionalChain([e, 'access', _58 => _58.render, 'optionalAccess', _59 => _59.shadowMapSize])||2048,antialias:_nullishCoalesce(_optionalChain([e, 'access', _60 => _60.render, 'optionalAccess', _61 => _61.antialias]), () => (!0)),pixelRatio:_optionalChain([e, 'access', _62 => _62.render, 'optionalAccess', _63 => _63.pixelRatio])||Math.min(window.devicePixelRatio,2),toneMapping:_optionalChain([e, 'access', _64 => _64.render, 'optionalAccess', _65 => _65.toneMapping])||i.NeutralToneMapping,toneMappingExposure:_optionalChain([e, 'access', _66 => _66.render, 'optionalAccess', _67 => _67.toneMappingExposure])||1,preserveDrawingBuffer:_nullishCoalesce(_optionalChain([e, 'access', _68 => _68.render, 'optionalAccess', _69 => _69.preserveDrawingBuffer]), () => (!1))},controls:{enableDamping:_nullishCoalesce(_optionalChain([e, 'access', _70 => _70.controls, 'optionalAccess', _71 => _71.enableDamping]), () => (!1)),dampingFactor:_optionalChain([e, 'access', _72 => _72.controls, 'optionalAccess', _73 => _73.dampingFactor])||.05,autoRotate:_nullishCoalesce(_optionalChain([e, 'access', _74 => _74.controls, 'optionalAccess', _75 => _75.autoRotate]), () => (!1)),autoRotateSpeed:_optionalChain([e, 'access', _76 => _76.controls, 'optionalAccess', _77 => _77.autoRotateSpeed])||.5,enableZoom:_nullishCoalesce(_optionalChain([e, 'access', _78 => _78.controls, 'optionalAccess', _79 => _79.enableZoom]), () => (!0)),enablePan:_nullishCoalesce(_optionalChain([e, 'access', _80 => _80.controls, 'optionalAccess', _81 => _81.enablePan]), () => (!0)),minDistance:_optionalChain([e, 'access', _82 => _82.controls, 'optionalAccess', _83 => _83.minDistance])||n.minDistance,maxDistance:_optionalChain([e, 'access', _84 => _84.controls, 'optionalAccess', _85 => _85.maxDistance])||1/0},events:{onBackgroundClicked:_optionalChain([e, 'access', _86 => _86.events, 'optionalAccess', _87 => _87.onBackgroundClicked]),onObjectSelected:_optionalChain([e, 'access', _88 => _88.events, 'optionalAccess', _89 => _89.onObjectSelected]),onMeshMetadataClicked:_optionalChain([e, 'access', _90 => _90.events, 'optionalAccess', _91 => _91.onMeshMetadataClicked]),selectionColor:_optionalChain([e, 'access', _92 => _92.events, 'optionalAccess', _93 => _93.selectionColor])||"#ff0000",enableEventHandlers:_nullishCoalesce(_optionalChain([e, 'access', _94 => _94.events, 'optionalAccess', _95 => _95.enableEventHandlers]), () => (!0)),enableKeyboardControls:_nullishCoalesce(_optionalChain([e, 'access', _96 => _96.events, 'optionalAccess', _97 => _97.enableKeyboardControls]), () => (!0)),enableClickToFocus:_nullishCoalesce(_optionalChain([e, 'access', _98 => _98.events, 'optionalAccess', _99 => _99.enableClickToFocus]), () => (!0))}}}function J(e){let r=new i.Scene;r.children.forEach(n=>{n.userData.id!=="floor"&&r.remove(n)});let t=typeof e.environment.backgroundColor=="string"?new i.Color(e.environment.backgroundColor):e.environment.backgroundColor;return r.background=t||null,r}function X(e,r,t,n){let o=null,a=function(){o=requestAnimationFrame(a),n.enableDamping&&n.update(),e.render(r,t)};return{animate:a,dispose:()=>{o!==null&&(cancelAnimationFrame(o),o=null)}}}function Q(e,r,t){let n=e.parentElement,o,a=null,s=()=>n?{width:n.clientWidth,height:n.clientHeight}:{width:window.innerWidth,height:window.innerHeight},l=()=>{o&&clearTimeout(o),o=setTimeout(()=>{let{width:T,height:h}=s();(r.domElement.width!==T||r.domElement.height!==h)&&(r.setSize(T,h,!1),t.aspect=T/h,t.updateProjectionMatrix())},16)};return n&&typeof ResizeObserver<"u"?(a=new ResizeObserver(l),a.observe(n)):window.addEventListener("resize",l),{resize:l,dispose:()=>{o&&clearTimeout(o),a?a.disconnect():window.removeEventListener("resize",l)}}}function ee(e,r){r.environment.enableEnvironmentLighting&&new (0, _RGBELoaderjs.RGBELoader)().load(r.environment.hdrPath||"/baseHDR.hdr",function(t){t.mapping=i.EquirectangularReflectionMapping,e.environment=t,r.environment.showEnvironment&&(e.background=t)},void 0,function(t){_chunkFNWG34KHcjs.j.call(void 0, ).warn("HDR texture could not be loaded, falling back to basic lighting:",t);let n=new i.AmbientLight(4210752,.4);e.add(n)})}function te(e,r){let t=new i.AmbientLight(r.lighting.ambientLightColor,r.lighting.ambientLightIntensity);if(e.add(t),r.lighting.enableSunlight){let n=new i.DirectionalLight(_nullishCoalesce(r.lighting.sunlightColor, () => (16777215)),r.lighting.sunlightIntensity),o=r.lighting.sunlightPosition;if(o&&n.position.set(o.x,o.y,o.z),r.render.enableShadows){n.castShadow=!0;let a=r.sceneScale==="mm"?.1:r.sceneScale==="cm"?10:100;n.shadow.camera.left=-a,n.shadow.camera.right=a,n.shadow.camera.top=a,n.shadow.camera.bottom=-a;let s=r.sceneScale==="mm"?.001:r.sceneScale==="cm"?.1:.5,l=r.sceneScale==="mm"?1:r.sceneScale==="cm"?100:500;n.shadow.camera.near=s,n.shadow.camera.far=l,n.shadow.mapSize.width=r.render.shadowMapSize||2048,n.shadow.mapSize.height=r.render.shadowMapSize||2048,n.shadow.bias=-1e-4,n.shadow.normalBias=.02}e.add(n)}}function ne(e,r){let t=r.floor.size,n=new i.PlaneGeometry(t,t),o=typeof r.floor.color=="string"?new i.Color(r.floor.color):r.floor.color,a=new i.MeshStandardMaterial({color:o,roughness:r.floor.roughness,metalness:r.floor.metalness,side:i.DoubleSide}),s=new i.Mesh(n,a);s.userData.id="floor",s.name="floor",s.rotation.x=-Math.PI/2,s.position.y=0,r.floor.receiveShadow&&r.render.enableShadows&&(s.receiveShadow=!0),e.add(s)}function re(e){let t=_optionalChain([document, 'access', _100 => _100.querySelector, 'call', _101 => _101("canvas"), 'optionalAccess', _102 => _102.parentElement]),n=t?t.clientWidth:window.innerWidth,o=t?t.clientHeight:window.innerHeight,a=new i.PerspectiveCamera(e.camera.fov,n/o,e.camera.near,e.camera.far),s=e.camera.position;return s&&a.position.set(s.x,s.y,s.z),a}function oe(e,r){let t=new i.WebGLRenderer({antialias:r.render.antialias,canvas:e,alpha:!0,powerPreference:"high-performance",preserveDrawingBuffer:r.render.preserveDrawingBuffer,logarithmicDepthBuffer:!0}),n=e.parentElement,o=n?n.clientWidth:window.innerWidth,a=n?n.clientHeight:window.innerHeight;return n&&(e.style.width="100%",e.style.height="100%",e.style.display="block"),t.setSize(o,a,!1),t.setPixelRatio(r.render.pixelRatio||Math.min(window.devicePixelRatio,2)),r.render.enableShadows&&(t.shadowMap.enabled=!0,t.shadowMap.type=i.VSMShadowMap),t.toneMapping=r.render.toneMapping||i.ACESFilmicToneMapping,t.toneMappingExposure=r.render.toneMappingExposure||1,t.outputColorSpace=i.SRGBColorSpace,t.sortObjects=!0,t}function ae(e,r,t,n,o){let a=new Set,s=new Map,l=new i.Raycaster,c=new i.Vector2,T=new i.Vector2,h=()=>{let d=new i.Box3;if(r.traverse(B=>{B.visible&&B.userData.id!=="floor"&&B instanceof i.Mesh&&d.expandByObject(B)}),d.isEmpty()){_chunkFNWG34KHcjs.j.call(void 0, ).warn("No objects to fit to view");return}let b=d.getCenter(new i.Vector3),g=d.getSize(new i.Vector3),v=Math.max(g.x,g.y,g.z),y=t.fov*(Math.PI/180),S=v/(2*Math.tan(y/2));S*=1.5;let $=t.position.clone().sub(n.target).normalize();t.position.copy(b.clone().add($.multiplyScalar(S))),n.target.copy(b),n.update()},u=typeof o.events.selectionColor=="string"?new i.Color(o.events.selectionColor):o.events.selectionColor instanceof i.Color?o.events.selectionColor:new i.Color("#ff0000"),p=()=>{a.forEach(d=>{d instanceof i.Mesh&&s.has(d)&&(d.material=s.get(d),s.delete(d))}),a.clear()},x=d=>{T.set(d.clientX,d.clientY)},f=d=>{let b=new i.Vector2(d.clientX,d.clientY);if(T.distanceTo(b)>5)return;let g=e.getBoundingClientRect();c.x=(d.clientX-g.left)/g.width*2-1,c.y=-((d.clientY-g.top)/g.height)*2+1,l.setFromCamera(c,t);let v=l.intersectObjects(r.children,!0);if(v.length>0){let y=v[0].object;if(!a.has(y)){if(p(),a.add(y),y instanceof i.Mesh&&y.material instanceof i.Material){s.set(y,y.material);let S=y.material.clone();S.emissive=u.clone(),y.material=S}_optionalChain([o, 'access', _103 => _103.events, 'optionalAccess', _104 => _104.onObjectSelected, 'optionalCall', _105 => _105(y)]),y instanceof i.Mesh&&Object.keys(y.userData).length>0&&_optionalChain([o, 'access', _106 => _106.events, 'optionalAccess', _107 => _107.onMeshMetadataClicked, 'optionalCall', _108 => _108(y.userData)])}}else p(),_optionalChain([o, 'access', _109 => _109.events, 'optionalAccess', _110 => _110.onBackgroundClicked, 'optionalCall', _111 => _111({x:c.x,y:c.y})])},H=d=>{if(_optionalChain([o, 'access', _112 => _112.events, 'optionalAccess', _113 => _113.enableKeyboardControls]))switch(d.key.toLowerCase()){case"f":d.preventDefault(),h();break;case"escape":d.preventDefault(),p();break;case" ":d.preventDefault(),h();break}};return _optionalChain([o, 'access', _114 => _114.events, 'optionalAccess', _115 => _115.enableClickToFocus])&&(e.addEventListener("mousedown",x),e.addEventListener("click",f)),_optionalChain([o, 'access', _116 => _116.events, 'optionalAccess', _117 => _117.enableKeyboardControls])&&(e.setAttribute("tabindex","0"),e.addEventListener("keydown",H)),{dispose:()=>{e.removeEventListener("mousedown",x),e.removeEventListener("click",f),e.removeEventListener("keydown",H),p()},fitToView:h,clearSelection:p}}function se(e,r,t){let n=new (0, _OrbitControlsjs.OrbitControls)(e,r),o=t.camera.target;return o&&n.target.set(o.x,o.y,o.z),n.enableDamping=t.controls.enableDamping||!1,n.dampingFactor=t.controls.dampingFactor||.05,n.autoRotate=t.controls.autoRotate||!1,n.autoRotateSpeed=t.controls.autoRotateSpeed||.5,n.enableZoom=t.controls.enableZoom||!0,n.enablePan=t.controls.enablePan||!0,n.minDistance=t.controls.minDistance||.001,n.maxDistance=t.controls.maxDistance||1/0,n.screenSpacePanning=!1,n.maxPolarAngle=Math.PI,n.update(),n}function N(e,r,t,n,o){if(ie(e),r.length===0)return;let a=new R.Box3;r.forEach(h=>{e.add(h);let u=new R.Box3().setFromObject(h);a.union(u)});let s=a.getCenter(new R.Vector3),l=a.getSize(new R.Vector3),c=Math.max(l.x,l.y,l.z);if(c/Math.min(l.x||1,l.y||1,l.z||1)>100||c>1e4?(t.near=c*1e-4,t.far=c*100):c>1e3?(t.near=c*.001,t.far=c*50):(t.near=Math.max(.01,c*.01),t.far=Math.max(2e3,c*20)),t.updateProjectionMatrix(),o)n.minDistance=t.near*2,n.maxDistance=t.far*.9;else{let h=c*4;t.position.set(s.x+h*.8,s.y+h,s.z+h*1.2),n.target=s,n.minDistance=t.near*2,n.maxDistance=t.far*.9,n.update()}}function I(e){if(!e||typeof e!="string")return _chunkFNWG34KHcjs.j.call(void 0, ).warn(`Invalid color input: ${e}, using white`),new R.Color(16777215);let r=e.trim();if(r.startsWith("#")||/^[0-9A-Fa-f]{6}$/.test(r))try{let t=r.startsWith("#")?r:`#${r}`;return new R.Color(t)}catch (e2){return _chunkFNWG34KHcjs.j.call(void 0, ).warn(`Invalid hex color: ${e}, using white`),new R.Color(16777215)}if(r.includes(",")){let t=r.split(",").map(n=>parseInt(n.trim(),10));if(t.length===3&&t.every(n=>!isNaN(n)&&n>=0&&n<=255))return new R.Color(t[0]/255,t[1]/255,t[2]/255)}try{return new R.Color(r.toLowerCase())}catch (e3){return _chunkFNWG34KHcjs.j.call(void 0, ).warn(`Invalid color string: ${e}, using white`),new R.Color(16777215)}}function D(e,r){e.forEach(t=>{t.position.y-=r})}function A(e){let r=new R.Box3;return e.forEach(t=>{t.geometry.computeBoundingBox(),t.geometry.boundingBox&&r.union(t.geometry.boundingBox)}),r}function ie(e){let r=[];e.traverse(t=>{t instanceof R.Mesh&&t.userData.id!=="floor"&&r.push(t)}),r.forEach(t=>{t instanceof R.Mesh&&(_optionalChain([t, 'access', _118 => _118.geometry, 'optionalAccess', _119 => _119.dispose, 'call', _120 => _120()]),(Array.isArray(t.material)?t.material:[t.material]).forEach(o=>{Object.values(o).forEach(a=>{a instanceof R.Texture&&a.dispose()}),o.dispose()})),t.removeFromParent()})}var L={};_chunkFNWG34KHcjs.a.call(void 0, L,{CONCRETE_MATERIAL:()=>fe,EMISSIVE_MATERIAL:()=>ce,GLASS_MATERIAL:()=>he,METAL_MATERIAL:()=>le,PLASTIC_MATERIAL:()=>de,RUBBER_MATERIAL:()=>me,WOOD_MATERIAL:()=>ue});var ce=new m.MeshPhysicalMaterial({color:0,emissive:new m.Color(16777215),emissiveIntensity:5,metalness:0,roughness:.2,clearcoat:.3,clearcoatRoughness:.2,depthWrite:!0,depthTest:!0,transparent:!1,alphaTest:0,polygonOffset:!0,side:m.FrontSide,dithering:!0}),le=new m.MeshPhysicalMaterial({color:new m.Color(0),metalness:.9,roughness:.3,envMapIntensity:1.2,clearcoat:.3,clearcoatRoughness:.2,reflectivity:1,ior:2.5,thickness:1,depthWrite:!0,transparent:!1,alphaTest:0,depthTest:!0,polygonOffset:!0,side:m.FrontSide,dithering:!0}),fe=new m.MeshPhysicalMaterial({color:new m.Color(13421772),metalness:0,roughness:.92,envMapIntensity:.15,clearcoat:.05,clearcoatRoughness:.9,reflectivity:.15,transmission:0,ior:1.45,thickness:0,depthWrite:!0,transparent:!1,alphaTest:.5,depthTest:!0,polygonOffset:!0,side:m.FrontSide,dithering:!0}),de=new m.MeshPhysicalMaterial({color:new m.Color(16777215),metalness:0,roughness:.3,envMapIntensity:.5,clearcoat:.5,clearcoatRoughness:.1,reflectivity:.5,ior:1.4,transmission:0,transparent:!1,depthWrite:!0,side:m.FrontSide,dithering:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),he=new m.MeshPhysicalMaterial({color:new m.Color(16777215),metalness:0,roughness:0,transmission:.95,transparent:!0,opacity:.3,envMapIntensity:1,clearcoat:1,clearcoatRoughness:0,ior:1.52,reflectivity:.9,thickness:1,side:m.DoubleSide,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),me=new m.MeshPhysicalMaterial({color:new m.Color(1710618),metalness:0,roughness:.9,envMapIntensity:.2,clearcoat:.1,clearcoatRoughness:.8,reflectivity:.2,ior:1.3,transmission:0,depthWrite:!0,side:m.FrontSide,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),ue=new m.MeshPhysicalMaterial({color:new m.Color(8934707),metalness:0,roughness:.7,envMapIntensity:.3,clearcoat:.3,clearcoatRoughness:.4,reflectivity:.3,ior:1.3,transmission:0,depthWrite:!0,side:m.FrontSide,dithering:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1});var _fflate = require('fflate'); var U = _interopRequireWildcard(_fflate);_chunkFNWG34KHcjs.i.call(void 0, );async function W(e){return new Promise((r,t)=>{try{let n=()=>{try{let o=_chunkM2HPEWXHcjs.c.call(void 0, e),a=U.gunzipSync(o),s=Ee(a);r(s)}catch(o){t(new (0, _chunkFNWG34KHcjs.d)(o instanceof _chunkFNWG34KHcjs.d?o.message:`Failed to decompress batched data: ${o instanceof Error?o.message:String(o)}`,o instanceof _chunkFNWG34KHcjs.d?o.code:_chunkFNWG34KHcjs.f.VALIDATION_ERROR,{context:{base64StringLength:e.length},originalError:o instanceof Error?o:new Error(String(o))}))}};"requestIdleCallback"in globalThis?globalThis.requestIdleCallback(n,{timeout:5e3}):setTimeout(n,0)}catch(n){t(new (0, _chunkFNWG34KHcjs.d)(`Failed to schedule decompression: ${n instanceof Error?n.message:String(n)}`,_chunkFNWG34KHcjs.f.VALIDATION_ERROR,{originalError:n instanceof Error?n:new Error(String(n))}))}})}function Ee(e){let r=new DataView(e.buffer,e.byteOffset,e.byteLength),t=0;if(t+4>r.byteLength)throw new (0, _chunkFNWG34KHcjs.d)("Insufficient data to read the number of vertex floats.",_chunkFNWG34KHcjs.f.VALIDATION_ERROR,{context:{expectedBytes:4,availableBytes:r.byteLength,offset:t}});let n=r.getUint32(t,!0);if(t+=4,n%3!==0)throw new (0, _chunkFNWG34KHcjs.d)("Invalid number of vertex floats; should be divisible by 3.",_chunkFNWG34KHcjs.f.VALIDATION_ERROR,{context:{numVertexFloats:n,remainder:n%3,totalBytes:r.byteLength}});let o=n*Float32Array.BYTES_PER_ELEMENT;if(t+o>r.byteLength)throw new (0, _chunkFNWG34KHcjs.d)("Insufficient data to read vertices.",_chunkFNWG34KHcjs.f.VALIDATION_ERROR,{context:{expectedBytes:o,availableBytes:r.byteLength-t,offset:t}});let a=new Float32Array(e.buffer,e.byteOffset+t,n);if(t+=o,t+4>r.byteLength)throw new (0, _chunkFNWG34KHcjs.d)("Insufficient data to read the number of face indices.",_chunkFNWG34KHcjs.f.VALIDATION_ERROR,{context:{expectedBytes:4,availableBytes:r.byteLength-t,offset:t}});let s=r.getUint32(t,!0);t+=4;let l=s*Uint32Array.BYTES_PER_ELEMENT;if(t+l>r.byteLength)throw new (0, _chunkFNWG34KHcjs.d)("Insufficient data to read face indices.",_chunkFNWG34KHcjs.f.VALIDATION_ERROR,{context:{expectedBytes:l,availableBytes:r.byteLength-t,offset:t}});let c=new Uint32Array(e.buffer,e.byteOffset+t,s);return{vertices:a,faces:c}}async function z(e,r){let{mergeByMaterial:t=!0,applyTransforms:n=!0,debug:o=!1}=_nullishCoalesce(r, () => ({})),a=o?performance.now():0,s=0;try{let l=performance.now(),c=JSON.parse(e);return s=performance.now()-l,await F(c,{mergeByMaterial:t,applyTransforms:n,debug:o,parseTime:s,perfStart:a})}catch(l){return _chunkFNWG34KHcjs.j.call(void 0, ).error("Error parsing mesh batch:",l),[]}}async function F(e,r){let{mergeByMaterial:t=!0,applyTransforms:n=!0,scaleFactor:o=1,debug:a=!1,parseTime:s=0,perfStart:l=a?performance.now():0}=_nullishCoalesce(r, () => ({})),c=0,T=0;try{let h=performance.now(),{vertices:u,faces:p}=await W(e.compressedData);c=performance.now()-h;let x=(e.compressedData.length*.75/1024/1024).toFixed(2),f=((u.byteLength+p.byteLength)/1024/1024).toFixed(2),H=((1-parseFloat(x)/parseFloat(f))*100).toFixed(1);a&&(_chunkFNWG34KHcjs.j.call(void 0, ).debug("Mesh Batch Stats:"),_chunkFNWG34KHcjs.j.call(void 0, ).debug(` Materials: ${e.materials.length} | Groups: ${e.groups.length}`),_chunkFNWG34KHcjs.j.call(void 0, ).debug(` Vertices: ${(u.length/3).toLocaleString()} | Faces: ${(p.length/3).toLocaleString()}`),_chunkFNWG34KHcjs.j.call(void 0, ).debug(` Compressed: ${x} MB | Uncompressed: ${f} MB`),_chunkFNWG34KHcjs.j.call(void 0, ).debug(` Compression Ratio: ${H}%`)),n&&Te(u);let O=performance.now(),d=e.materials.map(pe),b=[];for(let g of e.groups)if(t&&g.meshes.length>1){let v=ge(g,u,p,d);b.push(v)}else{let v=Re(g,u,p,d);b.push(...v)}if(o!==1)for(let g of b)g.scale.set(o,o,o);if(T=performance.now()-O,a){let g=performance.now()-l;_chunkFNWG34KHcjs.j.call(void 0, ).debug("Performance:"),s>0&&_chunkFNWG34KHcjs.j.call(void 0, ).debug(` Parse JSON: ${s.toFixed(2)}ms`),_chunkFNWG34KHcjs.j.call(void 0, ).debug(` Decompress: ${c.toFixed(2)}ms`),_chunkFNWG34KHcjs.j.call(void 0, ).debug(` Create Meshes: ${T.toFixed(2)}ms`),_chunkFNWG34KHcjs.j.call(void 0, ).debug(` Total: ${g.toFixed(2)}ms`)}return b}catch(h){return _chunkFNWG34KHcjs.j.call(void 0, ).error("Error parsing mesh batch object:",h),[]}}function pe(e){let r=I(e.color);return new w.MeshPhysicalMaterial({color:r,metalness:e.metalness,roughness:e.roughness,opacity:e.opacity,transparent:e.transparent,side:w.DoubleSide,polygonOffset:!0,polygonOffsetFactor:.5,polygonOffsetUnits:.5,depthWrite:!0,depthTest:!0})}function ge(e,r,t,n){let o=new w.BufferGeometry,a=0,s=0;for(let f of e.meshes)a+=f.vertexCount,s+=f.faceCount;let l=new Float32Array(a),c=new Uint32Array(s),T=0,h=0;for(let f of e.meshes){l.set(r.subarray(f.vertexOffset,f.vertexOffset+f.vertexCount),T);let H=t.subarray(f.faceOffset,f.faceOffset+f.faceCount),O=Math.floor(f.vertexOffset/3),b=Math.floor(T/3)-O;for(let g=0;g<H.length;g++)c[h+g]=H[g]+b;T+=f.vertexCount,h+=f.faceCount}o.setAttribute("position",new w.BufferAttribute(l,3)),o.setIndex(new w.BufferAttribute(c,1)),o.computeVertexNormals();let u=new w.Mesh(o,n[e.materialId]),p=e.meshes.map(f=>f.name).filter(f=>f&&f.length>0);u.name=p.length>0?p[0]:`merged_material_${e.materialId}`,u.castShadow=!0,u.receiveShadow=!0;let x=e.meshes.map(f=>f.metadata).filter(f=>f);return x.length>0&&(u.userData.mergedMetadata=x),u}function Re(e,r,t,n){let o=[];for(let a of e.meshes){let s=new w.BufferGeometry,l=r.subarray(a.vertexOffset,a.vertexOffset+a.vertexCount),c=t.subarray(a.faceOffset,a.faceOffset+a.faceCount),T=Math.floor(a.vertexOffset/3),h=new Uint32Array(c.length);for(let p=0;p<c.length;p++)h[p]=c[p]-T;s.setAttribute("position",new w.BufferAttribute(l,3)),s.setIndex(new w.BufferAttribute(h,1)),s.computeVertexNormals();let u=new w.Mesh(s,n[e.materialId]);u.name=a.name,a.metadata&&(u.userData={...u.userData,...a.metadata}),u.castShadow=!0,u.receiveShadow=!0,o.push(u)}return o}function Te(e){let r=Math.cos(-Math.PI/2),t=Math.sin(-Math.PI/2);for(let n=0;n<e.length;n+=3){let o=e[n],a=e[n+1],s=e[n+2];e[n]=o,e[n+1]=a*r-s*t,e[n+2]=a*t+s*r}}var P={Millimeters:1/1e3,Centimeters:1/100,Meters:1,Inches:1/39.37,Feet:1/3.28084},we="Display";async function G(e,r){let t=performance.now(),n=[],{allowScaling:o=!0,allowAutoPosition:a=!0,debug:s=!1,parsing:l={}}=_nullishCoalesce(r, () => ({}));try{let c=o?ye(e.modelunits):1;return await be(e,n,c,l,s),a&&xe(n),n}catch(c){throw He(c,n),c}finally{s&&Ce(t)}}function ye(e){return _nullishCoalesce(P[e], () => (1))}async function be(e,r,t,n,o){for(let a of e.values){let s=a.InnerTree;for(let l in s){let c=s[l];c&&await Me(c,r,t,n,o)}}}async function Me(e,r,t,n,o){for(let a of e)if(a.type.includes(we)){let s={mergeByMaterial:!0,applyTransforms:!0,debug:!1,...n},l=await z(a.data,s);if(t!==1)for(let c of l)c.scale.set(t,t,t);r.push(...l),o&&_chunkFNWG34KHcjs.j.call(void 0, ).debug(`Extracted ${l.length} meshes from batch`)}}function xe(e){if(e.length===0)return;let t=A(e).min.y;D(e,t)}function He(e,r){_chunkFNWG34KHcjs.j.call(void 0, ).error("An unexpected error occurred:",e),ve(r)}function ve(e){for(let r of e)r.geometry&&r.geometry.dispose(),r.material&&(Array.isArray(r.material)?r.material.forEach(t=>t.dispose()):r.material.dispose())}function Ce(e){let r=performance.now()-e;_chunkFNWG34KHcjs.j.call(void 0, ).info("Time to process meshes:",`${r.toFixed(2)}ms`)}exports.Materials = L; exports.SCALE_FACTORS = P; exports.getThreeMeshesFromComputeResponse = G; exports.initThree = _; exports.parseMeshBatchObject = F; exports.updateScene = N;
|
|
2
2
|
//# sourceMappingURL=visualization.cjs.map
|