import {MTLLoader} from "../lib/MTLLoader.js";
|
import {OBJLoader} from "../lib/OBJLoader.js";
|
import * as THREE from '../three.module.js';
|
|
function StoreGoods(object, data, shelf) {
|
let that = this;
|
that.data = data;
|
that.object = object;
|
that.shelf = shelf;
|
let palletList = [];
|
let goodsList = [];
|
|
for (let i=0;i<that.data.length;i++) {
|
let obj = that.data[i];
|
if (obj.loc_sts === 'D') {
|
palletList.push(obj);
|
} else if (obj.loc_sts === 'F') {
|
palletList.push(obj);
|
goodsList.push(obj);
|
}
|
}
|
|
const manager = new THREE.LoadingManager();
|
new MTLLoader(manager)
|
.setPath( '../static/model/obj/' )
|
.load( 'pallet.mtl', function ( materials ) {
|
materials.preload();
|
new OBJLoader( manager )
|
.setMaterials( materials )
|
.setPath( '../static/model/obj/' )
|
.load( 'pallet.obj', function ( obj ) {
|
obj.traverse (function (child) {
|
child.castShadow = true;
|
if (child instanceof THREE.Mesh) {
|
child.material = new THREE.MeshLambertMaterial({
|
color: 0x2F4F4F
|
});
|
}
|
});
|
obj.scale.set(4, 4, 3.5);
|
obj.position.x = -1;
|
obj.position.y = 22;
|
obj.position.z = -46;
|
|
palletList.map(item => {
|
var clone = obj.clone();
|
let positionX = that.shelf.positionX || 0;
|
let positionY = that.shelf.positionY || 0;
|
let positionZ = that.shelf.positionZ || 0;
|
|
clone.position.x = -18 + positionX;
|
clone.position.y = 22 + positionY;
|
clone.position.z = -46 + positionZ;
|
that.object.addObject(clone);
|
})
|
}, null, null );
|
});
|
|
}
|
|
export {StoreGoods}
|