@@ -241,31 +241,32 @@ export class Viewer {
241
241
renderer . xr . setFoveation ( 0 ) ;
242
242
}
243
243
244
+ // Temp Disable : WebXR
244
245
// initialize phyics
245
246
// we have this weird construct because ammo is loaded globally
246
247
// and things get funny with hot reloading
247
- if ( typeof window . Ammo === 'undefined' ) {
248
- console . error ( "Ammo not found" ) ;
249
- } else if ( typeof window . Ammo === 'function' ) {
250
- this . ammo = await window . Ammo ( ) ;
251
- } else {
252
- this . ammo = window . Ammo ;
253
- }
254
- if ( this . ammo ) {
255
- this . collisionConfiguration = new this . ammo . btDefaultCollisionConfiguration ( ) ;
256
- this . dispatcher = new this . ammo . btCollisionDispatcher ( this . collisionConfiguration ) ;
257
- this . broadphase = new this . ammo . btDbvtBroadphase ( ) ;
258
- this . solver = new this . ammo . btSequentialImpulseConstraintSolver ( ) ;
259
- this . physicsWorld = new this . ammo . btDiscreteDynamicsWorld (
260
- this . dispatcher ,
261
- this . broadphase ,
262
- this . solver ,
263
- this . collisionConfiguration
264
- ) ;
265
- this . physicsWorld . setGravity ( new this . ammo . btVector3 ( 0 , - 7.8 , 0 ) ) ;
266
- this . transformAux1 = new this . ammo . btTransform ( ) ;
267
- this . tempBtVec3_1 = new this . ammo . btVector3 ( 0 , 0 , 0 ) ;
268
- }
248
+ // if (typeof window.Ammo === 'undefined') {
249
+ // console.error("Ammo not found");
250
+ // } else if (typeof window.Ammo === 'function') {
251
+ // this.ammo = await window.Ammo();
252
+ // } else {
253
+ // this.ammo = window.Ammo;
254
+ // }
255
+ // if (this.ammo) {
256
+ // this.collisionConfiguration = new this.ammo.btDefaultCollisionConfiguration();
257
+ // this.dispatcher = new this.ammo.btCollisionDispatcher(this.collisionConfiguration);
258
+ // this.broadphase = new this.ammo.btDbvtBroadphase();
259
+ // this.solver = new this.ammo.btSequentialImpulseConstraintSolver();
260
+ // this.physicsWorld = new this.ammo.btDiscreteDynamicsWorld(
261
+ // this.dispatcher,
262
+ // this.broadphase,
263
+ // this.solver,
264
+ // this.collisionConfiguration
265
+ // );
266
+ // this.physicsWorld.setGravity(new this.ammo.btVector3(0, -7.8, 0));
267
+ // this.transformAux1 = new this.ammo.btTransform();
268
+ // this.tempBtVec3_1 = new this.ammo.btVector3(0, 0, 0);
269
+ // }
269
270
270
271
const scene = new THREE . Scene ( ) ;
271
272
this . scene = scene ;
@@ -478,6 +479,7 @@ export class Viewer {
478
479
new Stats . Panel ( "stats_ms" , "#8f8" , "#212" ) ,
479
480
) ;
480
481
482
+ // Temp Disable : WebXR
481
483
const statsMesh = new HTMLMesh ( stats . dom ) ;
482
484
this . statsMesh = statsMesh ;
483
485
@@ -490,67 +492,69 @@ export class Viewer {
490
492
this . bvhWorker = new GenerateMeshBVHWorker ( ) ;
491
493
this . raycaster . firstHitOnly = true ;
492
494
495
+ // Temp Disable : WebXR
493
496
// add joint / hand meshes
494
- {
495
- const geometry = new THREE . BoxGeometry ( 0.005 , 0.005 , 0.005 ) ;
496
- const material = new THREE . MeshStandardMaterial ( {
497
- color : 0xffffff ,
498
- roughness : 1.0 ,
499
- metalness : 0.0 ,
500
- } ) ;
501
-
502
- const mesh = new THREE . Mesh ( geometry , material ) ;
503
-
504
- const lineGeometry = new THREE . BufferGeometry ( ) . setFromPoints ( [
505
- new THREE . Vector3 ( 0 , 0 , 0 ) ,
506
- new THREE . Vector3 ( 0 , - 1 , 0 ) ,
507
- ] ) ;
508
-
509
- const line = new THREE . Line ( lineGeometry ) ;
510
- line . scale . z = 5 ;
511
-
512
- for ( const _ of joints ) {
513
- // Make joint mesh invisible
514
- const clonedMesh = mesh . clone ( ) ;
515
- clonedMesh . visible = false ;
516
-
517
- this . jointMeshes1 . push ( clonedMesh ) ;
518
- this . jointMeshes2 . push ( clonedMesh ) ;
519
- // this.jointMeshes1[this.jointMeshes1.length - 1].add(line.clone());
520
- // this.jointMeshes2[this.jointMeshes2.length - 1].add(line.clone());
521
-
522
- this . handGroup . add ( this . jointMeshes1 [ this . jointMeshes1 . length - 1 ] ) ;
523
- this . handGroup . add ( this . jointMeshes2 [ this . jointMeshes2 . length - 1 ] ) ;
524
- }
525
-
526
- this . handGroup . visible = false ;
527
- scene . add ( this . handGroup ) ;
528
- }
497
+ // {
498
+ // const geometry = new THREE.BoxGeometry(0.005, 0.005, 0.005);
499
+ // const material = new THREE.MeshStandardMaterial({
500
+ // color: 0xffffff,
501
+ // roughness: 1.0,
502
+ // metalness: 0.0,
503
+ // });
504
+
505
+ // const mesh = new THREE.Mesh(geometry, material);
506
+
507
+ // const lineGeometry = new THREE.BufferGeometry().setFromPoints([
508
+ // new THREE.Vector3(0, 0, 0),
509
+ // new THREE.Vector3(0, -1, 0),
510
+ // ]);
511
+
512
+ // const line = new THREE.Line(lineGeometry);
513
+ // line.scale.z = 5;
514
+
515
+ // for (const _ of joints) {
516
+ // // Make joint mesh invisible
517
+ // const clonedMesh = mesh.clone();
518
+ // clonedMesh.visible = false;
519
+
520
+ // this.jointMeshes1.push(clonedMesh);
521
+ // this.jointMeshes2.push(clonedMesh);
522
+ // // this.jointMeshes1[this.jointMeshes1.length - 1].add(line.clone());
523
+ // // this.jointMeshes2[this.jointMeshes2.length - 1].add(line.clone());
524
+
525
+ // this.handGroup.add(this.jointMeshes1[this.jointMeshes1.length - 1]);
526
+ // this.handGroup.add(this.jointMeshes2[this.jointMeshes2.length - 1]);
527
+ // }
528
+
529
+ // this.handGroup.visible = false;
530
+ // scene.add(this.handGroup);
531
+ // }
529
532
530
- {
531
- const geometry = new THREE . SphereGeometry ( 1 , 16 , 16 ) ;
532
- const material = new THREE . MeshBasicMaterial ( {
533
- color : 0xffff00 ,
534
- transparent : true ,
535
- opacity : 0.5 ,
536
- } ) ;
537
- const mesh = new THREE . Mesh ( geometry , material ) ;
538
- this . closestPart1 = mesh . clone ( ) ;
539
- this . closestPart2 = mesh . clone ( ) ;
540
- this . closestPart1 . visible = false ;
541
- this . closestPart2 . visible = false ;
542
- scene . add ( this . closestPart1 ) ;
543
- scene . add ( this . closestPart2 ) ;
544
- }
533
+ // {
534
+ // const geometry = new THREE.SphereGeometry(1, 16, 16);
535
+ // const material = new THREE.MeshBasicMaterial({
536
+ // color: 0xffff00,
537
+ // transparent: true,
538
+ // opacity: 0.5,
539
+ // });
540
+ // const mesh = new THREE.Mesh(geometry, material);
541
+ // this.closestPart1 = mesh.clone();
542
+ // this.closestPart2 = mesh.clone();
543
+ // this.closestPart1.visible = false;
544
+ // this.closestPart2.visible = false;
545
+ // scene.add(this.closestPart1);
546
+ // scene.add(this.closestPart2);
547
+ // }
545
548
546
- this . particleRenderer = new BatchedParticleRenderer ( ) ;
547
- scene . add ( this . particleRenderer ) ;
549
+ // this.particleRenderer = new BatchedParticleRenderer();
550
+ // scene.add(this.particleRenderer);
548
551
549
- new QuarksLoader ( ) . load ( 'particles/cartoon_star_field' , ( obj ) => {
550
- this . particleCartoonStarField = obj ;
552
+ // Temp Disable : WebXR
553
+ // new QuarksLoader().load('particles/cartoon_star_field', (obj) => {
554
+ // this.particleCartoonStarField = obj;
551
555
552
- this . newParticleInstance ( ) ;
553
- } ) ;
556
+ // this.newParticleInstance();
557
+ // });
554
558
555
559
window . addEventListener ( "resize" , ( ) => {
556
560
this . resize ( ) ;
@@ -676,17 +680,20 @@ export class Viewer {
676
680
if ( this . model ?. vrm ) {
677
681
this . unloadVRM ( ) ;
678
682
}
679
- setLoadingProgress ( "Loading VRM" ) ;
683
+ // Temp Disable : WebXR
684
+ // setLoadingProgress("Loading VRM");
680
685
681
686
// gltf and vrm
682
687
this . model = new Model ( this . camera || new THREE . Object3D ( ) ) ;
683
688
await this . model . loadVRM ( url , setLoadingProgress ) ;
684
- setLoadingProgress ( "VRM loaded" ) ;
689
+ // Temp Disable : WebXR
690
+ // setLoadingProgress("VRM loaded");
685
691
if ( ! this . model ?. vrm ) return ;
686
692
693
+ // Temp Disable : WebXR
687
694
// build bvh
688
- this . modelBVHGenerator = new StaticGeometryGenerator ( this . model . vrm . scene ) ;
689
- setLoadingProgress ( "Creating geometry" ) ;
695
+ // this.modelBVHGenerator = new StaticGeometryGenerator(this.model.vrm.scene);
696
+ // setLoadingProgress("Creating geometry");
690
697
691
698
// TODO show during debug mode
692
699
const wireframeMaterial = new THREE . MeshBasicMaterial ( {
@@ -714,7 +721,8 @@ export class Viewer {
714
721
715
722
// TODO since poses still work for procedural animation, we can use this to debug
716
723
if ( config ( "animation_procedural" ) !== "true" ) {
717
- setLoadingProgress ( "Loading animation" ) ;
724
+ // Temp Disable : WebXR
725
+ // setLoadingProgress("Loading animation");
718
726
const animation =
719
727
config ( "animation_url" ) . indexOf ( "vrma" ) > 0
720
728
? await loadVRMAnimation ( config ( "animation_url" ) )
@@ -725,23 +733,26 @@ export class Viewer {
725
733
}
726
734
}
727
735
728
- this . model ?. vrm ?. springBoneManager ?. joints . forEach ( ( e ) => {
729
- const geometry = new THREE . SphereGeometry ( 0.07 , 16 , 16 ) ;
730
- const material = new THREE . MeshBasicMaterial ( {
731
- color : 0xffff00 ,
732
- transparent : true ,
733
- opacity : 0.5 ,
734
- depthWrite : false ,
735
- } ) ;
736
- const mesh = new THREE . Mesh ( geometry , material ) ;
737
- mesh . position . copy ( e . bone . getWorldPosition ( new THREE . Vector3 ( ) ) ) ;
738
- // this.scene!.add(mesh);
739
- } ) ;
736
+ // Temp Disable : WebXR
737
+ // this.model?.vrm?.springBoneManager?.joints.forEach((e) => {
738
+ // const geometry = new THREE.SphereGeometry(0.07, 16, 16);
739
+ // const material = new THREE.MeshBasicMaterial({
740
+ // color: 0xffff00,
741
+ // transparent: true,
742
+ // opacity: 0.5,
743
+ // depthWrite: false,
744
+ // });
745
+ // const mesh = new THREE.Mesh(geometry, material);
746
+ // mesh.position.copy(e.bone.getWorldPosition(new THREE.Vector3()));
747
+ // // this.scene!.add(mesh);
748
+ // });
740
749
741
- setLoadingProgress ( "Regenerating BVH" ) ;
742
- await this . regenerateBVHForModel ( ) ;
750
+ // Temp Disable : WebXR
751
+ // setLoadingProgress("Regenerating BVH");
752
+ // await this.regenerateBVHForModel();
743
753
744
- setLoadingProgress ( "Complete" ) ;
754
+ // Temp Disable : WebXR
755
+ // setLoadingProgress("Complete");
745
756
746
757
// HACK: Adjust the camera position after playback because the origin of the animation is offset
747
758
this . resetCamera ( ) ;
@@ -1239,14 +1250,15 @@ export class Viewer {
1239
1250
// console.error("scenario update error", e);
1240
1251
// }
1241
1252
// this.scenarioMsPanel.update(performance.now() - ptime, 100);
1242
-
1243
- ptime = performance . now ( ) ;
1244
- try {
1245
- this . physicsWorld . stepSimulation ( delta , 10 ) ;
1246
- } catch ( e ) {
1247
- console . error ( "physics update error" , e ) ;
1248
- }
1249
- this . physicsMsPanel . update ( performance . now ( ) - ptime , 100 ) ;
1253
+
1254
+ // Temp Disable : WebXR
1255
+ // ptime = performance.now();
1256
+ // try {
1257
+ // this.physicsWorld.stepSimulation(delta, 10);
1258
+ // } catch (e) {
1259
+ // console.error("physics update error", e);
1260
+ // }
1261
+ // this.physicsMsPanel.update(performance.now() - ptime, 100);
1250
1262
1251
1263
ptime = performance . now ( ) ;
1252
1264
try {
0 commit comments