|
@@ -6,6 +6,9 @@ import { Mitt } from "./mitt.js";
|
|
|
import testData from "./save.json";
|
|
|
const stats = new Stats();
|
|
|
|
|
|
+function sleep(ms) {
|
|
|
+ return new Promise((resolve) => setTimeout(resolve, ms));
|
|
|
+}
|
|
|
const saveFile = function (strData, filename) {
|
|
|
var link = document.createElement("a");
|
|
|
if (typeof link.download === "string") {
|
|
@@ -30,6 +33,7 @@ export default class Scene extends Mitt {
|
|
|
this.sceneType = 1;
|
|
|
this.width = 0;
|
|
|
this.height = 0;
|
|
|
+ this.defaultZoom = 250;
|
|
|
this.inited = false;
|
|
|
|
|
|
this.init = () => {
|
|
@@ -58,7 +62,7 @@ export default class Scene extends Mitt {
|
|
|
0.1,
|
|
|
1000
|
|
|
);
|
|
|
- this.orthCamera.zoom = 250;
|
|
|
+ this.orthCamera.zoom = this.defaultZoom;
|
|
|
|
|
|
this.orthCamera.position.set(0, 10, 0);
|
|
|
this.orthCamera.lookAt(0, 0, 0);
|
|
@@ -178,10 +182,11 @@ export default class Scene extends Mitt {
|
|
|
this.player.editing(item);
|
|
|
}
|
|
|
|
|
|
- screenshot() {
|
|
|
+ screenshot(x, index) {
|
|
|
var imgData, imgNode;
|
|
|
const times = 4;
|
|
|
- this.orthCamera.zoom = 230;
|
|
|
+ this.orthCamera.zoom = this.defaultZoom;
|
|
|
+ this.scene.position.x = x || 0;
|
|
|
|
|
|
this.renderer.setSize(this.width * times, this.height * times);
|
|
|
this.orthCamera.aspect = this.width / this.height;
|
|
@@ -193,9 +198,39 @@ export default class Scene extends Mitt {
|
|
|
|
|
|
const dataURL = this.renderer.domElement.toDataURL("image/jpeg");
|
|
|
|
|
|
- saveFile(dataURL, "test.jpg");
|
|
|
+ saveFile(dataURL, `${index}.jpg`);
|
|
|
this.onResize(this.width, this.height);
|
|
|
}
|
|
|
+
|
|
|
+ test() {
|
|
|
+ this.orthCamera.zoom = this.defaultZoom;
|
|
|
+ const object = this.boxManager.model;
|
|
|
+ const total = this.boxManager.imgList.length;
|
|
|
+
|
|
|
+ object.updateMatrixWorld();
|
|
|
+ this.orthCamera.updateProjectionMatrix();
|
|
|
+ const boundingBox = new THREE.Box3().setFromObject(object);
|
|
|
+
|
|
|
+ // 计算宽度、高度和深度
|
|
|
+ const width = boundingBox.max.x - boundingBox.min.x;
|
|
|
+ const one = width / total;
|
|
|
+ let slides = Math.floor(total / 3);
|
|
|
+ console.log("slides", slides);
|
|
|
+ if (slides > 1) {
|
|
|
+ for (var i = 0; i <= slides; i++) {
|
|
|
+ (function (index, that) {
|
|
|
+ setTimeout(function () {
|
|
|
+ const offset = -(one * 3 * index + 0.21);
|
|
|
+ console.log("Iteration:", offset);
|
|
|
+ that.screenshot(offset, index);
|
|
|
+
|
|
|
+ console.log(`Width: ${offset}`);
|
|
|
+ }, index * 1000);
|
|
|
+ })(i, this); // 传递当前迭代的索引i给setTimeout的回调函数
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
onBindEvent = () => {
|
|
|
//window.addEventListener('resize', this.onResize)
|
|
|
};
|