From 4a3f6fdc18ecb642c0a34e4370cc88994dff2df6 Mon Sep 17 00:00:00 2001 From: Jon Ziebell Date: Tue, 10 Feb 2026 06:40:29 -0500 Subject: [PATCH] Cleanup --- js/beestat/setting.js | 2 ++ js/component/card/three_d.js | 1 + js/component/scene.js | 41 ++++++++++++++++++------------------ 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/js/beestat/setting.js b/js/beestat/setting.js index 5719e17..366325c 100644 --- a/js/beestat/setting.js +++ b/js/beestat/setting.js @@ -83,6 +83,8 @@ beestat.setting = function(argument_1, opt_value, opt_callback) { 'visualize.three_d.show_labels': false, 'visualize.three_d.auto_rotate': false, 'visualize.three_d.show_walls': false, + 'visualize.three_d.show_roof': false, + 'visualize.three_d.show_environment': true, 'date_format': 'M/D/YYYY', diff --git a/js/component/card/three_d.js b/js/component/card/three_d.js index d97cc6e..bf36a44 100644 --- a/js/component/card/three_d.js +++ b/js/component/card/three_d.js @@ -412,6 +412,7 @@ beestat.component.card.three_d.prototype.decorate_drawing_pane_ = function(paren }); this.scene_.set_layer_visible('walls', beestat.setting('visualize.three_d.show_walls')); + this.scene_.set_layer_visible('roof', beestat.setting('visualize.three_d.show_roof')); this.scene_.set_layer_visible('environment', beestat.setting('visualize.three_d.show_environment')); // Manage width of the scene. diff --git a/js/component/scene.js b/js/component/scene.js index 314a780..0904774 100644 --- a/js/component/scene.js +++ b/js/component/scene.js @@ -18,6 +18,15 @@ beestat.component.scene.layer_visible = 0; beestat.component.scene.layer_hidden = 1; beestat.component.scene.layer_outline = 2; +/** + * 3D Scene configuration constants + */ +beestat.component.scene.roof_pitch = 0.5; // Rise over run (0.5 = 6:12 pitch) +beestat.component.scene.wall_thickness = 4; +beestat.component.scene.environment_padding = 100; // Padding around floor plan +beestat.component.scene.room_floor_thickness = 6; +beestat.component.scene.room_wall_inset = 1.5; + /** * Brightness of the top-down light. This gives definition to the sides of * meshes by lighting the tops. Increase this for more edge definition. @@ -91,9 +100,6 @@ beestat.component.scene.prototype.decorate_ = function(parent) { this.add_main_group_(); this.add_floor_plan_(); - // Test SkeletonBuilder - this.test_skeleton_builder_(); - const animate = function() { self.animation_frame_ = window.requestAnimationFrame(animate); self.controls_.update(); @@ -290,6 +296,7 @@ beestat.component.scene.prototype.update_raycaster_ = function() { if ( intersects[i].object.type === 'Mesh' && intersects[i].object.userData.is_wall !== true && + intersects[i].object.userData.is_roof !== true && intersects[i].object.userData.is_environment !== true ) { this.intersected_mesh_ = intersects[i].object; @@ -725,13 +732,10 @@ beestat.component.scene.prototype.add_room_ = function(layer, group, room) { ClipperLib.EndType.etClosedPolygon ); var clipper_hole = new ClipperLib.Path(); - clipper_offset.Execute(clipper_hole, -1.5); - - // Full height - // const extrude_height = (room.height || group.height) - 3; + clipper_offset.Execute(clipper_hole, -beestat.component.scene.room_wall_inset); // Just the floor plan - const extrude_height = 6; + const extrude_height = beestat.component.scene.room_floor_thickness; // Create a shape using the points of the room. const shape = new THREE.Shape(); @@ -786,7 +790,6 @@ beestat.component.scene.prototype.add_room_ = function(layer, group, room) { // Allow me to go from room -> mesh and mesh -> room this.meshes_[room.room_id] = mesh; - // mesh.userData.room_id = room.room_id; mesh.userData.room = room; layer.add(mesh); @@ -861,7 +864,7 @@ beestat.component.scene.prototype.add_room_ = function(layer, group, room) { * @param {object} group The floor plan group. */ beestat.component.scene.prototype.add_walls_ = function(layer, group) { - const wall_thickness = 4; + const wall_thickness = beestat.component.scene.wall_thickness; if (group.rooms.length === 0) { return; @@ -1263,9 +1266,9 @@ beestat.component.scene.prototype.add_roofs_ = function() { // Create layer for roofs const roofs_layer = new THREE.Group(); this.main_group_.add(roofs_layer); - this.layers_['roofs'] = roofs_layer; + this.layers_['roof'] = roofs_layer; - const roof_pitch = 0.5; // Rise over run (e.g., 0.5 = 6:12 pitch, 0.75 = 9:12 pitch) + const roof_pitch = beestat.component.scene.roof_pitch; // Process each exposed area exposed_areas.forEach(function(area) { @@ -1396,6 +1399,7 @@ beestat.component.scene.prototype.add_roofs_ = function() { }); const mesh = new THREE.Mesh(geometry, material); + mesh.userData.is_roof = true; mesh.layers.set(beestat.component.scene.layer_visible); roofs_layer.add(mesh); }); @@ -1610,12 +1614,11 @@ beestat.component.scene.prototype.add_environment_ = function() { // Position the ground flush with the base of the house (hides any below-ground structures). let current_z = 0; - const padding = 60; + const padding = beestat.component.scene.environment_padding; const strata = [ - {'color': 0x4a7c3f, 'thickness': 8}, - {'color': 0x3d2b1f, 'thickness': 30}, - {'color': 0x8b5e3c, 'thickness': 30}, - {'color': 0x6e6e6e, 'thickness': 50} + {'color': 0x4a7c3f, 'thickness': 30}, // Grass (thicker, was 8) + {'color': 0x3d2b1f, 'thickness': 40}, // Dark brown dirt + {'color': 0x8b5e3c, 'thickness': 50} // Light brown dirt ]; const environment_layer = new THREE.Group(); @@ -1866,10 +1869,6 @@ beestat.component.scene.prototype.get_label_material_ = function(args) { const context = canvas.getContext('2d'); - // Debug red background - // context.fillStyle = 'rgba(255, 0, 0, 0.2)'; - // context.fillRect(0, 0, canvas.width, canvas.height); - const font_size = canvas.height / 2; switch (args.type) { case 'value': {