default voxel types
This commit is contained in:
parent
e37cb08698
commit
7ebccba199
|
|
@ -0,0 +1,40 @@
|
||||||
|
import type { VoxelType } from "../types/voxel";
|
||||||
|
|
||||||
|
const stone: VoxelType = {
|
||||||
|
id: 'stone',
|
||||||
|
name: 'Stone',
|
||||||
|
opacity: 1,
|
||||||
|
collidable: true,
|
||||||
|
color: 'white',
|
||||||
|
};
|
||||||
|
|
||||||
|
const dirt: VoxelType = {
|
||||||
|
id: 'dirt',
|
||||||
|
name: 'Dirt',
|
||||||
|
opacity: 1,
|
||||||
|
collidable: true,
|
||||||
|
color: '302520',
|
||||||
|
};
|
||||||
|
|
||||||
|
const water: VoxelType = {
|
||||||
|
id: 'water',
|
||||||
|
name: 'Stone',
|
||||||
|
opacity: 0.7,
|
||||||
|
collidable: false,
|
||||||
|
color: 'c0d0ff',
|
||||||
|
};
|
||||||
|
|
||||||
|
const glass: VoxelType = {
|
||||||
|
id: 'glass',
|
||||||
|
name: 'Glass',
|
||||||
|
opacity: 0.4,
|
||||||
|
collidable: true,
|
||||||
|
color: 'f0f8ff',
|
||||||
|
};
|
||||||
|
|
||||||
|
export const DEFAULT_VOXEL_TYPES = {
|
||||||
|
[stone.id]: stone,
|
||||||
|
[dirt.id]: dirt,
|
||||||
|
[water.id]: water,
|
||||||
|
[glass.id]: glass,
|
||||||
|
}
|
||||||
|
|
@ -1,16 +1,18 @@
|
||||||
import type { World } from "../types";
|
import type { World } from "../types";
|
||||||
|
import { DEFAULT_VOXEL_TYPES } from "./defaultVoxelTypes";
|
||||||
|
|
||||||
export class WorldFactory {
|
export class WorldFactory {
|
||||||
|
|
||||||
public static create(): World {
|
public static create(): World {
|
||||||
return {
|
return {
|
||||||
objectTypes: [],
|
objectTypes: {},
|
||||||
|
voxelTypes: DEFAULT_VOXEL_TYPES,
|
||||||
initialScene: {
|
initialScene: {
|
||||||
character: {
|
character: {
|
||||||
position: [0, 0, 0],
|
position: [0, 0, 0],
|
||||||
look: [0, 0, 0],
|
look: [0, 0, 0],
|
||||||
},
|
},
|
||||||
objects: [],
|
objects: {},
|
||||||
},
|
},
|
||||||
state: {
|
state: {
|
||||||
playing: false,
|
playing: false,
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import type { Pos3, V3 } from "../types/3d";
|
||||||
import { clone, randomId } from "../utils";
|
import { clone, randomId } from "../utils";
|
||||||
import type { VoxelType } from "../types/voxel";
|
import type { VoxelType } from "../types/voxel";
|
||||||
import { state } from "./root";
|
import { state } from "./root";
|
||||||
|
import { DEFAULT_VOXEL_TYPES } from "../model/defaultVoxelTypes";
|
||||||
|
|
||||||
export class WorldState {
|
export class WorldState {
|
||||||
public data: World = WorldFactory.create();
|
public data: World = WorldFactory.create();
|
||||||
|
|
@ -24,8 +25,8 @@ export class WorldState {
|
||||||
public loadMock() {
|
public loadMock() {
|
||||||
|
|
||||||
const objTypeId = 'test1';
|
const objTypeId = 'test1';
|
||||||
const voxelTypeId = 'red';
|
const voxelTypeId = 'water';
|
||||||
const objectId = 'red';
|
const objectId = 'object1';
|
||||||
|
|
||||||
this.data = {
|
this.data = {
|
||||||
objectTypes: {
|
objectTypes: {
|
||||||
|
|
@ -40,15 +41,7 @@ export class WorldState {
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
voxelTypes: {
|
voxelTypes: DEFAULT_VOXEL_TYPES,
|
||||||
[voxelTypeId]: {
|
|
||||||
id: voxelTypeId,
|
|
||||||
collidable: true,
|
|
||||||
name: 'Red',
|
|
||||||
opacity: 1,
|
|
||||||
color: 'red',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
editorCamera: {
|
editorCamera: {
|
||||||
position: [0, 2, 10],
|
position: [0, 2, 10],
|
||||||
look: [0, 0, 0],
|
look: [0, 0, 0],
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue