Skip to content

Commit 01225d3

Browse files
committed
fix(update): many updates
1 parent 3e99a3a commit 01225d3

10 files changed

Lines changed: 207 additions & 642 deletions

File tree

packages/app/components/dialogs/CreateUser.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ function onSubmit(
146146
characterType: characterType.value,
147147
skin: skin.value,
148148
graphic: {
149-
shadowQuality: ShadowQuality.MEDIUM
149+
shadowQuality: ShadowQuality.LOW
150150
}
151151
});
152152
}

packages/app/lib/classes/Renderer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export default class Renderer<
148148

149149
renderer.shadowMap.autoUpdate = true;
150150
this.renderer = renderer;
151-
this.setShadowQuality(ShadowQuality.MEDIUM);
151+
this.setShadowQuality(ShadowQuality.LOW);
152152

153153
// renderer.toneMapping = ACESFilmicToneMapping;
154154

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import type {
2+
UnitConstructorOptions,
3+
UnitModuleList,
4+
UnitModules,
5+
UnitOptions
6+
} from '../Unit';
7+
import LightUnitModule from '../unitModule/Light';
8+
import Unit from '../Unit';
9+
10+
export type LightUnitModules = UnitModules & {
11+
light: LightUnitModule;
12+
};
13+
export type LightUnitModuleList = (typeof LightUnitModule)[] & UnitModuleList;
14+
15+
export default class LightUnit<
16+
Options extends UnitOptions = UnitOptions,
17+
Modules extends LightUnitModules = LightUnitModules,
18+
ModuleList extends LightUnitModuleList = LightUnitModuleList
19+
> extends Unit<Options, Modules, ModuleList> {
20+
constructor(
21+
options: UnitConstructorOptions<Options>,
22+
moduleList: ModuleList = [] as unknown as ModuleList
23+
) {
24+
moduleList.push(LightUnitModule);
25+
super(
26+
{
27+
accessible: false,
28+
...options
29+
},
30+
moduleList
31+
);
32+
}
33+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import type { UnitConstructorOptions, UnitOptions } from '../../Unit';
2+
import LightUnitModule from '../../unitModule/Light';
3+
import WallUnit, {
4+
type WallUnitModuleList,
5+
type WallUnitModules
6+
} from '../Wall';
7+
8+
export type WallLightUnitModules = WallUnitModules & {
9+
light: LightUnitModule;
10+
};
11+
export type WallLightUnitModuleList = (typeof LightUnitModule)[] &
12+
WallUnitModuleList;
13+
14+
export default class WallLightUnit<
15+
Options extends UnitOptions = UnitOptions,
16+
Modules extends WallLightUnitModules = WallLightUnitModules,
17+
ModuleList extends WallLightUnitModuleList = WallLightUnitModuleList
18+
> extends WallUnit<Options, Modules, ModuleList> {
19+
constructor(
20+
options: UnitConstructorOptions<Options>,
21+
moduleList: ModuleList = [] as unknown as ModuleList
22+
) {
23+
moduleList.push(LightUnitModule);
24+
super(
25+
{
26+
accessible: false,
27+
...options
28+
},
29+
moduleList
30+
);
31+
}
32+
}

packages/app/lib/classes/unitModule/Bed.ts

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -63,63 +63,3 @@ export default class BedUnitModule extends SlotUnitModule<
6363
return root;
6464
}
6565
}
66-
67-
// import { OBJECT_NAME } from '@cuby-world/app/lib/utils/object';
68-
// import UnitModule, {
69-
// type UnitModuleObservables,
70-
// type UnitModuleOptions,
71-
// type UnitModuleSetupContext,
72-
// type UnitModuleState
73-
// } from '../UnitModule';
74-
// import { UNIT_TYPE } from '../../types/unit';
75-
// import { Vector3 } from 'three';
76-
// import type { UnitOptions } from '../Unit';
77-
// import type Unit from '../Unit';
78-
79-
// declare module '../../types/unit' {
80-
// interface UnitType {
81-
// BED: 'bed';
82-
// }
83-
// }
84-
85-
// UNIT_TYPE.BED = 'bed';
86-
87-
// declare module '../../utils/object' {
88-
// interface ObjectName {
89-
// BED: 'bed';
90-
// }
91-
// }
92-
93-
// OBJECT_NAME.BED = 'bed';
94-
95-
// export interface BedUnitOptions extends UnitOptions {
96-
// offset: Vector3;
97-
// }
98-
99-
// // eslint-disable-next-line @typescript-eslint/no-empty-object-type
100-
// interface Obervables extends UnitModuleObservables {}
101-
102-
// export type BedOptions = UnitModuleOptions;
103-
// // eslint-disable-next-line @typescript-eslint/no-empty-object-type
104-
// export interface BedState extends UnitModuleState {}
105-
// export default class BedUnitModule extends UnitModule<
106-
// BedOptions,
107-
// BedState,
108-
// Obervables
109-
// > {
110-
// static override TYPE = 'bed';
111-
112-
// override state: BedState = {
113-
// offset: new Vector3(0, 0, 0),
114-
// unit: null
115-
// };
116-
117-
// usedUnit: Unit | null = null;
118-
119-
// override async setup(context: UnitModuleSetupContext) {
120-
// context.unit.addType(UNIT_TYPE.BED);
121-
// context.unit.root.userData[OBJECT_NAME.BED] = true;
122-
// return context.mesh;
123-
// }
124-
125-
// }
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import { ReplaySubject } from 'rxjs';
2+
import UnitModule, {
3+
type UnitModuleObservables,
4+
type UnitModuleOptions,
5+
type UnitModuleSetupContext,
6+
type UnitModuleState
7+
} from '../UnitModule';
8+
import type Unit from '../Unit';
9+
10+
interface Obervables extends UnitModuleObservables {
11+
active$: ReplaySubject<boolean>;
12+
}
13+
14+
interface Options extends UnitModuleOptions {
15+
onTime?: number; // 0 → Mitternacht, 0.25 → 6 Uhr, 0.5 → Mittag, 0.75 → 18 Uhr, 1 → Mitternacht wieder
16+
offTime?: number; // 0 → Mitternacht, 0.25 → 6 Uhr, 0.5 → Mittag, 0.75 → 18 Uhr, 1 → Mitternacht wieder
17+
}
18+
19+
interface State extends UnitModuleState {
20+
active?: boolean;
21+
}
22+
export default class LightUnitModule extends UnitModule<
23+
Options,
24+
State,
25+
Obervables
26+
> {
27+
static override TYPE = 'light';
28+
29+
private active: boolean = false;
30+
31+
constructor(unit: Unit, options: Options, state: State, debug: boolean) {
32+
super(unit, options, state, debug);
33+
//#region observables
34+
this.observables.active$ = new ReplaySubject<boolean>();
35+
this.observables.active$.next(this.active);
36+
//#endregion
37+
}
38+
39+
override async setup(context: UnitModuleSetupContext) {
40+
this.subscription.add(
41+
context.room?.app.modules.time.observables.dayTime$.subscribe(
42+
(dayTime: number) => {
43+
const isOn =
44+
dayTime >= (this.options.onTime ?? 0.7) ||
45+
dayTime <= (this.options.offTime ?? 0.25);
46+
if (isOn !== this.isOn()) {
47+
this.active = isOn;
48+
if (isOn) {
49+
this.on();
50+
} else {
51+
this.off();
52+
}
53+
}
54+
}
55+
)
56+
);
57+
58+
return context.mesh;
59+
}
60+
61+
isOn() {
62+
return this.state.active ?? this.active;
63+
}
64+
65+
on() {
66+
this.observables.active$.next(true);
67+
}
68+
69+
off() {
70+
this.observables.active$.next(false);
71+
}
72+
}

0 commit comments

Comments
 (0)