Skip to content

Commit 7dec46e

Browse files
committed
V 0.0.5
1 parent 4fb19f4 commit 7dec46e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+318
-415
lines changed

public/dcv/dcv3.glb

6.03 MB
Binary file not shown.

public/dcv/dcv4.glb

6.03 MB
Binary file not shown.

public/dvm.jpg

-1.5 MB
Binary file not shown.

public/green_material.mtl

-9
This file was deleted.

public/image.png

-397 KB
Binary file not shown.

public/knobs/oven_knob1.glb

15.1 MB
Binary file not shown.

public/stanfordOne.ply

-619 Bytes
Binary file not shown.

public/switch/switch_button2.glb

6.95 MB
Binary file not shown.

public/switch/switch_button_off.glb

6.94 MB
Binary file not shown.

public/switch/switch_casing1.glb

311 KB
Binary file not shown.

public/tkm.png

-910 KB
Binary file not shown.

public/triangle.stl

-484 Bytes
Binary file not shown.

public/triangle_button.stl

-484 Bytes
Binary file not shown.
-42.8 MB
Binary file not shown.
17.1 MB
Binary file not shown.

public/vvr/vvr6.glb

6.31 MB
Binary file not shown.

public/wood_texture.jpg

-2.83 MB
Binary file not shown.

src/LABS/Lab1MainComponent.tsx

+20-18
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@ import React, { useState, useRef, Suspense } from "react";
22
import { Canvas, useFrame } from "@react-three/fiber";
33
import { OrbitControls, PerspectiveCamera, Environment } from "@react-three/drei";
44
import * as THREE from "three";
5-
import CornerText from "../shared/2dText";
5+
import CornerText from "../miscellaneous/2DTexts/2dText.tsx";
66
import ChatComponent from "../Assisstant/alltogether";
7-
import CircularTherm from "../labComponents/circularTherm/ThermometerMainComponent";
8-
import SmallKnob from "../labComponents/SmallKnob/smallKnob";
9-
import VVR from "../labComponents/VariableVoltageRegulator/mainframe";
10-
import BigKnob from "../labComponents/BigKnob/bigKnob";
11-
import Grid from "./grid";
12-
import RaycastingComponent from "../raycaster/lab1Raycaster";
13-
import LightSwitch from "../miscellaneous/switchAndCasing";
14-
import DVM from "../labComponents/DigitalVoltmeter/digitalVoltmeter.tsx";
7+
import CircularTherm from "../labComponents/SmallInstruments/circularTherm/ThermometerMainComponent.tsx";
8+
import SmallKnob from "../labComponents/knobs/smallKnob.tsx";
9+
import BigKnob from "../labComponents/knobs/currentKnob.tsx";
10+
import Grid from "../miscellaneous/planks/grid.tsx";
11+
import RaycastingComponent from "../raycasters/lab1Raycaster.tsx";
12+
import LightSwitch from "../clickables/VVR_switch/switchAndCasing.tsx";
13+
import DVM from "../labComponents/FrankHertzMainComp/digitalVoltmeter.tsx";
1514
import { FrontFaceContextProvider } from "../contexts/frontFaceContext.tsx";
1615
import { useFrontFaceContext } from "../hooks/useFrontFaceContext.tsx";
17-
import TripleOutput from "../labComponents/tripleOutPutPowerSupply/mainComponent.tsx";
18-
import CurrentInstrument from "../labComponents/Box/box.tsx";
19-
import OakPlank from "../planks/lightOak.tsx";
20-
import FrankHertzMain from "../labComponents/FrankhertzChasis/frankHertz.tsx";
21-
import CurrentRegulator from "../labComponents/FrankhertzChasis/currentRegulator.tsx";
22-
import ControlsComponent from "../miscellaneous/cameracontrol.tsx";
16+
import TripleOutput from "../labComponents/FrankHertzMainComp/tripleOutPutPowerSupply/mainComponent.tsx";
17+
import CurrentInstrument from "../labComponents/FrankHertzMainComp/currentInstrument.tsx";
18+
import OakPlank from "../miscellaneous/planks/lightOak.tsx";
19+
import FrankHertzMain from "../labComponents/FrankHertzMainComp/frankHertz.tsx";
20+
import CurrentRegulator from "../labComponents/FrankHertzMainComp/currentRegulator.tsx";
21+
import ControlsComponent from "../miscellaneous/controls/cameracontrol.tsx";
22+
import VVR from "../labComponents/FrankHertzMainComp/VariableVoltageRegulator/mainframe.tsx";
2323

