Files
ylst-pc/src/views/Creative/components/CreateMaterial.constant.js
2022-12-24 15:21:40 +08:00

241 lines
4.6 KiB
JavaScript

export const THREE_D_TYPE = {
PANORAMA: 1,
ENV_3D: 2,
SHELF: 3,
EXHIBITION_BOOTH: 4,
WARE: 5,
RING_3D: 6,
EMPTY_3D: 7,
CHARTLET: 8,
}
export const THREE_D_TYPE_S = [
{
type: THREE_D_TYPE.PANORAMA,
name: "3D全景"
},
{
type: THREE_D_TYPE.ENV_3D,
name: "三维环境"
},
{
type: THREE_D_TYPE.SHELF,
name: "货架模型"
},
{
type: THREE_D_TYPE.EXHIBITION_BOOTH,
name: "展台模型"
},
{
type: THREE_D_TYPE.WARE,
name: "商品模型"
},
{
type: THREE_D_TYPE.RING_3D,
name: "3D环物"
},
{
type: THREE_D_TYPE.EMPTY_3D,
name: "空白模型"
},
{
type: THREE_D_TYPE.CHARTLET,
name: "贴图"
},
];
const factorys = [
{
type: THREE_D_TYPE.PANORAMA,
build(data){
var url = "";
try{
url = data.fileList[0].response.url;
}
catch(e){ }
return {
...data,
data: {
"url": url,
"urlSmall": url,
"urlThumb": "",
"urlDepth": "",
"urlShelfExr": "",
"rotationY": 0,
"multiply": 3
}
};
}
},
{
type: THREE_D_TYPE.ENV_3D,
build(data){
return {
...data
};
}
},
{
type: THREE_D_TYPE.SHELF,
build(data){
var url = "";
var key = new Date().getTime();
var cells = [];
try{
data.fileList.forEach(file => {
if(file.response.url){
url = file.response.url;
}
if(file.response.cells){
cells = file.response.cells;
}
})
}
catch(e){ }
//#region 返回值
return {
...data,
data: {
"name": `${data.title}`,
"planetid": `shelf-${key}`,
"id": `shelf-${key}`,
"url": url,
"urlThumb": "",
"hideWhenSurvey": true,
"cells": cells,
"position": {
"x": 2.5193034425825946,
"y": -1.0605054800098004,
"z": 4.5102810375396987e-17
},
"rotation": {
"x": 0,
"y": -1.5707963267948966,
"z": 0
},
"scale": {
"x": 1,
"y": 1,
"z": 1
}
}
}
//#endregion
}
},
{
type: THREE_D_TYPE.EXHIBITION_BOOTH,
build(data){
//#region 返回值
var key = new Date().getTime();
return {
...data,
data: {
"name": `${data.title}`,
"planetid": `shelf-${key}`,
"id": `shelf-${key}`,
"url": "",
"urlThumb": "",
"hideWhenSurvey": true,
"cells": [],
"position": {
"x": 2.5193034425825946,
"y": -1.0605054800098004,
"z": 4.5102810375396987e-17
},
"rotation": {
"x": 0,
"y": -1.5707963267948966,
"z": 0
},
"scale": {
"x": 1,
"y": 1,
"z": 1
}
}
}
//#endregion
}
},
{
type: THREE_D_TYPE.WARE,
build(data){
var url = data.fileList[0].response.url;
var key = new Date().getTime();
return {
...data,
data: {
"planetid": `ware-${key}`,
"name": `${data.title}`,
"id": `ware-${key}`,
"type": 1,
"commodity": {
"url": url
},
"texture": null,
"urlThumb": "",
"surveyLogo": "",
"surveyPrice": 10
},
};
}
},
{
type: THREE_D_TYPE.RING_3D,
build(data){
return {
...data
};
}
},
{
type: THREE_D_TYPE.EMPTY_3D,
build(data){
var url = data.fileList[0].response.url;
var key = new Date().getTime();
return {
...data,
data: {
"id": `model-${key}`,
"name": `${data.title}`,
"url":url,
"urlThumb": "",
"uvGroup": "uv0001"
},
};
}
},
{
type: THREE_D_TYPE.CHARTLET,
build(data){
var url = data.fileList[0].response.url;
var key = new Date().getTime();
return {
...data,
data: {
"id": `texture-${key}`,
"name": `${data.title}`,
"relUvGroup": "uv0001",
"url": url,
"urlSmall": url,
"relCommodityId": "vB8DxY"
}
};
}
},
];
export const buildData = (data) => {
var factory = factorys.find(x => x.type == data.type);
if(!factory) throw new Error("CreateMaterial.constant: 未找到素材数据构造方法");
return factory.build(data);
};