| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- import * as three from "three-js";
- import { functional_factor } from "./functional_factor.js";
- const room = (space) => {
- const cube = new functional_factor(() => {
- const material = new three.MeshStandardMaterial({
- color: 0xA000A0
- });
- const geometry = new three.BoxGeometry(1, 1, 1);
- const mesh = new three.Mesh(geometry, material);
- mesh.position.x = 10;
- mesh.position.z = -10;
- mesh.position.y = 1;
- return mesh;
- }, (item) => {
- item.rotation.x += 0.01;
- });
- const light = new functional_factor(() => {
- const light = new three.HemisphereLight(0x707070);
-
- light.position.x = -10;
- light.position.z = 10;
- light.position.y = 10;
- return light;
- }, (item) => {
- if (item.rotation.x == 0) {
- item.position.y += 0.1;
- } else {
- item.position.y -= 0.1;
- }
- if (item.position.y > 10) {
- item.rotation.x = 0.1;
- }
- if (item.position.y < 0) {
- item.rotation.x = 0;
- }
- });
- space.add_factor(cube);
- space.add_factor(light);
- };
- export { room };
|