three-base 1.0.15 → 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/lib/Transition.ts +7 -1
- 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
|
|
package/lib/Transition.ts
CHANGED
|
@@ -92,6 +92,7 @@ export default class Transition {
|
|
|
92
92
|
} else {
|
|
93
93
|
this.onChangeCall(this.getJson());
|
|
94
94
|
}
|
|
95
|
+
return this;
|
|
95
96
|
}
|
|
96
97
|
|
|
97
98
|
runbindThis = this.run.bind(this);
|
|
@@ -144,7 +145,7 @@ export default class Transition {
|
|
|
144
145
|
return 0;
|
|
145
146
|
}
|
|
146
147
|
|
|
147
|
-
set(param: TParam): this {
|
|
148
|
+
async set(param: TParam): Promise<this> {
|
|
148
149
|
|
|
149
150
|
let timetemp = performance.now() + this._delay;;
|
|
150
151
|
|
|
@@ -184,6 +185,11 @@ export default class Transition {
|
|
|
184
185
|
|
|
185
186
|
}
|
|
186
187
|
threeUtils.addEventListener("requestAnimationFrame", this.runbindThis);
|
|
188
|
+
|
|
189
|
+
while (!this._isDone) {
|
|
190
|
+
await new Promise(resolve => setTimeout(resolve, 50));
|
|
191
|
+
}
|
|
192
|
+
|
|
187
193
|
return this;
|
|
188
194
|
}
|
|
189
195
|
// 重置起始和终止位置
|