@@ -72,7 +85,7 @@ export default class HeadEditor extends Component {
color={this.state.hair}
colors={hairColors}
onChange={(e) => {
- this.setState({hair:e.rgb});
+ this.setState({hair:e});
EditorUtils.setMaterialColor(e.hex, this.materials[0])
EditorUtils.setMaterialColor(e.hex, this.materials[1])
}}
@@ -84,7 +97,7 @@ export default class HeadEditor extends Component {
color={this.state.eye}
colors={eyeColors}
onChange={(e) => {
- this.setState({eye:e.rgb});
+ this.setState({eye:e});
EditorUtils.setMaterialColor(e.hex, this.materials[2])
}}
/>
diff --git a/src/components/jacket-editor.js b/src/components/jacket-editor.js
index 2fc3f0faa..cb049c0dc 100644
--- a/src/components/jacket-editor.js
+++ b/src/components/jacket-editor.js
@@ -1,15 +1,44 @@
import React, { Component } from "react";
+import * as THREE from "three";
+
+import ColorPicker from "./color-picker";
+import {DisableButton, PresetColorButton, CustomColorButton, TextureButton} from "./buttons"
+
import {EditorPage} from "./editor-page"
-import {DisableButton, PresetColorButton, CustomColorButton} from "./buttons"
+import EditorUtils from "./editor-utils"
+
+import { LabeledTexture } from "../labeled-texture";
+import Material from "./material"
+
+import jacket from "../../includes/textures/jacket_default.png"
+
+import ae from "../../includes/textures/logo_front/ae.png";
+import duck from "../../includes/textures/logo_front/duck.png";
+import gt from "../../includes/textures/logo_front/gt.png";
+
+const jacketColors = ["#7d0c1e", "#cedded", "#92a1b1", "#3479b7"];
export default class JacketEditor extends Component {
constructor(props) {
super(props);
+
+ this.materials = [
+ new Material(this.props.model.material.clone(), "jacket", [new LabeledTexture(jacket)]),
+ new Material(this.props.model.material.clone(), "jacketLogoBack",
+ [new LabeledTexture(duck),new LabeledTexture(ae),new LabeledTexture(gt)], false, true, 662,476,
+ 220,270, true)
+ ]
+
+ this.state = {
+ jacketColor: new THREE.Color().randomize().getHexStringFull()
+ }
+
this.editorPage = React.createRef();
}
- setActive(isActive) {
- this.editorPage.current.setActive(isActive);
+ setLogo(index, src) {
+ this.materials[index].setActive(src!=null);
+ (src == null) ? null : this.materials[index].setTextureByPath(src) ;
}
render() {
@@ -18,12 +47,16 @@ export default class JacketEditor extends Component {
diff --git a/src/components/material.js b/src/components/material.js
index 3714ce780..0fcd6aa2c 100644
--- a/src/components/material.js
+++ b/src/components/material.js
@@ -30,18 +30,10 @@ export default class Material {
this.material.needsUpdate = true;
}
- setTextureByPath(path) {
- const index = this.labeledTextures.findIndex((element) => {
- return element.path == path;
- });
-
- setTexture(index);
- }
setTexture(index) {
if (index >= this.labeledTextures.length || index < 0) return;
-
this.labeledTextures[index]
.getTexture(
this.x,
@@ -50,11 +42,18 @@ export default class Material {
this.height,
this.scaleTexture
).then(texture => {
- this.material.visible = this.active;
- this.material.needsUpdate = true;
- this.material.map = texture;
- this.index = index;
+ this.material.visible = this.active;
+ this.material.needsUpdate = true;
+ this.material.map = texture;
+ this.index = index;
+ });
+ }
+
+ setTextureByPath(path) {
+ const index = this.labeledTextures.findIndex((element) => {
+ return element.src == path;
});
+ this.setTexture(index);
}
getTexture() {
@@ -62,7 +61,7 @@ export default class Material {
this.scaleTexture);
}
- getDownloadTexture() {
+ getBakedTexture() {
//get current texture image
const img = this.material.map.image;
const clr = this.material.color;
diff --git a/src/components/shirt-editor.js b/src/components/shirt-editor.js
index e3ce27431..1bdc0f5df 100644
--- a/src/components/shirt-editor.js
+++ b/src/components/shirt-editor.js
@@ -2,6 +2,7 @@ import React, { Component } from "react";
import * as THREE from "three";
import ColorPicker from "./color-picker";
+import Swatches from "./color-picker2"
import {EditorPage} from "./editor-page"
import EditorUtils from "./editor-utils"
@@ -9,6 +10,7 @@ import { LabeledTexture } from "../labeled-texture";
import Material from "./material"
import shirt from "../../includes/textures/shirt_default.png";
+import jacket from "../../includes/textures/jacket_default.png";
import ae from "../../includes/textures/logo_front/ae.png";
import duck from "../../includes/textures/logo_front/duck.png";
@@ -24,51 +26,106 @@ export default class ShirtEditor extends Component {
this.materials = [
new Material(this.props.model.material.clone(), "shirt", [new LabeledTexture(shirt)]),
- new Material(this.props.model.material.clone(), "shirtfrontlogo",
- [new LabeledTexture(duck),new LabeledTexture(ae),new LabeledTexture(gt)], false, true, 148,476,
- 220,270, true)
+
+ new Material(this.props.model.material.clone(), "logoFront",
+ [new LabeledTexture(duck),new LabeledTexture(ae),new LabeledTexture(gt)], false, true, 148,476,
+ 220,270, true),
+ new Material(this.props.model.material.clone(), "jacket", [new LabeledTexture(jacket)]),
+ new Material(this.props.model.material.clone(), "logoBack",
+ [new LabeledTexture(duck),new LabeledTexture(ae),new LabeledTexture(gt)], false, true, 662,476,
+ 220,270, true),
]
this.state = {
shirt:new THREE.Color().randomize().getHexStringFull(),
+ jacket:new THREE.Color().randomize().getHexStringFull(),
}
EditorUtils.setMaterialColor(this.state.shirt, this.materials[0])
this.editorPage = React.createRef();
- //this.setLogo();
}
- setLogo() {
- this.materials[0].setTexture(0);
+ setLogo(index, src) {
+ this.materials[index].setActive(src!=null);
+ (src == null) ? null : this.materials[index].setTextureByPath(src) ;
}
render() {
return (
-
+
- {
- this.setState({hair:e.rgb});
- EditorUtils.setMaterialColor(e.hex, this.materials[0])
+ {
+ EditorUtils.setMaterialColor(color, this.materials[0])
+ }}
+ />
+
+
+
+ {
+ if (color == 'none') {
+ this.materials[2].setActive(false);
+ } else {
+ this.materials[2].setActive(true);
+ EditorUtils.setMaterialColor(color, this.materials[2])
+ }
}}
/>
+
-
-
-
-
+
+ {
+ if (src == 'none') {
+ this.setLogo(1, null);
+ } else {
+ this.setLogo(1, src)
+ }
+ }}
+ onUpload={(file) => {
+ const path = window.URL.createObjectURL(file);
+ this.materials[1].labeledTextures.push(new LabeledTexture(path))
+ console.log(this.materials[1].labeledTextures)
+ this.setLogo(1, path)
+ }}
+ />
-
-
-
-
+ {
+ if (src == 'none') {
+ this.setLogo(3, null);
+ } else {
+ this.setLogo(3, src)
+ }
+ }}
+ onUpload={(file) => {
+ const path = window.URL.createObjectURL(file);
+ this.materials[3].labeledTextures.push(new LabeledTexture(path))
+ console.log(this.materials[3].labeledTextures)
+ this.setLogo(3, path)
+ }}
+ />
+
);
diff --git a/src/labeled-texture.js b/src/labeled-texture.js
index b47bf26f0..c3d9987fc 100644
--- a/src/labeled-texture.js
+++ b/src/labeled-texture.js
@@ -4,6 +4,7 @@ export class LabeledTexture {
constructor(path, label = "Default", autoLoad = false) {
this.label = label;
this.path = path;
+ this.src = path;
this.loaded = undefined;
if (autoLoad) this.getTexture(path);
}
diff --git a/src/main.js b/src/main.js
index 817c3b308..00f7c3457 100644
--- a/src/main.js
+++ b/src/main.js
@@ -1,6 +1,7 @@
import * as THREE from "three";
import * as React from "react";
import * as ReactDOM from "react-dom";
+import { cloneDeep } from "lodash"
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
import styles from "./stylesheets/main.scss";
@@ -87,8 +88,11 @@ async function init() {
function processModel(src, bodyType, hair, val, success) {
var mod = null;
+ var fullscene = null;
if (success) {
+ fullscene = cloneDeep(val)
+
val.scene.scale.x = 30;
val.scene.scale.y = 30;
val.scene.scale.z = 30;
@@ -105,9 +109,9 @@ async function init() {
}
if (models[bodyType]) {
- models[bodyType][hair] = {model: mod, src:src}
+ models[bodyType][hair] = {model: mod, fullscene: fullscene}
} else {
- models[bodyType] = {[hair]: {model: mod, src:src}}
+ models[bodyType] = {[hair]: {model: mod, fullscene: fullscene}}
}
cnt+=1;
}
diff --git a/src/stylesheets/editor.scss b/src/stylesheets/editor.scss
index 33bcae733..f955740e4 100644
--- a/src/stylesheets/editor.scss
+++ b/src/stylesheets/editor.scss
@@ -7,10 +7,17 @@
.editorPage {
height: 100%;
padding: 20px;
+ padding-bottom: 0;
display: flex;
flex-direction: column;
justify-content: start;
align-items: center;
//background-color: blue;
+ &>div {
+ margin-bottom: 10px;
+ }
+ &>label {
+ margin-bottom: 5px;
+ }
}
diff --git a/src/stylesheets/main.scss b/src/stylesheets/main.scss
index 3c5f26205..563d89908 100644
--- a/src/stylesheets/main.scss
+++ b/src/stylesheets/main.scss
@@ -1,9 +1,23 @@
body {
font-family: Arial, Helvetica, sans-serif;
+ font-weight: bold;
+ display: flex;
+ justify-content: center;
}
#container {
+ margin-top: 30px;
height: 400px;
+ max-width: 900px;
+ display: flex;
+ flex-direction: row;
+ align-content: center;
+ justify-content: space-between;
+ width: 100%;
+
+ @media screen and (max-width: 900px) and (max-device-width: 900px){
+ flex-direction: column;
+ }
}
td {
@@ -17,10 +31,11 @@ td {
}
#options {
- display: inline-block;
+ display: inline-flex;
+ flex-direction: column;
vertical-align: top;
height: 100%;
-
+ width: 360px;
.texture-layer {
height: 32px;