@selvajs/visualization 1.6.1 → 1.7.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.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_gpu_ownership = require("./gpu-ownership-ADRZBxxs.cjs");
3
- const require_gpu_dispose = require("./gpu-dispose-D66GqIWS.cjs");
3
+ const require_gpu_dispose = require("./gpu-dispose-0c_-KS12.cjs");
4
4
  const require_merged_draw = require("./merged-draw-ma_2r4N8.cjs");
5
5
  let three = require("three");
6
6
  three = require_gpu_ownership.__toESM(three, 1);
@@ -2897,10 +2897,11 @@ const MIN_RELATIVE_STRENGTH = 1 / 3;
2897
2897
  /** Parts this close, as a share of the larger one's diagonal, are one lamp: a bulb and its reflector. */
2898
2898
  const SAME_LAMP_GAP = .05;
2899
2899
  /**
2900
- * three's point lights are in candela, so brightness falls off with the scene's units squared.
2901
- * Scaling by the scene's radius squared makes one strength read the same in millimetres and metres.
2900
+ * A glow sent without lumens lights like the lamp its strength stands for, so it agrees with one
2901
+ * that has them. Mirrors `Photometry` in Selva.Slva: one strength is 160 lm, spread over 4π
2902
+ * steradians, at 0.005 viewer units per lux. Assumes a scene in metres, as the lumens path does.
2902
2903
  */
2903
- const INTENSITY_PER_STRENGTH = .17;
2904
+ const LIGHT_PER_STRENGTH = 160 / (4 * Math.PI) * .005;
2904
2905
  /** Share of a source's light that comes back off the room, with no shadow to stop it. */
2905
2906
  const BOUNCE_SHARE = .07;
2906
2907
  /** A lamp's source has a size, so its shadow has a penumbra; three's default edge is a hard line. */
@@ -3031,7 +3032,7 @@ function createEmissiveLights(scene) {
3031
3032
  silenced.add(mesh);
3032
3033
  }
3033
3034
  };
3034
- const sync = (enabled, maxLights = DEFAULT_MAX_LIGHTS) => {
3035
+ const sync = (enabled, maxLights = DEFAULT_MAX_LIGHTS, lightScale = 1) => {
3035
3036
  for (const mesh of silenced) mesh.castShadow = true;
3036
3037
  silenced.clear();
3037
3038
  const { parts, radius } = enabled ? collect() : {
@@ -3041,7 +3042,7 @@ function createEmissiveLights(scene) {
3041
3042
  const sources = pickLightSources(sourcesFrom(parts, maxLights), maxLights);
3042
3043
  sources.forEach((source, index) => {
3043
3044
  const { key, bounce, home, size } = lights[index] ?? addLight(index < MAX_SHADOWED_LIGHTS);
3044
- const intensity = source.light ?? source.strength * INTENSITY_PER_STRENGTH * radius * radius;
3045
+ const intensity = (source.light ?? source.strength * LIGHT_PER_STRENGTH) * lightScale;
3045
3046
  key.color.copy(source.color);
3046
3047
  const spread = source.bounds.getSize(new three.Vector3()).length() / 2 / radius;
3047
3048
  key.intensity = !source.light && spread > MAX_POINT_SOURCE_SPREAD ? 0 : intensity;
@@ -3153,7 +3154,7 @@ function envMapIntensityForLook(material, preset) {
3153
3154
  if (own != null) return own;
3154
3155
  const target = material;
3155
3156
  const metalness = target[BASELINE_KEY]?.metalness ?? target.metalness ?? 0;
3156
- return require_gpu_dispose.lookEnvMapIntensity(preset.envMapIntensity, metalness);
3157
+ return require_gpu_dispose.lookEnvMapIntensity(preset.envMapIntensity, metalness, preset.metalReflection);
3157
3158
  }
3158
3159
  function lookPixelRatio(fullPixelRatio, preset) {
3159
3160
  return Math.min(fullPixelRatio, preset.maxPixelRatio ?? fullPixelRatio);
@@ -3211,8 +3212,8 @@ function createAppearanceController(params) {
3211
3212
  if (pipeline.get()) pipeline.rebuild();
3212
3213
  };
3213
3214
  const syncEmissiveLights = () => {
3214
- const { emissiveLights: enabled, maxEmissiveLights } = presetOf(activeLook);
3215
- emissiveLights.sync(!!enabled, maxEmissiveLights);
3215
+ const { emissiveLights: enabled, maxEmissiveLights, emissiveLightScale } = presetOf(activeLook);
3216
+ emissiveLights.sync(!!enabled, maxEmissiveLights, emissiveLightScale);
3216
3217
  requestRender();
3217
3218
  };
3218
3219
  const setLook = (look, options) => {