|
@@ -2,6 +2,24 @@
|
2
|
2
|
* 3d.js
|
3
|
3
|
*
|
4
|
4
|
* Copyright (c) 2024 Thomas Buck (thomas@xythobuz.de)
|
|
5
|
+ *
|
|
6
|
+ * For the fitCameraToObject() function also:
|
|
7
|
+ * Copyright (c) 2024 Michal Jirků
|
|
8
|
+ * https://wejn.org/2020/12/cracking-the-threejs-object-fitting-nut/
|
|
9
|
+ *
|
|
10
|
+ * For everything else:
|
|
11
|
+ *
|
|
12
|
+ * This program is free software: you can redistribute it and/or modify
|
|
13
|
+ * it under the terms of the GNU General Public License as published by
|
|
14
|
+ * the Free Software Foundation, either version 3 of the License, or
|
|
15
|
+ * (at your option) any later version.
|
|
16
|
+ *
|
|
17
|
+ * This program is distributed in the hope that it will be useful,
|
|
18
|
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
20
|
+ * GNU General Public License for more details.
|
|
21
|
+ *
|
|
22
|
+ * See <http://www.gnu.org/licenses/>.
|
5
|
23
|
*/
|
6
|
24
|
|
7
|
25
|
import * as THREE from 'three';
|
|
@@ -9,7 +27,6 @@ import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
|
9
|
27
|
import { STLLoader } from 'three/addons/loaders/STLLoader.js'
|
10
|
28
|
import { VRMLLoader } from 'three/addons/loaders/VRMLLoader.js';
|
11
|
29
|
|
12
|
|
-// https://wejn.org/2020/12/cracking-the-threejs-object-fitting-nut/
|
13
|
30
|
function fitCameraToObject(camera, object, offset, orbitControls, yOffset) {
|
14
|
31
|
const boundingBox = new THREE.Box3();
|
15
|
32
|
boundingBox.setFromObject( object );
|
|
@@ -92,7 +109,7 @@ export function init_3d(path, container, status, div_width, div_height) {
|
92
|
109
|
|
93
|
110
|
const camera = new THREE.PerspectiveCamera(75, width / height, 0.1, 1000);
|
94
|
111
|
|
95
|
|
- const renderer = new THREE.WebGLRenderer();
|
|
112
|
+ const renderer = new THREE.WebGLRenderer({ antialias: true });
|
96
|
113
|
renderer.setSize(width, height);
|
97
|
114
|
|
98
|
115
|
const controls = new OrbitControls(camera, renderer.domElement);
|