three-base 1.0.28 → 1.0.30

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.
Files changed (2) hide show
  1. package/lib/ThreeBase.ts +26 -2
  2. package/package.json +1 -1
package/lib/ThreeBase.ts CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  import elementResizeEvent from "element-resize-event";
9
9
  import { round } from "lodash";
10
- import { AxesHelper, EventDispatcher, GridHelper, LinearFilter, NoBlending, NormalBlending, Object3D, PerspectiveCamera, RGBAFormat, Scene, Texture, Vector2, Vector3, WebGLRenderer, WebGLRenderTarget } from "three";
10
+ import { AxesHelper, EventDispatcher, GridHelper, LinearFilter, MOUSE, NoBlending, NormalBlending, Object3D, PerspectiveCamera, RGBAFormat, Scene, Texture, TOUCH, Vector2, Vector3, WebGLRenderer, WebGLRenderTarget } from "three";
11
11
  import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
12
12
  import { generateUUID } from "three/src/math/MathUtils";
13
13
  import { clearShader, coptyShader, fullScreenMesh, gaussBlurShader, strokeShader } from "./shaders";
@@ -196,7 +196,6 @@ export default class ThreeBase extends EventDispatcher {
196
196
  this.controls.reset();
197
197
  this.controls.enableDamping = true;
198
198
 
199
-
200
199
  let currentPosition = this.camera.position.clone();
201
200
  let currentCenter = this.controls.target.clone();
202
201
 
@@ -252,6 +251,31 @@ export default class ThreeBase extends EventDispatcher {
252
251
  v3.z = 0;
253
252
  }
254
253
 
254
+ // 控制器类型
255
+ controlType: "OrbitControls" | "MapControls" = "OrbitControls";
256
+
257
+ // 记录一下空间平移方式
258
+ originScreenSpacePanning = false;
259
+
260
+ //改变控制器的类型
261
+ setControlType(controlType: "OrbitControls" | "MapControls") {
262
+
263
+ if (controlType === "OrbitControls") {
264
+ this.controls.screenSpacePanning = this.originScreenSpacePanning;
265
+ this.controls.mouseButtons = { LEFT: MOUSE.ROTATE, MIDDLE: MOUSE.DOLLY, RIGHT: MOUSE.PAN };
266
+ this.controls.touches = { ONE: TOUCH.ROTATE, TWO: TOUCH.DOLLY_PAN };
267
+ } else if (controlType === "MapControls") {
268
+ this.originScreenSpacePanning = this.controls.screenSpacePanning;
269
+ // pan orthogonal to world-space direction camera.up
270
+ this.controls.screenSpacePanning = false;
271
+ this.controls.mouseButtons.LEFT = MOUSE.PAN;
272
+ this.controls.mouseButtons.RIGHT = MOUSE.ROTATE;
273
+ this.controls.touches.ONE = TOUCH.PAN;
274
+ this.controls.touches.TWO = TOUCH.DOLLY_ROTATE;
275
+ }
276
+
277
+ }
278
+
255
279
  // 寻找最顶层的父元素
256
280
  _findRoot(dom: ParentNode): ParentNode | undefined {
257
281
  if (dom.parentNode) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "three-base",
3
- "version": "1.0.28",
3
+ "version": "1.0.30",
4
4
  "description": "three 3d three-base",
5
5
  "keywords": [
6
6
  "three",