@anov/3d 0.0.1-alpha.4 → 0.0.1-alpha.5
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/README.md +76 -0
- package/dist/core/camera.d.ts +10 -1
- package/dist/core/camera.js +23 -11
- package/dist/core/mesh.js +8 -8
- package/dist/core/scene.d.ts +1 -0
- package/dist/core/scene.js +1 -0
- package/dist/export.d.ts +28 -0
- package/dist/export.js +26 -0
- package/dist/index.d.ts +3 -27
- package/dist/index.js +5 -25
- package/dist/type.d.ts +2 -1
- package/dist/utils/move.d.ts +12 -9
- package/dist/utils/move.js +37 -12
- package/lib/3d.min.js +1 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -66,3 +66,79 @@ utils.moveWithRound(box2, 0.2, 100000)
|
|
|
66
66
|
scene.render(document.querySelector('#app')!)
|
|
67
67
|
scene.startFrameAnimate()
|
|
68
68
|
```
|
|
69
|
+
|
|
70
|
+
## umd usage
|
|
71
|
+
|
|
72
|
+
```html
|
|
73
|
+
<!DOCTYPE html>
|
|
74
|
+
<html lang="en">
|
|
75
|
+
<head>
|
|
76
|
+
<meta charset="UTF-8">
|
|
77
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
78
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
79
|
+
<title>Document</title>
|
|
80
|
+
<link rel="stylesheet" type="text/css" href="./source/base.css" />
|
|
81
|
+
</style>
|
|
82
|
+
</head>
|
|
83
|
+
|
|
84
|
+
<body>
|
|
85
|
+
<div id="describe">基本场景,鼠标点击移入移出点击交互</div>
|
|
86
|
+
<div id="my-sandbox"></div>
|
|
87
|
+
<script>
|
|
88
|
+
javascript: (function () {
|
|
89
|
+
var script = document.createElement('script');
|
|
90
|
+
script.onload = function () {
|
|
91
|
+
var stats = new Stats();
|
|
92
|
+
document.body.appendChild(stats.dom);
|
|
93
|
+
requestAnimationFrame(function loop() {
|
|
94
|
+
stats.update();
|
|
95
|
+
requestAnimationFrame(loop)
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
script.src = 'https://mrdoob.github.io/stats.js/build/stats.min.js';
|
|
99
|
+
document.head.appendChild(script);
|
|
100
|
+
})()
|
|
101
|
+
</script>
|
|
102
|
+
// umd包
|
|
103
|
+
<script src="./3d.min.js"></script>
|
|
104
|
+
|
|
105
|
+
<script script type="module">
|
|
106
|
+
const scene = new ANOV.Scene({
|
|
107
|
+
orbitControls: true,
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
const geometry = new ANOV.BoxGeometry(2, 2, 2)
|
|
111
|
+
const material = new ANOV.MeshBasicMaterial()
|
|
112
|
+
const box = new ANOV.Mesh(geometry, material)
|
|
113
|
+
|
|
114
|
+
const geometry2 = new ANOV.BoxGeometry(2, 2, 2)
|
|
115
|
+
const material2 = new ANOV.MeshBasicMaterial()
|
|
116
|
+
const box2 = new ANOV.Mesh(geometry2, material2)
|
|
117
|
+
|
|
118
|
+
box.addNatureEventListener('pointermove', (object3D) => {
|
|
119
|
+
object3D.material.color.set(0xFF0000)
|
|
120
|
+
})
|
|
121
|
+
box.addNatureEventListener('pointerleave', (object3D) => {
|
|
122
|
+
object3D.material.color.set('#ccc')
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
box2.addNatureEventListener('click', (object3D) => {
|
|
126
|
+
object3D.material.color.set(0xFF0000)
|
|
127
|
+
})
|
|
128
|
+
box2.addNatureEventListener('pointerleave', (object3D) => {
|
|
129
|
+
object3D.material.color.set('#fff')
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
box2.position.set(5, 0, 0)
|
|
133
|
+
scene.add(box)
|
|
134
|
+
scene.add(box2)
|
|
135
|
+
|
|
136
|
+
scene.scene.background = new ANOV.Color('#345')
|
|
137
|
+
scene.render(document.querySelector('#my-sandbox'))
|
|
138
|
+
scene.startFrameAnimate()
|
|
139
|
+
</script>
|
|
140
|
+
|
|
141
|
+
</body>
|
|
142
|
+
|
|
143
|
+
</html>
|
|
144
|
+
```
|
package/dist/core/camera.d.ts
CHANGED
|
@@ -18,6 +18,15 @@ declare class PerspectiveCamera extends TPerspectiveCamera {
|
|
|
18
18
|
* @param animationMethod
|
|
19
19
|
*/
|
|
20
20
|
demote: (targetObject3D: Object3D, distance: number, duration?: number, animationMethod?: string) => import("@tweenjs/tween.js").Tween<Vector3>;
|
|
21
|
-
|
|
21
|
+
/**
|
|
22
|
+
* 相机曲线漫游
|
|
23
|
+
* @param vec
|
|
24
|
+
* @param points
|
|
25
|
+
* @param linePoints
|
|
26
|
+
* @param helpLine
|
|
27
|
+
* @param lookat
|
|
28
|
+
* @returns
|
|
29
|
+
*/
|
|
30
|
+
surround: (vec: Vector3[], points?: number, linePoints?: number, helpLine?: boolean, lookat?: Vector3) => import("../utils/move").ControlsRetuenFuncType;
|
|
22
31
|
}
|
|
23
32
|
export { PerspectiveCamera };
|
package/dist/core/camera.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
5
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
7
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
2
8
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3
9
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
4
10
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
@@ -12,16 +18,9 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
12
18
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
19
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
14
20
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
15
|
-
import { PerspectiveCamera as TPerspectiveCamera } from 'three';
|
|
16
|
-
import { Direction, moveTo } from "../utils/move";
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* 相机围绕目标物体旋转
|
|
20
|
-
* @param targetObject3D
|
|
21
|
-
* @param radius
|
|
22
|
-
* @param toward
|
|
23
|
-
*/
|
|
24
|
-
var surround = function surround(targetObject3D, radius, toward) {};
|
|
21
|
+
import { BufferGeometry, CatmullRomCurve3, Line, LineBasicMaterial, PerspectiveCamera as TPerspectiveCamera } from 'three';
|
|
22
|
+
import { Direction, moveTo, moveWithLine } from "../utils/move";
|
|
23
|
+
import globalObjectManage from "./global";
|
|
25
24
|
var PerspectiveCamera = /*#__PURE__*/function (_TPerspectiveCamera) {
|
|
26
25
|
_inherits(PerspectiveCamera, _TPerspectiveCamera);
|
|
27
26
|
var _super = _createSuper(PerspectiveCamera);
|
|
@@ -32,7 +31,20 @@ var PerspectiveCamera = /*#__PURE__*/function (_TPerspectiveCamera) {
|
|
|
32
31
|
_defineProperty(_assertThisInitialized(_this), "demote", function (targetObject3D, distance, duration, animationMethod) {
|
|
33
32
|
return moveTo(_assertThisInitialized(_this), targetObject3D, distance, Direction.minus, duration, animationMethod);
|
|
34
33
|
});
|
|
35
|
-
_defineProperty(_assertThisInitialized(_this), "surround",
|
|
34
|
+
_defineProperty(_assertThisInitialized(_this), "surround", function (vec) {
|
|
35
|
+
var points = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 5;
|
|
36
|
+
var linePoints = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 500;
|
|
37
|
+
var helpLine = arguments.length > 3 ? arguments[3] : undefined;
|
|
38
|
+
var lookat = arguments.length > 4 ? arguments[4] : undefined;
|
|
39
|
+
var curve = new CatmullRomCurve3(_toConsumableArray(vec), true);
|
|
40
|
+
var geometry = new BufferGeometry().setFromPoints(curve.getPoints(points));
|
|
41
|
+
var material = new LineBasicMaterial({
|
|
42
|
+
color: '#fff'
|
|
43
|
+
});
|
|
44
|
+
var curveObject = new Line(geometry, material);
|
|
45
|
+
globalObjectManage.scene.add(curveObject);
|
|
46
|
+
return moveWithLine(_assertThisInitialized(_this), curve, linePoints, lookat);
|
|
47
|
+
});
|
|
36
48
|
return _this;
|
|
37
49
|
}
|
|
38
50
|
|
package/dist/core/mesh.js
CHANGED
|
@@ -72,13 +72,13 @@ var Mesh = /*#__PURE__*/function (_TMesh) {
|
|
|
72
72
|
*/
|
|
73
73
|
}, {
|
|
74
74
|
key: "handleClick",
|
|
75
|
-
value: function handleClick(natureEvent) {
|
|
75
|
+
value: function handleClick(natureEvent, intersect) {
|
|
76
76
|
var _this2 = this;
|
|
77
77
|
if (!globalObjectManage.triggerClick) return;
|
|
78
78
|
|
|
79
79
|
// get nature event
|
|
80
80
|
natureEvent.forEach(function (handlefn) {
|
|
81
|
-
handlefn(_this2);
|
|
81
|
+
handlefn(_this2, intersect);
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
84
|
|
|
@@ -89,10 +89,10 @@ var Mesh = /*#__PURE__*/function (_TMesh) {
|
|
|
89
89
|
*/
|
|
90
90
|
}, {
|
|
91
91
|
key: "handlePointerMove",
|
|
92
|
-
value: function handlePointerMove(natureEvent) {
|
|
92
|
+
value: function handlePointerMove(natureEvent, intersect) {
|
|
93
93
|
var _this3 = this;
|
|
94
94
|
natureEvent.forEach(function (handlefn) {
|
|
95
|
-
handlefn(_this3);
|
|
95
|
+
handlefn(_this3, intersect);
|
|
96
96
|
});
|
|
97
97
|
}
|
|
98
98
|
|
|
@@ -129,10 +129,10 @@ var Mesh = /*#__PURE__*/function (_TMesh) {
|
|
|
129
129
|
var object = intersect && intersect.object;
|
|
130
130
|
if (object === this) {
|
|
131
131
|
this.entered = true;
|
|
132
|
-
clickCallback && clickCallback.length > 0 && this.handleClick(clickCallback);
|
|
133
|
-
pointerupCallback && pointerupCallback.length > 0 && this.handleClick(pointerupCallback);
|
|
134
|
-
pointerdownCallback && pointerdownCallback.length > 0 && this.handleClick(pointerdownCallback);
|
|
135
|
-
pointermoveCallback && pointermoveCallback.length > 0 && this.handlePointerMove(pointermoveCallback);
|
|
132
|
+
clickCallback && clickCallback.length > 0 && this.handleClick(clickCallback, intersect);
|
|
133
|
+
pointerupCallback && pointerupCallback.length > 0 && this.handleClick(pointerupCallback, intersect);
|
|
134
|
+
pointerdownCallback && pointerdownCallback.length > 0 && this.handleClick(pointerdownCallback, intersect);
|
|
135
|
+
pointermoveCallback && pointermoveCallback.length > 0 && this.handlePointerMove(pointermoveCallback, intersect);
|
|
136
136
|
} else {
|
|
137
137
|
if (this.entered) {
|
|
138
138
|
this.handlePointerleave();
|
package/dist/core/scene.d.ts
CHANGED
package/dist/core/scene.js
CHANGED
package/dist/export.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import Scene from './core/scene';
|
|
2
|
+
import Mesh from './core/mesh';
|
|
3
|
+
import { PerspectiveCamera } from './core/camera';
|
|
4
|
+
import ModelLoader from './core/model';
|
|
5
|
+
import { ModelType } from './commonEnu';
|
|
6
|
+
import { createLabel } from './utils/createLabel';
|
|
7
|
+
import { Direction } from './utils/move';
|
|
8
|
+
declare const utils: {
|
|
9
|
+
moveTo: (currentObject3D: import("three").Object3D<import("three").Event>, targetObject3D: import("three").Object3D<import("three").Event>, distance: number, direction: Direction, duration?: number | undefined, animationMethod?: string | undefined) => import("@tweenjs/tween.js").Tween<import("three").Vector3>;
|
|
10
|
+
moveLine: (currentObject3D: import("three").Object3D<import("three").Event>, targetObject3D: import("three").Object3D<import("three").Event>) => void;
|
|
11
|
+
moveWithRound: (currentObject3d: import("three").Object3D<import("three").Event>, speed?: number, duration?: number | undefined) => void;
|
|
12
|
+
moveWithLine: (currentObject: import("three").Object3D<import("three").Event>, curve: import("three").CatmullRomCurve3, points?: number, lookat?: import("three").Vector3 | undefined) => import("./utils/move").ControlsRetuenFuncType;
|
|
13
|
+
};
|
|
14
|
+
declare const dom: {
|
|
15
|
+
appendChildren: (node: HTMLElement, children: HTMLElement[]) => void;
|
|
16
|
+
create: (...tags: string[]) => ((options?: import("./utils/createElement").OpsType, children?: HTMLElement[]) => HTMLElement)[];
|
|
17
|
+
createElement: (tag: string, options?: import("./utils/createElement").OpsType, children?: HTMLElement[]) => HTMLElement;
|
|
18
|
+
setAttributes: (el: HTMLElement, attrs?: {
|
|
19
|
+
[key: string]: string;
|
|
20
|
+
} | undefined) => void;
|
|
21
|
+
setClassList: (el: HTMLElement, classList: string[]) => void;
|
|
22
|
+
setEventListeners: (el: HTMLElement, events?: {
|
|
23
|
+
[key: string]: () => void;
|
|
24
|
+
} | undefined) => void;
|
|
25
|
+
};
|
|
26
|
+
export * from 'three';
|
|
27
|
+
export * from './threeCell';
|
|
28
|
+
export { Scene, Mesh, PerspectiveCamera, ModelLoader, createLabel, ModelType, Direction, utils, dom, };
|
package/dist/export.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/* eslint-disable import/export */
|
|
2
|
+
import Scene from "./core/scene";
|
|
3
|
+
import Mesh from "./core/mesh";
|
|
4
|
+
import { PerspectiveCamera } from "./core/camera";
|
|
5
|
+
import ModelLoader from "./core/model";
|
|
6
|
+
import { ModelType } from "./commonEnu";
|
|
7
|
+
import { createLabel } from "./utils/createLabel";
|
|
8
|
+
import { Direction, moveLine, moveTo, moveWithLine, moveWithRound } from "./utils/move";
|
|
9
|
+
import { appendChildren, create, createElement, setAttributes, setClassList, setEventListeners } from "./utils/createElement";
|
|
10
|
+
var utils = {
|
|
11
|
+
moveTo: moveTo,
|
|
12
|
+
moveLine: moveLine,
|
|
13
|
+
moveWithRound: moveWithRound,
|
|
14
|
+
moveWithLine: moveWithLine
|
|
15
|
+
};
|
|
16
|
+
var dom = {
|
|
17
|
+
appendChildren: appendChildren,
|
|
18
|
+
create: create,
|
|
19
|
+
createElement: createElement,
|
|
20
|
+
setAttributes: setAttributes,
|
|
21
|
+
setClassList: setClassList,
|
|
22
|
+
setEventListeners: setEventListeners
|
|
23
|
+
};
|
|
24
|
+
export * from 'three';
|
|
25
|
+
export * from "./threeCell";
|
|
26
|
+
export { Scene, Mesh, PerspectiveCamera, ModelLoader, createLabel, ModelType, Direction, utils, dom };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,27 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import ModelLoader from './core/model';
|
|
5
|
-
import { ModelType } from './commonEnu';
|
|
6
|
-
import { createLabel } from './utils/createLabel';
|
|
7
|
-
import { Direction } from './utils/move';
|
|
8
|
-
declare const utils: {
|
|
9
|
-
moveTo: (currentObject3D: import("three").Object3D<import("three").Event>, targetObject3D: import("three").Object3D<import("three").Event>, distance: number, direction: Direction, duration?: number | undefined, animationMethod?: string | undefined) => import("@tweenjs/tween.js").Tween<import("three").Vector3>;
|
|
10
|
-
moveLine: (currentObject3D: import("three").Object3D<import("three").Event>, targetObject3D: import("three").Object3D<import("three").Event>) => void;
|
|
11
|
-
moveWithRound: (currentObject3d: import("three").Object3D<import("three").Event>, speed?: number, duration?: number | undefined) => void;
|
|
12
|
-
};
|
|
13
|
-
declare const dom: {
|
|
14
|
-
appendChildren: (node: HTMLElement, children: HTMLElement[]) => void;
|
|
15
|
-
create: (...tags: string[]) => ((options?: import("./utils/createElement").OpsType, children?: HTMLElement[]) => HTMLElement)[];
|
|
16
|
-
createElement: (tag: string, options?: import("./utils/createElement").OpsType, children?: HTMLElement[]) => HTMLElement;
|
|
17
|
-
setAttributes: (el: HTMLElement, attrs?: {
|
|
18
|
-
[key: string]: string;
|
|
19
|
-
} | undefined) => void;
|
|
20
|
-
setClassList: (el: HTMLElement, classList: string[]) => void;
|
|
21
|
-
setEventListeners: (el: HTMLElement, events?: {
|
|
22
|
-
[key: string]: () => void;
|
|
23
|
-
} | undefined) => void;
|
|
24
|
-
};
|
|
25
|
-
export * from 'three';
|
|
26
|
-
export * from './threeCell';
|
|
27
|
-
export { Scene, Mesh, PerspectiveCamera, ModelLoader, createLabel, ModelType, Direction, utils, dom, };
|
|
1
|
+
import * as anov3d from './export';
|
|
2
|
+
export * from './export';
|
|
3
|
+
export { anov3d as ANOV, };
|
package/dist/index.js
CHANGED
|
@@ -1,25 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { ModelType } from "./commonEnu";
|
|
7
|
-
import { createLabel } from "./utils/createLabel";
|
|
8
|
-
import { Direction, moveLine, moveTo, moveWithRound } from "./utils/move";
|
|
9
|
-
import { appendChildren, create, createElement, setAttributes, setClassList, setEventListeners } from "./utils/createElement";
|
|
10
|
-
var utils = {
|
|
11
|
-
moveTo: moveTo,
|
|
12
|
-
moveLine: moveLine,
|
|
13
|
-
moveWithRound: moveWithRound
|
|
14
|
-
};
|
|
15
|
-
var dom = {
|
|
16
|
-
appendChildren: appendChildren,
|
|
17
|
-
create: create,
|
|
18
|
-
createElement: createElement,
|
|
19
|
-
setAttributes: setAttributes,
|
|
20
|
-
setClassList: setClassList,
|
|
21
|
-
setEventListeners: setEventListeners
|
|
22
|
-
};
|
|
23
|
-
export * from 'three';
|
|
24
|
-
export * from "./threeCell";
|
|
25
|
-
export { Scene, Mesh, PerspectiveCamera, ModelLoader, createLabel, ModelType, Direction, utils, dom };
|
|
1
|
+
import * as anov3d from "./export";
|
|
2
|
+
export * from "./export";
|
|
3
|
+
|
|
4
|
+
// umd
|
|
5
|
+
export { anov3d as ANOV };
|
package/dist/type.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Intersection } from 'three';
|
|
1
2
|
import type Mesh from './core/mesh';
|
|
2
3
|
export declare type CubeEventType = 'click' | 'pointerup' | 'pointerdown' | 'pointermove' | 'pointerleave';
|
|
3
|
-
export declare type EventHandleFn<T> = (event: Mesh) => void;
|
|
4
|
+
export declare type EventHandleFn<T> = (event: Mesh, intersect?: Intersection) => void;
|
package/dist/utils/move.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Object3D, Vector3 } from 'three';
|
|
2
|
+
import { CatmullRomCurve3 } from 'three';
|
|
2
3
|
import * as TWEEN from '@tweenjs/tween.js';
|
|
3
4
|
export declare enum Direction {
|
|
4
5
|
plus = "plus",
|
|
@@ -14,16 +15,19 @@ export declare enum Direction {
|
|
|
14
15
|
* @param animationMethod
|
|
15
16
|
*/
|
|
16
17
|
export declare const moveTo: (currentObject3D: Object3D, targetObject3D: Object3D, distance: number, direction: Direction, duration?: number, animationMethod?: string) => TWEEN.Tween<Vector3>;
|
|
17
|
-
export
|
|
18
|
+
export interface ControlsRetuenFuncType {
|
|
19
|
+
remove: () => void;
|
|
20
|
+
increaseSpeed: (currentStep: number) => void;
|
|
21
|
+
recoverSpeed: () => void;
|
|
22
|
+
}
|
|
18
23
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* 5. 运动的时间
|
|
25
|
-
* 6. 运动的方式
|
|
24
|
+
* 曲线路径移动
|
|
25
|
+
* @param currentObject
|
|
26
|
+
* @param curve
|
|
27
|
+
* @param points 曲线分割数, 同时也决定了运动速度
|
|
28
|
+
* @param lookat 默认曲线方向
|
|
26
29
|
*/
|
|
30
|
+
export declare const moveWithLine: (currentObject: Object3D, curve: CatmullRomCurve3, points?: number, lookat?: Vector3) => ControlsRetuenFuncType;
|
|
27
31
|
/**
|
|
28
32
|
* base 圆周运动
|
|
29
33
|
* @param currentObject3d
|
|
@@ -33,7 +37,6 @@ export declare const moveWithLine: (points: Vector3[], duration?: number) => voi
|
|
|
33
37
|
export declare const moveWithRound: (currentObject3d: Object3D, speed?: number, duration?: number) => void;
|
|
34
38
|
/**
|
|
35
39
|
* move 方法2 移动辅助线
|
|
36
|
-
* todo bug待修复
|
|
37
40
|
* @param currentObject3D
|
|
38
41
|
* @param targetObject3D
|
|
39
42
|
*/
|
package/dist/utils/move.js
CHANGED
|
@@ -68,19 +68,45 @@ var createLine = function createLine(points) {
|
|
|
68
68
|
});
|
|
69
69
|
return [new Line(geometry, material), curve];
|
|
70
70
|
};
|
|
71
|
-
export var moveWithLine = function moveWithLine(points, duration) {
|
|
72
|
-
// const line = createLine(points)
|
|
73
|
-
};
|
|
74
|
-
|
|
75
71
|
/**
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
* 5. 运动的时间
|
|
82
|
-
* 6. 运动的方式
|
|
72
|
+
* 曲线路径移动
|
|
73
|
+
* @param currentObject
|
|
74
|
+
* @param curve
|
|
75
|
+
* @param points 曲线分割数, 同时也决定了运动速度
|
|
76
|
+
* @param lookat 默认曲线方向
|
|
83
77
|
*/
|
|
78
|
+
export var moveWithLine = function moveWithLine(currentObject, curve) {
|
|
79
|
+
var points = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 500;
|
|
80
|
+
var lookat = arguments.length > 3 ? arguments[3] : undefined;
|
|
81
|
+
var totlePoints = curve.getPoints(points);
|
|
82
|
+
var totle = totlePoints.length;
|
|
83
|
+
var index = 0;
|
|
84
|
+
var step = 1;
|
|
85
|
+
var calcIndex = function calcIndex(index) {
|
|
86
|
+
return index > totle ? index - totle - 1 : index;
|
|
87
|
+
};
|
|
88
|
+
var handleCallback = function handleCallback() {
|
|
89
|
+
if (index >= totle) index = calcIndex(index);
|
|
90
|
+
var nextPoint = totlePoints[calcIndex(index) % totle];
|
|
91
|
+
currentObject.position.set(nextPoint.x, nextPoint.y, nextPoint.z);
|
|
92
|
+
if (lookat) currentObject.lookAt(lookat);else currentObject.lookAt(totlePoints[calcIndex(index + 1) % totle]);
|
|
93
|
+
index += step;
|
|
94
|
+
};
|
|
95
|
+
globalControl.add(handleCallback, 100000);
|
|
96
|
+
globalControl.start();
|
|
97
|
+
return {
|
|
98
|
+
remove: function remove() {
|
|
99
|
+
return globalControl.remove(handleCallback);
|
|
100
|
+
},
|
|
101
|
+
increaseSpeed: function increaseSpeed() {
|
|
102
|
+
var currentStep = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
103
|
+
step = currentStep + step;
|
|
104
|
+
},
|
|
105
|
+
recoverSpeed: function recoverSpeed() {
|
|
106
|
+
step = 1;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
};
|
|
84
110
|
|
|
85
111
|
/**
|
|
86
112
|
* base 圆周运动
|
|
@@ -106,7 +132,6 @@ export var moveWithRound = function moveWithRound(currentObject3d) {
|
|
|
106
132
|
|
|
107
133
|
/**
|
|
108
134
|
* move 方法2 移动辅助线
|
|
109
|
-
* todo bug待修复
|
|
110
135
|
* @param currentObject3D
|
|
111
136
|
* @param targetObject3D
|
|
112
137
|
*/
|