Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
CaseyNelson314 committed Dec 26, 2023
1 parent 9a8c5c6 commit f46e7e3
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
4 changes: 4 additions & 0 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
電気力線
</label> -->
<div class="settings_3d">
<label class="checkbox">
<input type="checkbox" id="checkbox_show_grid" checked />
グリッド表示
</label>
<label class="checkbox">
<input type="checkbox" id="checkbox_auto_rotate" checked />
自動回転
Expand Down
9 changes: 7 additions & 2 deletions app/script/Field3D.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ export class Field3D extends THREE.Object3D {
if (enable) {
if (this.point_charges_3d == null)
this.point_charges_3d = new PointCharges3D(this.point_charges);
else
this.point_charges_3d.update();
this.add(this.point_charges_3d);
}
else {
Expand All @@ -206,6 +208,8 @@ export class Field3D extends THREE.Object3D {
if (enable) {
if (this.electric_lines_3d == null)
this.electric_lines_3d = new ElectricLines3D(this.point_charges);
else
this.electric_lines_3d.update();
this.add(this.electric_lines_3d);
}
else {
Expand All @@ -217,8 +221,9 @@ export class Field3D extends THREE.Object3D {
enableElectricFieldVectors = (enable) => {
if (enable) {
if (this.electric_field_vectors_3d == null)
this.electric_field_vectors_3d =
new ElectricFieldVectors3D(this.point_charges);
this.electric_field_vectors_3d = new ElectricFieldVectors3D(this.point_charges);
else
this.electric_field_vectors_3d.update();
this.add(this.electric_field_vectors_3d);
}
else {
Expand Down
22 changes: 17 additions & 5 deletions app/script/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,23 @@ const init = () => {
});
}

// 床の表示/非表示
{
const helper = new THREE.GridHelper(2000, 100);
helper.material.opacity = 0;
scene.add(helper);

const ChangeHelper = (is_visible) => {
helper.visible = is_visible;
}

const checkbox = document.getElementById("checkbox_show_grid");
ChangeHelper(checkbox.checked); // 初期値
checkbox.addEventListener("change", (e) => {
ChangeHelper(e.target.checked);
});
}

// 2D/3D切り替え
{
const sw = document.getElementById("dimension_toggle_switch");
Expand Down Expand Up @@ -120,11 +137,6 @@ const init = () => {
});
}

const helper = new THREE.GridHelper(2000, 100);
helper.material.opacity = 0.5;
// helper.material.transparent = true;
scene.add(helper);

main(scene, renderer, camera, controls);
};
// 関数の実行時間を計測する関数
Expand Down

0 comments on commit f46e7e3

Please sign in to comment.