Skip to content

Commit 5099697

Browse files
small udpate for prod/local environments in threejs example
1 parent 185715e commit 5099697

File tree

2 files changed

+32
-13
lines changed

2 files changed

+32
-13
lines changed

react/bitbybit-threejs/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
"react-app-rewired": "2.2.1"
2727
},
2828
"scripts": {
29-
"start": "PORT=3000 react-app-rewired start",
30-
"build": "GENERATE_SOURCEMAP=false && react-app-rewired build",
29+
"start": "REACT_APP_ENVIRONMENT='local' PORT=3000 react-app-rewired start",
30+
"build": "REACT_APP_ENVIRONMENT='production' GENERATE_SOURCEMAP=false && react-app-rewired build",
3131
"test": "react-scripts test",
3232
"eject": "react-scripts eject"
3333
},

react/bitbybit-threejs/src/App.tsx

+30-11
Original file line numberDiff line numberDiff line change
@@ -40,31 +40,50 @@ function App() {
4040
const firstRenderRef = useRef(true);
4141

4242
useEffect(() => {
43-
// if (firstRenderRef.current) {
44-
// firstRenderRef.current = false;
45-
// return;
46-
// }
43+
if (process.env.REACT_APP_ENVIRONMENT !== 'production' &&
44+
firstRenderRef.current) {
45+
firstRenderRef.current = false;
46+
return;
47+
}
4748
init();
4849
}, [])
4950

5051
const createVaseByLoft = async (bitbybit?: BitByBitOCCT, scene?: THREE.Scene) => {
5152
if (scene && bitbybit) {
52-
const wire1 = await bitbybit.occt.shapes.wire.createCircleWire({ radius: 10 + addRadiusNarrow, center: [0, 0, 0], direction: [0, 1, 0] });
53-
const wire2 = await bitbybit.occt.shapes.wire.createEllipseWire({ radiusMinor: 20 + addRadiusWide, radiusMajor: 25 + addRadiusWide, center: [0, 20 + addMiddleHeight, 0], direction: [0, 1, 0] });
54-
const wire3 = await bitbybit.occt.shapes.wire.createCircleWire({ radius: 10 + addRadiusNarrow, center: [0, 30 + addMiddleHeight, 0], direction: [0, 1, 0] });
55-
const wire4 = await bitbybit.occt.shapes.wire.createCircleWire({ radius: 15 + addRadiusWide, center: [0, 40 + addMiddleHeight + addTopHeight, 0], direction: [0, 1, 0.1] });
53+
const wire1 = await bitbybit.occt.shapes.wire.createCircleWire({
54+
radius: 10 + addRadiusNarrow,
55+
center: [0, 0, 0],
56+
direction: [0, 1, 0]
57+
});
58+
const wire2 = await bitbybit.occt.shapes.wire.createEllipseWire({
59+
radiusMinor: 20 + addRadiusWide,
60+
radiusMajor: 25 + addRadiusWide,
61+
center: [0, 20 + addMiddleHeight, 0],
62+
direction: [0, 1, 0]
63+
});
64+
const wire3 = await bitbybit.occt.shapes.wire.createCircleWire({
65+
radius: 10 + addRadiusNarrow,
66+
center: [0, 30 + addMiddleHeight, 0],
67+
direction: [0, 1, 0]
68+
});
69+
const wire4 = await bitbybit.occt.shapes.wire.createCircleWire({
70+
radius: 15 + addRadiusWide,
71+
center: [0, 40 + addMiddleHeight + addTopHeight, 0],
72+
direction: [0, 1, 0.1]
73+
});
5674
const lAdvOpt = new Inputs.OCCT.LoftAdvancedDto([wire1, wire2, wire3, wire4]);
5775
const loft = await bitbybit.occt.operations.loftAdvanced(lAdvOpt);
5876
const loftFace = await bitbybit.occt.shapes.face.getFace({ shape: loft, index: 0 });
5977
const baseFace = await bitbybit.occt.shapes.face.createFaceFromWire({ shape: wire1, planar: true });
6078
const shell = await bitbybit.occt.shapes.shell.sewFaces({ shapes: [loftFace, baseFace], tolerance: 1e-7 });
6179
const fillet = await bitbybit.occt.fillets.filletEdges({ shape: shell, radius: 10 });
6280
const thick = await bitbybit.occt.operations.makeThickSolidSimple({ shape: fillet, offset: -2 })
63-
const chamfer = await bitbybit.occt.fillets.chamferEdges({ shape: thick, distance: 0.3 });
81+
const vase = await bitbybit.occt.fillets.chamferEdges({ shape: thick, distance: 0.3 });
82+
83+
const group = await addShapeToScene(bitbybit, vase, scene, 0.05);
6484

65-
const group = await addShapeToScene(bitbybit, chamfer, scene, 0.05);
6685
setGroup(group);
67-
setVase(chamfer);
86+
setVase(vase);
6887
}
6988
}
7089

0 commit comments

Comments
 (0)