Skip to content

Commit a7c7908

Browse files
authored
Merge pull request #153 from 4lukexp/disable-xr
WebXR
2 parents f391a97 + c7c644c commit a7c7908

File tree

2 files changed

+124
-110
lines changed

2 files changed

+124
-110
lines changed

src/features/vrmViewer/model.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ export class Model {
140140
loader.load(
141141
url,
142142
async (gltf) => {
143-
setLoadingProgress("Processing VRM");
143+
// Temp Disable : WebXR
144+
// setLoadingProgress("Processing VRM");
144145

145146
/*
146147
{
@@ -224,9 +225,10 @@ export class Model {
224225
resolve();
225226
},
226227
(xhr) => {
227-
setLoadingProgress(
228-
`${Math.floor((xhr.loaded / xhr.total) * 10000) / 100}% loaded`,
229-
);
228+
// Temp Disable : WebXR
229+
// setLoadingProgress(
230+
// `${Math.floor((xhr.loaded / xhr.total) * 10000) / 100}% loaded`,
231+
// );
230232
},
231233
(error) => {
232234
reject(error);

src/features/vrmViewer/viewer.ts

Lines changed: 118 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -241,31 +241,32 @@ export class Viewer {
241241
renderer.xr.setFoveation(0);
242242
}
243243

244+
// Temp Disable : WebXR
244245
// initialize phyics
245246
// we have this weird construct because ammo is loaded globally
246247
// 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+
// }
269270

270271
const scene = new THREE.Scene();
271272
this.scene = scene;
@@ -478,6 +479,7 @@ export class Viewer {
478479
new Stats.Panel("stats_ms", "#8f8", "#212"),
479480
);
480481

482+
// Temp Disable : WebXR
481483
const statsMesh = new HTMLMesh(stats.dom);
482484
this.statsMesh = statsMesh;
483485

@@ -490,67 +492,69 @@ export class Viewer {
490492
this.bvhWorker = new GenerateMeshBVHWorker();
491493
this.raycaster.firstHitOnly = true;
492494

495+
// Temp Disable : WebXR
493496
// 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+
// }
529532

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+
// }
545548

546-
this.particleRenderer = new BatchedParticleRenderer();
547-
scene.add(this.particleRenderer);
549+
// this.particleRenderer = new BatchedParticleRenderer();
550+
// scene.add(this.particleRenderer);
548551

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;
551555

552-
this.newParticleInstance();
553-
});
556+
// this.newParticleInstance();
557+
// });
554558

555559
window.addEventListener("resize", () => {
556560
this.resize();
@@ -676,17 +680,20 @@ export class Viewer {
676680
if (this.model?.vrm) {
677681
this.unloadVRM();
678682
}
679-
setLoadingProgress("Loading VRM");
683+
// Temp Disable : WebXR
684+
// setLoadingProgress("Loading VRM");
680685

681686
// gltf and vrm
682687
this.model = new Model(this.camera || new THREE.Object3D());
683688
await this.model.loadVRM(url, setLoadingProgress);
684-
setLoadingProgress("VRM loaded");
689+
// Temp Disable : WebXR
690+
// setLoadingProgress("VRM loaded");
685691
if (!this.model?.vrm) return;
686692

693+
// Temp Disable : WebXR
687694
// 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");
690697

691698
// TODO show during debug mode
692699
const wireframeMaterial = new THREE.MeshBasicMaterial({
@@ -714,7 +721,8 @@ export class Viewer {
714721

715722
// TODO since poses still work for procedural animation, we can use this to debug
716723
if (config("animation_procedural") !== "true") {
717-
setLoadingProgress("Loading animation");
724+
// Temp Disable : WebXR
725+
// setLoadingProgress("Loading animation");
718726
const animation =
719727
config("animation_url").indexOf("vrma") > 0
720728
? await loadVRMAnimation(config("animation_url"))
@@ -725,23 +733,26 @@ export class Viewer {
725733
}
726734
}
727735

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+
// });
740749

741-
setLoadingProgress("Regenerating BVH");
742-
await this.regenerateBVHForModel();
750+
// Temp Disable : WebXR
751+
// setLoadingProgress("Regenerating BVH");
752+
// await this.regenerateBVHForModel();
743753

744-
setLoadingProgress("Complete");
754+
// Temp Disable : WebXR
755+
// setLoadingProgress("Complete");
745756

746757
// HACK: Adjust the camera position after playback because the origin of the animation is offset
747758
this.resetCamera();
@@ -1239,14 +1250,15 @@ export class Viewer {
12391250
// console.error("scenario update error", e);
12401251
// }
12411252
// 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);
12501262

12511263
ptime = performance.now();
12521264
try {

0 commit comments

Comments
 (0)