@selvajs/compute 3.1.0-beta.13 → 3.1.0-beta.15
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/dist/{chunk-6R4EL3ZJ.cjs → chunk-25TNL6LY.cjs} +2 -2
- package/dist/chunk-25TNL6LY.cjs.map +1 -0
- package/dist/chunk-3QSC23Y2.cjs +120 -0
- package/dist/chunk-3QSC23Y2.cjs.map +1 -0
- package/dist/chunk-H3FZW6OX.cjs.map +1 -1
- package/dist/{chunk-6TMSTNHN.js → chunk-J4NKIVF3.js} +2 -2
- package/dist/chunk-KJVV3L5H.js +120 -0
- package/dist/chunk-KJVV3L5H.js.map +1 -0
- package/dist/core.cjs.map +1 -1
- package/dist/grasshopper.cjs +1 -1
- package/dist/grasshopper.cjs.map +1 -1
- package/dist/grasshopper.d.cts +2 -2
- package/dist/grasshopper.d.ts +2 -2
- package/dist/grasshopper.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{types-Dtok-mVq.d.ts → types-4FMvnx2j.d.ts} +14 -1
- package/dist/{types-C8XWc4Ab.d.cts → types-BpOl6U02.d.cts} +14 -1
- package/dist/visualization-2TKA3LVK.cjs +2 -0
- package/dist/visualization-2TKA3LVK.cjs.map +1 -0
- package/dist/visualization-XWX3PR4N.js +2 -0
- package/dist/visualization.cjs +1 -1
- package/dist/visualization.cjs.map +1 -1
- package/dist/visualization.d.cts +100 -9
- package/dist/visualization.d.ts +100 -9
- package/dist/visualization.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-6R4EL3ZJ.cjs.map +0 -1
- package/dist/chunk-GLOTP5TC.cjs +0 -120
- package/dist/chunk-GLOTP5TC.cjs.map +0 -1
- package/dist/chunk-NVMSD4CC.js +0 -120
- package/dist/chunk-NVMSD4CC.js.map +0 -1
- package/dist/visualization-BIHTM2KJ.js +0 -2
- package/dist/visualization-FLDYIZ3F.cjs +0 -2
- package/dist/visualization-FLDYIZ3F.cjs.map +0 -1
- /package/dist/{chunk-6TMSTNHN.js.map → chunk-J4NKIVF3.js.map} +0 -0
- /package/dist/{visualization-BIHTM2KJ.js.map → visualization-XWX3PR4N.js.map} +0 -0
package/dist/core.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["d:\\Coding\\selva\\packages\\compute\\dist\\core.cjs"],"names":[],"mappings":"AAAA,iIAA4H,8mBAAqS","file":"D:\\Coding\\selva\\packages\\compute\\dist\\core.cjs"}
|
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 _chunk25TNL6LYcjs = require('./chunk-25TNL6LY.cjs');var _chunkH3FZW6OXcjs = require('./chunk-H3FZW6OX.cjs');exports.GrasshopperClient = _chunk25TNL6LYcjs.g; exports.GrasshopperResponseProcessor = _chunk25TNL6LYcjs.h; exports.RhinoComputeError = _chunkH3FZW6OXcjs.d; exports.SolveScheduler = _chunk25TNL6LYcjs.f; exports.TreeBuilder = _chunk25TNL6LYcjs.m; exports.downloadFileData = _chunkH3FZW6OXcjs.v; exports.extractFilesFromComputeResponse = _chunkH3FZW6OXcjs.u; exports.fetchDefinitionIO = _chunk25TNL6LYcjs.k; exports.fetchParsedDefinitionIO = _chunk25TNL6LYcjs.l; exports.hashDefinition = _chunk25TNL6LYcjs.e; exports.hashSolveInput = _chunk25TNL6LYcjs.d; exports.isDefinitionRef = _chunk25TNL6LYcjs.a; exports.processInput = _chunk25TNL6LYcjs.i; exports.processInputs = _chunk25TNL6LYcjs.j; exports.solveGrasshopperDefinition = _chunk25TNL6LYcjs.b; exports.stableStringify = _chunk25TNL6LYcjs.c;
|
|
2
2
|
//# sourceMappingURL=grasshopper.cjs.map
|
package/dist/grasshopper.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["d:\\Coding\\selva\\packages\\compute\\dist\\grasshopper.cjs"],"names":[],"mappings":"AAAA,iIAA4H,wDAAuD,0xBAAmY","file":"D:\\Coding\\selva\\packages\\compute\\dist\\grasshopper.cjs"}
|
package/dist/grasshopper.d.cts
CHANGED
|
@@ -2,8 +2,8 @@ import { R as RhinoComputeError, C as ComputeServerStats, F as FileBaseInfo } fr
|
|
|
2
2
|
export { b as FileData, P as ProcessedFile, d as downloadFileData, e as extractFilesFromComputeResponse } from './handle-files-BISo_wob.cjs';
|
|
3
3
|
import { R as RetryPolicy, C as ComputeConfig } from './types-BGhtYxZ-.cjs';
|
|
4
4
|
export { a as RhinoModelUnit } from './types-BGhtYxZ-.cjs';
|
|
5
|
-
import { f as GrasshopperComputeResponse, a as DataTree, e as GrasshopperComputeConfig, g as GrasshopperParsedIO, h as GrasshopperParsedIORaw, m as MeshExtractionOptions, k as InputParamSchema, j as InputParam, b as DataTreeDefault, c as DataTreePath } from './types-
|
|
6
|
-
export { B as BooleanInputType, D as DataItem, d as DefaultValue, F as FileInputType, G as GeometryInputType, i as GrasshopperRequestSchema, I as InnerTreeData, N as NumericInputType, O as OutputParamSchema, l as OutputType, T as TextInputType, V as ValueListInputType } from './types-
|
|
5
|
+
import { f as GrasshopperComputeResponse, a as DataTree, e as GrasshopperComputeConfig, g as GrasshopperParsedIO, h as GrasshopperParsedIORaw, m as MeshExtractionOptions, k as InputParamSchema, j as InputParam, b as DataTreeDefault, c as DataTreePath } from './types-BpOl6U02.cjs';
|
|
6
|
+
export { B as BooleanInputType, D as DataItem, d as DefaultValue, F as FileInputType, G as GeometryInputType, i as GrasshopperRequestSchema, I as InnerTreeData, N as NumericInputType, O as OutputParamSchema, l as OutputType, T as TextInputType, V as ValueListInputType } from './types-BpOl6U02.cjs';
|
|
7
7
|
import * as THREE from 'three';
|
|
8
8
|
import 'rhino3dm';
|
|
9
9
|
|
package/dist/grasshopper.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { R as RhinoComputeError, C as ComputeServerStats, F as FileBaseInfo } fr
|
|
|
2
2
|
export { b as FileData, P as ProcessedFile, d as downloadFileData, e as extractFilesFromComputeResponse } from './handle-files-BISo_wob.js';
|
|
3
3
|
import { R as RetryPolicy, C as ComputeConfig } from './types-BGhtYxZ-.js';
|
|
4
4
|
export { a as RhinoModelUnit } from './types-BGhtYxZ-.js';
|
|
5
|
-
import { f as GrasshopperComputeResponse, a as DataTree, e as GrasshopperComputeConfig, g as GrasshopperParsedIO, h as GrasshopperParsedIORaw, m as MeshExtractionOptions, k as InputParamSchema, j as InputParam, b as DataTreeDefault, c as DataTreePath } from './types-
|
|
6
|
-
export { B as BooleanInputType, D as DataItem, d as DefaultValue, F as FileInputType, G as GeometryInputType, i as GrasshopperRequestSchema, I as InnerTreeData, N as NumericInputType, O as OutputParamSchema, l as OutputType, T as TextInputType, V as ValueListInputType } from './types-
|
|
5
|
+
import { f as GrasshopperComputeResponse, a as DataTree, e as GrasshopperComputeConfig, g as GrasshopperParsedIO, h as GrasshopperParsedIORaw, m as MeshExtractionOptions, k as InputParamSchema, j as InputParam, b as DataTreeDefault, c as DataTreePath } from './types-4FMvnx2j.js';
|
|
6
|
+
export { B as BooleanInputType, D as DataItem, d as DefaultValue, F as FileInputType, G as GeometryInputType, i as GrasshopperRequestSchema, I as InnerTreeData, N as NumericInputType, O as OutputParamSchema, l as OutputType, T as TextInputType, V as ValueListInputType } from './types-4FMvnx2j.js';
|
|
7
7
|
import * as THREE from 'three';
|
|
8
8
|
import 'rhino3dm';
|
|
9
9
|
|
package/dist/grasshopper.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as d,b as e,c as f,d as g,e as h,f as i,g as j,h as k,i as l,j as m,k as n,l as o,m as p}from"./chunk-
|
|
1
|
+
import{a as d,b as e,c as f,d as g,e as h,f as i,g as j,h as k,i as l,j as m,k as n,l as o,m as p}from"./chunk-J4NKIVF3.js";import{d as a,u as b,v as c}from"./chunk-Y3M7P3BW.js";export{j as GrasshopperClient,k as GrasshopperResponseProcessor,a as RhinoComputeError,i as SolveScheduler,p as TreeBuilder,c as downloadFileData,b as extractFilesFromComputeResponse,n as fetchDefinitionIO,o as fetchParsedDefinitionIO,h as hashDefinition,g as hashSolveInput,d as isDefinitionRef,l as processInput,m as processInputs,e as solveGrasshopperDefinition,f as stableStringify};
|
|
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 _chunk25TNL6LYcjs = require('./chunk-25TNL6LY.cjs');var _chunkH3FZW6OXcjs = require('./chunk-H3FZW6OX.cjs');exports.ComputeServerStats = _chunkH3FZW6OXcjs.p; exports.ErrorCodes = _chunkH3FZW6OXcjs.c; exports.GrasshopperClient = _chunk25TNL6LYcjs.g; exports.GrasshopperResponseProcessor = _chunk25TNL6LYcjs.h; exports.RhinoComputeError = _chunkH3FZW6OXcjs.d; exports.SolveScheduler = _chunk25TNL6LYcjs.f; exports.TreeBuilder = _chunk25TNL6LYcjs.m; exports.camelcaseKeys = _chunkH3FZW6OXcjs.r; exports.downloadFileData = _chunkH3FZW6OXcjs.v; exports.enableDebugLogging = _chunkH3FZW6OXcjs.g; exports.extractFilesFromComputeResponse = _chunkH3FZW6OXcjs.u; exports.fetchDefinitionIO = _chunk25TNL6LYcjs.k; exports.fetchParsedDefinitionIO = _chunk25TNL6LYcjs.l; exports.fetchRhinoCompute = _chunkH3FZW6OXcjs.n; exports.getLogger = _chunkH3FZW6OXcjs.e; exports.getResponseWireSize = _chunkH3FZW6OXcjs.m; exports.hashDefinition = _chunk25TNL6LYcjs.e; exports.hashSolveInput = _chunk25TNL6LYcjs.d; exports.isDefinitionRef = _chunk25TNL6LYcjs.a; exports.processInput = _chunk25TNL6LYcjs.i; exports.processInputs = _chunk25TNL6LYcjs.j; exports.setLogger = _chunkH3FZW6OXcjs.f; exports.setResponseWireSize = _chunkH3FZW6OXcjs.l; exports.solveGrasshopperDefinition = _chunk25TNL6LYcjs.b; exports.stableStringify = _chunk25TNL6LYcjs.c; exports.toCamelCase = _chunkH3FZW6OXcjs.q;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["d:\\Coding\\selva\\packages\\compute\\dist\\index.cjs"],"names":[],"mappings":"AAAA,iIAA4H,wDAAmH,yuCAA8kB","file":"D:\\Coding\\selva\\packages\\compute\\dist\\index.cjs"}
|
package/dist/index.d.cts
CHANGED
|
@@ -2,6 +2,6 @@ export { Logger, camelcaseKeys, enableDebugLogging, fetchRhinoCompute, getLogger
|
|
|
2
2
|
export { C as ComputeServerStats, E as ErrorCode, a as ErrorCodes, F as FileBaseInfo, b as FileData, P as ProcessedFile, R as RhinoComputeError, d as downloadFileData, e as extractFilesFromComputeResponse } from './handle-files-BISo_wob.cjs';
|
|
3
3
|
export { C as ComputeConfig, R as RetryPolicy, a as RhinoModelUnit, S as ServerTiming } from './types-BGhtYxZ-.cjs';
|
|
4
4
|
export { CacheOptions, DataTreeValue, DefinitionRef, GetValuesOptions, GetValuesResult, GrasshopperClient, GrasshopperResponseProcessor, ParsedContext, SchedulerMode, SolveContext, SolveDefinition, SolveOptions, SolveResult, SolveScheduler, SolveSchedulerOptions, TreeBuilder, fetchDefinitionIO, fetchParsedDefinitionIO, hashDefinition, hashSolveInput, isDefinitionRef, processInput, processInputs, solveGrasshopperDefinition, stableStringify } from './grasshopper.cjs';
|
|
5
|
-
export { B as BooleanInputType, D as DataItem, a as DataTree, b as DataTreeDefault, c as DataTreePath, d as DefaultValue, F as FileInputType, G as GeometryInputType, e as GrasshopperComputeConfig, f as GrasshopperComputeResponse, g as GrasshopperParsedIO, h as GrasshopperParsedIORaw, i as GrasshopperRequestSchema, I as InnerTreeData, j as InputParam, k as InputParamSchema, N as NumericInputType, O as OutputParamSchema, l as OutputType, T as TextInputType, V as ValueListInputType } from './types-
|
|
5
|
+
export { B as BooleanInputType, D as DataItem, a as DataTree, b as DataTreeDefault, c as DataTreePath, d as DefaultValue, F as FileInputType, G as GeometryInputType, e as GrasshopperComputeConfig, f as GrasshopperComputeResponse, g as GrasshopperParsedIO, h as GrasshopperParsedIORaw, i as GrasshopperRequestSchema, I as InnerTreeData, j as InputParam, k as InputParamSchema, N as NumericInputType, O as OutputParamSchema, l as OutputType, T as TextInputType, V as ValueListInputType } from './types-BpOl6U02.cjs';
|
|
6
6
|
import 'three';
|
|
7
7
|
import 'rhino3dm';
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ export { Logger, camelcaseKeys, enableDebugLogging, fetchRhinoCompute, getLogger
|
|
|
2
2
|
export { C as ComputeServerStats, E as ErrorCode, a as ErrorCodes, F as FileBaseInfo, b as FileData, P as ProcessedFile, R as RhinoComputeError, d as downloadFileData, e as extractFilesFromComputeResponse } from './handle-files-BISo_wob.js';
|
|
3
3
|
export { C as ComputeConfig, R as RetryPolicy, a as RhinoModelUnit, S as ServerTiming } from './types-BGhtYxZ-.js';
|
|
4
4
|
export { CacheOptions, DataTreeValue, DefinitionRef, GetValuesOptions, GetValuesResult, GrasshopperClient, GrasshopperResponseProcessor, ParsedContext, SchedulerMode, SolveContext, SolveDefinition, SolveOptions, SolveResult, SolveScheduler, SolveSchedulerOptions, TreeBuilder, fetchDefinitionIO, fetchParsedDefinitionIO, hashDefinition, hashSolveInput, isDefinitionRef, processInput, processInputs, solveGrasshopperDefinition, stableStringify } from './grasshopper.js';
|
|
5
|
-
export { B as BooleanInputType, D as DataItem, a as DataTree, b as DataTreeDefault, c as DataTreePath, d as DefaultValue, F as FileInputType, G as GeometryInputType, e as GrasshopperComputeConfig, f as GrasshopperComputeResponse, g as GrasshopperParsedIO, h as GrasshopperParsedIORaw, i as GrasshopperRequestSchema, I as InnerTreeData, j as InputParam, k as InputParamSchema, N as NumericInputType, O as OutputParamSchema, l as OutputType, T as TextInputType, V as ValueListInputType } from './types-
|
|
5
|
+
export { B as BooleanInputType, D as DataItem, a as DataTree, b as DataTreeDefault, c as DataTreePath, d as DefaultValue, F as FileInputType, G as GeometryInputType, e as GrasshopperComputeConfig, f as GrasshopperComputeResponse, g as GrasshopperParsedIO, h as GrasshopperParsedIORaw, i as GrasshopperRequestSchema, I as InnerTreeData, j as InputParam, k as InputParamSchema, N as NumericInputType, O as OutputParamSchema, l as OutputType, T as TextInputType, V as ValueListInputType } from './types-4FMvnx2j.js';
|
|
6
6
|
import 'three';
|
|
7
7
|
import 'rhino3dm';
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as h,b as i,c as j,d as k,e as l,f as n,g as q,h as s,i as u,j as v,k as w,l as y,m as z}from"./chunk-
|
|
1
|
+
import{a as h,b as i,c as j,d as k,e as l,f as n,g as q,h as s,i as u,j as v,k as w,l as y,m as z}from"./chunk-J4NKIVF3.js";import{c as o,d as r,e,f,g as m,l as p,m as t,n as x,p as a,q as b,r as c,u as d,v as g}from"./chunk-Y3M7P3BW.js";export{a as ComputeServerStats,o as ErrorCodes,q as GrasshopperClient,s as GrasshopperResponseProcessor,r as RhinoComputeError,n as SolveScheduler,z as TreeBuilder,c as camelcaseKeys,g as downloadFileData,m as enableDebugLogging,d as extractFilesFromComputeResponse,w as fetchDefinitionIO,y as fetchParsedDefinitionIO,x as fetchRhinoCompute,e as getLogger,t as getResponseWireSize,l as hashDefinition,k as hashSolveInput,h as isDefinitionRef,u as processInput,v as processInputs,f as setLogger,p as setResponseWireSize,i as solveGrasshopperDefinition,j as stableStringify,b as toCamelCase};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -529,8 +529,21 @@ interface MeshExtractionOptions {
|
|
|
529
529
|
parsing?: MeshBatchParsingOptions;
|
|
530
530
|
/** Apply scaling based on model units. Defaults to true. */
|
|
531
531
|
allowScaling?: boolean;
|
|
532
|
-
/**
|
|
532
|
+
/**
|
|
533
|
+
* Drop geometry so its lowest point sits on the ground plane. **Defaults to `false`** — content
|
|
534
|
+
* renders at its true Rhino coordinates, so the viewer matches the Grasshopper definition.
|
|
535
|
+
*
|
|
536
|
+
* Set `true` to always seat the model on the grid regardless of where it sits in Rhino. Note
|
|
537
|
+
* this shifts objects, so anything read back out of the scene (bounds, measured or picked
|
|
538
|
+
* positions) no longer corresponds to the model's Rhino coordinates.
|
|
539
|
+
*/
|
|
533
540
|
allowAutoPosition?: boolean;
|
|
541
|
+
/**
|
|
542
|
+
* The scene's up axis, used by the `allowAutoPosition` grounding to decide which component to
|
|
543
|
+
* drop to zero. Defaults to `'z'` — the frame Rhino geometry arrives in. Only set this if the
|
|
544
|
+
* viewer is configured with a non-default `sceneUp`.
|
|
545
|
+
*/
|
|
546
|
+
groundAxis?: 'x' | 'y' | 'z';
|
|
534
547
|
/**
|
|
535
548
|
* rhino3dm instance for decoding curve display items. selva-compute does not own the WASM
|
|
536
549
|
* instance; the host threads it in. Omit to skip curves (points still render).
|
|
@@ -529,8 +529,21 @@ interface MeshExtractionOptions {
|
|
|
529
529
|
parsing?: MeshBatchParsingOptions;
|
|
530
530
|
/** Apply scaling based on model units. Defaults to true. */
|
|
531
531
|
allowScaling?: boolean;
|
|
532
|
-
/**
|
|
532
|
+
/**
|
|
533
|
+
* Drop geometry so its lowest point sits on the ground plane. **Defaults to `false`** — content
|
|
534
|
+
* renders at its true Rhino coordinates, so the viewer matches the Grasshopper definition.
|
|
535
|
+
*
|
|
536
|
+
* Set `true` to always seat the model on the grid regardless of where it sits in Rhino. Note
|
|
537
|
+
* this shifts objects, so anything read back out of the scene (bounds, measured or picked
|
|
538
|
+
* positions) no longer corresponds to the model's Rhino coordinates.
|
|
539
|
+
*/
|
|
533
540
|
allowAutoPosition?: boolean;
|
|
541
|
+
/**
|
|
542
|
+
* The scene's up axis, used by the `allowAutoPosition` grounding to decide which component to
|
|
543
|
+
* drop to zero. Defaults to `'z'` — the frame Rhino geometry arrives in. Only set this if the
|
|
544
|
+
* viewer is configured with a non-default `sceneUp`.
|
|
545
|
+
*/
|
|
546
|
+
groundAxis?: 'x' | 'y' | 'z';
|
|
534
547
|
/**
|
|
535
548
|
* rhino3dm instance for decoding curve display items. selva-compute does not own the WASM
|
|
536
549
|
* instance; the host threads it in. Omit to skip curves (points still render).
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk3QSC23Y2cjs = require('./chunk-3QSC23Y2.cjs');require('./chunk-H3FZW6OX.cjs');exports.BINARY_MESH_MAGIC = _chunk3QSC23Y2cjs.F; exports.BINARY_MESH_VERSION = _chunk3QSC23Y2cjs.H; exports.COMPRESSED_MESH_MAGIC = _chunk3QSC23Y2cjs.G; exports.EDGES_SKIPPED_TRIANGLE_CAP = _chunk3QSC23Y2cjs.o; exports.EDGE_USERDATA_KIND = _chunk3QSC23Y2cjs.n; exports.FLAG_DELTA_ENCODED = _chunk3QSC23Y2cjs.L; exports.FLAG_FLOAT32 = _chunk3QSC23Y2cjs.J; exports.FLAG_HAS_UVS = _chunk3QSC23Y2cjs.M; exports.FLAG_HAS_VERTEX_COLORS = _chunk3QSC23Y2cjs.N; exports.FLAG_UINT16_INDICES = _chunk3QSC23Y2cjs.K; exports.LOOKS = _chunk3QSC23Y2cjs.D; exports.MIN_SUPPORTED_VERSION = _chunk3QSC23Y2cjs.I; exports.Materials = _chunk3QSC23Y2cjs.a; exports.SCALE_FACTORS = _chunk3QSC23Y2cjs.U; exports.TEXTURE_CACHE_MAX_ENTRIES = _chunk3QSC23Y2cjs.y; exports.UV_FORMAT_FLOAT32 = _chunk3QSC23Y2cjs.P; exports.UV_FORMAT_UINT16 = _chunk3QSC23Y2cjs.O; exports.addEdges = _chunk3QSC23Y2cjs.q; exports.addEdgesAsync = _chunk3QSC23Y2cjs.r; exports.applyOffset = _chunk3QSC23Y2cjs.i; exports.buildUpBasis = _chunk3QSC23Y2cjs.b; exports.clearTextureCache = _chunk3QSC23Y2cjs.A; exports.computeCombinedBoundingBox = _chunk3QSC23Y2cjs.j; exports.createCameraController = _chunk3QSC23Y2cjs.k; exports.createGrid = _chunk3QSC23Y2cjs.l; exports.createLabelLayer = _chunk3QSC23Y2cjs.v; exports.createMeasureTool = _chunk3QSC23Y2cjs.x; exports.createRenderPipeline = _chunk3QSC23Y2cjs.u; exports.createViewGizmo = _chunk3QSC23Y2cjs.m; exports.environmentRotationFor = _chunk3QSC23Y2cjs.e; exports.getThreeMeshesFromComputeResponse = _chunk3QSC23Y2cjs.V; exports.initThree = _chunk3QSC23Y2cjs.C; exports.isEdgeOverlay = _chunk3QSC23Y2cjs.p; exports.isoOffset = _chunk3QSC23Y2cjs.c; exports.materialAppearanceForLook = _chunk3QSC23Y2cjs.B; exports.parseBinaryMeshBatch = _chunk3QSC23Y2cjs.Q; exports.parseColor = _chunk3QSC23Y2cjs.h; exports.parseDisplayItems = _chunk3QSC23Y2cjs.E; exports.parseMeshBatch = _chunk3QSC23Y2cjs.R; exports.parseMeshBatchBlob = _chunk3QSC23Y2cjs.T; exports.parseMeshBatchObject = _chunk3QSC23Y2cjs.S; exports.removeEdges = _chunk3QSC23Y2cjs.s; exports.setTextureAnisotropy = _chunk3QSC23Y2cjs.z; exports.snapToVertex = _chunk3QSC23Y2cjs.w; exports.sunOffset = _chunk3QSC23Y2cjs.d; exports.upToAxis = _chunk3QSC23Y2cjs.f; exports.updateScene = _chunk3QSC23Y2cjs.g;
|
|
2
|
+
//# sourceMappingURL=visualization-2TKA3LVK.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["d:\\Coding\\selva\\packages\\compute\\dist\\visualization-2TKA3LVK.cjs"],"names":[],"mappings":"AAAA,iIAA0W,gCAA6B,qtEAAwhC","file":"D:\\Coding\\selva\\packages\\compute\\dist\\visualization-2TKA3LVK.cjs"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{A as j,B as S,C as I,D as L,E as R,F as D,G as B,H as G,I as u,J as P,K as F,L as b,M as N,N as U,O as V,P as v,Q as H,R as w,S as z,T as k,U as K,V as X,a as e,b as r,c as o,d as t,e as s,f as a,g as p,h as i,i as n,j as m,k as l,l as f,m as y,n as x,o as E,p as d,q as C,r as h,s as M,u as _,v as A,w as O,x as c,y as g,z as T}from"./chunk-KJVV3L5H.js";import"./chunk-Y3M7P3BW.js";export{D as BINARY_MESH_MAGIC,G as BINARY_MESH_VERSION,B as COMPRESSED_MESH_MAGIC,E as EDGES_SKIPPED_TRIANGLE_CAP,x as EDGE_USERDATA_KIND,b as FLAG_DELTA_ENCODED,P as FLAG_FLOAT32,N as FLAG_HAS_UVS,U as FLAG_HAS_VERTEX_COLORS,F as FLAG_UINT16_INDICES,L as LOOKS,u as MIN_SUPPORTED_VERSION,e as Materials,K as SCALE_FACTORS,g as TEXTURE_CACHE_MAX_ENTRIES,v as UV_FORMAT_FLOAT32,V as UV_FORMAT_UINT16,C as addEdges,h as addEdgesAsync,n as applyOffset,r as buildUpBasis,j as clearTextureCache,m as computeCombinedBoundingBox,l as createCameraController,f as createGrid,A as createLabelLayer,c as createMeasureTool,_ as createRenderPipeline,y as createViewGizmo,s as environmentRotationFor,X as getThreeMeshesFromComputeResponse,I as initThree,d as isEdgeOverlay,o as isoOffset,S as materialAppearanceForLook,H as parseBinaryMeshBatch,i as parseColor,R as parseDisplayItems,w as parseMeshBatch,k as parseMeshBatchBlob,z as parseMeshBatchObject,M as removeEdges,T as setTextureAnisotropy,O as snapToVertex,t as sunOffset,a as upToAxis,p as updateScene};
|
|
2
|
+
//# sourceMappingURL=visualization-XWX3PR4N.js.map
|
package/dist/visualization.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 _chunk3QSC23Y2cjs = require('./chunk-3QSC23Y2.cjs');require('./chunk-H3FZW6OX.cjs');exports.EDGES_SKIPPED_TRIANGLE_CAP = _chunk3QSC23Y2cjs.o; exports.EDGE_USERDATA_KIND = _chunk3QSC23Y2cjs.n; exports.EdgeDetectionPass = _chunk3QSC23Y2cjs.t; exports.LOOKS = _chunk3QSC23Y2cjs.D; exports.Materials = _chunk3QSC23Y2cjs.a; exports.SCALE_FACTORS = _chunk3QSC23Y2cjs.U; exports.addEdges = _chunk3QSC23Y2cjs.q; exports.addEdgesAsync = _chunk3QSC23Y2cjs.r; exports.applyOffset = _chunk3QSC23Y2cjs.i; exports.buildUpBasis = _chunk3QSC23Y2cjs.b; exports.computeCombinedBoundingBox = _chunk3QSC23Y2cjs.j; exports.createCameraController = _chunk3QSC23Y2cjs.k; exports.createGrid = _chunk3QSC23Y2cjs.l; exports.createLabelLayer = _chunk3QSC23Y2cjs.v; exports.createMeasureTool = _chunk3QSC23Y2cjs.x; exports.createRenderPipeline = _chunk3QSC23Y2cjs.u; exports.createViewGizmo = _chunk3QSC23Y2cjs.m; exports.environmentRotationFor = _chunk3QSC23Y2cjs.e; exports.getThreeMeshesFromComputeResponse = _chunk3QSC23Y2cjs.V; exports.initThree = _chunk3QSC23Y2cjs.C; exports.isEdgeOverlay = _chunk3QSC23Y2cjs.p; exports.isoOffset = _chunk3QSC23Y2cjs.c; exports.parseColor = _chunk3QSC23Y2cjs.h; exports.parseDisplayItems = _chunk3QSC23Y2cjs.E; exports.parseMeshBatchBlob = _chunk3QSC23Y2cjs.T; exports.parseMeshBatchObject = _chunk3QSC23Y2cjs.S; exports.removeEdges = _chunk3QSC23Y2cjs.s; exports.snapToVertex = _chunk3QSC23Y2cjs.w; exports.sunOffset = _chunk3QSC23Y2cjs.d; exports.upToAxis = _chunk3QSC23Y2cjs.f; exports.updateScene = _chunk3QSC23Y2cjs.g;
|
|
2
2
|
//# sourceMappingURL=visualization.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["d:\\Coding\\selva\\packages\\compute\\dist\\visualization.cjs"],"names":[],"mappings":"AAAA,iIAAqP,gCAA6B,26CAA8oB","file":"D:\\Coding\\selva\\packages\\compute\\dist\\visualization.cjs"}
|
package/dist/visualization.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
|
|
3
|
-
import { M as MaterialAppearanceOptions, f as GrasshopperComputeResponse, m as MeshExtractionOptions, n as MeshBatchParsingOptions, o as DisplayBatch, p as DisplayItem } from './types-
|
|
4
|
-
export { q as DisplayCurve, r as DisplayIdentity, s as DisplayItemBase, t as DisplayPoint, u as DisplayPosition, v as MeshBatch } from './types-
|
|
3
|
+
import { M as MaterialAppearanceOptions, f as GrasshopperComputeResponse, m as MeshExtractionOptions, n as MeshBatchParsingOptions, o as DisplayBatch, p as DisplayItem } from './types-BpOl6U02.cjs';
|
|
4
|
+
export { q as DisplayCurve, r as DisplayIdentity, s as DisplayItemBase, t as DisplayPoint, u as DisplayPosition, v as MeshBatch } from './types-BpOl6U02.cjs';
|
|
5
5
|
import { CSS2DObject } from 'three/addons/renderers/CSS2DRenderer.js';
|
|
6
6
|
import { LineSegments2 } from 'three/addons/lines/LineSegments2.js';
|
|
7
7
|
import { Pass } from 'three/addons/postprocessing/Pass.js';
|
|
@@ -48,6 +48,15 @@ type EnvironmentConfig = {
|
|
|
48
48
|
hdrPath?: string;
|
|
49
49
|
backgroundColor?: THREE.Color | string;
|
|
50
50
|
enableEnvironmentLighting?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* The scene's up axis. **Defaults to `(0, 0, 1)` — Rhino's Z-up**, not Three's native Y-up,
|
|
53
|
+
* because geometry arrives in Rhino's frame and is never rotated on ingress (see
|
|
54
|
+
* `coordinate-transform.ts`). Everything orientation-dependent derives from this: view presets,
|
|
55
|
+
* the default iso camera, sun position, grid plane, floor normal, and the hemisphere light.
|
|
56
|
+
*
|
|
57
|
+
* Overriding it reorients the viewer but does NOT rotate incoming geometry, so a Y-up value only
|
|
58
|
+
* makes sense if the host also feeds Y-up geometry.
|
|
59
|
+
*/
|
|
51
60
|
sceneUp?: THREE.Vector3;
|
|
52
61
|
showEnvironment?: boolean;
|
|
53
62
|
/**
|
|
@@ -172,7 +181,11 @@ type GridConfig = {
|
|
|
172
181
|
majorColor?: THREE.ColorRepresentation;
|
|
173
182
|
/** World radius at which the grid fully fades. Default 100. */
|
|
174
183
|
fadeDistance?: number;
|
|
175
|
-
/**
|
|
184
|
+
/**
|
|
185
|
+
* Axis the grid lies perpendicular to — the scene's up axis. Defaults to whichever axis
|
|
186
|
+
* `sceneUp` points along, so it is `'z'` (Rhino's horizontal ground) unless you override
|
|
187
|
+
* `sceneUp`. Set explicitly only to force a grid orientation that ignores the scene up.
|
|
188
|
+
*/
|
|
176
189
|
plane?: 'x' | 'y' | 'z';
|
|
177
190
|
};
|
|
178
191
|
/** Corner nav-cube/axis gizmo that snaps to preset views. See `createViewGizmo`. */
|
|
@@ -309,7 +322,8 @@ interface CameraControllerDeps {
|
|
|
309
322
|
/**
|
|
310
323
|
* The scene's up axis. Presets, the orthographic camera's up, and the iso direction are all derived
|
|
311
324
|
* from this so the controller is correct in any up convention (Three's native Y-up, Rhino's Z-up, …)
|
|
312
|
-
* without hardcoding an axis.
|
|
325
|
+
* without hardcoding an axis. Falls back to `perspective.up` when omitted; `initThree` always
|
|
326
|
+
* passes the configured `sceneUp`, which itself defaults to Rhino's Z-up.
|
|
313
327
|
*/
|
|
314
328
|
up?: THREE.Vector3;
|
|
315
329
|
}
|
|
@@ -337,7 +351,13 @@ interface GridOptions {
|
|
|
337
351
|
majorColor?: THREE.ColorRepresentation;
|
|
338
352
|
/** World-space radius at which the grid has fully faded out. Default 100. */
|
|
339
353
|
fadeDistance?: number;
|
|
340
|
-
/**
|
|
354
|
+
/**
|
|
355
|
+
* Axis the grid is laid perpendicular to — i.e. the scene's up axis. `'z'` is the horizontal
|
|
356
|
+
* ground in the Rhino Z-up frame the viewer uses; `'y'` is Three's native Y-up.
|
|
357
|
+
*
|
|
358
|
+
* This standalone default is `'y'`, but `initThree` always passes a plane derived from the
|
|
359
|
+
* configured `sceneUp`, so a viewer-created grid defaults to `'z'`.
|
|
360
|
+
*/
|
|
341
361
|
plane?: 'x' | 'y' | 'z';
|
|
342
362
|
}
|
|
343
363
|
interface Grid {
|
|
@@ -624,7 +644,8 @@ declare function updateScene(scene: THREE.Scene, meshes: THREE.Object3D[], camer
|
|
|
624
644
|
declare function parseColor(colorString: string): THREE.Color;
|
|
625
645
|
/**
|
|
626
646
|
* Shift objects along one world axis. Defaults to `z` — the up axis of the unified Z-up scene
|
|
627
|
-
* frame (see `../coordinate-transform.ts`), so grounding subtracts the content's lowest z.
|
|
647
|
+
* frame (see `../coordinate-transform.ts`), so grounding subtracts the content's lowest z. Pass an
|
|
648
|
+
* explicit axis when the scene is configured with a different `sceneUp`.
|
|
628
649
|
*/
|
|
629
650
|
declare function applyOffset(meshes: THREE.Object3D[], offset: number, axis?: 'x' | 'y' | 'z'): void;
|
|
630
651
|
/**
|
|
@@ -655,6 +676,76 @@ declare namespace threeMaterials {
|
|
|
655
676
|
export { threeMaterials_CONCRETE_MATERIAL as CONCRETE_MATERIAL, threeMaterials_EMISSIVE_MATERIAL as EMISSIVE_MATERIAL, threeMaterials_GLASS_MATERIAL as GLASS_MATERIAL, threeMaterials_METAL_MATERIAL as METAL_MATERIAL, threeMaterials_PLASTIC_MATERIAL as PLASTIC_MATERIAL, threeMaterials_RUBBER_MATERIAL as RUBBER_MATERIAL, threeMaterials_SHARED_MATERIALS as SHARED_MATERIALS, threeMaterials_WOOD_MATERIAL as WOOD_MATERIAL };
|
|
656
677
|
}
|
|
657
678
|
|
|
679
|
+
/**
|
|
680
|
+
* The single source of truth for "which way is up, and what do front/right mean" in the viewer.
|
|
681
|
+
*
|
|
682
|
+
* Every up-dependent default (camera framing, sun position, ground offset, view presets) derives
|
|
683
|
+
* from {@link buildUpBasis} instead of hardcoding an axis. Before this module those defaults each
|
|
684
|
+
* spelled out a Z-up vector inline, so a scene configured Y-up got a below-horizon camera and a
|
|
685
|
+
* near-horizontal sun while the presets and floor correctly followed `sceneUp`.
|
|
686
|
+
*
|
|
687
|
+
* ## Why front is -forward
|
|
688
|
+
*
|
|
689
|
+
* The basis returns `forward` = the direction the camera LOOKS (from camera toward model), and the
|
|
690
|
+
* preset positions are the opposite (from target toward camera). Rhino's convention fixes the signs:
|
|
691
|
+
* its Front view looks along +Y, so the camera sits at -Y; its Right view looks along -X, so the
|
|
692
|
+
* camera sits at +X. Deriving `right` as `seed x up` (rather than `up x seed`) is what makes the
|
|
693
|
+
* handedness come out matching Rhino rather than mirrored.
|
|
694
|
+
*/
|
|
695
|
+
/** An orthonormal frame derived from a scene up axis. All vectors are unit length. */
|
|
696
|
+
interface UpBasis {
|
|
697
|
+
/** The scene up axis, normalized. */
|
|
698
|
+
up: THREE.Vector3;
|
|
699
|
+
/** The direction a "front" view looks along (from camera toward the model). */
|
|
700
|
+
forward: THREE.Vector3;
|
|
701
|
+
/** Completes a right-handed frame with `up` and `forward`. */
|
|
702
|
+
right: THREE.Vector3;
|
|
703
|
+
}
|
|
704
|
+
/**
|
|
705
|
+
* Derive the ground-plane axes for a given up vector.
|
|
706
|
+
*
|
|
707
|
+
* The seed picks whichever world axis is least parallel to `up`, so the cross products stay
|
|
708
|
+
* well-conditioned in any up convention. For Rhino's Z-up this yields forward = +Y and right = +X,
|
|
709
|
+
* matching Rhino's own Front/Right views; for Three's native Y-up it yields forward = -Z and
|
|
710
|
+
* right = +X, matching Three's convention that the default camera looks down -Z.
|
|
711
|
+
*/
|
|
712
|
+
declare function buildUpBasis(up: THREE.Vector3): UpBasis;
|
|
713
|
+
/**
|
|
714
|
+
* The default 3/4 iso camera OFFSET from the target, scaled to `distance`.
|
|
715
|
+
*
|
|
716
|
+
* Placed behind-left and above the model (the conventional architectural 3/4), expressed in the
|
|
717
|
+
* scene's own basis so it reads the same in any up convention. Callers add this to the framing
|
|
718
|
+
* target to get a camera position.
|
|
719
|
+
*/
|
|
720
|
+
declare function isoOffset(up: THREE.Vector3, distance: number): THREE.Vector3;
|
|
721
|
+
/**
|
|
722
|
+
* A default sun position: high above the model, offset to one side so surfaces get a directional
|
|
723
|
+
* gradient instead of flat top-down light. Expressed in the scene basis rather than a literal
|
|
724
|
+
* Z-up vector, so a Y-up scene still gets an overhead sun rather than a horizontal one.
|
|
725
|
+
*/
|
|
726
|
+
declare function sunOffset(up: THREE.Vector3, sideDistance: number, height: number): THREE.Vector3;
|
|
727
|
+
/**
|
|
728
|
+
* The rotation that puts an equirectangular environment map's horizon on the scene's ground plane.
|
|
729
|
+
*
|
|
730
|
+
* Three's equirect mapping is hardcoded to Y-up: it assumes the HDR's horizon lies in the XZ plane
|
|
731
|
+
* and its zenith points along +Y. In a Z-up scene that leaves the environment on its side — the
|
|
732
|
+
* horizon runs vertically and image-based lighting arrives from +Y rather than from overhead. The
|
|
733
|
+
* result is a subtly wrong key direction that a neutral studio HDR hides but any sky/ground HDR
|
|
734
|
+
* makes obvious.
|
|
735
|
+
*
|
|
736
|
+
* Returns the Euler that rotates the map's native +Y zenith onto `up`. Identity for a Y-up scene.
|
|
737
|
+
* Apply to BOTH `scene.environmentRotation` and `scene.backgroundRotation` — they are independent
|
|
738
|
+
* properties, and setting only one makes the visible background disagree with the lighting.
|
|
739
|
+
*/
|
|
740
|
+
declare function environmentRotationFor(up: THREE.Vector3): THREE.Euler;
|
|
741
|
+
/**
|
|
742
|
+
* Which world axis (`'x' | 'y' | 'z'`) the up vector most closely aligns with.
|
|
743
|
+
*
|
|
744
|
+
* Used for the grid plane and for the ground-offset axis — both need a single component index
|
|
745
|
+
* rather than a full vector. An off-axis up vector resolves to its dominant component.
|
|
746
|
+
*/
|
|
747
|
+
declare function upToAxis(up: THREE.Vector3): 'x' | 'y' | 'z';
|
|
748
|
+
|
|
658
749
|
/**
|
|
659
750
|
* Crisp boundary/crease edges overlaid on meshes — the defining "technical drawing" look that makes
|
|
660
751
|
* shaded geometry read as discrete objects rather than blobs.
|
|
@@ -910,11 +1001,11 @@ declare const SCALE_FACTORS: Record<string, number>;
|
|
|
910
1001
|
* // With debugging enabled
|
|
911
1002
|
* const meshes = await getThreeMeshesFromComputeResponse(response, { debug: true });
|
|
912
1003
|
*
|
|
913
|
-
* //
|
|
1004
|
+
* // Opt in to seating the model on the grid instead of using its Rhino coordinates
|
|
914
1005
|
* const meshes = await getThreeMeshesFromComputeResponse(response, {
|
|
915
1006
|
* debug: true,
|
|
916
1007
|
* allowScaling: true,
|
|
917
|
-
* allowAutoPosition:
|
|
1008
|
+
* allowAutoPosition: true,
|
|
918
1009
|
* parsing: {
|
|
919
1010
|
* mergeByMaterial: false,
|
|
920
1011
|
* applyTransforms: true,
|
|
@@ -983,4 +1074,4 @@ interface DisplayItemParseOptions {
|
|
|
983
1074
|
*/
|
|
984
1075
|
declare function parseDisplayItems(items: DisplayItem[] | undefined, options?: DisplayItemParseOptions): THREE.Object3D[];
|
|
985
1076
|
|
|
986
|
-
export { type CameraConfig, type CameraController, type CameraProjection, type ControlsConfig, DisplayBatch, DisplayItem, type DisplayItemParseOptions, EDGES_SKIPPED_TRIANGLE_CAP, EDGE_USERDATA_KIND, type EdgeDetectionOptions, EdgeDetectionPass, type EdgeOptions, type EdgesConfig, type EnvironmentConfig, type EventConfig, type FloorConfig, type GizmoConfig, type Grid, type GridConfig, type GridOptions, LOOKS, type LabelHandle, type LabelLayer, type LightingConfig, type Look, threeMaterials as Materials, type MeasureConfig, type MeasureOptions, type MeasureTool, MeshExtractionOptions, type RenderConfig, type RenderPipeline, type RenderPipelineOptions, SCALE_FACTORS, type ThreeInitializerOptions, type ViewGizmo, type ViewPreset, addEdges, addEdgesAsync, applyOffset, computeCombinedBoundingBox, createCameraController, createGrid, createLabelLayer, createMeasureTool, createRenderPipeline, createViewGizmo, getThreeMeshesFromComputeResponse, initThree, isEdgeOverlay, parseColor, parseDisplayItems, parseMeshBatchBlob, parseMeshBatchObject, removeEdges, snapToVertex, updateScene };
|
|
1077
|
+
export { type CameraConfig, type CameraController, type CameraProjection, type ControlsConfig, DisplayBatch, DisplayItem, type DisplayItemParseOptions, EDGES_SKIPPED_TRIANGLE_CAP, EDGE_USERDATA_KIND, type EdgeDetectionOptions, EdgeDetectionPass, type EdgeOptions, type EdgesConfig, type EnvironmentConfig, type EventConfig, type FloorConfig, type GizmoConfig, type Grid, type GridConfig, type GridOptions, LOOKS, type LabelHandle, type LabelLayer, type LightingConfig, type Look, threeMaterials as Materials, type MeasureConfig, type MeasureOptions, type MeasureTool, MeshExtractionOptions, type RenderConfig, type RenderPipeline, type RenderPipelineOptions, SCALE_FACTORS, type ThreeInitializerOptions, type UpBasis, type ViewGizmo, type ViewPreset, addEdges, addEdgesAsync, applyOffset, buildUpBasis, computeCombinedBoundingBox, createCameraController, createGrid, createLabelLayer, createMeasureTool, createRenderPipeline, createViewGizmo, environmentRotationFor, getThreeMeshesFromComputeResponse, initThree, isEdgeOverlay, isoOffset, parseColor, parseDisplayItems, parseMeshBatchBlob, parseMeshBatchObject, removeEdges, snapToVertex, sunOffset, upToAxis, updateScene };
|
package/dist/visualization.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
|
|
3
|
-
import { M as MaterialAppearanceOptions, f as GrasshopperComputeResponse, m as MeshExtractionOptions, n as MeshBatchParsingOptions, o as DisplayBatch, p as DisplayItem } from './types-
|
|
4
|
-
export { q as DisplayCurve, r as DisplayIdentity, s as DisplayItemBase, t as DisplayPoint, u as DisplayPosition, v as MeshBatch } from './types-
|
|
3
|
+
import { M as MaterialAppearanceOptions, f as GrasshopperComputeResponse, m as MeshExtractionOptions, n as MeshBatchParsingOptions, o as DisplayBatch, p as DisplayItem } from './types-4FMvnx2j.js';
|
|
4
|
+
export { q as DisplayCurve, r as DisplayIdentity, s as DisplayItemBase, t as DisplayPoint, u as DisplayPosition, v as MeshBatch } from './types-4FMvnx2j.js';
|
|
5
5
|
import { CSS2DObject } from 'three/addons/renderers/CSS2DRenderer.js';
|
|
6
6
|
import { LineSegments2 } from 'three/addons/lines/LineSegments2.js';
|
|
7
7
|
import { Pass } from 'three/addons/postprocessing/Pass.js';
|
|
@@ -48,6 +48,15 @@ type EnvironmentConfig = {
|
|
|
48
48
|
hdrPath?: string;
|
|
49
49
|
backgroundColor?: THREE.Color | string;
|
|
50
50
|
enableEnvironmentLighting?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* The scene's up axis. **Defaults to `(0, 0, 1)` — Rhino's Z-up**, not Three's native Y-up,
|
|
53
|
+
* because geometry arrives in Rhino's frame and is never rotated on ingress (see
|
|
54
|
+
* `coordinate-transform.ts`). Everything orientation-dependent derives from this: view presets,
|
|
55
|
+
* the default iso camera, sun position, grid plane, floor normal, and the hemisphere light.
|
|
56
|
+
*
|
|
57
|
+
* Overriding it reorients the viewer but does NOT rotate incoming geometry, so a Y-up value only
|
|
58
|
+
* makes sense if the host also feeds Y-up geometry.
|
|
59
|
+
*/
|
|
51
60
|
sceneUp?: THREE.Vector3;
|
|
52
61
|
showEnvironment?: boolean;
|
|
53
62
|
/**
|
|
@@ -172,7 +181,11 @@ type GridConfig = {
|
|
|
172
181
|
majorColor?: THREE.ColorRepresentation;
|
|
173
182
|
/** World radius at which the grid fully fades. Default 100. */
|
|
174
183
|
fadeDistance?: number;
|
|
175
|
-
/**
|
|
184
|
+
/**
|
|
185
|
+
* Axis the grid lies perpendicular to — the scene's up axis. Defaults to whichever axis
|
|
186
|
+
* `sceneUp` points along, so it is `'z'` (Rhino's horizontal ground) unless you override
|
|
187
|
+
* `sceneUp`. Set explicitly only to force a grid orientation that ignores the scene up.
|
|
188
|
+
*/
|
|
176
189
|
plane?: 'x' | 'y' | 'z';
|
|
177
190
|
};
|
|
178
191
|
/** Corner nav-cube/axis gizmo that snaps to preset views. See `createViewGizmo`. */
|
|
@@ -309,7 +322,8 @@ interface CameraControllerDeps {
|
|
|
309
322
|
/**
|
|
310
323
|
* The scene's up axis. Presets, the orthographic camera's up, and the iso direction are all derived
|
|
311
324
|
* from this so the controller is correct in any up convention (Three's native Y-up, Rhino's Z-up, …)
|
|
312
|
-
* without hardcoding an axis.
|
|
325
|
+
* without hardcoding an axis. Falls back to `perspective.up` when omitted; `initThree` always
|
|
326
|
+
* passes the configured `sceneUp`, which itself defaults to Rhino's Z-up.
|
|
313
327
|
*/
|
|
314
328
|
up?: THREE.Vector3;
|
|
315
329
|
}
|
|
@@ -337,7 +351,13 @@ interface GridOptions {
|
|
|
337
351
|
majorColor?: THREE.ColorRepresentation;
|
|
338
352
|
/** World-space radius at which the grid has fully faded out. Default 100. */
|
|
339
353
|
fadeDistance?: number;
|
|
340
|
-
/**
|
|
354
|
+
/**
|
|
355
|
+
* Axis the grid is laid perpendicular to — i.e. the scene's up axis. `'z'` is the horizontal
|
|
356
|
+
* ground in the Rhino Z-up frame the viewer uses; `'y'` is Three's native Y-up.
|
|
357
|
+
*
|
|
358
|
+
* This standalone default is `'y'`, but `initThree` always passes a plane derived from the
|
|
359
|
+
* configured `sceneUp`, so a viewer-created grid defaults to `'z'`.
|
|
360
|
+
*/
|
|
341
361
|
plane?: 'x' | 'y' | 'z';
|
|
342
362
|
}
|
|
343
363
|
interface Grid {
|
|
@@ -624,7 +644,8 @@ declare function updateScene(scene: THREE.Scene, meshes: THREE.Object3D[], camer
|
|
|
624
644
|
declare function parseColor(colorString: string): THREE.Color;
|
|
625
645
|
/**
|
|
626
646
|
* Shift objects along one world axis. Defaults to `z` — the up axis of the unified Z-up scene
|
|
627
|
-
* frame (see `../coordinate-transform.ts`), so grounding subtracts the content's lowest z.
|
|
647
|
+
* frame (see `../coordinate-transform.ts`), so grounding subtracts the content's lowest z. Pass an
|
|
648
|
+
* explicit axis when the scene is configured with a different `sceneUp`.
|
|
628
649
|
*/
|
|
629
650
|
declare function applyOffset(meshes: THREE.Object3D[], offset: number, axis?: 'x' | 'y' | 'z'): void;
|
|
630
651
|
/**
|
|
@@ -655,6 +676,76 @@ declare namespace threeMaterials {
|
|
|
655
676
|
export { threeMaterials_CONCRETE_MATERIAL as CONCRETE_MATERIAL, threeMaterials_EMISSIVE_MATERIAL as EMISSIVE_MATERIAL, threeMaterials_GLASS_MATERIAL as GLASS_MATERIAL, threeMaterials_METAL_MATERIAL as METAL_MATERIAL, threeMaterials_PLASTIC_MATERIAL as PLASTIC_MATERIAL, threeMaterials_RUBBER_MATERIAL as RUBBER_MATERIAL, threeMaterials_SHARED_MATERIALS as SHARED_MATERIALS, threeMaterials_WOOD_MATERIAL as WOOD_MATERIAL };
|
|
656
677
|
}
|
|
657
678
|
|
|
679
|
+
/**
|
|
680
|
+
* The single source of truth for "which way is up, and what do front/right mean" in the viewer.
|
|
681
|
+
*
|
|
682
|
+
* Every up-dependent default (camera framing, sun position, ground offset, view presets) derives
|
|
683
|
+
* from {@link buildUpBasis} instead of hardcoding an axis. Before this module those defaults each
|
|
684
|
+
* spelled out a Z-up vector inline, so a scene configured Y-up got a below-horizon camera and a
|
|
685
|
+
* near-horizontal sun while the presets and floor correctly followed `sceneUp`.
|
|
686
|
+
*
|
|
687
|
+
* ## Why front is -forward
|
|
688
|
+
*
|
|
689
|
+
* The basis returns `forward` = the direction the camera LOOKS (from camera toward model), and the
|
|
690
|
+
* preset positions are the opposite (from target toward camera). Rhino's convention fixes the signs:
|
|
691
|
+
* its Front view looks along +Y, so the camera sits at -Y; its Right view looks along -X, so the
|
|
692
|
+
* camera sits at +X. Deriving `right` as `seed x up` (rather than `up x seed`) is what makes the
|
|
693
|
+
* handedness come out matching Rhino rather than mirrored.
|
|
694
|
+
*/
|
|
695
|
+
/** An orthonormal frame derived from a scene up axis. All vectors are unit length. */
|
|
696
|
+
interface UpBasis {
|
|
697
|
+
/** The scene up axis, normalized. */
|
|
698
|
+
up: THREE.Vector3;
|
|
699
|
+
/** The direction a "front" view looks along (from camera toward the model). */
|
|
700
|
+
forward: THREE.Vector3;
|
|
701
|
+
/** Completes a right-handed frame with `up` and `forward`. */
|
|
702
|
+
right: THREE.Vector3;
|
|
703
|
+
}
|
|
704
|
+
/**
|
|
705
|
+
* Derive the ground-plane axes for a given up vector.
|
|
706
|
+
*
|
|
707
|
+
* The seed picks whichever world axis is least parallel to `up`, so the cross products stay
|
|
708
|
+
* well-conditioned in any up convention. For Rhino's Z-up this yields forward = +Y and right = +X,
|
|
709
|
+
* matching Rhino's own Front/Right views; for Three's native Y-up it yields forward = -Z and
|
|
710
|
+
* right = +X, matching Three's convention that the default camera looks down -Z.
|
|
711
|
+
*/
|
|
712
|
+
declare function buildUpBasis(up: THREE.Vector3): UpBasis;
|
|
713
|
+
/**
|
|
714
|
+
* The default 3/4 iso camera OFFSET from the target, scaled to `distance`.
|
|
715
|
+
*
|
|
716
|
+
* Placed behind-left and above the model (the conventional architectural 3/4), expressed in the
|
|
717
|
+
* scene's own basis so it reads the same in any up convention. Callers add this to the framing
|
|
718
|
+
* target to get a camera position.
|
|
719
|
+
*/
|
|
720
|
+
declare function isoOffset(up: THREE.Vector3, distance: number): THREE.Vector3;
|
|
721
|
+
/**
|
|
722
|
+
* A default sun position: high above the model, offset to one side so surfaces get a directional
|
|
723
|
+
* gradient instead of flat top-down light. Expressed in the scene basis rather than a literal
|
|
724
|
+
* Z-up vector, so a Y-up scene still gets an overhead sun rather than a horizontal one.
|
|
725
|
+
*/
|
|
726
|
+
declare function sunOffset(up: THREE.Vector3, sideDistance: number, height: number): THREE.Vector3;
|
|
727
|
+
/**
|
|
728
|
+
* The rotation that puts an equirectangular environment map's horizon on the scene's ground plane.
|
|
729
|
+
*
|
|
730
|
+
* Three's equirect mapping is hardcoded to Y-up: it assumes the HDR's horizon lies in the XZ plane
|
|
731
|
+
* and its zenith points along +Y. In a Z-up scene that leaves the environment on its side — the
|
|
732
|
+
* horizon runs vertically and image-based lighting arrives from +Y rather than from overhead. The
|
|
733
|
+
* result is a subtly wrong key direction that a neutral studio HDR hides but any sky/ground HDR
|
|
734
|
+
* makes obvious.
|
|
735
|
+
*
|
|
736
|
+
* Returns the Euler that rotates the map's native +Y zenith onto `up`. Identity for a Y-up scene.
|
|
737
|
+
* Apply to BOTH `scene.environmentRotation` and `scene.backgroundRotation` — they are independent
|
|
738
|
+
* properties, and setting only one makes the visible background disagree with the lighting.
|
|
739
|
+
*/
|
|
740
|
+
declare function environmentRotationFor(up: THREE.Vector3): THREE.Euler;
|
|
741
|
+
/**
|
|
742
|
+
* Which world axis (`'x' | 'y' | 'z'`) the up vector most closely aligns with.
|
|
743
|
+
*
|
|
744
|
+
* Used for the grid plane and for the ground-offset axis — both need a single component index
|
|
745
|
+
* rather than a full vector. An off-axis up vector resolves to its dominant component.
|
|
746
|
+
*/
|
|
747
|
+
declare function upToAxis(up: THREE.Vector3): 'x' | 'y' | 'z';
|
|
748
|
+
|
|
658
749
|
/**
|
|
659
750
|
* Crisp boundary/crease edges overlaid on meshes — the defining "technical drawing" look that makes
|
|
660
751
|
* shaded geometry read as discrete objects rather than blobs.
|
|
@@ -910,11 +1001,11 @@ declare const SCALE_FACTORS: Record<string, number>;
|
|
|
910
1001
|
* // With debugging enabled
|
|
911
1002
|
* const meshes = await getThreeMeshesFromComputeResponse(response, { debug: true });
|
|
912
1003
|
*
|
|
913
|
-
* //
|
|
1004
|
+
* // Opt in to seating the model on the grid instead of using its Rhino coordinates
|
|
914
1005
|
* const meshes = await getThreeMeshesFromComputeResponse(response, {
|
|
915
1006
|
* debug: true,
|
|
916
1007
|
* allowScaling: true,
|
|
917
|
-
* allowAutoPosition:
|
|
1008
|
+
* allowAutoPosition: true,
|
|
918
1009
|
* parsing: {
|
|
919
1010
|
* mergeByMaterial: false,
|
|
920
1011
|
* applyTransforms: true,
|
|
@@ -983,4 +1074,4 @@ interface DisplayItemParseOptions {
|
|
|
983
1074
|
*/
|
|
984
1075
|
declare function parseDisplayItems(items: DisplayItem[] | undefined, options?: DisplayItemParseOptions): THREE.Object3D[];
|
|
985
1076
|
|
|
986
|
-
export { type CameraConfig, type CameraController, type CameraProjection, type ControlsConfig, DisplayBatch, DisplayItem, type DisplayItemParseOptions, EDGES_SKIPPED_TRIANGLE_CAP, EDGE_USERDATA_KIND, type EdgeDetectionOptions, EdgeDetectionPass, type EdgeOptions, type EdgesConfig, type EnvironmentConfig, type EventConfig, type FloorConfig, type GizmoConfig, type Grid, type GridConfig, type GridOptions, LOOKS, type LabelHandle, type LabelLayer, type LightingConfig, type Look, threeMaterials as Materials, type MeasureConfig, type MeasureOptions, type MeasureTool, MeshExtractionOptions, type RenderConfig, type RenderPipeline, type RenderPipelineOptions, SCALE_FACTORS, type ThreeInitializerOptions, type ViewGizmo, type ViewPreset, addEdges, addEdgesAsync, applyOffset, computeCombinedBoundingBox, createCameraController, createGrid, createLabelLayer, createMeasureTool, createRenderPipeline, createViewGizmo, getThreeMeshesFromComputeResponse, initThree, isEdgeOverlay, parseColor, parseDisplayItems, parseMeshBatchBlob, parseMeshBatchObject, removeEdges, snapToVertex, updateScene };
|
|
1077
|
+
export { type CameraConfig, type CameraController, type CameraProjection, type ControlsConfig, DisplayBatch, DisplayItem, type DisplayItemParseOptions, EDGES_SKIPPED_TRIANGLE_CAP, EDGE_USERDATA_KIND, type EdgeDetectionOptions, EdgeDetectionPass, type EdgeOptions, type EdgesConfig, type EnvironmentConfig, type EventConfig, type FloorConfig, type GizmoConfig, type Grid, type GridConfig, type GridOptions, LOOKS, type LabelHandle, type LabelLayer, type LightingConfig, type Look, threeMaterials as Materials, type MeasureConfig, type MeasureOptions, type MeasureTool, MeshExtractionOptions, type RenderConfig, type RenderPipeline, type RenderPipelineOptions, SCALE_FACTORS, type ThreeInitializerOptions, type UpBasis, type ViewGizmo, type ViewPreset, addEdges, addEdgesAsync, applyOffset, buildUpBasis, computeCombinedBoundingBox, createCameraController, createGrid, createLabelLayer, createMeasureTool, createRenderPipeline, createViewGizmo, environmentRotationFor, getThreeMeshesFromComputeResponse, initThree, isEdgeOverlay, isoOffset, parseColor, parseDisplayItems, parseMeshBatchBlob, parseMeshBatchObject, removeEdges, snapToVertex, sunOffset, upToAxis, updateScene };
|
package/dist/visualization.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{C as D,D as O,E as P,S as B,T as G,U as L,V as M,a as e,b as t,c as r,d as o,e as i,f as s,g as a,h as p,i as n,j as f,k as l,l as m,m as u,n as y,o as d,p as x,q as g,r as C,s as h,t as c,u as j,v,w as z,x as E}from"./chunk-KJVV3L5H.js";import"./chunk-Y3M7P3BW.js";export{d as EDGES_SKIPPED_TRIANGLE_CAP,y as EDGE_USERDATA_KIND,c as EdgeDetectionPass,O as LOOKS,e as Materials,L as SCALE_FACTORS,g as addEdges,C as addEdgesAsync,n as applyOffset,t as buildUpBasis,f as computeCombinedBoundingBox,l as createCameraController,m as createGrid,v as createLabelLayer,E as createMeasureTool,j as createRenderPipeline,u as createViewGizmo,i as environmentRotationFor,M as getThreeMeshesFromComputeResponse,D as initThree,x as isEdgeOverlay,r as isoOffset,p as parseColor,P as parseDisplayItems,G as parseMeshBatchBlob,B as parseMeshBatchObject,h as removeEdges,z as snapToVertex,o as sunOffset,s as upToAxis,a as updateScene};
|
|
2
2
|
//# sourceMappingURL=visualization.js.map
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/selva/selva/packages/compute/dist/chunk-6R4EL3ZJ.cjs","../src/core/utils/warnings.ts","../src/features/grasshopper/definition-ref.ts","../src/features/grasshopper/solve.ts"],"names":["warnedFunctions","isRealBrowser","nav","userAgent","warnIfClientSide","functionName","suppress","getLogger","isDefinitionRef","definition","DEFINITION_LOAD_FAILED","isDefinitionLoadMiss","error","RhinoComputeError","ErrorCodes","warnOnEmptyInnerTrees","response","debug","values","readField","empty","param","innerTree","scope"],"mappings":"AAAA,2/BAA+I,ICGzIA,EAAAA,CAAkB,IAAI,GAAA,CAa5B,SAASC,EAAAA,CAAAA,CAAyB,CAIjC,EAAA,CAHI,OAAO,MAAA,CAAW,GAAA,kBAER,UAAA,qBAA+D,OAAA,6BACnE,QAAA,6BAAU,MAAA,EAAQ,IAAA,CAAM,MAAO,CAAA,CAAA,CAEzC,IAAMC,CAAAA,CAAO,UAAA,CAAuD,SAAA,CAC9DC,CAAAA,CAAY,uBAAOD,CAAAA,6BAAK,WAAA,EAAc,QAAA,CAAWA,CAAAA,CAAI,SAAA,CAAY,EAAA,CACvE,MAAI,CAAA,QAAA,CAAS,IAAA,CAAKC,CAAS,CAG5B,CAEO,SAASC,CAAAA,CAAiBC,CAAAA,CAAsBC,CAAAA,CAA0B,CAC5EA,CAAAA,EAIAL,EAAAA,CAAc,CAAA,EAAK,CAACD,EAAAA,CAAgB,GAAA,CAAIK,CAAY,CAAA,EAAA,CACvDL,EAAAA,CAAgB,GAAA,CAAIK,CAAY,CAAA,CAChCE,iCAAAA,CAAU,CAAE,IAAA,CACX,CAAA,SAAA,EAAYF,CAAY,CAAA,8GAAA,CACzB,CAAA,CAEF,CCKO,SAASG,CAAAA,CAAgBC,CAAAA,CAA0D,CACzF,OACC,OAAOA,CAAAA,EAAe,QAAA,EACtB,CAAA,CAAEA,EAAAA,WAAsB,UAAA,CAAA,EACxB,OAAOA,CAAAA,CAAW,GAAA,EAAQ,QAAA,EAC1B,OAAOA,CAAAA,CAAW,IAAA,EAAS,UAE7B,CCvBA,IAAMC,EAAAA,CAAyB,uCAAA,CAG/B,SAASC,EAAAA,CAAqBC,CAAAA,CAAyB,CACtD,OAAMA,EAAAA,WAAiBC,mBAAAA,CAEtBD,CAAAA,CAAM,IAAA,GAASE,mBAAAA,CAAW,qBAAA,EAC1BF,CAAAA,CAAM,OAAA,CAAQ,QAAA,CAASF,EAAsB,CAAA,CAHI,CAAA,CAKnD,CAeO,SAASK,EAAAA,CAAsBC,CAAAA,CAAsCC,CAAAA,CAAuB,CAClG,EAAA,CAAI,CAACA,CAAAA,CAAO,MAAA,CAEZ,IAAMC,CAAAA,CAASC,iCAAAA,CAAqBH,CAAU,QAAQ,CAAA,CACtD,EAAA,CAAI,CAAC,KAAA,CAAM,OAAA,CAAQE,CAAM,CAAA,EAAKA,CAAAA,CAAO,MAAA,GAAW,CAAA,CAAG,MAAA,CAEnD,IAAME,CAAAA,CAAkB,CAAC,CAAA,CACzB,GAAA,CAAA,IAAWC,EAAAA,GAASH,CAAAA,CAAQ,CAC3B,IAAMI,CAAAA,CAAYH,iCAAAA,CAAmCE,CAAO,WAAW,CAAA,CAAA,CAEnE,CAACC,CAAAA,EAAa,MAAA,CAAO,IAAA,CAAKA,CAAS,CAAA,CAAE,MAAA,GAAW,CAAA,CAAA,EACnDF,CAAAA,CAAM,IAAA,kBAAKD,iCAAAA,CAAkBE,CAAO,WAAW,CAAA,SAAK,aAAW,CAEjE,CAEA,EAAA,CAAID,CAAAA,CAAM,MAAA,GAAW,CAAA,CAAG,MAAA,CAExB,IAAMG,CAAAA,CAAQH,CAAAA,CAAM,MAAA,GAAWF,CAAAA,CAAO,MAAA,CAAS,KAAA,CAAQ,CAAA,EAAA","file":"/home/runner/work/selva/selva/packages/compute/dist/chunk-6R4EL3ZJ.cjs","sourcesContent":[null,"import { getLogger } from './logger';\n\n/** Functions that already warned — the exposure risk doesn't change per call, so once is enough. */\nconst warnedFunctions = new Set<string>();\n\n/**\n * True only in a GENUINE browser/worker context — the case where an API key in\n * the config is actually exposed to end users. `typeof window !== 'undefined'`\n * alone is not enough: jsdom test environments define `window` too, and every\n * unsuppressed vitest/jest run would warn noisily (issue 110).\n *\n * Detection: `window` must exist, AND we must not be in Node (jsdom runs in\n * Node, so `process.versions.node` is defined there but never in a real\n * browser), AND the user agent must not carry jsdom's marker (belt-and-braces\n * for exotic setups that hide `process`). Genuine browsers pass all three.\n */\nfunction isRealBrowser(): boolean {\n\tif (typeof window === 'undefined') return false;\n\n\tconst proc = (globalThis as { process?: { versions?: { node?: unknown } } }).process;\n\tif (proc?.versions?.node != null) return false;\n\n\tconst nav = (globalThis as { navigator?: { userAgent?: unknown } }).navigator;\n\tconst userAgent = typeof nav?.userAgent === 'string' ? nav.userAgent : '';\n\tif (/jsdom/i.test(userAgent)) return false;\n\n\treturn true;\n}\n\nexport function warnIfClientSide(functionName: string, suppress?: boolean): void {\n\tif (suppress) {\n\t\treturn;\n\t}\n\n\tif (isRealBrowser() && !warnedFunctions.has(functionName)) {\n\t\twarnedFunctions.add(functionName);\n\t\tgetLogger().warn(\n\t\t\t`Warning: ${functionName} is running on the client side. For better performance and security, consider running this on the server side.`\n\t\t);\n\t}\n}\n\n/** @internal Reset the once-per-function dedupe — for tests only. */\nexport function resetClientSideWarnings(): void {\n\twarnedFunctions.clear();\n}\n","/**\n * By-reference definition form for solves.\n *\n * Lets a caller that already knows a definition's identity (e.g. a stored\n * version's UUID) schedule solves without materializing the multi-MB bytes:\n * cache keys and the server-pointer map are derived from `key` alone, and\n * `load()` is only called when an upload is genuinely unavoidable (first solve\n * of a definition, or a server-side pointer miss).\n */\n\n/**\n * A definition identified by a stable key, with bytes materialized on demand.\n *\n * **Immutability contract — read this before constructing one.** `key` must\n * identify IMMUTABLE bytes: every `load()` for a given `key` must return the\n * same content, forever. All caching (the scheduler's result cache, the\n * server-pointer map, and any durable cache built on these keys) trusts the\n * key as the definition's identity WITHOUT looking at the bytes. If two\n * different byte contents ever share a key, cached solves from one are served\n * for the other — silent cache poisoning with no diagnostic. Use an identity\n * that can never be reused for different content (e.g. a version UUID), never\n * a mutable name or path.\n */\nexport interface DefinitionRef {\n\t/**\n\t * Identity of immutable bytes (e.g. a version UUID). Two different byte\n\t * contents must never share a key — cache poisoning otherwise.\n\t */\n\tkey: string;\n\t/**\n\t * Materialize the bytes. Called ONLY when an upload is unavoidable — inside\n\t * the solve execution, so it counts toward the solve's abort semantics.\n\t */\n\tload: () => Promise<Uint8Array>;\n}\n\n/**\n * Every definition form accepted by the solve entry points:\n * - a URL, base64 string, or plain string (content-hashed for caching)\n * - raw `.gh` bytes (content-hashed)\n * - a {@link DefinitionRef} (identity-keyed; bytes loaded lazily)\n */\nexport type SolveDefinition = string | Uint8Array | DefinitionRef;\n\n/** Narrow a {@link SolveDefinition} to the by-reference form. */\nexport function isDefinitionRef(definition: SolveDefinition): definition is DefinitionRef {\n\treturn (\n\t\ttypeof definition === 'object' &&\n\t\t!(definition instanceof Uint8Array) &&\n\t\ttypeof definition.key === 'string' &&\n\t\ttypeof definition.load === 'function'\n\t);\n}\n","import { fetchRhinoCompute, RhinoComputeError, ErrorCodes } from '@/core';\nimport { getResponseWireSize, setResponseWireSize } from '@/core/compute-fetch/wire-size';\nimport { base64ByteArray, detectBase64Payload, encodeStringToBase64 } from '@/core/utils/encoding';\nimport { getLogger } from '@/core/utils/logger';\nimport { readField } from '@/core/utils/read-field';\nimport { warnIfClientSide } from '@/core/utils/warnings';\n\nimport {\n\tGrasshopperRequestSchema,\n\tGrasshopperComputeConfig,\n\tGrasshopperComputeResponse,\n\tDataTree\n} from './types';\nimport { isDefinitionRef, type SolveDefinition } from './definition-ref';\n\n/**\n * The exact message the server throws when it can neither resolve a `pointer`\n * nor a base64 `algo` to a definition (ResthopperEndpoints.cs). This is the\n * signal that a cache-key pointer missed the server's definition cache (GC'd, or\n * a different child in the pool), so the caller should retry with the full\n * definition. Matched as a substring because the server wraps it with a category\n * prefix in its exception handler.\n *\n * NOTE: the server only includes this message when running in debug mode; its\n * production exception handler scrubs the message to a generic string. The\n * reliable signal is therefore {@link ErrorCodes.DEFINITION_NOT_CACHED}, derived\n * from the server's machine `code` (which isn't scrubbed). The string match is\n * kept as a fallback for debug-mode servers and forks that don't yet emit a code.\n */\nconst DEFINITION_LOAD_FAILED = 'Unable to load grasshopper definition';\n\n/** Does this error look like a server-side definition-load miss? */\nfunction isDefinitionLoadMiss(error: unknown): boolean {\n\tif (!(error instanceof RhinoComputeError)) return false;\n\treturn (\n\t\terror.code === ErrorCodes.DEFINITION_NOT_CACHED ||\n\t\terror.message.includes(DEFINITION_LOAD_FAILED)\n\t);\n}\n\n/**\n * Debug aid: a solve can return successfully yet hand back outputs whose\n * `InnerTree` is empty (`{}`), meaning that parameter produced nothing — often a\n * sign the definition didn't actually compute (wrong/missing inputs, a guarded\n * branch). The names tell you exactly which output was empty so you can trace it\n * back to the responsible branch.\n *\n * Only logs when `debug` is set: an empty output can be legitimate, so this is a\n * diagnostic, never a hard failure. Reads `ParamName` / `InnerTree`\n * case-insensitively to stay robust across server-branch casing.\n *\n * @internal Exported for testing.\n */\nexport function warnOnEmptyInnerTrees(response: GrasshopperComputeResponse, debug?: boolean): void {\n\tif (!debug) return;\n\n\tconst values = readField<unknown[]>(response, 'values');\n\tif (!Array.isArray(values) || values.length === 0) return;\n\n\tconst empty: string[] = [];\n\tfor (const param of values) {\n\t\tconst innerTree = readField<Record<string, unknown>>(param, 'innerTree');\n\t\t// Treat a missing or empty innerTree as \"produced nothing\".\n\t\tif (!innerTree || Object.keys(innerTree).length === 0) {\n\t\t\tempty.push(readField<string>(param, 'paramName') ?? '<unnamed>');\n\t\t}\n\t}\n\n\tif (empty.length === 0) return;\n\n\tconst scope = empty.length === values.length ? 'all' : `${empty.length}/${values.length}`;\n\tgetLogger().warn(\n\t\t`Solve returned empty output(s) (${scope}): ${empty.join(', ')}. ` +\n\t\t\t`These parameters produced no data — check the definition's inputs and the branch feeding each.`\n\t);\n}\n\n/**\n * Result of a solve that also reports the definition's server-side cache key.\n *\n * `cacheKey` is the `md5_…` identifier the server assigned to the (base64)\n * definition — stable for identical content. A caller that holds it can solve\n * the same definition again by reference (`pointer: cacheKey`) instead of\n * re-uploading the full base64, which matters a lot for large (multi-MB)\n * definitions on a live UI. For a URL-pointer solve the server echoes the\n * request schema back, so `cacheKey` is the definition URL itself (already a\n * reference — nothing gained by re-pointing at it). `null` only when the\n * server's response carried no `pointer` at all — do NOT use `null` to detect\n * URL-pointer solves.\n */\nexport interface SolveWithCacheKey {\n\tresponse: GrasshopperComputeResponse;\n\tcacheKey: string | null;\n}\n\n/**\n * Runs a Rhino Compute job using the provided tree prototypes and Grasshopper definition.\n *\n * @public Use this for direct compute control. For high-level API, use `GrasshopperClient.solve()`.\n *\n * @param dataTree - An array of `DataTree` objects representing the input data for the compute job.\n * @param definition - The Grasshopper definition, which can be:\n * - A URL string (e.g., 'https://example.com/definition.gh')\n * - A base64-encoded string of the .gh file\n * - A plain string (will be base64-encoded)\n * - A Uint8Array of the .gh file (will be base64-encoded)\n * - A `DefinitionRef` (bytes are loaded via `ref.load()` for the upload)\n * @param config - Compute configuration (server URL, API key, etc. along with optional timeout, units, etc.)\n * @returns An object containing the compute result and extracted file data.\n *\n * @example\n * // Using a URL\n * await solveGrasshopperDefinition(trees, 'https://example.com/definition.gh', config);\n *\n * // Using a base64 string\n * await solveGrasshopperDefinition(trees, 'UEsDBBQAAAAIAL...', config);\n *\n * // Using binary data\n * const fileData = new Uint8Array([...]);\n * await solveGrasshopperDefinition(trees, fileData, config);\n */\nexport async function solveGrasshopperDefinition(\n\tdataTree: DataTree[],\n\tdefinition: SolveDefinition,\n\tconfig: GrasshopperComputeConfig\n): Promise<GrasshopperComputeResponse> {\n\t// Not gated on `debug`: exposing an API key in the browser is a security\n\t// concern in every configuration. `suppressBrowserWarning` is the opt-out.\n\twarnIfClientSide(\n\t\t'solveGrasshopperDefinition',\n\t\tconfig.suppressBrowserWarning ?? config.suppressClientSideWarning\n\t);\n\n\tconst bytes = await materializeDefinition(definition);\n\tconst { response } = await runSolve(prepareGrasshopperArgs(bytes, dataTree), config);\n\treturn response;\n}\n\n/**\n * Solve while reporting the server's definition cache key.\n *\n * Behaves like {@link solveGrasshopperDefinition} but returns the `cacheKey` the\n * server assigned, so a caller (e.g. the scheduler) can later solve the same\n * definition by reference instead of re-uploading it. The cache key is only\n * meaningful for base64/binary definitions; a URL-pointer solve returns the URL.\n *\n * @internal\n */\nexport async function solveGrasshopperDefinitionWithCacheKey(\n\tdataTree: DataTree[],\n\tdefinition: SolveDefinition,\n\tconfig: GrasshopperComputeConfig\n): Promise<SolveWithCacheKey> {\n\twarnIfClientSide(\n\t\t'solveGrasshopperDefinitionWithCacheKey',\n\t\tconfig.suppressBrowserWarning ?? config.suppressClientSideWarning\n\t);\n\n\tconst bytes = await materializeDefinition(definition);\n\treturn runSolve(prepareGrasshopperArgs(bytes, dataTree), config);\n}\n\n/**\n * Solve a definition by its server-side cache key (`pointer: cacheKey`),\n * skipping the (potentially multi-MB) base64 upload. If the key has been evicted\n * from the server's definition cache — `DEFINITION_LOAD_FAILED` — transparently\n * retry once with the full `definition` and report the fresh cache key so the\n * caller can update its mapping. A `DefinitionRef` definition is only\n * materialized (`ref.load()`) inside that miss branch — a pointer hit never\n * touches the bytes.\n *\n * @returns The solve result plus the (possibly refreshed) cache key, and whether\n * the fast path missed (so callers can record the new key / track hit rate).\n * @internal\n */\nexport async function solveByCacheKey(\n\tdataTree: DataTree[],\n\tcacheKey: string,\n\tdefinition: SolveDefinition,\n\tconfig: GrasshopperComputeConfig\n): Promise<SolveWithCacheKey & { missed: boolean }> {\n\twarnIfClientSide(\n\t\t'solveByCacheKey',\n\t\tconfig.suppressBrowserWarning ?? config.suppressClientSideWarning\n\t);\n\n\tconst pointerArgs: GrasshopperRequestSchema = { algo: null, pointer: cacheKey, values: dataTree };\n\n\ttry {\n\t\tconst fast = await runSolve(pointerArgs, config);\n\t\treturn { ...fast, missed: false };\n\t} catch (error) {\n\t\tif (!isDefinitionLoadMiss(error)) throw error;\n\t\t// Cache miss — fall back to the full upload and capture the fresh key.\n\t\tconst bytes = await materializeDefinition(definition);\n\t\tconst full = await runSolve(prepareGrasshopperArgs(bytes, dataTree), config);\n\t\treturn { ...full, missed: true };\n\t}\n}\n\n/**\n * Resolve a definition to uploadable form: a `DefinitionRef` is materialized\n * via `load()` (failures are wrapped so callers get a `RhinoComputeError`\n * naming the ref, not an opaque loader exception); other forms pass through.\n */\nasync function materializeDefinition(definition: SolveDefinition): Promise<string | Uint8Array> {\n\tif (!isDefinitionRef(definition)) return definition;\n\ttry {\n\t\treturn await definition.load();\n\t} catch (error) {\n\t\tthrow new RhinoComputeError(\n\t\t\t`Failed to load definition bytes for ref '${definition.key}'`,\n\t\t\tErrorCodes.INVALID_INPUT,\n\t\t\t{\n\t\t\t\tcontext: { definitionKey: definition.key },\n\t\t\t\toriginalError: error instanceof Error ? error : new Error(String(error))\n\t\t\t}\n\t\t);\n\t}\n}\n\n/**\n * Shared solve body: apply optional settings, POST, and split the server's\n * `pointer` (its cache key) off the response. `algo` — the request's full\n * base64 definition echoed back on every solve — is stripped too: keeping it\n * pins a multi-MB copy per response, multiplied by every cache holding\n * responses (the scheduler's LRU alone up to `maxEntries` times). Stripping via\n * shallow copy rather than `delete` keeps any already-observed response object\n * unmutated.\n */\nasync function runSolve(\n\targs: GrasshopperRequestSchema,\n\tconfig: GrasshopperComputeConfig\n): Promise<SolveWithCacheKey> {\n\tapplyOptionalComputeSettings(args, config);\n\n\tconst result = await fetchRhinoCompute<GrasshopperComputeResponse>('grasshopper', args, config);\n\n\tconst {\n\t\tpointer,\n\t\talgo: _algo,\n\t\t...rest\n\t} = result as GrasshopperComputeResponse & { pointer?: unknown; algo?: unknown };\n\tconst response = rest as GrasshopperComputeResponse;\n\t// The wire-size hint follows object identity, so the stripped copy must\n\t// re-register it — minus the echoed `algo`, which is no longer retained (it\n\t// can dwarf the actual outputs for a large definition).\n\tconst wireSize = getResponseWireSize(result);\n\tif (wireSize !== undefined) {\n\t\tconst algoLength = typeof _algo === 'string' ? _algo.length : 0;\n\t\tsetResponseWireSize(response, Math.max(0, wireSize - algoLength));\n\t}\n\twarnOnEmptyInnerTrees(response, config.debug);\n\treturn {\n\t\tresponse,\n\t\tcacheKey: typeof pointer === 'string' ? pointer : null\n\t};\n}\n\n// ============================================================================\n// Grasshopper Arguments\n// ============================================================================\n\n/**\n * Prepares Grasshopper arguments from a definition and data tree.\n * Automatically detects the definition format and converts it appropriately.\n *\n * @param definition - Can be a URL, base64 string, plain string, or Uint8Array\n * @param dataTree - Array of DataTree objects for compute inputs\n * @internal\n */\nexport function prepareGrasshopperArgs(\n\tdefinition: string | Uint8Array,\n\tdataTree: DataTree[]\n): GrasshopperRequestSchema {\n\tconst args: GrasshopperRequestSchema = {\n\t\talgo: null,\n\t\tpointer: null,\n\t\tvalues: dataTree\n\t};\n\n\tif (definition instanceof Uint8Array) {\n\t\t// Binary data → convert to base64\n\t\targs.algo = base64ByteArray(definition);\n\t} else if (/^https?:\\/\\//i.test(definition)) {\n\t\t// URL → use as pointer reference\n\t\targs.pointer = definition;\n\t} else {\n\t\t// Base64 detection is a heuristic (see detectBase64Payload): only long\n\t\t// (≥64 data chars), canonical base64 is passed through — normalized, so\n\t\t// newline-wrapped/unpadded definitions reach the server decodable instead\n\t\t// of double-encoded. Everything else (incl. short base64-shaped strings\n\t\t// like \"test\") is treated as a plain string and encoded. Pass a\n\t\t// Uint8Array to bypass sniffing entirely.\n\t\targs.algo = detectBase64Payload(definition) ?? encodeStringToBase64(definition);\n\t}\n\n\treturn args;\n}\n\n/**\n * @internal\n */\nexport function applyOptionalComputeSettings(\n\targlist: GrasshopperRequestSchema,\n\toptions: GrasshopperComputeConfig\n): void {\n\tif (options.cachesolve != null) arglist.cachesolve = options.cachesolve;\n\tif (options.cacheerroredsolves != null) arglist.cacheerroredsolves = options.cacheerroredsolves;\n\tif (options.modelunits != null) arglist.modelunits = options.modelunits;\n\tif (options.angletolerance != null) arglist.angletolerance = options.angletolerance;\n\tif (options.absolutetolerance != null) arglist.absolutetolerance = options.absolutetolerance;\n\tif (options.dataversion != null) arglist.dataversion = options.dataversion;\n}\n"]}
|