@mml-io/3d-web-client-core 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/character/CanvasText.d.ts +3 -3
- package/build/character/LocalController.d.ts +0 -1
- package/build/collisions/CollisionsManager.d.ts +14 -4
- package/build/index.js +1212 -963
- package/build/index.js.map +4 -4
- package/build/rendering/composer.d.ts +5 -4
- package/build/tweakpane/TweakPane.d.ts +11 -15
- package/build/tweakpane/blades/bcsFolder.d.ts +12 -0
- package/build/tweakpane/blades/characterFolder.d.ts +34 -0
- package/build/tweakpane/blades/environmentFolder.d.ts +41 -0
- package/build/tweakpane/blades/postExtrasFolder.d.ts +12 -0
- package/build/tweakpane/blades/rendererFolder.d.ts +15 -0
- package/build/tweakpane/blades/rendererStatsFolder.d.ts +12 -0
- package/build/tweakpane/blades/ssaoFolder.d.ts +53 -0
- package/build/tweakpane/blades/toneMappingFolder.d.ts +18 -0
- package/build/tweakpane/tweakPaneStyle.d.ts +1 -0
- package/package.json +20 -13
- package/build/tweakpane/characterSettings.d.ts +0 -89
- package/build/tweakpane/composerSettings.d.ts +0 -234
- package/build/tweakpane/envSettings.d.ts +0 -40
- package/build/tweakpane/sunSettings.d.ts +0 -31
package/build/index.js
CHANGED
@@ -1,10 +1,3 @@
|
|
1
|
-
var __defProp = Object.defineProperty;
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
3
|
-
var __publicField = (obj, key, value) => {
|
4
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
5
|
-
return value;
|
6
|
-
};
|
7
|
-
|
8
1
|
// src/camera/CameraManager.ts
|
9
2
|
import { PerspectiveCamera, Raycaster, Vector3 as Vector32 } from "three";
|
10
3
|
|
@@ -47,28 +40,26 @@ function getTweakpaneActive() {
|
|
47
40
|
var CameraManager = class {
|
48
41
|
constructor(collisionsManager) {
|
49
42
|
this.collisionsManager = collisionsManager;
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
__publicField(this, "hadTarget", false);
|
71
|
-
__publicField(this, "rayCaster");
|
43
|
+
this.initialDistance = 3.3;
|
44
|
+
this.minDistance = 0.1;
|
45
|
+
this.maxDistance = 8;
|
46
|
+
this.initialFOV = 60;
|
47
|
+
this.fov = this.initialFOV;
|
48
|
+
this.minFOV = 50;
|
49
|
+
this.maxFOV = 70;
|
50
|
+
this.targetFOV = this.initialFOV;
|
51
|
+
this.minPolarAngle = Math.PI * 0.25;
|
52
|
+
this.maxPolarAngle = Math.PI * 0.95;
|
53
|
+
this.dampingFactor = 0.091;
|
54
|
+
this.targetDistance = this.initialDistance;
|
55
|
+
this.distance = this.initialDistance;
|
56
|
+
this.targetPhi = Math.PI / 2;
|
57
|
+
this.phi = Math.PI / 2;
|
58
|
+
this.targetTheta = -Math.PI / 2;
|
59
|
+
this.theta = -Math.PI / 2;
|
60
|
+
this.dragging = false;
|
61
|
+
this.target = new Vector32(0, 1.55, 0);
|
62
|
+
this.hadTarget = false;
|
72
63
|
this.camera = new PerspectiveCamera(this.fov, window.innerWidth / window.innerHeight, 0.1, 400);
|
73
64
|
this.camera.position.set(0, 1.4, -this.initialDistance);
|
74
65
|
this.rayCaster = new Raycaster();
|
@@ -272,38 +263,110 @@ ${before}
|
|
272
263
|
);
|
273
264
|
}
|
274
265
|
|
275
|
-
// src/tweakpane/
|
266
|
+
// src/tweakpane/blades/characterFolder.ts
|
276
267
|
var characterValues = {
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
clearcoatRoughness: 0
|
292
|
-
}
|
268
|
+
transmission: 0.01,
|
269
|
+
metalness: 0.8,
|
270
|
+
roughness: 0.05,
|
271
|
+
ior: 1,
|
272
|
+
thickness: 0.1,
|
273
|
+
specularColor: { r: 1, g: 1, b: 1 },
|
274
|
+
specularIntensity: 0.1,
|
275
|
+
emissive: { r: 1, g: 1, b: 1 },
|
276
|
+
emissiveIntensity: 0.1,
|
277
|
+
envMapIntensity: 0.8,
|
278
|
+
sheenColor: { r: 1, g: 1, b: 1 },
|
279
|
+
sheen: 0.5,
|
280
|
+
clearcoat: 0,
|
281
|
+
clearcoatRoughness: 0
|
293
282
|
};
|
294
283
|
var characterOptions = {
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
284
|
+
transmission: { min: 0.01, max: 3, step: 0.01 },
|
285
|
+
metalness: { min: 0, max: 1, step: 0.01 },
|
286
|
+
roughness: { min: 0, max: 1, step: 0.01 },
|
287
|
+
ior: { min: 1, max: 5, step: 0.01 },
|
288
|
+
thickness: { min: 0, max: 1, step: 0.01 },
|
289
|
+
specularIntensity: { min: 0, max: 1, step: 0.01 },
|
290
|
+
emissiveIntensity: { min: 0, max: 1, step: 0.01 },
|
291
|
+
envMapIntensity: { min: 0, max: 1, step: 0.01 },
|
292
|
+
sheen: { min: 0, max: 1, step: 0.01 },
|
293
|
+
clearcoat: { min: 0, max: 1, step: 0.01 },
|
294
|
+
clearcoatRoughness: { min: 0, max: 1, step: 0.01 }
|
295
|
+
};
|
296
|
+
var CharacterFolder = class {
|
297
|
+
constructor(parentFolder, expand = false) {
|
298
|
+
this.folder = parentFolder.addFolder({ title: "characterMaterial", expanded: expand });
|
299
|
+
this.folder.addBinding(characterValues, "transmission", characterOptions.transmission);
|
300
|
+
this.folder.addBinding(characterValues, "metalness", characterOptions.metalness);
|
301
|
+
this.folder.addBinding(characterValues, "roughness", characterOptions.roughness);
|
302
|
+
this.folder.addBinding(characterValues, "ior", characterOptions.ior);
|
303
|
+
this.folder.addBinding(characterValues, "thickness", characterOptions.thickness);
|
304
|
+
this.folder.addBinding(characterValues, "specularColor", {
|
305
|
+
color: { type: "float" }
|
306
|
+
});
|
307
|
+
this.folder.addBinding(
|
308
|
+
characterValues,
|
309
|
+
"specularIntensity",
|
310
|
+
characterOptions.specularIntensity
|
311
|
+
);
|
312
|
+
this.folder.addBinding(characterValues, "emissive", {
|
313
|
+
color: { type: "float" }
|
314
|
+
});
|
315
|
+
this.folder.addBinding(
|
316
|
+
characterValues,
|
317
|
+
"emissiveIntensity",
|
318
|
+
characterOptions.emissiveIntensity
|
319
|
+
);
|
320
|
+
this.folder.addBinding(characterValues, "envMapIntensity", characterOptions.envMapIntensity);
|
321
|
+
this.folder.addBinding(characterValues, "sheenColor", {
|
322
|
+
color: { type: "float" }
|
323
|
+
});
|
324
|
+
this.folder.addBinding(characterValues, "sheen", characterOptions.sheen);
|
325
|
+
this.folder.addBinding(characterValues, "clearcoat", characterOptions.clearcoat);
|
326
|
+
this.folder.addBinding(
|
327
|
+
characterValues,
|
328
|
+
"clearcoatRoughness",
|
329
|
+
characterOptions.clearcoatRoughness
|
330
|
+
);
|
331
|
+
}
|
332
|
+
setupChangeEvent() {
|
333
|
+
this.folder.on("change", (e) => {
|
334
|
+
const target = e.target.key;
|
335
|
+
if (!target)
|
336
|
+
return;
|
337
|
+
switch (target) {
|
338
|
+
case "specularColor": {
|
339
|
+
const value = e.value;
|
340
|
+
characterValues.specularColor = {
|
341
|
+
r: value.r,
|
342
|
+
g: value.g,
|
343
|
+
b: value.b
|
344
|
+
};
|
345
|
+
break;
|
346
|
+
}
|
347
|
+
case "emissive": {
|
348
|
+
const value = e.value;
|
349
|
+
characterValues.emissive = {
|
350
|
+
r: value.r,
|
351
|
+
g: value.g,
|
352
|
+
b: value.b
|
353
|
+
};
|
354
|
+
break;
|
355
|
+
}
|
356
|
+
case "sheenColor": {
|
357
|
+
const value = e.value;
|
358
|
+
characterValues.sheenColor = {
|
359
|
+
r: value.r,
|
360
|
+
g: value.g,
|
361
|
+
b: value.b
|
362
|
+
};
|
363
|
+
break;
|
364
|
+
}
|
365
|
+
default: {
|
366
|
+
break;
|
367
|
+
}
|
368
|
+
}
|
369
|
+
});
|
307
370
|
}
|
308
371
|
};
|
309
372
|
|
@@ -311,35 +374,35 @@ var characterOptions = {
|
|
311
374
|
var CharacterMaterial = class extends MeshPhysicalMaterial {
|
312
375
|
constructor() {
|
313
376
|
super();
|
314
|
-
|
315
|
-
|
377
|
+
this.uniforms = {};
|
378
|
+
this.colorsCube216 = [];
|
316
379
|
this.color = new Color(16777215);
|
317
|
-
this.transmission = characterValues.
|
318
|
-
this.metalness = characterValues.
|
319
|
-
this.roughness = characterValues.
|
320
|
-
this.ior = characterValues.
|
321
|
-
this.thickness = characterValues.
|
380
|
+
this.transmission = characterValues.transmission;
|
381
|
+
this.metalness = characterValues.metalness;
|
382
|
+
this.roughness = characterValues.roughness;
|
383
|
+
this.ior = characterValues.ior;
|
384
|
+
this.thickness = characterValues.thickness;
|
322
385
|
this.specularColor = new Color().setRGB(
|
323
|
-
characterValues.
|
324
|
-
characterValues.
|
325
|
-
characterValues.
|
386
|
+
characterValues.specularColor.r,
|
387
|
+
characterValues.specularColor.g,
|
388
|
+
characterValues.specularColor.b
|
326
389
|
);
|
327
|
-
this.specularIntensity = characterValues.
|
390
|
+
this.specularIntensity = characterValues.specularIntensity;
|
328
391
|
this.emissive = new Color().setRGB(
|
329
|
-
characterValues.
|
330
|
-
characterValues.
|
331
|
-
characterValues.
|
392
|
+
characterValues.emissive.r,
|
393
|
+
characterValues.emissive.g,
|
394
|
+
characterValues.emissive.b
|
332
395
|
);
|
333
|
-
this.emissiveIntensity = characterValues.
|
334
|
-
this.envMapIntensity = characterValues.
|
396
|
+
this.emissiveIntensity = characterValues.emissiveIntensity;
|
397
|
+
this.envMapIntensity = characterValues.envMapIntensity;
|
335
398
|
this.sheenColor = new Color().setRGB(
|
336
|
-
characterValues.
|
337
|
-
characterValues.
|
338
|
-
characterValues.
|
399
|
+
characterValues.sheenColor.r,
|
400
|
+
characterValues.sheenColor.g,
|
401
|
+
characterValues.sheenColor.b
|
339
402
|
);
|
340
|
-
this.sheen = characterValues.
|
341
|
-
this.clearcoat = characterValues.
|
342
|
-
this.clearcoatRoughness = characterValues.
|
403
|
+
this.sheen = characterValues.sheen;
|
404
|
+
this.clearcoat = characterValues.clearcoat;
|
405
|
+
this.clearcoatRoughness = characterValues.clearcoatRoughness;
|
343
406
|
this.onBeforeCompile = (shader) => {
|
344
407
|
this.uniforms = UniformsUtils.clone(shader.uniforms);
|
345
408
|
this.uniforms.nearClip = { value: 0.01 };
|
@@ -439,32 +502,32 @@ var CharacterMaterial = class extends MeshPhysicalMaterial {
|
|
439
502
|
}
|
440
503
|
}
|
441
504
|
update() {
|
442
|
-
this.transmission = characterValues.
|
443
|
-
this.metalness = characterValues.
|
444
|
-
this.roughness = characterValues.
|
445
|
-
this.ior = characterValues.
|
446
|
-
this.thickness = characterValues.
|
505
|
+
this.transmission = characterValues.transmission;
|
506
|
+
this.metalness = characterValues.metalness;
|
507
|
+
this.roughness = characterValues.roughness;
|
508
|
+
this.ior = characterValues.ior;
|
509
|
+
this.thickness = characterValues.thickness;
|
447
510
|
this.specularColor = new Color().setRGB(
|
448
|
-
characterValues.
|
449
|
-
characterValues.
|
450
|
-
characterValues.
|
511
|
+
characterValues.specularColor.r,
|
512
|
+
characterValues.specularColor.g,
|
513
|
+
characterValues.specularColor.b
|
451
514
|
);
|
452
|
-
this.specularIntensity = characterValues.
|
515
|
+
this.specularIntensity = characterValues.specularIntensity;
|
453
516
|
this.emissive = new Color().setRGB(
|
454
|
-
characterValues.
|
455
|
-
characterValues.
|
456
|
-
characterValues.
|
517
|
+
characterValues.emissive.r,
|
518
|
+
characterValues.emissive.g,
|
519
|
+
characterValues.emissive.b
|
457
520
|
);
|
458
|
-
this.emissiveIntensity = characterValues.
|
459
|
-
this.envMapIntensity = characterValues.
|
521
|
+
this.emissiveIntensity = characterValues.emissiveIntensity;
|
522
|
+
this.envMapIntensity = characterValues.envMapIntensity;
|
460
523
|
this.sheenColor = new Color().setRGB(
|
461
|
-
characterValues.
|
462
|
-
characterValues.
|
463
|
-
characterValues.
|
524
|
+
characterValues.sheenColor.r,
|
525
|
+
characterValues.sheenColor.g,
|
526
|
+
characterValues.sheenColor.b
|
464
527
|
);
|
465
|
-
this.sheen = characterValues.
|
466
|
-
this.clearcoat = characterValues.
|
467
|
-
this.clearcoatRoughness = characterValues.
|
528
|
+
this.sheen = characterValues.sheen;
|
529
|
+
this.clearcoat = characterValues.clearcoat;
|
530
|
+
this.clearcoatRoughness = characterValues.clearcoatRoughness;
|
468
531
|
}
|
469
532
|
};
|
470
533
|
|
@@ -485,7 +548,6 @@ import { GLTFLoader as ThreeGLTFLoader } from "three/examples/jsm/loaders/GLTFLo
|
|
485
548
|
var CachedGLTFLoader = class extends ThreeGLTFLoader {
|
486
549
|
constructor(manager) {
|
487
550
|
super(manager);
|
488
|
-
__publicField(this, "blobCache");
|
489
551
|
this.blobCache = /* @__PURE__ */ new Map();
|
490
552
|
}
|
491
553
|
setBlobUrl(originalUrl, blobUrl) {
|
@@ -506,8 +568,6 @@ var CachedGLTFLoader = class extends ThreeGLTFLoader {
|
|
506
568
|
};
|
507
569
|
var LRUCache = class {
|
508
570
|
constructor(maxSize = 100) {
|
509
|
-
__publicField(this, "maxSize");
|
510
|
-
__publicField(this, "cache");
|
511
571
|
this.maxSize = maxSize;
|
512
572
|
this.cache = /* @__PURE__ */ new Map();
|
513
573
|
}
|
@@ -527,12 +587,9 @@ var LRUCache = class {
|
|
527
587
|
this.cache.set(key, value);
|
528
588
|
}
|
529
589
|
};
|
530
|
-
var _ModelLoader = class {
|
590
|
+
var _ModelLoader = class _ModelLoader {
|
531
591
|
constructor(maxCacheSize = 100) {
|
532
|
-
|
533
|
-
__publicField(this, "gltfLoader");
|
534
|
-
__publicField(this, "modelCache");
|
535
|
-
__publicField(this, "ongoingLoads", /* @__PURE__ */ new Map());
|
592
|
+
this.ongoingLoads = /* @__PURE__ */ new Map();
|
536
593
|
this.loadingManager = new LoadingManager();
|
537
594
|
this.gltfLoader = new CachedGLTFLoader(this.loadingManager);
|
538
595
|
this.modelCache = new LRUCache(maxCacheSize);
|
@@ -594,8 +651,8 @@ var _ModelLoader = class {
|
|
594
651
|
}
|
595
652
|
}
|
596
653
|
};
|
654
|
+
_ModelLoader.instance = null;
|
597
655
|
var ModelLoader = _ModelLoader;
|
598
|
-
__publicField(ModelLoader, "instance", null);
|
599
656
|
var MODEL_LOADER = ModelLoader.getInstance();
|
600
657
|
var ModelLoader_default = MODEL_LOADER;
|
601
658
|
|
@@ -604,12 +661,12 @@ var CharacterModel = class {
|
|
604
661
|
constructor(characterDescription) {
|
605
662
|
this.characterDescription = characterDescription;
|
606
663
|
/* TODO: pick between below eager instantiation or ModelLoader.getInstance() lazy one */
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
664
|
+
this.modelLoader = ModelLoader_default;
|
665
|
+
this.mesh = null;
|
666
|
+
this.material = new CharacterMaterial();
|
667
|
+
this.animations = {};
|
668
|
+
this.animationMixer = null;
|
669
|
+
this.currentAnimation = 0 /* idle */;
|
613
670
|
}
|
614
671
|
async init() {
|
615
672
|
await this.loadMainMesh();
|
@@ -632,10 +689,11 @@ var CharacterModel = class {
|
|
632
689
|
this.applyMaterialToAllSkinnedMeshes(this.material);
|
633
690
|
}
|
634
691
|
updateAnimation(targetAnimation, deltaTime) {
|
692
|
+
var _a;
|
635
693
|
if (this.currentAnimation !== targetAnimation) {
|
636
694
|
this.transitionToAnimation(targetAnimation);
|
637
695
|
}
|
638
|
-
this.animationMixer
|
696
|
+
(_a = this.animationMixer) == null ? void 0 : _a.update(deltaTime);
|
639
697
|
}
|
640
698
|
hideMaterialByMeshName(meshName) {
|
641
699
|
if (!this.mesh)
|
@@ -735,7 +793,7 @@ import {
|
|
735
793
|
} from "three";
|
736
794
|
|
737
795
|
// src/character/CanvasText.ts
|
738
|
-
import
|
796
|
+
import { Texture, LinearFilter, RGBAFormat, MeshBasicMaterial } from "three";
|
739
797
|
function getTextAlignOffset(textAlign, width) {
|
740
798
|
switch (textAlign) {
|
741
799
|
case "center":
|
@@ -836,10 +894,10 @@ function CanvasText(message, options) {
|
|
836
894
|
}
|
837
895
|
function THREECanvasTextTexture(text, options) {
|
838
896
|
const canvas = CanvasText(text, options);
|
839
|
-
const texture = new
|
840
|
-
texture.minFilter =
|
841
|
-
texture.magFilter =
|
842
|
-
texture.format =
|
897
|
+
const texture = new Texture(canvas);
|
898
|
+
texture.minFilter = LinearFilter;
|
899
|
+
texture.magFilter = LinearFilter;
|
900
|
+
texture.format = RGBAFormat;
|
843
901
|
texture.needsUpdate = true;
|
844
902
|
return { texture, width: canvas.width, height: canvas.height };
|
845
903
|
}
|
@@ -856,14 +914,11 @@ var defaultLabelHeight = 0.125;
|
|
856
914
|
var defaultLabelCastShadows = true;
|
857
915
|
var CharacterTooltip = class {
|
858
916
|
constructor(parentModel) {
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
__publicField(this, "fadingSpeed", 0.02);
|
865
|
-
__publicField(this, "secondsToFadeOut", 15);
|
866
|
-
__publicField(this, "props", {
|
917
|
+
this.visibleOpacity = 0.85;
|
918
|
+
this.targetOpacity = 0;
|
919
|
+
this.fadingSpeed = 0.02;
|
920
|
+
this.secondsToFadeOut = 15;
|
921
|
+
this.props = {
|
867
922
|
content: "",
|
868
923
|
alignment: defaultLabelAlignment,
|
869
924
|
width: defaultLabelWidth,
|
@@ -873,7 +928,7 @@ var CharacterTooltip = class {
|
|
873
928
|
color: defaultLabelColor,
|
874
929
|
fontColor: defaultFontColor,
|
875
930
|
castShadows: defaultLabelCastShadows
|
876
|
-
}
|
931
|
+
};
|
877
932
|
this.setText = this.setText.bind(this);
|
878
933
|
this.material = new MeshBasicMaterial2({
|
879
934
|
map: null,
|
@@ -965,7 +1020,7 @@ var CharacterTooltip = class {
|
|
965
1020
|
};
|
966
1021
|
|
967
1022
|
// src/character/LocalController.ts
|
968
|
-
import {
|
1023
|
+
import { Line3, Matrix4, Quaternion, Raycaster as Raycaster2, Vector3 as Vector33 } from "three";
|
969
1024
|
var LocalController = class {
|
970
1025
|
constructor(model, id, collisionsManager, keyInputManager, cameraManager, timeManager) {
|
971
1026
|
this.model = model;
|
@@ -974,45 +1029,35 @@ var LocalController = class {
|
|
974
1029
|
this.keyInputManager = keyInputManager;
|
975
1030
|
this.cameraManager = cameraManager;
|
976
1031
|
this.timeManager = timeManager;
|
977
|
-
|
978
|
-
|
1032
|
+
this.collisionDetectionSteps = 15;
|
1033
|
+
this.capsuleInfo = {
|
979
1034
|
radius: 0.4,
|
980
1035
|
segment: new Line3(new Vector33(), new Vector33(0, 1.05, 0))
|
981
|
-
}
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
__publicField(this, "left");
|
1007
|
-
__publicField(this, "right");
|
1008
|
-
__publicField(this, "run");
|
1009
|
-
__publicField(this, "jump");
|
1010
|
-
__publicField(this, "anyDirection");
|
1011
|
-
__publicField(this, "conflictingDirections");
|
1012
|
-
__publicField(this, "thirdPersonCamera", null);
|
1013
|
-
__publicField(this, "speed", 0);
|
1014
|
-
__publicField(this, "targetSpeed", 0);
|
1015
|
-
__publicField(this, "networkState");
|
1036
|
+
};
|
1037
|
+
this.maxWalkSpeed = 6;
|
1038
|
+
this.maxRunSpeed = 8.5;
|
1039
|
+
this.gravity = -42;
|
1040
|
+
this.jumpForce = 16;
|
1041
|
+
this.coyoteTimeThreshold = 70;
|
1042
|
+
this.coyoteTime = false;
|
1043
|
+
this.canJump = true;
|
1044
|
+
this.characterOnGround = false;
|
1045
|
+
this.characterWasOnGround = false;
|
1046
|
+
this.characterAirborneSince = 0;
|
1047
|
+
this.currentHeight = 0;
|
1048
|
+
this.characterVelocity = new Vector33();
|
1049
|
+
this.vectorUp = new Vector33(0, 1, 0);
|
1050
|
+
this.vectorDown = new Vector33(0, -1, 0);
|
1051
|
+
this.rotationOffset = 0;
|
1052
|
+
this.azimuthalAngle = 0;
|
1053
|
+
this.tempMatrix = new Matrix4();
|
1054
|
+
this.tempSegment = new Line3();
|
1055
|
+
this.tempVector = new Vector33();
|
1056
|
+
this.tempVector2 = new Vector33();
|
1057
|
+
this.rayCaster = new Raycaster2();
|
1058
|
+
this.thirdPersonCamera = null;
|
1059
|
+
this.speed = 0;
|
1060
|
+
this.targetSpeed = 0;
|
1016
1061
|
this.networkState = {
|
1017
1062
|
id: this.id,
|
1018
1063
|
position: { x: 0, y: 0, z: 0 },
|
@@ -1021,7 +1066,8 @@ var LocalController = class {
|
|
1021
1066
|
};
|
1022
1067
|
}
|
1023
1068
|
update() {
|
1024
|
-
|
1069
|
+
var _a, _b;
|
1070
|
+
if (!((_a = this.model) == null ? void 0 : _a.mesh) || !((_b = this.model) == null ? void 0 : _b.animationMixer))
|
1025
1071
|
return;
|
1026
1072
|
if (!this.thirdPersonCamera)
|
1027
1073
|
this.thirdPersonCamera = this.cameraManager.camera;
|
@@ -1089,7 +1135,8 @@ var LocalController = class {
|
|
1089
1135
|
}
|
1090
1136
|
}
|
1091
1137
|
updateAzimuthalAngle() {
|
1092
|
-
|
1138
|
+
var _a;
|
1139
|
+
if (!this.thirdPersonCamera || !((_a = this.model) == null ? void 0 : _a.mesh))
|
1093
1140
|
return;
|
1094
1141
|
const camToModelDistance = this.thirdPersonCamera.position.distanceTo(this.model.mesh.position);
|
1095
1142
|
const isCameraFirstPerson = camToModelDistance < 2;
|
@@ -1104,12 +1151,14 @@ var LocalController = class {
|
|
1104
1151
|
}
|
1105
1152
|
}
|
1106
1153
|
computeAngularDifference(rotationQuaternion) {
|
1107
|
-
|
1154
|
+
var _a;
|
1155
|
+
if (!((_a = this.model) == null ? void 0 : _a.mesh))
|
1108
1156
|
return 0;
|
1109
1157
|
return 2 * Math.acos(Math.abs(this.model.mesh.quaternion.dot(rotationQuaternion)));
|
1110
1158
|
}
|
1111
1159
|
updateRotation() {
|
1112
|
-
|
1160
|
+
var _a;
|
1161
|
+
if (!this.thirdPersonCamera || !((_a = this.model) == null ? void 0 : _a.mesh))
|
1113
1162
|
return;
|
1114
1163
|
this.updateRotationOffset();
|
1115
1164
|
this.updateAzimuthalAngle();
|
@@ -1122,12 +1171,14 @@ var LocalController = class {
|
|
1122
1171
|
this.model.mesh.quaternion.rotateTowards(rotationQuaternion, frameRotation);
|
1123
1172
|
}
|
1124
1173
|
addScaledVectorToCharacter(deltaTime) {
|
1125
|
-
|
1174
|
+
var _a;
|
1175
|
+
if (!((_a = this.model) == null ? void 0 : _a.mesh))
|
1126
1176
|
return;
|
1127
1177
|
this.model.mesh.position.addScaledVector(this.tempVector, this.speed * deltaTime);
|
1128
1178
|
}
|
1129
1179
|
updatePosition(deltaTime, _iter) {
|
1130
|
-
|
1180
|
+
var _a;
|
1181
|
+
if (!((_a = this.model) == null ? void 0 : _a.mesh))
|
1131
1182
|
return;
|
1132
1183
|
if (this.characterOnGround) {
|
1133
1184
|
if (!this.jump)
|
@@ -1169,15 +1220,10 @@ var LocalController = class {
|
|
1169
1220
|
this.addScaledVectorToCharacter(deltaTime);
|
1170
1221
|
}
|
1171
1222
|
this.model.mesh.updateMatrixWorld();
|
1172
|
-
this.tempBox.makeEmpty();
|
1173
1223
|
this.tempSegment.copy(this.capsuleInfo.segment);
|
1174
1224
|
this.tempSegment.start.applyMatrix4(this.model.mesh.matrixWorld).applyMatrix4(this.tempMatrix);
|
1175
1225
|
this.tempSegment.end.applyMatrix4(this.model.mesh.matrixWorld).applyMatrix4(this.tempMatrix);
|
1176
|
-
this.
|
1177
|
-
this.tempBox.expandByPoint(this.tempSegment.end);
|
1178
|
-
this.tempBox.min.subScalar(this.capsuleInfo.radius);
|
1179
|
-
this.tempBox.max.addScalar(this.capsuleInfo.radius);
|
1180
|
-
this.collisionsManager.applyColliders(this.tempSegment, this.capsuleInfo.radius, this.tempBox);
|
1226
|
+
this.collisionsManager.applyColliders(this.tempSegment, this.capsuleInfo.radius);
|
1181
1227
|
const newPosition = this.tempVector;
|
1182
1228
|
newPosition.copy(this.tempSegment.start);
|
1183
1229
|
const deltaVector = this.tempVector2;
|
@@ -1199,7 +1245,8 @@ var LocalController = class {
|
|
1199
1245
|
}
|
1200
1246
|
}
|
1201
1247
|
updateNetworkState() {
|
1202
|
-
|
1248
|
+
var _a;
|
1249
|
+
if (!((_a = this.model) == null ? void 0 : _a.mesh)) {
|
1203
1250
|
this.networkState = {
|
1204
1251
|
id: this.id,
|
1205
1252
|
position: new Vector33(),
|
@@ -1222,7 +1269,8 @@ var LocalController = class {
|
|
1222
1269
|
}
|
1223
1270
|
}
|
1224
1271
|
resetPosition() {
|
1225
|
-
|
1272
|
+
var _a;
|
1273
|
+
if (!((_a = this.model) == null ? void 0 : _a.mesh))
|
1226
1274
|
return;
|
1227
1275
|
this.characterVelocity.y = 0;
|
1228
1276
|
this.model.mesh.position.y = 3;
|
@@ -1241,12 +1289,12 @@ var Character = class {
|
|
1241
1289
|
this.keyInputManager = keyInputManager;
|
1242
1290
|
this.cameraManager = cameraManager;
|
1243
1291
|
this.timeManager = timeManager;
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1249
|
-
|
1292
|
+
this.controller = null;
|
1293
|
+
this.name = null;
|
1294
|
+
this.model = null;
|
1295
|
+
this.color = new Color3();
|
1296
|
+
this.position = new Vector34();
|
1297
|
+
this.tooltip = null;
|
1250
1298
|
this.load();
|
1251
1299
|
}
|
1252
1300
|
async load() {
|
@@ -1297,12 +1345,11 @@ var RemoteController = class {
|
|
1297
1345
|
constructor(character, id) {
|
1298
1346
|
this.character = character;
|
1299
1347
|
this.id = id;
|
1300
|
-
|
1301
|
-
|
1302
|
-
|
1303
|
-
|
1304
|
-
|
1305
|
-
__publicField(this, "networkState");
|
1348
|
+
this.modelLoader = ModelLoader_default;
|
1349
|
+
this.characterModel = null;
|
1350
|
+
this.animationMixer = new AnimationMixer2(new Object3D4());
|
1351
|
+
this.animations = /* @__PURE__ */ new Map();
|
1352
|
+
this.currentAnimation = 0 /* idle */;
|
1306
1353
|
this.characterModel = this.character.model.mesh;
|
1307
1354
|
this.characterModel.updateMatrixWorld();
|
1308
1355
|
this.animationMixer = new AnimationMixer2(this.characterModel);
|
@@ -1386,15 +1433,14 @@ var CharacterManager = class {
|
|
1386
1433
|
character was standing on a model and the page is reloaded the character falls into the model before it loads and
|
1387
1434
|
can be trapped).
|
1388
1435
|
*/
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
|
1394
|
-
|
1395
|
-
|
1396
|
-
|
1397
|
-
__publicField(this, "group");
|
1436
|
+
this.updateLocationHash = false;
|
1437
|
+
this.loadingCharacters = /* @__PURE__ */ new Map();
|
1438
|
+
this.remoteCharacters = /* @__PURE__ */ new Map();
|
1439
|
+
this.remoteCharacterControllers = /* @__PURE__ */ new Map();
|
1440
|
+
this.characterDescription = null;
|
1441
|
+
this.character = null;
|
1442
|
+
this.cameraOffsetTarget = 0;
|
1443
|
+
this.cameraOffset = 0;
|
1398
1444
|
this.group = new Group();
|
1399
1445
|
}
|
1400
1446
|
/* TODO:
|
@@ -1411,6 +1457,7 @@ var CharacterManager = class {
|
|
1411
1457
|
id,
|
1412
1458
|
isLocal,
|
1413
1459
|
() => {
|
1460
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
1414
1461
|
if (window.location.hash && window.location.hash.length > 1) {
|
1415
1462
|
decodeCharacterAndCamera(
|
1416
1463
|
window.location.hash.substring(1),
|
@@ -1434,14 +1481,14 @@ var CharacterManager = class {
|
|
1434
1481
|
}
|
1435
1482
|
character.model.hideMaterialByMeshName("SK_Mannequin_2");
|
1436
1483
|
if (!isLocal) {
|
1437
|
-
character.model
|
1438
|
-
character.model
|
1484
|
+
(_b = (_a = character.model) == null ? void 0 : _a.mesh) == null ? void 0 : _b.position.set(spawnPosition.x, spawnPosition.y, spawnPosition.z);
|
1485
|
+
(_d = (_c = character.model) == null ? void 0 : _c.mesh) == null ? void 0 : _d.updateMatrixWorld();
|
1439
1486
|
character.position.set(spawnPosition.x, spawnPosition.y, spawnPosition.z);
|
1440
1487
|
}
|
1441
1488
|
this.group.add(character.model.mesh);
|
1442
1489
|
if (isLocal) {
|
1443
1490
|
this.character = character;
|
1444
|
-
this.character.tooltip
|
1491
|
+
(_e = this.character.tooltip) == null ? void 0 : _e.setText(`${id}`);
|
1445
1492
|
} else {
|
1446
1493
|
this.remoteCharacters.set(id, character);
|
1447
1494
|
const remoteController = new RemoteController(character, id);
|
@@ -1461,13 +1508,13 @@ var CharacterManager = class {
|
|
1461
1508
|
4 /* air */,
|
1462
1509
|
characterDescription.airAnimationFileUrl
|
1463
1510
|
);
|
1464
|
-
remoteController.characterModel
|
1511
|
+
(_f = remoteController.characterModel) == null ? void 0 : _f.position.set(
|
1465
1512
|
spawnPosition.x,
|
1466
1513
|
spawnPosition.y,
|
1467
1514
|
spawnPosition.z
|
1468
1515
|
);
|
1469
1516
|
this.remoteCharacterControllers.set(id, remoteController);
|
1470
|
-
character.tooltip
|
1517
|
+
(_g = character.tooltip) == null ? void 0 : _g.setText(`${id}`);
|
1471
1518
|
}
|
1472
1519
|
resolve(character);
|
1473
1520
|
},
|
@@ -1505,9 +1552,10 @@ var CharacterManager = class {
|
|
1505
1552
|
this.loadingCharacters.clear();
|
1506
1553
|
}
|
1507
1554
|
update() {
|
1555
|
+
var _a;
|
1508
1556
|
if (this.character) {
|
1509
1557
|
this.character.update(this.timeManager.time);
|
1510
|
-
if (this.character.model
|
1558
|
+
if ((_a = this.character.model) == null ? void 0 : _a.mesh) {
|
1511
1559
|
this.cameraOffsetTarget = this.cameraManager.targetDistance <= 0.4 ? 0.6 : 0;
|
1512
1560
|
this.cameraOffset += ease(this.cameraOffsetTarget, this.cameraOffset, 0.1);
|
1513
1561
|
const targetOffset = new Vector36(0, 1.3, this.cameraOffset);
|
@@ -1557,7 +1605,7 @@ var CharacterManager = class {
|
|
1557
1605
|
// src/input/KeyInputManager.ts
|
1558
1606
|
var KeyInputManager = class {
|
1559
1607
|
constructor() {
|
1560
|
-
|
1608
|
+
this.keys = /* @__PURE__ */ new Map();
|
1561
1609
|
document.addEventListener("keydown", this.onKeyDown.bind(this));
|
1562
1610
|
document.addEventListener("keyup", this.onKeyUp.bind(this));
|
1563
1611
|
window.addEventListener("blur", this.handleUnfocus.bind(this));
|
@@ -1625,12 +1673,7 @@ var MMLCompositionScene = class {
|
|
1625
1673
|
this.audioListener = audioListener;
|
1626
1674
|
this.collisionsManager = collisionsManager;
|
1627
1675
|
this.getUserPositionAndRotation = getUserPositionAndRotation;
|
1628
|
-
|
1629
|
-
__publicField(this, "debug", false);
|
1630
|
-
__publicField(this, "mmlScene");
|
1631
|
-
__publicField(this, "promptManager");
|
1632
|
-
__publicField(this, "interactionListener");
|
1633
|
-
__publicField(this, "clickTrigger");
|
1676
|
+
this.debug = false;
|
1634
1677
|
this.group = new Group2();
|
1635
1678
|
this.promptManager = PromptManager.init(document.body);
|
1636
1679
|
const { interactionListener } = InteractionManager.init(document.body, this.camera, this.scene);
|
@@ -1679,22 +1722,23 @@ var MMLCompositionScene = class {
|
|
1679
1722
|
};
|
1680
1723
|
|
1681
1724
|
// src/rendering/composer.ts
|
1725
|
+
import { N8AOPostPass } from "n8ao";
|
1682
1726
|
import {
|
1683
1727
|
EffectComposer as EffectComposer2,
|
1684
1728
|
RenderPass,
|
1685
1729
|
EffectPass as EffectPass2,
|
1686
1730
|
FXAAEffect,
|
1687
1731
|
ShaderPass,
|
1688
|
-
BloomEffect
|
1732
|
+
BloomEffect,
|
1689
1733
|
SSAOEffect as SSAOEffect2,
|
1690
|
-
BlendFunction as
|
1734
|
+
BlendFunction as BlendFunction2,
|
1691
1735
|
TextureEffect,
|
1692
|
-
ToneMappingEffect
|
1736
|
+
ToneMappingEffect,
|
1693
1737
|
SMAAEffect,
|
1694
1738
|
SMAAPreset,
|
1695
1739
|
EdgeDetectionMode,
|
1696
1740
|
PredicationMode,
|
1697
|
-
NormalPass
|
1741
|
+
NormalPass as NormalPass2
|
1698
1742
|
} from "postprocessing";
|
1699
1743
|
import {
|
1700
1744
|
AmbientLight,
|
@@ -1705,21 +1749,21 @@ import {
|
|
1705
1749
|
LoadingManager as LoadingManager2,
|
1706
1750
|
PMREMGenerator,
|
1707
1751
|
Vector2 as Vector22,
|
1708
|
-
WebGLRenderer as
|
1752
|
+
WebGLRenderer as WebGLRenderer2
|
1709
1753
|
} from "three";
|
1710
1754
|
import { RGBELoader } from "three/examples/jsm/loaders/RGBELoader.js";
|
1711
1755
|
|
1712
1756
|
// src/sun/Sun.ts
|
1713
1757
|
import { CameraHelper, Color as Color4, DirectionalLight, Group as Group3, OrthographicCamera, Vector3 as Vector37 } from "three";
|
1714
1758
|
|
1715
|
-
// src/tweakpane/
|
1759
|
+
// src/tweakpane/blades/environmentFolder.ts
|
1716
1760
|
var sunValues = {
|
1717
1761
|
sunPosition: {
|
1718
1762
|
sunAzimuthalAngle: 39,
|
1719
1763
|
sunPolarAngle: 50
|
1720
1764
|
},
|
1721
1765
|
sunIntensity: 0.5,
|
1722
|
-
sunColor: { r: 1, g:
|
1766
|
+
sunColor: { r: 1, g: 0.74, b: 0.5 }
|
1723
1767
|
};
|
1724
1768
|
var sunOptions = {
|
1725
1769
|
sunPosition: {
|
@@ -1728,23 +1772,159 @@ var sunOptions = {
|
|
1728
1772
|
},
|
1729
1773
|
sunIntensity: { min: 0, max: 1, step: 0.05 }
|
1730
1774
|
};
|
1775
|
+
var envValues = {
|
1776
|
+
ambientLight: {
|
1777
|
+
ambientLightIntensity: 0,
|
1778
|
+
ambientLightColor: { r: 1, g: 1, b: 1 }
|
1779
|
+
},
|
1780
|
+
fog: {
|
1781
|
+
fogNear: 30,
|
1782
|
+
fogFar: 210,
|
1783
|
+
fogColor: { r: 0.42, g: 0.48, b: 0.59 }
|
1784
|
+
}
|
1785
|
+
};
|
1786
|
+
var envOptions = {
|
1787
|
+
ambientLight: {
|
1788
|
+
ambientLightIntensity: { min: 0, max: 1, step: 0.01 }
|
1789
|
+
},
|
1790
|
+
fog: {
|
1791
|
+
fogNear: { min: 0, max: 80, step: 1 },
|
1792
|
+
fogFar: { min: 81, max: 300, step: 1 }
|
1793
|
+
}
|
1794
|
+
};
|
1795
|
+
var EnvironmentFolder = class {
|
1796
|
+
constructor(parentFolder, expand = false) {
|
1797
|
+
this.folder = parentFolder.addFolder({ title: "environment", expanded: expand });
|
1798
|
+
this.sun = this.folder.addFolder({ title: "sun", expanded: true });
|
1799
|
+
this.ambient = this.folder.addFolder({ title: "ambient", expanded: true });
|
1800
|
+
this.sun.addBinding(
|
1801
|
+
sunValues.sunPosition,
|
1802
|
+
"sunAzimuthalAngle",
|
1803
|
+
sunOptions.sunPosition.sunAzimuthalAngle
|
1804
|
+
);
|
1805
|
+
this.sun.addBinding(
|
1806
|
+
sunValues.sunPosition,
|
1807
|
+
"sunPolarAngle",
|
1808
|
+
sunOptions.sunPosition.sunPolarAngle
|
1809
|
+
);
|
1810
|
+
this.sun.addBinding(sunValues, "sunIntensity", sunOptions.sunIntensity);
|
1811
|
+
this.sun.addBinding(sunValues, "sunColor", {
|
1812
|
+
color: { type: "float" }
|
1813
|
+
});
|
1814
|
+
this.sunButton = this.sun.addButton({ title: "Set HDRI" });
|
1815
|
+
this.ambient.addBinding(
|
1816
|
+
envValues.ambientLight,
|
1817
|
+
"ambientLightIntensity",
|
1818
|
+
envOptions.ambientLight.ambientLightIntensity
|
1819
|
+
);
|
1820
|
+
this.ambient.addBinding(envValues.ambientLight, "ambientLightColor", {
|
1821
|
+
color: { type: "float" }
|
1822
|
+
});
|
1823
|
+
this.ambient.addBinding(envValues.fog, "fogNear", envOptions.fog.fogNear);
|
1824
|
+
this.ambient.addBinding(envValues.fog, "fogFar", envOptions.fog.fogFar);
|
1825
|
+
this.ambient.addBinding(envValues.fog, "fogColor", {
|
1826
|
+
color: { type: "float" }
|
1827
|
+
});
|
1828
|
+
}
|
1829
|
+
setupChangeEvent(setHDR, setAmbientLight, setFog, sun) {
|
1830
|
+
this.sun.on("change", (e) => {
|
1831
|
+
const target = e.target.key;
|
1832
|
+
if (!target)
|
1833
|
+
return;
|
1834
|
+
switch (target) {
|
1835
|
+
case "sunAzimuthalAngle": {
|
1836
|
+
const value = e.value;
|
1837
|
+
sun == null ? void 0 : sun.setAzimuthalAngle(value * (Math.PI / 180));
|
1838
|
+
break;
|
1839
|
+
}
|
1840
|
+
case "sunPolarAngle": {
|
1841
|
+
const value = e.value;
|
1842
|
+
sun == null ? void 0 : sun.setPolarAngle(value * (Math.PI / 180));
|
1843
|
+
break;
|
1844
|
+
}
|
1845
|
+
case "sunIntensity": {
|
1846
|
+
const value = e.value;
|
1847
|
+
sun == null ? void 0 : sun.setIntensity(value);
|
1848
|
+
break;
|
1849
|
+
}
|
1850
|
+
case "sunColor": {
|
1851
|
+
const value = e.value;
|
1852
|
+
sunValues.sunColor = {
|
1853
|
+
r: value.r,
|
1854
|
+
g: value.g,
|
1855
|
+
b: value.b
|
1856
|
+
};
|
1857
|
+
sun == null ? void 0 : sun.setColor();
|
1858
|
+
break;
|
1859
|
+
}
|
1860
|
+
default:
|
1861
|
+
break;
|
1862
|
+
}
|
1863
|
+
});
|
1864
|
+
this.sunButton.on("click", () => {
|
1865
|
+
setHDR();
|
1866
|
+
});
|
1867
|
+
this.ambient.on("change", (e) => {
|
1868
|
+
const target = e.target.key;
|
1869
|
+
if (!target)
|
1870
|
+
return;
|
1871
|
+
switch (target) {
|
1872
|
+
case "ambientLightIntensity": {
|
1873
|
+
envValues.ambientLight.ambientLightIntensity = e.value;
|
1874
|
+
setAmbientLight();
|
1875
|
+
break;
|
1876
|
+
}
|
1877
|
+
case "ambientLightColor": {
|
1878
|
+
const value = e.value;
|
1879
|
+
envValues.ambientLight.ambientLightColor = {
|
1880
|
+
r: value.r,
|
1881
|
+
g: value.g,
|
1882
|
+
b: value.b
|
1883
|
+
};
|
1884
|
+
setAmbientLight();
|
1885
|
+
break;
|
1886
|
+
}
|
1887
|
+
case "fogNear": {
|
1888
|
+
envValues.fog.fogNear = e.value;
|
1889
|
+
setFog();
|
1890
|
+
break;
|
1891
|
+
}
|
1892
|
+
case "fogFar": {
|
1893
|
+
envValues.fog.fogFar = e.value;
|
1894
|
+
setFog();
|
1895
|
+
break;
|
1896
|
+
}
|
1897
|
+
case "fogColor": {
|
1898
|
+
const value = e.value;
|
1899
|
+
envValues.fog.fogColor = {
|
1900
|
+
r: value.r,
|
1901
|
+
g: value.g,
|
1902
|
+
b: value.b
|
1903
|
+
};
|
1904
|
+
setFog();
|
1905
|
+
break;
|
1906
|
+
}
|
1907
|
+
default:
|
1908
|
+
break;
|
1909
|
+
}
|
1910
|
+
});
|
1911
|
+
}
|
1912
|
+
};
|
1731
1913
|
|
1732
1914
|
// src/sun/Sun.ts
|
1733
1915
|
var Sun = class extends Group3 {
|
1734
1916
|
constructor() {
|
1735
1917
|
super();
|
1736
|
-
|
1737
|
-
|
1918
|
+
this.debug = false;
|
1919
|
+
this.sunOffset = new Vector37(
|
1738
1920
|
39 * (Math.PI / 180),
|
1739
1921
|
50 * (Math.PI / 180),
|
1740
1922
|
100
|
1741
|
-
)
|
1742
|
-
|
1743
|
-
|
1744
|
-
|
1745
|
-
|
1746
|
-
__publicField(this, "directionalLight");
|
1747
|
-
__publicField(this, "target", null);
|
1923
|
+
);
|
1924
|
+
this.shadowResolution = 8192;
|
1925
|
+
this.shadowCamFrustum = 50;
|
1926
|
+
this.camHelper = null;
|
1927
|
+
this.target = null;
|
1748
1928
|
this.shadowCamera = new OrthographicCamera(
|
1749
1929
|
-this.shadowCamFrustum,
|
1750
1930
|
this.shadowCamFrustum,
|
@@ -1762,6 +1942,7 @@ var Sun = class extends Group3 {
|
|
1762
1942
|
this.directionalLight.shadow.camera = this.shadowCamera;
|
1763
1943
|
this.directionalLight.shadow.mapSize.set(this.shadowResolution, this.shadowResolution);
|
1764
1944
|
this.directionalLight.castShadow = true;
|
1945
|
+
this.setColor();
|
1765
1946
|
this.updateCharacterPosition(new Vector37(0, 0, 0));
|
1766
1947
|
this.add(this.directionalLight);
|
1767
1948
|
if (this.debug === true && this.camHelper instanceof CameraHelper) {
|
@@ -1812,80 +1993,13 @@ var Sun = class extends Group3 {
|
|
1812
1993
|
}
|
1813
1994
|
};
|
1814
1995
|
|
1815
|
-
// src/tweakpane/
|
1816
|
-
|
1817
|
-
|
1818
|
-
|
1819
|
-
|
1820
|
-
toneMapping: 5,
|
1821
|
-
exposure: 1,
|
1822
|
-
bgIntensity: 0.5,
|
1823
|
-
bgBlurriness: 0
|
1824
|
-
},
|
1825
|
-
ssao: {
|
1826
|
-
blendFunction: BlendFunction.MULTIPLY,
|
1827
|
-
distanceScaling: true,
|
1828
|
-
depthAwareUpsampling: true,
|
1829
|
-
samples: 17,
|
1830
|
-
rings: 7,
|
1831
|
-
luminanceInfluence: 0.7,
|
1832
|
-
radius: 0.03,
|
1833
|
-
intensity: 2.5,
|
1834
|
-
bias: 0.05,
|
1835
|
-
fade: 0.03,
|
1836
|
-
resolutionScale: 0.75,
|
1837
|
-
color: { r: 0, g: 0, b: 0 },
|
1838
|
-
worldDistanceThreshold: 30,
|
1839
|
-
worldDistanceFalloff: 7,
|
1840
|
-
worldProximityThreshold: 0.5,
|
1841
|
-
worldProximityFalloff: 0.3
|
1842
|
-
},
|
1843
|
-
toneMapping: {
|
1844
|
-
mode: 2,
|
1845
|
-
resolution: 512,
|
1846
|
-
whitePoint: 32,
|
1847
|
-
middleGrey: 21,
|
1848
|
-
minLuminance: 0.01,
|
1849
|
-
averageLuminance: 0.01,
|
1850
|
-
adaptationRate: 2
|
1851
|
-
},
|
1852
|
-
brightness: -0.03,
|
1853
|
-
contrast: 1.21,
|
1854
|
-
saturation: 0.91,
|
1855
|
-
grain: 0.061,
|
1856
|
-
bloom: 0.25
|
1996
|
+
// src/tweakpane/blades/bcsFolder.ts
|
1997
|
+
var bcsValues = {
|
1998
|
+
brightness: 0,
|
1999
|
+
contrast: 1.25,
|
2000
|
+
saturation: 1
|
1857
2001
|
};
|
1858
|
-
var
|
1859
|
-
renderer: {
|
1860
|
-
shadowMap: { min: 0, max: 2, step: 1 },
|
1861
|
-
toneMapping: { min: 0, max: 5, step: 1 },
|
1862
|
-
exposure: { min: 0, max: 3, step: 0.01 },
|
1863
|
-
bgIntensity: { min: 0, max: 1.3, step: 0.01 },
|
1864
|
-
bgBlurriness: { min: 0, max: 0.1, step: 1e-3 }
|
1865
|
-
},
|
1866
|
-
ssao: {
|
1867
|
-
samples: { min: 1, max: 50, step: 1 },
|
1868
|
-
rings: { min: 1, max: 50, step: 1 },
|
1869
|
-
luminanceInfluence: { min: 0, max: 1, step: 0.01 },
|
1870
|
-
radius: { min: 0, max: 0.1, step: 1e-3 },
|
1871
|
-
intensity: { min: 0, max: 5, step: 0.1 },
|
1872
|
-
bias: { min: 0, max: 0.1, step: 1e-3 },
|
1873
|
-
fade: { min: 0, max: 0.1, step: 1e-3 },
|
1874
|
-
resolutionScale: { min: 0.25, max: 2, step: 0.25 },
|
1875
|
-
worldDistanceThreshold: { min: 0, max: 200, step: 1 },
|
1876
|
-
worldDistanceFalloff: { min: 0, max: 200, step: 1 },
|
1877
|
-
worldProximityThreshold: { min: 0, max: 2, step: 0.01 },
|
1878
|
-
worldProximityFalloff: { min: 0, max: 2, step: 0.01 }
|
1879
|
-
},
|
1880
|
-
toneMapping: {
|
1881
|
-
mode: { min: 0, max: 4, step: 1 },
|
1882
|
-
resolution: { min: 64, max: 512, step: 64 },
|
1883
|
-
whitePoint: { min: 0, max: 32, step: 0.01 },
|
1884
|
-
middleGrey: { min: 0, max: 32, step: 0.01 },
|
1885
|
-
minLuminance: { min: 0, max: 32, step: 1e-3 },
|
1886
|
-
averageLuminance: { min: 1e-3, max: 0.2, step: 1e-3 },
|
1887
|
-
adaptationRate: { min: 0.1, max: 2, step: 0.1 }
|
1888
|
-
},
|
2002
|
+
var bcsOptions = {
|
1889
2003
|
brightness: {
|
1890
2004
|
amount: { min: -1, max: 1, step: 0.01 }
|
1891
2005
|
},
|
@@ -1894,7 +2008,44 @@ var composerOptions = {
|
|
1894
2008
|
},
|
1895
2009
|
saturation: {
|
1896
2010
|
amount: { min: 0, max: 2, step: 0.01 }
|
1897
|
-
}
|
2011
|
+
}
|
2012
|
+
};
|
2013
|
+
var BrightnessContrastSaturationFolder = class {
|
2014
|
+
constructor(parentFolder, expand = false) {
|
2015
|
+
this.folder = parentFolder.addFolder({
|
2016
|
+
title: "brightness / contrast / sat",
|
2017
|
+
expanded: expand
|
2018
|
+
});
|
2019
|
+
this.folder.addBinding(bcsValues, "brightness", bcsOptions.brightness.amount);
|
2020
|
+
this.folder.addBinding(bcsValues, "contrast", bcsOptions.contrast.amount);
|
2021
|
+
this.folder.addBinding(bcsValues, "saturation", bcsOptions.saturation.amount);
|
2022
|
+
}
|
2023
|
+
setupChangeEvent(brightnessContrastSaturation) {
|
2024
|
+
this.folder.on("change", (e) => {
|
2025
|
+
const target = e.target.key;
|
2026
|
+
if (!target)
|
2027
|
+
return;
|
2028
|
+
switch (target) {
|
2029
|
+
case "brightness":
|
2030
|
+
brightnessContrastSaturation.uniforms.brightness.value = e.value;
|
2031
|
+
break;
|
2032
|
+
case "contrast":
|
2033
|
+
brightnessContrastSaturation.uniforms.contrast.value = e.value;
|
2034
|
+
break;
|
2035
|
+
case "saturation":
|
2036
|
+
brightnessContrastSaturation.uniforms.saturation.value = e.value;
|
2037
|
+
break;
|
2038
|
+
}
|
2039
|
+
});
|
2040
|
+
}
|
2041
|
+
};
|
2042
|
+
|
2043
|
+
// src/tweakpane/blades/postExtrasFolder.ts
|
2044
|
+
var extrasValues = {
|
2045
|
+
grain: 0.055,
|
2046
|
+
bloom: 0.25
|
2047
|
+
};
|
2048
|
+
var extrasOptions = {
|
1898
2049
|
grain: {
|
1899
2050
|
amount: { min: 0, max: 0.2, step: 2e-3 }
|
1900
2051
|
},
|
@@ -1902,12 +2053,52 @@ var composerOptions = {
|
|
1902
2053
|
amount: { min: 0, max: 2, step: 0.05 }
|
1903
2054
|
}
|
1904
2055
|
};
|
2056
|
+
var PostExtrasFolder = class {
|
2057
|
+
constructor(parentFolder, expand = false) {
|
2058
|
+
this.folder = parentFolder.addFolder({ title: "bloom / grain", expanded: expand });
|
2059
|
+
this.folder.addBinding(extrasValues, "bloom", extrasOptions.bloom.amount);
|
2060
|
+
this.folder.addBinding(extrasValues, "grain", extrasOptions.grain.amount);
|
2061
|
+
}
|
2062
|
+
setupChangeEvent(bloomEffect, gaussGrainEffect) {
|
2063
|
+
this.folder.on("change", (e) => {
|
2064
|
+
const target = e.target.key;
|
2065
|
+
if (!target)
|
2066
|
+
return;
|
2067
|
+
switch (target) {
|
2068
|
+
case "bloom":
|
2069
|
+
bloomEffect.intensity = e.value;
|
2070
|
+
break;
|
2071
|
+
case "grain":
|
2072
|
+
gaussGrainEffect.uniforms.amount.value = e.value;
|
2073
|
+
break;
|
2074
|
+
default:
|
2075
|
+
break;
|
2076
|
+
}
|
2077
|
+
});
|
2078
|
+
}
|
2079
|
+
};
|
2080
|
+
|
2081
|
+
// src/tweakpane/blades/rendererFolder.ts
|
2082
|
+
var rendererValues = {
|
2083
|
+
shadowMap: 2,
|
2084
|
+
toneMapping: 5,
|
2085
|
+
exposure: 1,
|
2086
|
+
bgIntensity: 0.45,
|
2087
|
+
bgBlurriness: 0
|
2088
|
+
};
|
2089
|
+
var rendererOptions = {
|
2090
|
+
shadowMap: { min: 0, max: 2, step: 1 },
|
2091
|
+
toneMapping: { min: 0, max: 5, step: 1 },
|
2092
|
+
exposure: { min: 0, max: 3, step: 0.01 },
|
2093
|
+
bgIntensity: { min: 0, max: 1.3, step: 0.01 },
|
2094
|
+
bgBlurriness: { min: 0, max: 0.1, step: 1e-3 }
|
2095
|
+
};
|
1905
2096
|
var shadowMapTypes = {
|
1906
2097
|
0: "BasicShadowMap",
|
1907
2098
|
1: "PCFShadowMap",
|
1908
2099
|
2: "PCFSoftShadowMap"
|
1909
2100
|
};
|
1910
|
-
var
|
2101
|
+
var toneMappingTypes = {
|
1911
2102
|
0: "NoToneMapping",
|
1912
2103
|
1: "LinearToneMapping",
|
1913
2104
|
2: "ReinhardToneMapping",
|
@@ -1915,28 +2106,120 @@ var rendererToneMappingTypes = {
|
|
1915
2106
|
4: "ACESFilmicToneMapping",
|
1916
2107
|
5: "CustomToneMapping"
|
1917
2108
|
};
|
1918
|
-
var
|
1919
|
-
|
1920
|
-
|
1921
|
-
2: "REINHARD2_ADAPTIVE",
|
1922
|
-
3: "OPTIMIZED_CINEON",
|
1923
|
-
4: "ACES_FILMIC"
|
1924
|
-
};
|
1925
|
-
var rendererBlades = {
|
1926
|
-
shadowMapType: shadowMapTypes[composerValues.renderer.shadowMap],
|
1927
|
-
toneMappingType: rendererToneMappingTypes[composerValues.renderer.toneMapping]
|
2109
|
+
var monitoredValues = {
|
2110
|
+
shadowMapType: shadowMapTypes[rendererValues.shadowMap],
|
2111
|
+
toneMappingType: toneMappingTypes[rendererValues.toneMapping]
|
1928
2112
|
};
|
1929
2113
|
var setShadowMapType = (value) => {
|
1930
|
-
|
2114
|
+
monitoredValues.shadowMapType = shadowMapTypes[value];
|
1931
2115
|
};
|
1932
2116
|
var setToneMappingType = (value) => {
|
1933
|
-
|
2117
|
+
monitoredValues.toneMappingType = toneMappingTypes[value];
|
1934
2118
|
};
|
1935
|
-
var
|
1936
|
-
|
2119
|
+
var RendererFolder = class {
|
2120
|
+
constructor(parentFolder, expand = false) {
|
2121
|
+
this.folder = parentFolder.addFolder({
|
2122
|
+
title: "rendererOptions",
|
2123
|
+
expanded: expand
|
2124
|
+
});
|
2125
|
+
this.folder.addBinding(rendererValues, "shadowMap", rendererOptions.shadowMap);
|
2126
|
+
this.folder.addBinding(monitoredValues, "shadowMapType", { readonly: true });
|
2127
|
+
this.folder.addBinding(rendererValues, "toneMapping", rendererOptions.toneMapping);
|
2128
|
+
this.folder.addBinding(monitoredValues, "toneMappingType", { readonly: true });
|
2129
|
+
this.folder.addBinding(rendererValues, "exposure", rendererOptions.exposure);
|
2130
|
+
this.folder.addBinding(rendererValues, "bgIntensity", rendererOptions.bgIntensity);
|
2131
|
+
this.folder.addBinding(rendererValues, "bgBlurriness", rendererOptions.bgBlurriness);
|
2132
|
+
}
|
2133
|
+
setupChangeEvent(scene, renderer, toneMappingFolder, toneMappingPass) {
|
2134
|
+
this.folder.on("change", (e) => {
|
2135
|
+
const target = e.target.key;
|
2136
|
+
if (!target)
|
2137
|
+
return;
|
2138
|
+
switch (target) {
|
2139
|
+
case "shadowMap": {
|
2140
|
+
const value = e.value;
|
2141
|
+
renderer.shadowMap.type = value;
|
2142
|
+
setShadowMapType(value);
|
2143
|
+
break;
|
2144
|
+
}
|
2145
|
+
case "toneMapping":
|
2146
|
+
renderer.toneMapping = e.value;
|
2147
|
+
toneMappingFolder.hidden = e.value !== 5;
|
2148
|
+
toneMappingPass.enabled = e.value === 5 ? true : false;
|
2149
|
+
setToneMappingType(e.value);
|
2150
|
+
break;
|
2151
|
+
case "exposure":
|
2152
|
+
renderer.toneMappingExposure = e.value;
|
2153
|
+
break;
|
2154
|
+
case "bgIntensity":
|
2155
|
+
scene.backgroundIntensity = e.value;
|
2156
|
+
break;
|
2157
|
+
case "bgBlurriness":
|
2158
|
+
scene.backgroundBlurriness = e.value;
|
2159
|
+
break;
|
2160
|
+
default:
|
2161
|
+
break;
|
2162
|
+
}
|
2163
|
+
});
|
2164
|
+
}
|
1937
2165
|
};
|
1938
|
-
|
1939
|
-
|
2166
|
+
|
2167
|
+
// src/tweakpane/blades/ssaoFolder.ts
|
2168
|
+
import { BlendFunction } from "postprocessing";
|
2169
|
+
import { Color as Color5 } from "three";
|
2170
|
+
var ppssaoValues = {
|
2171
|
+
enabled: false,
|
2172
|
+
blendFunction: BlendFunction.MULTIPLY,
|
2173
|
+
distanceScaling: true,
|
2174
|
+
depthAwareUpsampling: true,
|
2175
|
+
samples: 30,
|
2176
|
+
rings: 11,
|
2177
|
+
luminanceInfluence: 0.7,
|
2178
|
+
radius: 0.03,
|
2179
|
+
intensity: 2.5,
|
2180
|
+
bias: 0.05,
|
2181
|
+
fade: 0.03,
|
2182
|
+
resolutionScale: 0.5,
|
2183
|
+
color: { r: 0, g: 0, b: 0 },
|
2184
|
+
worldDistanceThreshold: 30,
|
2185
|
+
worldDistanceFalloff: 7,
|
2186
|
+
worldProximityThreshold: 0.5,
|
2187
|
+
worldProximityFalloff: 0.3
|
2188
|
+
};
|
2189
|
+
var ppssaoOptions = {
|
2190
|
+
samples: { min: 1, max: 50, step: 1 },
|
2191
|
+
rings: { min: 1, max: 50, step: 1 },
|
2192
|
+
luminanceInfluence: { min: 0, max: 1, step: 0.01 },
|
2193
|
+
radius: { min: 0, max: 0.1, step: 1e-3 },
|
2194
|
+
intensity: { min: 0, max: 5, step: 0.1 },
|
2195
|
+
bias: { min: 0, max: 0.1, step: 1e-3 },
|
2196
|
+
fade: { min: 0, max: 0.1, step: 1e-3 },
|
2197
|
+
resolutionScale: { min: 0.25, max: 2, step: 0.25 },
|
2198
|
+
worldDistanceThreshold: { min: 0, max: 200, step: 1 },
|
2199
|
+
worldDistanceFalloff: { min: 0, max: 200, step: 1 },
|
2200
|
+
worldProximityThreshold: { min: 0, max: 2, step: 0.01 },
|
2201
|
+
worldProximityFalloff: { min: 0, max: 2, step: 0.01 }
|
2202
|
+
};
|
2203
|
+
var n8ssaoValues = {
|
2204
|
+
enabled: true,
|
2205
|
+
halfRes: false,
|
2206
|
+
aoRadius: 5,
|
2207
|
+
distanceFalloff: 3,
|
2208
|
+
intensity: 1,
|
2209
|
+
color: { r: 0, g: 0, b: 0 },
|
2210
|
+
aoSamples: 16,
|
2211
|
+
denoiseSamples: 4,
|
2212
|
+
denoiseRadius: 12,
|
2213
|
+
viewMode: "Combined"
|
2214
|
+
};
|
2215
|
+
var n8ssaoOptions = {
|
2216
|
+
radius: { min: 0.1, max: 6, step: 0.1 },
|
2217
|
+
distanceFalloff: { min: 1, max: 6, step: 0.1 },
|
2218
|
+
intensity: { min: 0.1, max: 5, step: 0.1 },
|
2219
|
+
aoSamples: [2, 4, 8, 16, 32, 64],
|
2220
|
+
denoiseSamples: [2, 4, 8, 16, 32, 64],
|
2221
|
+
denoiseRadius: [3, 6, 12],
|
2222
|
+
viewMode: ["Combined", "AO", "Split", "No AO"]
|
1940
2223
|
};
|
1941
2224
|
var ssaoMaterialParams = [
|
1942
2225
|
"fade",
|
@@ -1947,72 +2230,336 @@ var ssaoMaterialParams = [
|
|
1947
2230
|
"worldProximityThreshold",
|
1948
2231
|
"worldProximityFalloff"
|
1949
2232
|
];
|
1950
|
-
var
|
1951
|
-
|
1952
|
-
|
1953
|
-
|
1954
|
-
|
1955
|
-
|
1956
|
-
|
1957
|
-
|
1958
|
-
|
1959
|
-
|
2233
|
+
var SSAOFolder = class {
|
2234
|
+
constructor(parentFolder, expand = false) {
|
2235
|
+
this.postProcessingSSAOIndex = 1;
|
2236
|
+
this.folder = parentFolder.addFolder({ title: "ambientOcclusion", expanded: expand });
|
2237
|
+
this.n8ssao = this.folder.addFolder({
|
2238
|
+
title: "N8 ambientOcclusion",
|
2239
|
+
expanded: n8ssaoValues.enabled
|
2240
|
+
});
|
2241
|
+
this.ppssao = this.folder.addFolder({
|
2242
|
+
title: "PP ambientOcclusion",
|
2243
|
+
expanded: ppssaoValues.enabled
|
2244
|
+
});
|
2245
|
+
{
|
2246
|
+
this.ppssao.addBinding({ enabled: ppssaoValues.enabled }, "enabled");
|
2247
|
+
this.ppssao.addBinding({ showEffectOnly: false }, "showEffectOnly");
|
2248
|
+
this.ppssao.addBinding(ppssaoValues, "samples", ppssaoOptions.samples);
|
2249
|
+
this.ppssao.addBinding(ppssaoValues, "rings", ppssaoOptions.rings);
|
2250
|
+
this.ppssao.addBinding(ppssaoValues, "luminanceInfluence", ppssaoOptions.luminanceInfluence);
|
2251
|
+
this.ppssao.addBinding(ppssaoValues, "radius", ppssaoOptions.radius);
|
2252
|
+
this.ppssao.addBinding(ppssaoValues, "intensity", ppssaoOptions.intensity);
|
2253
|
+
this.ppssao.addBinding(ppssaoValues, "bias", ppssaoOptions.bias);
|
2254
|
+
this.ppssao.addBinding(ppssaoValues, "fade", ppssaoOptions.fade);
|
2255
|
+
this.ppssao.addBinding(ppssaoValues, "resolutionScale", ppssaoOptions.resolutionScale);
|
2256
|
+
this.ppssao.addBinding(
|
2257
|
+
ppssaoValues,
|
2258
|
+
"worldDistanceThreshold",
|
2259
|
+
ppssaoOptions.worldDistanceThreshold
|
2260
|
+
);
|
2261
|
+
this.ppssao.addBinding(
|
2262
|
+
ppssaoValues,
|
2263
|
+
"worldDistanceFalloff",
|
2264
|
+
ppssaoOptions.worldDistanceFalloff
|
2265
|
+
);
|
2266
|
+
this.ppssao.addBinding(
|
2267
|
+
ppssaoValues,
|
2268
|
+
"worldProximityThreshold",
|
2269
|
+
ppssaoOptions.worldProximityThreshold
|
2270
|
+
);
|
2271
|
+
this.ppssao.addBinding(
|
2272
|
+
ppssaoValues,
|
2273
|
+
"worldProximityFalloff",
|
2274
|
+
ppssaoOptions.worldProximityFalloff
|
2275
|
+
);
|
2276
|
+
this.ppssao.addBinding(ppssaoValues, "color", { color: { alpha: false, type: "float" } });
|
2277
|
+
}
|
2278
|
+
{
|
2279
|
+
this.n8ssao.addBinding({ enabled: n8ssaoValues.enabled }, "enabled");
|
2280
|
+
this.n8ssao.addBinding({ halfRes: n8ssaoValues.halfRes }, "halfRes");
|
2281
|
+
this.n8ssao.addBinding(n8ssaoValues, "aoRadius", n8ssaoOptions.radius);
|
2282
|
+
this.n8ssao.addBinding(n8ssaoValues, "distanceFalloff", n8ssaoOptions.distanceFalloff);
|
2283
|
+
this.n8ssao.addBinding(n8ssaoValues, "intensity", n8ssaoOptions.intensity);
|
2284
|
+
this.n8ssao.addBinding(n8ssaoValues, "color", { color: { alpha: false, type: "float" } });
|
2285
|
+
this.aoSamples = this.n8ssao.addBinding(n8ssaoValues, "aoSamples", {
|
2286
|
+
view: "radiogrid",
|
2287
|
+
groupName: "aoSamples",
|
2288
|
+
size: [3, 2],
|
2289
|
+
cells: (x, y) => ({
|
2290
|
+
title: `${n8ssaoOptions.aoSamples[y * 3 + x]}`,
|
2291
|
+
value: n8ssaoOptions.aoSamples[y * 3 + x]
|
2292
|
+
}),
|
2293
|
+
label: "aoSamples"
|
2294
|
+
});
|
2295
|
+
this.denoiseSamples = this.n8ssao.addBinding(n8ssaoValues, "denoiseSamples", {
|
2296
|
+
view: "radiogrid",
|
2297
|
+
groupName: "denoiseSamples",
|
2298
|
+
size: [3, 2],
|
2299
|
+
cells: (x, y) => ({
|
2300
|
+
title: `${n8ssaoOptions.denoiseSamples[y * 3 + x]}`,
|
2301
|
+
value: n8ssaoOptions.denoiseSamples[y * 3 + x]
|
2302
|
+
}),
|
2303
|
+
label: "denoiseSamples"
|
2304
|
+
});
|
2305
|
+
this.denoiseRadius = this.n8ssao.addBinding(n8ssaoValues, "denoiseRadius", {
|
2306
|
+
view: "radiogrid",
|
2307
|
+
groupName: "denoiseRadius",
|
2308
|
+
size: [3, 1],
|
2309
|
+
cells: (x, y) => ({
|
2310
|
+
title: `${n8ssaoOptions.denoiseRadius[y * 3 + x]}`,
|
2311
|
+
value: n8ssaoOptions.denoiseRadius[y * 3 + x]
|
2312
|
+
}),
|
2313
|
+
label: "denoiseRadius"
|
2314
|
+
});
|
2315
|
+
this.aoDisplay = this.n8ssao.addBinding(n8ssaoValues, "viewMode", {
|
2316
|
+
view: "radiogrid",
|
2317
|
+
groupName: "viewMode",
|
2318
|
+
size: [2, 2],
|
2319
|
+
cells: (x, y) => ({
|
2320
|
+
title: `${n8ssaoOptions.viewMode[y * 2 + x]}`,
|
2321
|
+
value: `${n8ssaoOptions.viewMode[y * 2 + x]}`
|
2322
|
+
}),
|
2323
|
+
label: "viewMode"
|
2324
|
+
});
|
2325
|
+
}
|
2326
|
+
this.folder.addBlade({ view: "separator" });
|
2327
|
+
}
|
2328
|
+
setupChangeEvent(composer, normalPass, ppssaoEffect, ppssaoPass, n8aopass) {
|
2329
|
+
this.ppssao.on("change", (e) => {
|
2330
|
+
const target = e.target.key;
|
2331
|
+
if (!target)
|
2332
|
+
return;
|
2333
|
+
switch (target) {
|
2334
|
+
case "enabled": {
|
2335
|
+
const value = e.value;
|
2336
|
+
if (e.value === true) {
|
2337
|
+
composer.addPass(normalPass, this.postProcessingSSAOIndex);
|
2338
|
+
composer.addPass(ppssaoPass, this.postProcessingSSAOIndex + 1);
|
2339
|
+
} else {
|
2340
|
+
composer.removePass(ppssaoPass);
|
2341
|
+
composer.removePass(normalPass);
|
2342
|
+
}
|
2343
|
+
ppssaoValues.enabled = value;
|
2344
|
+
normalPass.enabled = value;
|
2345
|
+
ppssaoPass.enabled = value;
|
2346
|
+
break;
|
2347
|
+
}
|
2348
|
+
case "showEffectOnly": {
|
2349
|
+
const value = e.value;
|
2350
|
+
const blend = value === true ? BlendFunction.NORMAL : BlendFunction.MULTIPLY;
|
2351
|
+
ppssaoEffect.blendMode.blendFunction = blend;
|
2352
|
+
break;
|
2353
|
+
}
|
2354
|
+
case "resolutionScale": {
|
2355
|
+
const value = e.value;
|
2356
|
+
ppssaoEffect.resolution.scale = value;
|
2357
|
+
break;
|
2358
|
+
}
|
2359
|
+
case "color": {
|
2360
|
+
const value = e.value;
|
2361
|
+
ppssaoEffect.color = new Color5().setRGB(value.r, value.g, value.b);
|
2362
|
+
break;
|
2363
|
+
}
|
2364
|
+
default: {
|
2365
|
+
break;
|
2366
|
+
}
|
2367
|
+
}
|
2368
|
+
if (ssaoMaterialParams.includes(target)) {
|
2369
|
+
ppssaoEffect.ssaoMaterial[target] = e.value;
|
2370
|
+
return;
|
2371
|
+
}
|
2372
|
+
ppssaoEffect[target] = e.value;
|
2373
|
+
});
|
2374
|
+
this.n8ssao.on("change", (e) => {
|
2375
|
+
const target = e.target.key;
|
2376
|
+
if (!target)
|
2377
|
+
return;
|
2378
|
+
switch (target) {
|
2379
|
+
case "enabled":
|
2380
|
+
if (e.value === true) {
|
2381
|
+
composer.addPass(n8aopass, this.postProcessingSSAOIndex + 2);
|
2382
|
+
} else {
|
2383
|
+
composer.removePass(n8aopass);
|
2384
|
+
}
|
2385
|
+
n8aopass.enabled = e.value;
|
2386
|
+
break;
|
2387
|
+
case "halfRes":
|
2388
|
+
n8aopass.configuration.halfRes = e.value;
|
2389
|
+
break;
|
2390
|
+
case "aoRadius":
|
2391
|
+
n8aopass.configuration.aoRadius = e.value;
|
2392
|
+
break;
|
2393
|
+
case "distanceFalloff":
|
2394
|
+
n8aopass.configuration.distanceFalloff = e.value;
|
2395
|
+
break;
|
2396
|
+
case "intensity":
|
2397
|
+
n8aopass.configuration.intensity = e.value;
|
2398
|
+
break;
|
2399
|
+
case "color":
|
2400
|
+
const value = e.value;
|
2401
|
+
n8aopass.configuration.color = new Color5().setRGB(value.r, value.g, value.b);
|
2402
|
+
break;
|
2403
|
+
default:
|
2404
|
+
break;
|
2405
|
+
}
|
2406
|
+
});
|
2407
|
+
this.aoSamples.on("change", (e) => {
|
2408
|
+
n8aopass.configuration.aoSamples = e.value;
|
2409
|
+
});
|
2410
|
+
this.denoiseSamples.on("change", (e) => {
|
2411
|
+
n8aopass.configuration.denoiseSamples = e.value;
|
2412
|
+
});
|
2413
|
+
this.denoiseRadius.on("change", (e) => {
|
2414
|
+
n8aopass.configuration.denoiseRadius = e.value;
|
2415
|
+
});
|
2416
|
+
this.aoDisplay.on("change", (e) => {
|
2417
|
+
n8aopass.setDisplayMode(e.value);
|
2418
|
+
});
|
2419
|
+
}
|
1960
2420
|
};
|
1961
2421
|
|
1962
|
-
// src/tweakpane/
|
1963
|
-
var
|
1964
|
-
|
1965
|
-
|
1966
|
-
|
1967
|
-
|
1968
|
-
|
1969
|
-
|
1970
|
-
|
1971
|
-
fogColor: { r: 0.42, g: 0.48, b: 0.59 }
|
1972
|
-
}
|
2422
|
+
// src/tweakpane/blades/toneMappingFolder.ts
|
2423
|
+
var toneMappingValues = {
|
2424
|
+
mode: 2,
|
2425
|
+
resolution: 512,
|
2426
|
+
whitePoint: 32,
|
2427
|
+
middleGrey: 21,
|
2428
|
+
minLuminance: 0.01,
|
2429
|
+
averageLuminance: 0.01,
|
2430
|
+
adaptationRate: 2
|
1973
2431
|
};
|
1974
|
-
var
|
1975
|
-
|
1976
|
-
|
1977
|
-
},
|
1978
|
-
|
1979
|
-
|
1980
|
-
|
2432
|
+
var toneMappingOptions = {
|
2433
|
+
mode: { min: 0, max: 4, step: 1 },
|
2434
|
+
resolution: { min: 64, max: 512, step: 64 },
|
2435
|
+
whitePoint: { min: 0, max: 32, step: 0.01 },
|
2436
|
+
middleGrey: { min: 0, max: 32, step: 0.01 },
|
2437
|
+
minLuminance: { min: 0, max: 32, step: 1e-3 },
|
2438
|
+
averageLuminance: { min: 1e-3, max: 0.2, step: 1e-3 },
|
2439
|
+
adaptationRate: { min: 0.1, max: 2, step: 0.1 }
|
2440
|
+
};
|
2441
|
+
var customToneMappingTypes = {
|
2442
|
+
0: "REINHARD",
|
2443
|
+
1: "REINHARD2",
|
2444
|
+
2: "REINHARD2_ADAPTIVE",
|
2445
|
+
3: "OPTIMIZED_CINEON",
|
2446
|
+
4: "ACES_FILMIC"
|
2447
|
+
};
|
2448
|
+
var customToneMappingBlade = {
|
2449
|
+
customToneMappingType: customToneMappingTypes[toneMappingValues.mode]
|
2450
|
+
};
|
2451
|
+
var setCustomToneMappingType = (value) => {
|
2452
|
+
customToneMappingBlade.customToneMappingType = customToneMappingTypes[value];
|
2453
|
+
};
|
2454
|
+
var ToneMappingFolder = class {
|
2455
|
+
constructor(parentFolder, expand = false) {
|
2456
|
+
this.folder = parentFolder.addFolder({
|
2457
|
+
title: "customToneMapping",
|
2458
|
+
expanded: expand
|
2459
|
+
});
|
2460
|
+
this.folder.addBinding(toneMappingValues, "mode", toneMappingOptions.mode);
|
2461
|
+
this.folder.addBinding(customToneMappingBlade, "customToneMappingType", { readonly: true });
|
2462
|
+
this.folder.addBinding(toneMappingValues, "whitePoint", toneMappingOptions.whitePoint);
|
2463
|
+
this.folder.addBinding(toneMappingValues, "middleGrey", toneMappingOptions.middleGrey);
|
2464
|
+
this.minLuminance = this.folder.addBinding(
|
2465
|
+
toneMappingValues,
|
2466
|
+
"minLuminance",
|
2467
|
+
toneMappingOptions.minLuminance
|
2468
|
+
);
|
2469
|
+
this.minLuminance.hidden = toneMappingValues.mode === 2 ? true : false;
|
2470
|
+
this.avgLuminance = this.folder.addBinding(
|
2471
|
+
toneMappingValues,
|
2472
|
+
"averageLuminance",
|
2473
|
+
toneMappingOptions.averageLuminance
|
2474
|
+
);
|
2475
|
+
this.avgLuminance.hidden = toneMappingValues.mode === 2 ? true : false;
|
2476
|
+
this.folder.addBinding(toneMappingValues, "adaptationRate", toneMappingOptions.adaptationRate);
|
2477
|
+
}
|
2478
|
+
setupChangeEvent(toneMappingEffect) {
|
2479
|
+
this.folder.on("change", (e) => {
|
2480
|
+
const target = e.target.key;
|
2481
|
+
if (!target)
|
2482
|
+
return;
|
2483
|
+
if (target === "mode") {
|
2484
|
+
this.minLuminance.hidden = toneMappingValues.mode === 2 ? true : false;
|
2485
|
+
this.avgLuminance.hidden = toneMappingValues.mode === 2 ? true : false;
|
2486
|
+
setCustomToneMappingType(e.value);
|
2487
|
+
}
|
2488
|
+
toneMappingEffect[target] = e.value;
|
2489
|
+
return;
|
2490
|
+
});
|
1981
2491
|
}
|
1982
2492
|
};
|
1983
2493
|
|
1984
2494
|
// src/tweakpane/TweakPane.ts
|
1985
|
-
import
|
1986
|
-
BlendFunction as BlendFunction2
|
1987
|
-
} from "postprocessing";
|
1988
|
-
import { Color as Color5 } from "three";
|
2495
|
+
import * as EssentialsPlugin from "@tweakpane/plugin-essentials";
|
1989
2496
|
import { Pane } from "tweakpane";
|
1990
|
-
|
1991
|
-
|
1992
|
-
|
1993
|
-
|
1994
|
-
|
1995
|
-
|
2497
|
+
|
2498
|
+
// src/tweakpane/blades/rendererStatsFolder.ts
|
2499
|
+
var RendererStatsFolder = class {
|
2500
|
+
constructor(parentFolder, expanded = true) {
|
2501
|
+
this.statsData = {
|
2502
|
+
triangles: "0",
|
2503
|
+
geometries: "0",
|
2504
|
+
textures: "0",
|
2505
|
+
shaders: "0",
|
2506
|
+
postPasses: "0",
|
2507
|
+
drawCalls: "0",
|
2508
|
+
rawDeltaTime: "0",
|
2509
|
+
deltaTime: "0",
|
2510
|
+
FPS: "0"
|
2511
|
+
};
|
2512
|
+
this.folder = parentFolder.addFolder({ title: "renderStats", expanded });
|
2513
|
+
this.performance = this.folder.addFolder({ title: "performance", expanded: true });
|
2514
|
+
this.defails = this.folder.addFolder({ title: "pipeline details", expanded: false });
|
2515
|
+
this.folder.addBlade({ view: "separator" });
|
2516
|
+
this.performance.addBinding(this.statsData, "FPS", { readonly: true });
|
2517
|
+
this.performance.addBinding(this.statsData, "deltaTime", { readonly: true });
|
2518
|
+
this.performance.addBinding(this.statsData, "rawDeltaTime", { readonly: true });
|
2519
|
+
this.defails.addBinding(this.statsData, "triangles", { readonly: true });
|
2520
|
+
this.defails.addBinding(this.statsData, "geometries", { readonly: true });
|
2521
|
+
this.defails.addBinding(this.statsData, "textures", { readonly: true });
|
2522
|
+
this.defails.addBinding(this.statsData, "shaders", { readonly: true });
|
2523
|
+
this.defails.addBinding(this.statsData, "postPasses", { readonly: true });
|
2524
|
+
this.defails.addBinding(this.statsData, "drawCalls", { readonly: true });
|
2525
|
+
}
|
2526
|
+
update(renderer, composer, timeManager) {
|
2527
|
+
const { geometries, textures } = renderer.info.memory;
|
2528
|
+
const { triangles, calls } = renderer.info.render;
|
2529
|
+
this.statsData.triangles = triangles.toString();
|
2530
|
+
this.statsData.geometries = geometries.toString();
|
2531
|
+
this.statsData.textures = textures.toString();
|
2532
|
+
this.statsData.shaders = renderer.info.programs.length.toString();
|
2533
|
+
this.statsData.postPasses = composer.passes.length.toString();
|
2534
|
+
this.statsData.drawCalls = calls.toString();
|
2535
|
+
this.statsData.rawDeltaTime = (Math.round(timeManager.rawDeltaTime * 1e5) / 1e5).toString();
|
2536
|
+
this.statsData.deltaTime = (Math.round(timeManager.deltaTime * 1e5) / 1e5).toString();
|
2537
|
+
this.statsData.FPS = timeManager.fps.toString();
|
2538
|
+
}
|
2539
|
+
};
|
2540
|
+
|
2541
|
+
// src/tweakpane/tweakPaneStyle.ts
|
2542
|
+
var tweakPaneStyle = `
|
1996
2543
|
:root {
|
1997
|
-
--tp-base-background-color:
|
2544
|
+
--tp-base-background-color: rgba(0, 0, 0, 0.6);
|
1998
2545
|
--tp-base-shadow-color: hsla(0, 0%, 0%, 0.2);
|
1999
2546
|
--tp-button-background-color: hsla(0, 0%, 80%, 1);
|
2000
2547
|
--tp-button-background-color-active: hsla(0, 0%, 100%, 1);
|
2001
2548
|
--tp-button-background-color-focus: hsla(0, 0%, 95%, 1);
|
2002
2549
|
--tp-button-background-color-hover: hsla(0, 0%, 85%, 1);
|
2003
|
-
--tp-button-foreground-color: hsla(0, 0%, 0%, 0.
|
2550
|
+
--tp-button-foreground-color: hsla(0, 0%, 0%, 0.7);
|
2004
2551
|
--tp-container-background-color: hsla(0, 0%, 0%, 0.3);
|
2005
2552
|
--tp-container-background-color-active: hsla(0, 0%, 0%, 0.6);
|
2006
2553
|
--tp-container-background-color-focus: hsla(0, 0%, 0%, 0.5);
|
2007
2554
|
--tp-container-background-color-hover: hsla(0, 0%, 0%, 0.4);
|
2008
|
-
--tp-container-foreground-color: hsla(0, 0%,
|
2555
|
+
--tp-container-foreground-color: hsla(0, 0%, 90%, 0.6);
|
2009
2556
|
--tp-groove-foreground-color: hsla(0, 0%, 0%, 0.2);
|
2010
|
-
--tp-input-background-color: hsla(0, 0%,
|
2557
|
+
--tp-input-background-color: hsla(0, 0%, 30%, 0.3);
|
2011
2558
|
--tp-input-background-color-active: hsla(0, 0%, 0%, 0.6);
|
2012
2559
|
--tp-input-background-color-focus: hsla(0, 0%, 0%, 0.5);
|
2013
2560
|
--tp-input-background-color-hover: hsla(0, 0%, 0%, 0.4);
|
2014
|
-
--tp-input-foreground-color: hsla(0, 0%, 100%, 0.
|
2015
|
-
--tp-label-foreground-color: hsla(0, 0%, 100%, 0.
|
2561
|
+
--tp-input-foreground-color: hsla(0, 0%, 100%, 0.6);
|
2562
|
+
--tp-label-foreground-color: hsla(0, 0%, 100%, 0.6);
|
2016
2563
|
--tp-monitor-background-color: hsla(0, 0%, 0%, 0.3);
|
2017
2564
|
--tp-monitor-foreground-color: hsla(0, 0%, 100%, 0.3);
|
2018
2565
|
}
|
@@ -2024,31 +2571,50 @@ var TweakPane = class {
|
|
2024
2571
|
}
|
2025
2572
|
|
2026
2573
|
.tp-dfwv {
|
2027
|
-
|
2574
|
+
color: white;
|
2575
|
+
backdrop-filter: blur(12px);
|
2576
|
+
width: 360px !important;
|
2028
2577
|
display: none;
|
2578
|
+
-webkit-user-select: none;
|
2579
|
+
-ms-user-select: none;
|
2580
|
+
user-select: none;
|
2581
|
+
}
|
2582
|
+
|
2583
|
+
.tp-fldv_t {
|
2584
|
+
font-size: 11px;
|
2585
|
+
background-color: rgba(0, 0, 0, 0.1);
|
2029
2586
|
}
|
2030
2587
|
|
2031
2588
|
.tp-lblv_l {
|
2032
|
-
font-size:
|
2589
|
+
font-size: 11px;
|
2033
2590
|
padding-left: 0px !important;
|
2034
2591
|
padding-right: 0px !important;
|
2035
2592
|
}
|
2036
|
-
|
2037
|
-
|
2038
|
-
|
2039
|
-
|
2040
|
-
|
2041
|
-
|
2042
|
-
|
2043
|
-
|
2044
|
-
|
2045
|
-
|
2046
|
-
|
2047
|
-
|
2048
|
-
|
2049
|
-
|
2050
|
-
|
2051
|
-
|
2593
|
+
|
2594
|
+
.tp-lblv_v {
|
2595
|
+
width: 180px;
|
2596
|
+
}
|
2597
|
+
|
2598
|
+
.tp-sldtxtv_t {
|
2599
|
+
max-width: 50px;
|
2600
|
+
}
|
2601
|
+
|
2602
|
+
.tp-sglv_i {
|
2603
|
+
font-size: 11px;
|
2604
|
+
color: rgba(255, 255, 255, 0.7);
|
2605
|
+
}
|
2606
|
+
`;
|
2607
|
+
|
2608
|
+
// src/tweakpane/TweakPane.ts
|
2609
|
+
var TweakPane = class {
|
2610
|
+
constructor(renderer, scene, composer) {
|
2611
|
+
this.renderer = renderer;
|
2612
|
+
this.scene = scene;
|
2613
|
+
this.composer = composer;
|
2614
|
+
this.gui = new Pane();
|
2615
|
+
this.saveVisibilityInLocalStorage = true;
|
2616
|
+
this.guiVisible = false;
|
2617
|
+
this.gui.registerPlugin(EssentialsPlugin);
|
2052
2618
|
if (this.saveVisibilityInLocalStorage) {
|
2053
2619
|
const localStorageGuiVisible = localStorage.getItem("guiVisible");
|
2054
2620
|
if (localStorageGuiVisible !== null) {
|
@@ -2059,120 +2625,20 @@ var TweakPane = class {
|
|
2059
2625
|
}
|
2060
2626
|
}
|
2061
2627
|
}
|
2062
|
-
this.renderer = renderer;
|
2063
|
-
this.scene = scene;
|
2064
|
-
this.composer = composer;
|
2065
2628
|
const styleElement = document.createElement("style");
|
2066
2629
|
styleElement.type = "text/css";
|
2067
|
-
styleElement.appendChild(document.createTextNode(
|
2630
|
+
styleElement.appendChild(document.createTextNode(tweakPaneStyle));
|
2068
2631
|
document.head.appendChild(styleElement);
|
2069
|
-
this.
|
2070
|
-
this.
|
2071
|
-
this.
|
2072
|
-
this.
|
2073
|
-
this.
|
2074
|
-
this.
|
2075
|
-
this.
|
2076
|
-
|
2077
|
-
|
2078
|
-
|
2079
|
-
characterValues.material,
|
2080
|
-
"transmission",
|
2081
|
-
characterOptions.material.transmission
|
2082
|
-
);
|
2083
|
-
this.characterMaterial.addInput(
|
2084
|
-
characterValues.material,
|
2085
|
-
"metalness",
|
2086
|
-
characterOptions.material.metalness
|
2087
|
-
);
|
2088
|
-
this.characterMaterial.addInput(
|
2089
|
-
characterValues.material,
|
2090
|
-
"roughness",
|
2091
|
-
characterOptions.material.roughness
|
2092
|
-
);
|
2093
|
-
this.characterMaterial.addInput(
|
2094
|
-
characterValues.material,
|
2095
|
-
"ior",
|
2096
|
-
characterOptions.material.ior
|
2097
|
-
);
|
2098
|
-
this.characterMaterial.addInput(
|
2099
|
-
characterValues.material,
|
2100
|
-
"thickness",
|
2101
|
-
characterOptions.material.thickness
|
2102
|
-
);
|
2103
|
-
this.characterMaterial.addInput(characterValues.material, "specularColor", {
|
2104
|
-
color: { type: "float" }
|
2105
|
-
});
|
2106
|
-
this.characterMaterial.addInput(
|
2107
|
-
characterValues.material,
|
2108
|
-
"specularIntensity",
|
2109
|
-
characterOptions.material.specularIntensity
|
2110
|
-
);
|
2111
|
-
this.characterMaterial.addInput(characterValues.material, "emissive", {
|
2112
|
-
color: { type: "float" }
|
2113
|
-
});
|
2114
|
-
this.characterMaterial.addInput(
|
2115
|
-
characterValues.material,
|
2116
|
-
"emissiveIntensity",
|
2117
|
-
characterOptions.material.emissiveIntensity
|
2118
|
-
);
|
2119
|
-
this.characterMaterial.addInput(
|
2120
|
-
characterValues.material,
|
2121
|
-
"envMapIntensity",
|
2122
|
-
characterOptions.material.envMapIntensity
|
2123
|
-
);
|
2124
|
-
this.characterMaterial.addInput(characterValues.material, "sheenColor", {
|
2125
|
-
color: { type: "float" }
|
2126
|
-
});
|
2127
|
-
this.characterMaterial.addInput(
|
2128
|
-
characterValues.material,
|
2129
|
-
"sheen",
|
2130
|
-
characterOptions.material.sheen
|
2131
|
-
);
|
2132
|
-
this.characterMaterial.addInput(
|
2133
|
-
characterValues.material,
|
2134
|
-
"clearcoat",
|
2135
|
-
characterOptions.material.clearcoat
|
2136
|
-
);
|
2137
|
-
this.characterMaterial.addInput(
|
2138
|
-
characterValues.material,
|
2139
|
-
"clearcoatRoughness",
|
2140
|
-
characterOptions.material.clearcoatRoughness
|
2141
|
-
);
|
2142
|
-
this.characterMaterial.on("change", (e) => {
|
2143
|
-
if (!e.presetKey) {
|
2144
|
-
return;
|
2145
|
-
}
|
2146
|
-
if (e.presetKey === "specularColor") {
|
2147
|
-
characterValues.material.specularColor = {
|
2148
|
-
r: e.value.r,
|
2149
|
-
g: e.value.g,
|
2150
|
-
b: e.value.b
|
2151
|
-
};
|
2152
|
-
return;
|
2153
|
-
}
|
2154
|
-
if (e.presetKey === "emissive") {
|
2155
|
-
characterValues.material.emissive = {
|
2156
|
-
r: e.value.r,
|
2157
|
-
g: e.value.g,
|
2158
|
-
b: e.value.b
|
2159
|
-
};
|
2160
|
-
return;
|
2161
|
-
}
|
2162
|
-
if (e.presetKey === "sheenColor") {
|
2163
|
-
characterValues.material.sheenColor = {
|
2164
|
-
r: e.value.r,
|
2165
|
-
g: e.value.g,
|
2166
|
-
b: e.value.b
|
2167
|
-
};
|
2168
|
-
return;
|
2169
|
-
}
|
2170
|
-
});
|
2171
|
-
}
|
2172
|
-
this.environment = this.gui.addFolder({ title: "environment", expanded: false });
|
2173
|
-
this.sun = this.environment.addFolder({ title: "sun", expanded: true });
|
2174
|
-
this.ambient = this.environment.addFolder({ title: "ambient", expanded: true });
|
2175
|
-
this.export = this.gui.addFolder({ title: "import/export", expanded: false });
|
2632
|
+
this.renderStatsFolder = new RendererStatsFolder(this.gui, true);
|
2633
|
+
this.rendererFolder = new RendererFolder(this.gui, false);
|
2634
|
+
this.toneMappingFolder = new ToneMappingFolder(this.gui, false);
|
2635
|
+
this.ssaoFolder = new SSAOFolder(this.gui, false);
|
2636
|
+
this.bcsFolder = new BrightnessContrastSaturationFolder(this.gui, false);
|
2637
|
+
this.postExtrasFolder = new PostExtrasFolder(this.gui, false);
|
2638
|
+
this.character = new CharacterFolder(this.gui, false);
|
2639
|
+
this.environment = new EnvironmentFolder(this.gui, false);
|
2640
|
+
this.toneMappingFolder.folder.hidden = rendererValues.toneMapping === 5 ? false : true;
|
2641
|
+
this.export = this.gui.addFolder({ title: "import / export", expanded: false });
|
2176
2642
|
window.addEventListener("keydown", this.processKey.bind(this));
|
2177
2643
|
this.setupGUIListeners.bind(this)();
|
2178
2644
|
this.setupRenderPane = this.setupRenderPane.bind(this);
|
@@ -2189,319 +2655,33 @@ var TweakPane = class {
|
|
2189
2655
|
this.gui.element.addEventListener("mouseup", () => setTweakpaneActive(false));
|
2190
2656
|
this.gui.element.addEventListener("mouseleave", () => setTweakpaneActive(false));
|
2191
2657
|
}
|
2192
|
-
setupRenderPane(
|
2193
|
-
|
2194
|
-
this.
|
2195
|
-
this.
|
2196
|
-
this.
|
2197
|
-
|
2198
|
-
|
2199
|
-
|
2200
|
-
|
2201
|
-
|
2202
|
-
|
2203
|
-
|
2204
|
-
|
2205
|
-
this.renderOptions.addInput(
|
2206
|
-
composerValues.renderer,
|
2207
|
-
"shadowMap",
|
2208
|
-
composerOptions.renderer.shadowMap
|
2209
|
-
);
|
2210
|
-
this.renderOptions.addMonitor(rendererBlades, "shadowMapType");
|
2211
|
-
this.renderOptions.addInput(
|
2212
|
-
composerValues.renderer,
|
2213
|
-
"toneMapping",
|
2214
|
-
composerOptions.renderer.toneMapping
|
2215
|
-
);
|
2216
|
-
this.renderOptions.addMonitor(rendererBlades, "toneMappingType");
|
2217
|
-
this.renderOptions.addInput(
|
2218
|
-
composerValues.renderer,
|
2219
|
-
"exposure",
|
2220
|
-
composerOptions.renderer.exposure
|
2221
|
-
);
|
2222
|
-
this.renderOptions.addInput(
|
2223
|
-
composerValues.renderer,
|
2224
|
-
"bgIntensity",
|
2225
|
-
composerOptions.renderer.bgIntensity
|
2226
|
-
);
|
2227
|
-
this.renderOptions.addInput(
|
2228
|
-
composerValues.renderer,
|
2229
|
-
"bgBlurriness",
|
2230
|
-
composerOptions.renderer.bgBlurriness
|
2231
|
-
);
|
2232
|
-
this.renderOptions.on("change", (e) => {
|
2233
|
-
const target = e.target;
|
2234
|
-
switch (target.label) {
|
2235
|
-
case "shadowMap":
|
2236
|
-
this.renderer.shadowMap.type = e.value;
|
2237
|
-
setShadowMapType(e.value);
|
2238
|
-
break;
|
2239
|
-
case "toneMapping":
|
2240
|
-
this.renderer.toneMapping = e.value;
|
2241
|
-
this.toneMapping.hidden = e.value !== 5;
|
2242
|
-
toneMappingPass.enabled = e.value === 5 ? true : false;
|
2243
|
-
setToneMappingType(e.value);
|
2244
|
-
break;
|
2245
|
-
case "exposure":
|
2246
|
-
this.renderer.toneMappingExposure = e.value;
|
2247
|
-
break;
|
2248
|
-
case "bgIntensity":
|
2249
|
-
this.scene.backgroundIntensity = e.value;
|
2250
|
-
break;
|
2251
|
-
case "bgBlurriness":
|
2252
|
-
this.scene.backgroundBlurriness = e.value;
|
2253
|
-
break;
|
2254
|
-
default:
|
2255
|
-
break;
|
2256
|
-
}
|
2257
|
-
});
|
2258
|
-
}
|
2259
|
-
{
|
2260
|
-
this.ssao.addInput({ showEffectOnly: false }, "showEffectOnly");
|
2261
|
-
this.ssao.addInput(composerValues.ssao, "samples", composerOptions.ssao.samples);
|
2262
|
-
this.ssao.addInput(composerValues.ssao, "rings", composerOptions.ssao.rings);
|
2263
|
-
this.ssao.addInput(
|
2264
|
-
composerValues.ssao,
|
2265
|
-
"luminanceInfluence",
|
2266
|
-
composerOptions.ssao.luminanceInfluence
|
2267
|
-
);
|
2268
|
-
this.ssao.addInput(composerValues.ssao, "radius", composerOptions.ssao.radius);
|
2269
|
-
this.ssao.addInput(composerValues.ssao, "intensity", composerOptions.ssao.intensity);
|
2270
|
-
this.ssao.addInput(composerValues.ssao, "bias", composerOptions.ssao.bias);
|
2271
|
-
this.ssao.addInput(composerValues.ssao, "fade", composerOptions.ssao.fade);
|
2272
|
-
this.ssao.addInput(
|
2273
|
-
composerValues.ssao,
|
2274
|
-
"resolutionScale",
|
2275
|
-
composerOptions.ssao.resolutionScale
|
2276
|
-
);
|
2277
|
-
this.ssao.addInput(
|
2278
|
-
composerValues.ssao,
|
2279
|
-
"worldDistanceThreshold",
|
2280
|
-
composerOptions.ssao.worldDistanceThreshold
|
2281
|
-
);
|
2282
|
-
this.ssao.addInput(
|
2283
|
-
composerValues.ssao,
|
2284
|
-
"worldDistanceFalloff",
|
2285
|
-
composerOptions.ssao.worldDistanceFalloff
|
2286
|
-
);
|
2287
|
-
this.ssao.addInput(
|
2288
|
-
composerValues.ssao,
|
2289
|
-
"worldProximityThreshold",
|
2290
|
-
composerOptions.ssao.worldProximityThreshold
|
2291
|
-
);
|
2292
|
-
this.ssao.addInput(
|
2293
|
-
composerValues.ssao,
|
2294
|
-
"worldProximityFalloff",
|
2295
|
-
composerOptions.ssao.worldProximityFalloff
|
2296
|
-
);
|
2297
|
-
this.ssao.addInput(composerValues.ssao, "color", {
|
2298
|
-
color: { alpha: false, type: "float" }
|
2299
|
-
});
|
2300
|
-
this.ssao.on("change", (e) => {
|
2301
|
-
if (!e.presetKey) {
|
2302
|
-
return;
|
2303
|
-
}
|
2304
|
-
const preset = e.presetKey;
|
2305
|
-
if (preset === "showEffectOnly") {
|
2306
|
-
ssaoEffect.blendMode.blendFunction = e.value === true ? BlendFunction2.NORMAL : BlendFunction2.MULTIPLY;
|
2307
|
-
return;
|
2308
|
-
}
|
2309
|
-
if (preset === "resolutionScale") {
|
2310
|
-
ssaoEffect.resolution.scale = e.value;
|
2311
|
-
return;
|
2312
|
-
}
|
2313
|
-
if (ssaoMaterialParams.includes(e.presetKey)) {
|
2314
|
-
ssaoEffect.ssaoMaterial[preset] = e.value;
|
2315
|
-
return;
|
2316
|
-
}
|
2317
|
-
if (e.presetKey === "color") {
|
2318
|
-
ssaoEffect.color = new Color5().setRGB(e.value.r, e.value.g, e.value.b);
|
2319
|
-
return;
|
2320
|
-
}
|
2321
|
-
ssaoEffect[preset] = e.value;
|
2322
|
-
});
|
2323
|
-
}
|
2324
|
-
{
|
2325
|
-
this.toneMapping.addInput(
|
2326
|
-
composerValues.toneMapping,
|
2327
|
-
"mode",
|
2328
|
-
composerOptions.toneMapping.mode
|
2329
|
-
);
|
2330
|
-
this.toneMapping.addMonitor(customToneMappingBlade, "customToneMappingType");
|
2331
|
-
this.toneMapping.addInput(
|
2332
|
-
composerValues.toneMapping,
|
2333
|
-
"whitePoint",
|
2334
|
-
composerOptions.toneMapping.whitePoint
|
2335
|
-
);
|
2336
|
-
this.toneMapping.addInput(
|
2337
|
-
composerValues.toneMapping,
|
2338
|
-
"middleGrey",
|
2339
|
-
composerOptions.toneMapping.middleGrey
|
2340
|
-
);
|
2341
|
-
const minLuminance = this.toneMapping.addInput(
|
2342
|
-
composerValues.toneMapping,
|
2343
|
-
"minLuminance",
|
2344
|
-
composerOptions.toneMapping.minLuminance
|
2345
|
-
);
|
2346
|
-
minLuminance.hidden = composerValues.toneMapping.mode === 2 ? true : false;
|
2347
|
-
const averageLuminance = this.toneMapping.addInput(
|
2348
|
-
composerValues.toneMapping,
|
2349
|
-
"averageLuminance",
|
2350
|
-
composerOptions.toneMapping.averageLuminance
|
2351
|
-
);
|
2352
|
-
averageLuminance.hidden = composerValues.toneMapping.mode === 2 ? true : false;
|
2353
|
-
this.toneMapping.addInput(
|
2354
|
-
composerValues.toneMapping,
|
2355
|
-
"adaptationRate",
|
2356
|
-
composerOptions.toneMapping.adaptationRate
|
2357
|
-
);
|
2358
|
-
this.toneMapping.on("change", (e) => {
|
2359
|
-
if (!e.presetKey) {
|
2360
|
-
return;
|
2361
|
-
}
|
2362
|
-
const preset = e.presetKey;
|
2363
|
-
if (preset === "mode") {
|
2364
|
-
minLuminance.hidden = composerValues.toneMapping.mode === 2 ? true : false;
|
2365
|
-
averageLuminance.hidden = composerValues.toneMapping.mode === 2 ? true : false;
|
2366
|
-
setCustomToneMappingType(e.value);
|
2367
|
-
}
|
2368
|
-
toneMappingEffect[preset] = e.value;
|
2369
|
-
return;
|
2370
|
-
});
|
2371
|
-
}
|
2372
|
-
{
|
2373
|
-
this.post.addInput(composerValues, "brightness", composerOptions.brightness.amount);
|
2374
|
-
this.post.addInput(composerValues, "contrast", composerOptions.contrast.amount);
|
2375
|
-
this.post.addInput(composerValues, "saturation", composerOptions.saturation.amount);
|
2376
|
-
this.post.addInput(composerValues, "bloom", composerOptions.bloom.amount);
|
2377
|
-
this.post.addInput(composerValues, "grain", composerOptions.grain.amount);
|
2378
|
-
this.post.on("change", (e) => {
|
2379
|
-
const target = e.presetKey;
|
2380
|
-
switch (target) {
|
2381
|
-
case "brightness":
|
2382
|
-
brightnessContrastSaturation.uniforms.brightness.value = e.value;
|
2383
|
-
break;
|
2384
|
-
case "contrast":
|
2385
|
-
brightnessContrastSaturation.uniforms.contrast.value = e.value;
|
2386
|
-
break;
|
2387
|
-
case "saturation":
|
2388
|
-
brightnessContrastSaturation.uniforms.saturation.value = e.value;
|
2389
|
-
break;
|
2390
|
-
case "bloom":
|
2391
|
-
bloomEffect.intensity = e.value;
|
2392
|
-
break;
|
2393
|
-
case "grain":
|
2394
|
-
gaussGrainEffect.uniforms.amount.value = e.value;
|
2395
|
-
break;
|
2396
|
-
default:
|
2397
|
-
break;
|
2398
|
-
}
|
2399
|
-
});
|
2400
|
-
}
|
2401
|
-
{
|
2402
|
-
this.environment.hidden = hasLighting === false || sun === null;
|
2403
|
-
this.sun.addInput(
|
2404
|
-
sunValues.sunPosition,
|
2405
|
-
"sunAzimuthalAngle",
|
2406
|
-
sunOptions.sunPosition.sunAzimuthalAngle
|
2407
|
-
);
|
2408
|
-
this.sun.addInput(
|
2409
|
-
sunValues.sunPosition,
|
2410
|
-
"sunPolarAngle",
|
2411
|
-
sunOptions.sunPosition.sunPolarAngle
|
2412
|
-
);
|
2413
|
-
this.sun.addInput(sunValues, "sunIntensity", sunOptions.sunIntensity);
|
2414
|
-
this.sun.addInput(sunValues, "sunColor", {
|
2415
|
-
color: { type: "float" }
|
2416
|
-
});
|
2417
|
-
this.sunButton = this.sun.addButton({ title: "Set HDRI" });
|
2418
|
-
this.sunButton.on("click", () => {
|
2419
|
-
setHDR();
|
2420
|
-
});
|
2421
|
-
this.sun.on("change", (e) => {
|
2422
|
-
const target = e.presetKey;
|
2423
|
-
switch (target) {
|
2424
|
-
case "sunAzimuthalAngle":
|
2425
|
-
sun?.setAzimuthalAngle(e.value * (Math.PI / 180));
|
2426
|
-
break;
|
2427
|
-
case "sunPolarAngle":
|
2428
|
-
sun?.setPolarAngle(e.value * (Math.PI / 180));
|
2429
|
-
break;
|
2430
|
-
case "sunIntensity":
|
2431
|
-
sun?.setIntensity(e.value);
|
2432
|
-
break;
|
2433
|
-
case "sunColor":
|
2434
|
-
sunValues.sunColor = {
|
2435
|
-
r: e.value.r,
|
2436
|
-
g: e.value.g,
|
2437
|
-
b: e.value.b
|
2438
|
-
};
|
2439
|
-
sun?.setColor();
|
2440
|
-
break;
|
2441
|
-
default:
|
2442
|
-
break;
|
2443
|
-
}
|
2444
|
-
});
|
2445
|
-
this.ambient.addInput(
|
2446
|
-
envValues.ambientLight,
|
2447
|
-
"ambientLightIntensity",
|
2448
|
-
envOptions.ambientLight.ambientLightIntensity
|
2449
|
-
);
|
2450
|
-
this.ambient.addInput(envValues.ambientLight, "ambientLightColor", {
|
2451
|
-
color: { type: "float" }
|
2452
|
-
});
|
2453
|
-
this.ambient.addInput(envValues.fog, "fogNear", envOptions.fog.fogNear);
|
2454
|
-
this.ambient.addInput(envValues.fog, "fogFar", envOptions.fog.fogFar);
|
2455
|
-
this.ambient.addInput(envValues.fog, "fogColor", {
|
2456
|
-
color: { type: "float" }
|
2457
|
-
});
|
2458
|
-
this.ambient.on("change", (e) => {
|
2459
|
-
const target = e.presetKey;
|
2460
|
-
switch (target) {
|
2461
|
-
case "ambientLightIntensity":
|
2462
|
-
envValues.ambientLight.ambientLightIntensity = e.value;
|
2463
|
-
setAmbientLight();
|
2464
|
-
break;
|
2465
|
-
case "ambientLightColor":
|
2466
|
-
envValues.ambientLight.ambientLightColor = {
|
2467
|
-
r: e.value.r,
|
2468
|
-
g: e.value.g,
|
2469
|
-
b: e.value.b
|
2470
|
-
};
|
2471
|
-
setAmbientLight();
|
2472
|
-
break;
|
2473
|
-
case "fogNear":
|
2474
|
-
envValues.fog.fogNear = e.value;
|
2475
|
-
setFog();
|
2476
|
-
break;
|
2477
|
-
case "fogFar":
|
2478
|
-
envValues.fog.fogFar = e.value;
|
2479
|
-
setFog();
|
2480
|
-
break;
|
2481
|
-
case "fogColor":
|
2482
|
-
envValues.fog.fogColor = {
|
2483
|
-
r: e.value.r,
|
2484
|
-
g: e.value.g,
|
2485
|
-
b: e.value.b
|
2486
|
-
};
|
2487
|
-
setFog();
|
2488
|
-
break;
|
2489
|
-
default:
|
2490
|
-
break;
|
2491
|
-
}
|
2492
|
-
});
|
2493
|
-
}
|
2658
|
+
setupRenderPane(composer, normalPass, ppssaoEffect, ppssaoPass, n8aopass, toneMappingEffect, toneMappingPass, brightnessContrastSaturation, bloomEffect, gaussGrainEffect, hasLighting, sun, setHDR, setAmbientLight, setFog) {
|
2659
|
+
this.rendererFolder.setupChangeEvent(
|
2660
|
+
this.scene,
|
2661
|
+
this.renderer,
|
2662
|
+
this.toneMappingFolder.folder,
|
2663
|
+
toneMappingPass
|
2664
|
+
);
|
2665
|
+
this.toneMappingFolder.setupChangeEvent(toneMappingEffect);
|
2666
|
+
this.ssaoFolder.setupChangeEvent(composer, normalPass, ppssaoEffect, ppssaoPass, n8aopass);
|
2667
|
+
this.bcsFolder.setupChangeEvent(brightnessContrastSaturation);
|
2668
|
+
this.postExtrasFolder.setupChangeEvent(bloomEffect, gaussGrainEffect);
|
2669
|
+
this.environment.setupChangeEvent(setHDR, setAmbientLight, setFog, sun);
|
2670
|
+
this.environment.folder.hidden = hasLighting === false || sun === null;
|
2494
2671
|
const exportButton = this.export.addButton({ title: "export" });
|
2495
2672
|
exportButton.on("click", () => {
|
2496
|
-
this.downloadSettingsAsJSON(this.gui.
|
2673
|
+
this.downloadSettingsAsJSON(this.gui.exportState());
|
2497
2674
|
});
|
2498
2675
|
const importButton = this.export.addButton({ title: "import" });
|
2499
2676
|
importButton.on("click", () => {
|
2500
2677
|
this.importSettingsFromJSON((settings) => {
|
2501
|
-
this.gui.
|
2678
|
+
this.gui.importState(settings);
|
2502
2679
|
});
|
2503
2680
|
});
|
2504
2681
|
}
|
2682
|
+
updateStats(timeManager) {
|
2683
|
+
this.renderStatsFolder.update(this.renderer, this.composer, timeManager);
|
2684
|
+
}
|
2505
2685
|
formatDateForFilename() {
|
2506
2686
|
const date = /* @__PURE__ */ new Date();
|
2507
2687
|
const year = date.getFullYear();
|
@@ -2527,12 +2707,14 @@ var TweakPane = class {
|
|
2527
2707
|
input.type = "file";
|
2528
2708
|
input.accept = ".json";
|
2529
2709
|
input.addEventListener("change", (event) => {
|
2530
|
-
|
2710
|
+
var _a;
|
2711
|
+
const file = (_a = event.target.files) == null ? void 0 : _a[0];
|
2531
2712
|
if (file) {
|
2532
2713
|
const reader = new FileReader();
|
2533
2714
|
reader.onload = (loadEvent) => {
|
2715
|
+
var _a2;
|
2534
2716
|
try {
|
2535
|
-
const settings = JSON.parse(loadEvent.target
|
2717
|
+
const settings = JSON.parse((_a2 = loadEvent.target) == null ? void 0 : _a2.result);
|
2536
2718
|
callback(settings);
|
2537
2719
|
} catch (err) {
|
2538
2720
|
console.error("Error parsing JSON:", err);
|
@@ -2543,19 +2725,6 @@ var TweakPane = class {
|
|
2543
2725
|
});
|
2544
2726
|
input.click();
|
2545
2727
|
}
|
2546
|
-
updateStats(timeManager) {
|
2547
|
-
const { geometries, textures } = this.renderer.info.memory;
|
2548
|
-
const { triangles, calls } = this.renderer.info.render;
|
2549
|
-
statsData.triangles = triangles.toString();
|
2550
|
-
statsData.geometries = geometries.toString();
|
2551
|
-
statsData.textures = textures.toString();
|
2552
|
-
statsData.shaders = this.renderer.info.programs.length.toString();
|
2553
|
-
statsData.postPasses = this.composer.passes.length.toString();
|
2554
|
-
statsData.drawCalls = calls.toString();
|
2555
|
-
statsData.rawDeltaTime = (Math.round(timeManager.rawDeltaTime * 1e5) / 1e5).toString();
|
2556
|
-
statsData.deltaTime = (Math.round(timeManager.deltaTime * 1e5) / 1e5).toString();
|
2557
|
-
statsData.FPS = timeManager.fps.toString();
|
2558
|
-
}
|
2559
2728
|
toggleGUI() {
|
2560
2729
|
const gui = this.gui;
|
2561
2730
|
const paneElement = gui.containerElem_;
|
@@ -2714,39 +2883,18 @@ var GaussGrainEffect = new ShaderMaterial2({
|
|
2714
2883
|
// src/rendering/composer.ts
|
2715
2884
|
var Composer = class {
|
2716
2885
|
constructor(scene, camera, spawnSun = false) {
|
2717
|
-
|
2718
|
-
|
2719
|
-
|
2720
|
-
|
2721
|
-
|
2722
|
-
|
2723
|
-
|
2724
|
-
|
2725
|
-
__publicField(this, "renderPass");
|
2726
|
-
__publicField(this, "fxaaEffect");
|
2727
|
-
__publicField(this, "fxaaPass");
|
2728
|
-
__publicField(this, "bloomEffect");
|
2729
|
-
__publicField(this, "bloomPass");
|
2730
|
-
__publicField(this, "toneMappingEffect");
|
2731
|
-
__publicField(this, "smaaEffect");
|
2732
|
-
__publicField(this, "normalPass");
|
2733
|
-
__publicField(this, "normalTextureEffect");
|
2734
|
-
__publicField(this, "ssaoEffect");
|
2735
|
-
__publicField(this, "ssaoPass");
|
2736
|
-
__publicField(this, "toneMappingPass");
|
2737
|
-
__publicField(this, "smaaPass");
|
2738
|
-
__publicField(this, "bcs", BrightnessContrastSaturation);
|
2739
|
-
__publicField(this, "bcsPass");
|
2740
|
-
__publicField(this, "gaussGrainEffect", GaussGrainEffect);
|
2741
|
-
__publicField(this, "gaussGrainPass");
|
2742
|
-
__publicField(this, "ambientLight", null);
|
2743
|
-
__publicField(this, "sun", null);
|
2744
|
-
__publicField(this, "spawnSun");
|
2745
|
-
__publicField(this, "tweakPane");
|
2886
|
+
this.width = window.innerWidth;
|
2887
|
+
this.height = window.innerHeight;
|
2888
|
+
this.resolution = new Vector22(this.width, this.height);
|
2889
|
+
this.isEnvHDRI = false;
|
2890
|
+
this.bcs = BrightnessContrastSaturation;
|
2891
|
+
this.gaussGrainEffect = GaussGrainEffect;
|
2892
|
+
this.ambientLight = null;
|
2893
|
+
this.sun = null;
|
2746
2894
|
this.scene = scene;
|
2747
2895
|
this.camera = camera;
|
2748
2896
|
this.spawnSun = spawnSun;
|
2749
|
-
this.renderer = new
|
2897
|
+
this.renderer = new WebGLRenderer2({
|
2750
2898
|
powerPreference: "high-performance",
|
2751
2899
|
antialias: false,
|
2752
2900
|
stencil: false,
|
@@ -2755,9 +2903,9 @@ var Composer = class {
|
|
2755
2903
|
this.renderer.info.autoReset = false;
|
2756
2904
|
this.renderer.setSize(this.width, this.height);
|
2757
2905
|
this.renderer.shadowMap.enabled = true;
|
2758
|
-
this.renderer.shadowMap.type =
|
2759
|
-
this.renderer.toneMapping =
|
2760
|
-
this.renderer.toneMappingExposure =
|
2906
|
+
this.renderer.shadowMap.type = rendererValues.shadowMap;
|
2907
|
+
this.renderer.toneMapping = rendererValues.toneMapping;
|
2908
|
+
this.renderer.toneMappingExposure = rendererValues.exposure;
|
2761
2909
|
this.setAmbientLight();
|
2762
2910
|
this.setFog();
|
2763
2911
|
document.body.appendChild(this.renderer.domElement);
|
@@ -2766,44 +2914,59 @@ var Composer = class {
|
|
2766
2914
|
});
|
2767
2915
|
this.tweakPane = new TweakPane(this.renderer, this.scene, this.composer);
|
2768
2916
|
this.renderPass = new RenderPass(this.scene, this.camera);
|
2769
|
-
this.normalPass = new
|
2917
|
+
this.normalPass = new NormalPass2(this.scene, this.camera);
|
2918
|
+
this.normalPass.enabled = ppssaoValues.enabled;
|
2770
2919
|
this.normalTextureEffect = new TextureEffect({
|
2771
|
-
blendFunction:
|
2920
|
+
blendFunction: BlendFunction2.SKIP,
|
2772
2921
|
texture: this.normalPass.texture
|
2773
2922
|
});
|
2774
|
-
this.
|
2775
|
-
|
2776
|
-
|
2923
|
+
this.ppssaoEffect = new SSAOEffect2(this.camera, this.normalPass.texture, {
|
2924
|
+
blendFunction: ppssaoValues.blendFunction,
|
2925
|
+
distanceScaling: ppssaoValues.distanceScaling,
|
2926
|
+
depthAwareUpsampling: ppssaoValues.depthAwareUpsampling,
|
2927
|
+
samples: ppssaoValues.samples,
|
2928
|
+
rings: ppssaoValues.rings,
|
2929
|
+
luminanceInfluence: ppssaoValues.luminanceInfluence,
|
2930
|
+
radius: ppssaoValues.radius,
|
2931
|
+
intensity: ppssaoValues.intensity,
|
2932
|
+
bias: ppssaoValues.bias,
|
2933
|
+
fade: ppssaoValues.fade,
|
2934
|
+
resolutionScale: ppssaoValues.resolutionScale,
|
2935
|
+
color: new Color6().setRGB(ppssaoValues.color.r, ppssaoValues.color.g, ppssaoValues.color.b),
|
2936
|
+
worldDistanceThreshold: ppssaoValues.worldDistanceThreshold,
|
2937
|
+
worldDistanceFalloff: ppssaoValues.worldDistanceFalloff,
|
2938
|
+
worldProximityThreshold: ppssaoValues.worldProximityThreshold,
|
2939
|
+
worldProximityFalloff: ppssaoValues.worldProximityFalloff
|
2777
2940
|
});
|
2778
|
-
this.
|
2779
|
-
|
2780
|
-
|
2781
|
-
|
2782
|
-
|
2783
|
-
rings: composerValues.ssao.rings,
|
2784
|
-
luminanceInfluence: composerValues.ssao.luminanceInfluence,
|
2785
|
-
radius: composerValues.ssao.radius,
|
2786
|
-
intensity: composerValues.ssao.intensity,
|
2787
|
-
bias: composerValues.ssao.bias,
|
2788
|
-
fade: composerValues.ssao.fade,
|
2789
|
-
resolutionScale: composerValues.ssao.resolutionScale,
|
2790
|
-
color: new Color6().setRGB(composerValues.ssao.color.r, composerValues.ssao.color.g, composerValues.ssao.color.b),
|
2791
|
-
worldDistanceThreshold: composerValues.ssao.worldDistanceThreshold,
|
2792
|
-
worldDistanceFalloff: composerValues.ssao.worldDistanceFalloff,
|
2793
|
-
worldProximityThreshold: composerValues.ssao.worldProximityThreshold,
|
2794
|
-
worldProximityFalloff: composerValues.ssao.worldProximityFalloff
|
2941
|
+
this.ppssaoPass = new EffectPass2(this.camera, this.ppssaoEffect, this.normalTextureEffect);
|
2942
|
+
this.ppssaoPass.enabled = ppssaoValues.enabled;
|
2943
|
+
this.fxaaEffect = new FXAAEffect();
|
2944
|
+
this.bloomEffect = new BloomEffect({
|
2945
|
+
intensity: extrasValues.bloom
|
2795
2946
|
});
|
2947
|
+
this.n8aopass = new N8AOPostPass(this.scene, this.camera, this.width, this.height);
|
2948
|
+
this.n8aopass.configuration.aoRadius = n8ssaoValues.aoRadius;
|
2949
|
+
this.n8aopass.configuration.distanceFalloff = n8ssaoValues.distanceFalloff;
|
2950
|
+
this.n8aopass.configuration.intensity = n8ssaoValues.intensity;
|
2951
|
+
this.n8aopass.configuration.color = new Color6().setRGB(
|
2952
|
+
n8ssaoValues.color.r,
|
2953
|
+
n8ssaoValues.color.g,
|
2954
|
+
n8ssaoValues.color.b
|
2955
|
+
);
|
2956
|
+
this.n8aopass.configuration.aoSamples = n8ssaoValues.aoSamples;
|
2957
|
+
this.n8aopass.configuration.denoiseSamples = n8ssaoValues.denoiseSamples;
|
2958
|
+
this.n8aopass.configuration.denoiseRadius = n8ssaoValues.denoiseRadius;
|
2959
|
+
this.n8aopass.enabled = n8ssaoValues.enabled;
|
2796
2960
|
this.fxaaPass = new EffectPass2(this.camera, this.fxaaEffect);
|
2797
2961
|
this.bloomPass = new EffectPass2(this.camera, this.bloomEffect);
|
2798
|
-
this.
|
2799
|
-
|
2800
|
-
|
2801
|
-
|
2802
|
-
|
2803
|
-
|
2804
|
-
|
2805
|
-
|
2806
|
-
adaptationRate: composerValues.toneMapping.adaptationRate
|
2962
|
+
this.toneMappingEffect = new ToneMappingEffect({
|
2963
|
+
mode: toneMappingValues.mode,
|
2964
|
+
resolution: toneMappingValues.resolution,
|
2965
|
+
whitePoint: toneMappingValues.whitePoint,
|
2966
|
+
middleGrey: toneMappingValues.middleGrey,
|
2967
|
+
minLuminance: toneMappingValues.minLuminance,
|
2968
|
+
averageLuminance: toneMappingValues.averageLuminance,
|
2969
|
+
adaptationRate: toneMappingValues.adaptationRate
|
2807
2970
|
});
|
2808
2971
|
this.smaaEffect = new SMAAEffect({
|
2809
2972
|
preset: SMAAPreset.ULTRA,
|
@@ -2811,16 +2974,21 @@ var Composer = class {
|
|
2811
2974
|
predicationMode: PredicationMode.DEPTH
|
2812
2975
|
});
|
2813
2976
|
this.toneMappingPass = new EffectPass2(this.camera, this.toneMappingEffect);
|
2814
|
-
this.toneMappingPass.enabled =
|
2977
|
+
this.toneMappingPass.enabled = rendererValues.toneMapping === 5 || rendererValues.toneMapping === 0 ? true : false;
|
2815
2978
|
this.bcsPass = new ShaderPass(this.bcs, "tDiffuse");
|
2816
|
-
this.bcs.uniforms.brightness.value =
|
2817
|
-
this.bcs.uniforms.contrast.value =
|
2818
|
-
this.bcs.uniforms.saturation.value =
|
2979
|
+
this.bcs.uniforms.brightness.value = bcsValues.brightness;
|
2980
|
+
this.bcs.uniforms.contrast.value = bcsValues.contrast;
|
2981
|
+
this.bcs.uniforms.saturation.value = bcsValues.saturation;
|
2819
2982
|
this.gaussGrainPass = new ShaderPass(this.gaussGrainEffect, "tDiffuse");
|
2820
2983
|
this.smaaPass = new EffectPass2(this.camera, this.smaaEffect);
|
2821
2984
|
this.composer.addPass(this.renderPass);
|
2822
|
-
|
2823
|
-
|
2985
|
+
if (ppssaoValues.enabled) {
|
2986
|
+
this.composer.addPass(this.normalPass);
|
2987
|
+
this.composer.addPass(this.ppssaoPass);
|
2988
|
+
}
|
2989
|
+
if (n8ssaoValues.enabled) {
|
2990
|
+
this.composer.addPass(this.n8aopass);
|
2991
|
+
}
|
2824
2992
|
this.composer.addPass(this.fxaaPass);
|
2825
2993
|
this.composer.addPass(this.smaaPass);
|
2826
2994
|
this.composer.addPass(this.bloomPass);
|
@@ -2832,7 +3000,11 @@ var Composer = class {
|
|
2832
3000
|
this.scene.add(this.sun);
|
2833
3001
|
}
|
2834
3002
|
this.tweakPane.setupRenderPane(
|
2835
|
-
this.
|
3003
|
+
this.composer,
|
3004
|
+
this.normalPass,
|
3005
|
+
this.ppssaoEffect,
|
3006
|
+
this.ppssaoPass,
|
3007
|
+
this.n8aopass,
|
2836
3008
|
this.toneMappingEffect,
|
2837
3009
|
this.toneMappingPass,
|
2838
3010
|
this.bcs,
|
@@ -2853,8 +3025,14 @@ var Composer = class {
|
|
2853
3025
|
this.resolution = new Vector22(this.width, this.height);
|
2854
3026
|
this.composer.setSize(this.width, this.height);
|
2855
3027
|
this.renderPass.setSize(this.width, this.height);
|
2856
|
-
|
2857
|
-
|
3028
|
+
if (ppssaoValues.enabled) {
|
3029
|
+
this.normalPass.setSize(this.width, this.height);
|
3030
|
+
this.normalTextureEffect.setSize(this.width, this.height);
|
3031
|
+
this.ppssaoPass.setSize(this.width, this.height);
|
3032
|
+
}
|
3033
|
+
if (n8ssaoValues.enabled) {
|
3034
|
+
this.n8aopass.setSize(this.width, this.height);
|
3035
|
+
}
|
2858
3036
|
this.fxaaPass.setSize(this.width, this.height);
|
2859
3037
|
this.smaaPass.setSize(this.width, this.height);
|
2860
3038
|
this.bloomPass.setSize(this.width, this.height);
|
@@ -2889,7 +3067,7 @@ var Composer = class {
|
|
2889
3067
|
envMap.needsUpdate = true;
|
2890
3068
|
this.scene.environment = envMap;
|
2891
3069
|
this.scene.background = envMap;
|
2892
|
-
this.scene.backgroundIntensity =
|
3070
|
+
this.scene.backgroundIntensity = rendererValues.bgIntensity;
|
2893
3071
|
this.isEnvHDRI = true;
|
2894
3072
|
texture.dispose();
|
2895
3073
|
pmremGenerator.dispose();
|
@@ -2909,7 +3087,8 @@ var Composer = class {
|
|
2909
3087
|
fileInput.type = "file";
|
2910
3088
|
fileInput.accept = ".hdr";
|
2911
3089
|
fileInput.addEventListener("change", () => {
|
2912
|
-
|
3090
|
+
var _a;
|
3091
|
+
const file = (_a = fileInput.files) == null ? void 0 : _a[0];
|
2913
3092
|
if (!file) {
|
2914
3093
|
console.log("no file");
|
2915
3094
|
return;
|
@@ -2954,21 +3133,21 @@ var Composer = class {
|
|
2954
3133
|
import { Clock } from "three";
|
2955
3134
|
var TimeManager = class {
|
2956
3135
|
constructor() {
|
2957
|
-
|
2958
|
-
|
2959
|
-
|
2960
|
-
|
2961
|
-
|
2962
|
-
|
2963
|
-
|
2964
|
-
|
2965
|
-
|
2966
|
-
|
2967
|
-
|
2968
|
-
|
2969
|
-
|
2970
|
-
|
2971
|
-
|
3136
|
+
this.clock = new Clock();
|
3137
|
+
this.roundMagnitude = 2e5;
|
3138
|
+
this.maxAverageFrames = 150;
|
3139
|
+
this.deltaTimes = [];
|
3140
|
+
this.targetAverageDeltaTime = 0;
|
3141
|
+
this.lerpedAverageMagDelta = 0;
|
3142
|
+
this.fpsUpdateTime = 0;
|
3143
|
+
this.framesSinceLastFPSUpdate = 0;
|
3144
|
+
this.time = 0;
|
3145
|
+
this.deltaTime = 0;
|
3146
|
+
this.rawDeltaTime = 0;
|
3147
|
+
this.smoothDeltaTime = 0;
|
3148
|
+
this.frame = 0;
|
3149
|
+
this.fps = 0;
|
3150
|
+
this.averageFPS = 0;
|
2972
3151
|
}
|
2973
3152
|
update() {
|
2974
3153
|
this.rawDeltaTime = this.clock.getDelta();
|
@@ -2998,52 +3177,73 @@ var TimeManager = class {
|
|
2998
3177
|
|
2999
3178
|
// src/collisions/CollisionsManager.ts
|
3000
3179
|
import {
|
3001
|
-
|
3002
|
-
|
3180
|
+
getRelativePositionAndRotationRelativeToObject,
|
3181
|
+
MMLCollisionTrigger
|
3003
3182
|
} from "mml-web";
|
3004
3183
|
import {
|
3184
|
+
Box3 as Box32,
|
3005
3185
|
Color as Color7,
|
3006
3186
|
DoubleSide,
|
3007
3187
|
Euler,
|
3008
|
-
|
3188
|
+
Group as Group4,
|
3189
|
+
Line3 as Line32,
|
3190
|
+
Matrix4 as Matrix42,
|
3009
3191
|
Mesh as Mesh3,
|
3010
|
-
|
3192
|
+
MeshBasicMaterial as MeshBasicMaterial3,
|
3193
|
+
Ray,
|
3011
3194
|
Vector3 as Vector38
|
3012
3195
|
} from "three";
|
3196
|
+
import { VertexNormalsHelper } from "three/examples/jsm/helpers/VertexNormalsHelper.js";
|
3013
3197
|
import * as BufferGeometryUtils from "three/examples/jsm/utils/BufferGeometryUtils.js";
|
3014
3198
|
import { MeshBVH, MeshBVHVisualizer } from "three-mesh-bvh";
|
3015
3199
|
var CollisionsManager = class {
|
3016
3200
|
constructor(scene) {
|
3017
|
-
|
3018
|
-
|
3019
|
-
|
3020
|
-
|
3021
|
-
|
3022
|
-
|
3201
|
+
this.debug = false;
|
3202
|
+
this.tempVector = new Vector38();
|
3203
|
+
this.tempVector2 = new Vector38();
|
3204
|
+
this.tempVector3 = new Vector38();
|
3205
|
+
this.tempRay = new Ray();
|
3206
|
+
this.tempMatrix = new Matrix42();
|
3207
|
+
this.tempMatrix2 = new Matrix42();
|
3208
|
+
this.tempBox = new Box32();
|
3209
|
+
this.tempEuler = new Euler();
|
3210
|
+
this.tempSegment = new Line32();
|
3211
|
+
this.tempSegment2 = new Line32();
|
3212
|
+
this.collisionMeshState = /* @__PURE__ */ new Map();
|
3023
3213
|
this.scene = scene;
|
3024
3214
|
this.collisionTrigger = MMLCollisionTrigger.init();
|
3025
3215
|
}
|
3026
3216
|
raycastFirstDistance(ray) {
|
3027
3217
|
let minimumDistance = null;
|
3028
3218
|
for (const [, value] of this.collisionMeshState) {
|
3029
|
-
|
3219
|
+
this.tempRay.copy(ray).applyMatrix4(this.tempMatrix.copy(value.matrix).invert());
|
3220
|
+
const hit = value.meshBVH.raycastFirst(this.tempRay, DoubleSide);
|
3030
3221
|
if (hit) {
|
3031
|
-
|
3032
|
-
|
3222
|
+
this.tempSegment.start.copy(this.tempRay.origin);
|
3223
|
+
this.tempSegment.end.copy(hit.point);
|
3224
|
+
this.tempSegment.applyMatrix4(value.matrix);
|
3225
|
+
const dist = this.tempSegment.distance();
|
3226
|
+
if (minimumDistance === null || dist < minimumDistance) {
|
3227
|
+
minimumDistance = dist;
|
3033
3228
|
}
|
3034
3229
|
}
|
3035
3230
|
}
|
3036
3231
|
return minimumDistance;
|
3037
3232
|
}
|
3038
|
-
createCollisionMeshState(group) {
|
3233
|
+
createCollisionMeshState(group, trackCollisions) {
|
3039
3234
|
const geometries = [];
|
3235
|
+
group.updateWorldMatrix(true, false);
|
3236
|
+
const invertedRootMatrix = this.tempMatrix.copy(group.matrixWorld).invert();
|
3040
3237
|
group.traverse((child) => {
|
3041
3238
|
if (child.type === "Mesh") {
|
3042
3239
|
const mesh = child;
|
3043
|
-
mesh.localToWorld(new Vector38());
|
3044
|
-
mesh.updateMatrixWorld();
|
3045
3240
|
const clonedGeometry = mesh.geometry.clone();
|
3046
|
-
|
3241
|
+
if (child !== group) {
|
3242
|
+
mesh.updateWorldMatrix(true, false);
|
3243
|
+
clonedGeometry.applyMatrix4(
|
3244
|
+
this.tempMatrix2.multiplyMatrices(invertedRootMatrix, mesh.matrixWorld)
|
3245
|
+
);
|
3246
|
+
}
|
3047
3247
|
for (const key in clonedGeometry.attributes) {
|
3048
3248
|
if (key !== "position") {
|
3049
3249
|
clonedGeometry.deleteAttribute(key);
|
@@ -3056,85 +3256,134 @@ var CollisionsManager = class {
|
|
3056
3256
|
}
|
3057
3257
|
}
|
3058
3258
|
});
|
3059
|
-
const newBufferGeometry = BufferGeometryUtils.mergeGeometries(geometries);
|
3259
|
+
const newBufferGeometry = BufferGeometryUtils.mergeGeometries(geometries, false);
|
3260
|
+
newBufferGeometry.computeVertexNormals();
|
3060
3261
|
const meshBVH = new MeshBVH(newBufferGeometry);
|
3061
|
-
|
3062
|
-
|
3063
|
-
|
3064
|
-
|
3065
|
-
|
3066
|
-
|
3067
|
-
)
|
3068
|
-
|
3069
|
-
|
3070
|
-
|
3071
|
-
|
3072
|
-
|
3262
|
+
const meshState = {
|
3263
|
+
source: group,
|
3264
|
+
meshBVH,
|
3265
|
+
matrix: group.matrixWorld.clone(),
|
3266
|
+
trackCollisions
|
3267
|
+
};
|
3268
|
+
if (this.debug) {
|
3269
|
+
newBufferGeometry.boundsTree = meshBVH;
|
3270
|
+
const wireframeMesh = new Mesh3(newBufferGeometry, new MeshBasicMaterial3({ wireframe: true }));
|
3271
|
+
const normalsHelper = new VertexNormalsHelper(wireframeMesh, 0.25, 65280);
|
3272
|
+
const visualizer = new MeshBVHVisualizer(wireframeMesh, 4);
|
3273
|
+
visualizer.edgeMaterial.color = new Color7("blue");
|
3274
|
+
const debugGroup = new Group4();
|
3275
|
+
debugGroup.add(wireframeMesh, normalsHelper, visualizer);
|
3276
|
+
group.matrixWorld.decompose(debugGroup.position, debugGroup.quaternion, debugGroup.scale);
|
3277
|
+
visualizer.update();
|
3278
|
+
meshState.debugGroup = debugGroup;
|
3279
|
+
}
|
3280
|
+
return meshState;
|
3073
3281
|
}
|
3074
3282
|
addMeshesGroup(group, mElement) {
|
3075
3283
|
if (mElement) {
|
3076
3284
|
this.collisionTrigger.addCollider(group, mElement);
|
3077
3285
|
}
|
3078
|
-
const meshState = this.createCollisionMeshState(group);
|
3079
|
-
if (meshState.
|
3080
|
-
this.scene.add(meshState.
|
3286
|
+
const meshState = this.createCollisionMeshState(group, mElement !== void 0);
|
3287
|
+
if (meshState.debugGroup) {
|
3288
|
+
this.scene.add(meshState.debugGroup);
|
3081
3289
|
}
|
3082
3290
|
this.collisionMeshState.set(group, meshState);
|
3083
3291
|
}
|
3084
3292
|
updateMeshesGroup(group) {
|
3085
3293
|
const meshState = this.collisionMeshState.get(group);
|
3086
3294
|
if (meshState) {
|
3087
|
-
|
3088
|
-
|
3089
|
-
|
3090
|
-
|
3091
|
-
|
3092
|
-
|
3295
|
+
group.updateWorldMatrix(true, false);
|
3296
|
+
meshState.matrix.copy(group.matrixWorld);
|
3297
|
+
if (meshState.debugGroup) {
|
3298
|
+
group.matrixWorld.decompose(
|
3299
|
+
meshState.debugGroup.position,
|
3300
|
+
meshState.debugGroup.quaternion,
|
3301
|
+
meshState.debugGroup.scale
|
3302
|
+
);
|
3093
3303
|
}
|
3094
|
-
this.collisionMeshState.set(group, newMeshState);
|
3095
3304
|
}
|
3096
3305
|
}
|
3097
3306
|
removeMeshesGroup(group) {
|
3098
3307
|
this.collisionTrigger.removeCollider(group);
|
3099
3308
|
const meshState = this.collisionMeshState.get(group);
|
3100
3309
|
if (meshState) {
|
3101
|
-
if (meshState.
|
3102
|
-
this.scene.remove(meshState.
|
3310
|
+
if (meshState.debugGroup) {
|
3311
|
+
this.scene.remove(meshState.debugGroup);
|
3103
3312
|
}
|
3104
3313
|
this.collisionMeshState.delete(group);
|
3105
3314
|
}
|
3106
3315
|
}
|
3107
|
-
applyCollider(
|
3316
|
+
applyCollider(worldBasedCapsuleSegment, capsuleRadius, meshState) {
|
3317
|
+
const meshMatrix = this.tempMatrix.copy(meshState.matrix).invert();
|
3318
|
+
const meshRelativeCapsuleBoundingBox = this.tempBox;
|
3319
|
+
meshRelativeCapsuleBoundingBox.makeEmpty();
|
3320
|
+
meshRelativeCapsuleBoundingBox.expandByPoint(worldBasedCapsuleSegment.start);
|
3321
|
+
meshRelativeCapsuleBoundingBox.expandByPoint(worldBasedCapsuleSegment.end);
|
3322
|
+
meshRelativeCapsuleBoundingBox.min.subScalar(capsuleRadius);
|
3323
|
+
meshRelativeCapsuleBoundingBox.max.addScalar(capsuleRadius);
|
3324
|
+
meshRelativeCapsuleBoundingBox.applyMatrix4(meshMatrix);
|
3325
|
+
const meshRelativeCapsuleSegment = this.tempSegment;
|
3326
|
+
meshRelativeCapsuleSegment.start.copy(worldBasedCapsuleSegment.start);
|
3327
|
+
meshRelativeCapsuleSegment.end.copy(worldBasedCapsuleSegment.end);
|
3328
|
+
meshRelativeCapsuleSegment.applyMatrix4(meshMatrix);
|
3329
|
+
const initialMeshRelativeCapsuleSegmentStart = this.tempVector3.copy(
|
3330
|
+
meshRelativeCapsuleSegment.start
|
3331
|
+
);
|
3108
3332
|
let collisionPosition = null;
|
3109
3333
|
meshState.meshBVH.shapecast({
|
3110
|
-
intersectsBounds: (
|
3111
|
-
|
3112
|
-
|
3113
|
-
|
3114
|
-
const
|
3115
|
-
|
3116
|
-
|
3117
|
-
|
3118
|
-
|
3119
|
-
|
3120
|
-
|
3334
|
+
intersectsBounds: (meshBox) => {
|
3335
|
+
return meshBox.intersectsBox(meshRelativeCapsuleBoundingBox);
|
3336
|
+
},
|
3337
|
+
intersectsTriangle: (meshTriangle) => {
|
3338
|
+
const closestPointOnTriangle = this.tempVector;
|
3339
|
+
const closestPointOnSegment = this.tempVector2;
|
3340
|
+
meshTriangle.closestPointToSegment(
|
3341
|
+
meshRelativeCapsuleSegment,
|
3342
|
+
closestPointOnTriangle,
|
3343
|
+
closestPointOnSegment
|
3344
|
+
);
|
3345
|
+
const intersectionSegment = this.tempSegment2;
|
3346
|
+
intersectionSegment.start.copy(closestPointOnTriangle);
|
3347
|
+
intersectionSegment.end.copy(closestPointOnSegment);
|
3348
|
+
const modelReferenceDistance = intersectionSegment.distance();
|
3349
|
+
intersectionSegment.applyMatrix4(meshState.matrix);
|
3350
|
+
const realDistance = intersectionSegment.distance();
|
3351
|
+
if (realDistance < capsuleRadius) {
|
3352
|
+
if (!collisionPosition) {
|
3353
|
+
collisionPosition = new Vector38().copy(closestPointOnSegment);
|
3354
|
+
}
|
3355
|
+
const ratio = realDistance / modelReferenceDistance;
|
3356
|
+
const realDepth = capsuleRadius - realDistance;
|
3357
|
+
const modelDepth = realDepth / ratio;
|
3358
|
+
const direction = closestPointOnSegment.sub(closestPointOnTriangle).normalize();
|
3359
|
+
meshRelativeCapsuleSegment.start.addScaledVector(direction, modelDepth);
|
3360
|
+
meshRelativeCapsuleSegment.end.addScaledVector(direction, modelDepth);
|
3121
3361
|
}
|
3122
3362
|
}
|
3123
3363
|
});
|
3364
|
+
if (collisionPosition) {
|
3365
|
+
const delta = this.tempVector.copy(meshRelativeCapsuleSegment.start).sub(initialMeshRelativeCapsuleSegmentStart);
|
3366
|
+
this.tempMatrix.copy(meshState.matrix).setPosition(0, 0, 0);
|
3367
|
+
delta.applyMatrix4(this.tempMatrix);
|
3368
|
+
if (!(isNaN(delta.x) && isNaN(delta.y) && isNaN(delta.z))) {
|
3369
|
+
worldBasedCapsuleSegment.start.add(delta);
|
3370
|
+
worldBasedCapsuleSegment.end.add(delta);
|
3371
|
+
}
|
3372
|
+
}
|
3124
3373
|
return collisionPosition;
|
3125
3374
|
}
|
3126
|
-
applyColliders(tempSegment, radius
|
3375
|
+
applyColliders(tempSegment, radius) {
|
3127
3376
|
let collidedElements = null;
|
3128
3377
|
for (const meshState of this.collisionMeshState.values()) {
|
3129
|
-
const collisionPosition = this.applyCollider(tempSegment, radius,
|
3130
|
-
if (collisionPosition) {
|
3378
|
+
const collisionPosition = this.applyCollider(tempSegment, radius, meshState);
|
3379
|
+
if (collisionPosition && meshState.trackCollisions) {
|
3131
3380
|
if (collidedElements === null) {
|
3132
3381
|
collidedElements = /* @__PURE__ */ new Map();
|
3133
3382
|
}
|
3134
3383
|
const relativePosition = getRelativePositionAndRotationRelativeToObject(
|
3135
3384
|
{
|
3136
3385
|
position: collisionPosition,
|
3137
|
-
rotation:
|
3386
|
+
rotation: this.tempEuler.set(0, 0, 0)
|
3138
3387
|
},
|
3139
3388
|
meshState.source
|
3140
3389
|
);
|