UNPKG

3js-game-framework

Version:

3js-game-framework is a lightweight and flexible framework designed to streamline the creation of 3D games and interactive applications using Three.js

43 lines 1.73 kB
import * as THREE from "three"; export class Plane { constructor(game) { this.game = game; } /** * * @param game - The game instance * @param initOptions - Initialization options for the plane * @param initOptions.width - The width of the plane, default is 10 * @param initOptions.height - The height of the plane, default is 10 * @param initOptions.color - The color of the plane, default is 0x00ff00 (green) * @description Creates a plane in the game scene with the specified width, height, and color. */ start(game, initOptions) { this.game = game; const width = (initOptions === null || initOptions === void 0 ? void 0 : initOptions.width) || 10; const height = (initOptions === null || initOptions === void 0 ? void 0 : initOptions.height) || 10; const color = (initOptions === null || initOptions === void 0 ? void 0 : initOptions.color) || 0x00ff00; // Create a plane geometry and material const geometry = new THREE.PlaneGeometry(width, height); const material = new THREE.MeshBasicMaterial({ color, side: THREE.DoubleSide, }); // Create the mesh and add it to the scene this.mesh = new THREE.Mesh(geometry, material); this.mesh.rotation.x = -Math.PI / 2; // Rotate to make it horizontal this.game.scene.add(this.mesh); } update(dt, args) { // Method not implemented. } end() { if (this.mesh) { this.game.scene.remove(this.mesh); this.mesh.geometry.dispose(); this.mesh.material.dispose(); } this.mesh = undefined; } } //# sourceMappingURL=Plane.js.map