@xviewer.js/core 1.0.0-alpha.60 → 1.0.0-alpha.61
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/main.js +56 -14
- package/dist/main.js.map +1 -1
- package/dist/module.js +56 -14
- package/dist/module.js.map +1 -1
- package/package.json +1 -1
- package/types/materials/ReflectorMaterial.d.ts +7 -1
package/dist/main.js
CHANGED
|
@@ -3073,7 +3073,7 @@ class Plane extends three.Mesh {
|
|
|
3073
3073
|
}
|
|
3074
3074
|
|
|
3075
3075
|
class Reflector extends Component {
|
|
3076
|
-
constructor({ textureWidth = 512, textureHeight = 512, clipBias = 0, multisample = 4, layer = 0, normal = new three.Vector3(0,
|
|
3076
|
+
constructor({ textureWidth = 512, textureHeight = 512, clipBias = 0, multisample = 4, layer = 0, normal = new three.Vector3(0, 1, 0), mipmap = false } = {}){
|
|
3077
3077
|
super();
|
|
3078
3078
|
const reflectorPlane = new three.Plane();
|
|
3079
3079
|
const reflectorNormal = new three.Vector3();
|
|
@@ -3347,10 +3347,11 @@ function getShaderMaterial(uniforms, vertexShader, fragmentShader, onInit) {
|
|
|
3347
3347
|
return material;
|
|
3348
3348
|
}
|
|
3349
3349
|
|
|
3350
|
-
const vert_Reflector = `
|
|
3350
|
+
const vert_Reflector = /*glsl*/ `
|
|
3351
3351
|
uniform mat4 textureMatrix;
|
|
3352
3352
|
varying vec4 vUv4;
|
|
3353
3353
|
varying vec2 vUv;
|
|
3354
|
+
varying vec3 vPositionWS;
|
|
3354
3355
|
|
|
3355
3356
|
#ifdef USE_UV1
|
|
3356
3357
|
varying vec2 vUv1;
|
|
@@ -3380,9 +3381,6 @@ void main() {
|
|
|
3380
3381
|
transformed = instanceMatrix * transformed;
|
|
3381
3382
|
#endif
|
|
3382
3383
|
|
|
3383
|
-
vec4 positionWS = modelMatrix * transformed;
|
|
3384
|
-
vec4 mvPosition = viewMatrix * positionWS;
|
|
3385
|
-
|
|
3386
3384
|
vUv = uv;
|
|
3387
3385
|
|
|
3388
3386
|
#ifdef USE_UV1
|
|
@@ -3397,8 +3395,11 @@ void main() {
|
|
|
3397
3395
|
vUv3 = uv2;
|
|
3398
3396
|
#endif
|
|
3399
3397
|
|
|
3400
|
-
|
|
3398
|
+
vec4 positionWS = modelMatrix * transformed;
|
|
3399
|
+
vec4 mvPosition = viewMatrix * positionWS;
|
|
3401
3400
|
|
|
3401
|
+
vUv4 = textureMatrix * positionWS;
|
|
3402
|
+
vPositionWS = positionWS.xyz;
|
|
3402
3403
|
vViewPosition = -mvPosition.xyz;
|
|
3403
3404
|
vNormal = normalize(transformedNormal);
|
|
3404
3405
|
|
|
@@ -3407,7 +3408,7 @@ void main() {
|
|
|
3407
3408
|
#include <logdepthbuf_vertex>
|
|
3408
3409
|
}
|
|
3409
3410
|
`;
|
|
3410
|
-
const frag_Reflector = `
|
|
3411
|
+
const frag_Reflector = /*glsl*/ `
|
|
3411
3412
|
uniform vec3 color;
|
|
3412
3413
|
uniform float alpha;
|
|
3413
3414
|
uniform float roughness;
|
|
@@ -3419,7 +3420,9 @@ uniform sampler2D aoMap;
|
|
|
3419
3420
|
uniform float aoMapIntensity;
|
|
3420
3421
|
uniform sampler2D lightMap;
|
|
3421
3422
|
uniform float lightMapIntensity;
|
|
3422
|
-
uniform sampler2D
|
|
3423
|
+
uniform sampler2D reflectMap;
|
|
3424
|
+
uniform float reflectIntensity;
|
|
3425
|
+
varying vec3 vPositionWS;
|
|
3423
3426
|
|
|
3424
3427
|
varying vec2 vUv;
|
|
3425
3428
|
|
|
@@ -3446,10 +3449,14 @@ varying vec3 vNormal;
|
|
|
3446
3449
|
void main() {
|
|
3447
3450
|
#include <logdepthbuf_fragment>
|
|
3448
3451
|
|
|
3452
|
+
vec3 coord = vUv4.xyz / vUv4.w;
|
|
3453
|
+
vec2 reflectUv = coord.xy;
|
|
3454
|
+
|
|
3455
|
+
#ifdef USE_NORMALMAP
|
|
3449
3456
|
vec4 texelNormal = texture2D(normalMap, UV_NORMAL);
|
|
3450
3457
|
vec3 normal = normalize(vec3(texelNormal.r * 2.0 - 1.0, texelNormal.b, texelNormal.g * 2.0 - 1.0));
|
|
3451
|
-
|
|
3452
|
-
|
|
3458
|
+
reflectUv += coord.z * normal.xz * 0.05;
|
|
3459
|
+
#endif
|
|
3453
3460
|
|
|
3454
3461
|
vec3 geometryNormal = normalize(vNormal);
|
|
3455
3462
|
vec3 geometryViewDir = normalize(vViewPosition);
|
|
@@ -3470,7 +3477,11 @@ void main() {
|
|
|
3470
3477
|
vec3 specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
|
|
3471
3478
|
float specularF90 = 1.0;
|
|
3472
3479
|
|
|
3473
|
-
float roughnessFactor =
|
|
3480
|
+
float roughnessFactor = roughness;
|
|
3481
|
+
|
|
3482
|
+
#ifdef USE_ROUGHNESSMAP
|
|
3483
|
+
roughnessFactor *= texture2D(roughnessMap, UV_ROUGHNESS).g * roughness;
|
|
3484
|
+
#endif
|
|
3474
3485
|
|
|
3475
3486
|
computeMultiscattering( geometryNormal, geometryViewDir, specularColor, specularF90, roughnessFactor, singleScattering, multiScattering );
|
|
3476
3487
|
|
|
@@ -3478,10 +3489,13 @@ void main() {
|
|
|
3478
3489
|
vec3 diffuse = diffuseColor.rgb * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
|
|
3479
3490
|
|
|
3480
3491
|
vec3 irradiance = vec3(0.);
|
|
3492
|
+
|
|
3493
|
+
#ifdef USE_LIGHTMAP
|
|
3481
3494
|
irradiance += texture2D(lightMap, UV_LIGHTMAP).rgb * lightMapIntensity;
|
|
3495
|
+
#endif
|
|
3482
3496
|
|
|
3483
3497
|
float lod = roughnessFactor * (1.7 - 0.7 * roughnessFactor) * 6.;
|
|
3484
|
-
vec4 reflectColor = textureLod(
|
|
3498
|
+
vec4 reflectColor = textureLod(reflectMap, reflectUv, lod) * reflectIntensity;
|
|
3485
3499
|
|
|
3486
3500
|
vec3 f_specular = vec3(0.);
|
|
3487
3501
|
vec3 f_diffuse = vec3(0.);
|
|
@@ -3489,9 +3503,13 @@ void main() {
|
|
|
3489
3503
|
f_specular += reflectColor.rgb * (1.0 - roughnessFactor * roughnessFactor) + multiScattering * irradiance;
|
|
3490
3504
|
f_diffuse += diffuse * irradiance;
|
|
3491
3505
|
|
|
3506
|
+
#ifdef USE_AOMAP
|
|
3492
3507
|
float ambientOcclusion = mix(1., texture2D(aoMap, UV_AO).r, aoMapIntensity);
|
|
3508
|
+
|
|
3493
3509
|
float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
|
|
3494
3510
|
f_specular *= computeSpecularOcclusion(dotNV, ambientOcclusion, roughnessFactor);
|
|
3511
|
+
f_diffuse *= ambientOcclusion;
|
|
3512
|
+
#endif
|
|
3495
3513
|
|
|
3496
3514
|
gl_FragColor = vec4(f_specular + f_diffuse, diffuseColor.a);
|
|
3497
3515
|
|
|
@@ -3530,6 +3548,12 @@ class ReflectorMaterial extends three.ShaderMaterial {
|
|
|
3530
3548
|
shader.defines[key] = "vUv" + channel;
|
|
3531
3549
|
});
|
|
3532
3550
|
}
|
|
3551
|
+
get color() {
|
|
3552
|
+
return this.uniforms.color.value;
|
|
3553
|
+
}
|
|
3554
|
+
set color(v) {
|
|
3555
|
+
this.uniforms.color.value = v;
|
|
3556
|
+
}
|
|
3533
3557
|
get alpha() {
|
|
3534
3558
|
return this.uniforms.alpha.value;
|
|
3535
3559
|
}
|
|
@@ -3578,6 +3602,18 @@ class ReflectorMaterial extends three.ShaderMaterial {
|
|
|
3578
3602
|
set lightMap(v) {
|
|
3579
3603
|
this.uniforms.lightMap.value = v;
|
|
3580
3604
|
}
|
|
3605
|
+
get lightMapIntensity() {
|
|
3606
|
+
return this.uniforms.lightMapIntensity.value;
|
|
3607
|
+
}
|
|
3608
|
+
set lightMapIntensity(v) {
|
|
3609
|
+
this.uniforms.lightMapIntensity.value = v;
|
|
3610
|
+
}
|
|
3611
|
+
get reflectIntensity() {
|
|
3612
|
+
return this.uniforms.reflectIntensity.value;
|
|
3613
|
+
}
|
|
3614
|
+
set reflectIntensity(v) {
|
|
3615
|
+
this.uniforms.reflectIntensity.value = v;
|
|
3616
|
+
}
|
|
3581
3617
|
constructor(...args){
|
|
3582
3618
|
super(...args);
|
|
3583
3619
|
this.vertexShader = vert_Reflector;
|
|
@@ -3590,7 +3626,7 @@ class ReflectorMaterial extends three.ShaderMaterial {
|
|
|
3590
3626
|
};
|
|
3591
3627
|
this.uniforms = {
|
|
3592
3628
|
color: {
|
|
3593
|
-
value: new three.Color(
|
|
3629
|
+
value: new three.Color()
|
|
3594
3630
|
},
|
|
3595
3631
|
alpha: {
|
|
3596
3632
|
value: 1
|
|
@@ -3598,9 +3634,12 @@ class ReflectorMaterial extends three.ShaderMaterial {
|
|
|
3598
3634
|
map: {
|
|
3599
3635
|
value: null
|
|
3600
3636
|
},
|
|
3601
|
-
|
|
3637
|
+
reflectMap: {
|
|
3602
3638
|
value: null
|
|
3603
3639
|
},
|
|
3640
|
+
reflectIntensity: {
|
|
3641
|
+
value: 1
|
|
3642
|
+
},
|
|
3604
3643
|
textureMatrix: {
|
|
3605
3644
|
value: new three.Matrix4()
|
|
3606
3645
|
},
|
|
@@ -3631,6 +3670,9 @@ class ReflectorMaterial extends three.ShaderMaterial {
|
|
|
3631
3670
|
};
|
|
3632
3671
|
}
|
|
3633
3672
|
}
|
|
3673
|
+
__decorate([
|
|
3674
|
+
property
|
|
3675
|
+
], ReflectorMaterial.prototype, "color", null);
|
|
3634
3676
|
__decorate([
|
|
3635
3677
|
property({
|
|
3636
3678
|
min: 0,
|