three-base 1.0.16 → 1.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/ThreeBase.ts +11 -2
- package/package.json +1 -1
package/lib/ThreeBase.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import elementResizeEvent from "element-resize-event";
|
|
9
|
+
import { round } from "lodash";
|
|
9
10
|
import { AxesHelper, EventDispatcher, GridHelper, LinearFilter, NoBlending, NormalBlending, Object3D, PerspectiveCamera, RGBAFormat, Scene, Texture, Vector2, Vector3, WebGLRenderer, WebGLRenderTarget } from "three";
|
|
10
11
|
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
|
|
11
12
|
import { generateUUID } from "three/src/math/MathUtils";
|
|
@@ -221,9 +222,17 @@ export default class ThreeBase extends EventDispatcher {
|
|
|
221
222
|
|
|
222
223
|
// 获取控制的位置和朝向 保留3位小数
|
|
223
224
|
getLookAt() {
|
|
225
|
+
const position = this.camera.position.toArray().map(v => round(v, 3));
|
|
226
|
+
const center = this.controls.target.toArray().map(v => round(v, 3));
|
|
227
|
+
if (threeUtils.isDev) {
|
|
228
|
+
console.log(`
|
|
229
|
+
center: new Vector3(${center.join(",")}),
|
|
230
|
+
position: new Vector3(${position.join(",")})
|
|
231
|
+
`);
|
|
232
|
+
}
|
|
224
233
|
return {
|
|
225
|
-
position: new Vector3(
|
|
226
|
-
center: new Vector3()
|
|
234
|
+
position: new Vector3(...position),
|
|
235
|
+
center: new Vector3(...center)
|
|
227
236
|
}
|
|
228
237
|
}
|
|
229
238
|
|