@mml-io/3d-web-client-core 0.0.0-experimental-248ff6a-20240207 → 0.0.0-experimental-ad4b20a-20240208
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/Character.d.ts +2 -1
- package/build/character/CharacterManager.d.ts +0 -2
- package/build/character/CharacterMaterial.d.ts +13 -9
- package/build/character/CharacterModel.d.ts +7 -4
- package/build/index.js +124 -206
- package/build/index.js.map +3 -3
- package/build/tweakpane/blades/characterFolder.d.ts +0 -17
- package/package.json +3 -3
package/build/index.js
CHANGED
@@ -273,7 +273,7 @@ import {
|
|
273
273
|
} from "three";
|
274
274
|
|
275
275
|
// src/character/CharacterMaterial.ts
|
276
|
-
import { Color,
|
276
|
+
import { Color, MeshStandardMaterial, UniformsUtils } from "three";
|
277
277
|
|
278
278
|
// src/rendering/shaders/bayer-dither.ts
|
279
279
|
var bayerDither = (
|
@@ -367,50 +367,23 @@ ${before}
|
|
367
367
|
|
368
368
|
// src/tweakpane/blades/characterFolder.ts
|
369
369
|
var characterValues = {
|
370
|
-
transmission: 0.01,
|
371
370
|
metalness: 0.2,
|
372
371
|
roughness: 0.8,
|
373
|
-
ior: 1,
|
374
|
-
thickness: 0.1,
|
375
|
-
specularColor: { r: 1, g: 1, b: 1 },
|
376
|
-
specularIntensity: 0.1,
|
377
372
|
emissive: { r: 1, g: 1, b: 1 },
|
378
373
|
emissiveIntensity: 0.01,
|
379
|
-
envMapIntensity: 0.12
|
380
|
-
sheenColor: { r: 1, g: 1, b: 1 },
|
381
|
-
sheen: 0.5,
|
382
|
-
clearcoat: 0,
|
383
|
-
clearcoatRoughness: 0
|
374
|
+
envMapIntensity: 0.12
|
384
375
|
};
|
385
376
|
var characterOptions = {
|
386
|
-
transmission: { min: 0.01, max: 3, step: 0.01 },
|
387
377
|
metalness: { min: 0, max: 1, step: 0.01 },
|
388
378
|
roughness: { min: 0, max: 1, step: 0.01 },
|
389
|
-
ior: { min: 1, max: 5, step: 0.01 },
|
390
|
-
thickness: { min: 0, max: 1, step: 0.01 },
|
391
|
-
specularIntensity: { min: 0, max: 1, step: 0.01 },
|
392
379
|
emissiveIntensity: { min: 0, max: 1, step: 0.01 },
|
393
|
-
envMapIntensity: { min: 0, max: 1, step: 0.01 }
|
394
|
-
sheen: { min: 0, max: 1, step: 0.01 },
|
395
|
-
clearcoat: { min: 0, max: 1, step: 0.01 },
|
396
|
-
clearcoatRoughness: { min: 0, max: 1, step: 0.01 }
|
380
|
+
envMapIntensity: { min: 0, max: 1, step: 0.01 }
|
397
381
|
};
|
398
382
|
var CharacterFolder = class {
|
399
383
|
constructor(parentFolder, expand = false) {
|
400
384
|
this.folder = parentFolder.addFolder({ title: "characterMaterial", expanded: expand });
|
401
|
-
this.folder.addBinding(characterValues, "transmission", characterOptions.transmission);
|
402
385
|
this.folder.addBinding(characterValues, "metalness", characterOptions.metalness);
|
403
386
|
this.folder.addBinding(characterValues, "roughness", characterOptions.roughness);
|
404
|
-
this.folder.addBinding(characterValues, "ior", characterOptions.ior);
|
405
|
-
this.folder.addBinding(characterValues, "thickness", characterOptions.thickness);
|
406
|
-
this.folder.addBinding(characterValues, "specularColor", {
|
407
|
-
color: { type: "float" }
|
408
|
-
});
|
409
|
-
this.folder.addBinding(
|
410
|
-
characterValues,
|
411
|
-
"specularIntensity",
|
412
|
-
characterOptions.specularIntensity
|
413
|
-
);
|
414
387
|
this.folder.addBinding(characterValues, "emissive", {
|
415
388
|
color: { type: "float" }
|
416
389
|
});
|
@@ -420,16 +393,6 @@ var CharacterFolder = class {
|
|
420
393
|
characterOptions.emissiveIntensity
|
421
394
|
);
|
422
395
|
this.folder.addBinding(characterValues, "envMapIntensity", characterOptions.envMapIntensity);
|
423
|
-
this.folder.addBinding(characterValues, "sheenColor", {
|
424
|
-
color: { type: "float" }
|
425
|
-
});
|
426
|
-
this.folder.addBinding(characterValues, "sheen", characterOptions.sheen);
|
427
|
-
this.folder.addBinding(characterValues, "clearcoat", characterOptions.clearcoat);
|
428
|
-
this.folder.addBinding(
|
429
|
-
characterValues,
|
430
|
-
"clearcoatRoughness",
|
431
|
-
characterOptions.clearcoatRoughness
|
432
|
-
);
|
433
396
|
}
|
434
397
|
setupChangeEvent() {
|
435
398
|
this.folder.on("change", (e) => {
|
@@ -437,15 +400,6 @@ var CharacterFolder = class {
|
|
437
400
|
if (!target)
|
438
401
|
return;
|
439
402
|
switch (target) {
|
440
|
-
case "specularColor": {
|
441
|
-
const value = e.value;
|
442
|
-
characterValues.specularColor = {
|
443
|
-
r: value.r,
|
444
|
-
g: value.g,
|
445
|
-
b: value.b
|
446
|
-
};
|
447
|
-
break;
|
448
|
-
}
|
449
403
|
case "emissive": {
|
450
404
|
const value = e.value;
|
451
405
|
characterValues.emissive = {
|
@@ -455,15 +409,6 @@ var CharacterFolder = class {
|
|
455
409
|
};
|
456
410
|
break;
|
457
411
|
}
|
458
|
-
case "sheenColor": {
|
459
|
-
const value = e.value;
|
460
|
-
characterValues.sheenColor = {
|
461
|
-
r: value.r,
|
462
|
-
g: value.g,
|
463
|
-
b: value.b
|
464
|
-
};
|
465
|
-
break;
|
466
|
-
}
|
467
412
|
default: {
|
468
413
|
break;
|
469
414
|
}
|
@@ -473,83 +418,59 @@ var CharacterFolder = class {
|
|
473
418
|
};
|
474
419
|
|
475
420
|
// src/character/CharacterMaterial.ts
|
476
|
-
var CharacterMaterial = class extends
|
477
|
-
constructor(
|
421
|
+
var CharacterMaterial = class extends MeshStandardMaterial {
|
422
|
+
constructor(isLocal, cameraManager, characterId, originalMaterial, colorOverride) {
|
478
423
|
super();
|
479
|
-
this.
|
424
|
+
this.isLocal = isLocal;
|
425
|
+
this.cameraManager = cameraManager;
|
426
|
+
this.characterId = characterId;
|
427
|
+
this.originalMaterial = originalMaterial;
|
428
|
+
this.colorOverride = colorOverride;
|
429
|
+
this.uniforms = {
|
430
|
+
discardAll: { value: 1 },
|
431
|
+
diffuseColor: { value: new Color() },
|
432
|
+
map: { value: null }
|
433
|
+
};
|
480
434
|
this.colorsCube216 = [];
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
this.
|
485
|
-
this.
|
486
|
-
this.roughness = characterValues.roughness;
|
487
|
-
this.ior = characterValues.ior;
|
488
|
-
this.thickness = characterValues.thickness;
|
489
|
-
this.specularColor = new Color().setRGB(
|
490
|
-
characterValues.specularColor.r,
|
491
|
-
characterValues.specularColor.g,
|
492
|
-
characterValues.specularColor.b
|
493
|
-
);
|
494
|
-
this.specularIntensity = characterValues.specularIntensity;
|
495
|
-
this.emissive = new Color().setRGB(
|
496
|
-
characterValues.emissive.r,
|
497
|
-
characterValues.emissive.g,
|
498
|
-
characterValues.emissive.b
|
499
|
-
);
|
500
|
-
this.emissiveIntensity = characterValues.emissiveIntensity;
|
435
|
+
this.targetAlpha = 1;
|
436
|
+
this.currentAlpha = 1;
|
437
|
+
this.copy(this.originalMaterial);
|
438
|
+
this.generateColorCube();
|
439
|
+
this.color = this.colorOverride || this.colorsCube216[this.characterId];
|
501
440
|
this.envMapIntensity = characterValues.envMapIntensity;
|
502
|
-
this.
|
503
|
-
|
504
|
-
characterValues.sheenColor.g,
|
505
|
-
characterValues.sheenColor.b
|
506
|
-
);
|
507
|
-
this.sheen = characterValues.sheen;
|
508
|
-
this.clearcoat = characterValues.clearcoat;
|
509
|
-
this.clearcoatRoughness = characterValues.clearcoatRoughness;
|
441
|
+
this.transparent = true;
|
442
|
+
this.side = this.originalMaterial.side;
|
510
443
|
this.onBeforeCompile = (shader) => {
|
511
444
|
this.uniforms = UniformsUtils.clone(shader.uniforms);
|
512
445
|
this.uniforms.nearClip = { value: 0.01 };
|
513
446
|
this.uniforms.farClip = { value: 1e3 };
|
514
|
-
this.uniforms.ditheringNear = { value: 0.
|
447
|
+
this.uniforms.ditheringNear = { value: 0.3 };
|
515
448
|
this.uniforms.ditheringRange = { value: 0.5 };
|
516
449
|
this.uniforms.time = { value: 0 };
|
517
450
|
this.uniforms.diffuseRandomColor = { value: new Color() };
|
451
|
+
this.uniforms.discardAll = { value: 0 };
|
518
452
|
shader.uniforms = this.uniforms;
|
453
|
+
shader.vertexShader = "varying vec3 vWorldPosition;\n" + shader.vertexShader;
|
454
|
+
shader.vertexShader = shader.vertexShader.replace(
|
455
|
+
"#include <worldpos_vertex>",
|
456
|
+
"vec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\nvWorldPosition = worldPosition.xyz;"
|
457
|
+
);
|
519
458
|
shader.vertexShader = injectBeforeMain(shader.vertexShader, "varying vec2 vUv;");
|
520
459
|
shader.vertexShader = injectInsideMain(shader.vertexShader, "vUv = uv;");
|
521
460
|
shader.fragmentShader = injectBeforeMain(
|
522
461
|
shader.fragmentShader,
|
523
462
|
/* glsl */
|
524
463
|
`
|
525
|
-
//#define showPattern
|
526
464
|
varying vec2 vUv;
|
465
|
+
varying vec3 vWorldPosition;
|
527
466
|
uniform float nearClip;
|
528
467
|
uniform float farClip;
|
529
468
|
uniform float ditheringNear;
|
530
469
|
uniform float ditheringRange;
|
531
470
|
uniform float time;
|
532
471
|
uniform vec3 diffuseRandomColor;
|
472
|
+
uniform int discardAll;
|
533
473
|
${bayerDither}
|
534
|
-
|
535
|
-
#ifdef showPattern
|
536
|
-
vec2 rand2(vec2 p) {
|
537
|
-
return fract(vec2(sin(p.x * 591.32 + p.y * 154.077), cos(p.x * 391.32 + p.y * 49.077)));
|
538
|
-
}
|
539
|
-
float voronoi(in vec2 x) {
|
540
|
-
vec2 p = floor(x);
|
541
|
-
vec2 f = fract(x);
|
542
|
-
float minDistance = 1.0;
|
543
|
-
for(int j = -1; j <= 1; j ++)
|
544
|
-
for(int i = -1; i <= 1; i ++) {
|
545
|
-
vec2 b = vec2(i, j);
|
546
|
-
vec2 rand = 0.5 + 0.5 * sin(time * 1.5 + 12.0 * rand2(p + b));
|
547
|
-
vec2 r = vec2(b) - f + rand;
|
548
|
-
minDistance = min(minDistance, length(r));
|
549
|
-
}
|
550
|
-
return minDistance;
|
551
|
-
}
|
552
|
-
#endif
|
553
474
|
`
|
554
475
|
);
|
555
476
|
shader.fragmentShader = injectBefore(
|
@@ -557,42 +478,32 @@ var CharacterMaterial = class extends MeshPhysicalMaterial {
|
|
557
478
|
"#include <output_fragment>",
|
558
479
|
/* glsl */
|
559
480
|
`
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
481
|
+
if (discardAll == 1) {
|
482
|
+
discard;
|
483
|
+
} else {
|
484
|
+
float distance = length(vWorldPosition - cameraPosition);
|
485
|
+
float normalizedDistance = (distance - nearClip) / (farClip - nearClip);
|
486
|
+
ivec2 p = ivec2(mod(gl_FragCoord.xy, 8.0));
|
487
|
+
float d = 0.0;
|
488
|
+
if (p.x <= 3 && p.y <= 3) {
|
489
|
+
d = bayerDither(bayertl, p);
|
490
|
+
} else if (p.x > 3 && p.y <= 3) {
|
491
|
+
d = bayerDither(bayertr, p - ivec2(4, 0));
|
492
|
+
} else if (p.x <= 3 && p.y > 3) {
|
493
|
+
d = bayerDither(bayerbl, p - ivec2(0, 4));
|
494
|
+
} else if (p.x > 3 && p.y > 3) {
|
495
|
+
d = bayerDither(bayerbr, p - ivec2(4, 4));
|
496
|
+
}
|
497
|
+
if (distance <= ditheringNear + d * ditheringRange) discard;
|
498
|
+
outgoingLight *= diffuseRandomColor;
|
572
499
|
}
|
573
|
-
if (distance <= ditheringNear + d * ditheringRange) discard;
|
574
|
-
|
575
|
-
vec2 uv = vUv;
|
576
|
-
float s = clamp(0.35 + 0.35 * sin(5.0 * -time + vUv.y * 600.0), 0.0, 1.0);
|
577
|
-
float scanLines = pow(s, 1.33);
|
578
|
-
|
579
|
-
outgoingLight *= diffuseRandomColor;
|
580
|
-
|
581
|
-
#ifdef showPattern
|
582
|
-
float val = pow(voronoi(uv * 8.0) * 1.2, 0.5);
|
583
|
-
float thickness = 1.0 / 500.0;
|
584
|
-
vec2 g = step(mod(uv, 0.015), vec2(thickness));
|
585
|
-
float a = 1.0 - clamp(val * (g.x + g.y), 0.0, 1.0);
|
586
|
-
vec3 grid = vec3(smoothstep(0.01, 0.0, a) * 1.15) * diffuseRandomColor;
|
587
|
-
outgoingLight += grid;
|
588
|
-
#endif
|
589
500
|
`
|
590
501
|
);
|
591
502
|
};
|
592
|
-
this.
|
503
|
+
this.needsUpdate = true;
|
593
504
|
}
|
594
505
|
generateColorCube() {
|
595
|
-
const saturation =
|
506
|
+
const saturation = 1;
|
596
507
|
const lightness = 0.9;
|
597
508
|
const goldenRatioConjugate = 0.618033988749895;
|
598
509
|
let hue = 0;
|
@@ -604,17 +515,24 @@ var CharacterMaterial = class extends MeshPhysicalMaterial {
|
|
604
515
|
}
|
605
516
|
}
|
606
517
|
update() {
|
607
|
-
this.
|
518
|
+
if (this.isLocal) {
|
519
|
+
this.targetAlpha = this.cameraManager.targetDistance < 0.4 ? 0 : 1;
|
520
|
+
this.currentAlpha += ease(this.targetAlpha, this.currentAlpha, 0.07);
|
521
|
+
if (this.currentAlpha > 0.999) {
|
522
|
+
this.currentAlpha = 1;
|
523
|
+
this.cameraManager.minPolarAngle = Math.PI * 0.25;
|
524
|
+
}
|
525
|
+
if (this.currentAlpha < 1e-3) {
|
526
|
+
this.currentAlpha = 0;
|
527
|
+
this.cameraManager.minPolarAngle = Math.PI * 0.35;
|
528
|
+
}
|
529
|
+
this.uniforms.discardAll.value = this.currentAlpha === 0 ? 1 : 0;
|
530
|
+
if (this.currentAlpha !== this.opacity) {
|
531
|
+
this.opacity = this.currentAlpha;
|
532
|
+
}
|
533
|
+
}
|
608
534
|
this.metalness = characterValues.metalness;
|
609
535
|
this.roughness = characterValues.roughness;
|
610
|
-
this.ior = characterValues.ior;
|
611
|
-
this.thickness = characterValues.thickness;
|
612
|
-
this.specularColor = new Color().setRGB(
|
613
|
-
characterValues.specularColor.r,
|
614
|
-
characterValues.specularColor.g,
|
615
|
-
characterValues.specularColor.b
|
616
|
-
);
|
617
|
-
this.specularIntensity = characterValues.specularIntensity;
|
618
536
|
this.emissive = new Color().setRGB(
|
619
537
|
characterValues.emissive.r,
|
620
538
|
characterValues.emissive.g,
|
@@ -622,14 +540,6 @@ var CharacterMaterial = class extends MeshPhysicalMaterial {
|
|
622
540
|
);
|
623
541
|
this.emissiveIntensity = characterValues.emissiveIntensity;
|
624
542
|
this.envMapIntensity = characterValues.envMapIntensity;
|
625
|
-
this.sheenColor = new Color().setRGB(
|
626
|
-
characterValues.sheenColor.r,
|
627
|
-
characterValues.sheenColor.g,
|
628
|
-
characterValues.sheenColor.b
|
629
|
-
);
|
630
|
-
this.sheen = characterValues.sheen;
|
631
|
-
this.clearcoat = characterValues.clearcoat;
|
632
|
-
this.clearcoatRoughness = characterValues.clearcoatRoughness;
|
633
543
|
}
|
634
544
|
};
|
635
545
|
|
@@ -646,13 +556,16 @@ var AnimationState = /* @__PURE__ */ ((AnimationState2) => {
|
|
646
556
|
|
647
557
|
// src/character/CharacterModel.ts
|
648
558
|
var CharacterModel = class {
|
649
|
-
constructor(characterDescription, animationConfig, characterModelLoader) {
|
559
|
+
constructor(characterDescription, animationConfig, characterModelLoader, cameraManager, characterId, isLocal) {
|
650
560
|
this.characterDescription = characterDescription;
|
651
561
|
this.animationConfig = animationConfig;
|
652
562
|
this.characterModelLoader = characterModelLoader;
|
563
|
+
this.cameraManager = cameraManager;
|
564
|
+
this.characterId = characterId;
|
565
|
+
this.isLocal = isLocal;
|
653
566
|
this.mesh = null;
|
654
|
-
this.material = new CharacterMaterial();
|
655
567
|
this.headBone = null;
|
568
|
+
this.materials = /* @__PURE__ */ new Map();
|
656
569
|
this.animations = {};
|
657
570
|
this.animationMixer = null;
|
658
571
|
this.currentAnimation = 0 /* idle */;
|
@@ -669,22 +582,32 @@ var CharacterModel = class {
|
|
669
582
|
2 /* running */
|
670
583
|
);
|
671
584
|
await this.setAnimationFromFile(this.animationConfig.airAnimationFileUrl, 4 /* air */);
|
672
|
-
|
673
|
-
this.applyCustomMaterial(this.material);
|
674
|
-
}
|
585
|
+
this.applyCustomMaterials();
|
675
586
|
}
|
676
|
-
|
587
|
+
applyCustomMaterials() {
|
677
588
|
if (!this.mesh)
|
678
589
|
return;
|
679
590
|
this.mesh.traverse((child) => {
|
680
|
-
|
681
|
-
|
682
|
-
const
|
683
|
-
if (
|
684
|
-
|
591
|
+
if (child.isMesh || child.isSkinnedMesh) {
|
592
|
+
const asMesh = child;
|
593
|
+
const originalMaterial = asMesh.material;
|
594
|
+
if (this.materials.has(originalMaterial.name)) {
|
595
|
+
asMesh.material = this.materials.get(originalMaterial.name);
|
685
596
|
} else {
|
686
|
-
const
|
687
|
-
|
597
|
+
const material = originalMaterial.name === "body_replaceable_color" ? new CharacterMaterial(
|
598
|
+
this.isLocal,
|
599
|
+
this.cameraManager,
|
600
|
+
this.characterId,
|
601
|
+
originalMaterial
|
602
|
+
) : new CharacterMaterial(
|
603
|
+
this.isLocal,
|
604
|
+
this.cameraManager,
|
605
|
+
this.characterId,
|
606
|
+
originalMaterial,
|
607
|
+
originalMaterial.color
|
608
|
+
);
|
609
|
+
this.materials.set(originalMaterial.name, material);
|
610
|
+
asMesh.material = material;
|
688
611
|
}
|
689
612
|
}
|
690
613
|
});
|
@@ -813,6 +736,7 @@ var CharacterModel = class {
|
|
813
736
|
update(time) {
|
814
737
|
if (this.animationMixer) {
|
815
738
|
this.animationMixer.update(time);
|
739
|
+
this.materials.forEach((material) => material.update());
|
816
740
|
}
|
817
741
|
}
|
818
742
|
};
|
@@ -821,7 +745,7 @@ var CharacterModel = class {
|
|
821
745
|
import {
|
822
746
|
CircleGeometry,
|
823
747
|
GLSL3,
|
824
|
-
Mesh,
|
748
|
+
Mesh as Mesh2,
|
825
749
|
RawShaderMaterial
|
826
750
|
} from "three";
|
827
751
|
var CharacterSpeakingIndicator = class {
|
@@ -885,7 +809,7 @@ var CharacterSpeakingIndicator = class {
|
|
885
809
|
transparent: true,
|
886
810
|
glslVersion: GLSL3
|
887
811
|
});
|
888
|
-
this.mesh = new
|
812
|
+
this.mesh = new Mesh2(this.geometry, this.material);
|
889
813
|
this.currentAlpha = 0;
|
890
814
|
this.targetAlpha = 0;
|
891
815
|
this.scene.add(this.mesh);
|
@@ -914,13 +838,13 @@ import {
|
|
914
838
|
Color as Color2,
|
915
839
|
FrontSide,
|
916
840
|
LinearFilter as LinearFilter2,
|
917
|
-
Mesh as
|
841
|
+
Mesh as Mesh3,
|
918
842
|
MeshBasicMaterial as MeshBasicMaterial2,
|
919
843
|
PlaneGeometry
|
920
844
|
} from "three";
|
921
845
|
|
922
846
|
// src/character/CanvasText.ts
|
923
|
-
import { Texture, LinearFilter, RGBAFormat, MeshBasicMaterial } from "three";
|
847
|
+
import { Texture as Texture2, LinearFilter, RGBAFormat, MeshBasicMaterial } from "three";
|
924
848
|
function getTextAlignOffset(textAlign, width) {
|
925
849
|
switch (textAlign) {
|
926
850
|
case "center":
|
@@ -1021,7 +945,7 @@ function CanvasText(message, options) {
|
|
1021
945
|
}
|
1022
946
|
function THREECanvasTextTexture(text, options) {
|
1023
947
|
const canvas = CanvasText(text, options);
|
1024
|
-
const texture = new
|
948
|
+
const texture = new Texture2(canvas);
|
1025
949
|
texture.minFilter = LinearFilter;
|
1026
950
|
texture.magFilter = LinearFilter;
|
1027
951
|
texture.format = RGBAFormat;
|
@@ -1040,7 +964,7 @@ var defaultLabelWidth = 0.25;
|
|
1040
964
|
var defaultLabelHeight = 0.125;
|
1041
965
|
var defaultLabelCastShadows = true;
|
1042
966
|
var tooltipGeometry = new PlaneGeometry(1, 1, 1, 1);
|
1043
|
-
var CharacterTooltip = class extends
|
967
|
+
var CharacterTooltip = class extends Mesh3 {
|
1044
968
|
constructor() {
|
1045
969
|
super(tooltipGeometry);
|
1046
970
|
this.visibleOpacity = 0.85;
|
@@ -1147,7 +1071,7 @@ var CharacterTooltip = class extends Mesh2 {
|
|
1147
1071
|
|
1148
1072
|
// src/character/Character.ts
|
1149
1073
|
var Character = class extends Group {
|
1150
|
-
constructor(characterDescription, animationConfig, characterModelLoader, characterId, modelLoadedCallback, cameraManager, composer) {
|
1074
|
+
constructor(characterDescription, animationConfig, characterModelLoader, characterId, modelLoadedCallback, cameraManager, composer, isLocal) {
|
1151
1075
|
super();
|
1152
1076
|
this.characterDescription = characterDescription;
|
1153
1077
|
this.animationConfig = animationConfig;
|
@@ -1156,6 +1080,7 @@ var Character = class extends Group {
|
|
1156
1080
|
this.modelLoadedCallback = modelLoadedCallback;
|
1157
1081
|
this.cameraManager = cameraManager;
|
1158
1082
|
this.composer = composer;
|
1083
|
+
this.isLocal = isLocal;
|
1159
1084
|
this.model = null;
|
1160
1085
|
this.color = new Color3();
|
1161
1086
|
this.tooltip = null;
|
@@ -1168,14 +1093,16 @@ var Character = class extends Group {
|
|
1168
1093
|
this.model = new CharacterModel(
|
1169
1094
|
this.characterDescription,
|
1170
1095
|
this.animationConfig,
|
1171
|
-
this.characterModelLoader
|
1096
|
+
this.characterModelLoader,
|
1097
|
+
this.cameraManager,
|
1098
|
+
this.characterId,
|
1099
|
+
this.isLocal
|
1172
1100
|
);
|
1173
1101
|
await this.model.init();
|
1174
1102
|
this.add(this.model.mesh);
|
1175
1103
|
if (this.speakingIndicator === null) {
|
1176
1104
|
this.speakingIndicator = new CharacterSpeakingIndicator(this.composer.postPostScene);
|
1177
1105
|
}
|
1178
|
-
this.color = this.model.material.colorsCube216[this.characterId];
|
1179
1106
|
this.modelLoadedCallback();
|
1180
1107
|
}
|
1181
1108
|
updateAnimation(targetAnimation) {
|
@@ -1198,11 +1125,6 @@ var Character = class extends Group {
|
|
1198
1125
|
);
|
1199
1126
|
}
|
1200
1127
|
}
|
1201
|
-
if (typeof this.model.material.uniforms.time !== "undefined") {
|
1202
|
-
this.model.material.uniforms.time.value = time;
|
1203
|
-
this.model.material.uniforms.diffuseRandomColor.value = this.color;
|
1204
|
-
this.model.material.update();
|
1205
|
-
}
|
1206
1128
|
this.model.update(deltaTime);
|
1207
1129
|
}
|
1208
1130
|
getCurrentAnimation() {
|
@@ -1612,8 +1534,6 @@ var CharacterManager = class {
|
|
1612
1534
|
this.remoteCharacterControllers = /* @__PURE__ */ new Map();
|
1613
1535
|
this.localCharacterSpawned = false;
|
1614
1536
|
this.localCharacter = null;
|
1615
|
-
this.cameraOffsetTarget = 0;
|
1616
|
-
this.cameraOffset = 0;
|
1617
1537
|
this.speakingCharacters = /* @__PURE__ */ new Map();
|
1618
1538
|
this.group = new Group2();
|
1619
1539
|
}
|
@@ -1627,7 +1547,8 @@ var CharacterManager = class {
|
|
1627
1547
|
() => {
|
1628
1548
|
},
|
1629
1549
|
this.cameraManager,
|
1630
|
-
this.composer
|
1550
|
+
this.composer,
|
1551
|
+
true
|
1631
1552
|
);
|
1632
1553
|
const quaternion = new Quaternion5().setFromEuler(character.rotation);
|
1633
1554
|
this.sendUpdate({
|
@@ -1666,7 +1587,8 @@ var CharacterManager = class {
|
|
1666
1587
|
() => {
|
1667
1588
|
},
|
1668
1589
|
this.cameraManager,
|
1669
|
-
this.composer
|
1590
|
+
this.composer,
|
1591
|
+
false
|
1670
1592
|
);
|
1671
1593
|
this.remoteCharacters.set(id, character);
|
1672
1594
|
const remoteController = new RemoteController(character, id);
|
@@ -1713,12 +1635,9 @@ var CharacterManager = class {
|
|
1713
1635
|
if (this.timeManager.frame % 2 === 0) {
|
1714
1636
|
this.sendUpdate(this.localController.networkState);
|
1715
1637
|
}
|
1716
|
-
|
1717
|
-
this.
|
1718
|
-
|
1719
|
-
targetOffset.add(this.headTargetOffset);
|
1720
|
-
targetOffset.applyQuaternion(this.localCharacter.quaternion);
|
1721
|
-
this.cameraManager.setTarget(targetOffset.add(this.localCharacter.position));
|
1638
|
+
const targetOffset = new Vector38();
|
1639
|
+
targetOffset.add(this.headTargetOffset).applyQuaternion(this.localCharacter.quaternion).add(this.localCharacter.position);
|
1640
|
+
this.cameraManager.setTarget(targetOffset);
|
1722
1641
|
for (const [id, update] of this.clientStates) {
|
1723
1642
|
if (this.remoteCharacters.has(id) && this.speakingCharacters.has(id)) {
|
1724
1643
|
const character = this.remoteCharacters.get(id);
|
@@ -2068,8 +1987,8 @@ var BrightnessContrastSaturationFolder = class {
|
|
2068
1987
|
// src/tweakpane/blades/environmentFolder.ts
|
2069
1988
|
var sunValues = {
|
2070
1989
|
sunPosition: {
|
2071
|
-
sunAzimuthalAngle:
|
2072
|
-
sunPolarAngle: -
|
1990
|
+
sunAzimuthalAngle: 214.5,
|
1991
|
+
sunPolarAngle: -41.5
|
2073
1992
|
},
|
2074
1993
|
sunIntensity: 1,
|
2075
1994
|
sunColor: { r: 1, g: 1, b: 1 }
|
@@ -2223,14 +2142,14 @@ var EnvironmentFolder = class {
|
|
2223
2142
|
// src/tweakpane/blades/postExtrasFolder.ts
|
2224
2143
|
var extrasValues = {
|
2225
2144
|
grain: 0.055,
|
2226
|
-
bloom:
|
2145
|
+
bloom: 3
|
2227
2146
|
};
|
2228
2147
|
var extrasOptions = {
|
2229
2148
|
grain: {
|
2230
2149
|
amount: { min: 0, max: 0.2, step: 2e-3 }
|
2231
2150
|
},
|
2232
2151
|
bloom: {
|
2233
|
-
amount: { min: 0, max:
|
2152
|
+
amount: { min: 0, max: 5, step: 0.05 }
|
2234
2153
|
}
|
2235
2154
|
};
|
2236
2155
|
var PostExtrasFolder = class {
|
@@ -2263,7 +2182,7 @@ var rendererValues = {
|
|
2263
2182
|
shadowMap: 2,
|
2264
2183
|
toneMapping: 5,
|
2265
2184
|
exposure: 1,
|
2266
|
-
bgIntensity:
|
2185
|
+
bgIntensity: 1,
|
2267
2186
|
bgBlurriness: 0
|
2268
2187
|
};
|
2269
2188
|
var rendererOptions = {
|
@@ -2994,8 +2913,8 @@ var Sun = class extends Group4 {
|
|
2994
2913
|
}
|
2995
2914
|
this.directionalLight = new DirectionalLight(16777215, 0.5);
|
2996
2915
|
this.directionalLight.intensity = sunValues.sunIntensity;
|
2997
|
-
this.directionalLight.shadow.normalBias = 0.
|
2998
|
-
this.directionalLight.shadow.radius =
|
2916
|
+
this.directionalLight.shadow.normalBias = 0.01;
|
2917
|
+
this.directionalLight.shadow.radius = 0.02;
|
2999
2918
|
this.directionalLight.shadow.camera = this.shadowCamera;
|
3000
2919
|
this.directionalLight.shadow.mapSize.set(this.shadowResolution, this.shadowResolution);
|
3001
2920
|
this.directionalLight.castShadow = true;
|
@@ -3844,7 +3763,7 @@ var EffectShader = {
|
|
3844
3763
|
import {
|
3845
3764
|
BufferAttribute,
|
3846
3765
|
BufferGeometry,
|
3847
|
-
Mesh as
|
3766
|
+
Mesh as Mesh4,
|
3848
3767
|
OrthographicCamera as OrthographicCamera2,
|
3849
3768
|
Sphere
|
3850
3769
|
} from "three";
|
@@ -3860,7 +3779,7 @@ var FullScreenTriangle = class {
|
|
3860
3779
|
this.geometry.boundingSphere = new Sphere();
|
3861
3780
|
this.geometry.computeBoundingSphere = function() {
|
3862
3781
|
};
|
3863
|
-
this.mesh = new
|
3782
|
+
this.mesh = new Mesh4(this.geometry, material);
|
3864
3783
|
this.mesh.frustumCulled = false;
|
3865
3784
|
}
|
3866
3785
|
get material() {
|
@@ -4708,7 +4627,6 @@ var Composer = class {
|
|
4708
4627
|
if (envMap) {
|
4709
4628
|
envMap.colorSpace = LinearSRGBColorSpace;
|
4710
4629
|
envMap.needsUpdate = true;
|
4711
|
-
this.scene.environment = envMap;
|
4712
4630
|
this.scene.background = envMap;
|
4713
4631
|
this.scene.backgroundIntensity = rendererValues.bgIntensity;
|
4714
4632
|
this.isEnvHDRI = true;
|
@@ -4831,7 +4749,7 @@ import {
|
|
4831
4749
|
Group as Group5,
|
4832
4750
|
Line3 as Line32,
|
4833
4751
|
Matrix4 as Matrix46,
|
4834
|
-
Mesh as
|
4752
|
+
Mesh as Mesh5,
|
4835
4753
|
MeshBasicMaterial as MeshBasicMaterial3,
|
4836
4754
|
Quaternion as Quaternion6,
|
4837
4755
|
Ray as Ray2,
|
@@ -4919,7 +4837,7 @@ var CollisionsManager = class {
|
|
4919
4837
|
};
|
4920
4838
|
if (this.debug) {
|
4921
4839
|
newBufferGeometry.boundsTree = meshBVH;
|
4922
|
-
const wireframeMesh = new
|
4840
|
+
const wireframeMesh = new Mesh5(newBufferGeometry, new MeshBasicMaterial3({ wireframe: true }));
|
4923
4841
|
const normalsHelper = new VertexNormalsHelper(wireframeMesh, 0.25, 65280);
|
4924
4842
|
const visualizer = new MeshBVHHelper(wireframeMesh, 4);
|
4925
4843
|
visualizer.edgeMaterial.color = new Color8("blue");
|