12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- import * as THREE from "three";
- import HorizontalBox from "./HorizontalBox";
- import VerticalBox from "./VerticalBox";
- export default class BoxManager {
- constructor(scene) {
- this.scene = scene;
- this.loadingManager = new THREE.LoadingManager();
- this.loader = new THREE.TextureLoader(this.loadingManager);
- this.model = new THREE.Group();
- this.model.name = "boxManager";
- this.maps = {};
- this.imgList = [];
- this.opacity = 1;
- this.onBindEvent();
- }
- load = (list, type) => {
- console.log("this.model.name", this.model.name);
- list.forEach((item, index) => {
- if (type === 1) {
- //横排
- console.log("横排");
- const box = new HorizontalBox(this, item, index);
- this.model.add(box);
- }
- if (type === 2) {
- //竖排
- const box = new VerticalBox(this, item, index);
- // console.log("竖排");
- this.model.add(box);
- }
- });
- this.scene.scene.add(this.model);
- console.log("this.scene.scene", this.scene.scene);
- };
- onBindEvent = () => {
- const _this = this;
- this.loadingManager.onStart = function (url, itemsLoaded, itemsTotal) {
- // console.log( 'Started loading file: ' + url + '.\nLoaded ' + itemsLoaded + ' of ' + itemsTotal + ' files.' );
- console.log("loading_manager: loading...");
- };
- this.loadingManager.onLoad = function () {
- console.log("loading_manager: loading complete!");
- };
- this.loadingManager.onProgress = function (url, itemsLoaded, itemsTotal) {
- // console.log( 'Loading file: ' + url + '.\nLoaded ' + itemsLoaded + ' of ' + itemsTotal + ' files.' );
- };
- this.loadingManager.onError = function (url) {
- console.error("loading_manager: error loading " + url);
- };
- };
- setVisible = (val) => {
- if (!this.model) return;
- this.model.visible = val;
- };
- setOpacity = (val) => {
- this.material.opacity = val;
- };
- }
|