mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-06-25 17:10:43 +00:00
wip
This commit is contained in:
parent
8b0dd1ea68
commit
827895b548
4 changed files with 80 additions and 14 deletions
|
|
@ -799,7 +799,7 @@ export class CustomMadoriEnvManager extends EnvManager<CustomMadoriEnvOptions> {
|
|||
private floorRootNode: BABYLON.TransformNode | null = null;
|
||||
private wallRootNode: BABYLON.TransformNode | null = null;
|
||||
private ceilingMaterial: BABYLON.PBRMaterial | null = null;
|
||||
private floorMaterial: BABYLON.PBRMaterial | null = null;
|
||||
private floorMaterials: Record<string, BABYLON.PBRMaterial> = {};
|
||||
private skybox: BABYLON.Mesh | null = null;
|
||||
private skyboxMat: BABYLON.StandardMaterial | null = null;
|
||||
private roomLight: BABYLON.DirectionalLight | null = null;
|
||||
|
|
@ -842,6 +842,23 @@ export class CustomMadoriEnvManager extends EnvManager<CustomMadoriEnvOptions> {
|
|||
this.shadowGenerators.push(shadowGeneratorForRoomLight);
|
||||
}
|
||||
|
||||
for (const materialDef of options.flooringMaterials) {
|
||||
const mat = new BABYLON.PBRMaterial(`flooring_${materialDef.id}`, this.engine.scene);
|
||||
mat.albedoColor = new BABYLON.Color3(...materialDef.color);
|
||||
|
||||
const texPath = materialDef.texture === 'wood' ? '/client-assets/room/textures/flooring-wood.png'
|
||||
: materialDef.texture === 'concrete' ? '/client-assets/room/textures/concrete3.png'
|
||||
: null;
|
||||
|
||||
if (texPath != null) {
|
||||
const tex = new BABYLON.Texture(texPath, this.engine.scene, false, false);
|
||||
mat.albedoTexture = tex;
|
||||
}
|
||||
|
||||
mat.freeze();
|
||||
this.floorMaterials[materialDef.id] = mat;
|
||||
}
|
||||
|
||||
this.loaderResult = await BABYLON.LoadAssetContainerAsync('/client-assets/room/envs/custom-madori/units.glb', this.engine.scene);
|
||||
|
||||
this.envMapIndoor = BABYLON.CubeTexture.CreateFromPrefilteredData('/client-assets/room/indoor.env', this.engine.scene);
|
||||
|
|
@ -924,6 +941,8 @@ export class CustomMadoriEnvManager extends EnvManager<CustomMadoriEnvOptions> {
|
|||
const unitDef = options.units[postToIndex(x, z)];
|
||||
if (unitDef == null) return;
|
||||
|
||||
const floorMaterial = this.floorMaterials[unitDef.flooring.material];
|
||||
|
||||
const unitNDef = options.units[postToIndex(x, z + 1)];
|
||||
const unitSDef = options.units[postToIndex(x, z - 1)];
|
||||
const unitWDef = options.units[postToIndex(x + 1, z)];
|
||||
|
|
@ -938,6 +957,8 @@ export class CustomMadoriEnvManager extends EnvManager<CustomMadoriEnvOptions> {
|
|||
const unitFloorRootNode = this.floorRootNode.clone(`unit_${x}_${z}_floor`)!;
|
||||
unitFloorRootNode.parent = unitRoot;
|
||||
unitFloorRootNode.scaling = new BABYLON.Vector3(-WORLD_SCALE, WORLD_SCALE, WORLD_SCALE);
|
||||
const flooringMesh = unitFloorRootNode.getChildMeshes().find(m => m.name.includes('__X_FLOOR__'));
|
||||
flooringMesh.material = floorMaterial;
|
||||
|
||||
if (unitNDef == null) {
|
||||
const unitWallRootNode = this.wallRootNode.clone(`unit_${x}_${z}_wall_n`)!;
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
|
|
@ -37,28 +37,38 @@ export type MuseumEnvOptions = any;
|
|||
|
||||
export type CustomMadoriEnvOptions = {
|
||||
dimension: [number, number];
|
||||
wallMaterials: {
|
||||
id: string;
|
||||
texture: null | 'wood' | 'concrete';
|
||||
color: [number, number, number];
|
||||
}[];
|
||||
flooringMaterials: {
|
||||
id: string;
|
||||
texture: null | 'wood' | 'concrete';
|
||||
color: [number, number, number];
|
||||
}[];
|
||||
ceilingMaterials: {
|
||||
id: string;
|
||||
texture: null | 'wood' | 'concrete';
|
||||
color: [number, number, number];
|
||||
}[];
|
||||
units: ({
|
||||
type: 'floor';
|
||||
walls: Record<'n' | 's' | 'w' | 'e', {
|
||||
material: null | 'wood' | 'concrete';
|
||||
color: [number, number, number];
|
||||
withBeam: boolean;
|
||||
beamMaterial: null | 'wood' | 'concrete';
|
||||
beamColor: [number, number, number];
|
||||
withBaseboard: boolean;
|
||||
material: string;
|
||||
withBeam?: boolean;
|
||||
beamMaterial?: string;
|
||||
withBaseboard?: boolean;
|
||||
}>;
|
||||
pillars: Record<'nw' | 'ne' | 'sw' | 'se', {
|
||||
material: null | 'wood' | 'concrete';
|
||||
color: [number, number, number];
|
||||
show: boolean;
|
||||
material: string;
|
||||
show?: boolean;
|
||||
}>;
|
||||
flooring: {
|
||||
material: null | 'wood' | 'concrete';
|
||||
color: [number, number, number];
|
||||
material: string;
|
||||
};
|
||||
ceiling: {
|
||||
material: null | 'wood' | 'concrete';
|
||||
color: [number, number, number];
|
||||
material: string;
|
||||
};
|
||||
} | null)[];
|
||||
};
|
||||
|
|
@ -147,10 +157,45 @@ export function getDefaultMuseumEnvOptions(): MuseumEnvOptions {
|
|||
export function getDefaultCustomMadoriEnvOptions(): CustomMadoriEnvOptions {
|
||||
const units = Array.from({ length: 15 * 15 }, () => ({
|
||||
type: 'floor',
|
||||
walls: {
|
||||
n: {
|
||||
material: '0',
|
||||
},
|
||||
e: {
|
||||
material: '0',
|
||||
},
|
||||
s: {
|
||||
material: '0',
|
||||
},
|
||||
w: {
|
||||
material: '0',
|
||||
},
|
||||
},
|
||||
flooring: {
|
||||
material: '0',
|
||||
},
|
||||
ceiling: {
|
||||
material: '0',
|
||||
},
|
||||
}));
|
||||
|
||||
return {
|
||||
dimension: [15, 15],
|
||||
wallMaterials: [{
|
||||
id: '0',
|
||||
texture: null,
|
||||
color: [0.8, 0.8, 0.8],
|
||||
}],
|
||||
flooringMaterials: [{
|
||||
id: '0',
|
||||
texture: 'wood',
|
||||
color: [0.8, 0.8, 0.8],
|
||||
}],
|
||||
ceilingMaterials: [{
|
||||
id: '0',
|
||||
texture: null,
|
||||
color: [0.8, 0.8, 0.8],
|
||||
}],
|
||||
units: units,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue