@selvajs/visualization 1.6.1-beta.0 → 1.7.0-beta.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/dist/render.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as LookPreset, i as LookMaterialOverride, n as LOOKS, o as MaterialAppearanceOptions, r as Look, t as BloomOptions } from "./types-DW_qU4-Y.cjs";
1
+ import { a as LookPreset, i as LookMaterialOverride, n as LOOKS, o as MaterialAppearanceOptions, r as Look, t as BloomOptions } from "./types-i9wRcHK7.cjs";
2
2
  import * as THREE from "three";
3
3
  import { OrbitControls } from "three/addons/controls/OrbitControls.js";
4
4
  import "three/addons/lines/LineSegments2.js";
package/dist/render.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as LookPreset, i as LookMaterialOverride, n as LOOKS, o as MaterialAppearanceOptions, r as Look, t as BloomOptions } from "./types-DW_qU4-Y.js";
1
+ import { a as LookPreset, i as LookMaterialOverride, n as LOOKS, o as MaterialAppearanceOptions, r as Look, t as BloomOptions } from "./types-i9wRcHK7.js";
2
2
  import * as THREE from "three";
3
3
  import { LineSegments2 } from "three/addons/lines/LineSegments2.js";
4
4
  import { CSS2DObject } from "three/addons/renderers/CSS2DRenderer.js";
package/dist/render.js CHANGED
@@ -1,4 +1,4 @@
1
- import { S as VisualizationError, _ as materialAppearanceForLook, b as setLogger, c as computeCombinedBoundingBox, d as EMISSIVE_LIGHT, f as LOOK_PRESETS, g as lookPreset, h as lookEnvMapIntensity, m as OWN_ENV_MAP_INTENSITY, o as publishMaxAnisotropy, r as hideGlass, t as disposeObjectTree, u as DEFAULT_LOOK, v as enableDebugLogging, x as ErrorCodes, y as getLogger } from "./gpu-dispose-Di_nxeXF.js";
1
+ import { S as VisualizationError, _ as materialAppearanceForLook, b as setLogger, c as computeCombinedBoundingBox, d as EMISSIVE_LIGHT, f as LOOK_PRESETS, g as lookPreset, h as lookEnvMapIntensity, m as OWN_ENV_MAP_INTENSITY, o as publishMaxAnisotropy, r as hideGlass, t as disposeObjectTree, u as DEFAULT_LOOK, v as enableDebugLogging, x as ErrorCodes, y as getLogger } from "./gpu-dispose-k_Gq-ygL.js";
2
2
  import { n as cachedSourceOf } from "./gpu-ownership-Bs9l7hrU.js";
3
3
  import { a as onMemberDrawChange, i as getHiddenMembers, n as cloneForTint, r as getBaseMaterial, s as setMemberHighlight, t as clearMemberHighlight } from "./merged-draw-CO4rr2Co.js";
4
4
  import * as THREE from "three";
@@ -2895,10 +2895,11 @@ const MIN_RELATIVE_STRENGTH = 1 / 3;
2895
2895
  /** Parts this close, as a share of the larger one's diagonal, are one lamp: a bulb and its reflector. */
2896
2896
  const SAME_LAMP_GAP = .05;
2897
2897
  /**
2898
- * three's point lights are in candela, so brightness falls off with the scene's units squared.
2899
- * Scaling by the scene's radius squared makes one strength read the same in millimetres and metres.
2898
+ * A glow sent without lumens lights like the lamp its strength stands for, so it agrees with one
2899
+ * that has them. Mirrors `Photometry` in Selva.Slva: one strength is 160 lm, spread over 4π
2900
+ * steradians, at 0.005 viewer units per lux. Assumes a scene in metres, as the lumens path does.
2900
2901
  */
2901
- const INTENSITY_PER_STRENGTH = .17;
2902
+ const LIGHT_PER_STRENGTH = 160 / (4 * Math.PI) * .005;
2902
2903
  /** Share of a source's light that comes back off the room, with no shadow to stop it. */
2903
2904
  const BOUNCE_SHARE = .07;
2904
2905
  /** A lamp's source has a size, so its shadow has a penumbra; three's default edge is a hard line. */
@@ -3029,7 +3030,7 @@ function createEmissiveLights(scene) {
3029
3030
  silenced.add(mesh);
3030
3031
  }
3031
3032
  };
3032
- const sync = (enabled, maxLights = DEFAULT_MAX_LIGHTS) => {
3033
+ const sync = (enabled, maxLights = DEFAULT_MAX_LIGHTS, lightScale = 1) => {
3033
3034
  for (const mesh of silenced) mesh.castShadow = true;
3034
3035
  silenced.clear();
3035
3036
  const { parts, radius } = enabled ? collect() : {
@@ -3039,7 +3040,7 @@ function createEmissiveLights(scene) {
3039
3040
  const sources = pickLightSources(sourcesFrom(parts, maxLights), maxLights);
3040
3041
  sources.forEach((source, index) => {
3041
3042
  const { key, bounce, home, size } = lights[index] ?? addLight(index < MAX_SHADOWED_LIGHTS);
3042
- const intensity = source.light ?? source.strength * INTENSITY_PER_STRENGTH * radius * radius;
3043
+ const intensity = (source.light ?? source.strength * LIGHT_PER_STRENGTH) * lightScale;
3043
3044
  key.color.copy(source.color);
3044
3045
  const spread = source.bounds.getSize(new THREE.Vector3()).length() / 2 / radius;
3045
3046
  key.intensity = !source.light && spread > MAX_POINT_SOURCE_SPREAD ? 0 : intensity;
@@ -3151,7 +3152,7 @@ function envMapIntensityForLook(material, preset) {
3151
3152
  if (own != null) return own;
3152
3153
  const target = material;
3153
3154
  const metalness = target[BASELINE_KEY]?.metalness ?? target.metalness ?? 0;
3154
- return lookEnvMapIntensity(preset.envMapIntensity, metalness);
3155
+ return lookEnvMapIntensity(preset.envMapIntensity, metalness, preset.metalReflection);
3155
3156
  }
3156
3157
  function lookPixelRatio(fullPixelRatio, preset) {
3157
3158
  return Math.min(fullPixelRatio, preset.maxPixelRatio ?? fullPixelRatio);
@@ -3209,8 +3210,8 @@ function createAppearanceController(params) {
3209
3210
  if (pipeline.get()) pipeline.rebuild();
3210
3211
  };
3211
3212
  const syncEmissiveLights = () => {
3212
- const { emissiveLights: enabled, maxEmissiveLights } = presetOf(activeLook);
3213
- emissiveLights.sync(!!enabled, maxEmissiveLights);
3213
+ const { emissiveLights: enabled, maxEmissiveLights, emissiveLightScale } = presetOf(activeLook);
3214
+ emissiveLights.sync(!!enabled, maxEmissiveLights, emissiveLightScale);
3214
3215
  requestRender();
3215
3216
  };
3216
3217
  const setLook = (look, options) => {