2424
interface CameraProps {
2525
xN: number
@@ -116,12 +116,14 @@ const GraphPaperComponent: React.FC = () => {
116116

117117
{/* Components: From Bottom to Top*/}
118118
<Grid />
119-
<TripleOutput position={[-20, -0.4, 0]} />
119+
<TripleOutput position={[-22, -0.3, 22]} />
120120
<CurrentInstrument position={[27, 0.5, 0]} />
121121
<OakPlank />
122-
<FrankHertzMain position={[5, 16, 0]}/>
122+
<FrankHertzMain position={[5, 12, 0]}/>
123123
<CurrentRegulator position={[40, 26, 5]}/>
124-
<DVM position={[25, 28, 23]} scale={[4.4, 4.8, 4.4]} unique_id="DVM_2"/>
124+
<DVM position={[20, 30, 23]} scale={[1.7, 1.7, 1.85]} unique_id="DVM_2"/>
125+
<VVR position={[-30, 24, 2]} />
126+
<DVM position={[30, 80, 8]} scale={[1.7, 1.7, 1.85]} rotation={[0, Math.PI, 0]} unique_id="DVM_1"/>
125127
</Canvas>
126128
</div>
127129
</Suspense>
-2.55 MB
Binary file not shown.

src/assets/react.svg

-1
This file was deleted.

src/clickables/VVR_switch/switch.tsx

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import React, { useRef, useEffect, useState } from "react";
2+
import * as THREE from "three";
3+
import { useLoader } from "@react-three/fiber";
4+
import { GLTFLoader } from "three-stdlib";
5+
6+
interface SwitchProps {
7+
position: [number, number, number]; // Position prop
8+
scale?: [number, number, number];
9+
rotation?: [number, number, number]; // Optional rotation prop
10+
unique_id: string;
11+
}
12+
13+
const Switch: React.FC<SwitchProps> = ({
14+
position,
15+
scale = [1, 1, 1],
16+
rotation = [0, 0, 0],
17+
unique_id,
18+
}) => {
19+
const [isOn, setIsOn] = useState(false); // State for the switch position
20+
const groupRef = useRef<THREE.Group | null>(null);
21+
22+
// Load the "on" and "off" models
23+
const onModelGLTF = useLoader(GLTFLoader, "/switch/switch_button2.glb");
24+
const offModelGLTF = useLoader(GLTFLoader, "/switch/switch_button_off.glb");
25+
26+
const [onModel, setOnModel] = useState<THREE.Object3D | null>(null);
27+
const [offModel, setOffModel] = useState<THREE.Object3D | null>(null);
28+
29+
useEffect(() => {
30+
const handleClick = () => {
31+
setIsOn((prevState) => !prevState);
32+
};
33+
34+
// Add interaction handlers to the models
35+
const applyUserData = (model: THREE.Object3D, type_switch: string) => {
36+
const clonedScene = model.clone();
37+
clonedScene.traverse((child) => {
38+
if ((child as THREE.Mesh).isMesh) {
39+
const mesh = child as THREE.Mesh;
40+
mesh.userData.unique_id = unique_id;
41+
mesh.userData.handleIntersect = handleClick;
42+
mesh.userData.type = "switch_button";
43+
}
44+
});
45+
if (type_switch == "on") {
46+
setOnModel(clonedScene);
47+
} else {
48+
setOffModel(clonedScene);
49+
}
50+
};
51+
52+
if (onModelGLTF.scene) applyUserData(onModelGLTF.scene, "on");
53+
if (offModelGLTF.scene) applyUserData(offModelGLTF.scene, "off");
54+
55+
}, [onModelGLTF, offModelGLTF, unique_id]);
56+
57+
return (
58+
<group ref={groupRef} position={position} rotation={rotation} scale={scale}>
59+
{isOn ? (
60+
onModel && <primitive object={onModel} position={[-20.8, -14.9, -1]} />
61+
) : (
62+
offModel && (
63+
<primitive
64+
object={offModel}
65+
rotation={[0, 0, Math.PI]}
66+
/>
67+
)
68+
)}
69+
</group>
70+
);
71+
};
72+
73+
export default Switch;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import React, { useRef, useEffect, useState } from "react"
2+
import * as THREE from "three"
3+
import { useLoader } from "@react-three/fiber"
4+
import { GLTFLoader } from "three-stdlib"
5+
import Switch from "./switch"
6+
7+
interface LightSwitchProps {
8+
position: [number, number, number] // Position prop
9+
rotation?: [number, number, number] // Optional rotation prop
10+
unique_id: string
11+
scale?: [number, number, number]
12+
}
13+
14+
const LightSwitch: React.FC<LightSwitchProps> = ({
15+
position,
16+
rotation = [Math.PI, Math.PI, Math.PI / 2], // Default to 90 degrees around the Y-axis
17+
unique_id,
18+
scale = [0.2, 0.2, 0.2],
19+
}) => {
20+
const gltf = useLoader(GLTFLoader, "/switch/switch_casing1.glb")
21+
const [model, setModel] = useState<THREE.Object3D | null>(null)
22+
const groupRef = useRef<THREE.Group | null>(null)
23+
24+
// Clone and prepare the model
25+
useEffect(() => {
26+
if (gltf.scene) {
27+
const clonedScene = gltf.scene.clone()
28+
29+
clonedScene.traverse((child) => {
30+
if ((child as THREE.Mesh).isMesh) {
31+
const mesh = child as THREE.Mesh
32+
mesh.userData.unique_id = unique_id
33+
mesh.userData.type = "switch_casing"
34+
}
35+
})
36+
37+
setModel(clonedScene)
38+
}
39+
}, [gltf, unique_id])
40+
41+
return (
42+
<group ref={groupRef} position={position} rotation={rotation} scale={scale}>
43+
{model && <primitive object={model}/>}
44+
<Switch position={[20.85,14.9,1.2]} unique_id={"tops_switch_1"} />
45+
</group>
46+
)
47+
}
48+
49+
export default LightSwitch

src/jsonReader/readJson.tsx

-88
This file was deleted.

src/labComponents/Buttons/buttonsMain.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from "react"
22
import Button2 from "./longButton"
33
import Button1 from "./circleAndTriangleButton"
4-
import TriangleButton from "./triangleButton"
54

65
interface Button {
76
id: string
@@ -10,7 +9,8 @@ interface Button {
109
rotation: [number, number, number]
1110
scale: [number, number, number]
1211
type: string
13-
typeGen: string
12+
key: string
13+
typeGen?: string | null;
1414
}
1515

1616
interface ButtonComponentProps {
@@ -29,7 +29,7 @@ const ButtonComponent: React.FC<ButtonComponentProps> = ({ buttons }) => {
2929
position={button.position}
3030
rotation={button.rotation}
3131
scale={button.scale}
32-
typeGen={button.typeGen}
32+
typeGen={button.typeGen ?? "circleButton"}
3333
/>
3434
)
3535
} else if (button.type === "type2") {

src/labComponents/Buttons/circleAndTriangleButton.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ const Button1: React.FC<ButtonProps> = ({
4242
const mesh = child as THREE.Mesh;
4343
mesh.userData.unique_id = unique_id;
4444
mesh.userData.handleIntersect = handleClick;
45+
mesh.userData.type = "triangle_circle_button";
4546
}
4647
});
4748

@@ -56,17 +57,17 @@ const Button1: React.FC<ButtonProps> = ({
5657

5758
if (isMovingForward) {
5859
const targetY = position[1] - 0.5;
59-
groupRef.current.position.y = THREE.MathUtils.lerp(posY, targetY, 0.1);
60+
groupRef.current.position.y = THREE.MathUtils.lerp(posY, targetY, 0.6);
6061

6162
if (Math.abs(posY - targetY) < 0.01) {
6263
setIsMovingForward(false);
63-
setTimeout(() => setIsMovingBack(true), 300);
64+
setTimeout(() => setIsMovingBack(true), 50);
6465
}
6566
}
6667

6768
if (isMovingBack) {
6869
const targetY = position[1];
69-
groupRef.current.position.y = THREE.MathUtils.lerp(posY, targetY, 0.1);
70+
groupRef.current.position.y = THREE.MathUtils.lerp(posY, targetY, 0.4);
7071

7172
if (Math.abs(posY - targetY) < 0.01) {
7273
setIsMovingBack(false);

src/labComponents/DigitalVoltmeter/digitalVoltmeter.tsx

-55
This file was deleted.

0 commit comments

Comments
 (0)