three-base 1.0.52 → 1.0.54

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/declare.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
 
2
2
  // 声明模块
3
- // declare module "canvas-to-png";
4
3
 
5
4
  declare interface Window {
6
5
  }
package/lib/ThreeBase.ts CHANGED
@@ -15,7 +15,6 @@ import threeLoader from "./threeLoader";
15
15
  import ThreeMouse from "./ThreeMouse";
16
16
  import threeUtils from "./threeUtils";
17
17
  import Transition from "./Transition";
18
- import Canvas2image from "canvas-to-png";
19
18
 
20
19
  // three.js 的基础对象
21
20
  export default class ThreeBase extends EventDispatcher {
@@ -283,6 +282,17 @@ export default class ThreeBase extends EventDispatcher {
283
282
  //是否需要渲染, 当autoRender=false的时候就需要 手动触发渲染
284
283
  needRender = false;
285
284
 
285
+
286
+ // 停止渲染
287
+ stopRender(){
288
+ threeUtils.removeEventListener("requestAnimationFrame", this.renderBindThis);
289
+ this.renderer.forceContextLoss();
290
+ // 标记上下文被销毁了
291
+ this.isRendererContextLost = true;
292
+ this.resize(100, 100);
293
+ this.renderer.domElement.style.opacity = "0";
294
+ }
295
+
286
296
  // 渲染场景
287
297
  render() {
288
298
 
@@ -291,12 +301,7 @@ export default class ThreeBase extends EventDispatcher {
291
301
 
292
302
  // canvas 没有在页面上面的话 就跳过渲染
293
303
  if (!threeUtils.inDocument(this.renderer.domElement)) {
294
- threeUtils.removeEventListener("requestAnimationFrame", this.renderBindThis);
295
- this.renderer.forceContextLoss();
296
- // 标记上下文被销毁了
297
- this.isRendererContextLost = true;
298
- this.resize(100, 100);
299
- this.renderer.domElement.style.opacity = "0";
304
+ this.stopRender();
300
305
  return;
301
306
  }
302
307
 
package/lib/threeUtils.ts CHANGED
@@ -159,15 +159,11 @@ class ThreeUtils extends EventDispatcher {
159
159
 
160
160
  //缩放至指定大小
161
161
  scaleTo(object3d: Object3D | BufferGeometry, size: number = 1) {
162
+ const originSize = this.getSize(object3d);
163
+ const scale = size / Math.max(originSize.x, originSize.y, originSize.z);
162
164
  if (object3d instanceof Object3D) {
163
- this.box3.setFromObject(object3d);
164
- this.box3.getSize(this.size);
165
- const scale = size / Math.max(this.size.x, this.size.y, this.size.z);
166
165
  object3d.scale.multiplyScalar(scale);
167
- object3d.updateMatrixWorld(true);
168
166
  } else if (object3d instanceof BufferGeometry) {
169
- const originSize = this.getSize(object3d);
170
- const scale = size / Math.max(originSize.x, originSize.y, originSize.z);
171
167
  object3d.scale(scale, scale, scale);
172
168
  }
173
169
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "three-base",
3
- "version": "1.0.52",
3
+ "version": "1.0.54",
4
4
  "description": "three 3d three-base",
5
5
  "repository": {
6
6
  "type": "git",