@rings-webgpu/core 1.0.10 → 1.0.11
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/rings.es.js +180 -165
- package/dist/rings.es.js.map +2 -2
- package/dist/rings.es.max.js +662 -644
- package/dist/rings.umd.js +211 -196
- package/dist/rings.umd.js.map +2 -2
- package/dist/rings.umd.max.js +662 -644
- package/dist/types/assets/shader/materials/program/ShadowMapping_frag.d.ts +3 -0
- package/package.json +1 -1
package/dist/rings.es.js
CHANGED
|
@@ -1842,201 +1842,216 @@ var<uniform> materialUniform: MaterialUniform;
|
|
|
1842
1842
|
#endif
|
|
1843
1843
|
}
|
|
1844
1844
|
`,gl=`
|
|
1845
|
-
@group(1) @binding(auto) var shadowMapSampler:
|
|
1845
|
+
@group(1) @binding(auto) var shadowMapSampler: sampler_comparison;
|
|
1846
1846
|
@group(1) @binding(auto) var shadowMap: texture_depth_2d_array;
|
|
1847
|
-
@group(1) @binding(auto) var pointShadowMapSampler:
|
|
1847
|
+
@group(1) @binding(auto) var pointShadowMapSampler: sampler_comparison;
|
|
1848
1848
|
@group(1) @binding(auto) var pointShadowMap: texture_depth_cube_array;
|
|
1849
1849
|
|
|
1850
1850
|
var<private> directShadowVisibility: array<f32, 8>;
|
|
1851
1851
|
var<private> pointShadows: array<f32, 8>;
|
|
1852
|
-
var<private> shadowWeight: f32 = 1.0;
|
|
1852
|
+
var<private> shadowWeight: f32 = 1.0 ;
|
|
1853
1853
|
|
|
1854
1854
|
fn useShadow(){
|
|
1855
|
-
directShadowVisibility = array<f32, 8>(1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0);
|
|
1855
|
+
directShadowVisibility = array<f32, 8>( 1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0) ;
|
|
1856
1856
|
pointShadows = array<f32, 8>(1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0) ;
|
|
1857
1857
|
directShadowMaping(globalUniform.shadowBias);
|
|
1858
1858
|
pointShadowMapCompare(globalUniform.pointShadowBias);
|
|
1859
1859
|
}
|
|
1860
1860
|
|
|
1861
1861
|
fn calcBasicBias(shadowWorldSize:f32, shadowDepthTexSize:f32, near:f32, far:f32) -> f32{
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1862
|
+
var bias = shadowWorldSize / shadowDepthTexSize;
|
|
1863
|
+
bias = bias / (far - near);
|
|
1864
|
+
return bias * 2.0;
|
|
1865
1865
|
}
|
|
1866
1866
|
|
|
1867
|
-
const dirCount:i32 = 8;
|
|
1868
|
-
const pointCount:i32 = 8;
|
|
1869
|
-
const csmCount:i32 = ${Zt.Cascades};
|
|
1867
|
+
const dirCount:i32 = 8 ;
|
|
1868
|
+
const pointCount:i32 = 8 ;
|
|
1869
|
+
const csmCount:i32 = ${Zt.Cascades} ;
|
|
1870
1870
|
var<private> csmLevel:i32 = -1;
|
|
1871
|
+
fn directShadowMaping(shadowBias: f32) {
|
|
1871
1872
|
|
|
1872
|
-
fn directShadowMaping(shadowBias: f32) {
|
|
1873
1873
|
let enableCSM:bool = globalUniform.enableCSM > 0.5;
|
|
1874
|
-
for(var i:i32 = 0; i < dirCount; i = i+1){
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
if(validCount >= 2 || totalWeight >= 0.99){
|
|
1908
|
-
csmLevel = csm;
|
|
1909
|
-
break;
|
|
1910
|
-
};
|
|
1911
|
-
}
|
|
1912
|
-
}
|
|
1913
|
-
|
|
1914
|
-
totalWeight += 0.0001;
|
|
1915
|
-
if(validCount == 0){
|
|
1916
|
-
visibility = 1.0;
|
|
1917
|
-
}else{
|
|
1918
|
-
visibility = visibility / totalWeight ;
|
|
1919
|
-
};
|
|
1920
|
-
} else {
|
|
1921
|
-
shadowMatrix = globalUniform.shadowMatrix[shadowIndex];
|
|
1922
|
-
if(enableCSM) {
|
|
1923
|
-
shadowIndex += csmCount - 1;
|
|
1924
|
-
}
|
|
1925
|
-
visibility = directShadowMapingIndex(light, shadowMatrix, shadowIndex, shadowBias).x;
|
|
1874
|
+
for (var i: i32 = 0; i < dirCount ; i = i + 1) {
|
|
1875
|
+
if( i >= globalUniform.nDirShadowStart && i < globalUniform.nDirShadowEnd ){
|
|
1876
|
+
let ldx = globalUniform.shadowLights[u32(i) / 4u][u32(i) % 4u];
|
|
1877
|
+
let light = lightBuffer[u32(ldx)] ;
|
|
1878
|
+
var shadowIndex = i32(light.castShadow);
|
|
1879
|
+
var visibility = 1.0;
|
|
1880
|
+
var shadowMatrix:mat4x4<f32>;
|
|
1881
|
+
#if USE_CSM
|
|
1882
|
+
if(enableCSM && shadowIndex == 0){
|
|
1883
|
+
var totalWeight = 0.0;
|
|
1884
|
+
visibility = 0.0;
|
|
1885
|
+
var validCount = 0;
|
|
1886
|
+
for(var csm:i32 = 0; csm < csmCount; csm ++){
|
|
1887
|
+
var csmShadowBias = globalUniform.csmShadowBias[csm] * shadowBias;
|
|
1888
|
+
shadowMatrix = globalUniform.csmMatrix[csm];
|
|
1889
|
+
let csmShadowResult = directShadowMapingIndex(light, shadowMatrix, csm, csmShadowBias);
|
|
1890
|
+
if(csmShadowResult.y < 0.5){
|
|
1891
|
+
validCount ++;
|
|
1892
|
+
|
|
1893
|
+
var uv = 2.0 * csmShadowResult.zw - vec2<f32>(1.0);
|
|
1894
|
+
uv = saturate(vec2<f32>(1.0) - abs(uv));
|
|
1895
|
+
uv /= clamp(globalUniform.csmMargin, 0.01, 0.5);
|
|
1896
|
+
var weight:f32 = min(uv.x, 1.0);
|
|
1897
|
+
weight = min(weight, uv.y);
|
|
1898
|
+
|
|
1899
|
+
if(validCount == 1 && csm == csmCount - 1){
|
|
1900
|
+
visibility = 1.0 - weight + csmShadowResult.x * weight;
|
|
1901
|
+
totalWeight = 1.0;
|
|
1902
|
+
}else{
|
|
1903
|
+
weight *= 1.0 - totalWeight;
|
|
1904
|
+
visibility += csmShadowResult.x * weight;
|
|
1905
|
+
totalWeight += weight;
|
|
1926
1906
|
}
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1907
|
+
// if(weight < 1.0){
|
|
1908
|
+
// visibility += 0.1;
|
|
1909
|
+
// }
|
|
1910
|
+
if(validCount >= 2 || totalWeight >= 0.99){
|
|
1911
|
+
csmLevel = csm;
|
|
1912
|
+
break;
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
}
|
|
1916
|
+
totalWeight += 0.0001;
|
|
1917
|
+
if(validCount == 0){
|
|
1918
|
+
visibility = 1.0;
|
|
1919
|
+
}else{
|
|
1920
|
+
visibility = visibility / totalWeight ;
|
|
1921
|
+
}
|
|
1922
|
+
}else{
|
|
1923
|
+
shadowMatrix = globalUniform.shadowMatrix[shadowIndex];
|
|
1924
|
+
if(enableCSM) {
|
|
1925
|
+
shadowIndex += csmCount - 1;
|
|
1926
|
+
}
|
|
1927
|
+
visibility = directShadowMapingIndex(light, shadowMatrix, shadowIndex, shadowBias).x;
|
|
1928
|
+
}
|
|
1929
|
+
#else
|
|
1930
|
+
shadowMatrix = globalUniform.shadowMatrix[shadowIndex];
|
|
1931
|
+
visibility = directShadowMapingIndex(light, shadowMatrix, shadowIndex, shadowBias).x;
|
|
1932
|
+
#endif
|
|
1933
|
+
directShadowVisibility[i] = visibility;
|
|
1934
|
+
}
|
|
1933
1935
|
}
|
|
1936
|
+
|
|
1934
1937
|
}
|
|
1935
1938
|
|
|
1936
|
-
fn directShadowMapingIndex(light:LightData, matrix:mat4x4<f32>, depthTexIndex:i32, shadowBias:f32) -> vec4<f32>
|
|
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
|
-
|
|
1939
|
+
fn directShadowMapingIndex(light:LightData, matrix:mat4x4<f32>, depthTexIndex:i32, shadowBias:f32) -> vec4<f32>
|
|
1940
|
+
{
|
|
1941
|
+
var visibility = 1.0;
|
|
1942
|
+
var isOutSideArea:f32 = 1.0;
|
|
1943
|
+
var varying_shadowUV:vec2<f32> = vec2<f32>(0.0);
|
|
1944
|
+
#if USE_SHADOWMAPING
|
|
1945
|
+
var shadowPosTmp = matrix * vec4<f32>(ORI_VertexVarying.vWorldPos.xyz, 1.0);
|
|
1946
|
+
var shadowPos = shadowPosTmp.xyz / shadowPosTmp.w;
|
|
1947
|
+
varying_shadowUV = shadowPos.xy * vec2<f32>(0.5, -0.5) + vec2<f32>(0.5, 0.5);
|
|
1948
|
+
if (varying_shadowUV.x <= 1.0
|
|
1949
|
+
&& varying_shadowUV.x >= 0.0
|
|
1950
|
+
&& varying_shadowUV.y <= 1.0
|
|
1951
|
+
&& varying_shadowUV.y >= 0.0
|
|
1952
|
+
&& shadowPosTmp.z <= 1.0
|
|
1953
|
+
&& shadowPosTmp.z >= 0.0)
|
|
1954
|
+
{
|
|
1955
|
+
visibility = 0.0;
|
|
1956
|
+
isOutSideArea = 0.0;
|
|
1957
|
+
var uvOnePixel = 1.0 / vec2<f32>(globalUniform.shadowMapSize) ;
|
|
1958
|
+
var totalWeight = 0.0;
|
|
1959
|
+
// var NoL = (dot(normalize(ORI_VertexVarying.vWorldNormal), normalize(-light.direction)));
|
|
1960
|
+
// let v = max(NoL, 0.0) ;
|
|
1961
|
+
// var bias = max(0.05 * (dot(normalize(fragData.N), normalize(-light.direction)) ), -shadowBias);
|
|
1962
|
+
var bias = -0.005 * max(dot(fragData.N, -light.direction) , 0.0 );
|
|
1963
|
+
bias = clamp(bias, 0, 0.01) + -shadowBias;
|
|
1964
|
+
|
|
1965
|
+
// var bias = shadowBias / v;
|
|
1966
|
+
let bound = 1 ;
|
|
1967
|
+
for (var y = -bound; y <= bound; y++) {
|
|
1968
|
+
for (var x = -bound; x <= bound; x++) {
|
|
1969
|
+
var offset = vec2<f32>(f32(x), f32(y)) ;
|
|
1970
|
+
var offsetUV = offset * uvOnePixel ;
|
|
1971
|
+
var weight = min(length(offset),1.0) ;
|
|
1972
|
+
var depth = textureSampleCompareLevel(shadowMap, shadowMapSampler, varying_shadowUV + offsetUV , depthTexIndex, shadowPos.z - bias);
|
|
1973
|
+
if (depth < 0.5) {
|
|
1974
|
+
totalWeight += 1.0;
|
|
1975
|
+
}else{
|
|
1976
|
+
visibility += weight;
|
|
1977
|
+
totalWeight += weight;
|
|
1970
1978
|
}
|
|
1971
|
-
visibility /= totalWeight;
|
|
1972
1979
|
}
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
let light = lightBuffer[u32(ldx)];
|
|
1984
|
-
|
|
1985
|
-
#if USE_SHADOWMAPING
|
|
1986
|
-
let lightPos = light.position.xyz;
|
|
1987
|
-
var shadow = 0.0;
|
|
1988
|
-
let frgToLight = worldPos - lightPos.xyz;
|
|
1989
|
-
var dir: vec3<f32> = normalize(frgToLight);
|
|
1990
|
-
var len = length(frgToLight);
|
|
1991
|
-
var bias = max(shadowBias * globalUniform.far * (1.0 - dot(ORI_ShadingInput.Normal, dir)), 0.005);
|
|
1992
|
-
|
|
1993
|
-
#if USE_PCF_SHADOW
|
|
1994
|
-
let samples = 4.0;
|
|
1995
|
-
let sampleOffset = offset / (samples * 0.5);
|
|
1996
|
-
for (var x: f32 = -offset; x < offset; x += sampleOffset) {
|
|
1997
|
-
for (var y: f32 = -offset; y < offset; y += sampleOffset) {
|
|
1998
|
-
for (var z: f32 = -offset; z < offset; z += sampleOffset) {
|
|
1999
|
-
let offsetDir = normalize(dir.xyz + vec3<f32>(x, y, z));
|
|
2000
|
-
var depth = textureSampleLevel(pointShadowMap, pointShadowMapSampler, offsetDir, light.castShadow, 0);
|
|
2001
|
-
depth *= globalUniform.far;
|
|
2002
|
-
if ((len - bias) > depth) {
|
|
2003
|
-
shadow += 1.0 * dot(offsetDir, dir.xyz);
|
|
2004
|
-
}
|
|
2005
|
-
}
|
|
2006
|
-
}
|
|
2007
|
-
}
|
|
2008
|
-
shadow = min(max(shadow / (samples * samples * samples), 0.0), 1.0);
|
|
2009
|
-
#endif
|
|
1980
|
+
}
|
|
1981
|
+
visibility /= totalWeight;
|
|
1982
|
+
}
|
|
1983
|
+
#endif
|
|
1984
|
+
return vec4<f32>(visibility, isOutSideArea, varying_shadowUV);
|
|
1985
|
+
}
|
|
1986
|
+
|
|
1987
|
+
fn pointShadowMapCompare(shadowBias: f32){
|
|
1988
|
+
let worldPos = ORI_VertexVarying.vWorldPos.xyz;
|
|
1989
|
+
let offset = 0.1;
|
|
2010
1990
|
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
1991
|
+
for (var i: i32 = 0; i < pointCount ; i = i + 1) {
|
|
1992
|
+
if( i >= globalUniform.nPointShadowStart && i < globalUniform.nPointShadowEnd ){
|
|
1993
|
+
let ldx = globalUniform.shadowLights[u32(i) / 4u][u32(i) % 4u];
|
|
1994
|
+
let light = lightBuffer[u32(ldx)] ;
|
|
1995
|
+
|
|
1996
|
+
#if USE_SHADOWMAPING
|
|
1997
|
+
let lightPos = light.position.xyz;
|
|
1998
|
+
var shadow = 0.0;
|
|
1999
|
+
let frgToLight = worldPos - lightPos.xyz;
|
|
2000
|
+
var dir: vec3<f32> = normalize(frgToLight);
|
|
2001
|
+
var len = length(frgToLight);
|
|
2002
|
+
var bias = max(shadowBias * globalUniform.far * (1.0 - dot(ORI_ShadingInput.Normal, dir)), 0.005);
|
|
2003
|
+
|
|
2004
|
+
#if USE_PCF_SHADOW
|
|
2005
|
+
let samples = 4.0;
|
|
2006
|
+
let sampleOffset = offset / (samples * 0.5);
|
|
2007
|
+
for (var x: f32 = -offset; x < offset; x += sampleOffset) {
|
|
2008
|
+
for (var y: f32 = -offset; y < offset; y += sampleOffset) {
|
|
2009
|
+
for (var z: f32 = -offset; z < offset; z += sampleOffset) {
|
|
2010
|
+
let compareZ = (len - bias) / globalUniform.far;
|
|
2011
|
+
var depth = textureSampleCompareLevel(pointShadowMap, pointShadowMapSampler, dir.xyz, light.castShadow, compareZ);
|
|
2012
|
+
if (depth < 0.5) {
|
|
2013
|
+
shadow = 1.0;
|
|
2021
2014
|
}
|
|
2015
|
+
for (var j = 0; j < pointCount ; j+=1 ){
|
|
2016
|
+
if(i32(light.castShadow) == j){
|
|
2017
|
+
pointShadows[j] = 1.0 - shadow;
|
|
2018
|
+
}
|
|
2019
|
+
}
|
|
2020
|
+
}
|
|
2022
2021
|
}
|
|
2023
|
-
|
|
2022
|
+
}
|
|
2023
|
+
shadow = min(max(shadow / (samples * samples * samples), 0.0), 1.0);
|
|
2024
2024
|
#endif
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2025
|
+
|
|
2026
|
+
#if USE_SOFT_SHADOW
|
|
2027
|
+
let vDis = length(globalUniform.CameraPos.xyz - worldPos.xyz);
|
|
2028
|
+
let sampleRadies = globalUniform.shadowSoft;
|
|
2029
|
+
let samples = 20;
|
|
2030
|
+
for (var j: i32 = 0; j < samples; j += 1) {
|
|
2031
|
+
let offsetDir = normalize(dir.xyz + sampleOffsetDir[j] * sampleRadies);
|
|
2032
|
+
var depth = textureSampleCompareLevel(pointShadowMap, pointShadowMapSampler, offsetDir, light.castShadow, 0);
|
|
2028
2033
|
depth *= globalUniform.far;
|
|
2029
2034
|
if ((len - bias) > depth) {
|
|
2030
|
-
|
|
2031
|
-
}
|
|
2032
|
-
#endif
|
|
2033
|
-
for (var j=0; j < pointCount; j+=1) {
|
|
2034
|
-
if(i32(light.castShadow) == j){
|
|
2035
|
-
pointShadows[j] = 1.0 - shadow;
|
|
2036
|
-
}
|
|
2035
|
+
shadow += 1.0 * dot(offsetDir, dir.xyz);
|
|
2037
2036
|
}
|
|
2038
|
-
|
|
2039
|
-
|
|
2037
|
+
}
|
|
2038
|
+
shadow = min(max(shadow / f32(samples), 0.0), 1.0);
|
|
2039
|
+
#endif
|
|
2040
|
+
|
|
2041
|
+
#if USE_HARD_SHADOW
|
|
2042
|
+
var depth = textureSampleCompareLevel(pointShadowMap, pointShadowMapSampler, dir.xyz, light.castShadow, 0);
|
|
2043
|
+
depth *= globalUniform.far;
|
|
2044
|
+
if ((len - bias) > depth) {
|
|
2045
|
+
shadow = 1.0;
|
|
2046
|
+
}
|
|
2047
|
+
#endif
|
|
2048
|
+
for (var j = 0; j < pointCount ; j+=1 ) {
|
|
2049
|
+
if(i32(light.castShadow) == j){
|
|
2050
|
+
pointShadows[j] = 1.0 - shadow ;
|
|
2051
|
+
}
|
|
2052
|
+
}
|
|
2053
|
+
#endif
|
|
2054
|
+
}
|
|
2040
2055
|
}
|
|
2041
2056
|
}
|
|
2042
2057
|
|
|
@@ -7557,7 +7572,7 @@ $1\r
|
|
|
7557
7572
|
`;class hc{compute;constructor(){this.compute=new ue(lc)}generateBRDFLUTTexture(){let e=new Ae(256,256,X.rgba8unorm,!1,GPUTextureUsage.STORAGE_BINDING|GPUTextureUsage.TEXTURE_BINDING);this.compute.setStorageTexture("brdflutTexture",e),this.compute.workerSizeX=256/8,this.compute.workerSizeY=256/8;let t=F.beginCommandEncoder();return F.computeCommand(t,[this.compute]),F.endCommandEncoder(t),e}}class Ki{id;guiTexture;uvRec=new $(0,0,1,1);uvBorder=new $(0,0,0,0);offsetSize=new $(0,0,4,4);borderSize=new $(0,0,0,0);trimSize=new K;isSliced=!1;height=4;width=4;xadvance=0;xoffset=0;yoffset=0;constructor(e){this.guiTexture=e||m.res.defaultGUITexture}}class fi{static _maxUid=-1;_staticId=-1;dynamicId=-1;texture;width=1;height=1;get staticId(){return this._staticId}constructor(e){e||=m.res.whiteTexture,e.addressModeU="clamp-to-edge",e.addressModeV="clamp-to-edge",this.texture=e,fi._maxUid++,this._staticId=fi._maxUid,this.init()}init(){this.dynamicId=-1,this.width=this.texture.width,this.height=this.texture.height}}class xp{fntCache={};fntData={};addFontData(e,t,r){this.fntData[`${e}${t}`]=r}getFontData(e,t){return this.fntData[`${e}${t}`]}addFnt(e,t,r,i){let a=`${e}${t}`;this.fntCache[a]||(this.fntCache[a]={}),this.fntCache[a][r]=i}getFnt(e,t,r){let i=`${e}${t}`,a=this.fntCache[i];return a?a[r]:this.fntCache[" "]}}let qi=new xp;class uc{face="";size=0;bold=!1;italic=!1;stretchH=0;spacing="";outline=0;lineHeight=0;base=0;scaleW=0;scaleH=0;pages=0;packed=0;alphaChnl=0;redChnl=0;greenChnl=0;blueChnl=0;count=0;fontPage=[];fontChar={};constructor(){}}class cc{id=0;file=""}class fc{id=-1;x=0;y=0;width=0;height=0;xoffset=0;yoffset=0;xadvance=0;page=0;chnl=0}class Lr extends st{static format=Ge.TEXT;static parseSprite(e,t){for(const r in t.fontChar)if(Object.prototype.hasOwnProperty.call(t.fontChar,r)){const i=t.fontChar[r];let a=new Ki;a.id=i.id.toString(),a.offsetSize.set(0,0,i.width,i.height),a.trimSize.set(i.width,i.height),a.width=i.width,a.height=i.height,a.xadvance=i.xadvance,a.xoffset=i.xoffset,a.yoffset=i.yoffset,a.guiTexture=e[i.page],a.uvRec.set(i.x/t.scaleW,(t.scaleH-(i.y+i.height))/t.scaleH,i.width/t.scaleW,i.height/t.scaleH),qi.addFnt(t.face,t.size,a.id,a)}}verification(){if(this.data)return!0;throw new Error("Method not implemented.")}async parseString(e){let t=this.getNewLine(e),r=e,i=new uc;r.trim().split(t).forEach((a,o)=>{if(o<2)Lr.readLineProperty(a,i);else if(o<i.pages+2){let n=new cc;Lr.readLineProperty(a,n),i.fontPage.push(n)}else if(o<i.pages+3)Lr.readLineProperty(a,i);else if(i.count>0){let n=new fc;Lr.readLineProperty(a,n),i.fontChar[n.id]=n,i.count--}}),r="",this.data=i,await this.loadFontTextures()}getNewLine(e){return e.indexOf(`\r
|
|
7558
7573
|
`)!=-1?`\r
|
|
7559
7574
|
`:e.indexOf("\r")!=-1?"\r":`
|
|
7560
|
-
`}async loadFontTextures(){let e=[],t=this.data;for(const r of t.fontPage){let i=this.baseUrl+r.file;await m.res.loadTexture(i,null,!0);let a=m.res.getTexture(i),o=new fi(a);e.push(o)}Lr.parseSprite(e,t),t.fontChar[" "]||Lr.insertSpaceChar(t,e[0])}static insertSpaceChar(e,t){let r=new Ki,i=e.size*.5,a=e.lineHeight*.5;r.id=" ",r.offsetSize.set(0,0,e.size,e.size),r.trimSize.set(i,a),r.width=i,r.height=a,r.xadvance=0,r.xoffset=0,r.yoffset=0,r.guiTexture=t,r.uvRec.set(0,0,1e-6,1e-6),qi.addFnt(e.face,e.size,r.id,r)}static readLineProperty(e,t){e.trim().split(" ").forEach((r,i)=>{let a=r.split("=");if(a.length>1){let o=a[0],n=a[1];Object.prototype.hasOwnProperty.call(t,o)&&(n.indexOf('"')==-1?t[o]=parseFloat(a[1]):t[o]=n.replace('"',"").replace('"',""))}})}}function Bp(s,e){let t=new Ki;return t.id=s,t.offsetSize.set(0,0,e.width,e.height),t.trimSize.set(e.width,e.height),t.width=e.width,t.height=e.height,t.xadvance=0,t.xoffset=0,t.yoffset=0,t.guiTexture=new fi(e),t.uvRec.set(0,0,1,1),e.isVideoTexture||(e.flipY=!0),t}function dc(s,e,t){let r=new Ki;r.guiTexture=s,r.id=e,r.uvRec.copyFrom(t.textureRect),r.trimSize.x=t.textureRect.z,r.trimSize.y=t.textureRect.w,r.offsetSize.x=t.textureRectOffset.x,r.offsetSize.y=t.textureRectOffset.y,r.offsetSize.z=t.size.x,r.offsetSize.w=t.size.y,r.width=t.size.x,r.height=t.size.y;let i=1/s.width,a=1/s.height;r.uvRec.set(r.uvRec.x*i,r.uvRec.y*a,r.uvRec.z*i,r.uvRec.w*a);let o=.1;return t.border.x<=o&&t.border.y<=o&&t.border.z<=o&&t.border.x<=o?r.isSliced=!1:(r.borderSize.copyFrom(t.border),r.uvBorder.copyFrom(t.border),r.uvBorder.x-=t.textureRectOffset.x,r.uvBorder.y-=t.textureRectOffset.y,r.uvBorder.z=t.border.z-(t.size.x-t.textureRect.z-t.textureRectOffset.x),r.uvBorder.w=t.border.w-(t.size.y-t.textureRect.w-t.textureRectOffset.y),r.uvBorder.x/=t.textureRect.z,r.uvBorder.z/=t.textureRect.z,r.uvBorder.y/=t.textureRect.w,r.uvBorder.w/=t.textureRect.w,r.isSliced=!0),r}class gc{_spriteMap=new Map;_spriteList=[];textureSize=new K;name;constructor(e){this.textureSize.set(e.x,e.y)}setTexture(e,t,r){let i=dc(e,t,r);return this._spriteMap.set(i.id,i),this._spriteList.push(i),i}getSprite(e){return this._spriteMap.get(e)}get spriteList(){return this._spriteList}}class pc extends st{static format=Ge.TEXT;_json;_texture;async parseString(e){this._json=JSON.parse(e);let t=this.userData.replace(".json",".png");this._texture=await m.res.loadTexture(t,null,!0),this.data={json:this._json,texture:this._texture},this.parseAtlas()}verification(){if(this.data)return!0;throw new Error("verify failed.")}parseAtlas(){let e=new gc(this._json.size),t=new fi(this._texture),r=this._json.atlas;for(const i in r)e.setTexture(t,i,r[i]);m.res.addAtlas(this.baseUrl,e),this.data=e}}var kt=Uint8Array,$i=Uint16Array,vp=Int32Array,mc=new kt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Ac=new kt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Cp=new kt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Uc=function(s,e){for(var t=new $i(31),r=0;r<31;++r)t[r]=e+=1<<s[r-1];for(var i=new vp(t[30]),r=1;r<30;++r)for(var a=t[r];a<t[r+1];++a)i[a]=a-t[r]<<5|r;return{b:t,r:i}},xc=Uc(mc,2),Bc=xc.b,Sp=xc.r;Bc[28]=258,Sp[258]=28;for(var _p=Uc(Ac,0),Fp=_p.b,tn=new $i(32768),De=0;De<32768;++De){var ri=(De&43690)>>1|(De&21845)<<1;ri=(ri&52428)>>2|(ri&13107)<<2,ri=(ri&61680)>>4|(ri&3855)<<4,tn[De]=((ri&65280)>>8|(ri&255)<<8)>>1}for(var va=(function(s,e,t){for(var r=s.length,i=0,a=new $i(e);i<r;++i)s[i]&&++a[s[i]-1];var o=new $i(e);for(i=1;i<e;++i)o[i]=o[i-1]+a[i-1]<<1;var n;if(t){n=new $i(1<<e);var l=15-e;for(i=0;i<r;++i)if(s[i])for(var h=i<<4|s[i],u=e-s[i],c=o[s[i]-1]++<<u,f=c|(1<<u)-1;c<=f;++c)n[tn[c]>>l]=h}else for(n=new $i(r),i=0;i<r;++i)s[i]&&(n[i]=tn[o[s[i]-1]++]>>15-s[i]);return n}),Ca=new kt(288),De=0;De<144;++De)Ca[De]=8;for(var De=144;De<256;++De)Ca[De]=9;for(var De=256;De<280;++De)Ca[De]=7;for(var De=280;De<288;++De)Ca[De]=8;for(var vc=new kt(32),De=0;De<32;++De)vc[De]=5;var yp=va(Ca,9,1),bp=va(vc,5,1),rn=function(s){for(var e=s[0],t=1;t<s.length;++t)s[t]>e&&(e=s[t]);return e},sr=function(s,e,t){var r=e/8|0;return(s[r]|s[r+1]<<8)>>(e&7)&t},an=function(s,e){var t=e/8|0;return(s[t]|s[t+1]<<8|s[t+2]<<16)>>(e&7)},Qp=function(s){return(s+7)/8|0},sn=function(s,e,t){return(e==null||e<0)&&(e=0),(t==null||t>s.length)&&(t=s.length),new kt(s.subarray(e,t))},Rp=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Ht=function(s,e,t){var r=new Error(e||Rp[s]);if(r.code=s,Error.captureStackTrace&&Error.captureStackTrace(r,Ht),!t)throw r;return r},Ip=function(s,e,t,r){var i=s.length,a=r?r.length:0;if(!i||e.f&&!e.l)return t||new kt(0);var o=!t,n=o||e.i!=2,l=e.i;o&&(t=new kt(i*3));var h=function(Qt){var Rt=t.length;if(Qt>Rt){var Nt=new kt(Math.max(Rt*2,Qt));Nt.set(t),t=Nt}},u=e.f||0,c=e.p||0,f=e.b||0,g=e.l,p=e.d,A=e.m,U=e.n,x=i*8;do{if(!g){u=sr(s,c,1);var B=sr(s,c+1,3);if(c+=3,B)if(B==1)g=yp,p=bp,A=9,U=5;else if(B==2){var y=sr(s,c,31)+257,b=sr(s,c+10,15)+4,w=y+sr(s,c+5,31)+1;c+=14;for(var Q=new kt(w),E=new kt(19),M=0;M<b;++M)E[Cp[M]]=sr(s,c+M*3,7);c+=b*3;for(var z=rn(E),Y=(1<<z)-1,ee=va(E,z,1),M=0;M<w;){var oe=ee[sr(s,c,Y)];c+=oe&15;var S=oe>>4;if(S<16)Q[M++]=S;else{var te=0,ge=0;for(S==16?(ge=3+sr(s,c,3),c+=2,te=Q[M-1]):S==17?(ge=3+sr(s,c,7),c+=3):S==18&&(ge=11+sr(s,c,127),c+=7);ge--;)Q[M++]=te}}var Ce=Q.subarray(0,y),J=Q.subarray(y);A=rn(Ce),U=rn(J),g=va(Ce,A,1),p=va(J,U,1)}else Ht(1);else{var S=Qp(c)+4,C=s[S-4]|s[S-3]<<8,_=S+C;if(_>i){l&&Ht(0);break}n&&h(f+C),t.set(s.subarray(S,_),f),e.b=f+=C,e.p=c=_*8,e.f=u;continue}if(c>x){l&&Ht(0);break}}n&&h(f+131072);for(var ce=(1<<A)-1,he=(1<<U)-1,Ue=c;;Ue=c){var te=g[an(s,c)&ce],xe=te>>4;if(c+=te&15,c>x){l&&Ht(0);break}if(te||Ht(2),xe<256)t[f++]=xe;else if(xe==256){Ue=c,g=null;break}else{var Ve=xe-254;if(xe>264){var M=xe-257,Ie=mc[M];Ve=sr(s,c,(1<<Ie)-1)+Bc[M],c+=Ie}var Fe=p[an(s,c)&he],Me=Fe>>4;Fe||Ht(3),c+=Fe&15;var J=Fp[Me];if(Me>3){var Ie=Ac[Me];J+=an(s,c)&(1<<Ie)-1,c+=Ie}if(c>x){l&&Ht(0);break}n&&h(f+131072);var nt=f+Ve;if(f<J){var pr=a-J,Mt=Math.min(J,nt);for(pr+f<0&&Ht(3);f<Mt;++f)t[f]=r[pr+f]}for(;f<nt;++f)t[f]=t[f-J]}}e.l=g,e.p=Ue,e.b=f,e.f=u,g&&(u=1,e.m=A,e.d=p,e.n=U)}while(!u);return f!=t.length&&o?sn(t,0,f):t.subarray(0,f)},Ep=new kt(0),Fr=function(s,e){return s[e]|s[e+1]<<8},or=function(s,e){return(s[e]|s[e+1]<<8|s[e+2]<<16|s[e+3]<<24)>>>0},on=function(s,e){return or(s,e)+or(s,e+4)*4294967296};function wp(s,e){return Ip(s,{i:2},e&&e.out,e&&e.dictionary)}var nn=typeof TextDecoder<"u"&&new TextDecoder,Tp=0;try{nn.decode(Ep,{stream:!0}),Tp=1}catch{}var Dp=function(s){for(var e="",t=0;;){var r=s[t++],i=(r>127)+(r>223)+(r>239);if(t+i>s.length)return{s:e,r:sn(s,t-1)};i?i==3?(r=((r&15)<<18|(s[t++]&63)<<12|(s[t++]&63)<<6|s[t++]&63)-65536,e+=String.fromCharCode(55296|r>>10,56320|r&1023)):i&1?e+=String.fromCharCode((r&31)<<6|s[t++]&63):e+=String.fromCharCode((r&15)<<12|(s[t++]&63)<<6|s[t++]&63):e+=String.fromCharCode(r)}};function Cc(s,e){if(e){for(var t="",r=0;r<s.length;r+=16384)t+=String.fromCharCode.apply(null,s.subarray(r,r+16384));return t}else{if(nn)return nn.decode(s);var i=Dp(s),a=i.s,t=i.r;return t.length&&Ht(8),a}}var Mp=function(s,e){return e+30+Fr(s,e+26)+Fr(s,e+28)},Np=function(s,e,t){var r=Fr(s,e+28),i=Cc(s.subarray(e+46,e+46+r),!(Fr(s,e+8)&2048)),a=e+46+r,o=or(s,e+20),n=t&&o==4294967295?Vp(s,a):[o,or(s,e+24),or(s,e+42)],l=n[0],h=n[1],u=n[2];return[Fr(s,e+10),l,h,i,a+Fr(s,e+30)+Fr(s,e+32),u]},Vp=function(s,e){for(;Fr(s,e)!=1;e+=4+Fr(s,e+2));return[on(s,e+12),on(s,e+4),on(s,e+20)]};function Pp(s,e){for(var t={},r=s.length-22;or(s,r)!=101010256;--r)(!r||s.length-r>65558)&&Ht(13);var i=Fr(s,r+8);if(!i)return{};var a=or(s,r+16),o=a==4294967295||i==65535;if(o){var n=or(s,r-12);o=or(s,n)==101075792,o&&(i=or(s,n+32),a=or(s,n+48))}for(var l=0;l<i;++l){var h=Np(s,a,o),u=h[0],c=h[1],f=h[2],g=h[3],p=h[4],A=h[5],U=Mp(s,A);a=p,u?u==8?t[g]=wp(s.subarray(U,U+c),{out:new kt(f)}):Ht(14,"unknown compression type "+u):t[g]=sn(s,U,U+c)}return t}class pt extends yt{constructor(){super(),this.shader=new Ea,this.baseMap=m.res.whiteTexture}set baseMap(e){this.shader.setTexture("baseMap",e)}get baseMap(){return this.shader.getTexture("baseMap")}set baseColor(e){this.shader.setUniformColor("baseColor",e)}get baseColor(){return this.shader.getUniformColor("baseColor")}set envMap(e){}set shadowMap(e){}}class Ri extends Ne{shape_vertices=[];shape_indices=[];radius;widthSegments;heightSegments;phiStart;phiLength;thetaStart;thetaLength;constructor(e,t,r,i,a,o,n){super(),this.radius=e,this.widthSegments=t,this.heightSegments=r,this.phiStart=i,this.phiLength=a,this.thetaStart=o,this.thetaLength=n,this.buildGeometry()}buildGeometry(){var e,t,r=0;let i=this.heightSegments,a=this.widthSegments,o=this.radius;var n=(i+1)*(a+1);let l=new Float32Array(n*3),h=new Float32Array(n*3),u=new Float32Array(n*2),c=new Uint16Array(a*i*2*3),f=0,g=0,p=0;for(t=0;t<=i;++t){var A=Math.PI*t/i,U=o*Math.cos(A),x=o*Math.sin(A);for(e=0;e<=a;++e){var B=2*Math.PI*e/a,S=x*Math.cos(B),C=x*Math.sin(B),_=1/Math.sqrt(S*S+U*U+C*C);if(l[f++]=S,l[f++]=U,l[f++]=C,h[g++]=S*_,h[g++]=U*_,h[g++]=C*_,u[p++]=e/a,u[p++]=t/i,e>0&&t>0){var y=(a+1)*t+e,b=(a+1)*t+e-1,w=(a+1)*(t-1)+e-1,Q=(a+1)*(t-1)+e;t==i?(c[r++]=y,c[r++]=w,c[r++]=Q):t==1?(c[r++]=y,c[r++]=b,c[r++]=w):(c[r++]=y,c[r++]=b,c[r++]=w,c[r++]=y,c[r++]=w,c[r++]=Q)}}}this.setIndices(c),this.setAttribute(V.position,l),this.setAttribute(V.normal,h),this.setAttribute(V.uv,u),this.setAttribute(V.TEXCOORD_1,u),this.addSubGeometry({indexStart:0,indexCount:c.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0}),this.bounds=new Re(d.ZERO,new d(this.radius*2,this.radius*2,this.radius*2))}}class $a extends q{static register3DRepresentation=null;positionIndex=-1;positionValid=!1;marker;constructor(e){super(),this.parsePlacemark(e),this.setup3DRepresentation()}parsePlacemark(e){if(!e.slamPositionInfo){console.warn("WayPoint3D: slamPositionInfo is not found");return}const t=e.slamPositionInfo.slamPosition.split(",").map(Number);this.localPosition=new d(t[0],t[1],t[2]),this.positionIndex=Number(e.slamPositionInfo.slamPositionIndex),this.positionValid=e.slamPositionInfo.slamPositionValid==="1"}setup3DRepresentation(){if(this.marker&&(this.removeChild(this.marker),this.marker=null),$a.register3DRepresentation)this.marker=$a.register3DRepresentation(this),this.marker&&this.addChild(this.marker);else{this.marker=new q;const e=this.marker.addComponent(j);e.geometry=new Ri(.1,32,16),e.material=new pt,e.material.baseColor=this.positionValid?new P(0,1,0,1):new P(1,0,0,1),this.addChild(this.marker),this.marker.name="WayPoint3DMarker"}}}class es extends q{static register3DRepresentation=null;line;constructor(e){super(),this.parseWayLineFile(e),this.setup3DRepresentation()}parseWayLineFile(e){for(const t of e.Folder.Placemark){const r=new $a(t);this.addChild(r)}this.entityChildren=this.entityChildren.sort((t,r)=>t.positionIndex-r.positionIndex)}setup3DRepresentation(){this.line&&(this.removeChild(this.line),this.line=null),es.register3DRepresentation?(this.line=es.register3DRepresentation(this),this.line&&this.addChild(this.line)):(this.line=this.createMultiLine(this.entityChildren.map(e=>e.localPosition),new P(1,1,1,1)),this.addChild(this.line),this.line.name="WayLines3DLine")}createMultiLine(e,t){if(e.length<2)return null;const r=new Ne,i=new Float32Array(e.length*3);for(let h=0;h<e.length;h++)i[h*3]=e[h].x,i[h*3+1]=e[h].y,i[h*3+2]=e[h].z;const a=new Uint16Array((e.length-1)*2);for(let h=0;h<e.length-1;h++)a[h*2]=h,a[h*2+1]=h+1;r.setIndices(a),r.setAttribute(V.position,i),r.addSubGeometry({indexStart:0,indexCount:a.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0});const o=new q,n=o.addComponent(j),l=new pt;return l.topology="line-list",l.baseColor=t,l.blendMode=ae.ADD,l.castReflection=!1,n.geometry=r,n.material=l,o}}class Sc extends st{static format=Ge.BIN;parseBuffer(e){try{const t={template:null,waylines:null},r=Pp(new Uint8Array(e));for(const a in r){const o=r[a],l=new DOMParser().parseFromString(Cc(o),"application/xml"),h={};this.parseNode(l,h);const u=a.replace("wpmz/","").split(".")[0];Object.assign(t,{[u]:h["#document"].kml.Document})}const i=new es(t.waylines);this.data=i}catch(t){this.parserError(`KMZ parsing failed: ${t}`,-1)}}parseNode(e,t){const r=["Placemark","actionGroup","action"],i=e.nodeName.replace("wpml:","");if(!e.childNodes.length)t[i]=void 0;else{let a=null,o=!1;for(let n=0;n<e.childNodes.length;++n){const l=e.childNodes[n];if(l.nodeType==Node.TEXT_NODE){const h=l.nodeValue?.trim();h&&h.length>0&&(a=h)}else l.nodeType==Node.ELEMENT_NODE&&(o=!0)}if(a&&!o)t[i]=a;else if(o){r.includes(i)?t[i]?.length?t[i].push({}):t[i]=[{}]:t[i]={};for(let n=0;n<e.childNodes.length;++n){const l=e.childNodes[n];l.nodeType==Node.ELEMENT_NODE&&this.parseNode(l,Array.isArray(t[i])?t[i].at(-1):t[i])}}else t[i]=void 0}}verification(){if(this.data)return!0;throw new Error("verify failed.")}}class _c{_texturePool;_materialPool;_prefabPool;_gltfPool;_geometryPool;_atlasList;_obj;constructor(){this._texturePool=new Map,this._materialPool=new Map,this._prefabPool=new Map,this._geometryPool=new Map,this._gltfPool=new Map,this._atlasList=new Map,this._obj=new Map}getGltf(e){return this._gltfPool.get(e)}addObj(e,t){this._obj.set(e,t)}getObj(e){return this._obj.get(e)}addTexture(e,t){this._texturePool.set(e,t)}getTexture(e){return this._texturePool.get(e)}addGeometry(e,t){this._geometryPool.set(e,t)}getGeometry(e){return this._geometryPool.get(e)}addMat(e,t){return this._materialPool.set(e,t)}getMat(e){return this._materialPool.get(e)}addPrefab(e,t){this._prefabPool.set(e,t)}getPrefab(e){return this._prefabPool.get(e).instantiate()}addAtlas(e,t){t.name=e,this._atlasList.set(e,t)}getAtlas(e){return this._atlasList.get(e)}getGUISprite(e){for(let t of this._atlasList.values()){let r=t.getSprite(e);if(r)return r}return null}async load(e,t,r){return(await new gt().load(e,t,r)).data}async loadGltf(e,t){if(this._prefabPool.has(e))return this._prefabPool.get(e);let r,i=e.substring(e.lastIndexOf(".")).toLowerCase(),a=new gt;i==".gltf"?r=await a.load(e,Ut,t):r=await a.load(e,Wo,t);let o=r.data;return this._prefabPool.set(e,o),this._gltfPool.set(e,r.gltf),o}async loadObj(e,t){if(this._prefabPool.has(e))return this._prefabPool.get(e);let r,i=e.substring(e.lastIndexOf(".")).toLowerCase(),a=new gt;i==".obj"&&(r=await a.load(e,Gu,t));let o=r.data;return this._prefabPool.set(e,o),o}async loadB3DM(e,t,r){if(this._prefabPool.has(e))return this._prefabPool.get(e);let o=(await new gt().load(e,tc,t,r)).data;return this._prefabPool.set(e,o),o}async loadI3DM(e,t,r){if(this._prefabPool.has(e))return this._prefabPool.get(e);let o=(await new gt().load(e,nc,t,r)).data;return this._prefabPool.set(e,o),o}async loadTexture(e,t,r){if(this._texturePool.has(e))return this._texturePool.get(e);let i=new Mr;return i.flipY=r,await i.load(e,t),this._texturePool.set(e,i),i}async loadTextureCount(e,t,r,i){return new Promise(async(a,o)=>{let n=0,l=[];t==0&&a(l);for(let h=0;h<t;h++){const u=e.shift();this.loadTexture(u,r,i).then(c=>{l.push(c),n++,n==t&&a(l)})}})}async loadBitmapTextures(e,t=5,r,i){let a=[],o=Math.floor(e.length/t)+1,n=Math.floor(e.length%t);for(let l=0;l<o;l++){let h=await this.loadTextureCount(e,l==o-1?n:t,r,i);a.push(...h)}return a}async loadHDRTexture(e,t){if(this._texturePool.has(e))return this._texturePool.get(e);let r=new Yo;return r=await r.load(e,t),this._texturePool.set(e,r),r}async loadHDRTextureCube(e,t){if(this._texturePool.has(e))return this._texturePool.get(e);let r=new ms;return r=await r.load(e,t),this._texturePool.set(e,r),r}async loadLDRTextureCube(e,t){if(this._texturePool.has(e))return this._texturePool.get(e);let r=new Us;return r=await r.load(e,t),this._texturePool.set(e,r),r}async loadTextureCubeMaps(e){let t=e[0];if(this._texturePool.has(t))return this._texturePool.get(t);let r=new Jo;return await r.load(e),this._texturePool.set(e[0],r),r}async loadTextureCubeStd(e,t){if(this._texturePool.has(e))return this._texturePool.get(e);let r=new Jo;return await r.loadStd(e),r}async loadJSON(e,t){return await new gt().loadJson(e,t).then(async r=>r).catch(r=>{console.log(r)})}async loadFont(e,t,r){let a=await new gt().load(e,Lr,t,r),o=a.data;return qi.addFontData(o.face,o.size,o),a.data}async loadAtlas(e,t){return(await new gt().load(e,pc,t,e)).data}async loadKMZ(e,t){return(await new gt().load(e,Sc,t)).data}normalTexture;maskTexture;whiteTexture;blackTexture;redTexture;blueTexture;greenTexture;yellowTexture;grayTexture;defaultSky;defaultGUITexture;defaultGUISprite;defaultMaterial;createTexture(e,t,r,i,a,o,n){let l=32,h=32,u=new Uint8Array(l*h*4);this.fillColor(u,e,t,r,i,a,o);let c=new Bo;return c.name=n,c.create(16,16,u,!0),n&&this.addTexture(n,c),c}fillColor(e,t,r,i,a,o,n){for(let l=0;l<t;l++)for(let h=0;h<r;h++){let u=h*t+l;e[u*4+0]=i,e[u*4+1]=a,e[u*4+2]=o,e[u*4+3]=n}}initDefault(){this.normalTexture=this.createTexture(32,32,255*.5,255*.5,255,255,"default-normalTexture"),this.maskTexture=this.createTexture(32,32,255,255*.5,255,255,"default-maskTexture"),this.whiteTexture=this.createTexture(32,32,255,255,255,255,"default-whiteTexture"),this.blackTexture=this.createTexture(32,32,0,0,0,255,"default-blackTexture"),this.redTexture=this.createTexture(32,32,255,0,0,255,"default-redTexture"),this.blueTexture=this.createTexture(32,32,0,0,255,255,"default-blueTexture"),this.greenTexture=this.createTexture(32,32,0,255,0,255,"default-greenTexture"),this.yellowTexture=this.createTexture(32,32,0,255,255,255,"default-yellowTexture"),this.grayTexture=this.createTexture(32,32,128,128,128,255,"default-grayTexture");let t=new hc().generateBRDFLUTTexture(),r=t.name="BRDFLUT";this.addTexture(r,t),this.defaultSky=new ms,this.defaultSky.createFromTexture(128,this.blackTexture),me.getInstance().attached(this.defaultSky,this),me.getInstance().attached(t,this),me.getInstance().attached(this.normalTexture,this),me.getInstance().attached(this.maskTexture,this),me.getInstance().attached(this.whiteTexture,this),me.getInstance().attached(this.blackTexture,this),me.getInstance().attached(this.redTexture,this),me.getInstance().attached(this.blueTexture,this),me.getInstance().attached(this.greenTexture,this),me.getInstance().attached(this.yellowTexture,this),me.getInstance().attached(this.grayTexture,this),this.defaultGUITexture=new fi(this.whiteTexture),this.defaultGUISprite=new Ki(this.defaultGUITexture),this.defaultGUISprite.trimSize.set(4,4),this.defaultMaterial=new Qr}}class Fc extends Pe{_postList;init(e){this._postList=new Map}start(){}stop(){}onEnable(){this.activePost()}onDisable(){this.unActivePost()}activePost(){let e=this.transform.view3D,t=m.getRenderJob(e);this._postList.forEach(r=>{t.addPost(r)})}unActivePost(){let e=this.transform.view3D,t=m.getRenderJob(e);this._postList.forEach(r=>{t.removePost(r)})}addPost(e){if(this._postList.has(e))return;let t=new e;return this._postList.set(e,t),this._enable&&this.activePost(),t}removePost(e){if(!this._postList.has(e))return;let t=this._postList.get(e);this._postList.delete(e);let r=this.transform.view3D;m.getRenderJob(r).removePost(t)}getPost(e){return this._postList.has(e)?this._postList.get(e):null}}const kp="1.0.10";class m{static res;static inputSystem;static views;static _frameRateValue=0;static _frameRate=360;static _time=0;static _beforeRender;static _renderLoop;static _lateRender;static _requestAnimationFrameID=0;static get frameRate(){return this._frameRate}static set frameRate(e){this._frameRate=e,this._frameRateValue=1e3/e,e>=360&&(this._frameRateValue=0)}static get size(){return R.presentationSize}static get aspect(){return R.aspect}static get width(){return R.windowWidth}static get height(){return R.windowHeight}static setting={doublePrecision:!1,occlusionQuery:{enable:!0,debug:!1},pick:{enable:!0,mode:"bound",detail:"mesh"},render:{debug:!1,renderPassState:4,renderState_left:5,renderState_right:5,renderState_split:.5,quadScale:1,hdrExposure:1.5,debugQuad:-1,maxPointLight:1e3,maxDirectLight:4,maxSportLight:1e3,drawOpMin:0,drawOpMax:Number.MAX_SAFE_INTEGER,drawTrMin:0,drawTrMax:Number.MAX_SAFE_INTEGER,zPrePass:!1,useLogDepth:!1,useCompressGBuffer:!1,gi:!1,postProcessing:{bloom:{downSampleStep:3,downSampleBlurSize:9,downSampleBlurSigma:1,upSampleBlurSize:9,upSampleBlurSigma:1,luminanceThreshole:1,bloomIntensity:1,hdr:1},globalFog:{debug:!1,enable:!1,fogType:0,fogHeightScale:.1,start:400,end:10,density:.02,ins:.5,skyFactor:.5,skyRoughness:.4,overrideSkyFactor:.8,fogColor:new P(96/255,117/255,133/255,1),falloff:.7,rayLength:200,scatteringExponent:2.7,dirHeightLine:10},godRay:{blendColor:!0,rayMarchCount:16,scatteringExponent:5,intensity:.5},ssao:{enable:!1,radius:.15,bias:-.1,aoPower:2,debug:!0},outline:{enable:!1,strength:1,groupCount:4,outlinePixel:2,fadeOutlinePixel:4,textureScale:1,useAddMode:!1,debug:!0},taa:{enable:!1,jitterSeedCount:8,blendFactor:.1,sharpFactor:.6,sharpPreBlurFactor:.5,temporalJitterScale:.13,debug:!0},gtao:{enable:!1,darkFactor:1,maxDistance:5,maxPixel:50,rayMarchSegment:6,multiBounce:!1,usePosFloat32:!0,blendColor:!0,debug:!0},ssr:{enable:!1,pixelRatio:1,fadeEdgeRatio:.2,rayMarchRatio:.5,fadeDistanceMin:600,fadeDistanceMax:2e3,roughnessThreshold:.5,powDotRN:.2,mixThreshold:.1,debug:!0},fxaa:{enable:!1},depthOfView:{enable:!1,iterationCount:3,pixelOffset:1,near:150,far:300}}},shadow:{enable:!0,type:"HARD",pointShadowBias:5e-4,shadowSize:2048,pointShadowSize:1024,shadowSoft:.005,shadowBound:100,shadowBias:.05,needUpdate:!0,autoUpdate:!0,updateFrameRate:2,csmMargin:.1,csmScatteringExp:.7,csmAreaScale:.4,debug:!1},gi:{enable:!1,offsetX:0,offsetY:0,offsetZ:0,probeSpace:64,probeXCount:4,probeYCount:2,probeZCount:4,probeSize:32,probeSourceTextureSize:2048,octRTMaxSize:2048,octRTSideSize:16,maxDistance:64*1.73,normalBias:.25,depthSharpness:1,hysteresis:.98,lerpHysteresis:.01,irradianceChebyshevBias:.01,rayNumber:144,irradianceDistanceBias:32,indirectIntensity:1,ddgiGamma:2.2,bounceIntensity:.025,probeRoughness:1,realTimeGI:!1,debug:!1,autoRenderProbe:!1},sky:{type:"HDRSKY",sky:null,skyExposure:1,defaultFar:65536,defaultNear:1},light:{maxLight:4096},material:{materialChannelDebug:!1,materialDebug:!1},loader:{numConcurrent:20},reflectionSetting:{reflectionProbeMaxCount:8,reflectionProbeSize:256,width:256*6,height:8*256,enable:!0}};static renderJobs;static async init(e={}){console.log("Rings Version",kp),window.isSecureContext||console.warn("WebGPU is only supported in secure contexts (HTTPS or localhost)"),this.setting={...this.setting,...e.engineSetting},await pe.init(I.allocCount,this.setting.doublePrecision),await R.init(e.canvasConfig),this.setting.reflectionSetting.width=this.setting.reflectionSetting.reflectionProbeSize*6,this.setting.reflectionSetting.height=this.setting.reflectionSetting.reflectionProbeSize*this.setting.reflectionSetting.reflectionProbeMaxCount,se.getGBufferFrame(se.reflections_GBuffer,this.setting.reflectionSetting.width,this.setting.reflectionSetting.height,!1),O.init(),Dr.init(),ne.init(),vt.init(),wt.init(),this.res=new _c,this.res.initDefault(),this._beforeRender=e.beforeRender,this._renderLoop=e.renderLoop,this._lateRender=e.lateRender,this.inputSystem=new Ln,this.inputSystem.initCanvas(R.canvas)}static startRenderJob(e){let t=new Bu(e);return this.renderJobs.set(e,t),this.setting.pick.mode=="pixel"&&e.scene.getOrAddComponent(Fc).addPost(Io),(this.setting.pick.mode=="pixel"||this.setting.pick.mode=="bound")&&(e.enablePick=!0),t}static startRenderView(e){this.renderJobs||=new Map,this.views=[e];let t=this.startRenderJob(e);return this.resume(),t}static startRenderViews(e){this.renderJobs||=new Map,this.views=e;for(let t=0;t<e.length;t++)this.startRenderJob(e[t]);this.resume()}static getRenderJob(e){return this.renderJobs.get(e)}static pause(){this._requestAnimationFrameID!==0&&(cancelAnimationFrame(this._requestAnimationFrameID),this._requestAnimationFrameID=0)}static resume(){this._requestAnimationFrameID===0&&(this._requestAnimationFrameID=requestAnimationFrame(e=>this.render(e)))}static async render(e){if(this._frameRateValue>0){let t=e-this._time;if(t<this._frameRateValue){let r=performance.now();await new Promise(i=>{setTimeout(()=>{e+=performance.now()-r,i(!0)},this._frameRateValue-t)})}this._time=e}await this.updateFrame(e),this._requestAnimationFrameID=0,this.resume()}static async updateFrame(e){be.delta=e-be.time,be.time=e,be.frame+=1,ci.tick(be.delta);let t=this.views,r=0;for(r=0;r<t.length;r++){const o=t[r];o.scene.waitUpdate();let[n,l]=R.presentationSize;o.camera.viewPort.setTo(0,0,n,l)}this._beforeRender&&await this._beforeRender();for(const o of Se.componentsBeforeUpdateList){let n=o[0],l=o[1];for(const h of l){let u=h[0],c=h[1];u.enable&&c(n)}}let i=R.device.createCommandEncoder();for(const o of Se.componentsComputeList){let n=o[0],l=o[1];for(const h of l){let u=h[0],c=h[1];u.enable&&c(n,i)}}R.device.queue.submit([i.finish()]);for(const o of Se.componentsUpdateList){let n=o[0],l=o[1];for(const h of l){let u=h[0],c=h[1];u.enable&&c(n)}}for(const o of Se.graphicComponent){let n=o[0],l=o[1];for(const h of l){let u=h[0],c=h[1];n&&u.enable&&c(n)}}this._renderLoop&&await this._renderLoop(),pe.updateAllContinueTransform(0,I.useCount,16),ne.modelMatrixBindGroup.writeBuffer(I.useCount*16),this.renderJobs.forEach((o,n)=>{o.renderState||o.start(),o.renderFrame()});for(const o of Se.componentsLateUpdateList){let n=o[0],l=o[1];for(const h of l){let u=h[0],c=h[1];u.enable&&c(n)}}this._lateRender&&await this._lateRender()}}let xs=`
|
|
7575
|
+
`}async loadFontTextures(){let e=[],t=this.data;for(const r of t.fontPage){let i=this.baseUrl+r.file;await m.res.loadTexture(i,null,!0);let a=m.res.getTexture(i),o=new fi(a);e.push(o)}Lr.parseSprite(e,t),t.fontChar[" "]||Lr.insertSpaceChar(t,e[0])}static insertSpaceChar(e,t){let r=new Ki,i=e.size*.5,a=e.lineHeight*.5;r.id=" ",r.offsetSize.set(0,0,e.size,e.size),r.trimSize.set(i,a),r.width=i,r.height=a,r.xadvance=0,r.xoffset=0,r.yoffset=0,r.guiTexture=t,r.uvRec.set(0,0,1e-6,1e-6),qi.addFnt(e.face,e.size,r.id,r)}static readLineProperty(e,t){e.trim().split(" ").forEach((r,i)=>{let a=r.split("=");if(a.length>1){let o=a[0],n=a[1];Object.prototype.hasOwnProperty.call(t,o)&&(n.indexOf('"')==-1?t[o]=parseFloat(a[1]):t[o]=n.replace('"',"").replace('"',""))}})}}function Bp(s,e){let t=new Ki;return t.id=s,t.offsetSize.set(0,0,e.width,e.height),t.trimSize.set(e.width,e.height),t.width=e.width,t.height=e.height,t.xadvance=0,t.xoffset=0,t.yoffset=0,t.guiTexture=new fi(e),t.uvRec.set(0,0,1,1),e.isVideoTexture||(e.flipY=!0),t}function dc(s,e,t){let r=new Ki;r.guiTexture=s,r.id=e,r.uvRec.copyFrom(t.textureRect),r.trimSize.x=t.textureRect.z,r.trimSize.y=t.textureRect.w,r.offsetSize.x=t.textureRectOffset.x,r.offsetSize.y=t.textureRectOffset.y,r.offsetSize.z=t.size.x,r.offsetSize.w=t.size.y,r.width=t.size.x,r.height=t.size.y;let i=1/s.width,a=1/s.height;r.uvRec.set(r.uvRec.x*i,r.uvRec.y*a,r.uvRec.z*i,r.uvRec.w*a);let o=.1;return t.border.x<=o&&t.border.y<=o&&t.border.z<=o&&t.border.x<=o?r.isSliced=!1:(r.borderSize.copyFrom(t.border),r.uvBorder.copyFrom(t.border),r.uvBorder.x-=t.textureRectOffset.x,r.uvBorder.y-=t.textureRectOffset.y,r.uvBorder.z=t.border.z-(t.size.x-t.textureRect.z-t.textureRectOffset.x),r.uvBorder.w=t.border.w-(t.size.y-t.textureRect.w-t.textureRectOffset.y),r.uvBorder.x/=t.textureRect.z,r.uvBorder.z/=t.textureRect.z,r.uvBorder.y/=t.textureRect.w,r.uvBorder.w/=t.textureRect.w,r.isSliced=!0),r}class gc{_spriteMap=new Map;_spriteList=[];textureSize=new K;name;constructor(e){this.textureSize.set(e.x,e.y)}setTexture(e,t,r){let i=dc(e,t,r);return this._spriteMap.set(i.id,i),this._spriteList.push(i),i}getSprite(e){return this._spriteMap.get(e)}get spriteList(){return this._spriteList}}class pc extends st{static format=Ge.TEXT;_json;_texture;async parseString(e){this._json=JSON.parse(e);let t=this.userData.replace(".json",".png");this._texture=await m.res.loadTexture(t,null,!0),this.data={json:this._json,texture:this._texture},this.parseAtlas()}verification(){if(this.data)return!0;throw new Error("verify failed.")}parseAtlas(){let e=new gc(this._json.size),t=new fi(this._texture),r=this._json.atlas;for(const i in r)e.setTexture(t,i,r[i]);m.res.addAtlas(this.baseUrl,e),this.data=e}}var kt=Uint8Array,$i=Uint16Array,vp=Int32Array,mc=new kt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Ac=new kt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Cp=new kt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Uc=function(s,e){for(var t=new $i(31),r=0;r<31;++r)t[r]=e+=1<<s[r-1];for(var i=new vp(t[30]),r=1;r<30;++r)for(var a=t[r];a<t[r+1];++a)i[a]=a-t[r]<<5|r;return{b:t,r:i}},xc=Uc(mc,2),Bc=xc.b,Sp=xc.r;Bc[28]=258,Sp[258]=28;for(var _p=Uc(Ac,0),Fp=_p.b,tn=new $i(32768),De=0;De<32768;++De){var ri=(De&43690)>>1|(De&21845)<<1;ri=(ri&52428)>>2|(ri&13107)<<2,ri=(ri&61680)>>4|(ri&3855)<<4,tn[De]=((ri&65280)>>8|(ri&255)<<8)>>1}for(var va=(function(s,e,t){for(var r=s.length,i=0,a=new $i(e);i<r;++i)s[i]&&++a[s[i]-1];var o=new $i(e);for(i=1;i<e;++i)o[i]=o[i-1]+a[i-1]<<1;var n;if(t){n=new $i(1<<e);var l=15-e;for(i=0;i<r;++i)if(s[i])for(var h=i<<4|s[i],u=e-s[i],c=o[s[i]-1]++<<u,f=c|(1<<u)-1;c<=f;++c)n[tn[c]>>l]=h}else for(n=new $i(r),i=0;i<r;++i)s[i]&&(n[i]=tn[o[s[i]-1]++]>>15-s[i]);return n}),Ca=new kt(288),De=0;De<144;++De)Ca[De]=8;for(var De=144;De<256;++De)Ca[De]=9;for(var De=256;De<280;++De)Ca[De]=7;for(var De=280;De<288;++De)Ca[De]=8;for(var vc=new kt(32),De=0;De<32;++De)vc[De]=5;var yp=va(Ca,9,1),bp=va(vc,5,1),rn=function(s){for(var e=s[0],t=1;t<s.length;++t)s[t]>e&&(e=s[t]);return e},sr=function(s,e,t){var r=e/8|0;return(s[r]|s[r+1]<<8)>>(e&7)&t},an=function(s,e){var t=e/8|0;return(s[t]|s[t+1]<<8|s[t+2]<<16)>>(e&7)},Qp=function(s){return(s+7)/8|0},sn=function(s,e,t){return(e==null||e<0)&&(e=0),(t==null||t>s.length)&&(t=s.length),new kt(s.subarray(e,t))},Rp=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Ht=function(s,e,t){var r=new Error(e||Rp[s]);if(r.code=s,Error.captureStackTrace&&Error.captureStackTrace(r,Ht),!t)throw r;return r},Ip=function(s,e,t,r){var i=s.length,a=r?r.length:0;if(!i||e.f&&!e.l)return t||new kt(0);var o=!t,n=o||e.i!=2,l=e.i;o&&(t=new kt(i*3));var h=function(Qt){var Rt=t.length;if(Qt>Rt){var Nt=new kt(Math.max(Rt*2,Qt));Nt.set(t),t=Nt}},u=e.f||0,c=e.p||0,f=e.b||0,g=e.l,p=e.d,A=e.m,U=e.n,x=i*8;do{if(!g){u=sr(s,c,1);var B=sr(s,c+1,3);if(c+=3,B)if(B==1)g=yp,p=bp,A=9,U=5;else if(B==2){var y=sr(s,c,31)+257,b=sr(s,c+10,15)+4,w=y+sr(s,c+5,31)+1;c+=14;for(var Q=new kt(w),E=new kt(19),M=0;M<b;++M)E[Cp[M]]=sr(s,c+M*3,7);c+=b*3;for(var z=rn(E),Y=(1<<z)-1,ee=va(E,z,1),M=0;M<w;){var oe=ee[sr(s,c,Y)];c+=oe&15;var S=oe>>4;if(S<16)Q[M++]=S;else{var te=0,ge=0;for(S==16?(ge=3+sr(s,c,3),c+=2,te=Q[M-1]):S==17?(ge=3+sr(s,c,7),c+=3):S==18&&(ge=11+sr(s,c,127),c+=7);ge--;)Q[M++]=te}}var Ce=Q.subarray(0,y),J=Q.subarray(y);A=rn(Ce),U=rn(J),g=va(Ce,A,1),p=va(J,U,1)}else Ht(1);else{var S=Qp(c)+4,C=s[S-4]|s[S-3]<<8,_=S+C;if(_>i){l&&Ht(0);break}n&&h(f+C),t.set(s.subarray(S,_),f),e.b=f+=C,e.p=c=_*8,e.f=u;continue}if(c>x){l&&Ht(0);break}}n&&h(f+131072);for(var ce=(1<<A)-1,he=(1<<U)-1,Ue=c;;Ue=c){var te=g[an(s,c)&ce],xe=te>>4;if(c+=te&15,c>x){l&&Ht(0);break}if(te||Ht(2),xe<256)t[f++]=xe;else if(xe==256){Ue=c,g=null;break}else{var Ve=xe-254;if(xe>264){var M=xe-257,Ie=mc[M];Ve=sr(s,c,(1<<Ie)-1)+Bc[M],c+=Ie}var Fe=p[an(s,c)&he],Me=Fe>>4;Fe||Ht(3),c+=Fe&15;var J=Fp[Me];if(Me>3){var Ie=Ac[Me];J+=an(s,c)&(1<<Ie)-1,c+=Ie}if(c>x){l&&Ht(0);break}n&&h(f+131072);var nt=f+Ve;if(f<J){var pr=a-J,Mt=Math.min(J,nt);for(pr+f<0&&Ht(3);f<Mt;++f)t[f]=r[pr+f]}for(;f<nt;++f)t[f]=t[f-J]}}e.l=g,e.p=Ue,e.b=f,e.f=u,g&&(u=1,e.m=A,e.d=p,e.n=U)}while(!u);return f!=t.length&&o?sn(t,0,f):t.subarray(0,f)},Ep=new kt(0),Fr=function(s,e){return s[e]|s[e+1]<<8},or=function(s,e){return(s[e]|s[e+1]<<8|s[e+2]<<16|s[e+3]<<24)>>>0},on=function(s,e){return or(s,e)+or(s,e+4)*4294967296};function wp(s,e){return Ip(s,{i:2},e&&e.out,e&&e.dictionary)}var nn=typeof TextDecoder<"u"&&new TextDecoder,Tp=0;try{nn.decode(Ep,{stream:!0}),Tp=1}catch{}var Dp=function(s){for(var e="",t=0;;){var r=s[t++],i=(r>127)+(r>223)+(r>239);if(t+i>s.length)return{s:e,r:sn(s,t-1)};i?i==3?(r=((r&15)<<18|(s[t++]&63)<<12|(s[t++]&63)<<6|s[t++]&63)-65536,e+=String.fromCharCode(55296|r>>10,56320|r&1023)):i&1?e+=String.fromCharCode((r&31)<<6|s[t++]&63):e+=String.fromCharCode((r&15)<<12|(s[t++]&63)<<6|s[t++]&63):e+=String.fromCharCode(r)}};function Cc(s,e){if(e){for(var t="",r=0;r<s.length;r+=16384)t+=String.fromCharCode.apply(null,s.subarray(r,r+16384));return t}else{if(nn)return nn.decode(s);var i=Dp(s),a=i.s,t=i.r;return t.length&&Ht(8),a}}var Mp=function(s,e){return e+30+Fr(s,e+26)+Fr(s,e+28)},Np=function(s,e,t){var r=Fr(s,e+28),i=Cc(s.subarray(e+46,e+46+r),!(Fr(s,e+8)&2048)),a=e+46+r,o=or(s,e+20),n=t&&o==4294967295?Vp(s,a):[o,or(s,e+24),or(s,e+42)],l=n[0],h=n[1],u=n[2];return[Fr(s,e+10),l,h,i,a+Fr(s,e+30)+Fr(s,e+32),u]},Vp=function(s,e){for(;Fr(s,e)!=1;e+=4+Fr(s,e+2));return[on(s,e+12),on(s,e+4),on(s,e+20)]};function Pp(s,e){for(var t={},r=s.length-22;or(s,r)!=101010256;--r)(!r||s.length-r>65558)&&Ht(13);var i=Fr(s,r+8);if(!i)return{};var a=or(s,r+16),o=a==4294967295||i==65535;if(o){var n=or(s,r-12);o=or(s,n)==101075792,o&&(i=or(s,n+32),a=or(s,n+48))}for(var l=0;l<i;++l){var h=Np(s,a,o),u=h[0],c=h[1],f=h[2],g=h[3],p=h[4],A=h[5],U=Mp(s,A);a=p,u?u==8?t[g]=wp(s.subarray(U,U+c),{out:new kt(f)}):Ht(14,"unknown compression type "+u):t[g]=sn(s,U,U+c)}return t}class pt extends yt{constructor(){super(),this.shader=new Ea,this.baseMap=m.res.whiteTexture}set baseMap(e){this.shader.setTexture("baseMap",e)}get baseMap(){return this.shader.getTexture("baseMap")}set baseColor(e){this.shader.setUniformColor("baseColor",e)}get baseColor(){return this.shader.getUniformColor("baseColor")}set envMap(e){}set shadowMap(e){}}class Ri extends Ne{shape_vertices=[];shape_indices=[];radius;widthSegments;heightSegments;phiStart;phiLength;thetaStart;thetaLength;constructor(e,t,r,i,a,o,n){super(),this.radius=e,this.widthSegments=t,this.heightSegments=r,this.phiStart=i,this.phiLength=a,this.thetaStart=o,this.thetaLength=n,this.buildGeometry()}buildGeometry(){var e,t,r=0;let i=this.heightSegments,a=this.widthSegments,o=this.radius;var n=(i+1)*(a+1);let l=new Float32Array(n*3),h=new Float32Array(n*3),u=new Float32Array(n*2),c=new Uint16Array(a*i*2*3),f=0,g=0,p=0;for(t=0;t<=i;++t){var A=Math.PI*t/i,U=o*Math.cos(A),x=o*Math.sin(A);for(e=0;e<=a;++e){var B=2*Math.PI*e/a,S=x*Math.cos(B),C=x*Math.sin(B),_=1/Math.sqrt(S*S+U*U+C*C);if(l[f++]=S,l[f++]=U,l[f++]=C,h[g++]=S*_,h[g++]=U*_,h[g++]=C*_,u[p++]=e/a,u[p++]=t/i,e>0&&t>0){var y=(a+1)*t+e,b=(a+1)*t+e-1,w=(a+1)*(t-1)+e-1,Q=(a+1)*(t-1)+e;t==i?(c[r++]=y,c[r++]=w,c[r++]=Q):t==1?(c[r++]=y,c[r++]=b,c[r++]=w):(c[r++]=y,c[r++]=b,c[r++]=w,c[r++]=y,c[r++]=w,c[r++]=Q)}}}this.setIndices(c),this.setAttribute(V.position,l),this.setAttribute(V.normal,h),this.setAttribute(V.uv,u),this.setAttribute(V.TEXCOORD_1,u),this.addSubGeometry({indexStart:0,indexCount:c.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0}),this.bounds=new Re(d.ZERO,new d(this.radius*2,this.radius*2,this.radius*2))}}class $a extends q{static register3DRepresentation=null;positionIndex=-1;positionValid=!1;marker;constructor(e){super(),this.parsePlacemark(e),this.setup3DRepresentation()}parsePlacemark(e){if(!e.slamPositionInfo){console.warn("WayPoint3D: slamPositionInfo is not found");return}const t=e.slamPositionInfo.slamPosition.split(",").map(Number);this.localPosition=new d(t[0],t[1],t[2]),this.positionIndex=Number(e.slamPositionInfo.slamPositionIndex),this.positionValid=e.slamPositionInfo.slamPositionValid==="1"}setup3DRepresentation(){if(this.marker&&(this.removeChild(this.marker),this.marker=null),$a.register3DRepresentation)this.marker=$a.register3DRepresentation(this),this.marker&&this.addChild(this.marker);else{this.marker=new q;const e=this.marker.addComponent(j);e.geometry=new Ri(.1,32,16),e.material=new pt,e.material.baseColor=this.positionValid?new P(0,1,0,1):new P(1,0,0,1),this.addChild(this.marker),this.marker.name="WayPoint3DMarker"}}}class es extends q{static register3DRepresentation=null;line;constructor(e){super(),this.parseWayLineFile(e),this.setup3DRepresentation()}parseWayLineFile(e){for(const t of e.Folder.Placemark){const r=new $a(t);this.addChild(r)}this.entityChildren=this.entityChildren.sort((t,r)=>t.positionIndex-r.positionIndex)}setup3DRepresentation(){this.line&&(this.removeChild(this.line),this.line=null),es.register3DRepresentation?(this.line=es.register3DRepresentation(this),this.line&&this.addChild(this.line)):(this.line=this.createMultiLine(this.entityChildren.map(e=>e.localPosition),new P(1,1,1,1)),this.addChild(this.line),this.line.name="WayLines3DLine")}createMultiLine(e,t){if(e.length<2)return null;const r=new Ne,i=new Float32Array(e.length*3);for(let h=0;h<e.length;h++)i[h*3]=e[h].x,i[h*3+1]=e[h].y,i[h*3+2]=e[h].z;const a=new Uint16Array((e.length-1)*2);for(let h=0;h<e.length-1;h++)a[h*2]=h,a[h*2+1]=h+1;r.setIndices(a),r.setAttribute(V.position,i),r.addSubGeometry({indexStart:0,indexCount:a.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0});const o=new q,n=o.addComponent(j),l=new pt;return l.topology="line-list",l.baseColor=t,l.blendMode=ae.ADD,l.castReflection=!1,n.geometry=r,n.material=l,o}}class Sc extends st{static format=Ge.BIN;parseBuffer(e){try{const t={template:null,waylines:null},r=Pp(new Uint8Array(e));for(const a in r){const o=r[a],l=new DOMParser().parseFromString(Cc(o),"application/xml"),h={};this.parseNode(l,h);const u=a.replace("wpmz/","").split(".")[0];Object.assign(t,{[u]:h["#document"].kml.Document})}const i=new es(t.waylines);this.data=i}catch(t){this.parserError(`KMZ parsing failed: ${t}`,-1)}}parseNode(e,t){const r=["Placemark","actionGroup","action"],i=e.nodeName.replace("wpml:","");if(!e.childNodes.length)t[i]=void 0;else{let a=null,o=!1;for(let n=0;n<e.childNodes.length;++n){const l=e.childNodes[n];if(l.nodeType==Node.TEXT_NODE){const h=l.nodeValue?.trim();h&&h.length>0&&(a=h)}else l.nodeType==Node.ELEMENT_NODE&&(o=!0)}if(a&&!o)t[i]=a;else if(o){r.includes(i)?t[i]?.length?t[i].push({}):t[i]=[{}]:t[i]={};for(let n=0;n<e.childNodes.length;++n){const l=e.childNodes[n];l.nodeType==Node.ELEMENT_NODE&&this.parseNode(l,Array.isArray(t[i])?t[i].at(-1):t[i])}}else t[i]=void 0}}verification(){if(this.data)return!0;throw new Error("verify failed.")}}class _c{_texturePool;_materialPool;_prefabPool;_gltfPool;_geometryPool;_atlasList;_obj;constructor(){this._texturePool=new Map,this._materialPool=new Map,this._prefabPool=new Map,this._geometryPool=new Map,this._gltfPool=new Map,this._atlasList=new Map,this._obj=new Map}getGltf(e){return this._gltfPool.get(e)}addObj(e,t){this._obj.set(e,t)}getObj(e){return this._obj.get(e)}addTexture(e,t){this._texturePool.set(e,t)}getTexture(e){return this._texturePool.get(e)}addGeometry(e,t){this._geometryPool.set(e,t)}getGeometry(e){return this._geometryPool.get(e)}addMat(e,t){return this._materialPool.set(e,t)}getMat(e){return this._materialPool.get(e)}addPrefab(e,t){this._prefabPool.set(e,t)}getPrefab(e){return this._prefabPool.get(e).instantiate()}addAtlas(e,t){t.name=e,this._atlasList.set(e,t)}getAtlas(e){return this._atlasList.get(e)}getGUISprite(e){for(let t of this._atlasList.values()){let r=t.getSprite(e);if(r)return r}return null}async load(e,t,r){return(await new gt().load(e,t,r)).data}async loadGltf(e,t){if(this._prefabPool.has(e))return this._prefabPool.get(e);let r,i=e.substring(e.lastIndexOf(".")).toLowerCase(),a=new gt;i==".gltf"?r=await a.load(e,Ut,t):r=await a.load(e,Wo,t);let o=r.data;return this._prefabPool.set(e,o),this._gltfPool.set(e,r.gltf),o}async loadObj(e,t){if(this._prefabPool.has(e))return this._prefabPool.get(e);let r,i=e.substring(e.lastIndexOf(".")).toLowerCase(),a=new gt;i==".obj"&&(r=await a.load(e,Gu,t));let o=r.data;return this._prefabPool.set(e,o),o}async loadB3DM(e,t,r){if(this._prefabPool.has(e))return this._prefabPool.get(e);let o=(await new gt().load(e,tc,t,r)).data;return this._prefabPool.set(e,o),o}async loadI3DM(e,t,r){if(this._prefabPool.has(e))return this._prefabPool.get(e);let o=(await new gt().load(e,nc,t,r)).data;return this._prefabPool.set(e,o),o}async loadTexture(e,t,r){if(this._texturePool.has(e))return this._texturePool.get(e);let i=new Mr;return i.flipY=r,await i.load(e,t),this._texturePool.set(e,i),i}async loadTextureCount(e,t,r,i){return new Promise(async(a,o)=>{let n=0,l=[];t==0&&a(l);for(let h=0;h<t;h++){const u=e.shift();this.loadTexture(u,r,i).then(c=>{l.push(c),n++,n==t&&a(l)})}})}async loadBitmapTextures(e,t=5,r,i){let a=[],o=Math.floor(e.length/t)+1,n=Math.floor(e.length%t);for(let l=0;l<o;l++){let h=await this.loadTextureCount(e,l==o-1?n:t,r,i);a.push(...h)}return a}async loadHDRTexture(e,t){if(this._texturePool.has(e))return this._texturePool.get(e);let r=new Yo;return r=await r.load(e,t),this._texturePool.set(e,r),r}async loadHDRTextureCube(e,t){if(this._texturePool.has(e))return this._texturePool.get(e);let r=new ms;return r=await r.load(e,t),this._texturePool.set(e,r),r}async loadLDRTextureCube(e,t){if(this._texturePool.has(e))return this._texturePool.get(e);let r=new Us;return r=await r.load(e,t),this._texturePool.set(e,r),r}async loadTextureCubeMaps(e){let t=e[0];if(this._texturePool.has(t))return this._texturePool.get(t);let r=new Jo;return await r.load(e),this._texturePool.set(e[0],r),r}async loadTextureCubeStd(e,t){if(this._texturePool.has(e))return this._texturePool.get(e);let r=new Jo;return await r.loadStd(e),r}async loadJSON(e,t){return await new gt().loadJson(e,t).then(async r=>r).catch(r=>{console.log(r)})}async loadFont(e,t,r){let a=await new gt().load(e,Lr,t,r),o=a.data;return qi.addFontData(o.face,o.size,o),a.data}async loadAtlas(e,t){return(await new gt().load(e,pc,t,e)).data}async loadKMZ(e,t){return(await new gt().load(e,Sc,t)).data}normalTexture;maskTexture;whiteTexture;blackTexture;redTexture;blueTexture;greenTexture;yellowTexture;grayTexture;defaultSky;defaultGUITexture;defaultGUISprite;defaultMaterial;createTexture(e,t,r,i,a,o,n){let l=32,h=32,u=new Uint8Array(l*h*4);this.fillColor(u,e,t,r,i,a,o);let c=new Bo;return c.name=n,c.create(16,16,u,!0),n&&this.addTexture(n,c),c}fillColor(e,t,r,i,a,o,n){for(let l=0;l<t;l++)for(let h=0;h<r;h++){let u=h*t+l;e[u*4+0]=i,e[u*4+1]=a,e[u*4+2]=o,e[u*4+3]=n}}initDefault(){this.normalTexture=this.createTexture(32,32,255*.5,255*.5,255,255,"default-normalTexture"),this.maskTexture=this.createTexture(32,32,255,255*.5,255,255,"default-maskTexture"),this.whiteTexture=this.createTexture(32,32,255,255,255,255,"default-whiteTexture"),this.blackTexture=this.createTexture(32,32,0,0,0,255,"default-blackTexture"),this.redTexture=this.createTexture(32,32,255,0,0,255,"default-redTexture"),this.blueTexture=this.createTexture(32,32,0,0,255,255,"default-blueTexture"),this.greenTexture=this.createTexture(32,32,0,255,0,255,"default-greenTexture"),this.yellowTexture=this.createTexture(32,32,0,255,255,255,"default-yellowTexture"),this.grayTexture=this.createTexture(32,32,128,128,128,255,"default-grayTexture");let t=new hc().generateBRDFLUTTexture(),r=t.name="BRDFLUT";this.addTexture(r,t),this.defaultSky=new ms,this.defaultSky.createFromTexture(128,this.blackTexture),me.getInstance().attached(this.defaultSky,this),me.getInstance().attached(t,this),me.getInstance().attached(this.normalTexture,this),me.getInstance().attached(this.maskTexture,this),me.getInstance().attached(this.whiteTexture,this),me.getInstance().attached(this.blackTexture,this),me.getInstance().attached(this.redTexture,this),me.getInstance().attached(this.blueTexture,this),me.getInstance().attached(this.greenTexture,this),me.getInstance().attached(this.yellowTexture,this),me.getInstance().attached(this.grayTexture,this),this.defaultGUITexture=new fi(this.whiteTexture),this.defaultGUISprite=new Ki(this.defaultGUITexture),this.defaultGUISprite.trimSize.set(4,4),this.defaultMaterial=new Qr}}class Fc extends Pe{_postList;init(e){this._postList=new Map}start(){}stop(){}onEnable(){this.activePost()}onDisable(){this.unActivePost()}activePost(){let e=this.transform.view3D,t=m.getRenderJob(e);this._postList.forEach(r=>{t.addPost(r)})}unActivePost(){let e=this.transform.view3D,t=m.getRenderJob(e);this._postList.forEach(r=>{t.removePost(r)})}addPost(e){if(this._postList.has(e))return;let t=new e;return this._postList.set(e,t),this._enable&&this.activePost(),t}removePost(e){if(!this._postList.has(e))return;let t=this._postList.get(e);this._postList.delete(e);let r=this.transform.view3D;m.getRenderJob(r).removePost(t)}getPost(e){return this._postList.has(e)?this._postList.get(e):null}}const kp="1.0.11";class m{static res;static inputSystem;static views;static _frameRateValue=0;static _frameRate=360;static _time=0;static _beforeRender;static _renderLoop;static _lateRender;static _requestAnimationFrameID=0;static get frameRate(){return this._frameRate}static set frameRate(e){this._frameRate=e,this._frameRateValue=1e3/e,e>=360&&(this._frameRateValue=0)}static get size(){return R.presentationSize}static get aspect(){return R.aspect}static get width(){return R.windowWidth}static get height(){return R.windowHeight}static setting={doublePrecision:!1,occlusionQuery:{enable:!0,debug:!1},pick:{enable:!0,mode:"bound",detail:"mesh"},render:{debug:!1,renderPassState:4,renderState_left:5,renderState_right:5,renderState_split:.5,quadScale:1,hdrExposure:1.5,debugQuad:-1,maxPointLight:1e3,maxDirectLight:4,maxSportLight:1e3,drawOpMin:0,drawOpMax:Number.MAX_SAFE_INTEGER,drawTrMin:0,drawTrMax:Number.MAX_SAFE_INTEGER,zPrePass:!1,useLogDepth:!1,useCompressGBuffer:!1,gi:!1,postProcessing:{bloom:{downSampleStep:3,downSampleBlurSize:9,downSampleBlurSigma:1,upSampleBlurSize:9,upSampleBlurSigma:1,luminanceThreshole:1,bloomIntensity:1,hdr:1},globalFog:{debug:!1,enable:!1,fogType:0,fogHeightScale:.1,start:400,end:10,density:.02,ins:.5,skyFactor:.5,skyRoughness:.4,overrideSkyFactor:.8,fogColor:new P(96/255,117/255,133/255,1),falloff:.7,rayLength:200,scatteringExponent:2.7,dirHeightLine:10},godRay:{blendColor:!0,rayMarchCount:16,scatteringExponent:5,intensity:.5},ssao:{enable:!1,radius:.15,bias:-.1,aoPower:2,debug:!0},outline:{enable:!1,strength:1,groupCount:4,outlinePixel:2,fadeOutlinePixel:4,textureScale:1,useAddMode:!1,debug:!0},taa:{enable:!1,jitterSeedCount:8,blendFactor:.1,sharpFactor:.6,sharpPreBlurFactor:.5,temporalJitterScale:.13,debug:!0},gtao:{enable:!1,darkFactor:1,maxDistance:5,maxPixel:50,rayMarchSegment:6,multiBounce:!1,usePosFloat32:!0,blendColor:!0,debug:!0},ssr:{enable:!1,pixelRatio:1,fadeEdgeRatio:.2,rayMarchRatio:.5,fadeDistanceMin:600,fadeDistanceMax:2e3,roughnessThreshold:.5,powDotRN:.2,mixThreshold:.1,debug:!0},fxaa:{enable:!1},depthOfView:{enable:!1,iterationCount:3,pixelOffset:1,near:150,far:300}}},shadow:{enable:!0,type:"HARD",pointShadowBias:5e-4,shadowSize:2048,pointShadowSize:1024,shadowSoft:.005,shadowBound:100,shadowBias:.05,needUpdate:!0,autoUpdate:!0,updateFrameRate:2,csmMargin:.1,csmScatteringExp:.7,csmAreaScale:.4,debug:!1},gi:{enable:!1,offsetX:0,offsetY:0,offsetZ:0,probeSpace:64,probeXCount:4,probeYCount:2,probeZCount:4,probeSize:32,probeSourceTextureSize:2048,octRTMaxSize:2048,octRTSideSize:16,maxDistance:64*1.73,normalBias:.25,depthSharpness:1,hysteresis:.98,lerpHysteresis:.01,irradianceChebyshevBias:.01,rayNumber:144,irradianceDistanceBias:32,indirectIntensity:1,ddgiGamma:2.2,bounceIntensity:.025,probeRoughness:1,realTimeGI:!1,debug:!1,autoRenderProbe:!1},sky:{type:"HDRSKY",sky:null,skyExposure:1,defaultFar:65536,defaultNear:1},light:{maxLight:4096},material:{materialChannelDebug:!1,materialDebug:!1},loader:{numConcurrent:20},reflectionSetting:{reflectionProbeMaxCount:8,reflectionProbeSize:256,width:256*6,height:8*256,enable:!0}};static renderJobs;static async init(e={}){console.log("Rings Version",kp),window.isSecureContext||console.warn("WebGPU is only supported in secure contexts (HTTPS or localhost)"),this.setting={...this.setting,...e.engineSetting},await pe.init(I.allocCount,this.setting.doublePrecision),await R.init(e.canvasConfig),this.setting.reflectionSetting.width=this.setting.reflectionSetting.reflectionProbeSize*6,this.setting.reflectionSetting.height=this.setting.reflectionSetting.reflectionProbeSize*this.setting.reflectionSetting.reflectionProbeMaxCount,se.getGBufferFrame(se.reflections_GBuffer,this.setting.reflectionSetting.width,this.setting.reflectionSetting.height,!1),O.init(),Dr.init(),ne.init(),vt.init(),wt.init(),this.res=new _c,this.res.initDefault(),this._beforeRender=e.beforeRender,this._renderLoop=e.renderLoop,this._lateRender=e.lateRender,this.inputSystem=new Ln,this.inputSystem.initCanvas(R.canvas)}static startRenderJob(e){let t=new Bu(e);return this.renderJobs.set(e,t),this.setting.pick.mode=="pixel"&&e.scene.getOrAddComponent(Fc).addPost(Io),(this.setting.pick.mode=="pixel"||this.setting.pick.mode=="bound")&&(e.enablePick=!0),t}static startRenderView(e){this.renderJobs||=new Map,this.views=[e];let t=this.startRenderJob(e);return this.resume(),t}static startRenderViews(e){this.renderJobs||=new Map,this.views=e;for(let t=0;t<e.length;t++)this.startRenderJob(e[t]);this.resume()}static getRenderJob(e){return this.renderJobs.get(e)}static pause(){this._requestAnimationFrameID!==0&&(cancelAnimationFrame(this._requestAnimationFrameID),this._requestAnimationFrameID=0)}static resume(){this._requestAnimationFrameID===0&&(this._requestAnimationFrameID=requestAnimationFrame(e=>this.render(e)))}static async render(e){if(this._frameRateValue>0){let t=e-this._time;if(t<this._frameRateValue){let r=performance.now();await new Promise(i=>{setTimeout(()=>{e+=performance.now()-r,i(!0)},this._frameRateValue-t)})}this._time=e}await this.updateFrame(e),this._requestAnimationFrameID=0,this.resume()}static async updateFrame(e){be.delta=e-be.time,be.time=e,be.frame+=1,ci.tick(be.delta);let t=this.views,r=0;for(r=0;r<t.length;r++){const o=t[r];o.scene.waitUpdate();let[n,l]=R.presentationSize;o.camera.viewPort.setTo(0,0,n,l)}this._beforeRender&&await this._beforeRender();for(const o of Se.componentsBeforeUpdateList){let n=o[0],l=o[1];for(const h of l){let u=h[0],c=h[1];u.enable&&c(n)}}let i=R.device.createCommandEncoder();for(const o of Se.componentsComputeList){let n=o[0],l=o[1];for(const h of l){let u=h[0],c=h[1];u.enable&&c(n,i)}}R.device.queue.submit([i.finish()]);for(const o of Se.componentsUpdateList){let n=o[0],l=o[1];for(const h of l){let u=h[0],c=h[1];u.enable&&c(n)}}for(const o of Se.graphicComponent){let n=o[0],l=o[1];for(const h of l){let u=h[0],c=h[1];n&&u.enable&&c(n)}}this._renderLoop&&await this._renderLoop(),pe.updateAllContinueTransform(0,I.useCount,16),ne.modelMatrixBindGroup.writeBuffer(I.useCount*16),this.renderJobs.forEach((o,n)=>{o.renderState||o.start(),o.renderFrame()});for(const o of Se.componentsLateUpdateList){let n=o[0],l=o[1];for(const h of l){let u=h[0],c=h[1];u.enable&&c(n)}}this._lateRender&&await this._lateRender()}}let xs=`
|
|
7561
7576
|
struct BloomCfg{
|
|
7562
7577
|
downSampleStep: f32,
|
|
7563
7578
|
downSampleBlurSize: f32,
|