1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-07-30 05:24:37 +02:00
This commit is contained in:
syuilo
2026-07-28 14:56:51 +09:00
parent 6dffa2f59a
commit 4682180c8b
3 changed files with 29 additions and 20 deletions

View File

@@ -46,6 +46,7 @@ export class WorldEngine extends EngineBase<{
private show2dAvatarOnAvatar: boolean;
private envManager: WorldEnvManager | null = null;
private inited = false;
private isGodMode = false;
constructor(options: {
engine: BABYLON.WebGPUEngine;
@@ -107,20 +108,24 @@ export class WorldEngine extends EngineBase<{
this.camera.maxZ = cm(1000);
this.camera.fov = this.fov;
this.camera.ellipsoid = new BABYLON.Vector3(cm(15), cm(65), cm(15));
this.camera.checkCollisions = true;
this.camera.applyGravity = true;
this.camera.needMoveForGravity = true;
if (!this.isGodMode) {
this.camera.checkCollisions = true;
this.camera.applyGravity = true;
this.camera.needMoveForGravity = true;
}
this.camera.inputs.clear();
if (options.useVirtualJoystick) {
this.camera.inputs.add(new FreeCameraManualInput(this.scene, {
moveSensitivity: 0.015 * WORLD_SCALE,
moveSensitivity: 0.02 * WORLD_SCALE,
rotationSensitivity: 0.0007,
isGodMode: this.isGodMode,
}));
this.camera.inertia = 0.75;
} else {
this.camera.inputs.add(new FreeCameraManualInput(this.scene, {
moveSensitivity: 0.002 * WORLD_SCALE,
moveSensitivity: 0.003 * WORLD_SCALE,
rotationSensitivity: 0.0003,
isGodMode: this.isGodMode,
}));
}

View File

@@ -333,7 +333,7 @@ export class LobbyEnvManager extends WorldEnvManager {
adMesh.parent = adRoot;
adMesh.position = new BABYLON.Vector3(cm(0), cm(0), cm(7500));
const tex = new BABYLON.Texture('/client-assets/world/envs/lobby/dummy-ads/angry_ai.png', this.engine.scene);
const tex = new BABYLON.Texture('http://syu-win.local:3000/files/e67bd2ec-a217-4c17-a222-596dcdbd0e57', this.engine.scene);
const adMat = new BABYLON.StandardMaterial(`ad_${j}_${i}_mat`, this.engine.scene);
adMat.emissiveTexture = tex;
adMat.disableLighting = true;
@@ -396,11 +396,11 @@ export class LobbyEnvManager extends WorldEnvManager {
const videoEl = document.createElement('video');
videoEl.crossOrigin = 'anonymous';
videoEl.src = 'http://syu-win.localhost:3000/files/cf5bca47-8b4b-42d2-b782-0d6ca67187cf';
//videoEl.src = 'http://syu-win.local:3000/files/931c02c3-6238-4c29-9371-06bab78950bb';
//const hls = new Hls();
//hls.loadSource('https://tvs.misskey.io/official/hq-beta/ts:abr.m3u8');
//hls.attachMedia(videoEl);
const hls = new Hls();
hls.loadSource('https://tvs.misskey.io/official/hq-beta/ts:abr.m3u8');
hls.attachMedia(videoEl);
this.timer.setTimeout(() => {
const tex = new BABYLON.VideoTexture('', videoEl, this.engine.scene, true, true);

View File

@@ -677,14 +677,17 @@ export class FreeCameraManualInput implements BABYLON.ICameraInput<BABYLON.FreeC
private moveSensitivity: number;
private rotationSensitivity: number;
private moveVector = BABYLON.Vector3.Zero();
private isGodMode: boolean;
constructor(scene: BABYLON.Scene, options: {
moveSensitivity?: number;
rotationSensitivity?: number;
isGodMode?: boolean;
}) {
this.scene = scene;
this.moveSensitivity = options.moveSensitivity ?? 0.01;
this.rotationSensitivity = options.rotationSensitivity ?? 0.01;
this.isGodMode = options.isGodMode ?? false;
}
getClassName = () => this.constructor.name;
@@ -712,17 +715,18 @@ export class FreeCameraManualInput implements BABYLON.ICameraInput<BABYLON.FreeC
checkInputs() {
const ratio = this.scene.getAnimationRatio();
this.camera.cameraDirection.addInPlace(
BABYLON.Vector3.TransformCoordinates(this.moveVector.scale(ratio), BABYLON.Matrix.RotationY(this.camera.rotation.y)),
);
//const engine = this.camera.getEngine();
//const v = this.moveVector.scale(Math.sqrt(engine.getDeltaTime() / (engine.getFps() * 100.0)));
//console.log(v);
//this.camera._localDirection.copyFromFloats(v.x, v.y, v.z);
//this.camera.getViewMatrix().invertToRef(this.camera._cameraTransformMatrix);
//BABYLON.Vector3.TransformNormalToRef(this.camera._localDirection, this.camera._cameraTransformMatrix, this.camera._transformedDirection);
//this.camera.cameraDirection.addInPlace(this.camera._transformedDirection);
if (this.isGodMode) {
const v = this.moveVector.scale(ratio);
this.camera._localDirection.copyFromFloats(v.x, v.y, v.z);
this.camera.getViewMatrix().invertToRef(this.camera._cameraTransformMatrix);
BABYLON.Vector3.TransformNormalToRef(this.camera._localDirection, this.camera._cameraTransformMatrix, this.camera._transformedDirection);
this.camera.cameraDirection.addInPlace(this.camera._transformedDirection);
} else {
this.camera.cameraDirection.addInPlace(
BABYLON.Vector3.TransformCoordinates(this.moveVector.scale(ratio), BABYLON.Matrix.RotationY(this.camera.rotation.y)),
);
}
}
}