Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SG painting on image object #2011

Open
wants to merge 96 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
b8dde9e
Implemented drawing on image
May 15, 2020
cb5a43b
Added reseting of mesh's prev position
May 15, 2020
10dc60e
Changed drawing to percentage based
May 18, 2020
29f3317
Impelemented image texture saving
May 18, 2020
247f14a
Fixed drawing resets on save as a new shot
May 25, 2020
7f85ec2
Added image tab for mesh settings
May 27, 2020
a3ebaa9
Added eraser mesh and fixed image needs to be reselected to apply me…
May 27, 2020
1057d1f
Improved simple drawing mesh path
May 28, 2020
0dbedc9
Fixed modified texture csaves not on board save
May 28, 2020
559f658
Changed geometry to rounded plane geometry
Jun 1, 2020
fd0211c
Changed drawing mesh to global
Jun 1, 2020
8b826ee
Implemented drawing mode
Jun 1, 2020
15a20e9
Added button to clean image
Jun 1, 2020
2285b71
Fixed images texture saving
Jun 2, 2020
048ee03
Fixed can draw on invisible image
Jun 2, 2020
0e4a8da
Implemented texture loading for scene background
Jun 4, 2020
c36db07
Added simle cube texture pattern recognition and applied cubetexture …
Jun 5, 2020
27e8729
Added three standard pattern recognition
Jun 5, 2020
b563e0a
Added cube textures to shot-explorer
Jun 5, 2020
93aa3b8
Imelemented cubemap drawing
Jun 10, 2020
e2347c5
Implemented cube map changes saving
Jun 11, 2020
0ab24d0
Refactored cube texture creattor
Jun 12, 2020
4b04513
Added check for image extension when loading scene texture
Jun 12, 2020
d96282e
Implemented cleaning up of unsed textures and geometries
Jun 12, 2020
6bf3408
Fixed shot-generator image caching
Jun 12, 2020
188e471
Fixed xr caching image
Jun 12, 2020
a69881f
Clean up code
Jun 12, 2020
1c83952
Merged sg-cubemaps with sg-image-drawing
Jun 17, 2020
f2fc090
Implemented cubemaps loading in xr
Jun 17, 2020
44774c1
Combined drawing on images with drawing on cubemap
Jun 17, 2020
f5606b9
Added drawing on cube map when draw mode is on
Jun 17, 2020
df251c4
Extracted scene drawing texture from image drawing textures array
Jun 18, 2020
d3a00b3
Implemented reseting brush when moving to different face
Jun 18, 2020
d2144f7
Implemented saving cube map through temp file
Jun 18, 2020
920ee48
Changed naming from scenetexture to sceneTexture
Jun 18, 2020
8f8cbb1
Fixed shot-explorer naming convention
Jun 18, 2020
bacb43f
Impelemented temp resouce clean up + fixed draw is undefined
Jun 18, 2020
f93d6e4
Improved simple brush
Jun 18, 2020
c87071a
Fixed temp background doesn't clean up properly
Jun 18, 2020
9316db6
Impelemented percentage based brush
Jun 19, 2020
a93dce7
Renamed mesh to brush
Jun 19, 2020
cd21ba3
Fixed cube map uv jumps on face end
Jun 19, 2020
b371b32
Added hotkeys to go into drawing mode cmd+u
Jun 19, 2020
626e326
Implemented image compressing
Jun 22, 2020
47aba27
Added tabs to the scene inspector
Jun 23, 2020
ea88693
Removed hotkeys drawing mode switch
Jun 23, 2020
d9ab569
Imeplemented simple texture for background
Jun 23, 2020
e4191b0
Implemented ability to remove selected background texture
Jun 23, 2020
d0f478d
Cleaned up
Jun 23, 2020
7a91a3a
Fixed background disappears on first draw
Jun 23, 2020
3829b92
Implemented position buffer and continous drawing
Jun 24, 2020
c64aa99
Fixed scene background drawing
Jun 24, 2020
9f166e5
Fixed eraser brush
Jun 24, 2020
6ae2a20
Fixed cannot draw on cubemap on first click
Jun 30, 2020
d4dcf9b
Optimized drawing by removing saving of cropped image pieces
Jun 30, 2020
cab81fc
Changed simple brush algorithm to quadratic curve
Jul 1, 2020
fde5cbf
Improved continuous drawing
Jul 2, 2020
532031b
Cleaned up code
Jul 2, 2020
b3a99cf
Fixed drawing should affect changed objects
Jul 2, 2020
9e67953
Merged sg-image-drawing with master
Jul 10, 2020
0bfc985
Removed creation of brush in image creation
Jul 15, 2020
65af7be
Added drawing of point on click
Jul 15, 2020
7bbc6d5
Refactored brushes and drawing materials
Jul 15, 2020
bc8ece6
Injected mouseToClip and saveToData url from SceneManager
Jul 15, 2020
3f69a99
Created hook use-draw-on-image for image drawing logic
Jul 15, 2020
5df30b3
Removed cleaning up of textureLoader and fixed deselectObject of unde…
Jul 15, 2020
7168b98
Merged sg-cubemaps with sg-image-drawing
Jul 15, 2020
a4910bf
Merge pull request #2060 from wonderunit/sg-cubemaps
Jul 15, 2020
ed706c1
Merged sg-image-drawing with master
Jul 16, 2020
4f78dfd
Created drawMode reducer
Jul 16, 2020
e6d8e4f
Fixed typo
Jul 16, 2020
b803115
Fixed brush ui is buggy
Jul 17, 2020
ce7ec64
Added brush type to initial state
Jul 17, 2020
d978da6
Cleaned up code
Jul 17, 2020
2feb434
Renamed clean to clear and added hiding of clear button if image wasn…
Jul 21, 2020
a5af1d2
Fixed saving temp image throws error when image folder doesn't exist
Jul 21, 2020
3e19eef
Fixed cubemaps saving
Jul 21, 2020
80e4171
Merged sg-image-drawing with master
Jul 21, 2020
5f34f72
Refactored ddrawing textures
Sep 28, 2020
a9f7e38
Fixed eraser cannot draw on top of simple brush
Sep 28, 2020
2102a77
Added CurveBrush with Catmull rom spline algorithm
Sep 29, 2020
8f8d30a
Fixed camera resets if moved on hotkeys after fov changes
Sep 29, 2020
569079f
Cleaned up sceneBackground's save function
Sep 30, 2020
4950302
Fixed image cached when background type changed
Sep 30, 2020
2621d84
Removed console log
Sep 30, 2020
653a0a6
Implemented drawing only on unobstructed images
Oct 1, 2020
20d4da2
Cleaned up
Oct 1, 2020
363ca8d
Fixed cannot draw on image if volume is in front
Oct 2, 2020
416a067
Implemented not supported cubemap notification
Oct 2, 2020
e77cc31
Fixed xr cubeTextureCreator import
Oct 2, 2020
b46155d
Merged sg-image-drawing with master
Oct 2, 2020
c5e2806
Localized sg-image-drawing
Oct 2, 2020
da272bb
Localized the sg-image-drawing
Oct 12, 2020
2ac01c3
Fixed drawing is avaibale only of one half of image
Nov 9, 2020
2b05080
Merged sg-image-drawing with master
Dec 30, 2020
23e1eba
Fixed merge issues
Dec 30, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 3 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions src/js/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,10 @@
"directional-light": "Directional light",
"fog": "Fog",
"grayscale": "Grayscale",
"shading-mode": "Shading Mode"
"shading-mode": "Shading Mode",
"cubemap-not-supported": "Whoops cubemap format isn't supported check the {{link}} for details.",
"scene-cubemap":"Scene Cube map",
"scene-texture":"Scene Texture"
},
"common": {
"object-creation-help": "How to Create 3D Models for Custom Objects",
Expand Down Expand Up @@ -434,7 +437,11 @@
"are-you-sure": "Are you sure?"
},
"inspected-element": {
"properties": "Properties:"
"properties": "Properties:",
"brush-color":"Brush color",
"type":"Type",
"simple": "Brush",
"eraser": "Eraser"
},
"camera": {
"fov": "F.O.V."
Expand Down
15 changes: 11 additions & 4 deletions src/js/locales/ru-RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
"pencil": "Карандаш",
"pen": "Ручка",
"note-pen": "Ручка для записи",
"eraser": "Стирачка",
"eraser": "Ластик",
"clear-all-layers": "Очистить все слои",
"clear-layer": "Очистить слой",
"smaller-brush": "Маленькая кисть",
Expand Down Expand Up @@ -167,7 +167,7 @@
"description": "Персмотрите доски с этим иснтрументом. Есть что записать? Рисуйте прям на доске. Этот инструмент рисует на слою Notes, sпоэтому вы может легко это очистить."
},
"eraser": {
"title": "Страчка",
"title": "Ластик",
"description": "Надо что-то стиреть? Используйте стирачку. Если зажата кнопка option (или alt), тогда стирачка будет чистить всё на выбраном слою. В противном случае будет очищать все слои."
}
},
Expand Down Expand Up @@ -402,7 +402,10 @@
"directional-light": "Направленое освещение",
"fog": "Туман",
"grayscale": "Оттенки серого",
"shading-mode": "Режим затенения"
"shading-mode": "Режим затенения",
"cubemap-not-supported": "Упс, формат кубической текстуры неподерживается перейдите в {{link}} чтобы узнать детали.",
"scene-cubemap":"Кубическая текстура",
"scene-texture":"Текстура сцены"
},
"common": {
"object-creation-help": "Как создавать 3D модели для Кастомных Объектов",
Expand Down Expand Up @@ -434,7 +437,11 @@
"are-you-sure": "Вы уверены?"
},
"inspected-element": {
"properties": "Свойства:"
"properties": "Свойства:",
"brush-color":"Цвет кисти",
"type":"Тип",
"simple": "Кисть",
"eraser": "Ластик"
},
"camera": {
"fov": "F.O.V."
Expand Down
3 changes: 2 additions & 1 deletion src/js/services/model-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ const projectFolder = type => ({
'object': path.join('models', 'objects'),
'character': path.join('models', 'characters'),
'environment': path.join('models', 'environments'),
'attachable': path.join('models', 'attachables')
'attachable': path.join('models', 'attachables'),
'sceneTexture': path.join('models', 'sceneTextures')
}[type])

const modelIsInProjectFolder = ({ model, type }) =>
Expand Down
1 change: 0 additions & 1 deletion src/js/shared/actions/scene-object-creators.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ const createImage = (id, camera, room, imagePath = 'placeholder') => {
x, y, z: 1,

rotation: { x: 0, y: rotation, z: 0 },

visible: true,
opacity: 1,
visibleToCam: true,
Expand Down
44 changes: 41 additions & 3 deletions src/js/shared/reducers/shot-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const serializeSceneObject = require('./shot-generator/serialize-scene-object')
const ObjectModelFileDescriptions = require('../../../data/shot-generator/objects/objects.json')
const AttachablesModelFileDescriptions = require('../../../data/shot-generator/attachables/attachables.json')
const { ShadingType } = require('../../vendor/shading-effects/ShadingType')

const BrushType = require('../../shot-generator/components/Three/Helpers/Brushes/TextureBrushTypes')
const hashify = string => crypto.createHash('sha1').update(string).digest('base64')

const capitalize = string => string.charAt(0).toUpperCase() + string.slice(1)
Expand All @@ -36,6 +36,7 @@ const getSelectedAttachable = state => state.undoable.present.selectedAttachable

const getWorld = state => state.undoable.present.world

const getDrawMode = state => state.undoable.present.drawMode

const getHash = state =>
hashify(JSON.stringify(getSerializedState(state)))
Expand All @@ -47,7 +48,8 @@ const getSerializedState = state => {
return {
world: getWorld(state),
sceneObjects: R.map(serializeSceneObject, getSceneObjects(state)),
activeCamera: getActiveCamera(state)
activeCamera: getActiveCamera(state),
drawingBrush: getDrawMode(state).brush
}
}

Expand Down Expand Up @@ -674,6 +676,11 @@ const initialState = {

undoable: {
world: initialScene.world,
drawMode: {
brush: { color: '#000000', size: 2 },
isEnabled: false,
type: BrushType.SIMPLE
},
activeCamera: initialScene.activeCamera,
sceneObjects: withDisplayNames(initialScene.sceneObjects),
selections: [],
Expand Down Expand Up @@ -1312,6 +1319,12 @@ const worldReducer = (state = initialState.undoable.world, action) => {
if (action.payload.hasOwnProperty('backgroundColor')) {
draft.backgroundColor = action.payload.backgroundColor
}
if (action.payload.hasOwnProperty('sceneTexture')) {
draft.sceneTexture = action.payload.sceneTexture
}
if (action.payload.hasOwnProperty('textureType')) {
draft.textureType = action.payload.textureType
}
return

case 'UPDATE_WORLD_ROOM':
Expand Down Expand Up @@ -1564,6 +1577,29 @@ const mainReducer = (state/* = initialState*/, action) => {
})
}

const drawModeReducer = (state = initialState.undoable.drawMode, action) => {
return produce(state, draft => {
switch(action.type) {
case 'UPDATE_DRAW_MODE':
if(action.payload.hasOwnProperty('isEnabled')) {
draft.isEnabled = action.payload.isEnabled
}
if(action.payload.hasOwnProperty('cleanImages')) {
draft.cleanImages = action.payload.cleanImages
}
if(action.payload.brush) {
draft.brush.color = action.payload.brush.color ? action.payload.brush.color : draft.brush.color
draft.brush.size = action.payload.brush.size ? action.payload.brush.size : draft.brush.size
draft.brush.type = action.payload.brush.type ? action.payload.brush.type : draft.brush.type
}
return

default:
return
}
})
}

const checksReducer = (state, action) => {
return produce(state, draft => {
switch (action.type) {
Expand Down Expand Up @@ -1644,6 +1680,7 @@ const undoableReducers = combineReducers({
sceneObjects: sceneObjectsReducer,
activeCamera: activeCameraReducer,
world: worldReducer,
drawMode: drawModeReducer,
selections: selectionsReducer,
selectedBone: selectedBoneReducer,
selectedAttachable: attachableSelectionsReducer
Expand Down Expand Up @@ -1790,7 +1827,7 @@ module.exports = {
deleteScenePreset: id => ({ type: 'DELETE_SCENE_PRESET', payload: { id } }),

createCharacterPreset: payload => ({ type: 'CREATE_CHARACTER_PRESET', payload }),

updateDrawMode: payload => ({ type: 'UPDATE_DRAW_MODE', payload: payload}),
createPosePreset: payload => ({ type: 'CREATE_POSE_PRESET', payload }),
createHandPosePreset: payload => ({ type: 'CREATE_HAND_POSE_PRESET', payload }),
createEmotionPreset: payload => ({ type: 'CREATE_EMOTION_PRESET', payload }),
Expand Down Expand Up @@ -1824,6 +1861,7 @@ module.exports = {
// selectors
//
getSceneObjects,
getDrawMode,
getSelections,
getActiveCamera,
getSelectedBone,
Expand Down
22 changes: 16 additions & 6 deletions src/js/shot-explorer/ShotExplorerSceneManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
getSceneObjects,
getWorld,
getSelectedBone,
updateWorld,

} from '../shared/reducers/shot-generator'
import systemEmotionPresets from '../shared/reducers/shot-generator-presets/emotions.json'
Expand All @@ -23,6 +24,7 @@ import { getFilePathForImages } from '../shot-generator/helpers/get-filepath-for
import Room from '../shot-generator/components/Three/Room'
import CameraUpdate from '../shot-generator/CameraUpdate'
import deepEqualSelector from '../utils/deepEqualSelector'
import SceneBackground from '../shot-generator/components/Three/SceneBackground'
import FilepathsContext from '../shot-generator/contexts/filepaths'

const sceneObjectSelector = (state) => {
Expand All @@ -49,6 +51,7 @@ const ShotExplorerSceneManager = connect(
selectedBone: getSelectedBone(state),
}),
{
updateWorld,
withState: (fn) => (dispatch, getState) => fn(dispatch, getState())
}
)( React.memo(({
Expand All @@ -60,13 +63,15 @@ const ShotExplorerSceneManager = connect(
setLargeCanvasData,
withState,
shouldRender,
updateWorld,
}) => {
const { scene, camera, gl } = useThree()
const rootRef = useRef()
const groundRef = useRef()
const ambientLightRef = useRef()
const directionalLightRef = useRef()

const drawingTextures = useRef({})
const drawingSceneTexture = useRef({})
const sceneObjectLength = Object.values(sceneObjects).length
const modelObjectIds = useMemo(() => {
return Object.values(sceneObjects).filter(o => o.type === 'object').map(o => o.id)
Expand Down Expand Up @@ -106,10 +111,6 @@ const ShotExplorerSceneManager = connect(
directionalLightRef.current.rotateX(world.directional.tilt+Math.PI/2)
}, [world])

useEffect(() => {
scene.background = new THREE.Color(world.backgroundColor)
}, [world.backgroundColor])

useEffect(() => {
if(!directionalLightRef.current) return
directionalLightRef.current.rotation.x = 0
Expand Down Expand Up @@ -210,7 +211,8 @@ const ShotExplorerSceneManager = connect(
return <SimpleErrorBoundary key={ id }>
<Image
imagesPaths={getFilePathForImages(sceneObject, storyboarderFilePath)}
sceneObject={ sceneObject }/>
sceneObject={ sceneObject }
drawTextures={ drawingTextures.current }/>
</SimpleErrorBoundary>
})
}
Expand All @@ -230,6 +232,14 @@ const ShotExplorerSceneManager = connect(
visible={world.environment.visible}
grayscale={ world.environment.grayscale } />
}
{
<SceneBackground
imagePath={ getFilePathForImages({imageAttachmentIds: world.sceneTexture ? [world.sceneTexture] : [] }, storyboarderFilePath) }
world={world}
storyboarderFilePath={ storyboarderFilePath }
updateWorld={ updateWorld }
drawingSceneTexture={ drawingSceneTexture.current }/>
}
{
roomTexture && <Room
texture={ roomTexture }
Expand Down
Loading