@selvajs/visualization 1.8.0-beta.8 → 1.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{gpu-dispose-0c_-KS12.cjs → gpu-dispose--5MA0CcI.cjs} +10 -9
- package/dist/{gpu-dispose-0c_-KS12.cjs.map → gpu-dispose--5MA0CcI.cjs.map} +1 -1
- package/dist/{gpu-dispose-k_Gq-ygL.js → gpu-dispose-m5ywfM1f.js} +8 -8
- package/dist/{gpu-dispose-k_Gq-ygL.js.map → gpu-dispose-m5ywfM1f.js.map} +1 -1
- package/dist/{gpu-ownership-Bs9l7hrU.js → gpu-ownership-5o7F_lc2.js} +1 -1
- package/dist/{gpu-ownership-Bs9l7hrU.js.map → gpu-ownership-5o7F_lc2.js.map} +1 -1
- package/dist/{gpu-ownership-ADRZBxxs.cjs → gpu-ownership-BtECafMd.cjs} +1 -28
- package/dist/{gpu-ownership-ADRZBxxs.cjs.map → gpu-ownership-BtECafMd.cjs.map} +1 -1
- package/dist/{merged-draw-CO4rr2Co.js → merged-draw-BE0616Nv.js} +2 -2
- package/dist/{merged-draw-CO4rr2Co.js.map → merged-draw-BE0616Nv.js.map} +1 -1
- package/dist/{merged-draw-ma_2r4N8.cjs → merged-draw-C9jFRnos.cjs} +4 -3
- package/dist/merged-draw-C9jFRnos.cjs.map +1 -0
- package/dist/parse.cjs +23 -25
- package/dist/parse.cjs.map +1 -1
- package/dist/parse.d.cts +9 -3
- package/dist/parse.d.ts +9 -3
- package/dist/parse.js +21 -24
- package/dist/parse.js.map +1 -1
- package/dist/render.cjs +38 -35
- package/dist/render.cjs.map +1 -1
- package/dist/render.d.cts +10 -6
- package/dist/render.d.ts +14 -7
- package/dist/render.js +36 -34
- package/dist/render.js.map +1 -1
- package/dist/rolldown-runtime-CmQyd0Gu.cjs +27 -0
- package/dist/scene.cjs +3 -3
- package/dist/scene.cjs.map +1 -1
- package/dist/scene.d.cts +10 -2
- package/dist/scene.d.ts +10 -2
- package/dist/scene.js +1 -1
- package/dist/{types-i9wRcHK7.d.ts → types-8Qx4xyyR.d.ts} +1 -2
- package/dist/{types-i9wRcHK7.d.cts → types-D1PpOP_H.d.cts} +1 -2
- package/package.json +8 -8
- package/dist/merged-draw-ma_2r4N8.cjs.map +0 -1
package/dist/render.cjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
const require_gpu_dispose = require("./gpu-dispose-0c_-KS12.cjs");
|
|
4
|
-
const require_merged_draw = require("./merged-draw-ma_2r4N8.cjs");
|
|
2
|
+
const require_rolldown_runtime = require("./rolldown-runtime-CmQyd0Gu.cjs");
|
|
5
3
|
let three = require("three");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
let three_addons_lines_LineGeometry_js = require("three/addons/lines/LineGeometry.js");
|
|
9
|
-
let three_addons_lines_LineMaterial_js = require("three/addons/lines/LineMaterial.js");
|
|
4
|
+
const require_gpu_dispose = require("./gpu-dispose--5MA0CcI.cjs");
|
|
5
|
+
const require_gpu_ownership = require("./gpu-ownership-BtECafMd.cjs");
|
|
10
6
|
let three_addons_lines_LineSegments2_js = require("three/addons/lines/LineSegments2.js");
|
|
11
7
|
let three_addons_lines_LineSegmentsGeometry_js = require("three/addons/lines/LineSegmentsGeometry.js");
|
|
8
|
+
const require_merged_draw = require("./merged-draw-C9jFRnos.cjs");
|
|
9
|
+
let three_addons_lines_LineMaterial_js = require("three/addons/lines/LineMaterial.js");
|
|
12
10
|
let three_addons_renderers_CSS2DRenderer_js = require("three/addons/renderers/CSS2DRenderer.js");
|
|
11
|
+
let three_addons_lines_Line2_js = require("three/addons/lines/Line2.js");
|
|
12
|
+
let three_addons_lines_LineGeometry_js = require("three/addons/lines/LineGeometry.js");
|
|
13
13
|
let three_mesh_bvh = require("three-mesh-bvh");
|
|
14
14
|
let three_addons_helpers_ViewHelper_js = require("three/addons/helpers/ViewHelper.js");
|
|
15
15
|
let three_addons_postprocessing_EffectComposer_js = require("three/addons/postprocessing/EffectComposer.js");
|
|
@@ -22,6 +22,7 @@ let three_addons_postprocessing_Pass_js = require("three/addons/postprocessing/P
|
|
|
22
22
|
let three_addons_postprocessing_UnrealBloomPass_js = require("three/addons/postprocessing/UnrealBloomPass.js");
|
|
23
23
|
let three_addons_controls_OrbitControls_js = require("three/addons/controls/OrbitControls.js");
|
|
24
24
|
let three_addons_loaders_HDRLoader_js = require("three/addons/loaders/HDRLoader.js");
|
|
25
|
+
three = require_rolldown_runtime.__toESM(three, 1);
|
|
25
26
|
// src/shared/types.ts
|
|
26
27
|
/** Source of truth for {@link Look} — lets consumers (e.g. a style picker) iterate instead of hardcoding names. */
|
|
27
28
|
const LOOKS = [
|
|
@@ -177,6 +178,7 @@ const METAL = .5;
|
|
|
177
178
|
/** Above PMREM's blur for a mirror, so a softbox has an edge in chrome without showing as a shape. */
|
|
178
179
|
const STUDIO_BLUR = .03;
|
|
179
180
|
const KEY = "selvaReflectionEnvironment";
|
|
181
|
+
const probes = /* @__PURE__ */ new WeakSet();
|
|
180
182
|
/**
|
|
181
183
|
* Builds the studio probe once per scene. `rotation` turns its Y-up room to the scene's up, the same
|
|
182
184
|
* rotation the HDR gets.
|
|
@@ -195,6 +197,7 @@ function installReflectionEnvironment(scene, texture, rotation) {
|
|
|
195
197
|
texture,
|
|
196
198
|
rotation: rotation.clone()
|
|
197
199
|
};
|
|
200
|
+
probes.add(texture);
|
|
198
201
|
scene.userData[KEY] = environment;
|
|
199
202
|
applyReflectionEnvironment(scene, scene);
|
|
200
203
|
}
|
|
@@ -218,7 +221,7 @@ function applyReflectionEnvironment(root, scene) {
|
|
|
218
221
|
const materials = Array.isArray(mesh.material) ? mesh.material : mesh.material ? [mesh.material] : [];
|
|
219
222
|
for (const material of materials) {
|
|
220
223
|
if (!(material instanceof three.MeshStandardMaterial)) continue;
|
|
221
|
-
if (material.envMap && material.envMap
|
|
224
|
+
if (material.envMap && !probes.has(material.envMap)) continue;
|
|
222
225
|
const wanted = material.metalness > METAL ? environment.texture : null;
|
|
223
226
|
if (material.envMap === wanted) continue;
|
|
224
227
|
material.envMap = wanted;
|
|
@@ -370,15 +373,15 @@ function applyDefaults(options) {
|
|
|
370
373
|
sunlightPosition: options.lighting?.sunlightPosition || sunOffset(options.environment?.sceneUp ?? defaultUp, defaults.lightDistance, defaults.lightHeight),
|
|
371
374
|
ambientLightColor: options.lighting?.ambientLightColor || new three.Color(4210752),
|
|
372
375
|
ambientLightIntensity: options.lighting?.ambientLightIntensity ?? preset.ambientIntensity,
|
|
373
|
-
sunlightColor: options.lighting?.sunlightColor ||
|
|
376
|
+
sunlightColor: options.lighting?.sunlightColor || 0xffffff,
|
|
374
377
|
enableHemisphereLight: options.lighting?.enableHemisphereLight ?? preset.hemisphereIntensity > 0,
|
|
375
|
-
hemisphereSkyColor: options.lighting?.hemisphereSkyColor ??
|
|
378
|
+
hemisphereSkyColor: options.lighting?.hemisphereSkyColor ?? 0xdfe6ff,
|
|
376
379
|
hemisphereGroundColor: options.lighting?.hemisphereGroundColor ?? 7036754,
|
|
377
380
|
hemisphereIntensity: options.lighting?.hemisphereIntensity ?? preset.hemisphereIntensity
|
|
378
381
|
},
|
|
379
382
|
environment: {
|
|
380
383
|
hdrPath: options.environment?.hdrPath === false ? false : options.environment?.hdrPath || "/baseHDR.hdr",
|
|
381
|
-
backgroundColor: options.environment?.backgroundColor || new three.Color(
|
|
384
|
+
backgroundColor: options.environment?.backgroundColor || new three.Color(0xf0f0f0),
|
|
382
385
|
enableEnvironmentLighting: options.environment?.enableEnvironmentLighting ?? true,
|
|
383
386
|
sceneUp: options.environment?.sceneUp || defaultUp,
|
|
384
387
|
showEnvironment: options.environment?.showEnvironment ?? false,
|
|
@@ -417,7 +420,7 @@ function applyDefaults(options) {
|
|
|
417
420
|
enableZoom: options.controls?.enableZoom ?? true,
|
|
418
421
|
enablePan: options.controls?.enablePan ?? true,
|
|
419
422
|
minDistance: options.controls?.minDistance || defaults.minDistance,
|
|
420
|
-
maxDistance: options.controls?.maxDistance ||
|
|
423
|
+
maxDistance: options.controls?.maxDistance || 1e400
|
|
421
424
|
},
|
|
422
425
|
grid: {
|
|
423
426
|
enabled: options.grid?.enabled ?? false,
|
|
@@ -598,7 +601,7 @@ function setupLighting(scene, config) {
|
|
|
598
601
|
hemisphere,
|
|
599
602
|
sun: null
|
|
600
603
|
};
|
|
601
|
-
const sunlight = new three.DirectionalLight(config.lighting.sunlightColor ??
|
|
604
|
+
const sunlight = new three.DirectionalLight(config.lighting.sunlightColor ?? 0xffffff, config.lighting.sunlightIntensity);
|
|
602
605
|
const pos = config.lighting.sunlightPosition;
|
|
603
606
|
if (pos) sunlight.position.set(pos.x, pos.y, pos.z);
|
|
604
607
|
if (!config.render.enableShadows) {
|
|
@@ -1012,7 +1015,7 @@ const SPACING_PERCENTILE = .15;
|
|
|
1012
1015
|
const SPACING_SAMPLE_LIMIT = 4096;
|
|
1013
1016
|
function edgeSpacingOf(segments) {
|
|
1014
1017
|
const segmentCount = Math.floor(segments.length / 6);
|
|
1015
|
-
if (segmentCount === 0) return
|
|
1018
|
+
if (segmentCount === 0) return 1e400;
|
|
1016
1019
|
const stride = Math.max(1, Math.ceil(segmentCount / SPACING_SAMPLE_LIMIT));
|
|
1017
1020
|
const lengths = [];
|
|
1018
1021
|
for (let s = 0; s < segmentCount; s += stride) {
|
|
@@ -1020,7 +1023,7 @@ function edgeSpacingOf(segments) {
|
|
|
1020
1023
|
const length = Math.hypot(segments[i + 3] - segments[i], segments[i + 4] - segments[i + 1], segments[i + 5] - segments[i + 2]);
|
|
1021
1024
|
if (length > 0) lengths.push(length);
|
|
1022
1025
|
}
|
|
1023
|
-
if (lengths.length === 0) return
|
|
1026
|
+
if (lengths.length === 0) return 1e400;
|
|
1024
1027
|
lengths.sort((a, b) => a - b);
|
|
1025
1028
|
return lengths[Math.min(lengths.length - 1, Math.floor(lengths.length * SPACING_PERCENTILE))];
|
|
1026
1029
|
}
|
|
@@ -1288,7 +1291,7 @@ function fastPathData(geometry) {
|
|
|
1288
1291
|
}
|
|
1289
1292
|
function contentKey(data, thresholdAngle) {
|
|
1290
1293
|
const SAMPLE_WORDS = 4096;
|
|
1291
|
-
let hash =
|
|
1294
|
+
let hash = 0x811c9dc5;
|
|
1292
1295
|
const mix = (word) => {
|
|
1293
1296
|
hash ^= word;
|
|
1294
1297
|
hash = Math.imul(hash, 16777619);
|
|
@@ -1609,22 +1612,22 @@ const _fadeCameraPos = new three.Vector3();
|
|
|
1609
1612
|
function pixelsPerWorldUnit(overlay, camera, viewportHeightPx) {
|
|
1610
1613
|
if (!overlay.geometry.boundingSphere) overlay.geometry.computeBoundingSphere();
|
|
1611
1614
|
const sphere = overlay.geometry.boundingSphere;
|
|
1612
|
-
if (!sphere) return
|
|
1615
|
+
if (!sphere) return 1e400;
|
|
1613
1616
|
if (camera.isPerspectiveCamera) {
|
|
1614
1617
|
const perspective = camera;
|
|
1615
1618
|
_fadeCenter.copy(sphere.center).applyMatrix4(overlay.matrixWorld);
|
|
1616
1619
|
const distance = _fadeCameraPos.setFromMatrixPosition(camera.matrixWorld).distanceTo(_fadeCenter);
|
|
1617
|
-
if (distance <= sphere.radius * overlay.matrixWorld.getMaxScaleOnAxis()) return
|
|
1620
|
+
if (distance <= sphere.radius * overlay.matrixWorld.getMaxScaleOnAxis()) return 1e400;
|
|
1618
1621
|
const tanHalfFov = Math.tan(three.MathUtils.degToRad(perspective.fov) * .5);
|
|
1619
1622
|
const worldHeightAtCentre = 2 * distance * tanHalfFov;
|
|
1620
|
-
return worldHeightAtCentre > 0 ? viewportHeightPx / worldHeightAtCentre :
|
|
1623
|
+
return worldHeightAtCentre > 0 ? viewportHeightPx / worldHeightAtCentre : 1e400;
|
|
1621
1624
|
}
|
|
1622
1625
|
if (camera.isOrthographicCamera) {
|
|
1623
1626
|
const ortho = camera;
|
|
1624
1627
|
const worldHeight = (ortho.top - ortho.bottom) / ortho.zoom;
|
|
1625
|
-
return worldHeight > 0 ? viewportHeightPx / worldHeight :
|
|
1628
|
+
return worldHeight > 0 ? viewportHeightPx / worldHeight : 1e400;
|
|
1626
1629
|
}
|
|
1627
|
-
return
|
|
1630
|
+
return 1e400;
|
|
1628
1631
|
}
|
|
1629
1632
|
function enableDistanceFade(overlay, edgeSpacing) {
|
|
1630
1633
|
overlay.onBeforeRender = (renderer, _scene, camera) => {
|
|
@@ -2066,7 +2069,7 @@ function warmPickIndex(root) {
|
|
|
2066
2069
|
}
|
|
2067
2070
|
// src/render/measure.ts
|
|
2068
2071
|
const DEFAULT_SNAP_PIXELS = 12;
|
|
2069
|
-
const DEFAULT_COLOR =
|
|
2072
|
+
const DEFAULT_COLOR = 0xffcc00;
|
|
2070
2073
|
const LINE_PICK_FRACTION = .015;
|
|
2071
2074
|
const RENDER_ORDER_LINE = 998;
|
|
2072
2075
|
const RENDER_ORDER_MARKER = 999;
|
|
@@ -2558,7 +2561,7 @@ function createNearestDepthQuery() {
|
|
|
2558
2561
|
const singleBox = /* @__PURE__ */ new Float32Array(6);
|
|
2559
2562
|
let polygon = /* @__PURE__ */ new Float64Array(21);
|
|
2560
2563
|
let clipped = /* @__PURE__ */ new Float64Array(21);
|
|
2561
|
-
let nearest =
|
|
2564
|
+
let nearest = 1e400;
|
|
2562
2565
|
let sawContent = false;
|
|
2563
2566
|
const chunksOf = (object, geometry) => {
|
|
2564
2567
|
const position = geometry.getAttribute("position");
|
|
@@ -2579,7 +2582,7 @@ function createNearestDepthQuery() {
|
|
|
2579
2582
|
const chunkDepth = (chunks, chunk, planes) => {
|
|
2580
2583
|
const { position, index } = chunks;
|
|
2581
2584
|
const indices = index?.array;
|
|
2582
|
-
let best =
|
|
2585
|
+
let best = 1e400;
|
|
2583
2586
|
for (let t = chunks.ranges[chunk * 2]; t < chunks.ranges[chunk * 2 + 1]; t++) {
|
|
2584
2587
|
for (let corner = 0; corner < 3; corner++) {
|
|
2585
2588
|
const v = indices ? indices[t * 3 + corner] : t * 3 + corner;
|
|
@@ -2712,7 +2715,7 @@ function createNearestDepthQuery() {
|
|
|
2712
2715
|
worldPlanes[17] = forward.y;
|
|
2713
2716
|
worldPlanes[18] = forward.z;
|
|
2714
2717
|
worldPlanes[19] = -forward.dot(camera.position);
|
|
2715
|
-
nearest =
|
|
2718
|
+
nearest = 1e400;
|
|
2716
2719
|
sawContent = false;
|
|
2717
2720
|
for (const child of scene.children) visit(child);
|
|
2718
2721
|
return sawContent ? nearest : null;
|
|
@@ -2760,12 +2763,12 @@ function buildChunkBoxes(position, index, breaks) {
|
|
|
2760
2763
|
const fast = plain && position.itemSize === 3 && !position.normalized;
|
|
2761
2764
|
const indices = index?.array;
|
|
2762
2765
|
for (let chunk = 0; chunk < chunkCount; chunk++) {
|
|
2763
|
-
let minX =
|
|
2764
|
-
let minY =
|
|
2765
|
-
let minZ =
|
|
2766
|
-
let maxX = -
|
|
2767
|
-
let maxY = -
|
|
2768
|
-
let maxZ = -
|
|
2766
|
+
let minX = 1e400;
|
|
2767
|
+
let minY = 1e400;
|
|
2768
|
+
let minZ = 1e400;
|
|
2769
|
+
let maxX = -1e400;
|
|
2770
|
+
let maxY = -1e400;
|
|
2771
|
+
let maxZ = -1e400;
|
|
2769
2772
|
const end = ranges[chunk * 2 + 1] * 3;
|
|
2770
2773
|
for (let corner = ranges[chunk * 2] * 3; corner < end; corner++) {
|
|
2771
2774
|
const v = indices ? indices[corner] : corner;
|
|
@@ -3112,8 +3115,8 @@ function createEmissiveLights(scene) {
|
|
|
3112
3115
|
const silenced = /* @__PURE__ */ new Set();
|
|
3113
3116
|
const offset = new three.Vector3();
|
|
3114
3117
|
const addLight = (shadowed) => {
|
|
3115
|
-
const key = new three.PointLight(
|
|
3116
|
-
const bounce = new three.PointLight(
|
|
3118
|
+
const key = new three.PointLight(0xffffff, 1, 0, 2);
|
|
3119
|
+
const bounce = new three.PointLight(0xffffff, 1, 0, 1);
|
|
3117
3120
|
if (shadowed) {
|
|
3118
3121
|
key.castShadow = true;
|
|
3119
3122
|
key.shadow.mapSize.setScalar(SHADOW_MAP_SIZE);
|
|
@@ -3247,7 +3250,7 @@ function applyMaterialOverride(material, override) {
|
|
|
3247
3250
|
return;
|
|
3248
3251
|
}
|
|
3249
3252
|
if (!target[BASELINE_KEY]) target[BASELINE_KEY] = {
|
|
3250
|
-
color: target.color?.getHex() ??
|
|
3253
|
+
color: target.color?.getHex() ?? 0xffffff,
|
|
3251
3254
|
metalness: target.metalness ?? 0,
|
|
3252
3255
|
roughness: target.roughness ?? 1,
|
|
3253
3256
|
emissiveIntensity: target.emissiveIntensity ?? 0,
|
|
@@ -3861,7 +3864,7 @@ function setupControls(camera, canvas, config) {
|
|
|
3861
3864
|
controls.enableZoom = config.controls.enableZoom ?? true;
|
|
3862
3865
|
controls.enablePan = config.controls.enablePan ?? true;
|
|
3863
3866
|
controls.minDistance = config.controls.minDistance || .001;
|
|
3864
|
-
controls.maxDistance = config.controls.maxDistance ||
|
|
3867
|
+
controls.maxDistance = config.controls.maxDistance || 1e400;
|
|
3865
3868
|
controls.screenSpacePanning = false;
|
|
3866
3869
|
controls.maxPolarAngle = Math.PI;
|
|
3867
3870
|
controls.update();
|