room.js 812 B

12345678910111213141516171819202122232425262728293031323334
  1. import * as three from "three-js";
  2. import { functional_factor } from "./factor.js";
  3. const room = (space) => {
  4. const cube = new functional_factor(() => {
  5. const material = new three.MeshStandardMaterial({
  6. color: 0xA000A0
  7. });
  8. const geometry = new three.BoxGeometry(1, 1, 1);
  9. const mesh = new three.Mesh(geometry, material);
  10. mesh.position.x = 10;
  11. mesh.position.z = -10;
  12. mesh.position.y = 1;
  13. return mesh;
  14. });
  15. const light = new functional_factor(() => {
  16. const light = new three.HemisphereLight(0x707070);
  17. light.position.x = -10;
  18. light.position.z = 10;
  19. light.position.y = 10;
  20. return light;
  21. });
  22. space.add_factor(cube);
  23. space.add_factor(light);
  24. };
  25. export { room };