@mml-io/3d-web-client-core 0.0.0-experimental-1429b1e-20230821 → 0.0.0-experimental-bed2364-20230824
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/build/character/CharacterTooltip.d.ts +0 -1
- package/build/index.d.ts +1 -0
- package/build/index.js +662 -308
- package/build/index.js.map +4 -4
- package/build/rendering/composer.d.ts +9 -2
- package/build/sun/Sun.d.ts +18 -0
- package/build/tweakpane/TweakPane.d.ts +7 -1
- package/build/tweakpane/envSettings.d.ts +40 -0
- package/build/tweakpane/sunSettings.d.ts +31 -0
- package/package.json +3 -3
package/build/index.js
CHANGED
@@ -48,13 +48,13 @@ var CameraManager = class {
|
|
48
48
|
constructor(collisionsManager) {
|
49
49
|
this.collisionsManager = collisionsManager;
|
50
50
|
__publicField(this, "camera");
|
51
|
-
__publicField(this, "initialDistance",
|
51
|
+
__publicField(this, "initialDistance", 3.3);
|
52
52
|
__publicField(this, "minDistance", 0.1);
|
53
|
-
__publicField(this, "maxDistance",
|
54
|
-
__publicField(this, "initialFOV",
|
53
|
+
__publicField(this, "maxDistance", 8);
|
54
|
+
__publicField(this, "initialFOV", 60);
|
55
55
|
__publicField(this, "fov", this.initialFOV);
|
56
|
-
__publicField(this, "minFOV",
|
57
|
-
__publicField(this, "maxFOV",
|
56
|
+
__publicField(this, "minFOV", 50);
|
57
|
+
__publicField(this, "maxFOV", 70);
|
58
58
|
__publicField(this, "targetFOV", this.initialFOV);
|
59
59
|
__publicField(this, "minPolarAngle", Math.PI * 0.25);
|
60
60
|
__publicField(this, "maxPolarAngle", Math.PI * 0.95);
|
@@ -856,7 +856,6 @@ var defaultLabelHeight = 0.125;
|
|
856
856
|
var defaultLabelCastShadows = true;
|
857
857
|
var CharacterTooltip = class {
|
858
858
|
constructor(parentModel) {
|
859
|
-
__publicField(this, "texture");
|
860
859
|
__publicField(this, "geometry");
|
861
860
|
__publicField(this, "material");
|
862
861
|
__publicField(this, "mesh");
|
@@ -877,7 +876,7 @@ var CharacterTooltip = class {
|
|
877
876
|
});
|
878
877
|
this.setText = this.setText.bind(this);
|
879
878
|
this.material = new MeshBasicMaterial2({
|
880
|
-
map:
|
879
|
+
map: null,
|
881
880
|
transparent: true,
|
882
881
|
opacity: 0
|
883
882
|
});
|
@@ -1698,7 +1697,9 @@ import {
|
|
1698
1697
|
NormalPass
|
1699
1698
|
} from "postprocessing";
|
1700
1699
|
import {
|
1701
|
-
|
1700
|
+
AmbientLight,
|
1701
|
+
Color as Color6,
|
1702
|
+
Fog,
|
1702
1703
|
HalfFloatType,
|
1703
1704
|
LinearSRGBColorSpace,
|
1704
1705
|
LoadingManager as LoadingManager2,
|
@@ -1708,6 +1709,109 @@ import {
|
|
1708
1709
|
} from "three";
|
1709
1710
|
import { RGBELoader } from "three/examples/jsm/loaders/RGBELoader.js";
|
1710
1711
|
|
1712
|
+
// src/sun/Sun.ts
|
1713
|
+
import { CameraHelper, Color as Color4, DirectionalLight, Group as Group3, OrthographicCamera, Vector3 as Vector37 } from "three";
|
1714
|
+
|
1715
|
+
// src/tweakpane/sunSettings.ts
|
1716
|
+
var sunValues = {
|
1717
|
+
sunPosition: {
|
1718
|
+
sunAzimuthalAngle: 39,
|
1719
|
+
sunPolarAngle: 50
|
1720
|
+
},
|
1721
|
+
sunIntensity: 0.5,
|
1722
|
+
sunColor: { r: 1, g: 1, b: 1 }
|
1723
|
+
};
|
1724
|
+
var sunOptions = {
|
1725
|
+
sunPosition: {
|
1726
|
+
sunAzimuthalAngle: { min: 0, max: 360, step: 1 },
|
1727
|
+
sunPolarAngle: { min: -90, max: 90, step: 1 }
|
1728
|
+
},
|
1729
|
+
sunIntensity: { min: 0, max: 1, step: 0.05 }
|
1730
|
+
};
|
1731
|
+
|
1732
|
+
// src/sun/Sun.ts
|
1733
|
+
var Sun = class extends Group3 {
|
1734
|
+
constructor() {
|
1735
|
+
super();
|
1736
|
+
__publicField(this, "debug", false);
|
1737
|
+
__publicField(this, "sunOffset", new Vector37(
|
1738
|
+
39 * (Math.PI / 180),
|
1739
|
+
50 * (Math.PI / 180),
|
1740
|
+
100
|
1741
|
+
));
|
1742
|
+
__publicField(this, "shadowResolution", 8192);
|
1743
|
+
__publicField(this, "shadowCamFrustum", 50);
|
1744
|
+
__publicField(this, "camHelper", null);
|
1745
|
+
__publicField(this, "shadowCamera");
|
1746
|
+
__publicField(this, "directionalLight");
|
1747
|
+
__publicField(this, "target", null);
|
1748
|
+
this.shadowCamera = new OrthographicCamera(
|
1749
|
+
-this.shadowCamFrustum,
|
1750
|
+
this.shadowCamFrustum,
|
1751
|
+
this.shadowCamFrustum,
|
1752
|
+
-this.shadowCamFrustum,
|
1753
|
+
0.1,
|
1754
|
+
200
|
1755
|
+
);
|
1756
|
+
if (this.debug === true) {
|
1757
|
+
this.camHelper = new CameraHelper(this.shadowCamera);
|
1758
|
+
}
|
1759
|
+
this.directionalLight = new DirectionalLight(16777215, 0.5);
|
1760
|
+
this.directionalLight.shadow.normalBias = 0.05;
|
1761
|
+
this.directionalLight.shadow.radius = 1.5;
|
1762
|
+
this.directionalLight.shadow.camera = this.shadowCamera;
|
1763
|
+
this.directionalLight.shadow.mapSize.set(this.shadowResolution, this.shadowResolution);
|
1764
|
+
this.directionalLight.castShadow = true;
|
1765
|
+
this.updateCharacterPosition(new Vector37(0, 0, 0));
|
1766
|
+
this.add(this.directionalLight);
|
1767
|
+
if (this.debug === true && this.camHelper instanceof CameraHelper) {
|
1768
|
+
this.add(this.camHelper);
|
1769
|
+
}
|
1770
|
+
}
|
1771
|
+
updateCharacterPosition(position) {
|
1772
|
+
if (!position)
|
1773
|
+
return;
|
1774
|
+
this.target = position;
|
1775
|
+
this.setSunPosition(this.sunOffset.x, this.sunOffset.y);
|
1776
|
+
}
|
1777
|
+
setAzimuthalAngle(angle) {
|
1778
|
+
if (this.sunOffset)
|
1779
|
+
this.sunOffset.x = angle;
|
1780
|
+
if (this.target)
|
1781
|
+
this.updateCharacterPosition(this.target);
|
1782
|
+
}
|
1783
|
+
setPolarAngle(angle) {
|
1784
|
+
if (this.sunOffset)
|
1785
|
+
this.sunOffset.y = angle;
|
1786
|
+
if (this.target)
|
1787
|
+
this.updateCharacterPosition(this.target);
|
1788
|
+
}
|
1789
|
+
setIntensity(intensity) {
|
1790
|
+
this.directionalLight.intensity = intensity;
|
1791
|
+
}
|
1792
|
+
setColor() {
|
1793
|
+
this.directionalLight.color = new Color4().setRGB(
|
1794
|
+
sunValues.sunColor.r,
|
1795
|
+
sunValues.sunColor.g,
|
1796
|
+
sunValues.sunColor.b
|
1797
|
+
);
|
1798
|
+
}
|
1799
|
+
setSunPosition(azimuthalAngle, polarAngle) {
|
1800
|
+
if (!this.target)
|
1801
|
+
return;
|
1802
|
+
const distance = this.sunOffset.z;
|
1803
|
+
const sphericalPosition = new Vector37(
|
1804
|
+
distance * Math.sin(polarAngle) * Math.cos(azimuthalAngle),
|
1805
|
+
distance * Math.cos(polarAngle),
|
1806
|
+
distance * Math.sin(polarAngle) * Math.sin(azimuthalAngle)
|
1807
|
+
);
|
1808
|
+
const newSunPosition = this.target.clone().add(sphericalPosition);
|
1809
|
+
this.directionalLight.position.set(newSunPosition.x, newSunPosition.y, newSunPosition.z);
|
1810
|
+
this.directionalLight.target.position.copy(this.target.clone());
|
1811
|
+
this.directionalLight.target.updateMatrixWorld();
|
1812
|
+
}
|
1813
|
+
};
|
1814
|
+
|
1711
1815
|
// src/tweakpane/composerSettings.ts
|
1712
1816
|
import { BlendFunction } from "postprocessing";
|
1713
1817
|
var composerValues = {
|
@@ -1746,17 +1850,17 @@ var composerValues = {
|
|
1746
1850
|
adaptationRate: 2
|
1747
1851
|
},
|
1748
1852
|
brightness: -0.03,
|
1749
|
-
contrast: 1.
|
1853
|
+
contrast: 1.21,
|
1750
1854
|
saturation: 0.91,
|
1751
1855
|
grain: 0.061,
|
1752
|
-
bloom: 0.
|
1856
|
+
bloom: 0.25
|
1753
1857
|
};
|
1754
1858
|
var composerOptions = {
|
1755
1859
|
renderer: {
|
1756
1860
|
shadowMap: { min: 0, max: 2, step: 1 },
|
1757
1861
|
toneMapping: { min: 0, max: 5, step: 1 },
|
1758
1862
|
exposure: { min: 0, max: 3, step: 0.01 },
|
1759
|
-
bgIntensity: { min: 0, max: 1, step: 0.01 },
|
1863
|
+
bgIntensity: { min: 0, max: 1.3, step: 0.01 },
|
1760
1864
|
bgBlurriness: { min: 0, max: 0.1, step: 1e-3 }
|
1761
1865
|
},
|
1762
1866
|
ssao: {
|
@@ -1855,17 +1959,81 @@ var statsData = {
|
|
1855
1959
|
FPS: "0"
|
1856
1960
|
};
|
1857
1961
|
|
1962
|
+
// src/tweakpane/envSettings.ts
|
1963
|
+
var envValues = {
|
1964
|
+
ambientLight: {
|
1965
|
+
ambientLightIntensity: 0,
|
1966
|
+
ambientLightColor: { r: 1, g: 1, b: 1 }
|
1967
|
+
},
|
1968
|
+
fog: {
|
1969
|
+
fogNear: 30,
|
1970
|
+
fogFar: 210,
|
1971
|
+
fogColor: { r: 0.42, g: 0.48, b: 0.59 }
|
1972
|
+
}
|
1973
|
+
};
|
1974
|
+
var envOptions = {
|
1975
|
+
ambientLight: {
|
1976
|
+
ambientLightIntensity: { min: 0, max: 1, step: 0.01 }
|
1977
|
+
},
|
1978
|
+
fog: {
|
1979
|
+
fogNear: { min: 0, max: 80, step: 1 },
|
1980
|
+
fogFar: { min: 81, max: 300, step: 1 }
|
1981
|
+
}
|
1982
|
+
};
|
1983
|
+
|
1858
1984
|
// src/tweakpane/TweakPane.ts
|
1859
1985
|
import {
|
1860
1986
|
BlendFunction as BlendFunction2
|
1861
1987
|
} from "postprocessing";
|
1862
|
-
import { Color as
|
1988
|
+
import { Color as Color5 } from "three";
|
1863
1989
|
import { Pane } from "tweakpane";
|
1864
1990
|
var TweakPane = class {
|
1865
1991
|
constructor(renderer, scene, composer) {
|
1866
1992
|
__publicField(this, "renderer");
|
1867
1993
|
__publicField(this, "scene");
|
1868
1994
|
__publicField(this, "composer");
|
1995
|
+
__publicField(this, "guiStyle", `
|
1996
|
+
:root {
|
1997
|
+
--tp-base-background-color: hsla(0, 0%, 10%, 0.8);
|
1998
|
+
--tp-base-shadow-color: hsla(0, 0%, 0%, 0.2);
|
1999
|
+
--tp-button-background-color: hsla(0, 0%, 80%, 1);
|
2000
|
+
--tp-button-background-color-active: hsla(0, 0%, 100%, 1);
|
2001
|
+
--tp-button-background-color-focus: hsla(0, 0%, 95%, 1);
|
2002
|
+
--tp-button-background-color-hover: hsla(0, 0%, 85%, 1);
|
2003
|
+
--tp-button-foreground-color: hsla(0, 0%, 0%, 0.8);
|
2004
|
+
--tp-container-background-color: hsla(0, 0%, 0%, 0.3);
|
2005
|
+
--tp-container-background-color-active: hsla(0, 0%, 0%, 0.6);
|
2006
|
+
--tp-container-background-color-focus: hsla(0, 0%, 0%, 0.5);
|
2007
|
+
--tp-container-background-color-hover: hsla(0, 0%, 0%, 0.4);
|
2008
|
+
--tp-container-foreground-color: hsla(0, 0%, 100%, 0.5);
|
2009
|
+
--tp-groove-foreground-color: hsla(0, 0%, 0%, 0.2);
|
2010
|
+
--tp-input-background-color: hsla(0, 0%, 0%, 0.3);
|
2011
|
+
--tp-input-background-color-active: hsla(0, 0%, 0%, 0.6);
|
2012
|
+
--tp-input-background-color-focus: hsla(0, 0%, 0%, 0.5);
|
2013
|
+
--tp-input-background-color-hover: hsla(0, 0%, 0%, 0.4);
|
2014
|
+
--tp-input-foreground-color: hsla(0, 0%, 100%, 0.5);
|
2015
|
+
--tp-label-foreground-color: hsla(0, 0%, 100%, 0.5);
|
2016
|
+
--tp-monitor-background-color: hsla(0, 0%, 0%, 0.3);
|
2017
|
+
--tp-monitor-foreground-color: hsla(0, 0%, 100%, 0.3);
|
2018
|
+
}
|
2019
|
+
|
2020
|
+
.tp-brkv {
|
2021
|
+
-webkit-user-select: none;
|
2022
|
+
-ms-user-select: none;
|
2023
|
+
user-select: none;
|
2024
|
+
}
|
2025
|
+
|
2026
|
+
.tp-dfwv {
|
2027
|
+
width: 333px !important;
|
2028
|
+
display: none;
|
2029
|
+
}
|
2030
|
+
|
2031
|
+
.tp-lblv_l {
|
2032
|
+
font-size: 10px;
|
2033
|
+
padding-left: 0px !important;
|
2034
|
+
padding-right: 0px !important;
|
2035
|
+
}
|
2036
|
+
`);
|
1869
2037
|
__publicField(this, "gui", new Pane());
|
1870
2038
|
__publicField(this, "render");
|
1871
2039
|
__publicField(this, "stats");
|
@@ -1875,6 +2043,10 @@ var TweakPane = class {
|
|
1875
2043
|
__publicField(this, "post");
|
1876
2044
|
__publicField(this, "export");
|
1877
2045
|
__publicField(this, "characterMaterial");
|
2046
|
+
__publicField(this, "environment");
|
2047
|
+
__publicField(this, "sun");
|
2048
|
+
__publicField(this, "sunButton");
|
2049
|
+
__publicField(this, "ambient");
|
1878
2050
|
__publicField(this, "saveVisibilityInLocalStorage", true);
|
1879
2051
|
__publicField(this, "guiVisible", false);
|
1880
2052
|
if (this.saveVisibilityInLocalStorage) {
|
@@ -1890,6 +2062,10 @@ var TweakPane = class {
|
|
1890
2062
|
this.renderer = renderer;
|
1891
2063
|
this.scene = scene;
|
1892
2064
|
this.composer = composer;
|
2065
|
+
const styleElement = document.createElement("style");
|
2066
|
+
styleElement.type = "text/css";
|
2067
|
+
styleElement.appendChild(document.createTextNode(this.guiStyle));
|
2068
|
+
document.head.appendChild(styleElement);
|
1893
2069
|
this.render = this.gui.addFolder({ title: "rendering", expanded: true });
|
1894
2070
|
this.stats = this.render.addFolder({ title: "stats", expanded: true });
|
1895
2071
|
this.renderOptions = this.render.addFolder({ title: "renderOptions", expanded: false });
|
@@ -1897,96 +2073,105 @@ var TweakPane = class {
|
|
1897
2073
|
this.ssao = this.render.addFolder({ title: "ambientOcclusion", expanded: false });
|
1898
2074
|
this.post = this.render.addFolder({ title: "post", expanded: false });
|
1899
2075
|
this.toneMapping.hidden = composerValues.renderer.toneMapping === 5 ? false : true;
|
1900
|
-
|
1901
|
-
|
1902
|
-
|
1903
|
-
|
1904
|
-
|
1905
|
-
|
1906
|
-
|
1907
|
-
|
1908
|
-
|
1909
|
-
|
1910
|
-
|
1911
|
-
|
1912
|
-
|
1913
|
-
|
1914
|
-
|
1915
|
-
|
1916
|
-
|
1917
|
-
|
1918
|
-
|
1919
|
-
|
1920
|
-
|
1921
|
-
|
1922
|
-
|
1923
|
-
|
1924
|
-
|
1925
|
-
|
1926
|
-
|
1927
|
-
"
|
1928
|
-
|
1929
|
-
|
1930
|
-
|
1931
|
-
|
1932
|
-
|
1933
|
-
|
1934
|
-
|
1935
|
-
"
|
1936
|
-
|
1937
|
-
|
1938
|
-
|
1939
|
-
|
1940
|
-
|
1941
|
-
|
1942
|
-
|
1943
|
-
|
1944
|
-
|
1945
|
-
|
1946
|
-
|
1947
|
-
|
1948
|
-
"
|
1949
|
-
|
1950
|
-
|
1951
|
-
|
1952
|
-
|
1953
|
-
|
1954
|
-
|
1955
|
-
|
1956
|
-
|
1957
|
-
|
1958
|
-
|
1959
|
-
|
1960
|
-
|
1961
|
-
|
1962
|
-
|
1963
|
-
|
1964
|
-
|
1965
|
-
|
1966
|
-
|
1967
|
-
|
1968
|
-
|
1969
|
-
|
1970
|
-
|
1971
|
-
|
1972
|
-
|
1973
|
-
|
1974
|
-
|
1975
|
-
|
1976
|
-
|
1977
|
-
|
1978
|
-
|
1979
|
-
|
1980
|
-
|
1981
|
-
|
1982
|
-
|
1983
|
-
|
1984
|
-
|
1985
|
-
|
1986
|
-
|
1987
|
-
|
1988
|
-
|
1989
|
-
|
2076
|
+
{
|
2077
|
+
this.characterMaterial = this.gui.addFolder({ title: "characterMaterial", expanded: false });
|
2078
|
+
this.characterMaterial.addInput(
|
2079
|
+
characterValues.material,
|
2080
|
+
"transmission",
|
2081
|
+
characterOptions.material.transmission
|
2082
|
+
);
|
2083
|
+
this.characterMaterial.addInput(
|
2084
|
+
characterValues.material,
|
2085
|
+
"metalness",
|
2086
|
+
characterOptions.material.metalness
|
2087
|
+
);
|
2088
|
+
this.characterMaterial.addInput(
|
2089
|
+
characterValues.material,
|
2090
|
+
"roughness",
|
2091
|
+
characterOptions.material.roughness
|
2092
|
+
);
|
2093
|
+
this.characterMaterial.addInput(
|
2094
|
+
characterValues.material,
|
2095
|
+
"ior",
|
2096
|
+
characterOptions.material.ior
|
2097
|
+
);
|
2098
|
+
this.characterMaterial.addInput(
|
2099
|
+
characterValues.material,
|
2100
|
+
"thickness",
|
2101
|
+
characterOptions.material.thickness
|
2102
|
+
);
|
2103
|
+
this.characterMaterial.addInput(characterValues.material, "specularColor", {
|
2104
|
+
color: { type: "float" }
|
2105
|
+
});
|
2106
|
+
this.characterMaterial.addInput(
|
2107
|
+
characterValues.material,
|
2108
|
+
"specularIntensity",
|
2109
|
+
characterOptions.material.specularIntensity
|
2110
|
+
);
|
2111
|
+
this.characterMaterial.addInput(characterValues.material, "emissive", {
|
2112
|
+
color: { type: "float" }
|
2113
|
+
});
|
2114
|
+
this.characterMaterial.addInput(
|
2115
|
+
characterValues.material,
|
2116
|
+
"emissiveIntensity",
|
2117
|
+
characterOptions.material.emissiveIntensity
|
2118
|
+
);
|
2119
|
+
this.characterMaterial.addInput(
|
2120
|
+
characterValues.material,
|
2121
|
+
"envMapIntensity",
|
2122
|
+
characterOptions.material.envMapIntensity
|
2123
|
+
);
|
2124
|
+
this.characterMaterial.addInput(characterValues.material, "sheenColor", {
|
2125
|
+
color: { type: "float" }
|
2126
|
+
});
|
2127
|
+
this.characterMaterial.addInput(
|
2128
|
+
characterValues.material,
|
2129
|
+
"sheen",
|
2130
|
+
characterOptions.material.sheen
|
2131
|
+
);
|
2132
|
+
this.characterMaterial.addInput(
|
2133
|
+
characterValues.material,
|
2134
|
+
"clearcoat",
|
2135
|
+
characterOptions.material.clearcoat
|
2136
|
+
);
|
2137
|
+
this.characterMaterial.addInput(
|
2138
|
+
characterValues.material,
|
2139
|
+
"clearcoatRoughness",
|
2140
|
+
characterOptions.material.clearcoatRoughness
|
2141
|
+
);
|
2142
|
+
this.characterMaterial.on("change", (e) => {
|
2143
|
+
if (!e.presetKey) {
|
2144
|
+
return;
|
2145
|
+
}
|
2146
|
+
if (e.presetKey === "specularColor") {
|
2147
|
+
characterValues.material.specularColor = {
|
2148
|
+
r: e.value.r,
|
2149
|
+
g: e.value.g,
|
2150
|
+
b: e.value.b
|
2151
|
+
};
|
2152
|
+
return;
|
2153
|
+
}
|
2154
|
+
if (e.presetKey === "emissive") {
|
2155
|
+
characterValues.material.emissive = {
|
2156
|
+
r: e.value.r,
|
2157
|
+
g: e.value.g,
|
2158
|
+
b: e.value.b
|
2159
|
+
};
|
2160
|
+
return;
|
2161
|
+
}
|
2162
|
+
if (e.presetKey === "sheenColor") {
|
2163
|
+
characterValues.material.sheenColor = {
|
2164
|
+
r: e.value.r,
|
2165
|
+
g: e.value.g,
|
2166
|
+
b: e.value.b
|
2167
|
+
};
|
2168
|
+
return;
|
2169
|
+
}
|
2170
|
+
});
|
2171
|
+
}
|
2172
|
+
this.environment = this.gui.addFolder({ title: "environment", expanded: false });
|
2173
|
+
this.sun = this.environment.addFolder({ title: "sun", expanded: true });
|
2174
|
+
this.ambient = this.environment.addFolder({ title: "ambient", expanded: true });
|
1990
2175
|
this.export = this.gui.addFolder({ title: "import/export", expanded: false });
|
1991
2176
|
window.addEventListener("keydown", this.processKey.bind(this));
|
1992
2177
|
this.setupGUIListeners.bind(this)();
|
@@ -2004,201 +2189,308 @@ var TweakPane = class {
|
|
2004
2189
|
this.gui.element.addEventListener("mouseup", () => setTweakpaneActive(false));
|
2005
2190
|
this.gui.element.addEventListener("mouseleave", () => setTweakpaneActive(false));
|
2006
2191
|
}
|
2007
|
-
setupRenderPane(ssaoEffect, toneMappingEffect, toneMappingPass, brightnessContrastSaturation, bloomEffect, gaussGrainEffect) {
|
2008
|
-
|
2009
|
-
|
2010
|
-
|
2011
|
-
|
2012
|
-
|
2013
|
-
|
2014
|
-
|
2015
|
-
|
2016
|
-
|
2017
|
-
|
2018
|
-
|
2019
|
-
|
2020
|
-
|
2021
|
-
|
2022
|
-
|
2023
|
-
|
2024
|
-
|
2025
|
-
"
|
2026
|
-
|
2027
|
-
|
2028
|
-
|
2029
|
-
|
2030
|
-
|
2031
|
-
"
|
2032
|
-
|
2033
|
-
|
2034
|
-
|
2035
|
-
|
2036
|
-
|
2037
|
-
|
2038
|
-
|
2039
|
-
|
2040
|
-
|
2041
|
-
|
2042
|
-
|
2043
|
-
|
2044
|
-
|
2045
|
-
|
2046
|
-
|
2047
|
-
|
2048
|
-
|
2049
|
-
|
2050
|
-
|
2051
|
-
|
2052
|
-
|
2053
|
-
|
2054
|
-
|
2055
|
-
|
2056
|
-
|
2057
|
-
|
2058
|
-
|
2059
|
-
|
2060
|
-
|
2061
|
-
|
2062
|
-
|
2063
|
-
|
2064
|
-
|
2065
|
-
|
2066
|
-
|
2067
|
-
|
2068
|
-
|
2069
|
-
|
2070
|
-
|
2071
|
-
|
2072
|
-
|
2073
|
-
|
2074
|
-
|
2075
|
-
"
|
2076
|
-
composerOptions.ssao.
|
2077
|
-
|
2078
|
-
|
2079
|
-
|
2080
|
-
|
2081
|
-
|
2082
|
-
|
2083
|
-
composerValues.ssao,
|
2084
|
-
"
|
2085
|
-
composerOptions.ssao.
|
2086
|
-
|
2087
|
-
|
2088
|
-
|
2089
|
-
|
2090
|
-
|
2091
|
-
|
2092
|
-
|
2093
|
-
|
2094
|
-
|
2095
|
-
|
2096
|
-
|
2097
|
-
|
2098
|
-
|
2099
|
-
|
2100
|
-
|
2101
|
-
|
2102
|
-
|
2103
|
-
|
2104
|
-
|
2105
|
-
|
2106
|
-
|
2107
|
-
|
2108
|
-
|
2109
|
-
|
2110
|
-
|
2111
|
-
|
2112
|
-
|
2113
|
-
|
2114
|
-
|
2115
|
-
|
2116
|
-
|
2117
|
-
|
2118
|
-
|
2119
|
-
|
2120
|
-
|
2121
|
-
|
2122
|
-
|
2123
|
-
|
2124
|
-
|
2125
|
-
|
2126
|
-
|
2127
|
-
|
2128
|
-
|
2129
|
-
|
2130
|
-
|
2131
|
-
|
2132
|
-
|
2133
|
-
|
2134
|
-
|
2135
|
-
|
2136
|
-
|
2137
|
-
|
2138
|
-
|
2139
|
-
|
2140
|
-
|
2141
|
-
|
2142
|
-
|
2143
|
-
|
2144
|
-
|
2145
|
-
|
2146
|
-
|
2147
|
-
|
2148
|
-
|
2149
|
-
|
2150
|
-
|
2151
|
-
|
2152
|
-
|
2153
|
-
|
2154
|
-
|
2155
|
-
|
2156
|
-
|
2157
|
-
|
2158
|
-
|
2159
|
-
|
2160
|
-
|
2161
|
-
|
2162
|
-
|
2163
|
-
|
2192
|
+
setupRenderPane(ssaoEffect, toneMappingEffect, toneMappingPass, brightnessContrastSaturation, bloomEffect, gaussGrainEffect, hasLighting, sun, setHDR, setAmbientLight, setFog) {
|
2193
|
+
{
|
2194
|
+
this.stats.addMonitor(statsData, "triangles");
|
2195
|
+
this.stats.addMonitor(statsData, "geometries");
|
2196
|
+
this.stats.addMonitor(statsData, "textures");
|
2197
|
+
this.stats.addMonitor(statsData, "shaders");
|
2198
|
+
this.stats.addMonitor(statsData, "postPasses");
|
2199
|
+
this.stats.addMonitor(statsData, "drawCalls");
|
2200
|
+
this.stats.addMonitor(statsData, "rawDeltaTime");
|
2201
|
+
this.stats.addMonitor(statsData, "deltaTime");
|
2202
|
+
this.stats.addMonitor(statsData, "FPS");
|
2203
|
+
}
|
2204
|
+
{
|
2205
|
+
this.renderOptions.addInput(
|
2206
|
+
composerValues.renderer,
|
2207
|
+
"shadowMap",
|
2208
|
+
composerOptions.renderer.shadowMap
|
2209
|
+
);
|
2210
|
+
this.renderOptions.addMonitor(rendererBlades, "shadowMapType");
|
2211
|
+
this.renderOptions.addInput(
|
2212
|
+
composerValues.renderer,
|
2213
|
+
"toneMapping",
|
2214
|
+
composerOptions.renderer.toneMapping
|
2215
|
+
);
|
2216
|
+
this.renderOptions.addMonitor(rendererBlades, "toneMappingType");
|
2217
|
+
this.renderOptions.addInput(
|
2218
|
+
composerValues.renderer,
|
2219
|
+
"exposure",
|
2220
|
+
composerOptions.renderer.exposure
|
2221
|
+
);
|
2222
|
+
this.renderOptions.addInput(
|
2223
|
+
composerValues.renderer,
|
2224
|
+
"bgIntensity",
|
2225
|
+
composerOptions.renderer.bgIntensity
|
2226
|
+
);
|
2227
|
+
this.renderOptions.addInput(
|
2228
|
+
composerValues.renderer,
|
2229
|
+
"bgBlurriness",
|
2230
|
+
composerOptions.renderer.bgBlurriness
|
2231
|
+
);
|
2232
|
+
this.renderOptions.on("change", (e) => {
|
2233
|
+
const target = e.target;
|
2234
|
+
switch (target.label) {
|
2235
|
+
case "shadowMap":
|
2236
|
+
this.renderer.shadowMap.type = e.value;
|
2237
|
+
setShadowMapType(e.value);
|
2238
|
+
break;
|
2239
|
+
case "toneMapping":
|
2240
|
+
this.renderer.toneMapping = e.value;
|
2241
|
+
this.toneMapping.hidden = e.value !== 5;
|
2242
|
+
toneMappingPass.enabled = e.value === 5 ? true : false;
|
2243
|
+
setToneMappingType(e.value);
|
2244
|
+
break;
|
2245
|
+
case "exposure":
|
2246
|
+
this.renderer.toneMappingExposure = e.value;
|
2247
|
+
break;
|
2248
|
+
case "bgIntensity":
|
2249
|
+
this.scene.backgroundIntensity = e.value;
|
2250
|
+
break;
|
2251
|
+
case "bgBlurriness":
|
2252
|
+
this.scene.backgroundBlurriness = e.value;
|
2253
|
+
break;
|
2254
|
+
default:
|
2255
|
+
break;
|
2256
|
+
}
|
2257
|
+
});
|
2258
|
+
}
|
2259
|
+
{
|
2260
|
+
this.ssao.addInput({ showEffectOnly: false }, "showEffectOnly");
|
2261
|
+
this.ssao.addInput(composerValues.ssao, "samples", composerOptions.ssao.samples);
|
2262
|
+
this.ssao.addInput(composerValues.ssao, "rings", composerOptions.ssao.rings);
|
2263
|
+
this.ssao.addInput(
|
2264
|
+
composerValues.ssao,
|
2265
|
+
"luminanceInfluence",
|
2266
|
+
composerOptions.ssao.luminanceInfluence
|
2267
|
+
);
|
2268
|
+
this.ssao.addInput(composerValues.ssao, "radius", composerOptions.ssao.radius);
|
2269
|
+
this.ssao.addInput(composerValues.ssao, "intensity", composerOptions.ssao.intensity);
|
2270
|
+
this.ssao.addInput(composerValues.ssao, "bias", composerOptions.ssao.bias);
|
2271
|
+
this.ssao.addInput(composerValues.ssao, "fade", composerOptions.ssao.fade);
|
2272
|
+
this.ssao.addInput(
|
2273
|
+
composerValues.ssao,
|
2274
|
+
"resolutionScale",
|
2275
|
+
composerOptions.ssao.resolutionScale
|
2276
|
+
);
|
2277
|
+
this.ssao.addInput(
|
2278
|
+
composerValues.ssao,
|
2279
|
+
"worldDistanceThreshold",
|
2280
|
+
composerOptions.ssao.worldDistanceThreshold
|
2281
|
+
);
|
2282
|
+
this.ssao.addInput(
|
2283
|
+
composerValues.ssao,
|
2284
|
+
"worldDistanceFalloff",
|
2285
|
+
composerOptions.ssao.worldDistanceFalloff
|
2286
|
+
);
|
2287
|
+
this.ssao.addInput(
|
2288
|
+
composerValues.ssao,
|
2289
|
+
"worldProximityThreshold",
|
2290
|
+
composerOptions.ssao.worldProximityThreshold
|
2291
|
+
);
|
2292
|
+
this.ssao.addInput(
|
2293
|
+
composerValues.ssao,
|
2294
|
+
"worldProximityFalloff",
|
2295
|
+
composerOptions.ssao.worldProximityFalloff
|
2296
|
+
);
|
2297
|
+
this.ssao.addInput(composerValues.ssao, "color", {
|
2298
|
+
color: { alpha: false, type: "float" }
|
2299
|
+
});
|
2300
|
+
this.ssao.on("change", (e) => {
|
2301
|
+
if (!e.presetKey) {
|
2302
|
+
return;
|
2303
|
+
}
|
2304
|
+
const preset = e.presetKey;
|
2305
|
+
if (preset === "showEffectOnly") {
|
2306
|
+
ssaoEffect.blendMode.blendFunction = e.value === true ? BlendFunction2.NORMAL : BlendFunction2.MULTIPLY;
|
2307
|
+
return;
|
2308
|
+
}
|
2309
|
+
if (preset === "resolutionScale") {
|
2310
|
+
ssaoEffect.resolution.scale = e.value;
|
2311
|
+
return;
|
2312
|
+
}
|
2313
|
+
if (ssaoMaterialParams.includes(e.presetKey)) {
|
2314
|
+
ssaoEffect.ssaoMaterial[preset] = e.value;
|
2315
|
+
return;
|
2316
|
+
}
|
2317
|
+
if (e.presetKey === "color") {
|
2318
|
+
ssaoEffect.color = new Color5().setRGB(e.value.r, e.value.g, e.value.b);
|
2319
|
+
return;
|
2320
|
+
}
|
2321
|
+
ssaoEffect[preset] = e.value;
|
2322
|
+
});
|
2323
|
+
}
|
2324
|
+
{
|
2325
|
+
this.toneMapping.addInput(
|
2326
|
+
composerValues.toneMapping,
|
2327
|
+
"mode",
|
2328
|
+
composerOptions.toneMapping.mode
|
2329
|
+
);
|
2330
|
+
this.toneMapping.addMonitor(customToneMappingBlade, "customToneMappingType");
|
2331
|
+
this.toneMapping.addInput(
|
2332
|
+
composerValues.toneMapping,
|
2333
|
+
"whitePoint",
|
2334
|
+
composerOptions.toneMapping.whitePoint
|
2335
|
+
);
|
2336
|
+
this.toneMapping.addInput(
|
2337
|
+
composerValues.toneMapping,
|
2338
|
+
"middleGrey",
|
2339
|
+
composerOptions.toneMapping.middleGrey
|
2340
|
+
);
|
2341
|
+
const minLuminance = this.toneMapping.addInput(
|
2342
|
+
composerValues.toneMapping,
|
2343
|
+
"minLuminance",
|
2344
|
+
composerOptions.toneMapping.minLuminance
|
2345
|
+
);
|
2346
|
+
minLuminance.hidden = composerValues.toneMapping.mode === 2 ? true : false;
|
2347
|
+
const averageLuminance = this.toneMapping.addInput(
|
2348
|
+
composerValues.toneMapping,
|
2349
|
+
"averageLuminance",
|
2350
|
+
composerOptions.toneMapping.averageLuminance
|
2351
|
+
);
|
2352
|
+
averageLuminance.hidden = composerValues.toneMapping.mode === 2 ? true : false;
|
2353
|
+
this.toneMapping.addInput(
|
2354
|
+
composerValues.toneMapping,
|
2355
|
+
"adaptationRate",
|
2356
|
+
composerOptions.toneMapping.adaptationRate
|
2357
|
+
);
|
2358
|
+
this.toneMapping.on("change", (e) => {
|
2359
|
+
if (!e.presetKey) {
|
2360
|
+
return;
|
2361
|
+
}
|
2362
|
+
const preset = e.presetKey;
|
2363
|
+
if (preset === "mode") {
|
2364
|
+
minLuminance.hidden = composerValues.toneMapping.mode === 2 ? true : false;
|
2365
|
+
averageLuminance.hidden = composerValues.toneMapping.mode === 2 ? true : false;
|
2366
|
+
setCustomToneMappingType(e.value);
|
2367
|
+
}
|
2368
|
+
toneMappingEffect[preset] = e.value;
|
2164
2369
|
return;
|
2165
|
-
}
|
2166
|
-
|
2167
|
-
|
2168
|
-
|
2169
|
-
|
2170
|
-
|
2171
|
-
|
2172
|
-
|
2173
|
-
|
2174
|
-
|
2175
|
-
|
2176
|
-
|
2177
|
-
|
2178
|
-
|
2179
|
-
|
2180
|
-
|
2181
|
-
|
2182
|
-
|
2183
|
-
|
2184
|
-
|
2185
|
-
|
2186
|
-
|
2187
|
-
|
2188
|
-
|
2189
|
-
|
2190
|
-
|
2191
|
-
|
2192
|
-
|
2193
|
-
|
2194
|
-
|
2195
|
-
|
2196
|
-
|
2197
|
-
|
2198
|
-
|
2199
|
-
|
2200
|
-
|
2201
|
-
|
2370
|
+
});
|
2371
|
+
}
|
2372
|
+
{
|
2373
|
+
this.post.addInput(composerValues, "brightness", composerOptions.brightness.amount);
|
2374
|
+
this.post.addInput(composerValues, "contrast", composerOptions.contrast.amount);
|
2375
|
+
this.post.addInput(composerValues, "saturation", composerOptions.saturation.amount);
|
2376
|
+
this.post.addInput(composerValues, "bloom", composerOptions.bloom.amount);
|
2377
|
+
this.post.addInput(composerValues, "grain", composerOptions.grain.amount);
|
2378
|
+
this.post.on("change", (e) => {
|
2379
|
+
const target = e.presetKey;
|
2380
|
+
switch (target) {
|
2381
|
+
case "brightness":
|
2382
|
+
brightnessContrastSaturation.uniforms.brightness.value = e.value;
|
2383
|
+
break;
|
2384
|
+
case "contrast":
|
2385
|
+
brightnessContrastSaturation.uniforms.contrast.value = e.value;
|
2386
|
+
break;
|
2387
|
+
case "saturation":
|
2388
|
+
brightnessContrastSaturation.uniforms.saturation.value = e.value;
|
2389
|
+
break;
|
2390
|
+
case "bloom":
|
2391
|
+
bloomEffect.intensity = e.value;
|
2392
|
+
break;
|
2393
|
+
case "grain":
|
2394
|
+
gaussGrainEffect.uniforms.amount.value = e.value;
|
2395
|
+
break;
|
2396
|
+
default:
|
2397
|
+
break;
|
2398
|
+
}
|
2399
|
+
});
|
2400
|
+
}
|
2401
|
+
{
|
2402
|
+
this.environment.hidden = hasLighting === false || sun === null;
|
2403
|
+
this.sun.addInput(
|
2404
|
+
sunValues.sunPosition,
|
2405
|
+
"sunAzimuthalAngle",
|
2406
|
+
sunOptions.sunPosition.sunAzimuthalAngle
|
2407
|
+
);
|
2408
|
+
this.sun.addInput(
|
2409
|
+
sunValues.sunPosition,
|
2410
|
+
"sunPolarAngle",
|
2411
|
+
sunOptions.sunPosition.sunPolarAngle
|
2412
|
+
);
|
2413
|
+
this.sun.addInput(sunValues, "sunIntensity", sunOptions.sunIntensity);
|
2414
|
+
this.sun.addInput(sunValues, "sunColor", {
|
2415
|
+
color: { type: "float" }
|
2416
|
+
});
|
2417
|
+
this.sunButton = this.sun.addButton({ title: "Set HDRI" });
|
2418
|
+
this.sunButton.on("click", () => {
|
2419
|
+
setHDR();
|
2420
|
+
});
|
2421
|
+
this.sun.on("change", (e) => {
|
2422
|
+
const target = e.presetKey;
|
2423
|
+
switch (target) {
|
2424
|
+
case "sunAzimuthalAngle":
|
2425
|
+
sun?.setAzimuthalAngle(e.value * (Math.PI / 180));
|
2426
|
+
break;
|
2427
|
+
case "sunPolarAngle":
|
2428
|
+
sun?.setPolarAngle(e.value * (Math.PI / 180));
|
2429
|
+
break;
|
2430
|
+
case "sunIntensity":
|
2431
|
+
sun?.setIntensity(e.value);
|
2432
|
+
break;
|
2433
|
+
case "sunColor":
|
2434
|
+
sunValues.sunColor = {
|
2435
|
+
r: e.value.r,
|
2436
|
+
g: e.value.g,
|
2437
|
+
b: e.value.b
|
2438
|
+
};
|
2439
|
+
sun?.setColor();
|
2440
|
+
break;
|
2441
|
+
default:
|
2442
|
+
break;
|
2443
|
+
}
|
2444
|
+
});
|
2445
|
+
this.ambient.addInput(
|
2446
|
+
envValues.ambientLight,
|
2447
|
+
"ambientLightIntensity",
|
2448
|
+
envOptions.ambientLight.ambientLightIntensity
|
2449
|
+
);
|
2450
|
+
this.ambient.addInput(envValues.ambientLight, "ambientLightColor", {
|
2451
|
+
color: { type: "float" }
|
2452
|
+
});
|
2453
|
+
this.ambient.addInput(envValues.fog, "fogNear", envOptions.fog.fogNear);
|
2454
|
+
this.ambient.addInput(envValues.fog, "fogFar", envOptions.fog.fogFar);
|
2455
|
+
this.ambient.addInput(envValues.fog, "fogColor", {
|
2456
|
+
color: { type: "float" }
|
2457
|
+
});
|
2458
|
+
this.ambient.on("change", (e) => {
|
2459
|
+
const target = e.presetKey;
|
2460
|
+
switch (target) {
|
2461
|
+
case "ambientLightIntensity":
|
2462
|
+
envValues.ambientLight.ambientLightIntensity = e.value;
|
2463
|
+
setAmbientLight();
|
2464
|
+
break;
|
2465
|
+
case "ambientLightColor":
|
2466
|
+
envValues.ambientLight.ambientLightColor = {
|
2467
|
+
r: e.value.r,
|
2468
|
+
g: e.value.g,
|
2469
|
+
b: e.value.b
|
2470
|
+
};
|
2471
|
+
setAmbientLight();
|
2472
|
+
break;
|
2473
|
+
case "fogNear":
|
2474
|
+
envValues.fog.fogNear = e.value;
|
2475
|
+
setFog();
|
2476
|
+
break;
|
2477
|
+
case "fogFar":
|
2478
|
+
envValues.fog.fogFar = e.value;
|
2479
|
+
setFog();
|
2480
|
+
break;
|
2481
|
+
case "fogColor":
|
2482
|
+
envValues.fog.fogColor = {
|
2483
|
+
r: e.value.r,
|
2484
|
+
g: e.value.g,
|
2485
|
+
b: e.value.b
|
2486
|
+
};
|
2487
|
+
setFog();
|
2488
|
+
break;
|
2489
|
+
default:
|
2490
|
+
break;
|
2491
|
+
}
|
2492
|
+
});
|
2493
|
+
}
|
2202
2494
|
const exportButton = this.export.addButton({ title: "export" });
|
2203
2495
|
exportButton.on("click", () => {
|
2204
2496
|
this.downloadSettingsAsJSON(this.gui.exportPreset());
|
@@ -2421,7 +2713,7 @@ var GaussGrainEffect = new ShaderMaterial2({
|
|
2421
2713
|
|
2422
2714
|
// src/rendering/composer.ts
|
2423
2715
|
var Composer = class {
|
2424
|
-
constructor(scene, camera) {
|
2716
|
+
constructor(scene, camera, spawnSun = false) {
|
2425
2717
|
__publicField(this, "width", window.innerWidth);
|
2426
2718
|
__publicField(this, "height", window.innerHeight);
|
2427
2719
|
__publicField(this, "resolution", new Vector22(this.width, this.height));
|
@@ -2447,9 +2739,13 @@ var Composer = class {
|
|
2447
2739
|
__publicField(this, "bcsPass");
|
2448
2740
|
__publicField(this, "gaussGrainEffect", GaussGrainEffect);
|
2449
2741
|
__publicField(this, "gaussGrainPass");
|
2742
|
+
__publicField(this, "ambientLight", null);
|
2743
|
+
__publicField(this, "sun", null);
|
2744
|
+
__publicField(this, "spawnSun");
|
2450
2745
|
__publicField(this, "tweakPane");
|
2451
2746
|
this.scene = scene;
|
2452
2747
|
this.camera = camera;
|
2748
|
+
this.spawnSun = spawnSun;
|
2453
2749
|
this.renderer = new WebGLRenderer3({
|
2454
2750
|
powerPreference: "high-performance",
|
2455
2751
|
antialias: false,
|
@@ -2462,6 +2758,8 @@ var Composer = class {
|
|
2462
2758
|
this.renderer.shadowMap.type = composerValues.renderer.shadowMap;
|
2463
2759
|
this.renderer.toneMapping = composerValues.renderer.toneMapping;
|
2464
2760
|
this.renderer.toneMappingExposure = composerValues.renderer.exposure;
|
2761
|
+
this.setAmbientLight();
|
2762
|
+
this.setFog();
|
2465
2763
|
document.body.appendChild(this.renderer.domElement);
|
2466
2764
|
this.composer = new EffectComposer2(this.renderer, {
|
2467
2765
|
frameBufferType: HalfFloatType
|
@@ -2489,7 +2787,7 @@ var Composer = class {
|
|
2489
2787
|
bias: composerValues.ssao.bias,
|
2490
2788
|
fade: composerValues.ssao.fade,
|
2491
2789
|
resolutionScale: composerValues.ssao.resolutionScale,
|
2492
|
-
color: new
|
2790
|
+
color: new Color6().setRGB(composerValues.ssao.color.r, composerValues.ssao.color.g, composerValues.ssao.color.b),
|
2493
2791
|
worldDistanceThreshold: composerValues.ssao.worldDistanceThreshold,
|
2494
2792
|
worldDistanceFalloff: composerValues.ssao.worldDistanceFalloff,
|
2495
2793
|
worldProximityThreshold: composerValues.ssao.worldProximityThreshold,
|
@@ -2529,13 +2827,22 @@ var Composer = class {
|
|
2529
2827
|
this.composer.addPass(this.toneMappingPass);
|
2530
2828
|
this.composer.addPass(this.bcsPass);
|
2531
2829
|
this.composer.addPass(this.gaussGrainPass);
|
2830
|
+
if (this.spawnSun === true) {
|
2831
|
+
this.sun = new Sun();
|
2832
|
+
this.scene.add(this.sun);
|
2833
|
+
}
|
2532
2834
|
this.tweakPane.setupRenderPane(
|
2533
2835
|
this.ssaoEffect,
|
2534
2836
|
this.toneMappingEffect,
|
2535
2837
|
this.toneMappingPass,
|
2536
2838
|
this.bcs,
|
2537
2839
|
this.bloomEffect,
|
2538
|
-
this.gaussGrainEffect
|
2840
|
+
this.gaussGrainEffect,
|
2841
|
+
this.spawnSun,
|
2842
|
+
this.sun,
|
2843
|
+
this.setHDRIFromFile.bind(this),
|
2844
|
+
this.setAmbientLight.bind(this),
|
2845
|
+
this.setFog.bind(this)
|
2539
2846
|
);
|
2540
2847
|
window.addEventListener("resize", () => this.updateProjection());
|
2541
2848
|
this.updateProjection();
|
@@ -2569,8 +2876,8 @@ var Composer = class {
|
|
2569
2876
|
this.tweakPane.updateStats(timeManager);
|
2570
2877
|
}
|
2571
2878
|
}
|
2572
|
-
useHDRI(url) {
|
2573
|
-
if (this.isEnvHDRI || !this.renderer)
|
2879
|
+
useHDRI(url, fromFile = false) {
|
2880
|
+
if (this.isEnvHDRI && fromFile === false || !this.renderer)
|
2574
2881
|
return;
|
2575
2882
|
const pmremGenerator = new PMREMGenerator(this.renderer);
|
2576
2883
|
new RGBELoader(new LoadingManager2()).load(
|
@@ -2595,6 +2902,52 @@ var Composer = class {
|
|
2595
2902
|
}
|
2596
2903
|
);
|
2597
2904
|
}
|
2905
|
+
setHDRIFromFile() {
|
2906
|
+
if (!this.renderer)
|
2907
|
+
return;
|
2908
|
+
const fileInput = document.createElement("input");
|
2909
|
+
fileInput.type = "file";
|
2910
|
+
fileInput.accept = ".hdr";
|
2911
|
+
fileInput.addEventListener("change", () => {
|
2912
|
+
const file = fileInput.files?.[0];
|
2913
|
+
if (!file) {
|
2914
|
+
console.log("no file");
|
2915
|
+
return;
|
2916
|
+
}
|
2917
|
+
const fileURL = URL.createObjectURL(file);
|
2918
|
+
if (fileURL) {
|
2919
|
+
this.useHDRI(fileURL, true);
|
2920
|
+
URL.revokeObjectURL(fileURL);
|
2921
|
+
document.body.removeChild(fileInput);
|
2922
|
+
}
|
2923
|
+
});
|
2924
|
+
document.body.appendChild(fileInput);
|
2925
|
+
fileInput.click();
|
2926
|
+
}
|
2927
|
+
setFog() {
|
2928
|
+
const fogColor = new Color6().setRGB(
|
2929
|
+
envValues.fog.fogColor.r,
|
2930
|
+
envValues.fog.fogColor.g,
|
2931
|
+
envValues.fog.fogColor.b
|
2932
|
+
);
|
2933
|
+
this.scene.fog = new Fog(fogColor, envValues.fog.fogNear, envValues.fog.fogFar);
|
2934
|
+
}
|
2935
|
+
setAmbientLight() {
|
2936
|
+
if (this.ambientLight) {
|
2937
|
+
this.scene.remove(this.ambientLight);
|
2938
|
+
this.ambientLight.dispose();
|
2939
|
+
}
|
2940
|
+
const ambientLightColor = new Color6().setRGB(
|
2941
|
+
envValues.ambientLight.ambientLightColor.r,
|
2942
|
+
envValues.ambientLight.ambientLightColor.g,
|
2943
|
+
envValues.ambientLight.ambientLightColor.b
|
2944
|
+
);
|
2945
|
+
this.ambientLight = new AmbientLight(
|
2946
|
+
ambientLightColor,
|
2947
|
+
envValues.ambientLight.ambientLightIntensity
|
2948
|
+
);
|
2949
|
+
this.scene.add(this.ambientLight);
|
2950
|
+
}
|
2598
2951
|
};
|
2599
2952
|
|
2600
2953
|
// src/time/TimeManager.ts
|
@@ -2649,13 +3002,13 @@ import {
|
|
2649
3002
|
getRelativePositionAndRotationRelativeToObject
|
2650
3003
|
} from "mml-web";
|
2651
3004
|
import {
|
2652
|
-
Color as
|
3005
|
+
Color as Color7,
|
2653
3006
|
DoubleSide,
|
2654
3007
|
Euler,
|
2655
3008
|
FrontSide as FrontSide2,
|
2656
3009
|
Mesh as Mesh3,
|
2657
3010
|
MeshStandardMaterial as MeshStandardMaterial2,
|
2658
|
-
Vector3 as
|
3011
|
+
Vector3 as Vector38
|
2659
3012
|
} from "three";
|
2660
3013
|
import * as BufferGeometryUtils from "three/examples/jsm/utils/BufferGeometryUtils.js";
|
2661
3014
|
import { MeshBVH, MeshBVHVisualizer } from "three-mesh-bvh";
|
@@ -2663,8 +3016,8 @@ var CollisionsManager = class {
|
|
2663
3016
|
constructor(scene) {
|
2664
3017
|
__publicField(this, "debug", false);
|
2665
3018
|
__publicField(this, "scene");
|
2666
|
-
__publicField(this, "tempVector", new
|
2667
|
-
__publicField(this, "tempVector2", new
|
3019
|
+
__publicField(this, "tempVector", new Vector38());
|
3020
|
+
__publicField(this, "tempVector2", new Vector38());
|
2668
3021
|
__publicField(this, "collisionMeshState", /* @__PURE__ */ new Map());
|
2669
3022
|
__publicField(this, "collisionTrigger");
|
2670
3023
|
this.scene = scene;
|
@@ -2687,7 +3040,7 @@ var CollisionsManager = class {
|
|
2687
3040
|
group.traverse((child) => {
|
2688
3041
|
if (child.type === "Mesh") {
|
2689
3042
|
const mesh = child;
|
2690
|
-
mesh.localToWorld(new
|
3043
|
+
mesh.localToWorld(new Vector38());
|
2691
3044
|
mesh.updateMatrixWorld();
|
2692
3045
|
const clonedGeometry = mesh.geometry.clone();
|
2693
3046
|
clonedGeometry.applyMatrix4(mesh.matrixWorld);
|
@@ -2714,7 +3067,7 @@ var CollisionsManager = class {
|
|
2714
3067
|
);
|
2715
3068
|
mergedMesh.geometry.boundsTree = meshBVH;
|
2716
3069
|
const visualizer = new MeshBVHVisualizer(mergedMesh, 3);
|
2717
|
-
visualizer.edgeMaterial.color = new
|
3070
|
+
visualizer.edgeMaterial.color = new Color7(255);
|
2718
3071
|
visualizer.update();
|
2719
3072
|
return { source: group, visualizer, meshBVH };
|
2720
3073
|
}
|
@@ -2761,7 +3114,7 @@ var CollisionsManager = class {
|
|
2761
3114
|
const distance = tri.closestPointToSegment(tempSegment, triPoint, capsulePoint);
|
2762
3115
|
if (distance < radius) {
|
2763
3116
|
const depth = radius - distance;
|
2764
|
-
collisionPosition = new
|
3117
|
+
collisionPosition = new Vector38().copy(capsulePoint);
|
2765
3118
|
const direction = capsulePoint.sub(triPoint).normalize();
|
2766
3119
|
tempSegment.start.addScaledVector(direction, depth);
|
2767
3120
|
tempSegment.end.addScaledVector(direction, depth);
|
@@ -2801,6 +3154,7 @@ export {
|
|
2801
3154
|
Composer,
|
2802
3155
|
KeyInputManager,
|
2803
3156
|
MMLCompositionScene,
|
3157
|
+
Sun,
|
2804
3158
|
TimeManager
|
2805
3159
|
};
|
2806
3160
|
//# sourceMappingURL=index.js.map
|